libktorrent  2.2.0
Classes | Public Slots | Signals | Public Member Functions | Protected Member Functions | Friends | List of all members
bt::TorrentControl Class Reference

Controls just about everything. More...

#include <torrentcontrol.h>

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

Public Slots

void pause () override
 
void scrapeTracker () override
 
static void setDataCheckWhenCompleted (bool on)
 
static void setMinimumDiskSpace (Uint32 m)
 
void start () override
 
void stop (WaitJob *wjob=0) override
 
void trackerScrapeDone ()
 
void unpause () override
 
void update () override
 
void updateTracker () override
 

Signals

void dataCheckFinished ()
 
- Signals inherited from bt::TorrentInterface
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

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

Protected Member Functions

void afterDataCheck (DataCheckerJob *job, const BitSet &result)
 Called when a data check is finished by DataCheckerJob.
 
void allJobsDone ()
 
void beforeDataCheck ()
 
bool preallocate ()
 
void preallocFinished (const QString &error, bool completed)
 

Friends

class DataCheckerJob
 
class JobQueue
 
class PreallocationJob
 

Additional Inherited Members

- Public Types inherited from bt::TorrentInterface
enum  ChangeOutputFlags { MOVE_FILES = 1, FULL_PATH = 2 }
 
typedef QSharedPointer< TorrentInterfacePtr
 
typedef QPointer< TorrentInterfaceWPtr
 
- Protected Attributes inherited from bt::TorrentInterface
QString display_name
 
TorrentStats stats
 
QUrl url
 
QString user_modified_name
 

Detailed Description

Author
Joris Guisson This is the interface which any user gets to deal with. This class controls the uploading, downloading, choking, updating the tracker and chunk management.

Definition at line 68 of file torrentcontrol.h.

Member Function Documentation

◆ addPeerSource()

void bt::TorrentControl::addPeerSource ( PeerSource ps)
overridevirtual

Add a new PeerSource

Parameters
ps

Implements bt::TorrentInterface.

◆ availableChunksBitSet()

const BitSet& bt::TorrentControl::availableChunksBitSet ( ) const
overridevirtual

Get a BitSet of the availability of all Chunks

Implements bt::TorrentInterface.

◆ changeOutputDir()

bool bt::TorrentControl::changeOutputDir ( const QString &  new_dir,
int  flags 
)
overridevirtual

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

Implements bt::TorrentInterface.

◆ changeTorDir()

bool bt::TorrentControl::changeTorDir ( const QString &  new_dir)
overridevirtual

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

Implements bt::TorrentInterface.

◆ createTorrentFileStream()

TorrentFileStream::Ptr bt::TorrentControl::createTorrentFileStream ( bt::Uint32  index,
bool  streaming_mode,
QObject *  parent 
)
overridevirtual

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

Implements bt::TorrentInterface.

◆ deleteDataFiles()

void bt::TorrentControl::deleteDataFiles ( )
overridevirtual

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

Implements bt::TorrentInterface.

◆ dndMissingFiles()

void bt::TorrentControl::dndMissingFiles ( )
overridevirtual

Mark missing files as do not download.

Implements bt::TorrentInterface.

◆ downloadedChunksBitSet()

const BitSet& bt::TorrentControl::downloadedChunksBitSet ( ) const
overridevirtual

Get a BitSet of the status of all Chunks

Implements bt::TorrentInterface.

◆ excludedChunksBitSet()

const BitSet& bt::TorrentControl::excludedChunksBitSet ( ) const
overridevirtual

Get a BitSet of the excluded Chunks

Implements bt::TorrentInterface.

◆ getETA()

int bt::TorrentControl::getETA ( )
overridevirtual

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

Implements bt::TorrentInterface.

◆ getMoveWhenCompletedDir()

QString bt::TorrentControl::getMoveWhenCompletedDir ( ) const
inlineoverridevirtual

Get the move upon completion directory.

Implements bt::TorrentInterface.

Definition at line 166 of file torrentcontrol.h.

◆ getRunningTimeDL()

Uint32 bt::TorrentControl::getRunningTimeDL ( ) const
overridevirtual

Get the download running time of this torrent in seconds

Returns
Uint32 - time in seconds

Implements bt::TorrentInterface.

◆ getRunningTimeUL()

Uint32 bt::TorrentControl::getRunningTimeUL ( ) const
overridevirtual

Get the upload running time of this torrent in seconds

Returns
Uint32 - time in seconds

Implements bt::TorrentInterface.

◆ getTorDir()

QString bt::TorrentControl::getTorDir ( ) const
inlineoverridevirtual

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

Implements bt::TorrentInterface.

Definition at line 110 of file torrentcontrol.h.

◆ getTorrentFile() [1/2]

const TorrentFileInterface& bt::TorrentControl::getTorrentFile ( Uint32  index) const
overridevirtual

Const version of the previous one.

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

Implements bt::TorrentInterface.

◆ getTorrentFile() [2/2]

TorrentFileInterface& bt::TorrentControl::getTorrentFile ( Uint32  index)
overridevirtual

Get the index'th file of a multifile torrent

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

Implements bt::TorrentInterface.

◆ hasMissingFiles()

bool bt::TorrentControl::hasMissingFiles ( QStringList &  sl)
overridevirtual

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

Implements bt::TorrentInterface.

◆ init()

void bt::TorrentControl::init ( QueueManagerInterface qman,
const QByteArray &  data,
const QString &  tmpdir,
const QString &  datadir 
)

Initialize the TorrentControl.

Parameters
qmanThe QueueManager
dataThe data of the torrent
tmpdirThe directory to store temporary data
datadirThe directory to store the actual file(s) (only used the first time we load a torrent)
Exceptions
Errorwhen something goes wrong

◆ isStorageMounted()

bool bt::TorrentControl::isStorageMounted ( QStringList &  missing)
overridevirtual

Is storage mounted for this torrent

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

Implements bt::TorrentInterface.

◆ moveTorrentFiles()

bool bt::TorrentControl::moveTorrentFiles ( const QMap< TorrentFileInterface *, QString > &  files)
overridevirtual

Move a torrent file to a new location.

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

Implements bt::TorrentInterface.

◆ onlySeedChunksBitSet()

const BitSet& bt::TorrentControl::onlySeedChunksBitSet ( ) const
overridevirtual

Get a bitset of only seed chunks

Implements bt::TorrentInterface.

◆ pause

void bt::TorrentControl::pause ( )
overrideslot

Pause the torrent.

◆ readyForPreview()

bool bt::TorrentControl::readyForPreview ( ) const
overridevirtual

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

Returns
true if it is

Implements bt::TorrentInterface.

◆ recreateMissingFiles()

void bt::TorrentControl::recreateMissingFiles ( )
overridevirtual

Recreate missing files.

Implements bt::TorrentInterface.

◆ removePeerSource()

void bt::TorrentControl::removePeerSource ( PeerSource ps)
overridevirtual

Remove a nPeerSource

Parameters
ps

Implements bt::TorrentInterface.

◆ rollback()

void bt::TorrentControl::rollback ( )
overridevirtual

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

Implements bt::TorrentInterface.

◆ scrapeTracker

void bt::TorrentControl::scrapeTracker ( )
overrideslot

Scrape the tracker.

◆ setChunkSelectorFactory()

void bt::TorrentControl::setChunkSelectorFactory ( ChunkSelectorFactoryInterface *  csfi)

Set a custom chunk selector factory (needs to be done for init is called) Note: TorrentControl does not take ownership

◆ setDataCheckWhenCompleted

static void bt::TorrentControl::setDataCheckWhenCompleted ( bool  on)
inlinestaticslot

Enable or disable data check upon completion

Parameters
on

Definition at line 231 of file torrentcontrol.h.

◆ setMinimumDiskSpace

static void bt::TorrentControl::setMinimumDiskSpace ( Uint32  m)
inlinestaticslot

Set the minimum amount of diskspace in MB. When there is less then this free, torrents will be stopped.

Parameters
m

Definition at line 237 of file torrentcontrol.h.

◆ setMoveWhenCompletedDir()

void bt::TorrentControl::setMoveWhenCompletedDir ( const QString &  dir)
inlineoverridevirtual

Get the move upon completion directory.

Parameters
dirthe directory an empty url disables this feature

Implements bt::TorrentInterface.

Definition at line 165 of file torrentcontrol.h.

◆ setQueued()

void bt::TorrentControl::setQueued ( bool  queued)
overridevirtual

Set whether the torrent is queued or not

Implements bt::TorrentInterface.

◆ setSuperSeeding()

void bt::TorrentControl::setSuperSeeding ( bool  on)
overridevirtual

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

Implements bt::TorrentInterface.

◆ start

void bt::TorrentControl::start ( )
overrideslot

Start the download of the torrent.

◆ startDataCheck()

Job* bt::TorrentControl::startDataCheck ( bool  auto_import,
bt::Uint32  from,
bt::Uint32  to 
)
overridevirtual

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

Implements bt::TorrentInterface.

◆ stop

void bt::TorrentControl::stop ( WaitJob wjob = 0)
overrideslot

Stop the download, closes all connections.

Parameters
wjobWaitJob to wait at exit for the completion of stopped requests

◆ trackerScrapeDone

void bt::TorrentControl::trackerScrapeDone ( )
slot

A scrape has finished on the tracker.

◆ unpause

void bt::TorrentControl::unpause ( )
overrideslot

Unpause the torrent.

◆ update

void bt::TorrentControl::update ( )
overrideslot

Update the object, should be called periodically.

◆ updateTracker

void bt::TorrentControl::updateTracker ( )
overrideslot

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: