From 4a344e382b281b2a31c6f13d4891399b94355d1b Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Fri, 4 Nov 2016 15:55:42 +0000 Subject: [PATCH] [UI] [Core] Update and refactor proxy settings * Combine I2P into proxy settings. --- deluge/core/core.py | 42 ++- deluge/core/preferencesmanager.py | 55 +-- .../modes/preferences/preference_panes.py | 64 ++-- deluge/ui/gtkui/glade/preferences_dialog.ui | 312 +++++++----------- deluge/ui/gtkui/preferences.py | 78 +++-- .../js/deluge-all/preferences/ProxyField.js | 57 +++- .../deluge-all/preferences/ProxyI2PField.js | 75 ----- .../js/deluge-all/preferences/ProxyPage.js | 23 -- 8 files changed, 310 insertions(+), 396 deletions(-) delete mode 100644 deluge/ui/web/js/deluge-all/preferences/ProxyI2PField.js diff --git a/deluge/core/core.py b/deluge/core/core.py index 90b58ba78..16070cb1c 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -645,28 +645,34 @@ class Core(component.Component): """Returns the active listen port""" return self.session.listen_port() - @deprecated - @export - def get_i2p_proxy(self): - """Returns the active listen port""" - # Deprecated: Moved to proxy types - i2p_settings = self.session.i2p_proxy() - i2p_dict = {'hostname': i2p_settings.hostname, 'port': i2p_settings.port} - return i2p_dict - @export def get_proxy(self): - """Returns the active listen port""" - proxy_settings = self.session.proxy() + """Returns the proxy settings + + Returns: + dict: Contains proxy settings. + + Notes: + Proxy type names: + 0: None, 1: Socks4, 2: Socks5, 3: Socks5 w Auth, 4: HTTP, 5: HTTP w Auth, 6: I2P + + """ + + settings = self.session.get_settings() + proxy_type = settings['proxy_type'] + proxy_hostname = settings['i2p_hostname'] if proxy_type == 6 else settings['proxy_hostname'] + proxy_port = settings['i2p_port'] if proxy_type == 6 else settings['proxy_port'] proxy_dict = { - 'type': int(proxy_settings.type), - 'hostname': proxy_settings.hostname, - 'username': proxy_settings.username, - 'password': proxy_settings.password, - 'port': proxy_settings.port, - 'proxy_hostnames': proxy_settings.proxy_hostnames, - 'proxy_peer_connections': proxy_settings.proxy_peer_connections + 'type': proxy_type, + 'hostname': proxy_hostname, + 'username': settings['proxy_username'], + 'password': settings['proxy_password'], + 'port': proxy_port, + 'proxy_hostnames': settings['proxy_hostnames'], + 'proxy_peer_connections': settings['proxy_peer_connections'], + 'proxy_tracker_connections': settings['proxy_tracker_connections'] } + return proxy_dict @export diff --git a/deluge/core/preferencesmanager.py b/deluge/core/preferencesmanager.py index cad19ac09..38a3717bf 100644 --- a/deluge/core/preferencesmanager.py +++ b/deluge/core/preferencesmanager.py @@ -101,14 +101,12 @@ DEFAULT_PREFS = { 'port': 8080, 'proxy_hostnames': True, 'proxy_peer_connections': True, - }, - 'i2p_proxy': { - 'hostname': '', - 'port': 0 + 'proxy_tracker_connections': True, + 'force_proxy': False, + 'anonymous_mode': False, }, 'peer_tos': '0x00', 'rate_limit_ip_overhead': True, - 'anonymous_mode': False, 'geoip_db_location': '/usr/share/GeoIP/GeoIP.dat', 'cache_size': 512, 'cache_expiry': 60, @@ -127,6 +125,17 @@ class PreferencesManager(component.Component): self.config['proxy'].update(self.config['proxies']['peer']) log.warning('New proxy config is: %s', self.config['proxy']) del self.config['proxies'] + if 'i2p_proxy' in self.config and self.config['i2p_proxy']['hostname']: + self.config['proxy'].update(self.config['i2p_proxy']) + self.config['proxy']['type'] = 6 + del self.config['i2p_proxy'] + if 'anonymous_mode' in self.config: + self.config['proxy']['anonymous_mode'] = self.config['anonymous_mode'] + del self.config['anonymous_mode'] + if 'proxy' in self.config: + for key in DEFAULT_PREFS['proxy']: + if key not in self.config['proxy']: + self.config['proxy'][key] = DEFAULT_PREFS['proxy'][key] self.core = component.get('Core') self.new_release_timer = None @@ -343,33 +352,39 @@ class PreferencesManager(component.Component): self.new_release_timer.stop() def _on_set_proxy(self, key, value): - if key == 'i2p_proxy' or value['type'] == 6: - proxy_settings = { + # Initialise with type none and blank hostnames. + proxy_settings = { + 'proxy_type': lt.proxy_type.none, + 'i2p_hostname': '', + 'proxy_hostname': '', + 'proxy_hostnames': value['proxy_hostnames'], + 'proxy_peer_connections': value['proxy_peer_connections'], + 'proxy_tracker_connections': value['proxy_tracker_connections'], + 'force_proxy': value['force_proxy'], + 'anonymous_mode': value['anonymous_mode'] + } + + if value['type'] == lt.proxy_type.i2p_proxy: + proxy_settings.update({ 'proxy_type': lt.proxy_type.i2p_proxy, 'i2p_hostname': value['hostname'], - 'i2p_port': value['port'] - } - else: - proxy_settings = { + 'i2p_port': value['port'], + }) + elif value['type'] != lt.proxy_type.none: + proxy_settings.update({ 'proxy_type': value['type'], 'proxy_hostname': value['hostname'], 'proxy_port': value['port'], 'proxy_username': value['username'], 'proxy_password': value['password'], - 'proxy_hostnames': value['proxy_hostnames'], - 'proxy_peer_connections': value['proxy_peer_connections'], - } - self.core.apply_session_settings(proxy_settings) - def _on_set_i2p_proxy(self, key, value): - self._on_set_proxy(key, value) + }) + + self.core.apply_session_settings(proxy_settings) def _on_set_rate_limit_ip_overhead(self, key, value): self.core.apply_session_setting('rate_limit_ip_overhead', value) - def _on_set_anonymous_mode(self, key, value): - self.core.apply_session_setting('anonymous_mode', value) - def _on_set_geoip_db_location(self, key, geoipdb_path): # Load the GeoIP DB for country look-ups if available if os.path.exists(geoipdb_path): diff --git a/deluge/ui/console/modes/preferences/preference_panes.py b/deluge/ui/console/modes/preferences/preference_panes.py index 6497a42c7..fbf862b4d 100644 --- a/deluge/ui/console/modes/preferences/preference_panes.py +++ b/deluge/ui/console/modes/preferences/preference_panes.py @@ -72,24 +72,17 @@ class BasePreferencePane(BaseInputPane, BaseWindow, PopupsHandler): def add_config_values(self, conf_dict): for ipt in self.inputs: if ipt.has_input(): - # gross, have to special case in/out ports since they are tuples - if ipt.name in ('listen_ports_to', 'listen_ports_from', 'out_ports_from', 'out_ports_to', - 'i2p_port', 'i2p_hostname', 'proxy_type', 'proxy_username', 'proxy_hostnames', - 'proxy_password', 'proxy_hostname', 'proxy_port', 'proxy_peer_connections', - 'listen_interface'): - if ipt.name == 'listen_ports_to': - conf_dict['listen_ports'] = (self.infrom.get_value(), self.into.get_value()) - elif ipt.name == 'out_ports_to': - conf_dict['outgoing_ports'] = (self.outfrom.get_value(), self.outto.get_value()) - elif ipt.name == 'listen_interface': - interface = ipt.get_value().strip() - if is_ip(interface) or not interface: - conf_dict['listen_interface'] = interface - elif ipt.name == 'i2p_port': - conf_dict.setdefault('i2p_proxy', {})['port'] = ipt.get_value() - elif ipt.name == 'i2p_hostname': - conf_dict.setdefault('i2p_proxy', {})['hostname'] = ipt.get_value() - elif ipt.name == 'proxy_type': + # Need special cases for in/out ports or proxy since they are tuples or dicts. + if ipt.name == 'listen_ports_to' or ipt.name == 'listen_ports_from': + conf_dict['listen_ports'] = (self.infrom.get_value(), self.into.get_value()) + elif ipt.name == 'out_ports_to' or ipt.name == 'out_ports_from': + conf_dict['outgoing_ports'] = (self.outfrom.get_value(), self.outto.get_value()) + elif ipt.name == 'listen_interface': + interface = ipt.get_value().strip() + if is_ip(interface) or not interface: + conf_dict['listen_interface'] = interface + elif ipt.name.startswith('proxy_'): + if ipt.name == 'proxy_type': conf_dict.setdefault('proxy', {})['type'] = ipt.get_value() elif ipt.name == 'proxy_username': conf_dict.setdefault('proxy', {})['username'] = ipt.get_value() @@ -103,8 +96,15 @@ class BasePreferencePane(BaseInputPane, BaseWindow, PopupsHandler): conf_dict.setdefault('proxy', {})['proxy_hostnames'] = ipt.get_value() elif ipt.name == 'proxy_peer_connections': conf_dict.setdefault('proxy', {})['proxy_peer_connections'] = ipt.get_value() + elif ipt.name == 'proxy_tracker_connections': + conf_dict.setdefault('proxy', {})['proxy_tracker_connections'] = ipt.get_value() + elif ipt.name == 'force_proxy': + conf_dict.setdefault('proxy', {})['force_proxy'] = ipt.get_value() + elif ipt.name == 'anonymous_mode': + conf_dict.setdefault('proxy', {})['anonymous_mode'] = ipt.get_value() else: conf_dict[ipt.name] = ipt.get_value() + if hasattr(ipt, 'get_child'): c = ipt.get_child() conf_dict[c.name] = c.get_value() @@ -372,25 +372,29 @@ class ProxyPane(BasePreferencePane): @overrides(BasePreferencePane) def create_pane(self, core_conf, console_config): + proxy = core_conf['proxy'] + self.add_header(_('Proxy Settings')) self.add_header(_('Proxy'), space_above=True) - proxy = core_conf['proxy'] self.add_int_spin_input('proxy_type', '%s:' % _('Type'), proxy['type'], min_val=0, max_val=5) - self.add_info_field('proxy_info_1', ' 0: None 1: Socks4 2: Socks5', '') - self.add_info_field('proxy_info_2', ' 3: Socks5 Auth 4: HTTP 5: HTTP Auth', '') self.add_text_input('proxy_username', '%s:' % _('Username'), proxy['username']) self.add_text_input('proxy_password', '%s:' % _('Password'), proxy['password']) self.add_text_input('proxy_hostname', '%s:' % _('Hostname'), proxy['hostname']) self.add_int_spin_input('proxy_port', '%s:' % _('Port'), proxy['port'], min_val=0, max_val=65535) - self.add_checked_input('proxy_hostnames', _('Proxy hostnames'), proxy['proxy_hostnames']) - self.add_checked_input('proxy_peer_connections', _('Proxy peer connections'), proxy['proxy_peer_connections']) - - self.add_header(_('I2P Proxy'), space_above=True) - self.add_text_input('i2p_hostname', '%s:' % _('Hostname'), - core_conf['i2p_proxy']['hostname']) - self.add_int_spin_input('i2p_port', - '%s:' % _('Port'), core_conf['i2p_proxy']['port'], min_val=0, max_val=65535) - self.add_checked_input('anonymous_mode', _('Anonymous Mode'), core_conf['anonymous_mode']) + self.add_checked_input('proxy_hostnames', _('Proxy Hostnames'), proxy['proxy_hostnames']) + self.add_checked_input('proxy_peer_connections', _('Proxy Peers'), proxy['proxy_peer_connections']) + self.add_checked_input('proxy_tracker_connections', _('Proxy Trackers'), proxy['proxy_tracker_connections']) + self.add_header('%s' % _('Force Proxy'), space_above=True) + self.add_checked_input('force_proxy', _('Force Proxy'), proxy['force_proxy']) + self.add_checked_input('anonymous_mode', _('Hide Client Identity'), proxy['anonymous_mode']) + self.add_header('%s' % _('Proxy Type Help'), space_above=True) + self.add_text_area( + 'proxy_text_area', + ' 0: None 1: Socks4\n' + ' 2: Socks5 3: Socks5 Auth\n' + ' 4: HTTP 5: HTTP Auth\n' + ' 6: I2P' + ) class CachePane(BasePreferencePane): diff --git a/deluge/ui/gtkui/glade/preferences_dialog.ui b/deluge/ui/gtkui/glade/preferences_dialog.ui index b88751521..5533df75d 100644 --- a/deluge/ui/gtkui/glade/preferences_dialog.ui +++ b/deluge/ui/gtkui/glade/preferences_dialog.ui @@ -2,6 +2,67 @@ + + 1 + 32000 + 60 + 1 + 10 + + + 999999 + 100 + 1 + 10 + + + 0.5 + 100 + 2 + 0.10000000000000001 + 1 + + + -1 + 100 + 1.5 + 0.10000000000000001 + 10 + + + -1 + 9999 + 1 + 10 + + + 65535 + 1 + 10 + + + -1 + 9999 + 1 + 10 + + + 65535 + 1 + 10 + + + -1 + 9999 + 1 + 10 + + + -1 + 9999 + 1 + 10 + -1 9999 @@ -84,72 +145,6 @@ 0.10000000000000001 10 - - 1 - 32000 - 60 - 1 - 10 - - - 999999 - 100 - 1 - 10 - - - 0.5 - 100 - 2 - 0.10000000000000001 - 1 - - - -1 - 100 - 1.5 - 0.10000000000000001 - 10 - - - -1 - 9999 - 1 - 10 - - - 65535 - 1 - 10 - - - -1 - 9999 - 1 - 10 - - - 65535 - 1 - 10 - - - 65535 - 1 - 10 - - - -1 - 9999 - 1 - 10 - - - -1 - 9999 - 1 - 10 - @@ -233,6 +228,9 @@ HTTP Auth + + I2P + @@ -3469,7 +3467,7 @@ used sparingly. True False - 7 + 8 2 5 @@ -3645,7 +3643,7 @@ the proxy instead of using the local DNS service - Proxy Peer Connections + Proxy Peers False True True @@ -3662,6 +3660,24 @@ the proxy instead of using the local DNS service GTK_FILL + + + Proxy Trackers + False + True + True + False + 0.49000000953674316 + True + True + + + 2 + 7 + 8 + GTK_FILL + + @@ -3685,101 +3701,71 @@ the proxy instead of using the local DNS service - + True False 0 none - + True False - 5 - 12 - 12 - + True False - 2 - 2 - 5 - 2 + 5 + 12 + 12 - - True - False - 0 - Hostname: - - - GTK_FILL - - - - + + Force Proxy Use + False True True - True - False - False - True - True + False + True - - 1 - 2 - - - - - True - False - 1 - Port: - - - 1 - 2 - GTK_FILL - - - - - True - False - 0 - 0 - - - True - True - False - False - True - True - adjustment_spin_i2p_port - True - - - - - 1 - 2 - 1 - 2 - GTK_FILL - + + True + True + 0 + + + + + True + False + 5 + 12 + 12 + + + Hide Client Identity + False + True + True + False + Attempt to hide client identity and only use proxy for incoming connections. + True + + + + + True + True + 1 + - + True False - I2P Proxy + Force Proxy @@ -3793,50 +3779,6 @@ the proxy instead of using the local DNS service 1 - - - True - False - 0 - none - - - True - False - 5 - 12 - 12 - - - Hide Client Identity - False - True - True - False - Attempt to hide client identity and only use proxy for incoming connections. - True - - - - - - - True - False - Anonymous Mode - - - - - - - - False - False - 5 - 2 - - diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index 0d275d025..f46a01339 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -350,7 +350,7 @@ class Preferences(component.Component): 'spin_max_connections_per_second': ('value', 'max_connections_per_second'), 'chk_ignore_limits_on_local_network': ('active', 'ignore_limits_on_local_network'), 'chk_rate_limit_ip_overhead': ('active', 'rate_limit_ip_overhead'), - 'chk_anonymous_mode': ('active', 'anonymous_mode'), + 'spin_max_connections_per_torrent': ('value', 'max_connections_per_torrent'), 'spin_max_upload_slots_per_torrent': ('value', 'max_upload_slots_per_torrent'), 'spin_max_download_per_torrent': ('value', 'max_download_speed_per_torrent'), @@ -379,8 +379,9 @@ class Preferences(component.Component): 'spin_proxy_port': ('value', lambda: self.core_config['proxy']['port']), 'chk_proxy_host_resolve': ('active', lambda: self.core_config['proxy']['proxy_hostnames']), 'chk_proxy_peer_conn': ('active', lambda: self.core_config['proxy']['proxy_peer_connections']), - 'entry_i2p_host': ('text', lambda: self.core_config['i2p_proxy']['hostname']), - 'spin_i2p_port': ('value', lambda: self.core_config['i2p_proxy']['port']), + 'chk_proxy_tracker_conn': ('active', lambda: self.core_config['proxy']['proxy_tracker_connections']), + 'chk_force_proxy': ('active', lambda: self.core_config['proxy']['force_proxy']), + 'chk_anonymous_mode': ('active', lambda: self.core_config['proxy']['anonymous_mode']), 'accounts_add': (None, None), 'accounts_listview': (None, None), 'button_cache_refresh': (None, None), @@ -599,20 +600,18 @@ class Preferences(component.Component): new_core_config['new_release_check'] = self.builder.get_object('chk_new_releases').get_active() # Proxy tab # - new_core_config['proxy'] = {} - new_core_config['proxy']['type'] = self.builder.get_object('combo_proxy_type').get_active() - new_core_config['proxy']['username'] = self.builder.get_object('entry_proxy_user').get_text() - new_core_config['proxy']['password'] = self.builder.get_object('entry_proxy_pass').get_text() - new_core_config['proxy']['hostname'] = self.builder.get_object('entry_proxy_host').get_text() - new_core_config['proxy']['port'] = self.builder.get_object('spin_proxy_port').get_value_as_int() - new_core_config['proxy']['proxy_hostnames'] = self.builder.get_object( - 'chk_proxy_host_resolve').get_active() - new_core_config['proxy']['proxy_peer_connections'] = self.builder.get_object( - 'chk_proxy_peer_conn').get_active() - new_core_config['i2p_proxy'] = {} - new_core_config['i2p_proxy']['hostname'] = self.builder.get_object('entry_i2p_host').get_text() - new_core_config['i2p_proxy']['port'] = self.builder.get_object('spin_i2p_port').get_value_as_int() - new_core_config['anonymous_mode'] = self.builder.get_object('chk_anonymous_mode').get_active() + new_core_config['proxy'] = { + 'type': self.builder.get_object('combo_proxy_type').get_active(), + 'username': self.builder.get_object('entry_proxy_user').get_text(), + 'password': self.builder.get_object('entry_proxy_pass').get_text(), + 'hostname': self.builder.get_object('entry_proxy_host').get_text(), + 'port': self.builder.get_object('spin_proxy_port').get_value_as_int(), + 'proxy_hostnames': self.builder.get_object('chk_proxy_host_resolve').get_active(), + 'proxy_peer_connections': self.builder.get_object('chk_proxy_peer_conn').get_active(), + 'proxy_tracker_connections': self.builder.get_object('chk_proxy_tracker_conn').get_active(), + 'force_proxy': self.builder.get_object('chk_force_proxy').get_active(), + 'anonymous_mode': self.builder.get_object('chk_anonymous_mode').get_active() + } # Queue tab # new_core_config['queue_new_to_top'] = self.builder.get_object('chk_queue_new_top').get_active() @@ -642,7 +641,7 @@ class Preferences(component.Component): # Run plugin hook to apply preferences component.get('PluginManager').run_on_apply_prefs() - # Lanuage + # Language if self.language_checkbox.get_active(): new_gtkui_config['language'] = None else: @@ -954,31 +953,28 @@ class Preferences(component.Component): def _on_combo_proxy_type_changed(self, widget): proxy_type = self.builder.get_object('combo_proxy_type').get_active() + proxy_entries = [ + 'label_proxy_host', 'entry_proxy_host', 'label_proxy_port', 'spin_proxy_port', + 'label_proxy_pass', 'entry_proxy_pass', 'label_proxy_user', 'entry_proxy_user', + 'chk_proxy_host_resolve', 'chk_proxy_peer_conn', 'chk_proxy_tracker_conn'] - hides = [] - shows = [] - # 0:"None" - if proxy_type == 0: - hides.extend(['entry_proxy_pass', 'entry_proxy_user', 'entry_proxy_host', 'spin_proxy_port', - 'label_proxy_pass', 'label_proxy_user', 'label_proxy_host', 'label_proxy_port', - 'chk_proxy_host_resolve', 'chk_proxy_peer_conn']) - # 1:"Socks4", 2:"Socks5", 4:"HTTP" - elif proxy_type in (1, 2, 4): - if proxy_type in (2, 4): - shows.extend(['chk_proxy_host_resolve']) - hides.extend(['entry_proxy_pass', 'entry_proxy_user', 'label_proxy_pass', 'label_proxy_user']) - shows.extend(['entry_proxy_host', 'spin_proxy_port', 'label_proxy_host', - 'label_proxy_port', 'chk_proxy_peer_conn']) - # 3:"Socks5 Auth", 5:"HTTP Auth" - elif proxy_type in (3, 5): - shows.extend(['entry_proxy_pass', 'entry_proxy_user', 'entry_proxy_host', 'spin_proxy_port', - 'label_proxy_pass', 'label_proxy_user', 'label_proxy_host', 'label_proxy_port', - 'chk_proxy_host_resolve', 'chk_proxy_peer_conn']) + # 0: None, 1: Socks4, 2: Socks5, 3: Socks5 Auth, 4: HTTP, 5: HTTP Auth, 6: I2P + show_entries = [] + if proxy_type > 0: + show_entries.extend([ + 'label_proxy_host', 'entry_proxy_host', 'label_proxy_port', 'spin_proxy_port', + 'chk_proxy_peer_conn', 'chk_proxy_tracker_conn']) + if proxy_type in (3, 5): + show_entries.extend([ + 'label_proxy_pass', 'entry_proxy_pass', 'label_proxy_user', 'entry_proxy_user']) + if proxy_type in (2, 3, 4, 5): + show_entries.extend(['chk_proxy_host_resolve']) - for hide_entry in hides: - self.builder.get_object(hide_entry).hide() - for show_entry in shows: - self.builder.get_object(show_entry).show() + for entry in proxy_entries: + if entry in show_entries: + self.builder.get_object(entry).show() + else: + self.builder.get_object(entry).hide() def _on_button_associate_magnet_clicked(self, widget): associate_magnet_links(True) diff --git a/deluge/ui/web/js/deluge-all/preferences/ProxyField.js b/deluge/ui/web/js/deluge-all/preferences/ProxyField.js index e0a79c4c8..6c51b37b9 100644 --- a/deluge/ui/web/js/deluge-all/preferences/ProxyField.js +++ b/deluge/ui/web/js/deluge-all/preferences/ProxyField.js @@ -36,7 +36,8 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, { [2, _('Socks5')], [3, _('Socks5 Auth')], [4, _('HTTP')], - [5, _('HTTP Auth')] + [5, _('HTTP Auth')], + [6, _('I2P')] ] }), editable: false, @@ -100,11 +101,49 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, { xtype: 'checkbox', name: 'proxy_peer_conn', fieldLabel: '', - boxLabel: _('Proxy Peer Connections'), + boxLabel: _('Proxy Peers'), width: 220 }); this.proxy_peer_conn.on('change', this.onFieldChange, this); + this.proxy_tracker_conn = this.add({ + xtype: 'checkbox', + name: 'proxy_tracker_conn', + fieldLabel: '', + boxLabel: _('Proxy Trackers'), + width: 220 + }); + this.proxy_tracker_conn.on('change', this.onFieldChange, this); + + var fieldset = this.add({ + xtype: 'fieldset', + border: false, + title: _('Force Proxy'), + autoHeight: true, + labelWidth: 1, + defaultType: 'checkbox', + style: 'padding-left: 0px; margin-top: 10px' + }); + + this.force_proxy = fieldset.add({ + fieldLabel: '', + labelSeparator: '', + height: 20, + name: 'force_proxy', + boxLabel: _('Force Use of Proxy'), + + }); + this.force_proxy.on('change', this.onFieldChange, this); + + this.anonymous_mode = fieldset.add({ + fieldLabel: '', + labelSeparator: '', + height: 20, + name: 'anonymous_mode', + boxLabel: _('Hide Client Identity') + }); + this.anonymous_mode.on('change', this.onFieldChange, this); + this.setting = false; }, @@ -120,7 +159,10 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, { 'username': this.username.getValue(), 'password': this.password.getValue(), 'proxy_hostnames': this.proxy_host_resolve.getValue(), - 'proxy_peer_connections': this.proxy_peer_conn.getValue() + 'proxy_peer_connections': this.proxy_peer_conn.getValue(), + 'proxy_tracker_connections': this.proxy_tracker_conn.getValue(), + 'force_proxy': this.force_proxy.getValue(), + 'anonymous_mode': this.anonymous_mode.getValue() } }, @@ -137,6 +179,9 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, { this.password.setValue(value['password']); this.proxy_host_resolve.setValue(value['proxy_hostnames']); this.proxy_peer_conn.setValue(value['proxy_peer_connections']); + this.proxy_tracker_conn.setValue(value['proxy_tracker_connections']); + this.force_proxy.setValue(value['force_proxy']); + this.anonymous_mode.setValue(value['anonymous_mode']); this.onTypeSelect(this.type, record, index); this.setting = false; @@ -157,14 +202,18 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, { this.hostname.show(); this.port.show(); this.proxy_peer_conn.show(); - if (typeId != 1) { + this.proxy_tracker_conn.show(); + if (typeId > 1 && typeId < 6) { this.proxy_host_resolve.show(); + } else { + this.proxy_host_resolve.hide(); } } else { this.hostname.hide(); this.port.hide(); this.proxy_host_resolve.hide(); this.proxy_peer_conn.hide(); + this.proxy_tracker_conn.hide(); } if (typeId == 3 || typeId == 5) { diff --git a/deluge/ui/web/js/deluge-all/preferences/ProxyI2PField.js b/deluge/ui/web/js/deluge-all/preferences/ProxyI2PField.js deleted file mode 100644 index 6367a817d..000000000 --- a/deluge/ui/web/js/deluge-all/preferences/ProxyI2PField.js +++ /dev/null @@ -1,75 +0,0 @@ -/*! - * Deluge.preferences.ProxyI2PField.js - * - * Copyright (c) Damien Churchill 2009-2010 - * - * This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with - * the additional special exception to link portions of this program with the OpenSSL library. - * See LICENSE for more details. - */ -Ext.ns('Deluge.preferences'); - -/** - * @class Deluge.preferences.ProxyI2PField - * @extends Ext.form.FieldSet - */ -Deluge.preferences.ProxyI2PField = Ext.extend(Ext.form.FieldSet, { - - border: false, - autoHeight: true, - labelWidth: 70, - - initComponent: function() { - Deluge.preferences.ProxyI2PField.superclass.initComponent.call(this); - this.hostname = this.add({ - xtype: 'textfield', - name: 'hostname', - fieldLabel: _('Host:'), - labelSeparator: '', - width: 220 - }); - this.hostname.on('change', this.onFieldChange, this); - - this.port = this.add({ - xtype: 'spinnerfield', - name: 'port', - fieldLabel: _('Port:'), - labelSeparator: '', - width: 80, - decimalPrecision: 0, - minValue: 0, - maxValue: 65535 - }); - this.port.on('change', this.onFieldChange, this); - - this.setting = false; - }, - - getName: function() { - return this.initialConfig.name; - }, - - getValue: function() { - return { - 'hostname': this.hostname.getValue(), - 'port': Number(this.port.getValue()) - } - }, - - // Set the values of the proxies - setValue: function(value) { - this.setting = true; - this.hostname.setValue(value['hostname']); - this.port.setValue(value['port']); - this.setting = false; - }, - - onFieldChange: function(field, newValue, oldValue) { - if (this.setting) return; - var newValues = this.getValue(); - var oldValues = Ext.apply({}, newValues); - oldValues[field.getName()] = oldValue; - - this.fireEvent('change', this, newValues, oldValues); - } -}); diff --git a/deluge/ui/web/js/deluge-all/preferences/ProxyPage.js b/deluge/ui/web/js/deluge-all/preferences/ProxyPage.js index 126c18487..9a0280754 100644 --- a/deluge/ui/web/js/deluge-all/preferences/ProxyPage.js +++ b/deluge/ui/web/js/deluge-all/preferences/ProxyPage.js @@ -33,29 +33,6 @@ Deluge.preferences.Proxy = Ext.extend(Ext.form.FormPanel, { })); this.proxy.on('change', this.onProxyChange, this); deluge.preferences.getOptionsManager().bind('proxy', this.proxy); - - this.i2p_proxy = this.add(new Deluge.preferences.ProxyI2PField({ - title: _('I2P Proxy'), - name: 'i2p_proxy' - })); - deluge.preferences.getOptionsManager().bind('i2p_proxy', this.i2p_proxy); - - var fieldset = this.add({ - xtype: 'fieldset', - border: false, - title: _('Anonymous Mode'), - autoHeight: true, - labelWidth: 1, - defaultType: 'checkbox' - }); - deluge.preferences.getOptionsManager().bind('anonymous_mode', fieldset.add({ - fieldLabel: '', - labelSeparator: '', - height: 20, - name: 'anonymous_mode', - boxLabel: _('Hide Client Identity') - })); - }, getValue: function() {