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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DownloadManager
addDownloadManager(java.lang.String fileName, byte[] optionalHash, java.lang.String savePath, int initialState, boolean persistent)
Create and add a Download Manager to the global listDownloadManager
addDownloadManager(java.lang.String fileName, byte[] optionalHash, java.lang.String savePath, int initialState, boolean persistent, boolean for_seeding, DownloadManagerInitialisationAdapter adapter)
Create and add a Download Manager to the global listDownloadManager
addDownloadManager(java.lang.String fileName, byte[] optionalHash, java.lang.String savePath, java.lang.String saveFile, int initialState, boolean persistent, boolean for_seeding, DownloadManagerInitialisationAdapter adapter)
Create and add a Download Manager to the global listDownloadManager
addDownloadManager(java.lang.String file_name, java.lang.String save_path)
Create and add a Download Manager to the global listvoid
addDownloadManagerInitialisationAdapter(DownloadManagerInitialisationAdapter adapter)
Any adapters added will get a chance to see/set the initial state of downloads as they are addedvoid
addDownloadWillBeRemovedListener(GlobalManagerDownloadWillBeRemovedListener l)
Add a listener triggered when Download is about to be removedvoid
addEventListener(GlobalManagerEventListener listener)
void
addListener(GlobalManagerListener l)
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 removedboolean
canPauseDownloads()
Indicates whether or not there are any downloads that can be paused.boolean
canResumeDownloads()
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.java.util.Map
exportDownloadStateToMap(DownloadManager dm)
void
fireGlobalManagerEvent(int type, DownloadManager param)
void
fixUpDownloadManagerPositions()
Verifies the positions of the DownloadManagers, filling in gaps and shifting duplicate IDs down if necessary.java.lang.Object
getDownloadHistoryManager()
DownloadManager
getDownloadManager(TOTorrent torrent)
Retrieve the DownloadManager associated with a TOTorrent objectDownloadManager
getDownloadManager(HashWrapper hash)
Retrieve the DownloadManager associated with a hashjava.util.List<DownloadManager>
getDownloadManagers()
Retrieve a list ofDownloadManager
s that GlobalManager is handlingMainlineDHTProvider
getMainlineDHTProvider()
java.lang.Object[]
getNATStatus()
See plugin ConnectionManager.NAT_ constants for return valuesint
getPauseDownloadPeriodRemaining()
seconds remaining, 0 if not activeGlobalManagerStats
getStats()
Retrieve the Global Manager Statistics classjava.lang.String
getSwarmMergingInfo(DownloadManager dm)
TRTrackerScraper
getTrackerScraper()
Retrieve the Tracker Scraper management classDownloadManager
importDownloadStateFromMap(java.util.Map map)
boolean
isMoveableDown(DownloadManager dm)
Retrieve whether a DownloadManager can move down in the GlobalManager listboolean
isMoveableUp(DownloadManager dm)
Retrieve whether a DownloadManager can move up in the GlobalManager listboolean
isPaused(DownloadManager dm)
Retrieve whether a DownloadManager is in a paused stateboolean
isPotentiallySeedingOnly()
As for isSeedingOnly but includes queued seedsboolean
isSeedingOnly()
Determines whether we are only seeding, and not currently downloading anything.boolean
isStopping()
boolean
isSwarmMerging(DownloadManager dm)
void
moveDown(DownloadManager dm)
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
moveTop(DownloadManager[] dm)
Move a list of DownloadManagers to the top of the GlobalManager listvoid
moveUp(DownloadManager dm)
Move one DownloadManager up in the GlobalManager's listboolean
pauseDownload(DownloadManager dm, boolean only_if_active)
Pause one DownloadManagervoid
pauseDownloads()
Pauses (stops) all running downloads/seedings.void
pauseDownloadsForPeriod(int seconds)
pause any non-paused downloads and auto-resume all downloads after n secondsvoid
removeDownloadManager(DownloadManager dm)
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
removeDownloadManagerInitialisationAdapter(DownloadManagerInitialisationAdapter adapter)
void
removeDownloadWillBeRemovedListener(GlobalManagerDownloadWillBeRemovedListener l)
Remove a listener triggered when Download is about to be removedvoid
removeEventListener(GlobalManagerEventListener listener)
void
removeListener(GlobalManagerListener l)
Removes a Global Manager listenervoid
resumeDownload(DownloadManager dm)
Resume a previously paused DownloadManagervoid
resumeDownloads()
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
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 !void
saveState()
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
startAllDownloads()
Starts all downloadsvoid
statsRequest(java.util.Map request, java.util.Map reply)
void
stopAllDownloads()
Stops all downloads without removing themvoid
stopGlobalManager(GlobalMangerProgressListener callback)
Puts GlobalManager in a stopped state.
Used when closing down the client.boolean
stopPausedDownload(DownloadManager dm)
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 Detail
-
addDownloadManager
DownloadManager addDownloadManager(java.lang.String file_name, java.lang.String save_path)
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(java.lang.String fileName, byte[] optionalHash, java.lang.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(java.lang.String fileName, byte[] optionalHash, java.lang.String savePath, java.lang.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(java.lang.String fileName, byte[] optionalHash, java.lang.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
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
java.util.List<DownloadManager> getDownloadManagers()
Retrieve a list ofDownloadManager
s that GlobalManager is handling- Returns:
- a list of
DownloadManager
s
-
getDownloadManager
DownloadManager getDownloadManager(TOTorrent torrent)
Retrieve the DownloadManager associated with a TOTorrent object- Parameters:
torrent
- Torrent to search for- Returns:
- The DownloadManager associted 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 associted 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
void pauseDownloads()
Pauses (stops) all running downloads/seedings.
-
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
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
-
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:
-
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
java.lang.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 movenewPosition
- position to place
-
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
java.lang.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 param)
-
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(java.util.Map request, java.util.Map reply)
-
contains
boolean contains(DownloadManager manager)
- Parameters:
manager
-- Returns:
- Since:
- 4.0.0.5
-
saveState
void saveState()
-
exportDownloadStateToMap
java.util.Map exportDownloadStateToMap(DownloadManager dm)
-
importDownloadStateFromMap
DownloadManager importDownloadStateFromMap(java.util.Map map)
-
getDownloadHistoryManager
java.lang.Object getDownloadHistoryManager()
-
isStopping
boolean isStopping()
-
-