From bf32e90c400205f9e1253ec2bdd70e781b5e521f Mon Sep 17 00:00:00 2001 From: An0n <47396879+an0n666@users.noreply.github.com> Date: Thu, 9 Jan 2020 18:43:06 +0600 Subject: [PATCH] Change placement of stop tracker timeout --- src/base/bittorrent/session.cpp | 33 ++++++++++---------- src/base/bittorrent/session.h | 6 ++-- src/gui/advancedsettings.cpp | 17 +++++----- src/gui/advancedsettings.h | 4 +-- src/webui/api/appcontroller.cpp | 14 ++++----- src/webui/www/private/views/preferences.html | 20 ++++++------ 6 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index b6b356e66..c5d01e6c4 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -373,7 +373,6 @@ Session::Session(QObject *parent) , m_announceToAllTrackers(BITTORRENT_SESSION_KEY("AnnounceToAllTrackers"), false) , m_announceToAllTiers(BITTORRENT_SESSION_KEY("AnnounceToAllTiers"), true) , m_asyncIOThreads(BITTORRENT_SESSION_KEY("AsyncIOThreadsCount"), 4) - , m_stopTrackerTimeout(BITTORRENT_SESSION_KEY("StopTrackerTimeout"), 1) , m_filePoolSize(BITTORRENT_SESSION_KEY("FilePoolSize"), 40) , m_checkingMemUsage(BITTORRENT_SESSION_KEY("CheckingMemUsageSize"), 32) , m_diskCacheSize(BITTORRENT_SESSION_KEY("DiskCacheSize"), -1) @@ -403,6 +402,7 @@ Session::Session(QObject *parent) , m_ignoreLimitsOnLAN(BITTORRENT_SESSION_KEY("IgnoreLimitsOnLAN"), false) , m_includeOverheadInLimits(BITTORRENT_SESSION_KEY("IncludeOverheadInLimits"), false) , m_announceIP(BITTORRENT_SESSION_KEY("AnnounceIP")) + , m_stopTrackerTimeout(BITTORRENT_SESSION_KEY("StopTrackerTimeout"), 1) , m_isSuperSeedingEnabled(BITTORRENT_SESSION_KEY("SuperSeedingEnabled"), false) , m_maxConnections(BITTORRENT_SESSION_KEY("MaxConnections"), 500, lowerLimited(0, -1)) , m_maxUploads(BITTORRENT_SESSION_KEY("MaxUploads"), -1, lowerLimited(0, -1)) @@ -1304,7 +1304,6 @@ void Session::loadLTSettings(lt::settings_pack &settingsPack) settingsPack.set_bool(lt::settings_pack::announce_to_all_tiers, announceToAllTiers()); settingsPack.set_int(lt::settings_pack::aio_threads, asyncIOThreads()); - settingsPack.set_int(lt::settings_pack::stop_tracker_timeout, stopTrackerTimeout()); settingsPack.set_int(lt::settings_pack::file_pool_size, filePoolSize()); const int checkingMemUsageSize = checkingMemUsage() * 64; @@ -1360,6 +1359,8 @@ void Session::loadLTSettings(lt::settings_pack &settingsPack) 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()); + // Stop tracker timeout + settingsPack.set_int(lt::settings_pack::stop_tracker_timeout, stopTrackerTimeout()); // Super seeding settingsPack.set_bool(lt::settings_pack::strict_super_seeding, isSuperSeedingEnabled()); // * Max connections limit @@ -3149,20 +3150,6 @@ void Session::setAsyncIOThreads(const int num) configureDeferred(); } -int Session::stopTrackerTimeout() const -{ - return m_stopTrackerTimeout; -} - -void Session::setStopTrackerTimeout(const int value) -{ - if (value == m_stopTrackerTimeout) - return; - - m_stopTrackerTimeout = value; - configureDeferred(); -} - int Session::filePoolSize() const { return m_filePoolSize; @@ -3517,6 +3504,20 @@ void Session::setAnnounceIP(const QString &ip) } } +int Session::stopTrackerTimeout() const +{ + return m_stopTrackerTimeout; +} + +void Session::setStopTrackerTimeout(const int value) +{ + if (value == m_stopTrackerTimeout) + return; + + m_stopTrackerTimeout = value; + configureDeferred(); +} + bool Session::isSuperSeedingEnabled() const { return m_isSuperSeedingEnabled; diff --git a/src/base/bittorrent/session.h b/src/base/bittorrent/session.h index ae0fabd73..ed8171830 100644 --- a/src/base/bittorrent/session.h +++ b/src/base/bittorrent/session.h @@ -325,8 +325,6 @@ namespace BitTorrent void setAnnounceToAllTiers(bool val); int asyncIOThreads() const; void setAsyncIOThreads(int num); - int stopTrackerTimeout() const; - void setStopTrackerTimeout(int value); int filePoolSize() const; void setFilePoolSize(int size); int checkingMemUsage() const; @@ -371,6 +369,8 @@ namespace BitTorrent void setIncludeOverheadInLimits(bool include); QString announceIP() const; void setAnnounceIP(const QString &ip); + int stopTrackerTimeout() const; + void setStopTrackerTimeout(int value); bool isSuperSeedingEnabled() const; void setSuperSeedingEnabled(bool enabled); int maxConnections() const; @@ -606,7 +606,6 @@ namespace BitTorrent CachedSettingValue m_announceToAllTrackers; CachedSettingValue m_announceToAllTiers; CachedSettingValue m_asyncIOThreads; - CachedSettingValue m_stopTrackerTimeout; CachedSettingValue m_filePoolSize; CachedSettingValue m_checkingMemUsage; CachedSettingValue m_diskCacheSize; @@ -632,6 +631,7 @@ namespace BitTorrent CachedSettingValue m_ignoreLimitsOnLAN; CachedSettingValue m_includeOverheadInLimits; CachedSettingValue m_announceIP; + CachedSettingValue m_stopTrackerTimeout; CachedSettingValue m_isSuperSeedingEnabled; CachedSettingValue m_maxConnections; CachedSettingValue m_maxUploads; diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index 845af7c1a..fff13cf5c 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -89,7 +89,6 @@ enum AdvSettingsRows // libtorrent section LIBTORRENT_HEADER, ASYNC_IO_THREADS, - STOP_TRACKER_TIMEOUT, FILE_POOL_SIZE, CHECKING_MEM_USAGE, // cache @@ -118,6 +117,7 @@ enum AdvSettingsRows ANNOUNCE_ALL_TRACKERS, ANNOUNCE_ALL_TIERS, ANNOUNCE_IP, + STOP_TRACKER_TIMEOUT, ROW_COUNT }; @@ -178,8 +178,6 @@ void AdvancedSettings::saveAdvancedSettings() #endif // Async IO threads session->setAsyncIOThreads(m_spinBoxAsyncIOThreads.value()); - // Stop tracker timeout - session->setStopTrackerTimeout(m_spinBoxStopTrackerTimeout.value()); // File pool size session->setFilePoolSize(m_spinBoxFilePoolSize.value()); // Checking Memory Usage @@ -237,7 +235,8 @@ void AdvancedSettings::saveAdvancedSettings() // Construct a QHostAddress to filter malformed strings const QHostAddress addr(m_lineEditAnnounceIP.text().trimmed()); session->setAnnounceIP(addr.toString()); - + // Stop tracker timeout + session->setStopTrackerTimeout(m_spinBoxStopTrackerTimeout.value()); // Program notification MainWindow *const mainWindow = static_cast(QCoreApplication::instance())->mainWindow(); mainWindow->setNotificationsEnabled(m_checkBoxProgramNotifications.isChecked()); @@ -379,11 +378,6 @@ void AdvancedSettings::loadAdvancedSettings() m_spinBoxAsyncIOThreads.setValue(session->asyncIOThreads()); addRow(ASYNC_IO_THREADS, (tr("Asynchronous I/O threads") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#aio_threads", "(?)")) , &m_spinBoxAsyncIOThreads); - // stop tracker timeout - m_spinBoxStopTrackerTimeout.setValue(session->stopTrackerTimeout()); - m_spinBoxStopTrackerTimeout.setSuffix(tr(" s", " seconds")); - addRow(STOP_TRACKER_TIMEOUT, (tr("Stop tracker timeout") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#stop_tracker_timeout", "(?)")) - , &m_spinBoxStopTrackerTimeout); // File pool size m_spinBoxFilePoolSize.setMinimum(1); m_spinBoxFilePoolSize.setMaximum(std::numeric_limits::max()); @@ -531,6 +525,11 @@ void AdvancedSettings::loadAdvancedSettings() // Announce IP m_lineEditAnnounceIP.setText(session->announceIP()); addRow(ANNOUNCE_IP, tr("IP Address to report to trackers (requires restart)"), &m_lineEditAnnounceIP); + // stop tracker timeout + m_spinBoxStopTrackerTimeout.setValue(session->stopTrackerTimeout()); + m_spinBoxStopTrackerTimeout.setSuffix(tr(" s", " seconds")); + addRow(STOP_TRACKER_TIMEOUT, (tr("Stop tracker timeout") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#stop_tracker_timeout", "(?)")) + , &m_spinBoxStopTrackerTimeout); // Program notifications const MainWindow *const mainWindow = static_cast(QCoreApplication::instance())->mainWindow(); diff --git a/src/gui/advancedsettings.h b/src/gui/advancedsettings.h index 9f5938f67..4ad58d319 100644 --- a/src/gui/advancedsettings.h +++ b/src/gui/advancedsettings.h @@ -57,10 +57,10 @@ private: void loadAdvancedSettings(); template void addRow(int row, const QString &text, T *widget); - QSpinBox m_spinBoxAsyncIOThreads, m_spinBoxStopTrackerTimeout, m_spinBoxFilePoolSize, m_spinBoxCheckingMemUsage, m_spinBoxCache, + QSpinBox m_spinBoxAsyncIOThreads, m_spinBoxFilePoolSize, m_spinBoxCheckingMemUsage, m_spinBoxCache, m_spinBoxSaveResumeDataInterval, m_spinBoxOutgoingPortsMin, m_spinBoxOutgoingPortsMax, m_spinBoxListRefresh, m_spinBoxTrackerPort, m_spinBoxCacheTTL, m_spinBoxSendBufferWatermark, m_spinBoxSendBufferLowWatermark, - m_spinBoxSendBufferWatermarkFactor, m_spinBoxSocketBacklogSize, m_spinBoxSavePathHistoryLength; + m_spinBoxSendBufferWatermarkFactor, m_spinBoxSocketBacklogSize, m_spinBoxStopTrackerTimeout, m_spinBoxSavePathHistoryLength; QCheckBox m_checkBoxOsCache, m_checkBoxRecheckCompleted, m_checkBoxResolveCountries, m_checkBoxResolveHosts, m_checkBoxSuperSeeding, m_checkBoxProgramNotifications, m_checkBoxTorrentAddedNotifications, m_checkBoxTrackerFavicon, m_checkBoxTrackerStatus, m_checkBoxConfirmTorrentRecheck, m_checkBoxConfirmRemoveAllTags, m_checkBoxAnnounceAllTrackers, m_checkBoxAnnounceAllTiers, diff --git a/src/webui/api/appcontroller.cpp b/src/webui/api/appcontroller.cpp index bb518b6be..3ad9c4f59 100644 --- a/src/webui/api/appcontroller.cpp +++ b/src/webui/api/appcontroller.cpp @@ -270,8 +270,6 @@ void AppController::preferencesAction() // libtorrent preferences // Async IO threads data["async_io_threads"] = session->asyncIOThreads(); - // stop tracker timeout - data["stop_tracker_timeout"] = session->stopTrackerTimeout(); // File pool size data["file_pool_size"] = session->filePoolSize(); // Checking memory usage @@ -311,6 +309,8 @@ void AppController::preferencesAction() data["announce_to_all_trackers"] = session->announceToAllTrackers(); data["announce_to_all_tiers"] = session->announceToAllTiers(); data["announce_ip"] = session->announceIP(); + // Stop tracker timeout + data["stop_tracker_timeout"] = session->stopTrackerTimeout(); setResult(data); } @@ -649,8 +649,8 @@ void AppController::setPreferencesAction() }); const QString ifaceName = (ifacesIter != ifaces.cend()) ? ifacesIter->humanReadableName() : QString {}; - session->setNetworkInterface(ifaceValue); - session->setNetworkInterfaceName(ifaceName); + session->setNetworkInterface(ifaceValue); + session->setNetworkInterfaceName(ifaceName); } // Current network interface address if (hasKey("current_interface_address")) { @@ -671,9 +671,6 @@ void AppController::setPreferencesAction() // Async IO threads if (hasKey("async_io_threads")) session->setAsyncIOThreads(it.value().toInt()); - // Stop tracker timeout - if (hasKey("stop_tracker_timeout")) - session->setStopTrackerTimeout(it.value().toInt()); // File pool size if (hasKey("file_pool_size")) session->setFilePoolSize(it.value().toInt()); @@ -738,6 +735,9 @@ void AppController::setPreferencesAction() const QHostAddress announceAddr {it.value().toString().trimmed()}; session->setAnnounceIP(announceAddr.isNull() ? QString {} : announceAddr.toString()); } + // Stop tracker timeout + if (hasKey("stop_tracker_timeout")) + session->setStopTrackerTimeout(it.value().toInt()); // Save preferences pref->apply(); diff --git a/src/webui/www/private/views/preferences.html b/src/webui/www/private/views/preferences.html index a50c49b39..6585ababa 100644 --- a/src/webui/www/private/views/preferences.html +++ b/src/webui/www/private/views/preferences.html @@ -878,14 +878,6 @@ - - - - - - - - @@ -1080,6 +1072,14 @@ + + + + + + + + @@ -1742,7 +1742,6 @@ $('resolvePeerCountries').setProperty('checked', pref.resolve_peer_countries); // libtorrent section $('asyncIOThreads').setProperty('value', pref.async_io_threads); - $('stopTrackerTimeout').setProperty('value', pref.stop_tracker_timeout); $('filePoolSize').setProperty('value', pref.file_pool_size); $('outstandMemoryWhenCheckingTorrents').setProperty('value', pref.checking_memory_use); $('diskCache').setProperty('value', pref.disk_cache); @@ -1766,6 +1765,7 @@ $('announceAllTrackers').setProperty('checked', pref.announce_to_all_trackers); $('announceAllTiers').setProperty('checked', pref.announce_to_all_tiers); $('announceIP').setProperty('value', pref.announce_ip); + $('stopTrackerTimeout').setProperty('value', pref.stop_tracker_timeout); } } }).send(); @@ -2107,7 +2107,6 @@ // libtorrent section settings.set('async_io_threads', $('asyncIOThreads').getProperty('value')); - settings.set('stop_tracker_timeout', $('stopTrackerTimeout').getProperty('value')); settings.set('file_pool_size', $('filePoolSize').getProperty('value')); settings.set('checking_memory_use', $('outstandMemoryWhenCheckingTorrents').getProperty('value')); settings.set('disk_cache', $('diskCache').getProperty('value')); @@ -2131,6 +2130,7 @@ settings.set('announce_to_all_trackers', $('announceAllTrackers').getProperty('checked')); settings.set('announce_to_all_tiers', $('announceAllTiers').getProperty('checked')); settings.set('announce_ip', $('announceIP').getProperty('value')); + settings.set('stop_tracker_timeout', $('stopTrackerTimeout').getProperty('value')); // Send it to qBT const json_str = JSON.encode(settings);