libktorrent  2.2.0
Public Types | Signals | Public Member Functions | Protected Attributes | List of all members
bt::TorrentInterface Class Referenceabstract

Interface for an object which controls one torrent. More...

#include <torrentinterface.h>

Inheritance diagram for bt::TorrentInterface:
Inheritance graph
[legend]

Public Types

enum  ChangeOutputFlags { MOVE_FILES = 1, FULL_PATH = 2 }
 
typedef QSharedPointer< TorrentInterfacePtr
 
typedef QPointer< TorrentInterfaceWPtr
 

Signals

void aboutToBeStarted (bt::TorrentInterface *me, bool &ret)
 
void chunkDownloaded (bt::TorrentInterface *me, bt::Uint32 chunk)
 
void corruptedDataFound (bt::TorrentInterface *me)
 
void diskSpaceLow (bt::TorrentInterface *me, bool toStop)
 
void finished (bt::TorrentInterface *me)
 
void maxRatioChanged (bt::TorrentInterface *me)
 
void missingFilesMarkedDND (bt::TorrentInterface *me)
 
void needDataCheck (bt::TorrentInterface *me)
 
void runningJobsDone (bt::TorrentInterface *me)
 
void seedingAutoStopped (bt::TorrentInterface *me, bt::AutoStopReason reason)
 
void statusChanged (bt::TorrentInterface *me)
 
void stoppedByError (bt::TorrentInterface *me, QString msg)
 
void torrentStopped (bt::TorrentInterface *me)
 
void updateQueue ()
 

Public Member Functions

virtual void addPeerSource (PeerSource *ps)=0
 
virtual bool addWebSeed (const QUrl &url)=0
 Add a webseed (return false, if there is already a webseed with the same url)
 
virtual bool announceAllowed ()=0
 Is manual announce allowed?
 
virtual const bt::BitSetavailableChunksBitSet () const =0
 
virtual bool changeOutputDir (const QString &new_dir, int flags)=0
 
virtual void changeTextCodec (QTextCodec *tc)=0
 Set the text codec.
 
virtual bool changeTorDir (const QString &new_dir)=0
 
virtual bool checkDiskSpace (bool emit_sig=true)=0
 Check if there is enough diskspace available for this torrent.
 
virtual TorrentFileStream::Ptr createTorrentFileStream (bt::Uint32 index, bool streaming_mode, QObject *parent)=0
 
virtual void deleteDataFiles ()=0
 
virtual void dndMissingFiles ()=0
 
virtual const bt::BitSetdownloadedChunksBitSet () const =0
 
virtual const bt::BitSetexcludedChunksBitSet () const =0
 
virtual void getAssuredSpeeds (Uint32 &up, Uint32 &down)=0
 Get the assured speeds.
 
virtual QString getComments () const =0
 Get the comments.
 
virtual QString getDataDir () const =0
 Get the data directory of this torrent.
 
virtual const DHTNodegetDHTNode (Uint32 i) const =0
 Get a DHT node.
 
QString getDisplayName () const
 Gets the displayed name.
 
virtual int getETA ()=0
 
virtual const bt::SHA1HashgetInfoHash () const =0
 Get the info_hash.
 
virtual const JobQueuegetJobQueue () const =0
 Get the JobQueue of the torrent.
 
virtual float getMaxSeedTime () const =0
 Get the max seed time.
 
virtual float getMaxShareRatio () const =0
 Get the max share ratio.
 
virtual QString getMoveWhenCompletedDir () const =0
 
virtual Uint32 getNumDHTNodes () const =0
 Get the number of initial DHT nodes.
 
virtual Uint32 getNumFiles () const =0
 Get the number of files in a multifile torrent (0 if we do not have a multifile torrent)
 
virtual Uint32 getNumWebSeeds () const =0
 Get the number of webseeds.
 
virtual const bt::PeerIDgetOwnPeerID () const =0
 Get our PeerID.
 
virtual int getPriority () const =0
 Get the torrent queue number. Zero if not in queue.
 
virtual Uint32 getRunningTimeDL () const =0
 
virtual Uint32 getRunningTimeUL () const =0
 
const TorrentStatsgetStats () const
 Get the torrent's statistics.
 
virtual const QTextCodec * getTextCodec () const =0
 Get the text codec used in the torrent.
 
virtual QString getTorDir () const =0
 
virtual const TorrentFileInterfacegetTorrentFile (Uint32 index) const =0
 
virtual TorrentFileInterfacegetTorrentFile (Uint32 index)=0
 
virtual const TrackersListgetTrackersList () const =0
 Get a pointer to TrackersList object.
 
virtual TrackersListgetTrackersList ()=0
 Get a pointer to TrackersList object.
 
virtual void getTrafficLimits (Uint32 &up, Uint32 &down)=0
 Get the traffic limits.
 
QString getUserModifiedFileName () const
 Gets the user modified file or toplevel directory name.
 
virtual const WebSeedInterfacegetWebSeed (Uint32 i) const =0
 Get a webseed (returns 0 if index is invalid)
 
virtual WebSeedInterfacegetWebSeed (Uint32 i)=0
 Get a webseed (returns 0 if index is invalid)
 
virtual void handleError (const QString &err)=0
 Handle an error.
 
virtual bool hasMissingFiles (QStringList &sl)=0
 
bool isAllowedToStart () const
 
virtual bool isFeatureEnabled (TorrentFeature tf)=0
 Is a feature enabled.
 
virtual bool isMultimedia () const =0
 See if this is a single file torrent and a multimedia files.
 
virtual bool isStorageMounted (QStringList &missing)=0
 
QUrl loadUrl () const
 Get the URL which the torrent was loaded from.
 
virtual void markExistingFilesAsDownloaded ()=0
 Mark all existing files as downloaded (.
 
virtual bool moveTorrentFiles (const QMap< TorrentFileInterface *, QString > &files)=0
 
virtual void networkUp ()=0
 After some network down time, the network is back up.
 
virtual const bt::BitSetonlySeedChunksBitSet () const =0
 
virtual bool overMaxRatio ()=0
 Checks if a seeding torrent has reached its maximum share ratio.
 
virtual bool overMaxSeedTime ()=0
 Checks if a seeding torrent has reached it's max seed timery / will be ret.
 
virtual void pause ()=0
 
virtual bool readyForPreview () const =0
 
virtual void recreateMissingFiles ()=0
 
virtual void removePeerSource (PeerSource *ps)=0
 
virtual bool removeWebSeed (const QUrl &url)=0
 Remove a webseed (only user created ones can be removed)
 
virtual void rollback ()=0
 
virtual void scrapeTracker ()=0
 
virtual void setAllowedToStart (bool on)=0
 Set whether the QM can start a torrent.
 
virtual void setAssuredSpeeds (Uint32 up, Uint32 down)=0
 Set the assured speeds.
 
virtual void setChunkSelector (ChunkSelectorInterface *csel)=0
 Set the ChunkSelector to use (0 resets to the default ChunkSelector)
 
virtual void setDisplayName (const QString &n)=0
 Set the displayed name.
 
virtual void setFeatureEnabled (TorrentFeature tf, bool on)=0
 Disable or enable a feature.
 
void setLoadUrl (const QUrl &u)
 Set the URL which the torrent was loaded from.
 
virtual void setMaxSeedTime (float hours)=0
 Set the max seed time in hours (0 is no limit)
 
virtual void setMaxShareRatio (float ratio)=0
 Set the max share ratio.
 
virtual void setMonitor (MonitorInterface *tmo)=0
 Set the monitor.
 
virtual void setMoveWhenCompletedDir (const QString &dir)=0
 
virtual void setPriority (int p)=0
 Set the torrent queue number.
 
virtual void setQueued (bool queued)=0
 
virtual void setSuperSeeding (bool on)=0
 
virtual void setTrafficLimits (Uint32 up, Uint32 down)=0
 Set the traffic limits for this torrent.
 
virtual void setUserModifiedFileName (const QString &n)
 Set the user modified file or toplevel directory name.
 
virtual void start ()=0
 
virtual JobstartDataCheck (bool auto_import, bt::Uint32 from, bt::Uint32 to)=0
 
virtual void stop (bt::WaitJob *wjob=0)=0
 
virtual void unpause ()=0
 
virtual void update ()=0
 
virtual void updateStatus ()=0
 Update the status.
 
virtual void updateTracker ()=0
 

Protected Attributes

QString display_name
 
TorrentStats stats
 
QUrl url
 
QString user_modified_name
 

Detailed Description

Author
Joris Guisson

This class is the interface for an object which controls the up- and download of one torrent.

Definition at line 89 of file torrentinterface.h.

Member Function Documentation

◆ aboutToBeStarted

void bt::TorrentInterface::aboutToBeStarted ( bt::TorrentInterface me,
bool &  ret 
)
signal

Emitted just before the torrent is started, this should be used to do some checks on the files in the cache.

Parameters
meThe torrent which emitted the signal
retThe return value

◆ addPeerSource()

virtual void bt::TorrentInterface::addPeerSource ( PeerSource ps)
pure virtual

Add a new PeerSource

Parameters
ps

Implemented in bt::TorrentControl.

◆ availableChunksBitSet()

virtual const bt::BitSet& bt::TorrentInterface::availableChunksBitSet ( ) const
pure virtual

Get a BitSet of the availability of all Chunks

Implemented in bt::TorrentControl.

◆ changeOutputDir()

virtual bool bt::TorrentInterface::changeOutputDir ( const QString &  new_dir,
int  flags 
)
pure virtual

Change to a new data dir. If this fails we will fall back on the old directory.

Parameters
new_dirThe new directory
flagsThe OR of ChangeOutputFlags
Returns
true upon succes

Implemented in bt::TorrentControl.

◆ changeTorDir()

virtual bool bt::TorrentInterface::changeTorDir ( const QString &  new_dir)
pure virtual

Change to a new torX dir. If this fails we will fall back on the old directory.

Parameters
new_dirThe new directory
Returns
true upon succes

Implemented in bt::TorrentControl.

◆ chunkDownloaded

void bt::TorrentInterface::chunkDownloaded ( bt::TorrentInterface me,
bt::Uint32  chunk 
)
signal

Emitted when a chunk is downloaded.

Parameters
meThe torrent
chunkThe chunk

◆ corruptedDataFound

void bt::TorrentInterface::corruptedDataFound ( bt::TorrentInterface me)
signal

A corrupted chunk has been found during upload.

Parameters
meThe torrent which emitted the signal

◆ createTorrentFileStream()

virtual TorrentFileStream::Ptr bt::TorrentInterface::createTorrentFileStream ( bt::Uint32  index,
bool  streaming_mode,
QObject *  parent 
)
pure virtual

Create a TorrentFileStream object. If the torrent is destroyed this object must also be destroyed.

Parameters
indexIndex of the file (in case of a single file torrent, this does not matter)
streaming_modeSet to true if this needs to be streamed (note that only one streaming_mode per torrent is allowed)
parentParent of the TorrentFileStream
Returns
A TorrentFileStream or 0 if index is not valid

Implemented in bt::TorrentControl.

◆ deleteDataFiles()

virtual void bt::TorrentInterface::deleteDataFiles ( )
pure virtual

Delete the data files of the torrent, they will be lost permanently

Implemented in bt::TorrentControl.

◆ diskSpaceLow

void bt::TorrentInterface::diskSpaceLow ( bt::TorrentInterface me,
bool  toStop 
)
signal

Disk is running out of space.

Parameters
meThe torrent which emitted the signal
toStopshould this torrent be stopped or not

◆ dndMissingFiles()

virtual void bt::TorrentInterface::dndMissingFiles ( )
pure virtual

Mark missing files as do not download.

Implemented in bt::TorrentControl.

◆ downloadedChunksBitSet()

virtual const bt::BitSet& bt::TorrentInterface::downloadedChunksBitSet ( ) const
pure virtual

Get a BitSet of the status of all Chunks

Implemented in bt::TorrentControl.

◆ excludedChunksBitSet()

virtual const bt::BitSet& bt::TorrentInterface::excludedChunksBitSet ( ) const
pure virtual

Get a BitSet of the excluded Chunks

Implemented in bt::TorrentControl.

◆ finished

void bt::TorrentInterface::finished ( bt::TorrentInterface me)
signal

Emitted when we have finished downloading.

Parameters
meThe object who emitted the signal

◆ getETA()

virtual int bt::TorrentInterface::getETA ( )
pure virtual

Returns estimated time left for finishing download. Returned value is in seconds. Uses TimeEstimator class to calculate this value.

Implemented in bt::TorrentControl.

◆ getMoveWhenCompletedDir()

virtual QString bt::TorrentInterface::getMoveWhenCompletedDir ( ) const
pure virtual

Get the move upon completion directory.

Implemented in bt::TorrentControl.

◆ getRunningTimeDL()

virtual Uint32 bt::TorrentInterface::getRunningTimeDL ( ) const
pure virtual

Get the download running time of this torrent in seconds

Returns
Uint32 - time in seconds

Implemented in bt::TorrentControl.

◆ getRunningTimeUL()

virtual Uint32 bt::TorrentInterface::getRunningTimeUL ( ) const
pure virtual

Get the upload running time of this torrent in seconds

Returns
Uint32 - time in seconds

Implemented in bt::TorrentControl.

◆ getTorDir()

virtual QString bt::TorrentInterface::getTorDir ( ) const
pure virtual

Get the torX directory of this torrent. Temporary stuff like the index file get stored there.

Implemented in bt::TorrentControl.

◆ getTorrentFile() [1/2]

virtual const TorrentFileInterface& bt::TorrentInterface::getTorrentFile ( Uint32  index) const
pure virtual

Const version of the previous one.

Parameters
indexThe index of the file
Returns
The TorrentFileInterface (isNull() will be true in case of error)

Implemented in bt::TorrentControl.

◆ getTorrentFile() [2/2]

virtual TorrentFileInterface& bt::TorrentInterface::getTorrentFile ( Uint32  index)
pure virtual

Get the index'th file of a multifile torrent

Parameters
indexThe index
Returns
The TorrentFileInterface (isNull() will be true in case of error)

Implemented in bt::TorrentControl.

◆ hasMissingFiles()

virtual bool bt::TorrentInterface::hasMissingFiles ( QStringList &  sl)
pure virtual

Test all files and see if they are not missing. If so put them in a list

Implemented in bt::TorrentControl.

◆ isAllowedToStart()

bool bt::TorrentInterface::isAllowedToStart ( ) const
inline

Can the torrent be started by the QM.

Returns
True if it can, false otherwise

Definition at line 435 of file torrentinterface.h.

◆ isStorageMounted()

virtual bool bt::TorrentInterface::isStorageMounted ( QStringList &  missing)
pure virtual

Is storage mounted for this torrent

Parameters
missingFilled with missing mount points (if any)
Returns
true if there are any missing, false otherwise

Implemented in bt::TorrentControl.

◆ maxRatioChanged

void bt::TorrentInterface::maxRatioChanged ( bt::TorrentInterface me)
signal

Emitted when maximum share ratio for this torrent is changed

Parameters
meThe object which emitted the signal.

◆ missingFilesMarkedDND

void bt::TorrentInterface::missingFilesMarkedDND ( bt::TorrentInterface me)
signal

Emitted when missing files have been marked as dnd. The intention of this signal is to update the GUI.

Parameters
meThe torrent which emitted the signal

◆ moveTorrentFiles()

virtual bool bt::TorrentInterface::moveTorrentFiles ( const QMap< TorrentFileInterface *, QString > &  files)
pure virtual

Move a torrent file to a new location.

Parameters
filesMap of files and their new location
Returns
true upon success

Implemented in bt::TorrentControl.

◆ needDataCheck

void bt::TorrentInterface::needDataCheck ( bt::TorrentInterface me)
signal

Signal emitted when the torrent needs a data check

Parameters
meThe torrent

◆ onlySeedChunksBitSet()

virtual const bt::BitSet& bt::TorrentInterface::onlySeedChunksBitSet ( ) const
pure virtual

Get a bitset of only seed chunks

Implemented in bt::TorrentControl.

◆ pause()

virtual void bt::TorrentInterface::pause ( )
pure virtual

Pause the torrent.

◆ readyForPreview()

virtual bool bt::TorrentInterface::readyForPreview ( ) const
pure virtual

Checks if torrent is multimedial and chunks needed for preview are downloaded This only works for single file torrents

Returns
true if it is

Implemented in bt::TorrentControl.

◆ recreateMissingFiles()

virtual void bt::TorrentInterface::recreateMissingFiles ( )
pure virtual

Recreate missing files.

Implemented in bt::TorrentControl.

◆ removePeerSource()

virtual void bt::TorrentInterface::removePeerSource ( PeerSource ps)
pure virtual

Remove a nPeerSource

Parameters
ps

Implemented in bt::TorrentControl.

◆ rollback()

virtual void bt::TorrentInterface::rollback ( )
pure virtual

Roll back the previous changeDataDir call. Does nothing if there was no previous changeDataDir call.

Implemented in bt::TorrentControl.

◆ runningJobsDone

void bt::TorrentInterface::runningJobsDone ( bt::TorrentInterface me)
signal

Emitted when all running jobs are done.

Parameters
methe torrent

◆ scrapeTracker()

virtual void bt::TorrentInterface::scrapeTracker ( )
pure virtual

Scrape all or one tracker (private torrents)

◆ seedingAutoStopped

void bt::TorrentInterface::seedingAutoStopped ( bt::TorrentInterface me,
bt::AutoStopReason  reason 
)
signal

Emitted then torrent is stopped from seeding by KTorrent. Happens when torrent has reached maximum share ratio and maybe we'll add something more...

Parameters
meThe object which emitted the signal.
reasonThe reason why it was aut stopped

◆ setMoveWhenCompletedDir()

virtual void bt::TorrentInterface::setMoveWhenCompletedDir ( const QString &  dir)
pure virtual

Get the move upon completion directory.

Parameters
dirthe directory an empty url disables this feature

Implemented in bt::TorrentControl.

◆ setQueued()

virtual void bt::TorrentInterface::setQueued ( bool  queued)
pure virtual

Set whether the torrent is queued or not

Implemented in bt::TorrentControl.

◆ setSuperSeeding()

virtual void bt::TorrentInterface::setSuperSeeding ( bool  on)
pure virtual

Enable or disable superseeding mode, does nothing if the torrent is not finished.

Implemented in bt::TorrentControl.

◆ start()

virtual void bt::TorrentInterface::start ( )
pure virtual

Start the download of the torrent.

◆ startDataCheck()

virtual Job* bt::TorrentInterface::startDataCheck ( bool  auto_import,
bt::Uint32  from,
bt::Uint32  to 
)
pure virtual

Verify the correctness of all data. If from and to are not a valid range, the entire torrent will be checked.

Parameters
auto_importIs this an automatic import
fromChunk to start from
toChunk to end with

Implemented in bt::TorrentControl.

◆ statusChanged

void bt::TorrentInterface::statusChanged ( bt::TorrentInterface me)
signal

Emitted whenever the status of the torrent changes.

Parameters
methe torrent

◆ stop()

virtual void bt::TorrentInterface::stop ( bt::WaitJob wjob = 0)
pure virtual

Stop the download, closes all connections.

Parameters
wjobWaitJob, used when KT is shutting down, so that we can wait for all stopped events to reach the tracker

◆ stoppedByError

void bt::TorrentInterface::stoppedByError ( bt::TorrentInterface me,
QString  msg 
)
signal

Emitted when a Torrent download is stopped by error

Parameters
meThe object who emitted the signal
msgError message

◆ torrentStopped

void bt::TorrentInterface::torrentStopped ( bt::TorrentInterface me)
signal

Torrent has been stopped

Parameters
meThe torrent which emitted the signal

◆ unpause()

virtual void bt::TorrentInterface::unpause ( )
pure virtual

Unpause the torrent.

◆ update()

virtual void bt::TorrentInterface::update ( )
pure virtual

Update the object, should be called periodically.

◆ updateQueue

void bt::TorrentInterface::updateQueue ( )
signal

Emitted when the torrent thinks the QM should update the queue

◆ updateTracker()

virtual void bt::TorrentInterface::updateTracker ( )
pure virtual

Update the tracker, this should normally handled internally. We leave it public so that the user can do a manual announce.


The documentation for this class was generated from the following file: