Browse Source

Merge pull request #11848 from an0n666/stop_tracker_timeout_placement

Change stop tracker timeout settings placement
adaptive-webui-19844
Mike Tzou 5 years ago committed by GitHub
parent
commit
a124decdc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 33
      src/base/bittorrent/session.cpp
  2. 6
      src/base/bittorrent/session.h
  3. 17
      src/gui/advancedsettings.cpp
  4. 4
      src/gui/advancedsettings.h
  5. 14
      src/webui/api/appcontroller.cpp
  6. 20
      src/webui/www/private/views/preferences.html

33
src/base/bittorrent/session.cpp

@ -373,7 +373,6 @@ Session::Session(QObject *parent) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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;

6
src/base/bittorrent/session.h

@ -325,8 +325,6 @@ namespace BitTorrent @@ -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 @@ -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 @@ -606,7 +606,6 @@ namespace BitTorrent
CachedSettingValue<bool> m_announceToAllTrackers;
CachedSettingValue<bool> m_announceToAllTiers;
CachedSettingValue<int> m_asyncIOThreads;
CachedSettingValue<int> m_stopTrackerTimeout;
CachedSettingValue<int> m_filePoolSize;
CachedSettingValue<int> m_checkingMemUsage;
CachedSettingValue<int> m_diskCacheSize;
@ -632,6 +631,7 @@ namespace BitTorrent @@ -632,6 +631,7 @@ namespace BitTorrent
CachedSettingValue<bool> m_ignoreLimitsOnLAN;
CachedSettingValue<bool> m_includeOverheadInLimits;
CachedSettingValue<QString> m_announceIP;
CachedSettingValue<int> m_stopTrackerTimeout;
CachedSettingValue<bool> m_isSuperSeedingEnabled;
CachedSettingValue<int> m_maxConnections;
CachedSettingValue<int> m_maxUploads;

17
src/gui/advancedsettings.cpp

@ -89,7 +89,6 @@ enum AdvSettingsRows @@ -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 @@ -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() @@ -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() @@ -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<Application*>(QCoreApplication::instance())->mainWindow();
mainWindow->setNotificationsEnabled(m_checkBoxProgramNotifications.isChecked());
@ -379,11 +378,6 @@ void AdvancedSettings::loadAdvancedSettings() @@ -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<int>::max());
@ -531,6 +525,11 @@ void AdvancedSettings::loadAdvancedSettings() @@ -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<Application*>(QCoreApplication::instance())->mainWindow();

4
src/gui/advancedsettings.h

@ -57,10 +57,10 @@ private: @@ -57,10 +57,10 @@ private:
void loadAdvancedSettings();
template <typename T> 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,

14
src/webui/api/appcontroller.cpp

@ -270,8 +270,6 @@ void AppController::preferencesAction() @@ -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() @@ -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() @@ -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() @@ -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() @@ -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();

20
src/webui/www/private/views/preferences.html

@ -878,14 +878,6 @@ @@ -878,14 +878,6 @@
<input type="text" id="asyncIOThreads" style="width: 15em;" />
</td>
</tr>
<tr>
<td>
<label for="stopTrackerTimeout">QBT_TR(Stop tracker timeout:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#stop_tracker_timeout" target="_blank">(?)</a></label>
</td>
<td>
<input type="text" id="stopTrackerTimeout" style="width: 15em;" />
</td>
</tr>
<tr>
<td>
<label for="filePoolSize">QBT_TR(File pool size:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#file_pool_size" target="_blank">(?)</a></label>
@ -1080,6 +1072,14 @@ @@ -1080,6 +1072,14 @@
<input type="text" id="announceIP" style="width: 15em;" />
</td>
</tr>
<tr>
<td>
<label for="stopTrackerTimeout">QBT_TR(Stop tracker timeout:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#stop_tracker_timeout" target="_blank">(?)</a></label>
</td>
<td>
<input type="text" id="stopTrackerTimeout" style="width: 15em;" />
</td>
</tr>
</table>
</fieldset>
</div>
@ -1742,7 +1742,6 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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);

Loading…
Cancel
Save