proxy is fixed (TODO: mange proxies)
This commit is contained in:
parent
3fcc90fa0a
commit
316ca92083
|
@ -115,11 +115,7 @@ class Config:
|
|||
'resource': [ opt_str, 'gajim' ],
|
||||
'priority': [ opt_int, 5 ],
|
||||
'autoconnect': [ opt_bool, False ],
|
||||
'use_proxy': [ opt_bool, False ],
|
||||
'proxyhost': [ opt_str, '' ],
|
||||
'proxyport': [ opt_int, 3128 ],
|
||||
'proxyuser': [ opt_str, '' ],
|
||||
'proxypass': [ opt_str, '' ],
|
||||
'proxy': [ opt_str, '' ],
|
||||
'keyid': [ opt_str, '' ],
|
||||
'keyname': [ opt_str, '' ],
|
||||
'usessl': [ opt_bool, False ],
|
||||
|
@ -139,6 +135,13 @@ class Config:
|
|||
'enabled': [ opt_bool, True ],
|
||||
'path': [ opt_str, '' ],
|
||||
}, {}),
|
||||
'proxies': ({
|
||||
'type': [ opt_str, 'http' ],
|
||||
'host': [ opt_str, '' ],
|
||||
'port': [ opt_int, 3128 ],
|
||||
'user': [ opt_str, '' ],
|
||||
'password': [ opt_str, '' ],
|
||||
}, {}),
|
||||
}
|
||||
|
||||
emoticons_default = {
|
||||
|
|
|
@ -597,15 +597,12 @@ class Connection:
|
|||
if self.connection:
|
||||
return self.connection
|
||||
self.connected = 1
|
||||
if gajim.config.get_per('accounts', self.name, 'use_proxy'):
|
||||
proxy = {'host': gajim.config.get_per('accounts', self.name,
|
||||
'proxyhost')}
|
||||
proxy['port'] = gajim.config.get_per('accounts', self.name,
|
||||
'proxyport')
|
||||
proxy['user'] = gajim.config.get_per('accounts', self.name,
|
||||
'proxyuser')
|
||||
proxy['password'] = gajim.config.get_per('accounts', self.name,
|
||||
'proxypass')
|
||||
p = gajim.config.get_per('accounts', self.name, 'proxy')
|
||||
if p and gajim.config.get_per('proxies').has_key(p):
|
||||
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:
|
||||
proxy = None
|
||||
if gajim.verbose:
|
||||
|
@ -880,9 +877,12 @@ class Connection:
|
|||
# If a connection already exist we cannot create a new account
|
||||
if self.connection:
|
||||
return
|
||||
if config['use_proxy']:
|
||||
proxy = {'host': config['proxyhost'], 'port': config['proxyport'],
|
||||
'user': config['proxyuser'], 'password': config['proxypass']}
|
||||
p = config['proxy']
|
||||
if p and gajim.config.get_per('proxies').has_key(p):
|
||||
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:
|
||||
proxy = None
|
||||
if gajim.verbose:
|
||||
|
|
|
@ -1069,13 +1069,6 @@ class Account_modification_window:
|
|||
for w in widgets:
|
||||
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):
|
||||
keyid = gajim.config.get_per('accounts', self.account, 'keyid')
|
||||
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.\
|
||||
get_per('accounts', self.account, 'priority'))
|
||||
|
||||
use_proxy = gajim.config.get_per('accounts', self.account, 'use_proxy')
|
||||
self.xml.get_widget('use_proxy_checkbutton').set_active(use_proxy)
|
||||
|
||||
entry = self.xml.get_widget('proxyhost_entry')
|
||||
entry.set_sensitive(use_proxy)
|
||||
entry.set_text(gajim.config.get_per('accounts', self.account,
|
||||
'proxyhost'))
|
||||
entry = self.xml.get_widget('proxyport_entry')
|
||||
entry.set_sensitive(use_proxy)
|
||||
entry.set_text(str(gajim.config.get_per('accounts', self.account,
|
||||
'proxyport')))
|
||||
|
||||
entry = self.xml.get_widget('proxyuser_entry')
|
||||
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'))
|
||||
# init proxy list
|
||||
our_proxy = gajim.config.get_per('accounts', self.account, 'proxy')
|
||||
if not our_proxy:
|
||||
our_proxy = 'None'
|
||||
self.proxy_combobox = self.xml.get_widget('proxies_combobox')
|
||||
model = gtk.ListStore(gobject.TYPE_STRING)
|
||||
self.proxy_combobox.set_model(model)
|
||||
l = gajim.config.get_per('proxies')
|
||||
l.insert(0, 'None')
|
||||
for i in range(len(l)):
|
||||
model.append([l[i]])
|
||||
if our_proxy == l[i]:
|
||||
self.proxy_combobox.set_active(i)
|
||||
|
||||
usessl = gajim.config.get_per('accounts', self.account, '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(
|
||||
'sync_with_global_status_checkbutton').get_active()
|
||||
|
||||
config['use_proxy'] = self.xml.get_widget('use_proxy_checkbutton').\
|
||||
get_active()
|
||||
config['proxyhost'] = self.xml.get_widget('proxyhost_entry').get_text()
|
||||
config['proxyport'] = self.xml.get_widget('proxyport_entry').get_text()
|
||||
config['proxyuser'] = self.xml.get_widget('proxyuser_entry').get_text()
|
||||
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
|
||||
active = self.proxy_combobox.get_active()
|
||||
proxy = self.proxy_combobox.get_model()[active][0]
|
||||
if proxy == 'None':
|
||||
proxy = ''
|
||||
config['proxy'] = proxy
|
||||
|
||||
config['usessl'] = self.xml.get_widget('use_ssl_checkbutton').get_active()
|
||||
(config['name'], config['hostname']) = jid.split('@')
|
||||
|
|
|
@ -1058,7 +1058,7 @@
|
|||
<child>
|
||||
<widget class="GtkComboBox" id="proxies_combobox">
|
||||
<property name="visible">True</property>
|
||||
<property name="items" translatable="yes">None</property>
|
||||
<property name="items" translatable="yes"></property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
|
@ -13724,7 +13724,7 @@ the Jabber network.</property>
|
|||
</child>
|
||||
</widget>
|
||||
|
||||
<widget class="GtkWindow" id="manage_proxy_profiles_window">
|
||||
<widget class="GtkWindow" id="manage_proxies_window">
|
||||
<property name="border_width">6</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">Manage Proxy Profiles</property>
|
||||
|
|
Loading…
Reference in New Issue