Protocols::BitTorrent::Torrents::Torrent Class Reference

#include <Torrent.h> [code]

List of all members.


Detailed Description

Represents parsed BitTorrent file.

This class is used to store all needed BitTorrent file properties. It provides value semantics (objects copying allowed) and implicit data sharing.

Torrent structure is made according to these specifications: http://wiki.theory.org/BitTorrentSpecification#Metainfo_File_Structure .

Optional tracker announce list is made according to these specifications: http://home.elp.rr.com/tur/multitracker-spec.txt (this is an extention to the official specification, which is also backwards compatible).

Optional field 'private' is made according to these specifications: http://www.azureuswiki.com/index.php/Secure_Torrents (this field is used in practice but it is not part of the official specification).

Information about stored files (info dictionary) abstracts the difference between single and multiple file mode so there is only a list of file information and if a torrent files info is in the multiple file mode then each file is beginning with the directory name so there is no stand-alone directory saved in the Torrent class. However, if every file in the file info structure begins with the same directory (prefix) you can be sure that this is the original directory name specified in the parsed torrent file.

It does not throw its own exceptions and lets any thrown exceptions through to the user. In case an exception (e.g. bad_alloc) gets thrown, the Torrent object will be left in an unchanged state. Thus the class meets the strong guarantee of exception safety.

Torrent objects can currently only be created using TorrentParser which makes sure that only valid Torrent objects are created.

Todo:
Use something like Sha1HashDigest instead of FixedSizeByteArray <20> as Piece data type.
Todo:
Remove announce() and keep only announceList()? Single torrent trackers will have announceList() return a single list with one element.
Todo:
Do BitTorrent client really query only one of the trackers in the announceList()? I think BitComet at least queries all the trackers.

Definition at line 83 of file Torrent.h.

Public Types

typedef QList< QList< Uri > > AnnounceList
 List of tiers of announces (URLs of trackers).
typedef FixedSizeByteArray< 20 > Piece
 20-byte SHA1 hash for storing piece hash.
typedef QList< PiecePieceList
 List of hash values of pieces.
typedef FixedSizeByteArray< 20 > InfoHash
 20-byte SHA1 hash for storing the hashed value of the info key.
typedef QList< FileInfoFileInfoList
 List of files information.

Public Member Functions

 Torrent (const Torrent &)
 Copy constructor.
Torrentoperator= (const Torrent &)
 Assignment operator.
bool operator== (const Torrent &) const
 Equality comparison.
bool operator!= (const Torrent &) const
 Inequality comparison.
 Torrent ()
 Default constructor.
 ~Torrent ()
 Destructor.
Uri announce () const
 Returns the announce URL of the tracker.
AnnounceList announceList () const
 Returns list of announce URLs of trackers.
QDateTime creationDate () const
 Returns the creation date of the torrent.
QString comment () const
 Returns the torrent comment.
QString createdBy () const
 Returns the name/version of the torrent creator.
int pieceLength () const
 Returns number of bytes in each piece.
PieceList pieces () const
 Returns concatenation of all hash values.
bool isPrivate () const
 Returns true if the private (security) flag is set to true.
FileInfoList files () const
 Returns list of files information.
InfoHash infoHash () const
 Returns the hashed value of the info key.

Private Attributes

QSharedDataPointer< PrivateDatad
 Private data with implicit sharing.

Friends

class TorrentParser

Classes

class  FileInfo
 Information about a single file. More...
struct  PrivateData
 Stores the private members of Torrent using implicit sharing. More...


Member Typedef Documentation

typedef QList<QList <Uri> > Protocols::BitTorrent::Torrents::Torrent::AnnounceList
 

List of tiers of announces (URLs of trackers).

Definition at line 90 of file Torrent.h.

typedef QList<FileInfo> Protocols::BitTorrent::Torrents::Torrent::FileInfoList
 

List of files information.

Definition at line 141 of file Torrent.h.

typedef FixedSizeByteArray<20> Protocols::BitTorrent::Torrents::Torrent::InfoHash
 

20-byte SHA1 hash for storing the hashed value of the info key.

Todo:
Use something like Sha1HashDigest instead.

Definition at line 102 of file Torrent.h.

typedef FixedSizeByteArray<20> Protocols::BitTorrent::Torrents::Torrent::Piece
 

20-byte SHA1 hash for storing piece hash.

Definition at line 93 of file Torrent.h.

typedef QList<Piece> Protocols::BitTorrent::Torrents::Torrent::PieceList
 

List of hash values of pieces.

Definition at line 96 of file Torrent.h.


Constructor & Destructor Documentation

Torrent::Torrent const Torrent other  ) 
 

Copy constructor.

Constructs a copy of the other object.

Definition at line 126 of file Torrent.cpp.

Torrent::Torrent  ) 
 

Default constructor.

Constructs an empty Torrent object.

Definition at line 107 of file Torrent.cpp.

Torrent::~Torrent  ) 
 

Destructor.

Destroys a Torrent object.

Definition at line 118 of file Torrent.cpp.


Member Function Documentation

Uri Protocols::BitTorrent::Torrents::Torrent::announce  )  const [inline]
 

Returns the announce URL of the tracker.

Definition at line 195 of file Torrent.h.

Torrent::AnnounceList Protocols::BitTorrent::Torrents::Torrent::announceList  )  const [inline]
 

Returns list of announce URLs of trackers.

Definition at line 199 of file Torrent.h.

QString Protocols::BitTorrent::Torrents::Torrent::comment  )  const [inline]
 

Returns the torrent comment.

Definition at line 207 of file Torrent.h.

QString Protocols::BitTorrent::Torrents::Torrent::createdBy  )  const [inline]
 

Returns the name/version of the torrent creator.

Definition at line 211 of file Torrent.h.

QDateTime Protocols::BitTorrent::Torrents::Torrent::creationDate  )  const [inline]
 

Returns the creation date of the torrent.

Definition at line 203 of file Torrent.h.

Torrent::FileInfoList Protocols::BitTorrent::Torrents::Torrent::files  )  const [inline]
 

Returns list of files information.

Definition at line 227 of file Torrent.h.

Torrent::InfoHash Protocols::BitTorrent::Torrents::Torrent::infoHash  )  const [inline]
 

Returns the hashed value of the info key.

Definition at line 231 of file Torrent.h.

bool Protocols::BitTorrent::Torrents::Torrent::isPrivate  )  const [inline]
 

Returns true if the private (security) flag is set to true.

Definition at line 223 of file Torrent.h.

bool Torrent::operator!= const Torrent other  )  const
 

Inequality comparison.

Returns true if this Torrent object is not equal to the other object.

Definition at line 164 of file Torrent.cpp.

Torrent & Torrent::operator= const Torrent other  ) 
 

Assignment operator.

Assigns the other object to this object and returns a reference to this object.

Definition at line 136 of file Torrent.cpp.

bool Torrent::operator== const Torrent other  )  const
 

Equality comparison.

Returns true if this Torrent object is equal to the other object.

Definition at line 146 of file Torrent.cpp.

int Protocols::BitTorrent::Torrents::Torrent::pieceLength  )  const [inline]
 

Returns number of bytes in each piece.

Definition at line 215 of file Torrent.h.

Torrent::PieceList Protocols::BitTorrent::Torrents::Torrent::pieces  )  const [inline]
 

Returns concatenation of all hash values.

Definition at line 219 of file Torrent.h.


Friends And Related Function Documentation

friend class TorrentParser [friend]
 

Definition at line 162 of file Torrent.h.


Member Data Documentation

QSharedDataPointer<PrivateData> Protocols::BitTorrent::Torrents::Torrent::d [private]
 

Private data with implicit sharing.

Definition at line 179 of file Torrent.h.


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