コード例 #1
0
  // returns true if downloaded something, false if didn't
  private boolean downloadLinks(String linksText, JDFeedMeFeed feed, JDFeedMePost post) {
    // make sure we have something to download
    if (linksText.trim().length() == 0) return false;

    boolean skip_grabber = feed.getSkiplinkgrabber();
    boolean autostart = gui.getConfig().getStartdownloads();

    // handle a direct download
    if (skip_grabber) {
      // get all the links from the text
      ArrayList<DownloadLink> links = new DistributeData(linksText).findLinks();

      // create a new package for the data
      FilePackage fp = FilePackage.getInstance();
      fp.setName(post.getTitle() + " [JDFeedMe]");
      fp.addLinks(links);

      // download the package
      LinkGrabberController.getInstance().addLinks(links, skip_grabber, autostart);

      // restart the downloads if needed
      if (autostart) DownloadWatchDog.getInstance().startDownloads();
    } else // throw into the link grabber using the old code
    {
      new DistributeData(linksText, skip_grabber).start();
    }

    return true;
  }
コード例 #2
0
 public void refreshModel() {
     synchronized (LinkGrabberController.ControllerLock) {
         synchronized (LinkGrabberController.getInstance().getPackages()) {
             synchronized (list) {
                 list.clear();
                 for (LinkGrabberFilePackage fp : LinkGrabberController.getInstance().getPackages()) {
                     list.add(fp);
                     if (fp.getBooleanProperty(LinkGrabberController.PROPERTY_EXPANDED, false)) {
                         for (DownloadLink dl : fp.getDownloadLinks()) {
                             list.add(dl);
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #3
0
  @Override
  public void onAction(ActionEvent e) {
    if (!UserIO.isOK(
        UserIO.getInstance()
            .requestConfirmDialog(
                UserIO.DONT_SHOW_AGAIN | UserIO.DONT_SHOW_AGAIN_IGNORES_CANCEL,
                JDL.L(
                    "jd.gui.swing.jdgui.menu.actions.RemoveDisabledAction.message",
                    "Do you really want to remove all disabled DownloadLinks?")))) return;

    if (!LinkGrabberPanel.getLinkGrabber().isNotVisible()) {
      synchronized (LinkGrabberController.ControllerLock) {
        synchronized (LinkGrabberController.getInstance().getPackages()) {
          ArrayList<LinkGrabberFilePackage> selected_packages =
              new ArrayList<LinkGrabberFilePackage>(
                  LinkGrabberController.getInstance().getPackages());
          selected_packages.add(LinkGrabberController.getInstance().getFilterPackage());
          for (LinkGrabberFilePackage fp2 : selected_packages) {
            ArrayList<DownloadLink> links = new ArrayList<DownloadLink>(fp2.getDownloadLinks());
            for (DownloadLink dl : links) {
              if (!dl.isEnabled()) fp2.remove(dl);
            }
          }
        }
      }
    } else {
      DownloadController dlc = DownloadController.getInstance();
      ArrayList<DownloadLink> downloadstodelete = new ArrayList<DownloadLink>();
      synchronized (dlc.getPackages()) {
        for (FilePackage fp : dlc.getPackages()) {
          synchronized (fp.getDownloadLinkList()) {
            for (DownloadLink dl : fp.getDownloadLinkList()) {
              if (!dl.isEnabled()) downloadstodelete.add(dl);
            }
          }
        }
      }
      for (DownloadLink dl : downloadstodelete) {
        dl.getFilePackage().remove(dl);
      }
    }
  }