diff --git a/src/common/connection.py b/src/common/connection.py index 587cc6159..83f77d8ab 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -106,7 +106,7 @@ def get_os_info(): class Connection: """Connection class""" def __init__(self, name): - # dict of function to be calledfor each event + # dict of function to be called for each event self.handlers = {'ROSTER': [], 'WARNING': [], 'ERROR': [], 'STATUS': [], 'NOTIFY': [], 'MSG': [], 'MSGERROR': [], 'MSGSENT': [] , 'SUBSCRIBED': [], 'UNSUBSCRIBED': [], 'SUBSCRIBE': [], @@ -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! diff --git a/src/config.py b/src/config.py index 4872548c1..6a535db3f 100644 --- a/src/config.py +++ b/src/config.py @@ -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