libktorrent  2.2.0
Public Slots | Signals | Public Member Functions | Static Public Member Functions | List of all members
bt::Downloader Class Reference

Manages the downloading. More...

#include <downloader.h>

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

Public Slots

void dataChecked (const BitSet &ok_chunks, bt::Uint32 from, bt::Uint32 to)
 
void recalcDownloaded ()
 
void setMonitor (MonitorInterface *tmo)
 
void update ()
 

Signals

void chunkDownloaded (Uint32 chunk)
 
void ioError (const QString &msg)
 

Public Member Functions

 Downloader (Torrent &tor, PeerManager &pman, ChunkManager &cman)
 
void addPieceDownloader (PieceDownloader *peer)
 
WebSeedaddWebSeed (const QUrl &url)
 Add a webseed.
 
CurChunkCItr beginDownloads () const
 
Uint64 bytesDownloaded () const
 Get the number of bytes we have downloaded.
 
bool canDownloadFromWebSeed (Uint32 chunk) const
 
void clearDownloads ()
 
void corrupted (Uint32 chunk)
 
ChunkDownloaddownload (Uint32 chunk)
 
const ChunkDownloaddownload (Uint32 chunk) const
 
bool downloading (Uint32 chunk) const
 
Uint32 downloadRate () const
 Get the current dowload rate.
 
CurChunkCItr endDownloads () const
 
bool endgameMode () const
 Are we in endgame mode.
 
Uint32 getDownloadedBytesOfCurrentChunksFile (const QString &file)
 
Uint32 getNumWebSeeds () const
 Get the number of webseeds.
 
WebSeedgetWebSeed (Uint32 i)
 Get a webseed.
 
const WebSeedgetWebSeed (Uint32 i) const
 Get a webseed.
 
bool isFinished () const
 See if the download is finished.
 
void loadDownloads (const QString &file)
 
void loadWebSeeds (const QString &file)
 Add the user created webseeds.
 
Uint32 numActiveDownloads () const
 Get the number of chunks we are dowloading.
 
Uint32 numDownloadersForChunk (Uint32 chunk) const
 
void pause ()
 
void removeAllWebSeeds ()
 Remove all webseeds.
 
void removePieceDownloader (PieceDownloader *peer)
 
bool removeWebSeed (const QUrl &url)
 Remove a webseed.
 
void saveDownloads (const QString &file)
 
void saveWebSeeds (const QString &file)
 Save the user created webseeds.
 
void setChunkSelector (ChunkSelectorInterface *csel)
 Set the ChunkSelector, 0 means KT will reset to the default selector.
 
void setGroupIDs (Uint32 up, Uint32 down)
 
- Public Member Functions inherited from bt::PieceHandler
virtual void pieceReceived (const Piece &p)=0
 

Static Public Member Functions

static void setUseWebSeeds (bool on)
 Enable or disable the use of webseeds.
 

Detailed Description

Author
Joris Guisson This class manages the downloading of the file. It should regurarly be updated.

Definition at line 67 of file downloader.h.

Constructor & Destructor Documentation

◆ Downloader()

bt::Downloader::Downloader ( Torrent tor,
PeerManager pman,
ChunkManager cman 
)

Constructor.

Parameters
torThe Torrent
pmanThe PeerManager
cmanThe ChunkManager

Member Function Documentation

◆ addPieceDownloader()

void bt::Downloader::addPieceDownloader ( PieceDownloader peer)

We got a new connection.

Parameters
peerThe PieceDownloader

◆ canDownloadFromWebSeed()

bool bt::Downloader::canDownloadFromWebSeed ( Uint32  chunk) const

Can we download a chunk from a webseed.

Parameters
chunkID of Chunk
Returns
true if we can

◆ chunkDownloaded

void bt::Downloader::chunkDownloaded ( Uint32  chunk)
signal

Emitted when a chunk has been downloaded.

Parameters
chunkThe chunk

◆ clearDownloads()

void bt::Downloader::clearDownloads ( )

Clear all downloads. Deletes all active downloads.

◆ corrupted()

void bt::Downloader::corrupted ( Uint32  chunk)

A corrupted chunk has been detected, make sure we redownload it.

Parameters
chunkThe chunk

◆ dataChecked

void bt::Downloader::dataChecked ( const BitSet ok_chunks,
bt::Uint32  from,
bt::Uint32  to 
)
slot

Data has been checked, and these chunks are OK.

Parameters
ok_chunksThe ok_chunks
fromFirst chunk of the check
toLast chunk of the check

◆ download() [1/2]

ChunkDownload* bt::Downloader::download ( Uint32  chunk)

Get a download for a chunk

Parameters
chunkThe chunk
Returns
The ChunkDownload, or 0 if no download is found

◆ download() [2/2]

const ChunkDownload* bt::Downloader::download ( Uint32  chunk) const

Get a download for a chunk (const version)

Parameters
chunkThe chunk
Returns
The ChunkDownload, or 0 if no download is found

◆ downloading()

bool bt::Downloader::downloading ( Uint32  chunk) const

See if we are downloading a Chunk

Parameters
chunkID of Chunk
Returns
true if we are, false if not

◆ getDownloadedBytesOfCurrentChunksFile()

Uint32 bt::Downloader::getDownloadedBytesOfCurrentChunksFile ( const QString &  file)

Get the number of bytes already downloaded in the current_chunks file.

Parameters
fileThe path of the current_chunks file
Returns
The bytes already downloading

◆ ioError

void bt::Downloader::ioError ( const QString &  msg)
signal

An error occurred while we we're writing or reading from disk.

Parameters
msgMessage

◆ loadDownloads()

void bt::Downloader::loadDownloads ( const QString &  file)

Load the current downloads.

Parameters
fileThe file to load from

◆ numDownloadersForChunk()

Uint32 bt::Downloader::numDownloadersForChunk ( Uint32  chunk) const

Get the number of downloaders assigned to a chunk

Parameters
chunkID of Chunk
Returns
the number of downloaders for that chunk

◆ pause()

void bt::Downloader::pause ( )

Pause the download

◆ recalcDownloaded

void bt::Downloader::recalcDownloaded ( )
slot

Recalculate the number of bytes downloaded.

◆ removePieceDownloader()

void bt::Downloader::removePieceDownloader ( PieceDownloader peer)

Remove a piece downloader.

Parameters
peerThe PieceDownloader

◆ saveDownloads()

void bt::Downloader::saveDownloads ( const QString &  file)

Save the current downloads.

Parameters
fileThe file to save to

◆ setGroupIDs()

void bt::Downloader::setGroupIDs ( Uint32  up,
Uint32  down 
)

Set the group ID's of the webseed (for speed limits)

Parameters
upUpload group id
downDownload group id

◆ setMonitor

void bt::Downloader::setMonitor ( MonitorInterface tmo)
slot

Set the TorrentMonitor.

Parameters
tmo

◆ update

void bt::Downloader::update ( )
slot

Update the downloader.


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