Browse Source

Change to `lt` namespace

Quoting from libtorrent doc:
> In the future, libtorrent will be the alias and lt the namespace name.
adaptive-webui-19844
Chocobo1 6 years ago
parent
commit
3955eef50d
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 8
      src/base/bittorrent/infohash.cpp
  2. 10
      src/base/bittorrent/infohash.h
  3. 4
      src/base/bittorrent/magneturi.cpp
  4. 4
      src/base/bittorrent/magneturi.h
  5. 4
      src/base/bittorrent/peerinfo.h
  6. 4
      src/base/bittorrent/private/filterparserthread.h
  7. 2
      src/base/bittorrent/private/portforwarderimpl.cpp
  8. 2
      src/base/bittorrent/private/portforwarderimpl.h
  9. 14
      src/base/bittorrent/session.cpp
  10. 54
      src/base/bittorrent/session.h
  11. 44
      src/base/bittorrent/torrenthandle.cpp
  12. 48
      src/base/bittorrent/torrenthandle.h
  13. 2
      src/base/bittorrent/torrentinfo.cpp
  14. 8
      src/base/bittorrent/torrentinfo.h
  15. 24
      src/base/bittorrent/tracker.cpp
  16. 9
      src/base/bittorrent/tracker.h
  17. 6
      src/base/bittorrent/trackerentry.cpp
  18. 6
      src/base/bittorrent/trackerentry.h

8
src/base/bittorrent/infohash.cpp

@ -38,7 +38,7 @@ InfoHash::InfoHash() @@ -38,7 +38,7 @@ InfoHash::InfoHash()
{
}
InfoHash::InfoHash(const libtorrent::sha1_hash &nativeHash)
InfoHash::InfoHash(const lt::sha1_hash &nativeHash)
: m_valid(true)
, m_nativeHash(nativeHash)
{
@ -66,7 +66,7 @@ bool InfoHash::isValid() const @@ -66,7 +66,7 @@ bool InfoHash::isValid() const
return m_valid;
}
InfoHash::operator libtorrent::sha1_hash() const
InfoHash::operator lt::sha1_hash() const
{
return m_nativeHash;
}
@ -78,8 +78,8 @@ InfoHash::operator QString() const @@ -78,8 +78,8 @@ InfoHash::operator QString() const
bool BitTorrent::operator==(const InfoHash &left, const InfoHash &right)
{
return (static_cast<libtorrent::sha1_hash>(left)
== static_cast<libtorrent::sha1_hash>(right));
return (static_cast<lt::sha1_hash>(left)
== static_cast<lt::sha1_hash>(right));
}
bool BitTorrent::operator!=(const InfoHash &left, const InfoHash &right)

10
src/base/bittorrent/infohash.h

@ -40,27 +40,27 @@ namespace BitTorrent @@ -40,27 +40,27 @@ namespace BitTorrent
{
public:
InfoHash();
InfoHash(const libtorrent::sha1_hash &nativeHash);
InfoHash(const lt::sha1_hash &nativeHash);
InfoHash(const QString &hashString);
InfoHash(const InfoHash &other) = default;
static constexpr int length()
{
#if (LIBTORRENT_VERSION_NUM < 10200)
return libtorrent::sha1_hash::size;
return lt::sha1_hash::size;
#else
return libtorrent::sha1_hash::size();
return lt::sha1_hash::size();
#endif
}
bool isValid() const;
operator libtorrent::sha1_hash() const;
operator lt::sha1_hash() const;
operator QString() const;
private:
bool m_valid;
libtorrent::sha1_hash m_nativeHash;
lt::sha1_hash m_nativeHash;
QString m_hashString;
};

4
src/base/bittorrent/magneturi.cpp

@ -76,7 +76,7 @@ MagnetUri::MagnetUri(const QString &source) @@ -76,7 +76,7 @@ MagnetUri::MagnetUri(const QString &source)
m_name = QString::fromStdString(m_addTorrentParams.name);
for (const std::string &tracker : m_addTorrentParams.trackers)
m_trackers.append(libtorrent::announce_entry {tracker});
m_trackers.append(lt::announce_entry {tracker});
for (const std::string &urlSeed : m_addTorrentParams.url_seeds)
m_urlSeeds.append(QUrl(QString::fromStdString(urlSeed)));
@ -112,7 +112,7 @@ QString MagnetUri::url() const @@ -112,7 +112,7 @@ QString MagnetUri::url() const
return m_url;
}
libtorrent::add_torrent_params MagnetUri::addTorrentParams() const
lt::add_torrent_params MagnetUri::addTorrentParams() const
{
return m_addTorrentParams;
}

4
src/base/bittorrent/magneturi.h

@ -52,7 +52,7 @@ namespace BitTorrent @@ -52,7 +52,7 @@ namespace BitTorrent
QList<QUrl> urlSeeds() const;
QString url() const;
libtorrent::add_torrent_params addTorrentParams() const;
lt::add_torrent_params addTorrentParams() const;
private:
bool m_valid;
@ -61,7 +61,7 @@ namespace BitTorrent @@ -61,7 +61,7 @@ namespace BitTorrent
QString m_name;
QList<TrackerEntry> m_trackers;
QList<QUrl> m_urlSeeds;
libtorrent::add_torrent_params m_addTorrentParams;
lt::add_torrent_params m_addTorrentParams;
};
}

4
src/base/bittorrent/peerinfo.h

@ -53,7 +53,7 @@ namespace BitTorrent @@ -53,7 +53,7 @@ namespace BitTorrent
Q_DECLARE_TR_FUNCTIONS(PeerInfo)
public:
PeerInfo(const TorrentHandle *torrent, const libtorrent::peer_info &nativeInfo);
PeerInfo(const TorrentHandle *torrent, const lt::peer_info &nativeInfo);
bool fromDHT() const;
bool fromPeX() const;
@ -105,7 +105,7 @@ namespace BitTorrent @@ -105,7 +105,7 @@ namespace BitTorrent
void calcRelevance(const TorrentHandle *torrent);
void determineFlags();
libtorrent::peer_info m_nativeInfo;
lt::peer_info m_nativeInfo;
qreal m_relevance;
QString m_flags;
QString m_flagsDescription;

4
src/base/bittorrent/private/filterparserthread.h

@ -43,7 +43,7 @@ public: @@ -43,7 +43,7 @@ public:
FilterParserThread(QObject *parent = nullptr);
~FilterParserThread();
void processFilterFile(const QString &filePath);
libtorrent::ip_filter IPfilter();
lt::ip_filter IPfilter();
signals:
void IPFilterParsed(int ruleCount);
@ -62,7 +62,7 @@ private: @@ -62,7 +62,7 @@ private:
bool m_abort;
QString m_filePath;
libtorrent::ip_filter m_filter;
lt::ip_filter m_filter;
};
#endif // BITTORRENT_FILTERPARSERTHREAD_H

2
src/base/bittorrent/private/portforwarderimpl.cpp

@ -37,7 +37,7 @@ @@ -37,7 +37,7 @@
const QString KEY_ENABLED = QStringLiteral("Network/PortForwardingEnabled");
PortForwarderImpl::PortForwarderImpl(libtorrent::session *provider, QObject *parent)
PortForwarderImpl::PortForwarderImpl(lt::session *provider, QObject *parent)
: Net::PortForwarder {parent}
, m_active {SettingsStorage::instance()->loadValue(KEY_ENABLED, true).toBool()}
, m_provider {provider}

2
src/base/bittorrent/private/portforwarderimpl.h

@ -60,6 +60,6 @@ private: @@ -60,6 +60,6 @@ private:
void stop();
bool m_active;
libtorrent::session *m_provider;
lt::session *m_provider;
QHash<quint16, std::vector<LTPortMapping>> m_mappedPorts;
};

14
src/base/bittorrent/session.cpp

@ -945,12 +945,12 @@ Session::~Session() @@ -945,12 +945,12 @@ Session::~Session()
saveResumeData();
// We must delete FilterParserThread
// before we delete libtorrent::session
// before we delete lt::session
if (m_filterParser)
delete m_filterParser;
// We must delete PortForwarderImpl before
// we delete libtorrent::session
// we delete lt::session
delete Net::PortForwarder::instance();
qDebug("Deleting the session");
@ -1043,7 +1043,7 @@ void Session::adjustLimits(lt::settings_pack &settingsPack) @@ -1043,7 +1043,7 @@ void Session::adjustLimits(lt::settings_pack &settingsPack)
, maxActive > -1 ? maxActive + m_extraLimit : maxActive);
}
void Session::applyBandwidthLimits(libtorrent::settings_pack &settingsPack)
void Session::applyBandwidthLimits(lt::settings_pack &settingsPack)
{
const bool altSpeedLimitEnabled = isAltGlobalSpeedLimitEnabled();
settingsPack.set_int(lt::settings_pack::download_rate_limit, altSpeedLimitEnabled ? altGlobalDownloadSpeedLimit() : globalDownloadSpeedLimit());
@ -1128,7 +1128,7 @@ void Session::initMetrics() @@ -1128,7 +1128,7 @@ void Session::initMetrics()
Q_ASSERT(m_metricIndices.disk.diskJobTime >= 0);
}
void Session::configure(libtorrent::settings_pack &settingsPack)
void Session::configure(lt::settings_pack &settingsPack)
{
Logger *const logger = Logger::instance();
@ -3449,12 +3449,12 @@ void Session::handleTorrentFinished(TorrentHandle *const torrent) @@ -3449,12 +3449,12 @@ void Session::handleTorrentFinished(TorrentHandle *const torrent)
emit allTorrentsFinished();
}
void Session::handleTorrentResumeDataReady(TorrentHandle *const torrent, const libtorrent::entry &data)
void Session::handleTorrentResumeDataReady(TorrentHandle *const torrent, const lt::entry &data)
{
--m_numResumeData;
// Separated thread is used for the blocking IO which results in slow processing of many torrents.
// Encoding data in parallel while doing IO saves time. Copying libtorrent::entry objects around
// Encoding data in parallel while doing IO saves time. Copying lt::entry objects around
// isn't cheap too.
QByteArray out;
@ -3531,7 +3531,7 @@ void Session::enableIPFilter() @@ -3531,7 +3531,7 @@ void Session::enableIPFilter()
{
qDebug("Enabling IPFilter");
// 1. Parse the IP filter
// 2. In the slot add the manually banned IPs to the provided libtorrent::ip_filter
// 2. In the slot add the manually banned IPs to the provided lt::ip_filter
// 3. Set the ip_filter in one go so there isn't a time window where there isn't an ip_filter
// set between clearing the old one and setting the new one.
if (!m_filterParser) {

54
src/base/bittorrent/session.h

@ -441,7 +441,7 @@ namespace BitTorrent @@ -441,7 +441,7 @@ namespace BitTorrent
void handleTorrentTrackersChanged(TorrentHandle *const torrent);
void handleTorrentUrlSeedsAdded(TorrentHandle *const torrent, const QList<QUrl> &newUrlSeeds);
void handleTorrentUrlSeedsRemoved(TorrentHandle *const torrent, const QList<QUrl> &urlSeeds);
void handleTorrentResumeDataReady(TorrentHandle *const torrent, const libtorrent::entry &data);
void handleTorrentResumeDataReady(TorrentHandle *const torrent, const lt::entry &data);
void handleTorrentResumeDataFailed(TorrentHandle *const torrent);
void handleTorrentTrackerReply(TorrentHandle *const torrent, const QString &trackerUrl);
void handleTorrentTrackerWarning(TorrentHandle *const torrent, const QString &trackerUrl);
@ -518,14 +518,14 @@ namespace BitTorrent @@ -518,14 +518,14 @@ namespace BitTorrent
// Session configuration
Q_INVOKABLE void configure();
void configure(libtorrent::settings_pack &settingsPack);
void configure(lt::settings_pack &settingsPack);
void configurePeerClasses();
void adjustLimits(libtorrent::settings_pack &settingsPack);
void applyBandwidthLimits(libtorrent::settings_pack &settingsPack);
void adjustLimits(lt::settings_pack &settingsPack);
void applyBandwidthLimits(lt::settings_pack &settingsPack);
void initMetrics();
void adjustLimits();
void applyBandwidthLimits();
void processBannedIPs(libtorrent::ip_filter &filter);
void processBannedIPs(lt::ip_filter &filter);
const QStringList getListeningIPs();
void configureListeningInterface();
void enableTracker(bool enable);
@ -543,35 +543,35 @@ namespace BitTorrent @@ -543,35 +543,35 @@ namespace BitTorrent
void exportTorrentFile(TorrentHandle *const torrent, TorrentExportFolder folder = TorrentExportFolder::Regular);
void saveTorrentResumeData(TorrentHandle *const torrent);
void handleAlert(const libtorrent::alert *a);
void dispatchTorrentAlert(const libtorrent::alert *a);
void handleAddTorrentAlert(const libtorrent::add_torrent_alert *p);
void handleStateUpdateAlert(const libtorrent::state_update_alert *p);
void handleMetadataReceivedAlert(const libtorrent::metadata_received_alert *p);
void handleFileErrorAlert(const libtorrent::file_error_alert *p);
void handleTorrentRemovedAlert(const libtorrent::torrent_removed_alert *p);
void handleTorrentDeletedAlert(const libtorrent::torrent_deleted_alert *p);
void handleTorrentDeleteFailedAlert(const libtorrent::torrent_delete_failed_alert *p);
void handlePortmapWarningAlert(const libtorrent::portmap_error_alert *p);
void handlePortmapAlert(const libtorrent::portmap_alert *p);
void handlePeerBlockedAlert(const libtorrent::peer_blocked_alert *p);
void handlePeerBanAlert(const libtorrent::peer_ban_alert *p);
void handleUrlSeedAlert(const libtorrent::url_seed_alert *p);
void handleListenSucceededAlert(const libtorrent::listen_succeeded_alert *p);
void handleListenFailedAlert(const libtorrent::listen_failed_alert *p);
void handleExternalIPAlert(const libtorrent::external_ip_alert *p);
void handleSessionStatsAlert(const libtorrent::session_stats_alert *p);
void createTorrentHandle(const libtorrent::torrent_handle &nativeHandle);
void handleAlert(const lt::alert *a);
void dispatchTorrentAlert(const lt::alert *a);
void handleAddTorrentAlert(const lt::add_torrent_alert *p);
void handleStateUpdateAlert(const lt::state_update_alert *p);
void handleMetadataReceivedAlert(const lt::metadata_received_alert *p);
void handleFileErrorAlert(const lt::file_error_alert *p);
void handleTorrentRemovedAlert(const lt::torrent_removed_alert *p);
void handleTorrentDeletedAlert(const lt::torrent_deleted_alert *p);
void handleTorrentDeleteFailedAlert(const lt::torrent_delete_failed_alert *p);
void handlePortmapWarningAlert(const lt::portmap_error_alert *p);
void handlePortmapAlert(const lt::portmap_alert *p);
void handlePeerBlockedAlert(const lt::peer_blocked_alert *p);
void handlePeerBanAlert(const lt::peer_ban_alert *p);
void handleUrlSeedAlert(const lt::url_seed_alert *p);
void handleListenSucceededAlert(const lt::listen_succeeded_alert *p);
void handleListenFailedAlert(const lt::listen_failed_alert *p);
void handleExternalIPAlert(const lt::external_ip_alert *p);
void handleSessionStatsAlert(const lt::session_stats_alert *p);
void createTorrentHandle(const lt::torrent_handle &nativeHandle);
void saveResumeData();
void saveTorrentsQueue();
void removeTorrentsQueue();
void getPendingAlerts(std::vector<libtorrent::alert *> &out, ulong time = 0);
void getPendingAlerts(std::vector<lt::alert *> &out, ulong time = 0);
// BitTorrent
libtorrent::session *m_nativeSession;
lt::session *m_nativeSession;
bool m_deferredConfigureScheduled;
bool m_IPFilteringChanged;

44
src/base/bittorrent/torrenthandle.cpp

@ -165,7 +165,7 @@ const int TorrentHandle::NO_SEEDING_TIME_LIMIT = -1; @@ -165,7 +165,7 @@ const int TorrentHandle::NO_SEEDING_TIME_LIMIT = -1;
const qreal TorrentHandle::MAX_RATIO = 9999.;
const int TorrentHandle::MAX_SEEDING_TIME = 525600;
TorrentHandle::TorrentHandle(Session *session, const libtorrent::torrent_handle &nativeHandle,
TorrentHandle::TorrentHandle(Session *session, const lt::torrent_handle &nativeHandle,
const CreateTorrentParams &params)
: QObject(session)
, m_session(session)
@ -1509,7 +1509,7 @@ void TorrentHandle::handleStateUpdate(const lt::torrent_status &nativeStatus) @@ -1509,7 +1509,7 @@ void TorrentHandle::handleStateUpdate(const lt::torrent_status &nativeStatus)
updateStatus(nativeStatus);
}
void TorrentHandle::handleStorageMovedAlert(const libtorrent::storage_moved_alert *p)
void TorrentHandle::handleStorageMovedAlert(const lt::storage_moved_alert *p)
{
if (!isMoveInProgress()) {
qWarning() << "Unexpected " << Q_FUNC_INFO << " call.";
@ -1550,7 +1550,7 @@ void TorrentHandle::handleStorageMovedAlert(const libtorrent::storage_moved_aler @@ -1550,7 +1550,7 @@ void TorrentHandle::handleStorageMovedAlert(const libtorrent::storage_moved_aler
m_moveFinishedTriggers.takeFirst()();
}
void TorrentHandle::handleStorageMovedFailedAlert(const libtorrent::storage_moved_failed_alert *p)
void TorrentHandle::handleStorageMovedFailedAlert(const lt::storage_moved_failed_alert *p)
{
if (!isMoveInProgress()) {
qWarning() << "Unexpected " << Q_FUNC_INFO << " call.";
@ -1572,7 +1572,7 @@ void TorrentHandle::handleStorageMovedFailedAlert(const libtorrent::storage_move @@ -1572,7 +1572,7 @@ void TorrentHandle::handleStorageMovedFailedAlert(const libtorrent::storage_move
m_moveFinishedTriggers.takeFirst()();
}
void TorrentHandle::handleTrackerReplyAlert(const libtorrent::tracker_reply_alert *p)
void TorrentHandle::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);
@ -1583,7 +1583,7 @@ void TorrentHandle::handleTrackerReplyAlert(const libtorrent::tracker_reply_aler @@ -1583,7 +1583,7 @@ void TorrentHandle::handleTrackerReplyAlert(const libtorrent::tracker_reply_aler
m_session->handleTorrentTrackerReply(this, trackerUrl);
}
void TorrentHandle::handleTrackerWarningAlert(const libtorrent::tracker_warning_alert *p)
void TorrentHandle::handleTrackerWarningAlert(const lt::tracker_warning_alert *p)
{
const QString trackerUrl = p->tracker_url();
const QString message = p->warning_message();
@ -1594,7 +1594,7 @@ void TorrentHandle::handleTrackerWarningAlert(const libtorrent::tracker_warning_ @@ -1594,7 +1594,7 @@ void TorrentHandle::handleTrackerWarningAlert(const libtorrent::tracker_warning_
m_session->handleTorrentTrackerWarning(this, trackerUrl);
}
void TorrentHandle::handleTrackerErrorAlert(const libtorrent::tracker_error_alert *p)
void TorrentHandle::handleTrackerErrorAlert(const lt::tracker_error_alert *p)
{
const QString trackerUrl = p->tracker_url();
const QString message = p->error_message();
@ -1604,7 +1604,7 @@ void TorrentHandle::handleTrackerErrorAlert(const libtorrent::tracker_error_aler @@ -1604,7 +1604,7 @@ void TorrentHandle::handleTrackerErrorAlert(const libtorrent::tracker_error_aler
m_session->handleTorrentTrackerError(this, trackerUrl);
}
void TorrentHandle::handleTorrentCheckedAlert(const libtorrent::torrent_checked_alert *p)
void TorrentHandle::handleTorrentCheckedAlert(const lt::torrent_checked_alert *p)
{
Q_UNUSED(p);
qDebug("\"%s\" have just finished checking", qUtf8Printable(name()));
@ -1638,7 +1638,7 @@ void TorrentHandle::handleTorrentCheckedAlert(const libtorrent::torrent_checked_ @@ -1638,7 +1638,7 @@ void TorrentHandle::handleTorrentCheckedAlert(const libtorrent::torrent_checked_
m_session->handleTorrentChecked(this);
}
void TorrentHandle::handleTorrentFinishedAlert(const libtorrent::torrent_finished_alert *p)
void TorrentHandle::handleTorrentFinishedAlert(const lt::torrent_finished_alert *p)
{
Q_UNUSED(p);
qDebug("Got a torrent finished alert for \"%s\"", qUtf8Printable(name()));
@ -1665,7 +1665,7 @@ void TorrentHandle::handleTorrentFinishedAlert(const libtorrent::torrent_finishe @@ -1665,7 +1665,7 @@ void TorrentHandle::handleTorrentFinishedAlert(const libtorrent::torrent_finishe
}
}
void TorrentHandle::handleTorrentPausedAlert(const libtorrent::torrent_paused_alert *p)
void TorrentHandle::handleTorrentPausedAlert(const lt::torrent_paused_alert *p)
{
Q_UNUSED(p);
@ -1676,7 +1676,7 @@ void TorrentHandle::handleTorrentPausedAlert(const libtorrent::torrent_paused_al @@ -1676,7 +1676,7 @@ void TorrentHandle::handleTorrentPausedAlert(const libtorrent::torrent_paused_al
}
}
void TorrentHandle::handleTorrentResumedAlert(const libtorrent::torrent_resumed_alert *p)
void TorrentHandle::handleTorrentResumedAlert(const lt::torrent_resumed_alert *p)
{
Q_UNUSED(p);
@ -1686,12 +1686,12 @@ void TorrentHandle::handleTorrentResumedAlert(const libtorrent::torrent_resumed_ @@ -1686,12 +1686,12 @@ void TorrentHandle::handleTorrentResumedAlert(const libtorrent::torrent_resumed_
m_startupState = Started;
}
void TorrentHandle::handleSaveResumeDataAlert(const libtorrent::save_resume_data_alert *p)
void TorrentHandle::handleSaveResumeDataAlert(const lt::save_resume_data_alert *p)
{
const bool useDummyResumeData = !(p && p->resume_data);
libtorrent::entry dummyEntry;
lt::entry dummyEntry;
libtorrent::entry &resumeData = useDummyResumeData ? dummyEntry : *(p->resume_data);
lt::entry &resumeData = useDummyResumeData ? dummyEntry : *(p->resume_data);
if (useDummyResumeData) {
resumeData["qBt-magnetUri"] = toMagnetUri().toStdString();
resumeData["qBt-paused"] = isPaused();
@ -1720,7 +1720,7 @@ void TorrentHandle::handleSaveResumeDataAlert(const libtorrent::save_resume_data @@ -1720,7 +1720,7 @@ void TorrentHandle::handleSaveResumeDataAlert(const libtorrent::save_resume_data
m_session->handleTorrentResumeDataReady(this, resumeData);
}
void TorrentHandle::handleSaveResumeDataFailedAlert(const libtorrent::save_resume_data_failed_alert *p)
void TorrentHandle::handleSaveResumeDataFailedAlert(const lt::save_resume_data_failed_alert *p)
{
// if torrent has no metadata we should save dummy fastresume data
// containing Magnet URI and qBittorrent own resume data only
@ -1730,7 +1730,7 @@ void TorrentHandle::handleSaveResumeDataFailedAlert(const libtorrent::save_resum @@ -1730,7 +1730,7 @@ void TorrentHandle::handleSaveResumeDataFailedAlert(const libtorrent::save_resum
m_session->handleTorrentResumeDataFailed(this);
}
void TorrentHandle::handleFastResumeRejectedAlert(const libtorrent::fastresume_rejected_alert *p)
void TorrentHandle::handleFastResumeRejectedAlert(const lt::fastresume_rejected_alert *p)
{
if (p->error.value() == lt::errors::mismatching_file_size) {
// Mismatching file size (files were probably moved)
@ -1743,7 +1743,7 @@ void TorrentHandle::handleFastResumeRejectedAlert(const libtorrent::fastresume_r @@ -1743,7 +1743,7 @@ void TorrentHandle::handleFastResumeRejectedAlert(const libtorrent::fastresume_r
}
}
void TorrentHandle::handleFileRenamedAlert(const libtorrent::file_renamed_alert *p)
void TorrentHandle::handleFileRenamedAlert(const lt::file_renamed_alert *p)
{
const QString newName = Utils::Fs::fromNativePath(p->new_name());
@ -1773,7 +1773,7 @@ void TorrentHandle::handleFileRenamedAlert(const libtorrent::file_renamed_alert @@ -1773,7 +1773,7 @@ void TorrentHandle::handleFileRenamedAlert(const libtorrent::file_renamed_alert
m_moveFinishedTriggers.takeFirst()();
}
void TorrentHandle::handleFileRenameFailedAlert(const libtorrent::file_rename_failed_alert *p)
void TorrentHandle::handleFileRenameFailedAlert(const lt::file_rename_failed_alert *p)
{
Q_UNUSED(p);
@ -1782,7 +1782,7 @@ void TorrentHandle::handleFileRenameFailedAlert(const libtorrent::file_rename_fa @@ -1782,7 +1782,7 @@ void TorrentHandle::handleFileRenameFailedAlert(const libtorrent::file_rename_fa
m_moveFinishedTriggers.takeFirst()();
}
void TorrentHandle::handleFileCompletedAlert(const libtorrent::file_completed_alert *p)
void TorrentHandle::handleFileCompletedAlert(const lt::file_completed_alert *p)
{
// We don't really need to call updateStatus() in this place.
// All we need to do is make sure we have a valid instance of the TorrentInfo object.
@ -1800,7 +1800,7 @@ void TorrentHandle::handleFileCompletedAlert(const libtorrent::file_completed_al @@ -1800,7 +1800,7 @@ void TorrentHandle::handleFileCompletedAlert(const libtorrent::file_completed_al
}
}
void TorrentHandle::handleStatsAlert(const libtorrent::stats_alert *p)
void TorrentHandle::handleStatsAlert(const lt::stats_alert *p)
{
Q_ASSERT(p->interval >= 1000);
const SpeedSample transferred(p->transferred[lt::stats_alert::download_payload] * 1000LL / p->interval,
@ -1854,7 +1854,7 @@ void TorrentHandle::handleAppendExtensionToggled() @@ -1854,7 +1854,7 @@ void TorrentHandle::handleAppendExtensionToggled()
manageIncompleteFiles();
}
void TorrentHandle::handleAlert(const libtorrent::alert *a)
void TorrentHandle::handleAlert(const lt::alert *a)
{
switch (a->type()) {
case lt::stats_alert::alert_type:
@ -1965,7 +1965,7 @@ void TorrentHandle::adjustActualSavePath_impl() @@ -1965,7 +1965,7 @@ void TorrentHandle::adjustActualSavePath_impl()
moveStorage(Utils::Fs::toNativePath(path), true);
}
libtorrent::torrent_handle TorrentHandle::nativeHandle() const
lt::torrent_handle TorrentHandle::nativeHandle() const
{
return m_nativeHandle;
}
@ -1992,7 +1992,7 @@ void TorrentHandle::updateStatus() @@ -1992,7 +1992,7 @@ void TorrentHandle::updateStatus()
updateStatus(m_nativeHandle.status());
}
void TorrentHandle::updateStatus(const libtorrent::torrent_status &nativeStatus)
void TorrentHandle::updateStatus(const lt::torrent_status &nativeStatus)
{
m_nativeStatus = nativeStatus;

48
src/base/bittorrent/torrenthandle.h

@ -142,7 +142,7 @@ namespace BitTorrent @@ -142,7 +142,7 @@ namespace BitTorrent
static const qreal MAX_RATIO;
static const int MAX_SEEDING_TIME;
TorrentHandle(Session *session, const libtorrent::torrent_handle &nativeHandle,
TorrentHandle(Session *session, const lt::torrent_handle &nativeHandle,
const CreateTorrentParams &params);
~TorrentHandle();
@ -334,10 +334,10 @@ namespace BitTorrent @@ -334,10 +334,10 @@ namespace BitTorrent
bool needSaveResumeData() const;
// Session interface
libtorrent::torrent_handle nativeHandle() const;
lt::torrent_handle nativeHandle() const;
void handleAlert(const libtorrent::alert *a);
void handleStateUpdate(const libtorrent::torrent_status &nativeStatus);
void handleAlert(const lt::alert *a);
void handleStateUpdate(const lt::torrent_status &nativeStatus);
void handleTempPathChanged();
void handleCategorySavePathChanged();
void handleAppendExtensionToggled();
@ -355,27 +355,27 @@ namespace BitTorrent @@ -355,27 +355,27 @@ namespace BitTorrent
typedef std::function<void ()> EventTrigger;
void updateStatus();
void updateStatus(const libtorrent::torrent_status &nativeStatus);
void updateStatus(const lt::torrent_status &nativeStatus);
void updateState();
void updateTorrentInfo();
void handleStorageMovedAlert(const libtorrent::storage_moved_alert *p);
void handleStorageMovedFailedAlert(const libtorrent::storage_moved_failed_alert *p);
void handleTrackerReplyAlert(const libtorrent::tracker_reply_alert *p);
void handleTrackerWarningAlert(const libtorrent::tracker_warning_alert *p);
void handleTrackerErrorAlert(const libtorrent::tracker_error_alert *p);
void handleTorrentCheckedAlert(const libtorrent::torrent_checked_alert *p);
void handleTorrentFinishedAlert(const libtorrent::torrent_finished_alert *p);
void handleTorrentPausedAlert(const libtorrent::torrent_paused_alert *p);
void handleTorrentResumedAlert(const libtorrent::torrent_resumed_alert *p);
void handleSaveResumeDataAlert(const libtorrent::save_resume_data_alert *p);
void handleSaveResumeDataFailedAlert(const libtorrent::save_resume_data_failed_alert *p);
void handleFastResumeRejectedAlert(const libtorrent::fastresume_rejected_alert *p);
void handleFileRenamedAlert(const libtorrent::file_renamed_alert *p);
void handleFileRenameFailedAlert(const libtorrent::file_rename_failed_alert *p);
void handleFileCompletedAlert(const libtorrent::file_completed_alert *p);
void handleMetadataReceivedAlert(const libtorrent::metadata_received_alert *p);
void handleStatsAlert(const libtorrent::stats_alert *p);
void handleStorageMovedAlert(const lt::storage_moved_alert *p);
void handleStorageMovedFailedAlert(const lt::storage_moved_failed_alert *p);
void handleTrackerReplyAlert(const lt::tracker_reply_alert *p);
void handleTrackerWarningAlert(const lt::tracker_warning_alert *p);
void handleTrackerErrorAlert(const lt::tracker_error_alert *p);
void handleTorrentCheckedAlert(const lt::torrent_checked_alert *p);
void handleTorrentFinishedAlert(const lt::torrent_finished_alert *p);
void handleTorrentPausedAlert(const lt::torrent_paused_alert *p);
void handleTorrentResumedAlert(const lt::torrent_resumed_alert *p);
void handleSaveResumeDataAlert(const lt::save_resume_data_alert *p);
void handleSaveResumeDataFailedAlert(const lt::save_resume_data_failed_alert *p);
void handleFastResumeRejectedAlert(const lt::fastresume_rejected_alert *p);
void handleFileRenamedAlert(const lt::file_renamed_alert *p);
void handleFileRenameFailedAlert(const lt::file_rename_failed_alert *p);
void handleFileCompletedAlert(const lt::file_completed_alert *p);
void handleMetadataReceivedAlert(const lt::metadata_received_alert *p);
void handleStatsAlert(const lt::stats_alert *p);
void resume_impl(bool forced);
bool isMoveInProgress() const;
@ -394,8 +394,8 @@ namespace BitTorrent @@ -394,8 +394,8 @@ namespace BitTorrent
void setFirstLastPiecePriorityImpl(bool enabled, const QVector<DownloadPriority> &updatedFilePrio = {});
Session *const m_session;
libtorrent::torrent_handle m_nativeHandle;
libtorrent::torrent_status m_nativeStatus;
lt::torrent_handle m_nativeHandle;
lt::torrent_status m_nativeStatus;
TorrentState m_state;
TorrentInfo m_torrentInfo;
SpeedMonitor m_speedMonitor;

2
src/base/bittorrent/torrentinfo.cpp

@ -413,7 +413,7 @@ void TorrentInfo::stripRootFolder() @@ -413,7 +413,7 @@ void TorrentInfo::stripRootFolder()
{
if (!hasRootFolder()) return;
libtorrent::file_storage files = m_nativeInfo->files();
lt::file_storage files = m_nativeInfo->files();
// Solution for case of renamed root folder
const std::string testName = filePath(0).split('/').value(0).toStdString();

8
src/base/bittorrent/torrentinfo.h

@ -56,11 +56,11 @@ namespace BitTorrent @@ -56,11 +56,11 @@ namespace BitTorrent
public:
#if (LIBTORRENT_VERSION_NUM < 10200)
using NativeConstPtr = boost::shared_ptr<const libtorrent::torrent_info>;
using NativePtr = boost::shared_ptr<libtorrent::torrent_info>;
using NativeConstPtr = boost::shared_ptr<const lt::torrent_info>;
using NativePtr = boost::shared_ptr<lt::torrent_info>;
#else
using NativeConstPtr = std::shared_ptr<const libtorrent::torrent_info>;
using NativePtr = std::shared_ptr<libtorrent::torrent_info>;
using NativeConstPtr = std::shared_ptr<const lt::torrent_info>;
using NativePtr = std::shared_ptr<lt::torrent_info>;
#endif
explicit TorrentInfo(NativeConstPtr nativeInfo = {});

24
src/base/bittorrent/tracker.cpp

@ -58,15 +58,15 @@ QString Peer::uid() const @@ -58,15 +58,15 @@ QString Peer::uid() const
return ip.toString() + ':' + QString::number(port);
}
libtorrent::entry Peer::toEntry(const bool noPeerId) const
lt::entry Peer::toEntry(const bool noPeerId) const
{
libtorrent::entry::dictionary_type peerMap;
lt::entry::dictionary_type peerMap;
if (!noPeerId)
peerMap["id"] = libtorrent::entry(peerId.toStdString());
peerMap["ip"] = libtorrent::entry(ip.toString().toStdString());
peerMap["port"] = libtorrent::entry(port);
peerMap["id"] = lt::entry(peerId.toStdString());
peerMap["ip"] = lt::entry(ip.toString().toStdString());
peerMap["port"] = lt::entry(port);
return libtorrent::entry(peerMap);
return lt::entry(peerMap);
}
// Tracker
@ -247,18 +247,18 @@ void Tracker::unregisterPeer(const TrackerAnnounceRequest &announceReq) @@ -247,18 +247,18 @@ void Tracker::unregisterPeer(const TrackerAnnounceRequest &announceReq)
void Tracker::replyWithPeerList(const TrackerAnnounceRequest &announceReq)
{
// Prepare the entry for bencoding
libtorrent::entry::dictionary_type replyDict;
replyDict["interval"] = libtorrent::entry(ANNOUNCE_INTERVAL);
lt::entry::dictionary_type replyDict;
replyDict["interval"] = lt::entry(ANNOUNCE_INTERVAL);
libtorrent::entry::list_type peerList;
lt::entry::list_type peerList;
for (const Peer &p : m_torrents.value(announceReq.infoHash))
peerList.push_back(p.toEntry(announceReq.noPeerId));
replyDict["peers"] = libtorrent::entry(peerList);
replyDict["peers"] = lt::entry(peerList);
const libtorrent::entry replyEntry(replyDict);
const lt::entry replyEntry(replyDict);
// bencode
QByteArray reply;
libtorrent::bencode(std::back_inserter(reply), replyEntry);
lt::bencode(std::back_inserter(reply), replyEntry);
qDebug("Tracker: reply with the following bencoded data:\n %s", reply.constData());
// HTTP reply

9
src/base/bittorrent/tracker.h

@ -30,6 +30,8 @@ @@ -30,6 +30,8 @@
#ifndef BITTORRENT_TRACKER_H
#define BITTORRENT_TRACKER_H
#include <libtorrent/fwd.hpp>
#include <QHash>
#include <QObject>
#include <QHostAddress>
@ -37,11 +39,6 @@ @@ -37,11 +39,6 @@
#include "base/http/irequesthandler.h"
#include "base/http/responsebuilder.h"
namespace libtorrent
{
class entry;
}
namespace Http
{
class Server;
@ -58,7 +55,7 @@ namespace BitTorrent @@ -58,7 +55,7 @@ namespace BitTorrent
bool operator!=(const Peer &other) const;
bool operator==(const Peer &other) const;
QString uid() const;
libtorrent::entry toEntry(bool noPeerId) const;
lt::entry toEntry(bool noPeerId) const;
};
struct TrackerAnnounceRequest

6
src/base/bittorrent/trackerentry.cpp

@ -42,7 +42,7 @@ TrackerEntry::TrackerEntry(const QString &url) @@ -42,7 +42,7 @@ TrackerEntry::TrackerEntry(const QString &url)
{
}
TrackerEntry::TrackerEntry(const libtorrent::announce_entry &nativeEntry)
TrackerEntry::TrackerEntry(const lt::announce_entry &nativeEntry)
: m_nativeEntry(nativeEntry)
{
}
@ -72,7 +72,7 @@ int TrackerEntry::tier() const @@ -72,7 +72,7 @@ int TrackerEntry::tier() const
TrackerEntry::Status TrackerEntry::status() const
{
// libtorrent::announce_entry::is_working() returns
// lt::announce_entry::is_working() returns
// true when the tracker hasn't been tried yet.
if (m_nativeEntry.verified && isWorking())
return Working;
@ -119,7 +119,7 @@ int TrackerEntry::numDownloaded() const @@ -119,7 +119,7 @@ int TrackerEntry::numDownloaded() const
#endif
}
libtorrent::announce_entry TrackerEntry::nativeEntry() const
lt::announce_entry TrackerEntry::nativeEntry() const
{
return m_nativeEntry;
}

6
src/base/bittorrent/trackerentry.h

@ -48,7 +48,7 @@ namespace BitTorrent @@ -48,7 +48,7 @@ namespace BitTorrent
};
TrackerEntry(const QString &url);
TrackerEntry(const libtorrent::announce_entry &nativeEntry);
TrackerEntry(const lt::announce_entry &nativeEntry);
TrackerEntry(const TrackerEntry &other) = default;
TrackerEntry &operator=(const TrackerEntry &other) = default;
@ -63,10 +63,10 @@ namespace BitTorrent @@ -63,10 +63,10 @@ namespace BitTorrent
int numLeeches() const;
int numDownloaded() const;
libtorrent::announce_entry nativeEntry() const;
lt::announce_entry nativeEntry() const;
private:
libtorrent::announce_entry m_nativeEntry;
lt::announce_entry m_nativeEntry;
};
bool operator==(const TrackerEntry &left, const TrackerEntry &right);

Loading…
Cancel
Save