Package org.gudy.azureus2.plugins.download

Examples of org.gudy.azureus2.plugins.download.DownloadManager


    // 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


      // prevents someone without the hash from downloading the torrent
   
    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;
View Full Code Here

      ShareItem  item = (ShareItem)items.get(i);
       
        try{
        Torrent  t = item.getTorrent();
                  
        Download  download = dm.getDownload( t );
       
        if ( download == null ){
                   
          continue;
        }
       
        int  dl_state = download.getState();
       
        if (   dl_state == Download.ST_ERROR ){
         
        }else if ( dl_state != Download.ST_STOPPED ){
         
View Full Code Here

          try{
            Torrent  t = item.getTorrent();
           
            TrackerTorrent  tracker_torrent = tracker.getTorrent( t );
           
            Download  download = dm.getDownload( t );
           
            if ( tracker_torrent == null || download == null ){
                             
              continue;
            }
           
            int  dl_state = download.getState();
           
            if (   dl_state == Download.ST_ERROR ){
             
            }else if ( dl_state != Download.ST_STOPPED ){
             
              if ( do_stop ){
               
                try{
                  download.stop();
                }catch( Throwable e ){
                }
               
                try{
                  tracker_torrent.stop();
                }catch( Throwable e ){
                }
              }
             
            }else{
             
              if ( !do_stop ){
               
                try{
                  download.restart();
                }catch( Throwable e ){
                }
               
                try{
                  tracker_torrent.start();
View Full Code Here

      // However, check just in case
      AzureusCoreFactory.addCoreRunningListener(new AzureusCoreRunningListener() {
     
        public void azureusCoreRunning(AzureusCore core) {
         
          DownloadManager dm = PluginInitializer.getDefaultInterface().getDownloadManager();
         
          dm.addListener( DeviceUPnPImpl.this, true );
        }
      });
    }
       
    addListener( this );
View Full Code Here

     
      dynamic_transcode_profile = null;
     
      dynamic_xcode_map = null;
    
      DownloadManager dm = PluginInitializer.getDefaultInterface().getDownloadManager();

      dm.removeListener( this );
     
      removeListener( this );
     
      TranscodeFileImpl[]  transcode_files = getFiles();
     
View Full Code Here

   
                  Torrent torrent = new TorrentImpl( TOTorrentFactory.deserialiseFromBEncodedInputStream( is ));
                           
                  // PlatformTorrentUtils.setContentTitle(torrent, torr );
             
                  DownloadManager dm = PluginInitializer.getDefaultInterface().getDownloadManager();
                 
                  Download  download;
                 
                  boolean auto_start = manager.shouldAutoStart( torrent );
                 
                  if ( auto_start ){
                 
                    download = dm.addDownload( torrent );
                   
                  }else{
                 
                    download = dm.addDownloadStopped( torrent, null, null );
                  }
                 
                  log( subs.getName() + ": added download " + download.getName()+ ": auto-start=" + auto_start );

                  subs.addAssociation( torrent.getHash());
View Full Code Here

              if ( !dht_plugin.isEnabled()){
               
                return;
              }
             
              DownloadManager dm = plugin_interface.getDownloadManager();
             
              Download[] downloads = dm.getDownloads();
             
              addDownloads( downloads, true );
             
              dm.addListener(
                new DownloadManagerListener()
                {
                  public void
                  downloadAdded(
                    Download  download )
View Full Code Here

  protected static void
  hookDownloadAddition()
  {
    PluginInterface pi = PluginInitializer.getDefaultInterface();

    DownloadManager  dm = pi.getDownloadManager();
   
      // need to get in early to ensure property present on initial announce
   
    dm.addDownloadWillBeAddedListener(
      new DownloadWillBeAddedListener()
      {
        public void
        initialised(
          Download   download )
        {
            // unfortunately the has-been-opened state is updated by azureus when a user opens content
            // but is also preserved across torrent export/import (e.g. when downloaded via magnet
            // URL. So reset it here if it is found to be set
         
          org.gudy.azureus2.core3.download.DownloadManager dm = PluginCoreUtils.unwrap( download );
         
          if ( PlatformTorrentUtils.getHasBeenOpened( dm )){
           
            PlatformTorrentUtils.setHasBeenOpened( dm, false );
          }
         
          register( download );
        }
      });
   
    dm.addListener(
      new DownloadManagerListener()
      {
        public void
        downloadAdded(
          Download download )
View Full Code Here

public class TorrentUtils {

  
   
    public static boolean sharingLatest(){
        DownloadManager dm = View.getPluginInterface().getDownloadManager();
        Download[] downloads = dm.getDownloads();
        for(int i = 0 ; i < downloads.length ; i++){
            //setForceSeed(Tab1.version);
            if(downloads[i].getName().equalsIgnoreCase(Tab1_Subtab_1.version)){
                return (true);
            }
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.plugins.download.DownloadManager

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.