コード例 #1
0
 public boolean isGlobalTransferBarShown() {
   if (!AzureusCoreFactory.isCoreRunning()) {
     return false;
   }
   return AllTransfersBar.getManager()
       .isOpen(AzureusCoreFactory.getSingleton().getGlobalManager());
 }
コード例 #2
0
ファイル: PlayUtils.java プロジェクト: nuclearrussian/LPS
  private static boolean canPlay(TOTorrent torrent, int file_index) {
    if (!PlatformTorrentUtils.isContent(torrent, false)) {
      return false;
    }

    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);
  }
コード例 #3
0
  // @see com.aelitis.azureus.ui.swt.UIFunctionsSWT#showCoreWaitDlg()
  public Shell showCoreWaitDlg() {
    final SkinnedDialog closeDialog =
        new SkinnedDialog(
            "skin3_dlg_coreloading",
            "coreloading.body",
            SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL);

    closeDialog.setTitle(MessageText.getString("dlg.corewait.title"));
    SWTSkin skin = closeDialog.getSkin();
    SWTSkinObjectButton soButton = (SWTSkinObjectButton) skin.getSkinObject("close");

    final SWTSkinObjectText soWaitTask = (SWTSkinObjectText) skin.getSkinObject("task");

    final SWTSkinObject soWaitProgress = skin.getSkinObject("progress");
    if (soWaitProgress != null) {
      soWaitProgress
          .getControl()
          .addPaintListener(
              new PaintListener() {
                public void paintControl(PaintEvent e) {
                  Control c = (Control) e.widget;
                  Point size = c.getSize();
                  e.gc.setBackground(ColorCache.getColor(e.display, "#23a7df"));
                  Object data = soWaitProgress.getData("progress");
                  if (data instanceof Long) {
                    int waitProgress = ((Long) data).intValue();
                    int breakX = size.x * waitProgress / 100;
                    e.gc.fillRectangle(0, 0, breakX, size.y);
                    e.gc.setBackground(ColorCache.getColor(e.display, "#cccccc"));
                    e.gc.fillRectangle(breakX, 0, size.x - breakX, size.y);
                  }
                }
              });
    }

    if (!AzureusCoreFactory.isCoreRunning()) {
      final Initializer initializer = Initializer.getLastInitializer();
      if (initializer != null) {
        initializer.addListener(
            new InitializerListener() {
              public void reportPercent(final int percent) {
                Utils.execSWTThread(
                    new AERunnable() {
                      public void runSupport() {
                        if (soWaitProgress != null && !soWaitProgress.isDisposed()) {
                          soWaitProgress.setData("progress", new Long(percent));
                          soWaitProgress.getControl().redraw();
                          soWaitProgress.getControl().update();
                        }
                      }
                    });
                if (percent > 100) {
                  initializer.removeListener(this);
                }
              }

              public void reportCurrentTask(String currentTask) {
                if (soWaitTask != null && !soWaitTask.isDisposed()) {
                  soWaitTask.setText(currentTask);
                }
              }
            });
      }
    }

    if (soButton != null) {
      soButton.addSelectionListener(
          new ButtonListenerAdapter() {
            public void pressed(
                SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
              closeDialog.close();
            }
          });
    }

    closeDialog.addCloseListener(
        new SkinnedDialogClosedListener() {
          public void skinDialogClosed(SkinnedDialog dialog) {}
        });

    closeDialog.open();
    return closeDialog.getShell();
  }
コード例 #4
0
  public boolean addTorrentWithOptions(boolean force, final TorrentOpenOptions torrentOptions) {

    if (AzureusCoreFactory.isCoreRunning()) {
      GlobalManager gm = AzureusCoreFactory.getSingleton().getGlobalManager();
      // Check if torrent already exists in gm, and add if not
      DownloadManager existingDownload = gm.getDownloadManager(torrentOptions.getTorrent());

      if (existingDownload != null) {

        final String fExistingName = existingDownload.getDisplayName();
        final DownloadManager fExistingDownload = existingDownload;

        fExistingDownload.fireGlobalManagerEvent(GlobalManagerEvent.ET_REQUEST_ATTENTION);

        Utils.execSWTThread(
            new AERunnable() {
              public void runSupport() {
                boolean can_merge =
                    TorrentUtils.canMergeAnnounceURLs(
                        torrentOptions.getTorrent(), fExistingDownload.getTorrent());

                Shell mainShell = UIFunctionsManagerSWT.getUIFunctionsSWT().getMainShell();

                if ((Display.getDefault().getActiveShell() == null
                        || !mainShell.isVisible()
                        || mainShell.getMinimized())
                    && (!can_merge)) {

                  new MessageSlideShell(
                      Display.getCurrent(),
                      SWT.ICON_INFORMATION,
                      MSG_ALREADY_EXISTS,
                      null,
                      new String[] {
                        ":" + torrentOptions.sOriginatingLocation,
                        fExistingName,
                        MessageText.getString(MSG_ALREADY_EXISTS_NAME),
                      },
                      new Object[] {fExistingDownload},
                      -1);
                } else {

                  if (can_merge) {

                    String text =
                        MessageText.getString(
                            MSG_ALREADY_EXISTS + ".text",
                            new String[] {
                              ":" + torrentOptions.sOriginatingLocation,
                              fExistingName,
                              MessageText.getString(MSG_ALREADY_EXISTS_NAME),
                            });

                    text +=
                        "\n\n" + MessageText.getString("openTorrentWindow.mb.alreadyExists.merge");

                    MessageBoxShell mb =
                        new MessageBoxShell(
                            SWT.YES | SWT.NO,
                            MessageText.getString(MSG_ALREADY_EXISTS + ".title"),
                            text);

                    mb.open(
                        new UserPrompterResultListener() {
                          public void prompterClosed(int result) {
                            if (result == SWT.YES) {

                              TorrentUtils.mergeAnnounceURLs(
                                  torrentOptions.getTorrent(), fExistingDownload.getTorrent());
                            }
                          }
                        });
                  } else {
                    MessageBoxShell mb =
                        new MessageBoxShell(
                            SWT.OK,
                            MSG_ALREADY_EXISTS,
                            new String[] {
                              ":" + torrentOptions.sOriginatingLocation,
                              fExistingName,
                              MessageText.getString(MSG_ALREADY_EXISTS_NAME),
                            });
                    mb.open(null);
                  }
                }
              }
            });

        if (torrentOptions.bDeleteFileOnCancel) {
          File torrentFile = new File(torrentOptions.sFileName);
          torrentFile.delete();
        }
        return true;
      }
    }

    if (!force) {
      String showAgainMode =
          COConfigurationManager.getStringParameter(
              ConfigurationDefaults.CFG_TORRENTADD_OPENOPTIONS);
      if (showAgainMode != null
          && ((showAgainMode.equals(ConfigurationDefaults.CFG_TORRENTADD_OPENOPTIONS_NEVER))
              || (showAgainMode.equals(ConfigurationDefaults.CFG_TORRENTADD_OPENOPTIONS_MANY)
                  && torrentOptions.getFiles() != null
                  && torrentOptions.getFiles().length == 1))) {

        // we're about to silently add the download - ensure that it is going to be saved somewhere
        // vaguely sensible
        // as the current save location is simply taken from the 'default download' config which can
        // be blank (for example)

        boolean looks_good = false;

        String save_loc = torrentOptions.getParentDir().trim();

        if (save_loc.length() == 0) {

          // blank :(

        } else if (save_loc.startsWith(".")) {

          // relative to who knows where
        } else {

          File f = new File(save_loc);

          if (!f.exists()) {

            f.mkdirs();
          }

          if (f.isDirectory() && FileUtil.canWriteToDirectory(f)) {

            if (!f.equals(AETemporaryFileHandler.getTempDirectory())) {

              looks_good = true;
            }
          }
        }

        if (looks_good) {

          return TorrentOpener.addTorrent(torrentOptions);

        } else {

          torrentOptions.setParentDir("");

          MessageBoxShell mb =
              new MessageBoxShell(
                  SWT.OK | SWT.ICON_ERROR,
                  "OpenTorrentWindow.mb.invaliddefsave",
                  new String[] {save_loc});

          mb.open(
              new UserPrompterResultListener() {
                public void prompterClosed(int result) {
                  OpenTorrentOptionsWindow.addTorrent(torrentOptions);
                }
              });

          return (true);
        }
      }
    }

    OpenTorrentOptionsWindow.addTorrent(torrentOptions);

    return true;
  }