org.gudy.azureus2.core3.download.impl
Class DownloadManagerImpl

java.lang.Object
  extended by org.gudy.azureus2.core3.logging.LogRelation
      extended by org.gudy.azureus2.core3.download.impl.DownloadManagerImpl
All Implemented Interfaces:
DownloadManager, Taggable

public class DownloadManagerImpl
extends LogRelation
implements DownloadManager, Taggable

Author:
Olivier

Nested Class Summary
protected static class DownloadManagerImpl.NoStackException
           
 
Field Summary
static String dnd_subfolder
           
protected  AEMonitor this_mon
           
 
Fields inherited from interface org.gudy.azureus2.core3.download.DownloadManager
ET_INSUFFICIENT_SPACE, ET_NONE, ET_OTHER, STATE_ALLOCATING, STATE_CHECKING, STATE_CLOSED, STATE_DOWNLOADING, STATE_ERROR, STATE_FINISHING, STATE_INITIALIZED, STATE_INITIALIZING, STATE_QUEUED, STATE_READY, STATE_SEEDING, STATE_START_OF_DAY, STATE_STOPPED, STATE_STOPPING, STATE_WAITING, WEALTH_ERROR, WEALTH_KO, WEALTH_NO_REMOTE, WEALTH_NO_TRACKER, WEALTH_OK, WEALTH_STOPPED
 
Fields inherited from interface com.aelitis.azureus.core.tag.Taggable
TT_DOWNLOAD, TT_PEER
 
Constructor Summary
DownloadManagerImpl(GlobalManager _gm, byte[] _torrent_hash, String _torrentFileName, String _torrent_save_dir, String _torrent_save_file, int _initialState, boolean _persistent, boolean _recovered, boolean _open_for_seeding, boolean _has_ever_been_started, List _file_priorities, DownloadManagerInitialisationAdapter _initialisation_adapter)
           
 
Method Summary
protected  boolean activateRequest(int count)
           
 void addActivationListener(DownloadManagerActivationListener listener)
           
 void addDiskListener(DownloadManagerDiskListener listener)
           
static void addGlobalDownloadListener(DownloadManagerListener listener)
           
 void addListener(DownloadManagerListener listener)
           
 void addListener(DownloadManagerListener listener, boolean triggerStateChange)
           
 void addPeer(PEPeer peer)
           
 void addPeerListener(DownloadManagerPeerListener listener)
           
 void addPeerListener(DownloadManagerPeerListener listener, boolean bDispatchForExisting)
           
 void addPiece(PEPiece piece)
           
 void addPieceListener(DownloadManagerPieceListener listener)
           
 void addPieceListener(DownloadManagerPieceListener listener, boolean bDispatchForExisting)
           
 void addRateLimiter(LimitedRateGroup group, boolean upload)
           
 void addTPSListener(DownloadManagerTPSListener listener)
           
 void addTrackerListener(DownloadManagerTrackerListener listener)
           
 boolean canForceRecheck()
           
 boolean canMoveDataFiles()
           
protected  void clearFileLinks()
           
 void copyDataFiles(File parent_dir)
           
protected  void deleteDataFiles()
           
protected  void deletePartialDataFiles()
           
protected  void deleteTorrentFile()
           
 void destroy(boolean is_duplicate)
          Indicates that the download manager is no longer needed
protected  void downloadEnded(boolean never_downloaded)
          Is called when a download is finished.
 boolean equals(Object obj)
           
 boolean filesExist()
          Deprecated.  
 boolean filesExist(boolean expected_to_be_allocated)
          Checks if all the files the user wants to download from this torrent actually exist on their filesystem.
 void fireGlobalManagerEvent(int eventType)
           
 void forceRecheck()
           
 void forceRecheck(ForceRecheckListener l)
           
 void generateEvidence(IndentWriter writer)
           
 File getAbsoluteSaveLocation()
          Returns the file location where we save the torrent, this includes the parent directory and the actual file name.
 int getActivationCount()
           
protected  Object[] getActiveScrapeResponse()
          Returns the "first" online scrape response found, and its active URL, otherwise one of the failing scrapes
 boolean getAssumedComplete()
          Retrieve whether this download is assumed complete.
 long getAutoResumeTime()
           
 long getCreationTime()
          gives the time this download was created (not the torrent but the download itself)
 int getCryptoLevel()
           
 PEPeer[] getCurrentPeers()
           
 PEPiece[] getCurrentPieces()
           
 Object getData(String key)
          To retreive arbitrary objects against this object.
 DiskManager getDiskManager()
           
 DiskManagerFileInfo[] getDiskManagerFileInfo()
          Deprecated. use getDiskManagerFileInfoSet() instead
 DiskManagerFileInfoSet getDiskManagerFileInfoSet()
           
 String getDisplayName()
           
 DownloadManagerState getDownloadState()
           
 int getEffectiveMaxUploads()
          Returns the max uploads depending on whether the download is seeding and it has a separate rate for this
protected  int getEffectiveUploadPriority()
           
 int getEffectiveUploadRateLimitBytesPerSecond()
          returns the currently in force upload speed limit which may vary from the stats.
 String getErrorDetails()
           
 int getErrorType()
           
 int getExtendedMessagingMode()
           
 GlobalManager getGlobalManager()
           
 List<TRTrackerScraperResponse> getGoodTrackerScrapeResponses()
           
 int getHealthStatus()
           
 String getInternalName()
          returns a name based on the torrent hash or an empty string if torrent invalid
protected  int[] getMaxConnections(boolean mixed)
           
protected  int[] getMaxConnectionsWhenSeeding(boolean mixed)
           
protected  int[] getMaxSeedConnections(boolean mixed)
           
 int getMaxUploads()
           
protected  int getMaxUploadsWhenSeeding()
           
 int getNATStatus()
          See plugin ConnectionManager.NAT_ constants for return values
 int getNbPeers()
           
 int getNbPieces()
           
 int getNbSeeds()
           
 int getNumFileInfos()
           
 PEPeerManager getPeerManager()
           
 String getPieceLength()
           
 int getPosition()
           
 Object[] getQueryableInterfaces()
          Query this class for a reference to another class that it may hold
 LimitedRateGroup[] getRateLimiters(boolean upload)
           
 String getRelationText()
          A short description of what your class holds that can be printed by the logger
 File getSaveLocation()
           
 int getSeedingRank()
           
 long getSize()
           
 int getState()
           
 DownloadManagerStats getStats()
           
 int[] getStorageType(DiskManagerFileInfo[] info)
           
 int getSubState()
          For stopping this returns the target state after stopping (stopped/queued)
 String getTaggableID()
           
 TaggableResolver getTaggableResolver()
           
 Object getTaggableTransientProperty(String key)
           
 int getTaggableType()
           
 TOTorrent getTorrent()
           
 String getTorrentComment()
           
 String getTorrentCreatedBy()
           
 long getTorrentCreationDate()
           
 String getTorrentFileName()
          This includes the full path to the torrent file.
 TRTrackerAnnouncer getTrackerClient()
           
 List<TrackerPeerSource> getTrackerPeerSources()
           
 TRTrackerScraperResponse getTrackerScrapeResponse()
           
 String getTrackerStatus()
           
 int getTrackerTime()
          When the next call to the tracker will occur (in seconds)
 Object getUserData(Object key)
          To retreive arbitrary objects against a download.
 int hashCode()
           
protected  void informDownloadEnded()
           
protected  void informPositionChanged(int new_position)
           
protected  void informPriorityChange(DiskManagerFileInfo file)
           
protected  void informStarted(PEPeerManager pm)
           
protected  void informStateChanged()
          Doesn't not inform if state didn't change from last inform call
protected  void informStopped(PEPeerManager pm, boolean for_queue)
           
protected  void informWillBeStarted(PEPeerManager pm)
           
 void initialize()
           
 boolean isDataAlreadyAllocated()
          Determine whether disk allocation has already been done.
 boolean isDestroyed()
           
 boolean isDownloadComplete(boolean bIncludeDND)
          Retrieves whether the download is complete
 boolean isForceStart()
           
 boolean isInDefaultSaveDir()
          Returns true if the download is being saved to one of the default save directories.
protected  boolean isMaxConnectionsWhenSeedingEnabled()
           
protected  boolean isMaxUploadsWhenSeedingEnabled()
           
 boolean isPaused()
           
 boolean isPersistent()
           
 String isSwarmMerging()
           
 boolean isTrackerError()
           
 boolean isUnauthorisedOnTracker()
           
 void moveDataFiles(File new_parent_dir)
          Move data files to new location.
 void moveDataFiles(File destination, String new_name)
          Move the files and rename a download in one go.
 void moveDataFiles(File destination, String new_name, boolean live)
           
 void moveDataFilesLive(File new_parent_dir)
          At some point someone made the file-move operations stop+restart the download when it was designed to work without doing this (see move-on-complete for example).
 void moveTorrentFile(File new_parent_dir)
          Move torrent file to new location.
 void moveTorrentFile(File new_parent_dir, String new_name)
           
 boolean pause()
           
 boolean pause(long _resume_time)
           
protected  void readParameters()
           
protected  void readTorrent()
           
 void recheckFile(DiskManagerFileInfo file)
          Recheck a particular file.
 void removeActivationListener(DownloadManagerActivationListener listener)
           
 void removeDiskListener(DownloadManagerDiskListener listener)
           
static void removeGlobalDownloadListener(DownloadManagerListener listener)
           
 void removeListener(DownloadManagerListener listener)
           
 void removePeer(PEPeer peer)
           
 void removePeerListener(DownloadManagerPeerListener listener)
           
 void removePiece(PEPiece piece)
           
 void removePieceListener(DownloadManagerPieceListener listener)
           
 void removeRateLimiter(LimitedRateGroup group, boolean upload)
           
 void removeTPSListener(DownloadManagerTPSListener listener)
           
 void removeTrackerListener(DownloadManagerTrackerListener listener)
           
 void rename(String name)
          Renames the save file, torrent file and the displayed name.
 void renameDownload(String new_name)
          Rename the download - this means the name of the file being downloaded (for single file torrents), or the name of the directory holding the files (in a multi-file torrent).
 void renameTorrent(String name)
           
 void renameTorrentSafe(String name)
          Same as renameTorrent, but appends numbers if torrent already exists
 boolean requestAssumedCompleteMode()
          Will set this download to be "assumed complete" for if the download is already complete (excluding DND)
 void requestAttention()
           
 void requestTrackerAnnounce(boolean force)
           
 void requestTrackerScrape(boolean force)
           
 void resetFile(DiskManagerFileInfo file)
          Reset the file download state to totally undownloaded.
 void resume()
           
 void saveDownload()
          persist any general download related information, excluding resume data which is managed separately by saveResumeData
 void saveResumeData()
          persist resume data
 boolean seedPieceRecheck()
          Gives the download an opportunity to schedule seeding mode piece rechecks if desired
 void setAnnounceResult(DownloadAnnounceResult result)
           
protected  void setAssumedComplete(boolean _assumedComplete)
           
 void setCreationTime(long t)
           
 void setCryptoLevel(int level)
           
 void setData(String key, Object value)
          To store arbitrary objects against this object.
 void setDataAlreadyAllocated(boolean already_allocated)
          Set whether data allocation has already been done, so we know when to allocate and when to throw a missing-data error message.
protected  void setFailed()
           
protected  void setFailed(String str)
           
protected  void setFailed(Throwable e)
           
protected  void setFileLinks()
           
 void setFilePriorities(DiskManagerFileInfo[] fileInfos, int priority)
          Sets the priority for an array for files
 void setForceStart(boolean forceStart)
           
 void setManualUploadPriority(int priority)
           
 void setMaxUploads(int max)
           
 void setPieceCheckingEnabled(boolean enabled)
          Use with care - introduced to support speed tests whereby we want to avoid checking the virtual torrent used for the test
 void setPosition(int new_position)
           
 void setScrapeResult(DownloadScrapeResult result)
           
 void setSeedingRank(int rank)
           
 void setStateFinishing()
           
 void setStateQueued()
           
 void setStateWaiting()
           
 void setTaggableTransientProperty(String key, Object value)
           
 void setTorrentFile(File new_parent_dir, String new_name)
          Sets the torrent file name (will perform a move of the torrent file) - this shouldn't be used unless you know what you are doing (it requires the download to be stopped!) - it is safer to use moveTorrentFile instead.
 void setTorrentFileName(String string)
           
protected  void setTorrentInvalid(String str)
           
 void setTorrentSaveDir(String new_dir)
          changes the save directory.
 void setTorrentSaveDir(String new_dir, String dl_name)
          changes the save directory.
protected  void setTrackerRefreshDelayOverrides(int percent)
           
 void setTrackerScrapeResponse(TRTrackerScraperResponse response)
           
 void setUserData(Object key, Object value)
          To store arbitrary objects against a download.
 void startDownload()
           
 void stopIt(int state_after_stopping, boolean remove_torrent, boolean remove_data)
          Stop the download manager, and do any file/torrent removals.
 void stopIt(int state_after_stopping, boolean remove_torrent, boolean remove_data, boolean for_removal)
          As above but definitely indicates that the stop is for removal (if for_removal is true) and therefore that any removal specific actions such as removing partial files should be performed
 String toString()
           
 void updateAutoUploadPriority(Object key, boolean inc)
           
 
Methods inherited from class org.gudy.azureus2.core3.logging.LogRelation
propogatedRelationText, queryForClass, queryForClass
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

dnd_subfolder

public static volatile String dnd_subfolder

this_mon

protected final AEMonitor this_mon
Constructor Detail

DownloadManagerImpl

public DownloadManagerImpl(GlobalManager _gm,
                           byte[] _torrent_hash,
                           String _torrentFileName,
                           String _torrent_save_dir,
                           String _torrent_save_file,
                           int _initialState,
                           boolean _persistent,
                           boolean _recovered,
                           boolean _open_for_seeding,
                           boolean _has_ever_been_started,
                           List _file_priorities,
                           DownloadManagerInitialisationAdapter _initialisation_adapter)
Method Detail

addGlobalDownloadListener

public static void addGlobalDownloadListener(DownloadManagerListener listener)

removeGlobalDownloadListener

public static void removeGlobalDownloadListener(DownloadManagerListener listener)

getTaggableType

public int getTaggableType()

getTaggableResolver

public TaggableResolver getTaggableResolver()

getTaggableID

public String getTaggableID()

readTorrent

protected void readTorrent()

readParameters

protected void readParameters()

getMaxConnections

protected int[] getMaxConnections(boolean mixed)

getMaxConnectionsWhenSeeding

protected int[] getMaxConnectionsWhenSeeding(boolean mixed)

isMaxConnectionsWhenSeedingEnabled

protected boolean isMaxConnectionsWhenSeedingEnabled()

getMaxSeedConnections

protected int[] getMaxSeedConnections(boolean mixed)

isMaxUploadsWhenSeedingEnabled

protected boolean isMaxUploadsWhenSeedingEnabled()

getMaxUploadsWhenSeeding

protected int getMaxUploadsWhenSeeding()

updateAutoUploadPriority

public void updateAutoUploadPriority(Object key,
                                     boolean inc)
Specified by:
updateAutoUploadPriority in interface DownloadManager

getEffectiveUploadPriority

protected int getEffectiveUploadPriority()

getMaxUploads

public int getMaxUploads()
Specified by:
getMaxUploads in interface DownloadManager

setMaxUploads

public void setMaxUploads(int max)
Specified by:
setMaxUploads in interface DownloadManager

setManualUploadPriority

public void setManualUploadPriority(int priority)

getEffectiveMaxUploads

public int getEffectiveMaxUploads()
Description copied from interface: DownloadManager
Returns the max uploads depending on whether the download is seeding and it has a separate rate for this

Specified by:
getEffectiveMaxUploads in interface DownloadManager
Returns:

getEffectiveUploadRateLimitBytesPerSecond

public int getEffectiveUploadRateLimitBytesPerSecond()
Description copied from interface: DownloadManager
returns the currently in force upload speed limit which may vary from the stats. value as this gives the fixed per-torrent limit

Specified by:
getEffectiveUploadRateLimitBytesPerSecond in interface DownloadManager
Returns:

setFileLinks

protected void setFileLinks()

clearFileLinks

protected void clearFileLinks()

filesExist

public boolean filesExist()
Deprecated. 

Description copied from interface: DownloadManager
Same as filesExist( true );

Specified by:
filesExist in interface DownloadManager
Returns:

filesExist

public boolean filesExist(boolean expected_to_be_allocated)
Description copied from interface: DownloadManager
Checks if all the files the user wants to download from this torrent actually exist on their filesystem.

If a file does not exist, the download will be set to error state.

Specified by:
filesExist in interface DownloadManager
Parameters:
expected_to_be_allocated - if this is false and allocation hasn't been attempted then the method will return with false without marking the download as in an error state
Returns:
Whether all the non-skipped (non-DND) files exist

isPersistent

public boolean isPersistent()
Specified by:
isPersistent in interface DownloadManager

getDisplayName

public String getDisplayName()
Specified by:
getDisplayName in interface DownloadManager

getInternalName

public String getInternalName()
Description copied from interface: DownloadManager
returns a name based on the torrent hash or an empty string if torrent invalid

Specified by:
getInternalName in interface DownloadManager
Returns:

getErrorDetails

public String getErrorDetails()
Specified by:
getErrorDetails in interface DownloadManager

getErrorType

public int getErrorType()
Specified by:
getErrorType in interface DownloadManager

getSize

public long getSize()
Specified by:
getSize in interface DownloadManager

setFailed

protected void setFailed()

setFailed

protected void setFailed(Throwable e)

setFailed

protected void setFailed(String str)

setTorrentInvalid

protected void setTorrentInvalid(String str)

saveResumeData

public void saveResumeData()
Description copied from interface: DownloadManager
persist resume data

Specified by:
saveResumeData in interface DownloadManager

saveDownload

public void saveDownload()
Description copied from interface: DownloadManager
persist any general download related information, excluding resume data which is managed separately by saveResumeData

Specified by:
saveDownload in interface DownloadManager

initialize

public void initialize()
Specified by:
initialize in interface DownloadManager

setStateWaiting

public void setStateWaiting()
Specified by:
setStateWaiting in interface DownloadManager

setStateFinishing

public void setStateFinishing()

setStateQueued

public void setStateQueued()
Specified by:
setStateQueued in interface DownloadManager

getState

public int getState()
Specified by:
getState in interface DownloadManager

getSubState

public int getSubState()
Description copied from interface: DownloadManager
For stopping this returns the target state after stopping (stopped/queued)

Specified by:
getSubState in interface DownloadManager
Returns:

canForceRecheck

public boolean canForceRecheck()
Specified by:
canForceRecheck in interface DownloadManager

forceRecheck

public void forceRecheck()
Specified by:
forceRecheck in interface DownloadManager

forceRecheck

public void forceRecheck(ForceRecheckListener l)
Specified by:
forceRecheck in interface DownloadManager

setPieceCheckingEnabled

public void setPieceCheckingEnabled(boolean enabled)
Description copied from interface: DownloadManager
Use with care - introduced to support speed tests whereby we want to avoid checking the virtual torrent used for the test

Specified by:
setPieceCheckingEnabled in interface DownloadManager

resetFile

public void resetFile(DiskManagerFileInfo file)
Description copied from interface: DownloadManager
Reset the file download state to totally undownloaded. Download must be stopped

Specified by:
resetFile in interface DownloadManager

recheckFile

public void recheckFile(DiskManagerFileInfo file)
Description copied from interface: DownloadManager
Recheck a particular file. Download must be stopped

Specified by:
recheckFile in interface DownloadManager

startDownload

public void startDownload()
Specified by:
startDownload in interface DownloadManager

stopIt

public void stopIt(int state_after_stopping,
                   boolean remove_torrent,
                   boolean remove_data)
Description copied from interface: DownloadManager
Stop the download manager, and do any file/torrent removals.

Specified by:
stopIt in interface DownloadManager
remove_torrent - remove the .torrent file after stopping
remove_data - remove the data file after stopping

stopIt

public void stopIt(int state_after_stopping,
                   boolean remove_torrent,
                   boolean remove_data,
                   boolean for_removal)
Description copied from interface: DownloadManager
As above but definitely indicates that the stop is for removal (if for_removal is true) and therefore that any removal specific actions such as removing partial files should be performed

Specified by:
stopIt in interface DownloadManager

pause

public boolean pause()
Specified by:
pause in interface DownloadManager

pause

public boolean pause(long _resume_time)
Specified by:
pause in interface DownloadManager

getAutoResumeTime

public long getAutoResumeTime()
Specified by:
getAutoResumeTime in interface DownloadManager

isPaused

public boolean isPaused()
Specified by:
isPaused in interface DownloadManager

resume

public void resume()
Specified by:
resume in interface DownloadManager

getAssumedComplete

public boolean getAssumedComplete()
Description copied from interface: DownloadManager
Retrieve whether this download is assumed complete.

Assumed complete status is kept while the torrent is in a non-running state, even if it has no data.

When the torrent starts up, the real complete level will be checked, and if the torrent actually does have missing data, the download will be thrown into error state.

Only a forced-recheck should clear this flag.

Specified by:
getAssumedComplete in interface DownloadManager
See Also:
#requestAssumedCompleteMode()}

requestAssumedCompleteMode

public boolean requestAssumedCompleteMode()
Description copied from interface: DownloadManager
Will set this download to be "assumed complete" for if the download is already complete (excluding DND)

Specified by:
requestAssumedCompleteMode in interface DownloadManager
Returns:
true- success; false- failure, download not complete

setAssumedComplete

protected void setAssumedComplete(boolean _assumedComplete)

getNbSeeds

public int getNbSeeds()
Specified by:
getNbSeeds in interface DownloadManager

getNbPeers

public int getNbPeers()
Specified by:
getNbPeers in interface DownloadManager

getTrackerStatus

public String getTrackerStatus()
Specified by:
getTrackerStatus in interface DownloadManager

getTrackerClient

public TRTrackerAnnouncer getTrackerClient()
Specified by:
getTrackerClient in interface DownloadManager

setAnnounceResult

public void setAnnounceResult(DownloadAnnounceResult result)
Specified by:
setAnnounceResult in interface DownloadManager

setScrapeResult

public void setScrapeResult(DownloadScrapeResult result)
Specified by:
setScrapeResult in interface DownloadManager

getNbPieces

public int getNbPieces()
Specified by:
getNbPieces in interface DownloadManager

getTrackerTime

public int getTrackerTime()
Description copied from interface: DownloadManager
When the next call to the tracker will occur (in seconds)

Specified by:
getTrackerTime in interface DownloadManager

getTorrent

public TOTorrent getTorrent()
Specified by:
getTorrent in interface DownloadManager

getSaveLocation

public File getSaveLocation()
Specified by:
getSaveLocation in interface DownloadManager

getAbsoluteSaveLocation

public File getAbsoluteSaveLocation()
Description copied from interface: DownloadManager
Returns the file location where we save the torrent, this includes the parent directory and the actual file name.

Specified by:
getAbsoluteSaveLocation in interface DownloadManager

setTorrentSaveDir

public void setTorrentSaveDir(String new_dir)
Description copied from interface: DownloadManager
changes the save directory. Only call this if you know what you are doing!!!!

Specified by:
setTorrentSaveDir in interface DownloadManager

setTorrentSaveDir

public void setTorrentSaveDir(String new_dir,
                              String dl_name)
Description copied from interface: DownloadManager
changes the save directory. Only call this if you know what you are doing!!!!

Specified by:
setTorrentSaveDir in interface DownloadManager

getPieceLength

public String getPieceLength()
Specified by:
getPieceLength in interface DownloadManager

getTorrentFileName

public String getTorrentFileName()
Description copied from interface: DownloadManager
This includes the full path to the torrent file.

Specified by:
getTorrentFileName in interface DownloadManager
Returns:

setTorrentFileName

public void setTorrentFileName(String string)
Specified by:
setTorrentFileName in interface DownloadManager

setTrackerScrapeResponse

public void setTrackerScrapeResponse(TRTrackerScraperResponse response)
Specified by:
setTrackerScrapeResponse in interface DownloadManager

getTrackerScrapeResponse

public TRTrackerScraperResponse getTrackerScrapeResponse()
Specified by:
getTrackerScrapeResponse in interface DownloadManager

getActiveScrapeResponse

protected Object[] getActiveScrapeResponse()
Returns the "first" online scrape response found, and its active URL, otherwise one of the failing scrapes

Returns:

getGoodTrackerScrapeResponses

public List<TRTrackerScraperResponse> getGoodTrackerScrapeResponses()
Specified by:
getGoodTrackerScrapeResponses in interface DownloadManager

requestTrackerAnnounce

public void requestTrackerAnnounce(boolean force)
Specified by:
requestTrackerAnnounce in interface DownloadManager

requestTrackerScrape

public void requestTrackerScrape(boolean force)
Specified by:
requestTrackerScrape in interface DownloadManager

setTrackerRefreshDelayOverrides

protected void setTrackerRefreshDelayOverrides(int percent)

activateRequest

protected boolean activateRequest(int count)

getActivationCount

public int getActivationCount()
Specified by:
getActivationCount in interface DownloadManager

getTorrentComment

public String getTorrentComment()
Specified by:
getTorrentComment in interface DownloadManager

getTorrentCreatedBy

public String getTorrentCreatedBy()
Specified by:
getTorrentCreatedBy in interface DownloadManager

getTorrentCreationDate

public long getTorrentCreationDate()
Specified by:
getTorrentCreationDate in interface DownloadManager

getGlobalManager

public GlobalManager getGlobalManager()
Specified by:
getGlobalManager in interface DownloadManager

getDiskManager

public DiskManager getDiskManager()
Specified by:
getDiskManager in interface DownloadManager

getDiskManagerFileInfoSet

public DiskManagerFileInfoSet getDiskManagerFileInfoSet()
Specified by:
getDiskManagerFileInfoSet in interface DownloadManager

getDiskManagerFileInfo

public DiskManagerFileInfo[] getDiskManagerFileInfo()
Deprecated. use getDiskManagerFileInfoSet() instead

Specified by:
getDiskManagerFileInfo in interface DownloadManager

getNumFileInfos

public int getNumFileInfos()
Specified by:
getNumFileInfos in interface DownloadManager

getPeerManager

public PEPeerManager getPeerManager()
Specified by:
getPeerManager in interface DownloadManager

isDownloadComplete

public boolean isDownloadComplete(boolean bIncludeDND)
Description copied from interface: DownloadManager
Retrieves whether the download is complete

Specified by:
isDownloadComplete in interface DownloadManager
Parameters:
bIncludeDND - true- include files marked as Do Not Download.
false- don't include files marked DND.

If there are DND files and you choose to include DND in the calculation, false will always be returned.

Returns:
whether download is complete

addListener

public void addListener(DownloadManagerListener listener)
Specified by:
addListener in interface DownloadManager

addListener

public void addListener(DownloadManagerListener listener,
                        boolean triggerStateChange)
Specified by:
addListener in interface DownloadManager

removeListener

public void removeListener(DownloadManagerListener listener)
Specified by:
removeListener in interface DownloadManager

informStateChanged

protected void informStateChanged()
Doesn't not inform if state didn't change from last inform call


informDownloadEnded

protected void informDownloadEnded()

informPriorityChange

protected void informPriorityChange(DiskManagerFileInfo file)

informPositionChanged

protected void informPositionChanged(int new_position)

addPeerListener

public void addPeerListener(DownloadManagerPeerListener listener)
Specified by:
addPeerListener in interface DownloadManager

addPeerListener

public void addPeerListener(DownloadManagerPeerListener listener,
                            boolean bDispatchForExisting)
Specified by:
addPeerListener in interface DownloadManager

removePeerListener

public void removePeerListener(DownloadManagerPeerListener listener)
Specified by:
removePeerListener in interface DownloadManager

addPieceListener

public void addPieceListener(DownloadManagerPieceListener listener)
Specified by:
addPieceListener in interface DownloadManager

addPieceListener

public void addPieceListener(DownloadManagerPieceListener listener,
                             boolean bDispatchForExisting)
Specified by:
addPieceListener in interface DownloadManager

removePieceListener

public void removePieceListener(DownloadManagerPieceListener listener)
Specified by:
removePieceListener in interface DownloadManager

addPeer

public void addPeer(PEPeer peer)

removePeer

public void removePeer(PEPeer peer)

getCurrentPeers

public PEPeer[] getCurrentPeers()
Specified by:
getCurrentPeers in interface DownloadManager

addPiece

public void addPiece(PEPiece piece)

removePiece

public void removePiece(PEPiece piece)

getCurrentPieces

public PEPiece[] getCurrentPieces()
Specified by:
getCurrentPieces in interface DownloadManager

informWillBeStarted

protected void informWillBeStarted(PEPeerManager pm)

informStarted

protected void informStarted(PEPeerManager pm)

informStopped

protected void informStopped(PEPeerManager pm,
                             boolean for_queue)

getStats

public DownloadManagerStats getStats()
Specified by:
getStats in interface DownloadManager

isForceStart

public boolean isForceStart()
Specified by:
isForceStart in interface DownloadManager

setForceStart

public void setForceStart(boolean forceStart)
Specified by:
setForceStart in interface DownloadManager

downloadEnded

protected void downloadEnded(boolean never_downloaded)
Is called when a download is finished. Activates alerts for the user.

Parameters:
never_downloaded - true indicates that we never actually downloaded anything in this session, but we determined that the download is complete (usually via startDownload())

addDiskListener

public void addDiskListener(DownloadManagerDiskListener listener)
Specified by:
addDiskListener in interface DownloadManager

removeDiskListener

public void removeDiskListener(DownloadManagerDiskListener listener)
Specified by:
removeDiskListener in interface DownloadManager

addActivationListener

public void addActivationListener(DownloadManagerActivationListener listener)
Specified by:
addActivationListener in interface DownloadManager

removeActivationListener

public void removeActivationListener(DownloadManagerActivationListener listener)
Specified by:
removeActivationListener in interface DownloadManager

getHealthStatus

public int getHealthStatus()
Specified by:
getHealthStatus in interface DownloadManager
Returns:
the wealthy status of this download

getNATStatus

public int getNATStatus()
Description copied from interface: DownloadManager
See plugin ConnectionManager.NAT_ constants for return values

Specified by:
getNATStatus in interface DownloadManager
Returns:

getPosition

public int getPosition()
Specified by:
getPosition in interface DownloadManager

setPosition

public void setPosition(int new_position)
Specified by:
setPosition in interface DownloadManager

addTrackerListener

public void addTrackerListener(DownloadManagerTrackerListener listener)
Specified by:
addTrackerListener in interface DownloadManager

removeTrackerListener

public void removeTrackerListener(DownloadManagerTrackerListener listener)
Specified by:
removeTrackerListener in interface DownloadManager

deleteDataFiles

protected void deleteDataFiles()

deletePartialDataFiles

protected void deletePartialDataFiles()

deleteTorrentFile

protected void deleteTorrentFile()

getDownloadState

public DownloadManagerState getDownloadState()
Specified by:
getDownloadState in interface DownloadManager

getData

public Object getData(String key)
Description copied from interface: DownloadManager
To retreive arbitrary objects against this object.

Specified by:
getData in interface DownloadManager

setData

public void setData(String key,
                    Object value)
Description copied from interface: DownloadManager
To store arbitrary objects against this object.

Specified by:
setData in interface DownloadManager

getUserData

public Object getUserData(Object key)
To retreive arbitrary objects against a download.

Specified by:
getUserData in interface DownloadManager

setUserData

public void setUserData(Object key,
                        Object value)
To store arbitrary objects against a download.

Specified by:
setUserData in interface DownloadManager

getTaggableTransientProperty

public Object getTaggableTransientProperty(String key)

setTaggableTransientProperty

public void setTaggableTransientProperty(String key,
                                         Object value)

isDataAlreadyAllocated

public boolean isDataAlreadyAllocated()
Description copied from interface: DownloadManager
Determine whether disk allocation has already been done. Used for checking if data is missing on a previously-loaded torrent.

Specified by:
isDataAlreadyAllocated in interface DownloadManager
Returns:
true if data files have already been allocated

setDataAlreadyAllocated

public void setDataAlreadyAllocated(boolean already_allocated)
Description copied from interface: DownloadManager
Set whether data allocation has already been done, so we know when to allocate and when to throw a missing-data error message.

Specified by:
setDataAlreadyAllocated in interface DownloadManager

setSeedingRank

public void setSeedingRank(int rank)
Specified by:
setSeedingRank in interface DownloadManager

getSeedingRank

public int getSeedingRank()
Specified by:
getSeedingRank in interface DownloadManager

getCreationTime

public long getCreationTime()
Description copied from interface: DownloadManager
gives the time this download was created (not the torrent but the download itself)

Specified by:
getCreationTime in interface DownloadManager
Returns:

setCreationTime

public void setCreationTime(long t)
Specified by:
setCreationTime in interface DownloadManager

isSwarmMerging

public String isSwarmMerging()
Specified by:
isSwarmMerging in interface DownloadManager

getExtendedMessagingMode

public int getExtendedMessagingMode()
Specified by:
getExtendedMessagingMode in interface DownloadManager
Returns:
messaging mode = az, lt or bt

setCryptoLevel

public void setCryptoLevel(int level)
Specified by:
setCryptoLevel in interface DownloadManager

getCryptoLevel

public int getCryptoLevel()
Specified by:
getCryptoLevel in interface DownloadManager

moveDataFiles

public void moveDataFiles(File new_parent_dir)
                   throws DownloadManagerException
Description copied from interface: DownloadManager
Move data files to new location. Torrent must be in stopped/error state

Specified by:
moveDataFiles in interface DownloadManager
Throws:
DownloadManagerException

moveDataFilesLive

public void moveDataFilesLive(File new_parent_dir)
                       throws DownloadManagerException
Description copied from interface: DownloadManager
At some point someone made the file-move operations stop+restart the download when it was designed to work without doing this (see move-on-complete for example). As I don't know the reason for this change I've (parg) added a new method to do this in the hope that we might in time migrate back to the 'proper' behaviour. grrr

Specified by:
moveDataFilesLive in interface DownloadManager
Throws:
DownloadManagerException

renameDownload

public void renameDownload(String new_name)
                    throws DownloadManagerException
Description copied from interface: DownloadManager
Rename the download - this means the name of the file being downloaded (for single file torrents), or the name of the directory holding the files (in a multi-file torrent). This does not alter the displayed name of the download.

Specified by:
renameDownload in interface DownloadManager
Throws:
DownloadManagerException

moveDataFiles

public void moveDataFiles(File destination,
                          String new_name)
                   throws DownloadManagerException
Description copied from interface: DownloadManager
Move the files and rename a download in one go. For convenience - either argument can be null, but not both.

Specified by:
moveDataFiles in interface DownloadManager
Throws:
DownloadManagerException
See Also:
DownloadManager.moveDataFiles(File), DownloadManager.renameDownload(String)

moveDataFiles

public void moveDataFiles(File destination,
                          String new_name,
                          boolean live)
                   throws DownloadManagerException
Throws:
DownloadManagerException

copyDataFiles

public void copyDataFiles(File parent_dir)
                   throws DownloadManagerException
Specified by:
copyDataFiles in interface DownloadManager
Throws:
DownloadManagerException

moveTorrentFile

public void moveTorrentFile(File new_parent_dir)
                     throws DownloadManagerException
Description copied from interface: DownloadManager
Move torrent file to new location. Download must be stopped/error

Specified by:
moveTorrentFile in interface DownloadManager
Throws:
DownloadManagerException

moveTorrentFile

public void moveTorrentFile(File new_parent_dir,
                            String new_name)
                     throws DownloadManagerException
Specified by:
moveTorrentFile in interface DownloadManager
Throws:
DownloadManagerException

setTorrentFile

public void setTorrentFile(File new_parent_dir,
                           String new_name)
                    throws DownloadManagerException
Description copied from interface: DownloadManager
Sets the torrent file name (will perform a move of the torrent file) - this shouldn't be used unless you know what you are doing (it requires the download to be stopped!) - it is safer to use moveTorrentFile instead.

Specified by:
setTorrentFile in interface DownloadManager
Throws:
DownloadManagerException

isInDefaultSaveDir

public boolean isInDefaultSaveDir()
Description copied from interface: DownloadManager
Returns true if the download is being saved to one of the default save directories.

Specified by:
isInDefaultSaveDir in interface DownloadManager

seedPieceRecheck

public boolean seedPieceRecheck()
Description copied from interface: DownloadManager
Gives the download an opportunity to schedule seeding mode piece rechecks if desired

Specified by:
seedPieceRecheck in interface DownloadManager
Returns:
true if a piece has been rechecked

addRateLimiter

public void addRateLimiter(LimitedRateGroup group,
                           boolean upload)
Specified by:
addRateLimiter in interface DownloadManager

getRateLimiters

public LimitedRateGroup[] getRateLimiters(boolean upload)
Specified by:
getRateLimiters in interface DownloadManager

removeRateLimiter

public void removeRateLimiter(LimitedRateGroup group,
                              boolean upload)
Specified by:
removeRateLimiter in interface DownloadManager

isTrackerError

public boolean isTrackerError()
Specified by:
isTrackerError in interface DownloadManager

isUnauthorisedOnTracker

public boolean isUnauthorisedOnTracker()
Specified by:
isUnauthorisedOnTracker in interface DownloadManager

getTrackerPeerSources

public List<TrackerPeerSource> getTrackerPeerSources()
Specified by:
getTrackerPeerSources in interface DownloadManager

addTPSListener

public void addTPSListener(DownloadManagerTPSListener listener)
Specified by:
addTPSListener in interface DownloadManager

removeTPSListener

public void removeTPSListener(DownloadManagerTPSListener listener)
Specified by:
removeTPSListener in interface DownloadManager

equals

public boolean equals(Object obj)
Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getRelationText

public String getRelationText()
Description copied from class: LogRelation
A short description of what your class holds that can be printed by the logger

Overrides:
getRelationText in class LogRelation
Returns:

getQueryableInterfaces

public Object[] getQueryableInterfaces()
Description copied from class: LogRelation
Query this class for a reference to another class that it may hold

Overrides:
getQueryableInterfaces in class LogRelation
Returns:
If found, the class desired. Otherwise, null.

toString

public String toString()
Overrides:
toString in class Object

generateEvidence

public void generateEvidence(IndentWriter writer)
Specified by:
generateEvidence in interface DownloadManager

destroy

public void destroy(boolean is_duplicate)
Description copied from interface: DownloadManager
Indicates that the download manager is no longer needed

Specified by:
destroy in interface DownloadManager
Parameters:
is_duplicate - indicates whether this dm is being destroyed because it is a duplicate

isDestroyed

public boolean isDestroyed()
Specified by:
isDestroyed in interface DownloadManager

getStorageType

public int[] getStorageType(DiskManagerFileInfo[] info)
Specified by:
getStorageType in interface DownloadManager

canMoveDataFiles

public boolean canMoveDataFiles()
Specified by:
canMoveDataFiles in interface DownloadManager

rename

public void rename(String name)
            throws DownloadManagerException
Description copied from interface: DownloadManager
Renames the save file, torrent file and the displayed name.

Specified by:
rename in interface DownloadManager
Throws:
DownloadManagerException

renameTorrent

public void renameTorrent(String name)
                   throws DownloadManagerException
Specified by:
renameTorrent in interface DownloadManager
Throws:
DownloadManagerException

renameTorrentSafe

public void renameTorrentSafe(String name)
                       throws DownloadManagerException
Description copied from interface: DownloadManager
Same as renameTorrent, but appends numbers if torrent already exists

Specified by:
renameTorrentSafe in interface DownloadManager
Throws:
DownloadManagerException

requestAttention

public void requestAttention()
Specified by:
requestAttention in interface DownloadManager

fireGlobalManagerEvent

public void fireGlobalManagerEvent(int eventType)
Specified by:
fireGlobalManagerEvent in interface DownloadManager

setFilePriorities

public void setFilePriorities(DiskManagerFileInfo[] fileInfos,
                              int priority)
Description copied from interface: DownloadManager
Sets the priority for an array for files

Specified by:
setFilePriorities in interface DownloadManager