qBittorrent
BitTorrent::TorrentInfo Class Reference

#include <torrentinfo.h>

Public Types

using PieceRange = IndexRange< int >
 

Public Member Functions

 TorrentInfo ()=default
 
 TorrentInfo (const TorrentInfo &other)
 
 TorrentInfo (const lt::torrent_info &nativeInfo)
 
nonstd::expected< void, QString > saveToFile (const QString &path) const
 
TorrentInfooperator= (const TorrentInfo &other)
 
bool isValid () const
 
InfoHash infoHash () const
 
QString name () const
 
QDateTime creationDate () const
 
QString creator () const
 
QString comment () const
 
bool isPrivate () const
 
qlonglong totalSize () const
 
int filesCount () const
 
int pieceLength () const
 
int pieceLength (int index) const
 
int piecesCount () const
 
QString filePath (int index) const
 
QStringList filePaths () const
 
qlonglong fileSize (int index) const
 
qlonglong fileOffset (int index) const
 
QVector< TrackerEntrytrackers () const
 
QVector< QUrl > urlSeeds () const
 
QByteArray metadata () const
 
QStringList filesForPiece (int pieceIndex) const
 
QVector< int > fileIndicesForPiece (int pieceIndex) const
 
QVector< QByteArray > pieceHashes () const
 
PieceRange filePieces (const QString &file) const
 
PieceRange filePieces (int fileIndex) const
 
QString rootFolder () const
 
bool hasRootFolder () const
 
std::shared_ptr< lt::torrent_info > nativeInfo () const
 
QVector< lt::file_index_t > nativeIndexes () const
 

Static Public Member Functions

static nonstd::expected< TorrentInfo, QString > load (const QByteArray &data) noexcept
 
static nonstd::expected< TorrentInfo, QString > loadFromFile (const QString &path) noexcept
 

Private Member Functions

int fileIndex (const QString &fileName) const
 
TorrentContentLayout contentLayout () const
 

Private Attributes

std::shared_ptr< const lt::torrent_info > m_nativeInfo
 
QVector< lt::file_index_t > m_nativeIndexes
 

Detailed Description

Definition at line 50 of file torrentinfo.h.

Member Typedef Documentation

◆ PieceRange

Definition at line 89 of file torrentinfo.h.

Constructor & Destructor Documentation

◆ TorrentInfo() [1/3]

BitTorrent::TorrentInfo::TorrentInfo ( )
default

◆ TorrentInfo() [2/3]

TorrentInfo::TorrentInfo ( const TorrentInfo other)

Definition at line 68 of file torrentinfo.cpp.

69  : m_nativeInfo {other.m_nativeInfo}
71 {
72 }
QVector< lt::file_index_t > m_nativeIndexes
Definition: torrentinfo.h:110
std::shared_ptr< const lt::torrent_info > m_nativeInfo
Definition: torrentinfo.h:106

◆ TorrentInfo() [3/3]

TorrentInfo::TorrentInfo ( const lt::torrent_info &  nativeInfo)
explicit

Definition at line 54 of file torrentinfo.cpp.

55  : m_nativeInfo {std::make_shared<const lt::torrent_info>(nativeInfo)}
56 {
57  Q_ASSERT(m_nativeInfo->is_valid() && (m_nativeInfo->num_files() > 0));
58 
59  const lt::file_storage &fileStorage = m_nativeInfo->orig_files();
60  m_nativeIndexes.reserve(fileStorage.num_files());
61  for (const lt::file_index_t nativeIndex : fileStorage.file_range())
62  {
63  if (!fileStorage.pad_file_at(nativeIndex))
64  m_nativeIndexes.append(nativeIndex);
65  }
66 }
std::shared_ptr< lt::torrent_info > nativeInfo() const

References m_nativeIndexes, and m_nativeInfo.

Member Function Documentation

◆ comment()

QString TorrentInfo::comment ( ) const

Definition at line 190 of file torrentinfo.cpp.

191 {
192  if (!isValid()) return {};
193 
194  return QString::fromStdString(m_nativeInfo->comment());
195 }

References isValid(), and m_nativeInfo.

Referenced by BitTorrent::TorrentImpl::comment(), and AddNewTorrentDialog::setupTreeview().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ contentLayout()

TorrentContentLayout TorrentInfo::contentLayout ( ) const
private

Definition at line 425 of file torrentinfo.cpp.

426 {
427  if (!isValid())
428  return TorrentContentLayout::Original;
429 
430  return detectContentLayout(filePaths());
431 }
QStringList filePaths() const
TorrentContentLayout detectContentLayout(const QStringList &filePaths)

References BitTorrent::detectContentLayout(), filePaths(), and isValid().

Here is the call graph for this function:

◆ creationDate()

QDateTime TorrentInfo::creationDate ( ) const

Definition at line 175 of file torrentinfo.cpp.

176 {
177  if (!isValid()) return {};
178 
179  const std::time_t date = m_nativeInfo->creation_date();
180  return ((date != 0) ? QDateTime::fromSecsSinceEpoch(date) : QDateTime());
181 }

References isValid(), and m_nativeInfo.

Referenced by BitTorrent::TorrentImpl::creationDate(), and AddNewTorrentDialog::setupTreeview().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ creator()

QString TorrentInfo::creator ( ) const

Definition at line 183 of file torrentinfo.cpp.

184 {
185  if (!isValid()) return {};
186 
187  return QString::fromStdString(m_nativeInfo->creator());
188 }

References isValid(), and m_nativeInfo.

Referenced by BitTorrent::TorrentImpl::creator().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fileIndex()

int TorrentInfo::fileIndex ( const QString &  fileName) const
private

Definition at line 399 of file torrentinfo.cpp.

400 {
401  // the check whether the object is valid is not needed here
402  // because if filesCount() returns -1 the loop exits immediately
403  for (int i = 0; i < filesCount(); ++i)
404  {
405  if (fileName == filePath(i))
406  return i;
407  }
408 
409  return -1;
410 }
QString filePath(int index) const
QString fileName(const QString &filePath)
Definition: fs.cpp:87

References Utils::Fs::fileName(), filePath(), and filesCount().

Referenced by filePieces().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fileIndicesForPiece()

QVector< int > TorrentInfo::fileIndicesForPiece ( int  pieceIndex) const

Definition at line 328 of file torrentinfo.cpp.

329 {
330  if (!isValid() || (pieceIndex < 0) || (pieceIndex >= piecesCount()))
331  return {};
332 
333  const std::vector<lt::file_slice> files = m_nativeInfo->map_block(
334  lt::piece_index_t {pieceIndex}, 0, m_nativeInfo->piece_size(lt::piece_index_t {pieceIndex}));
335  QVector<int> res;
336  res.reserve(static_cast<decltype(res)::size_type>(files.size()));
337  for (const lt::file_slice &fileSlice : files)
338  {
339  const int index = m_nativeIndexes.indexOf(fileSlice.file_index);
340  if (index >= 0)
341  res.append(index);
342  }
343 
344  return res;
345 }
flag icons free of to any person obtaining a copy of this software and associated documentation files(the "Software")

References files(), isValid(), m_nativeIndexes, m_nativeInfo, and piecesCount().

Referenced by filesForPiece(), PiecesBar::highlightFile(), and PiecesBar::showToolTip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fileOffset()

qlonglong TorrentInfo::fileOffset ( int  index) const

Definition at line 264 of file torrentinfo.cpp.

265 {
266  if (!isValid()) return -1;
267 
268  return m_nativeInfo->orig_files().file_offset(m_nativeIndexes[index]);
269 }

References isValid(), m_nativeIndexes, and m_nativeInfo.

Referenced by filePieces().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filePath()

QString TorrentInfo::filePath ( int  index) const

Definition at line 239 of file torrentinfo.cpp.

240 {
241  if (!isValid()) return {};
242 
244  QString::fromStdString(m_nativeInfo->orig_files().file_path(m_nativeIndexes[index])));
245 }
QString toUniformPath(const QString &path)
Definition: fs.cpp:69

References isValid(), m_nativeIndexes, m_nativeInfo, and Utils::Fs::toUniformPath().

Referenced by BitTorrent::Session::addTorrent_impl(), fileIndex(), filePaths(), and PiecesBar::showToolTip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filePaths()

QStringList TorrentInfo::filePaths ( ) const

Definition at line 247 of file torrentinfo.cpp.

248 {
249  QStringList list;
250  list.reserve(filesCount());
251  for (int i = 0; i < filesCount(); ++i)
252  list << filePath(i);
253 
254  return list;
255 }

References filePath(), and filesCount().

Referenced by BitTorrent::Session::addTorrent_impl(), contentLayout(), AddNewTorrentDialog::contentLayoutChanged(), BitTorrent::Session::findIncompleteFiles(), BitTorrent::TorrentImpl::handleSaveResumeDataAlert(), rootFolder(), and AddNewTorrentDialog::setupTreeview().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filePieces() [1/2]

TorrentInfo::PieceRange TorrentInfo::filePieces ( const QString &  file) const

Definition at line 362 of file torrentinfo.cpp.

363 {
364  if (!isValid()) // if we do not check here the debug message will be printed, which would be not correct
365  return {};
366 
367  const int index = fileIndex(file);
368  if (index == -1)
369  {
370  qDebug() << "Filename" << file << "was not found in torrent" << name();
371  return {};
372  }
373  return filePieces(index);
374 }
int fileIndex(const QString &fileName) const
PieceRange filePieces(const QString &file) const
QString name() const
file(GLOB QBT_TS_FILES "${qBittorrent_SOURCE_DIR}/src/lang/*.ts") set_source_files_properties($
Definition: CMakeLists.txt:5

References file(), fileIndex(), isValid(), and name().

Referenced by BitTorrent::TorrentImpl::applyFirstLastPiecePriority(), BitTorrent::TorrentImpl::availableFileFractions(), TorrentsController::filesAction(), and PiecesBar::highlightFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filePieces() [2/2]

TorrentInfo::PieceRange TorrentInfo::filePieces ( int  fileIndex) const

Definition at line 376 of file torrentinfo.cpp.

377 {
378  if (!isValid())
379  return {};
380 
381  if ((fileIndex < 0) || (fileIndex >= filesCount()))
382  {
383  qDebug() << "File index (" << fileIndex << ") is out of range for torrent" << name();
384  return {};
385  }
386 
387  const lt::file_storage &files = m_nativeInfo->orig_files();
388  const auto fileSize = files.file_size(m_nativeIndexes[fileIndex]);
389  const auto fileOffset = files.file_offset(m_nativeIndexes[fileIndex]);
390 
391  const int beginIdx = (fileOffset / pieceLength());
392  const int endIdx = ((fileOffset + fileSize - 1) / pieceLength());
393 
394  if (fileSize <= 0)
395  return {beginIdx, 0};
396  return makeInterval(beginIdx, endIdx);
397 }
qlonglong fileOffset(int index) const
qlonglong fileSize(int index) const
constexpr IndexInterval< T > makeInterval(const T first, const T last)
Definition: indexrange.h:63

References fileIndex(), fileOffset(), files(), filesCount(), fileSize(), isValid(), m_nativeIndexes, m_nativeInfo, makeInterval(), name(), and pieceLength().

Here is the call graph for this function:

◆ filesCount()

int TorrentInfo::filesCount ( ) const

◆ filesForPiece()

QStringList TorrentInfo::filesForPiece ( int  pieceIndex) const

Definition at line 315 of file torrentinfo.cpp.

316 {
317  // no checks here because fileIndicesForPiece() will return an empty list
318  const QVector<int> fileIndices = fileIndicesForPiece(pieceIndex);
319 
320  QStringList res;
321  res.reserve(fileIndices.size());
322  std::transform(fileIndices.begin(), fileIndices.end(), std::back_inserter(res),
323  [this](int i) { return filePath(i); });
324 
325  return res;
326 }
QVector< int > fileIndicesForPiece(int pieceIndex) const

References fileIndicesForPiece().

Referenced by SyncController::torrentPeersAction(), and PeerListWidget::updatePeer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fileSize()

qlonglong TorrentInfo::fileSize ( int  index) const

Definition at line 257 of file torrentinfo.cpp.

258 {
259  if (!isValid()) return -1;
260 
261  return m_nativeInfo->orig_files().file_size(m_nativeIndexes[index]);
262 }

References isValid(), m_nativeIndexes, and m_nativeInfo.

Referenced by filePieces(), BitTorrent::TorrentImpl::fileSize(), PiecesBar::showToolTip(), and AddNewTorrentDialog::updateDiskSpaceLabel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasRootFolder()

bool TorrentInfo::hasRootFolder ( ) const

Definition at line 420 of file torrentinfo.cpp.

421 {
422  return !rootFolder().isEmpty();
423 }
QString rootFolder() const

References rootFolder().

Here is the call graph for this function:

◆ infoHash()

InfoHash TorrentInfo::infoHash ( ) const

Definition at line 157 of file torrentinfo.cpp.

158 {
159  if (!isValid()) return {};
160 
161 #ifdef QBT_USES_LIBTORRENT2
162  return m_nativeInfo->info_hashes();
163 #else
164  return m_nativeInfo->info_hash();
165 #endif
166 }

References isValid(), and m_nativeInfo.

Referenced by BitTorrent::Session::findIncompleteFiles(), AddNewTorrentDialog::loadTorrentImpl(), and AddNewTorrentDialog::updateMetadata().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isPrivate()

bool TorrentInfo::isPrivate ( ) const

Definition at line 197 of file torrentinfo.cpp.

198 {
199  if (!isValid()) return false;
200 
201  return m_nativeInfo->priv();
202 }

References isValid(), and m_nativeInfo.

Referenced by BitTorrent::Session::addTorrent_impl(), BitTorrent::TorrentImpl::isPrivate(), and AddNewTorrentDialog::loadTorrentImpl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isValid()

◆ load()

nonstd::expected< TorrentInfo, QString > TorrentInfo::load ( const QByteArray &  data)
staticnoexcept

Definition at line 89 of file torrentinfo.cpp.

90 {
91  // 2-step construction to overcome default limits of `depth_limit` & `token_limit` which are
92  // used in `torrent_info()` constructor
93  const int depthLimit = 100;
94  const int tokenLimit = 10000000;
95 
96  lt::error_code ec;
97  const lt::bdecode_node node = lt::bdecode(data, ec
98  , nullptr, depthLimit, tokenLimit);
99  if (ec)
100  return nonstd::make_unexpected(QString::fromStdString(ec.message()));
101 
102  lt::torrent_info nativeInfo {node, ec};
103  if (ec)
104  return nonstd::make_unexpected(QString::fromStdString(ec.message()));
105 
106  return TorrentInfo(nativeInfo);
107 }

Referenced by TorrentsController::addAction(), AddNewTorrentDialog::handleDownloadFinished(), and BitTorrent::Session::handleDownloadFinished().

Here is the caller graph for this function:

◆ loadFromFile()

nonstd::expected< TorrentInfo, QString > TorrentInfo::loadFromFile ( const QString &  path)
staticnoexcept

Definition at line 109 of file torrentinfo.cpp.

110 {
111  QFile file {path};
112  if (!file.open(QIODevice::ReadOnly))
113  return nonstd::make_unexpected(file.errorString());
114 
115  if (file.size() > MAX_TORRENT_SIZE)
116  return nonstd::make_unexpected(tr("File size exceeds max limit %1").arg(Utils::Misc::friendlyUnit(MAX_TORRENT_SIZE)));
117 
118  QByteArray data;
119  try
120  {
121  data = file.readAll();
122  }
123  catch (const std::bad_alloc &e)
124  {
125  return nonstd::make_unexpected(tr("Torrent file read error: %1").arg(e.what()));
126  }
127 
128  if (data.size() != file.size())
129  return nonstd::make_unexpected(tr("Torrent file read error: size mismatch"));
130 
131  file.close();
132 
133  return load(data);
134 }
static nonstd::expected< TorrentInfo, QString > load(const QByteArray &data) noexcept
Definition: torrentinfo.cpp:89
const int MAX_TORRENT_SIZE
Definition: global.h:39
QString friendlyUnit(qint64 bytes, bool isSpeed=false)
Definition: misc.cpp:261

References nova3.nova2dl::e, file(), Utils::Misc::friendlyUnit(), and MAX_TORRENT_SIZE.

Referenced by BitTorrent::Session::addTorrent(), TorrentCreatorDialog::handleCreationSuccess(), BitTorrent::Session::handleTorrentFinished(), AddNewTorrentDialog::loadTorrentFile(), TorrentFilesWatcher::Worker::processFailedTorrents(), TorrentFilesWatcher::Worker::processFolder(), and BitTorrent::Session::recursiveTorrentDownload().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ metadata()

QByteArray TorrentInfo::metadata ( ) const

Definition at line 304 of file torrentinfo.cpp.

305 {
306  if (!isValid()) return {};
307 #ifdef QBT_USES_LIBTORRENT2
308  const lt::span<const char> infoSection {m_nativeInfo->info_section()};
309  return {infoSection.data(), static_cast<int>(infoSection.size())};
310 #else
311  return {m_nativeInfo->metadata().get(), m_nativeInfo->metadata_size()};
312 #endif
313 }

References isValid(), and m_nativeInfo.

Here is the call graph for this function:

◆ name()

QString TorrentInfo::name ( ) const

Definition at line 168 of file torrentinfo.cpp.

169 {
170  if (!isValid()) return {};
171 
172  return QString::fromStdString(m_nativeInfo->orig_files().name());
173 }

References isValid(), and m_nativeInfo.

Referenced by BitTorrent::Session::addTorrent_impl(), filePieces(), BitTorrent::TorrentImpl::name(), AddNewTorrentDialog::saveTorrentFile(), and AddNewTorrentDialog::setupTreeview().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nativeIndexes()

◆ nativeInfo()

std::shared_ptr< lt::torrent_info > TorrentInfo::nativeInfo ( ) const

Definition at line 433 of file torrentinfo.cpp.

434 {
435  if (!isValid())
436  return nullptr;
437 
438  return std::make_shared<lt::torrent_info>(*m_nativeInfo);
439 }

References isValid(), and m_nativeInfo.

Referenced by BitTorrent::Session::addTorrent_impl(), BitTorrent::TorrentImpl::prioritizeFiles(), and saveToFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

TorrentInfo & TorrentInfo::operator= ( const TorrentInfo other)

Definition at line 74 of file torrentinfo.cpp.

75 {
76  if (this != &other)
77  {
78  m_nativeInfo = other.m_nativeInfo;
80  }
81  return *this;
82 }

References m_nativeIndexes, and m_nativeInfo.

◆ pieceHashes()

QVector< QByteArray > TorrentInfo::pieceHashes ( ) const

Definition at line 347 of file torrentinfo.cpp.

348 {
349  if (!isValid())
350  return {};
351 
352  const int count = piecesCount();
353  QVector<QByteArray> hashes;
354  hashes.reserve(count);
355 
356  for (int i = 0; i < count; ++i)
357  hashes += {m_nativeInfo->hash_for_piece_ptr(lt::piece_index_t {i}), SHA1Hash::length()};
358 
359  return hashes;
360 }
static constexpr int length()
Definition: digest32.h:53

References isValid(), Digest32< 160 >::length(), m_nativeInfo, and piecesCount().

Referenced by TorrentsController::pieceHashesAction().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pieceLength() [1/2]

int TorrentInfo::pieceLength ( ) const

Definition at line 218 of file torrentinfo.cpp.

219 {
220  if (!isValid()) return -1;
221 
222  return m_nativeInfo->piece_length();
223 }

References isValid(), and m_nativeInfo.

Referenced by filePieces(), BitTorrent::TorrentImpl::pieceLength(), and PiecesBar::showToolTip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pieceLength() [2/2]

int TorrentInfo::pieceLength ( int  index) const

Definition at line 225 of file torrentinfo.cpp.

226 {
227  if (!isValid()) return -1;
228 
229  return m_nativeInfo->piece_size(lt::piece_index_t {index});
230 }

References isValid(), and m_nativeInfo.

Here is the call graph for this function:

◆ piecesCount()

int TorrentInfo::piecesCount ( ) const

Definition at line 232 of file torrentinfo.cpp.

233 {
234  if (!isValid()) return -1;
235 
236  return m_nativeInfo->num_pieces();
237 }

References isValid(), and m_nativeInfo.

Referenced by fileIndicesForPiece(), pieceHashes(), and BitTorrent::TorrentImpl::piecesCount().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rootFolder()

QString TorrentInfo::rootFolder ( ) const

Definition at line 412 of file torrentinfo.cpp.

413 {
414  if (!isValid())
415  return {};
416 
418 }
QString findRootFolder(const QStringList &filePaths)
Definition: fs.cpp:403

References filePaths(), Utils::Fs::findRootFolder(), and isValid().

Referenced by BitTorrent::Session::addTorrent_impl(), hasRootFolder(), and BitTorrent::TorrentImpl::rootPath().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveToFile()

nonstd::expected< void, QString > TorrentInfo::saveToFile ( const QString &  path) const

Definition at line 136 of file torrentinfo.cpp.

137 {
138  if (!isValid())
139  return nonstd::make_unexpected(tr("Invalid metadata"));
140 
141  try
142  {
143  const auto torrentCreator = lt::create_torrent(*nativeInfo());
144  const lt::entry torrentEntry = torrentCreator.generate();
145  const nonstd::expected<void, QString> result = Utils::IO::saveToFile(path, torrentEntry);
146  if (!result)
147  return result.get_unexpected();
148  }
149  catch (const lt::system_error &err)
150  {
151  return nonstd::make_unexpected(QString::fromLocal8Bit(err.what()));
152  }
153 
154  return {};
155 }
nonstd::expected< void, QString > saveToFile(const QString &path, const QByteArray &data)
Definition: io.cpp:69

References isValid(), nativeInfo(), and Utils::IO::saveToFile().

Referenced by BitTorrent::Session::exportTorrentFile(), and AddNewTorrentDialog::saveTorrentFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ totalSize()

qlonglong TorrentInfo::totalSize ( ) const

Definition at line 204 of file torrentinfo.cpp.

205 {
206  if (!isValid()) return -1;
207 
208  return m_nativeInfo->total_size();
209 }

References isValid(), and m_nativeInfo.

Referenced by anonymous_namespace{piecesbar.cpp}::PieceIndexToImagePos::PieceIndexToImagePos(), BitTorrent::TorrentImpl::totalSize(), and AddNewTorrentDialog::updateDiskSpaceLabel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ trackers()

QVector< TrackerEntry > TorrentInfo::trackers ( ) const

Definition at line 271 of file torrentinfo.cpp.

272 {
273  if (!isValid()) return {};
274 
275  const std::vector<lt::announce_entry> trackers = m_nativeInfo->trackers();
276 
277  QVector<TrackerEntry> ret;
278  ret.reserve(static_cast<decltype(ret)::size_type>(trackers.size()));
279 
280  for (const lt::announce_entry &tracker : trackers)
281  ret.append({QString::fromStdString(tracker.url)});
282 
283  return ret;
284 }
QVector< TrackerEntry > trackers() const

References isValid(), and m_nativeInfo.

Referenced by BitTorrent::Session::addTorrent_impl(), and AddNewTorrentDialog::loadTorrentImpl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ urlSeeds()

QVector< QUrl > TorrentInfo::urlSeeds ( ) const

Definition at line 286 of file torrentinfo.cpp.

287 {
288  if (!isValid()) return {};
289 
290  const std::vector<lt::web_seed_entry> &nativeWebSeeds = m_nativeInfo->web_seeds();
291 
292  QVector<QUrl> urlSeeds;
293  urlSeeds.reserve(static_cast<decltype(urlSeeds)::size_type>(nativeWebSeeds.size()));
294 
295  for (const lt::web_seed_entry &webSeed : nativeWebSeeds)
296  {
297  if (webSeed.type == lt::web_seed_entry::url_seed)
298  urlSeeds.append(QUrl(webSeed.url.c_str()));
299  }
300 
301  return urlSeeds;
302 }
QVector< QUrl > urlSeeds() const

References isValid(), and m_nativeInfo.

Referenced by BitTorrent::Session::addTorrent_impl(), and AddNewTorrentDialog::loadTorrentImpl().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_nativeIndexes

QVector<lt::file_index_t> BitTorrent::TorrentInfo::m_nativeIndexes
private

◆ m_nativeInfo

std::shared_ptr<const lt::torrent_info> BitTorrent::TorrentInfo::m_nativeInfo
private

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