Package org.gudy.azureus2.core3.tracker.client

Examples of org.gudy.azureus2.core3.tracker.client.TRTrackerScraperResponse


    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

          return "";
        return "(max " + DisplayFormatters.formatByteCountToKiBEtcPerSec(uploadSpeed) + ")";
       
      case 'S':
      case 'P':
        TRTrackerScraperResponse hd = dm.getTrackerScrapeResponse();
        if (hd == null || !hd.isValid())
          return "?";
        else
        {
          if( variable == 'S' )
            return Integer.toString(hd.getSeeds());
          else
            return Integer.toString(hd.getPeers());
        }
      default:
        return "??" + variable + "??";
    }
  }
View Full Code Here

    }
   
   
    setTime(manager.getStats().getElapsedTime(), remaining );
           
    TRTrackerScraperResponse hd = manager.getTrackerScrapeResponse();
    String seeds_str = manager.getNbSeeds() +" "+ MessageText.getString("GeneralView.label.connected");
    String peers_str = manager.getNbPeers() +" "+ MessageText.getString("GeneralView.label.connected");
    String completed;
    if(hd != null && hd.isValid()) {
      seeds_str += " ( " + hd.getSeeds() +" "+ MessageText.getString("GeneralView.label.in_swarm") + " )";
      peers_str += " ( " + hd.getPeers() +" "+ MessageText.getString("GeneralView.label.in_swarm") + " )";
      completed = hd.getCompleted() > -1 ? Integer.toString(hd.getCompleted()) : "?";

    } else {
      completed = "?";
    }
   
View Full Code Here

       
        active_url = announcer.getTrackerURL();
       
      }else{
       
        TRTrackerScraperResponse scrape = download_manager.getTrackerScrapeResponse();
       
        if ( scrape != null ){
         
          active_url = scrape.getURL();
        }
      }
     
      if ( active_url == null ){
       
View Full Code Here

      update_state = ((SystemTime.getCurrentTime() / 1000
          - trackerClient.getLastUpdateTime() >= TRTrackerAnnouncer.REFRESH_MINIMUM_SECS));

    } else {
      TRTrackerScraperResponse sr = manager.getTrackerScrapeResponse();
     
      if ( sr == null ){
       
        update_state = true;
       
      }else{
       
        update_state = ((SystemTime.getCurrentTime()
            - sr.getScrapeStartTime() >= TRTrackerScraper.REFRESH_MINIMUM_SECS * 1000));
      }
    }

    if (updateButton.getEnabled() != update_state) {

View Full Code Here

      num_wanted = WANT_LIMIT;
    }

    int current_connection_count = PeerIdentityManager.getIdentityCount( _hash );

    final TRTrackerScraperResponse tsr = adapter.getTrackerScrapeResponse();

    if( tsr != null && tsr.isValid() ) {  //we've got valid scrape info
      final int num_seeds = tsr.getSeeds();  
      final int num_peers = tsr.getPeers();

      final int swarm_size;

      if( seeding_mode ) {
        //Only use peer count when seeding, as other seeds are unconnectable.
View Full Code Here

    if ( force ){
     
      tracker_checker.syncUpdate( torrent, target_url );
    }
   
    TRTrackerScraperResponse  res = tracker_checker.getHashData( torrent, target_url );
   
    // System.out.println( "scrape: " + torrent + " -> " + (res==null?"null":""+res.getSeeds()));
   
    return( res );
  }
View Full Code Here

    if ( torrent == null ){
     
      return null;
    }

    TRTrackerScraperResponse  res = tracker_checker.peekHashData( torrent, target_url );
       
    return( res );
  }
View Full Code Here

 
  public TRTrackerScraperResponse
  scrape(
    TRTrackerAnnouncer  tracker_client )
  {
    TRTrackerScraperResponse  res = tracker_checker.getHashData( tracker_client );
   
    // System.out.println( "scrape: " + tracker_client + " -> " + (res==null?"null":""+res.getSeeds()));
   
    return( res );
  }
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.core3.tracker.client.TRTrackerScraperResponse

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.