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

View File

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