libktorrent
2.2.0
|
Loads a .torrent file. More...
#include <torrent.h>
Public Member Functions | |
Torrent (const bt::SHA1Hash &hash) | |
void | calcChunkPos (Uint32 chunk, QList< Uint32 > &file_list) const |
void | changeTextCodec (QTextCodec *codec) |
Change the text codec. | |
void | debugPrintInfo () |
void | downloadPriorityChanged (TorrentFile *tf, Priority newpriority, Priority oldpriority) |
void | filePercentageChanged (TorrentFile *tf, float perc) |
void | filePreviewChanged (TorrentFile *tf, bool preview) |
Uint64 | getChunkSize () const |
Get the size of a chunk. | |
QString | getComments () const |
Return the comments in the torrent. | |
const DHTNode & | getDHTNode (Uint32 i) |
Get a DHT node. | |
TorrentFile & | getFile (Uint32 idx) |
const TorrentFile & | getFile (Uint32 idx) const |
const SHA1Hash & | getHash (Uint32 idx) const |
const SHA1Hash & | getInfoHash () const |
Get the info_hash. | |
Uint64 | getLastChunkSize () const |
Get the size of the last chunk. | |
const QByteArray & | getMetaData () const |
Get the metadata. | |
QString | getNameSuggestion () const |
Get the suggested name. | |
Uint32 | getNumChunks () const |
Get the number of chunks. | |
Uint32 | getNumDHTNodes () const |
Get the number of initial DHT nodes. | |
Uint32 | getNumFiles () const |
unsigned int | getNumTrackerURLs () const |
Get the number of tracker URL's. | |
const PeerID & | getPeerID () const |
Get our peer_id. | |
const QTextCodec * | getTextCodec () |
Get the text codec. | |
Uint64 | getTotalSize () const |
Get the file size in number of bytes. | |
const TrackerTier * | getTrackerList () const |
Gets a pointer to AnnounceList. | |
const QList< QUrl > & | getWebSeeds () const |
bool | isLoaded () const |
Is the torrent loaded. | |
bool | isMultiFile () const |
See if we have a multi file torrent. | |
bool | isMultimedia () const |
bool | isPrivate () const |
See if the torrent is private. | |
void | load (const QByteArray &data, bool verbose) |
void | setFilePriorityListener (FilePriorityListener *l) |
void | setMonitor (MonitorInterface *m) |
Set the monitor. | |
void | updateFilePercentage (ChunkManager &cman) |
void | updateFilePercentage (Uint32 chunk, ChunkManager &cman) |
bool | verifyHash (const SHA1Hash &h, Uint32 index) |
Loads a torrent file and calculates some miscelanious other data, like the info_hash and the peer_id.
void bt::Torrent::calcChunkPos | ( | Uint32 | chunk, |
QList< Uint32 > & | file_list | ||
) | const |
Calculate in which file(s) a Chunk lies. A list will get filled with the indices of all the files. The list gets cleared at the beginning. If something is wrong only the list will get cleared.
chunk | The index of the chunk |
file_list | This list will be filled with all the indices |
void bt::Torrent::downloadPriorityChanged | ( | TorrentFile * | tf, |
Priority | newpriority, | ||
Priority | oldpriority | ||
) |
Called by TorrentFile when the priority changes
tf | The file |
newpriority | The old priority |
oldpriority | The new priority |
void bt::Torrent::filePercentageChanged | ( | TorrentFile * | tf, |
float | perc | ||
) |
Called by TorrentFile when the percentage changes
tf | The file |
perc | The percentage |
void bt::Torrent::filePreviewChanged | ( | TorrentFile * | tf, |
bool | preview | ||
) |
Called by TorrentFile when the preview state changes
tf | The file |
preview | Whether preview is possible or not |
TorrentFile& bt::Torrent::getFile | ( | Uint32 | idx | ) |
Get a TorrentFile. If the index is out of range, or we have a single file torrent we return a null TorrentFile.
idx | Index of the file |
A | reference to the file |
const TorrentFile& bt::Torrent::getFile | ( | Uint32 | idx | ) | const |
Get a TorrentFile. If the index is out of range, or we have a single file torrent we return a null TorrentFile.
idx | Index of the file |
A | reference to the file |
const SHA1Hash& bt::Torrent::getHash | ( | Uint32 | idx | ) | const |
|
inline |
|
inline |
bool bt::Torrent::isMultimedia | ( | ) | const |
Checks if torrent file is audio or video.
void bt::Torrent::load | ( | const QByteArray & | data, |
bool | verbose | ||
) |
Load a .torrent file.
data | The data |
verbose | Whether to print information to the log |
Error | if something goes wrong |
|
inline |
void bt::Torrent::updateFilePercentage | ( | ChunkManager & | cman | ) |
Update the percentage of all files.
cman | The ChunkManager |
void bt::Torrent::updateFilePercentage | ( | Uint32 | chunk, |
ChunkManager & | cman | ||
) |
Update the percentage of a all files which have a particular chunk.
cman | The ChunkManager |
bool bt::Torrent::verifyHash | ( | const SHA1Hash & | h, |
Uint32 | index | ||
) |
Verify whether a hash matches the hash of a Chunk
h | The hash |
index | The index of the chunk |