libktorrent  2.2.0
Public Member Functions | List of all members
bt::Torrent Class Reference

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 DHTNodegetDHTNode (Uint32 i)
 Get a DHT node.
 
TorrentFilegetFile (Uint32 idx)
 
const TorrentFilegetFile (Uint32 idx) const
 
const SHA1HashgetHash (Uint32 idx) const
 
const SHA1HashgetInfoHash () 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 PeerIDgetPeerID () const
 Get our peer_id.
 
const QTextCodec * getTextCodec ()
 Get the text codec.
 
Uint64 getTotalSize () const
 Get the file size in number of bytes.
 
const TrackerTiergetTrackerList () 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)
 

Detailed Description

Author
Joris Guisson Loads a torrent file and calculates some miscelanious other data, like the info_hash and the peer_id.

Definition at line 79 of file torrent.h.

Member Function Documentation

◆ calcChunkPos()

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.

Parameters
chunkThe index of the chunk
file_listThis list will be filled with all the indices

◆ downloadPriorityChanged()

void bt::Torrent::downloadPriorityChanged ( TorrentFile tf,
Priority  newpriority,
Priority  oldpriority 
)

Called by TorrentFile when the priority changes

Parameters
tfThe file
newpriorityThe old priority
oldpriorityThe new priority

◆ filePercentageChanged()

void bt::Torrent::filePercentageChanged ( TorrentFile tf,
float  perc 
)

Called by TorrentFile when the percentage changes

Parameters
tfThe file
percThe percentage

◆ filePreviewChanged()

void bt::Torrent::filePreviewChanged ( TorrentFile tf,
bool  preview 
)

Called by TorrentFile when the preview state changes

Parameters
tfThe file
previewWhether preview is possible or not

◆ getFile() [1/2]

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.

Parameters
idxIndex of the file
Areference to the file

◆ getFile() [2/2]

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.

Parameters
idxIndex of the file
Areference to the file

◆ getHash()

const SHA1Hash& bt::Torrent::getHash ( Uint32  idx) const

Get the hash of a Chunk. Throws an Error if idx is out of bounds.

Parameters
idxIndex of Chunk
Returns
The SHA1 hash of the chunk

◆ getNumFiles()

Uint32 bt::Torrent::getNumFiles ( ) const
inline

Get the number of files in a multi file torrent. If we have a single file torrent, this will return 0.

Definition at line 173 of file torrent.h.

◆ getWebSeeds()

const QList<QUrl>& bt::Torrent::getWebSeeds ( ) const
inline

Get the list with web seed URL's

Definition at line 236 of file torrent.h.

◆ isMultimedia()

bool bt::Torrent::isMultimedia ( ) const

Checks if torrent file is audio or video.

◆ load()

void bt::Torrent::load ( const QByteArray &  data,
bool  verbose 
)

Load a .torrent file.

Parameters
dataThe data
verboseWhether to print information to the log
Exceptions
Errorif something goes wrong

◆ setFilePriorityListener()

void bt::Torrent::setFilePriorityListener ( FilePriorityListener l)
inline

Set the FilePriorityListener

Parameters
lTHe listener

Definition at line 90 of file torrent.h.

◆ updateFilePercentage() [1/2]

void bt::Torrent::updateFilePercentage ( ChunkManager cman)

Update the percentage of all files.

Parameters
cmanThe ChunkManager

◆ updateFilePercentage() [2/2]

void bt::Torrent::updateFilePercentage ( Uint32  chunk,
ChunkManager cman 
)

Update the percentage of a all files which have a particular chunk.

Parameters
cmanThe ChunkManager

◆ verifyHash()

bool bt::Torrent::verifyHash ( const SHA1Hash h,
Uint32  index 
)

Verify whether a hash matches the hash of a Chunk

Parameters
hThe hash
indexThe index of the chunk
Returns
true if they match

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