From 2a4077414f44f370d4bb66c3fd91ec755d4ce04d Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Thu, 26 Sep 2024 18:49:42 +0300 Subject: [PATCH] Reorder code to match UI --- src/webui/api/appcontroller.cpp | 42 ++++++++++++++-------------- src/webui/www/private/views/preferences.html | 20 ++++++------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/webui/api/appcontroller.cpp b/src/webui/api/appcontroller.cpp index f4bef826c..922754ee1 100644 --- a/src/webui/api/appcontroller.cpp +++ b/src/webui/api/appcontroller.cpp @@ -374,8 +374,16 @@ void AppController::preferencesAction() data[u"resolve_peer_countries"_s] = pref->resolvePeerCountries(); // Reannounce to all trackers when ip/port changed data[u"reannounce_when_address_changed"_s] = session->isReannounceWhenAddressChangedEnabled(); + // Embedded tracker + data[u"enable_embedded_tracker"_s] = session->isTrackerEnabled(); + data[u"embedded_tracker_port"_s] = pref->getTrackerPort(); + data[u"embedded_tracker_port_forwarding"_s] = pref->isTrackerPortForwardingEnabled(); + // Mark-of-the-Web + data[u"mark_of_the_web"_s] = pref->isMarkOfTheWebEnabled(); // Ignore SSL errors data[u"ignore_ssl_errors"_s] = pref->isIgnoreSSLErrors(); + // Python executable path + data[u"python_executable_path"_s] = pref->getPythonExecutablePath().toString(); // libtorrent preferences // Bdecode depth limit @@ -438,14 +446,6 @@ void AppController::preferencesAction() data[u"ssrf_mitigation"_s] = session->isSSRFMitigationEnabled(); // Disallow connection to peers on privileged ports data[u"block_peers_on_privileged_ports"_s] = session->blockPeersOnPrivilegedPorts(); - // Embedded tracker - data[u"enable_embedded_tracker"_s] = session->isTrackerEnabled(); - data[u"embedded_tracker_port"_s] = pref->getTrackerPort(); - data[u"embedded_tracker_port_forwarding"_s] = pref->isTrackerPortForwardingEnabled(); - // Mark-of-the-Web - data[u"mark_of_the_web"_s] = pref->isMarkOfTheWebEnabled(); - // Python executable path - data[u"python_executable_path"_s] = pref->getPythonExecutablePath().toString(); // Choking algorithm data[u"upload_slots_behavior"_s] = static_cast(session->chokingAlgorithm()); // Seed choking algorithm @@ -984,9 +984,22 @@ void AppController::setPreferencesAction() // Reannounce to all trackers when ip/port changed if (hasKey(u"reannounce_when_address_changed"_s)) session->setReannounceWhenAddressChangedEnabled(it.value().toBool()); + // Embedded tracker + if (hasKey(u"embedded_tracker_port"_s)) + pref->setTrackerPort(it.value().toInt()); + if (hasKey(u"embedded_tracker_port_forwarding"_s)) + pref->setTrackerPortForwardingEnabled(it.value().toBool()); + if (hasKey(u"enable_embedded_tracker"_s)) + session->setTrackerEnabled(it.value().toBool()); + // Mark-of-the-Web + if (hasKey(u"mark_of_the_web"_s)) + pref->setMarkOfTheWebEnabled(it.value().toBool()); // Ignore SLL errors if (hasKey(u"ignore_ssl_errors"_s)) pref->setIgnoreSSLErrors(it.value().toBool()); + // Python executable path + if (hasKey(u"python_executable_path"_s)) + pref->setPythonExecutablePath(Path(it.value().toString())); // libtorrent preferences // Bdecode depth limit @@ -1081,19 +1094,6 @@ void AppController::setPreferencesAction() // Disallow connection to peers on privileged ports if (hasKey(u"block_peers_on_privileged_ports"_s)) session->setBlockPeersOnPrivilegedPorts(it.value().toBool()); - // Embedded tracker - if (hasKey(u"embedded_tracker_port"_s)) - pref->setTrackerPort(it.value().toInt()); - if (hasKey(u"embedded_tracker_port_forwarding"_s)) - pref->setTrackerPortForwardingEnabled(it.value().toBool()); - if (hasKey(u"enable_embedded_tracker"_s)) - session->setTrackerEnabled(it.value().toBool()); - // Mark-of-the-Web - if (hasKey(u"mark_of_the_web"_s)) - pref->setMarkOfTheWebEnabled(it.value().toBool()); - // Python executable path - if (hasKey(u"python_executable_path"_s)) - pref->setPythonExecutablePath(Path(it.value().toString())); // Choking algorithm if (hasKey(u"upload_slots_behavior"_s)) session->setChokingAlgorithm(static_cast(it.value().toInt())); diff --git a/src/webui/www/private/views/preferences.html b/src/webui/www/private/views/preferences.html index dca1aa7d7..8bbcad525 100644 --- a/src/webui/www/private/views/preferences.html +++ b/src/webui/www/private/views/preferences.html @@ -2361,7 +2361,12 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD $("refreshInterval").setProperty("value", pref.refresh_interval); $("resolvePeerCountries").setProperty("checked", pref.resolve_peer_countries); $("reannounceWhenAddressChanged").setProperty("checked", pref.reannounce_when_address_changed); + $("enableEmbeddedTracker").setProperty("checked", pref.enable_embedded_tracker); + $("embeddedTrackerPort").setProperty("value", pref.embedded_tracker_port); + $("embeddedTrackerPortForwarding").setProperty("checked", pref.embedded_tracker_port_forwarding); + $("markOfTheWeb").setProperty("checked", pref.mark_of_the_web); $("ignoreSSLErrors").setProperty("checked", pref.ignore_ssl_errors); + $("pythonExecutablePath").setProperty("value", pref.python_executable_path); // libtorrent section $("bdecodeDepthLimit").setProperty("value", pref.bdecode_depth_limit); $("bdecodeTokenLimit").setProperty("value", pref.bdecode_token_limit); @@ -2395,11 +2400,6 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD $("validateHTTPSTrackerCertificate").setProperty("checked", pref.validate_https_tracker_certificate); $("mitigateSSRF").setProperty("checked", pref.ssrf_mitigation); $("blockPeersOnPrivilegedPorts").setProperty("checked", pref.block_peers_on_privileged_ports); - $("enableEmbeddedTracker").setProperty("checked", pref.enable_embedded_tracker); - $("embeddedTrackerPort").setProperty("value", pref.embedded_tracker_port); - $("embeddedTrackerPortForwarding").setProperty("checked", pref.embedded_tracker_port_forwarding); - $("markOfTheWeb").setProperty("checked", pref.mark_of_the_web); - $("pythonExecutablePath").setProperty("value", pref.python_executable_path); $("uploadSlotsBehavior").setProperty("value", pref.upload_slots_behavior); $("uploadChokingAlgorithm").setProperty("value", pref.upload_choking_algorithm); $("announceAllTrackers").setProperty("checked", pref.announce_to_all_trackers); @@ -2811,7 +2811,12 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD settings["refresh_interval"] = Number($("refreshInterval").getProperty("value")); settings["resolve_peer_countries"] = $("resolvePeerCountries").getProperty("checked"); settings["reannounce_when_address_changed"] = $("reannounceWhenAddressChanged").getProperty("checked"); + settings["enable_embedded_tracker"] = $("enableEmbeddedTracker").getProperty("checked"); + settings["embedded_tracker_port"] = Number($("embeddedTrackerPort").getProperty("value")); + settings["embedded_tracker_port_forwarding"] = $("embeddedTrackerPortForwarding").getProperty("checked"); + settings["mark_of_the_web"] = $("markOfTheWeb").getProperty("checked"); settings["ignore_ssl_errors"] = $("ignoreSSLErrors").getProperty("checked"); + settings["python_executable_path"] = $("pythonExecutablePath").getProperty("value"); // libtorrent section settings["bdecode_depth_limit"] = Number($("bdecodeDepthLimit").getProperty("value")); @@ -2846,11 +2851,6 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD settings["validate_https_tracker_certificate"] = $("validateHTTPSTrackerCertificate").getProperty("checked"); settings["ssrf_mitigation"] = $("mitigateSSRF").getProperty("checked"); settings["block_peers_on_privileged_ports"] = $("blockPeersOnPrivilegedPorts").getProperty("checked"); - settings["enable_embedded_tracker"] = $("enableEmbeddedTracker").getProperty("checked"); - settings["embedded_tracker_port"] = Number($("embeddedTrackerPort").getProperty("value")); - settings["embedded_tracker_port_forwarding"] = $("embeddedTrackerPortForwarding").getProperty("checked"); - settings["mark_of_the_web"] = $("markOfTheWeb").getProperty("checked"); - settings["python_executable_path"] = $("pythonExecutablePath").getProperty("value"); settings["upload_slots_behavior"] = Number($("uploadSlotsBehavior").getProperty("value")); settings["upload_choking_algorithm"] = Number($("uploadChokingAlgorithm").getProperty("value")); settings["announce_to_all_trackers"] = $("announceAllTrackers").getProperty("checked"); -- 2.11.4.GIT