Merge pull request #8372 from thalieht/inactiverate

Expose the libtorrent fields for "dont_count_slow_torrents" to GUI.
Closes #5713.
This commit is contained in:
Vladimir Golovnev
2018-02-24 14:13:39 +03:00
committed by GitHub
4 changed files with 194 additions and 7 deletions

View File

@@ -295,6 +295,9 @@ Session::Session(QObject *parent)
, m_maxActiveUploads(BITTORRENT_SESSION_KEY("MaxActiveUploads"), 3, lowerLimited(-1))
, m_maxActiveTorrents(BITTORRENT_SESSION_KEY("MaxActiveTorrents"), 5, lowerLimited(-1))
, m_ignoreSlowTorrentsForQueueing(BITTORRENT_SESSION_KEY("IgnoreSlowTorrentsForQueueing"), false)
, m_downloadRateForSlowTorrents(BITTORRENT_SESSION_KEY("SlowTorrentsDownloadRate"), 2)
, m_uploadRateForSlowTorrents(BITTORRENT_SESSION_KEY("SlowTorrentsUploadRate"), 2)
, m_slowTorrentsInactivityTimer(BITTORRENT_SESSION_KEY("SlowTorrentsInactivityTimer"), 60)
, m_outgoingPortsMin(BITTORRENT_SESSION_KEY("OutgoingPortsMin"), 0)
, m_outgoingPortsMax(BITTORRENT_SESSION_KEY("OutgoingPortsMax"), 0)
, m_ignoreLimitsOnLAN(BITTORRENT_SESSION_KEY("IgnoreLimitsOnLAN"), true)
@@ -1327,6 +1330,9 @@ void Session::configure(libtorrent::settings_pack &settingsPack)
settingsPack.set_int(libt::settings_pack::active_seeds, maxActiveUploads());
settingsPack.set_bool(libt::settings_pack::dont_count_slow_torrents, ignoreSlowTorrentsForQueueing());
settingsPack.set_int(libt::settings_pack::inactive_down_rate, downloadRateForSlowTorrents() * 1024); // KiB to Bytes
settingsPack.set_int(libt::settings_pack::inactive_up_rate, uploadRateForSlowTorrents() * 1024); // KiB to Bytes
settingsPack.set_int(libt::settings_pack::auto_manage_startup, slowTorrentsInactivityTimer());
}
else {
settingsPack.set_int(libt::settings_pack::active_downloads, -1);
@@ -3208,6 +3214,48 @@ void Session::setIgnoreSlowTorrentsForQueueing(bool ignore)
}
}
int Session::downloadRateForSlowTorrents() const
{
return m_downloadRateForSlowTorrents;
}
void Session::setDownloadRateForSlowTorrents(int rateInKibiBytes)
{
if (rateInKibiBytes == m_downloadRateForSlowTorrents)
return;
m_downloadRateForSlowTorrents = rateInKibiBytes;
configureDeferred();
}
int Session::uploadRateForSlowTorrents() const
{
return m_uploadRateForSlowTorrents;
}
void Session::setUploadRateForSlowTorrents(int rateInKibiBytes)
{
if (rateInKibiBytes == m_uploadRateForSlowTorrents)
return;
m_uploadRateForSlowTorrents = rateInKibiBytes;
configureDeferred();
}
int Session::slowTorrentsInactivityTimer() const
{
return m_slowTorrentsInactivityTimer;
}
void Session::setSlowTorrentsInactivityTimer(int timeInSeconds)
{
if (timeInSeconds == m_slowTorrentsInactivityTimer)
return;
m_slowTorrentsInactivityTimer = timeInSeconds;
configureDeferred();
}
int Session::outgoingPortsMin() const
{
return m_outgoingPortsMin;

View File

@@ -398,6 +398,12 @@ namespace BitTorrent
void setQueueingSystemEnabled(bool enabled);
bool ignoreSlowTorrentsForQueueing() const;
void setIgnoreSlowTorrentsForQueueing(bool ignore);
int downloadRateForSlowTorrents() const;
void setDownloadRateForSlowTorrents(int rateInKibiBytes);
int uploadRateForSlowTorrents() const;
void setUploadRateForSlowTorrents(int rateInKibiBytes);
int slowTorrentsInactivityTimer() const;
void setSlowTorrentsInactivityTimer(int timeInSeconds);
int outgoingPortsMin() const;
void setOutgoingPortsMin(int min);
int outgoingPortsMax() const;
@@ -659,6 +665,9 @@ namespace BitTorrent
CachedSettingValue<int> m_maxActiveUploads;
CachedSettingValue<int> m_maxActiveTorrents;
CachedSettingValue<bool> m_ignoreSlowTorrentsForQueueing;
CachedSettingValue<int> m_downloadRateForSlowTorrents;
CachedSettingValue<int> m_uploadRateForSlowTorrents;
CachedSettingValue<int> m_slowTorrentsInactivityTimer;
CachedSettingValue<int> m_outgoingPortsMin;
CachedSettingValue<int> m_outgoingPortsMax;
CachedSettingValue<bool> m_ignoreLimitsOnLAN;