From 3955eef50da2ea4fb2dcf37c8287e7bfd7101050 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 9 May 2019 12:45:52 +0800 Subject: [PATCH] Change to `lt` namespace Quoting from libtorrent doc: > In the future, libtorrent will be the alias and lt the namespace name. --- src/base/bittorrent/infohash.cpp | 8 +-- src/base/bittorrent/infohash.h | 10 ++-- src/base/bittorrent/magneturi.cpp | 4 +- src/base/bittorrent/magneturi.h | 4 +- src/base/bittorrent/peerinfo.h | 4 +- .../bittorrent/private/filterparserthread.h | 4 +- .../bittorrent/private/portforwarderimpl.cpp | 2 +- .../bittorrent/private/portforwarderimpl.h | 2 +- src/base/bittorrent/session.cpp | 14 ++--- src/base/bittorrent/session.h | 52 +++++++++---------- src/base/bittorrent/torrenthandle.cpp | 44 ++++++++-------- src/base/bittorrent/torrenthandle.h | 48 ++++++++--------- src/base/bittorrent/torrentinfo.cpp | 2 +- src/base/bittorrent/torrentinfo.h | 8 +-- src/base/bittorrent/tracker.cpp | 24 ++++----- src/base/bittorrent/tracker.h | 9 ++-- src/base/bittorrent/trackerentry.cpp | 6 +-- src/base/bittorrent/trackerentry.h | 6 +-- 18 files changed, 124 insertions(+), 127 deletions(-) diff --git a/src/base/bittorrent/infohash.cpp b/src/base/bittorrent/infohash.cpp index 9a7f51a74..122d4e88f 100644 --- a/src/base/bittorrent/infohash.cpp +++ b/src/base/bittorrent/infohash.cpp @@ -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 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 bool BitTorrent::operator==(const InfoHash &left, const InfoHash &right) { - return (static_cast(left) - == static_cast(right)); + return (static_cast(left) + == static_cast(right)); } bool BitTorrent::operator!=(const InfoHash &left, const InfoHash &right) diff --git a/src/base/bittorrent/infohash.h b/src/base/bittorrent/infohash.h index 234549d38..049746fae 100644 --- a/src/base/bittorrent/infohash.h +++ b/src/base/bittorrent/infohash.h @@ -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; }; diff --git a/src/base/bittorrent/magneturi.cpp b/src/base/bittorrent/magneturi.cpp index 939502414..f15ff39d0 100644 --- a/src/base/bittorrent/magneturi.cpp +++ b/src/base/bittorrent/magneturi.cpp @@ -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 return m_url; } -libtorrent::add_torrent_params MagnetUri::addTorrentParams() const +lt::add_torrent_params MagnetUri::addTorrentParams() const { return m_addTorrentParams; } diff --git a/src/base/bittorrent/magneturi.h b/src/base/bittorrent/magneturi.h index d6e8baa8a..e2b8757c3 100644 --- a/src/base/bittorrent/magneturi.h +++ b/src/base/bittorrent/magneturi.h @@ -52,7 +52,7 @@ namespace BitTorrent QList 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 QString m_name; QList m_trackers; QList m_urlSeeds; - libtorrent::add_torrent_params m_addTorrentParams; + lt::add_torrent_params m_addTorrentParams; }; } diff --git a/src/base/bittorrent/peerinfo.h b/src/base/bittorrent/peerinfo.h index 9edac8552..6aae66f75 100644 --- a/src/base/bittorrent/peerinfo.h +++ b/src/base/bittorrent/peerinfo.h @@ -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 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; diff --git a/src/base/bittorrent/private/filterparserthread.h b/src/base/bittorrent/private/filterparserthread.h index ab5f4a6ab..0f374bbf5 100644 --- a/src/base/bittorrent/private/filterparserthread.h +++ b/src/base/bittorrent/private/filterparserthread.h @@ -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: bool m_abort; QString m_filePath; - libtorrent::ip_filter m_filter; + lt::ip_filter m_filter; }; #endif // BITTORRENT_FILTERPARSERTHREAD_H diff --git a/src/base/bittorrent/private/portforwarderimpl.cpp b/src/base/bittorrent/private/portforwarderimpl.cpp index e0282bbf7..23d8d6dbd 100644 --- a/src/base/bittorrent/private/portforwarderimpl.cpp +++ b/src/base/bittorrent/private/portforwarderimpl.cpp @@ -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} diff --git a/src/base/bittorrent/private/portforwarderimpl.h b/src/base/bittorrent/private/portforwarderimpl.h index df353c47c..4889abe67 100644 --- a/src/base/bittorrent/private/portforwarderimpl.h +++ b/src/base/bittorrent/private/portforwarderimpl.h @@ -60,6 +60,6 @@ private: void stop(); bool m_active; - libtorrent::session *m_provider; + lt::session *m_provider; QHash> m_mappedPorts; }; diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 0f5f11d4c..2e8df1759 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -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) , 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() 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) 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() { 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) { diff --git a/src/base/bittorrent/session.h b/src/base/bittorrent/session.h index 87c8ec890..55d73bd1c 100644 --- a/src/base/bittorrent/session.h +++ b/src/base/bittorrent/session.h @@ -441,7 +441,7 @@ namespace BitTorrent void handleTorrentTrackersChanged(TorrentHandle *const torrent); void handleTorrentUrlSeedsAdded(TorrentHandle *const torrent, const QList &newUrlSeeds); void handleTorrentUrlSeedsRemoved(TorrentHandle *const torrent, const QList &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 // 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 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 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 libtorrent::torrent_handle &nativeHandle); + void createTorrentHandle(const lt::torrent_handle &nativeHandle); void saveResumeData(); void saveTorrentsQueue(); void removeTorrentsQueue(); - void getPendingAlerts(std::vector &out, ulong time = 0); + void getPendingAlerts(std::vector &out, ulong time = 0); // BitTorrent - libtorrent::session *m_nativeSession; + lt::session *m_nativeSession; bool m_deferredConfigureScheduled; bool m_IPFilteringChanged; diff --git a/src/base/bittorrent/torrenthandle.cpp b/src/base/bittorrent/torrenthandle.cpp index 27c2c1a2f..09847116c 100644 --- a/src/base/bittorrent/torrenthandle.cpp +++ b/src/base/bittorrent/torrenthandle.cpp @@ -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 ¶ms) : QObject(session) , m_session(session) @@ -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 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 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 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_ 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 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_ 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 } } -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 } } -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_ 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 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 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 } } -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 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 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 } } -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() 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() 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() updateStatus(m_nativeHandle.status()); } -void TorrentHandle::updateStatus(const libtorrent::torrent_status &nativeStatus) +void TorrentHandle::updateStatus(const lt::torrent_status &nativeStatus) { m_nativeStatus = nativeStatus; diff --git a/src/base/bittorrent/torrenthandle.h b/src/base/bittorrent/torrenthandle.h index 40c3e30ce..f7b9c8519 100644 --- a/src/base/bittorrent/torrenthandle.h +++ b/src/base/bittorrent/torrenthandle.h @@ -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 ¶ms); ~TorrentHandle(); @@ -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 typedef std::function 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 void setFirstLastPiecePriorityImpl(bool enabled, const QVector &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; diff --git a/src/base/bittorrent/torrentinfo.cpp b/src/base/bittorrent/torrentinfo.cpp index 4f0092980..7123a6e12 100644 --- a/src/base/bittorrent/torrentinfo.cpp +++ b/src/base/bittorrent/torrentinfo.cpp @@ -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(); diff --git a/src/base/bittorrent/torrentinfo.h b/src/base/bittorrent/torrentinfo.h index ea6216abe..bedefd2b9 100644 --- a/src/base/bittorrent/torrentinfo.h +++ b/src/base/bittorrent/torrentinfo.h @@ -56,11 +56,11 @@ namespace BitTorrent public: #if (LIBTORRENT_VERSION_NUM < 10200) - using NativeConstPtr = boost::shared_ptr; - using NativePtr = boost::shared_ptr; + using NativeConstPtr = boost::shared_ptr; + using NativePtr = boost::shared_ptr; #else - using NativeConstPtr = std::shared_ptr; - using NativePtr = std::shared_ptr; + using NativeConstPtr = std::shared_ptr; + using NativePtr = std::shared_ptr; #endif explicit TorrentInfo(NativeConstPtr nativeInfo = {}); diff --git a/src/base/bittorrent/tracker.cpp b/src/base/bittorrent/tracker.cpp index db7ac6e47..d52280727 100644 --- a/src/base/bittorrent/tracker.cpp +++ b/src/base/bittorrent/tracker.cpp @@ -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) 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 diff --git a/src/base/bittorrent/tracker.h b/src/base/bittorrent/tracker.h index 02e799908..dff8c908c 100644 --- a/src/base/bittorrent/tracker.h +++ b/src/base/bittorrent/tracker.h @@ -30,6 +30,8 @@ #ifndef BITTORRENT_TRACKER_H #define BITTORRENT_TRACKER_H +#include + #include #include #include @@ -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 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 diff --git a/src/base/bittorrent/trackerentry.cpp b/src/base/bittorrent/trackerentry.cpp index 885dd8e72..5522dcebc 100644 --- a/src/base/bittorrent/trackerentry.cpp +++ b/src/base/bittorrent/trackerentry.cpp @@ -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 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 #endif } -libtorrent::announce_entry TrackerEntry::nativeEntry() const +lt::announce_entry TrackerEntry::nativeEntry() const { return m_nativeEntry; } diff --git a/src/base/bittorrent/trackerentry.h b/src/base/bittorrent/trackerentry.h index 8806a1f16..e99389cf8 100644 --- a/src/base/bittorrent/trackerentry.h +++ b/src/base/bittorrent/trackerentry.h @@ -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 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);