Interface GlobalManager

All Superinterfaces:
CoreComponent, DataSourceResolver.DataSourceImporter, TaggableResolver
All Known Implementing Classes:
GlobalManagerImpl

The GlobalManager contains a list of all the downloads (DownloadManager objects) that the client controls.
  • Method Details

    • addDownloadManager

      DownloadManager addDownloadManager(String file_name, String save_path)
      Create and add a Download Manager to the global list
      Parameters:
      file_name - location and name of torrent file
      save_path - path to write the data to
      Returns:
      The Downloadmanger based on the supplied information.
      May return an existing DownloadManager if torrent was already in GlobalManager.
    • addDownloadManager

      DownloadManager addDownloadManager(String fileName, byte[] optionalHash, String savePath, int initialState, boolean persistent)
      Create and add a Download Manager to the global list
      Parameters:
      fileName - location and name of torrent file
      savePath - path to write the data to
      initialState - Initial state of download. See DownloadManager.STATE_*
      persistent - Whether the download should be treated as persistent download
      Returns:
      The Downloadmanger based on the supplied information.
      May return an existing DownloadManager if torrent was already in GlobalManager.
    • addDownloadManager

      DownloadManager addDownloadManager(String fileName, byte[] optionalHash, String savePath, String saveFile, int initialState, boolean persistent, boolean for_seeding, DownloadManagerInitialisationAdapter adapter)
      Create and add a Download Manager to the global list
      Parameters:
      fileName - location and name of torrent file
      savePath - path to write the data to
      safeFile - subdirectory or filename to write the data to
      initialState - Initial state of download. See DownloadManager.STATE_*
      persistent - Whether the download should be treated as persistent download
      for_seeding - Whether the manager should assume the torrent is already complete and ready for seeding.
      Returns:
      The Downloadmanger based on the supplied information.
      May return an existing DownloadManager if torrent was already in GlobalManager.
    • addDownloadManager

      DownloadManager addDownloadManager(String fileName, byte[] optionalHash, String savePath, int initialState, boolean persistent, boolean for_seeding, DownloadManagerInitialisationAdapter adapter)
      Create and add a Download Manager to the global list
      Parameters:
      fileName - location and name of torrent file
      savePath - path to write the data to
      initialState - Initial state of download. See DownloadManager.STATE_*
      persistent - Whether the download should be treated as persistent download
      for_seeding - Whether the manager should assume the torrent is already complete and ready for seeding.
      Returns:
      The Downloadmanger based on the supplied information.
      May return an existing DownloadManager if torrent was already in GlobalManager.
    • removeDownloadManager

      void removeDownloadManager(DownloadManager dm) throws GlobalManagerDownloadRemovalVetoException
      Removes a DownloadManager from the global list, providing it can be removed (see #canDownloadManagerBeRemoved(DownloadManager))

      The DownloadManager will not be stopped if it is running. Scraping, however, will be turned off.

      Parameters:
      dm - DownloadManager to remove
      Throws:
      GlobalManagerDownloadRemovalVetoException
    • canDownloadManagerBeRemoved

      void canDownloadManagerBeRemoved(DownloadManager dm, boolean remove_torrent, boolean remove_data) throws GlobalManagerDownloadRemovalVetoException
      Determines whether a DownloadManager can be removed
      Parameters:
      dm - DownloadManager to check
      Throws:
      GlobalManagerDownloadRemovalVetoException
    • getDownloadManagers

      List<DownloadManager> getDownloadManagers()
      Retrieve a list of DownloadManagers that GlobalManager is handling
      Returns:
      a list of DownloadManagers
    • getDownloadManager

      DownloadManager getDownloadManager(TOTorrent torrent)
      Retrieve the DownloadManager associated with a TOTorrent object
      Parameters:
      torrent - Torrent to search for
      Returns:
      The DownloadManager associated with the TOTOrrent, or null if none found
    • getDownloadManager

      DownloadManager getDownloadManager(HashWrapper hash)
      Retrieve the DownloadManager associated with a hash
      Parameters:
      hash - Hash to search for
      Returns:
      The DownloadManager associated with the hash, or null if none found
    • getTrackerScraper

      TRTrackerScraper getTrackerScraper()
      Retrieve the Tracker Scraper management class
      Returns:
      Tracker Scraper management class
    • getStats

      GlobalManagerStats getStats()
      Retrieve the Global Manager Statistics class
      Returns:
      the Global Manager Statistics class
    • stopGlobalManager

      void stopGlobalManager(GlobalMangerProgressListener callback)
      Puts GlobalManager in a stopped state.
      Used when closing down the client.
    • stopAllDownloads

      void stopAllDownloads()
      Stops all downloads without removing them
    • startAllDownloads

      void startAllDownloads()
      Starts all downloads
    • pauseDownloads

      default void pauseDownloads()
      Pauses (stops) all running downloads/seedings.
    • pauseDownloads

      void pauseDownloads(boolean pause_force_start)
    • pauseDownloadsForPeriod

      void pauseDownloadsForPeriod(int seconds)
      pause any non-paused downloads and auto-resume all downloads after n seconds
      Parameters:
      seconds -
    • getPauseDownloadPeriodRemaining

      int getPauseDownloadPeriodRemaining()
      seconds remaining, 0 if not active
      Returns:
    • canPauseDownloads

      default boolean canPauseDownloads()
      Indicates whether or not there are any downloads that can be paused.
      Returns:
      true if there is at least one download to pause, false if none
    • canPauseDownloads

      boolean canPauseDownloads(boolean pause_force_start)
    • resumeDownloads

      void resumeDownloads()
      Resumes (starts) all downloads paused by the previous pauseDownloads call.
    • resumeDownloads

      boolean resumeDownloads(boolean is_auto_resume)
      Attempt to automatically resume downloads - request may be denied if manual override in effect
      Parameters:
      is_auto_resume -
      Returns:
      whether operation was accepted
    • canResumeDownloads

      boolean canResumeDownloads()
      Indicates whether or not there are any paused downloads to resume.
      Returns:
      true if there is at least one download to resume, false if none.
    • resumingDownload

      boolean resumingDownload(DownloadManager dm)
      This reports that a download is being resumed in order to remove it from the paused set Don't use this to actually resume a download, use resumeDownload !
      Parameters:
      dm -
      Returns:
      true if download was paused AND was force started
    • pauseDownload

      boolean pauseDownload(DownloadManager dm, boolean only_if_active)
      Pause one DownloadManager
      Parameters:
      dm - DownloadManager to pause
      Returns:
      False if DownloadManager was invalid, stopped, or pause failed
    • stopPausedDownload

      boolean stopPausedDownload(DownloadManager dm)
      Don't use me, use dm.stopPausedDownload()
      Parameters:
      dm -
      Returns:
    • resumeDownload

      void resumeDownload(DownloadManager dm)
      Resume a previously paused DownloadManager
      Parameters:
      dm - DownloadManager to resume
    • clearNonPersistentDownloadState

      void clearNonPersistentDownloadState(byte[] hash)
    • isPaused

      boolean isPaused(DownloadManager dm)
      Retrieve whether a DownloadManager is in a paused state
      Parameters:
      dm - DownloadManager to query
      Returns:
      the pause state
    • isSwarmMerging

      boolean isSwarmMerging(DownloadManager dm)
    • getSwarmMergingInfo

      String getSwarmMergingInfo(DownloadManager dm)
    • isSeedingOnly

      boolean isSeedingOnly()
      Determines whether we are only seeding, and not currently downloading anything.
      Returns:
      Seeding Only State
    • isPotentiallySeedingOnly

      boolean isPotentiallySeedingOnly()
      As for isSeedingOnly but includes queued seeds
      Returns:
    • downloadManagerCount

      int downloadManagerCount(boolean bCompleted)
      Retrieve the number of download managers the global manager is managing.
      Parameters:
      bCompleted - True: Return count of completed downloads
      False: Return count of incomplete downloads
      Returns:
      count
    • isMoveableDown

      boolean isMoveableDown(DownloadManager dm)
      Retrieve whether a DownloadManager can move down in the GlobalManager list
      Parameters:
      dm - DownloadManager to check
      Returns:
      True - Can move down
    • isMoveableUp

      boolean isMoveableUp(DownloadManager dm)
      Retrieve whether a DownloadManager can move up in the GlobalManager list
      Parameters:
      dm - DownloadManager to check
      Returns:
      True - Can move up
    • moveTop

      void moveTop(DownloadManager[] dm)
      Move a list of DownloadManagers to the top of the GlobalManager list
      Parameters:
      dm - array list of DownloadManager objects to move
    • moveUp

      void moveUp(DownloadManager dm)
      Move one DownloadManager up in the GlobalManager's list
      Parameters:
      dm - DownloadManager to move up
    • moveDown

      void moveDown(DownloadManager dm)
      Move one DownloadManager down in the GlobalManager's list
      Parameters:
      dm - DownloadManager to move down
    • moveEnd

      void moveEnd(DownloadManager[] dm)
      Move a list of DownloadManagers to the end of the GlobalManager list
      Parameters:
      dm - array list of DownloadManager objects to move
    • moveTo

      void moveTo(DownloadManager manager, int newPosition)
      Move a Downloadmanager to a new position.
      Parameters:
      manager - DownloadManager to move
      newPosition - position to place
    • moveTo

      void moveTo(List<DownloadManager> managers, List<Integer> newPositions)
    • fixUpDownloadManagerPositions

      void fixUpDownloadManagerPositions()
      Verifies the positions of the DownloadManagers, filling in gaps and shifting duplicate IDs down if necessary.

      This does not need to be called after MoveXXX, addDownloadManager, or removeDownloadManager functions.

    • addListener

      void addListener(GlobalManagerListener l)
      Add a Global Manager listener and triggers it
      Parameters:
      l - Listener to add
    • removeListener

      void removeListener(GlobalManagerListener l)
      Removes a Global Manager listener
      Parameters:
      l - Listener to remove
    • addDownloadWillBeRemovedListener

      void addDownloadWillBeRemovedListener(GlobalManagerDownloadWillBeRemovedListener l)
      Add a listener triggered when Download is about to be removed
      Parameters:
      l - Listener to add
    • removeDownloadWillBeRemovedListener

      void removeDownloadWillBeRemovedListener(GlobalManagerDownloadWillBeRemovedListener l)
      Remove a listener triggered when Download is about to be removed
      Parameters:
      l - Listener to remove
    • getNATStatus

      Object[] getNATStatus()
      See plugin ConnectionManager.NAT_ constants for return values
      Returns:
      ConnectionManager.NAT_*
    • addDownloadManagerInitialisationAdapter

      void addDownloadManagerInitialisationAdapter(DownloadManagerInitialisationAdapter adapter)
      Any adapters added will get a chance to see/set the initial state of downloads as they are added
      Parameters:
      adapter -
    • removeDownloadManagerInitialisationAdapter

      void removeDownloadManagerInitialisationAdapter(DownloadManagerInitialisationAdapter adapter)
    • addEventListener

      void addEventListener(GlobalManagerEventListener listener)
    • removeEventListener

      void removeEventListener(GlobalManagerEventListener listener)
    • fireGlobalManagerEvent

      void fireGlobalManagerEvent(int type, DownloadManager dm, Object data)
    • addListener

      void addListener(GlobalManagerListener listener, boolean trigger)
      Parameters:
      listener -
      trigger -
    • removeDownloadManager

      void removeDownloadManager(DownloadManager manager, boolean remove_torrent, boolean remove_data) throws GlobalManagerDownloadRemovalVetoException
      Parameters:
      manager -
      remove_torrent -
      remove_data -
      Throws:
      GlobalManagerDownloadRemovalVetoException
      Since:
      3.0.1.7
    • setMainlineDHTProvider

      void setMainlineDHTProvider(MainlineDHTProvider provider)
      Calling this method doesn't prepare the client to be DHT-ready, it is only used to store, or remove, a DHT provider - so that it can be globally accessible. See the DHT manager classes in the plugin API for a better way to register a provider.
      Since:
      3.0.4.3
    • getMainlineDHTProvider

      MainlineDHTProvider getMainlineDHTProvider()
      Since:
      3.0.4.3
    • statsRequest

      void statsRequest(Map request, Map reply)
    • contains

      boolean contains(DownloadManager manager)
      Parameters:
      manager -
      Returns:
      Since:
      4.0.0.5
    • saveState

      void saveState()
    • exportDownloadStateToMap

      Map exportDownloadStateToMap(DownloadManager dm)
    • importDownloadStateFromMap

      DownloadManager importDownloadStateFromMap(Map map)
    • getDownloadHistoryManager

      Object getDownloadHistoryManager()
    • isStopping

      boolean isStopping()