mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-20 07:27:22 -06:00
Remove redundant suffix from TorrentHandle class
Originally, it was just a wrapper for libtorrent::torrent_handle class, so it mimicked its name. It was then transformed into a more complex aggregate, but the name was retained (just by inertia). Unlike libtorrent::torrent_handle class in whose name "handle" means the pattern used, it does not matter for qBittorrent classes and just eats up space in the source code.
This commit is contained in:
committed by
sledgehammer999
parent
0cbd15890a
commit
1880082017
@@ -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
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
#include "torrenthandle.h"
|
||||
#include "torrent.h"
|
||||
#include "torrentcontentlayout.h"
|
||||
|
||||
namespace BitTorrent
|
||||
@@ -58,7 +58,7 @@ namespace BitTorrent
|
||||
std::optional<bool> 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;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -30,14 +30,14 @@
|
||||
|
||||
#include <QBitArray>
|
||||
|
||||
#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();
|
||||
|
||||
@@ -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 = {};
|
||||
|
||||
@@ -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<InfoHash, TorrentHandleImpl *> torrents {m_torrents};
|
||||
for (TorrentHandleImpl *const torrent : torrents)
|
||||
const QHash<InfoHash, TorrentImpl *> 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<InfoHash> &hashes)
|
||||
{
|
||||
using ElementType = std::pair<int, TorrentHandleImpl *>;
|
||||
using ElementType = std::pair<int, TorrentImpl *>;
|
||||
std::priority_queue<ElementType
|
||||
, std::vector<ElementType>
|
||||
, std::greater<ElementType>> torrentQueue;
|
||||
@@ -1895,7 +1895,7 @@ void Session::increaseTorrentsQueuePos(const QVector<InfoHash> &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<InfoHash> &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<InfoHash> &hashes)
|
||||
|
||||
void Session::decreaseTorrentsQueuePos(const QVector<InfoHash> &hashes)
|
||||
{
|
||||
using ElementType = std::pair<int, TorrentHandleImpl *>;
|
||||
using ElementType = std::pair<int, TorrentImpl *>;
|
||||
std::priority_queue<ElementType> 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<InfoHash> &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<InfoHash> &hashes)
|
||||
|
||||
void Session::topTorrentsQueuePos(const QVector<InfoHash> &hashes)
|
||||
{
|
||||
using ElementType = std::pair<int, TorrentHandleImpl *>;
|
||||
using ElementType = std::pair<int, TorrentImpl *>;
|
||||
std::priority_queue<ElementType> 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<InfoHash> &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<InfoHash> &hashes)
|
||||
|
||||
void Session::bottomTorrentsQueuePos(const QVector<InfoHash> &hashes)
|
||||
{
|
||||
using ElementType = std::pair<int, TorrentHandleImpl *>;
|
||||
using ElementType = std::pair<int, TorrentImpl *>;
|
||||
std::priority_queue<ElementType
|
||||
, std::vector<ElementType>
|
||||
, std::greater<ElementType>> torrentQueue;
|
||||
@@ -1972,7 +1972,7 @@ void Session::bottomTorrentsQueuePos(const QVector<InfoHash> &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<InfoHash> &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<InfoHash> &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<TorrentHandle *> Session::torrents() const
|
||||
QVector<Torrent *> Session::torrents() const
|
||||
{
|
||||
QVector<TorrentHandle *> result;
|
||||
QVector<Torrent *> 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<MagnetUri, TorrentInfo> &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<int, QString> 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<LTUnderlyingType<lt::queue_position_t>>(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<TrackerEntry> &newTrackers)
|
||||
void Session::handleTorrentTrackersAdded(TorrentImpl *const torrent, const QVector<TrackerEntry> &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<TrackerEntry> &deletedTrackers)
|
||||
void Session::handleTorrentTrackersRemoved(TorrentImpl *const torrent, const QVector<TrackerEntry> &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<QUrl> &newUrlSeeds)
|
||||
void Session::handleTorrentUrlSeedsAdded(TorrentImpl *const torrent, const QVector<QUrl> &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<QUrl> &urlSeeds)
|
||||
void Session::handleTorrentUrlSeedsRemoved(TorrentImpl *const torrent, const QVector<QUrl> &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<lt::entry> &data)
|
||||
void Session::handleTorrentResumeDataReady(TorrentImpl *const torrent, const std::shared_ptr<lt::entry> &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<const lt::torrent_alert*>(a)->handle.info_hash());
|
||||
TorrentImpl *const torrent = m_torrents.value(static_cast<const lt::torrent_alert*>(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<TorrentHandle *> updatedTorrents;
|
||||
QVector<Torrent *> 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;
|
||||
|
||||
@@ -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<TorrentHandle *> torrents() const;
|
||||
Torrent *findTorrent(const InfoHash &hash) const;
|
||||
QVector<Torrent *> 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<InfoHash> &hashes);
|
||||
void bottomTorrentsQueuePos(const QVector<InfoHash> &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<TrackerEntry> &newTrackers);
|
||||
void handleTorrentTrackersRemoved(TorrentHandleImpl *const torrent, const QVector<TrackerEntry> &deletedTrackers);
|
||||
void handleTorrentTrackersChanged(TorrentHandleImpl *const torrent);
|
||||
void handleTorrentUrlSeedsAdded(TorrentHandleImpl *const torrent, const QVector<QUrl> &newUrlSeeds);
|
||||
void handleTorrentUrlSeedsRemoved(TorrentHandleImpl *const torrent, const QVector<QUrl> &urlSeeds);
|
||||
void handleTorrentResumeDataReady(TorrentHandleImpl *const torrent, const std::shared_ptr<lt::entry> &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);
|
||||
// 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<TrackerEntry> &newTrackers);
|
||||
void handleTorrentTrackersRemoved(TorrentImpl *const torrent, const QVector<TrackerEntry> &deletedTrackers);
|
||||
void handleTorrentTrackersChanged(TorrentImpl *const torrent);
|
||||
void handleTorrentUrlSeedsAdded(TorrentImpl *const torrent, const QVector<QUrl> &newUrlSeeds);
|
||||
void handleTorrentUrlSeedsRemoved(TorrentImpl *const torrent, const QVector<QUrl> &urlSeeds);
|
||||
void handleTorrentResumeDataReady(TorrentImpl *const torrent, const std::shared_ptr<lt::entry> &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(TorrentHandleImpl *torrent, const QString &newPath, MoveStorageMode mode);
|
||||
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<TorrentHandle *> &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<TrackerEntry> &trackers);
|
||||
void trackersChanged(TorrentHandle *torrent);
|
||||
void trackersRemoved(TorrentHandle *torrent, const QVector<TrackerEntry> &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<Torrent *> &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<TrackerEntry> &trackers);
|
||||
void trackersChanged(Torrent *torrent);
|
||||
void trackersRemoved(Torrent *torrent, const QVector<TrackerEntry> &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<MagnetUri, TorrentInfo> &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<InfoHash> m_downloadedMetadata;
|
||||
|
||||
QHash<InfoHash, TorrentHandleImpl *> m_torrents;
|
||||
QHash<InfoHash, TorrentImpl *> m_torrents;
|
||||
QHash<InfoHash, LoadTorrentParams> m_loadingTorrents;
|
||||
QHash<QString, AddTorrentParams> m_downloadedTorrents;
|
||||
QHash<InfoHash, RemovingTorrentData> m_removingTorrents;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
* exception statement from your version.
|
||||
*/
|
||||
|
||||
#include "torrenthandle.h"
|
||||
#include "torrent.h"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
@@ -40,33 +40,33 @@ namespace BitTorrent
|
||||
return ::qHash(static_cast<std::underlying_type_t<TorrentState>>(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());
|
||||
}
|
||||
@@ -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;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
namespace BitTorrent
|
||||
{
|
||||
class TorrentHandle;
|
||||
class Torrent;
|
||||
}
|
||||
|
||||
using InfoHashSet = QSet<BitTorrent::InfoHash>;
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user