Package org.gudy.azureus2.core3.util

Examples of org.gudy.azureus2.core3.util.TimeLimitedTask


  }

  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


    out.println("Torrent Filename: " + dm.getTorrentFileName());
    out.println("Saving to: " + dm.getSaveLocation());
    out.println("Created By: " + dm.getTorrentCreatedBy());
    out.println("Comment: " + dm.getTorrentComment());
    out.println("- Tracker Info -");
    TRTrackerAnnouncer trackerclient = dm.getTrackerClient();
    if (trackerclient != null) {
      out.println("URL: " + trackerclient.getTrackerURL());
      String timestr;
      try {
        int time = trackerclient.getTimeUntilNextUpdate();
        if (time < 0) {
          timestr = MessageText.getString("GeneralView.label.updatein.querying");
        } else {
          int minutes = time / 60;
          int seconds = time % 60;
          String strSeconds = "" + seconds;
          if (seconds < 10) {
            strSeconds = "0" + seconds; //$NON-NLS-1$
          }
          timestr = minutes + ":" + strSeconds;
        }
      } catch (Exception e) {
        timestr = "unknown";
      }
      out.println("Time till next Update: " + timestr);
      out.println("Status: " + trackerclient.getStatusString());
    } else
      out.println("  Not available");
   
    out.println("- Files Info -");
    DiskManagerFileInfo files[] = dm.getDiskManagerFileInfo();
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

  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

    }
   
    final trustDialog[]  dialog = new trustDialog[1];
   
    try{
      Utils.execSWTThread(new AERunnable() {
            public void
            runSupport()
            {
              dialog[0] = new trustDialog( display, resource, cert );
            }
View Full Code Here

      return;
    }
   
    try{
      display.asyncExec(
          new AERunnable()
          {
            public void
            runSupport()
            {
               new createDialog( display );
View Full Code Here

    if (logAlert.details != null) {
      text += "\n<A HREF=\"details\">" + MessageText.getString("v3.MainWindow.button.viewdetails") + "</A>";
    }

    Utils.execSWTThread(new AERunnable() {
      public void runSupport() {
        openWindow();
      }
    });
  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.eclipse.ui.IStartup#earlyStartup()
   */
  public void earlyStartup() {
    final Display display = Display.getDefault();
    display.syncExec(new AERunnable() {
      public void runSupport() {
        hookApplicationMenu(display);
      }
    });
  }
View Full Code Here

        InsertMenuItemTextWithCFString(menu, 0, (short) 8,
            kMenuItemAttrSeparator, 0);
      }

      // schedule disposal of callback object
      display.disposeExec(new AERunnable() {
        public void runSupport() {
          try {
            mCallback_dispose.invoke(commandCallback, new Object[] {});
          } catch (Throwable e) {
          }
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.core3.util.TimeLimitedTask

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.