From d59a59dadc12c2435dff93d1a5684ec88e953c3f Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Sat, 29 Nov 2008 03:16:43 +0000 Subject: [PATCH] Break out proxy preferences to include peer, web_seed, tracker and dht. --- deluge/core/preferencesmanager.py | 72 +- .../ui/gtkui/glade/preferences_dialog.glade | 832 +++++++++++++++--- deluge/ui/gtkui/preferences.py | 47 +- 3 files changed, 759 insertions(+), 192 deletions(-) diff --git a/deluge/core/preferencesmanager.py b/deluge/core/preferencesmanager.py index a66bf707b..90780bc64 100644 --- a/deluge/core/preferencesmanager.py +++ b/deluge/core/preferencesmanager.py @@ -91,11 +91,37 @@ DEFAULT_PREFS = { "move_completed": False, "move_completed_path": deluge.common.get_default_download_dir(), "new_release_check": True, - "proxy_type" : 0, - "proxy_server" : "", - "proxy_username" : "", - "proxy_password" : "", - "proxy_port": 8080, + "proxies": { + "peer": { + "type": 0, + "hostname": "", + "username": "", + "password": "", + "port": 8080 + }, + "web_seed": { + "type": 0, + "hostname": "", + "username": "", + "password": "", + "port": 8080 + }, + "tracker": { + "type": 0, + "hostname": "", + "username": "", + "password": "", + "port": 8080 + }, + "dht": { + "type": 0, + "hostname": "", + "username": "", + "password": "", + "port": 8080 + }, + + }, "outgoing_ports": [0, 0], "random_outgoing_ports": True, "peer_tos": "0x00", @@ -172,16 +198,8 @@ class PreferencesManager(component.Component): self._on_set_dont_count_slow_torrents) self.config.register_set_function("send_info", self._on_send_info) - self.config.register_set_function("proxy_type", - self._on_set_proxy) - self.config.register_set_function("proxy_username", - self._on_set_proxy) - self.config.register_set_function("proxy_password", - self._on_set_proxy) - self.config.register_set_function("proxy_server", - self._on_set_proxy) - self.config.register_set_function("proxy_port", - self._on_set_proxy) + self.config.register_set_function("proxies", + self._on_set_proxies) self.new_release_timer = None self.config.register_set_function("new_release_check", self._on_new_release_check) @@ -436,19 +454,17 @@ class PreferencesManager(component.Component): if self.new_release_timer: gobject.source.remove(self.new_release_timer) - def _on_set_proxy(self, key, value): - log.debug("Proxy value %s set to %s..", key, value) - proxy_settings = lt.proxy_settings() - proxy_settings.proxy_type = lt.proxy_type(self.config["proxy_type"]) - if self.config["proxy_type"] != 0: - proxy_settings.username = self.config["proxy_username"] - proxy_settings.password = self.config["proxy_password"] - proxy_settings.hostname = self.config["proxy_server"] - proxy_settings.port = int(self.config["proxy_port"]) - self.session.set_peer_proxy(proxy_settings) - self.session.set_web_seed_proxy(proxy_settings) - self.session.set_tracker_proxy(proxy_settings) - self.session.set_dht_proxy(proxy_settings) + def _on_set_proxies(self, key, value): + for k, v in value.items(): + if v["type"]: + proxy_settings = lt.proxy_settings() + proxy_settings.proxy_type = lt.proxy_type(v["type"]) + proxy_settings.username = v["username"] + proxy_settings.password = v["password"] + proxy_settings.hostname = v["hostname"] + proxy_settings.port = v["port"] + log.debug("setting %s proxy settings", k) + getattr(self.session, "set_%s_proxy" % k)(proxy_settings) def _on_rate_limit_ip_overhead(self, key, value): log.debug("%s: %s", key, value) diff --git a/deluge/ui/gtkui/glade/preferences_dialog.glade b/deluge/ui/gtkui/glade/preferences_dialog.glade index 2706d8c8d..eebca8495 100644 --- a/deluge/ui/gtkui/glade/preferences_dialog.glade +++ b/deluge/ui/gtkui/glade/preferences_dialog.glade @@ -1,6 +1,6 @@ - + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -2880,180 +2880,724 @@ Disabled - + True - 0 - GTK_SHADOW_NONE + 5 - + True - 12 - 12 + 0 + GTK_SHADOW_NONE - + True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - 2 - 5 + 12 + 12 - + True - 0 - 0 + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + 2 + 5 - + True - True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 0 65000 1 10 10 - True + 0 + Username: + + 1 + 2 + GTK_FILL + - - - 1 - 2 - 4 - 5 - - - - - True - 0 - Port: - - - 4 - 5 - GTK_FILL - - - - - True - 0 - Host: - - - 3 - 4 - GTK_FILL - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - Password: - - - 2 - 3 - GTK_FILL - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - Username: - - - 1 - 2 - GTK_FILL - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - Type: - - - GTK_FILL - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - None + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Type: + + + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + None Socksv4 Socksv5 Socksv5 W/ Auth HTTP HTTP W/ Auth + + + 1 + 2 + GTK_FILL + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + True + 0 + 0 + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 8080 0 65535 1 10 0 + True + + + + + 1 + 2 + 4 + 5 + GTK_FILL + + + + + True + 0 + Port: + + + 4 + 5 + GTK_FILL + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + 1 + 2 + 3 + 4 + + + + + True + 0 + Host: + + + 3 + 4 + GTK_FILL + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + False + + + 1 + 2 + 2 + 3 + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Password: + + + 2 + 3 + GTK_FILL + + - - 1 - 2 - GTK_FILL - - - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - - 1 - 2 - 1 - 2 - - - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - False - - - 1 - 2 - 2 - 3 - - - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - - 1 - 2 - 3 - 4 - + + + True + <b>Peer</b> + True + + + label_item + + - + True - <b>Settings</b> - True + 0 + GTK_SHADOW_NONE + + + True + 12 + 12 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + 2 + 5 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Username: + + + 1 + 2 + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Type: + + + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + None +Socksv4 +Socksv5 +Socksv5 W/ Auth +HTTP +HTTP W/ Auth + + + 1 + 2 + GTK_FILL + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + True + 0 + 0 + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 8080 0 65535 1 10 0 + True + + + + + 1 + 2 + 4 + 5 + GTK_FILL + + + + + True + 0 + Port: + + + 4 + 5 + GTK_FILL + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + 1 + 2 + 3 + 4 + + + + + True + 0 + Host: + + + 3 + 4 + GTK_FILL + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + False + + + 1 + 2 + 2 + 3 + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Password: + + + 2 + 3 + GTK_FILL + + + + + + + + + True + <b>Web Seed</b> + True + + + label_item + + - label_item + 1 + + + + + True + 0 + GTK_SHADOW_NONE + + + True + 12 + 12 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + 2 + 5 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Username: + + + 1 + 2 + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Type: + + + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + None +Socksv4 +Socksv5 +Socksv5 W/ Auth +HTTP +HTTP W/ Auth + + + 1 + 2 + GTK_FILL + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + True + 0 + 0 + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 8080 0 65535 1 10 0 + True + + + + + 1 + 2 + 4 + 5 + GTK_FILL + + + + + True + 0 + Port: + + + 4 + 5 + GTK_FILL + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + 1 + 2 + 3 + 4 + + + + + True + 0 + Host: + + + 3 + 4 + GTK_FILL + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + False + + + 1 + 2 + 2 + 3 + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Password: + + + 2 + 3 + GTK_FILL + + + + + + + + + True + <b>Tracker</b> + True + + + label_item + + + + + 2 + + + + + True + 0 + GTK_SHADOW_NONE + + + True + 12 + 12 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + 2 + 5 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Username: + + + 1 + 2 + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Type: + + + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + None +Socksv4 +Socksv5 +Socksv5 W/ Auth +HTTP +HTTP W/ Auth + + + 1 + 2 + GTK_FILL + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + True + 0 + 0 + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 8080 0 65535 1 10 0 + True + + + + + 1 + 2 + 4 + 5 + GTK_FILL + + + + + True + 0 + Port: + + + 4 + 5 + GTK_FILL + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + 1 + 2 + 3 + 4 + + + + + True + 0 + Host: + + + 3 + 4 + GTK_FILL + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + False + + + 1 + 2 + 2 + 3 + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Password: + + + 2 + 3 + GTK_FILL + + + + + + + + + True + <b>DHT</b> + True + + + label_item + + + + + 3 - False - False 5 2 diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index d9fb480fc..fe68a7170 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -264,12 +264,14 @@ class Preferences(component.Component): "chk_seed_ratio": ("active", self.core_config["stop_seed_at_ratio"]), "spin_share_ratio": ("value", self.core_config["stop_seed_ratio"]), "chk_remove_ratio": ("active", self.core_config["remove_seed_at_ratio"]), - "spin_proxy_port": ("value", self.core_config["proxy_port"]), - "combo_proxy_type": ("active", self.core_config["proxy_type"]), - "txt_proxy_server": ("text", self.core_config["proxy_server"]), - "txt_proxy_username": ("text", self.core_config["proxy_username"]), - "txt_proxy_password": ("text", self.core_config["proxy_password"]), } + # Add proxy stuff + for t in ("peer", "web_seed", "tracker", "dht"): + 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["txt_proxy_server_%s" % t] = ("text", self.core_config["proxies"][t]["hostname"]) + core_widgets["txt_proxy_username_%s" % t] = ("text", self.core_config["proxies"][t]["username"]) + core_widgets["txt_proxy_password_%s" % t] = ("text", self.core_config["proxies"][t]["password"]) # Change a few widgets if we're connected to a remote host if not client.is_localhost(): @@ -387,12 +389,14 @@ class Preferences(component.Component): "spin_share_ratio_limit", "spin_seed_time_ratio_limit", "spin_seed_time_limit", - "spin_proxy_port", - "combo_proxy_type", - "txt_proxy_username", - "txt_proxy_password", - "txt_proxy_server", ] + for t in ("peer", "web_seed", "tracker", "dht"): + core_widget_list.append("spin_proxy_port_%s" % t) + core_widget_list.append("combo_proxy_type_%s" % t) + core_widget_list.append("txt_proxy_username_%s" % t) + core_widget_list.append("txt_proxy_password_%s" % t) + core_widget_list.append("txt_proxy_server_%s" % t) + # We don't appear to be connected to a daemon for key in core_widget_list: widget = self.glade.get_widget(key) @@ -644,16 +648,19 @@ class Preferences(component.Component): self.glade.get_widget("chk_new_releases").get_active() ## Proxy tab ## - new_core_config["proxy_type"] = \ - self.glade.get_widget("combo_proxy_type").get_active() - new_core_config["proxy_port"] = \ - self.glade.get_widget("spin_proxy_port").get_value_as_int() - new_core_config["proxy_username"] = \ - self.glade.get_widget("txt_proxy_username").get_text() - new_core_config["proxy_password"] = \ - self.glade.get_widget("txt_proxy_password").get_text() - new_core_config["proxy_server"] = \ - self.glade.get_widget("txt_proxy_server").get_text() + new_core_config["proxies"] = {} + for t in ("peer", "web_seed", "tracker", "dht"): + new_core_config["proxies"][t] = {} + new_core_config["proxies"][t]["type"] = \ + self.glade.get_widget("combo_proxy_type_%s" % t).get_active() + new_core_config["proxies"][t]["port"] = \ + self.glade.get_widget("spin_proxy_port_%s" % t).get_value_as_int() + new_core_config["proxies"][t]["username"] = \ + self.glade.get_widget("txt_proxy_username_%s" % t).get_text() + new_core_config["proxies"][t]["password"] = \ + self.glade.get_widget("txt_proxy_password_%s" % t).get_text() + new_core_config["proxies"][t]["hostname"] = \ + self.glade.get_widget("txt_proxy_server_%s" % t).get_text() ## Queue tab ## new_core_config["queue_new_to_top"] = \