diff --git a/src/app/application.cpp b/src/app/application.cpp index c89827a8a..eb7db1634 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -63,7 +63,7 @@ #include "base/bittorrent/infohash.h" #include "base/bittorrent/session.h" -#include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/torrent.h" #include "base/exceptions.h" #include "base/iconprovider.h" #include "base/logger.h" @@ -311,7 +311,7 @@ void Application::processMessage(const QString &message) m_paramsQueue.append(params); } -void Application::runExternalProgram(const BitTorrent::TorrentHandle *torrent) const +void Application::runExternalProgram(const BitTorrent::Torrent *torrent) const { QString program = Preferences::instance()->getAutoRunProgram().trimmed(); program.replace("%N", torrent->name()); @@ -405,7 +405,7 @@ void Application::runExternalProgram(const BitTorrent::TorrentHandle *torrent) c #endif } -void Application::sendNotificationEmail(const BitTorrent::TorrentHandle *torrent) +void Application::sendNotificationEmail(const BitTorrent::Torrent *torrent) { // Prepare mail content const QString content = tr("Torrent name: %1").arg(torrent->name()) + '\n' @@ -424,7 +424,7 @@ void Application::sendNotificationEmail(const BitTorrent::TorrentHandle *torrent content); } -void Application::torrentFinished(BitTorrent::TorrentHandle *const torrent) +void Application::torrentFinished(BitTorrent::Torrent *const torrent) { Preferences *const pref = Preferences::instance(); diff --git a/src/app/application.h b/src/app/application.h index afa66084d..c788d65c6 100644 --- a/src/app/application.h +++ b/src/app/application.h @@ -59,7 +59,7 @@ class FileLogger; namespace BitTorrent { - class TorrentHandle; + class Torrent; } namespace RSS @@ -112,7 +112,7 @@ protected: private slots: void processMessage(const QString &message); - void torrentFinished(BitTorrent::TorrentHandle *const torrent); + void torrentFinished(BitTorrent::Torrent *const torrent); void allTorrentsFinished(); void cleanup(); #if (!defined(DISABLE_GUI) && defined(Q_OS_WIN)) @@ -142,6 +142,6 @@ private: void initializeTranslation(); void processParams(const QStringList ¶ms); - void runExternalProgram(const BitTorrent::TorrentHandle *torrent) const; - void sendNotificationEmail(const BitTorrent::TorrentHandle *torrent); + void runExternalProgram(const BitTorrent::Torrent *torrent) const; + void sendNotificationEmail(const BitTorrent::Torrent *torrent); }; diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt index d2fe22b0e..b5c48acc9 100644 --- a/src/base/CMakeLists.txt +++ b/src/base/CMakeLists.txt @@ -25,10 +25,10 @@ add_library(qbt_base STATIC bittorrent/sessionstatus.h bittorrent/speedmonitor.h bittorrent/statistics.h + bittorrent/torrent.h bittorrent/torrentcontentlayout.h bittorrent/torrentcreatorthread.h - bittorrent/torrenthandle.h - bittorrent/torrenthandleimpl.h + bittorrent/torrentimpl.h bittorrent/torrentinfo.h bittorrent/tracker.h bittorrent/trackerentry.h @@ -107,9 +107,9 @@ add_library(qbt_base STATIC bittorrent/session.cpp bittorrent/speedmonitor.cpp bittorrent/statistics.cpp + bittorrent/torrent.cpp bittorrent/torrentcreatorthread.cpp - bittorrent/torrenthandle.cpp - bittorrent/torrenthandleimpl.cpp + bittorrent/torrentimpl.cpp bittorrent/torrentinfo.cpp bittorrent/tracker.cpp bittorrent/trackerentry.cpp diff --git a/src/base/base.pri b/src/base/base.pri index 3e86be00c..a9f6cbe65 100644 --- a/src/base/base.pri +++ b/src/base/base.pri @@ -24,10 +24,10 @@ HEADERS += \ $$PWD/bittorrent/sessionstatus.h \ $$PWD/bittorrent/speedmonitor.h \ $$PWD/bittorrent/statistics.h \ + $$PWD/bittorrent/torrent.h \ $$PWD/bittorrent/torrentcontentlayout.h \ $$PWD/bittorrent/torrentcreatorthread.h \ - $$PWD/bittorrent/torrenthandle.h \ - $$PWD/bittorrent/torrenthandleimpl.h \ + $$PWD/bittorrent/torrentimpl.h \ $$PWD/bittorrent/torrentinfo.h \ $$PWD/bittorrent/tracker.h \ $$PWD/bittorrent/trackerentry.h \ @@ -107,9 +107,9 @@ SOURCES += \ $$PWD/bittorrent/session.cpp \ $$PWD/bittorrent/speedmonitor.cpp \ $$PWD/bittorrent/statistics.cpp \ + $$PWD/bittorrent/torrent.cpp \ $$PWD/bittorrent/torrentcreatorthread.cpp \ - $$PWD/bittorrent/torrenthandle.cpp \ - $$PWD/bittorrent/torrenthandleimpl.cpp \ + $$PWD/bittorrent/torrentimpl.cpp \ $$PWD/bittorrent/torrentinfo.cpp \ $$PWD/bittorrent/tracker.cpp \ $$PWD/bittorrent/trackerentry.cpp \ diff --git a/src/base/bittorrent/addtorrentparams.h b/src/base/bittorrent/addtorrentparams.h index df1663260..04be354e3 100644 --- a/src/base/bittorrent/addtorrentparams.h +++ b/src/base/bittorrent/addtorrentparams.h @@ -34,7 +34,7 @@ #include #include -#include "torrenthandle.h" +#include "torrent.h" #include "torrentcontentlayout.h" namespace BitTorrent @@ -58,7 +58,7 @@ namespace BitTorrent std::optional useAutoTMM; int uploadLimit = -1; int downloadLimit = -1; - int seedingTimeLimit = TorrentHandle::USE_GLOBAL_SEEDING_TIME; - qreal ratioLimit = TorrentHandle::USE_GLOBAL_RATIO; + int seedingTimeLimit = Torrent::USE_GLOBAL_SEEDING_TIME; + qreal ratioLimit = Torrent::USE_GLOBAL_RATIO; }; } diff --git a/src/base/bittorrent/peerinfo.cpp b/src/base/bittorrent/peerinfo.cpp index 3c2bcbc14..ada9fc343 100644 --- a/src/base/bittorrent/peerinfo.cpp +++ b/src/base/bittorrent/peerinfo.cpp @@ -30,14 +30,14 @@ #include -#include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/torrent.h" #include "base/net/geoipmanager.h" #include "base/unicodestrings.h" #include "peeraddress.h" using namespace BitTorrent; -PeerInfo::PeerInfo(const TorrentHandle *torrent, const lt::peer_info &nativeInfo) +PeerInfo::PeerInfo(const Torrent *torrent, const lt::peer_info &nativeInfo) : m_nativeInfo(nativeInfo) { calcRelevance(torrent); @@ -226,7 +226,7 @@ QString PeerInfo::connectionType() const : QLatin1String {"Web"}; } -void PeerInfo::calcRelevance(const TorrentHandle *torrent) +void PeerInfo::calcRelevance(const Torrent *torrent) { const QBitArray allPieces = torrent->pieces(); const QBitArray peerPieces = pieces(); diff --git a/src/base/bittorrent/peerinfo.h b/src/base/bittorrent/peerinfo.h index 968abb21b..bfa5f9b2e 100644 --- a/src/base/bittorrent/peerinfo.h +++ b/src/base/bittorrent/peerinfo.h @@ -36,7 +36,7 @@ class QBitArray; namespace BitTorrent { - class TorrentHandle; + class Torrent; struct PeerAddress; class PeerInfo @@ -45,7 +45,7 @@ namespace BitTorrent public: PeerInfo() = default; - PeerInfo(const TorrentHandle *torrent, const lt::peer_info &nativeInfo); + PeerInfo(const Torrent *torrent, const lt::peer_info &nativeInfo); bool fromDHT() const; bool fromPeX() const; @@ -92,7 +92,7 @@ namespace BitTorrent int downloadingPieceIndex() const; private: - void calcRelevance(const TorrentHandle *torrent); + void calcRelevance(const Torrent *torrent); void determineFlags(); lt::peer_info m_nativeInfo = {}; diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 9fb331569..087c0d34c 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -96,7 +96,7 @@ #include "portforwarderimpl.h" #include "resumedatasavingmanager.h" #include "statistics.h" -#include "torrenthandleimpl.h" +#include "torrentimpl.h" #include "tracker.h" #include "trackerentry.h" @@ -578,7 +578,7 @@ void Session::setTempPathEnabled(const bool enabled) if (enabled != isTempPathEnabled()) { m_isTempPathEnabled = enabled; - for (TorrentHandleImpl *const torrent : asConst(m_torrents)) + for (TorrentImpl *const torrent : asConst(m_torrents)) torrent->handleTempPathChanged(); } } @@ -595,7 +595,7 @@ void Session::setAppendExtensionEnabled(const bool enabled) m_isAppendExtensionEnabled = enabled; // append or remove .!qB extension for incomplete files - for (TorrentHandleImpl *const torrent : asConst(m_torrents)) + for (TorrentImpl *const torrent : asConst(m_torrents)) torrent->handleAppendExtensionToggled(); } } @@ -748,13 +748,13 @@ bool Session::editCategory(const QString &name, const QString &savePath) m_storedCategories = map_cast(m_categories); if (isDisableAutoTMMWhenCategorySavePathChanged()) { - for (TorrentHandleImpl *const torrent : asConst(m_torrents)) + for (TorrentImpl *const torrent : asConst(m_torrents)) if (torrent->category() == name) torrent->setAutoTMMEnabled(false); } else { - for (TorrentHandleImpl *const torrent : asConst(m_torrents)) + for (TorrentImpl *const torrent : asConst(m_torrents)) if (torrent->category() == name) torrent->handleCategorySavePathChanged(); } @@ -764,7 +764,7 @@ bool Session::editCategory(const QString &name, const QString &savePath) bool Session::removeCategory(const QString &name) { - for (TorrentHandleImpl *const torrent : asConst(m_torrents)) + for (TorrentImpl *const torrent : asConst(m_torrents)) if (torrent->belongsToCategory(name)) torrent->setCategory(""); @@ -858,7 +858,7 @@ bool Session::removeTag(const QString &tag) { if (m_tags.remove(tag)) { - for (TorrentHandleImpl *const torrent : asConst(m_torrents)) + for (TorrentImpl *const torrent : asConst(m_torrents)) torrent->removeTag(tag); m_storedTags = m_tags.values(); emit tagRemoved(tag); @@ -1618,16 +1618,16 @@ void Session::processShareLimits() // We shouldn't iterate over `m_torrents` in the loop below // since `deleteTorrent()` modifies it indirectly - const QHash torrents {m_torrents}; - for (TorrentHandleImpl *const torrent : torrents) + const QHash torrents {m_torrents}; + for (TorrentImpl *const torrent : torrents) { if (torrent->isSeed() && !torrent->isForced()) { - if (torrent->ratioLimit() != TorrentHandle::NO_RATIO_LIMIT) + if (torrent->ratioLimit() != Torrent::NO_RATIO_LIMIT) { const qreal ratio = torrent->realRatio(); qreal ratioLimit = torrent->ratioLimit(); - if (ratioLimit == TorrentHandle::USE_GLOBAL_RATIO) + if (ratioLimit == Torrent::USE_GLOBAL_RATIO) // If Global Max Ratio is really set... ratioLimit = globalMaxRatio(); @@ -1635,7 +1635,7 @@ void Session::processShareLimits() { qDebug("Ratio: %f (limit: %f)", ratio, ratioLimit); - if ((ratio <= TorrentHandle::MAX_RATIO) && (ratio >= ratioLimit)) + if ((ratio <= Torrent::MAX_RATIO) && (ratio >= ratioLimit)) { if (m_maxRatioAction == Remove) { @@ -1645,7 +1645,7 @@ void Session::processShareLimits() else if (m_maxRatioAction == DeleteFiles) { LogMsg(tr("'%1' reached the maximum ratio you set. Removed torrent and its files.").arg(torrent->name())); - deleteTorrent(torrent->hash(), TorrentAndFiles); + deleteTorrent(torrent->hash(), DeleteTorrentAndFiles); } else if ((m_maxRatioAction == Pause) && !torrent->isPaused()) { @@ -1662,11 +1662,11 @@ void Session::processShareLimits() } } - if (torrent->seedingTimeLimit() != TorrentHandle::NO_SEEDING_TIME_LIMIT) + if (torrent->seedingTimeLimit() != Torrent::NO_SEEDING_TIME_LIMIT) { const qlonglong seedingTimeInMinutes = torrent->seedingTime() / 60; int seedingTimeLimit = torrent->seedingTimeLimit(); - if (seedingTimeLimit == TorrentHandle::USE_GLOBAL_SEEDING_TIME) + if (seedingTimeLimit == Torrent::USE_GLOBAL_SEEDING_TIME) { // If Global Seeding Time Limit is really set... seedingTimeLimit = globalMaxSeedingMinutes(); @@ -1674,7 +1674,7 @@ void Session::processShareLimits() if (seedingTimeLimit >= 0) { - if ((seedingTimeInMinutes <= TorrentHandle::MAX_SEEDING_TIME) && (seedingTimeInMinutes >= seedingTimeLimit)) + if ((seedingTimeInMinutes <= Torrent::MAX_SEEDING_TIME) && (seedingTimeInMinutes >= seedingTimeLimit)) { if (m_maxRatioAction == Remove) { @@ -1684,7 +1684,7 @@ void Session::processShareLimits() else if (m_maxRatioAction == DeleteFiles) { LogMsg(tr("'%1' reached the maximum seeding time you set. Removed torrent and its files.").arg(torrent->name())); - deleteTorrent(torrent->hash(), TorrentAndFiles); + deleteTorrent(torrent->hash(), DeleteTorrentAndFiles); } else if ((m_maxRatioAction == Pause) && !torrent->isPaused()) { @@ -1723,7 +1723,7 @@ void Session::handleDownloadFinished(const Net::DownloadResult &result) void Session::fileSearchFinished(const InfoHash &id, const QString &savePath, const QStringList &fileNames) { - TorrentHandleImpl *torrent = m_torrents.value(id); + TorrentImpl *torrent = m_torrents.value(id); if (torrent) { torrent->fileSearchFinished(savePath, fileNames); @@ -1747,14 +1747,14 @@ void Session::fileSearchFinished(const InfoHash &id, const QString &savePath, co } // Return the torrent handle, given its hash -TorrentHandle *Session::findTorrent(const InfoHash &hash) const +Torrent *Session::findTorrent(const InfoHash &hash) const { return m_torrents.value(hash); } bool Session::hasActiveTorrents() const { - return std::any_of(m_torrents.begin(), m_torrents.end(), [](TorrentHandleImpl *torrent) + return std::any_of(m_torrents.begin(), m_torrents.end(), [](TorrentImpl *torrent) { return TorrentFilter::ActiveTorrent.match(torrent); }); @@ -1762,7 +1762,7 @@ bool Session::hasActiveTorrents() const bool Session::hasUnfinishedTorrents() const { - return std::any_of(m_torrents.begin(), m_torrents.end(), [](const TorrentHandleImpl *torrent) + return std::any_of(m_torrents.begin(), m_torrents.end(), [](const TorrentImpl *torrent) { return (!torrent->isSeed() && !torrent->isPaused()); }); @@ -1770,7 +1770,7 @@ bool Session::hasUnfinishedTorrents() const bool Session::hasRunningSeed() const { - return std::any_of(m_torrents.begin(), m_torrents.end(), [](const TorrentHandleImpl *torrent) + return std::any_of(m_torrents.begin(), m_torrents.end(), [](const TorrentImpl *torrent) { return (torrent->isSeed() && !torrent->isPaused()); }); @@ -1799,14 +1799,14 @@ void Session::banIP(const QString &ip) // and from the disk, if the corresponding deleteOption is chosen bool Session::deleteTorrent(const InfoHash &hash, const DeleteOption deleteOption) { - TorrentHandleImpl *const torrent = m_torrents.take(hash); + TorrentImpl *const torrent = m_torrents.take(hash); if (!torrent) return false; qDebug("Deleting torrent with hash: %s", qUtf8Printable(torrent->hash())); emit torrentAboutToBeRemoved(torrent); // Remove it from session - if (deleteOption == Torrent) + if (deleteOption == DeleteTorrent) { m_removingTorrents[torrent->hash()] = {torrent->name(), "", deleteOption}; @@ -1887,7 +1887,7 @@ bool Session::cancelDownloadMetadata(const InfoHash &hash) void Session::increaseTorrentsQueuePos(const QVector &hashes) { - using ElementType = std::pair; + using ElementType = std::pair; std::priority_queue , std::greater> torrentQueue; @@ -1895,7 +1895,7 @@ void Session::increaseTorrentsQueuePos(const QVector &hashes) // Sort torrents by queue position for (const InfoHash &infoHash : hashes) { - TorrentHandleImpl *const torrent = m_torrents.value(infoHash); + TorrentImpl *const torrent = m_torrents.value(infoHash); if (torrent && !torrent->isSeed()) torrentQueue.emplace(torrent->queuePosition(), torrent); } @@ -1903,7 +1903,7 @@ void Session::increaseTorrentsQueuePos(const QVector &hashes) // Increase torrents queue position (starting with the one in the highest queue position) while (!torrentQueue.empty()) { - const TorrentHandleImpl *torrent = torrentQueue.top().second; + const TorrentImpl *torrent = torrentQueue.top().second; torrentQueuePositionUp(torrent->nativeHandle()); torrentQueue.pop(); } @@ -1913,13 +1913,13 @@ void Session::increaseTorrentsQueuePos(const QVector &hashes) void Session::decreaseTorrentsQueuePos(const QVector &hashes) { - using ElementType = std::pair; + using ElementType = std::pair; std::priority_queue torrentQueue; // Sort torrents by queue position for (const InfoHash &infoHash : hashes) { - TorrentHandleImpl *const torrent = m_torrents.value(infoHash); + TorrentImpl *const torrent = m_torrents.value(infoHash); if (torrent && !torrent->isSeed()) torrentQueue.emplace(torrent->queuePosition(), torrent); } @@ -1927,7 +1927,7 @@ void Session::decreaseTorrentsQueuePos(const QVector &hashes) // Decrease torrents queue position (starting with the one in the lowest queue position) while (!torrentQueue.empty()) { - const TorrentHandleImpl *torrent = torrentQueue.top().second; + const TorrentImpl *torrent = torrentQueue.top().second; torrentQueuePositionDown(torrent->nativeHandle()); torrentQueue.pop(); } @@ -1940,13 +1940,13 @@ void Session::decreaseTorrentsQueuePos(const QVector &hashes) void Session::topTorrentsQueuePos(const QVector &hashes) { - using ElementType = std::pair; + using ElementType = std::pair; std::priority_queue torrentQueue; // Sort torrents by queue position for (const InfoHash &infoHash : hashes) { - TorrentHandleImpl *const torrent = m_torrents.value(infoHash); + TorrentImpl *const torrent = m_torrents.value(infoHash); if (torrent && !torrent->isSeed()) torrentQueue.emplace(torrent->queuePosition(), torrent); } @@ -1954,7 +1954,7 @@ void Session::topTorrentsQueuePos(const QVector &hashes) // Top torrents queue position (starting with the one in the lowest queue position) while (!torrentQueue.empty()) { - const TorrentHandleImpl *torrent = torrentQueue.top().second; + const TorrentImpl *torrent = torrentQueue.top().second; torrentQueuePositionTop(torrent->nativeHandle()); torrentQueue.pop(); } @@ -1964,7 +1964,7 @@ void Session::topTorrentsQueuePos(const QVector &hashes) void Session::bottomTorrentsQueuePos(const QVector &hashes) { - using ElementType = std::pair; + using ElementType = std::pair; std::priority_queue , std::greater> torrentQueue; @@ -1972,7 +1972,7 @@ void Session::bottomTorrentsQueuePos(const QVector &hashes) // Sort torrents by queue position for (const InfoHash &infoHash : hashes) { - TorrentHandleImpl *const torrent = m_torrents.value(infoHash); + TorrentImpl *const torrent = m_torrents.value(infoHash); if (torrent && !torrent->isSeed()) torrentQueue.emplace(torrent->queuePosition(), torrent); } @@ -1980,7 +1980,7 @@ void Session::bottomTorrentsQueuePos(const QVector &hashes) // Bottom torrents queue position (starting with the one in the highest queue position) while (!torrentQueue.empty()) { - const TorrentHandleImpl *torrent = torrentQueue.top().second; + const TorrentImpl *torrent = torrentQueue.top().second; torrentQueuePositionBottom(torrent->nativeHandle()); torrentQueue.pop(); } @@ -1991,17 +1991,17 @@ void Session::bottomTorrentsQueuePos(const QVector &hashes) saveTorrentsQueue(); } -void Session::handleTorrentSaveResumeDataRequested(const TorrentHandleImpl *torrent) +void Session::handleTorrentSaveResumeDataRequested(const TorrentImpl *torrent) { qDebug("Saving resume data is requested for torrent '%s'...", qUtf8Printable(torrent->name())); ++m_numResumeData; } -QVector Session::torrents() const +QVector Session::torrents() const { - QVector result; + QVector result; result.reserve(m_torrents.size()); - for (TorrentHandleImpl *torrent : asConst(m_torrents)) + for (TorrentImpl *torrent : asConst(m_torrents)) result << torrent; return result; @@ -2099,7 +2099,7 @@ bool Session::addTorrent_impl(const std::variant &source if (m_loadingTorrents.contains(hash)) return false; - TorrentHandleImpl *const torrent = m_torrents.value(hash); + TorrentImpl *const torrent = m_torrents.value(hash); if (torrent) { // a duplicate torrent is added if (torrent->isPrivate() || (hasMetadata && metadata.isPrivate())) @@ -2293,7 +2293,7 @@ bool Session::downloadMetadata(const MagnetUri &magnetUri) return true; } -void Session::exportTorrentFile(const TorrentHandle *torrent, TorrentExportFolder folder) +void Session::exportTorrentFile(const Torrent *torrent, TorrentExportFolder folder) { Q_ASSERT(((folder == TorrentExportFolder::Regular) && !torrentExportDirectory().isEmpty()) || ((folder == TorrentExportFolder::Finished) && !finishedTorrentExportDirectory().isEmpty())); @@ -2321,7 +2321,7 @@ void Session::exportTorrentFile(const TorrentHandle *torrent, TorrentExportFolde void Session::generateResumeData() { - for (TorrentHandleImpl *const torrent : asConst(m_torrents)) + for (TorrentImpl *const torrent : asConst(m_torrents)) { if (!torrent->isValid()) continue; @@ -2367,7 +2367,7 @@ void Session::saveTorrentsQueue() { // store hash in textual representation QMap queue; // Use QMap since it should be ordered by key - for (const TorrentHandleImpl *torrent : asConst(m_torrents)) + for (const TorrentImpl *torrent : asConst(m_torrents)) { // We require actual (non-cached) queue position here! const int queuePos = static_cast>(torrent->nativeHandle().queue_position()); @@ -2409,10 +2409,10 @@ void Session::setDefaultSavePath(QString path) m_defaultSavePath = path; if (isDisableAutoTMMWhenDefaultSavePathChanged()) - for (TorrentHandleImpl *const torrent : asConst(m_torrents)) + for (TorrentImpl *const torrent : asConst(m_torrents)) torrent->setAutoTMMEnabled(false); else - for (TorrentHandleImpl *const torrent : asConst(m_torrents)) + for (TorrentImpl *const torrent : asConst(m_torrents)) torrent->handleCategorySavePathChanged(); } @@ -2423,7 +2423,7 @@ void Session::setTempPath(QString path) m_tempPath = path; - for (TorrentHandleImpl *const torrent : asConst(m_torrents)) + for (TorrentImpl *const torrent : asConst(m_torrents)) torrent->handleTempPathChanged(); } @@ -3751,8 +3751,8 @@ bool Session::isKnownTorrent(const InfoHash &hash) const void Session::updateSeedingLimitTimer() { - if ((globalMaxRatio() == TorrentHandle::NO_RATIO_LIMIT) && !hasPerTorrentRatioLimit() - && (globalMaxSeedingMinutes() == TorrentHandle::NO_SEEDING_TIME_LIMIT) && !hasPerTorrentSeedingTimeLimit()) + if ((globalMaxRatio() == Torrent::NO_RATIO_LIMIT) && !hasPerTorrentRatioLimit() + && (globalMaxSeedingMinutes() == Torrent::NO_SEEDING_TIME_LIMIT) && !hasPerTorrentSeedingTimeLimit()) { if (m_seedingLimitTimer->isActive()) m_seedingLimitTimer->stop(); @@ -3763,48 +3763,48 @@ void Session::updateSeedingLimitTimer() } } -void Session::handleTorrentShareLimitChanged(TorrentHandleImpl *const torrent) +void Session::handleTorrentShareLimitChanged(TorrentImpl *const torrent) { torrent->saveResumeData(); updateSeedingLimitTimer(); } -void Session::handleTorrentNameChanged(TorrentHandleImpl *const torrent) +void Session::handleTorrentNameChanged(TorrentImpl *const torrent) { torrent->saveResumeData(); } -void Session::handleTorrentSavePathChanged(TorrentHandleImpl *const torrent) +void Session::handleTorrentSavePathChanged(TorrentImpl *const torrent) { torrent->saveResumeData(); emit torrentSavePathChanged(torrent); } -void Session::handleTorrentCategoryChanged(TorrentHandleImpl *const torrent, const QString &oldCategory) +void Session::handleTorrentCategoryChanged(TorrentImpl *const torrent, const QString &oldCategory) { torrent->saveResumeData(); emit torrentCategoryChanged(torrent, oldCategory); } -void Session::handleTorrentTagAdded(TorrentHandleImpl *const torrent, const QString &tag) +void Session::handleTorrentTagAdded(TorrentImpl *const torrent, const QString &tag) { torrent->saveResumeData(); emit torrentTagAdded(torrent, tag); } -void Session::handleTorrentTagRemoved(TorrentHandleImpl *const torrent, const QString &tag) +void Session::handleTorrentTagRemoved(TorrentImpl *const torrent, const QString &tag) { torrent->saveResumeData(); emit torrentTagRemoved(torrent, tag); } -void Session::handleTorrentSavingModeChanged(TorrentHandleImpl *const torrent) +void Session::handleTorrentSavingModeChanged(TorrentImpl *const torrent) { torrent->saveResumeData(); emit torrentSavingModeChanged(torrent); } -void Session::handleTorrentTrackersAdded(TorrentHandleImpl *const torrent, const QVector &newTrackers) +void Session::handleTorrentTrackersAdded(TorrentImpl *const torrent, const QVector &newTrackers) { torrent->saveResumeData(); @@ -3816,7 +3816,7 @@ void Session::handleTorrentTrackersAdded(TorrentHandleImpl *const torrent, const emit trackersChanged(torrent); } -void Session::handleTorrentTrackersRemoved(TorrentHandleImpl *const torrent, const QVector &deletedTrackers) +void Session::handleTorrentTrackersRemoved(TorrentImpl *const torrent, const QVector &deletedTrackers) { torrent->saveResumeData(); @@ -3828,27 +3828,27 @@ void Session::handleTorrentTrackersRemoved(TorrentHandleImpl *const torrent, con emit trackersChanged(torrent); } -void Session::handleTorrentTrackersChanged(TorrentHandleImpl *const torrent) +void Session::handleTorrentTrackersChanged(TorrentImpl *const torrent) { torrent->saveResumeData(); emit trackersChanged(torrent); } -void Session::handleTorrentUrlSeedsAdded(TorrentHandleImpl *const torrent, const QVector &newUrlSeeds) +void Session::handleTorrentUrlSeedsAdded(TorrentImpl *const torrent, const QVector &newUrlSeeds) { torrent->saveResumeData(); for (const QUrl &newUrlSeed : newUrlSeeds) LogMsg(tr("URL seed '%1' was added to torrent '%2'").arg(newUrlSeed.toString(), torrent->name())); } -void Session::handleTorrentUrlSeedsRemoved(TorrentHandleImpl *const torrent, const QVector &urlSeeds) +void Session::handleTorrentUrlSeedsRemoved(TorrentImpl *const torrent, const QVector &urlSeeds) { torrent->saveResumeData(); for (const QUrl &urlSeed : urlSeeds) LogMsg(tr("URL seed '%1' was removed from torrent '%2'").arg(urlSeed.toString(), torrent->name())); } -void Session::handleTorrentMetadataReceived(TorrentHandleImpl *const torrent) +void Session::handleTorrentMetadataReceived(TorrentImpl *const torrent) { // Save metadata const QDir resumeDataDir {m_resumeFolderPath}; @@ -3869,24 +3869,24 @@ void Session::handleTorrentMetadataReceived(TorrentHandleImpl *const torrent) emit torrentMetadataReceived(torrent); } -void Session::handleTorrentPaused(TorrentHandleImpl *const torrent) +void Session::handleTorrentPaused(TorrentImpl *const torrent) { torrent->saveResumeData(); emit torrentPaused(torrent); } -void Session::handleTorrentResumed(TorrentHandleImpl *const torrent) +void Session::handleTorrentResumed(TorrentImpl *const torrent) { torrent->saveResumeData(); emit torrentResumed(torrent); } -void Session::handleTorrentChecked(TorrentHandleImpl *const torrent) +void Session::handleTorrentChecked(TorrentImpl *const torrent) { emit torrentFinishedChecking(torrent); } -void Session::handleTorrentFinished(TorrentHandleImpl *const torrent) +void Session::handleTorrentFinished(TorrentImpl *const torrent) { if (!torrent->hasError() && !torrent->hasMissingFiles()) torrent->saveResumeData(); @@ -3925,7 +3925,7 @@ void Session::handleTorrentFinished(TorrentHandleImpl *const torrent) emit allTorrentsFinished(); } -void Session::handleTorrentResumeDataReady(TorrentHandleImpl *const torrent, const std::shared_ptr &data) +void Session::handleTorrentResumeDataReady(TorrentImpl *const torrent, const std::shared_ptr &data) { --m_numResumeData; @@ -3942,17 +3942,17 @@ void Session::handleTorrentResumeDataReady(TorrentHandleImpl *const torrent, con #endif } -void Session::handleTorrentTrackerReply(TorrentHandleImpl *const torrent, const QString &trackerUrl) +void Session::handleTorrentTrackerReply(TorrentImpl *const torrent, const QString &trackerUrl) { emit trackerSuccess(torrent, trackerUrl); } -void Session::handleTorrentTrackerError(TorrentHandleImpl *const torrent, const QString &trackerUrl) +void Session::handleTorrentTrackerError(TorrentImpl *const torrent, const QString &trackerUrl) { emit trackerError(torrent, trackerUrl); } -bool Session::addMoveTorrentStorageJob(TorrentHandleImpl *torrent, const QString &newPath, const MoveStorageMode mode) +bool Session::addMoveTorrentStorageJob(TorrentImpl *torrent, const QString &newPath, const MoveStorageMode mode) { Q_ASSERT(torrent); @@ -4009,7 +4009,7 @@ bool Session::addMoveTorrentStorageJob(TorrentHandleImpl *torrent, const QString void Session::moveTorrentStorage(const MoveStorageJob &job) const { const InfoHash infoHash = job.torrentHandle.info_hash(); - const TorrentHandleImpl *torrent = m_torrents.value(infoHash); + const TorrentImpl *torrent = m_torrents.value(infoHash); const QString torrentName = (torrent ? torrent->name() : QString {infoHash}); LogMsg(tr("Moving \"%1\" to \"%2\"...").arg(torrentName, job.path)); @@ -4032,7 +4032,7 @@ void Session::handleMoveTorrentStorageJobFinished() const bool torrentHasOutstandingJob = (iter != m_moveStorageQueue.cend()); - TorrentHandleImpl *torrent = m_torrents.value(finishedJob.torrentHandle.info_hash()); + TorrentImpl *torrent = m_torrents.value(finishedJob.torrentHandle.info_hash()); if (torrent) { torrent->handleMoveStorageJobFinished(torrentHasOutstandingJob); @@ -4042,19 +4042,19 @@ void Session::handleMoveTorrentStorageJobFinished() // Last job is completed for torrent that being removing, so actually remove it const lt::torrent_handle nativeHandle {finishedJob.torrentHandle}; const RemovingTorrentData &removingTorrentData = m_removingTorrents[nativeHandle.info_hash()]; - if (removingTorrentData.deleteOption == Torrent) + if (removingTorrentData.deleteOption == DeleteTorrent) m_nativeSession->remove_torrent(nativeHandle, lt::session::delete_partfile); } } -void Session::handleTorrentTrackerWarning(TorrentHandleImpl *const torrent, const QString &trackerUrl) +void Session::handleTorrentTrackerWarning(TorrentImpl *const torrent, const QString &trackerUrl) { emit trackerWarning(torrent, trackerUrl); } bool Session::hasPerTorrentRatioLimit() const { - return std::any_of(m_torrents.cbegin(), m_torrents.cend(), [](const TorrentHandleImpl *torrent) + return std::any_of(m_torrents.cbegin(), m_torrents.cend(), [](const TorrentImpl *torrent) { return (torrent->ratioLimit() >= 0); }); @@ -4062,7 +4062,7 @@ bool Session::hasPerTorrentRatioLimit() const bool Session::hasPerTorrentSeedingTimeLimit() const { - return std::any_of(m_torrents.cbegin(), m_torrents.cend(), [](const TorrentHandleImpl *torrent) + return std::any_of(m_torrents.cbegin(), m_torrents.cend(), [](const TorrentImpl *torrent) { return (torrent->seedingTimeLimit() >= 0); }); @@ -4143,7 +4143,7 @@ void Session::disableIPFilter() void Session::recursiveTorrentDownload(const InfoHash &hash) { - TorrentHandleImpl *const torrent = m_torrents.value(hash); + TorrentImpl *const torrent = m_torrents.value(hash); if (!torrent) return; for (int i = 0; i < torrent->filesCount(); ++i) @@ -4189,7 +4189,7 @@ bool Session::loadTorrentResumeData(const QByteArray &data, const TorrentInfo &m Utils::Fs::toUniformPath(fromLTString(root.dict_find_string_value("qBt-savePath")))); torrentParams.hasSeedStatus = root.dict_find_int_value("qBt-seedStatus"); torrentParams.firstLastPiecePriority = root.dict_find_int_value("qBt-firstLastPiecePriority"); - torrentParams.seedingTimeLimit = root.dict_find_int_value("qBt-seedingTimeLimit", TorrentHandle::USE_GLOBAL_SEEDING_TIME); + torrentParams.seedingTimeLimit = root.dict_find_int_value("qBt-seedingTimeLimit", Torrent::USE_GLOBAL_SEEDING_TIME); // TODO: The following code is deprecated. Replace with the commented one after several releases in 4.4.x. // === BEGIN DEPRECATED CODE === // @@ -4212,7 +4212,7 @@ bool Session::loadTorrentResumeData(const QByteArray &data, const TorrentInfo &m const lt::string_view ratioLimitString = root.dict_find_string_value("qBt-ratioLimit"); if (ratioLimitString.empty()) - torrentParams.ratioLimit = root.dict_find_int_value("qBt-ratioLimit", TorrentHandle::USE_GLOBAL_RATIO * 1000) / 1000.0; + torrentParams.ratioLimit = root.dict_find_int_value("qBt-ratioLimit", Torrent::USE_GLOBAL_RATIO * 1000) / 1000.0; else torrentParams.ratioLimit = fromLTString(ratioLimitString).toDouble(); @@ -4546,7 +4546,7 @@ void Session::handleAlert(const lt::alert *a) void Session::dispatchTorrentAlert(const lt::alert *a) { - TorrentHandleImpl *const torrent = m_torrents.value(static_cast(a)->handle.info_hash()); + TorrentImpl *const torrent = m_torrents.value(static_cast(a)->handle.info_hash()); if (torrent) { torrent->handleAlert(a); @@ -4561,13 +4561,13 @@ void Session::dispatchTorrentAlert(const lt::alert *a) } } -void Session::createTorrentHandle(const lt::torrent_handle &nativeHandle) +void Session::createTorrent(const lt::torrent_handle &nativeHandle) { Q_ASSERT(m_loadingTorrents.contains(nativeHandle.info_hash())); const LoadTorrentParams params = m_loadingTorrents.take(nativeHandle.info_hash()); - auto *const torrent = new TorrentHandleImpl {this, m_nativeSession, nativeHandle, params}; + auto *const torrent = new TorrentImpl {this, m_nativeSession, nativeHandle, params}; m_torrents.insert(torrent->hash(), torrent); const bool hasMetadata = torrent->hasMetadata(); @@ -4635,7 +4635,7 @@ void Session::handleAddTorrentAlert(const lt::add_torrent_alert *p) } else if (m_loadingTorrents.contains(p->handle.info_hash())) { - createTorrentHandle(p->handle); + createTorrent(p->handle); } } @@ -4646,7 +4646,7 @@ void Session::handleTorrentRemovedAlert(const lt::torrent_removed_alert *p) const auto removingTorrentDataIter = m_removingTorrents.find(infoHash); if (removingTorrentDataIter != m_removingTorrents.end()) { - if (removingTorrentDataIter->deleteOption == Torrent) + if (removingTorrentDataIter->deleteOption == DeleteTorrent) { LogMsg(tr("'%1' was removed from the transfer list.", "'xxx.avi' was removed...").arg(removingTorrentDataIter->name)); m_removingTorrents.erase(removingTorrentDataIter); @@ -4712,7 +4712,7 @@ void Session::handleMetadataReceivedAlert(const lt::metadata_received_alert *p) void Session::handleFileErrorAlert(const lt::file_error_alert *p) { - TorrentHandleImpl *const torrent = m_torrents.value(p->handle.info_hash()); + TorrentImpl *const torrent = m_torrents.value(p->handle.info_hash()); if (!torrent) return; @@ -4782,7 +4782,7 @@ void Session::handlePeerBanAlert(const lt::peer_ban_alert *p) void Session::handleUrlSeedAlert(const lt::url_seed_alert *p) { - const TorrentHandleImpl *torrent = m_torrents.value(p->handle.info_hash()); + const TorrentImpl *torrent = m_torrents.value(p->handle.info_hash()); if (!torrent) return; @@ -4920,7 +4920,7 @@ void Session::handleStorageMovedAlert(const lt::storage_moved_alert *p) Q_ASSERT(newPath == currentJob.path); const InfoHash infoHash = currentJob.torrentHandle.info_hash(); - TorrentHandleImpl *torrent = m_torrents.value(infoHash); + TorrentImpl *torrent = m_torrents.value(infoHash); const QString torrentName = (torrent ? torrent->name() : QString {infoHash}); LogMsg(tr("\"%1\" is successfully moved to \"%2\".").arg(torrentName, newPath)); @@ -4935,7 +4935,7 @@ void Session::handleStorageMovedFailedAlert(const lt::storage_moved_failed_alert Q_ASSERT(currentJob.torrentHandle == p->handle); const InfoHash infoHash = currentJob.torrentHandle.info_hash(); - TorrentHandleImpl *torrent = m_torrents.value(infoHash); + TorrentImpl *torrent = m_torrents.value(infoHash); const QString torrentName = (torrent ? torrent->name() : QString {infoHash}); const QString currentLocation = QString::fromStdString(p->handle.status(lt::torrent_handle::query_save_path).save_path); const QString errorMessage = QString::fromStdString(p->message()); @@ -4947,12 +4947,12 @@ void Session::handleStorageMovedFailedAlert(const lt::storage_moved_failed_alert void Session::handleStateUpdateAlert(const lt::state_update_alert *p) { - QVector updatedTorrents; + QVector updatedTorrents; updatedTorrents.reserve(p->status.size()); for (const lt::torrent_status &status : p->status) { - TorrentHandleImpl *const torrent = m_torrents.value(status.info_hash); + TorrentImpl *const torrent = m_torrents.value(status.info_hash); if (!torrent) continue; diff --git a/src/base/bittorrent/session.h b/src/base/bittorrent/session.h index a5521dba3..9daced861 100644 --- a/src/base/bittorrent/session.h +++ b/src/base/bittorrent/session.h @@ -85,8 +85,8 @@ enum MaxRatioAction enum DeleteOption { - Torrent, - TorrentAndFiles + DeleteTorrent, + DeleteTorrentAndFiles }; enum TorrentExportFolder @@ -104,8 +104,8 @@ namespace BitTorrent { class InfoHash; class MagnetUri; - class TorrentHandle; - class TorrentHandleImpl; + class Torrent; + class TorrentImpl; class Tracker; class TrackerEntry; struct LoadTorrentParams; @@ -440,8 +440,8 @@ namespace BitTorrent #endif void startUpTorrents(); - TorrentHandle *findTorrent(const InfoHash &hash) const; - QVector torrents() const; + Torrent *findTorrent(const InfoHash &hash) const; + QVector torrents() const; bool hasActiveTorrents() const; bool hasUnfinishedTorrents() const; bool hasRunningSeed() const; @@ -460,7 +460,7 @@ namespace BitTorrent bool addTorrent(const QString &source, const AddTorrentParams ¶ms = AddTorrentParams()); bool addTorrent(const MagnetUri &magnetUri, const AddTorrentParams ¶ms = AddTorrentParams()); bool addTorrent(const TorrentInfo &torrentInfo, const AddTorrentParams ¶ms = AddTorrentParams()); - bool deleteTorrent(const InfoHash &hash, DeleteOption deleteOption = Torrent); + bool deleteTorrent(const InfoHash &hash, DeleteOption deleteOption = DeleteTorrent); bool downloadMetadata(const MagnetUri &magnetUri); bool cancelDownloadMetadata(const InfoHash &hash); @@ -470,31 +470,31 @@ namespace BitTorrent void topTorrentsQueuePos(const QVector &hashes); void bottomTorrentsQueuePos(const QVector &hashes); - // TorrentHandle interface - void handleTorrentSaveResumeDataRequested(const TorrentHandleImpl *torrent); - void handleTorrentShareLimitChanged(TorrentHandleImpl *const torrent); - void handleTorrentNameChanged(TorrentHandleImpl *const torrent); - void handleTorrentSavePathChanged(TorrentHandleImpl *const torrent); - void handleTorrentCategoryChanged(TorrentHandleImpl *const torrent, const QString &oldCategory); - void handleTorrentTagAdded(TorrentHandleImpl *const torrent, const QString &tag); - void handleTorrentTagRemoved(TorrentHandleImpl *const torrent, const QString &tag); - void handleTorrentSavingModeChanged(TorrentHandleImpl *const torrent); - void handleTorrentMetadataReceived(TorrentHandleImpl *const torrent); - void handleTorrentPaused(TorrentHandleImpl *const torrent); - void handleTorrentResumed(TorrentHandleImpl *const torrent); - void handleTorrentChecked(TorrentHandleImpl *const torrent); - void handleTorrentFinished(TorrentHandleImpl *const torrent); - void handleTorrentTrackersAdded(TorrentHandleImpl *const torrent, const QVector &newTrackers); - void handleTorrentTrackersRemoved(TorrentHandleImpl *const torrent, const QVector &deletedTrackers); - void handleTorrentTrackersChanged(TorrentHandleImpl *const torrent); - void handleTorrentUrlSeedsAdded(TorrentHandleImpl *const torrent, const QVector &newUrlSeeds); - void handleTorrentUrlSeedsRemoved(TorrentHandleImpl *const torrent, const QVector &urlSeeds); - void handleTorrentResumeDataReady(TorrentHandleImpl *const torrent, const std::shared_ptr &data); - void handleTorrentTrackerReply(TorrentHandleImpl *const torrent, const QString &trackerUrl); - void handleTorrentTrackerWarning(TorrentHandleImpl *const torrent, const QString &trackerUrl); - void handleTorrentTrackerError(TorrentHandleImpl *const torrent, const QString &trackerUrl); - - bool addMoveTorrentStorageJob(TorrentHandleImpl *torrent, const QString &newPath, MoveStorageMode mode); + // Torrent interface + void handleTorrentSaveResumeDataRequested(const TorrentImpl *torrent); + void handleTorrentShareLimitChanged(TorrentImpl *const torrent); + void handleTorrentNameChanged(TorrentImpl *const torrent); + void handleTorrentSavePathChanged(TorrentImpl *const torrent); + void handleTorrentCategoryChanged(TorrentImpl *const torrent, const QString &oldCategory); + void handleTorrentTagAdded(TorrentImpl *const torrent, const QString &tag); + void handleTorrentTagRemoved(TorrentImpl *const torrent, const QString &tag); + void handleTorrentSavingModeChanged(TorrentImpl *const torrent); + void handleTorrentMetadataReceived(TorrentImpl *const torrent); + void handleTorrentPaused(TorrentImpl *const torrent); + void handleTorrentResumed(TorrentImpl *const torrent); + void handleTorrentChecked(TorrentImpl *const torrent); + void handleTorrentFinished(TorrentImpl *const torrent); + void handleTorrentTrackersAdded(TorrentImpl *const torrent, const QVector &newTrackers); + void handleTorrentTrackersRemoved(TorrentImpl *const torrent, const QVector &deletedTrackers); + void handleTorrentTrackersChanged(TorrentImpl *const torrent); + void handleTorrentUrlSeedsAdded(TorrentImpl *const torrent, const QVector &newUrlSeeds); + void handleTorrentUrlSeedsRemoved(TorrentImpl *const torrent, const QVector &urlSeeds); + void handleTorrentResumeDataReady(TorrentImpl *const torrent, const std::shared_ptr &data); + void handleTorrentTrackerReply(TorrentImpl *const torrent, const QString &trackerUrl); + void handleTorrentTrackerWarning(TorrentImpl *const torrent, const QString &trackerUrl); + void handleTorrentTrackerError(TorrentImpl *const torrent, const QString &trackerUrl); + + bool addMoveTorrentStorageJob(TorrentImpl *torrent, const QString &newPath, MoveStorageMode mode); void findIncompleteFiles(const TorrentInfo &torrentInfo, const QString &savePath) const; @@ -504,37 +504,37 @@ namespace BitTorrent void categoryRemoved(const QString &categoryName); void downloadFromUrlFailed(const QString &url, const QString &reason); void downloadFromUrlFinished(const QString &url); - void fullDiskError(TorrentHandle *torrent, const QString &msg); + void fullDiskError(Torrent *torrent, const QString &msg); void IPFilterParsed(bool error, int ruleCount); void loadTorrentFailed(const QString &error); void metadataDownloaded(const TorrentInfo &info); - void recursiveTorrentDownloadPossible(TorrentHandle *torrent); + void recursiveTorrentDownloadPossible(Torrent *torrent); void speedLimitModeChanged(bool alternative); void statsUpdated(); void subcategoriesSupportChanged(); void tagAdded(const QString &tag); void tagRemoved(const QString &tag); - void torrentAboutToBeRemoved(TorrentHandle *torrent); - void torrentAdded(TorrentHandle *torrent); - void torrentCategoryChanged(TorrentHandle *torrent, const QString &oldCategory); - void torrentFinished(TorrentHandle *torrent); - void torrentFinishedChecking(TorrentHandle *torrent); - void torrentLoaded(TorrentHandle *torrent); - void torrentMetadataReceived(TorrentHandle *torrent); - void torrentPaused(TorrentHandle *torrent); - void torrentResumed(TorrentHandle *torrent); - void torrentSavePathChanged(TorrentHandle *torrent); - void torrentSavingModeChanged(TorrentHandle *torrent); - void torrentsUpdated(const QVector &torrents); - void torrentTagAdded(TorrentHandle *torrent, const QString &tag); - void torrentTagRemoved(TorrentHandle *torrent, const QString &tag); - void trackerError(TorrentHandle *torrent, const QString &tracker); - void trackerlessStateChanged(TorrentHandle *torrent, bool trackerless); - void trackersAdded(TorrentHandle *torrent, const QVector &trackers); - void trackersChanged(TorrentHandle *torrent); - void trackersRemoved(TorrentHandle *torrent, const QVector &trackers); - void trackerSuccess(TorrentHandle *torrent, const QString &tracker); - void trackerWarning(TorrentHandle *torrent, const QString &tracker); + void torrentAboutToBeRemoved(Torrent *torrent); + void torrentAdded(Torrent *torrent); + void torrentCategoryChanged(Torrent *torrent, const QString &oldCategory); + void torrentFinished(Torrent *torrent); + void torrentFinishedChecking(Torrent *torrent); + void torrentLoaded(Torrent *torrent); + void torrentMetadataReceived(Torrent *torrent); + void torrentPaused(Torrent *torrent); + void torrentResumed(Torrent *torrent); + void torrentSavePathChanged(Torrent *torrent); + void torrentSavingModeChanged(Torrent *torrent); + void torrentsUpdated(const QVector &torrents); + void torrentTagAdded(Torrent *torrent, const QString &tag); + void torrentTagRemoved(Torrent *torrent, const QString &tag); + void trackerError(Torrent *torrent, const QString &tracker); + void trackerlessStateChanged(Torrent *torrent, bool trackerless); + void trackersAdded(Torrent *torrent, const QVector &trackers); + void trackersChanged(Torrent *torrent); + void trackersRemoved(Torrent *torrent, const QVector &trackers); + void trackerSuccess(Torrent *torrent, const QString &tracker); + void trackerWarning(Torrent *torrent, const QString &tracker); private slots: void configureDeferred(); @@ -604,7 +604,7 @@ namespace BitTorrent bool addTorrent_impl(const std::variant &source, const AddTorrentParams &addTorrentParams); void updateSeedingLimitTimer(); - void exportTorrentFile(const TorrentHandle *torrent, TorrentExportFolder folder = TorrentExportFolder::Regular); + void exportTorrentFile(const Torrent *torrent, TorrentExportFolder folder = TorrentExportFolder::Regular); void handleAlert(const lt::alert *a); void dispatchTorrentAlert(const lt::alert *a); @@ -629,7 +629,7 @@ namespace BitTorrent void handleStorageMovedFailedAlert(const lt::storage_moved_failed_alert *p); void handleSocks5Alert(const lt::socks5_alert *p) const; - void createTorrentHandle(const lt::torrent_handle &nativeHandle); + void createTorrent(const lt::torrent_handle &nativeHandle); void saveResumeData(); void saveTorrentsQueue(); @@ -771,7 +771,7 @@ namespace BitTorrent QSet m_downloadedMetadata; - QHash m_torrents; + QHash m_torrents; QHash m_loadingTorrents; QHash m_downloadedTorrents; QHash m_removingTorrents; diff --git a/src/base/bittorrent/torrenthandle.cpp b/src/base/bittorrent/torrent.cpp similarity index 77% rename from src/base/bittorrent/torrenthandle.cpp rename to src/base/bittorrent/torrent.cpp index b66a15990..e0dcb9ca0 100644 --- a/src/base/bittorrent/torrenthandle.cpp +++ b/src/base/bittorrent/torrent.cpp @@ -27,7 +27,7 @@ * exception statement from your version. */ -#include "torrenthandle.h" +#include "torrent.h" #include @@ -40,33 +40,33 @@ namespace BitTorrent return ::qHash(static_cast>(key), seed); } - // TorrentHandle + // Torrent - const qreal TorrentHandle::USE_GLOBAL_RATIO = -2.; - const qreal TorrentHandle::NO_RATIO_LIMIT = -1.; + const qreal Torrent::USE_GLOBAL_RATIO = -2.; + const qreal Torrent::NO_RATIO_LIMIT = -1.; - const int TorrentHandle::USE_GLOBAL_SEEDING_TIME = -2; - const int TorrentHandle::NO_SEEDING_TIME_LIMIT = -1; + const int Torrent::USE_GLOBAL_SEEDING_TIME = -2; + const int Torrent::NO_SEEDING_TIME_LIMIT = -1; - const qreal TorrentHandle::MAX_RATIO = 9999.; - const int TorrentHandle::MAX_SEEDING_TIME = 525600; + const qreal Torrent::MAX_RATIO = 9999.; + const int Torrent::MAX_SEEDING_TIME = 525600; - bool TorrentHandle::isResumed() const + bool Torrent::isResumed() const { return !isPaused(); } - qlonglong TorrentHandle::remainingSize() const + qlonglong Torrent::remainingSize() const { return wantedSize() - completedSize(); } - void TorrentHandle::toggleSequentialDownload() + void Torrent::toggleSequentialDownload() { setSequentialDownload(!isSequentialDownload()); } - void TorrentHandle::toggleFirstLastPiecePriority() + void Torrent::toggleFirstLastPiecePriority() { setFirstLastPiecePriority(!hasFirstLastPiecePriority()); } diff --git a/src/base/bittorrent/torrenthandle.h b/src/base/bittorrent/torrent.h similarity index 99% rename from src/base/bittorrent/torrenthandle.h rename to src/base/bittorrent/torrent.h index 18e7ceac2..5d5f1ca07 100644 --- a/src/base/bittorrent/torrenthandle.h +++ b/src/base/bittorrent/torrent.h @@ -91,7 +91,7 @@ namespace BitTorrent uint qHash(TorrentState key, uint seed); - class TorrentHandle : public AbstractFileStorage + class Torrent : public AbstractFileStorage { public: static const qreal USE_GLOBAL_RATIO; @@ -103,7 +103,7 @@ namespace BitTorrent static const qreal MAX_RATIO; static const int MAX_SEEDING_TIME; - virtual ~TorrentHandle() = default; + virtual ~Torrent() = default; virtual InfoHash hash() const = 0; virtual QString name() const = 0; diff --git a/src/base/bittorrent/torrenthandleimpl.cpp b/src/base/bittorrent/torrentimpl.cpp similarity index 84% rename from src/base/bittorrent/torrenthandleimpl.cpp rename to src/base/bittorrent/torrentimpl.cpp index 447360ba8..f1f9aa2e3 100644 --- a/src/base/bittorrent/torrenthandleimpl.cpp +++ b/src/base/bittorrent/torrentimpl.cpp @@ -27,7 +27,7 @@ * exception statement from your version. */ -#include "torrenthandleimpl.h" +#include "torrentimpl.h" #include #include @@ -98,9 +98,9 @@ namespace } } -// TorrentHandleImpl +// TorrentImpl -TorrentHandleImpl::TorrentHandleImpl(Session *session, lt::session *nativeSession +TorrentImpl::TorrentImpl(Session *session, lt::session *nativeSession , const lt::torrent_handle &nativeHandle, const LoadTorrentParams ¶ms) : QObject(session) , m_session(session) @@ -161,19 +161,19 @@ TorrentHandleImpl::TorrentHandleImpl(Session *session, lt::session *nativeSessio // == END UPGRADE CODE == } -TorrentHandleImpl::~TorrentHandleImpl() {} +TorrentImpl::~TorrentImpl() {} -bool TorrentHandleImpl::isValid() const +bool TorrentImpl::isValid() const { return m_nativeHandle.is_valid(); } -InfoHash TorrentHandleImpl::hash() const +InfoHash TorrentImpl::hash() const { return m_hash; } -QString TorrentHandleImpl::name() const +QString TorrentImpl::name() const { if (!m_name.isEmpty()) return m_name; @@ -188,58 +188,58 @@ QString TorrentHandleImpl::name() const return m_hash; } -QDateTime TorrentHandleImpl::creationDate() const +QDateTime TorrentImpl::creationDate() const { return m_torrentInfo.creationDate(); } -QString TorrentHandleImpl::creator() const +QString TorrentImpl::creator() const { return m_torrentInfo.creator(); } -QString TorrentHandleImpl::comment() const +QString TorrentImpl::comment() const { return m_torrentInfo.comment(); } -bool TorrentHandleImpl::isPrivate() const +bool TorrentImpl::isPrivate() const { return m_torrentInfo.isPrivate(); } -qlonglong TorrentHandleImpl::totalSize() const +qlonglong TorrentImpl::totalSize() const { return m_torrentInfo.totalSize(); } // size without the "don't download" files -qlonglong TorrentHandleImpl::wantedSize() const +qlonglong TorrentImpl::wantedSize() const { return m_nativeStatus.total_wanted; } -qlonglong TorrentHandleImpl::completedSize() const +qlonglong TorrentImpl::completedSize() const { return m_nativeStatus.total_wanted_done; } -qlonglong TorrentHandleImpl::pieceLength() const +qlonglong TorrentImpl::pieceLength() const { return m_torrentInfo.pieceLength(); } -qlonglong TorrentHandleImpl::wastedSize() const +qlonglong TorrentImpl::wastedSize() const { return (m_nativeStatus.total_failed_bytes + m_nativeStatus.total_redundant_bytes); } -QString TorrentHandleImpl::currentTracker() const +QString TorrentImpl::currentTracker() const { return QString::fromStdString(m_nativeStatus.current_tracker); } -QString TorrentHandleImpl::savePath(bool actual) const +QString TorrentImpl::savePath(bool actual) const { if (actual) return Utils::Fs::toUniformPath(actualStorageLocation()); @@ -247,7 +247,7 @@ QString TorrentHandleImpl::savePath(bool actual) const return Utils::Fs::toUniformPath(m_savePath); } -QString TorrentHandleImpl::rootPath(bool actual) const +QString TorrentImpl::rootPath(bool actual) const { if (!hasMetadata()) return {}; @@ -260,7 +260,7 @@ QString TorrentHandleImpl::rootPath(bool actual) const return QDir(savePath(actual)).absoluteFilePath(firstFilePath); } -QString TorrentHandleImpl::contentPath(const bool actual) const +QString TorrentImpl::contentPath(const bool actual) const { if (!hasMetadata()) return {}; @@ -274,12 +274,12 @@ QString TorrentHandleImpl::contentPath(const bool actual) const return savePath(actual); } -bool TorrentHandleImpl::isAutoTMMEnabled() const +bool TorrentImpl::isAutoTMMEnabled() const { return m_useAutoTMM; } -void TorrentHandleImpl::setAutoTMMEnabled(bool enabled) +void TorrentImpl::setAutoTMMEnabled(bool enabled) { if (m_useAutoTMM == enabled) return; @@ -290,12 +290,12 @@ void TorrentHandleImpl::setAutoTMMEnabled(bool enabled) move_impl(m_session->categorySavePath(m_category), MoveStorageMode::Overwrite); } -QString TorrentHandleImpl::actualStorageLocation() const +QString TorrentImpl::actualStorageLocation() const { return QString::fromStdString(m_nativeStatus.save_path); } -void TorrentHandleImpl::setAutoManaged(const bool enable) +void TorrentImpl::setAutoManaged(const bool enable) { if (enable) m_nativeHandle.set_flags(lt::torrent_flags::auto_managed); @@ -303,7 +303,7 @@ void TorrentHandleImpl::setAutoManaged(const bool enable) m_nativeHandle.unset_flags(lt::torrent_flags::auto_managed); } -QVector TorrentHandleImpl::trackers() const +QVector TorrentImpl::trackers() const { const std::vector nativeTrackers = m_nativeHandle.trackers(); @@ -316,12 +316,12 @@ QVector TorrentHandleImpl::trackers() const return entries; } -QHash TorrentHandleImpl::trackerInfos() const +QHash TorrentImpl::trackerInfos() const { return m_trackerInfos; } -void TorrentHandleImpl::addTrackers(const QVector &trackers) +void TorrentImpl::addTrackers(const QVector &trackers) { QSet currentTrackers; for (const lt::announce_entry &entry : m_nativeHandle.trackers()) @@ -343,7 +343,7 @@ void TorrentHandleImpl::addTrackers(const QVector &trackers) m_session->handleTorrentTrackersAdded(this, newTrackers); } -void TorrentHandleImpl::replaceTrackers(const QVector &trackers) +void TorrentImpl::replaceTrackers(const QVector &trackers) { QVector currentTrackers = this->trackers(); @@ -383,7 +383,7 @@ void TorrentHandleImpl::replaceTrackers(const QVector &trackers) } } -QVector TorrentHandleImpl::urlSeeds() const +QVector TorrentImpl::urlSeeds() const { const std::set currentSeeds = m_nativeHandle.url_seeds(); @@ -396,7 +396,7 @@ QVector TorrentHandleImpl::urlSeeds() const return urlSeeds; } -void TorrentHandleImpl::addUrlSeeds(const QVector &urlSeeds) +void TorrentImpl::addUrlSeeds(const QVector &urlSeeds) { const std::set currentSeeds = m_nativeHandle.url_seeds(); @@ -417,7 +417,7 @@ void TorrentHandleImpl::addUrlSeeds(const QVector &urlSeeds) m_session->handleTorrentUrlSeedsAdded(this, addedUrlSeeds); } -void TorrentHandleImpl::removeUrlSeeds(const QVector &urlSeeds) +void TorrentImpl::removeUrlSeeds(const QVector &urlSeeds) { const std::set currentSeeds = m_nativeHandle.url_seeds(); @@ -438,12 +438,12 @@ void TorrentHandleImpl::removeUrlSeeds(const QVector &urlSeeds) m_session->handleTorrentUrlSeedsRemoved(this, removedUrlSeeds); } -void TorrentHandleImpl::clearPeers() +void TorrentImpl::clearPeers() { m_nativeHandle.clear_peers(); } -bool TorrentHandleImpl::connectPeer(const PeerAddress &peerAddress) +bool TorrentImpl::connectPeer(const PeerAddress &peerAddress) { lt::error_code ec; const lt::address addr = lt::make_address(peerAddress.ip.toString().toStdString(), ec); @@ -465,35 +465,35 @@ bool TorrentHandleImpl::connectPeer(const PeerAddress &peerAddress) return true; } -bool TorrentHandleImpl::needSaveResumeData() const +bool TorrentImpl::needSaveResumeData() const { if (m_isStopped && !(m_nativeStatus.flags & lt::torrent_flags::auto_managed)) return false; return m_nativeStatus.need_save_resume; } -void TorrentHandleImpl::saveResumeData() +void TorrentImpl::saveResumeData() { m_nativeHandle.save_resume_data(); m_session->handleTorrentSaveResumeDataRequested(this); } -int TorrentHandleImpl::filesCount() const +int TorrentImpl::filesCount() const { return m_torrentInfo.filesCount(); } -int TorrentHandleImpl::piecesCount() const +int TorrentImpl::piecesCount() const { return m_torrentInfo.piecesCount(); } -int TorrentHandleImpl::piecesHave() const +int TorrentImpl::piecesHave() const { return m_nativeStatus.num_pieces; } -qreal TorrentHandleImpl::progress() const +qreal TorrentImpl::progress() const { if (isChecking()) return m_nativeStatus.progress; @@ -509,12 +509,12 @@ qreal TorrentHandleImpl::progress() const return progress; } -QString TorrentHandleImpl::category() const +QString TorrentImpl::category() const { return m_category; } -bool TorrentHandleImpl::belongsToCategory(const QString &category) const +bool TorrentImpl::belongsToCategory(const QString &category) const { if (m_category.isEmpty()) return category.isEmpty(); if (!Session::isValidCategoryName(category)) return false; @@ -527,17 +527,17 @@ bool TorrentHandleImpl::belongsToCategory(const QString &category) const return false; } -QSet TorrentHandleImpl::tags() const +QSet TorrentImpl::tags() const { return m_tags; } -bool TorrentHandleImpl::hasTag(const QString &tag) const +bool TorrentImpl::hasTag(const QString &tag) const { return m_tags.contains(tag); } -bool TorrentHandleImpl::addTag(const QString &tag) +bool TorrentImpl::addTag(const QString &tag) { if (!Session::isValidTag(tag)) return false; @@ -554,7 +554,7 @@ bool TorrentHandleImpl::addTag(const QString &tag) return false; } -bool TorrentHandleImpl::removeTag(const QString &tag) +bool TorrentImpl::removeTag(const QString &tag) { if (m_tags.remove(tag)) { @@ -564,46 +564,46 @@ bool TorrentHandleImpl::removeTag(const QString &tag) return false; } -void TorrentHandleImpl::removeAllTags() +void TorrentImpl::removeAllTags() { for (const QString &tag : asConst(tags())) removeTag(tag); } -QDateTime TorrentHandleImpl::addedTime() const +QDateTime TorrentImpl::addedTime() const { return QDateTime::fromSecsSinceEpoch(m_nativeStatus.added_time); } -qreal TorrentHandleImpl::ratioLimit() const +qreal TorrentImpl::ratioLimit() const { return m_ratioLimit; } -int TorrentHandleImpl::seedingTimeLimit() const +int TorrentImpl::seedingTimeLimit() const { return m_seedingTimeLimit; } -QString TorrentHandleImpl::filePath(int index) const +QString TorrentImpl::filePath(int index) const { return m_torrentInfo.filePath(index); } -QString TorrentHandleImpl::fileName(int index) const +QString TorrentImpl::fileName(int index) const { if (!hasMetadata()) return {}; return Utils::Fs::fileName(filePath(index)); } -qlonglong TorrentHandleImpl::fileSize(int index) const +qlonglong TorrentImpl::fileSize(int index) const { return m_torrentInfo.fileSize(index); } // Return a list of absolute paths corresponding // to all files in a torrent -QStringList TorrentHandleImpl::absoluteFilePaths() const +QStringList TorrentImpl::absoluteFilePaths() const { if (!hasMetadata()) return {}; @@ -614,7 +614,7 @@ QStringList TorrentHandleImpl::absoluteFilePaths() const return res; } -QVector TorrentHandleImpl::filePriorities() const +QVector TorrentImpl::filePriorities() const { const std::vector fp = m_nativeHandle.get_file_priorities(); @@ -626,17 +626,17 @@ QVector TorrentHandleImpl::filePriorities() const return ret; } -TorrentInfo TorrentHandleImpl::info() const +TorrentInfo TorrentImpl::info() const { return m_torrentInfo; } -bool TorrentHandleImpl::isPaused() const +bool TorrentImpl::isPaused() const { return m_isStopped; } -bool TorrentHandleImpl::isQueued() const +bool TorrentImpl::isQueued() const { // Torrent is Queued if it isn't in Paused state but paused internally return (!isPaused() @@ -644,13 +644,13 @@ bool TorrentHandleImpl::isQueued() const && (m_nativeStatus.flags & lt::torrent_flags::paused)); } -bool TorrentHandleImpl::isChecking() const +bool TorrentImpl::isChecking() const { return ((m_nativeStatus.state == lt::torrent_status::checking_files) || (m_nativeStatus.state == lt::torrent_status::checking_resume_data)); } -bool TorrentHandleImpl::isDownloading() const +bool TorrentImpl::isDownloading() const { return m_state == TorrentState::Downloading || m_state == TorrentState::DownloadingMetadata @@ -661,7 +661,7 @@ bool TorrentHandleImpl::isDownloading() const || m_state == TorrentState::ForcedDownloading; } -bool TorrentHandleImpl::isUploading() const +bool TorrentImpl::isUploading() const { return m_state == TorrentState::Uploading || m_state == TorrentState::StalledUploading @@ -670,7 +670,7 @@ bool TorrentHandleImpl::isUploading() const || m_state == TorrentState::ForcedUploading; } -bool TorrentHandleImpl::isCompleted() const +bool TorrentImpl::isCompleted() const { return m_state == TorrentState::Uploading || m_state == TorrentState::StalledUploading @@ -680,7 +680,7 @@ bool TorrentHandleImpl::isCompleted() const || m_state == TorrentState::ForcedUploading; } -bool TorrentHandleImpl::isActive() const +bool TorrentImpl::isActive() const { if (m_state == TorrentState::StalledDownloading) return (uploadPayloadRate() > 0); @@ -693,44 +693,44 @@ bool TorrentHandleImpl::isActive() const || m_state == TorrentState::Moving; } -bool TorrentHandleImpl::isInactive() const +bool TorrentImpl::isInactive() const { return !isActive(); } -bool TorrentHandleImpl::isErrored() const +bool TorrentImpl::isErrored() const { return m_state == TorrentState::MissingFiles || m_state == TorrentState::Error; } -bool TorrentHandleImpl::isSeed() const +bool TorrentImpl::isSeed() const { return ((m_nativeStatus.state == lt::torrent_status::finished) || (m_nativeStatus.state == lt::torrent_status::seeding)); } -bool TorrentHandleImpl::isForced() const +bool TorrentImpl::isForced() const { return (!isPaused() && (m_operatingMode == TorrentOperatingMode::Forced)); } -bool TorrentHandleImpl::isSequentialDownload() const +bool TorrentImpl::isSequentialDownload() const { return static_cast(m_nativeStatus.flags & lt::torrent_flags::sequential_download); } -bool TorrentHandleImpl::hasFirstLastPiecePriority() const +bool TorrentImpl::hasFirstLastPiecePriority() const { return m_hasFirstLastPiecePriority; } -TorrentState TorrentHandleImpl::state() const +TorrentState TorrentImpl::state() const { return m_state; } -void TorrentHandleImpl::updateState() +void TorrentImpl::updateState() { if (m_nativeStatus.state == lt::torrent_status::checking_resume_data) { @@ -792,22 +792,22 @@ void TorrentHandleImpl::updateState() } } -bool TorrentHandleImpl::hasMetadata() const +bool TorrentImpl::hasMetadata() const { return m_torrentInfo.isValid(); } -bool TorrentHandleImpl::hasMissingFiles() const +bool TorrentImpl::hasMissingFiles() const { return m_hasMissingFiles; } -bool TorrentHandleImpl::hasError() const +bool TorrentImpl::hasError() const { return static_cast(m_nativeStatus.errc); } -bool TorrentHandleImpl::hasFilteredPieces() const +bool TorrentImpl::hasFilteredPieces() const { const std::vector pp = m_nativeHandle.get_piece_priorities(); return std::any_of(pp.cbegin(), pp.cend(), [](const lt::download_priority_t priority) @@ -816,44 +816,44 @@ bool TorrentHandleImpl::hasFilteredPieces() const }); } -int TorrentHandleImpl::queuePosition() const +int TorrentImpl::queuePosition() const { if (m_nativeStatus.queue_position < lt::queue_position_t {0}) return 0; return static_cast(m_nativeStatus.queue_position) + 1; } -QString TorrentHandleImpl::error() const +QString TorrentImpl::error() const { return QString::fromStdString(m_nativeStatus.errc.message()); } -qlonglong TorrentHandleImpl::totalDownload() const +qlonglong TorrentImpl::totalDownload() const { return m_nativeStatus.all_time_download; } -qlonglong TorrentHandleImpl::totalUpload() const +qlonglong TorrentImpl::totalUpload() const { return m_nativeStatus.all_time_upload; } -qlonglong TorrentHandleImpl::activeTime() const +qlonglong TorrentImpl::activeTime() const { return lt::total_seconds(m_nativeStatus.active_duration); } -qlonglong TorrentHandleImpl::finishedTime() const +qlonglong TorrentImpl::finishedTime() const { return lt::total_seconds(m_nativeStatus.finished_duration); } -qlonglong TorrentHandleImpl::seedingTime() const +qlonglong TorrentImpl::seedingTime() const { return lt::total_seconds(m_nativeStatus.seeding_duration); } -qlonglong TorrentHandleImpl::eta() const +qlonglong TorrentImpl::eta() const { if (isPaused()) return MAX_ETA; @@ -894,7 +894,7 @@ qlonglong TorrentHandleImpl::eta() const return (wantedSize() - completedSize()) / speedAverage.download; } -QVector TorrentHandleImpl::filesProgress() const +QVector TorrentImpl::filesProgress() const { if (!hasMetadata()) return {}; @@ -917,50 +917,50 @@ QVector TorrentHandleImpl::filesProgress() const return result; } -int TorrentHandleImpl::seedsCount() const +int TorrentImpl::seedsCount() const { return m_nativeStatus.num_seeds; } -int TorrentHandleImpl::peersCount() const +int TorrentImpl::peersCount() const { return m_nativeStatus.num_peers; } -int TorrentHandleImpl::leechsCount() const +int TorrentImpl::leechsCount() const { return (m_nativeStatus.num_peers - m_nativeStatus.num_seeds); } -int TorrentHandleImpl::totalSeedsCount() const +int TorrentImpl::totalSeedsCount() const { return (m_nativeStatus.num_complete > 0) ? m_nativeStatus.num_complete : m_nativeStatus.list_seeds; } -int TorrentHandleImpl::totalPeersCount() const +int TorrentImpl::totalPeersCount() const { const int peers = m_nativeStatus.num_complete + m_nativeStatus.num_incomplete; return (peers > 0) ? peers : m_nativeStatus.list_peers; } -int TorrentHandleImpl::totalLeechersCount() const +int TorrentImpl::totalLeechersCount() const { return (m_nativeStatus.num_incomplete > 0) ? m_nativeStatus.num_incomplete : (m_nativeStatus.list_peers - m_nativeStatus.list_seeds); } -int TorrentHandleImpl::completeCount() const +int TorrentImpl::completeCount() const { // additional info: https://github.com/qbittorrent/qBittorrent/pull/5300#issuecomment-267783646 return m_nativeStatus.num_complete; } -int TorrentHandleImpl::incompleteCount() const +int TorrentImpl::incompleteCount() const { // additional info: https://github.com/qbittorrent/qBittorrent/pull/5300#issuecomment-267783646 return m_nativeStatus.num_incomplete; } -QDateTime TorrentHandleImpl::lastSeenComplete() const +QDateTime TorrentImpl::lastSeenComplete() const { if (m_nativeStatus.last_seen_complete > 0) return QDateTime::fromSecsSinceEpoch(m_nativeStatus.last_seen_complete); @@ -968,7 +968,7 @@ QDateTime TorrentHandleImpl::lastSeenComplete() const return {}; } -QDateTime TorrentHandleImpl::completedTime() const +QDateTime TorrentImpl::completedTime() const { if (m_nativeStatus.completed_time > 0) return QDateTime::fromSecsSinceEpoch(m_nativeStatus.completed_time); @@ -976,21 +976,21 @@ QDateTime TorrentHandleImpl::completedTime() const return {}; } -qlonglong TorrentHandleImpl::timeSinceUpload() const +qlonglong TorrentImpl::timeSinceUpload() const { if (m_nativeStatus.last_upload.time_since_epoch().count() == 0) return -1; return lt::total_seconds(lt::clock_type::now() - m_nativeStatus.last_upload); } -qlonglong TorrentHandleImpl::timeSinceDownload() const +qlonglong TorrentImpl::timeSinceDownload() const { if (m_nativeStatus.last_download.time_since_epoch().count() == 0) return -1; return lt::total_seconds(lt::clock_type::now() - m_nativeStatus.last_download); } -qlonglong TorrentHandleImpl::timeSinceActivity() const +qlonglong TorrentImpl::timeSinceActivity() const { const qlonglong upTime = timeSinceUpload(); const qlonglong downTime = timeSinceDownload(); @@ -999,37 +999,37 @@ qlonglong TorrentHandleImpl::timeSinceActivity() const : std::min(upTime, downTime); } -int TorrentHandleImpl::downloadLimit() const +int TorrentImpl::downloadLimit() const { return m_nativeHandle.download_limit(); } -int TorrentHandleImpl::uploadLimit() const +int TorrentImpl::uploadLimit() const { return m_nativeHandle.upload_limit(); } -bool TorrentHandleImpl::superSeeding() const +bool TorrentImpl::superSeeding() const { return static_cast(m_nativeStatus.flags & lt::torrent_flags::super_seeding); } -bool TorrentHandleImpl::isDHTDisabled() const +bool TorrentImpl::isDHTDisabled() const { return static_cast(m_nativeStatus.flags & lt::torrent_flags::disable_dht); } -bool TorrentHandleImpl::isPEXDisabled() const +bool TorrentImpl::isPEXDisabled() const { return static_cast(m_nativeStatus.flags & lt::torrent_flags::disable_pex); } -bool TorrentHandleImpl::isLSDDisabled() const +bool TorrentImpl::isLSDDisabled() const { return static_cast(m_nativeStatus.flags & lt::torrent_flags::disable_lsd); } -QVector TorrentHandleImpl::peers() const +QVector TorrentImpl::peers() const { std::vector nativePeers; m_nativeHandle.get_peer_info(nativePeers); @@ -1041,7 +1041,7 @@ QVector TorrentHandleImpl::peers() const return peers; } -QBitArray TorrentHandleImpl::pieces() const +QBitArray TorrentImpl::pieces() const { QBitArray result(m_nativeStatus.pieces.size()); for (int i = 0; i < result.size(); ++i) @@ -1052,7 +1052,7 @@ QBitArray TorrentHandleImpl::pieces() const return result; } -QBitArray TorrentHandleImpl::downloadingPieces() const +QBitArray TorrentImpl::downloadingPieces() const { QBitArray result(piecesCount()); @@ -1065,7 +1065,7 @@ QBitArray TorrentHandleImpl::downloadingPieces() const return result; } -QVector TorrentHandleImpl::pieceAvailability() const +QVector TorrentImpl::pieceAvailability() const { std::vector avail; m_nativeHandle.piece_availability(avail); @@ -1073,12 +1073,12 @@ QVector TorrentHandleImpl::pieceAvailability() const return Vector::fromStdVector(avail); } -qreal TorrentHandleImpl::distributedCopies() const +qreal TorrentImpl::distributedCopies() const { return m_nativeStatus.distributed_copies; } -qreal TorrentHandleImpl::maxRatio() const +qreal TorrentImpl::maxRatio() const { if (m_ratioLimit == USE_GLOBAL_RATIO) return m_session->globalMaxRatio(); @@ -1086,7 +1086,7 @@ qreal TorrentHandleImpl::maxRatio() const return m_ratioLimit; } -int TorrentHandleImpl::maxSeedingTime() const +int TorrentImpl::maxSeedingTime() const { if (m_seedingTimeLimit == USE_GLOBAL_SEEDING_TIME) return m_session->globalMaxSeedingMinutes(); @@ -1094,7 +1094,7 @@ int TorrentHandleImpl::maxSeedingTime() const return m_seedingTimeLimit; } -qreal TorrentHandleImpl::realRatio() const +qreal TorrentImpl::realRatio() const { const int64_t upload = m_nativeStatus.all_time_upload; // special case for a seeder who lost its stats, also assume nobody will import a 99% done torrent @@ -1110,42 +1110,42 @@ qreal TorrentHandleImpl::realRatio() const return (ratio > MAX_RATIO) ? MAX_RATIO : ratio; } -int TorrentHandleImpl::uploadPayloadRate() const +int TorrentImpl::uploadPayloadRate() const { return m_nativeStatus.upload_payload_rate; } -int TorrentHandleImpl::downloadPayloadRate() const +int TorrentImpl::downloadPayloadRate() const { return m_nativeStatus.download_payload_rate; } -qlonglong TorrentHandleImpl::totalPayloadUpload() const +qlonglong TorrentImpl::totalPayloadUpload() const { return m_nativeStatus.total_payload_upload; } -qlonglong TorrentHandleImpl::totalPayloadDownload() const +qlonglong TorrentImpl::totalPayloadDownload() const { return m_nativeStatus.total_payload_download; } -int TorrentHandleImpl::connectionsCount() const +int TorrentImpl::connectionsCount() const { return m_nativeStatus.num_connections; } -int TorrentHandleImpl::connectionsLimit() const +int TorrentImpl::connectionsLimit() const { return m_nativeStatus.connections_limit; } -qlonglong TorrentHandleImpl::nextAnnounce() const +qlonglong TorrentImpl::nextAnnounce() const { return lt::total_seconds(m_nativeStatus.next_announce); } -void TorrentHandleImpl::setName(const QString &name) +void TorrentImpl::setName(const QString &name) { if (m_name != name) { @@ -1154,7 +1154,7 @@ void TorrentHandleImpl::setName(const QString &name) } } -bool TorrentHandleImpl::setCategory(const QString &category) +bool TorrentImpl::setCategory(const QString &category) { if (m_category != category) { @@ -1177,7 +1177,7 @@ bool TorrentHandleImpl::setCategory(const QString &category) return true; } -void TorrentHandleImpl::move(QString path) +void TorrentImpl::move(QString path) { if (m_useAutoTMM) { @@ -1194,7 +1194,7 @@ void TorrentHandleImpl::move(QString path) move_impl(path, MoveStorageMode::KeepExistingFiles); } -void TorrentHandleImpl::move_impl(QString path, const MoveStorageMode mode) +void TorrentImpl::move_impl(QString path, const MoveStorageMode mode) { if (path == savePath()) return; path = Utils::Fs::toNativePath(path); @@ -1210,17 +1210,17 @@ void TorrentHandleImpl::move_impl(QString path, const MoveStorageMode mode) } } -void TorrentHandleImpl::forceReannounce(int index) +void TorrentImpl::forceReannounce(int index) { m_nativeHandle.force_reannounce(0, index); } -void TorrentHandleImpl::forceDHTAnnounce() +void TorrentImpl::forceDHTAnnounce() { m_nativeHandle.force_dht_announce(); } -void TorrentHandleImpl::forceRecheck() +void TorrentImpl::forceRecheck() { if (!hasMetadata()) return; @@ -1236,7 +1236,7 @@ void TorrentHandleImpl::forceRecheck() } } -void TorrentHandleImpl::setSequentialDownload(const bool enable) +void TorrentImpl::setSequentialDownload(const bool enable) { if (enable) { @@ -1252,7 +1252,7 @@ void TorrentHandleImpl::setSequentialDownload(const bool enable) saveResumeData(); } -void TorrentHandleImpl::setFirstLastPiecePriority(const bool enabled) +void TorrentImpl::setFirstLastPiecePriority(const bool enabled) { if (m_hasFirstLastPiecePriority == enabled) return; @@ -1267,7 +1267,7 @@ void TorrentHandleImpl::setFirstLastPiecePriority(const bool enabled) saveResumeData(); } -void TorrentHandleImpl::applyFirstLastPiecePriority(const bool enabled, const QVector &updatedFilePrio) +void TorrentImpl::applyFirstLastPiecePriority(const bool enabled, const QVector &updatedFilePrio) { Q_ASSERT(hasMetadata()); @@ -1301,12 +1301,12 @@ void TorrentHandleImpl::applyFirstLastPiecePriority(const bool enabled, const QV m_nativeHandle.prioritize_pieces(piecePriorities); } -void TorrentHandleImpl::fileSearchFinished(const QString &savePath, const QStringList &fileNames) +void TorrentImpl::fileSearchFinished(const QString &savePath, const QStringList &fileNames) { endReceivedMetadataHandling(savePath, fileNames); } -void TorrentHandleImpl::endReceivedMetadataHandling(const QString &savePath, const QStringList &fileNames) +void TorrentImpl::endReceivedMetadataHandling(const QString &savePath, const QStringList &fileNames) { lt::add_torrent_params &p = m_ltAddTorrentParams; @@ -1328,7 +1328,7 @@ void TorrentHandleImpl::endReceivedMetadataHandling(const QString &savePath, con m_session->handleTorrentMetadataReceived(this); } -void TorrentHandleImpl::reload() +void TorrentImpl::reload() { const auto queuePos = m_nativeHandle.queue_position(); @@ -1359,7 +1359,7 @@ void TorrentHandleImpl::reload() m_torrentInfo = TorrentInfo {m_nativeHandle.torrent_file()}; } -void TorrentHandleImpl::pause() +void TorrentImpl::pause() { if (!m_isStopped) { @@ -1376,7 +1376,7 @@ void TorrentHandleImpl::pause() } } -void TorrentHandleImpl::resume(const TorrentOperatingMode mode) +void TorrentImpl::resume(const TorrentOperatingMode mode) { if (hasError()) m_nativeHandle.clear_error(); @@ -1410,7 +1410,7 @@ void TorrentHandleImpl::resume(const TorrentOperatingMode mode) } } -void TorrentHandleImpl::moveStorage(const QString &newPath, const MoveStorageMode mode) +void TorrentImpl::moveStorage(const QString &newPath, const MoveStorageMode mode) { if (m_session->addMoveTorrentStorageJob(this, newPath, mode)) { @@ -1419,7 +1419,7 @@ void TorrentHandleImpl::moveStorage(const QString &newPath, const MoveStorageMod } } -void TorrentHandleImpl::renameFile(const int index, const QString &path) +void TorrentImpl::renameFile(const int index, const QString &path) { const QString oldPath = filePath(index); m_oldPath[lt::file_index_t {index}].push_back(oldPath); @@ -1427,12 +1427,12 @@ void TorrentHandleImpl::renameFile(const int index, const QString &path) m_nativeHandle.rename_file(lt::file_index_t {index}, Utils::Fs::toNativePath(path).toStdString()); } -void TorrentHandleImpl::handleStateUpdate(const lt::torrent_status &nativeStatus) +void TorrentImpl::handleStateUpdate(const lt::torrent_status &nativeStatus) { updateStatus(nativeStatus); } -void TorrentHandleImpl::handleMoveStorageJobFinished(const bool hasOutstandingJob) +void TorrentImpl::handleMoveStorageJobFinished(const bool hasOutstandingJob) { m_storageIsMoving = hasOutstandingJob; @@ -1450,7 +1450,7 @@ void TorrentHandleImpl::handleMoveStorageJobFinished(const bool hasOutstandingJo m_moveFinishedTriggers.takeFirst()(); } -void TorrentHandleImpl::handleTrackerReplyAlert(const lt::tracker_reply_alert *p) +void TorrentImpl::handleTrackerReplyAlert(const lt::tracker_reply_alert *p) { const QString trackerUrl(p->tracker_url()); qDebug("Received a tracker reply from %s (Num_peers = %d)", qUtf8Printable(trackerUrl), p->num_peers); @@ -1460,7 +1460,7 @@ void TorrentHandleImpl::handleTrackerReplyAlert(const lt::tracker_reply_alert *p m_session->handleTorrentTrackerReply(this, trackerUrl); } -void TorrentHandleImpl::handleTrackerWarningAlert(const lt::tracker_warning_alert *p) +void TorrentImpl::handleTrackerWarningAlert(const lt::tracker_warning_alert *p) { const QString trackerUrl = p->tracker_url(); const QString message = p->warning_message(); @@ -1471,7 +1471,7 @@ void TorrentHandleImpl::handleTrackerWarningAlert(const lt::tracker_warning_aler m_session->handleTorrentTrackerWarning(this, trackerUrl); } -void TorrentHandleImpl::handleTrackerErrorAlert(const lt::tracker_error_alert *p) +void TorrentImpl::handleTrackerErrorAlert(const lt::tracker_error_alert *p) { const QString trackerUrl = p->tracker_url(); const QString message = p->error_message(); @@ -1490,7 +1490,7 @@ void TorrentHandleImpl::handleTrackerErrorAlert(const lt::tracker_error_alert *p m_session->handleTorrentTrackerError(this, trackerUrl); } -void TorrentHandleImpl::handleTorrentCheckedAlert(const lt::torrent_checked_alert *p) +void TorrentImpl::handleTorrentCheckedAlert(const lt::torrent_checked_alert *p) { Q_UNUSED(p); qDebug("\"%s\" have just finished checking.", qUtf8Printable(name())); @@ -1524,7 +1524,7 @@ void TorrentHandleImpl::handleTorrentCheckedAlert(const lt::torrent_checked_aler m_session->handleTorrentChecked(this); } -void TorrentHandleImpl::handleTorrentFinishedAlert(const lt::torrent_finished_alert *p) +void TorrentImpl::handleTorrentFinishedAlert(const lt::torrent_finished_alert *p) { Q_UNUSED(p); qDebug("Got a torrent finished alert for \"%s\"", qUtf8Printable(name())); @@ -1553,17 +1553,17 @@ void TorrentHandleImpl::handleTorrentFinishedAlert(const lt::torrent_finished_al } } -void TorrentHandleImpl::handleTorrentPausedAlert(const lt::torrent_paused_alert *p) +void TorrentImpl::handleTorrentPausedAlert(const lt::torrent_paused_alert *p) { Q_UNUSED(p); } -void TorrentHandleImpl::handleTorrentResumedAlert(const lt::torrent_resumed_alert *p) +void TorrentImpl::handleTorrentResumedAlert(const lt::torrent_resumed_alert *p) { Q_UNUSED(p); } -void TorrentHandleImpl::handleSaveResumeDataAlert(const lt::save_resume_data_alert *p) +void TorrentImpl::handleSaveResumeDataAlert(const lt::save_resume_data_alert *p) { if (!m_hasMissingFiles) { @@ -1639,13 +1639,13 @@ void TorrentHandleImpl::handleSaveResumeDataAlert(const lt::save_resume_data_ale m_session->handleTorrentResumeDataReady(this, resumeDataPtr); } -void TorrentHandleImpl::handleSaveResumeDataFailedAlert(const lt::save_resume_data_failed_alert *p) +void TorrentImpl::handleSaveResumeDataFailedAlert(const lt::save_resume_data_failed_alert *p) { Q_UNUSED(p); Q_ASSERT_X(false, Q_FUNC_INFO, "This point should be unreachable since libtorrent 1.2.11"); } -void TorrentHandleImpl::handleFastResumeRejectedAlert(const lt::fastresume_rejected_alert *p) +void TorrentImpl::handleFastResumeRejectedAlert(const lt::fastresume_rejected_alert *p) { m_fastresumeDataRejected = true; @@ -1662,7 +1662,7 @@ void TorrentHandleImpl::handleFastResumeRejectedAlert(const lt::fastresume_rejec } } -void TorrentHandleImpl::handleFileRenamedAlert(const lt::file_renamed_alert *p) +void TorrentImpl::handleFileRenamedAlert(const lt::file_renamed_alert *p) { // Remove empty leftover folders // For example renaming "a/b/c" to "d/b/c", then folders "a/b" and "a" will @@ -1706,7 +1706,7 @@ void TorrentHandleImpl::handleFileRenamedAlert(const lt::file_renamed_alert *p) saveResumeData(); // otherwise the new path will not be saved } -void TorrentHandleImpl::handleFileRenameFailedAlert(const lt::file_rename_failed_alert *p) +void TorrentImpl::handleFileRenameFailedAlert(const lt::file_rename_failed_alert *p) { LogMsg(tr("File rename failed. Torrent: \"%1\", file: \"%2\", reason: \"%3\"") .arg(name(), filePath(static_cast>(p->index)) @@ -1724,7 +1724,7 @@ void TorrentHandleImpl::handleFileRenameFailedAlert(const lt::file_rename_failed saveResumeData(); // otherwise the new path will not be saved } -void TorrentHandleImpl::handleFileCompletedAlert(const lt::file_completed_alert *p) +void TorrentImpl::handleFileCompletedAlert(const lt::file_completed_alert *p) { qDebug("A file completed download in torrent \"%s\"", qUtf8Printable(name())); if (m_session->isAppendExtensionEnabled()) @@ -1740,7 +1740,7 @@ void TorrentHandleImpl::handleFileCompletedAlert(const lt::file_completed_alert } } -void TorrentHandleImpl::handleMetadataReceivedAlert(const lt::metadata_received_alert *p) +void TorrentImpl::handleMetadataReceivedAlert(const lt::metadata_received_alert *p) { Q_UNUSED(p); @@ -1750,31 +1750,31 @@ void TorrentHandleImpl::handleMetadataReceivedAlert(const lt::metadata_received_ saveResumeData(); } -void TorrentHandleImpl::handlePerformanceAlert(const lt::performance_alert *p) const +void TorrentImpl::handlePerformanceAlert(const lt::performance_alert *p) const { LogMsg((tr("Performance alert: ") + QString::fromStdString(p->message())) , Log::INFO); } -void TorrentHandleImpl::handleTempPathChanged() +void TorrentImpl::handleTempPathChanged() { adjustActualSavePath(); } -void TorrentHandleImpl::handleCategorySavePathChanged() +void TorrentImpl::handleCategorySavePathChanged() { if (m_useAutoTMM) move_impl(m_session->categorySavePath(m_category), MoveStorageMode::Overwrite); } -void TorrentHandleImpl::handleAppendExtensionToggled() +void TorrentImpl::handleAppendExtensionToggled() { if (!hasMetadata()) return; manageIncompleteFiles(); } -void TorrentHandleImpl::handleAlert(const lt::alert *a) +void TorrentImpl::handleAlert(const lt::alert *a) { switch (a->type()) { @@ -1826,7 +1826,7 @@ void TorrentHandleImpl::handleAlert(const lt::alert *a) } } -void TorrentHandleImpl::manageIncompleteFiles() +void TorrentImpl::manageIncompleteFiles() { const bool isAppendExtensionEnabled = m_session->isAppendExtensionEnabled(); const QVector fp = filesProgress(); @@ -1861,7 +1861,7 @@ void TorrentHandleImpl::manageIncompleteFiles() } } -void TorrentHandleImpl::adjustActualSavePath() +void TorrentImpl::adjustActualSavePath() { if (!isMoveInProgress()) adjustActualSavePath_impl(); @@ -1869,7 +1869,7 @@ void TorrentHandleImpl::adjustActualSavePath() m_moveFinishedTriggers.append([this]() { adjustActualSavePath_impl(); }); } -void TorrentHandleImpl::adjustActualSavePath_impl() +void TorrentImpl::adjustActualSavePath_impl() { const bool needUseTempDir = useTempPath(); const QDir tempDir {m_session->torrentTempPath(info())}; @@ -1896,27 +1896,27 @@ void TorrentHandleImpl::adjustActualSavePath_impl() moveStorage(Utils::Fs::toNativePath(targetDir.absolutePath()), MoveStorageMode::Overwrite); } -lt::torrent_handle TorrentHandleImpl::nativeHandle() const +lt::torrent_handle TorrentImpl::nativeHandle() const { return m_nativeHandle; } -bool TorrentHandleImpl::isMoveInProgress() const +bool TorrentImpl::isMoveInProgress() const { return m_storageIsMoving; } -bool TorrentHandleImpl::useTempPath() const +bool TorrentImpl::useTempPath() const { return m_session->isTempPathEnabled() && !(isSeed() || m_hasSeedStatus); } -void TorrentHandleImpl::updateStatus() +void TorrentImpl::updateStatus() { updateStatus(m_nativeHandle.status()); } -void TorrentHandleImpl::updateStatus(const lt::torrent_status &nativeStatus) +void TorrentImpl::updateStatus(const lt::torrent_status &nativeStatus) { m_nativeStatus = nativeStatus; updateState(); @@ -1935,7 +1935,7 @@ void TorrentHandleImpl::updateStatus(const lt::torrent_status &nativeStatus) } } -void TorrentHandleImpl::setRatioLimit(qreal limit) +void TorrentImpl::setRatioLimit(qreal limit) { if (limit < USE_GLOBAL_RATIO) limit = NO_RATIO_LIMIT; @@ -1949,7 +1949,7 @@ void TorrentHandleImpl::setRatioLimit(qreal limit) } } -void TorrentHandleImpl::setSeedingTimeLimit(int limit) +void TorrentImpl::setSeedingTimeLimit(int limit) { if (limit < USE_GLOBAL_SEEDING_TIME) limit = NO_SEEDING_TIME_LIMIT; @@ -1963,7 +1963,7 @@ void TorrentHandleImpl::setSeedingTimeLimit(int limit) } } -void TorrentHandleImpl::setUploadLimit(const int limit) +void TorrentImpl::setUploadLimit(const int limit) { if (limit == uploadLimit()) return; @@ -1972,7 +1972,7 @@ void TorrentHandleImpl::setUploadLimit(const int limit) saveResumeData(); } -void TorrentHandleImpl::setDownloadLimit(const int limit) +void TorrentImpl::setDownloadLimit(const int limit) { if (limit == downloadLimit()) return; @@ -1981,7 +1981,7 @@ void TorrentHandleImpl::setDownloadLimit(const int limit) saveResumeData(); } -void TorrentHandleImpl::setSuperSeeding(const bool enable) +void TorrentImpl::setSuperSeeding(const bool enable) { if (enable == superSeeding()) return; @@ -1993,7 +1993,7 @@ void TorrentHandleImpl::setSuperSeeding(const bool enable) saveResumeData(); } -void TorrentHandleImpl::setDHTDisabled(const bool disable) +void TorrentImpl::setDHTDisabled(const bool disable) { if (disable == isDHTDisabled()) return; @@ -2005,7 +2005,7 @@ void TorrentHandleImpl::setDHTDisabled(const bool disable) saveResumeData(); } -void TorrentHandleImpl::setPEXDisabled(const bool disable) +void TorrentImpl::setPEXDisabled(const bool disable) { if (disable == isPEXDisabled()) return; @@ -2017,7 +2017,7 @@ void TorrentHandleImpl::setPEXDisabled(const bool disable) saveResumeData(); } -void TorrentHandleImpl::setLSDDisabled(const bool disable) +void TorrentImpl::setLSDDisabled(const bool disable) { if (disable == isLSDDisabled()) return; @@ -2029,17 +2029,17 @@ void TorrentHandleImpl::setLSDDisabled(const bool disable) saveResumeData(); } -void TorrentHandleImpl::flushCache() const +void TorrentImpl::flushCache() const { m_nativeHandle.flush_cache(); } -QString TorrentHandleImpl::createMagnetURI() const +QString TorrentImpl::createMagnetURI() const { return QString::fromStdString(lt::make_magnet_uri(m_nativeHandle)); } -void TorrentHandleImpl::prioritizeFiles(const QVector &priorities) +void TorrentImpl::prioritizeFiles(const QVector &priorities) { if (!hasMetadata()) return; if (priorities.size() != filesCount()) return; @@ -2067,7 +2067,7 @@ void TorrentHandleImpl::prioritizeFiles(const QVector &priorit applyFirstLastPiecePriority(true, priorities); } -QVector TorrentHandleImpl::availableFileFractions() const +QVector TorrentImpl::availableFileFractions() const { const int filesCount = this->filesCount(); if (filesCount <= 0) return {}; diff --git a/src/base/bittorrent/torrenthandleimpl.h b/src/base/bittorrent/torrentimpl.h similarity index 96% rename from src/base/bittorrent/torrenthandleimpl.h rename to src/base/bittorrent/torrentimpl.h index d959c0910..4ef9fa32b 100644 --- a/src/base/bittorrent/torrenthandleimpl.h +++ b/src/base/bittorrent/torrentimpl.h @@ -46,7 +46,7 @@ #include "infohash.h" #include "speedmonitor.h" -#include "torrenthandle.h" +#include "torrent.h" #include "torrentinfo.h" namespace BitTorrent @@ -69,8 +69,8 @@ namespace BitTorrent bool paused = false; - qreal ratioLimit = TorrentHandle::USE_GLOBAL_RATIO; - int seedingTimeLimit = TorrentHandle::USE_GLOBAL_SEEDING_TIME; + qreal ratioLimit = Torrent::USE_GLOBAL_RATIO; + int seedingTimeLimit = Torrent::USE_GLOBAL_SEEDING_TIME; bool restored = false; // is existing torrent job? }; @@ -87,15 +87,15 @@ namespace BitTorrent HandleMetadata }; - class TorrentHandleImpl final : public QObject, public TorrentHandle + class TorrentImpl final : public QObject, public Torrent { - Q_DISABLE_COPY(TorrentHandleImpl) - Q_DECLARE_TR_FUNCTIONS(BitTorrent::TorrentHandleImpl) + Q_DISABLE_COPY(TorrentImpl) + Q_DECLARE_TR_FUNCTIONS(BitTorrent::TorrentImpl) public: - TorrentHandleImpl(Session *session, lt::session *nativeSession + TorrentImpl(Session *session, lt::session *nativeSession , const lt::torrent_handle &nativeHandle, const LoadTorrentParams ¶ms); - ~TorrentHandleImpl() override; + ~TorrentImpl() override; bool isValid() const; diff --git a/src/base/torrentfilter.cpp b/src/base/torrentfilter.cpp index 1c4dcaa7d..c8c154d28 100644 --- a/src/base/torrentfilter.cpp +++ b/src/base/torrentfilter.cpp @@ -29,7 +29,7 @@ #include "torrentfilter.h" #include "bittorrent/infohash.h" -#include "bittorrent/torrenthandle.h" +#include "bittorrent/torrent.h" const QString TorrentFilter::AnyCategory; const InfoHashSet TorrentFilter::AnyHash {{}}; @@ -47,7 +47,7 @@ const TorrentFilter TorrentFilter::StalledUploadingTorrent(TorrentFilter::Stalle const TorrentFilter TorrentFilter::StalledDownloadingTorrent(TorrentFilter::StalledDownloading); const TorrentFilter TorrentFilter::ErroredTorrent(TorrentFilter::Errored); -using BitTorrent::TorrentHandle; +using BitTorrent::Torrent; TorrentFilter::TorrentFilter(const Type type, const InfoHashSet &hashSet, const QString &category, const QString &tag) : m_type(type) @@ -146,14 +146,14 @@ bool TorrentFilter::setTag(const QString &tag) return false; } -bool TorrentFilter::match(const TorrentHandle *const torrent) const +bool TorrentFilter::match(const Torrent *const torrent) const { if (!torrent) return false; return (matchState(torrent) && matchHash(torrent) && matchCategory(torrent) && matchTag(torrent)); } -bool TorrentFilter::matchState(const BitTorrent::TorrentHandle *const torrent) const +bool TorrentFilter::matchState(const BitTorrent::Torrent *const torrent) const { switch (m_type) { @@ -187,21 +187,21 @@ bool TorrentFilter::matchState(const BitTorrent::TorrentHandle *const torrent) c } } -bool TorrentFilter::matchHash(const BitTorrent::TorrentHandle *const torrent) const +bool TorrentFilter::matchHash(const BitTorrent::Torrent *const torrent) const { if (m_hashSet == AnyHash) return true; return m_hashSet.contains(torrent->hash()); } -bool TorrentFilter::matchCategory(const BitTorrent::TorrentHandle *const torrent) const +bool TorrentFilter::matchCategory(const BitTorrent::Torrent *const torrent) const { if (m_category.isNull()) return true; return (torrent->belongsToCategory(m_category)); } -bool TorrentFilter::matchTag(const BitTorrent::TorrentHandle *const torrent) const +bool TorrentFilter::matchTag(const BitTorrent::Torrent *const torrent) const { // Empty tag is a special value to indicate we're filtering for untagged torrents. if (m_tag.isNull()) return true; diff --git a/src/base/torrentfilter.h b/src/base/torrentfilter.h index 088037744..44f85699b 100644 --- a/src/base/torrentfilter.h +++ b/src/base/torrentfilter.h @@ -35,7 +35,7 @@ namespace BitTorrent { - class TorrentHandle; + class Torrent; } using InfoHashSet = QSet; @@ -88,13 +88,13 @@ public: bool setCategory(const QString &category); bool setTag(const QString &tag); - bool match(const BitTorrent::TorrentHandle *torrent) const; + bool match(const BitTorrent::Torrent *torrent) const; private: - bool matchState(const BitTorrent::TorrentHandle *torrent) const; - bool matchHash(const BitTorrent::TorrentHandle *torrent) const; - bool matchCategory(const BitTorrent::TorrentHandle *torrent) const; - bool matchTag(const BitTorrent::TorrentHandle *torrent) const; + bool matchState(const BitTorrent::Torrent *torrent) const; + bool matchHash(const BitTorrent::Torrent *torrent) const; + bool matchCategory(const BitTorrent::Torrent *torrent) const; + bool matchTag(const BitTorrent::Torrent *torrent) const; Type m_type {All}; QString m_category; diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index f05cd94c5..afbbc3587 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -42,7 +42,7 @@ #include "base/bittorrent/infohash.h" #include "base/bittorrent/magneturi.h" #include "base/bittorrent/session.h" -#include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/torrent.h" #include "base/exceptions.h" #include "base/global.h" #include "base/net/downloadmanager.h" @@ -275,7 +275,7 @@ bool AddNewTorrentDialog::loadTorrentImpl() // Prevent showing the dialog if download is already present if (BitTorrent::Session::instance()->isKnownTorrent(infoHash)) { - BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(infoHash); + BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(infoHash); if (torrent) { if (torrent->isPrivate() || m_torrentInfo.isPrivate()) @@ -316,7 +316,7 @@ bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri) // Prevent showing the dialog if download is already present if (BitTorrent::Session::instance()->isKnownTorrent(infoHash)) { - BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(infoHash); + BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(infoHash); if (torrent) { if (torrent->isPrivate()) diff --git a/src/gui/categoryfiltermodel.cpp b/src/gui/categoryfiltermodel.cpp index edbff6df5..7a910d463 100644 --- a/src/gui/categoryfiltermodel.cpp +++ b/src/gui/categoryfiltermodel.cpp @@ -32,7 +32,7 @@ #include #include "base/bittorrent/session.h" -#include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/torrent.h" #include "base/global.h" #include "uithememanager.h" @@ -336,7 +336,7 @@ void CategoryFilterModel::categoryRemoved(const QString &categoryName) } } -void CategoryFilterModel::torrentAdded(BitTorrent::TorrentHandle *const torrent) +void CategoryFilterModel::torrentAdded(BitTorrent::Torrent *const torrent) { CategoryModelItem *item = findItem(torrent->category()); Q_ASSERT(item); @@ -345,7 +345,7 @@ void CategoryFilterModel::torrentAdded(BitTorrent::TorrentHandle *const torrent) m_rootItem->childAt(0)->increaseTorrentsCount(); } -void CategoryFilterModel::torrentAboutToBeRemoved(BitTorrent::TorrentHandle *const torrent) +void CategoryFilterModel::torrentAboutToBeRemoved(BitTorrent::Torrent *const torrent) { CategoryModelItem *item = findItem(torrent->category()); Q_ASSERT(item); @@ -354,7 +354,7 @@ void CategoryFilterModel::torrentAboutToBeRemoved(BitTorrent::TorrentHandle *con m_rootItem->childAt(0)->decreaseTorrentsCount(); } -void CategoryFilterModel::torrentCategoryChanged(BitTorrent::TorrentHandle *const torrent, const QString &oldCategory) +void CategoryFilterModel::torrentCategoryChanged(BitTorrent::Torrent *const torrent, const QString &oldCategory) { QModelIndex i; @@ -403,7 +403,7 @@ void CategoryFilterModel::populate() m_rootItem->addChild(UID_ALL, new CategoryModelItem(nullptr, tr("All"), torrents.count())); // Uncategorized torrents - using Torrent = BitTorrent::TorrentHandle; + using Torrent = BitTorrent::Torrent; m_rootItem->addChild( UID_UNCATEGORIZED , new CategoryModelItem( @@ -411,7 +411,7 @@ void CategoryFilterModel::populate() , std::count_if(torrents.begin(), torrents.end() , [](Torrent *torrent) { return torrent->category().isEmpty(); }))); - using Torrent = BitTorrent::TorrentHandle; + using Torrent = BitTorrent::Torrent; for (auto i = session->categories().cbegin(); i != session->categories().cend(); ++i) { const QString &category = i.key(); diff --git a/src/gui/categoryfiltermodel.h b/src/gui/categoryfiltermodel.h index a11babf1d..63ec637c2 100644 --- a/src/gui/categoryfiltermodel.h +++ b/src/gui/categoryfiltermodel.h @@ -36,7 +36,7 @@ class CategoryModelItem; namespace BitTorrent { - class TorrentHandle; + class Torrent; } class CategoryFilterModel final : public QAbstractItemModel @@ -63,9 +63,9 @@ public: private slots: void categoryAdded(const QString &categoryName); void categoryRemoved(const QString &categoryName); - void torrentAdded(BitTorrent::TorrentHandle *const torrent); - void torrentAboutToBeRemoved(BitTorrent::TorrentHandle *const torrent); - void torrentCategoryChanged(BitTorrent::TorrentHandle *const torrent, const QString &oldCategory); + void torrentAdded(BitTorrent::Torrent *const torrent); + void torrentAboutToBeRemoved(BitTorrent::Torrent *const torrent); + void torrentCategoryChanged(BitTorrent::Torrent *const torrent, const QString &oldCategory); void subcategoriesSupportChanged(); private: diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index cbc938e83..bc865cfdc 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -58,7 +58,7 @@ #include "base/bittorrent/session.h" #include "base/bittorrent/sessionstatus.h" -#include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/torrent.h" #include "base/global.h" #include "base/logger.h" #include "base/net/downloadmanager.h" @@ -260,11 +260,11 @@ MainWindow::MainWindow(QWidget *parent) connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerlessStateChanged, m_transferListFiltersWidget, &TransferListFiltersWidget::changeTrackerless); connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerSuccess - , m_transferListFiltersWidget, qOverload(&TransferListFiltersWidget::trackerSuccess)); + , m_transferListFiltersWidget, qOverload(&TransferListFiltersWidget::trackerSuccess)); connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerError - , m_transferListFiltersWidget, qOverload(&TransferListFiltersWidget::trackerError)); + , m_transferListFiltersWidget, qOverload(&TransferListFiltersWidget::trackerError)); connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerWarning - , m_transferListFiltersWidget, qOverload(&TransferListFiltersWidget::trackerWarning)); + , m_transferListFiltersWidget, qOverload(&TransferListFiltersWidget::trackerWarning)); #ifdef Q_OS_MACOS // Increase top spacing to avoid tab overlapping @@ -858,20 +858,20 @@ void MainWindow::addTorrentFailed(const QString &error) const } // called when a torrent was added -void MainWindow::torrentNew(BitTorrent::TorrentHandle *const torrent) const +void MainWindow::torrentNew(BitTorrent::Torrent *const torrent) const { if (isTorrentAddedNotificationsEnabled()) showNotificationBaloon(tr("Torrent added"), tr("'%1' was added.", "e.g: xxx.avi was added.").arg(torrent->name())); } // called when a torrent has finished -void MainWindow::finishedTorrent(BitTorrent::TorrentHandle *const torrent) const +void MainWindow::finishedTorrent(BitTorrent::Torrent *const torrent) const { showNotificationBaloon(tr("Download completion"), tr("'%1' has finished downloading.", "e.g: xxx.avi has finished downloading.").arg(torrent->name())); } // Notification when disk is full -void MainWindow::fullDiskError(BitTorrent::TorrentHandle *const torrent, const QString &msg) const +void MainWindow::fullDiskError(BitTorrent::Torrent *const torrent, const QString &msg) const { showNotificationBaloon(tr("I/O Error", "i.e: Input/Output Error") , tr("An I/O error occurred for torrent '%1'.\n Reason: %2" @@ -961,7 +961,7 @@ void MainWindow::displayExecutionLogTab() // End of keyboard shortcuts slots -void MainWindow::askRecursiveTorrentDownloadConfirmation(BitTorrent::TorrentHandle *const torrent) +void MainWindow::askRecursiveTorrentDownloadConfirmation(BitTorrent::Torrent *const torrent) { Preferences *const pref = Preferences::instance(); if (pref->recursiveDownloadDisabled()) return; @@ -1639,7 +1639,7 @@ void MainWindow::reloadSessionStats() } } -void MainWindow::reloadTorrentStats(const QVector &torrents) +void MainWindow::reloadTorrentStats(const QVector &torrents) { if (currentTabWidget() == m_transferListWidget) { diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index db0dd15ab..cea1140fb 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -58,7 +58,7 @@ class TransferListWidget; namespace BitTorrent { - class TorrentHandle; + class Torrent; } namespace Net @@ -110,7 +110,7 @@ private slots: void balloonClicked(); void writeSettings(); void readSettings(); - void fullDiskError(BitTorrent::TorrentHandle *const torrent, const QString &msg) const; + void fullDiskError(BitTorrent::Torrent *const torrent, const QString &msg) const; void handleDownloadFromUrlFailure(const QString &, const QString &) const; void tabChanged(int newTab); bool defineUILockPassword(); @@ -127,12 +127,12 @@ private slots: void displayExecutionLogTab(); void focusSearchFilter(); void reloadSessionStats(); - void reloadTorrentStats(const QVector &torrents); + void reloadTorrentStats(const QVector &torrents); void loadPreferences(bool configureSession = true); void addTorrentFailed(const QString &error) const; - void torrentNew(BitTorrent::TorrentHandle *const torrent) const; - void finishedTorrent(BitTorrent::TorrentHandle *const torrent) const; - void askRecursiveTorrentDownloadConfirmation(BitTorrent::TorrentHandle *const torrent); + void torrentNew(BitTorrent::Torrent *const torrent) const; + void finishedTorrent(BitTorrent::Torrent *const torrent) const; + void askRecursiveTorrentDownloadConfirmation(BitTorrent::Torrent *const torrent); void optionsSaved(); #if defined(Q_OS_WIN) || defined(Q_OS_MACOS) void handleUpdateCheckFinished(bool updateAvailable, QString newVersion, bool invokedByUser); diff --git a/src/gui/previewselectdialog.cpp b/src/gui/previewselectdialog.cpp index cdbb72d86..cb7d9a611 100644 --- a/src/gui/previewselectdialog.cpp +++ b/src/gui/previewselectdialog.cpp @@ -37,7 +37,7 @@ #include #include "base/bittorrent/common.h" -#include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/torrent.h" #include "base/preferences.h" #include "base/utils/fs.h" #include "base/utils/misc.h" @@ -47,7 +47,7 @@ #define SETTINGS_KEY(name) "PreviewSelectDialog/" name -PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, const BitTorrent::TorrentHandle *torrent) +PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, const BitTorrent::Torrent *torrent) : QDialog(parent) , m_ui(new Ui::PreviewSelectDialog) , m_torrent(torrent) diff --git a/src/gui/previewselectdialog.h b/src/gui/previewselectdialog.h index 34376fc69..842573202 100644 --- a/src/gui/previewselectdialog.h +++ b/src/gui/previewselectdialog.h @@ -36,7 +36,7 @@ class QStandardItemModel; namespace BitTorrent { - class TorrentHandle; + class Torrent; } namespace Ui { @@ -60,7 +60,7 @@ public: NB_COLUMNS }; - PreviewSelectDialog(QWidget *parent, const BitTorrent::TorrentHandle *torrent); + PreviewSelectDialog(QWidget *parent, const BitTorrent::Torrent *torrent); ~PreviewSelectDialog(); signals: @@ -78,7 +78,7 @@ private: Ui::PreviewSelectDialog *m_ui; QStandardItemModel *m_previewListModel; PreviewListDelegate *m_listDelegate; - const BitTorrent::TorrentHandle *m_torrent; + const BitTorrent::Torrent *m_torrent; bool m_headerStateInitialized = false; // Settings diff --git a/src/gui/properties/peerlistwidget.cpp b/src/gui/properties/peerlistwidget.cpp index 96729a780..ecef330e6 100644 --- a/src/gui/properties/peerlistwidget.cpp +++ b/src/gui/properties/peerlistwidget.cpp @@ -47,7 +47,7 @@ #include "base/bittorrent/peeraddress.h" #include "base/bittorrent/peerinfo.h" #include "base/bittorrent/session.h" -#include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/torrent.h" #include "base/global.h" #include "base/logger.h" #include "base/net/geoipmanager.h" @@ -260,7 +260,7 @@ void PeerListWidget::updatePeerCountryResolutionState() void PeerListWidget::showPeerListMenu(const QPoint &) { - BitTorrent::TorrentHandle *const torrent = m_properties->getCurrentTorrent(); + BitTorrent::Torrent *const torrent = m_properties->getCurrentTorrent(); if (!torrent) return; QMenu *menu = new QMenu(this); @@ -370,7 +370,7 @@ void PeerListWidget::saveSettings() const Preferences::instance()->setPeerListState(header()->saveState()); } -void PeerListWidget::loadPeers(const BitTorrent::TorrentHandle *torrent) +void PeerListWidget::loadPeers(const BitTorrent::Torrent *torrent) { if (!torrent) return; @@ -406,7 +406,7 @@ void PeerListWidget::loadPeers(const BitTorrent::TorrentHandle *torrent) } } -void PeerListWidget::updatePeer(const BitTorrent::TorrentHandle *torrent, const BitTorrent::PeerInfo &peer, bool &isNewPeer) +void PeerListWidget::updatePeer(const BitTorrent::Torrent *torrent, const BitTorrent::PeerInfo &peer, bool &isNewPeer) { const PeerEndpoint peerEndpoint {peer.address(), peer.connectionType()}; const QString peerIp = peerEndpoint.address.ip.toString(); diff --git a/src/gui/properties/peerlistwidget.h b/src/gui/properties/peerlistwidget.h index e3c0c9f5f..28ae98b51 100644 --- a/src/gui/properties/peerlistwidget.h +++ b/src/gui/properties/peerlistwidget.h @@ -43,7 +43,7 @@ struct PeerEndpoint; namespace BitTorrent { - class TorrentHandle; + class Torrent; class PeerInfo; } @@ -80,7 +80,7 @@ public: explicit PeerListWidget(PropertiesWidget *parent); ~PeerListWidget() override; - void loadPeers(const BitTorrent::TorrentHandle *torrent); + void loadPeers(const BitTorrent::Torrent *torrent); void updatePeerHostNameResolutionState(); void updatePeerCountryResolutionState(); void clear(); @@ -96,7 +96,7 @@ private slots: void handleResolved(const QHostAddress &ip, const QString &hostname) const; private: - void updatePeer(const BitTorrent::TorrentHandle *torrent, const BitTorrent::PeerInfo &peer, bool &isNewPeer); + void updatePeer(const BitTorrent::Torrent *torrent, const BitTorrent::PeerInfo &peer, bool &isNewPeer); void wheelEvent(QWheelEvent *event) override; diff --git a/src/gui/properties/piecesbar.cpp b/src/gui/properties/piecesbar.cpp index 9acaa572b..d9da364cb 100644 --- a/src/gui/properties/piecesbar.cpp +++ b/src/gui/properties/piecesbar.cpp @@ -38,7 +38,7 @@ #include #include "base/indexrange.h" -#include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/torrent.h" #include "base/bittorrent/torrentinfo.h" #include "base/utils/misc.h" @@ -119,7 +119,7 @@ PiecesBar::PiecesBar(QWidget *parent) setMouseTracking(true); } -void PiecesBar::setTorrent(const BitTorrent::TorrentHandle *torrent) +void PiecesBar::setTorrent(const BitTorrent::Torrent *torrent) { m_torrent = torrent; if (!m_torrent) diff --git a/src/gui/properties/piecesbar.h b/src/gui/properties/piecesbar.h index fabcf7b36..66f2f3074 100644 --- a/src/gui/properties/piecesbar.h +++ b/src/gui/properties/piecesbar.h @@ -37,7 +37,7 @@ class QHelpEvent; namespace BitTorrent { - class TorrentHandle; + class Torrent; } class PiecesBar : public QWidget @@ -49,7 +49,7 @@ class PiecesBar : public QWidget public: explicit PiecesBar(QWidget *parent = nullptr); - void setTorrent(const BitTorrent::TorrentHandle *torrent); + void setTorrent(const BitTorrent::Torrent *torrent); virtual void clear(); @@ -87,7 +87,7 @@ private: virtual bool updateImage(QImage &image) = 0; void updatePieceColors(); - const BitTorrent::TorrentHandle *m_torrent; + const BitTorrent::Torrent *m_torrent; QImage m_image; // buffered 256 levels gradient from bg_color to piece_color QVector m_pieceColors; diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index ea050b175..a7b84b5d9 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -45,7 +45,7 @@ #include "base/bittorrent/downloadpriority.h" #include "base/bittorrent/infohash.h" #include "base/bittorrent/session.h" -#include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/torrent.h" #include "base/preferences.h" #include "base/unicodestrings.h" #include "base/utils/fs.h" @@ -265,7 +265,7 @@ void PropertiesWidget::clear() m_propListModel->model()->clear(); } -BitTorrent::TorrentHandle *PropertiesWidget::getCurrentTorrent() const +BitTorrent::Torrent *PropertiesWidget::getCurrentTorrent() const { return m_torrent; } @@ -285,25 +285,25 @@ QTreeView *PropertiesWidget::getFilesList() const return m_ui->filesList; } -void PropertiesWidget::updateSavePath(BitTorrent::TorrentHandle *const torrent) +void PropertiesWidget::updateSavePath(BitTorrent::Torrent *const torrent) { if (torrent == m_torrent) m_ui->labelSavePathVal->setText(Utils::Fs::toNativePath(m_torrent->savePath())); } -void PropertiesWidget::loadTrackers(BitTorrent::TorrentHandle *const torrent) +void PropertiesWidget::loadTrackers(BitTorrent::Torrent *const torrent) { if (torrent == m_torrent) m_trackerList->loadTrackers(); } -void PropertiesWidget::updateTorrentInfos(BitTorrent::TorrentHandle *const torrent) +void PropertiesWidget::updateTorrentInfos(BitTorrent::Torrent *const torrent) { if (torrent == m_torrent) loadTorrentInfos(m_torrent); } -void PropertiesWidget::loadTorrentInfos(BitTorrent::TorrentHandle *const torrent) +void PropertiesWidget::loadTorrentInfos(BitTorrent::Torrent *const torrent) { clear(); m_torrent = torrent; @@ -437,7 +437,7 @@ void PropertiesWidget::loadDynamicData() // Update ratio info const qreal ratio = m_torrent->realRatio(); - m_ui->labelShareRatioVal->setText(ratio > BitTorrent::TorrentHandle::MAX_RATIO ? QString::fromUtf8(C_INFINITY) : Utils::String::fromDouble(ratio, 2)); + m_ui->labelShareRatioVal->setText(ratio > BitTorrent::Torrent::MAX_RATIO ? QString::fromUtf8(C_INFINITY) : Utils::String::fromDouble(ratio, 2)); m_ui->labelSeedsVal->setText(tr("%1 (%2 total)", "%1 and %2 are numbers, e.g. 3 (10 total)") .arg(QString::number(m_torrent->seedsCount()) diff --git a/src/gui/properties/propertieswidget.h b/src/gui/properties/propertieswidget.h index d7546bc07..ce57d984b 100644 --- a/src/gui/properties/propertieswidget.h +++ b/src/gui/properties/propertieswidget.h @@ -45,7 +45,7 @@ class TrackerListWidget; namespace BitTorrent { - class TorrentHandle; + class Torrent; } namespace Ui @@ -68,24 +68,24 @@ public: explicit PropertiesWidget(QWidget *parent); ~PropertiesWidget() override; - BitTorrent::TorrentHandle *getCurrentTorrent() const; + BitTorrent::Torrent *getCurrentTorrent() const; TrackerListWidget *getTrackerList() const; PeerListWidget *getPeerList() const; QTreeView *getFilesList() const; public slots: void setVisibility(bool visible); - void loadTorrentInfos(BitTorrent::TorrentHandle *const torrent); + void loadTorrentInfos(BitTorrent::Torrent *const torrent); void loadDynamicData(); void clear(); void readSettings(); void saveSettings(); void reloadPreferences(); void openItem(const QModelIndex &index) const; - void loadTrackers(BitTorrent::TorrentHandle *const torrent); + void loadTrackers(BitTorrent::Torrent *const torrent); protected slots: - void updateTorrentInfos(BitTorrent::TorrentHandle *const torrent); + void updateTorrentInfos(BitTorrent::Torrent *const torrent); void loadUrlSeeds(); void askWebSeed(); void deleteSelectedUrlSeeds(); @@ -101,7 +101,7 @@ protected slots: private slots: void configure(); void filterText(const QString &filter); - void updateSavePath(BitTorrent::TorrentHandle *const torrent); + void updateSavePath(BitTorrent::Torrent *const torrent); private: QPushButton *getButtonFromIndex(int index); @@ -110,7 +110,7 @@ private: QString getFullPath(const QModelIndex &index) const; Ui::PropertiesWidget *m_ui; - BitTorrent::TorrentHandle *m_torrent; + BitTorrent::Torrent *m_torrent; SlideState m_state; TorrentContentFilterModel *m_propListModel; PropListDelegate *m_propListDelegate; diff --git a/src/gui/properties/proplistdelegate.cpp b/src/gui/properties/proplistdelegate.cpp index 3df53663f..5e10dd6d5 100644 --- a/src/gui/properties/proplistdelegate.cpp +++ b/src/gui/properties/proplistdelegate.cpp @@ -41,7 +41,7 @@ #endif #include "base/bittorrent/downloadpriority.h" -#include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/torrent.h" #include "gui/torrentcontentmodel.h" #include "propertieswidget.h" @@ -111,7 +111,7 @@ QWidget *PropListDelegate::createEditor(QWidget *parent, const QStyleOptionViewI if (m_properties) { - const BitTorrent::TorrentHandle *torrent = m_properties->getCurrentTorrent(); + const BitTorrent::Torrent *torrent = m_properties->getCurrentTorrent(); if (!torrent || !torrent->hasMetadata() || torrent->isSeed()) return nullptr; } diff --git a/src/gui/properties/trackerlistwidget.cpp b/src/gui/properties/trackerlistwidget.cpp index ce0193b5c..16d172233 100644 --- a/src/gui/properties/trackerlistwidget.cpp +++ b/src/gui/properties/trackerlistwidget.cpp @@ -46,7 +46,7 @@ #include "base/bittorrent/peerinfo.h" #include "base/bittorrent/session.h" -#include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/torrent.h" #include "base/bittorrent/trackerentry.h" #include "base/global.h" #include "base/preferences.h" @@ -172,7 +172,7 @@ void TrackerListWidget::setRowColor(const int row, const QColor &color) void TrackerListWidget::moveSelectionUp() { - BitTorrent::TorrentHandle *const torrent = m_properties->getCurrentTorrent(); + BitTorrent::Torrent *const torrent = m_properties->getCurrentTorrent(); if (!torrent) { clear(); @@ -218,7 +218,7 @@ void TrackerListWidget::moveSelectionUp() void TrackerListWidget::moveSelectionDown() { - BitTorrent::TorrentHandle *const torrent = m_properties->getCurrentTorrent(); + BitTorrent::Torrent *const torrent = m_properties->getCurrentTorrent(); if (!torrent) { clear(); @@ -281,7 +281,7 @@ void TrackerListWidget::clear() m_LSDItem->setText(COL_MSG, ""); } -void TrackerListWidget::loadStickyItems(const BitTorrent::TorrentHandle *torrent) +void TrackerListWidget::loadStickyItems(const BitTorrent::Torrent *torrent) { const QString working {tr("Working")}; const QString disabled {tr("Disabled")}; @@ -361,7 +361,7 @@ void TrackerListWidget::loadStickyItems(const BitTorrent::TorrentHandle *torrent void TrackerListWidget::loadTrackers() { // Load trackers from torrent handle - const BitTorrent::TorrentHandle *torrent = m_properties->getCurrentTorrent(); + const BitTorrent::Torrent *torrent = m_properties->getCurrentTorrent(); if (!torrent) return; loadStickyItems(torrent); @@ -438,7 +438,7 @@ void TrackerListWidget::loadTrackers() // Ask the user for new trackers and add them to the torrent void TrackerListWidget::askForTrackers() { - BitTorrent::TorrentHandle *const torrent = m_properties->getCurrentTorrent(); + BitTorrent::Torrent *const torrent = m_properties->getCurrentTorrent(); if (!torrent) return; QVector trackers; @@ -466,7 +466,7 @@ void TrackerListWidget::copyTrackerUrl() void TrackerListWidget::deleteSelectedTrackers() { - BitTorrent::TorrentHandle *const torrent = m_properties->getCurrentTorrent(); + BitTorrent::Torrent *const torrent = m_properties->getCurrentTorrent(); if (!torrent) { clear(); @@ -504,7 +504,7 @@ void TrackerListWidget::deleteSelectedTrackers() void TrackerListWidget::editSelectedTracker() { - BitTorrent::TorrentHandle *const torrent = m_properties->getCurrentTorrent(); + BitTorrent::Torrent *const torrent = m_properties->getCurrentTorrent(); if (!torrent) return; const QVector selectedTrackerItems = getSelectedTrackerItems(); @@ -555,7 +555,7 @@ void TrackerListWidget::reannounceSelected() const QList selItems = selectedItems(); if (selItems.isEmpty()) return; - BitTorrent::TorrentHandle *const torrent = m_properties->getCurrentTorrent(); + BitTorrent::Torrent *const torrent = m_properties->getCurrentTorrent(); if (!torrent) return; const QVector trackers = torrent->trackers(); @@ -585,7 +585,7 @@ void TrackerListWidget::reannounceSelected() void TrackerListWidget::showTrackerListMenu(const QPoint &) { - BitTorrent::TorrentHandle *const torrent = m_properties->getCurrentTorrent(); + BitTorrent::Torrent *const torrent = m_properties->getCurrentTorrent(); if (!torrent) return; QMenu *menu = new QMenu(this); @@ -617,7 +617,7 @@ void TrackerListWidget::showTrackerListMenu(const QPoint &) const QAction *reannounceAllAct = menu->addAction(UIThemeManager::instance()->getIcon("view-refresh"), tr("Force reannounce to all trackers")); connect(reannounceAllAct, &QAction::triggered, this, [this]() { - BitTorrent::TorrentHandle *h = m_properties->getCurrentTorrent(); + BitTorrent::Torrent *h = m_properties->getCurrentTorrent(); h->forceReannounce(); h->forceDHTAnnounce(); }); diff --git a/src/gui/properties/trackerlistwidget.h b/src/gui/properties/trackerlistwidget.h index 58d36d031..a4ed39d10 100644 --- a/src/gui/properties/trackerlistwidget.h +++ b/src/gui/properties/trackerlistwidget.h @@ -35,7 +35,7 @@ class PropertiesWidget; namespace BitTorrent { - class TorrentHandle; + class Torrent; } class TrackerListWidget : public QTreeWidget @@ -70,7 +70,7 @@ public slots: void moveSelectionDown(); void clear(); - void loadStickyItems(const BitTorrent::TorrentHandle *torrent); + void loadStickyItems(const BitTorrent::Torrent *torrent); void loadTrackers(); void askForTrackers(); void copyTrackerUrl(); diff --git a/src/gui/properties/trackersadditiondialog.cpp b/src/gui/properties/trackersadditiondialog.cpp index 6dbe8d48e..e2f2f7197 100644 --- a/src/gui/properties/trackersadditiondialog.cpp +++ b/src/gui/properties/trackersadditiondialog.cpp @@ -32,14 +32,14 @@ #include #include -#include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/torrent.h" #include "base/bittorrent/trackerentry.h" #include "base/global.h" #include "base/net/downloadmanager.h" #include "gui/uithememanager.h" #include "ui_trackersadditiondialog.h" -TrackersAdditionDialog::TrackersAdditionDialog(QWidget *parent, BitTorrent::TorrentHandle *const torrent) +TrackersAdditionDialog::TrackersAdditionDialog(QWidget *parent, BitTorrent::Torrent *const torrent) : QDialog(parent) , m_ui(new Ui::TrackersAdditionDialog()) , m_torrent(torrent) @@ -129,7 +129,7 @@ void TrackersAdditionDialog::torrentListDownloadFinished(const Net::DownloadResu QMessageBox::information(this, tr("No change"), tr("No additional trackers were found."), QMessageBox::Ok); } -QStringList TrackersAdditionDialog::askForTrackers(QWidget *parent, BitTorrent::TorrentHandle *const torrent) +QStringList TrackersAdditionDialog::askForTrackers(QWidget *parent, BitTorrent::Torrent *const torrent) { QStringList trackers; TrackersAdditionDialog dlg(parent, torrent); diff --git a/src/gui/properties/trackersadditiondialog.h b/src/gui/properties/trackersadditiondialog.h index 817a32dda..f05338a10 100644 --- a/src/gui/properties/trackersadditiondialog.h +++ b/src/gui/properties/trackersadditiondialog.h @@ -35,7 +35,7 @@ class QString; namespace BitTorrent { - class TorrentHandle; + class Torrent; } namespace Net @@ -53,11 +53,11 @@ class TrackersAdditionDialog : public QDialog Q_OBJECT public: - TrackersAdditionDialog(QWidget *parent, BitTorrent::TorrentHandle *const torrent); + TrackersAdditionDialog(QWidget *parent, BitTorrent::Torrent *const torrent); ~TrackersAdditionDialog(); QStringList newTrackers() const; - static QStringList askForTrackers(QWidget *parent, BitTorrent::TorrentHandle *const torrent); + static QStringList askForTrackers(QWidget *parent, BitTorrent::Torrent *const torrent); public slots: void on_uTorrentListButton_clicked(); @@ -65,5 +65,5 @@ public slots: private: Ui::TrackersAdditionDialog *m_ui; - BitTorrent::TorrentHandle *const m_torrent; + BitTorrent::Torrent *const m_torrent; }; diff --git a/src/gui/statsdialog.cpp b/src/gui/statsdialog.cpp index c618cfa3c..2ac1e4a76 100644 --- a/src/gui/statsdialog.cpp +++ b/src/gui/statsdialog.cpp @@ -33,7 +33,7 @@ #include "base/bittorrent/cachestatus.h" #include "base/bittorrent/session.h" #include "base/bittorrent/sessionstatus.h" -#include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/torrent.h" #include "base/global.h" #include "base/utils/misc.h" #include "base/utils/string.h" diff --git a/src/gui/tagfiltermodel.cpp b/src/gui/tagfiltermodel.cpp index 8e81e3e0a..0713ad177 100644 --- a/src/gui/tagfiltermodel.cpp +++ b/src/gui/tagfiltermodel.cpp @@ -34,7 +34,7 @@ #include #include "base/bittorrent/session.h" -#include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/torrent.h" #include "base/global.h" #include "uithememanager.h" @@ -203,7 +203,7 @@ void TagFilterModel::tagRemoved(const QString &tag) endRemoveRows(); } -void TagFilterModel::torrentTagAdded(BitTorrent::TorrentHandle *const torrent, const QString &tag) +void TagFilterModel::torrentTagAdded(BitTorrent::Torrent *const torrent, const QString &tag) { if (torrent->tags().count() == 1) untaggedItem()->decreaseTorrentsCount(); @@ -217,7 +217,7 @@ void TagFilterModel::torrentTagAdded(BitTorrent::TorrentHandle *const torrent, c emit dataChanged(i, i); } -void TagFilterModel::torrentTagRemoved(BitTorrent::TorrentHandle *const torrent, const QString &tag) +void TagFilterModel::torrentTagRemoved(BitTorrent::Torrent *const torrent, const QString &tag) { if (torrent->tags().empty()) untaggedItem()->increaseTorrentsCount(); @@ -232,7 +232,7 @@ void TagFilterModel::torrentTagRemoved(BitTorrent::TorrentHandle *const torrent, emit dataChanged(i, i); } -void TagFilterModel::torrentAdded(BitTorrent::TorrentHandle *const torrent) +void TagFilterModel::torrentAdded(BitTorrent::Torrent *const torrent) { allTagsItem()->increaseTorrentsCount(); @@ -244,7 +244,7 @@ void TagFilterModel::torrentAdded(BitTorrent::TorrentHandle *const torrent) item->increaseTorrentsCount(); } -void TagFilterModel::torrentAboutToBeRemoved(BitTorrent::TorrentHandle *const torrent) +void TagFilterModel::torrentAboutToBeRemoved(BitTorrent::Torrent *const torrent) { allTagsItem()->decreaseTorrentsCount(); @@ -266,7 +266,7 @@ QString TagFilterModel::tagDisplayName(const QString &tag) void TagFilterModel::populate() { - using Torrent = BitTorrent::TorrentHandle; + using Torrent = BitTorrent::Torrent; const auto *session = BitTorrent::Session::instance(); const auto torrents = session->torrents(); diff --git a/src/gui/tagfiltermodel.h b/src/gui/tagfiltermodel.h index 8c7d5b0d9..761ae1eda 100644 --- a/src/gui/tagfiltermodel.h +++ b/src/gui/tagfiltermodel.h @@ -37,7 +37,7 @@ class TagModelItem; namespace BitTorrent { - class TorrentHandle; + class Torrent; } class TagFilterModel final : public QAbstractListModel @@ -62,10 +62,10 @@ public: private slots: void tagAdded(const QString &tag); void tagRemoved(const QString &tag); - void torrentTagAdded(BitTorrent::TorrentHandle *const torrent, const QString &tag); - void torrentTagRemoved(BitTorrent::TorrentHandle *const, const QString &tag); - void torrentAdded(BitTorrent::TorrentHandle *const torrent); - void torrentAboutToBeRemoved(BitTorrent::TorrentHandle *const torrent); + void torrentTagAdded(BitTorrent::Torrent *const torrent, const QString &tag); + void torrentTagRemoved(BitTorrent::Torrent *const, const QString &tag); + void torrentAdded(BitTorrent::Torrent *const torrent); + void torrentAboutToBeRemoved(BitTorrent::Torrent *const torrent); private: static QString tagDisplayName(const QString &tag); diff --git a/src/gui/torrentcontenttreeview.cpp b/src/gui/torrentcontenttreeview.cpp index 6f4f01a96..cdf29c133 100644 --- a/src/gui/torrentcontenttreeview.cpp +++ b/src/gui/torrentcontenttreeview.cpp @@ -40,7 +40,7 @@ #include "base/bittorrent/abstractfilestorage.h" #include "base/bittorrent/common.h" #include "base/bittorrent/session.h" -#include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/torrent.h" #include "base/bittorrent/torrentinfo.h" #include "base/exceptions.h" #include "base/global.h" diff --git a/src/gui/torrentcontenttreeview.h b/src/gui/torrentcontenttreeview.h index 468c1ccdb..9f596dcb3 100644 --- a/src/gui/torrentcontenttreeview.h +++ b/src/gui/torrentcontenttreeview.h @@ -33,7 +33,7 @@ namespace BitTorrent { class AbstractFileStorage; - class TorrentHandle; + class Torrent; class TorrentInfo; } diff --git a/src/gui/torrentcreatordialog.cpp b/src/gui/torrentcreatordialog.cpp index 372966236..bce90be65 100644 --- a/src/gui/torrentcreatordialog.cpp +++ b/src/gui/torrentcreatordialog.cpp @@ -246,8 +246,8 @@ void TorrentCreatorDialog::handleCreationSuccess(const QString &path, const QStr params.skipChecking = true; if (m_ui->checkIgnoreShareLimits->isChecked()) { - params.ratioLimit = BitTorrent::TorrentHandle::NO_RATIO_LIMIT; - params.seedingTimeLimit = BitTorrent::TorrentHandle::NO_SEEDING_TIME_LIMIT; + params.ratioLimit = BitTorrent::Torrent::NO_RATIO_LIMIT; + params.seedingTimeLimit = BitTorrent::Torrent::NO_SEEDING_TIME_LIMIT; } params.useAutoTMM = false; // otherwise if it is on by default, it will overwrite `savePath` to the default save path diff --git a/src/gui/torrentoptionsdialog.cpp b/src/gui/torrentoptionsdialog.cpp index 335cf3987..e09005f11 100644 --- a/src/gui/torrentoptionsdialog.cpp +++ b/src/gui/torrentoptionsdialog.cpp @@ -33,7 +33,7 @@ #include "base/bittorrent/infohash.h" #include "base/bittorrent/session.h" -#include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/torrent.h" #include "base/global.h" #include "base/unicodestrings.h" #include "ui_torrentoptionsdialog.h" @@ -53,7 +53,7 @@ namespace } } -TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector &torrents) +TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector &torrents) : QDialog {parent} , m_ui {new Ui::TorrentOptionsDialog} , m_storeDialogSize {SETTINGS_KEY("Size")} @@ -76,7 +76,7 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVectorisLSDDisabled(); m_torrentHashes.reserve(torrents.size()); - for (const BitTorrent::TorrentHandle *torrent : torrents) + for (const BitTorrent::Torrent *torrent : torrents) { m_torrentHashes << torrent->hash(); if (allSameUpLimit) @@ -180,8 +180,8 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVectorradioUseGlobalShareLimits->setChecked(true); } - else if ((firstTorrentRatio == BitTorrent::TorrentHandle::NO_RATIO_LIMIT) - && (firstTorrentSeedingTime == BitTorrent::TorrentHandle::NO_SEEDING_TIME_LIMIT)) + else if ((firstTorrentRatio == BitTorrent::Torrent::NO_RATIO_LIMIT) + && (firstTorrentSeedingTime == BitTorrent::Torrent::NO_SEEDING_TIME_LIMIT)) { m_ui->radioNoLimit->setChecked(true); } @@ -288,7 +288,7 @@ void TorrentOptionsDialog::accept() const auto *session = BitTorrent::Session::instance(); for (const BitTorrent::InfoHash &hash : asConst(m_torrentHashes)) { - BitTorrent::TorrentHandle *torrent = session->findTorrent(hash); + BitTorrent::Torrent *torrent = session->findTorrent(hash); if (!torrent) continue; if (m_initialValues.upSpeedLimit != m_ui->spinUploadLimit->value()) @@ -324,10 +324,10 @@ qreal TorrentOptionsDialog::getRatio() const return MIXED_SHARE_LIMITS; if (m_ui->radioUseGlobalShareLimits->isChecked()) - return BitTorrent::TorrentHandle::USE_GLOBAL_RATIO; + return BitTorrent::Torrent::USE_GLOBAL_RATIO; if (m_ui->radioNoLimit->isChecked() || !m_ui->checkMaxRatio->isChecked()) - return BitTorrent::TorrentHandle::NO_RATIO_LIMIT; + return BitTorrent::Torrent::NO_RATIO_LIMIT; return m_ui->spinRatioLimit->value(); } @@ -338,10 +338,10 @@ int TorrentOptionsDialog::getSeedingTime() const return MIXED_SHARE_LIMITS; if (m_ui->radioUseGlobalShareLimits->isChecked()) - return BitTorrent::TorrentHandle::USE_GLOBAL_SEEDING_TIME; + return BitTorrent::Torrent::USE_GLOBAL_SEEDING_TIME; if (m_ui->radioNoLimit->isChecked() || !m_ui->checkMaxTime->isChecked()) - return BitTorrent::TorrentHandle::NO_SEEDING_TIME_LIMIT; + return BitTorrent::Torrent::NO_SEEDING_TIME_LIMIT; return m_ui->spinTimeLimit->value(); } diff --git a/src/gui/torrentoptionsdialog.h b/src/gui/torrentoptionsdialog.h index 728b271c1..12c6daf2f 100644 --- a/src/gui/torrentoptionsdialog.h +++ b/src/gui/torrentoptionsdialog.h @@ -35,7 +35,7 @@ namespace BitTorrent { class InfoHash; - class TorrentHandle; + class Torrent; } namespace Ui @@ -49,7 +49,7 @@ class TorrentOptionsDialog final : public QDialog Q_DISABLE_COPY(TorrentOptionsDialog) public: - explicit TorrentOptionsDialog(QWidget *parent, const QVector &torrents); + explicit TorrentOptionsDialog(QWidget *parent, const QVector &torrents); ~TorrentOptionsDialog() override; public slots: diff --git a/src/gui/transferlistfilterswidget.cpp b/src/gui/transferlistfilterswidget.cpp index 53788b485..5a78557ba 100644 --- a/src/gui/transferlistfilterswidget.cpp +++ b/src/gui/transferlistfilterswidget.cpp @@ -40,7 +40,7 @@ #include "base/bittorrent/infohash.h" #include "base/bittorrent/session.h" -#include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/torrent.h" #include "base/bittorrent/trackerentry.h" #include "base/global.h" #include "base/logger.h" @@ -240,8 +240,8 @@ void StatusFilterWidget::updateTorrentNumbers() int nbStalledDownloading = 0; int nbErrored = 0; - const QVector torrents = BitTorrent::Session::instance()->torrents(); - for (const BitTorrent::TorrentHandle *torrent : torrents) + const QVector torrents = BitTorrent::Session::instance()->torrents(); + for (const BitTorrent::Torrent *torrent : torrents) { if (torrent->isDownloading()) ++nbDownloading; @@ -288,9 +288,9 @@ void StatusFilterWidget::applyFilter(int row) transferList->applyStatusFilter(row); } -void StatusFilterWidget::handleNewTorrent(BitTorrent::TorrentHandle *const) {} +void StatusFilterWidget::handleNewTorrent(BitTorrent::Torrent *const) {} -void StatusFilterWidget::torrentAboutToBeDeleted(BitTorrent::TorrentHandle *const) {} +void StatusFilterWidget::torrentAboutToBeDeleted(BitTorrent::Torrent *const) {} TrackerFiltersList::TrackerFiltersList(QWidget *parent, TransferListWidget *transferList, const bool downloadFavicon) : BaseFilterWidget(parent, transferList) @@ -577,7 +577,7 @@ void TrackerFiltersList::applyFilter(const int row) transferList->applyTrackerFilter(getInfoHashes(row)); } -void TrackerFiltersList::handleNewTorrent(BitTorrent::TorrentHandle *const torrent) +void TrackerFiltersList::handleNewTorrent(BitTorrent::Torrent *const torrent) { const BitTorrent::InfoHash hash {torrent->hash()}; const QVector trackers {torrent->trackers()}; @@ -591,7 +591,7 @@ void TrackerFiltersList::handleNewTorrent(BitTorrent::TorrentHandle *const torre item(ALL_ROW)->setText(tr("All (%1)", "this is for the tracker filter").arg(++m_totalTorrents)); } -void TrackerFiltersList::torrentAboutToBeDeleted(BitTorrent::TorrentHandle *const torrent) +void TrackerFiltersList::torrentAboutToBeDeleted(BitTorrent::Torrent *const torrent) { const BitTorrent::InfoHash hash {torrent->hash()}; const QVector trackers {torrent->trackers()}; @@ -742,34 +742,34 @@ void TransferListFiltersWidget::setDownloadTrackerFavicon(bool value) m_trackerFilters->setDownloadTrackerFavicon(value); } -void TransferListFiltersWidget::addTrackers(const BitTorrent::TorrentHandle *torrent, const QVector &trackers) +void TransferListFiltersWidget::addTrackers(const BitTorrent::Torrent *torrent, const QVector &trackers) { for (const BitTorrent::TrackerEntry &tracker : trackers) m_trackerFilters->addItem(tracker.url(), torrent->hash()); } -void TransferListFiltersWidget::removeTrackers(const BitTorrent::TorrentHandle *torrent, const QVector &trackers) +void TransferListFiltersWidget::removeTrackers(const BitTorrent::Torrent *torrent, const QVector &trackers) { for (const BitTorrent::TrackerEntry &tracker : trackers) m_trackerFilters->removeItem(tracker.url(), torrent->hash()); } -void TransferListFiltersWidget::changeTrackerless(const BitTorrent::TorrentHandle *torrent, const bool trackerless) +void TransferListFiltersWidget::changeTrackerless(const BitTorrent::Torrent *torrent, const bool trackerless) { m_trackerFilters->changeTrackerless(trackerless, torrent->hash()); } -void TransferListFiltersWidget::trackerSuccess(const BitTorrent::TorrentHandle *torrent, const QString &tracker) +void TransferListFiltersWidget::trackerSuccess(const BitTorrent::Torrent *torrent, const QString &tracker) { emit trackerSuccess(torrent->hash(), tracker); } -void TransferListFiltersWidget::trackerWarning(const BitTorrent::TorrentHandle *torrent, const QString &tracker) +void TransferListFiltersWidget::trackerWarning(const BitTorrent::Torrent *torrent, const QString &tracker) { emit trackerWarning(torrent->hash(), tracker); } -void TransferListFiltersWidget::trackerError(const BitTorrent::TorrentHandle *torrent, const QString &tracker) +void TransferListFiltersWidget::trackerError(const BitTorrent::Torrent *torrent, const QString &tracker) { emit trackerError(torrent->hash(), tracker); } diff --git a/src/gui/transferlistfilterswidget.h b/src/gui/transferlistfilterswidget.h index 3046c8e34..7e65cc947 100644 --- a/src/gui/transferlistfilterswidget.h +++ b/src/gui/transferlistfilterswidget.h @@ -40,7 +40,7 @@ class TransferListWidget; namespace BitTorrent { class InfoHash; - class TorrentHandle; + class Torrent; class TrackerEntry; } @@ -69,8 +69,8 @@ protected: private slots: virtual void showMenu(const QPoint &) = 0; virtual void applyFilter(int row) = 0; - virtual void handleNewTorrent(BitTorrent::TorrentHandle *const) = 0; - virtual void torrentAboutToBeDeleted(BitTorrent::TorrentHandle *const) = 0; + virtual void handleNewTorrent(BitTorrent::Torrent *const) = 0; + virtual void torrentAboutToBeDeleted(BitTorrent::Torrent *const) = 0; }; class StatusFilterWidget final : public BaseFilterWidget @@ -90,8 +90,8 @@ private: // No need to redeclare them here as slots. void showMenu(const QPoint &) override; void applyFilter(int row) override; - void handleNewTorrent(BitTorrent::TorrentHandle *const) override; - void torrentAboutToBeDeleted(BitTorrent::TorrentHandle *const) override; + void handleNewTorrent(BitTorrent::Torrent *const) override; + void torrentAboutToBeDeleted(BitTorrent::Torrent *const) override; }; class TrackerFiltersList final : public BaseFilterWidget @@ -122,8 +122,8 @@ private: // No need to redeclare them here as slots. void showMenu(const QPoint &) override; void applyFilter(int row) override; - void handleNewTorrent(BitTorrent::TorrentHandle *const torrent) override; - void torrentAboutToBeDeleted(BitTorrent::TorrentHandle *const torrent) override; + void handleNewTorrent(BitTorrent::Torrent *const torrent) override; + void torrentAboutToBeDeleted(BitTorrent::Torrent *const torrent) override; QString trackerFromRow(int row) const; int rowFromTracker(const QString &tracker) const; QSet getInfoHashes(int row) const; @@ -150,12 +150,12 @@ public: void setDownloadTrackerFavicon(bool value); public slots: - void addTrackers(const BitTorrent::TorrentHandle *torrent, const QVector &trackers); - void removeTrackers(const BitTorrent::TorrentHandle *torrent, const QVector &trackers); - void changeTrackerless(const BitTorrent::TorrentHandle *torrent, bool trackerless); - void trackerSuccess(const BitTorrent::TorrentHandle *torrent, const QString &tracker); - void trackerWarning(const BitTorrent::TorrentHandle *torrent, const QString &tracker); - void trackerError(const BitTorrent::TorrentHandle *torrent, const QString &tracker); + void addTrackers(const BitTorrent::Torrent *torrent, const QVector &trackers); + void removeTrackers(const BitTorrent::Torrent *torrent, const QVector &trackers); + void changeTrackerless(const BitTorrent::Torrent *torrent, bool trackerless); + void trackerSuccess(const BitTorrent::Torrent *torrent, const QString &tracker); + void trackerWarning(const BitTorrent::Torrent *torrent, const QString &tracker); + void trackerError(const BitTorrent::Torrent *torrent, const QString &tracker); signals: void trackerSuccess(const BitTorrent::InfoHash &hash, const QString &tracker); diff --git a/src/gui/transferlistmodel.cpp b/src/gui/transferlistmodel.cpp index 479ec0d3c..617a1d6fc 100644 --- a/src/gui/transferlistmodel.cpp +++ b/src/gui/transferlistmodel.cpp @@ -36,7 +36,7 @@ #include #include "base/bittorrent/session.h" -#include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/torrent.h" #include "base/global.h" #include "base/preferences.h" #include "base/unicodestrings.h" @@ -133,7 +133,7 @@ TransferListModel::TransferListModel(QObject *parent) // Load the torrents using namespace BitTorrent; - for (TorrentHandle *const torrent : asConst(Session::instance()->torrents())) + for (Torrent *const torrent : asConst(Session::instance()->torrents())) addTorrent(torrent); // Listen for torrent changes @@ -234,7 +234,7 @@ QVariant TransferListModel::headerData(int section, Qt::Orientation orientation, return {}; } -QString TransferListModel::displayValue(const BitTorrent::TorrentHandle *torrent, const int column) const +QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, const int column) const { bool hideValues = false; if (m_hideZeroValuesMode == HideZeroValuesMode::Always) @@ -276,7 +276,7 @@ QString TransferListModel::displayValue(const BitTorrent::TorrentHandle *torrent if (hideValues && (value <= 0)) return {}; - return ((static_cast(value) == -1) || (value > BitTorrent::TorrentHandle::MAX_RATIO)) + return ((static_cast(value) == -1) || (value > BitTorrent::Torrent::MAX_RATIO)) ? QString::fromUtf8(C_INFINITY) : Utils::String::fromDouble(value, 2); }; @@ -399,7 +399,7 @@ QString TransferListModel::displayValue(const BitTorrent::TorrentHandle *torrent return {}; } -QVariant TransferListModel::internalValue(const BitTorrent::TorrentHandle *torrent, const int column, const bool alt) const +QVariant TransferListModel::internalValue(const BitTorrent::Torrent *torrent, const int column, const bool alt) const { switch (column) { @@ -474,7 +474,7 @@ QVariant TransferListModel::data(const QModelIndex &index, const int role) const { if (!index.isValid()) return {}; - const BitTorrent::TorrentHandle *torrent = m_torrentList.value(index.row()); + const BitTorrent::Torrent *torrent = m_torrentList.value(index.row()); if (!torrent) return {}; switch (role) @@ -537,7 +537,7 @@ bool TransferListModel::setData(const QModelIndex &index, const QVariant &value, { if (!index.isValid() || (role != Qt::DisplayRole)) return false; - BitTorrent::TorrentHandle *const torrent = m_torrentList.value(index.row()); + BitTorrent::Torrent *const torrent = m_torrentList.value(index.row()); if (!torrent) return false; // Category and Name columns can be edited @@ -556,7 +556,7 @@ bool TransferListModel::setData(const QModelIndex &index, const QVariant &value, return true; } -void TransferListModel::addTorrent(BitTorrent::TorrentHandle *const torrent) +void TransferListModel::addTorrent(BitTorrent::Torrent *const torrent) { Q_ASSERT(!m_torrentMap.contains(torrent)); @@ -576,14 +576,14 @@ Qt::ItemFlags TransferListModel::flags(const QModelIndex &index) const return QAbstractListModel::flags(index) | Qt::ItemIsEditable; } -BitTorrent::TorrentHandle *TransferListModel::torrentHandle(const QModelIndex &index) const +BitTorrent::Torrent *TransferListModel::torrentHandle(const QModelIndex &index) const { if (!index.isValid()) return nullptr; return m_torrentList.value(index.row()); } -void TransferListModel::handleTorrentAboutToBeRemoved(BitTorrent::TorrentHandle *const torrent) +void TransferListModel::handleTorrentAboutToBeRemoved(BitTorrent::Torrent *const torrent) { const int row = m_torrentMap.value(torrent, -1); Q_ASSERT(row >= 0); @@ -599,7 +599,7 @@ void TransferListModel::handleTorrentAboutToBeRemoved(BitTorrent::TorrentHandle endRemoveRows(); } -void TransferListModel::handleTorrentStatusUpdated(BitTorrent::TorrentHandle *const torrent) +void TransferListModel::handleTorrentStatusUpdated(BitTorrent::Torrent *const torrent) { const int row = m_torrentMap.value(torrent, -1); Q_ASSERT(row >= 0); @@ -607,13 +607,13 @@ void TransferListModel::handleTorrentStatusUpdated(BitTorrent::TorrentHandle *co emit dataChanged(index(row, 0), index(row, columnCount() - 1)); } -void TransferListModel::handleTorrentsUpdated(const QVector &torrents) +void TransferListModel::handleTorrentsUpdated(const QVector &torrents) { const int columns = (columnCount() - 1); if (torrents.size() <= (m_torrentList.size() * 0.5)) { - for (BitTorrent::TorrentHandle *const torrent : torrents) + for (BitTorrent::Torrent *const torrent : torrents) { const int row = m_torrentMap.value(torrent, -1); Q_ASSERT(row >= 0); diff --git a/src/gui/transferlistmodel.h b/src/gui/transferlistmodel.h index ef77711cd..91734bc8e 100644 --- a/src/gui/transferlistmodel.h +++ b/src/gui/transferlistmodel.h @@ -34,7 +34,7 @@ #include #include -#include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/torrent.h" namespace BitTorrent { @@ -99,21 +99,21 @@ public: QVariant headerData(int section, Qt::Orientation orientation, int role) const override; Qt::ItemFlags flags(const QModelIndex &index) const override; - BitTorrent::TorrentHandle *torrentHandle(const QModelIndex &index) const; + BitTorrent::Torrent *torrentHandle(const QModelIndex &index) const; private slots: - void addTorrent(BitTorrent::TorrentHandle *const torrent); - void handleTorrentAboutToBeRemoved(BitTorrent::TorrentHandle *const torrent); - void handleTorrentStatusUpdated(BitTorrent::TorrentHandle *const torrent); - void handleTorrentsUpdated(const QVector &torrents); + void addTorrent(BitTorrent::Torrent *const torrent); + void handleTorrentAboutToBeRemoved(BitTorrent::Torrent *const torrent); + void handleTorrentStatusUpdated(BitTorrent::Torrent *const torrent); + void handleTorrentsUpdated(const QVector &torrents); private: void configure(); - QString displayValue(const BitTorrent::TorrentHandle *torrent, int column) const; - QVariant internalValue(const BitTorrent::TorrentHandle *torrent, int column, bool alt = false) const; + QString displayValue(const BitTorrent::Torrent *torrent, int column) const; + QVariant internalValue(const BitTorrent::Torrent *torrent, int column, bool alt = false) const; - QList m_torrentList; // maps row number to torrent handle - QHash m_torrentMap; // maps torrent handle to row number + QList m_torrentList; // maps row number to torrent handle + QHash m_torrentMap; // maps torrent handle to row number const QHash m_statusStrings; // row text colors const QHash m_stateThemeColors; diff --git a/src/gui/transferlistsortmodel.cpp b/src/gui/transferlistsortmodel.cpp index 1d37f4a02..ef13b0780 100644 --- a/src/gui/transferlistsortmodel.cpp +++ b/src/gui/transferlistsortmodel.cpp @@ -31,7 +31,7 @@ #include #include "base/bittorrent/infohash.h" -#include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/torrent.h" #include "base/global.h" #include "base/types.h" #include "base/utils/string.h" @@ -292,7 +292,7 @@ bool TransferListSortModel::matchFilter(const int sourceRow, const QModelIndex & const auto *model = qobject_cast(sourceModel()); if (!model) return false; - const BitTorrent::TorrentHandle *torrent = model->torrentHandle(model->index(sourceRow, 0, sourceParent)); + const BitTorrent::Torrent *torrent = model->torrentHandle(model->index(sourceRow, 0, sourceParent)); if (!torrent) return false; return m_filter.match(torrent); diff --git a/src/gui/transferlistwidget.cpp b/src/gui/transferlistwidget.cpp index 798756c0a..5aa8f5151 100644 --- a/src/gui/transferlistwidget.cpp +++ b/src/gui/transferlistwidget.cpp @@ -46,7 +46,7 @@ #include "base/bittorrent/infohash.h" #include "base/bittorrent/session.h" -#include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/torrent.h" #include "base/bittorrent/trackerentry.h" #include "base/global.h" #include "base/logger.h" @@ -77,16 +77,16 @@ namespace { - QVector extractHashes(const QVector &torrents) + QVector extractHashes(const QVector &torrents) { QVector hashes; hashes.reserve(torrents.size()); - for (const BitTorrent::TorrentHandle *torrent : torrents) + for (const BitTorrent::Torrent *torrent : torrents) hashes << torrent->hash(); return hashes; } - bool torrentContainsPreviewableFiles(const BitTorrent::TorrentHandle *const torrent) + bool torrentContainsPreviewableFiles(const BitTorrent::Torrent *const torrent) { if (!torrent->hasMetadata()) return false; @@ -100,7 +100,7 @@ namespace return false; } - void openDestinationFolder(const BitTorrent::TorrentHandle *const torrent) + void openDestinationFolder(const BitTorrent::Torrent *const torrent) { #ifdef Q_OS_MACOS MacUtils::openFiles({torrent->contentPath(true)}); @@ -112,11 +112,11 @@ namespace #endif } - void removeTorrents(const QVector &torrents, const bool isDeleteFileSelected) + void removeTorrents(const QVector &torrents, const bool isDeleteFileSelected) { auto *session = BitTorrent::Session::instance(); - const DeleteOption deleteOption = isDeleteFileSelected ? TorrentAndFiles : Torrent; - for (const BitTorrent::TorrentHandle *torrent : torrents) + const DeleteOption deleteOption = isDeleteFileSelected ? DeleteTorrentAndFiles : DeleteTorrent; + for (const BitTorrent::Torrent *torrent : torrents) session->deleteTorrent(torrent->hash(), deleteOption); } } @@ -271,7 +271,7 @@ void TransferListWidget::torrentDoubleClicked() if ((selectedIndexes.size() != 1) || !selectedIndexes.first().isValid()) return; const QModelIndex index = m_listModel->index(mapToSource(selectedIndexes.first()).row()); - BitTorrent::TorrentHandle *const torrent = m_listModel->torrentHandle(index); + BitTorrent::Torrent *const torrent = m_listModel->torrentHandle(index); if (!torrent) return; int action; @@ -307,22 +307,22 @@ void TransferListWidget::torrentDoubleClicked() } } -QVector TransferListWidget::getSelectedTorrents() const +QVector TransferListWidget::getSelectedTorrents() const { const QModelIndexList selectedRows = selectionModel()->selectedRows(); - QVector torrents; + QVector torrents; torrents.reserve(selectedRows.size()); for (const QModelIndex &index : selectedRows) torrents << m_listModel->torrentHandle(mapToSource(index)); return torrents; } -QVector TransferListWidget::getVisibleTorrents() const +QVector TransferListWidget::getVisibleTorrents() const { const int visibleTorrentsCount = m_sortFilterModel->rowCount(); - QVector torrents; + QVector torrents; torrents.reserve(visibleTorrentsCount); for (int i = 0; i < visibleTorrentsCount; ++i) torrents << m_listModel->torrentHandle(mapToSource(m_sortFilterModel->index(i, 0))); @@ -331,7 +331,7 @@ QVector TransferListWidget::getVisibleTorrents() co void TransferListWidget::setSelectedTorrentsLocation() { - const QVector torrents = getSelectedTorrents(); + const QVector torrents = getSelectedTorrents(); if (torrents.isEmpty()) return; const QString oldLocation = torrents[0]->savePath(); @@ -340,49 +340,49 @@ void TransferListWidget::setSelectedTorrentsLocation() if (newLocation.isEmpty() || !QDir(newLocation).exists()) return; // Actually move storage - for (BitTorrent::TorrentHandle *const torrent : torrents) + for (BitTorrent::Torrent *const torrent : torrents) torrent->move(Utils::Fs::expandPathAbs(newLocation)); } void TransferListWidget::pauseAllTorrents() { - for (BitTorrent::TorrentHandle *const torrent : asConst(BitTorrent::Session::instance()->torrents())) + for (BitTorrent::Torrent *const torrent : asConst(BitTorrent::Session::instance()->torrents())) torrent->pause(); } void TransferListWidget::resumeAllTorrents() { - for (BitTorrent::TorrentHandle *const torrent : asConst(BitTorrent::Session::instance()->torrents())) + for (BitTorrent::Torrent *const torrent : asConst(BitTorrent::Session::instance()->torrents())) torrent->resume(); } void TransferListWidget::startSelectedTorrents() { - for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents())) + for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents())) torrent->resume(); } void TransferListWidget::forceStartSelectedTorrents() { - for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents())) + for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents())) torrent->resume(BitTorrent::TorrentOperatingMode::Forced); } void TransferListWidget::startVisibleTorrents() { - for (BitTorrent::TorrentHandle *const torrent : asConst(getVisibleTorrents())) + for (BitTorrent::Torrent *const torrent : asConst(getVisibleTorrents())) torrent->resume(); } void TransferListWidget::pauseSelectedTorrents() { - for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents())) + for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents())) torrent->pause(); } void TransferListWidget::pauseVisibleTorrents() { - for (BitTorrent::TorrentHandle *const torrent : asConst(getVisibleTorrents())) + for (BitTorrent::Torrent *const torrent : asConst(getVisibleTorrents())) torrent->pause(); } @@ -400,7 +400,7 @@ void TransferListWidget::deleteSelectedTorrents(const bool deleteLocalFiles) { if (m_mainWindow->currentTabWidget() != this) return; - const QVector torrents = getSelectedTorrents(); + const QVector torrents = getSelectedTorrents(); if (torrents.empty()) return; if (Preferences::instance()->confirmTorrentDeletion()) @@ -423,7 +423,7 @@ void TransferListWidget::deleteSelectedTorrents(const bool deleteLocalFiles) void TransferListWidget::deleteVisibleTorrents() { - const QVector torrents = getVisibleTorrents(); + const QVector torrents = getVisibleTorrents(); if (torrents.empty()) return; if (Preferences::instance()->confirmTorrentDeletion()) @@ -473,7 +473,7 @@ void TransferListWidget::bottomQueuePosSelectedTorrents() void TransferListWidget::copySelectedMagnetURIs() const { QStringList magnetUris; - for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents())) + for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents())) magnetUris << torrent->createMagnetURI(); qApp->clipboard()->setText(magnetUris.join('\n')); @@ -482,7 +482,7 @@ void TransferListWidget::copySelectedMagnetURIs() const void TransferListWidget::copySelectedNames() const { QStringList torrentNames; - for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents())) + for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents())) torrentNames << torrent->name(); qApp->clipboard()->setText(torrentNames.join('\n')); @@ -491,7 +491,7 @@ void TransferListWidget::copySelectedNames() const void TransferListWidget::copySelectedHashes() const { QStringList torrentHashes; - for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents())) + for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents())) torrentHashes << torrent->hash(); qApp->clipboard()->setText(torrentHashes.join('\n')); @@ -510,14 +510,14 @@ void TransferListWidget::openSelectedTorrentsFolder() const #ifdef Q_OS_MACOS // On macOS you expect both the files and folders to be opened in their parent // folders prehilighted for opening, so we use a custom method. - for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents())) + for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents())) { QString path = torrent->contentPath(true); pathsList.insert(path); } MacUtils::openFiles(pathsList); #else - for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents())) + for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents())) { QString path = torrent->contentPath(true); if (!pathsList.contains(path)) @@ -534,7 +534,7 @@ void TransferListWidget::openSelectedTorrentsFolder() const void TransferListWidget::previewSelectedTorrents() { - for (const BitTorrent::TorrentHandle *torrent : asConst(getSelectedTorrents())) + for (const BitTorrent::Torrent *torrent : asConst(getSelectedTorrents())) { if (torrentContainsPreviewableFiles(torrent)) { @@ -553,7 +553,7 @@ void TransferListWidget::previewSelectedTorrents() void TransferListWidget::setTorrentOptions() { - const QVector selectedTorrents = getSelectedTorrents(); + const QVector selectedTorrents = getSelectedTorrents(); if (selectedTorrents.empty()) return; auto dialog = new TorrentOptionsDialog {this, selectedTorrents}; @@ -569,13 +569,13 @@ void TransferListWidget::recheckSelectedTorrents() if (ret != QMessageBox::Yes) return; } - for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents())) + for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents())) torrent->forceRecheck(); } void TransferListWidget::reannounceSelectedTorrents() { - for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents())) + for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents())) torrent->forceReannounce(); } @@ -627,7 +627,7 @@ void TransferListWidget::displayDLHoSMenu(const QPoint&) void TransferListWidget::setSelectedTorrentsSuperSeeding(const bool enabled) const { - for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents())) + for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents())) { if (torrent->hasMetadata()) torrent->setSuperSeeding(enabled); @@ -636,19 +636,19 @@ void TransferListWidget::setSelectedTorrentsSuperSeeding(const bool enabled) con void TransferListWidget::setSelectedTorrentsSequentialDownload(const bool enabled) const { - for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents())) + for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents())) torrent->setSequentialDownload(enabled); } void TransferListWidget::setSelectedFirstLastPiecePrio(const bool enabled) const { - for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents())) + for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents())) torrent->setFirstLastPiecePriority(enabled); } void TransferListWidget::setSelectedAutoTMMEnabled(const bool enabled) const { - for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents())) + for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents())) torrent->setAutoTMMEnabled(enabled); } @@ -668,14 +668,14 @@ void TransferListWidget::askAddTagsForSelection() void TransferListWidget::editTorrentTrackers() { - const QVector torrents = getSelectedTorrents(); + const QVector torrents = getSelectedTorrents(); QVector commonTrackers; if (!torrents.empty()) { commonTrackers = torrents[0]->trackers(); - for (const BitTorrent::TorrentHandle *torrent : torrents) + for (const BitTorrent::Torrent *torrent : torrents) { QSet trackerSet; @@ -694,7 +694,7 @@ void TransferListWidget::editTorrentTrackers() connect(trackerDialog, &QDialog::accepted, this, [torrents, trackerDialog]() { - for (BitTorrent::TorrentHandle *torrent : torrents) + for (BitTorrent::Torrent *torrent : torrents) torrent->replaceTrackers(trackerDialog->trackers()); }); @@ -737,11 +737,11 @@ QStringList TransferListWidget::askTagsForSelection(const QString &dialogTitle) return tags; } -void TransferListWidget::applyToSelectedTorrents(const std::function &fn) +void TransferListWidget::applyToSelectedTorrents(const std::function &fn) { for (const QModelIndex &index : asConst(selectionModel()->selectedRows())) { - BitTorrent::TorrentHandle *const torrent = m_listModel->torrentHandle(mapToSource(index)); + BitTorrent::Torrent *const torrent = m_listModel->torrentHandle(mapToSource(index)); Q_ASSERT(torrent); fn(torrent); } @@ -753,7 +753,7 @@ void TransferListWidget::renameSelectedTorrent() if ((selectedIndexes.size() != 1) || !selectedIndexes.first().isValid()) return; const QModelIndex mi = m_listModel->index(mapToSource(selectedIndexes.first()).row(), TransferListModel::TR_NAME); - BitTorrent::TorrentHandle *const torrent = m_listModel->torrentHandle(mi); + BitTorrent::Torrent *const torrent = m_listModel->torrentHandle(mi); if (!torrent) return; // Ask for a new Name @@ -775,17 +775,17 @@ void TransferListWidget::setSelectionCategory(const QString &category) void TransferListWidget::addSelectionTag(const QString &tag) { - applyToSelectedTorrents([&tag](BitTorrent::TorrentHandle *const torrent) { torrent->addTag(tag); }); + applyToSelectedTorrents([&tag](BitTorrent::Torrent *const torrent) { torrent->addTag(tag); }); } void TransferListWidget::removeSelectionTag(const QString &tag) { - applyToSelectedTorrents([&tag](BitTorrent::TorrentHandle *const torrent) { torrent->removeTag(tag); }); + applyToSelectedTorrents([&tag](BitTorrent::Torrent *const torrent) { torrent->removeTag(tag); }); } void TransferListWidget::clearSelectionTags() { - applyToSelectedTorrents([](BitTorrent::TorrentHandle *const torrent) { torrent->removeAllTags(); }); + applyToSelectedTorrents([](BitTorrent::Torrent *const torrent) { torrent->removeAllTags(); }); } void TransferListWidget::displayListMenu(const QPoint &) @@ -866,7 +866,7 @@ void TransferListWidget::displayListMenu(const QPoint &) { // Get the file name // Get handle and pause the torrent - const BitTorrent::TorrentHandle *torrent = m_listModel->torrentHandle(mapToSource(index)); + const BitTorrent::Torrent *torrent = m_listModel->torrentHandle(mapToSource(index)); if (!torrent) continue; if (firstCategory.isEmpty() && first) @@ -1100,7 +1100,7 @@ void TransferListWidget::displayListMenu(const QPoint &) void TransferListWidget::currentChanged(const QModelIndex ¤t, const QModelIndex&) { qDebug("CURRENT CHANGED"); - BitTorrent::TorrentHandle *torrent = nullptr; + BitTorrent::Torrent *torrent = nullptr; if (current.isValid()) { torrent = m_listModel->torrentHandle(mapToSource(current)); diff --git a/src/gui/transferlistwidget.h b/src/gui/transferlistwidget.h index 1380a7514..baffb9e06 100644 --- a/src/gui/transferlistwidget.h +++ b/src/gui/transferlistwidget.h @@ -40,7 +40,7 @@ class TransferListSortModel; namespace BitTorrent { class InfoHash; - class TorrentHandle; + class Torrent; } class TransferListWidget final : public QTreeView @@ -96,7 +96,7 @@ protected: QModelIndex mapToSource(const QModelIndex &index) const; QModelIndex mapFromSource(const QModelIndex &index) const; bool loadSettings(); - QVector getSelectedTorrents() const; + QVector getSelectedTorrents() const; protected slots: void torrentDoubleClicked(); @@ -110,7 +110,7 @@ protected slots: void saveSettings(); signals: - void currentTorrentChanged(BitTorrent::TorrentHandle *const torrent); + void currentTorrentChanged(BitTorrent::Torrent *const torrent); private: void wheelEvent(QWheelEvent *event) override; @@ -118,8 +118,8 @@ private: void editTorrentTrackers(); void confirmRemoveAllTagsForSelection(); QStringList askTagsForSelection(const QString &dialogTitle); - void applyToSelectedTorrents(const std::function &fn); - QVector getVisibleTorrents() const; + void applyToSelectedTorrents(const std::function &fn); + QVector getVisibleTorrents() const; TransferListDelegate *m_listDelegate; TransferListModel *m_listModel; diff --git a/src/webui/api/serialize/serialize_torrent.cpp b/src/webui/api/serialize/serialize_torrent.cpp index 6b46ac3b3..59c0039ed 100644 --- a/src/webui/api/serialize/serialize_torrent.cpp +++ b/src/webui/api/serialize/serialize_torrent.cpp @@ -33,7 +33,7 @@ #include #include "base/bittorrent/infohash.h" -#include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/torrent.h" #include "base/bittorrent/trackerentry.h" #include "base/utils/fs.h" @@ -83,7 +83,7 @@ namespace } } -QVariantMap serialize(const BitTorrent::TorrentHandle &torrent) +QVariantMap serialize(const BitTorrent::Torrent &torrent) { QVariantMap ret = { @@ -136,7 +136,7 @@ QVariantMap serialize(const BitTorrent::TorrentHandle &torrent) }; const qreal ratio = torrent.realRatio(); - ret[KEY_TORRENT_RATIO] = (ratio > BitTorrent::TorrentHandle::MAX_RATIO) ? -1 : ratio; + ret[KEY_TORRENT_RATIO] = (ratio > BitTorrent::Torrent::MAX_RATIO) ? -1 : ratio; if (torrent.isPaused() || torrent.isChecking()) { diff --git a/src/webui/api/serialize/serialize_torrent.h b/src/webui/api/serialize/serialize_torrent.h index 022bb0821..1db455af1 100644 --- a/src/webui/api/serialize/serialize_torrent.h +++ b/src/webui/api/serialize/serialize_torrent.h @@ -32,7 +32,7 @@ namespace BitTorrent { - class TorrentHandle; + class Torrent; } // Torrent keys @@ -82,4 +82,4 @@ const char KEY_TORRENT_AUTO_TORRENT_MANAGEMENT[] = "auto_tmm"; const char KEY_TORRENT_TIME_ACTIVE[] = "time_active"; const char KEY_TORRENT_AVAILABILITY[] = "availability"; -QVariantMap serialize(const BitTorrent::TorrentHandle &torrent); +QVariantMap serialize(const BitTorrent::Torrent &torrent); diff --git a/src/webui/api/synccontroller.cpp b/src/webui/api/synccontroller.cpp index f486cf604..b8c24b39c 100644 --- a/src/webui/api/synccontroller.cpp +++ b/src/webui/api/synccontroller.cpp @@ -38,7 +38,7 @@ #include "base/bittorrent/peeraddress.h" #include "base/bittorrent/peerinfo.h" #include "base/bittorrent/session.h" -#include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/torrent.h" #include "base/bittorrent/trackerentry.h" #include "base/global.h" #include "base/net/geoipmanager.h" @@ -458,7 +458,7 @@ void SyncController::maindataAction() QVariantHash torrents; QHash trackers; - for (const BitTorrent::TorrentHandle *torrent : asConst(session->torrents())) + for (const BitTorrent::Torrent *torrent : asConst(session->torrents())) { const BitTorrent::InfoHash torrentHash = torrent->hash(); @@ -542,7 +542,7 @@ void SyncController::torrentPeersAction() auto lastAcceptedResponse = sessionManager()->session()->getData(QLatin1String("syncTorrentPeersLastAcceptedResponse")).toMap(); const QString hash {params()["hash"]}; - const BitTorrent::TorrentHandle *torrent = BitTorrent::Session::instance()->findTorrent(hash); + const BitTorrent::Torrent *torrent = BitTorrent::Session::instance()->findTorrent(hash); if (!torrent) throw APIError(APIErrorType::NotFound); diff --git a/src/webui/api/torrentscontroller.cpp b/src/webui/api/torrentscontroller.cpp index 35f244659..e8149dd5b 100644 --- a/src/webui/api/torrentscontroller.cpp +++ b/src/webui/api/torrentscontroller.cpp @@ -45,7 +45,7 @@ #include "base/bittorrent/peeraddress.h" #include "base/bittorrent/peerinfo.h" #include "base/bittorrent/session.h" -#include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/torrent.h" #include "base/bittorrent/torrentinfo.h" #include "base/bittorrent/trackerentry.h" #include "base/global.h" @@ -118,25 +118,25 @@ namespace { using Utils::String::parseBool; - void applyToTorrents(const QStringList &hashes, const std::function &func) + void applyToTorrents(const QStringList &hashes, const std::function &func) { if ((hashes.size() == 1) && (hashes[0] == QLatin1String("all"))) { - for (BitTorrent::TorrentHandle *const torrent : asConst(BitTorrent::Session::instance()->torrents())) + for (BitTorrent::Torrent *const torrent : asConst(BitTorrent::Session::instance()->torrents())) func(torrent); } else { for (const QString &hash : hashes) { - BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); + BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash); if (torrent) func(torrent); } } } - QJsonArray getStickyTrackers(const BitTorrent::TorrentHandle *const torrent) + QJsonArray getStickyTrackers(const BitTorrent::Torrent *const torrent) { int seedsDHT = 0, seedsPeX = 0, seedsLSD = 0, leechesDHT = 0, leechesPeX = 0, leechesLSD = 0; for (const BitTorrent::PeerInfo &peer : asConst(torrent->peers())) @@ -263,7 +263,7 @@ void TorrentsController::infoAction() const TorrentFilter torrentFilter(filter, (hashes.isEmpty() ? TorrentFilter::AnyHash : hashSet), category); QVariantList torrentList; - for (const BitTorrent::TorrentHandle *torrent : asConst(BitTorrent::Session::instance()->torrents())) + for (const BitTorrent::Torrent *torrent : asConst(BitTorrent::Session::instance()->torrents())) { if (torrentFilter.match(torrent)) torrentList.append(serialize(*torrent)); @@ -372,7 +372,7 @@ void TorrentsController::propertiesAction() requireParams({"hash"}); const QString hash {params()["hash"]}; - BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); + BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash); if (!torrent) throw APIError(APIErrorType::NotFound); @@ -401,7 +401,7 @@ void TorrentsController::propertiesAction() dataDict[KEY_PROP_PEERS] = torrent->leechsCount(); dataDict[KEY_PROP_PEERS_TOTAL] = torrent->totalLeechersCount(); const qreal ratio = torrent->realRatio(); - dataDict[KEY_PROP_RATIO] = ratio > BitTorrent::TorrentHandle::MAX_RATIO ? -1 : ratio; + dataDict[KEY_PROP_RATIO] = ratio > BitTorrent::Torrent::MAX_RATIO ? -1 : ratio; dataDict[KEY_PROP_REANNOUNCE] = torrent->nextAnnounce(); dataDict[KEY_PROP_TOTAL_SIZE] = torrent->totalSize(); dataDict[KEY_PROP_PIECES_NUM] = torrent->piecesCount(); @@ -443,7 +443,7 @@ void TorrentsController::trackersAction() requireParams({"hash"}); const QString hash {params()["hash"]}; - const BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); + const BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash); if (!torrent) throw APIError(APIErrorType::NotFound); @@ -479,7 +479,7 @@ void TorrentsController::webseedsAction() requireParams({"hash"}); const QString hash {params()["hash"]}; - BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); + BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash); if (!torrent) throw APIError(APIErrorType::NotFound); @@ -510,7 +510,7 @@ void TorrentsController::filesAction() requireParams({"hash"}); const QString hash {params()["hash"]}; - const BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); + const BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash); if (!torrent) throw APIError(APIErrorType::NotFound); @@ -556,7 +556,7 @@ void TorrentsController::pieceHashesAction() requireParams({"hash"}); const QString hash {params()["hash"]}; - BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); + BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash); if (!torrent) throw APIError(APIErrorType::NotFound); @@ -578,7 +578,7 @@ void TorrentsController::pieceStatesAction() requireParams({"hash"}); const QString hash {params()["hash"]}; - BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); + BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash); if (!torrent) throw APIError(APIErrorType::NotFound); @@ -684,7 +684,7 @@ void TorrentsController::addTrackersAction() requireParams({"hash", "urls"}); const QString hash = params()["hash"]; - BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); + BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash); if (!torrent) throw APIError(APIErrorType::NotFound); @@ -706,7 +706,7 @@ void TorrentsController::editTrackerAction() const QString origUrl = params()["origUrl"]; const QString newUrl = params()["newUrl"]; - BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); + BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash); if (!torrent) throw APIError(APIErrorType::NotFound); @@ -746,7 +746,7 @@ void TorrentsController::removeTrackersAction() requireParams({"hash", "urls"}); const QString hash = params()["hash"]; - BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); + BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash); if (!torrent) throw APIError(APIErrorType::NotFound); @@ -791,7 +791,7 @@ void TorrentsController::addPeersAction() QJsonObject results; - applyToTorrents(hashes, [peers, peerList, &results](BitTorrent::TorrentHandle *const torrent) + applyToTorrents(hashes, [peers, peerList, &results](BitTorrent::Torrent *const torrent) { const int peersAdded = std::count_if(peerList.cbegin(), peerList.cend(), [torrent](const BitTorrent::PeerAddress &peer) { @@ -813,7 +813,7 @@ void TorrentsController::pauseAction() requireParams({"hashes"}); const QStringList hashes = params()["hashes"].split('|'); - applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) { torrent->pause(); }); + applyToTorrents(hashes, [](BitTorrent::Torrent *const torrent) { torrent->pause(); }); } void TorrentsController::resumeAction() @@ -821,7 +821,7 @@ void TorrentsController::resumeAction() requireParams({"hashes"}); const QStringList hashes = params()["hashes"].split('|'); - applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) { torrent->resume(); }); + applyToTorrents(hashes, [](BitTorrent::Torrent *const torrent) { torrent->resume(); }); } void TorrentsController::filePrioAction() @@ -837,7 +837,7 @@ void TorrentsController::filePrioAction() if (!BitTorrent::isValidDownloadPriority(priority)) throw APIError(APIErrorType::BadParams, tr("Priority is not valid")); - BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); + BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash); if (!torrent) throw APIError(APIErrorType::NotFound); if (!torrent->hasMetadata()) @@ -874,7 +874,7 @@ void TorrentsController::uploadLimitAction() for (const QString &hash : hashes) { int limit = -1; - const BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); + const BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash); if (torrent) limit = torrent->uploadLimit(); map[hash] = limit; @@ -892,7 +892,7 @@ void TorrentsController::downloadLimitAction() for (const QString &hash : hashes) { int limit = -1; - const BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); + const BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash); if (torrent) limit = torrent->downloadLimit(); map[hash] = limit; @@ -910,7 +910,7 @@ void TorrentsController::setUploadLimitAction() limit = -1; const QStringList hashes {params()["hashes"].split('|')}; - applyToTorrents(hashes, [limit](BitTorrent::TorrentHandle *const torrent) { torrent->setUploadLimit(limit); }); + applyToTorrents(hashes, [limit](BitTorrent::Torrent *const torrent) { torrent->setUploadLimit(limit); }); } void TorrentsController::setDownloadLimitAction() @@ -922,7 +922,7 @@ void TorrentsController::setDownloadLimitAction() limit = -1; const QStringList hashes {params()["hashes"].split('|')}; - applyToTorrents(hashes, [limit](BitTorrent::TorrentHandle *const torrent) { torrent->setDownloadLimit(limit); }); + applyToTorrents(hashes, [limit](BitTorrent::Torrent *const torrent) { torrent->setDownloadLimit(limit); }); } void TorrentsController::setShareLimitsAction() @@ -933,7 +933,7 @@ void TorrentsController::setShareLimitsAction() const qlonglong seedingTimeLimit = params()["seedingTimeLimit"].toLongLong(); const QStringList hashes = params()["hashes"].split('|'); - applyToTorrents(hashes, [ratioLimit, seedingTimeLimit](BitTorrent::TorrentHandle *const torrent) + applyToTorrents(hashes, [ratioLimit, seedingTimeLimit](BitTorrent::Torrent *const torrent) { torrent->setRatioLimit(ratioLimit); torrent->setSeedingTimeLimit(seedingTimeLimit); @@ -945,7 +945,7 @@ void TorrentsController::toggleSequentialDownloadAction() requireParams({"hashes"}); const QStringList hashes {params()["hashes"].split('|')}; - applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) { torrent->toggleSequentialDownload(); }); + applyToTorrents(hashes, [](BitTorrent::Torrent *const torrent) { torrent->toggleSequentialDownload(); }); } void TorrentsController::toggleFirstLastPiecePrioAction() @@ -953,7 +953,7 @@ void TorrentsController::toggleFirstLastPiecePrioAction() requireParams({"hashes"}); const QStringList hashes {params()["hashes"].split('|')}; - applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) { torrent->toggleFirstLastPiecePriority(); }); + applyToTorrents(hashes, [](BitTorrent::Torrent *const torrent) { torrent->toggleFirstLastPiecePriority(); }); } void TorrentsController::setSuperSeedingAction() @@ -962,7 +962,7 @@ void TorrentsController::setSuperSeedingAction() const bool value {parseBool(params()["value"]).value_or(false)}; const QStringList hashes {params()["hashes"].split('|')}; - applyToTorrents(hashes, [value](BitTorrent::TorrentHandle *const torrent) { torrent->setSuperSeeding(value); }); + applyToTorrents(hashes, [value](BitTorrent::Torrent *const torrent) { torrent->setSuperSeeding(value); }); } void TorrentsController::setForceStartAction() @@ -971,7 +971,7 @@ void TorrentsController::setForceStartAction() const bool value {parseBool(params()["value"]).value_or(false)}; const QStringList hashes {params()["hashes"].split('|')}; - applyToTorrents(hashes, [value](BitTorrent::TorrentHandle *const torrent) + applyToTorrents(hashes, [value](BitTorrent::Torrent *const torrent) { torrent->resume(value ? BitTorrent::TorrentOperatingMode::Forced : BitTorrent::TorrentOperatingMode::AutoManaged); }); @@ -983,8 +983,8 @@ void TorrentsController::deleteAction() const QStringList hashes {params()["hashes"].split('|')}; const DeleteOption deleteOption = parseBool(params()["deleteFiles"]).value_or(false) - ? TorrentAndFiles : Torrent; - applyToTorrents(hashes, [deleteOption](const BitTorrent::TorrentHandle *torrent) + ? DeleteTorrentAndFiles : DeleteTorrent; + applyToTorrents(hashes, [deleteOption](const BitTorrent::Torrent *torrent) { BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), deleteOption); }); @@ -1052,7 +1052,7 @@ void TorrentsController::setLocationAction() if (!QFileInfo(newLocation).isWritable()) throw APIError(APIErrorType::AccessDenied, tr("Cannot write to directory")); - applyToTorrents(hashes, [newLocation](BitTorrent::TorrentHandle *const torrent) + applyToTorrents(hashes, [newLocation](BitTorrent::Torrent *const torrent) { LogMsg(tr("WebUI Set location: moving \"%1\", from \"%2\" to \"%3\"") .arg(torrent->name(), Utils::Fs::toNativePath(torrent->savePath()), Utils::Fs::toNativePath(newLocation))); @@ -1070,7 +1070,7 @@ void TorrentsController::renameAction() if (name.isEmpty()) throw APIError(APIErrorType::Conflict, tr("Incorrect torrent name")); - BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); + BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash); if (!torrent) throw APIError(APIErrorType::NotFound); @@ -1085,7 +1085,7 @@ void TorrentsController::setAutoManagementAction() const QStringList hashes {params()["hashes"].split('|')}; const bool isEnabled {parseBool(params()["enable"]).value_or(false)}; - applyToTorrents(hashes, [isEnabled](BitTorrent::TorrentHandle *const torrent) + applyToTorrents(hashes, [isEnabled](BitTorrent::Torrent *const torrent) { torrent->setAutoTMMEnabled(isEnabled); }); @@ -1096,7 +1096,7 @@ void TorrentsController::recheckAction() requireParams({"hashes"}); const QStringList hashes {params()["hashes"].split('|')}; - applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) { torrent->forceRecheck(); }); + applyToTorrents(hashes, [](BitTorrent::Torrent *const torrent) { torrent->forceRecheck(); }); } void TorrentsController::reannounceAction() @@ -1104,7 +1104,7 @@ void TorrentsController::reannounceAction() requireParams({"hashes"}); const QStringList hashes {params()["hashes"].split('|')}; - applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) { torrent->forceReannounce(); }); + applyToTorrents(hashes, [](BitTorrent::Torrent *const torrent) { torrent->forceReannounce(); }); } void TorrentsController::setCategoryAction() @@ -1114,7 +1114,7 @@ void TorrentsController::setCategoryAction() const QStringList hashes {params()["hashes"].split('|')}; const QString category {params()["category"]}; - applyToTorrents(hashes, [category](BitTorrent::TorrentHandle *const torrent) + applyToTorrents(hashes, [category](BitTorrent::Torrent *const torrent) { if (!torrent->setCategory(category)) throw APIError(APIErrorType::Conflict, tr("Incorrect category name")); @@ -1188,7 +1188,7 @@ void TorrentsController::addTagsAction() for (const QString &tag : tags) { const QString tagTrimmed {tag.trimmed()}; - applyToTorrents(hashes, [&tagTrimmed](BitTorrent::TorrentHandle *const torrent) + applyToTorrents(hashes, [&tagTrimmed](BitTorrent::Torrent *const torrent) { torrent->addTag(tagTrimmed); }); @@ -1205,7 +1205,7 @@ void TorrentsController::removeTagsAction() for (const QString &tag : tags) { const QString tagTrimmed {tag.trimmed()}; - applyToTorrents(hashes, [&tagTrimmed](BitTorrent::TorrentHandle *const torrent) + applyToTorrents(hashes, [&tagTrimmed](BitTorrent::Torrent *const torrent) { torrent->removeTag(tagTrimmed); }); @@ -1213,7 +1213,7 @@ void TorrentsController::removeTagsAction() if (tags.isEmpty()) { - applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) + applyToTorrents(hashes, [](BitTorrent::Torrent *const torrent) { torrent->removeAllTags(); }); @@ -1252,7 +1252,7 @@ void TorrentsController::renameFileAction() requireParams({"hash", "oldPath", "newPath"}); const QString hash = params()["hash"]; - BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); + BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash); if (!torrent) throw APIError(APIErrorType::NotFound); @@ -1274,7 +1274,7 @@ void TorrentsController::renameFolderAction() requireParams({"hash", "oldPath", "newPath"}); const QString hash = params()["hash"]; - BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); + BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash); if (!torrent) throw APIError(APIErrorType::NotFound);