Browse Source

Don't use deprecated libtorrent features

adaptive-webui-19844
Vladimir Golovnev (Glassez) 5 years ago
parent
commit
60ffa3030e
No known key found for this signature in database
GPG Key ID: 52A2C7DEE2DFA6F7
  1. 1
      src/base/CMakeLists.txt
  2. 1
      src/base/base.pri
  3. 61
      src/base/bittorrent/private/ltunderlyingtype.h
  4. 62
      src/base/bittorrent/session.cpp
  5. 6
      src/base/bittorrent/session.h
  6. 18
      src/base/bittorrent/torrentcreatorthread.cpp
  7. 58
      src/base/bittorrent/torrenthandle.cpp
  8. 8
      src/base/bittorrent/torrenthandle.h
  9. 4
      src/base/bittorrent/torrentinfo.cpp
  10. 7
      src/gui/advancedsettings.cpp
  11. 2
      src/gui/advancedsettings.h
  12. 15
      src/gui/optionsdialog.cpp
  13. 1
      src/gui/optionsdialog.h
  14. 38
      src/gui/optionsdialog.ui
  15. 8
      src/webui/api/appcontroller.cpp
  16. 26
      src/webui/www/private/preferences_content.html

1
src/base/CMakeLists.txt

@ -10,6 +10,7 @@ bittorrent/magneturi.h
bittorrent/peerinfo.h bittorrent/peerinfo.h
bittorrent/private/bandwidthscheduler.h bittorrent/private/bandwidthscheduler.h
bittorrent/private/filterparserthread.h bittorrent/private/filterparserthread.h
bittorrent/private/ltunderlyingtype.h
bittorrent/private/portforwarderimpl.h bittorrent/private/portforwarderimpl.h
bittorrent/private/resumedatasavingmanager.h bittorrent/private/resumedatasavingmanager.h
bittorrent/private/speedmonitor.h bittorrent/private/speedmonitor.h

1
src/base/base.pri

@ -9,6 +9,7 @@ HEADERS += \
$$PWD/bittorrent/peerinfo.h \ $$PWD/bittorrent/peerinfo.h \
$$PWD/bittorrent/private/bandwidthscheduler.h \ $$PWD/bittorrent/private/bandwidthscheduler.h \
$$PWD/bittorrent/private/filterparserthread.h \ $$PWD/bittorrent/private/filterparserthread.h \
$$PWD/bittorrent/private/ltunderlyingtype.h \
$$PWD/bittorrent/private/portforwarderimpl.h \ $$PWD/bittorrent/private/portforwarderimpl.h \
$$PWD/bittorrent/private/resumedatasavingmanager.h \ $$PWD/bittorrent/private/resumedatasavingmanager.h \
$$PWD/bittorrent/private/speedmonitor.h \ $$PWD/bittorrent/private/speedmonitor.h \

61
src/base/bittorrent/private/ltunderlyingtype.h

@ -0,0 +1,61 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2019 Vladimir Golovnev <glassez@yandex.ru>
*
* 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 <type_traits>
template <typename ...>
using void_t = void; // replace this with std::void_t in C++17
template <typename T, typename = void>
struct HasUnderlyingType
: std::false_type
{
};
template <typename T>
struct HasUnderlyingType<T, void_t<typename T::underlying_type>>
: std::true_type
{
};
template <typename T, typename = void>
struct LTUnderlying
{
using type = T;
};
template <typename T>
struct LTUnderlying<T, typename std::enable_if_t<HasUnderlyingType<T>::value>>
{
using type = typename T::underlying_type;
};
template <typename T>
using LTUnderlyingType = typename LTUnderlying<T>::type;

62
src/base/bittorrent/session.cpp

@ -86,6 +86,7 @@
#include "magneturi.h" #include "magneturi.h"
#include "private/bandwidthscheduler.h" #include "private/bandwidthscheduler.h"
#include "private/filterparserthread.h" #include "private/filterparserthread.h"
#include "private/ltunderlyingtype.h"
#include "private/portforwarderimpl.h" #include "private/portforwarderimpl.h"
#include "private/resumedatasavingmanager.h" #include "private/resumedatasavingmanager.h"
#include "private/statistics.h" #include "private/statistics.h"
@ -106,10 +107,16 @@ using namespace BitTorrent;
namespace namespace
{ {
#if (LIBTORRENT_VERSION_NUM < 10200) #if (LIBTORRENT_VERSION_NUM < 10200)
using LTAlertCategory = int;
using LTPeerClass = int;
using LTQueuePosition = int;
using LTSessionFlags = int; using LTSessionFlags = int;
using LTStatusFlags = int; using LTStatusFlags = int;
using LTString = std::string; using LTString = std::string;
#else #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 LTSessionFlags = lt::session_flags_t;
using LTStatusFlags = lt::status_flags_t; using LTStatusFlags = lt::status_flags_t;
using LTString = lt::string_view; using LTString = lt::string_view;
@ -277,7 +284,6 @@ Session::Session(QObject *parent)
, m_diskCacheSize(BITTORRENT_SESSION_KEY("DiskCacheSize"), 64) , m_diskCacheSize(BITTORRENT_SESSION_KEY("DiskCacheSize"), 64)
, m_diskCacheTTL(BITTORRENT_SESSION_KEY("DiskCacheTTL"), 60) , m_diskCacheTTL(BITTORRENT_SESSION_KEY("DiskCacheTTL"), 60)
, m_useOSCache(BITTORRENT_SESSION_KEY("UseOSCache"), true) , m_useOSCache(BITTORRENT_SESSION_KEY("UseOSCache"), true)
, m_guidedReadCacheEnabled(BITTORRENT_SESSION_KEY("GuidedReadCache"), true)
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
, m_coalesceReadWriteEnabled(BITTORRENT_SESSION_KEY("CoalesceReadWrite"), true) , m_coalesceReadWriteEnabled(BITTORRENT_SESSION_KEY("CoalesceReadWrite"), true)
#else #else
@ -338,7 +344,6 @@ Session::Session(QObject *parent)
, m_networkInterfaceAddress(BITTORRENT_SESSION_KEY("InterfaceAddress")) , m_networkInterfaceAddress(BITTORRENT_SESSION_KEY("InterfaceAddress"))
, m_isIPv6Enabled(BITTORRENT_SESSION_KEY("IPv6Enabled"), false) , m_isIPv6Enabled(BITTORRENT_SESSION_KEY("IPv6Enabled"), false)
, m_encryption(BITTORRENT_SESSION_KEY("Encryption"), 0) , m_encryption(BITTORRENT_SESSION_KEY("Encryption"), 0)
, m_isForceProxyEnabled(BITTORRENT_SESSION_KEY("ForceProxy"), true)
, m_isProxyPeerConnectionsEnabled(BITTORRENT_SESSION_KEY("ProxyPeerConnections"), false) , m_isProxyPeerConnectionsEnabled(BITTORRENT_SESSION_KEY("ProxyPeerConnections"), false)
, m_chokingAlgorithm(BITTORRENT_SESSION_KEY("ChokingAlgorithm"), ChokingAlgorithm::FixedSlots , m_chokingAlgorithm(BITTORRENT_SESSION_KEY("ChokingAlgorithm"), ChokingAlgorithm::FixedSlots
, clampValue(ChokingAlgorithm::FixedSlots, ChokingAlgorithm::RateBased)) , clampValue(ChokingAlgorithm::FixedSlots, ChokingAlgorithm::RateBased))
@ -381,7 +386,7 @@ Session::Session(QObject *parent)
connect(m_seedingLimitTimer, &QTimer::timeout, this, &Session::processShareLimits); connect(m_seedingLimitTimer, &QTimer::timeout, this, &Session::processShareLimits);
// Set severity level of libtorrent session // 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::peer_notification
| lt::alert::port_mapping_notification | lt::alert::port_mapping_notification
| lt::alert::storage_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::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_trackers, announceToAllTrackers());
settingsPack.set_bool(lt::settings_pack::announce_to_all_tiers, announceToAllTiers()); 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; : 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_read_mode, mode);
settingsPack.set_int(lt::settings_pack::disk_io_write_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_reads, isCoalesceReadWriteEnabled());
settingsPack.set_bool(lt::settings_pack::coalesce_writes, 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() // Proactively do the same for 0.0.0.0 and address_v4::any()
f.add_rule(lt::address_v4::any() f.add_rule(lt::address_v4::any()
, lt::address_v4::broadcast() , lt::address_v4::broadcast()
, 1 << lt::session::global_peer_class_id); , 1 << static_cast<LTUnderlyingType<LTPeerClass>>(lt::session::global_peer_class_id));
#if (LIBTORRENT_VERSION_NUM >= 10200) || TORRENT_USE_IPV6 #if (LIBTORRENT_VERSION_NUM >= 10200) || TORRENT_USE_IPV6
// IPv6 may not be available on OS and the parsing // IPv6 may not be available on OS and the parsing
@ -1407,7 +1409,7 @@ void Session::configurePeerClasses()
try { try {
f.add_rule(lt::address_v6::any() f.add_rule(lt::address_v6::any()
, lt::address_v6::from_string("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff") , lt::address_v6::from_string("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")
, 1 << lt::session::global_peer_class_id); , 1 << static_cast<LTUnderlyingType<LTPeerClass>>(lt::session::global_peer_class_id));
} }
catch (const std::exception &) {} catch (const std::exception &) {}
#endif #endif
@ -1416,21 +1418,21 @@ void Session::configurePeerClasses()
// local networks // local networks
f.add_rule(lt::address_v4::from_string("10.0.0.0") f.add_rule(lt::address_v4::from_string("10.0.0.0")
, lt::address_v4::from_string("10.255.255.255") , lt::address_v4::from_string("10.255.255.255")
, 1 << lt::session::local_peer_class_id); , 1 << static_cast<LTUnderlyingType<LTPeerClass>>(lt::session::local_peer_class_id));
f.add_rule(lt::address_v4::from_string("172.16.0.0") f.add_rule(lt::address_v4::from_string("172.16.0.0")
, lt::address_v4::from_string("172.31.255.255") , lt::address_v4::from_string("172.31.255.255")
, 1 << lt::session::local_peer_class_id); , 1 << static_cast<LTUnderlyingType<LTPeerClass>>(lt::session::local_peer_class_id));
f.add_rule(lt::address_v4::from_string("192.168.0.0") f.add_rule(lt::address_v4::from_string("192.168.0.0")
, lt::address_v4::from_string("192.168.255.255") , lt::address_v4::from_string("192.168.255.255")
, 1 << lt::session::local_peer_class_id); , 1 << static_cast<LTUnderlyingType<LTPeerClass>>(lt::session::local_peer_class_id));
// link local // link local
f.add_rule(lt::address_v4::from_string("169.254.0.0") f.add_rule(lt::address_v4::from_string("169.254.0.0")
, lt::address_v4::from_string("169.254.255.255") , lt::address_v4::from_string("169.254.255.255")
, 1 << lt::session::local_peer_class_id); , 1 << static_cast<LTUnderlyingType<LTPeerClass>>(lt::session::local_peer_class_id));
// loopback // loopback
f.add_rule(lt::address_v4::from_string("127.0.0.0") f.add_rule(lt::address_v4::from_string("127.0.0.0")
, lt::address_v4::from_string("127.255.255.255") , lt::address_v4::from_string("127.255.255.255")
, 1 << lt::session::local_peer_class_id); , 1 << static_cast<LTUnderlyingType<LTPeerClass>>(lt::session::local_peer_class_id));
#if (LIBTORRENT_VERSION_NUM >= 10200) || TORRENT_USE_IPV6 #if (LIBTORRENT_VERSION_NUM >= 10200) || TORRENT_USE_IPV6
// IPv6 may not be available on OS and the parsing // IPv6 may not be available on OS and the parsing
@ -1440,15 +1442,15 @@ void Session::configurePeerClasses()
// link local // link local
f.add_rule(lt::address_v6::from_string("fe80::") f.add_rule(lt::address_v6::from_string("fe80::")
, lt::address_v6::from_string("febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff") , lt::address_v6::from_string("febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff")
, 1 << lt::session::local_peer_class_id); , 1 << static_cast<LTUnderlyingType<LTPeerClass>>(lt::session::local_peer_class_id));
// unique local addresses // unique local addresses
f.add_rule(lt::address_v6::from_string("fc00::") f.add_rule(lt::address_v6::from_string("fc00::")
, lt::address_v6::from_string("fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff") , lt::address_v6::from_string("fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")
, 1 << lt::session::local_peer_class_id); , 1 << static_cast<LTUnderlyingType<LTPeerClass>>(lt::session::local_peer_class_id));
// loopback // loopback
f.add_rule(lt::address_v6::loopback() f.add_rule(lt::address_v6::loopback()
, lt::address_v6::loopback() , lt::address_v6::loopback()
, 1 << lt::session::local_peer_class_id); , 1 << static_cast<LTUnderlyingType<LTPeerClass>>(lt::session::local_peer_class_id));
} }
catch (const std::exception &) {} catch (const std::exception &) {}
#endif #endif
@ -2206,7 +2208,7 @@ void Session::saveTorrentsQueue()
QMap<int, QString> queue; // Use QMap since it should be ordered by key QMap<int, QString> queue; // Use QMap since it should be ordered by key
for (const TorrentHandle *torrent : asConst(torrents())) { for (const TorrentHandle *torrent : asConst(torrents())) {
// We require actual (non-cached) queue position here! // We require actual (non-cached) queue position here!
const int queuePos = torrent->nativeHandle().queue_position(); const int queuePos = LTUnderlyingType<LTQueuePosition> {torrent->nativeHandle().queue_position()};
if (queuePos >= 0) if (queuePos >= 0)
queue[queuePos] = torrent->hash(); 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 bool Session::isProxyPeerConnectionsEnabled() const
{ {
return m_isProxyPeerConnectionsEnabled; 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 bool Session::isCoalesceReadWriteEnabled() const
{ {
return m_coalesceReadWriteEnabled; return m_coalesceReadWriteEnabled;

6
src/base/bittorrent/session.h

@ -298,8 +298,6 @@ namespace BitTorrent
void setIPv6Enabled(bool enabled); void setIPv6Enabled(bool enabled);
int encryption() const; int encryption() const;
void setEncryption(int state); void setEncryption(int state);
bool isForceProxyEnabled() const;
void setForceProxyEnabled(bool enabled);
bool isProxyPeerConnectionsEnabled() const; bool isProxyPeerConnectionsEnabled() const;
void setProxyPeerConnectionsEnabled(bool enabled); void setProxyPeerConnectionsEnabled(bool enabled);
ChokingAlgorithm chokingAlgorithm() const; ChokingAlgorithm chokingAlgorithm() const;
@ -330,8 +328,6 @@ namespace BitTorrent
void setDiskCacheTTL(int ttl); void setDiskCacheTTL(int ttl);
bool useOSCache() const; bool useOSCache() const;
void setUseOSCache(bool use); void setUseOSCache(bool use);
bool isGuidedReadCacheEnabled() const;
void setGuidedReadCacheEnabled(bool enabled);
bool isCoalesceReadWriteEnabled() const; bool isCoalesceReadWriteEnabled() const;
void setCoalesceReadWriteEnabled(bool enabled); void setCoalesceReadWriteEnabled(bool enabled);
bool isSuggestModeEnabled() const; bool isSuggestModeEnabled() const;
@ -595,7 +591,6 @@ namespace BitTorrent
CachedSettingValue<int> m_diskCacheSize; CachedSettingValue<int> m_diskCacheSize;
CachedSettingValue<int> m_diskCacheTTL; CachedSettingValue<int> m_diskCacheTTL;
CachedSettingValue<bool> m_useOSCache; CachedSettingValue<bool> m_useOSCache;
CachedSettingValue<bool> m_guidedReadCacheEnabled;
CachedSettingValue<bool> m_coalesceReadWriteEnabled; CachedSettingValue<bool> m_coalesceReadWriteEnabled;
CachedSettingValue<bool> m_isSuggestMode; CachedSettingValue<bool> m_isSuggestMode;
CachedSettingValue<int> m_sendBufferWatermark; CachedSettingValue<int> m_sendBufferWatermark;
@ -650,7 +645,6 @@ namespace BitTorrent
CachedSettingValue<QString> m_networkInterfaceAddress; CachedSettingValue<QString> m_networkInterfaceAddress;
CachedSettingValue<bool> m_isIPv6Enabled; CachedSettingValue<bool> m_isIPv6Enabled;
CachedSettingValue<int> m_encryption; CachedSettingValue<int> m_encryption;
CachedSettingValue<bool> m_isForceProxyEnabled;
CachedSettingValue<bool> m_isProxyPeerConnectionsEnabled; CachedSettingValue<bool> m_isProxyPeerConnectionsEnabled;
CachedSettingValue<ChokingAlgorithm> m_chokingAlgorithm; CachedSettingValue<ChokingAlgorithm> m_chokingAlgorithm;
CachedSettingValue<SeedChokingAlgorithm> m_seedChokingAlgorithm; CachedSettingValue<SeedChokingAlgorithm> m_seedChokingAlgorithm;

18
src/base/bittorrent/torrentcreatorthread.cpp

@ -44,14 +44,17 @@
#include "base/global.h" #include "base/global.h"
#include "base/utils/fs.h" #include "base/utils/fs.h"
#include "base/utils/string.h" #include "base/utils/string.h"
#include "private/ltunderlyingtype.h"
namespace namespace
{ {
#if (LIBTORRENT_VERSION_NUM < 10200) #if (LIBTORRENT_VERSION_NUM < 10200)
using CreateFlags = int; using LTCreateFlags = int;
using LTPieceIndex = int;
#else #else
using CreateFlags = lt::create_flags_t; using LTCreateFlags = lt::create_flags_t;
#endif using LTPieceIndex = lt::piece_index_t;
#endif
// do not include files and folders whose // do not include files and folders whose
// name starts with a . // name starts with a .
@ -136,7 +139,7 @@ void TorrentCreatorThread::run()
if (isInterruptionRequested()) return; if (isInterruptionRequested()) return;
lt::create_torrent newTorrent(fs, m_params.pieceSize, -1 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 // Add url seeds
for (QString seed : asConst(m_params.urlSeeds)) { for (QString seed : asConst(m_params.urlSeeds)) {
@ -157,7 +160,10 @@ void TorrentCreatorThread::run()
// calculate the hash for all pieces // calculate the hash for all pieces
lt::set_piece_hashes(newTorrent, Utils::Fs::toNativePath(parentPath).toStdString() 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<LTPieceIndex> {n}, newTorrent.num_pieces());
});
// Set qBittorrent as creator and add user comment to // Set qBittorrent as creator and add user comment to
// torrent_info structure // torrent_info structure
newTorrent.set_creator(creatorStr.toUtf8().constData()); 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); lt::add_files(fs, Utils::Fs::toNativePath(inputPath).toStdString(), fileFilter);
return lt::create_torrent(fs, pieceSize, -1 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();
} }

58
src/base/bittorrent/torrenthandle.cpp

@ -66,6 +66,7 @@
#include "base/utils/string.h" #include "base/utils/string.h"
#include "downloadpriority.h" #include "downloadpriority.h"
#include "peerinfo.h" #include "peerinfo.h"
#include "private/ltunderlyingtype.h"
#include "session.h" #include "session.h"
#include "trackerentry.h" #include "trackerentry.h"
@ -77,11 +78,13 @@ namespace
{ {
#if (LIBTORRENT_VERSION_NUM < 10200) #if (LIBTORRENT_VERSION_NUM < 10200)
using LTDownloadPriority = int; using LTDownloadPriority = int;
using LTDownloadPriorityUnderlyingType = int; using LTFileIndex = int;
using LTPieceIndex = int;
using LTQueuePosition = int; using LTQueuePosition = int;
#else #else
using LTDownloadPriority = lt::download_priority_t; 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; using LTQueuePosition = lt::queue_position_t;
#endif #endif
@ -92,7 +95,7 @@ namespace
, std::back_inserter(out), [](BitTorrent::DownloadPriority priority) , std::back_inserter(out), [](BitTorrent::DownloadPriority priority)
{ {
return static_cast<LTDownloadPriority>( return static_cast<LTDownloadPriority>(
static_cast<LTDownloadPriorityUnderlyingType>(priority)); static_cast<LTUnderlyingType<LTDownloadPriority>>(priority));
}); });
return out; return out;
} }
@ -377,7 +380,7 @@ bool TorrentHandle::isAutoManaged() const
#if (LIBTORRENT_VERSION_NUM < 10200) #if (LIBTORRENT_VERSION_NUM < 10200)
return m_nativeStatus.auto_managed; return m_nativeStatus.auto_managed;
#else #else
return (m_nativeStatus.flags & lt::torrent_flags::auto_managed); return bool {m_nativeStatus.flags & lt::torrent_flags::auto_managed};
#endif #endif
} }
@ -680,7 +683,7 @@ QStringList TorrentHandle::absoluteFilePathsUnwanted() const
QStringList res; QStringList res;
for (int i = 0; i < static_cast<int>(fp.size()); ++i) { for (int i = 0; i < static_cast<int>(fp.size()); ++i) {
if (fp[i] == 0) { if (fp[i] == LTDownloadPriority {0}) {
const QString path = Utils::Fs::expandPathAbs(saveDir.absoluteFilePath(filePath(i))); const QString path = Utils::Fs::expandPathAbs(saveDir.absoluteFilePath(filePath(i)));
if (path.contains(".unwanted")) if (path.contains(".unwanted"))
res << path; res << path;
@ -701,8 +704,7 @@ QVector<DownloadPriority> TorrentHandle::filePriorities() const
QVector<DownloadPriority> ret; QVector<DownloadPriority> ret;
std::transform(fp.cbegin(), fp.cend(), std::back_inserter(ret), [](LTDownloadPriority priority) std::transform(fp.cbegin(), fp.cend(), std::back_inserter(ret), [](LTDownloadPriority priority)
{ {
return static_cast<DownloadPriority>( return static_cast<DownloadPriority>(LTUnderlyingType<LTDownloadPriority> {priority});
static_cast<std::underlying_type<DownloadPriority>::type>(priority));
}); });
return ret; return ret;
} }
@ -825,7 +827,7 @@ bool TorrentHandle::isSequentialDownload() const
#if (LIBTORRENT_VERSION_NUM < 10200) #if (LIBTORRENT_VERSION_NUM < 10200)
return m_nativeStatus.sequential_download; return m_nativeStatus.sequential_download;
#else #else
return (m_nativeStatus.flags & lt::torrent_flags::sequential_download); return bool {m_nativeStatus.flags & lt::torrent_flags::sequential_download};
#endif #endif
} }
@ -840,13 +842,13 @@ bool TorrentHandle::hasFirstLastPiecePriority() const
const std::vector<LTDownloadPriority> filePriorities = nativeHandle().get_file_priorities(); const std::vector<LTDownloadPriority> filePriorities = nativeHandle().get_file_priorities();
#endif #endif
for (int i = 0; i < static_cast<int>(filePriorities.size()); ++i) { for (int i = 0; i < static_cast<int>(filePriorities.size()); ++i) {
if (filePriorities[i] <= 0) if (filePriorities[i] <= LTDownloadPriority {0})
continue; continue;
const TorrentInfo::PieceRange extremities = info().filePieces(i); const TorrentInfo::PieceRange extremities = info().filePieces(i);
const int firstPiecePrio = nativeHandle().piece_priority(extremities.first()); const LTDownloadPriority firstPiecePrio = nativeHandle().piece_priority(LTPieceIndex {extremities.first()});
const int lastPiecePrio = nativeHandle().piece_priority(extremities.last()); const LTDownloadPriority lastPiecePrio = nativeHandle().piece_priority(LTPieceIndex {extremities.last()});
return ((firstPiecePrio == 7) && (lastPiecePrio == 7)); return ((firstPiecePrio == LTDownloadPriority {7}) && (lastPiecePrio == LTDownloadPriority {7}));
} }
return false; return false;
@ -1149,7 +1151,7 @@ bool TorrentHandle::superSeeding() const
#if (LIBTORRENT_VERSION_NUM < 10200) #if (LIBTORRENT_VERSION_NUM < 10200)
return m_nativeStatus.super_seeding; return m_nativeStatus.super_seeding;
#else #else
return (m_nativeStatus.flags & lt::torrent_flags::super_seeding); return bool {m_nativeStatus.flags & lt::torrent_flags::super_seeding};
#endif #endif
} }
@ -1171,7 +1173,7 @@ QBitArray TorrentHandle::pieces() const
QBitArray result(m_nativeStatus.pieces.size()); QBitArray result(m_nativeStatus.pieces.size());
for (int i = 0; i < m_nativeStatus.pieces.size(); ++i) 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; return result;
} }
@ -1184,7 +1186,11 @@ QBitArray TorrentHandle::downloadingPieces() const
m_nativeHandle.get_download_queue(queue); m_nativeHandle.get_download_queue(queue);
for (const lt::partial_piece_info &info : queue) for (const lt::partial_piece_info &info : queue)
#if (LIBTORRENT_VERSION_NUM < 10200)
result.setBit(info.piece_index); result.setBit(info.piece_index);
#else
result.setBit(LTUnderlyingType<LTPieceIndex> {info.piece_index});
#endif
return result; return result;
} }
@ -1410,7 +1416,7 @@ void TorrentHandle::setFirstLastPiecePriorityImpl(const bool enabled, const QVec
continue; continue;
// Determine the priority to set // 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); const TorrentInfo::PieceRange extremities = info().filePieces(index);
// worst case: AVI index = 1% of total file size (at the end of the file) // 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; if (m_startupState != Started) return;
m_oldPath[LTFileIndex {index}].push_back(filePath(index)); m_oldPath[index].push_back(filePath(index));
++m_renameCount; ++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) bool TorrentHandle::saveTorrentFile(const QString &path)
@ -1807,11 +1813,11 @@ void TorrentHandle::handleFileRenamedAlert(const lt::file_renamed_alert *p)
// remove empty leftover folders // remove empty leftover folders
// for example renaming "a/b/c" to "d/b/c", then folders "a/b" and "a" will // for example renaming "a/b/c" to "d/b/c", then folders "a/b" and "a" will
// be removed if they are empty // be removed if they are empty
const QString oldFilePath = m_oldPath[LTFileIndex {p->index}].takeFirst(); const QString oldFilePath = m_oldPath[LTUnderlyingType<LTFileIndex> {p->index}].takeFirst();
const QString newFilePath = Utils::Fs::toUniformPath(p->new_name()); const QString newFilePath = Utils::Fs::toUniformPath(p->new_name());
if (m_oldPath[LTFileIndex {p->index}].isEmpty()) if (m_oldPath[LTUnderlyingType<LTFileIndex> {p->index}].isEmpty())
m_oldPath.remove(LTFileIndex {p->index}); m_oldPath.remove(LTUnderlyingType<LTFileIndex> {p->index});
QVector<QStringRef> oldPathParts = oldFilePath.splitRef('/', QString::SkipEmptyParts); QVector<QStringRef> oldPathParts = oldFilePath.splitRef('/', QString::SkipEmptyParts);
oldPathParts.removeLast(); // drop file name part 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) void TorrentHandle::handleFileRenameFailedAlert(const lt::file_rename_failed_alert *p)
{ {
LogMsg(tr("File rename failed. Torrent: \"%1\", file: \"%2\", reason: \"%3\"") LogMsg(tr("File rename failed. Torrent: \"%1\", file: \"%2\", reason: \"%3\"")
.arg(name(), filePath(p->index) .arg(name(), filePath(LTUnderlyingType<LTFileIndex> {p->index})
, QString::fromStdString(p->error.message())), Log::WARNING); , QString::fromStdString(p->error.message())), Log::WARNING);
m_oldPath[LTFileIndex {p->index}].removeFirst(); m_oldPath[LTUnderlyingType<LTFileIndex> {p->index}].removeFirst();
if (m_oldPath[LTFileIndex {p->index}].isEmpty()) if (m_oldPath[LTUnderlyingType<LTFileIndex> {p->index}].isEmpty())
m_oldPath.remove(LTFileIndex {p->index}); m_oldPath.remove(LTUnderlyingType<LTFileIndex> {p->index});
--m_renameCount; --m_renameCount;
while (!isMoveInProgress() && (m_renameCount == 0) && !m_moveFinishedTriggers.isEmpty()) 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())); qDebug("A file completed download in torrent \"%s\"", qUtf8Printable(name()));
if (m_session->isAppendExtensionEnabled()) { if (m_session->isAppendExtensionEnabled()) {
QString name = filePath(p->index); QString name = filePath(LTUnderlyingType<LTFileIndex> {p->index});
if (name.endsWith(QB_EXT)) { if (name.endsWith(QB_EXT)) {
const QString oldName = name; const QString oldName = name;
name.chop(QB_EXT.size()); name.chop(QB_EXT.size());
qDebug("Renaming %s to %s", qUtf8Printable(oldName), qUtf8Printable(name)); qDebug("Renaming %s to %s", qUtf8Printable(oldName), qUtf8Printable(name));
renameFile(p->index, name); renameFile(LTUnderlyingType<LTFileIndex> {p->index}, name);
} }
} }
} }

8
src/base/bittorrent/torrenthandle.h

@ -355,12 +355,6 @@ namespace BitTorrent
private: private:
typedef std::function<void ()> EventTrigger; typedef std::function<void ()> EventTrigger;
#if (LIBTORRENT_VERSION_NUM < 10200)
using LTFileIndex = int;
#else
using LTFileIndex = lt::file_index_t;
#endif
void updateStatus(); void updateStatus();
void updateStatus(const lt::torrent_status &nativeStatus); void updateStatus(const lt::torrent_status &nativeStatus);
void updateState(); void updateState();
@ -425,7 +419,7 @@ namespace BitTorrent
// Until libtorrent provide an "old_name" field in `file_renamed_alert` // Until libtorrent provide an "old_name" field in `file_renamed_alert`
// we will rely on this workaround to remove empty leftover folders // we will rely on this workaround to remove empty leftover folders
QHash<LTFileIndex, QVector<QString>> m_oldPath; QHash<int, QVector<QString>> m_oldPath;
bool m_useAutoTMM; bool m_useAutoTMM;

4
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) void TorrentInfo::renameFile(const int index, const QString &newPath)
{ {
if (!isValid()) return; 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 int BitTorrent::TorrentInfo::fileIndex(const QString &fileName) const
@ -428,7 +428,7 @@ void TorrentInfo::stripRootFolder()
if (files.name() != testName) { if (files.name() != testName) {
files.set_name(testName); files.set_name(testName);
for (int i = 0; i < files.num_files(); ++i) 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(""); files.set_name("");

7
src/gui/advancedsettings.cpp

@ -96,7 +96,6 @@ enum AdvSettingsRows
DISK_CACHE, DISK_CACHE,
DISK_CACHE_TTL, DISK_CACHE_TTL,
OS_CACHE, OS_CACHE,
GUIDED_READ_CACHE,
COALESCE_RW, COALESCE_RW,
SUGGEST_MODE, SUGGEST_MODE,
SEND_BUF_WATERMARK, SEND_BUF_WATERMARK,
@ -166,8 +165,6 @@ void AdvancedSettings::saveAdvancedSettings()
session->setDiskCacheTTL(spinBoxCacheTTL.value()); session->setDiskCacheTTL(spinBoxCacheTTL.value());
// Enable OS cache // Enable OS cache
session->setUseOSCache(checkBoxOsCache.isChecked()); session->setUseOSCache(checkBoxOsCache.isChecked());
// Guided read cache
session->setGuidedReadCacheEnabled(checkBoxGuidedReadCache.isChecked());
// Coalesce reads & writes // Coalesce reads & writes
session->setCoalesceReadWriteEnabled(checkBoxCoalesceRW.isChecked()); session->setCoalesceReadWriteEnabled(checkBoxCoalesceRW.isChecked());
// Suggest mode // Suggest mode
@ -382,10 +379,6 @@ void AdvancedSettings::loadAdvancedSettings()
checkBoxOsCache.setChecked(session->useOSCache()); checkBoxOsCache.setChecked(session->useOSCache());
addRow(OS_CACHE, (tr("Enable OS cache") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#disk_io_write_mode", "(?)")) addRow(OS_CACHE, (tr("Enable OS cache") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#disk_io_write_mode", "(?)"))
, &checkBoxOsCache); , &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 // Coalesce reads & writes
checkBoxCoalesceRW.setChecked(session->isCoalesceReadWriteEnabled()); checkBoxCoalesceRW.setChecked(session->isCoalesceReadWriteEnabled());
addRow(COALESCE_RW, (tr("Coalesce reads & writes") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#coalesce_reads", "(?)")) addRow(COALESCE_RW, (tr("Coalesce reads & writes") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#coalesce_reads", "(?)"))

2
src/gui/advancedsettings.h

@ -64,7 +64,7 @@ private:
QCheckBox checkBoxOsCache, checkBoxRecheckCompleted, checkBoxResolveCountries, checkBoxResolveHosts, checkBoxSuperSeeding, QCheckBox checkBoxOsCache, checkBoxRecheckCompleted, checkBoxResolveCountries, checkBoxResolveHosts, checkBoxSuperSeeding,
checkBoxProgramNotifications, checkBoxTorrentAddedNotifications, checkBoxTrackerFavicon, checkBoxTrackerStatus, checkBoxProgramNotifications, checkBoxTorrentAddedNotifications, checkBoxTrackerFavicon, checkBoxTrackerStatus,
checkBoxConfirmTorrentRecheck, checkBoxConfirmRemoveAllTags, checkBoxListenIPv6, checkBoxAnnounceAllTrackers, checkBoxAnnounceAllTiers, checkBoxConfirmTorrentRecheck, checkBoxConfirmRemoveAllTags, checkBoxListenIPv6, checkBoxAnnounceAllTrackers, checkBoxAnnounceAllTiers,
checkBoxGuidedReadCache, checkBoxMultiConnectionsPerIp, checkBoxSuggestMode, checkBoxCoalesceRW, checkBoxSpeedWidgetEnabled; checkBoxMultiConnectionsPerIp, checkBoxSuggestMode, checkBoxCoalesceRW, checkBoxSpeedWidgetEnabled;
QComboBox comboBoxInterface, comboBoxInterfaceAddress, comboBoxUtpMixedMode, comboBoxChokingAlgorithm, comboBoxSeedChokingAlgorithm; QComboBox comboBoxInterface, comboBoxInterfaceAddress, comboBoxUtpMixedMode, comboBoxChokingAlgorithm, comboBoxSeedChokingAlgorithm;
QLineEdit lineEditAnnounceIP; QLineEdit lineEditAnnounceIP;

15
src/gui/optionsdialog.cpp

@ -211,7 +211,6 @@ OptionsDialog::OptionsDialog(QWidget *parent)
void (QComboBox::*qComboBoxCurrentIndexChanged)(int) = &QComboBox::currentIndexChanged; void (QComboBox::*qComboBoxCurrentIndexChanged)(int) = &QComboBox::currentIndexChanged;
void (QSpinBox::*qSpinBoxValueChanged)(int) = &QSpinBox::valueChanged; 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->comboProxyType, qComboBoxCurrentIndexChanged, this, &ThisType::enableProxy);
connect(m_ui->checkRandomPort, &QAbstractButton::toggled, m_ui->spinPort, &ThisType::setDisabled); 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->textProxyIP, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
connect(m_ui->spinProxyPort, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); connect(m_ui->spinProxyPort, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
connect(m_ui->checkProxyPeerConnecs, &QAbstractButton::toggled, 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->isProxyOnlyForTorrents, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkProxyAuth, &QGroupBox::toggled, this, &ThisType::enableApplyButton); connect(m_ui->checkProxyAuth, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->textProxyUsername, &QLineEdit::textChanged, this, &ThisType::enableApplyButton); connect(m_ui->textProxyUsername, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
@ -728,7 +726,6 @@ void OptionsDialog::saveOptions()
proxyConfigManager->setProxyConfiguration(proxyConf); proxyConfigManager->setProxyConfiguration(proxyConf);
session->setProxyPeerConnectionsEnabled(m_ui->checkProxyPeerConnecs->isChecked()); session->setProxyPeerConnectionsEnabled(m_ui->checkProxyPeerConnecs->isChecked());
session->setForceProxyEnabled(m_ui->checkForceProxy->isChecked());
// End Connection preferences // End Connection preferences
// Bittorrent preferences // Bittorrent preferences
@ -1057,8 +1054,6 @@ void OptionsDialog::loadOptions()
m_ui->textProxyPassword->setText(proxyConf.password); m_ui->textProxyPassword->setText(proxyConf.password);
m_ui->checkProxyPeerConnecs->setChecked(session->isProxyPeerConnectionsEnabled()); m_ui->checkProxyPeerConnecs->setChecked(session->isProxyPeerConnectionsEnabled());
m_ui->checkForceProxy->setChecked(session->isForceProxyEnabled());
enableForceProxy(session->isForceProxyEnabled());
m_ui->isProxyOnlyForTorrents->setChecked(proxyConfigManager->isProxyOnlyForTorrents()); m_ui->isProxyOnlyForTorrents->setChecked(proxyConfigManager->isProxyOnlyForTorrents());
enableProxy(m_ui->comboProxyType->currentIndex()); enableProxy(m_ui->comboProxyType->currentIndex());
@ -1358,12 +1353,6 @@ void OptionsDialog::toggleComboRatioLimitAct()
m_ui->comboRatioLimitAct->setEnabled(m_ui->checkMaxRatio->isChecked() || m_ui->checkMaxSeedingMinutes->isChecked()); 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) void OptionsDialog::enableProxy(int index)
{ {
if (index) { if (index) {
@ -1373,7 +1362,6 @@ void OptionsDialog::enableProxy(int index)
m_ui->lblProxyPort->setEnabled(true); m_ui->lblProxyPort->setEnabled(true);
m_ui->spinProxyPort->setEnabled(true); m_ui->spinProxyPort->setEnabled(true);
m_ui->checkProxyPeerConnecs->setEnabled(true); m_ui->checkProxyPeerConnecs->setEnabled(true);
m_ui->checkForceProxy->setEnabled(true);
if (index > 1) { if (index > 1) {
m_ui->checkProxyAuth->setEnabled(true); m_ui->checkProxyAuth->setEnabled(true);
m_ui->isProxyOnlyForTorrents->setEnabled(true); m_ui->isProxyOnlyForTorrents->setEnabled(true);
@ -1384,7 +1372,6 @@ void OptionsDialog::enableProxy(int index)
m_ui->isProxyOnlyForTorrents->setEnabled(false); m_ui->isProxyOnlyForTorrents->setEnabled(false);
m_ui->isProxyOnlyForTorrents->setChecked(true); m_ui->isProxyOnlyForTorrents->setChecked(true);
} }
enableForceProxy(m_ui->checkForceProxy->isChecked());
} }
else { else {
//disable //disable
@ -1393,11 +1380,9 @@ void OptionsDialog::enableProxy(int index)
m_ui->lblProxyPort->setEnabled(false); m_ui->lblProxyPort->setEnabled(false);
m_ui->spinProxyPort->setEnabled(false); m_ui->spinProxyPort->setEnabled(false);
m_ui->checkProxyPeerConnecs->setEnabled(false); m_ui->checkProxyPeerConnecs->setEnabled(false);
m_ui->checkForceProxy->setEnabled(false);
m_ui->isProxyOnlyForTorrents->setEnabled(false); m_ui->isProxyOnlyForTorrents->setEnabled(false);
m_ui->checkProxyAuth->setEnabled(false); m_ui->checkProxyAuth->setEnabled(false);
m_ui->checkProxyAuth->setChecked(false); m_ui->checkProxyAuth->setChecked(false);
enableForceProxy(false);
} }
} }

1
src/gui/optionsdialog.h

@ -87,7 +87,6 @@ public slots:
void showConnectionTab(); void showConnectionTab();
private slots: private slots:
void enableForceProxy(bool enable);
void enableProxy(int index); void enableProxy(int index);
void on_buttonBox_accepted(); void on_buttonBox_accepted();
void closeEvent(QCloseEvent *e) override; void closeEvent(QCloseEvent *e) override;

38
src/gui/optionsdialog.ui

@ -1633,43 +1633,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<layout class="QHBoxLayout" name="forceProxyHorizontalLayout">
<item>
<widget class="QCheckBox" name="checkForceProxy">
<property name="text">
<string>Disable connections not supported by proxies</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelForceProxy">
<property name="text">
<string>(&lt;a href=&quot;https://github.com/qbittorrent/qBittorrent/wiki/Disable-connections-not-supported-by-proxies&quot;&gt;More information&lt;/a&gt;)</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_22">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item> <item>
<widget class="QCheckBox" name="isProxyOnlyForTorrents"> <widget class="QCheckBox" name="isProxyOnlyForTorrents">
<property name="toolTip"> <property name="toolTip">
@ -3342,7 +3305,6 @@ Use ';' to split multiple entries. Can use wildcard '*'.</string>
<tabstop>textProxyIP</tabstop> <tabstop>textProxyIP</tabstop>
<tabstop>spinProxyPort</tabstop> <tabstop>spinProxyPort</tabstop>
<tabstop>checkProxyPeerConnecs</tabstop> <tabstop>checkProxyPeerConnecs</tabstop>
<tabstop>checkForceProxy</tabstop>
<tabstop>isProxyOnlyForTorrents</tabstop> <tabstop>isProxyOnlyForTorrents</tabstop>
<tabstop>checkProxyAuth</tabstop> <tabstop>checkProxyAuth</tabstop>
<tabstop>textProxyUsername</tabstop> <tabstop>textProxyUsername</tabstop>

8
src/webui/api/appcontroller.cpp

@ -159,7 +159,6 @@ void AppController::preferencesAction()
data["proxy_password"] = proxyConf.password; data["proxy_password"] = proxyConf.password;
data["proxy_peer_connections"] = session->isProxyPeerConnectionsEnabled(); data["proxy_peer_connections"] = session->isProxyPeerConnectionsEnabled();
data["force_proxy"] = session->isForceProxyEnabled();
data["proxy_torrents_only"] = proxyManager->isProxyOnlyForTorrents(); data["proxy_torrents_only"] = proxyManager->isProxyOnlyForTorrents();
// IP Filtering // IP Filtering
@ -281,8 +280,6 @@ void AppController::preferencesAction()
data["disk_cache_ttl"] = session->diskCacheTTL(); data["disk_cache_ttl"] = session->diskCacheTTL();
// Enable OS cache // Enable OS cache
data["enable_os_cache"] = session->useOSCache(); data["enable_os_cache"] = session->useOSCache();
// Guided read cache
data["enable_guided_read_cache"] = session->isGuidedReadCacheEnabled();
// Coalesce reads & writes // Coalesce reads & writes
data["enable_coalesce_read_write"] = session->isCoalesceReadWriteEnabled(); data["enable_coalesce_read_write"] = session->isCoalesceReadWriteEnabled();
// Suggest mode // Suggest mode
@ -467,8 +464,6 @@ void AppController::setPreferencesAction()
if (hasKey("proxy_peer_connections")) if (hasKey("proxy_peer_connections"))
session->setProxyPeerConnectionsEnabled(it.value().toBool()); session->setProxyPeerConnectionsEnabled(it.value().toBool());
if (hasKey("force_proxy"))
session->setForceProxyEnabled(it.value().toBool());
if (hasKey("proxy_torrents_only")) if (hasKey("proxy_torrents_only"))
proxyManager->setProxyOnlyForTorrents(it.value().toBool()); proxyManager->setProxyOnlyForTorrents(it.value().toBool());
@ -693,9 +688,6 @@ void AppController::setPreferencesAction()
// Enable OS cache // Enable OS cache
if (hasKey("enable_os_cache")) if (hasKey("enable_os_cache"))
session->setUseOSCache(it.value().toBool()); session->setUseOSCache(it.value().toBool());
// Guided read cache
if (hasKey("enable_guided_read_cache"))
session->setGuidedReadCacheEnabled(it.value().toBool());
// Coalesce reads & writes // Coalesce reads & writes
if (hasKey("enable_coalesce_read_write")) if (hasKey("enable_coalesce_read_write"))
session->setCoalesceReadWriteEnabled(it.value().toBool()); session->setCoalesceReadWriteEnabled(it.value().toBool());

26
src/webui/www/private/preferences_content.html

@ -321,10 +321,6 @@
<input type="checkbox" id="use_peer_proxy_checkbox" /> <input type="checkbox" id="use_peer_proxy_checkbox" />
<label for="use_peer_proxy_checkbox">QBT_TR(Use proxy for peer connections)QBT_TR[CONTEXT=OptionsDialog]</label> <label for="use_peer_proxy_checkbox">QBT_TR(Use proxy for peer connections)QBT_TR[CONTEXT=OptionsDialog]</label>
</div> </div>
<div class="formRow">
<input type="checkbox" id="force_proxy_checkbox" onclick="updateForceProxySettings();" />
<label for="force_proxy_checkbox">QBT_TR(Disable connections not supported by proxies)QBT_TR[CONTEXT=OptionsDialog] (<a target="_blank" href="https://github.com/qbittorrent/qBittorrent/wiki/Disable-connections-not-supported-by-proxies">QBT_TR(More information)QBT_TR[CONTEXT=HttpServer]</a>)</label>
</div>
<div class="formRow"> <div class="formRow">
<input type="checkbox" id="proxy_only_for_torrents_checkbox" /> <input type="checkbox" id="proxy_only_for_torrents_checkbox" />
<label for="proxy_only_for_torrents_checkbox">QBT_TR(Use proxy only for torrents)QBT_TR[CONTEXT=OptionsDialog]</label> <label for="proxy_only_for_torrents_checkbox">QBT_TR(Use proxy only for torrents)QBT_TR[CONTEXT=OptionsDialog]</label>
@ -924,14 +920,6 @@
<input type="checkbox" id="enableOSCache" /> <input type="checkbox" id="enableOSCache" />
</td> </td>
</tr> </tr>
<tr>
<td>
<label for="guidedReadCache">QBT_TR(Guided read cache:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#guided_read_cache" target="_blank">(?)</a></label>
</td>
<td>
<input type="checkbox" id="guidedReadCache" />
</td>
</tr>
<tr> <tr>
<td> <td>
<label for="coalesceReadsAndWrites">QBT_TR(Coalesce reads & writes:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#coalesce_reads" target="_blank">(?)</a></label> <label for="coalesceReadsAndWrites">QBT_TR(Coalesce reads & writes:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#coalesce_reads" target="_blank">(?)</a></label>
@ -1237,7 +1225,6 @@
$('peer_proxy_host_text').setProperty('disabled', !isPeerProxyTypeSelected); $('peer_proxy_host_text').setProperty('disabled', !isPeerProxyTypeSelected);
$('peer_proxy_port_value').setProperty('disabled', !isPeerProxyTypeSelected); $('peer_proxy_port_value').setProperty('disabled', !isPeerProxyTypeSelected);
$('use_peer_proxy_checkbox').setProperty('disabled', !isPeerProxyTypeSelected); $('use_peer_proxy_checkbox').setProperty('disabled', !isPeerProxyTypeSelected);
$('force_proxy_checkbox').setProperty('disabled', !isPeerProxyTypeSelected);
$('proxy_only_for_torrents_checkbox').setProperty('disabled', !isPeerProxyTypeSelected); $('proxy_only_for_torrents_checkbox').setProperty('disabled', !isPeerProxyTypeSelected);
if (isPeerProxyTypeSelected) { if (isPeerProxyTypeSelected) {
@ -1254,14 +1241,6 @@
$('peer_proxy_auth_checkbox').setProperty('checked', isPeerProxyTypeSelected); $('peer_proxy_auth_checkbox').setProperty('checked', isPeerProxyTypeSelected);
updatePeerProxyAuthSettings(); 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() { var updatePeerProxyAuthSettings = function() {
@ -1568,8 +1547,6 @@
$('peer_proxy_host_text').setProperty('value', pref.proxy_ip); $('peer_proxy_host_text').setProperty('value', pref.proxy_ip);
$('peer_proxy_port_value').setProperty('value', pref.proxy_port); $('peer_proxy_port_value').setProperty('value', pref.proxy_port);
$('use_peer_proxy_checkbox').setProperty('checked', pref.proxy_peer_connections); $('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); $('proxy_only_for_torrents_checkbox').setProperty('checked', pref.proxy_torrents_only);
$('peer_proxy_auth_checkbox').setProperty('checked', pref.proxy_auth_enabled); $('peer_proxy_auth_checkbox').setProperty('checked', pref.proxy_auth_enabled);
updatePeerProxyAuthSettings(); updatePeerProxyAuthSettings();
@ -1703,7 +1680,6 @@
$('diskCache').setProperty('value', pref.disk_cache); $('diskCache').setProperty('value', pref.disk_cache);
$('diskCacheExpiryInterval').setProperty('value', pref.disk_cache_ttl); $('diskCacheExpiryInterval').setProperty('value', pref.disk_cache_ttl);
$('enableOSCache').setProperty('checked', pref.enable_os_cache); $('enableOSCache').setProperty('checked', pref.enable_os_cache);
$('guidedReadCache').setProperty('checked', pref.enable_guided_read_cache);
$('coalesceReadsAndWrites').setProperty('checked', pref.enable_coalesce_read_write); $('coalesceReadsAndWrites').setProperty('checked', pref.enable_coalesce_read_write);
$('sendUploadPieceSuggestions').setProperty('checked', pref.enable_upload_suggestions); $('sendUploadPieceSuggestions').setProperty('checked', pref.enable_upload_suggestions);
$('sendBufferWatermark').setProperty('value', pref.send_buffer_watermark); $('sendBufferWatermark').setProperty('value', pref.send_buffer_watermark);
@ -1856,7 +1832,6 @@
settings.set('proxy_ip', $('peer_proxy_host_text').getProperty('value')); settings.set('proxy_ip', $('peer_proxy_host_text').getProperty('value'));
settings.set('proxy_port', $('peer_proxy_port_value').getProperty('value').toInt()); settings.set('proxy_port', $('peer_proxy_port_value').getProperty('value').toInt());
settings.set('proxy_peer_connections', $('use_peer_proxy_checkbox').getProperty('checked')); 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_torrents_only', $('proxy_only_for_torrents_checkbox').getProperty('checked'));
settings.set('proxy_username', $('peer_proxy_username_text').getProperty('value')); settings.set('proxy_username', $('peer_proxy_username_text').getProperty('value'));
settings.set('proxy_password', $('peer_proxy_password_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', $('diskCache').getProperty('value'));
settings.set('disk_cache_ttl', $('diskCacheExpiryInterval').getProperty('value')); settings.set('disk_cache_ttl', $('diskCacheExpiryInterval').getProperty('value'));
settings.set('enable_os_cache', $('enableOSCache').getProperty('checked')); 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_coalesce_read_write', $('coalesceReadsAndWrites').getProperty('checked'));
settings.set('enable_upload_suggestions', $('sendUploadPieceSuggestions').getProperty('checked')); settings.set('enable_upload_suggestions', $('sendUploadPieceSuggestions').getProperty('checked'));
settings.set('send_buffer_watermark', $('sendBufferWatermark').getProperty('value')); settings.set('send_buffer_watermark', $('sendBufferWatermark').getProperty('value'));

Loading…
Cancel
Save