示例#1
0
  /**
   * @param dl
   * @since 3.0.2.3
   */
  public static String getMediaServerContentURL(Download dl) {

    // TorrentListViewsUtils.debugDCAD("enter - getMediaServerContentURL");

    PluginManager pm = AzureusCoreFactory.getSingleton().getPluginManager();
    PluginInterface pi = pm.getPluginInterfaceByID("azupnpav", false);

    if (pi == null) {
      Logger.log(new LogEvent(LogIDs.UI3, "Media server plugin not found"));
      return null;
    }

    if (!pi.getPluginState().isOperational()) {
      Logger.log(new LogEvent(LogIDs.UI3, "Media server plugin not operational"));
      return null;
    }

    try {
      Program program = Program.findProgram(".qtl");
      boolean hasQuickTime =
          program == null ? false : (program.getName().toLowerCase().indexOf("quicktime") != -1);

      pi.getIPC().invoke("setQuickTimeAvailable", new Object[] {new Boolean(hasQuickTime)});

      Object url = pi.getIPC().invoke("getContentURL", new Object[] {dl});
      if (url instanceof String) {
        return (String) url;
      }
    } catch (Throwable e) {
      Logger.log(
          new LogEvent(LogIDs.UI3, LogEvent.LT_WARNING, "IPC to media server plugin failed", e));
    }

    return null;
  }
示例#2
0
 private IPCInterface getMediaIpc() {
   if (mediaIpc == null) {
     final PluginInterface mediaInterface = pluginManager.getPluginInterfaceByID("azupnpav", true);
     if (mediaInterface == null) {
       throw new RuntimeException(
           "couldnot find azupnpav plugin - check it is installed and started up");
     }
     mediaIpc = mediaInterface.getIPC();
   }
   return mediaIpc;
 }
示例#3
0
  protected void publish(final boolean force) {
    long now = plugin_interface.getUtilities().getCurrentSystemTime();

    if (now < last_publish && !force) {

      last_publish = now;

    } else {

      if (force || now - last_publish >= REPUBLISH_TIME_MIN) {

        last_publish = now;

        plugin_interface
            .getUtilities()
            .createThread(
                "DHTNATPuncher:publisher",
                new Runnable() {
                  public void run() {
                    try {
                      pub_mon.enter();

                      if (publish_in_progress) {

                        return;
                      }

                      publish_in_progress = true;

                    } finally {

                      pub_mon.exit();
                    }

                    try {
                      publishSupport();

                    } finally {

                      try {
                        pub_mon.enter();

                        publish_in_progress = false;

                      } finally {

                        pub_mon.exit();
                      }
                    }
                  }
                });
      }
    }
  }
  public void initialize(PluginInterface pi) {
    Properties props = pi.getPluginProperties();

    props.setProperty("plugin.mandatory", "true");

    if (pi.getPluginVersion() == null) {

      props.setProperty("plugin.version", "1.0");
    }

    props.setProperty("plugin.id", "azupdater");
  }
示例#5
0
  public DHTNATPuncherImpl(DHTNATPuncherAdapter _adapter, DHT _dht) {
    adapter = _adapter;
    dht = _dht;

    logger = dht.getLogger();

    plugin_interface = dht.getLogger().getPluginInterface();

    formatters = plugin_interface.getUtilities().getFormatters();
    pub_mon = plugin_interface.getUtilities().getMonitor();
    server_mon = plugin_interface.getUtilities().getMonitor();
    punch_mon = plugin_interface.getUtilities().getMonitor();

    timer = plugin_interface.getUtilities().createTimer("DHTNATPuncher:refresher", true);
  }
示例#6
0
  /** @return */
  public static boolean hasFullBurn() {

    PluginInterface pi =
        PluginInitializer.getDefaultInterface().getPluginState().isInitialisationComplete()
            ? AzureusCoreFactory.getSingleton()
                .getPluginManager()
                .getPluginInterfaceByID("azburn_v")
            : null;
    if (pi == null) {
      // maybe not added yet.. use featman
      Set<String> featuresInstalled = UtilitiesImpl.getFeaturesInstalled();
      return featuresInstalled.contains("dvdburn_trial") && !featuresInstalled.contains("dvdburn");
    }
    return pi.getPluginState().isOperational();
  }
  public DHTSpeedTesterImpl(DHT _dht) {
    dht = _dht;

    plugin_interface = dht.getLogger().getPluginInterface();

    UTTimer timer = plugin_interface.getUtilities().createTimer("DHTSpeedTester:finder", true);

    timer.addPeriodicEvent(
        5000,
        new UTTimerEventPerformer() {
          public void perform(UTTimerEvent event) {
            findContacts();
          }
        });

    timer.addPeriodicEvent(
        1000,
        new UTTimerEventPerformer() {
          int tick_count;

          public void perform(UTTimerEvent event) {
            try {
              pingContacts(tick_count);

            } finally {

              tick_count++;
            }
          }
        });
  }
 public Torrent getChannelTorrent(String channelName) {
   try {
     Map genericMap = genericTorrent.writeToMap();
     Map info = (Map) genericMap.get("info");
     info.put("name", channelName.getBytes());
     info.put("name.utf8", channelName.getBytes("UTF-8"));
     genericMap.put("info", info);
     byte[] channelTorrent = plugin_interface.getUtilities().getFormatters().bEncode(genericMap);
     Torrent result = plugin_interface.getTorrentManager().createFromBEncodedData(channelTorrent);
     result.setAnnounceURL(new URL("dht://chat.dht/announce"));
     return result;
   } catch (Exception e) {
     e.printStackTrace();
   }
   return null;
 }
示例#9
0
文件: Test.java 项目: aprasa/oldwork
  protected void taTest() {
    try {

      final TorrentAttribute ta =
          plugin_interface.getTorrentManager().getAttribute(TorrentAttribute.TA_CATEGORY);

      ta.addTorrentAttributeListener(
          new TorrentAttributeListener() {
            public void event(TorrentAttributeEvent ev) {
              System.out.println("ev: " + ev.getType() + ", " + ev.getData());

              if (ev.getType() == TorrentAttributeEvent.ET_ATTRIBUTE_VALUE_ADDED) {

                if ("plop".equals(ev.getData())) {

                  ta.removeDefinedValue("plop");
                }
              }
            }
          });

      ta.addDefinedValue("wibble");

      plugin_interface
          .getDownloadManager()
          .addListener(
              new DownloadManagerListener() {
                public void downloadAdded(Download download) {
                  try {
                    download.setAttribute(ta, "wibble");

                  } catch (Throwable e) {

                    e.printStackTrace();
                  }
                }

                public void downloadRemoved(Download download) {}
              });

    } catch (Throwable e) {

      e.printStackTrace();
    }
  }
 public void configParameterChanged(ConfigParameter param) {
   nick =
       plugin_interface
           .getPluginconfig()
           .getPluginStringParameter("nick", "Guest" + (int) (Math.random() * 100000));
   if (nick.startsWith("System") || nick.startsWith("system")) {
     nick = "Guest" + (int) (Math.random() * 100000);
   }
 }
示例#11
0
  protected void logAlert(int type, String resource, String[] params) {
    String text =
        plugin_interface
            .getUtilities()
            .getLocaleUtilities()
            .getLocalisedMessageText(resource, params);

    log.logAlertRepeatable(type, text);
  }
示例#12
0
  private static final synchronized boolean loadEmpPluginClass() {
    if (piEmp != null && piEmp.getPluginState().isUnloaded()) {
      piEmp = null;
      triedLoadingEmpPluginClass = false;
      methodIsExternallyPlayable = null;
      methodIsExternallyPlayable2 = null;
    }

    if (!triedLoadingEmpPluginClass) {
      triedLoadingEmpPluginClass = true;

      try {
        piEmp =
            AzureusCoreFactory.getSingleton().getPluginManager().getPluginInterfaceByID("azemp");

        if (piEmp == null) {

          return (false);
        }

        Class empPluginClass = piEmp.getPlugin().getClass();

        methodIsExternallyPlayable =
            empPluginClass.getMethod("isExternallyPlayable", new Class[] {TOTorrent.class});

        try {
          methodIsExternallyPlayable2 =
              empPluginClass.getMethod(
                  "isExternallyPlayable", new Class[] {TOTorrent.class, int.class});
        } catch (Throwable e) {
          Logger.log(new LogEvent(LogIDs.UI3, "isExternallyPlayable with file_index not found"));
        }

        // methodIsExternalPlayerInstalled = empPluginClass.getMethod("isExternalPlayerInstalled",
        // new Class[] {});

      } catch (Exception e1) {
        return false;
      }
    }
    return true;
  }
示例#13
0
  protected void setDeviceStats(String USN, String stat_key, long value) {
    String key = "upnp.device.stats." + stat_key;

    PluginConfig pc = plugin_interface.getPluginconfig();

    Map counts = pc.getPluginMapParameter(key, new HashMap());

    counts.put(USN, new Long(value));

    pc.getPluginMapParameter(key, counts);
  }
  public Download addChannel(String channelName) {
    Torrent torrent = getChannelTorrent(channelName);
    String savePath = plugin_interface.getPluginDirectoryName();
    try {
      File saveDir = new File(savePath, "channels" + File.separator);
      saveDir.mkdir();
      Download dl = plugin_interface.getDownloadManager().addDownload(torrent, null, saveDir);
      dl.setForceStart(true);

      File dest = new File(savePath, "channels" + File.separator + channelName);
      File src = new File(savePath, "channels" + File.separator + "channel");
      copyFile(src, dest);

      controller.addBridge(dl, channelName);
      return dl;
    } catch (Exception e) {
      e.printStackTrace();
    }
    return null;
  }
  public void initialize(PluginInterface pi) {
    plugin_interface = pi;
    formatters = plugin_interface.getUtilities().getFormatters();
    genericTorrent = loadTorrent(resTorrent);

    nick =
        plugin_interface
            .getPluginconfig()
            .getPluginStringParameter("nick", "Guest" + (int) (Math.random() * 100000));
    active = plugin_interface.getPluginconfig().getPluginBooleanParameter("enable", true);

    if (active) {
      listeners = new ArrayList();
      listenersDownload = new ArrayList();
      controller = new PeerControllerImpl(this, nick);
      controller.addMessageListener(this);
      controller.initialize();
      controller.startPeerProcessing();
    }
  }
示例#16
0
  protected void updateIgnoreList() {
    try {
      String param = "";

      if (ignore_bad_devices.getValue()) {

        PluginConfig pc = plugin_interface.getPluginconfig();

        Map ignored = pc.getPluginMapParameter("upnp.device.ignorelist", new HashMap());

        Iterator it = ignored.entrySet().iterator();

        while (it.hasNext()) {

          Map.Entry entry = (Map.Entry) it.next();

          Map value = (Map) entry.getValue();

          param += "\n    " + entry.getKey() + ": " + new String((byte[]) value.get("Location"));
        }

        if (ignored.size() > 0) {

          log.log("Devices currently being ignored: " + param);
        }
      }

      String text =
          plugin_interface
              .getUtilities()
              .getLocaleUtilities()
              .getLocalisedMessageText("upnp.ignorebaddevices.info", new String[] {param});

      ignored_devices_list.setLabelText(text);

    } catch (Throwable e) {

      Debug.printStackTrace(e);
    }
  }
示例#17
0
  protected NetworkSearch(AzureusCore core, String searchText, Browser browser) {
    PluginInterface pi = core.getPluginManager().getPluginInterfaceByID("azsearch", false);

    if (pi == null) {

      Logger.log(new LogEvent(LOGID, "Search plugin not found"));

      return;
    }

    if (!pi.getPluginState().isOperational()) {

      Logger.log(new LogEvent(LOGID, "Search plugin not operational"));

      return;
    }

    Logger.log(new LogEvent(LOGID, "Search plugin functionality disabled"));
    /*

    Map params = new HashMap();

    params.put("expression", searchText);

    params.put("swtbrowser", browser);

    try {
    	IPCInterface my_ipc = new IPCInterfaceImpl(this);

    	pi.getIPC().invoke("search", new Object[] {
    		my_ipc,
    		params
    	});

    } catch (Throwable e) {

    	Logger.log(new LogEvent(LOGID, "IPC to search plugin failed", e));
    }
    */
  }
示例#18
0
 public Download getDownload(String torrentID) {
   if (torrentID.startsWith(OneSwarmConstants.BITTORRENT_MAGNET_PREFIX)) {
     torrentID = torrentID.substring(OneSwarmConstants.BITTORRENT_MAGNET_PREFIX.length());
     byte[] torrentHash = Base32.decode(torrentID);
     try {
       return pluginInterface.getDownloadManager().getDownload(torrentHash);
     } catch (DownloadException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
   return null;
 }
示例#19
0
  protected void ignoreDevice(String USN, URL location) {
    // only take note of this if enabled to do so

    if (ignore_bad_devices.getValue()) {

      try {
        PluginConfig pc = plugin_interface.getPluginconfig();

        Map ignored = pc.getPluginMapParameter("upnp.device.ignorelist", new HashMap());

        Map entry = (Map) ignored.get(USN);

        if (entry == null) {

          entry = new HashMap();

          entry.put("Location", location.toString().getBytes());

          ignored.put(USN, entry);

          pc.setPluginMapParameter("upnp.device.ignorelist", ignored);

          updateIgnoreList();

          String text =
              plugin_interface
                  .getUtilities()
                  .getLocaleUtilities()
                  .getLocalisedMessageText(
                      "upnp.ignorebaddevices.alert", new String[] {location.toString()});

          log.logAlertRepeatable(LoggerChannel.LT_WARNING, text);
        }
      } catch (Throwable e) {

        Debug.printStackTrace(e);
      }
    }
  }
  private DHT[] getDHTs() {
    if (dhts == null) {

      try {
        PluginManager pm = core.getPluginManager();

        if (pm.isInitialized()) {

          PluginInterface dht_pi = pm.getPluginInterfaceByClass(DHTPlugin.class);

          if (dht_pi == null) {

            dhts = new DHT[0];

          } else {

            DHTPlugin plugin = (DHTPlugin) dht_pi.getPlugin();

            if (!plugin.isInitialising()) {

              if (plugin.isEnabled()) {

                dhts = ((DHTPlugin) dht_pi.getPlugin()).getDHTs();

              } else {

                dhts = new DHT[0];
              }
            }
          }
        }
      } catch (Throwable e) {

        dhts = new DHT[0];
      }
    }

    return (dhts);
  }
 private Torrent loadTorrent(String res) {
   ClassLoader cl = this.getClass().getClassLoader();
   InputStream is = cl.getResourceAsStream(res);
   if (is != null) {
     try {
       return plugin_interface.getTorrentManager().createFromBEncodedInputStream(is);
     } catch (Exception e) {
       Logger.info("System: The channel torrent is impossible to create!");
       return null;
     }
   }
   Logger.info("System: The channel torrent created is null");
   return null;
 }
示例#22
0
  public void rootDeviceFound(UPnPRootDevice device) {
    incrementDeviceStats(device.getUSN(), "found");

    checkDeviceStats(device);

    try {
      int interesting = processDevice(device.getDevice());

      if (interesting > 0) {

        try {
          this_mon.enter();

          root_info_map.put(device.getLocation(), device.getInfo());

          Iterator<String> it = root_info_map.values().iterator();

          String all_info = "";

          List reported_info = new ArrayList();

          while (it.hasNext()) {

            String info = (String) it.next();

            if (info != null && !reported_info.contains(info)) {

              reported_info.add(info);

              all_info += (all_info.length() == 0 ? "" : ",") + info;
            }
          }

          if (all_info.length() > 0) {

            plugin_interface.getPluginconfig().setPluginParameter("plugin.info", all_info);
          }

        } finally {

          this_mon.exit();
        }
      }
    } catch (Throwable e) {

      log.log("Root device processing fails", e);
    }
  }
示例#23
0
  protected long getDeviceStats(String USN, String stat_key) {
    String key = "upnp.device.stats." + stat_key;

    PluginConfig pc = plugin_interface.getPluginconfig();

    Map counts = pc.getPluginMapParameter(key, new HashMap());

    Long count = (Long) counts.get(USN);

    if (count == null) {

      return (0);
    }

    return (count.longValue());
  }
示例#24
0
文件: Test.java 项目: aprasa/oldwork
  protected void testLinks() {
    plugin_interface
        .getDownloadManager()
        .addListener(
            new DownloadManagerListener() {
              public void downloadAdded(Download download) {
                DiskManagerFileInfo[] info = download.getDiskManagerFileInfo();

                for (int i = 0; i < info.length; i++) {

                  info[i].setLink(new File("C:\\temp"));
                }
              }

              public void downloadRemoved(Download download) {}
            });
  }
示例#25
0
  protected void receiveBind(DHTTransportUDPContact originator, Map request, Map response) {
    trace("received bind request");

    boolean ok = true;
    boolean log = true;

    try {
      server_mon.enter();

      Object[] entry = (Object[]) rendezvous_bindings.get(originator.getAddress().toString());

      if (entry == null) {

        if (rendezvous_bindings.size() == RENDEZVOUS_SERVER_MAX) {

          ok = false;
        }
      } else {

        // already present, no need to log again

        log = false;
      }

      if (ok) {

        long now = plugin_interface.getUtilities().getCurrentSystemTime();

        rendezvous_bindings.put(
            originator.getAddress().toString(), new Object[] {originator, new Long(now)});

        response.put("port", new Long(originator.getAddress().getPort()));
      }
    } finally {

      server_mon.exit();
    }

    if (log) {

      log("Rendezvous request from " + originator.getString() + " " + (ok ? "accepted" : "denied"));
    }

    response.put("ok", new Long(ok ? 1 : 0));
  }
示例#26
0
文件: Test.java 项目: aprasa/oldwork
  public void initialize(PluginInterface _pi) {
    plugin_interface = _pi;

    singleton = this;

    init_sem.release();

    plugin_interface.addListener(
        new PluginListener() {
          public void initializationComplete() {
            Thread t =
                new AEThread("test") {
                  public void runSupport() {

                    // testLinks();
                    testMessaging();
                    try {
                      // PlatformManagerFactory.getPlatformManager().performRecoverableFileDelete(
                      // "C:\\temp\\recycle.txt" );
                      // PlatformManagerFactory.getPlatformManager().setTCPTOSEnabled( false );

                    } catch (Throwable e) {

                      e.printStackTrace();
                    }
                  }
                };

            t.setDaemon(true);

            t.start();
          }

          public void closedownInitiated() {}

          public void closedownComplete() {}
        });
  }
示例#27
0
  protected void runRendezvous() {
    try {
      pub_mon.enter();

      if (!rendezvous_thread_running) {

        rendezvous_thread_running = true;

        plugin_interface
            .getUtilities()
            .createThread(
                "DHTNatPuncher:rendevzous",
                new Runnable() {
                  public void run() {
                    runRendezvousSupport();
                  }
                });
      }
    } finally {

      pub_mon.exit();
    }
  }
示例#28
0
  protected long incrementDeviceStats(String USN, String stat_key) {
    String key = "upnp.device.stats." + stat_key;

    PluginConfig pc = plugin_interface.getPluginconfig();

    Map counts = pc.getPluginMapParameter(key, new HashMap());

    Long count = (Long) counts.get(USN);

    if (count == null) {

      count = new Long(1);

    } else {

      count = new Long(count.longValue() + 1);
    }

    counts.put(USN, count);

    pc.getPluginMapParameter(key, counts);

    return (count.longValue());
  }
 public LocaleUtilities getLocaleUtils() {
   return plugin_interface.getUtilities().getLocaleUtilities();
 }
 public void setNick(String nick) {
   this.nick = nick;
   plugin_interface.getPluginconfig().setPluginParameter("nick", nick);
 }