From b321535601079ae05a7f5c7e8b3768d224a77c89 Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Tue, 22 Jul 2008 02:51:40 +0000 Subject: [PATCH] proxy support --- deluge/core/core.py | 28 ++ .../ui/gtkui/glade/preferences_dialog.glade | 243 +++++++++++++++++- deluge/ui/gtkui/preferences.py | 28 +- 3 files changed, 289 insertions(+), 10 deletions(-) diff --git a/deluge/core/core.py b/deluge/core/core.py index e5c13c488..510736ffe 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -111,6 +111,11 @@ 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, } class Core( @@ -278,6 +283,16 @@ class Core( 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.new_release = None self.new_release_timer = None self.config.register_set_function("new_release_check", @@ -930,3 +945,16 @@ class Core( else: 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"]) + 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) diff --git a/deluge/ui/gtkui/glade/preferences_dialog.glade b/deluge/ui/gtkui/glade/preferences_dialog.glade index cd174399a..ce82fb76a 100644 --- a/deluge/ui/gtkui/glade/preferences_dialog.glade +++ b/deluge/ui/gtkui/glade/preferences_dialog.glade @@ -1,7 +1,6 @@ - - - + + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 5 @@ -562,8 +561,8 @@ page 6 - tab False + tab @@ -1098,9 +1097,9 @@ Disabled page 7 - tab 1 False + tab @@ -1570,9 +1569,9 @@ Disabled page 8 - tab 2 False + tab @@ -2680,6 +2679,236 @@ Disabled tab + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + GTK_RESIZE_QUEUE + GTK_SHADOW_NONE + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0.05000000074505806 + 10 + <i><b><big>Proxy</big></b></i> + True + + + False + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + 3 + + + + + + + + + + + + + + + + + + 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 + + + + + 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 + 0 0 65000 1 10 10 + True + + + 1 + 2 + 4 + 5 + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + 1 + 2 + 3 + 4 + + + + + True + 10 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Type + + + + + + + True + 10 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Username + + + + + 1 + 2 + + + + + True + 10 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Password + + + + + 2 + 3 + + + + + True + 10 + + + True + 0 + Server + + + + + 3 + 4 + + + + + True + 10 + + + True + 0 + Port + + + + + 4 + 5 + + + + + False + 1 + + + + + + + + + + + + 7 + + + + + + tab + + True @@ -2763,7 +2992,7 @@ Disabled - 7 + 8 diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index 0dffb1e0b..b3f19ccd2 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -64,7 +64,7 @@ class Preferences(component.Component): # Add the default categories i = 0 for category in ["Downloads", "Network", "Bandwidth", "Interface", - "Other", "Daemon", "Queue", "Plugins"]: + "Other", "Daemon", "Queue", "Proxy", "Plugins"]: self.liststore.append([i, category]) i += 1 @@ -262,7 +262,12 @@ class Preferences(component.Component): "spin_seed_time_limit": ("value", self.core_config["seed_time_limit"]), "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"]) + "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"]) } # Change a few widgets if we're connected to a remote host @@ -375,7 +380,12 @@ class Preferences(component.Component): "chk_remove_ratio", "spin_share_ratio_limit", "spin_seed_time_ratio_limit", - "spin_seed_time_limit" + "spin_seed_time_limit", + "spin_proxy_port", + "combo_proxy_type", + "txt_proxy_username", + "txt_proxy_password", + "txt_proxy_server", ] # We don't appear to be connected to a daemon for key in core_widget_list: @@ -562,6 +572,18 @@ class Preferences(component.Component): self.glade.get_widget("chk_allow_remote_connections").get_active() new_core_config["new_release_check"] = \ 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() ## Queue tab ## new_core_config["queue_new_to_top"] = \