Package org.gudy.azureus2.plugins.utils.search

Examples of org.gudy.azureus2.plugins.utils.search.SearchResult


   *
   * @since 3.0.0.7
   */
  private boolean nextUpdate() {
    if (iterDownloaders.hasNext()) {
      ResourceDownloader downloader = (ResourceDownloader) iterDownloaders.next();
      downloader.addListener(this);
      downloader.asyncDownload();
      return true;
    }
    return false;
  }
View Full Code Here


              }
             
              setProgress( 0 );
             
              downloader.addListener(
                new ResourceDownloaderAdapter()
                {
                  public void
                  reportPercentComplete(
                    ResourceDownloader  downloader,
                    int          percentage )
View Full Code Here

                continue;
              }
             
              hashes.add( Base32.encode( hash ));
             
              SearchResult result =
                new SearchResult()
                {
                  public Object
                  getProperty(
                    int    property_name )
                  {
View Full Code Here

          continue;
        }
       
        hashes.add( hash_str );

        SearchResult result =
          new SearchResult()
          {
            public Object
            getProperty(
              int    property_name )
            {
View Full Code Here

                }
             
                hashes.add( hash_str );
              }
             
              SearchResult search_result =
                new SearchResult()
                {
                  public Object
                  getProperty(
                    int    property_name )
                  {
                    return( result_properties.get( property_name ));
                  }
                };
           
              try{
                observer.resultReceived( si, search_result );
               
              }catch( Throwable e ){
               
                Debug.out( e );
              }
            }
                       
            Map<String,Object[]> template_matches = new HashMap<String, Object[]>();
               
            Engine[] engines = MetaSearchManagerFactory.getSingleton().getMetaSearch().getEngines( false, false );
           
            Map<Subscription,List<String>>  sub_dl_name_map = null;
           
            for ( Subscription sub: getSubscriptions( false )){
             
              if ( !sub.isSearchTemplate()){
               
                continue;
              }
             
              String  sub_name = sub.getName();
                           
              Engine sub_engine = sub.getEngine();
             
              if ( sub_engine.isActive() || !(sub_engine instanceof RSSEngine )){
               
                continue;
              }
             
              int  pos = sub_name.indexOf( ":" );
             
              String t_name = sub_name.substring( pos+1 );
             
              pos  = t_name.indexOf( "(v" );
             
              int t_ver;
             
              if ( pos == -1 ){
               
                t_ver = 1;
               
              }else{
               
                String s = t_name.substring( pos+2, t_name.length()-1);
               
                t_name = t_name.substring( 0, pos );
               
                try{
             
                  t_ver = Integer.parseInt(s);
                 
                }catch( Throwable e ){
                 
                  t_ver = 1;
                }
              }
             
              t_name = t_name.trim();
             
              boolean skip = false;
             
              for ( Engine e: engines ){
               
                if ( e != sub_engine && e.sameLogicAs( sub_engine )){
                 
                  skip = true;
                 
                  break;
                }
               
                if ( e.getName().equalsIgnoreCase( t_name )){
                 
                  if ( e.getVersion() >= t_ver ){
                   
                    skip = true;
                  }
                }
              }
             
              if ( skip ){
               
                continue;
              }
             
              if ( sub_dl_name_map == null ){
               
                sub_dl_name_map = new HashMap<Subscription, List<String>>();
               
                SubscriptionDownloadDetails[] sdds = SubscriptionUtils.getAllCachedDownloadDetails( azureus_core );
               
                for ( SubscriptionDownloadDetails sdd: sdds ){
                 
                  String name = sdd.getDownload().getDisplayName();
                 
                  if ( matcher.matches( name )){
                   
                    Subscription[] x = sdd.getSubscriptions();
                   
                    for ( Subscription s: x ){
                     
                      List<String> g = sub_dl_name_map.get( s );
                     
                      if ( g == null ){
                       
                        g = new ArrayList<String>();
                       
                        sub_dl_name_map.put( s, g );
                      }
                     
                      g.add( name );
                    }
                  }
                }
              }
             
              List<String> names = sub_dl_name_map.get( sub );
             
              if ( names == null ){
               
                continue;
              }
                         
              String key = t_name.toLowerCase();
             
              Object[] entry = template_matches.get( key );
             
              if ( entry == null ){
               
                entry = new Object[]{ sub, t_ver };
               
                template_matches.put( key, entry );
               
              }else{
               
                if ( t_ver > (Integer)entry[1]){
                 
                  entry[0= sub;
                  entry[1= t_ver;
                }
              }
            }
           
            List<Subscription>  interesting = new ArrayList<Subscription>();
           
            for ( Object[] entry: template_matches.values()){
           
              interesting.add((Subscription)entry[0]);
            }
           
            Collections.sort(
              interesting,
              new Comparator<Subscription>()
              {
                public int
                compare(
                  Subscription o1,
                  Subscription o2)
                {
                  long res = o2.getCachedPopularity() - o1.getCachedPopularity();
                 
                  if ( res < 0 ){
                    return( -1 );
                  }else if ( res > 0 ){
                    return( 1 );
                  }else{
                    return( 0 );
                  }
                }
              });
           
            int  added = 0;
           
            for ( final Subscription sub: interesting ){
               
              if ( added >= 3 ){
               
                break;
              }
             
              try{
                String subs_url_str = ((RSSEngine)sub.getEngine()).getSearchUrl( true );
               
                URL subs_url = new URL( subs_url_str );
               
                final byte[] vf_bytes = FileUtil.readInputStreamAsByteArray(subs_url.openConnection().getInputStream());
 
                VuzeFile vf = VuzeFileHandler.getSingleton().loadVuzeFile( vf_bytes );
               
                if ( MetaSearchManagerFactory.getSingleton().isImportable( vf )){
                 
                  final URL url =
                    MagnetURIHandler.getSingleton().registerResource(
                      new MagnetURIHandler.ResourceProvider()
                      {
                        public String
                        getUID()
                        {
                          return( SubscriptionManager.class.getName() + ".sid." + sub.getID() );
                        }
                       
                        public String
                        getFileType()
                        {
                          return( "vuze" );
                        }
                           
                        public byte[]
                        getData()
                        {
                          return( vf_bytes );
                        }
                      });
                     
                  SearchResult search_result =
                    new SearchResult()
                    {
                      public Object
                      getProperty(
                        int    property_name )
                      {
View Full Code Here

    props         = new propertyWrapper(_props );
    pluginDir       = _pluginDir;
    config         = new PluginConfigImpl(this,pluginConfigKey);
    given_plugin_id      = _plugin_id;
    plugin_version    = _plugin_version;
    ipc_interface      = new IPCInterfaceImpl( initialiser, plugin );
    state                 = new PluginStateImpl(this, initialiser);
   
    boolean verified   = false;
    boolean bad    = false;
   
View Full Code Here

  }
 
  public IPFilter
  getIPFilter()
  {
    return( new IPFilterImpl());
  }
View Full Code Here

 
  public Logger getLogger()
  {
    if ( logger == null ){
     
      logger = new LoggerImpl( this );
    }
   
    return( logger );
  }
View Full Code Here

    else {
      plug_msg = new MessageAdapter( message )//core created
    }
   
    RawMessage raw_plug = plug_encoder.encodeMessage( plug_msg );
    return new com.aelitis.azureus.core.networkmanager.RawMessage[]{ new RawMessageAdapter( raw_plug )};
  }
View Full Code Here

    return config;
  }


  public PluginConfigUIFactory getPluginConfigUIFactory() {
    return new PluginConfigUIFactoryImpl(config,pluginConfigKey);
  }
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.plugins.utils.search.SearchResult

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.