Client's connect() does not raise exception on error as it was in jabberpy

in xmpppy it connect() returns connection type in a string
apparently that string can be 'tls', 'tcp' (simple without tls) and '' when it fails to connect
This commit is contained in:
Nikos Kouremenos 2005-05-26 13:35:58 +00:00
parent 92b1c8226c
commit 81b28a9cff
2 changed files with 8 additions and 12 deletions

View File

@ -515,7 +515,7 @@ class Connection:
resource = gajim.config.get_per('accounts', self.name, 'resource') resource = gajim.config.get_per('accounts', self.name, 'resource')
usetls = gajim.config.get_per('accounts', self.name, 'usetls') usetls = gajim.config.get_per('accounts', self.name, 'usetls')
#create connexion if it doesn't already existe #create connection if it doesn't already exist
if self.connection: if self.connection:
return self.connection return self.connection
self.connected = 1 self.connected = 1
@ -539,11 +539,8 @@ class Connection:
common.xmpp.dispatcher.DefaultTimeout = 45 common.xmpp.dispatcher.DefaultTimeout = 45
con.UnregisterDisconnectHandler(con.DisconnectHandler) con.UnregisterDisconnectHandler(con.DisconnectHandler)
con.RegisterDisconnectHandler(self._disconnectedCB) con.RegisterDisconnectHandler(self._disconnectedCB)
try: con_type = con.connect(proxy=proxy, tls=usetls) #FIXME: blocking
c = con.connect(proxy=proxy, tls=usetls) #FIXME: blocking if not con_type:
except:
c = None
if not c:
gajim.log.debug('Couldn\'t connect to %s' % hostname) gajim.log.debug('Couldn\'t connect to %s' % hostname)
self.connected = 0 self.connected = 0
self.dispatch('STATUS', 'offline') self.dispatch('STATUS', 'offline')
@ -790,12 +787,11 @@ class Connection:
else: else:
proxy = None proxy = None
c = common.xmpp.Client(server = config['hostname'], debug = []) c = common.xmpp.Client(server = config['hostname'], debug = [])
try: con_type = c.connect(proxy = proxy)
c.connect(proxy = proxy) if not con_type:
except:
gajim.log.debug('Couldn\'t connect to %s' % config['hostname']) gajim.log.debug('Couldn\'t connect to %s' % config['hostname'])
self.dispatch('ERROR', _('Couldn\'t connect to ') + config['hostname']) self.dispatch('ERROR', _('Couldn\'t connect to ') + config['hostname'])
return 0 return False
else: else:
gajim.log.debug('Connected to server') gajim.log.debug('Connected to server')
req = common.xmpp.features.getRegInfo(c, config['hostname']).asDict() # FIXME! This blocks! req = common.xmpp.features.getRegInfo(c, config['hostname']).asDict() # FIXME! This blocks!

View File

@ -1234,7 +1234,7 @@ class Account_modification_window:
return return
con = connection.Connection(name) con = connection.Connection(name)
self.plugin.register_handlers(con) self.plugin.register_handlers(con)
#if we neeed to register a new account #if we need to register a new account
if new_account: if new_account:
con.new_account(name, config) con.new_account(name, config)
return return