Package org.gudy.azureus2.core3.download

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


   * Runs a DownloadManager or DiskManagerFileInfo
   */
  public static void runDataSources(Object[] datasources) {
    for (int i = datasources.length - 1; i >= 0; i--) {
      if (datasources[i] instanceof DownloadManager) {
        DownloadManager dm = (DownloadManager) datasources[i];
        ManagerUtils.run(dm);
      } else if (datasources[i] instanceof DiskManagerFileInfo) {
        DiskManagerFileInfo info = (DiskManagerFileInfo) datasources[i];
        Utils.launch(info);
      }
View Full Code Here


    task.go();
  }
 
  public static void promptUserForComment(final DownloadManager[] dms) {
    if (dms.length == 0) {return;}
    DownloadManager dm = dms[0];
   
    // Create dialog box.
    String suggested = dm.getDownloadState().getUserComment();
    String msg_key_prefix = "MyTorrentsView.menu.edit_comment.enter.";
    SimpleTextEntryWindow text_entry = new SimpleTextEntryWindow();
    text_entry.setTitle(msg_key_prefix + "title");
    text_entry.setMessage(msg_key_prefix + "message");
    text_entry.setPreenteredText(suggested, false);
    text_entry.setMultiLine(true);
    text_entry.prompt(new UIInputReceiverListener() {
      public void UIInputReceiverClosed(UIInputReceiver text_entry) {
        if (text_entry.hasSubmittedInput()) {
          String value = text_entry.getSubmittedInput();
          final String value_to_set = (value.length() == 0) ? null : value;
          DMTask task = new DMTask(dms) {
            public void run(DownloadManager dm) {
              dm.getDownloadState().setUserComment(value_to_set);
            }
          };
          task.go();
        }
      }
View Full Code Here

  private static DownloadManager[] toDMS(Object[] objects) {
    int count = 0;
    DownloadManager[] result = new DownloadManager[objects.length];
    for (Object object : objects) {
      if (object instanceof DownloadManager) {
        DownloadManager dm = (DownloadManager) object;
        result[count++] = dm;
      } else if (object instanceof SelectedContent) {
        SelectedContent sc = (SelectedContent) object;
        if (sc.getFileIndex() == -1 && sc.getDownloadManager() != null) {
          result[count++] = sc.getDownloadManager();
View Full Code Here

        result[count++] = fileInfo;
      } else if (object instanceof SelectedContent) {
        SelectedContent sc = (SelectedContent) object;
        int fileIndex = sc.getFileIndex();
        if (fileIndex >= 0 && sc.getDownloadManager() != null) {
          DownloadManager dm = sc.getDownloadManager();
          if (dm != null) {
            DiskManagerFileInfo[] infos = dm.getDiskManagerFileInfo();
            if (fileIndex < infos.length) {
              result[count++] = infos[fileIndex];
            }
          }
        }
View Full Code Here

      boolean hasDM = false;
 
      if (currentContent.length > 0 && hasRealDM) {
        for (int i = 0; i < currentContent.length; i++) {
          ISelectedContent content = currentContent[i];
          DownloadManager dm = content.getDownloadManager();
          int fileIndex = content.getFileIndex();
          if (fileIndex == -1) {
            hasDM = true;
            if (!canStart && ManagerUtils.isStartable(dm)) {
              canStart = true;
            }
            if (!canStop && ManagerUtils.isStopable(dm)) {
              canStop = true;
            }
          } else {
            DiskManagerFileInfo[] fileInfos = dm.getDiskManagerFileInfo();
            if (fileIndex < fileInfos.length) {
              DiskManagerFileInfo fileInfo = fileInfos[fileIndex];
              if (!canStart && (fileInfo.isSkipped())) {
                canStart = true;
              }
             
              if (!canStop && !fileInfo.isSkipped()) {
                canStop = true;
              }
             
              if (!canRemoveFileInfo && !fileInfo.isSkipped()) {
                int storageType = fileInfo.getStorageType();
                if (storageType == DiskManagerFileInfo.ST_LINEAR
                    || storageType == DiskManagerFileInfo.ST_COMPACT) {
                  canRemoveFileInfo = true;
                }
              }
             
              if (!canRunFileInfo
                  && fileInfo.getAccessMode() == DiskManagerFileInfo.READ
                  && fileInfo.getDownloaded() == fileInfo.getLength()
                  && fileInfo.getFile(true).exists()) {
                canRunFileInfo = true;
              }
            }
          }
        }
        boolean canRemove = hasDM || canRemoveFileInfo;
        mapNewToolbarStates.put("remove", canRemove);
      }
 
      boolean canRun = has1Selection && ((hasDM && !canRunFileInfo) || (!hasDM && canRunFileInfo));
      if (canRun) {
        ISelectedContent content = currentContent[0];
        DownloadManager dm = content.getDownloadManager();
 
        if (dm == null) {
          canRun = false;
        } else {
          TOTorrent torrent = dm.getTorrent();
 
          if (torrent == null) {
 
            canRun = false;
 
          } else if (!dm.getAssumedComplete() && torrent.isSimpleTorrent()) {
 
            canRun = false;
  /*
          } else if (PlatformTorrentUtils.useEMP(torrent)
              && PlatformTorrentUtils.embeddedPlayerAvail()
View Full Code Here

    // chose to act on all, we do immediately all and quit. 
    // If the user chose an action just for the one torrent, we do that action,
    // remove that item from the array (by nulling it), and then call
    // removeDownloads again so we can prompt again (or erase more published/low noise torrents)
    for (int i = 0; i < dms.length; i++) {
      DownloadManager dm = dms[i];
      if (dm == null) {
        continue;
      }

      boolean deleteTorrent = COConfigurationManager.getBooleanParameter("def.deletetorrent");

      int confirm = COConfigurationManager.getIntParameter("tb.confirm.delete.content");
      boolean doPrompt = confirm == 0 | forcePrompt;

      if (doPrompt) {
        String title = MessageText.getString("deletedata.title");
        String text = MessageText.getString("v3.deleteContent.message",
            new String[] {
              dm.getDisplayName()
            });

        String[] buttons;
        int[] buttonVals;
        int defaultButtonPos;
View Full Code Here

    }
    if (doAll) {
      if (result == 1 || result == 2) {

        for (int i = index; i < dms.length; i++) {
          DownloadManager dm = dms[i];
          boolean deleteData = result == 2 ? false
              : !dm.getDownloadState().getFlag(
                  Download.FLAG_DO_NOT_DELETE_DATA_ON_REMOVE);
          ManagerUtils.asyncStopDelete(dm, DownloadManager.STATE_STOPPED,
              deleteTorrent, deleteData, deleteFailed);
        }
      } //else cancel
    } else { // not remembered
      if (result == 1 || result == 2) {
        DownloadManager dm = dms[index];
        boolean deleteData = result == 2 ? false
            : !dm.getDownloadState().getFlag(
                Download.FLAG_DO_NOT_DELETE_DATA_ON_REMOVE);

        ManagerUtils.asyncStopDelete(dm, DownloadManager.STATE_STOPPED,
            deleteTorrent, deleteData, null);
      }
View Full Code Here

    StringBuffer toolTip = new StringBuffer();
    String separator = ""; //$NON-NLS-1$
    try{
      managers_mon.enter();
      for (int i = 0; i < managers.size(); i++) {
        DownloadManager manager = (DownloadManager) managers.get(i);
    DownloadManagerStats  stats = manager.getStats();
   
        String name = manager.getDisplayName();
        String completed = DisplayFormatters.formatPercentFromThousands(stats.getCompleted());
        toolTip.append(separator);
        toolTip.append(name);
        toolTip.append(" -- C: ");
        toolTip.append(completed);
View Full Code Here

    DiskManagerFileInfo[] file_infos = new DiskManagerFileInfo[datasources.length];
    for (int i = 0; i < datasources.length; i++) {
      file_infos[i] = (DiskManagerFileInfo) datasources[i];

      DownloadManager dm = file_infos[i].getDownloadManager();
      ArrayList<DiskManagerFileInfo> listFileInfos = mapDMtoDMFI.get(dm);
      if (listFileInfos == null) {
        listFileInfos = new ArrayList<DiskManagerFileInfo>(1);
        mapDMtoDMFI.put(dm, listFileInfos);
      }
      listFileInfos.add(file_infos[i]);

      if (type == PRIORITY_NORMAL || type == PRIORITY_HIGH) {
        file_infos[i].setPriority(type == PRIORITY_HIGH ? 1 : 0);
      }
    }
    boolean skipped = (type == PRIORITY_SKIPPED || type == PRIORITY_DELETE);
    boolean delete_action = (type == PRIORITY_DELETE);
    for (DownloadManager dm : mapDMtoDMFI.keySet()) {
      ArrayList<DiskManagerFileInfo> list = mapDMtoDMFI.get(dm);
      DiskManagerFileInfo[] fileInfos = list.toArray(new DiskManagerFileInfo[0]);
      boolean paused = setSkipped(dm, fileInfos, skipped, delete_action);

      if (paused) {

        dm.resume();
      }
    }
  }
View Full Code Here

          DiskManagerFileInfo[] file_infos = new DiskManagerFileInfo[datasources.length];
          for (int i = 0; i < datasources.length; i++) {
            file_infos[i] = (DiskManagerFileInfo) datasources[i];

            DownloadManager dm = file_infos[i].getDownloadManager();
            ArrayList<DiskManagerFileInfo> listFileInfos = mapDMtoDMFI.get(dm);
            if (listFileInfos == null) {
              listFileInfos = new ArrayList<DiskManagerFileInfo>(1);
              mapDMtoDMFI.put(dm, listFileInfos);
            }
            listFileInfos.add(file_infos[i]);

            file_infos[i].setPriority(priority);
          }

          for (DownloadManager dm : mapDMtoDMFI.keySet()) {
            ArrayList<DiskManagerFileInfo> list = mapDMtoDMFI.get(dm);
            DiskManagerFileInfo[] fileInfos = list.toArray(new DiskManagerFileInfo[0]);
            boolean paused = setSkipped(dm, fileInfos, false, false);

            if (paused) {

              dm.resume();
            }
          }

        }
      }
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.