Package org.gudy.azureus2.core3.download

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


            new AzureusCoreRunningListener() {
              public void azureusCoreRunning(AzureusCore core) {
                GlobalManager gm = core.getGlobalManager();
                List<?> downloadManagers = gm.getDownloadManagers();
                for (Iterator<?> iter = downloadManagers.iterator(); iter.hasNext();) {
                  DownloadManager dm = (DownloadManager) iter.next();

                  if (!PlatformTorrentUtils.getHasBeenOpened(dm)
                      && dm.getAssumedComplete()) {
                    PlatformTorrentUtils.setHasBeenOpened(dm, true);
                  }
                }
              }
            });
View Full Code Here


          List<?> downloads = gm.getDownloadManagers();

          for (int i = 0; i < downloads.size(); i++) {

            DownloadManager download = (DownloadManager) downloads.get(i);

            if (download.getState() == DownloadManager.STATE_ERROR) {

              if (download.getAssumedComplete()) {

                if (comp_error == null) {

                  comp_error = download.getDisplayName() + ": "
                      + download.getErrorDetails();
                } else {

                  comp_error += "...";
                }
              } else {
                if (incomp_error == null) {

                  incomp_error = download.getDisplayName() + ": "
                      + download.getErrorDetails();
                } else {

                  incomp_error += "...";
                }
              }
            }
          }

          stats.errorCompleteTooltip = comp_error;
          stats.errorInCompleteTooltip = incomp_error;
        }
      }
    };

    gm.addListener(new GlobalManagerAdapter() {
      public void downloadManagerRemoved(DownloadManager dm) {
        downloadManagerRemoved(dm, statsNoLowNoise);
        downloadManagerRemoved(dm, statsWithLowNoise);
      }

      public void downloadManagerRemoved(DownloadManager dm, stats stats) {
        if (!stats.includeLowNoise
            && PlatformTorrentUtils.isAdvancedViewOnly(dm)) {
          return;
        }

        recountUnopened();
        if (dm.getAssumedComplete()) {
          stats.numComplete--;
          Boolean wasDownloadingB = (Boolean) dm.getUserData("wasDownloading");
          if (wasDownloadingB != null && wasDownloadingB.booleanValue()) {
            stats.numDownloading--;
          }
        } else {
          stats.numIncomplete--;
          Boolean wasSeedingB = (Boolean) dm.getUserData("wasSeeding");
          if (wasSeedingB != null && wasSeedingB.booleanValue()) {
            stats.numSeeding--;
          }
        }

        Boolean wasStoppedB = (Boolean) dm.getUserData("wasStopped");
        boolean wasStopped = wasStoppedB == null ? false
            : wasStoppedB.booleanValue();
        if (wasStopped) {
          stats.numStoppedAll--;
          if (!dm.getAssumedComplete()) {
            stats.numStoppedIncomplete--;
          }
        }

        refreshAllLibraries();
        dm.removeListener(dmListener);
      }

      public void downloadManagerAdded(DownloadManager dm) {
        dm.addListener(dmListener, false);
        recountUnopened();

        downloadManagerAdded(dm, statsNoLowNoise);
        downloadManagerAdded(dm, statsWithLowNoise);
        refreshAllLibraries();
      }

      public void downloadManagerAdded(DownloadManager dm, stats stats) {
        if (!stats.includeLowNoise
            && PlatformTorrentUtils.isAdvancedViewOnly(dm)) {
          return;
        }

        if (dm.getAssumedComplete()) {
          stats.numComplete++;
          if (dm.getState() == DownloadManager.STATE_SEEDING) {
            stats.numSeeding++;
          }
        } else {
          stats.numIncomplete++;
          if (dm.getState() == DownloadManager.STATE_DOWNLOADING) {
            dm.setUserData("wasDownloading", Boolean.TRUE);
            stats.numDownloading++;
          } else {
            dm.setUserData("wasDownloading", Boolean.FALSE);
          }
        }
      }
    }, false);
    List<?> downloadManagers = gm.getDownloadManagers();
    for (Iterator<?> iter = downloadManagers.iterator(); iter.hasNext();) {
      DownloadManager dm = (DownloadManager) iter.next();
      boolean lowNoise = PlatformTorrentUtils.isAdvancedViewOnly(dm);
      dm.addListener(dmListener, false);
      int state = dm.getState();
      if (state == DownloadManager.STATE_STOPPED) {
        dm.setUserData("wasStopped", Boolean.TRUE);
        statsWithLowNoise.numStoppedAll++;
        if (!dm.getAssumedComplete()) {
          statsWithLowNoise.numStoppedIncomplete++;
        }
        if (!lowNoise) {
          statsNoLowNoise.numStoppedAll++;
          if (!dm.getAssumedComplete()) {
            statsNoLowNoise.numStoppedIncomplete++;
          }
        }
      } else {
        dm.setUserData("wasStopped", Boolean.FALSE);
      }
      if (dm.getAssumedComplete()) {
        statsWithLowNoise.numComplete++;
        if (!lowNoise) {
          statsNoLowNoise.numComplete++;
        }
        if (state == DownloadManager.STATE_SEEDING) {
          dm.setUserData("wasSeeding", Boolean.TRUE);
          statsWithLowNoise.numSeeding++;
          if (!lowNoise) {
            statsNoLowNoise.numSeeding++;
          }
        } else {
          dm.setUserData("wasSeeding", Boolean.FALSE);
        }
      } else {
        statsWithLowNoise.numIncomplete++;
        if (!lowNoise) {
          statsNoLowNoise.numIncomplete++;
View Full Code Here

            GlobalManager gm = AzureusCoreFactory.getSingleton().getGlobalManager();
            for (int i = 1; i < split.length; i++) {
              String hash = split[i];

              try {
                DownloadManager dm = gm.getDownloadManager(new HashWrapper(
                    Base32.decode(hash)));

                if (dm != null) {
                  TorrentUtil.assignToCategory(new Object[] {
                    dm
View Full Code Here

    }
    GlobalManager gm = AzureusCoreFactory.getSingleton().getGlobalManager();
    List<?> dms = gm.getDownloadManagers();
    statsNoLowNoise.numUnOpened = 0;
    for (Iterator<?> iter = dms.iterator(); iter.hasNext();) {
      DownloadManager dm = (DownloadManager) iter.next();
      if (!PlatformTorrentUtils.getHasBeenOpened(dm) && dm.getAssumedComplete()) {
        statsNoLowNoise.numUnOpened++;
      }
    }
    statsWithLowNoise.numUnOpened = statsNoLowNoise.numUnOpened;
  }
View Full Code Here

        return (org.gudy.azureus2.core3.disk.DiskManagerFileInfo) ds;
      } else if ((ds instanceof ISelectedContent)
          && ((ISelectedContent) ds).getFileIndex() >= 0) {
        ISelectedContent sc = (ISelectedContent) ds;
        int idx = sc.getFileIndex();
        DownloadManager dm = sc.getDownloadManager();
        return dm.getDiskManagerFileInfoSet().getFiles()[idx];
      } else if (ds instanceof TranscodeJob) {
        TranscodeJob tj = (TranscodeJob) ds;
        try {
          return PluginCoreUtils.unwrap(tj.getFile());
        } catch (DownloadException e) {
View Full Code Here

    try {
      if (ds instanceof DownloadManager) {
        return (DownloadManager) ds;
      } else if (ds instanceof VuzeActivitiesEntry) {
        VuzeActivitiesEntry entry = (VuzeActivitiesEntry) ds;
        DownloadManager dm = entry.getDownloadManger();
        if (dm == null) {
          String assetHash = entry.getAssetHash();
          if (assetHash != null && AzureusCoreFactory.isCoreRunning()) {
            GlobalManager gm = AzureusCoreFactory.getSingleton().getGlobalManager();
            dm = gm.getDownloadManager(new HashWrapper(Base32.decode(assetHash)));
View Full Code Here

    }
    if (ds instanceof VuzeActivitiesEntry) {
      TOTorrent torrent = ((VuzeActivitiesEntry) ds).getTorrent();
      if (torrent == null) {
        // getDM will check hash as well
        DownloadManager dm = getDM(ds);
        if (dm != null) {
          torrent = dm.getTorrent();
        }
      }
      return torrent;
    }

    if (ds instanceof TranscodeFile) {
      TranscodeFile tf = (TranscodeFile) ds;
      try {
        DiskManagerFileInfo file = tf.getSourceFile();
        if (file != null) {
          Download download = file.getDownload();
          if (download != null) {
            Torrent torrent = download.getTorrent();
            if (torrent != null) {
              return PluginCoreUtils.unwrap(torrent);
            }
          }
        }
      } catch (Throwable e) {
      }
    }

    if (ds instanceof TranscodeJob) {
      TranscodeJob tj = (TranscodeJob) ds;
      try {
        DiskManagerFileInfo file = tj.getFile();
        if (file != null) {
          Download download = tj.getFile().getDownload();
         
          if (download != null) {
            Torrent torrent = download.getTorrent();
            if (torrent != null) {
              return PluginCoreUtils.unwrap(torrent);
            }
          }
        }
      } catch (DownloadException e) {
      }
    }
   
    if (ds instanceof DeviceOfflineDownload ){
      Torrent torrent = ((DeviceOfflineDownload) ds).getDownload().getTorrent();
      if (torrent != null) {
        return PluginCoreUtils.unwrap(torrent);
      }
    }

    if (ds instanceof ISelectedContent) {
      return ((ISelectedContent)ds).getTorrent();
    }
   
    if (ds instanceof String) {
      String hash = (String) ds;
      try {
        GlobalManager gm = AzureusCoreFactory.getSingleton().getGlobalManager();
        DownloadManager dm = gm.getDownloadManager(new HashWrapper(Base32.decode(hash)));
        if (dm != null) {
          return dm.getTorrent();
        }
      } catch (Exception e) {
        // ignore
      }
    }
View Full Code Here

        try {
          DiskManagerFileInfo file = tj.getFile();
          if (file != null) {
            Download download = tj.getFile().getDownload();
            if (download != null) {
              DownloadManager dm = PluginCoreUtils.unwrap(download);
              return getContentNetwork(dm);
            }
          }
        } catch (DownloadException e) {
        }
      } else if (ds instanceof TranscodeFile) {
        TranscodeFile tf = (TranscodeFile) ds;
        try {
          DiskManagerFileInfo file = tf.getSourceFile();
          if (file != null) {
            Download download = file.getDownload();
            if (download != null) {
              DownloadManager dm = PluginCoreUtils.unwrap(download);
              return getContentNetwork(dm);
            }
          }
        } catch (Throwable e) {
        }
View Full Code Here

    if (!AzureusCoreFactory.isCoreRunning()) {
      return false;
    }

    GlobalManager gm = AzureusCoreFactory.getSingleton().getGlobalManager();
    DownloadManager dm = gm.getDownloadManager(torrent);
 
 
    if (dm != null) {
      return dm.getAssumedComplete() || canUseEMP(torrent, file_index);
    }
    return canUseEMP(torrent, file_index);
  }
View Full Code Here

    if (ds instanceof org.gudy.azureus2.core3.disk.DiskManagerFileInfo) {
      org.gudy.azureus2.core3.disk.DiskManagerFileInfo fi = (org.gudy.azureus2.core3.disk.DiskManagerFileInfo) ds;
      return canPlayDS(fi.getDownloadManager(), fi.getIndex());
    }
 
    DownloadManager dm = DataSourceUtils.getDM(ds);
    if (dm != null) {
      return canPlay(dm, file_index);
    }
    TOTorrent torrent = DataSourceUtils.getTorrent(ds);
    if (torrent != null) {
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.