Package org.gudy.azureus2.core3.torrent

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


  {
    super("publish", null, "Publishing");
  }

  protected boolean performCommand(ConsoleInput ci, DownloadManager dm, List args) {
    TOTorrent torrent = dm.getTorrent();
        if (torrent != null) {
          try {
          TRHost  host = ci.azureus_core.getTrackerHost();
         
          TRHostTorrent  existing = host.getHostTorrent( torrent );
View Full Code Here


            StringBuffer sb = new StringBuffer();
            Object[] selectedDataSources = tv.getSelectedDataSources(true);
            for (Object ds : selectedDataSources) {
              if (ds instanceof DownloadManager) {
                DownloadManager dm = (DownloadManager) ds;
                TOTorrent torrent = dm.getTorrent();
                if (torrent != null) {
                  try {
                    sb.append(torrent.getHashWrapper().toBase32String());
                    sb.append('\n');
                  } catch (TOTorrentException e) {
                  }
                }
              } else if (ds instanceof DiskManagerFileInfo) {
                DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) ds;
                DownloadManager dm = fileInfo.getDownloadManager();
                TOTorrent torrent = dm.getTorrent();
                if (torrent != null) {
                  try {
                    sb.append(torrent.getHashWrapper().toBase32String());
                    sb.append(';');
                    sb.append(fileInfo.getIndex());
                    sb.append('\n');
                    onlyDMs = false;
                  } catch (TOTorrentException e) {
View Full Code Here

    String  error_title;
    String  error_detail;
   
    try{
   
      TOTorrent  torrent;
     
      try{
       
        torrent = TOTorrentFactory.deserialiseFromBEncodedFile( input_file );
 
        try{
         
          torrent.serialiseToXMLFile( output_file );
         
          return( true );
               
        }catch( TOTorrentException e ){
       
View Full Code Here

  }

  private TorrentInfo addTorrent(String sFileName,
      final String sOriginatingLocation) {
    TorrentInfo info = null;
    TOTorrent torrent = null;
    File torrentFile;
    boolean bDeleteFileOnCancel = false;

    // Make a copy if user wants that.  We'll delete it when we cancel, if we
    // actually made a copy.
    try {
      if (sFileName.startsWith("file://localhost/")) {
        sFileName = UrlUtils.decode(sFileName.substring(16));
      }

      final File fOriginal = new File(sFileName);

      if (!fOriginal.isFile() || !fOriginal.exists()) {
        Utils.execSWTThread(new AERunnable() {
          public void runSupport() {
            if (shell == null)
              new MessageSlideShell(Display.getCurrent(), SWT.ICON_ERROR,
                  "OpenTorrentWindow.mb.openError", fOriginal.toString(), new String[] {
                    UrlUtils.decode(sOriginatingLocation),
                    "Not a File"
                  }, -1 );
            else {
              MessageBoxShell mb = new MessageBoxShell(SWT.OK,
                  "OpenTorrentWindow.mb.openError", new String[] {
                    sOriginatingLocation,
                    "Not a File"
                  });
              mb.open(null);
            }
          }
        });
        return null;
      }

      if (fOriginal.length() > 20*1024*1024) {
        Utils.execSWTThread(new AERunnable() {
          public void runSupport() {
            if (shell == null)
              new MessageSlideShell(Display.getCurrent(), SWT.ICON_ERROR,
                  "OpenTorrentWindow.mb.openError", fOriginal.toString(), new String[] {
                    UrlUtils.decode(sOriginatingLocation),
                    "Too large to be a torrent"
                  }, -1 );
            else {
              MessageBoxShell mb = new MessageBoxShell(SWT.OK,
                  "OpenTorrentWindow.mb.openError", new String[] {
                    sOriginatingLocation,
                    "Too large to be a torrent"
                  });
              mb.open(null);
            }
          }
        });
        return null;
      }

      torrentFile = TorrentUtils.copyTorrentFileToSaveDir(fOriginal, true);
      bDeleteFileOnCancel = !fOriginal.equals(torrentFile);
      // TODO if the files are still equal, and it isn't in the save
      //       dir, we should copy it to a temp file in case something
      //       re-writes it.  No need to copy a torrent coming from the
      //       downloader though..
    } catch (IOException e1) {
      // Use torrent in wherever it is and hope for the best
      // XXX Should error instead?
      torrentFile = new File(sFileName);
    }

    VuzeFileHandler vfh = VuzeFileHandler.getSingleton();
   
    VuzeFile vf = vfh.loadVuzeFile( torrentFile );
   
    if ( vf != null ){
     
        vfh.handleFiles( new VuzeFile[]{ vf }, VuzeFileComponent.COMP_TYPE_NONE );

        return null;
    }
   
    // Do a quick check to see if it's a torrent
    if (!TorrentUtil.isFileTorrent(torrentFile, shellForChildren,
        torrentFile.getName())) {
      if (bDeleteFileOnCancel) {
        torrentFile.delete();
      }
      return null;
    }

    // Load up the torrent, see it it's real
    try {
      torrent = TorrentUtils.readFromFile(torrentFile, false);
    } catch (final TOTorrentException e) {
     
      Utils.execSWTThread(new AERunnable() {
        public void runSupport() {
          if (shell == null)
            new MessageSlideShell(Display.getCurrent(), SWT.ICON_ERROR,
                "OpenTorrentWindow.mb.openError", Debug.getStackTrace(e),
                new String[] {
                  sOriginatingLocation,
                  e.getMessage()
                }, -1 );
          else {
            MessageBoxShell mb = new MessageBoxShell(SWT.OK,
                "OpenTorrentWindow.mb.openError", new String[] {
                  sOriginatingLocation,
                  e.getMessage()
                });
            mb.open(null);
          }
        }
      });

      if (bDeleteFileOnCancel)
        torrentFile.delete();

      return null;
    }

    String sExistingName = null;
    try {
      HashWrapper hash = torrent.getHashWrapper();
      if (hash != null) {
        for (int i = 0; i < torrentList.size(); i++) {
          try {
            TorrentInfo existing = (TorrentInfo) torrentList.get(i);
            if (existing.torrent.getHashWrapper().equals(hash)) {
View Full Code Here

        _shareRatio,
        swarm_completion,
        distributedCopies
    );
     
    TOTorrent  torrent = manager.getTorrent();
   
    String creation_date = DisplayFormatters.formatDate(manager.getTorrentCreationDate()*1000);
    byte[] created_by = torrent == null ? null : torrent.getCreatedBy();
    if (created_by != null) {
      try {
        creation_date = MessageText.getString("GeneralView.torrent_created_on_and_by", new String[] {
          creation_date, new String(created_by, Constants.DEFAULT_ENCODING)
        });
      }
      catch (java.io.UnsupportedEncodingException e) {/* forget it */}
    }
   
    setInfos(
      manager.getDisplayName(),
    DisplayFormatters.formatByteCountToKiBEtc(manager.getSize()),
    DisplayFormatters.formatDownloadStatus(manager),
      manager.getSaveLocation().toString(),
      TorrentUtils.nicePrintTorrentHash(torrent),
      piecesDoneAndSum,
      manager.getPieceLength(),
      manager.getTorrentComment(),
      creation_date,
      manager.getDownloadState().getUserComment(),
      MessageText.getString("GeneralView."+(torrent != null && torrent.getPrivate()?"yes":"no"))
      );
   
   
    //A special layout, for OS X and Linux, on which for some unknown reason
    //the initial layout fails.
View Full Code Here

      {
        Map<String,List<DownloadManager>>  same_map = new HashMap<String, List<DownloadManager>>();
       
        for ( DownloadManager dm: dms ){
         
          TOTorrent torrent = dm.getTorrent();
         
          if ( torrent == null ){
           
            continue;
          }
         
          List<List<String>> group = TorrentUtils.announceGroupsToList(torrent);
         
          String str = "";
         
          for ( List<String> l: group ){
            str += "[[";
           
            for ( String s:l ){
              str += s + ", ";
            }
          }
         
          List<DownloadManager> dl = same_map.get( str );
         
          if ( dl == null ){
           
            dl = new ArrayList<DownloadManager>();
           
            same_map.put( str, dl );
          }
         
          dl.add(dm );
        }
       
        for ( final List<DownloadManager> set: same_map.values()){
                   
          TOTorrent torrent = set.get(0).getTorrent();

          List<List<String>> group = TorrentUtils.announceGroupsToList(torrent);

          new MultiTrackerEditor(
            null,
            group,
            new TrackerEditorListener()
            {
              public void
              trackersChanged(
                String         str,
                String         str2,
                List<List<String>>   group )
              {
                for ( DownloadManager dm: set ){
                 
                  TOTorrent torrent = dm.getTorrent();
                 
                  TorrentUtils.listToAnnounceGroups(group, torrent);
   
                  try{
                    TorrentUtils.writeToFile(torrent);
                   
                  }catch (Throwable e){
                   
                    Debug.printStackTrace(e);
                  }
   
                  if ( dm.getTrackerClient() != null){
                   
                    dm.getTrackerClient().resetTrackerUrl(true);
                  }
                }
              }
            }, true);
        }
      }
    });
   
    itemEditTracker.setEnabled(hasSelection);

      // edit webseeds
   
    final MenuItem itemEditWebSeeds = new MenuItem(menuTracker, SWT.PUSH);
    Messages.setLanguageText(itemEditWebSeeds, "MyTorrentsView.menu.editWebSeeds");
    itemEditWebSeeds.addListener(SWT.Selection, new DMTask(dms) {
      public void
      run(
        final DownloadManager[] dms )
      {
        final TOTorrent torrent = dms[0].getTorrent();
       
        if ( torrent == null ){
         
          return;
        }
       
        List getright = getURLList( torrent, "url-list" );
        List webseeds = getURLList( torrent, "httpseeds" );
       
        Map ws = new HashMap();
               
        ws.put( "getright", getright );               
        ws.put( "webseeds", webseeds );
       
        ws = BDecoder.decodeStrings( ws );
       
        new WebSeedsEditor(
            null, ws,
            new WebSeedsEditorListener()
            {
              public void
              webSeedsChanged(
                String   oldName,
                String   newName,
                Map   ws )
              {
                try{
                    // String -> byte[]
                 
                  ws = BDecoder.decode( BEncoder.encode( ws ));
                 
                  List  getright =  (List)ws.get( "getright" );
                 
                  if ( getright == null || getright.size() == 0 ){
                   
                    torrent.removeAdditionalProperty( "url-list" );
                   
                  }else{
                   
                    torrent.setAdditionalListProperty( "url-list", getright );
                  }
                 
                  List  webseeds =  (List)ws.get( "webseeds" );
                 
                  if ( webseeds == null || webseeds.size() == 0 ){
                   
                    torrent.removeAdditionalProperty( "httpseeds" );
                   
                  }else{
                   
                    torrent.setAdditionalListProperty( "httpseeds", webseeds );
                  }
     
                  PluginInterface pi = AzureusCoreFactory.getSingleton().getPluginManager().getPluginInterfaceByClass(ExternalSeedPlugin.class);
                 
                  if ( pi != null ){
                   
                    ExternalSeedPlugin ext_seed_plugin = (ExternalSeedPlugin)pi.getPlugin();
                   
                    ext_seed_plugin.downloadChanged( PluginCoreUtils.wrap( dms[0] ));
                  }
           
                }catch (Throwable e){
           
                  Debug.printStackTrace( e );
                }
              }
            },
            true );

      }
     
      protected List
      getURLList(
        TOTorrent  torrent,
        String    key )
      {
        Object obj = torrent.getAdditionalProperty( key );
       
        if ( obj instanceof byte[] ){
         
                  List l = new ArrayList();
                 
              l.add(obj);
             
              return( l );
             
        }else if ( obj instanceof List ){
         
          return((List)obj);
         
        }else{
         
          return( new ArrayList());
        }
      }
    });
   
    itemEditWebSeeds.setEnabled(dms.length==1);

      // manual update
   
    final MenuItem itemManualUpdate = new MenuItem(menuTracker, SWT.PUSH);
    Messages.setLanguageText(itemManualUpdate, "GeneralView.label.trackerurlupdate"); //$NON-NLS-1$
    //itemManualUpdate.setImage(ImageRepository.getImage("edit_trackers"));
    itemManualUpdate.addListener(SWT.Selection, new DMTask(dms) {
      public void run(DownloadManager dm) {
        dm.requestTrackerAnnounce(false);
      }
    });
    itemManualUpdate.setEnabled(manualUpdate);

    boolean scrape_enabled = COConfigurationManager.getBooleanParameter("Tracker Client Scrape Enable");

    boolean scrape_stopped = COConfigurationManager.getBooleanParameter("Tracker Client Scrape Stopped Enable");

    boolean manualScrape = (!scrape_enabled) || ((!scrape_stopped) && allStopped);

    final MenuItem itemManualScrape = new MenuItem(menuTracker, SWT.PUSH);
    Messages.setLanguageText(itemManualScrape, "GeneralView.label.trackerscrapeupdate");
    //itemManualUpdate.setImage(ImageRepository.getImage("edit_trackers"));
    itemManualScrape.addListener(SWT.Selection, new DMTask(dms, true, true ) {
      public void run(DownloadManager dm) {
        dm.requestTrackerScrape(true);
      }
    });
    itemManualScrape.setEnabled(manualScrape);

    // advanced > files

    final MenuItem itemFiles = new MenuItem(menuAdvanced, SWT.CASCADE);
    Messages.setLanguageText(itemFiles, "ConfigView.section.files");

    final Menu menuFiles = new Menu(composite.getShell(), SWT.DROP_DOWN);
    itemFiles.setMenu(menuFiles);

    final MenuItem itemFileMoveData = new MenuItem(menuFiles, SWT.PUSH);
    Messages.setLanguageText(itemFileMoveData, "MyTorrentsView.menu.movedata");
    itemFileMoveData.addListener(SWT.Selection, new DMTask(dms) {
      public void run(DownloadManager[] dms) {
        if (dms != null && dms.length > 0) {

          DirectoryDialog dd = new DirectoryDialog(composite.getShell());

          dd.setFilterPath(TorrentOpener.getFilterPathData());

          dd.setText(MessageText.getString("MyTorrentsView.menu.movedata.dialog"));

          String path = dd.open();

          if (path != null) {

            TorrentOpener.setFilterPathData(path);

            File target = new File(path);

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

              try {
                dms[i].moveDataFiles(target);

              }
              catch (Throwable e) {

                Logger.log(new LogAlert(dms[i], LogAlert.REPEATABLE,
                    "Download data move operation failed", e));
              }
            }
          }
        }
      }
    });
    itemFileMoveData.setEnabled(fileMove);

    final MenuItem itemFileMoveTorrent = new MenuItem(menuFiles, SWT.PUSH);
    Messages.setLanguageText(itemFileMoveTorrent, "MyTorrentsView.menu.movetorrent");
    itemFileMoveTorrent.addListener(SWT.Selection, new DMTask(dms) {
      public void run(DownloadManager[] dms) {
        if (dms != null && dms.length > 0) {

          DirectoryDialog dd = new DirectoryDialog(composite.getShell());
          String filter_path = TorrentOpener.getFilterPathTorrent();
         
          // If we don't have a decent path, default to the path of the first
          // torrent.
          if (filter_path == null || filter_path.trim().length() == 0) {
            filter_path = new File(dms[0].getTorrentFileName()).getParent();
          }
         
          dd.setFilterPath(filter_path);

          dd.setText(MessageText.getString("MyTorrentsView.menu.movedata.dialog"));

          String path = dd.open();

          if (path != null) {

            File target = new File(path);

            TorrentOpener.setFilterPathTorrent(target.toString());

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

              try {
                dms[i].moveTorrentFile(target);

              }
              catch (Throwable e) {

                Logger.log(new LogAlert(dms[i], LogAlert.REPEATABLE,
                    "Download torrent move operation failed", e));
              }
            }
          }
        }
      }
    });
    itemFileMoveTorrent.setEnabled(fileMove);
   
    final MenuItem itemCheckFilesExist = new MenuItem(menuFiles, SWT.PUSH);
    Messages.setLanguageText(itemCheckFilesExist, "MyTorrentsView.menu.checkfilesexist");
    itemCheckFilesExist.addListener(SWT.Selection, new DMTask(dms) {
      public void run(DownloadManager dm) {
        dm.filesExist( true );
      }
    });

    final MenuItem itemFileRescan = new MenuItem(menuFiles, SWT.CHECK);
    Messages.setLanguageText(itemFileRescan, "MyTorrentsView.menu.rescanfile");
    itemFileRescan.addListener(SWT.Selection, new DMTask(dms) {
      public void run(DownloadManager dm) {
        dm.getDownloadState().setFlag(DownloadManagerState.FLAG_SCAN_INCOMPLETE_PIECES,
            itemFileRescan.getSelection());
      }
    });
    itemFileRescan.setSelection(allScanSelected);
    itemFileRescan.setEnabled(fileRescan);

      // clear allocation
   
    MenuItem itemFileClearAlloc = new MenuItem(menuFiles, SWT.PUSH);
    Messages.setLanguageText(itemFileClearAlloc, "MyTorrentsView.menu.clear_alloc_data");
    itemFileClearAlloc.addListener(SWT.Selection, new DMTask(dms) {
      public void run(DownloadManager dm) {
        dm.setDataAlreadyAllocated( false );
      }
    });
   
    itemFileClearAlloc.setEnabled(allStopped);
   
      // clear resume
   
    MenuItem itemFileClearResume = new MenuItem(menuFiles, SWT.PUSH);
    Messages.setLanguageText(itemFileClearResume, "MyTorrentsView.menu.clear_resume_data");
    itemFileClearResume.addListener(SWT.Selection, new DMTask(dms) {
      public void run(DownloadManager dm) {
        dm.getDownloadState().clearResumeData();
      }
    });
    itemFileClearResume.setEnabled(allStopped);

    // Advanced - > Rename
    final MenuItem itemRename = new MenuItem(menuAdvanced, SWT.DROP_DOWN);
    Messages.setLanguageText(itemRename, "MyTorrentsView.menu.rename");
    itemRename.setEnabled(hasSelection);
    itemRename.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event event) {
        for (DownloadManager dm : dms) {
          AdvRenameWindow window = new AdvRenameWindow();
          window.open(dm);
        }
      }
    });

    // === advanced > export ===
    // =========================

    if (userMode > 0) {
      final MenuItem itemExport = new MenuItem(menuAdvanced, SWT.CASCADE);
      Messages.setLanguageText(itemExport, "MyTorrentsView.menu.exportmenu"); //$NON-NLS-1$
      Utils.setMenuItemImage(itemExport, "export");
      itemExport.setEnabled(hasSelection);

      final Menu menuExport = new Menu(composite.getShell(), SWT.DROP_DOWN);
      itemExport.setMenu(menuExport);

      // Advanced > Export > Export XML
      final MenuItem itemExportXML = new MenuItem(menuExport, SWT.PUSH);
      Messages.setLanguageText(itemExportXML, "MyTorrentsView.menu.export");
      itemExportXML.addListener(SWT.Selection, new DMTask(dms) {
        public void run(DownloadManager[] dms) {
          DownloadManager dm = dms[0]; // First only.
          if (dm != null) new ExportTorrentWizard(itemExportXML.getDisplay(), dm);
        }
      });

      // Advanced > Export > Export Torrent
      final MenuItem itemExportTorrent = new MenuItem(menuExport, SWT.PUSH);
      Messages.setLanguageText(itemExportTorrent, "MyTorrentsView.menu.exporttorrent");
      itemExportTorrent.addListener(SWT.Selection, new DMTask(dms) {
        public void run(DownloadManager[] dms) {
          // FileDialog for single download
          // DirectoryDialog for multiple.
          File[] destinations = new File[dms.length];
          if (dms.length == 1) {
            FileDialog fd = new FileDialog(composite.getShell(), SWT.SAVE);
            fd.setFileName(dms[0].getTorrentFileName());
            String path = fd.open();
            if (path == null) {return;}
            destinations[0] = new File(path);
          }
          else {
            DirectoryDialog dd = new DirectoryDialog(composite.getShell(), SWT.SAVE);
            String path = dd.open();
            if (path == null) {return;}
            for (int i=0; i<dms.length; i++) {
              destinations[i] = new File(path, new File(dms[i].getTorrentFileName()).getName());
            }
          }
         
          int i=0;
          try {
            for (; i<dms.length; i++) {
              File target = destinations[i];
              if (target.exists()) {
                MessageBox mb = new MessageBox(composite.getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
                mb.setText(MessageText.getString("exportTorrentWizard.process.outputfileexists.title"));
                mb.setMessage(MessageText.getString("exportTorrentWizard.process.outputfileexists.message") + "\n" + destinations[i].getName());

                int result = mb.open();
                if (result == SWT.NO) {return;}

                if (!target.delete()) {
                  throw (new Exception("Failed to delete file"));
                }
              } // end deal with clashing torrent

              // first copy the torrent - DON'T use "writeTorrent" as this amends the
              // "filename" field in the torrent
              TorrentUtils.copyToFile(dms[i].getDownloadState().getTorrent(), target);

              // now remove the non-standard entries
              TOTorrent dest = TOTorrentFactory.deserialiseFromBEncodedFile(target);
              dest.removeAdditionalProperties();
              dest.serialiseToBEncodedFile(target);
            } // end for
          } // end try
          catch (Throwable e) {
            Logger.log(new LogAlert(dms[i], LogAlert.UNREPEATABLE, "Torrent export failed", e));
          }
        } // end run()
      }); // end DMTask
     
      // Advanced > Export > WebSeed URL
      final MenuItem itemWebSeed = new MenuItem(menuExport, SWT.PUSH);
      Messages.setLanguageText(itemWebSeed, "MyTorrentsView.menu.exporthttpseeds");
      itemWebSeed.addListener(SWT.Selection, new DMTask(dms) {
        public void run(DownloadManager[] dms) {
          final String  NL = "\r\n";
          String  data = "";
         
          boolean http_enable = COConfigurationManager.getBooleanParameter( "HTTP.Data.Listen.Port.Enable" );
         
          String  port;
         
          if ( http_enable ){
           
            int  p = COConfigurationManager.getIntParameter( "HTTP.Data.Listen.Port" );
            int o = COConfigurationManager.getIntParameter( "HTTP.Data.Listen.Port.Override" );
             
            if ( o == 0 ){
             
              port = String.valueOf( p );
             
            }else{
             
              port = String.valueOf( o );
            }
          }else{

            data = "You need to enable the HTTP port or modify the URL(s) appropriately" + NL + NL;
           
            port = "<port>";
          }
           
          String  ip = COConfigurationManager.getStringParameter( "Tracker IP", "" );
         
          if ( ip.length() == 0 ){
           
            data += "You might need to modify the host address in the URL(s)" + NL + NL;
           
            try{
           
              InetAddress ia = AzureusCoreFactory.getSingleton().getInstanceManager().getMyInstance().getExternalAddress();
           
              if ( ia != null ){
               
                ip = IPToHostNameResolver.syncResolve( ia.getHostAddress(), 10000 );
              }
            }catch( Throwable e ){
             
            }
           
            if ( ip.length() == 0 ){
             
              ip = "<host>";
            }
          }
         
          String  base = "http://" + UrlUtils.convertIPV6Host(ip) + ":" + port + "/";
         
          for (int i=0;i<dms.length;i++){
           
            DownloadManager dm = dms[i];
           
            if ( dm == null ){
              continue;
            }
           
            TOTorrent torrent = dm.getTorrent();
           
            if ( torrent == null ){
             
              continue;
            }
           
            data += base + "webseed" + NL;
           
            try{
              data += base + "files/" + URLEncoder.encode( new String( torrent.getHash(), "ISO-8859-1"), "ISO-8859-1" ) + "/" + NL + NL;
             
            }catch( Throwable e ){
             
            }
          }
View Full Code Here

        DownloadManager dm = content.getDownloadManager();
 
        if (dm == null) {
          canRun = false;
        } else {
          TOTorrent torrent = dm.getTorrent();
 
          if (torrent == null) {
 
            canRun = false;
 
          } else if (!dm.getAssumedComplete() && torrent.isSimpleTorrent()) {
 
            canRun = false;
  /*
          } else if (PlatformTorrentUtils.useEMP(torrent)
              && PlatformTorrentUtils.embeddedPlayerAvail()
View Full Code Here

    Label label = new Label(gTorrentInfo, SWT.NULL);
    gridData = new GridData();
    label.setLayoutData( gridData );
    label.setText( MessageText.getString( TEXT_PREFIX + "torrent.encoding" ) + ": " );

    TOTorrent  torrent = download_manager.getTorrent();
    BufferedLabel blabel = new BufferedLabel(gTorrentInfo, SWT.NULL);
    gridData = new GridData();
   
    blabel.setLayoutData( gridData );
    blabel.setText(torrent==null?"":LocaleTorrentUtil.getCurrentTorrentEncoding( torrent ));
   
      // trackers
   
    label = new Label(gTorrentInfo, SWT.NULL);
    gridData = new GridData();
    label.setLayoutData( gridData );
    label.setText( MessageText.getString( "MyTrackerView.tracker" ) + ": " );

    String  trackers = "";
   
    if ( torrent != null ){
     
      TOTorrentAnnounceURLGroup group = torrent.getAnnounceURLGroup();
     
      TOTorrentAnnounceURLSet[]  sets = group.getAnnounceURLSets();
     
      List  tracker_list = new ArrayList();
     
      URL  url = torrent.getAnnounceURL();
     
      tracker_list.add( url.getHost() + (url.getPort()==-1?"":(":"+url.getPort())));
       
      for (int i=0;i<sets.length;i++){
                   
        TOTorrentAnnounceURLSet  set = sets[i];
       
        URL[]  urls = set.getAnnounceURLs();
       
        for (int j=0;j<urls.length;j++){
       
          url = urls[j];
         
          String  str = url.getHost() + (url.getPort()==-1?"":(":"+url.getPort()));
         
          if ( !tracker_list.contains(str )){
           
            tracker_list.add(str);
          }
        }
      }
       
      TRTrackerAnnouncer announcer = download_manager.getTrackerClient();
     
      URL  active_url = null;
     
      if ( announcer != null ){
       
        active_url = announcer.getTrackerURL();
       
      }else{
       
        TRTrackerScraperResponse scrape = download_manager.getTrackerScrapeResponse();
       
        if ( scrape != null ){
         
          active_url = scrape.getURL();
        }
      }
     
      if ( active_url == null ){
       
        active_url = torrent.getAnnounceURL();
      }
     
      trackers = active_url.getHost() + (active_url.getPort()==-1?"":(":"+active_url.getPort()));
   
      tracker_list.remove( trackers );
View Full Code Here

    tv.runForSelectedRows(new TableGroupRowRunner() {
      public void run(TableRowCore row) {
       
      TRHostTorrent  tr_torrent = (TRHostTorrent)row.getDataSource(true);
   
    final TOTorrent  torrent = tr_torrent.getTorrent();
   
    DownloadManager dm = core.getGlobalManager().getDownloadManager( torrent );

    if ( dm != null ){
     
View Full Code Here

     
      cell.setText("");
     
    }else{
     
      TOTorrent  torrent = tr_torrent.getTorrent();
     
      if (gm == null) {
        if (AzureusCoreFactory.isCoreRunning()) {
          return;
        }
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.