Class RPDownloadManager
- java.lang.Object
-
- com.biglybt.pifimpl.remote.RPObject
-
- com.biglybt.pifimpl.remote.download.RPDownloadManager
-
- All Implemented Interfaces:
DownloadManager
,java.io.Serializable
public class RPDownloadManager extends RPObject implements DownloadManager
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected DownloadManager
delegate
-
Fields inherited from class com.biglybt.pifimpl.remote.RPObject
__delegate, _dispatcher, _object_id, next_key, object_registry, object_registry_reverse
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
RPDownloadManager(DownloadManager _delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RPReply
_process(RPRequest request)
protected void
_setDelegate(java.lang.Object _delegate)
java.lang.Object
_setLocal()
Download
addDownload(Torrent torrent)
Add a torrent from a "Torrent" object.Download
addDownload(Torrent torrent, java.io.File torrent_location, java.io.File data_location)
Add a torrent from a "Torrent" object and point it at the data location.void
addDownload(java.io.File torrent_file)
Add a torrent from a file.void
addDownload(java.net.URL url)
add a torrent from a URL.void
addDownload(java.net.URL url, boolean auto_download)
Add a torrent from a URL with explicit auto-download optionvoid
addDownload(java.net.URL url, java.net.URL referer)
add a torrent from a URL.void
addDownload(java.net.URL url, java.util.Map request_properties)
add a torrent from a URL and use the supplied request propertiesDownload
addDownloadStopped(Torrent torrent, java.io.File torrent_location, java.io.File data_location)
Explicit way of adding a download in a stopped statevoid
addDownloadStubListener(DownloadStubListener l, boolean inform_of_current)
void
addDownloadWillBeAddedListener(DownloadWillBeAddedListener listener)
void
addListener(DownloadManagerListener l)
Add a listener that will be informed when a download is added to and removed from the client.void
addListener(DownloadManagerListener l, boolean notify)
Add a listener that will be informed when a download is added to and removed from the client.Download
addNonPersistentDownload(Torrent torrent, java.io.File torrent_location, java.io.File data_location)
Add a non-persistent download.Download
addNonPersistentDownloadStopped(Torrent torrent, java.io.File torrentLocation, java.io.File dataLocation)
boolean
canPauseDownloads()
boolean
canResumeDownloads()
void
clearNonPersistentDownloadState(byte[] hash)
Although non-persistent downloads themselves aren't rememebered across restarts, some internal stats are (for continuity, like total up/down, file allocation state) - this method allows this to be removedstatic RPDownloadManager
create(DownloadManager _delegate)
DefaultSaveLocationManager
getDefaultSaveLocationManager()
Returns the defaultSaveLocationManager
object that controls where downloads should be placed.Download
getDownload(byte[] hash)
Gets a download given its hashDownload
getDownload(Torrent torrent)
Gets the download for a particular torrent, returns null if not foundDownload[]
getDownloads()
Gets all the downloads.Download[]
getDownloads(boolean bSort)
Gets all the downloads.int
getDownloadStubCount()
DownloadStub[]
getDownloadStubs()
DownloadEventNotifier
getGlobalDownloadEventNotifier()
Return aDownloadEventNotifier
object which can be used as an easy way to register listeners against all downloads handled by the client.SaveLocationManager
getSaveLocationManager()
Returns the currentSaveLocationManager
object which decides where downloads should be placed.DownloadManagerStats
getStats()
Get the download manager statisticsboolean
isSeedingOnly()
indicates whether or not all active downloads are in a seeding (or effective) seeding stateDownloadStub
lookupDownloadStub(byte[] hash)
void
pauseDownloads()
pause all running downloadsvoid
removeDownloadStubListener(DownloadStubListener l)
void
removeDownloadWillBeAddedListener(DownloadWillBeAddedListener listener)
void
removeListener(DownloadManagerListener l)
Removes a previously added listener.void
removeListener(DownloadManagerListener l, boolean notify)
Removes a previously added listener.void
resumeDownloads()
resume previously paused downloadsvoid
setSaveLocationManager(SaveLocationManager manager)
Registers an object to be in control of determining the default save location for downloads.void
startAllDownloads()
starts all non-running downloadsvoid
stopAllDownloads()
stops all running downloads-
Methods inherited from class com.biglybt.pifimpl.remote.RPObject
_fixupLocal, _getDelegate, _getName, _getOID, _lookupLocal, _lookupLocal, _refresh, _setRemote, getDispatcher, notSupported, notSupported
-
-
-
-
Field Detail
-
delegate
protected transient DownloadManager delegate
-
-
Constructor Detail
-
RPDownloadManager
protected RPDownloadManager(DownloadManager _delegate)
-
-
Method Detail
-
create
public static RPDownloadManager create(DownloadManager _delegate)
-
_setDelegate
protected void _setDelegate(java.lang.Object _delegate)
- Overrides:
_setDelegate
in classRPObject
-
_setLocal
public java.lang.Object _setLocal() throws RPException
- Overrides:
_setLocal
in classRPObject
- Throws:
RPException
-
addDownload
public void addDownload(java.io.File torrent_file) throws DownloadException
Description copied from interface:DownloadManager
Add a torrent from a file. This may prompt the user for a download location etc. if required. This is an async operation, so no Download is returned. If you want to force a download to be added without prompting the user, you should create a Torrent object first, and then use an alternative addDownload method.- Specified by:
addDownload
in interfaceDownloadManager
- Throws:
DownloadException
- See Also:
DownloadManager.addDownload(Torrent)
,DownloadManager.addDownload(Torrent, File, File)
,TorrentManager.createFromBEncodedFile
-
addDownload
public void addDownload(java.net.URL url, java.net.URL referer)
Description copied from interface:DownloadManager
add a torrent from a URL. This will prompt the user for download location etc. if required This is an async operation so no Download returned- Specified by:
addDownload
in interfaceDownloadManager
-
addDownload
public void addDownload(java.net.URL url) throws DownloadException
Description copied from interface:DownloadManager
add a torrent from a URL. This will prompt the user for download location etc. if required This is an async operation so no Download returned- Specified by:
addDownload
in interfaceDownloadManager
- Throws:
DownloadException
-
addDownload
public void addDownload(java.net.URL url, boolean auto_download) throws DownloadException
Description copied from interface:DownloadManager
Add a torrent from a URL with explicit auto-download option- Specified by:
addDownload
in interfaceDownloadManager
- Throws:
DownloadException
-
addDownload
public void addDownload(java.net.URL url, java.util.Map request_properties)
Description copied from interface:DownloadManager
add a torrent from a URL and use the supplied request properties- Specified by:
addDownload
in interfaceDownloadManager
-
addDownload
public Download addDownload(Torrent torrent) throws DownloadException
Description copied from interface:DownloadManager
Add a torrent from a "Torrent" object. The default torrent file and data locations will be used if defined - a DownloadException will be thrown if they're not. You can explicitly set these values by using theaddDownload(Torrent, File, File)
method.- Specified by:
addDownload
in interfaceDownloadManager
- Returns:
- Throws:
DownloadException
- See Also:
DownloadManager.addDownload(Torrent, File, File)
-
addDownload
public Download addDownload(Torrent torrent, java.io.File torrent_location, java.io.File data_location) throws DownloadException
Description copied from interface:DownloadManager
Add a torrent from a "Torrent" object and point it at the data location. The torrent_location should be the location of where the torrent file is on disk. This will be the torrent file that the client will use internally. If null is passed, then a file to store the torrent data in will be automatically created by the client.- Specified by:
addDownload
in interfaceDownloadManager
- Parameters:
torrent
- The torrent object to create a download with.torrent_location
- The location of the file on disk - ifnull
, a file to store the torrent data into will be created automatically.data_location
- null -> user default data save location if defined- Returns:
- support for null params for torrent_location/data_location since 2.1.0.4
- Throws:
DownloadException
-
addDownloadStopped
public Download addDownloadStopped(Torrent torrent, java.io.File torrent_location, java.io.File data_location) throws DownloadException
Description copied from interface:DownloadManager
Explicit way of adding a download in a stopped state- Specified by:
addDownloadStopped
in interfaceDownloadManager
- Returns:
- Throws:
DownloadException
-
addNonPersistentDownload
public Download addNonPersistentDownload(Torrent torrent, java.io.File torrent_location, java.io.File data_location) throws DownloadException
Description copied from interface:DownloadManager
Add a non-persistent download. Such downloads are not persisted by the client and as such will not be remembered across an client close and restart.- Specified by:
addNonPersistentDownload
in interfaceDownloadManager
- Returns:
- Throws:
DownloadException
-
addNonPersistentDownloadStopped
public Download addNonPersistentDownloadStopped(Torrent torrent, java.io.File torrentLocation, java.io.File dataLocation) throws DownloadException
- Specified by:
addNonPersistentDownloadStopped
in interfaceDownloadManager
- Throws:
DownloadException
-
clearNonPersistentDownloadState
public void clearNonPersistentDownloadState(byte[] hash)
Description copied from interface:DownloadManager
Although non-persistent downloads themselves aren't rememebered across restarts, some internal stats are (for continuity, like total up/down, file allocation state) - this method allows this to be removed- Specified by:
clearNonPersistentDownloadState
in interfaceDownloadManager
-
getDownload
public Download getDownload(Torrent torrent)
Description copied from interface:DownloadManager
Gets the download for a particular torrent, returns null if not found- Specified by:
getDownload
in interfaceDownloadManager
- Returns:
-
getDownload
public Download getDownload(byte[] hash)
Description copied from interface:DownloadManager
Gets a download given its hash- Specified by:
getDownload
in interfaceDownloadManager
- Returns:
-
getDownloads
public Download[] getDownloads()
Description copied from interface:DownloadManager
Gets all the downloads. Returned in Download "index" order- Specified by:
getDownloads
in interfaceDownloadManager
- Returns:
-
getDownloads
public Download[] getDownloads(boolean bSort)
Description copied from interface:DownloadManager
Gets all the downloads.- Specified by:
getDownloads
in interfaceDownloadManager
- Parameters:
bSort
- true - Returned in Download "index" order.
false - Order not guaranteed. Faster retrieval.- Returns:
- array of Download object
-
pauseDownloads
public void pauseDownloads()
Description copied from interface:DownloadManager
pause all running downloads- Specified by:
pauseDownloads
in interfaceDownloadManager
-
canPauseDownloads
public boolean canPauseDownloads()
- Specified by:
canPauseDownloads
in interfaceDownloadManager
-
resumeDownloads
public void resumeDownloads()
Description copied from interface:DownloadManager
resume previously paused downloads- Specified by:
resumeDownloads
in interfaceDownloadManager
-
canResumeDownloads
public boolean canResumeDownloads()
- Specified by:
canResumeDownloads
in interfaceDownloadManager
-
startAllDownloads
public void startAllDownloads()
Description copied from interface:DownloadManager
starts all non-running downloads- Specified by:
startAllDownloads
in interfaceDownloadManager
-
stopAllDownloads
public void stopAllDownloads()
Description copied from interface:DownloadManager
stops all running downloads- Specified by:
stopAllDownloads
in interfaceDownloadManager
-
getStats
public DownloadManagerStats getStats()
Description copied from interface:DownloadManager
Get the download manager statistics- Specified by:
getStats
in interfaceDownloadManager
- Returns:
-
isSeedingOnly
public boolean isSeedingOnly()
Description copied from interface:DownloadManager
indicates whether or not all active downloads are in a seeding (or effective) seeding state- Specified by:
isSeedingOnly
in interfaceDownloadManager
- Returns:
-
addListener
public void addListener(DownloadManagerListener l)
Description copied from interface:DownloadManager
Add a listener that will be informed when a download is added to and removed from the client. Invoking this method is equivalent toaddListener(l, true)
.- Specified by:
addListener
in interfaceDownloadManager
- Parameters:
l
- The listener to add.- See Also:
DownloadManager.addListener(DownloadManagerListener, boolean)
-
addListener
public void addListener(DownloadManagerListener l, boolean notify)
Description copied from interface:DownloadManager
Add a listener that will be informed when a download is added to and removed from the client.- Specified by:
addListener
in interfaceDownloadManager
- Parameters:
l
- The listener to add.notify
- true - if you want the listener to have itsdownloadAdded
method invoked immediately with all downloads currently managed by the client. false - if you only want to be notified about new downloads added after this method is called.
-
removeListener
public void removeListener(DownloadManagerListener l)
Description copied from interface:DownloadManager
Removes a previously added listener. Invoking this method is equivalent toremoveListener(l, false)
.- Specified by:
removeListener
in interfaceDownloadManager
- Parameters:
l
- The listener to remove.- See Also:
DownloadManager.removeListener(DownloadManagerListener, boolean)
-
removeListener
public void removeListener(DownloadManagerListener l, boolean notify)
Description copied from interface:DownloadManager
Removes a previously added listener.- Specified by:
removeListener
in interfaceDownloadManager
- Parameters:
l
- The listener to remove.notify
- true - if you want the listener to have itsdownloadRemoved
method invoked immediately with all downloads currently managed by the client, false otherwise.
-
addDownloadWillBeAddedListener
public void addDownloadWillBeAddedListener(DownloadWillBeAddedListener listener)
- Specified by:
addDownloadWillBeAddedListener
in interfaceDownloadManager
-
removeDownloadWillBeAddedListener
public void removeDownloadWillBeAddedListener(DownloadWillBeAddedListener listener)
- Specified by:
removeDownloadWillBeAddedListener
in interfaceDownloadManager
-
getGlobalDownloadEventNotifier
public DownloadEventNotifier getGlobalDownloadEventNotifier()
Description copied from interface:DownloadManager
Return aDownloadEventNotifier
object which can be used as an easy way to register listeners against all downloads handled by the client.- Specified by:
getGlobalDownloadEventNotifier
in interfaceDownloadManager
-
setSaveLocationManager
public void setSaveLocationManager(SaveLocationManager manager)
Description copied from interface:DownloadManager
Registers an object to be in control of determining the default save location for downloads. You can set it to null to remove any object which was previously set.By default, the client will use its default save location manager which handles on-completion and on-removal events.
- Specified by:
setSaveLocationManager
in interfaceDownloadManager
- Parameters:
manager
- The new manager object to use.
-
getSaveLocationManager
public SaveLocationManager getSaveLocationManager()
Description copied from interface:DownloadManager
Returns the currentSaveLocationManager
object which decides where downloads should be placed.- Specified by:
getSaveLocationManager
in interfaceDownloadManager
- Returns:
- The manager object currently in use.
-
getDefaultSaveLocationManager
public DefaultSaveLocationManager getDefaultSaveLocationManager()
Description copied from interface:DownloadManager
Returns the defaultSaveLocationManager
object that controls where downloads should be placed.- Specified by:
getDefaultSaveLocationManager
in interfaceDownloadManager
- Returns:
- The default save location manager object.
-
getDownloadStubs
public DownloadStub[] getDownloadStubs()
- Specified by:
getDownloadStubs
in interfaceDownloadManager
-
getDownloadStubCount
public int getDownloadStubCount()
- Specified by:
getDownloadStubCount
in interfaceDownloadManager
-
lookupDownloadStub
public DownloadStub lookupDownloadStub(byte[] hash)
- Specified by:
lookupDownloadStub
in interfaceDownloadManager
-
addDownloadStubListener
public void addDownloadStubListener(DownloadStubListener l, boolean inform_of_current)
- Specified by:
addDownloadStubListener
in interfaceDownloadManager
-
removeDownloadStubListener
public void removeDownloadStubListener(DownloadStubListener l)
- Specified by:
removeDownloadStubListener
in interfaceDownloadManager
-
-