proxy is fixed (TODO: mange proxies)

This commit is contained in:
Yann Leboulanger 2005-06-08 15:48:53 +00:00
parent 3fcc90fa0a
commit 316ca92083
4 changed files with 41 additions and 70 deletions

View File

@ -115,11 +115,7 @@ class Config:
'resource': [ opt_str, 'gajim' ], 'resource': [ opt_str, 'gajim' ],
'priority': [ opt_int, 5 ], 'priority': [ opt_int, 5 ],
'autoconnect': [ opt_bool, False ], 'autoconnect': [ opt_bool, False ],
'use_proxy': [ opt_bool, False ], 'proxy': [ opt_str, '' ],
'proxyhost': [ opt_str, '' ],
'proxyport': [ opt_int, 3128 ],
'proxyuser': [ opt_str, '' ],
'proxypass': [ opt_str, '' ],
'keyid': [ opt_str, '' ], 'keyid': [ opt_str, '' ],
'keyname': [ opt_str, '' ], 'keyname': [ opt_str, '' ],
'usessl': [ opt_bool, False ], 'usessl': [ opt_bool, False ],
@ -139,6 +135,13 @@ class Config:
'enabled': [ opt_bool, True ], 'enabled': [ opt_bool, True ],
'path': [ opt_str, '' ], 'path': [ opt_str, '' ],
}, {}), }, {}),
'proxies': ({
'type': [ opt_str, 'http' ],
'host': [ opt_str, '' ],
'port': [ opt_int, 3128 ],
'user': [ opt_str, '' ],
'password': [ opt_str, '' ],
}, {}),
} }
emoticons_default = { emoticons_default = {

View File

@ -597,15 +597,12 @@ class Connection:
if self.connection: if self.connection:
return self.connection return self.connection
self.connected = 1 self.connected = 1
if gajim.config.get_per('accounts', self.name, 'use_proxy'): p = gajim.config.get_per('accounts', self.name, 'proxy')
proxy = {'host': gajim.config.get_per('accounts', self.name, if p and gajim.config.get_per('proxies').has_key(p):
'proxyhost')} proxy = {'host': gajim.config.get_per('proxies', p, 'host')}
proxy['port'] = gajim.config.get_per('accounts', self.name, proxy['port'] = gajim.config.get_per('proxies', p, 'port')
'proxyport') proxy['user'] = gajim.config.get_per('proxies', p, 'user')
proxy['user'] = gajim.config.get_per('accounts', self.name, proxy['password'] = gajim.config.get_per('proxies', p, 'pass')
'proxyuser')
proxy['password'] = gajim.config.get_per('accounts', self.name,
'proxypass')
else: else:
proxy = None proxy = None
if gajim.verbose: if gajim.verbose:
@ -880,9 +877,12 @@ class Connection:
# If a connection already exist we cannot create a new account # If a connection already exist we cannot create a new account
if self.connection: if self.connection:
return return
if config['use_proxy']: p = config['proxy']
proxy = {'host': config['proxyhost'], 'port': config['proxyport'], if p and gajim.config.get_per('proxies').has_key(p):
'user': config['proxyuser'], 'password': config['proxypass']} proxy = {'host': gajim.config.get_per('proxies', p, 'host')}
proxy['port'] = gajim.config.get_per('proxies', p, 'port')
proxy['user'] = gajim.config.get_per('proxies', p, 'user')
proxy['password'] = gajim.config.get_per('proxies', p, 'pass')
else: else:
proxy = None proxy = None
if gajim.verbose: if gajim.verbose:

View File

@ -1069,13 +1069,6 @@ class Account_modification_window:
for w in widgets: for w in widgets:
w.set_sensitive(widget.get_active()) w.set_sensitive(widget.get_active())
def on_use_proxy_checkbutton_toggled(self, widget):
proxy_table = self.xml.get_widget('proxy_table')
widgets = proxy_table.get_children()
widgets.append(proxy_table)
self.on_checkbutton_toggled(widget, widgets)
def init_account_gpg(self): def init_account_gpg(self):
keyid = gajim.config.get_per('accounts', self.account, 'keyid') keyid = gajim.config.get_per('accounts', self.account, 'keyid')
keyname = gajim.config.get_per('accounts', self.account, 'keyname') keyname = gajim.config.get_per('accounts', self.account, 'keyname')
@ -1120,27 +1113,19 @@ class Account_modification_window:
self.xml.get_widget('priority_spinbutton').set_value(gajim.config.\ self.xml.get_widget('priority_spinbutton').set_value(gajim.config.\
get_per('accounts', self.account, 'priority')) get_per('accounts', self.account, 'priority'))
use_proxy = gajim.config.get_per('accounts', self.account, 'use_proxy') # init proxy list
self.xml.get_widget('use_proxy_checkbutton').set_active(use_proxy) our_proxy = gajim.config.get_per('accounts', self.account, 'proxy')
if not our_proxy:
entry = self.xml.get_widget('proxyhost_entry') our_proxy = 'None'
entry.set_sensitive(use_proxy) self.proxy_combobox = self.xml.get_widget('proxies_combobox')
entry.set_text(gajim.config.get_per('accounts', self.account, model = gtk.ListStore(gobject.TYPE_STRING)
'proxyhost')) self.proxy_combobox.set_model(model)
entry = self.xml.get_widget('proxyport_entry') l = gajim.config.get_per('proxies')
entry.set_sensitive(use_proxy) l.insert(0, 'None')
entry.set_text(str(gajim.config.get_per('accounts', self.account, for i in range(len(l)):
'proxyport'))) model.append([l[i]])
if our_proxy == l[i]:
entry = self.xml.get_widget('proxyuser_entry') self.proxy_combobox.set_active(i)
entry.set_sensitive(use_proxy)
entry.set_text(gajim.config.get_per('accounts', self.account,
'proxyuser'))
entry = self.xml.get_widget('proxypass_entry')
entry.set_sensitive(use_proxy)
entry.set_text(gajim.config.get_per('accounts', self.account,
'proxypass'))
usessl = gajim.config.get_per('accounts', self.account, 'usessl') usessl = gajim.config.get_per('accounts', self.account, 'usessl')
self.xml.get_widget('use_ssl_checkbutton').set_active(usessl) self.xml.get_widget('use_ssl_checkbutton').set_active(usessl)
@ -1212,28 +1197,11 @@ _('To change the account name, it must be disconnected.')).get_response()
config['sync_with_global_status'] = self.xml.get_widget( config['sync_with_global_status'] = self.xml.get_widget(
'sync_with_global_status_checkbutton').get_active() 'sync_with_global_status_checkbutton').get_active()
config['use_proxy'] = self.xml.get_widget('use_proxy_checkbutton').\ active = self.proxy_combobox.get_active()
get_active() proxy = self.proxy_combobox.get_model()[active][0]
config['proxyhost'] = self.xml.get_widget('proxyhost_entry').get_text() if proxy == 'None':
config['proxyport'] = self.xml.get_widget('proxyport_entry').get_text() proxy = ''
config['proxyuser'] = self.xml.get_widget('proxyuser_entry').get_text() config['proxy'] = proxy
config['proxypass'] = self.xml.get_widget('proxypass_entry').get_text()
if config['use_proxy']:
if config['proxyport'] != '':
if not config['proxyport'].isdigit():
dialogs.Error_dialog(_('Invalid proxy port'),
_('Port numbers must contain digits only.')).get_response()
return
config['proxyport'] = int(config['proxyport'])
else:
dialogs.Error_dialog(_('Invalid proxy port'),
_('You must enter a port number to use a proxy.')).get_response()
return
if config['proxyhost'] == '':
dialogs.Error_dialog(_('Invalid proxy host'),
_('You must enter a proxy host to use a proxy.')).get_response()
return
config['usessl'] = self.xml.get_widget('use_ssl_checkbutton').get_active() config['usessl'] = self.xml.get_widget('use_ssl_checkbutton').get_active()
(config['name'], config['hostname']) = jid.split('@') (config['name'], config['hostname']) = jid.split('@')

View File

@ -1058,7 +1058,7 @@
<child> <child>
<widget class="GtkComboBox" id="proxies_combobox"> <widget class="GtkComboBox" id="proxies_combobox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="items" translatable="yes">None</property> <property name="items" translatable="yes"></property>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>
@ -13724,7 +13724,7 @@ the Jabber network.</property>
</child> </child>
</widget> </widget>
<widget class="GtkWindow" id="manage_proxy_profiles_window"> <widget class="GtkWindow" id="manage_proxies_window">
<property name="border_width">6</property> <property name="border_width">6</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="title" translatable="yes">Manage Proxy Profiles</property> <property name="title" translatable="yes">Manage Proxy Profiles</property>