Browse Source

Add piece_extent_affinity to AdvancedSettings

Expose option in WebUI settings and WebAPI.

Requires WebAPI version bump.

Closes #11436.
adaptive-webui-19844
FranciscoPombal 5 years ago
parent
commit
ed96a07a75
  1. 18
      src/base/bittorrent/session.cpp
  2. 3
      src/base/bittorrent/session.h
  3. 12
      src/gui/advancedsettings.cpp
  4. 2
      src/gui/advancedsettings.h
  5. 5
      src/webui/api/appcontroller.cpp
  6. 10
      src/webui/www/private/views/preferences.html

18
src/base/bittorrent/session.cpp

@ -383,6 +383,7 @@ Session::Session(QObject *parent) @@ -383,6 +383,7 @@ Session::Session(QObject *parent)
#else
, m_coalesceReadWriteEnabled(BITTORRENT_SESSION_KEY("CoalesceReadWrite"), false)
#endif
, m_usePieceExtentAffinity(BITTORRENT_SESSION_KEY("PieceExtentAffinity"), false)
, m_isSuggestMode(BITTORRENT_SESSION_KEY("SuggestMode"), false)
, m_sendBufferWatermark(BITTORRENT_SESSION_KEY("SendBufferWatermark"), 500)
, m_sendBufferLowWatermark(BITTORRENT_SESSION_KEY("SendBufferLowWatermark"), 10)
@ -1323,6 +1324,10 @@ void Session::loadLTSettings(lt::settings_pack &settingsPack) @@ -1323,6 +1324,10 @@ void Session::loadLTSettings(lt::settings_pack &settingsPack)
settingsPack.set_bool(lt::settings_pack::coalesce_reads, isCoalesceReadWriteEnabled());
settingsPack.set_bool(lt::settings_pack::coalesce_writes, isCoalesceReadWriteEnabled());
#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);
@ -3248,6 +3253,19 @@ bool Session::isSuggestModeEnabled() const @@ -3248,6 +3253,19 @@ bool Session::isSuggestModeEnabled() const
return m_isSuggestMode;
}
bool Session::usePieceExtentAffinity() const
{
return m_usePieceExtentAffinity;
}
void Session::setPieceExtentAffinity(const bool enabled)
{
if (enabled == m_usePieceExtentAffinity) return;
m_usePieceExtentAffinity = enabled;
configureDeferred();
}
void Session::setSuggestMode(const bool mode)
{
if (mode == m_isSuggestMode) return;

3
src/base/bittorrent/session.h

@ -337,6 +337,8 @@ namespace BitTorrent @@ -337,6 +337,8 @@ namespace BitTorrent
void setUseOSCache(bool use);
bool isCoalesceReadWriteEnabled() const;
void setCoalesceReadWriteEnabled(bool enabled);
bool usePieceExtentAffinity() const;
void setPieceExtentAffinity(bool enabled);
bool isSuggestModeEnabled() const;
void setSuggestMode(bool mode);
int sendBufferWatermark() const;
@ -610,6 +612,7 @@ namespace BitTorrent @@ -610,6 +612,7 @@ namespace BitTorrent
CachedSettingValue<int> m_diskCacheTTL;
CachedSettingValue<bool> m_useOSCache;
CachedSettingValue<bool> m_coalesceReadWriteEnabled;
CachedSettingValue<bool> m_usePieceExtentAffinity;
CachedSettingValue<bool> m_isSuggestMode;
CachedSettingValue<int> m_sendBufferWatermark;
CachedSettingValue<int> m_sendBufferLowWatermark;

12
src/gui/advancedsettings.cpp

@ -96,6 +96,9 @@ enum AdvSettingsRows @@ -96,6 +96,9 @@ enum AdvSettingsRows
DISK_CACHE_TTL,
OS_CACHE,
COALESCE_RW,
#if (LIBTORRENT_VERSION_NUM >= 10202)
PIECE_EXTENT_AFFINITY,
#endif
SUGGEST_MODE,
SEND_BUF_WATERMARK,
SEND_BUF_LOW_WATERMARK,
@ -188,6 +191,10 @@ void AdvancedSettings::saveAdvancedSettings() @@ -188,6 +191,10 @@ void AdvancedSettings::saveAdvancedSettings()
session->setUseOSCache(m_checkBoxOsCache.isChecked());
// Coalesce reads & writes
session->setCoalesceReadWriteEnabled(m_checkBoxCoalesceRW.isChecked());
#if (LIBTORRENT_VERSION_NUM >= 10202)
// Piece extent affinity
session->setPieceExtentAffinity(m_checkBoxPieceExtentAffinity.isChecked());
#endif
// Suggest mode
session->setSuggestMode(m_checkBoxSuggestMode.isChecked());
// Send buffer watermark
@ -426,6 +433,11 @@ void AdvancedSettings::loadAdvancedSettings() @@ -426,6 +433,11 @@ void AdvancedSettings::loadAdvancedSettings()
m_checkBoxCoalesceRW.setChecked(session->isCoalesceReadWriteEnabled());
addRow(COALESCE_RW, (tr("Coalesce reads & writes") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#coalesce_reads", "(?)"))
, &m_checkBoxCoalesceRW);
#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", "(?)"))

2
src/gui/advancedsettings.h

@ -64,7 +64,7 @@ private: @@ -64,7 +64,7 @@ private:
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,
m_checkBoxMultiConnectionsPerIp, m_checkBoxSuggestMode, m_checkBoxCoalesceRW, m_checkBoxSpeedWidgetEnabled;
m_checkBoxMultiConnectionsPerIp, m_checkBoxPieceExtentAffinity, m_checkBoxSuggestMode, m_checkBoxCoalesceRW, m_checkBoxSpeedWidgetEnabled;
QComboBox m_comboBoxInterface, m_comboBoxInterfaceAddress, m_comboBoxUtpMixedMode, m_comboBoxChokingAlgorithm, m_comboBoxSeedChokingAlgorithm;
QLineEdit m_lineEditAnnounceIP;

5
src/webui/api/appcontroller.cpp

@ -281,6 +281,8 @@ void AppController::preferencesAction() @@ -281,6 +281,8 @@ void AppController::preferencesAction()
data["enable_os_cache"] = session->useOSCache();
// Coalesce reads & writes
data["enable_coalesce_read_write"] = session->isCoalesceReadWriteEnabled();
// Piece Extent Affinity
data["enable_piece_extent_affinity"] = session->usePieceExtentAffinity();
// Suggest mode
data["enable_upload_suggestions"] = session->isSuggestModeEnabled();
// Send buffer watermark
@ -686,6 +688,9 @@ void AppController::setPreferencesAction() @@ -686,6 +688,9 @@ void AppController::setPreferencesAction()
// Coalesce reads & writes
if (hasKey("enable_coalesce_read_write"))
session->setCoalesceReadWriteEnabled(it.value().toBool());
// Piece extent affinity
if (hasKey("enable_piece_extent_affinity"))
session->setPieceExtentAffinity(it.value().toBool());
// Suggest mode
if (hasKey("enable_upload_suggestions"))
session->setSuggestMode(it.value().toBool());

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

@ -926,6 +926,14 @@ @@ -926,6 +926,14 @@
<input type="checkbox" id="coalesceReadsAndWrites" />
</td>
</tr>
<tr>
<td>
<label for="pieceExtentAffinity">QBT_TR(Use piece extent affinity (requires libtorrent >= 1.2.2):)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://libtorrent.org/single-page-ref.html#piece_extent_affinity" target="_blank">(?)</a></label>
</td>
<td>
<input type="checkbox" id="pieceExtentAffinity" />
</td>
</tr>
<tr>
<td>
<label for="sendUploadPieceSuggestions">QBT_TR(Send upload piece suggestions:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://www.libtorrent.org/reference-Settings.html#suggest_mode" target="_blank">(?)</a></label>
@ -1741,6 +1749,7 @@ @@ -1741,6 +1749,7 @@
$('diskCacheExpiryInterval').setProperty('value', pref.disk_cache_ttl);
$('enableOSCache').setProperty('checked', pref.enable_os_cache);
$('coalesceReadsAndWrites').setProperty('checked', pref.enable_coalesce_read_write);
$('pieceExtentAffinity').setProperty('checked', pref.enable_piece_extent_affinity);
$('sendUploadPieceSuggestions').setProperty('checked', pref.enable_upload_suggestions);
$('sendBufferWatermark').setProperty('value', pref.send_buffer_watermark);
$('sendBufferLowWatermark').setProperty('value', pref.send_buffer_low_watermark);
@ -2105,6 +2114,7 @@ @@ -2105,6 +2114,7 @@
settings.set('disk_cache_ttl', $('diskCacheExpiryInterval').getProperty('value'));
settings.set('enable_os_cache', $('enableOSCache').getProperty('checked'));
settings.set('enable_coalesce_read_write', $('coalesceReadsAndWrites').getProperty('checked'));
settings.set('enable_piece_extent_affinity', $('pieceExtentAffinity').getProperty('checked'));
settings.set('enable_upload_suggestions', $('sendUploadPieceSuggestions').getProperty('checked'));
settings.set('send_buffer_watermark', $('sendBufferWatermark').getProperty('value'));
settings.set('send_buffer_low_watermark', $('sendBufferLowWatermark').getProperty('value'));

Loading…
Cancel
Save