Class TorrentManagerImpl
- java.lang.Object
-
- com.biglybt.pifimpl.local.torrent.TorrentManagerImpl
-
- All Implemented Interfaces:
TOTorrentProgressListener
,TorrentManager
public class TorrentManagerImpl extends java.lang.Object implements TorrentManager, TOTorrentProgressListener
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
TorrentManagerImpl.TorrentOptionsImpl
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Map<java.lang.String,TorrentAttribute>
attribute_map
private static TorrentAttribute
category_attribute
private static AEMonitor
class_mon
private static TorrentAttribute
comment_attribute
private static TorrentAttribute
disp_name_attribute
protected static CopyOnWriteList<TorrentManagerListener>
listeners
private static TorrentAttribute
networks_attribute
private static TorrentAttribute
peer_sources_attribute
protected PluginInterface
plugin_interface
private static TorrentAttribute
relative_save_path_attribute
private static TorrentAttribute
share_properties_attribute
private static TorrentManagerImpl
singleton
private java.util.Map<TorrentOpenOptions,TorrentManagerImpl.TorrentOptionsImpl>
too_state
private static TorrentAttribute
tr_ext_attribute
-
Fields inherited from interface com.biglybt.pif.torrent.TorrentManager
PRESERVE_ALL, PRESERVE_ENCODING, PRESERVE_NONE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
TorrentManagerImpl(PluginInterface _pi)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(TorrentManagerListener l)
Torrent
createFromBEncodedData(byte[] data)
decodes a torrent encoded using the normal "bencoding" rules from a byte arrayTorrent
createFromBEncodedData(byte[] data, int preserve)
decodes a torrent encoded using the normal "bencoding" rules from a byte arrayTorrent
createFromBEncodedFile(java.io.File file)
decodes a torrent encoded using the normal "bencoding" rules from a fileTorrent
createFromBEncodedFile(java.io.File file, boolean for_seeding)
decodes a torrent encoded using the normal "bencoding" rules from a file but discards the piece hashes to save memory.Torrent
createFromBEncodedFile(java.io.File file, int preserve)
decodes a torrent encoded using the normal "bencoding" rules from a fileTorrent
createFromBEncodedInputStream(java.io.InputStream data)
decodes a torrent encoded using the normal "bencoding" rules from an InputStreamTorrent
createFromBEncodedInputStream(java.io.InputStream data, int preserve)
decodes a torrent encoded using the normal "bencoding" rules from an InputStreamTorrent
createFromDataFile(java.io.File data, java.net.URL announce_url)
creates a new torrent from an input fileTorrent
createFromDataFile(java.io.File data, java.net.URL announce_url, boolean include_other_hashes)
TorrentCreator
createFromDataFileEx(java.io.File data, java.net.URL announce_url, boolean include_other_hashes)
private void
fireEvent(int type, java.lang.Object data)
TorrentAttribute
getAttribute(java.lang.String name)
Gives access to the standard built-in attributesTorrentAttribute[]
getDefinedAttributes()
Gives access to the currently defined torrent attributes.TorrentAttribute
getPluginAttribute(java.lang.String name)
Gives access to/creates arbitrary String attributes for plugins to use.static TorrentManagerImpl
getSingleton()
TorrentDownloader
getURLDownloader(java.net.URL url)
TorrentDownloader
getURLDownloader(java.net.URL url, java.lang.String user_name, java.lang.String password)
void
optionsAccepted(TorrentOpenOptions options)
void
optionsAdded(TorrentOpenOptions options)
void
optionsRemoved(TorrentOpenOptions options)
private TOTorrent
preserveFields(TOTorrent torrent, int preserve)
void
removeListener(TorrentManagerListener l)
void
reportCurrentTask(java.lang.String task_description)
void
reportProgress(int percent_complete)
TorrentManager
specialise(PluginInterface _pi)
protected void
tryToSetDefaultTorrentEncoding(TOTorrent torrent)
protected void
tryToSetTorrentEncoding(TOTorrent torrent, java.lang.String encoding)
-
-
-
Field Detail
-
singleton
private static TorrentManagerImpl singleton
-
class_mon
private static AEMonitor class_mon
-
category_attribute
private static TorrentAttribute category_attribute
-
share_properties_attribute
private static TorrentAttribute share_properties_attribute
-
networks_attribute
private static TorrentAttribute networks_attribute
-
peer_sources_attribute
private static TorrentAttribute peer_sources_attribute
-
tr_ext_attribute
private static TorrentAttribute tr_ext_attribute
-
disp_name_attribute
private static TorrentAttribute disp_name_attribute
-
comment_attribute
private static TorrentAttribute comment_attribute
-
relative_save_path_attribute
private static TorrentAttribute relative_save_path_attribute
-
attribute_map
private static java.util.Map<java.lang.String,TorrentAttribute> attribute_map
-
listeners
protected static CopyOnWriteList<TorrentManagerListener> listeners
-
plugin_interface
protected PluginInterface plugin_interface
-
too_state
private java.util.Map<TorrentOpenOptions,TorrentManagerImpl.TorrentOptionsImpl> too_state
-
-
Constructor Detail
-
TorrentManagerImpl
protected TorrentManagerImpl(PluginInterface _pi)
-
-
Method Detail
-
getSingleton
public static TorrentManagerImpl getSingleton()
-
specialise
public TorrentManager specialise(PluginInterface _pi)
-
getURLDownloader
public TorrentDownloader getURLDownloader(java.net.URL url) throws TorrentException
- Specified by:
getURLDownloader
in interfaceTorrentManager
- Throws:
TorrentException
-
getURLDownloader
public TorrentDownloader getURLDownloader(java.net.URL url, java.lang.String user_name, java.lang.String password) throws TorrentException
- Specified by:
getURLDownloader
in interfaceTorrentManager
- Throws:
TorrentException
-
createFromBEncodedFile
public Torrent createFromBEncodedFile(java.io.File file) throws TorrentException
Description copied from interface:TorrentManager
decodes a torrent encoded using the normal "bencoding" rules from a file- Specified by:
createFromBEncodedFile
in interfaceTorrentManager
- Returns:
- Throws:
TorrentException
-
createFromBEncodedFile
public Torrent createFromBEncodedFile(java.io.File file, boolean for_seeding) throws TorrentException
Description copied from interface:TorrentManager
decodes a torrent encoded using the normal "bencoding" rules from a file but discards the piece hashes to save memory. note that this means that if something reads the hashes they will be re-read from the torrent file and if the file has since been deleted things go smelly- Specified by:
createFromBEncodedFile
in interfaceTorrentManager
for_seeding
- reduces memory usage by discarding piece hashes- Returns:
- Throws:
TorrentException
-
createFromBEncodedInputStream
public Torrent createFromBEncodedInputStream(java.io.InputStream data) throws TorrentException
Description copied from interface:TorrentManager
decodes a torrent encoded using the normal "bencoding" rules from an InputStream- Specified by:
createFromBEncodedInputStream
in interfaceTorrentManager
- Returns:
- Throws:
TorrentException
-
createFromBEncodedData
public Torrent createFromBEncodedData(byte[] data) throws TorrentException
Description copied from interface:TorrentManager
decodes a torrent encoded using the normal "bencoding" rules from a byte array- Specified by:
createFromBEncodedData
in interfaceTorrentManager
- Returns:
- Throws:
TorrentException
-
createFromDataFile
public Torrent createFromDataFile(java.io.File data, java.net.URL announce_url) throws TorrentException
Description copied from interface:TorrentManager
creates a new torrent from an input file- Specified by:
createFromDataFile
in interfaceTorrentManager
- Returns:
- Throws:
TorrentException
-
createFromDataFile
public Torrent createFromDataFile(java.io.File data, java.net.URL announce_url, boolean include_other_hashes) throws TorrentException
- Specified by:
createFromDataFile
in interfaceTorrentManager
- Throws:
TorrentException
-
createFromDataFileEx
public TorrentCreator createFromDataFileEx(java.io.File data, java.net.URL announce_url, boolean include_other_hashes) throws TorrentException
- Specified by:
createFromDataFileEx
in interfaceTorrentManager
- Throws:
TorrentException
-
getDefinedAttributes
public TorrentAttribute[] getDefinedAttributes()
Description copied from interface:TorrentManager
Gives access to the currently defined torrent attributes. As of 2.1.0.2 only "category" is defined, however in the future more could be added such as "quality", "bit rate" etc.- Specified by:
getDefinedAttributes
in interfaceTorrentManager
- Returns:
-
getAttribute
public TorrentAttribute getAttribute(java.lang.String name)
Description copied from interface:TorrentManager
Gives access to the standard built-in attributes- Specified by:
getAttribute
in interfaceTorrentManager
- Returns:
-
getPluginAttribute
public TorrentAttribute getPluginAttribute(java.lang.String name)
Description copied from interface:TorrentManager
Gives access to/creates arbitrary String attributes for plugins to use. The attribute will be specific to the plugin, so you can use short torrent names like "name", you won't need to add the plugin ID or any other sort of unique identifier to the attribute name.- Specified by:
getPluginAttribute
in interfaceTorrentManager
- Returns:
-
createFromBEncodedData
public Torrent createFromBEncodedData(byte[] data, int preserve) throws TorrentException
Description copied from interface:TorrentManager
decodes a torrent encoded using the normal "bencoding" rules from a byte array- Specified by:
createFromBEncodedData
in interfaceTorrentManager
preserve
- PRESERVE_* flags- Returns:
- Throws:
TorrentException
-
createFromBEncodedFile
public Torrent createFromBEncodedFile(java.io.File file, int preserve) throws TorrentException
Description copied from interface:TorrentManager
decodes a torrent encoded using the normal "bencoding" rules from a file- Specified by:
createFromBEncodedFile
in interfaceTorrentManager
preserve
- PRESERVE_* flags- Returns:
- Throws:
TorrentException
-
createFromBEncodedInputStream
public Torrent createFromBEncodedInputStream(java.io.InputStream data, int preserve) throws TorrentException
Description copied from interface:TorrentManager
decodes a torrent encoded using the normal "bencoding" rules from an InputStream- Specified by:
createFromBEncodedInputStream
in interfaceTorrentManager
preserve
- PRESERVE_* flags- Returns:
- Throws:
TorrentException
-
reportProgress
public void reportProgress(int percent_complete)
- Specified by:
reportProgress
in interfaceTOTorrentProgressListener
-
reportCurrentTask
public void reportCurrentTask(java.lang.String task_description)
- Specified by:
reportCurrentTask
in interfaceTOTorrentProgressListener
-
tryToSetTorrentEncoding
protected void tryToSetTorrentEncoding(TOTorrent torrent, java.lang.String encoding) throws TorrentEncodingException
- Throws:
TorrentEncodingException
-
tryToSetDefaultTorrentEncoding
protected void tryToSetDefaultTorrentEncoding(TOTorrent torrent) throws TorrentException
- Throws:
TorrentException
-
fireEvent
private void fireEvent(int type, java.lang.Object data)
-
optionsAdded
public void optionsAdded(TorrentOpenOptions options)
-
optionsAccepted
public void optionsAccepted(TorrentOpenOptions options)
-
optionsRemoved
public void optionsRemoved(TorrentOpenOptions options)
-
addListener
public void addListener(TorrentManagerListener l)
- Specified by:
addListener
in interfaceTorrentManager
-
removeListener
public void removeListener(TorrentManagerListener l)
- Specified by:
removeListener
in interfaceTorrentManager
-
-