Package org.gudy.azureus2.plugins

Examples of org.gudy.azureus2.plugins.PluginException


                }
              }
            }
        }catch( Throwable e ){
         
          throw( new PluginException( "Failed to read plugin file", e ));
       
        }finally{
       
          if ( zis != null ){
           
            try{
              zis.close();
             
            }catch( Throwable e ){
             
              Debug.printStackTrace(e);
            }
          }
        }

        pos = prefix.lastIndexOf("_");
        String filename_id = null, filename_version = null;
        if ( pos != -1 ){
          filename_id       = prefix.substring(0,pos);             
          filename_version    = prefix.substring(pos+1);
        }
       
        if ( properties == null ){
         
            // one valid possibility here, this is a built-in plugin. this doesn't have
            // a plugin.properties
                   
          if (filename_id != null) {
         
            id       = filename_id;             
            version    = filename_version;
                     
            PluginInterface pi = installer.getPluginManager().getPluginInterfaceByID( id );

            ok =    pi != null &&
                pi.getPluginDirectoryName() == null ||
                    pi.getPluginDirectoryName().length() == 0 );
          }
         
          if ( !ok ){
         
            throw( new PluginException( "Mandatory file 'plugin.properties' not found in plugin file" ));
          }
        }else{ // properties != null
       
          // unfortunately plugin.id isn't mandatory for the properties, and neither is plugin.version
       
          PluginInitializer.checkJDKVersion( "", properties, false );
          PluginInitializer.checkAzureusVersion("", properties, false);
         
          id    = properties.getProperty( "plugin.id" );
          version  = properties.getProperty( "plugin.version" );
         
          // Force both versions to be the same if they are both defined.
          String prop_version = version;
          if (prop_version != null && filename_version != null && !filename_version.equals(prop_version)) {
              throw new PluginException("inconsistent versions [file=" + filename_version + ", prop=" + prop_version + "]");
          }

        }
       
        if ( id == null ){
         
          // see if plugin is already loaded, if so we can get the id from it
         
          String  plugin_class = properties.getProperty("plugin.class");
         
          if ( plugin_class == null ){
           
            String  plugin_classes = properties.getProperty( "plugin.classes" );
           
            if ( plugin_classes != null ){
             
              int  semi_pos = plugin_classes.indexOf(";");
             
              if ( semi_pos == -1 ){
               
                plugin_class  = plugin_classes;
               
              }else{
               
                plugin_class = plugin_classes.substring( 0, semi_pos );
              }
            }
          }
         
          if ( plugin_class != null ){
           
            try{
              PluginInterface pi = installer.getPluginManager().getPluginInterfaceByClass( plugin_class );
             
              if ( pi != null ){
               
                id  = pi.getPluginID();
              }
            }catch( Throwable ignore ){
             
            }
          }
        }
       
        pos = prefix.lastIndexOf("_");
   
        if ( pos != -1 ){
   
          id       = id==null?prefix.substring(0,pos):id;

            // see if we can normalise the ID based on SF values
         
          try{
            SFPluginDetailsLoader  loader = SFPluginDetailsLoaderFactory.getSingleton();
         
            String[]  ids = loader.getPluginIDs();
           
            for (int i=0;i<ids.length;i++){
             
              if ( ids[i].equalsIgnoreCase(id)){
               
                id = ids[i];
               
                break;
              }
            }
          }catch( Throwable e ){
           
            Debug.printStackTrace(e);
          }

          version    = version == null?prefix.substring(pos+1):version;

        }
       
        this.name = id;
       
        if ( properties != null ){
         
          String plugin_name = properties.getProperty( "plugin.name" );
         
          if ( plugin_name != null ){
           
            this.name = plugin_name;
          }
        }
       
        ok  = id != null && version != null;
      }
    }
   
    if ( !ok ){
     
      throw( new PluginException( "Invalid plugin file name: must be of form <pluginid>_<version>.[jar|zip]" ));
    }
  }
View Full Code Here


    unload( false );
  }
 
  protected void unload( boolean for_reload ) throws PluginException {
    if (!isUnloadable()) {
      throw new PluginException("Plugin isn't unloadable");
    }
       
    String dir = pi.getPluginDirectoryName();
       
    // if not dir based then just test this one
View Full Code Here

    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

TOP

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

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.