org.gudy.azureus2.core3.download.impl
Class DownloadManagerStateImpl
java.lang.Object
org.gudy.azureus2.core3.download.impl.DownloadManagerStateImpl
- All Implemented Interfaces:
- ParameterListener, DownloadManagerState
public class DownloadManagerStateImpl
- extends Object
- implements DownloadManagerState, ParameterListener
- Author:
- parg
Overall aim of this is to stop updating the torrent file itself and update something
Azureus owns. To this end a file based on torrent hash is created in user-dir/active
It is actually just a copy of the torrent file
Fields inherited from interface org.gudy.azureus2.core3.download.DownloadManagerState |
AT_AGGREGATE_SCRAPE_CACHE, AT_AVAIL_BAD_TIME, AT_CANONICAL_SD_DMAP, AT_CATEGORY, AT_COMPLETE_LAST_TIME, AT_DISPLAY_NAME, AT_DL_FILE_ALERTS, AT_DND_PREFIX, AT_DND_SUBFOLDER, AT_FILE_DOWNLOADED, AT_FILE_LINKS_DEPRECATED, AT_FILE_LINKS2, AT_FILE_OTHER_HASHES, AT_FILE_STORE_TYPES, AT_FILES_EXPANDED, AT_FLAGS, AT_INCOMP_FILE_SUFFIX, AT_LAST_ADDED_TO_ACTIVE_TAG, AT_MD_INFO_DICT_SIZE, AT_MERGED_DATA, AT_NETWORKS, AT_PARAMETERS, AT_PEAK_RECEIVE_RATE, AT_PEAK_SEND_RATE, AT_PEER_SOURCES, AT_PEER_SOURCES_DENIED, AT_PRIMARY_FILE, AT_PRIMARY_FILE_IDX, AT_RELATIVE_SAVE_PATH, AT_REORDER_MIN_MB, AT_RESUME_STATE, AT_SCRAPE_CACHE, AT_SCRAPE_CACHE_SOURCE, AT_SECRETS, AT_SHARE_RATIO_PROGRESS, AT_TIME_SINCE_DOWNLOAD, AT_TIME_SINCE_UPLOAD, AT_TIME_STOPPED, AT_TRACKER_CLIENT_EXTENSIONS, AT_USER, AT_USER_COMMENT, AT_VERSION, ATTRIBUTE_DEFAULTS, DEFAULT_MAX_UPLOADS, DEFAULT_UPLOAD_PRIORITY, FLAG_ALLOW_PERMITTED_PEER_SOURCE_CHANGES, FLAG_DISABLE_AUTO_FILE_MOVE, FLAG_DISABLE_IP_FILTER, FLAG_DO_NOT_DELETE_DATA_ON_REMOVE, FLAG_ERROR_REPORTED, FLAG_FORCE_DIRECT_DELETE, FLAG_INITIAL_NETWORKS_SET, FLAG_LOW_NOISE, FLAG_METADATA_DOWNLOAD, FLAG_MOVE_ON_COMPLETION_DONE, FLAG_ONLY_EVER_SEEDED, FLAG_SCAN_INCOMPLETE_PIECES, MIN_MAX_UPLOADS, PARAM_DND_FLAGS, PARAM_DOWNLOAD_ADDED_TIME, PARAM_DOWNLOAD_COMPLETED_TIME, PARAM_DOWNLOAD_FILE_COMPLETED_TIME, PARAM_DOWNLOAD_LAST_ACTIVE_TIME, PARAM_MAX_PEERS, PARAM_MAX_PEERS_WHEN_SEEDING, PARAM_MAX_PEERS_WHEN_SEEDING_ENABLED, PARAM_MAX_SEEDS, PARAM_MAX_SHARE_RATIO, PARAM_MAX_UPLOAD_WHEN_BUSY, PARAM_MAX_UPLOADS, PARAM_MAX_UPLOADS_WHEN_SEEDING, PARAM_MAX_UPLOADS_WHEN_SEEDING_ENABLED, PARAM_MIN_SHARE_RATIO, PARAM_RANDOM_SEED, PARAM_STATS_COUNTED, PARAM_UPLOAD_PRIORITY, PARAMETERS |
Method Summary |
static void |
addGlobalListener(DownloadManagerStateAttributeListener l,
String attribute,
int event_type)
|
void |
addListener(DownloadManagerStateAttributeListener l,
String attribute,
int event_type)
|
void |
addListener(DownloadManagerStateListener l)
|
void |
clearFileLinks()
|
void |
clearResumeData()
|
void |
clearTrackerResponseCache()
|
void |
delete()
deletes the saved state |
static void |
deleteDownloadState(byte[] download_hash)
|
static void |
deleteDownloadState(File source_dir,
byte[] download_hash)
|
void |
discardFluff()
|
static void |
discardGlobalStateCache()
|
void |
dump(IndentWriter writer)
|
boolean |
exportState(File target_dir)
|
void |
generateEvidence(IndentWriter writer)
|
String |
getAttribute(String name)
|
boolean |
getBooleanAttribute(String name)
|
boolean |
getBooleanParameter(String name)
|
Category |
getCategory()
|
String |
getDisplayName()
|
DownloadManager |
getDownloadManager()
|
static DownloadManagerState |
getDownloadState(DownloadManager dm)
|
protected static DownloadManagerState |
getDownloadState(DownloadManagerImpl download_manager,
String torrent_file,
byte[] torrent_hash,
boolean inactive)
|
static DownloadManagerState |
getDownloadState(TOTorrent original_torrent)
|
File |
getFileLink(int source_index,
File link_source)
|
LinkFileMap |
getFileLinks()
returns a File -> File map of the defined links (empty if no links) |
boolean |
getFlag(long flag)
|
long |
getFlags()
|
protected static File |
getGlobalStateFile()
|
int |
getIntAttribute(String name)
|
int |
getIntParameter(String name)
|
String[] |
getListAttribute(String attribute_name)
|
String |
getListAttribute(String name,
int idx)
|
protected List |
getListAttributeSupport(String attribute_name)
|
long |
getLongAttribute(String attribute_name)
|
long |
getLongParameter(String name)
|
Map |
getMapAttribute(String attribute_name)
|
String[] |
getNetworks()
|
String[] |
getPeerSources()
|
DiskManagerFileInfo |
getPrimaryFile()
|
String |
getRelativeSavePath()
|
Map |
getResumeData()
|
File |
getStateFile()
|
protected static File |
getStateFile(byte[] torrent_hash)
|
protected String |
getStringAttribute(String attribute_name)
|
TOTorrent |
getTorrent()
|
String |
getTrackerClientExtensions()
|
Map |
getTrackerResponseCache()
|
String |
getUserComment()
|
boolean |
hasAttribute(String name)
|
static void |
importDownloadState(File source_dir,
byte[] download_hash)
|
protected void |
informWillRead(String attribute_name)
|
protected void |
informWritten(String attribute_name)
|
boolean |
isNetworkEnabled(String network)
|
boolean |
isOurContent()
|
boolean |
isPeerSourceEnabled(String peerSource)
|
boolean |
isPeerSourcePermitted(String peerSource)
|
boolean |
isResumeDataComplete()
|
static void |
loadGlobalStateCache()
|
protected void |
mergeTorrentDetails(TOTorrent other_torrent)
|
void |
parameterChanged(String parameterName)
Called, when a parameter has changed. |
boolean |
parameterExists(String name)
|
static void |
removeGlobalListener(DownloadManagerStateAttributeListener l,
String attribute,
int event_type)
|
void |
removeListener(DownloadManagerStateAttributeListener l,
String attribute,
int event_type)
|
void |
removeListener(DownloadManagerStateListener l)
|
void |
save()
|
protected void |
save(boolean force)
|
static void |
saveGlobalStateCache()
|
void |
setActive(boolean active)
|
void |
setAttribute(String name,
String value)
|
void |
setBooleanAttribute(String name,
boolean value)
|
void |
setBooleanParameter(String name,
boolean value)
|
void |
setCategory(Category cat)
|
void |
setDisplayName(String value)
|
protected void |
setDownloadManager(DownloadManagerImpl dm)
|
void |
setFileLink(int source_index,
File link_source,
File link_destination)
|
void |
setFileLinks(List<Integer> source_indexes,
List<File> link_sources,
List<File> link_destinations)
|
void |
setFlag(long flag,
boolean set)
|
void |
setIntAttribute(String name,
int value)
|
void |
setIntParameter(String name,
int value)
|
protected void |
setListAttribute(String attribute_name,
List attribute_value)
|
void |
setListAttribute(String name,
String[] values)
|
void |
setLongAttribute(String attribute_name,
long attribute_value)
|
void |
setLongParameter(String name,
long value)
|
void |
setMapAttribute(String attribute_name,
Map attribute_value)
|
protected void |
setMapAttribute(String attribute_name,
Map attribute_value,
boolean disable_change_notification)
|
void |
setNetworkEnabled(String network,
boolean enabled)
|
void |
setNetworks(String[] networks)
|
void |
setParameterDefault(String name)
Reset to default value |
void |
setPeerSourceEnabled(String source,
boolean enabled)
|
void |
setPeerSourcePermitted(String peerSource,
boolean enabled)
|
void |
setPeerSources(String[] ps)
|
void |
setPrimaryFile(DiskManagerFileInfo dmfi)
|
void |
setResumeData(Map data)
|
protected void |
setStringAttribute(String attribute_name,
String attribute_value)
|
void |
setTrackerClientExtensions(String value)
|
void |
setTrackerResponseCache(Map value)
|
void |
setUserComment(String value)
|
void |
suppressStateSave(boolean suppress)
This method should only be invoked in matching try-finally pairs. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SUPPRESS_FIXUP_ERRORS
public static boolean SUPPRESS_FIXUP_ERRORS
DownloadManagerStateImpl
protected DownloadManagerStateImpl(DownloadManagerImpl _download_manager,
TorrentUtils.ExtendedTorrent _torrent)
getDownloadState
public static DownloadManagerState getDownloadState(TOTorrent original_torrent)
throws TOTorrentException
- Throws:
TOTorrentException
getDownloadState
protected static DownloadManagerState getDownloadState(DownloadManagerImpl download_manager,
String torrent_file,
byte[] torrent_hash,
boolean inactive)
throws TOTorrentException
- Throws:
TOTorrentException
getStateFile
protected static File getStateFile(byte[] torrent_hash)
getGlobalStateFile
protected static File getGlobalStateFile()
loadGlobalStateCache
public static void loadGlobalStateCache()
saveGlobalStateCache
public static void saveGlobalStateCache()
discardGlobalStateCache
public static void discardGlobalStateCache()
importDownloadState
public static void importDownloadState(File source_dir,
byte[] download_hash)
throws DownloadManagerException
- Throws:
DownloadManagerException
deleteDownloadState
public static void deleteDownloadState(byte[] download_hash)
throws DownloadManagerException
- Throws:
DownloadManagerException
deleteDownloadState
public static void deleteDownloadState(File source_dir,
byte[] download_hash)
throws DownloadManagerException
- Throws:
DownloadManagerException
parameterChanged
public void parameterChanged(String parameterName)
- Description copied from interface:
ParameterListener
- Called, when a parameter has changed.
The listener could only react if the parameter name is relevant.
Or the listener can just read all parameters again.
- Specified by:
parameterChanged
in interface ParameterListener
- Parameters:
parameterName
- the name of the parameter that has changed
getDownloadManager
public DownloadManager getDownloadManager()
- Specified by:
getDownloadManager
in interface DownloadManagerState
setDownloadManager
protected void setDownloadManager(DownloadManagerImpl dm)
getStateFile
public File getStateFile()
- Specified by:
getStateFile
in interface DownloadManagerState
clearTrackerResponseCache
public void clearTrackerResponseCache()
- Specified by:
clearTrackerResponseCache
in interface DownloadManagerState
getTrackerResponseCache
public Map getTrackerResponseCache()
- Specified by:
getTrackerResponseCache
in interface DownloadManagerState
setTrackerResponseCache
public void setTrackerResponseCache(Map value)
- Specified by:
setTrackerResponseCache
in interface DownloadManagerState
getResumeData
public Map getResumeData()
- Specified by:
getResumeData
in interface DownloadManagerState
clearResumeData
public void clearResumeData()
- Specified by:
clearResumeData
in interface DownloadManagerState
setResumeData
public void setResumeData(Map data)
- Specified by:
setResumeData
in interface DownloadManagerState
isResumeDataComplete
public boolean isResumeDataComplete()
- Specified by:
isResumeDataComplete
in interface DownloadManagerState
getTorrent
public TOTorrent getTorrent()
- Specified by:
getTorrent
in interface DownloadManagerState
setActive
public void setActive(boolean active)
- Specified by:
setActive
in interface DownloadManagerState
discardFluff
public void discardFluff()
- Specified by:
discardFluff
in interface DownloadManagerState
exportState
public boolean exportState(File target_dir)
- Specified by:
exportState
in interface DownloadManagerState
suppressStateSave
public void suppressStateSave(boolean suppress)
- Description copied from interface:
DownloadManagerState
- This method should only be invoked in matching try-finally pairs. If it is invoked with true
multiple times it must be invoked with false the equal amount of times to reallow state
writes
- Specified by:
suppressStateSave
in interface DownloadManagerState
- Parameters:
suppress
- when set to true prevents flushing of the state/increments the internal nesting
counter, decrements/allows flush otherwise
save
public void save()
- Specified by:
save
in interface DownloadManagerState
save
protected void save(boolean force)
delete
public void delete()
- Description copied from interface:
DownloadManagerState
- deletes the saved state
- Specified by:
delete
in interface DownloadManagerState
mergeTorrentDetails
protected void mergeTorrentDetails(TOTorrent other_torrent)
setFlag
public void setFlag(long flag,
boolean set)
- Specified by:
setFlag
in interface DownloadManagerState
getFlag
public boolean getFlag(long flag)
- Specified by:
getFlag
in interface DownloadManagerState
getFlags
public long getFlags()
- Specified by:
getFlags
in interface DownloadManagerState
parameterExists
public boolean parameterExists(String name)
- Specified by:
parameterExists
in interface DownloadManagerState
- Returns:
setParameterDefault
public void setParameterDefault(String name)
- Description copied from interface:
DownloadManagerState
- Reset to default value
- Specified by:
setParameterDefault
in interface DownloadManagerState
getLongParameter
public long getLongParameter(String name)
- Specified by:
getLongParameter
in interface DownloadManagerState
setLongParameter
public void setLongParameter(String name,
long value)
- Specified by:
setLongParameter
in interface DownloadManagerState
getIntParameter
public int getIntParameter(String name)
- Specified by:
getIntParameter
in interface DownloadManagerState
setIntParameter
public void setIntParameter(String name,
int value)
- Specified by:
setIntParameter
in interface DownloadManagerState
getBooleanParameter
public boolean getBooleanParameter(String name)
- Specified by:
getBooleanParameter
in interface DownloadManagerState
setBooleanParameter
public void setBooleanParameter(String name,
boolean value)
- Specified by:
setBooleanParameter
in interface DownloadManagerState
setAttribute
public void setAttribute(String name,
String value)
- Specified by:
setAttribute
in interface DownloadManagerState
getAttribute
public String getAttribute(String name)
- Specified by:
getAttribute
in interface DownloadManagerState
getCategory
public Category getCategory()
- Specified by:
getCategory
in interface DownloadManagerState
setCategory
public void setCategory(Category cat)
- Specified by:
setCategory
in interface DownloadManagerState
getTrackerClientExtensions
public String getTrackerClientExtensions()
- Specified by:
getTrackerClientExtensions
in interface DownloadManagerState
setTrackerClientExtensions
public void setTrackerClientExtensions(String value)
- Specified by:
setTrackerClientExtensions
in interface DownloadManagerState
getDisplayName
public String getDisplayName()
- Specified by:
getDisplayName
in interface DownloadManagerState
setDisplayName
public void setDisplayName(String value)
- Specified by:
setDisplayName
in interface DownloadManagerState
getUserComment
public String getUserComment()
- Specified by:
getUserComment
in interface DownloadManagerState
setUserComment
public void setUserComment(String value)
- Specified by:
setUserComment
in interface DownloadManagerState
getRelativeSavePath
public String getRelativeSavePath()
- Specified by:
getRelativeSavePath
in interface DownloadManagerState
getPrimaryFile
public DiskManagerFileInfo getPrimaryFile()
- Specified by:
getPrimaryFile
in interface DownloadManagerState
setPrimaryFile
public void setPrimaryFile(DiskManagerFileInfo dmfi)
- Specified by:
setPrimaryFile
in interface DownloadManagerState
- Parameters:
primary
-
getNetworks
public String[] getNetworks()
- Specified by:
getNetworks
in interface DownloadManagerState
isNetworkEnabled
public boolean isNetworkEnabled(String network)
- Specified by:
isNetworkEnabled
in interface DownloadManagerState
setNetworks
public void setNetworks(String[] networks)
- Specified by:
setNetworks
in interface DownloadManagerState
setNetworkEnabled
public void setNetworkEnabled(String network,
boolean enabled)
- Specified by:
setNetworkEnabled
in interface DownloadManagerState
getPeerSources
public String[] getPeerSources()
- Specified by:
getPeerSources
in interface DownloadManagerState
isPeerSourceEnabled
public boolean isPeerSourceEnabled(String peerSource)
- Specified by:
isPeerSourceEnabled
in interface DownloadManagerState
isPeerSourcePermitted
public boolean isPeerSourcePermitted(String peerSource)
- Specified by:
isPeerSourcePermitted
in interface DownloadManagerState
setPeerSourcePermitted
public void setPeerSourcePermitted(String peerSource,
boolean enabled)
- Specified by:
setPeerSourcePermitted
in interface DownloadManagerState
setPeerSources
public void setPeerSources(String[] ps)
- Specified by:
setPeerSources
in interface DownloadManagerState
setPeerSourceEnabled
public void setPeerSourceEnabled(String source,
boolean enabled)
- Specified by:
setPeerSourceEnabled
in interface DownloadManagerState
setFileLink
public void setFileLink(int source_index,
File link_source,
File link_destination)
- Specified by:
setFileLink
in interface DownloadManagerState
setFileLinks
public void setFileLinks(List<Integer> source_indexes,
List<File> link_sources,
List<File> link_destinations)
- Specified by:
setFileLinks
in interface DownloadManagerState
clearFileLinks
public void clearFileLinks()
- Specified by:
clearFileLinks
in interface DownloadManagerState
getFileLink
public File getFileLink(int source_index,
File link_source)
- Specified by:
getFileLink
in interface DownloadManagerState
getFileLinks
public LinkFileMap getFileLinks()
- Description copied from interface:
DownloadManagerState
- returns a File -> File map of the defined links (empty if no links)
- Specified by:
getFileLinks
in interface DownloadManagerState
- Returns:
isOurContent
public boolean isOurContent()
- Specified by:
isOurContent
in interface DownloadManagerState
- Returns:
getStringAttribute
protected String getStringAttribute(String attribute_name)
setStringAttribute
protected void setStringAttribute(String attribute_name,
String attribute_value)
getLongAttribute
public long getLongAttribute(String attribute_name)
- Specified by:
getLongAttribute
in interface DownloadManagerState
setLongAttribute
public void setLongAttribute(String attribute_name,
long attribute_value)
- Specified by:
setLongAttribute
in interface DownloadManagerState
setListAttribute
public void setListAttribute(String name,
String[] values)
- Specified by:
setListAttribute
in interface DownloadManagerState
getListAttribute
public String getListAttribute(String name,
int idx)
- Specified by:
getListAttribute
in interface DownloadManagerState
getListAttribute
public String[] getListAttribute(String attribute_name)
- Specified by:
getListAttribute
in interface DownloadManagerState
getListAttributeSupport
protected List getListAttributeSupport(String attribute_name)
setListAttribute
protected void setListAttribute(String attribute_name,
List attribute_value)
getMapAttribute
public Map getMapAttribute(String attribute_name)
- Specified by:
getMapAttribute
in interface DownloadManagerState
setMapAttribute
public void setMapAttribute(String attribute_name,
Map attribute_value)
- Specified by:
setMapAttribute
in interface DownloadManagerState
setMapAttribute
protected void setMapAttribute(String attribute_name,
Map attribute_value,
boolean disable_change_notification)
hasAttribute
public boolean hasAttribute(String name)
- Specified by:
hasAttribute
in interface DownloadManagerState
setIntAttribute
public void setIntAttribute(String name,
int value)
- Specified by:
setIntAttribute
in interface DownloadManagerState
getIntAttribute
public int getIntAttribute(String name)
- Specified by:
getIntAttribute
in interface DownloadManagerState
setBooleanAttribute
public void setBooleanAttribute(String name,
boolean value)
- Specified by:
setBooleanAttribute
in interface DownloadManagerState
getBooleanAttribute
public boolean getBooleanAttribute(String name)
- Specified by:
getBooleanAttribute
in interface DownloadManagerState
getDownloadState
public static DownloadManagerState getDownloadState(DownloadManager dm)
informWritten
protected void informWritten(String attribute_name)
informWillRead
protected void informWillRead(String attribute_name)
addListener
public void addListener(DownloadManagerStateListener l)
- Specified by:
addListener
in interface DownloadManagerState
removeListener
public void removeListener(DownloadManagerStateListener l)
- Specified by:
removeListener
in interface DownloadManagerState
addListener
public void addListener(DownloadManagerStateAttributeListener l,
String attribute,
int event_type)
- Specified by:
addListener
in interface DownloadManagerState
removeListener
public void removeListener(DownloadManagerStateAttributeListener l,
String attribute,
int event_type)
- Specified by:
removeListener
in interface DownloadManagerState
addGlobalListener
public static void addGlobalListener(DownloadManagerStateAttributeListener l,
String attribute,
int event_type)
removeGlobalListener
public static void removeGlobalListener(DownloadManagerStateAttributeListener l,
String attribute,
int event_type)
generateEvidence
public void generateEvidence(IndentWriter writer)
- Specified by:
generateEvidence
in interface DownloadManagerState
dump
public void dump(IndentWriter writer)
- Specified by:
dump
in interface DownloadManagerState