Package org.gudy.azureus2.core3.torrent

Examples of org.gudy.azureus2.core3.torrent.TOTorrent


              // the process of attempting to start the torrent may have left some empty
              // directories created, some users take exception to this.
              // the most straight forward way of remedying this is to delete such empty
              // folders here
         
            TOTorrent  torrent = download_manager.getTorrent();
       
            if ( torrent != null && !torrent.isSimpleTorrent()){
 
              File  save_dir_file  = download_manager.getAbsoluteSaveLocation();
 
              if ( save_dir_file != null && save_dir_file.exists() && save_dir_file.isDirectory()){
             
View Full Code Here


    // secrets for inbound connections, support all
 
  public byte[][]
  getSecrets()
  {
    TOTorrent  torrent = download_manager.getTorrent();
       
    try{
      byte[]  secret1 = torrent.getHash();
     
      try{
       
        byte[]  secret2   = getSecret2( torrent );
     
View Full Code Here

 
  public byte[][]
    getSecrets(
      int  crypto_level )
  {
    TOTorrent  torrent = download_manager.getTorrent();

    try{
      byte[]  secret;
     
      if ( crypto_level == PeerItemFactory.CRYPTO_LEVEL_1 ){
       
        secret = torrent.getHash();
       
      }else{
       
        secret = getSecret2( torrent );
      }
View Full Code Here

      if ( stopped || destroyed ){
       
        return;
      }
     
      TOTorrent torrent = getTorrent();
         
      TOTorrentAnnounceURLSet[]  sets = torrent.getAnnounceURLGroup().getAnnounceURLSets();
     
        // sanitise dht entries
     
      if ( sets.length == 0 ){
       
        sets = new TOTorrentAnnounceURLSet[]{ torrent.getAnnounceURLGroup().createAnnounceURLSet( new URL[]{ torrent.getAnnounceURL()})};
       
      }else{
       
        boolean  found_decentralised = false;
        boolean  modified      = false;
       
        for ( int i=0;i<sets.length;i++ ){
         
          TOTorrentAnnounceURLSet set = sets[i];
         
          URL[] urls = set.getAnnounceURLs().clone();
         
          for (int j=0;j<urls.length;j++){
           
            URL u = urls[j];
           
            if ( u != null && TorrentUtils.isDecentralised( u )){
                           
              if ( found_decentralised ){
               
                modified = true;
               
                urls[j] = null;
               
              }else{
               
                found_decentralised = true;
              }
            }
          }
        }
       
        if ( modified ){
         
          List<TOTorrentAnnounceURLSet> s_list = new ArrayList<TOTorrentAnnounceURLSet>();
         
          for ( TOTorrentAnnounceURLSet set: sets ){
           
            URL[] urls = set.getAnnounceURLs();
           
            List<URL> u_list = new ArrayList<URL>( urls.length );
           
            for ( URL u: urls ){
             
              if ( u != null ){
               
                u_list.add( u );
              }
            }
           
            if ( u_list.size() > 0 ){
             
              s_list.add( torrent.getAnnounceURLGroup().createAnnounceURLSet( u_list.toArray( new URL[ u_list.size() ])));
            }
          }
         
          sets = s_list.toArray( new TOTorrentAnnounceURLSet[ s_list.size() ]);
        }
      }
     
      List<TOTorrentAnnounceURLSet[]>  new_sets = new ArrayList<TOTorrentAnnounceURLSet[]>();
     
      if ( is_manual || sets.length < 2 ){
         
        new_sets.add( sets );
       
      }else{
       
        List<TOTorrentAnnounceURLSet> list = new ArrayList<TOTorrentAnnounceURLSet>( Arrays.asList( sets ));
       
          // often we have http:/xxxx/ and udp:/xxxx/ as separate groups - keep these together
               
        while( list.size() > 0 ){
         
          TOTorrentAnnounceURLSet set1 = list.remove(0);
         
          boolean  done = false;
         
          URL[] urls1 = set1.getAnnounceURLs();
         
          if ( urls1.length == 1 ){
           
            URL url1 = urls1[0];
           
            String prot1 = url1.getProtocol().toLowerCase();
            String host1  = url1.getHost();
           
            for (int i=0;i<list.size();i++){
             
              TOTorrentAnnounceURLSet set2 = list.get(i);
             
              URL[] urls2 = set2.getAnnounceURLs();
             
              if ( urls2.length == 1 ){
               
                URL url2 = urls2[0];
               
                String prot2 = url2.getProtocol().toLowerCase();
                String host2 = url2.getHost();
       
                if ( host1.equals( host2 )){
                 
                  if (  ( prot1.equals( "udp" ) && prot2.startsWith( "http" )) ||
                      ( prot2.equals( "udp" ) && prot1.startsWith( "http" ))){
                   
                    list.remove( i );
                   
                    new_sets.add( new TOTorrentAnnounceURLSet[]{ set1, set2 });
                   
                    done  = true;
                  }
                }
              }
            }
          }
         
          if ( !done ){
           
            new_sets.add( new TOTorrentAnnounceURLSet[]{ set1 });
          }
        }
      }
     
        // work out the difference
     
      Iterator<TOTorrentAnnounceURLSet[]> ns_it = new_sets.iterator();
     
      List<TRTrackerAnnouncerHelper> existing_announcers   = announcers.getList();
      List<TRTrackerAnnouncerHelper> new_announcers     = new ArrayList<TRTrackerAnnouncerHelper>();
     
        // first look for unchanged sets
     
      while( ns_it.hasNext()){
       
        TOTorrentAnnounceURLSet[] ns = ns_it.next();
       
        Iterator<TRTrackerAnnouncerHelper> a_it = existing_announcers.iterator();
         
        while( a_it.hasNext()){
         
          TRTrackerAnnouncerHelper a = a_it.next();
         
          TOTorrentAnnounceURLSet[] os = a.getAnnounceSets();
         
          if ( same( ns, os )){
           
            ns_it.remove();
            a_it.remove();
           
            new_announcers.add( a );
           
            break;
          }
        }
      }
         
        // reuse existing announcers
     
        // first remove dht ones from the equation
     
      TRTrackerAnnouncerHelper   existing_dht_announcer   = null;
      TOTorrentAnnounceURLSet[]  new_dht_set        = null;

      ns_it = new_sets.iterator();
     
      while( ns_it.hasNext()){
       
        TOTorrentAnnounceURLSet[] x = ns_it.next();
       
        if ( TorrentUtils.isDecentralised( x[0].getAnnounceURLs()[0])){
         
          new_dht_set = x;
           
          ns_it.remove();
         
          break;
        }
      }
     
      Iterator<TRTrackerAnnouncerHelper>  an_it = existing_announcers.iterator();
     
      while( an_it.hasNext()){
       
        TRTrackerAnnouncerHelper a = an_it.next();
       
        TOTorrentAnnounceURLSet[] x = a.getAnnounceSets();
       
        if ( TorrentUtils.isDecentralised( x[0].getAnnounceURLs()[0])){
         
          existing_dht_announcer = a;
           
          an_it.remove();
         
          break;
        }
      }
 
      if ( existing_dht_announcer != null && new_dht_set != null ){
       
        new_announcers.add( existing_dht_announcer );
       
      }else if ( existing_dht_announcer != null ){
       
        activated.remove( existing_dht_announcer );
       
        existing_dht_announcer.destroy();
       
      }else if ( new_dht_set != null ){
       
        TRTrackerAnnouncerHelper a = create( torrent, new_dht_set );
       
        new_announcers.add( a );
      }

        // now do the non-dht ones
     
      ns_it = new_sets.iterator();

      while( ns_it.hasNext() && existing_announcers.size() > 0 ){
       
        TRTrackerAnnouncerHelper a = existing_announcers.remove(0);
       
        TOTorrentAnnounceURLSet[] s = ns_it.next();
       
        ns_it.remove();
       
        if (   activated.contains( a ) &&
            torrent.getPrivate() &&
            a instanceof TRTrackerBTAnnouncerImpl ){
         
          URL url = a.getTrackerURL();
       
          if ( url != null ){
           
            forceStop((TRTrackerBTAnnouncerImpl)a, url );
          }
        }
       
        a.setAnnounceSets( s );
       
        new_announcers.add( a );
      }
     
        // create any new ones required
     
      ns_it = new_sets.iterator();
     
      while( ns_it.hasNext()){
       
        TOTorrentAnnounceURLSet[] s = ns_it.next();
       
        TRTrackerAnnouncerHelper a = create( torrent, s );
       
        new_announcers.add( a );
      }
     
        // finally fix up the announcer list to represent the new state
     
      Iterator<TRTrackerAnnouncerHelper>  a_it = announcers.iterator();
       
      while( a_it.hasNext()){
       
        TRTrackerAnnouncerHelper a = a_it.next();
       
        if ( !new_announcers.contains( a )){
         
          a_it.remove();
         
          try{
            if (   activated.contains( a ) &&
                torrent.getPrivate() &&
                a instanceof TRTrackerBTAnnouncerImpl ){
             
              URL url = a.getTrackerURL();
           
              if ( url != null ){
View Full Code Here

  public static DiskManagerFileInfoSet
  getFileInfoSkeleton(
      final DownloadManager       download_manager,
      final DiskManagerListener   listener )
  {
      TOTorrent   torrent = download_manager.getTorrent();
 
      if ( torrent == null ){
 
          return( new DiskManagerFileInfoSetImpl(new DiskManagerFileInfoImpl[0],null) );
      }
 
      String  tempRootDir = download_manager.getAbsoluteSaveLocation().getParent();
     
      if(tempRootDir == null) // in case we alraedy are at the root
        tempRootDir = download_manager.getAbsoluteSaveLocation().getPath();
     
 
      if ( !torrent.isSimpleTorrent()){
        tempRootDir += File.separator + download_manager.getAbsoluteSaveLocation().getName();
      }
 
      tempRootDir    += File.separator;
     
      final String root_dir = StringInterner.intern(tempRootDir) ;
 
      try{
          final LocaleUtilDecoder locale_decoder = LocaleTorrentUtil.getTorrentEncoding( torrent );
 
          TOTorrentFile[] torrent_files = torrent.getFiles();
 
          final FileSkeleton[]   res = new FileSkeleton[ torrent_files.length ];
         
      final String incomplete_suffix = download_manager.getDownloadState().getAttribute( DownloadManagerState.AT_INCOMP_FILE_SUFFIX );

          final DiskManagerFileInfoSet fileSetSkeleton = new DiskManagerFileInfoSet() {
 
        public DiskManagerFileInfo[] getFiles() {
          return res;
        }
 
        public int nbFiles() {
          return res.length;
        }
 
        public void setPriority(int[] toChange) {
          if(toChange.length != res.length)
            throw new IllegalArgumentException("array length mismatches the number of files");
         
          for(int i=0;i<res.length;i++)
            res[i].priority = toChange[i];
         
          DiskManagerImpl.storeFilePriorities( download_manager, res);
         
         
         
          for(int i=0;i<res.length;i++)
            if(toChange[i] > 0 )
              listener.filePriorityChanged(res[i]);
        }
 
        public void setSkipped(boolean[] toChange, boolean setSkipped) {
          if(toChange.length != res.length)
            throw new IllegalArgumentException("array length mismatches the number of files");
         
              if (!setSkipped ){
              String[] types = DiskManagerImpl.getStorageTypes(download_manager);

              boolean[]  toLinear   = new boolean[toChange.length];
              boolean[]  toReorder   = new boolean[toChange.length];
             
              int  num_linear   = 0;
              int num_reorder  = 0;
             
              for ( int i=0;i<toChange.length;i++){
               
                if ( toChange[i] ){
                 
                  int old_type = DiskManagerUtil.convertDMStorageTypeFromString( types[i] );
                 
                  if ( old_type == DiskManagerFileInfo.ST_COMPACT ){
                   
                    toLinear[i] = true;
                   
                    num_linear++;
                   
                  }else if ( old_type == DiskManagerFileInfo.ST_REORDER_COMPACT ){
                   
                    toReorder[i] = true;
                   
                    num_reorder++;
                  }
                } 
              }
             
              if ( num_linear > 0 ){
               
                if (!Arrays.equals(toLinear, setStorageTypes(toLinear, DiskManagerFileInfo.ST_LINEAR))){
                 
                  return;
                }
              }
           
              if ( num_reorder > 0 ){
               
                if (!Arrays.equals(toReorder, setStorageTypes(toReorder, DiskManagerFileInfo.ST_REORDER ))){
                 
                  return;
                }
              }
              }
             
          for(int i=0;i<res.length;i++)
            if(toChange[i])
              res[i].skipped = setSkipped;
         
          if(!setSkipped)
            doFileExistenceChecks(this, toChange, download_manager, true);
         
          DiskManagerImpl.storeFilePriorities( download_manager, res);
         
          for(int i=0;i<res.length;i++)
            if(toChange[i])
              listener.filePriorityChanged(res[i]);
        }
 
        public boolean[] setStorageTypes(boolean[] toChange, int newStorageType) {
          if(toChange.length != res.length)
            throw new IllegalArgumentException("array length mismatches the number of files");
         
          String[] types = DiskManagerImpl.getStorageTypes(download_manager);
          boolean[] modified = new boolean[res.length];
          boolean[] toSkip = new boolean[res.length];
          int toSkipCount = 0;
          DownloadManagerState dmState = download_manager.getDownloadState();
         
          try {
            dmState.suppressStateSave(true);
 
            for(int i=0;i<res.length;i++)
            {
              if(!toChange[i])
                continue;
 
 
              final int idx = i;
 
              int old_type = DiskManagerUtil.convertDMStorageTypeFromString( types[i] );
 
              //System.out.println(old_type + " <> " + newStroageType);
 
              if ( newStorageType == old_type )
              {
                modified[i] = true;
                continue;
              }
 
              try{
                File    target_file = res[i].getFile( true );
 
                // if the file doesn't exist then this is the start-of-day, most likely
                // being called from the torrent-opener, so we don't need to do any
                // file fiddling (in fact, if we do, we end up leaving zero length
                // files for dnd files which then force a recheck when the download
                // starts for the first time)
 
                if ( target_file.exists()){
 
                  CacheFile cache_file =
                    CacheFileManagerFactory.getSingleton().createFile(
                      new CacheFileOwner()
                      {
                        public String
                        getCacheFileOwnerName()
                        {
                          return( download_manager.getInternalName());
                        }
 
                        public TOTorrentFile
                        getCacheFileTorrentFile()
                        {
                          return( res[idx].getTorrentFile() );
                        }
 
                        public File
                        getCacheFileControlFileDir()
                        {
                          return( download_manager.getDownloadState().getStateFile( ));
                        }
                        public int
                        getCacheMode()
                        {
                          return( CacheFileOwner.CACHE_MODE_NORMAL );
                        }
                      },
                      target_file,
                      DiskManagerUtil.convertDMStorageTypeToCache( newStorageType ));
 
                  cache_file.close();
 
                  toSkip[i] = ( newStorageType == FileSkeleton.ST_COMPACT || newStorageType == FileSkeleton.ST_REORDER_COMPACT )&& !res[i].isSkipped();
                  if(toSkip[i])
                    toSkipCount++;
                }
 
 
                modified[i] = true;
 
              }catch( Throwable e ){
 
                Debug.printStackTrace(e);
 
                Logger.log(
                  new LogAlert(download_manager,
                    LogAlert.REPEATABLE,
                    LogAlert.AT_ERROR,
                    "Failed to change storage type for '" + res[i].getFile(true) +"': " + Debug.getNestedExceptionMessage(e)));
 
                // download's not running - tag for recheck
 
                RDResumeHandler.recheckFile( download_manager, res[i] );
 
              }
 
              types[i] = DiskManagerUtil.convertDMStorageTypeToString( newStorageType );
            }
           
            /*
             * set storage type and skipped before we do piece clearing and file
             * clearing checks as those checks work better when skipped/stype is set
             * properly
             */
            dmState.setListAttribute( DownloadManagerState.AT_FILE_STORE_TYPES, types);
            if(toSkipCount > 0)
              setSkipped(toSkip, true);
           
           
            for(int i=0;i<res.length;i++)
            {
              if(!toChange[i])
                continue;
             
              // download's not running, update resume data as necessary
 
              int cleared = RDResumeHandler.storageTypeChanged( download_manager, res[i] );
 
              // try and maintain reasonable figures for downloaded. Note that because
              // we don't screw with the first and last pieces of the file during
              // storage type changes we don't have the problem of dealing with
              // the last piece being smaller than torrent piece size
 
              if (cleared > 0)
              {
                res[i].downloaded = res[i].downloaded - cleared * res[i].getTorrentFile().getTorrent().getPieceLength();
                if (res[i].downloaded < 0) res[i].downloaded = 0;
              }
            }
 
            DiskManagerImpl.storeFileDownloaded( download_manager, res, true );
 
            doFileExistenceChecks(this, toChange, download_manager, newStorageType == FileSkeleton.ST_LINEAR || newStorageType == FileSkeleton.ST_REORDER );
 
          } finally {
            dmState.suppressStateSave(false);
            dmState.save();
          }
         
          return modified;
        }
          };
 
          for (int i=0;i<res.length;i++){
 
              final TOTorrentFile torrent_file    = torrent_files[i];
 
              final int file_index = i;
 
              FileSkeleton info = new FileSkeleton() {
 
                private CacheFile   read_cache_file;
                // do not access this field directly, use lazyGetFile() instead
                private WeakReference dataFile = new WeakReference(null);
 
                public void
                setPriority(int b)
                {
                  priority    = b;
 
                  DiskManagerImpl.storeFilePriorities( download_manager, res );
 
                  listener.filePriorityChanged( this );
                }
 
                public void
                setSkipped(boolean _skipped)
                {
                  if ( !_skipped && getStorageType() == ST_COMPACT ){
                    if ( !setStorageType( ST_LINEAR )){
                      return;
                    }
                  }
 
                  if ( !_skipped && getStorageType() == ST_REORDER_COMPACT ){
                    if ( !setStorageType( ST_REORDER )){
                      return;
                    }
                  }

                  skipped = _skipped;
 
                  DiskManagerImpl.storeFilePriorities( download_manager, res );
                 
                  if(!_skipped)
                  {
                    boolean[] toCheck = new boolean[fileSetSkeleton.nbFiles()];
                    toCheck[file_index] = true;
                    doFileExistenceChecks(fileSetSkeleton, toCheck, download_manager, true);                     
                  }
                 
 
                  listener.filePriorityChanged( this );
                }
 
                public int
                getAccessMode()
                {
                  return( READ );
                }
 
                public long
                getDownloaded()
                {
                  return( downloaded );
                }
 
                public void
                setDownloaded(
                  long    l )
                {
                  downloaded  = l;
                }
 
                public String
                getExtension()
                {
                  String    ext   = lazyGetFile().getName();
                 
                      if ( incomplete_suffix != null && ext.endsWith( incomplete_suffix )){
                       
                        ext = ext.substring( 0, ext.length() - incomplete_suffix.length());
                      }

                  int separator = ext.lastIndexOf(".");
                  if (separator == -1)
                    separator = 0;
                  return ext.substring(separator);
                }
 
                public int
                getFirstPieceNumber()
                {
                  return( torrent_file.getFirstPieceNumber());
                }
 
                public int
                getLastPieceNumber()
                {
                  return( torrent_file.getLastPieceNumber());
                }
 
                public long
                getLength()
                {
                  return( torrent_file.getLength());
                }
 
                public int
                getIndex()
                {
                  return( file_index );
                }
 
                public int
                getNbPieces()
                {
                  return( torrent_file.getNumberOfPieces());
                }
 
                public int
                getPriority()
                {
                  return( priority );
                }
 
                public boolean
                isSkipped()
                {
                  return( skipped );
                }
 
                public DiskManager
                getDiskManager()
                {
                  return( null );
                }
 
                public DownloadManager
                getDownloadManager()
                {
                  return( download_manager );
                }
 
                public File
                getFile(
                  boolean follow_link )
                {
                  if ( follow_link ){
 
                    File link = getLink();
 
                    if ( link != null ){
 
                      return( link );
                    }
                  }
                  return lazyGetFile();
                }
 
                private File lazyGetFile()
                {
                  File toReturn = (File)dataFile.get();
                  if(toReturn != null)
                    return toReturn;
 
                  TOTorrent tor = download_manager.getTorrent();
 
                  String  path_str = root_dir;
                  File simpleFile = null;
 
                  // for a simple torrent the target file can be changed
 
                  if ( tor.isSimpleTorrent()){
 
                    simpleFile = download_manager.getAbsoluteSaveLocation();
 
                  }else{
                    byte[][]path_comps = torrent_file.getPathComponents();
View Full Code Here

  public static String
  formatHashFails(
    DownloadManager    download_manager )
  {
    TOTorrent  torrent = download_manager.getTorrent();
   
    if ( torrent != null ){
     
      long bad = download_manager.getStats().getHashFailBytes();
 
          // size can exceed int so ensure longs used in multiplication
 
      long count = bad / (long)torrent.getPieceLength();
 
      String result = count + " ( " + formatByteCountToKiBEtc(bad) + " )";
 
      return result;
      }
View Full Code Here

     
      long  dl_marker = 0;
     
      for ( DownloadManager dm: dms ){
       
        TOTorrent torrent = dm.getTorrent();
       
        if ( torrent == null ){
         
          continue;
        }
       
        if ( !TorrentUtils.isReallyPrivate( torrent )){
       
          dl_marker += dm.getDownloadState().getLongParameter( DownloadManagerState.PARAM_DOWNLOAD_ADDED_TIME );
       
          downloads.add( PluginCoreUtils.wrap(dm));
        }
      }
     
      String  config_key = "cat.rss.config." + Base32.encode( cat.getName().getBytes( "UTF-8" ));
     
      long  old_marker = COConfigurationManager.getLongParameter( config_key + ".marker", 0 );
     
      long  last_modified = COConfigurationManager.getLongParameter( config_key + ".last_mod", 0 );
     
      long now = SystemTime.getCurrentTime();
     
      if ( old_marker == dl_marker ){
       
        if ( last_modified == 0 ){
         
          last_modified = now;
        }
      }else{
       
        COConfigurationManager.setParameter( config_key + ".marker", dl_marker );
       
        last_modified = now;
      }
     
      if ( last_modified == now ){
       
        COConfigurationManager.setParameter( config_key + ".last_mod", last_modified );
      }
     
      pw.println( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" );
     
      pw.println( "<rss version=\"2.0\" xmlns:vuze=\"http://www.vuze.com\">" );
     
      pw.println( "<channel>" );
     
      pw.println( "<title>" + escape( getDisplayName( cat )) + "</title>" );
     
      Collections.sort(
          downloads,
        new Comparator<Download>()
        {
          public int
          compare(
            Download d1,
            Download d2)
          {
            long  added1 = getAddedTime( d1 )/1000;
            long  added2 = getAddedTime( d2 )/1000;
   
            return((int)(added2 - added1 ));
          }
        });
               
             
      pw.println"<pubDate>" + TimeFormatter.getHTTPDate( last_modified ) + "</pubDate>" );
   
      for (int i=0;i<downloads.size();i++){
       
        Download download = downloads.get( i );
       
        DownloadManager  core_download = PluginCoreUtils.unwrap( download );
       
        Torrent torrent = download.getTorrent();
       
        byte[] hash = torrent.getHash();
       
        String  hash_str = Base32.encode( hash );
       
        pw.println( "<item>" );
       
        pw.println( "<title>" + escape( download.getName()) + "</title>" );
       
        pw.println( "<guid>" + hash_str + "</guid>" );
       
        String magnet_url = UrlUtils.getMagnetURI( hash );

        pw.println( "<link>" + magnet_url + "</link>" );
       
        long added = core_download.getDownloadState().getLongParameter(DownloadManagerState.PARAM_DOWNLOAD_ADDED_TIME);
       
        pw.println"<pubDate>" + TimeFormatter.getHTTPDate( added ) + "</pubDate>" );
       
        pw.println"<vuze:size>" + torrent.getSize()+ "</vuze:size>" );
        pw.println"<vuze:assethash>" + hash_str + "</vuze:assethash>" );
                       
        pw.println( "<vuze:downloadurl>" + magnet_url + "</vuze:downloadurl>" );
   
        DownloadScrapeResult scrape = download.getLastScrapeResult();
View Full Code Here

  {
    try{

      TRHostTorrent  host_torrent = ((TrackerTorrentImpl)tracker_torrent).getHostTorrent();

      TOTorrent  torrent = host_torrent.getTorrent();

      // make a copy of the torrent

      TOTorrent  torrent_to_send = TOTorrentFactory.deserialiseFromMap(torrent.serialiseToMap());

      // remove any non-standard stuff (e.g. resume data)

      torrent_to_send.removeAdditionalProperties();

      if ( !TorrentUtils.isDecentralised( torrent_to_send )){

        URL[][]  url_sets = TRTrackerUtils.getAnnounceURLs();

          // if tracker ip not set then assume they know what they're doing

        if ( host_torrent.getStatus() != TRHostTorrent.TS_PUBLISHED && url_sets.length > 0 ){

            // if the user has disabled the mangling of urls when hosting then don't do it here
            // either

          if ( COConfigurationManager.getBooleanParameter("Tracker Host Add Our Announce URLs")){

            String protocol = torrent_to_send.getAnnounceURL().getProtocol();

            for (int i=0;i<url_sets.length;i++){

              URL[]  urls = url_sets[i];

              if ( urls[0].getProtocol().equalsIgnoreCase( protocol )){

                torrent_to_send.setAnnounceURL( urls[0] );

                torrent_to_send.getAnnounceURLGroup().setAnnounceURLSets( new TOTorrentAnnounceURLSet[0]);

                for (int j=1;j<urls.length;j++){

                  TorrentUtils.announceGroupsInsertLast( torrent_to_send, new URL[]{ urls[j] });
                }

                break;
              }
            }
          }
        }
      }

      baos.write( BEncoder.encode( torrent_to_send.serialiseToMap()));

      setContentType( "application/x-bittorrent" );

    }catch( TOTorrentException e ){
View Full Code Here

      channel_id = channel_id_next++;
    }
       
    TOTorrentFile  tf = core_file.getTorrentFile();
   
    TOTorrent   torrent = tf.getTorrent();
   
    TOTorrentFile[]  tfs = torrent.getFiles();

    rtas  = new long[torrent.getNumberOfPieces()];
   
    core_download.addPeerListener( this );
     
    for (int i=0;i<core_file.getIndex();i++){
       
View Full Code Here

   
    for (int i=0;i<managers.size();i++){
     
      DownloadManager  dm = (DownloadManager)managers.get(i);
     
      TOTorrent t = dm.getTorrent();
     
      if ( t != null ){
       
        try{
          if ( Arrays.equals( hash, t.getHash())){
           
            return( t );
          }
        }catch( TOTorrentException e ){
         
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.core3.torrent.TOTorrent

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.