diff --git a/src/webui/api/appcontroller.cpp b/src/webui/api/appcontroller.cpp index d28464d1e..395afde3f 100644 --- a/src/webui/api/appcontroller.cpp +++ b/src/webui/api/appcontroller.cpp @@ -193,6 +193,16 @@ void AppController::preferencesAction() data[u"max_uploads"_s] = session->maxUploads(); data[u"max_uploads_per_torrent"_s] = session->maxUploadsPerTorrent(); + // I2P + data[u"i2p_enabled"_s] = session->isI2PEnabled(); + data[u"i2p_address"_s] = session->I2PAddress(); + data[u"i2p_port"_s] = session->I2PPort(); + data[u"i2p_mixed_mode"_s] = session->I2PMixedMode(); + data[u"i2p_inbound_quantity"_s] = session->I2PInboundQuantity(); + data[u"i2p_outbound_quantity"_s] = session->I2POutboundQuantity(); + data[u"i2p_inbound_length"_s] = session->I2PInboundLength(); + data[u"i2p_outbound_length"_s] = session->I2POutboundLength(); + // Proxy Server const auto *proxyManager = Net::ProxyConfigurationManager::instance(); Net::ProxyConfiguration proxyConf = proxyManager->proxyConfiguration(); @@ -632,6 +642,24 @@ void AppController::setPreferencesAction() if (hasKey(u"max_uploads_per_torrent"_s)) session->setMaxUploadsPerTorrent(it.value().toInt()); + // I2P + if (hasKey(u"i2p_enabled"_s)) + session->setI2PEnabled(it.value().toBool()); + if (hasKey(u"i2p_address"_s)) + session->setI2PAddress(it.value().toString()); + if (hasKey(u"i2p_port"_s)) + session->setI2PPort(it.value().toInt()); + if (hasKey(u"i2p_mixed_mode"_s)) + session->setI2PMixedMode(it.value().toBool()); + if (hasKey(u"i2p_inbound_quantity"_s)) + session->setI2PInboundQuantity(it.value().toInt()); + if (hasKey(u"i2p_outbound_quantity"_s)) + session->setI2POutboundQuantity(it.value().toInt()); + if (hasKey(u"i2p_inbound_length"_s)) + session->setI2PInboundLength(it.value().toInt()); + if (hasKey(u"i2p_outbound_length"_s)) + session->setI2POutboundLength(it.value().toInt()); + // Proxy Server auto *proxyManager = Net::ProxyConfigurationManager::instance(); Net::ProxyConfiguration proxyConf = proxyManager->proxyConfiguration(); diff --git a/src/webui/webapplication.h b/src/webui/webapplication.h index d28c8a851..d149e8ac5 100644 --- a/src/webui/webapplication.h +++ b/src/webui/webapplication.h @@ -52,7 +52,7 @@ #include "base/utils/version.h" #include "api/isessionmanager.h" -inline const Utils::Version<3, 2> API_VERSION {2, 9, 5}; +inline const Utils::Version<3, 2> API_VERSION {2, 9, 6}; class APIController; class AuthController; diff --git a/src/webui/www/private/views/preferences.html b/src/webui/www/private/views/preferences.html index dc79b5d91..002866531 100644 --- a/src/webui/www/private/views/preferences.html +++ b/src/webui/www/private/views/preferences.html @@ -349,6 +349,33 @@ +
+ @@ -1471,6 +1530,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD updateMaxConnecPerTorrentEnabled: updateMaxConnecPerTorrentEnabled, updateMaxUploadsEnabled: updateMaxUploadsEnabled, updateMaxUploadsPerTorrentEnabled: updateMaxUploadsPerTorrentEnabled, + updateI2PSettingsEnabled: updateI2PSettingsEnabled, updatePeerProxySettings: updatePeerProxySettings, updatePeerProxyAuthSettings: updatePeerProxyAuthSettings, updateFilterSettings: updateFilterSettings, @@ -1660,6 +1720,13 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD $('max_uploads_per_torrent_value').setProperty('disabled', !isMaxUploadsPerTorrentEnabled); }; + const updateI2PSettingsEnabled = function() { + const isI2PEnabled = $('i2pEnabledCheckbox').getProperty('checked'); + $('i2pAddress').setProperty('disabled', !isI2PEnabled); + $('i2pPort').setProperty('disabled', !isI2PEnabled); + $('i2pMixedMode').setProperty('disabled', !isI2PEnabled); + }; + const updatePeerProxySettings = function() { const proxyType = $('peer_proxy_type_select').getProperty('value'); const isProxyDisabled = (proxyType === "None"); @@ -2039,6 +2106,13 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD } updateMaxUploadsPerTorrentEnabled(); + // I2P + $('i2pEnabledCheckbox').setProperty('checked', pref.i2p_enabled); + $('i2pAddress').setProperty('value', pref.i2p_address); + $('i2pPort').setProperty('value', pref.i2p_port); + $('i2pMixedMode').setProperty('checked', pref.i2p_mixed_mode); + updateI2PSettingsEnabled(); + // Proxy Server $('peer_proxy_type_select').setProperty('value', pref.proxy_type); $('peer_proxy_host_text').setProperty('value', pref.proxy_ip); @@ -2259,6 +2333,10 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD $('peerTurnoverInterval').setProperty('value', pref.peer_turnover_interval); $('requestQueueSize').setProperty('value', pref.request_queue_size); $('dhtBootstrapNodes').setProperty('value', pref.dht_bootstrap_nodes); + $('i2pInboundQuantity').setProperty('value', pref.i2p_inbound_quantity); + $('i2pOutboundQuantity').setProperty('value', pref.i2p_outbound_quantity); + $('i2pInboundLength').setProperty('value', pref.i2p_inbound_length); + $('i2pOutboundLength').setProperty('value', pref.i2p_outbound_length); } } }).send(); @@ -2378,6 +2456,12 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD } settings.set('max_uploads_per_torrent', max_uploads_per_torrent); + // I2P + settings.set('i2p_enabled', $('i2pEnabledCheckbox').getProperty('checked')); + settings.set('i2p_address', $('i2pAddress').getProperty('value')); + settings.set('i2p_port', $('i2pPort').getProperty('value').toInt()); + settings.set('i2p_mixed_mode', $('i2pMixedMode').getProperty('checked')); + // Proxy Server settings.set('proxy_type', $('peer_proxy_type_select').getProperty('value')); settings.set('proxy_ip', $('peer_proxy_host_text').getProperty('value')); @@ -2693,6 +2777,10 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD settings.set('peer_turnover_interval', $('peerTurnoverInterval').getProperty('value')); settings.set('request_queue_size', $('requestQueueSize').getProperty('value')); settings.set('dht_bootstrap_nodes', $('dhtBootstrapNodes').getProperty('value')); + settings.set('i2p_inbound_quantity', $('i2pInboundQuantity').getProperty('value')); + settings.set('i2p_outbound_quantity', $('i2pOutboundQuantity').getProperty('value')); + settings.set('i2p_inbound_length', $('i2pInboundLength').getProperty('value')); + settings.set('i2p_outbound_length', $('i2pOutboundLength').getProperty('value')); // Send it to qBT const json_str = JSON.encode(settings);