From 60ffa3030ee021ec05b3789c42a9460a61ee5e7a Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Thu, 18 Jul 2019 19:53:04 +0300 Subject: [PATCH] Don't use deprecated libtorrent features --- src/base/CMakeLists.txt | 1 + src/base/base.pri | 1 + .../bittorrent/private/ltunderlyingtype.h | 61 ++++++++++++++++++ src/base/bittorrent/session.cpp | 62 ++++++------------- src/base/bittorrent/session.h | 6 -- src/base/bittorrent/torrentcreatorthread.cpp | 18 ++++-- src/base/bittorrent/torrenthandle.cpp | 58 +++++++++-------- src/base/bittorrent/torrenthandle.h | 8 +-- src/base/bittorrent/torrentinfo.cpp | 4 +- src/gui/advancedsettings.cpp | 7 --- src/gui/advancedsettings.h | 2 +- src/gui/optionsdialog.cpp | 15 ----- src/gui/optionsdialog.h | 1 - src/gui/optionsdialog.ui | 38 ------------ src/webui/api/appcontroller.cpp | 8 --- .../www/private/preferences_content.html | 26 -------- 16 files changed, 130 insertions(+), 186 deletions(-) create mode 100644 src/base/bittorrent/private/ltunderlyingtype.h diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt index 1a736ede2..1914db676 100644 --- a/src/base/CMakeLists.txt +++ b/src/base/CMakeLists.txt @@ -10,6 +10,7 @@ bittorrent/magneturi.h bittorrent/peerinfo.h bittorrent/private/bandwidthscheduler.h bittorrent/private/filterparserthread.h +bittorrent/private/ltunderlyingtype.h bittorrent/private/portforwarderimpl.h bittorrent/private/resumedatasavingmanager.h bittorrent/private/speedmonitor.h diff --git a/src/base/base.pri b/src/base/base.pri index f5a0b025d..11a579753 100644 --- a/src/base/base.pri +++ b/src/base/base.pri @@ -9,6 +9,7 @@ HEADERS += \ $$PWD/bittorrent/peerinfo.h \ $$PWD/bittorrent/private/bandwidthscheduler.h \ $$PWD/bittorrent/private/filterparserthread.h \ + $$PWD/bittorrent/private/ltunderlyingtype.h \ $$PWD/bittorrent/private/portforwarderimpl.h \ $$PWD/bittorrent/private/resumedatasavingmanager.h \ $$PWD/bittorrent/private/speedmonitor.h \ diff --git a/src/base/bittorrent/private/ltunderlyingtype.h b/src/base/bittorrent/private/ltunderlyingtype.h new file mode 100644 index 000000000..8df51fbfc --- /dev/null +++ b/src/base/bittorrent/private/ltunderlyingtype.h @@ -0,0 +1,61 @@ +/* + * Bittorrent Client using Qt and libtorrent. + * Copyright (C) 2019 Vladimir Golovnev + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * In addition, as a special exception, the copyright holders give permission to + * link this program with the OpenSSL project's "OpenSSL" library (or with + * modified versions of it that use the same license as the "OpenSSL" library), + * and distribute the linked executables. You must obey the GNU General Public + * License in all respects for all of the code used other than "OpenSSL". If you + * modify file(s), you may extend this exception to your version of the file(s), + * but you are not obligated to do so. If you do not wish to do so, delete this + * exception statement from your version. + */ + +#pragma once + +#include + +template +using void_t = void; // replace this with std::void_t in C++17 + +template +struct HasUnderlyingType + : std::false_type +{ +}; + +template +struct HasUnderlyingType> + : std::true_type +{ +}; + +template +struct LTUnderlying +{ + using type = T; +}; + +template +struct LTUnderlying::value>> +{ + using type = typename T::underlying_type; +}; + +template +using LTUnderlyingType = typename LTUnderlying::type; diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 80f9814a9..540a28f19 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -86,6 +86,7 @@ #include "magneturi.h" #include "private/bandwidthscheduler.h" #include "private/filterparserthread.h" +#include "private/ltunderlyingtype.h" #include "private/portforwarderimpl.h" #include "private/resumedatasavingmanager.h" #include "private/statistics.h" @@ -106,10 +107,16 @@ using namespace BitTorrent; namespace { #if (LIBTORRENT_VERSION_NUM < 10200) + using LTAlertCategory = int; + using LTPeerClass = int; + using LTQueuePosition = int; using LTSessionFlags = int; using LTStatusFlags = int; using LTString = std::string; #else + using LTAlertCategory = lt::alert_category_t; + using LTPeerClass = lt::peer_class_t; + using LTQueuePosition = lt::queue_position_t; using LTSessionFlags = lt::session_flags_t; using LTStatusFlags = lt::status_flags_t; using LTString = lt::string_view; @@ -277,7 +284,6 @@ Session::Session(QObject *parent) , m_diskCacheSize(BITTORRENT_SESSION_KEY("DiskCacheSize"), 64) , m_diskCacheTTL(BITTORRENT_SESSION_KEY("DiskCacheTTL"), 60) , m_useOSCache(BITTORRENT_SESSION_KEY("UseOSCache"), true) - , m_guidedReadCacheEnabled(BITTORRENT_SESSION_KEY("GuidedReadCache"), true) #ifdef Q_OS_WIN , m_coalesceReadWriteEnabled(BITTORRENT_SESSION_KEY("CoalesceReadWrite"), true) #else @@ -338,7 +344,6 @@ Session::Session(QObject *parent) , m_networkInterfaceAddress(BITTORRENT_SESSION_KEY("InterfaceAddress")) , m_isIPv6Enabled(BITTORRENT_SESSION_KEY("IPv6Enabled"), false) , m_encryption(BITTORRENT_SESSION_KEY("Encryption"), 0) - , m_isForceProxyEnabled(BITTORRENT_SESSION_KEY("ForceProxy"), true) , m_isProxyPeerConnectionsEnabled(BITTORRENT_SESSION_KEY("ProxyPeerConnections"), false) , m_chokingAlgorithm(BITTORRENT_SESSION_KEY("ChokingAlgorithm"), ChokingAlgorithm::FixedSlots , clampValue(ChokingAlgorithm::FixedSlots, ChokingAlgorithm::RateBased)) @@ -381,7 +386,7 @@ Session::Session(QObject *parent) connect(m_seedingLimitTimer, &QTimer::timeout, this, &Session::processShareLimits); // Set severity level of libtorrent session - const int alertMask = lt::alert::error_notification + const LTAlertCategory alertMask = lt::alert::error_notification | lt::alert::peer_notification | lt::alert::port_mapping_notification | lt::alert::storage_notification @@ -1252,8 +1257,6 @@ void Session::configure(lt::settings_pack &settingsPack) settingsPack.set_bool(lt::settings_pack::proxy_peer_connections, isProxyPeerConnectionsEnabled()); } - settingsPack.set_bool(lt::settings_pack::force_proxy - , ((proxyConfig.type == Net::ProxyType::None) ? false : isForceProxyEnabled())); settingsPack.set_bool(lt::settings_pack::announce_to_all_trackers, announceToAllTrackers()); settingsPack.set_bool(lt::settings_pack::announce_to_all_tiers, announceToAllTiers()); @@ -1274,7 +1277,6 @@ void Session::configure(lt::settings_pack &settingsPack) : lt::settings_pack::disable_os_cache; settingsPack.set_int(lt::settings_pack::disk_io_read_mode, mode); settingsPack.set_int(lt::settings_pack::disk_io_write_mode, mode); - settingsPack.set_bool(lt::settings_pack::guided_read_cache, isGuidedReadCacheEnabled()); settingsPack.set_bool(lt::settings_pack::coalesce_reads, isCoalesceReadWriteEnabled()); settingsPack.set_bool(lt::settings_pack::coalesce_writes, isCoalesceReadWriteEnabled()); @@ -1398,7 +1400,7 @@ void Session::configurePeerClasses() // Proactively do the same for 0.0.0.0 and address_v4::any() f.add_rule(lt::address_v4::any() , lt::address_v4::broadcast() - , 1 << lt::session::global_peer_class_id); + , 1 << static_cast>(lt::session::global_peer_class_id)); #if (LIBTORRENT_VERSION_NUM >= 10200) || TORRENT_USE_IPV6 // IPv6 may not be available on OS and the parsing @@ -1407,7 +1409,7 @@ void Session::configurePeerClasses() try { f.add_rule(lt::address_v6::any() , lt::address_v6::from_string("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff") - , 1 << lt::session::global_peer_class_id); + , 1 << static_cast>(lt::session::global_peer_class_id)); } catch (const std::exception &) {} #endif @@ -1416,21 +1418,21 @@ void Session::configurePeerClasses() // local networks f.add_rule(lt::address_v4::from_string("10.0.0.0") , lt::address_v4::from_string("10.255.255.255") - , 1 << lt::session::local_peer_class_id); + , 1 << static_cast>(lt::session::local_peer_class_id)); f.add_rule(lt::address_v4::from_string("172.16.0.0") , lt::address_v4::from_string("172.31.255.255") - , 1 << lt::session::local_peer_class_id); + , 1 << static_cast>(lt::session::local_peer_class_id)); f.add_rule(lt::address_v4::from_string("192.168.0.0") , lt::address_v4::from_string("192.168.255.255") - , 1 << lt::session::local_peer_class_id); + , 1 << static_cast>(lt::session::local_peer_class_id)); // link local f.add_rule(lt::address_v4::from_string("169.254.0.0") , lt::address_v4::from_string("169.254.255.255") - , 1 << lt::session::local_peer_class_id); + , 1 << static_cast>(lt::session::local_peer_class_id)); // loopback f.add_rule(lt::address_v4::from_string("127.0.0.0") , lt::address_v4::from_string("127.255.255.255") - , 1 << lt::session::local_peer_class_id); + , 1 << static_cast>(lt::session::local_peer_class_id)); #if (LIBTORRENT_VERSION_NUM >= 10200) || TORRENT_USE_IPV6 // IPv6 may not be available on OS and the parsing @@ -1440,15 +1442,15 @@ void Session::configurePeerClasses() // link local f.add_rule(lt::address_v6::from_string("fe80::") , lt::address_v6::from_string("febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff") - , 1 << lt::session::local_peer_class_id); + , 1 << static_cast>(lt::session::local_peer_class_id)); // unique local addresses f.add_rule(lt::address_v6::from_string("fc00::") , lt::address_v6::from_string("fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff") - , 1 << lt::session::local_peer_class_id); + , 1 << static_cast>(lt::session::local_peer_class_id)); // loopback f.add_rule(lt::address_v6::loopback() , lt::address_v6::loopback() - , 1 << lt::session::local_peer_class_id); + , 1 << static_cast>(lt::session::local_peer_class_id)); } catch (const std::exception &) {} #endif @@ -2206,7 +2208,7 @@ void Session::saveTorrentsQueue() QMap queue; // Use QMap since it should be ordered by key for (const TorrentHandle *torrent : asConst(torrents())) { // We require actual (non-cached) queue position here! - const int queuePos = torrent->nativeHandle().queue_position(); + const int queuePos = LTUnderlyingType {torrent->nativeHandle().queue_position()}; if (queuePos >= 0) queue[queuePos] = torrent->hash(); } @@ -2618,19 +2620,6 @@ void Session::setEncryption(const int state) } } -bool Session::isForceProxyEnabled() const -{ - return m_isForceProxyEnabled; -} - -void Session::setForceProxyEnabled(const bool enabled) -{ - if (enabled != isForceProxyEnabled()) { - m_isForceProxyEnabled = enabled; - configureDeferred(); - } -} - bool Session::isProxyPeerConnectionsEnabled() const { return m_isProxyPeerConnectionsEnabled; @@ -2925,19 +2914,6 @@ void Session::setUseOSCache(const bool use) } } -bool Session::isGuidedReadCacheEnabled() const -{ - return m_guidedReadCacheEnabled; -} - -void Session::setGuidedReadCacheEnabled(const bool enabled) -{ - if (enabled == m_guidedReadCacheEnabled) return; - - m_guidedReadCacheEnabled = enabled; - configureDeferred(); -} - bool Session::isCoalesceReadWriteEnabled() const { return m_coalesceReadWriteEnabled; diff --git a/src/base/bittorrent/session.h b/src/base/bittorrent/session.h index e99270037..6ed0613a8 100644 --- a/src/base/bittorrent/session.h +++ b/src/base/bittorrent/session.h @@ -298,8 +298,6 @@ namespace BitTorrent void setIPv6Enabled(bool enabled); int encryption() const; void setEncryption(int state); - bool isForceProxyEnabled() const; - void setForceProxyEnabled(bool enabled); bool isProxyPeerConnectionsEnabled() const; void setProxyPeerConnectionsEnabled(bool enabled); ChokingAlgorithm chokingAlgorithm() const; @@ -330,8 +328,6 @@ namespace BitTorrent void setDiskCacheTTL(int ttl); bool useOSCache() const; void setUseOSCache(bool use); - bool isGuidedReadCacheEnabled() const; - void setGuidedReadCacheEnabled(bool enabled); bool isCoalesceReadWriteEnabled() const; void setCoalesceReadWriteEnabled(bool enabled); bool isSuggestModeEnabled() const; @@ -595,7 +591,6 @@ namespace BitTorrent CachedSettingValue m_diskCacheSize; CachedSettingValue m_diskCacheTTL; CachedSettingValue m_useOSCache; - CachedSettingValue m_guidedReadCacheEnabled; CachedSettingValue m_coalesceReadWriteEnabled; CachedSettingValue m_isSuggestMode; CachedSettingValue m_sendBufferWatermark; @@ -650,7 +645,6 @@ namespace BitTorrent CachedSettingValue m_networkInterfaceAddress; CachedSettingValue m_isIPv6Enabled; CachedSettingValue m_encryption; - CachedSettingValue m_isForceProxyEnabled; CachedSettingValue m_isProxyPeerConnectionsEnabled; CachedSettingValue m_chokingAlgorithm; CachedSettingValue m_seedChokingAlgorithm; diff --git a/src/base/bittorrent/torrentcreatorthread.cpp b/src/base/bittorrent/torrentcreatorthread.cpp index 6b5961351..b8acc4f08 100644 --- a/src/base/bittorrent/torrentcreatorthread.cpp +++ b/src/base/bittorrent/torrentcreatorthread.cpp @@ -44,14 +44,17 @@ #include "base/global.h" #include "base/utils/fs.h" #include "base/utils/string.h" +#include "private/ltunderlyingtype.h" namespace { #if (LIBTORRENT_VERSION_NUM < 10200) - using CreateFlags = int; + using LTCreateFlags = int; + using LTPieceIndex = int; #else - using CreateFlags = lt::create_flags_t; -#endif + using LTCreateFlags = lt::create_flags_t; + using LTPieceIndex = lt::piece_index_t; +#endif // do not include files and folders whose // name starts with a . @@ -136,7 +139,7 @@ void TorrentCreatorThread::run() if (isInterruptionRequested()) return; lt::create_torrent newTorrent(fs, m_params.pieceSize, -1 - , (m_params.isAlignmentOptimized ? lt::create_torrent::optimize_alignment : CreateFlags {})); + , (m_params.isAlignmentOptimized ? lt::create_torrent::optimize_alignment : LTCreateFlags {})); // Add url seeds for (QString seed : asConst(m_params.urlSeeds)) { @@ -157,7 +160,10 @@ void TorrentCreatorThread::run() // calculate the hash for all pieces lt::set_piece_hashes(newTorrent, Utils::Fs::toNativePath(parentPath).toStdString() - , [this, &newTorrent](const int n) { sendProgressSignal(n, newTorrent.num_pieces()); }); + , [this, &newTorrent](const LTPieceIndex n) + { + sendProgressSignal(LTUnderlyingType {n}, newTorrent.num_pieces()); + }); // Set qBittorrent as creator and add user comment to // torrent_info structure newTorrent.set_creator(creatorStr.toUtf8().constData()); @@ -208,5 +214,5 @@ int TorrentCreatorThread::calculateTotalPieces(const QString &inputPath, const i lt::add_files(fs, Utils::Fs::toNativePath(inputPath).toStdString(), fileFilter); return lt::create_torrent(fs, pieceSize, -1 - , (isAlignmentOptimized ? lt::create_torrent::optimize_alignment : CreateFlags {})).num_pieces(); + , (isAlignmentOptimized ? lt::create_torrent::optimize_alignment : LTCreateFlags {})).num_pieces(); } diff --git a/src/base/bittorrent/torrenthandle.cpp b/src/base/bittorrent/torrenthandle.cpp index 006298cc5..62ec8c0c9 100644 --- a/src/base/bittorrent/torrenthandle.cpp +++ b/src/base/bittorrent/torrenthandle.cpp @@ -66,6 +66,7 @@ #include "base/utils/string.h" #include "downloadpriority.h" #include "peerinfo.h" +#include "private/ltunderlyingtype.h" #include "session.h" #include "trackerentry.h" @@ -77,11 +78,13 @@ namespace { #if (LIBTORRENT_VERSION_NUM < 10200) using LTDownloadPriority = int; - using LTDownloadPriorityUnderlyingType = int; + using LTFileIndex = int; + using LTPieceIndex = int; using LTQueuePosition = int; #else using LTDownloadPriority = lt::download_priority_t; - using LTDownloadPriorityUnderlyingType = lt::download_priority_t::underlying_type; + using LTFileIndex = lt::file_index_t; + using LTPieceIndex = lt::piece_index_t; using LTQueuePosition = lt::queue_position_t; #endif @@ -92,7 +95,7 @@ namespace , std::back_inserter(out), [](BitTorrent::DownloadPriority priority) { return static_cast( - static_cast(priority)); + static_cast>(priority)); }); return out; } @@ -377,7 +380,7 @@ bool TorrentHandle::isAutoManaged() const #if (LIBTORRENT_VERSION_NUM < 10200) return m_nativeStatus.auto_managed; #else - return (m_nativeStatus.flags & lt::torrent_flags::auto_managed); + return bool {m_nativeStatus.flags & lt::torrent_flags::auto_managed}; #endif } @@ -680,7 +683,7 @@ QStringList TorrentHandle::absoluteFilePathsUnwanted() const QStringList res; for (int i = 0; i < static_cast(fp.size()); ++i) { - if (fp[i] == 0) { + if (fp[i] == LTDownloadPriority {0}) { const QString path = Utils::Fs::expandPathAbs(saveDir.absoluteFilePath(filePath(i))); if (path.contains(".unwanted")) res << path; @@ -701,8 +704,7 @@ QVector TorrentHandle::filePriorities() const QVector ret; std::transform(fp.cbegin(), fp.cend(), std::back_inserter(ret), [](LTDownloadPriority priority) { - return static_cast( - static_cast::type>(priority)); + return static_cast(LTUnderlyingType {priority}); }); return ret; } @@ -825,7 +827,7 @@ bool TorrentHandle::isSequentialDownload() const #if (LIBTORRENT_VERSION_NUM < 10200) return m_nativeStatus.sequential_download; #else - return (m_nativeStatus.flags & lt::torrent_flags::sequential_download); + return bool {m_nativeStatus.flags & lt::torrent_flags::sequential_download}; #endif } @@ -840,13 +842,13 @@ bool TorrentHandle::hasFirstLastPiecePriority() const const std::vector filePriorities = nativeHandle().get_file_priorities(); #endif for (int i = 0; i < static_cast(filePriorities.size()); ++i) { - if (filePriorities[i] <= 0) + if (filePriorities[i] <= LTDownloadPriority {0}) continue; const TorrentInfo::PieceRange extremities = info().filePieces(i); - const int firstPiecePrio = nativeHandle().piece_priority(extremities.first()); - const int lastPiecePrio = nativeHandle().piece_priority(extremities.last()); - return ((firstPiecePrio == 7) && (lastPiecePrio == 7)); + const LTDownloadPriority firstPiecePrio = nativeHandle().piece_priority(LTPieceIndex {extremities.first()}); + const LTDownloadPriority lastPiecePrio = nativeHandle().piece_priority(LTPieceIndex {extremities.last()}); + return ((firstPiecePrio == LTDownloadPriority {7}) && (lastPiecePrio == LTDownloadPriority {7})); } return false; @@ -1149,7 +1151,7 @@ bool TorrentHandle::superSeeding() const #if (LIBTORRENT_VERSION_NUM < 10200) return m_nativeStatus.super_seeding; #else - return (m_nativeStatus.flags & lt::torrent_flags::super_seeding); + return bool {m_nativeStatus.flags & lt::torrent_flags::super_seeding}; #endif } @@ -1171,7 +1173,7 @@ QBitArray TorrentHandle::pieces() const QBitArray result(m_nativeStatus.pieces.size()); for (int i = 0; i < m_nativeStatus.pieces.size(); ++i) - result.setBit(i, m_nativeStatus.pieces.get_bit(i)); + result.setBit(i, m_nativeStatus.pieces.get_bit(LTPieceIndex {i})); return result; } @@ -1184,7 +1186,11 @@ QBitArray TorrentHandle::downloadingPieces() const m_nativeHandle.get_download_queue(queue); for (const lt::partial_piece_info &info : queue) +#if (LIBTORRENT_VERSION_NUM < 10200) result.setBit(info.piece_index); +#else + result.setBit(LTUnderlyingType {info.piece_index}); +#endif return result; } @@ -1410,7 +1416,7 @@ void TorrentHandle::setFirstLastPiecePriorityImpl(const bool enabled, const QVec continue; // Determine the priority to set - const int newPrio = enabled ? LTDownloadPriority {7} : filePrio; + const LTDownloadPriority newPrio = enabled ? LTDownloadPriority {7} : filePrio; const TorrentInfo::PieceRange extremities = info().filePieces(index); // worst case: AVI index = 1% of total file size (at the end of the file) @@ -1507,9 +1513,9 @@ void TorrentHandle::renameFile(const int index, const QString &name) { if (m_startupState != Started) return; - m_oldPath[LTFileIndex {index}].push_back(filePath(index)); + m_oldPath[index].push_back(filePath(index)); ++m_renameCount; - m_nativeHandle.rename_file(index, Utils::Fs::toNativePath(name).toStdString()); + m_nativeHandle.rename_file(LTFileIndex {index}, Utils::Fs::toNativePath(name).toStdString()); } bool TorrentHandle::saveTorrentFile(const QString &path) @@ -1807,11 +1813,11 @@ void TorrentHandle::handleFileRenamedAlert(const lt::file_renamed_alert *p) // remove empty leftover folders // for example renaming "a/b/c" to "d/b/c", then folders "a/b" and "a" will // be removed if they are empty - const QString oldFilePath = m_oldPath[LTFileIndex {p->index}].takeFirst(); + const QString oldFilePath = m_oldPath[LTUnderlyingType {p->index}].takeFirst(); const QString newFilePath = Utils::Fs::toUniformPath(p->new_name()); - if (m_oldPath[LTFileIndex {p->index}].isEmpty()) - m_oldPath.remove(LTFileIndex {p->index}); + if (m_oldPath[LTUnderlyingType {p->index}].isEmpty()) + m_oldPath.remove(LTUnderlyingType {p->index}); QVector oldPathParts = oldFilePath.splitRef('/', QString::SkipEmptyParts); oldPathParts.removeLast(); // drop file name part @@ -1847,12 +1853,12 @@ void TorrentHandle::handleFileRenamedAlert(const lt::file_renamed_alert *p) void TorrentHandle::handleFileRenameFailedAlert(const lt::file_rename_failed_alert *p) { LogMsg(tr("File rename failed. Torrent: \"%1\", file: \"%2\", reason: \"%3\"") - .arg(name(), filePath(p->index) + .arg(name(), filePath(LTUnderlyingType {p->index}) , QString::fromStdString(p->error.message())), Log::WARNING); - m_oldPath[LTFileIndex {p->index}].removeFirst(); - if (m_oldPath[LTFileIndex {p->index}].isEmpty()) - m_oldPath.remove(LTFileIndex {p->index}); + m_oldPath[LTUnderlyingType {p->index}].removeFirst(); + if (m_oldPath[LTUnderlyingType {p->index}].isEmpty()) + m_oldPath.remove(LTUnderlyingType {p->index}); --m_renameCount; while (!isMoveInProgress() && (m_renameCount == 0) && !m_moveFinishedTriggers.isEmpty()) @@ -1870,12 +1876,12 @@ void TorrentHandle::handleFileCompletedAlert(const lt::file_completed_alert *p) qDebug("A file completed download in torrent \"%s\"", qUtf8Printable(name())); if (m_session->isAppendExtensionEnabled()) { - QString name = filePath(p->index); + QString name = filePath(LTUnderlyingType {p->index}); if (name.endsWith(QB_EXT)) { const QString oldName = name; name.chop(QB_EXT.size()); qDebug("Renaming %s to %s", qUtf8Printable(oldName), qUtf8Printable(name)); - renameFile(p->index, name); + renameFile(LTUnderlyingType {p->index}, name); } } } diff --git a/src/base/bittorrent/torrenthandle.h b/src/base/bittorrent/torrenthandle.h index b64ea14be..25bf69433 100644 --- a/src/base/bittorrent/torrenthandle.h +++ b/src/base/bittorrent/torrenthandle.h @@ -355,12 +355,6 @@ namespace BitTorrent private: typedef std::function EventTrigger; -#if (LIBTORRENT_VERSION_NUM < 10200) - using LTFileIndex = int; -#else - using LTFileIndex = lt::file_index_t; -#endif - void updateStatus(); void updateStatus(const lt::torrent_status &nativeStatus); void updateState(); @@ -425,7 +419,7 @@ namespace BitTorrent // Until libtorrent provide an "old_name" field in `file_renamed_alert` // we will rely on this workaround to remove empty leftover folders - QHash> m_oldPath; + QHash> m_oldPath; bool m_useAutoTMM; diff --git a/src/base/bittorrent/torrentinfo.cpp b/src/base/bittorrent/torrentinfo.cpp index 0567206c8..8f938264a 100644 --- a/src/base/bittorrent/torrentinfo.cpp +++ b/src/base/bittorrent/torrentinfo.cpp @@ -378,7 +378,7 @@ TorrentInfo::PieceRange TorrentInfo::filePieces(const int fileIndex) const void TorrentInfo::renameFile(const int index, const QString &newPath) { if (!isValid()) return; - nativeInfo()->rename_file(index, Utils::Fs::toNativePath(newPath).toStdString()); + nativeInfo()->rename_file(LTFileIndex {index}, Utils::Fs::toNativePath(newPath).toStdString()); } int BitTorrent::TorrentInfo::fileIndex(const QString &fileName) const @@ -428,7 +428,7 @@ void TorrentInfo::stripRootFolder() if (files.name() != testName) { files.set_name(testName); for (int i = 0; i < files.num_files(); ++i) - files.rename_file(i, files.file_path(i)); + files.rename_file(LTFileIndex {i}, files.file_path(LTFileIndex {i})); } files.set_name(""); diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index 4ec7f922b..ee7d3fab8 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -96,7 +96,6 @@ enum AdvSettingsRows DISK_CACHE, DISK_CACHE_TTL, OS_CACHE, - GUIDED_READ_CACHE, COALESCE_RW, SUGGEST_MODE, SEND_BUF_WATERMARK, @@ -166,8 +165,6 @@ void AdvancedSettings::saveAdvancedSettings() session->setDiskCacheTTL(spinBoxCacheTTL.value()); // Enable OS cache session->setUseOSCache(checkBoxOsCache.isChecked()); - // Guided read cache - session->setGuidedReadCacheEnabled(checkBoxGuidedReadCache.isChecked()); // Coalesce reads & writes session->setCoalesceReadWriteEnabled(checkBoxCoalesceRW.isChecked()); // Suggest mode @@ -382,10 +379,6 @@ void AdvancedSettings::loadAdvancedSettings() checkBoxOsCache.setChecked(session->useOSCache()); addRow(OS_CACHE, (tr("Enable OS cache") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#disk_io_write_mode", "(?)")) , &checkBoxOsCache); - // Guided read cache - checkBoxGuidedReadCache.setChecked(session->isGuidedReadCacheEnabled()); - addRow(GUIDED_READ_CACHE, (tr("Guided read cache") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#guided_read_cache", "(?)")) - , &checkBoxGuidedReadCache); // Coalesce reads & writes checkBoxCoalesceRW.setChecked(session->isCoalesceReadWriteEnabled()); addRow(COALESCE_RW, (tr("Coalesce reads & writes") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#coalesce_reads", "(?)")) diff --git a/src/gui/advancedsettings.h b/src/gui/advancedsettings.h index 5d317644a..92d43aa5e 100644 --- a/src/gui/advancedsettings.h +++ b/src/gui/advancedsettings.h @@ -64,7 +64,7 @@ private: QCheckBox checkBoxOsCache, checkBoxRecheckCompleted, checkBoxResolveCountries, checkBoxResolveHosts, checkBoxSuperSeeding, checkBoxProgramNotifications, checkBoxTorrentAddedNotifications, checkBoxTrackerFavicon, checkBoxTrackerStatus, checkBoxConfirmTorrentRecheck, checkBoxConfirmRemoveAllTags, checkBoxListenIPv6, checkBoxAnnounceAllTrackers, checkBoxAnnounceAllTiers, - checkBoxGuidedReadCache, checkBoxMultiConnectionsPerIp, checkBoxSuggestMode, checkBoxCoalesceRW, checkBoxSpeedWidgetEnabled; + checkBoxMultiConnectionsPerIp, checkBoxSuggestMode, checkBoxCoalesceRW, checkBoxSpeedWidgetEnabled; QComboBox comboBoxInterface, comboBoxInterfaceAddress, comboBoxUtpMixedMode, comboBoxChokingAlgorithm, comboBoxSeedChokingAlgorithm; QLineEdit lineEditAnnounceIP; diff --git a/src/gui/optionsdialog.cpp b/src/gui/optionsdialog.cpp index e3dc5de0c..232d102c6 100644 --- a/src/gui/optionsdialog.cpp +++ b/src/gui/optionsdialog.cpp @@ -211,7 +211,6 @@ OptionsDialog::OptionsDialog(QWidget *parent) void (QComboBox::*qComboBoxCurrentIndexChanged)(int) = &QComboBox::currentIndexChanged; void (QSpinBox::*qSpinBoxValueChanged)(int) = &QSpinBox::valueChanged; - connect(m_ui->checkForceProxy, &QAbstractButton::toggled, this, &ThisType::enableForceProxy); connect(m_ui->comboProxyType, qComboBoxCurrentIndexChanged, this, &ThisType::enableProxy); connect(m_ui->checkRandomPort, &QAbstractButton::toggled, m_ui->spinPort, &ThisType::setDisabled); @@ -353,7 +352,6 @@ OptionsDialog::OptionsDialog(QWidget *parent) connect(m_ui->textProxyIP, &QLineEdit::textChanged, this, &ThisType::enableApplyButton); connect(m_ui->spinProxyPort, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); connect(m_ui->checkProxyPeerConnecs, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); - connect(m_ui->checkForceProxy, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->isProxyOnlyForTorrents, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->checkProxyAuth, &QGroupBox::toggled, this, &ThisType::enableApplyButton); connect(m_ui->textProxyUsername, &QLineEdit::textChanged, this, &ThisType::enableApplyButton); @@ -728,7 +726,6 @@ void OptionsDialog::saveOptions() proxyConfigManager->setProxyConfiguration(proxyConf); session->setProxyPeerConnectionsEnabled(m_ui->checkProxyPeerConnecs->isChecked()); - session->setForceProxyEnabled(m_ui->checkForceProxy->isChecked()); // End Connection preferences // Bittorrent preferences @@ -1057,8 +1054,6 @@ void OptionsDialog::loadOptions() m_ui->textProxyPassword->setText(proxyConf.password); m_ui->checkProxyPeerConnecs->setChecked(session->isProxyPeerConnectionsEnabled()); - m_ui->checkForceProxy->setChecked(session->isForceProxyEnabled()); - enableForceProxy(session->isForceProxyEnabled()); m_ui->isProxyOnlyForTorrents->setChecked(proxyConfigManager->isProxyOnlyForTorrents()); enableProxy(m_ui->comboProxyType->currentIndex()); @@ -1358,12 +1353,6 @@ void OptionsDialog::toggleComboRatioLimitAct() m_ui->comboRatioLimitAct->setEnabled(m_ui->checkMaxRatio->isChecked() || m_ui->checkMaxSeedingMinutes->isChecked()); } -void OptionsDialog::enableForceProxy(bool enable) -{ - m_ui->checkUPnP->setEnabled(!enable); - m_ui->checkLSD->setEnabled(!enable); -} - void OptionsDialog::enableProxy(int index) { if (index) { @@ -1373,7 +1362,6 @@ void OptionsDialog::enableProxy(int index) m_ui->lblProxyPort->setEnabled(true); m_ui->spinProxyPort->setEnabled(true); m_ui->checkProxyPeerConnecs->setEnabled(true); - m_ui->checkForceProxy->setEnabled(true); if (index > 1) { m_ui->checkProxyAuth->setEnabled(true); m_ui->isProxyOnlyForTorrents->setEnabled(true); @@ -1384,7 +1372,6 @@ void OptionsDialog::enableProxy(int index) m_ui->isProxyOnlyForTorrents->setEnabled(false); m_ui->isProxyOnlyForTorrents->setChecked(true); } - enableForceProxy(m_ui->checkForceProxy->isChecked()); } else { //disable @@ -1393,11 +1380,9 @@ void OptionsDialog::enableProxy(int index) m_ui->lblProxyPort->setEnabled(false); m_ui->spinProxyPort->setEnabled(false); m_ui->checkProxyPeerConnecs->setEnabled(false); - m_ui->checkForceProxy->setEnabled(false); m_ui->isProxyOnlyForTorrents->setEnabled(false); m_ui->checkProxyAuth->setEnabled(false); m_ui->checkProxyAuth->setChecked(false); - enableForceProxy(false); } } diff --git a/src/gui/optionsdialog.h b/src/gui/optionsdialog.h index f94b562bf..92d228bc0 100644 --- a/src/gui/optionsdialog.h +++ b/src/gui/optionsdialog.h @@ -87,7 +87,6 @@ public slots: void showConnectionTab(); private slots: - void enableForceProxy(bool enable); void enableProxy(int index); void on_buttonBox_accepted(); void closeEvent(QCloseEvent *e) override; diff --git a/src/gui/optionsdialog.ui b/src/gui/optionsdialog.ui index e9efb4dd3..7a3bf911c 100644 --- a/src/gui/optionsdialog.ui +++ b/src/gui/optionsdialog.ui @@ -1633,43 +1633,6 @@ - - - - - - Disable connections not supported by proxies - - - true - - - - - - - (<a href="https://github.com/qbittorrent/qBittorrent/wiki/Disable-connections-not-supported-by-proxies">More information</a>) - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - @@ -3342,7 +3305,6 @@ Use ';' to split multiple entries. Can use wildcard '*'. textProxyIP spinProxyPort checkProxyPeerConnecs - checkForceProxy isProxyOnlyForTorrents checkProxyAuth textProxyUsername diff --git a/src/webui/api/appcontroller.cpp b/src/webui/api/appcontroller.cpp index 5b114c9ce..582371c5a 100644 --- a/src/webui/api/appcontroller.cpp +++ b/src/webui/api/appcontroller.cpp @@ -159,7 +159,6 @@ void AppController::preferencesAction() data["proxy_password"] = proxyConf.password; data["proxy_peer_connections"] = session->isProxyPeerConnectionsEnabled(); - data["force_proxy"] = session->isForceProxyEnabled(); data["proxy_torrents_only"] = proxyManager->isProxyOnlyForTorrents(); // IP Filtering @@ -281,8 +280,6 @@ void AppController::preferencesAction() data["disk_cache_ttl"] = session->diskCacheTTL(); // Enable OS cache data["enable_os_cache"] = session->useOSCache(); - // Guided read cache - data["enable_guided_read_cache"] = session->isGuidedReadCacheEnabled(); // Coalesce reads & writes data["enable_coalesce_read_write"] = session->isCoalesceReadWriteEnabled(); // Suggest mode @@ -467,8 +464,6 @@ void AppController::setPreferencesAction() if (hasKey("proxy_peer_connections")) session->setProxyPeerConnectionsEnabled(it.value().toBool()); - if (hasKey("force_proxy")) - session->setForceProxyEnabled(it.value().toBool()); if (hasKey("proxy_torrents_only")) proxyManager->setProxyOnlyForTorrents(it.value().toBool()); @@ -693,9 +688,6 @@ void AppController::setPreferencesAction() // Enable OS cache if (hasKey("enable_os_cache")) session->setUseOSCache(it.value().toBool()); - // Guided read cache - if (hasKey("enable_guided_read_cache")) - session->setGuidedReadCacheEnabled(it.value().toBool()); // Coalesce reads & writes if (hasKey("enable_coalesce_read_write")) session->setCoalesceReadWriteEnabled(it.value().toBool()); diff --git a/src/webui/www/private/preferences_content.html b/src/webui/www/private/preferences_content.html index 6dc0ac9e0..8d13e022e 100644 --- a/src/webui/www/private/preferences_content.html +++ b/src/webui/www/private/preferences_content.html @@ -321,10 +321,6 @@ -
- - -
@@ -924,14 +920,6 @@ - - - - - - - - @@ -1237,7 +1225,6 @@ $('peer_proxy_host_text').setProperty('disabled', !isPeerProxyTypeSelected); $('peer_proxy_port_value').setProperty('disabled', !isPeerProxyTypeSelected); $('use_peer_proxy_checkbox').setProperty('disabled', !isPeerProxyTypeSelected); - $('force_proxy_checkbox').setProperty('disabled', !isPeerProxyTypeSelected); $('proxy_only_for_torrents_checkbox').setProperty('disabled', !isPeerProxyTypeSelected); if (isPeerProxyTypeSelected) { @@ -1254,14 +1241,6 @@ $('peer_proxy_auth_checkbox').setProperty('checked', isPeerProxyTypeSelected); updatePeerProxyAuthSettings(); } - - updateForceProxySettings(); - }; - - var updateForceProxySettings = function() { - var isForceProxyEnabled = (!$('force_proxy_checkbox').getProperty('disabled')) && ($('force_proxy_checkbox').getProperty('checked')); - $('upnp_checkbox').setProperty('disabled', isForceProxyEnabled); - $('lsd_checkbox').setProperty('disabled', isForceProxyEnabled); }; var updatePeerProxyAuthSettings = function() { @@ -1568,8 +1547,6 @@ $('peer_proxy_host_text').setProperty('value', pref.proxy_ip); $('peer_proxy_port_value').setProperty('value', pref.proxy_port); $('use_peer_proxy_checkbox').setProperty('checked', pref.proxy_peer_connections); - $('force_proxy_checkbox').setProperty('checked', pref.force_proxy); - updateForceProxySettings(); $('proxy_only_for_torrents_checkbox').setProperty('checked', pref.proxy_torrents_only); $('peer_proxy_auth_checkbox').setProperty('checked', pref.proxy_auth_enabled); updatePeerProxyAuthSettings(); @@ -1703,7 +1680,6 @@ $('diskCache').setProperty('value', pref.disk_cache); $('diskCacheExpiryInterval').setProperty('value', pref.disk_cache_ttl); $('enableOSCache').setProperty('checked', pref.enable_os_cache); - $('guidedReadCache').setProperty('checked', pref.enable_guided_read_cache); $('coalesceReadsAndWrites').setProperty('checked', pref.enable_coalesce_read_write); $('sendUploadPieceSuggestions').setProperty('checked', pref.enable_upload_suggestions); $('sendBufferWatermark').setProperty('value', pref.send_buffer_watermark); @@ -1856,7 +1832,6 @@ settings.set('proxy_ip', $('peer_proxy_host_text').getProperty('value')); settings.set('proxy_port', $('peer_proxy_port_value').getProperty('value').toInt()); settings.set('proxy_peer_connections', $('use_peer_proxy_checkbox').getProperty('checked')); - settings.set('force_proxy', $('force_proxy_checkbox').getProperty('checked')); settings.set('proxy_torrents_only', $('proxy_only_for_torrents_checkbox').getProperty('checked')); settings.set('proxy_username', $('peer_proxy_username_text').getProperty('value')); settings.set('proxy_password', $('peer_proxy_password_text').getProperty('value')); @@ -2069,7 +2044,6 @@ settings.set('disk_cache', $('diskCache').getProperty('value')); settings.set('disk_cache_ttl', $('diskCacheExpiryInterval').getProperty('value')); settings.set('enable_os_cache', $('enableOSCache').getProperty('checked')); - settings.set('enable_guided_read_cache', $('guidedReadCache').getProperty('checked')); settings.set('enable_coalesce_read_write', $('coalesceReadsAndWrites').getProperty('checked')); settings.set('enable_upload_suggestions', $('sendUploadPieceSuggestions').getProperty('checked')); settings.set('send_buffer_watermark', $('sendBufferWatermark').getProperty('value'));