From 5514387db7825309bfbd84292bf13d49a546d0bf Mon Sep 17 00:00:00 2001 From: Nikos Kouremenos Date: Mon, 13 Jun 2005 21:16:41 +0000 Subject: [PATCH] gajim can now connect to custom hostname and port [TODO: patch xmpppy to do ssl in any port I ask] --- src/common/config.py | 1 + src/common/connection.py | 17 ++++++++--------- src/config.py | 26 ++++++++++++++++++++++++-- src/gtkgui.glade | 1 + 4 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/common/config.py b/src/common/config.py index 976fa226b..9fa63960a 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -119,6 +119,7 @@ class Config: 'accounts': ({ 'name': [ opt_str, '' ], 'hostname': [ opt_str, '' ], + 'port': [ opt_int, 5222 ], 'savepass': [ opt_bool, False ], 'password': [ opt_str, '' ], 'resource': [ opt_str, 'gajim' ], diff --git a/src/common/connection.py b/src/common/connection.py index 5619b3cbf..205710211 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -594,6 +594,7 @@ class Connection: """Connect and authenticate to the Jabber server""" name = gajim.config.get_per('accounts', self.name, 'name') hostname = gajim.config.get_per('accounts', self.name, 'hostname') + port = gajim.config.get_per('accounts', self.name, 'port') resource = gajim.config.get_per('accounts', self.name, 'resource') usessl = gajim.config.get_per('accounts', self.name, 'usessl') @@ -613,14 +614,11 @@ class Connection: con = common.xmpp.Client(hostname) else: con = common.xmpp.Client(hostname, debug = []) - #debug = [common.jabber.DBG_ALWAYS], log = sys.stderr, \ - #connection=common.xmlstream.TCP_SSL, port=5223, proxy = proxy) - common.xmpp.dispatcher.DefaultTimeout = 45 + common.xmpp.dispatcher.DefaultTimeout = 45 # wait 45 seconds until you timeout connection con.UnregisterDisconnectHandler(con.DisconnectHandler) con.RegisterDisconnectHandler(self._disconnectedCB) - port = 5222 - if usessl: - port = 5223 + + #pass ssl optional arg if neccessary when client.py is patched con_type = con.connect((hostname, port), proxy = proxy) #FIXME: blocking if not con_type: gajim.log.debug("Couldn't connect to %s" % self.name) @@ -896,9 +894,10 @@ class Connection: common.xmpp.dispatcher.DefaultTimeout = 45 c.UnregisterDisconnectHandler(c.DisconnectHandler) c.RegisterDisconnectHandler(self._disconnectedCB) - port = 5222 -# if usessl: -# port = 5223 + port = gajim.config.get_per('accounts', self.name, 'port') + #FIXME: use ssl + #if usessl: + #port = 5223 #FIXME: blocking con_type = c.connect((config['hostname'], port), proxy = proxy) if not con_type: diff --git a/src/config.py b/src/config.py index c5c426782..e6b61fda5 100644 --- a/src/config.py +++ b/src/config.py @@ -1056,6 +1056,9 @@ class AccountModificationWindow: usessl = gajim.config.get_per('accounts', self.account, 'usessl') self.xml.get_widget('use_ssl_checkbutton').set_active(usessl) + port = gajim.config.get_per('accounts', self.account, 'port') + self.xml.get_widget('custom_port_entry').set_text(str(port)) + gpg_key_label = self.xml.get_widget('gpg_key_label') if gajim.config.get('usegpg'): self.init_account_gpg() @@ -1128,9 +1131,21 @@ _('To change the account name, it must be disconnected.')).get_response() if proxy == 'None': proxy = '' config['proxy'] = proxy - + config['usessl'] = self.xml.get_widget('use_ssl_checkbutton').get_active() - (config['name'], config['hostname']) = jid.split('@') + + if self.xml.get_widget('custom_host_port_checkbutton').get_active(): + config['name'] = jid.split('@')[0] + config['hostname'] = self.xml.get_widget('custom_host_entry').get_text() + config['port'] = int(self.xml.get_widget('custom_port_entry').get_text()) + else: + (config['name'], config['hostname']) = jid.split('@') + if config['usessl']: + port = 5223 #FIXME: better way + else: + port = 5222 + config['port'] = port + config['keyname'] = self.xml.get_widget('gpg_name_label').get_text() if config['keyname'] == '': #no key selected config['keyid'] = '' @@ -1303,6 +1318,13 @@ _('There was a problem retrieving your GPG secret keys.')).get_response() if not widget.get_active(): w.set_text('') + def on_use_ssl_checkbutton_toggled(self, widget): + isactive = widget.get_active() + if isactive: + self.xml.get_widget('custom_port_entry').set_text('5223') + else: + self.xml.get_widget('custom_port_entry').set_text('5222') + def on_custom_host_port_checkbutton_toggled(self, widget): isactive = widget.get_active() self.xml.get_widget('custom_host_port_hbox').set_sensitive(isactive) diff --git a/src/gtkgui.glade b/src/gtkgui.glade index 54c6a1884..346efa4b0 100644 --- a/src/gtkgui.glade +++ b/src/gtkgui.glade @@ -1322,6 +1322,7 @@ False False True + 0