Browse Source

Drop support for building with libtorrent < 1.2.11

Co-authored-by: Vladimir Golovnev <glassez@yandex.ru>
adaptive-webui-19844
Vladimir Golovnev 4 years ago committed by FranciscoPombal
parent
commit
2f6ed86c78
  1. 43
      src/base/bittorrent/session.cpp
  2. 7
      src/base/bittorrent/session.h
  3. 12
      src/base/bittorrent/torrenthandleimpl.cpp
  4. 18
      src/gui/advancedsettings.cpp

43
src/base/bittorrent/session.cpp

@ -346,11 +346,7 @@ Session::Session(QObject *parent) @@ -346,11 +346,7 @@ Session::Session(QObject *parent)
, m_hashingThreads(BITTORRENT_SESSION_KEY("HashingThreadsCount"), 2)
, m_filePoolSize(BITTORRENT_SESSION_KEY("FilePoolSize"), 40)
, m_checkingMemUsage(BITTORRENT_SESSION_KEY("CheckingMemUsageSize"), 32)
#if (LIBTORRENT_VERSION_NUM >= 10206)
, m_diskCacheSize(BITTORRENT_SESSION_KEY("DiskCacheSize"), -1)
#else
, m_diskCacheSize(BITTORRENT_SESSION_KEY("DiskCacheSize"), 64)
#endif
, m_diskCacheTTL(BITTORRENT_SESSION_KEY("DiskCacheTTL"), 60)
, m_useOSCache(BITTORRENT_SESSION_KEY("UseOSCache"), true)
#ifdef Q_OS_WIN
@ -380,11 +376,7 @@ Session::Session(QObject *parent) @@ -380,11 +376,7 @@ Session::Session(QObject *parent)
, m_includeOverheadInLimits(BITTORRENT_SESSION_KEY("IncludeOverheadInLimits"), false)
, m_announceIP(BITTORRENT_SESSION_KEY("AnnounceIP"))
, m_maxConcurrentHTTPAnnounces(BITTORRENT_SESSION_KEY("MaxConcurrentHTTPAnnounces"), 50)
#if (LIBTORRENT_VERSION_NUM >= 10206)
, m_stopTrackerTimeout(BITTORRENT_SESSION_KEY("StopTrackerTimeout"), 5)
#else
, m_stopTrackerTimeout(BITTORRENT_SESSION_KEY("StopTrackerTimeout"), 1)
#endif
, m_maxConnections(BITTORRENT_SESSION_KEY("MaxConnections"), 500, lowerLimited(0, -1))
, m_maxUploads(BITTORRENT_SESSION_KEY("MaxUploads"), 20, lowerLimited(0, -1))
, m_maxConnectionsPerTorrent(BITTORRENT_SESSION_KEY("MaxConnectionsPerTorrent"), 100, lowerLimited(0, -1))
@ -1089,9 +1081,6 @@ void Session::initializeNativeSession() @@ -1089,9 +1081,6 @@ void Session::initializeNativeSession()
// turn them off before `lt::session` ctor to avoid split second effects
pack.set_bool(lt::settings_pack::enable_upnp, false);
pack.set_bool(lt::settings_pack::enable_natpmp, false);
#if (LIBTORRENT_VERSION_NUM < 10204)
pack.set_bool(lt::settings_pack::upnp_ignore_nonrouters, true);
#endif
#if (LIBTORRENT_VERSION_NUM > 20000)
// preserve the same behavior as in earlier libtorrent versions
@ -1341,9 +1330,7 @@ void Session::loadLTSettings(lt::settings_pack &settingsPack) @@ -1341,9 +1330,7 @@ void Session::loadLTSettings(lt::settings_pack &settingsPack)
settingsPack.set_bool(lt::settings_pack::coalesce_writes, isCoalesceReadWriteEnabled());
#endif
#if (LIBTORRENT_VERSION_NUM >= 10202)
settingsPack.set_bool(lt::settings_pack::piece_extent_affinity, usePieceExtentAffinity());
#endif
settingsPack.set_int(lt::settings_pack::suggest_mode, isSuggestModeEnabled()
? lt::settings_pack::suggest_read_cache : lt::settings_pack::no_piece_suggestions);
@ -1380,18 +1367,14 @@ void Session::loadLTSettings(lt::settings_pack &settingsPack) @@ -1380,18 +1367,14 @@ void Session::loadLTSettings(lt::settings_pack &settingsPack)
settingsPack.set_int(lt::settings_pack::outgoing_port, outgoingPortsMin());
settingsPack.set_int(lt::settings_pack::num_outgoing_ports, outgoingPortsMax() - outgoingPortsMin() + 1);
#if (LIBTORRENT_VERSION_NUM >= 10206)
settingsPack.set_int(lt::settings_pack::upnp_lease_duration, UPnPLeaseDuration());
#endif
// Include overhead in transfer limits
settingsPack.set_bool(lt::settings_pack::rate_limit_ip_overhead, includeOverheadInLimits());
// IP address to announce to trackers
settingsPack.set_str(lt::settings_pack::announce_ip, announceIP().toStdString());
#if (LIBTORRENT_VERSION_NUM >= 10207)
// Max concurrent HTTP announces
settingsPack.set_int(lt::settings_pack::max_concurrent_http_announces, maxConcurrentHTTPAnnounces());
#endif
// Stop tracker timeout
settingsPack.set_int(lt::settings_pack::stop_tracker_timeout, stopTrackerTimeout());
// * Max connections limit
@ -4504,11 +4487,6 @@ void Session::handleAlert(const lt::alert *a) @@ -4504,11 +4487,6 @@ void Session::handleAlert(const lt::alert *a)
case lt::file_error_alert::alert_type:
handleFileErrorAlert(static_cast<const lt::file_error_alert*>(a));
break;
#if (LIBTORRENT_VERSION_NUM < 10208)
case lt::read_piece_alert::alert_type:
handleReadPieceAlert(static_cast<const lt::read_piece_alert*>(a));
break;
#endif
case lt::add_torrent_alert::alert_type:
handleAddTorrentAlert(static_cast<const lt::add_torrent_alert*>(a));
break;
@ -4554,11 +4532,9 @@ void Session::handleAlert(const lt::alert *a) @@ -4554,11 +4532,9 @@ void Session::handleAlert(const lt::alert *a)
case lt::storage_moved_failed_alert::alert_type:
handleStorageMovedFailedAlert(static_cast<const lt::storage_moved_failed_alert*>(a));
break;
#if (LIBTORRENT_VERSION_NUM >= 10204)
case lt::socks5_alert::alert_type:
handleSocks5Alert(static_cast<const lt::socks5_alert *>(a));
break;
#endif
}
}
catch (const std::exception &exc)
@ -4645,12 +4621,6 @@ void Session::createTorrentHandle(const lt::torrent_handle &nativeHandle) @@ -4645,12 +4621,6 @@ void Session::createTorrentHandle(const lt::torrent_handle &nativeHandle)
// Torrent could have error just after adding to libtorrent
if (torrent->hasError())
LogMsg(tr("Torrent errored. Torrent: \"%1\". Error: %2.").arg(torrent->name(), torrent->error()), Log::WARNING);
#if (LIBTORRENT_VERSION_NUM < 10208)
// Check if file(s) exist when using skip hash check
if (nativeHandle.flags() & lt::torrent_flags::seed_mode)
nativeHandle.read_piece(lt::piece_index_t {0});
#endif
}
void Session::handleAddTorrentAlert(const lt::add_torrent_alert *p)
@ -4761,17 +4731,6 @@ void Session::handleFileErrorAlert(const lt::file_error_alert *p) @@ -4761,17 +4731,6 @@ void Session::handleFileErrorAlert(const lt::file_error_alert *p)
m_recentErroredTorrentsTimer->start();
}
#if (LIBTORRENT_VERSION_NUM < 10208)
void Session::handleReadPieceAlert(const lt::read_piece_alert *p) const
{
if (p->error)
{
p->handle.unset_flags(lt::torrent_flags::auto_managed);
p->handle.force_recheck();
}
}
#endif
void Session::handlePortmapWarningAlert(const lt::portmap_error_alert *p)
{
LogMsg(tr("UPnP/NAT-PMP: Port mapping failure, message: %1").arg(QString::fromStdString(p->message())), Log::CRITICAL);
@ -5013,7 +4972,6 @@ void Session::handleStateUpdateAlert(const lt::state_update_alert *p) @@ -5013,7 +4972,6 @@ void Session::handleStateUpdateAlert(const lt::state_update_alert *p)
enqueueRefresh();
}
#if (LIBTORRENT_VERSION_NUM >= 10204)
void Session::handleSocks5Alert(const lt::socks5_alert *p) const
{
if (p->error)
@ -5022,4 +4980,3 @@ void Session::handleSocks5Alert(const lt::socks5_alert *p) const @@ -5022,4 +4980,3 @@ void Session::handleSocks5Alert(const lt::socks5_alert *p) const
, Log::WARNING);
}
}
#endif

7
src/base/bittorrent/session.h

@ -50,7 +50,7 @@ @@ -50,7 +50,7 @@
#include "sessionstatus.h"
#include "torrentinfo.h"
#if ((LIBTORRENT_VERSION_NUM >= 10206) && !defined(Q_OS_WIN))
#if !defined(Q_OS_WIN)
#define HAS_HTTPS_TRACKER_VALIDATION
#endif
@ -604,9 +604,6 @@ namespace BitTorrent @@ -604,9 +604,6 @@ namespace BitTorrent
void handleStateUpdateAlert(const lt::state_update_alert *p);
void handleMetadataReceivedAlert(const lt::metadata_received_alert *p);
void handleFileErrorAlert(const lt::file_error_alert *p);
#if (LIBTORRENT_VERSION_NUM < 10208)
void handleReadPieceAlert(const lt::read_piece_alert *p) const;
#endif
void handleTorrentRemovedAlert(const lt::torrent_removed_alert *p);
void handleTorrentDeletedAlert(const lt::torrent_deleted_alert *p);
void handleTorrentDeleteFailedAlert(const lt::torrent_delete_failed_alert *p);
@ -622,9 +619,7 @@ namespace BitTorrent @@ -622,9 +619,7 @@ namespace BitTorrent
void handleAlertsDroppedAlert(const lt::alerts_dropped_alert *p) const;
void handleStorageMovedAlert(const lt::storage_moved_alert *p);
void handleStorageMovedFailedAlert(const lt::storage_moved_failed_alert *p);
#if (LIBTORRENT_VERSION_NUM >= 10204)
void handleSocks5Alert(const lt::socks5_alert *p) const;
#endif
void createTorrentHandle(const lt::torrent_handle &nativeHandle);

12
src/base/bittorrent/torrenthandleimpl.cpp

@ -445,9 +445,7 @@ void TorrentHandleImpl::removeUrlSeeds(const QVector<QUrl> &urlSeeds) @@ -445,9 +445,7 @@ void TorrentHandleImpl::removeUrlSeeds(const QVector<QUrl> &urlSeeds)
void TorrentHandleImpl::clearPeers()
{
#if (LIBTORRENT_VERSION_NUM >= 10207)
m_nativeHandle.clear_peers();
#endif
}
bool TorrentHandleImpl::connectPeer(const PeerAddress &peerAddress)
@ -1473,7 +1471,7 @@ void TorrentHandleImpl::handleTorrentResumedAlert(const lt::torrent_resumed_aler @@ -1473,7 +1471,7 @@ void TorrentHandleImpl::handleTorrentResumedAlert(const lt::torrent_resumed_aler
void TorrentHandleImpl::handleSaveResumeDataAlert(const lt::save_resume_data_alert *p)
{
if (p && !m_hasMissingFiles)
if (!m_hasMissingFiles)
{
// Update recent resume data
m_ltAddTorrentParams = p->params;
@ -1503,7 +1501,7 @@ void TorrentHandleImpl::handleSaveResumeDataAlert(const lt::save_resume_data_ale @@ -1503,7 +1501,7 @@ void TorrentHandleImpl::handleSaveResumeDataAlert(const lt::save_resume_data_ale
// TODO: The following code is deprecated. Remove after several releases in 4.3.x.
// === BEGIN DEPRECATED CODE === //
const bool useDummyResumeData = !p;
const bool useDummyResumeData = !hasMetadata();
if (useDummyResumeData)
{
updateStatus();
@ -1534,11 +1532,7 @@ void TorrentHandleImpl::handleSaveResumeDataAlert(const lt::save_resume_data_ale @@ -1534,11 +1532,7 @@ void TorrentHandleImpl::handleSaveResumeDataAlert(const lt::save_resume_data_ale
void TorrentHandleImpl::handleSaveResumeDataFailedAlert(const lt::save_resume_data_failed_alert *p)
{
Q_UNUSED(p);
// if torrent has no metadata libtorrent doesn't generate "fastresume" data
// so we should save dummy "fastresume" data containing the values used to
// load torrent and qBittorrent own resume data
handleSaveResumeDataAlert(nullptr);
Q_ASSERT_X(false, Q_FUNC_INFO, "This point should be unreachable since libtorrent 1.2.11");
}
void TorrentHandleImpl::handleFastResumeRejectedAlert(const lt::fastresume_rejected_alert *p)

18
src/gui/advancedsettings.cpp

@ -102,9 +102,7 @@ namespace @@ -102,9 +102,7 @@ namespace
#if (LIBTORRENT_VERSION_NUM < 20000)
COALESCE_RW,
#endif
#if (LIBTORRENT_VERSION_NUM >= 10202)
PIECE_EXTENT_AFFINITY,
#endif
SUGGEST_MODE,
SEND_BUF_WATERMARK,
SEND_BUF_LOW_WATERMARK,
@ -113,9 +111,7 @@ namespace @@ -113,9 +111,7 @@ namespace
SOCKET_BACKLOG_SIZE,
OUTGOING_PORT_MIN,
OUTGOING_PORT_MAX,
#if (LIBTORRENT_VERSION_NUM >= 10206)
UPNP_LEASE_DURATION,
#endif
UTP_MIX_MODE,
MULTI_CONNECTIONS_PER_IP,
#ifdef HAS_HTTPS_TRACKER_VALIDATION
@ -129,9 +125,7 @@ namespace @@ -129,9 +125,7 @@ namespace
ANNOUNCE_ALL_TRACKERS,
ANNOUNCE_ALL_TIERS,
ANNOUNCE_IP,
#if (LIBTORRENT_VERSION_NUM >= 10207)
MAX_CONCURRENT_HTTP_ANNOUNCES,
#endif
STOP_TRACKER_TIMEOUT,
PEER_TURNOVER,
PEER_TURNOVER_CUTOFF,
@ -210,10 +204,8 @@ void AdvancedSettings::saveAdvancedSettings() @@ -210,10 +204,8 @@ void AdvancedSettings::saveAdvancedSettings()
// Coalesce reads & writes
session->setCoalesceReadWriteEnabled(m_checkBoxCoalesceRW.isChecked());
#endif
#if (LIBTORRENT_VERSION_NUM >= 10202)
// Piece extent affinity
session->setPieceExtentAffinity(m_checkBoxPieceExtentAffinity.isChecked());
#endif
// Suggest mode
session->setSuggestMode(m_checkBoxSuggestMode.isChecked());
// Send buffer watermark
@ -227,10 +219,8 @@ void AdvancedSettings::saveAdvancedSettings() @@ -227,10 +219,8 @@ void AdvancedSettings::saveAdvancedSettings()
// Outgoing ports
session->setOutgoingPortsMin(m_spinBoxOutgoingPortsMin.value());
session->setOutgoingPortsMax(m_spinBoxOutgoingPortsMax.value());
#if (LIBTORRENT_VERSION_NUM >= 10206)
// UPnP lease duration
session->setUPnPLeaseDuration(m_spinBoxUPnPLeaseDuration.value());
#endif
// uTP-TCP mixed mode
session->setUtpMixedMode(static_cast<BitTorrent::MixedModeAlgorithm>(m_comboBoxUtpMixedMode.currentIndex()));
// multiple connections per IP
@ -270,10 +260,8 @@ void AdvancedSettings::saveAdvancedSettings() @@ -270,10 +260,8 @@ void AdvancedSettings::saveAdvancedSettings()
// Construct a QHostAddress to filter malformed strings
const QHostAddress addr(m_lineEditAnnounceIP.text().trimmed());
session->setAnnounceIP(addr.toString());
#if (LIBTORRENT_VERSION_NUM >= 10207)
// Max concurrent HTTP announces
session->setMaxConcurrentHTTPAnnounces(m_spinBoxMaxConcurrentHTTPAnnounces.value());
#endif
// Stop tracker timeout
session->setStopTrackerTimeout(m_spinBoxStopTrackerTimeout.value());
// Program notification
@ -488,11 +476,9 @@ void AdvancedSettings::loadAdvancedSettings() @@ -488,11 +476,9 @@ void AdvancedSettings::loadAdvancedSettings()
addRow(COALESCE_RW, (tr("Coalesce reads & writes") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#coalesce_reads", "(?)"))
, &m_checkBoxCoalesceRW);
#endif
#if (LIBTORRENT_VERSION_NUM >= 10202)
// Piece extent affinity
m_checkBoxPieceExtentAffinity.setChecked(session->usePieceExtentAffinity());
addRow(PIECE_EXTENT_AFFINITY, (tr("Use piece extent affinity") + ' ' + makeLink("https://libtorrent.org/single-page-ref.html#piece_extent_affinity", "(?)")), &m_checkBoxPieceExtentAffinity);
#endif
// Suggest mode
m_checkBoxSuggestMode.setChecked(session->isSuggestModeEnabled());
addRow(SUGGEST_MODE, (tr("Send upload piece suggestions") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#suggest_mode", "(?)"))
@ -544,7 +530,6 @@ void AdvancedSettings::loadAdvancedSettings() @@ -544,7 +530,6 @@ void AdvancedSettings::loadAdvancedSettings()
addRow(OUTGOING_PORT_MAX, (tr("Outgoing ports (Max) [0: Disabled]")
+ ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#outgoing_port", "(?)"))
, &m_spinBoxOutgoingPortsMax);
#if (LIBTORRENT_VERSION_NUM >= 10206)
// UPnP lease duration
m_spinBoxUPnPLeaseDuration.setMinimum(0);
m_spinBoxUPnPLeaseDuration.setMaximum(std::numeric_limits<int>::max());
@ -552,7 +537,6 @@ void AdvancedSettings::loadAdvancedSettings() @@ -552,7 +537,6 @@ void AdvancedSettings::loadAdvancedSettings()
m_spinBoxUPnPLeaseDuration.setSuffix(tr(" s", " seconds"));
addRow(UPNP_LEASE_DURATION, (tr("UPnP lease duration [0: Permanent lease]") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#upnp_lease_duration", "(?)"))
, &m_spinBoxUPnPLeaseDuration);
#endif
// uTP-TCP mixed mode
m_comboBoxUtpMixedMode.addItems({tr("Prefer TCP"), tr("Peer proportional (throttles TCP)")});
m_comboBoxUtpMixedMode.setCurrentIndex(static_cast<int>(session->utpMixedMode()));
@ -621,13 +605,11 @@ void AdvancedSettings::loadAdvancedSettings() @@ -621,13 +605,11 @@ void AdvancedSettings::loadAdvancedSettings()
addRow(ANNOUNCE_IP, (tr("IP Address to report to trackers (requires restart)")
+ ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#announce_ip", "(?)"))
, &m_lineEditAnnounceIP);
#if (LIBTORRENT_VERSION_NUM >= 10207)
// Max concurrent HTTP announces
m_spinBoxMaxConcurrentHTTPAnnounces.setMaximum(std::numeric_limits<int>::max());
m_spinBoxMaxConcurrentHTTPAnnounces.setValue(session->maxConcurrentHTTPAnnounces());
addRow(MAX_CONCURRENT_HTTP_ANNOUNCES, (tr("Max concurrent HTTP announces") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#max_concurrent_http_announces", "(?)"))
, &m_spinBoxMaxConcurrentHTTPAnnounces);
#endif
// Stop tracker timeout
m_spinBoxStopTrackerTimeout.setValue(session->stopTrackerTimeout());
m_spinBoxStopTrackerTimeout.setSuffix(tr(" s", " seconds"));

Loading…
Cancel
Save