Package org.gudy.azureus2.core3.download

Examples of org.gudy.azureus2.core3.download.DownloadManager


  }

 
  // @see com.aelitis.azureus.ui.common.table.TableDataSourceChangedListener#tableDataSourceChanged(java.lang.Object)
  public void tableDataSourceChanged(Object newDataSource) {
    DownloadManager old_manager = manager;
    if (newDataSource == null)
      manager = null;
    else if (newDataSource instanceof Object[])
      manager = (DownloadManager)((Object[])newDataSource)[0];
    else
      manager = (DownloadManager)newDataSource;
   
    if (old_manager != null) {
      old_manager.getDownloadState().removeListener(this, DownloadManagerState.AT_FILE_LINKS, DownloadManagerStateAttributeListener.WRITTEN);
    }
    if (manager != null) {
      manager.getDownloadState().addListener(this, DownloadManagerState.AT_FILE_LINKS, DownloadManagerStateAttributeListener.WRITTEN);
    }
View Full Code Here


   
    AZ3Functions.provider az3 = AZ3Functions.getProvider();
   
    if ( az3 != null ){
     
      DownloadManager dm = fileInfo.getDownloadManager();
     
      if ( az3.canPlay(dm, fileInfo.getIndex()) || (stateMask & SWT.CONTROL) > 0 ){
       
        az3.play( dm, fileInfo.getIndex() );
       
View Full Code Here

  private List matchWildcard( List torrents, String filter )
  {
    Pattern pattern = Pattern.compile(wildcardToPattern(filter), Pattern.CASE_INSENSITIVE);
    List list = new ArrayList();
    for (Iterator iter = torrents.iterator(); iter.hasNext();) {
      DownloadManager dm = (DownloadManager) iter.next();
      if( pattern.matcher(dm.getDisplayName()).matches() )
        list.add(dm);
    }
    return list;
  }
View Full Code Here

        String subcommand = (String) args.remove(0);
      if (ci.torrents.isEmpty()) {
        ci.out.println("> Command '" + getCommandName() + "': No torrents in list (Maybe you forgot to 'show torrents' first).");
      } else {
        String name;
        DownloadManager dm;
        try {
          int number = Integer.parseInt(subcommand);
          if ((number > 0) && (number <= ci.torrents.size())) {
            dm = (DownloadManager) ci.torrents.get(number - 1);
            if (dm.getDisplayName() == null)
              name = "?";
            else
              name = dm.getDisplayName();
            performCommandIfAllowed(ci, args, dm, "#" + subcommand, name);
          } else
            ci.out.println("> Command '" + getCommandName() + "': Torrent #" + subcommand + " unknown.");
        } catch (NumberFormatException e) {
          if ("all".equalsIgnoreCase(subcommand)) {
            Iterator torrent = ci.torrents.iterator();
            while (torrent.hasNext()) {
              dm = (DownloadManager) torrent.next();
              if (dm.getDisplayName() == null)
                name = "?";
              else
                name = dm.getDisplayName();
              performCommandIfAllowed(ci, args, dm, subcommand, name);
            }
          } else if ("hash".equalsIgnoreCase(subcommand)) {
            String hash = (String) args.remove(0);
            List torrents = ci.getGlobalManager().getDownloadManagers();
            boolean foundit = false;
            Iterator torrent = torrents.iterator();
            while (torrent.hasNext()) {
              dm = (DownloadManager) torrent.next();
              if (hash.equals(TorrentUtils.nicePrintTorrentHash(dm.getTorrent(), true))) {
                if (dm.getDisplayName() == null)
                  name = "?";
                else
                  name = dm.getDisplayName();
                // FIXME: check user permission here and fix it to take torrent hash instead of subcommand
               
                performCommandIfAllowed(ci, args, dm, hash, name);
                foundit = true;
                break;
View Full Code Here

   * @param filename
   * @param outputDir
   */
  public void downloadTorrent( String filename, String outputDir )
  {
    DownloadManager manager = azureus_core.getGlobalManager().addDownloadManager(filename, outputDir);
    manager.getDownloadState().setAttribute(DownloadManagerState.AT_USER, getUserProfile().getUsername());
  }
View Full Code Here

      int seeding = 0;
      int downloading = 0;
 
      // OMG this must be slow on 10k lists
      for (int i = 0; i < managers.size(); i++) {
        DownloadManager manager = (DownloadManager) managers.get(i);
        int state = manager.getState();
        if (state == DownloadManager.STATE_DOWNLOADING)
          downloading++;
        if (state == DownloadManager.STATE_SEEDING)
          seeding++;
      }
View Full Code Here

        fileAccessModeChanged(
          DiskManagerFileInfo    file,
          int            old_mode,
          int            new_mode )
        {
          DownloadManager dm = file.getDownloadManager();
       
          if (   old_mode == DiskManagerFileInfo.WRITE &&
              new_mode == DiskManagerFileInfo.READ &&
              file.getDownloaded() == file.getLength()){
           
            if( dm == null || !dm.getDownloadState().getFlag( DownloadManagerState.FLAG_LOW_NOISE )){

              activityFinished(false, file.getFile(true).getName(), file.getDiskManager());
            }
          }
       
          /*
          System.out.println(
            "amc:" +
            file.getDownloadManager().getDisplayName() + "/" +
            file.getName() + ":" + old_mode + " -> " + new_mode );
          */
        }
      };
     
    final DownloadManagerDiskListener dm_disk_listener =
      new DownloadManagerDiskListener()
      {
        public void
        diskManagerAdded(
          DiskManager  dm )
        {
          dm.addListener( disk_listener );
        }
       
        public void
        diskManagerRemoved(
          DiskManager  dm )
        {
          dm.removeListener( disk_listener );
        }

      };

      global_manager.addListener(
View Full Code Here

               
                  // be optimistic and share out the bytes between non-seeds
               
                for (int i=0;i<managers.size();i++){
                 
                  DownloadManager  dm = (DownloadManager)managers.get(i);
                 
                  if ( dm.getStats().getDownloadCompleted( false ) == 1000 ){
                   
                    continue;
                  }
                 
                  int  state = dm.getState();
                 
                  if (   state != DownloadManager.STATE_ERROR &&
                      state != DownloadManager.STATE_STOPPING &&
                      state != DownloadManager.STATE_STOPPED ){
                   
View Full Code Here

   
      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>" );
View Full Code Here

 
  protected long
  getAddedTime(
    Download  download )
  {
    DownloadManager  core_download = PluginCoreUtils.unwrap( download );
   
    return( core_download.getDownloadState().getLongParameter(DownloadManagerState.PARAM_DOWNLOAD_ADDED_TIME));
  }
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.core3.download.DownloadManager

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.