Package com.biglybt.core.global
Interface GlobalManager
- All Superinterfaces:
CoreComponent
,DataSourceResolver.DataSourceImporter
,TaggableResolver
- All Known Implementing Classes:
GlobalManagerImpl
public interface GlobalManager
extends CoreComponent, TaggableResolver, DataSourceResolver.DataSourceImporter
The GlobalManager contains a list of all the downloads
(DownloadManager objects) that the client controls.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.biglybt.core.tag.TaggableResolver
TaggableResolver.LifecycleControlListener
-
Method Summary
Modifier and TypeMethodDescriptionaddDownloadManager
(String fileName, byte[] optionalHash, String savePath, int initialState, boolean persistent) Create and add a Download Manager to the global listaddDownloadManager
(String fileName, byte[] optionalHash, String savePath, int initialState, boolean persistent, boolean for_seeding, DownloadManagerInitialisationAdapter adapter) Create and add a Download Manager to the global listaddDownloadManager
(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 listaddDownloadManager
(String file_name, String save_path) Create and add a Download Manager to the global listvoid
Any adapters added will get a chance to see/set the initial state of downloads as they are addedvoid
Add a listener triggered when Download is about to be removedvoid
addEventListener
(GlobalManagerEventListener listener) void
Add a Global Manager listener and triggers itvoid
addListener
(GlobalManagerListener listener, boolean trigger) void
canDownloadManagerBeRemoved
(DownloadManager dm, boolean remove_torrent, boolean remove_data) Determines whether a DownloadManager can be removeddefault boolean
Indicates whether or not there are any downloads that can be paused.boolean
canPauseDownloads
(boolean pause_force_start) boolean
Indicates whether or not there are any paused downloads to resume.void
clearNonPersistentDownloadState
(byte[] hash) boolean
contains
(DownloadManager manager) int
downloadManagerCount
(boolean bCompleted) Retrieve the number of download managers the global manager is managing.void
fireGlobalManagerEvent
(int type, DownloadManager dm, Object data) void
Verifies the positions of the DownloadManagers, filling in gaps and shifting duplicate IDs down if necessary.getDownloadManager
(TOTorrent torrent) Retrieve the DownloadManager associated with a TOTorrent objectRetrieve the DownloadManager associated with a hashRetrieve a list ofDownloadManager
s that GlobalManager is handlingObject[]
See plugin ConnectionManager.NAT_ constants for return valuesint
seconds remaining, 0 if not activegetStats()
Retrieve the Global Manager Statistics classRetrieve the Tracker Scraper management classboolean
Retrieve whether a DownloadManager can move down in the GlobalManager listboolean
Retrieve whether a DownloadManager can move up in the GlobalManager listboolean
Retrieve whether a DownloadManager is in a paused stateboolean
As for isSeedingOnly but includes queued seedsboolean
Determines whether we are only seeding, and not currently downloading anything.boolean
boolean
void
Move one DownloadManager down in the GlobalManager's listvoid
moveEnd
(DownloadManager[] dm) Move a list of DownloadManagers to the end of the GlobalManager listvoid
moveTo
(DownloadManager manager, int newPosition) Move a Downloadmanager to a new position.void
moveTo
(List<DownloadManager> managers, List<Integer> newPositions) void
moveTop
(DownloadManager[] dm) Move a list of DownloadManagers to the top of the GlobalManager listvoid
Move one DownloadManager up in the GlobalManager's listboolean
pauseDownload
(DownloadManager dm, boolean only_if_active) Pause one DownloadManagerdefault void
Pauses (stops) all running downloads/seedings.void
pauseDownloads
(boolean pause_force_start) void
pauseDownloadsForPeriod
(int seconds) pause any non-paused downloads and auto-resume all downloads after n secondsvoid
Removes a DownloadManager from the global list, providing it can be removed (see#canDownloadManagerBeRemoved(DownloadManager)
)void
removeDownloadManager
(DownloadManager manager, boolean remove_torrent, boolean remove_data) void
void
Remove a listener triggered when Download is about to be removedvoid
void
Removes a Global Manager listenervoid
Resume a previously paused DownloadManagervoid
Resumes (starts) all downloads paused by the previous pauseDownloads call.boolean
resumeDownloads
(boolean is_auto_resume) Attempt to automatically resume downloads - request may be denied if manual override in effectboolean
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 !void
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.void
Starts all downloadsvoid
statsRequest
(Map request, Map reply) void
Stops all downloads without removing themvoid
Puts GlobalManager in a stopped state.
Used when closing down the client.boolean
Don't use me, use dm.stopPausedDownload()Methods inherited from interface com.biglybt.core.util.DataSourceResolver.DataSourceImporter
importDataSource
Methods inherited from interface com.biglybt.core.tag.TaggableResolver
addLifecycleControlListener, getDisplayName, getResolvedTaggables, getResolverTaggableType, removeLifecycleControlListener, requestAttention, resolveTaggable
-
Method Details
-
addDownloadManager
Create and add a Download Manager to the global list- Parameters:
file_name
- location and name of torrent filesave_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 filesavePath
- path to write the data toinitialState
- 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 filesavePath
- path to write the data tosafeFile
- subdirectory or filename to write the data toinitialState
- Initial state of download. See DownloadManager.STATE_*persistent
- Whether the download should be treated as persistent downloadfor_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 filesavePath
- path to write the data toinitialState
- Initial state of download. See DownloadManager.STATE_*persistent
- Whether the download should be treated as persistent downloadfor_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
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 ofDownloadManager
s that GlobalManager is handling- Returns:
- a list of
DownloadManager
s
-
getDownloadManager
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
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
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
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
Pause one DownloadManager- Parameters:
dm
- DownloadManager to pause- Returns:
- False if DownloadManager was invalid, stopped, or pause failed
-
stopPausedDownload
Don't use me, use dm.stopPausedDownload()- Parameters:
dm
-- Returns:
-
resumeDownload
Resume a previously paused DownloadManager- Parameters:
dm
- DownloadManager to resume
-
clearNonPersistentDownloadState
void clearNonPersistentDownloadState(byte[] hash) -
isPaused
Retrieve whether a DownloadManager is in a paused state- Parameters:
dm
- DownloadManager to query- Returns:
- the pause state
-
isSwarmMerging
-
getSwarmMergingInfo
-
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
Retrieve whether a DownloadManager can move down in the GlobalManager list- Parameters:
dm
- DownloadManager to check- Returns:
- True - Can move down
-
isMoveableUp
Retrieve whether a DownloadManager can move up in the GlobalManager list- Parameters:
dm
- DownloadManager to check- Returns:
- True - Can move up
-
moveTop
Move a list of DownloadManagers to the top of the GlobalManager list- Parameters:
dm
- array list of DownloadManager objects to move
-
moveUp
Move one DownloadManager up in the GlobalManager's list- Parameters:
dm
- DownloadManager to move up
-
moveDown
Move one DownloadManager down in the GlobalManager's list- Parameters:
dm
- DownloadManager to move down
-
moveEnd
Move a list of DownloadManagers to the end of the GlobalManager list- Parameters:
dm
- array list of DownloadManager objects to move
-
moveTo
Move a Downloadmanager to a new position.- Parameters:
manager
- DownloadManager to movenewPosition
- position to place
-
moveTo
-
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
Add a Global Manager listener and triggers it- Parameters:
l
- Listener to add
-
removeListener
Removes a Global Manager listener- Parameters:
l
- Listener to remove
-
addDownloadWillBeRemovedListener
Add a listener triggered when Download is about to be removed- Parameters:
l
- Listener to add
-
removeDownloadWillBeRemovedListener
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
Any adapters added will get a chance to see/set the initial state of downloads as they are added- Parameters:
adapter
-
-
removeDownloadManagerInitialisationAdapter
-
addEventListener
-
removeEventListener
-
fireGlobalManagerEvent
-
addListener
- 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
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
-
contains
- Parameters:
manager
-- Returns:
- Since:
- 4.0.0.5
-
saveState
void saveState() -
exportDownloadStateToMap
-
importDownloadStateFromMap
-
getDownloadHistoryManager
Object getDownloadHistoryManager() -
isStopping
boolean isStopping()
-