Class LWSDownload

    • Method Detail

      • getState

        public int getState()
        Description copied from interface: Download
        get state from above ST_ set
        Specified by:
        getState in interface Download
        Returns:
        ST_ constant
      • getSubState

        public int getSubState()
        Description copied from interface: Download
        For the STOPPING state this method gives the state that is being transited too (STOPPED, QUEUED or ERROR)
        Specified by:
        getSubState in interface Download
        Returns:
      • getErrorStateDetails

        public java.lang.String getErrorStateDetails()
        Description copied from interface: Download
        When the download state is ERROR this method returns the error details
        Specified by:
        getErrorStateDetails in interface Download
        Returns:
      • setFlag

        public void setFlag​(long flag,
                            boolean value)
        Description copied from interface: Download
        Set the flag value.
        Specified by:
        setFlag in interface Download
        Parameters:
        flag - FLAG value from above
        value - true to enable the flag, false to disable it.
      • getFlag

        public boolean getFlag​(long flag)
        Description copied from interface: Download
        Get the flag value
        Specified by:
        getFlag in interface Download
        Parameters:
        flag - FLAG value from above
        Returns:
      • getFlags

        public long getFlags()
        Description copied from interface: Download
        get all the flags as a bitmap
        Specified by:
        getFlags in interface Download
        Returns:
      • startDownload

        public void startDownload​(boolean force)
        Description copied from interface: Download
        Simple method to start the download. Will not raise an error if it didn't work, or if the download is already running.
        Specified by:
        startDownload in interface Download
        Parameters:
        force - true to force the download to be started.
      • stopDownload

        public void stopDownload()
        Description copied from interface: Download
        Simple method to stop the download. Will not raise an error if it didn't work, or if the download is already stopped.
        Specified by:
        stopDownload in interface Download
      • setStopReason

        public void setStopReason​(java.lang.String reason)
        Specified by:
        setStopReason in interface Download
      • getStopReason

        public java.lang.String getStopReason()
        Specified by:
        getStopReason in interface Download
      • pause

        public void pause()
        Description copied from interface: Download
        Pause the download
        Specified by:
        pause in interface Download
      • resume

        public void resume()
        Description copied from interface: Download
        Resume the download if paused
        Specified by:
        resume in interface Download
      • recheckData

        public void recheckData()
                         throws DownloadException
        Description copied from interface: Download
        Performs a complete recheck of the downloaded data Download must be in stopped, queued or error state Action is performed asynchronously and will progress the download through states PREPARING back to the relevant state
        Specified by:
        recheckData in interface Download
        Throws:
        DownloadException
      • isStartStopLocked

        public boolean isStartStopLocked()
        Description copied from interface: Download
        When a download is "start-stop locked" it means that seeding rules shouldn't start or stop the download as it is under manual control
        Specified by:
        isStartStopLocked in interface Download
        Returns:
        True if download is locked and should not be started or stopped
      • isForceStart

        public boolean isForceStart()
        Description copied from interface: Download
        Retrieves whether the download is force started
        Specified by:
        isForceStart in interface Download
        Returns:
        True if download is force started. False if not.
      • setForceStart

        public void setForceStart​(boolean forceStart)
        Description copied from interface: Download
        Set the forcestart state of the download
        Specified by:
        setForceStart in interface Download
        Parameters:
        forceStart - True - Download will start, despite any Start/Stop rules/limits
        False - Turn forcestart state off. Download may or may not stop, depending on Start/Stop rules/limits
      • isPaused

        public boolean isPaused()
        Specified by:
        isPaused in interface Download
        Returns:
      • getName

        public java.lang.String getName()
        Description copied from interface: Download
        Returns the name of the torrent. Similar to Torrent.getName() and is usefull if getTorrent() returns null and you still need the name.
        Specified by:
        getName in interface Download
        Specified by:
        getName in interface DownloadStub
        Returns:
        name of the torrent
      • getTorrentFileName

        public java.lang.String getTorrentFileName()
        Description copied from interface: Download
        Returns the full file path and name of the .torrent file
        Specified by:
        getTorrentFileName in interface Download
        Returns:
        File name of the torrent.
      • getAttribute

        public java.lang.String getAttribute​(TorrentAttribute attribute)
        Description copied from interface: Download
        Gets an attribute of this download. For category use the Category torrent attribute
        Specified by:
        getAttribute in interface Download
        Returns:
      • setAttribute

        public void setAttribute​(TorrentAttribute attribute,
                                 java.lang.String value)
        Description copied from interface: Download
        Sets an attribute of this download. For category use the Category torrent attribute
        Specified by:
        setAttribute in interface Download
        Parameters:
        attribute - Previously created attribute
        value - Value to store. null to remove attribute
      • setMapAttribute

        public void setMapAttribute​(TorrentAttribute attribute,
                                    java.util.Map value)
        Specified by:
        setMapAttribute in interface Download
        value - must be bencodable - key is string, value is Map, List, Long or byte[]
      • getIntAttribute

        public int getIntAttribute​(TorrentAttribute name)
        Description copied from interface: Download
        Gets the value of the given attribute from the download. If no value is set, then 0 will be returned.
        Specified by:
        getIntAttribute in interface Download
      • getBooleanAttribute

        public boolean getBooleanAttribute​(TorrentAttribute name)
        Description copied from interface: Download
        Gets the value of the given attribute from the download. If no value is set, then false will be returned.
        Specified by:
        getBooleanAttribute in interface Download
      • hasAttribute

        public boolean hasAttribute​(TorrentAttribute name)
        Description copied from interface: Download
        Returns true if the download has an explicit value stored for the given attribute.
        Specified by:
        hasAttribute in interface Download
      • getCategoryName

        public java.lang.String getCategoryName()
        Description copied from interface: Download
        Returns the name of the Category
        Specified by:
        getCategoryName in interface Download
        Returns:
        name of the category
      • setCategory

        public void setCategory​(java.lang.String sName)
        Description copied from interface: Download
        Sets the category for the download
        Specified by:
        setCategory in interface Download
        Parameters:
        sName - Category name
      • getTags

        public java.util.List<Tag> getTags()
        Specified by:
        getTags in interface Download
        Returns:
      • isRemoved

        public boolean isRemoved()
        Specified by:
        isRemoved in interface Download
        Returns:
      • getPosition

        public int getPosition()
        Description copied from interface: Download
        Returns the current position in the queue Completed and Incompleted downloads have seperate position sets. This means we can have a position x for Completed, and position x for Incompleted.
        Specified by:
        getPosition in interface Download
      • getCreationTime

        public long getCreationTime()
        Description copied from interface: Download
        returns the time this download was created in milliseconds
        Specified by:
        getCreationTime in interface Download
        Returns:
      • setPosition

        public void setPosition​(int newPosition)
        Description copied from interface: Download
        Sets the position in the queue Completed and Incompleted downloads have seperate position sets
        Specified by:
        setPosition in interface Download
      • moveUp

        public void moveUp()
        Description copied from interface: Download
        Moves the download position up one
        Specified by:
        moveUp in interface Download
      • moveDown

        public void moveDown()
        Description copied from interface: Download
        Moves the download down one position
        Specified by:
        moveDown in interface Download
      • moveTo

        public void moveTo​(int position)
        Description copied from interface: Download
        Moves a download and re-orders the others appropriately. Note that setPosition does not do this, it merely sets the position thus making it possible, for example, for two downloads to have the same position
        Specified by:
        moveTo in interface Download
      • getLastScrapeResult

        public DownloadScrapeResult getLastScrapeResult()
        Description copied from interface: Download
        Gives access to the last scrape result received from the tracker for the download
        Specified by:
        getLastScrapeResult in interface Download
        Returns:
        a non-null DownloadScrapeResult
      • getActivationState

        public DownloadActivationEvent getActivationState()
        Description copied from interface: Download
        Gives access to the current activation state. Note that we currently only fire the activation listener on an increase in activation requirements. This method however gives the current view of the state and takes into account decreases too
        Specified by:
        getActivationState in interface Download
        Returns:
      • getStats

        public DownloadStats getStats()
        Description copied from interface: Download
        Gives access to the download's statistics
        Specified by:
        getStats in interface Download
        Returns:
      • isPersistent

        public boolean isPersistent()
        Description copied from interface: Download
        Downloads can be persistent (be remembered across client sessions), or non-persistent.
        Specified by:
        isPersistent in interface Download
        Returns:
        true - persistent
        false - non-persistent
      • setMaximumDownloadKBPerSecond

        public void setMaximumDownloadKBPerSecond​(int kb)
        Description copied from interface: Download
        Sets the maximum download speed in bytes per second. 0 -> unlimited
        Specified by:
        setMaximumDownloadKBPerSecond in interface Download
      • getMaximumDownloadKBPerSecond

        public int getMaximumDownloadKBPerSecond()
        Description copied from interface: Download
        Get the max download rate allowed for this download
        Specified by:
        getMaximumDownloadKBPerSecond in interface Download
        Returns:
        upload rate in KB/s, 0 for unlimited
        Since 4.8.1.3: -1 for download disabled
      • addRateLimiter

        public void addRateLimiter​(RateLimiter limiter,
                                   boolean is_upload)
        Specified by:
        addRateLimiter in interface Download
        Parameters:
        limiter - create via ConnectionManager
        is_upload - false -> download limit
      • getUploadRateLimitBytesPerSecond

        public int getUploadRateLimitBytesPerSecond()
        Description copied from interface: Download
        Get the max upload rate allowed for this download.
        Specified by:
        getUploadRateLimitBytesPerSecond in interface Download
        Returns:
        upload rate in bytes per second, 0 for unlimited, -1 for upload disabled
      • setUploadRateLimitBytesPerSecond

        public void setUploadRateLimitBytesPerSecond​(int max_rate_bps)
        Description copied from interface: Download
        Set the max upload rate allowed for this download.
        Specified by:
        setUploadRateLimitBytesPerSecond in interface Download
        Parameters:
        max_rate_bps - limit in bytes per second, 0 for unlimited, -1 for upload disabled
      • getDownloadRateLimitBytesPerSecond

        public int getDownloadRateLimitBytesPerSecond()
        Description copied from interface: Download
        Get the max download rate allowed for this download.
        Specified by:
        getDownloadRateLimitBytesPerSecond in interface Download
        Returns:
        upload rate in bytes per second, 0 for unlimited, -1 for download disabled
      • setDownloadRateLimitBytesPerSecond

        public void setDownloadRateLimitBytesPerSecond​(int max_rate_bps)
        Description copied from interface: Download
        Set the max download rate allowed for this download.
        Specified by:
        setDownloadRateLimitBytesPerSecond in interface Download
        Parameters:
        max_rate_bps - limit in bytes per second, 0 for unlimited, -1 for dowmload disabled
      • isComplete

        public boolean isComplete()
        Description copied from interface: Download
        Indicates if the download has completed or not, exluding any files marked as Do No Download
        Specified by:
        isComplete in interface Download
        Returns:
        Download Complete status
      • isComplete

        public boolean isComplete​(boolean bIncludeDND)
        Description copied from interface: Download
        Indicates if the download has completed or not
        Specified by:
        isComplete in interface Download
        Parameters:
        bIncludeDND - Whether to include DND files when determining completion state
        Returns:
        Download Complete status
      • isChecking

        public boolean isChecking()
        Description copied from interface: Download
        When a download is completed it is rechecked (if the option is enabled). This method returns true during this phase (at which time the status will be seeding)
        Specified by:
        isChecking in interface Download
        Returns:
      • isMoving

        public boolean isMoving()
        Description copied from interface: Download
        Returns true if the download is currently in the process of having its datafiles moved
        Specified by:
        isMoving in interface Download
        Returns:
      • getSavePath

        public java.lang.String getSavePath()
        Description copied from interface: Download
        This returns the full save path for the download. If the download is a simple torrent, this will be the full path of the file being downloaded. If the download is a multiple file torrent, this will be the path to the directory containing all the files in the torrent.
        Specified by:
        getSavePath in interface Download
        Specified by:
        getSavePath in interface DownloadStub
        Returns:
        Full save path for this download.
      • moveDataFiles

        public void moveDataFiles​(java.io.File new_parent_dir)
                           throws DownloadException
        Description copied from interface: Download
        Move a download's data files to a new location.

        If a download is running, it will be automatically paused and resumed afterwards - be aware that this behaviour may generate stateChanged events being fired.

        Specified by:
        moveDataFiles in interface Download
        Parameters:
        new_parent_dir - New location. Note that non-simple torrents' data will be placed in a subdirectory of the torrent's name (Download.getName()) under this new_parent_dir
        Throws:
        DownloadException
      • canMoveDataFiles

        public boolean canMoveDataFiles()
        Description copied from interface: Download
        Returns true if the client will allow the data files for the torrent to be moved.
        Specified by:
        canMoveDataFiles in interface Download
      • renameDownload

        public void renameDownload​(java.lang.String name)
                            throws DownloadException
        Description copied from interface: Download
        Renames the file (for a single file torrent) or directory (for a multi file torrent) where the download is being saved to. The download must be in a state to move the data files to a new location (see Download.moveDataFiles(File)).

        This will not rename the displayed name for the torrent - if you wish to do that, you must do it via the TorrentAttribute class.

        If a download is running, it will be automatically paused and resumed afterwards - be aware that this behaviour may generate stateChanged events being fired.

        Specified by:
        renameDownload in interface Download
        Parameters:
        name - New name for the download.
        Throws:
        DownloadException
        See Also:
        Download.moveDataFiles(File)
      • getPeerManager

        public PeerManager getPeerManager()
        Description copied from interface: Download
        return the current peer manager for the download.
        Specified by:
        getPeerManager in interface Download
        Returns:
        null returned if torrent currently doesn't have one (e.g. it is stopped)
      • getDiskManager

        public DiskManager getDiskManager()
        Description copied from interface: Download
        Return the disk manager, null if its not running
        Specified by:
        getDiskManager in interface Download
        Returns:
      • getDiskManagerFileInfo

        public DiskManagerFileInfo[] getDiskManagerFileInfo()
        Description copied from interface: Download
        Returns info about the torrent's files. Note that this will return "stub" values if the download isn't running (not including info such as completion status)
        Specified by:
        getDiskManagerFileInfo in interface Download
        Returns:
      • getDiskManagerFileInfo

        public DiskManagerFileInfo getDiskManagerFileInfo​(int i)
        Description copied from interface: Download
        Returns file info for the given index. Note that this will return "stub" values if the download isn't running (not including info such as completion status)
        Specified by:
        getDiskManagerFileInfo in interface Download
        Returns:
        null if index is invalid
      • getDiskManagerFileCount

        public int getDiskManagerFileCount()
        Description copied from interface: Download
        Return the number of DiskManagerFile objects
        Specified by:
        getDiskManagerFileCount in interface Download
        Returns:
      • requestTrackerAnnounce

        public void requestTrackerAnnounce()
        Description copied from interface: Download
        request a tracker announce
        Specified by:
        requestTrackerAnnounce in interface Download
      • requestTrackerAnnounce

        public void requestTrackerAnnounce​(boolean immediate)
        Description copied from interface: Download
        request a tracker announce
        Specified by:
        requestTrackerAnnounce in interface Download
      • requestTrackerScrape

        public void requestTrackerScrape​(boolean immediate)
        Description copied from interface: Download
        request a tracker announce
        Specified by:
        requestTrackerScrape in interface Download
      • addTrackerListener

        public void addTrackerListener​(DownloadTrackerListener l)
        Description copied from interface: DownloadEventNotifier
        Adds a listener that will be informed when the latest announce/scrape results change.

        Listener events will be immediately triggered after the listener has been added.

        Specified by:
        addTrackerListener in interface DownloadEventNotifier
        Parameters:
        l - The listener to add.
      • addTrackerListener

        public void addTrackerListener​(DownloadTrackerListener l,
                                       boolean immediateTrigger)
        Description copied from interface: DownloadEventNotifier
        Adds a listener that will be informed when the latest announce/scrape results change.
        Specified by:
        addTrackerListener in interface DownloadEventNotifier
        Parameters:
        l - The listener to add.
        immediateTrigger - Whether to immediately trigger listener's events.
      • setSeedingRank

        public void setSeedingRank​(Download.SeedingRank rank)
        Description copied from interface: Download
        The torrents with the highest rankings will be seeded first.
        Specified by:
        setSeedingRank in interface Download
        Parameters:
        rank - New Ranking
      • getDownloadPeerId

        public byte[] getDownloadPeerId()
        Description copied from interface: Download
        Get the local peerID advertised to the download swarm.
        Specified by:
        getDownloadPeerId in interface Download
        Returns:
        self peer id
      • isMessagingEnabled

        public boolean isMessagingEnabled()
        Description copied from interface: Download
        Is advanced AZ messaging enabled for this download.
        Specified by:
        isMessagingEnabled in interface Download
        Returns:
        true if enabled, false if disabled
      • setMessagingEnabled

        public void setMessagingEnabled​(boolean enabled)
        Description copied from interface: Download
        Enable or disable advanced AZ messaging for this download.
        Specified by:
        setMessagingEnabled in interface Download
        Parameters:
        enabled - true to enabled, false to disabled
      • moveDataFiles

        public void moveDataFiles​(java.io.File new_parent_dir,
                                  java.lang.String new_name)
                           throws DownloadException
        Description copied from interface: Download
        Move a download's data files to a new location, and rename the download at the same time. Download must be stopped and persistent. This is equivalent to calling moveDataFiles[File] and then renameDownload[String]. For convenience, either argument can be null, but not both.

        If a download is running, it will be automatically paused and resumed afterwards - be aware that this behaviour may generate stateChanged events being fired.

        Specified by:
        moveDataFiles in interface Download
        Parameters:
        new_parent_dir - new location to move torrent data files to. If null, and simple torrent, torrent data file will be renamed new_name. If null, and not simple torrent, torrent end path will be changed to new_name.
        new_name - For simple torrent, changes the filename of the downloaded file. For non-simple torrent, changes the end path for the downloaded files. If null, torrent data files will be moved to new_parent_dir, with a subfolder of Download.getName().
        Throws:
        DownloadException
      • getUserData

        public java.lang.Object getUserData​(java.lang.Object key)
        Description copied from interface: Download
        get user-defined key/value
        Specified by:
        getUserData in interface Download
        Returns:
      • setUserData

        public void setUserData​(java.lang.Object key,
                                java.lang.Object data)
        Description copied from interface: Download
        set user defined value. this is TRANSIENT and not persisted over the client stop/start
        Specified by:
        setUserData in interface Download
      • notSupported

        protected void notSupported()
      • getRelationText

        public java.lang.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 java.lang.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.