mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-03 15:08:40 +00:00
[#2991] Fix display/setting single proxy in UIs
* Now copies all proxy settings from peer to other types to reflect how that the single undelying libtorrent proxy is set. * Grey-out the other proxies types in GTKUI to avoid some confusion.
This commit is contained in:
parent
a86b6f0f8f
commit
d977915f32
3 changed files with 806 additions and 113 deletions
|
@ -151,6 +151,8 @@ DEFAULT_PREFS = {
|
||||||
}
|
}
|
||||||
|
|
||||||
class PreferencesManager(component.Component):
|
class PreferencesManager(component.Component):
|
||||||
|
LT_SINGLE_PROXY = deluge.common.VersionSplit(lt.version) >= deluge.common.VersionSplit("0.16.0.0")
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
component.Component.__init__(self, "PreferencesManager")
|
component.Component.__init__(self, "PreferencesManager")
|
||||||
|
|
||||||
|
@ -478,15 +480,26 @@ class PreferencesManager(component.Component):
|
||||||
self.new_release_timer.stop()
|
self.new_release_timer.stop()
|
||||||
|
|
||||||
def _on_set_proxies(self, key, value):
|
def _on_set_proxies(self, key, value):
|
||||||
lt_single_proxy = deluge.common.VersionSplit(lt.version) >= deluge.common.VersionSplit("0.16.0.0")
|
# Test for single proxy with lt >= 0.16
|
||||||
for k, v in value.items():
|
if self.LT_SINGLE_PROXY:
|
||||||
if k != "peer" and lt_single_proxy:
|
for proxy_type in value:
|
||||||
# Only set peer proxy to stop overwriting proxy setting in libtorrent >= 0.16.
|
if proxy_type == "peer":
|
||||||
if v["hostname"]:
|
|
||||||
log.warning("Using libtorrent >= 0.16 ignores proxy settings for %s", k)
|
|
||||||
self.config["proxies"][k] = DEFAULT_PREFS["proxies"][k]
|
|
||||||
continue
|
continue
|
||||||
|
if self.config["proxies"][proxy_type] != value["peer"]:
|
||||||
|
log.warning("This version of libtorrent only supports a single proxy setting "
|
||||||
|
"based upon 'peer' which will apply to all other other types.")
|
||||||
|
self.config["proxies"][proxy_type] = value["peer"]
|
||||||
|
|
||||||
|
proxy_settings = lt.proxy_settings()
|
||||||
|
proxy_settings.type = lt.proxy_type(value["peer"]["type"])
|
||||||
|
proxy_settings.username = str(value["peer"]["username"])
|
||||||
|
proxy_settings.password = str(value["peer"]["password"])
|
||||||
|
proxy_settings.hostname = str(value["peer"]["hostname"])
|
||||||
|
proxy_settings.port = value["peer"]["port"]
|
||||||
|
log.debug("Setting proxy settings: %s", value["peer"])
|
||||||
|
self.session.set_proxy(proxy_settings)
|
||||||
|
else:
|
||||||
|
for k, v in value.items():
|
||||||
proxy_settings = lt.proxy_settings()
|
proxy_settings = lt.proxy_settings()
|
||||||
proxy_settings.type = lt.proxy_type(v["type"])
|
proxy_settings.type = lt.proxy_type(v["type"])
|
||||||
proxy_settings.username = str(v["username"])
|
proxy_settings.username = str(v["username"])
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -317,7 +317,17 @@ class Preferences(component.Component):
|
||||||
"spin_cache_expiry": ("value", self.core_config["cache_expiry"])
|
"spin_cache_expiry": ("value", self.core_config["cache_expiry"])
|
||||||
}
|
}
|
||||||
# Add proxy stuff
|
# Add proxy stuff
|
||||||
|
|
||||||
|
# Display workaround for single proxy in libtorrent >v0.16
|
||||||
|
try:
|
||||||
|
lt_single_proxy = component.get("PreferencesManager").LT_SINGLE_PROXY
|
||||||
|
except AttributeError:
|
||||||
|
lt_single_proxy = False
|
||||||
|
|
||||||
for t in ("peer", "web_seed", "tracker", "dht"):
|
for t in ("peer", "web_seed", "tracker", "dht"):
|
||||||
|
if lt_single_proxy and not t == "peer":
|
||||||
|
widget = self.glade.get_widget("frame_%s" % t)
|
||||||
|
widget.set_sensitive(False)
|
||||||
core_widgets["spin_proxy_port_%s" % t] = ("value", self.core_config["proxies"][t]["port"])
|
core_widgets["spin_proxy_port_%s" % t] = ("value", self.core_config["proxies"][t]["port"])
|
||||||
core_widgets["combo_proxy_type_%s" % t] = ("active", self.core_config["proxies"][t]["type"])
|
core_widgets["combo_proxy_type_%s" % t] = ("active", self.core_config["proxies"][t]["type"])
|
||||||
core_widgets["txt_proxy_server_%s" % t] = ("text", self.core_config["proxies"][t]["hostname"])
|
core_widgets["txt_proxy_server_%s" % t] = ("text", self.core_config["proxies"][t]["hostname"])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue