Class ShareManagerImpl
- java.lang.Object
-
- com.biglybt.pifimpl.local.sharing.ShareManagerImpl
-
- All Implemented Interfaces:
ParameterListener
,TOTorrentProgressListener
,AEDiagnosticsEvidenceGenerator
,ShareManager
public class ShareManagerImpl extends java.lang.Object implements ShareManager, TOTorrentProgressListener, ParameterListener, AEDiagnosticsEvidenceGenerator
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
ShareManagerImpl.shareScanner
-
Field Summary
Fields Modifier and Type Field Description private java.net.URL[]
announce_urls
private static AEMonitor
class_mon
private ShareConfigImpl
config
private ShareManagerImpl.shareScanner
current_scanner
private boolean
initialised
private boolean
initialising
private java.util.List<ShareManagerListener>
listeners
private static LogIDs
LOGID
static int
MAX_DIRS
static int
MAX_FILES_PER_DIR
private static boolean
persistent_shares
private boolean
scanning
private java.io.File
share_dir
private java.util.Map<java.lang.String,ShareResourceImpl>
shares
protected static ShareManagerImpl
singleton
protected AEMonitor
this_mon
protected TOTorrentCreator
to_creator
private ByteArrayHashMap<ShareResource>
torrent_map
static java.lang.String
TORRENT_STORE
static java.lang.String
TORRENT_SUBSTORE
-
Fields inherited from interface com.biglybt.pif.sharing.ShareManager
PR_NETWORKS, PR_PERSISTENT, PR_PERSONAL, PR_TAGS, PR_USER_DATA
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ShareManagerImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ShareResourceDir
addDir(ShareResourceDirContentsImpl parent, java.io.File dir, boolean personal, java.util.Map<java.lang.String,java.lang.String> properties)
ShareResourceDir
addDir(java.io.File dir)
ShareResourceDir
addDir(java.io.File dir, java.util.Map<java.lang.String,java.lang.String> properties)
ShareResourceDirContents
addDirContents(java.io.File dir, boolean recursive)
ShareResourceDirContents
addDirContents(java.io.File dir, boolean recursive, java.util.Map<java.lang.String,java.lang.String> properties)
protected ShareResourceFile
addFile(ShareResourceDirContentsImpl parent, java.io.File file, boolean personal, java.util.Map<java.lang.String,java.lang.String> properties)
ShareResourceFile
addFile(java.io.File file)
ShareResourceFile
addFile(java.io.File file, java.util.Map<java.lang.String,java.lang.String> properties)
protected ShareResource
addFileOrDir(ShareResourceDirContentsImpl parent, java.io.File file, int type, boolean personal, java.util.Map<java.lang.String,java.lang.String> properties)
void
addListener(ShareManagerListener l)
void
cancelOperation()
adding shares can take a long time due to the torrent creation process.protected void
checkConsistency()
protected void
configDirty()
protected void
delete(ShareResourceImpl resource, boolean fire_listeners)
protected void
deleteTorrent(ShareItemImpl item)
protected void
deserialiseResource(java.util.Map map)
void
generate(IndentWriter writer)
protected void
generate(IndentWriter writer, ShareResourceDirContents node)
protected boolean
getAddHashes()
protected java.net.URL[]
getAnnounceURLs()
private boolean
getBooleanProperty(java.util.Map<java.lang.String,java.lang.String> properties, java.lang.String name)
protected java.lang.String
getDebugName(ShareResource _share)
ShareResourceDir
getDir(java.io.File file)
ShareResourceFile
getFile(java.io.File file)
protected java.lang.String
getNewTorrentLocation()
protected ShareResourceImpl
getResource(java.io.File file)
ShareResource
getShare(java.io.File file_or_dir)
returns null if share not definedprotected ShareConfigImpl
getShareConfig()
int
getShareCount()
ShareResource[]
getShares()
static ShareManagerImpl
getSingleton()
protected java.io.File
getTorrentFile(ShareItemImpl item)
void
initialise()
boolean
isInitialising()
ShareResource
lookupShare(byte[] torrent_hash)
void
parameterChanged(java.lang.String name)
Called, when a parameter has changed.protected void
readAZConfig()
protected void
readAZConfigSupport()
protected void
readTorrent(ShareItemImpl item)
void
removeListener(ShareManagerListener l)
void
reportCurrentTask(java.lang.String task_description)
protected void
reportError(java.lang.Throwable e)
void
reportProgress(int percent_complete)
protected void
scanShares()
private java.util.Map<java.lang.String,java.lang.String>
setPropertyDefaults(java.util.Map<java.lang.String,java.lang.String> properties)
protected void
setTorrentCreator(TOTorrentCreator _to_creator)
protected boolean
torrentExists(ShareItemImpl item)
protected void
writeTorrent(ShareItemImpl item)
-
-
-
Field Detail
-
LOGID
private static final LogIDs LOGID
-
TORRENT_STORE
public static final java.lang.String TORRENT_STORE
- See Also:
- Constant Field Values
-
TORRENT_SUBSTORE
public static final java.lang.String TORRENT_SUBSTORE
- See Also:
- Constant Field Values
-
MAX_FILES_PER_DIR
public static final int MAX_FILES_PER_DIR
- See Also:
- Constant Field Values
-
MAX_DIRS
public static final int MAX_DIRS
- See Also:
- Constant Field Values
-
singleton
protected static ShareManagerImpl singleton
-
class_mon
private static AEMonitor class_mon
-
persistent_shares
private static boolean persistent_shares
-
this_mon
protected AEMonitor this_mon
-
to_creator
protected TOTorrentCreator to_creator
-
initialised
private volatile boolean initialised
-
initialising
private volatile boolean initialising
-
share_dir
private java.io.File share_dir
-
announce_urls
private java.net.URL[] announce_urls
-
config
private ShareConfigImpl config
-
shares
private java.util.Map<java.lang.String,ShareResourceImpl> shares
-
torrent_map
private ByteArrayHashMap<ShareResource> torrent_map
-
current_scanner
private ShareManagerImpl.shareScanner current_scanner
-
scanning
private boolean scanning
-
listeners
private java.util.List<ShareManagerListener> listeners
-
-
Constructor Detail
-
ShareManagerImpl
protected ShareManagerImpl() throws ShareException
- Throws:
ShareException
-
-
Method Detail
-
getSingleton
public static ShareManagerImpl getSingleton() throws ShareException
- Throws:
ShareException
-
initialise
public void initialise() throws ShareException
- Specified by:
initialise
in interfaceShareManager
- Throws:
ShareException
-
isInitialising
public boolean isInitialising()
- Specified by:
isInitialising
in interfaceShareManager
-
readAZConfig
protected void readAZConfig()
-
parameterChanged
public void parameterChanged(java.lang.String name)
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 interfaceParameterListener
- Parameters:
name
- the name of the parameter that has changed
-
readAZConfigSupport
protected void readAZConfigSupport()
-
getShareConfig
protected ShareConfigImpl getShareConfig()
-
checkConsistency
protected void checkConsistency() throws ShareException
- Throws:
ShareException
-
deserialiseResource
protected void deserialiseResource(java.util.Map map)
-
getNewTorrentLocation
protected java.lang.String getNewTorrentLocation() throws ShareException
- Throws:
ShareException
-
writeTorrent
protected void writeTorrent(ShareItemImpl item) throws ShareException
- Throws:
ShareException
-
readTorrent
protected void readTorrent(ShareItemImpl item) throws ShareException
- Throws:
ShareException
-
deleteTorrent
protected void deleteTorrent(ShareItemImpl item)
-
torrentExists
protected boolean torrentExists(ShareItemImpl item)
-
getTorrentFile
protected java.io.File getTorrentFile(ShareItemImpl item)
-
getAnnounceURLs
protected java.net.URL[] getAnnounceURLs() throws ShareException
- Throws:
ShareException
-
getAddHashes
protected boolean getAddHashes()
-
getShares
public ShareResource[] getShares()
- Specified by:
getShares
in interfaceShareManager
-
getShareCount
public int getShareCount()
- Specified by:
getShareCount
in interfaceShareManager
-
getResource
protected ShareResourceImpl getResource(java.io.File file) throws ShareException
- Throws:
ShareException
-
getShare
public ShareResource getShare(java.io.File file_or_dir)
Description copied from interface:ShareManager
returns null if share not defined- Specified by:
getShare
in interfaceShareManager
- Returns:
-
lookupShare
public ShareResource lookupShare(byte[] torrent_hash) throws ShareException
- Specified by:
lookupShare
in interfaceShareManager
- Throws:
ShareException
-
getBooleanProperty
private boolean getBooleanProperty(java.util.Map<java.lang.String,java.lang.String> properties, java.lang.String name)
-
addFile
public ShareResourceFile addFile(java.io.File file) throws ShareException, ShareResourceDeletionVetoException
- Specified by:
addFile
in interfaceShareManager
- Throws:
ShareException
ShareResourceDeletionVetoException
-
addFile
public ShareResourceFile addFile(java.io.File file, java.util.Map<java.lang.String,java.lang.String> properties) throws ShareException, ShareResourceDeletionVetoException
- Specified by:
addFile
in interfaceShareManager
- Throws:
ShareException
ShareResourceDeletionVetoException
-
addFile
protected ShareResourceFile addFile(ShareResourceDirContentsImpl parent, java.io.File file, boolean personal, java.util.Map<java.lang.String,java.lang.String> properties) throws ShareException, ShareResourceDeletionVetoException
-
getFile
public ShareResourceFile getFile(java.io.File file) throws ShareException
- Throws:
ShareException
-
addDir
public ShareResourceDir addDir(java.io.File dir) throws ShareException, ShareResourceDeletionVetoException
- Specified by:
addDir
in interfaceShareManager
- Throws:
ShareException
ShareResourceDeletionVetoException
-
addDir
public ShareResourceDir addDir(java.io.File dir, java.util.Map<java.lang.String,java.lang.String> properties) throws ShareException, ShareResourceDeletionVetoException
- Specified by:
addDir
in interfaceShareManager
- Throws:
ShareException
ShareResourceDeletionVetoException
-
addDir
public ShareResourceDir addDir(ShareResourceDirContentsImpl parent, java.io.File dir, boolean personal, java.util.Map<java.lang.String,java.lang.String> properties) throws ShareException, ShareResourceDeletionVetoException
-
getDir
public ShareResourceDir getDir(java.io.File file) throws ShareException
- Throws:
ShareException
-
addFileOrDir
protected ShareResource addFileOrDir(ShareResourceDirContentsImpl parent, java.io.File file, int type, boolean personal, java.util.Map<java.lang.String,java.lang.String> properties) throws ShareException, ShareResourceDeletionVetoException
-
addDirContents
public ShareResourceDirContents addDirContents(java.io.File dir, boolean recursive) throws ShareException, ShareResourceDeletionVetoException
- Specified by:
addDirContents
in interfaceShareManager
- Throws:
ShareException
ShareResourceDeletionVetoException
-
addDirContents
public ShareResourceDirContents addDirContents(java.io.File dir, boolean recursive, java.util.Map<java.lang.String,java.lang.String> properties) throws ShareException, ShareResourceDeletionVetoException
- Specified by:
addDirContents
in interfaceShareManager
- Throws:
ShareException
ShareResourceDeletionVetoException
-
delete
protected void delete(ShareResourceImpl resource, boolean fire_listeners) throws ShareException
- Throws:
ShareException
-
scanShares
protected void scanShares() throws ShareException
- Throws:
ShareException
-
setTorrentCreator
protected void setTorrentCreator(TOTorrentCreator _to_creator)
-
setPropertyDefaults
private java.util.Map<java.lang.String,java.lang.String> setPropertyDefaults(java.util.Map<java.lang.String,java.lang.String> properties)
-
cancelOperation
public void cancelOperation()
Description copied from interface:ShareManager
adding shares can take a long time due to the torrent creation process. The current activity can be interrupted by calling this function, in which case the original activity will fail with a ShareException- Specified by:
cancelOperation
in interfaceShareManager
-
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
-
reportError
protected void reportError(java.lang.Throwable e)
-
addListener
public void addListener(ShareManagerListener l)
- Specified by:
addListener
in interfaceShareManager
-
removeListener
public void removeListener(ShareManagerListener l)
- Specified by:
removeListener
in interfaceShareManager
-
generate
public void generate(IndentWriter writer)
- Specified by:
generate
in interfaceAEDiagnosticsEvidenceGenerator
-
generate
protected void generate(IndentWriter writer, ShareResourceDirContents node)
-
getDebugName
protected java.lang.String getDebugName(ShareResource _share)
-
configDirty
protected void configDirty()
-
-