Package org.gudy.azureus2.core3.tracker.host

Examples of org.gudy.azureus2.core3.tracker.host.TRHostTorrent


  }

  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


  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 );
         
          if ( existing == null ){
           
            host.publishTorrent(torrent);
          }else{
            try{
              existing.remove();
             
            }catch( Throwable e ){
View Full Code Here

    TOTorrent torrent = dm.getTorrent();
        if (torrent != null) {
          try {
          TRHost  host = ci.azureus_core.getTrackerHost();
         
          TRHostTorrent  existing = host.getHostTorrent( torrent );
         
          if ( existing == null ){
           
            host.publishTorrent(torrent);
          }else{
            try{
              existing.remove();
             
            }catch( Throwable e ){
             
              e.printStackTrace();
            }
View Full Code Here

    }
  }

  // @see com.aelitis.azureus.ui.common.table.TableSelectionListener#defaultSelected(com.aelitis.azureus.ui.common.table.TableRowCore[])
  public void defaultSelected(TableRowCore[] rows, int stateMask) {
    final TRHostTorrent torrent = (TRHostTorrent) tv.getFirstSelectedDataSource();
    if (torrent == null)
      return;
    CoreWaiterSWT.waitForCoreRunning(new AzureusCoreRunningListener() {
   
      public void azureusCoreRunning(AzureusCore core) {
        DownloadManager dm = core.getGlobalManager().getDownloadManager(
            torrent.getTorrent());
        if (dm != null) {
          UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
          if (uiFunctions != null) {
            uiFunctions.openView(UIFunctions.VIEW_DM_DETAILS, dm);
          }
View Full Code Here

      boolean  stop_ok    = true;
      boolean  remove_ok  = true;
     
      for (int i = 0; i < hostTorrents.length; i++) {
       
        TRHostTorrent  host_torrent = (TRHostTorrent)hostTorrents[i];
       
        int  status = host_torrent.getStatus();
       
        if ( status != TRHostTorrent.TS_STOPPED ){
         
          start_ok  = false;
         
View Full Code Here

     
      if (row == null){
        continue;
      }
     
      TRHostTorrent  host_torrent = (TRHostTorrent)rows[x].getDataSource(true);
     
      if (host_torrent == null){
        continue;
      }
     
      long  uploaded  = host_torrent.getTotalUploaded();
      long  downloaded  = host_torrent.getTotalDownloaded();
      long  left    = host_torrent.getTotalLeft();

      int    seed_count  = host_torrent.getSeedCount();

      host_torrent.setData("GUI_PeerCount", new Long(host_torrent.getLeecherCount()));
      host_torrent.setData("GUI_SeedCount", new Long(seed_count));
      host_torrent.setData("GUI_BadNATCount", new Long(host_torrent.getBadNATCount()));
      host_torrent.setData("GUI_Uploaded", new Long(uploaded));
      host_torrent.setData("GUI_Downloaded", new Long(downloaded));
      host_torrent.setData("GUI_Left", new Long(left));

      if ( seed_count != 0 ){
        Color fg = row.getForeground();
       
        if (fg != null && fg.equals(Colors.blues[Colors.BLUES_MIDDARK])) {
View Full Code Here

    boolean start = false, stop = false, remove = false;
    Object[] hostTorrents = tv.getSelectedDataSources().toArray();
    if (hostTorrents.length > 0) {
      remove = true;
      for (int i = 0; i < hostTorrents.length; i++) {
        TRHostTorrent  host_torrent = (TRHostTorrent)hostTorrents[i];
       
        int  status = host_torrent.getStatus();
       
        if ( status == TRHostTorrent.TS_STOPPED ){         
          start  = true;         
        }
       
View Full Code Here

  }
 
  private void stopSelectedTorrents() {
    tv.runForSelectedRows(new TableGroupRowRunner() {
      public void run(TableRowCore row) {
        TRHostTorrent  torrent = (TRHostTorrent)row.getDataSource(true);
        if (torrent.getStatus() == TRHostTorrent.TS_STARTED)
          torrent.stop();
      }
    });
  }
View Full Code Here

  }
 
  private void startSelectedTorrents() {
    tv.runForSelectedRows(new TableGroupRowRunner() {
      public void run(TableRowCore row) {
        TRHostTorrent  torrent = (TRHostTorrent)row.getDataSource(true);
        if (torrent.getStatus() == TRHostTorrent.TS_STOPPED)
          torrent.start();
      }
    });
  }
View Full Code Here

  }
 
  private void removeSelectedTorrents() {
    tv.runForSelectedRows(new TableGroupRowRunner() {
      public void run(TableRowCore row) {
        TRHostTorrent  torrent = (TRHostTorrent)row.getDataSource(true);
        try{
          torrent.remove();
         
        }catch( TRHostTorrentRemovalVetoException f ){
         
          Logger.log(new LogAlert(torrent, false,
              "{globalmanager.download.remove.veto}", f));
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.core3.tracker.host.TRHostTorrent

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.