Browse Source

Add guided_read_cache knob

cleanup header include order
adaptive-webui-19844
Chocobo1 7 years ago
parent
commit
6150e0c56b
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 16
      src/base/bittorrent/session.cpp
  2. 3
      src/base/bittorrent/session.h
  3. 6
      src/gui/advancedsettings.cpp
  4. 9
      src/gui/advancedsettings.h

16
src/base/bittorrent/session.cpp

@ -263,6 +263,7 @@ Session::Session(QObject *parent)
, m_diskCacheSize(BITTORRENT_SESSION_KEY("DiskCacheSize"), 0) , m_diskCacheSize(BITTORRENT_SESSION_KEY("DiskCacheSize"), 0)
, m_diskCacheTTL(BITTORRENT_SESSION_KEY("DiskCacheTTL"), 60) , m_diskCacheTTL(BITTORRENT_SESSION_KEY("DiskCacheTTL"), 60)
, m_useOSCache(BITTORRENT_SESSION_KEY("UseOSCache"), true) , m_useOSCache(BITTORRENT_SESSION_KEY("UseOSCache"), true)
, m_guidedReadCacheEnabled(BITTORRENT_SESSION_KEY("GuidedReadCache"), true)
, m_isAnonymousModeEnabled(BITTORRENT_SESSION_KEY("AnonymousModeEnabled"), false) , m_isAnonymousModeEnabled(BITTORRENT_SESSION_KEY("AnonymousModeEnabled"), false)
, m_isQueueingEnabled(BITTORRENT_SESSION_KEY("QueueingSystemEnabled"), true) , m_isQueueingEnabled(BITTORRENT_SESSION_KEY("QueueingSystemEnabled"), true)
, m_maxActiveDownloads(BITTORRENT_SESSION_KEY("MaxActiveDownloads"), 3, lowerLimited(-1)) , m_maxActiveDownloads(BITTORRENT_SESSION_KEY("MaxActiveDownloads"), 3, lowerLimited(-1))
@ -1256,6 +1257,7 @@ void Session::configure(libtorrent::settings_pack &settingsPack)
: libt::settings_pack::disable_os_cache; : libt::settings_pack::disable_os_cache;
settingsPack.set_int(libt::settings_pack::disk_io_read_mode, mode); settingsPack.set_int(libt::settings_pack::disk_io_read_mode, mode);
settingsPack.set_int(libt::settings_pack::disk_io_write_mode, mode); settingsPack.set_int(libt::settings_pack::disk_io_write_mode, mode);
settingsPack.set_bool(libt::settings_pack::guided_read_cache, isGuidedReadCacheEnabled());
settingsPack.set_bool(libt::settings_pack::anonymous_mode, isAnonymousModeEnabled()); settingsPack.set_bool(libt::settings_pack::anonymous_mode, isAnonymousModeEnabled());
@ -1472,6 +1474,7 @@ void Session::configure(libtorrent::session_settings &sessionSettings)
: libt::session_settings::disable_os_cache; : libt::session_settings::disable_os_cache;
sessionSettings.disk_io_read_mode = mode; sessionSettings.disk_io_read_mode = mode;
sessionSettings.disk_io_write_mode = mode; sessionSettings.disk_io_write_mode = mode;
sessionSettings.guided_read_cache = isGuidedReadCacheEnabled();
sessionSettings.anonymous_mode = isAnonymousModeEnabled(); sessionSettings.anonymous_mode = isAnonymousModeEnabled();
@ -2844,6 +2847,19 @@ void Session::setUseOSCache(bool use)
} }
} }
bool Session::isGuidedReadCacheEnabled() const
{
return m_guidedReadCacheEnabled;
}
void Session::setGuidedReadCacheEnabled(bool enabled)
{
if (enabled == m_guidedReadCacheEnabled) return;
m_guidedReadCacheEnabled = enabled;
configureDeferred();
}
bool Session::isAnonymousModeEnabled() const bool Session::isAnonymousModeEnabled() const
{ {
return m_isAnonymousModeEnabled; return m_isAnonymousModeEnabled;

3
src/base/bittorrent/session.h

@ -333,6 +333,8 @@ namespace BitTorrent
void setDiskCacheTTL(int ttl); void setDiskCacheTTL(int ttl);
bool useOSCache() const; bool useOSCache() const;
void setUseOSCache(bool use); void setUseOSCache(bool use);
bool isGuidedReadCacheEnabled() const;
void setGuidedReadCacheEnabled(bool enabled);
bool isAnonymousModeEnabled() const; bool isAnonymousModeEnabled() const;
void setAnonymousModeEnabled(bool enabled); void setAnonymousModeEnabled(bool enabled);
bool isQueueingSystemEnabled() const; bool isQueueingSystemEnabled() const;
@ -575,6 +577,7 @@ namespace BitTorrent
CachedSettingValue<int> m_diskCacheSize; CachedSettingValue<int> m_diskCacheSize;
CachedSettingValue<int> m_diskCacheTTL; CachedSettingValue<int> m_diskCacheTTL;
CachedSettingValue<bool> m_useOSCache; CachedSettingValue<bool> m_useOSCache;
CachedSettingValue<bool> m_guidedReadCacheEnabled;
CachedSettingValue<bool> m_isAnonymousModeEnabled; CachedSettingValue<bool> m_isAnonymousModeEnabled;
CachedSettingValue<bool> m_isQueueingEnabled; CachedSettingValue<bool> m_isQueueingEnabled;
CachedSettingValue<int> m_maxActiveDownloads; CachedSettingValue<int> m_maxActiveDownloads;

6
src/gui/advancedsettings.cpp

@ -78,6 +78,7 @@ enum AdvSettingsRows
DISK_CACHE, DISK_CACHE,
DISK_CACHE_TTL, DISK_CACHE_TTL,
OS_CACHE, OS_CACHE,
GUIDED_READ_CACHE,
// ports // ports
MAX_HALF_OPEN, MAX_HALF_OPEN,
OUTGOING_PORT_MIN, OUTGOING_PORT_MIN,
@ -127,6 +128,8 @@ void AdvancedSettings::saveAdvancedSettings()
session->setDiskCacheTTL(spin_cache_ttl.value()); session->setDiskCacheTTL(spin_cache_ttl.value());
// Enable OS cache // Enable OS cache
session->setUseOSCache(cb_os_cache.isChecked()); session->setUseOSCache(cb_os_cache.isChecked());
// Guided read cache
session->setGuidedReadCacheEnabled(cbGuidedReadCache.isChecked());
// Save resume data interval // Save resume data interval
session->setSaveResumeDataInterval(spin_save_resume_data_interval.value()); session->setSaveResumeDataInterval(spin_save_resume_data_interval.value());
// Outgoing ports // Outgoing ports
@ -278,6 +281,9 @@ void AdvancedSettings::loadAdvancedSettings()
// Enable OS cache // Enable OS cache
cb_os_cache.setChecked(session->useOSCache()); cb_os_cache.setChecked(session->useOSCache());
addRow(OS_CACHE, tr("Enable OS cache"), &cb_os_cache); addRow(OS_CACHE, tr("Enable OS cache"), &cb_os_cache);
// Guided read cache
cbGuidedReadCache.setChecked(session->isGuidedReadCacheEnabled());
addRow(GUIDED_READ_CACHE, tr("Guided read cache"), &cbGuidedReadCache);
// Save resume data interval // Save resume data interval
spin_save_resume_data_interval.setMinimum(1); spin_save_resume_data_interval.setMinimum(1);
spin_save_resume_data_interval.setMaximum(1440); spin_save_resume_data_interval.setMaximum(1440);

9
src/gui/advancedsettings.h

@ -29,15 +29,14 @@
#ifndef ADVANCEDSETTINGS_H #ifndef ADVANCEDSETTINGS_H
#define ADVANCEDSETTINGS_H #define ADVANCEDSETTINGS_H
#include <QCheckBox>
#include <QComboBox>
#include <QEvent> #include <QEvent>
#include <QLabel> #include <QLabel>
#include <QSpinBox>
#include <QCheckBox>
#include <QLineEdit> #include <QLineEdit>
#include <QComboBox> #include <QSpinBox>
#include <QTableWidget> #include <QTableWidget>
class WheelEventEater: public QObject class WheelEventEater: public QObject
{ {
Q_OBJECT Q_OBJECT
@ -79,7 +78,7 @@ private:
QSpinBox spin_cache, spin_save_resume_data_interval, outgoing_ports_min, outgoing_ports_max, spin_list_refresh, spin_maxhalfopen, spin_tracker_port, spin_cache_ttl; QSpinBox spin_cache, spin_save_resume_data_interval, outgoing_ports_min, outgoing_ports_max, spin_list_refresh, spin_maxhalfopen, spin_tracker_port, spin_cache_ttl;
QCheckBox cb_os_cache, cb_recheck_completed, cb_resolve_countries, cb_resolve_hosts, cb_super_seeding, QCheckBox cb_os_cache, cb_recheck_completed, cb_resolve_countries, cb_resolve_hosts, cb_super_seeding,
cb_program_notifications, cb_torrent_added_notifications, cb_tracker_favicon, cb_tracker_status, cb_program_notifications, cb_torrent_added_notifications, cb_tracker_favicon, cb_tracker_status,
cb_confirm_torrent_recheck, cb_confirm_remove_all_tags, cb_listen_ipv6, cb_announce_all_trackers; cb_confirm_torrent_recheck, cb_confirm_remove_all_tags, cb_listen_ipv6, cb_announce_all_trackers, cbGuidedReadCache;
QComboBox combo_iface, combo_iface_address; QComboBox combo_iface, combo_iface_address;
QLineEdit txtAnnounceIP; QLineEdit txtAnnounceIP;

Loading…
Cancel
Save