qBittorrent
BitTorrent::InfoHash Class Reference

#include <infohash.h>

Public Types

using WrappedType = lt::sha1_hash
 

Public Member Functions

 InfoHash ()=default
 
 InfoHash (const WrappedType &nativeHash)
 
bool isValid () const
 
SHA1Hash v1 () const
 
SHA256Hash v2 () const
 
TorrentID toTorrentID () const
 
 operator WrappedType () const
 

Private Attributes

bool m_valid = false
 
WrappedType m_nativeHash
 

Detailed Description

Definition at line 57 of file infohash.h.

Member Typedef Documentation

◆ WrappedType

using BitTorrent::InfoHash::WrappedType = lt::sha1_hash

Definition at line 63 of file infohash.h.

Constructor & Destructor Documentation

◆ InfoHash() [1/2]

BitTorrent::InfoHash::InfoHash ( )
default

◆ InfoHash() [2/2]

BitTorrent::InfoHash::InfoHash ( const WrappedType nativeHash)

Definition at line 33 of file infohash.cpp.

34  : m_valid {true}
35  , m_nativeHash {nativeHash}
36 {
37 }
WrappedType m_nativeHash
Definition: infohash.h:78

Member Function Documentation

◆ isValid()

bool BitTorrent::InfoHash::isValid ( ) const

Definition at line 39 of file infohash.cpp.

40 {
41  return m_valid;
42 }

◆ operator WrappedType()

BitTorrent::InfoHash::operator WrappedType ( ) const

Definition at line 71 of file infohash.cpp.

72 {
73  return m_nativeHash;
74 }

◆ toTorrentID()

BitTorrent::TorrentID BitTorrent::InfoHash::toTorrentID ( ) const

Definition at line 62 of file infohash.cpp.

63 {
64 #ifdef QBT_USES_LIBTORRENT2
65  return m_nativeHash.get_best();
66 #else
67  return {m_nativeHash};
68 #endif
69 }

Referenced by BitTorrent::TorrentID::fromInfoHash(), BitTorrent::Torrent::id(), and AddNewTorrentDialog::reject().

Here is the caller graph for this function:

◆ v1()

SHA1Hash BitTorrent::InfoHash::v1 ( ) const

Definition at line 44 of file infohash.cpp.

45 {
46 #ifdef QBT_USES_LIBTORRENT2
47  return (m_nativeHash.has_v1() ? SHA1Hash(m_nativeHash.v1) : SHA1Hash());
48 #else
49  return {m_nativeHash};
50 #endif
51 }

Referenced by TransferListWidget::displayListMenu(), AddNewTorrentDialog::loadMagnet(), AddNewTorrentDialog::loadTorrentImpl(), PropertiesWidget::loadTorrentInfos(), TorrentsController::propertiesAction(), Application::runExternalProgram(), and serialize().

Here is the caller graph for this function:

◆ v2()

SHA256Hash BitTorrent::InfoHash::v2 ( ) const

Definition at line 53 of file infohash.cpp.

54 {
55 #ifdef QBT_USES_LIBTORRENT2
56  return (m_nativeHash.has_v2() ? SHA256Hash(m_nativeHash.v2) : SHA256Hash());
57 #else
58  return {};
59 #endif
60 }

Referenced by TransferListWidget::displayListMenu(), AddNewTorrentDialog::loadMagnet(), AddNewTorrentDialog::loadTorrentImpl(), PropertiesWidget::loadTorrentInfos(), TorrentsController::propertiesAction(), Application::runExternalProgram(), serialize(), and AddNewTorrentDialog::updateMetadata().

Here is the caller graph for this function:

Member Data Documentation

◆ m_nativeHash

WrappedType BitTorrent::InfoHash::m_nativeHash
private

Definition at line 78 of file infohash.h.

◆ m_valid

bool BitTorrent::InfoHash::m_valid = false
private

Definition at line 77 of file infohash.h.


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