Package org.gudy.azureus2.plugins

Examples of org.gudy.azureus2.plugins.PluginInterface


    try{
      byte[]  search_key = ((DDBaseKeyImpl)key).getBytes();
     
      Download   download = null;
       
      PluginInterface pi = PluginInitializer.getDefaultInterface();
                 
      String  search_sha1 = pi.getUtilities().getFormatters().encodeBytesToString( search_key );
     
      if ( ta_sha1 == null ){
       
        ta_sha1 = pi.getTorrentManager().getPluginAttribute( "DDBaseTTTorrent::sha1");
      }
       
        // gotta look for the sha1(hash)
     
      Download[]  downloads = pi.getDownloadManager().getDownloads();
     
      for (int i=0;i<downloads.length;i++){
       
        Download  dl = downloads[i];
       
        if ( dl.getTorrent() == null ){
         
          continue;
        }
       
        String  sha1 = dl.getAttribute( ta_sha1 );
       
        if ( sha1 == null ){
         
          sha1 = pi.getUtilities().getFormatters().encodeBytesToString(
                new SHA1Simple().calculateHash( dl.getTorrent().getHash()));
         
          dl.setAttribute( ta_sha1, sha1 );
        }
       
        if ( sha1.equals( search_sha1 )){
         
          download  = dl;
                   
          break;
        }
      }
       
      if ( download == null ){
       
        synchronized( this ){
         
          if ( external_downloads != null ){
           
            for (int i=0;i<external_downloads.size();i++){
             
              Download  dl = (Download)external_downloads.get(i);
             
              if ( dl.getTorrent() == null ){
               
                continue;
              }
             
              String  sha1 = dl.getAttribute( ta_sha1 );
             
              if ( sha1 == null ){
               
                sha1 = pi.getUtilities().getFormatters().encodeBytesToString(
                      new SHA1Simple().calculateHash( dl.getTorrent().getHash()));
               
                dl.setAttribute( ta_sha1, sha1 );
              }
             
              if ( sha1.equals( search_sha1 )){
               
                download  = dl;
                         
                break;
              }
            }
          }
        }
      }
     
      String  originator = contact.getName();
     
      if ( download == null ){
       
        String msg = "TorrentDownload: request from " + originator + " for '" + pi.getUtilities().getFormatters().encodeBytesToString( search_key ) + "' not found";
       
        if ( TRACE ){
         
          System.out.println( msg );
        }
View Full Code Here


  private long last_recheck_time;
 
  protected UpdateMonitor(AzureusCore _azureus_core) {
    azCore = _azureus_core;

    PluginInterface defPI = PluginInitializer.getDefaultInterface();
    UpdateManager um = defPI.getUpdateManager();

    um.addListener(new UpdateManagerListener() {
      public void checkInstanceCreated(UpdateCheckInstance instance) {
        instance.addListener(UpdateMonitor.this);
       
View Full Code Here

        {
          public void
          handleEvent(Event event)
          {
            try{
              PluginInterface pi = AzureusCoreFactory.getSingleton().getPluginManager().getDefaultPluginInterface();
             
              UpdateInstaller installer = pi.getUpdateManager().createInstaller();
           
              installer.addMoveAction(
                "C:\\temp\\file1", "C:\\temp\\file2" );
           
              installer.installNow(
View Full Code Here

      ci.out.println();
      return;
    }
   
    String plugin_id = (String)args.get(1);
    PluginInterface plugin = ci.getCore().getPluginManager().getPluginInterfaceByID(plugin_id, false);
    if (plugin == null) {
      ci.out.println("Invalid plugin ID: " + plugin_id);
      ci.out.println();
      return;
    }
   
    if (subcmd.equals("status")) {
      ci.out.println("ID     : " + plugin.getPluginID());
      ci.out.println("Name   : " + plugin.getPluginName());
      ci.out.println("Version: " + plugin.getPluginVersion());
      ci.out.println("Running: " + plugin.getPluginState().isOperational());
      ci.out.println("Runs at startup: " + plugin.getPluginState().isLoadedAtStartup());
      if (!plugin.getPluginState().isBuiltIn()) {
        ci.out.println("Location: " + plugin.getPluginDirectoryName());
      }
      ci.out.println();
      return;
    }
   
    if (subcmd.equals("startup")) {
      if (args.size() == 2) {
        ci.out.println("Need to pass either \"on\" or \"off\"");
        ci.out.println();
        return;
      }
      String enabled_mode = (String)args.get(2);
      if (enabled_mode.equals("on")) {
        plugin.getPluginState().setLoadedAtStartup(true);
      }
      else if (enabled_mode.equals("off")) {
        plugin.getPluginState().setLoadedAtStartup(false);
      }
      else {
        ci.out.println("Need to pass either \"on\" or \"off\"");
        ci.out.println();
        return;
View Full Code Here

   
  List  items = getSelectedItems();
 
    if (items.size() > 0) {
   
      PluginInterface pi = PluginInitializer.getDefaultInterface();

      org.gudy.azureus2.plugins.download.DownloadManager  dm     = pi.getDownloadManager();

      remove = true;
     
      for (int i=0; i < items.size(); i++){       
      
View Full Code Here

    List  items = getSelectedItems();
    if (items.size() == 0) {
      return;
    }
 
    PluginInterface pi = PluginInitializer.getDefaultInterface();
     
    org.gudy.azureus2.plugins.download.DownloadManager  dm     = pi.getDownloadManager();
     
    Tracker      tracker = pi.getTracker();
     

      for (int i=0;i<items.size();i++){
       
        ShareItem  item = (ShareItem)items.get(i);
View Full Code Here

  protected void
  showDHTStats(
    ConsoleInput  ci )
  {
    try{
      PluginInterface  def = ci.azureus_core.getPluginManager().getDefaultPluginInterface();
     
      PluginInterface dht_pi =
        def.getPluginManager().getPluginInterfaceByClass(DHTPlugin.class );
     
      if ( dht_pi == null ){
     
        ci.out.println( "\tDHT isn't present" );
       
        return;
      }
     
      DHTPlugin  dht_plugin = (DHTPlugin)dht_pi.getPlugin();
     
      if ( dht_plugin.getStatus() != DHTPlugin.STATUS_RUNNING ){
       
        ci.out.println( "\tDHT isn't running yet (disabled or initialising)" );
       
View Full Code Here

    // Proably need to wait for core to be running to make sure dht plugin is fully avail
    AzureusCoreFactory.addCoreRunningListener(new AzureusCoreRunningListener() {
      public void azureusCoreRunning(AzureusCore core) {
        PluginManager pm = core.getPluginManager();
        connection_manager = PluginInitializer.getDefaultInterface().getConnectionManager();
        PluginInterface dht_pi = pm.getPluginInterfaceByClass(DHTPlugin.class);
        if (dht_pi != null) {
          dhtPlugin = (DHTPlugin) dht_pi.getPlugin();
        }
      }
    });
  }
View Full Code Here

                  }else{
                   
                    torrent.setAdditionalListProperty( "httpseeds", webseeds );
                  }
     
                  PluginInterface pi = AzureusCoreFactory.getSingleton().getPluginManager().getPluginInterfaceByClass(ExternalSeedPlugin.class);
                 
                  if ( pi != null ){
                   
                    ExternalSeedPlugin ext_seed_plugin = (ExternalSeedPlugin)pi.getPlugin();
                   
                    ext_seed_plugin.downloadChanged( PluginCoreUtils.wrap( dms[0] ));
                  }
           
                }catch (Throwable e){
View Full Code Here

          run()
          {
            for (int i = 0; i < items.length; i++) {
              int index = items[i];
              if (index >= 0 && index < pluginIFs.size()) {
                PluginInterface pluginIF = (PluginInterface) pluginIFs.get(index);
                if (pluginIF.getPluginState().isOperational()) {
                  if (pluginIF.getPluginState().isUnloadable()) {
                    try {
                      pluginIF.getPluginState().unload();
                    } catch (PluginException e1) {
                      // TODO Auto-generated catch block
                      e1.printStackTrace();
                    }
                  }
                }
               
                Utils.execSWTThread(
                  new Runnable()
                  {
                    public void
                    run()
                    {
                      pluginIFs = rebuildPluginIFs();
                      table.setItemCount(pluginIFs.size());
                      Collections.sort(pluginIFs, comparator);
                      table.clearAll();
                    }
                  });
              }
            }
          }
        }.start();
      }
    });
    btnUnload.setEnabled( false );
   
    final Button btnLoad = new Button(cButtons, SWT.PUSH);
    btnUnload.setLayoutData(new GridData());
    Messages.setLanguageText(btnLoad, "ConfigView.pluginlist.loadSelected");
    btnLoad.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent e) {
        final int[] items = table.getSelectionIndices();

        new AEThread2( "load" ){
          public void
          run()
          {
            for (int i = 0; i < items.length; i++) {
              int index = items[i];
              if (index >= 0 && index < pluginIFs.size()) {
               
                PluginInterface pluginIF = (PluginInterface) pluginIFs.get(index);
                if (pluginIF.getPluginState().isOperational()) {continue;} // Already loaded.
   
                // Re-enable disabled plugins, as long as they haven't failed on
                // initialise.
                if (pluginIF.getPluginState().isDisabled()) {
                  if (pluginIF.getPluginState().hasFailed()) {continue;}
                  pluginIF.getPluginState().setDisabled(false);
                }
               
                try {
                  pluginIF.getPluginState().reload();
                } catch (PluginException e1) {
                  // TODO Auto-generated catch block
                  Debug.printStackTrace(e1);
                }
               
                Utils.execSWTThread(
                  new Runnable()
                  {
                    public void
                    run()
                    {
                      pluginIFs = rebuildPluginIFs();
                      table.setItemCount(pluginIFs.size());
                      Collections.sort(pluginIFs, comparator);
                      table.clearAll();
                    }
                  });
              }
            }
          }
        }.start();
      }
    });
    btnLoad.setEnabled( false );
   
   
    final Button btnScan = new Button(cButtons, SWT.PUSH);
    btnScan.setLayoutData(new GridData());
    Messages.setLanguageText(btnScan, "ConfigView.pluginlist.scan");
    btnScan.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent e) {
        AzureusCoreFactory.getSingleton().getPluginManager().refreshPluginList(false);
        pluginIFs = rebuildPluginIFs();
        table.setItemCount(pluginIFs.size());
        Collections.sort(pluginIFs, comparator);
        table.clearAll();
      }
    });


    table.addListener(SWT.SetData, new Listener() {
      public void handleEvent(Event event) {
        TableItem item = (TableItem) event.item;
        int index = table.indexOf(item);
        PluginInterface pluginIF = (PluginInterface) pluginIFs.get(index);

        for (int i = 0; i < COLUMN_HEADERS.length; i++) {
          if (i == FilterComparator.FIELD_NAME)
            item.setImage(i, pluginIF.getPluginState().isOperational()
                ? imgGreenLed : imgRedLed);
         
          String sText = comparator.getFieldValue(i, pluginIF);
          if (sText == null)
            sText = "";
          item.setText(i, sText);
        }

        item.setGrayed(pluginIF.getPluginState().isMandatory());
        boolean bEnabled = pluginIF.getPluginState().isLoadedAtStartup();
        Utils.setCheckedInSetData(item, bEnabled);
        item.setData("PluginID", pluginIF.getPluginID());
        Utils.alternateRowBackground(item);
      }
    });

    table.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent e) {
        TableItem item = (TableItem) e.item;
        int index = table.indexOf(item);
        PluginInterface pluginIF = (PluginInterface) pluginIFs.get(index);

        if (e.detail == SWT.CHECK){
           
          if (item.getGrayed()) {
            if (!item.getChecked())
              item.setChecked(true);
            return;
          }

          pluginIF.getPluginState().setDisabled(!item.getChecked());
          pluginIF.getPluginState().setLoadedAtStartup(item.getChecked());
        }
       
        btnUnload.setEnabled(pluginIF.getPluginState().isOperational() && pluginIF.getPluginState().isUnloadable());
        btnLoad.setEnabled(!pluginIF.getPluginState().isOperational() && !pluginIF.getPluginState().hasFailed());
      }
    });

    table.setItemCount(pluginIFs.size());
   
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.plugins.PluginInterface

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.