Merge pull request #10950 from glassez/drop-deprecated

Don't use deprecated libtorrent features
This commit is contained in:
Vladimir Golovnev 2019-07-23 09:19:15 +03:00 committed by GitHub
commit cf2e7d77d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 140 additions and 178 deletions

View file

@ -11,6 +11,7 @@ bittorrent/peeraddress.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

View file

@ -10,6 +10,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 \

View file

@ -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;

View file

@ -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<LTUnderlyingType<LTPeerClass>>(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<LTUnderlyingType<LTPeerClass>>(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<LTUnderlyingType<LTPeerClass>>(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<LTUnderlyingType<LTPeerClass>>(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<LTUnderlyingType<LTPeerClass>>(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<LTUnderlyingType<LTPeerClass>>(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<LTUnderlyingType<LTPeerClass>>(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<LTUnderlyingType<LTPeerClass>>(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<LTUnderlyingType<LTPeerClass>>(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<LTUnderlyingType<LTPeerClass>>(lt::session::local_peer_class_id));
}
catch (const std::exception &) {}
#endif
@ -2206,7 +2208,7 @@ void Session::saveTorrentsQueue()
QMap<int, QString> 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<LTQueuePosition> {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;

View file

@ -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<int> m_diskCacheSize;
CachedSettingValue<int> m_diskCacheTTL;
CachedSettingValue<bool> m_useOSCache;
CachedSettingValue<bool> m_guidedReadCacheEnabled;
CachedSettingValue<bool> m_coalesceReadWriteEnabled;
CachedSettingValue<bool> m_isSuggestMode;
CachedSettingValue<int> m_sendBufferWatermark;
@ -650,7 +645,6 @@ namespace BitTorrent
CachedSettingValue<QString> m_networkInterfaceAddress;
CachedSettingValue<bool> m_isIPv6Enabled;
CachedSettingValue<int> m_encryption;
CachedSettingValue<bool> m_isForceProxyEnabled;
CachedSettingValue<bool> m_isProxyPeerConnectionsEnabled;
CachedSettingValue<ChokingAlgorithm> m_chokingAlgorithm;
CachedSettingValue<SeedChokingAlgorithm> m_seedChokingAlgorithm;

View file

@ -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<LTPieceIndex> {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();
}

View file

@ -67,6 +67,7 @@
#include "downloadpriority.h"
#include "peeraddress.h"
#include "peerinfo.h"
#include "private/ltunderlyingtype.h"
#include "session.h"
#include "trackerentry.h"
@ -74,15 +75,29 @@ const QString QB_EXT {QStringLiteral(".!qB")};
using namespace BitTorrent;
#if (LIBTORRENT_VERSION_NUM >= 10200)
namespace libtorrent
{
namespace aux
{
template <typename T, typename Tag>
uint qHash(const strong_typedef<T, Tag> &key, const uint seed)
{
return static_cast<uint>((std::hash<strong_typedef<T, Tag>> {})(key) ^ seed);
}
}
}
#endif
namespace
{
#if (LIBTORRENT_VERSION_NUM < 10200)
using LTDownloadPriority = int;
using LTDownloadPriorityUnderlyingType = int;
using LTPieceIndex = int;
using LTQueuePosition = int;
#else
using LTDownloadPriority = lt::download_priority_t;
using LTDownloadPriorityUnderlyingType = lt::download_priority_t::underlying_type;
using LTPieceIndex = lt::piece_index_t;
using LTQueuePosition = lt::queue_position_t;
#endif
@ -93,7 +108,7 @@ namespace
, std::back_inserter(out), [](BitTorrent::DownloadPriority priority)
{
return static_cast<LTDownloadPriority>(
static_cast<LTDownloadPriorityUnderlyingType>(priority));
static_cast<LTUnderlyingType<LTDownloadPriority>>(priority));
});
return out;
}
@ -378,7 +393,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
}
@ -681,7 +696,7 @@ QStringList TorrentHandle::absoluteFilePathsUnwanted() const
QStringList res;
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)));
if (path.contains(".unwanted"))
res << path;
@ -702,8 +717,7 @@ QVector<DownloadPriority> TorrentHandle::filePriorities() const
QVector<DownloadPriority> ret;
std::transform(fp.cbegin(), fp.cend(), std::back_inserter(ret), [](LTDownloadPriority priority)
{
return static_cast<DownloadPriority>(
static_cast<std::underlying_type<DownloadPriority>::type>(priority));
return static_cast<DownloadPriority>(LTUnderlyingType<LTDownloadPriority> {priority});
});
return ret;
}
@ -826,7 +840,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
}
@ -841,13 +855,13 @@ bool TorrentHandle::hasFirstLastPiecePriority() const
const std::vector<LTDownloadPriority> filePriorities = nativeHandle().get_file_priorities();
#endif
for (int i = 0; i < static_cast<int>(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;
@ -1150,7 +1164,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
}
@ -1172,7 +1186,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;
}
@ -1185,7 +1199,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<LTPieceIndex> {info.piece_index});
#endif
return result;
}
@ -1411,7 +1429,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)
@ -1510,7 +1528,7 @@ void TorrentHandle::renameFile(const int index, const QString &name)
m_oldPath[LTFileIndex {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)
@ -1808,11 +1826,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[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[p->index].isEmpty())
m_oldPath.remove(p->index);
QVector<QStringRef> oldPathParts = oldFilePath.splitRef('/', QString::SkipEmptyParts);
oldPathParts.removeLast(); // drop file name part
@ -1848,12 +1866,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<LTFileIndex> {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[p->index].removeFirst();
if (m_oldPath[p->index].isEmpty())
m_oldPath.remove(p->index);
--m_renameCount;
while (!isMoveInProgress() && (m_renameCount == 0) && !m_moveFinishedTriggers.isEmpty())
@ -1871,12 +1889,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<LTFileIndex> {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<LTFileIndex> {p->index}, name);
}
}
}

View file

@ -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("");

View file

@ -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", "(?)"))

View file

@ -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;

View file

@ -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);
}
}

View file

@ -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;

View file

@ -1633,43 +1633,6 @@
</property>
</widget>
</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>
<widget class="QCheckBox" name="isProxyOnlyForTorrents">
<property name="toolTip">
@ -3342,7 +3305,6 @@ Use ';' to split multiple entries. Can use wildcard '*'.</string>
<tabstop>textProxyIP</tabstop>
<tabstop>spinProxyPort</tabstop>
<tabstop>checkProxyPeerConnecs</tabstop>
<tabstop>checkForceProxy</tabstop>
<tabstop>isProxyOnlyForTorrents</tabstop>
<tabstop>checkProxyAuth</tabstop>
<tabstop>textProxyUsername</tabstop>

View file

@ -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());

View file

@ -321,10 +321,6 @@
<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>
</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">
<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>
@ -924,14 +920,6 @@
<input type="checkbox" id="enableOSCache" />
</td>
</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>
<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>
@ -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'));