diff src/core/xmpp.py @ 1060:aa15453ec54d

core (xmpp), stdui (profile_manager), bridge, frontends: raise an exception if the XMPP connection failed instead of sending a signal
author souliane <souliane@mailoo.org>
date Fri, 23 May 2014 09:59:35 +0200
parents 71d63750963e
children 3700165d68dc
line wrap: on
line diff
--- a/src/core/xmpp.py	Fri May 23 10:40:54 2014 +0200
+++ b/src/core/xmpp.py	Fri May 23 09:59:35 2014 +0200
@@ -83,26 +83,26 @@
 
     def initializationFailed(self, reason):
         log.error(_("ERROR: XMPP connection failed for profile '%(profile)s': %(reason)s" % {'profile': self.profile, 'reason': reason}))
-        self.host_app.bridge.connectionError("AUTH_ERROR", self.profile)
+        self.conn_deferred.errback(reason.value)
         try:
             client.XMPPClient.initializationFailed(self, reason)
         except:
-            # we already send an error signal, no need to raise an exception
+            # we already chained an errback, no need to raise an exception
             pass
-        self.conn_deferred.errback()
 
     def isConnected(self):
         return self.__connected
 
     def connectionLost(self, connector, unused_reason):
-        self.__connected = False
-        log.info(_("********** [%s] DISCONNECTED **********") % self.profile)
         try:
             self.keep_alife.stop()
         except AttributeError:
             log.debug(_("No keep_alife"))
-        self.host_app.bridge.disconnected(self.profile)  # we send the signal to the clients
-        self.host_app.purgeClient(self.profile)  # and we remove references to this client
+        if self.__connected:
+            log.info(_("********** [%s] DISCONNECTED **********") % self.profile)
+            self.host_app.bridge.disconnected(self.profile)  # we send the signal to the clients
+            self.host_app.purgeClient(self.profile)  # and we remove references to this client
+        self.__connected = False
 
 
 class SatMessageProtocol(xmppim.MessageProtocol):