Package org.gudy.azureus2.plugins.utils.resourcedownloader

Examples of org.gudy.azureus2.plugins.utils.resourcedownloader.ResourceDownloader


  private void start() {
    for (int i = 0; i < updates.length; i++) {
      Update update = updates[i];
      ResourceDownloader[] rds = update.getDownloaders();
      for (int j = 0; j < rds.length; j++) {
        ResourceDownloader rd = rds[j];
        downloaders.add(rd);
      }
    }

    iterDownloaders = downloaders.iterator();
View Full Code Here


   *
   * @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

    nextUpdate();
  }
 
  private void nextUpdate() {
    if(iterDownloaders.hasNext()) {
      ResourceDownloader downloader = (ResourceDownloader) iterDownloaders.next();
      downloader.addListener(this);
      downloader.asyncDownload();
    } else {
      switchToRestart();     
    }
  }
View Full Code Here

            public void
            checkForUpdate(
              final UpdateChecker  checker )
            {
              try{
                ResourceDownloader rd =
                  manager.getDefaultPluginInterface().getUtilities().getResourceDownloaderFactory().create( new File( plugin_dir ));
 
                  // the plugin may have > 1 plugin interfaces, make the name up appropriately
               
                String  update_name = "";
                 
                PluginInterface[]  ifs = manager.getPluginInterfaces();
               
                  Arrays.sort(
                      ifs,
                      new Comparator()
                    {
                          public int
                      compare(
                        Object o1,
                        Object o2)
                          {
                            return(((PluginInterface)o1).getPluginName().compareTo(((PluginInterface)o2).getPluginName()));
                          }
                    });
                 
                for (int i=0;i<ifs.length;i++){
                 
                  if ( ifs[i].getPluginID().equals(pi.getPluginID())){
                 
                    update_name += (update_name.length()==0?"":",") + ifs[i].getPluginName();
                  }
                }
               
                final Update update = checker.addUpdate(
                  update_name,
                  new String[]{ "Uninstall: " + plugin_dir},
                  pi.getPluginVersion(),
                  rd,
                  pi.getPluginState().isUnloadable()?Update.RESTART_REQUIRED_NO:Update.RESTART_REQUIRED_YES );
                 
                rd.addListener(
                    new ResourceDownloaderAdapter()
                    {
                      public boolean
                      completed(
                        ResourceDownloader  downloader,
View Full Code Here

          public void
          checkForUpdate(
            UpdateChecker  checker )
          {
            try{
              ResourceDownloader rd =
                plugin_interface.getUtilities().getResourceDownloaderFactory().create( file );
             
              plugin_update_plugin.addUpdate(
                plugin_interface,
                checker,
View Full Code Here

            }
          } else {
            // no old dl, download sync now
            Logger.log(new LogEvent(LOGID, "sync Downloading " + file));
            try {
              ResourceDownloader rd = ResourceDownloaderFactoryImpl.getSingleton().create(
                  new URL(file));
              fin = rd.download();
              FileUtil.copyFile(fin, filtersFile);
              setNextAutoDownload(true);
            } catch (ResourceDownloaderException e) {
              return;
            }
View Full Code Here

   * @param url
   *
   * @since 3.0.1.5
   */
  private void downloadFiltersAsync(URL url) {
    ResourceDownloader rd = ResourceDownloaderFactoryImpl.getSingleton().create(
        url);
    // old dl exists, load old one while new one downloads async
    rd.addListener(new ResourceDownloaderAdapter() {
      // @see org.gudy.azureus2.plugins.utils.resourcedownloader.ResourceDownloaderAdapter#reportPercentComplete(org.gudy.azureus2.plugins.utils.resourcedownloader.ResourceDownloader, int)
      public void reportPercentComplete(ResourceDownloader downloader,
          int percentage) {
      }

      public boolean completed(ResourceDownloader downloader, InputStream data) {
        try {
          setNextAutoDownload(true);

          Logger.log(new LogEvent(LOGID, "downloaded..waiting"));
          // since this is a different thread, we can use class_mon as
          // a cheap semaphore to wait until previous load completes
          class_mon.enter();
          Logger.log(new LogEvent(LOGID, "downloaded.. copying"));

          try {
            FileUtil.copyFile(data, FileUtil.getUserFile("ipfilter.dl"));
            AEThread thread = new AEThread("reload ipfilters", true) {
              public void runSupport() {
                try {
                  UIFunctions uif = UIFunctionsManager.getUIFunctions();
                  if (uif != null) {
                    uif.setStatusText("Reloading Filters..");
                  }
                  ipFilter.reload(false);
                  if (uif != null) {
                    uif.setStatusText(null);
                  }
                } catch (Exception e) {
                  Debug.out(e);
                }
              }
            };
            thread.setPriority(Thread.NORM_PRIORITY - 1);
            thread.start();
          } catch (Exception e) {
            Debug.out(e);
          }
        } finally {
          class_mon.exit();
        }

        return true;
      }
    });
    rd.asyncDownload();
  }
View Full Code Here

    try{
      ResourceDownloaderFactory rdf = plugin_interface.getUtilities().getResourceDownloaderFactory();
   
      URL sl_url = new URL( SECONDARY_LOOKUP + "magnetLookup?hash=" + Base32.encode( hash ) + (args.length()==0?"":("&args=" + UrlUtils.encode( args ))));
     
      ResourceDownloader rd = rdf.create( sl_url );
     
      rd.addListener(
        new ResourceDownloaderAdapter()
        {
          public boolean
          completed(
            ResourceDownloader  downloader,
            InputStream      data )
          {
            listener.reportActivity( getMessageText( "report.secondarylookup.ok", null ));

            synchronized( result ){
           
              result[0] = data;
            }
           
            return( true );
          }
         
          public void
          failed(
            ResourceDownloader      downloader,
            ResourceDownloaderException e )
          {
            synchronized( result ){
             
              result[0] = e;
            }
           
            listener.reportActivity( getMessageText( "report.secondarylookup.fail" ));
          }
        });
     
      rd.asyncDownload();
     
    }catch( Throwable e ){
     
      listener.reportActivity( getMessageText( "report.secondarylookup.fail", Debug.getNestedExceptionMessage( e ) ));
    }
View Full Code Here

  private static byte[] downloadURL(URL url, String postData)
      throws Exception {
    ResourceDownloaderFactory rdf = StaticUtilities.getResourceDownloaderFactory();

    ResourceDownloader rd = rdf.create(url, postData);

    rd.setProperty( "URL_Connection", "Keep-Alive" );
   
    rd = rdf.getRetryDownloader(rd, 3);
    // We could report percentage to listeners, but there's no need to atm
    //    rd.addListener(new ResourceDownloaderListener() {
    //   
    //      public void reportPercentComplete(ResourceDownloader downloader,
    //          int percentage) {
    //      }
    //   
    //      public void reportActivity(ResourceDownloader downloader, String activity) {
    //      }
    //   
    //      public void failed(ResourceDownloader downloader,
    //          ResourceDownloaderException e) {
    //      }
    //   
    //      public boolean completed(ResourceDownloader downloader, InputStream data) {
    //        return true;
    //      }
    //    });

    InputStream is = rd.download();

    byte data[];

    try {
      int length = is.available();
View Full Code Here

       
        String  protocol = url.getProtocol().toLowerCase();
       
        if ( protocol.equals( "http" ) || protocol.equals( "https" )){
         
          ResourceDownloader rd = StaticUtilities.getResourceDownloaderFactory().create( url );
       
          return( getVuzeFile(rd.download()));
        }
      }
    }catch( Throwable e ){
    }
   
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.plugins.utils.resourcedownloader.ResourceDownloader

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.