we can now manage proxies
This commit is contained in:
parent
2fd11adc18
commit
ff11a7433c
|
@ -140,7 +140,7 @@ class Config:
|
||||||
'host': [ opt_str, '' ],
|
'host': [ opt_str, '' ],
|
||||||
'port': [ opt_int, 3128 ],
|
'port': [ opt_int, 3128 ],
|
||||||
'user': [ opt_str, '' ],
|
'user': [ opt_str, '' ],
|
||||||
'password': [ opt_str, '' ],
|
'pass': [ opt_str, '' ],
|
||||||
}, {}),
|
}, {}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
192
src/config.py
192
src/config.py
|
@ -21,6 +21,7 @@ import gtk
|
||||||
import gtk.glade
|
import gtk.glade
|
||||||
import gobject
|
import gobject
|
||||||
import os
|
import os
|
||||||
|
import common.config
|
||||||
import common.sleepy
|
import common.sleepy
|
||||||
|
|
||||||
import dialogs
|
import dialogs
|
||||||
|
@ -1095,6 +1096,20 @@ class Account_modification_window:
|
||||||
self.account, 'gpgpassword')
|
self.account, 'gpgpassword')
|
||||||
entry.set_text(gpgpassword)
|
entry.set_text(gpgpassword)
|
||||||
|
|
||||||
|
def update_proxy_list(self):
|
||||||
|
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)
|
||||||
|
|
||||||
def init_account(self):
|
def init_account(self):
|
||||||
'''Initialize window with defaults values'''
|
'''Initialize window with defaults values'''
|
||||||
self.xml.get_widget('name_entry').set_text(self.account)
|
self.xml.get_widget('name_entry').set_text(self.account)
|
||||||
|
@ -1117,18 +1132,7 @@ class Account_modification_window:
|
||||||
get_per('accounts', self.account, 'priority'))
|
get_per('accounts', self.account, 'priority'))
|
||||||
|
|
||||||
# init proxy list
|
# init proxy list
|
||||||
our_proxy = gajim.config.get_per('accounts', self.account, 'proxy')
|
self.update_proxy_list()
|
||||||
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')
|
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)
|
||||||
|
@ -1341,6 +1345,13 @@ _('To change the account name, it must be disconnected.')).get_response()
|
||||||
dialogs.Vcard_window(jid, self.plugin, self.account, True)
|
dialogs.Vcard_window(jid, self.plugin, self.account, True)
|
||||||
gajim.connections[self.account].request_vcard(jid)
|
gajim.connections[self.account].request_vcard(jid)
|
||||||
|
|
||||||
|
def on_manage_proxies_button_clicked(self, widget):
|
||||||
|
if self.plugin.windows.has_key('manage_proxies'):
|
||||||
|
self.plugin.windows['manage_proxies'].window.present()
|
||||||
|
else:
|
||||||
|
self.plugin.windows['manage_proxies'] = \
|
||||||
|
Manage_proxies_window(self.plugin)
|
||||||
|
|
||||||
def on_gpg_choose_button_clicked(self, widget, data = None):
|
def on_gpg_choose_button_clicked(self, widget, data = None):
|
||||||
secret_keys = gajim.connections[self.account].ask_gpg_secrete_keys()
|
secret_keys = gajim.connections[self.account].ask_gpg_secrete_keys()
|
||||||
if not secret_keys:
|
if not secret_keys:
|
||||||
|
@ -1392,6 +1403,163 @@ _('There was a problem retrieving your GPG secret keys.')).get_response()
|
||||||
password_entry.set_sensitive(False)
|
password_entry.set_sensitive(False)
|
||||||
password_entry.set_text('')
|
password_entry.set_text('')
|
||||||
|
|
||||||
|
#---------- Manage_proxies_window class -------------#
|
||||||
|
class Manage_proxies_window:
|
||||||
|
def __init__(self, plugin):
|
||||||
|
self.plugin = plugin
|
||||||
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'manage_proxies_window', APP)
|
||||||
|
self.window = self.xml.get_widget('manage_proxies_window')
|
||||||
|
self.proxies_treeview = self.xml.get_widget('proxies_treeview')
|
||||||
|
self.proxyname_entry = self.xml.get_widget('proxyname_entry')
|
||||||
|
self.init_list()
|
||||||
|
self.xml.signal_autoconnect(self)
|
||||||
|
self.window.show_all()
|
||||||
|
|
||||||
|
def fill_proxies_treeview(self):
|
||||||
|
model = self.proxies_treeview.get_model()
|
||||||
|
model.clear()
|
||||||
|
iter = model.append()
|
||||||
|
model.set(iter, 0, 'None')
|
||||||
|
for p in gajim.config.get_per('proxies'):
|
||||||
|
iter = model.append()
|
||||||
|
model.set(iter, 0, p)
|
||||||
|
|
||||||
|
def init_list(self):
|
||||||
|
self.xml.get_widget('remove_proxy_button').set_sensitive(False)
|
||||||
|
self.xml.get_widget('proxytype_combobox').set_sensitive(False)
|
||||||
|
self.xml.get_widget('proxy_table').set_sensitive(False)
|
||||||
|
model = gtk.ListStore(gobject.TYPE_STRING)
|
||||||
|
self.proxies_treeview.set_model(model)
|
||||||
|
col = gtk.TreeViewColumn('Proxies')
|
||||||
|
self.proxies_treeview.append_column(col)
|
||||||
|
renderer = gtk.CellRendererText()
|
||||||
|
col.pack_start(renderer, True)
|
||||||
|
col.set_attributes(renderer, text = 0)
|
||||||
|
self.fill_proxies_treeview()
|
||||||
|
self.xml.get_widget('proxytype_combobox').set_active(0)
|
||||||
|
|
||||||
|
def on_manage_proxies_window_destroy(self, widget):
|
||||||
|
for account in gajim.connections:
|
||||||
|
if self.plugin.windows[account].has_key('account_modification'):
|
||||||
|
self.plugin.windows[account]['account_modification'].\
|
||||||
|
update_proxy_list()
|
||||||
|
if self.plugin.windows.has_key('account_modification'):
|
||||||
|
self.plugin.windows['account_modification'].update_proxy_list()
|
||||||
|
del self.plugin.windows['manage_proxies']
|
||||||
|
|
||||||
|
def on_add_proxy_button_clicked(self, widget):
|
||||||
|
model = self.proxies_treeview.get_model()
|
||||||
|
proxies = gajim.config.get_per('proxies')
|
||||||
|
i = 1
|
||||||
|
while ('proxy' + str(i)) in proxies:
|
||||||
|
i += 1
|
||||||
|
iter = model.append()
|
||||||
|
model.set(iter, 0, 'proxy' + str(i))
|
||||||
|
gajim.config.add_per('proxies', 'proxy' + str(i))
|
||||||
|
|
||||||
|
def on_remove_proxy_button_clicked(self, widget):
|
||||||
|
(model, iter) = self.proxies_treeview.get_selection().get_selected()
|
||||||
|
if not iter:
|
||||||
|
return
|
||||||
|
proxy = model.get_value(iter, 0)
|
||||||
|
model.remove(iter)
|
||||||
|
gajim.config.del_per('proxies', proxy)
|
||||||
|
self.xml.get_widget('remove_proxy_button').set_sensitive(False)
|
||||||
|
|
||||||
|
def on_close_button_clicked(self, widget):
|
||||||
|
self.window.destroy()
|
||||||
|
|
||||||
|
def on_useauth_checkbutton_toggled(self, widget):
|
||||||
|
act = widget.get_active()
|
||||||
|
self.xml.get_widget('proxyuser_entry').set_sensitive(act)
|
||||||
|
self.xml.get_widget('proxypass_entry').set_sensitive(act)
|
||||||
|
|
||||||
|
def on_proxies_treeview_cursor_changed(self, widget):
|
||||||
|
#TODO: check if off proxy settings are correct (see http://trac.gajim.org/changeset/1921#file2 line 1221
|
||||||
|
(model, iter) = widget.get_selection().get_selected()
|
||||||
|
if not iter:
|
||||||
|
return
|
||||||
|
self.xml.get_widget('remove_proxy_button').set_sensitive(True)
|
||||||
|
proxy = model.get_value(iter, 0)
|
||||||
|
self.xml.get_widget('proxyname_entry').set_text(proxy)
|
||||||
|
proxyhost_entry = self.xml.get_widget('proxyhost_entry')
|
||||||
|
proxyport_entry = self.xml.get_widget('proxyport_entry')
|
||||||
|
proxyuser_entry = self.xml.get_widget('proxyuser_entry')
|
||||||
|
proxypass_entry = self.xml.get_widget('proxypass_entry')
|
||||||
|
useauth_checkbutton = self.xml.get_widget('useauth_checkbutton')
|
||||||
|
proxyhost_entry.set_text('')
|
||||||
|
proxyport_entry.set_text('')
|
||||||
|
proxyuser_entry.set_text('')
|
||||||
|
proxypass_entry.set_text('')
|
||||||
|
useauth_checkbutton.set_active(False)
|
||||||
|
self.on_useauth_checkbutton_toggled(useauth_checkbutton)
|
||||||
|
if proxy == 'None':
|
||||||
|
self.proxyname_entry.set_editable(False)
|
||||||
|
self.xml.get_widget('proxytype_combobox').set_sensitive(False)
|
||||||
|
self.xml.get_widget('proxy_table').set_sensitive(False)
|
||||||
|
else:
|
||||||
|
self.proxyname_entry.set_editable(True)
|
||||||
|
self.xml.get_widget('proxytype_combobox').set_sensitive(True)
|
||||||
|
self.xml.get_widget('proxy_table').set_sensitive(True)
|
||||||
|
proxyhost_entry.set_text(gajim.config.get_per('proxies', proxy,
|
||||||
|
'host'))
|
||||||
|
proxyport_entry.set_text(str(gajim.config.get_per('proxies', proxy,
|
||||||
|
'port')))
|
||||||
|
proxyuser_entry.set_text(gajim.config.get_per('proxies', proxy,
|
||||||
|
'user'))
|
||||||
|
proxypass_entry.set_text(gajim.config.get_per('proxies', proxy,
|
||||||
|
'pass'))
|
||||||
|
#TODO: if we have several proxy type, set the combobox
|
||||||
|
if gajim.config.get_per('proxies', proxy, 'user'):
|
||||||
|
useauth_checkbutton.set_active(True)
|
||||||
|
|
||||||
|
def on_proxies_treeview_key_press_event(self, widget, event):
|
||||||
|
if event.keyval == gtk.keysyms.Delete:
|
||||||
|
self.on_remove_proxy_button_clicked(widget)
|
||||||
|
|
||||||
|
def on_proxyname_entry_changed(self, widget):
|
||||||
|
(model, iter) = self.proxies_treeview.get_selection().get_selected()
|
||||||
|
if not iter:
|
||||||
|
return
|
||||||
|
old_name = model.get_value(iter, 0)
|
||||||
|
new_name = widget.get_text()
|
||||||
|
if new_name == '':
|
||||||
|
return
|
||||||
|
if new_name == old_name:
|
||||||
|
return
|
||||||
|
config = gajim.config.get_per('proxies', old_name)
|
||||||
|
gajim.config.del_per('proxies', old_name)
|
||||||
|
gajim.config.add_per('proxies', new_name)
|
||||||
|
for option in config:
|
||||||
|
gajim.config.set_per('proxies', new_name, option,
|
||||||
|
config[option][common.config.OPT_VAL])
|
||||||
|
model.set_value(iter, 0, new_name)
|
||||||
|
|
||||||
|
def on_proxytype_combobox_changed(self, widget):
|
||||||
|
#TODO: if we have several proxy type
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_proxyhost_entry_changed(self, widget):
|
||||||
|
value = widget.get_text()
|
||||||
|
proxy = self.proxyname_entry.get_text()
|
||||||
|
gajim.config.set_per('proxies', proxy, 'host', value)
|
||||||
|
|
||||||
|
def on_proxyport_entry_changed(self, widget):
|
||||||
|
value = widget.get_text()
|
||||||
|
proxy = self.proxyname_entry.get_text()
|
||||||
|
gajim.config.set_per('proxies', proxy, 'port', value)
|
||||||
|
|
||||||
|
def on_proxyuser_entry_changed(self, widget):
|
||||||
|
value = widget.get_text()
|
||||||
|
proxy = self.proxyname_entry.get_text()
|
||||||
|
gajim.config.set_per('proxies', proxy, 'user', value)
|
||||||
|
|
||||||
|
def on_proxypass_entry_changed(self, widget):
|
||||||
|
value = widget.get_text()
|
||||||
|
proxy = self.proxyname_entry.get_text()
|
||||||
|
gajim.config.set_per('proxies', proxy, 'pass', value)
|
||||||
|
|
||||||
|
|
||||||
#---------- Accounts_window class -------------#
|
#---------- Accounts_window class -------------#
|
||||||
class Accounts_window:
|
class Accounts_window:
|
||||||
'''Class for accounts window: list of accounts'''
|
'''Class for accounts window: list of accounts'''
|
||||||
|
|
|
@ -11037,7 +11037,6 @@ send a chat message to</property>
|
||||||
|
|
||||||
<widget class="GtkWindow" id="groupchat_config_window">
|
<widget class="GtkWindow" id="groupchat_config_window">
|
||||||
<property name="border_width">6</property>
|
<property name="border_width">6</property>
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="title" translatable="yes">Room Configuration</property>
|
<property name="title" translatable="yes">Room Configuration</property>
|
||||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||||
<property name="window_position">GTK_WIN_POS_NONE</property>
|
<property name="window_position">GTK_WIN_POS_NONE</property>
|
||||||
|
@ -13149,7 +13148,6 @@ the Jabber network.</property>
|
||||||
|
|
||||||
<widget class="GtkWindow" id="manage_bookmarks_window">
|
<widget class="GtkWindow" id="manage_bookmarks_window">
|
||||||
<property name="border_width">6</property>
|
<property name="border_width">6</property>
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="title" translatable="yes">Manage Bookmarks</property>
|
<property name="title" translatable="yes">Manage Bookmarks</property>
|
||||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||||
<property name="window_position">GTK_WIN_POS_NONE</property>
|
<property name="window_position">GTK_WIN_POS_NONE</property>
|
||||||
|
@ -13524,7 +13522,6 @@ the Jabber network.</property>
|
||||||
|
|
||||||
<widget class="GtkWindow" id="manage_proxies_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="title" translatable="yes">Manage Proxy Profiles</property>
|
<property name="title" translatable="yes">Manage Proxy Profiles</property>
|
||||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||||
<property name="window_position">GTK_WIN_POS_NONE</property>
|
<property name="window_position">GTK_WIN_POS_NONE</property>
|
||||||
|
@ -13536,6 +13533,7 @@ the Jabber network.</property>
|
||||||
<property name="skip_pager_hint">False</property>
|
<property name="skip_pager_hint">False</property>
|
||||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||||
|
<signal name="destroy" handler="on_manage_proxies_window_destroy" last_modification_time="Wed, 08 Jun 2005 17:33:08 GMT"/>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkVBox" id="vbox87">
|
<widget class="GtkVBox" id="vbox87">
|
||||||
|
@ -13565,13 +13563,15 @@ the Jabber network.</property>
|
||||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkTreeView" id="treeview1">
|
<widget class="GtkTreeView" id="proxies_treeview">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="headers_visible">False</property>
|
<property name="headers_visible">False</property>
|
||||||
<property name="rules_hint">False</property>
|
<property name="rules_hint">False</property>
|
||||||
<property name="reorderable">False</property>
|
<property name="reorderable">False</property>
|
||||||
<property name="enable_search">True</property>
|
<property name="enable_search">True</property>
|
||||||
|
<signal name="cursor_changed" handler="on_proxies_treeview_cursor_changed" last_modification_time="Wed, 08 Jun 2005 17:53:49 GMT"/>
|
||||||
|
<signal name="key_press_event" handler="on_proxies_treeview_key_press_event" last_modification_time="Wed, 08 Jun 2005 17:53:56 GMT"/>
|
||||||
</widget>
|
</widget>
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -13715,6 +13715,7 @@ the Jabber network.</property>
|
||||||
<widget class="GtkComboBox" id="proxytype_combobox">
|
<widget class="GtkComboBox" id="proxytype_combobox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="items" translatable="yes">HTTP Connect</property>
|
<property name="items" translatable="yes">HTTP Connect</property>
|
||||||
|
<signal name="changed" handler="on_proxytype_combobox_changed" last_modification_time="Wed, 08 Jun 2005 17:45:26 GMT"/>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">1</property>
|
||||||
|
@ -13736,6 +13737,7 @@ the Jabber network.</property>
|
||||||
<property name="has_frame">True</property>
|
<property name="has_frame">True</property>
|
||||||
<property name="invisible_char">*</property>
|
<property name="invisible_char">*</property>
|
||||||
<property name="activates_default">False</property>
|
<property name="activates_default">False</property>
|
||||||
|
<signal name="changed" handler="on_proxyname_entry_changed" last_modification_time="Wed, 08 Jun 2005 17:43:44 GMT"/>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">1</property>
|
||||||
|
@ -13842,6 +13844,7 @@ the Jabber network.</property>
|
||||||
<property name="has_frame">True</property>
|
<property name="has_frame">True</property>
|
||||||
<property name="invisible_char">*</property>
|
<property name="invisible_char">*</property>
|
||||||
<property name="activates_default">False</property>
|
<property name="activates_default">False</property>
|
||||||
|
<signal name="changed" handler="on_proxyhost_entry_changed" last_modification_time="Wed, 08 Jun 2005 20:56:20 GMT"/>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">1</property>
|
||||||
|
@ -13859,10 +13862,11 @@ the Jabber network.</property>
|
||||||
<property name="editable">True</property>
|
<property name="editable">True</property>
|
||||||
<property name="visibility">True</property>
|
<property name="visibility">True</property>
|
||||||
<property name="max_length">0</property>
|
<property name="max_length">0</property>
|
||||||
<property name="text">3128</property>
|
<property name="text"></property>
|
||||||
<property name="has_frame">True</property>
|
<property name="has_frame">True</property>
|
||||||
<property name="invisible_char">*</property>
|
<property name="invisible_char">*</property>
|
||||||
<property name="activates_default">False</property>
|
<property name="activates_default">False</property>
|
||||||
|
<signal name="changed" handler="on_proxyport_entry_changed" last_modification_time="Wed, 08 Jun 2005 20:57:45 GMT"/>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">1</property>
|
||||||
|
@ -13959,6 +13963,7 @@ the Jabber network.</property>
|
||||||
<property name="has_frame">True</property>
|
<property name="has_frame">True</property>
|
||||||
<property name="invisible_char">*</property>
|
<property name="invisible_char">*</property>
|
||||||
<property name="activates_default">False</property>
|
<property name="activates_default">False</property>
|
||||||
|
<signal name="changed" handler="on_proxypass_entry_changed" last_modification_time="Wed, 08 Jun 2005 20:58:01 GMT"/>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">1</property>
|
||||||
|
@ -13980,6 +13985,7 @@ the Jabber network.</property>
|
||||||
<property name="has_frame">True</property>
|
<property name="has_frame">True</property>
|
||||||
<property name="invisible_char">*</property>
|
<property name="invisible_char">*</property>
|
||||||
<property name="activates_default">False</property>
|
<property name="activates_default">False</property>
|
||||||
|
<signal name="changed" handler="on_proxyuser_entry_changed" last_modification_time="Wed, 08 Jun 2005 20:57:53 GMT"/>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">1</property>
|
||||||
|
|
Loading…
Reference in New Issue