Support for proxy
This commit is contained in:
parent
4e9f627a05
commit
133c635c83
3 changed files with 245 additions and 29 deletions
19
core/core.py
19
core/core.py
|
@ -178,12 +178,16 @@ class GajimCore:
|
|||
name = self.cfgParser.tab[account]["name"]
|
||||
password = self.cfgParser.tab[account]["password"]
|
||||
ressource = self.cfgParser.tab[account]["ressource"]
|
||||
if self.cfgParser.tab[account]["use_proxy"]:
|
||||
proxy = {"host":self.cfgParser.tab[account]["proxyhost"]}
|
||||
proxy["port"] = self.cfgParser.tab[account]["proxyport"]
|
||||
else:
|
||||
proxy = None
|
||||
con = common.jabber.Client(host = hostname, \
|
||||
debug = [], log = sys.stderr, \
|
||||
# debug = [common.jabber.DBG_ALWAYS], log = sys.stderr, \
|
||||
connection=common.xmlstream.TCP, port=5222)
|
||||
#debug = [common.jabber.DBG_ALWAYS], log = sys.stderr, \
|
||||
#connection=common.xmlstream.TCP_SSL, port=5223)
|
||||
connection=common.xmlstream.TCP, port=5222, proxy = proxy)
|
||||
#connection=common.xmlstream.TCP_SSL, port=5223, proxy = proxy)
|
||||
try:
|
||||
con.connect()
|
||||
except IOError, e:
|
||||
|
@ -351,10 +355,15 @@ class GajimCore:
|
|||
#('REG_AGENT', account, infos)
|
||||
elif ev[0] == 'REG_AGENT':
|
||||
con.sendRegInfo(ev[2])
|
||||
#('NEW_ACC', (hostname, login, password, name, ressource))
|
||||
#('NEW_ACC', (hostname, login, password, name, ressource, use_proxy\
|
||||
#, proxyhost, proxyport))
|
||||
elif ev[0] == 'NEW_ACC':
|
||||
if ev[2][5]:
|
||||
proxy = {'host': ev[2][6], 'port': ev[2][7]}
|
||||
else:
|
||||
proxy = None
|
||||
c = common.jabber.Client(host = \
|
||||
ev[2][0], debug = False, log = sys.stderr)
|
||||
ev[2][0], debug = False, log = sys.stderr, proxy = proxy)
|
||||
try:
|
||||
c.connect()
|
||||
except IOError, e:
|
||||
|
|
|
@ -1287,18 +1287,183 @@ Yann Le Boulanger (asterix@crans.org)</property>
|
|||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label12">
|
||||
<widget class="GtkVBox" id="vbox25">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Empty</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkFrame" id="frame12">
|
||||
<property name="visible">True</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="label_yalign">0.5</property>
|
||||
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox35">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTable" id="table14">
|
||||
<property name="border_width">5</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="n_rows">3</property>
|
||||
<property name="n_columns">2</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="row_spacing">5</property>
|
||||
<property name="column_spacing">5</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="entry_proxyport">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="visibility">True</property>
|
||||
<property name="max_length">0</property>
|
||||
<property name="text" translatable="yes"></property>
|
||||
<property name="has_frame">True</property>
|
||||
<property name="invisible_char" translatable="yes">*</property>
|
||||
<property name="activates_default">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label136">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Port:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">1</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="entry_proxyhost">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="visibility">True</property>
|
||||
<property name="max_length">0</property>
|
||||
<property name="text" translatable="yes"></property>
|
||||
<property name="has_frame">True</property>
|
||||
<property name="invisible_char" translatable="yes">*</property>
|
||||
<property name="activates_default">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label135">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Host:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="checkbutton_proxy">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Use proxy</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="active">False</property>
|
||||
<property name="inconsistent">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="bottom_attach">1</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label134">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Proxy</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="type">label_item</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="tab_expand">False</property>
|
||||
|
|
|
@ -597,6 +597,13 @@ class accountPreference_Window:
|
|||
self.xml.get_widget("entry_password").set_text(infos['password'])
|
||||
if infos.has_key('ressource'):
|
||||
self.xml.get_widget("entry_ressource").set_text(infos['ressource'])
|
||||
if infos.has_key('use_proxy'):
|
||||
self.xml.get_widget("checkbutton_proxy").set_active(infos['use_proxy'])
|
||||
if infos.has_key('proxyhost'):
|
||||
self.xml.get_widget("entry_proxyhost").set_text(infos['proxyhost'])
|
||||
if infos.has_key('proxyport'):
|
||||
self.xml.get_widget("entry_proxyport").set_text('%i'%\
|
||||
infos['proxyport'])
|
||||
|
||||
def on_save_clicked(self, widget):
|
||||
"""When save button is clicked : Save informations in config file"""
|
||||
|
@ -605,6 +612,14 @@ class accountPreference_Window:
|
|||
check = self.xml.get_widget("checkbutton")
|
||||
entryName = self.xml.get_widget("entry_name")
|
||||
entryJid = self.xml.get_widget("entry_jid")
|
||||
checkProxy = self.xml.get_widget("checkbutton_proxy")
|
||||
if checkProxy.get_active():
|
||||
useProxy = 1
|
||||
else:
|
||||
useProxy = 0
|
||||
entryProxyhost = self.xml.get_widget("entry_proxyhost")
|
||||
entryProxyport = self.xml.get_widget("entry_proxyport")
|
||||
proxyPort = entryProxyport.get_text()
|
||||
name = entryName.get_text()
|
||||
jid = entryJid.get_text()
|
||||
if (name == ''):
|
||||
|
@ -614,8 +629,13 @@ class accountPreference_Window:
|
|||
warning_Window('You must enter a Jabber ID for this account\n\
|
||||
For example : login@hostname')
|
||||
return 0
|
||||
else:
|
||||
(login, hostname) = string.split(jid, '@')
|
||||
if proxyPort != '':
|
||||
try:
|
||||
proxyPort = string.atoi(proxyPort)
|
||||
except ValueError:
|
||||
warning_Window('Proxy Port must be a port number')
|
||||
return 0
|
||||
(login, hostname) = string.split(jid, '@')
|
||||
#if we are modifying an account
|
||||
if self.modify:
|
||||
#if we modify the name of the account
|
||||
|
@ -639,7 +659,8 @@ class accountPreference_Window:
|
|||
self.plugin.send('ACC_CHG', self.account, name)
|
||||
self.plugin.accounts[name] = {'name': login, 'hostname': hostname,\
|
||||
'password': entryPass.get_text(), 'ressource': \
|
||||
entryRessource.get_text()}
|
||||
entryRessource.get_text(), 'use_proxy': useProxy, 'proxyhost': \
|
||||
entryProxyhost.get_text(), 'proxyport': proxyPort}
|
||||
self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts))
|
||||
#refresh accounts window
|
||||
if self.plugin.windows.has_key('accounts'):
|
||||
|
@ -656,12 +677,15 @@ class accountPreference_Window:
|
|||
#if we neeed to register a new account
|
||||
if check.get_active():
|
||||
self.plugin.send('NEW_ACC', None, (hostname, login, \
|
||||
entryPass.get_text(), name, entryRessource.get_text()))
|
||||
entryPass.get_text(), name, entryRessource.get_text(), \
|
||||
checkProxy.get_active(), entryProxyhost.get_text(), \
|
||||
entryProxyport.get_text()))
|
||||
check.set_active(FALSE)
|
||||
return
|
||||
self.plugin.accounts[name] = {'name': login, 'hostname': hostname,\
|
||||
'password': entryPass.get_text(), 'ressource': \
|
||||
entryRessource.get_text()}
|
||||
entryRessource.get_text(), 'use_proxy': useProxy, 'proxyhost': \
|
||||
entryProxyhost.get_text(), 'proxyport': proxyPort}
|
||||
self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts))
|
||||
#update variables
|
||||
self.plugin.windows[name] = {'infos': {}, 'chats': {}}
|
||||
|
@ -766,10 +790,19 @@ class accounts_Window:
|
|||
(model, iter) = sel.get_selected()
|
||||
account = model.get_value(iter, 0)
|
||||
infos['name'] = account
|
||||
infos['jid'] = self.plugin.accounts[account]["name"] + \
|
||||
'@' + self.plugin.accounts[account]["hostname"]
|
||||
infos['password'] = self.plugin.accounts[account]["password"]
|
||||
infos['ressource'] = self.plugin.accounts[account]["ressource"]
|
||||
if self.plugin.accounts[account].has_key("name"):
|
||||
infos['jid'] = self.plugin.accounts[account]["name"] + \
|
||||
'@' + self.plugin.accounts[account]["hostname"]
|
||||
if self.plugin.accounts[account].has_key("password"):
|
||||
infos['password'] = self.plugin.accounts[account]["password"]
|
||||
if self.plugin.accounts[account].has_key("ressource"):
|
||||
infos['ressource'] = self.plugin.accounts[account]["ressource"]
|
||||
if self.plugin.accounts[account].has_key("use_proxy"):
|
||||
infos['use_proxy'] = self.plugin.accounts[account]["use_proxy"]
|
||||
if self.plugin.accounts[account].has_key("proxyhost"):
|
||||
infos['proxyhost'] = self.plugin.accounts[account]["proxyhost"]
|
||||
if self.plugin.accounts[account].has_key("proxyport"):
|
||||
infos['proxyport'] = self.plugin.accounts[account]["proxyport"]
|
||||
self.plugin.windows['accountPreference'] = \
|
||||
accountPreference_Window(self.plugin, infos)
|
||||
|
||||
|
@ -1521,10 +1554,19 @@ class roster_Window:
|
|||
if not self.plugin.windows.has_key('accountPreference'):
|
||||
infos = {}
|
||||
infos['name'] = account
|
||||
infos['jid'] = self.plugin.accounts[account]["name"] + \
|
||||
'@' + self.plugin.accounts[account]["hostname"]
|
||||
infos['password'] = self.plugin.accounts[account]["password"]
|
||||
infos['ressource'] = self.plugin.accounts[account]["ressource"]
|
||||
if self.plugin.accounts[account].has_key("name"):
|
||||
infos['jid'] = self.plugin.accounts[account]["name"] + \
|
||||
'@' + self.plugin.accounts[account]["hostname"]
|
||||
if self.plugin.accounts[account].has_key("password"):
|
||||
infos['password'] = self.plugin.accounts[account]["password"]
|
||||
if self.plugin.accounts[account].has_key("ressource"):
|
||||
infos['ressource'] = self.plugin.accounts[account]["ressource"]
|
||||
if self.plugin.accounts[account].has_key("use_proxy"):
|
||||
infos['use_proxy'] = self.plugin.accounts[account]["use_proxy"]
|
||||
if self.plugin.accounts[account].has_key("proxyhost"):
|
||||
infos['proxyhost'] = self.plugin.accounts[account]["proxyhost"]
|
||||
if self.plugin.accounts[account].has_key("proxyport"):
|
||||
infos['proxyport'] = self.plugin.accounts[account]["proxyport"]
|
||||
self.plugin.windows['accountPreference'] = \
|
||||
accountPreference_Window(self.plugin, infos)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue