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

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


          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(
                new UpdateInstallerListener()
                {
                  public void
                  reportProgress(
                    String    str )
View Full Code Here


           
              installer.addMoveAction(
                "C:\\temp\\file1", "C:\\temp\\file2" );
           
              installer.installNow(
                new UpdateInstallerListener()
                {
                  public void
                  reportProgress(
                    String    str )
                  {
View Full Code Here

          public void perform(TimerEvent ev) {
            performAutoCheck(false);
          }
        });

    DelayedTask delayed_task =
      UtilitiesImpl.addDelayedTask(
        "Update Check",
        new Runnable()
        {
          public void
          run()
          {
            // check for non-writeable app dir on non-vista platforms (vista we've got a chance of
            // elevating perms when updating) and warn user. Particularly useful on OSX when
            // users haven't installed properly
   
            if ( !( Constants.isWindowsVistaOrHigher || SystemProperties.isJavaWebStartInstance())){
   
              String  app_str = SystemProperties.getApplicationPath();
   
              if ( !new File(app_str).canWrite()){
   
                final UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
   
                if ( uiFunctions != null ){
   
                  if ( app_str.endsWith( File.separator )){
   
                    app_str = app_str.substring(0, app_str.length()-1);
                  }
                 
                  final String f_app_str = app_str;
                 
                  Utils.execSWTThread(
                    new Runnable()
                    {
                      public void
                      run()
                      {
                        UIFunctionsUserPrompter prompt =
                          uiFunctions.getUserPrompter(
                            MessageText.getString("updater.cant.write.to.app.title"),
                            MessageText.getString("updater.cant.write.to.app.details", new String[]{f_app_str}),
                            new String[]{ MessageText.getString( "Button.ok" )},
                            0 );
       
                        //prompt.setHtml( "http://a.b.c/" );
         
                        prompt.setIconResource( "warning" );
         
                        prompt.setRemember( "UpdateMonitor.can.not.write.to.app.dir.2", false,
                            MessageText.getString( "MessageBoxWindow.nomoreprompting" ));
         
                        prompt.open(null);
                      }
                    },
                    true );
                }
              }
            }
   
            performAutoCheck(true);
          }
        });
   
    delayed_task.queue();
  }
View Full Code Here

  {
    boolean  handled = false;
   
    for (int i=0;i<listeners.size();i++){
     
      PooledByteBuffer  buffer = new PooledByteBufferImpl(message.getPayload());
     
      try{
        ((GenericMessageConnectionListener)listeners.get(i)).receive( this, buffer );
       
        handled = true;
       
      }catch( Throwable f ){
       
        buffer.returnToPool();
       
        if ( !( f instanceof MessageException )){
       
          Debug.printStackTrace(f);
        }
View Full Code Here

  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

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

    String                  args )
  {
    listener.reportActivity( getMessageText( "report.secondarylookup", null ));
   
    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
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) {
View Full Code Here

     
        // hack to support POST by encoding into URL
     
        // http://xxxx/index.php?main=search&azmethod=post_basic:SearchString1=%s&SearchString=&search=Search
       
      ResourceDownloaderFactory rdf = StaticUtilities.getResourceDownloaderFactory();

      URL          initial_url;
      ResourceDownloader   initial_url_rd;
         
     
      int  post_pos = searchURL.indexOf( "azmethod=" );
     
      if ( post_pos > 0 ){
       
        String post_params = searchURL.substring( post_pos+9 );
       
        searchURL = searchURL.substring( 0, post_pos-1 );
       
        debugLog( "search_url: " + searchURL + ", post=" + post_params );

        initial_url = new URL(searchURL);

        int  sep = post_params.indexOf( ':' );
       
        String  type = post_params.substring( 0, sep );
       
        if ( !type.equals( "post_basic" )){
         
          throw( new SearchException( "Only basic type supported" ));
        }
       
        post_params = post_params.substring( sep+1 );
       
          // already URL encoded
       
        initial_url_rd = rdf.create( initial_url, post_params );

        initial_url_rd.setProperty( "URL_Content-Type", "application/x-www-form-urlencoded" );
       
      }else{
     
        debugLog( "search_url: " + searchURL );
     
        initial_url = new URL(searchURL);
     
        initial_url_rd = rdf.create( initial_url );
      }
     
      setHeaders( initial_url_rd, headers );
       
      if ( needsAuth && local_cookies != null ){
       
        initial_url_rd.setProperty( "URL_Cookie", local_cookies );       
      }
       
      if ( only_if_modified ){
       
        String last_modified   = getLocalString( LD_LAST_MODIFIED );
        String etag        = getLocalString( LD_ETAG );

        if ( last_modified != null ){
         
          initial_url_rd.setProperty( "URL_If-Modified-Since", last_modified );
        }
       
        if ( etag != null ){
         
          initial_url_rd.setProperty( "URL_If-None-Match", etag );
        }
      }
     
      InputStream  is;
     
      String content_charset = "UTF-8";

      ResourceDownloader mr_rd = null;
     
      if ( initial_url.getProtocol().equalsIgnoreCase( "file" )){
       
          // handle file://c:/ - map to file:/c:/
       
        String  str = initial_url.toExternalForm();
       
        if ( initial_url.getAuthority() != null ){
       
          str = str.replaceFirst( "://", ":/" );
        }
               
        int  pos = str.indexOf( '?' );
       
        if ( pos != -1 ){
         
          str = str.substring( 0, pos );
        }
       
        is = new FileInputStream( new File( new URL( str ).toURI()));
       
      }else{
       
        mr_rd = rdf.getMetaRefreshDownloader( initial_url_rd );

        try{
       
          is = mr_rd.download();
         
View Full Code Here

TOP

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

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.