Mercurial > libervia-backend
comparison 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 |
comparison
equal
deleted
inserted
replaced
1059:b2b9c184033f | 1060:aa15453ec54d |
---|---|
81 | 81 |
82 disco_d.addCallback(finish_connection) | 82 disco_d.addCallback(finish_connection) |
83 | 83 |
84 def initializationFailed(self, reason): | 84 def initializationFailed(self, reason): |
85 log.error(_("ERROR: XMPP connection failed for profile '%(profile)s': %(reason)s" % {'profile': self.profile, 'reason': reason})) | 85 log.error(_("ERROR: XMPP connection failed for profile '%(profile)s': %(reason)s" % {'profile': self.profile, 'reason': reason})) |
86 self.host_app.bridge.connectionError("AUTH_ERROR", self.profile) | 86 self.conn_deferred.errback(reason.value) |
87 try: | 87 try: |
88 client.XMPPClient.initializationFailed(self, reason) | 88 client.XMPPClient.initializationFailed(self, reason) |
89 except: | 89 except: |
90 # we already send an error signal, no need to raise an exception | 90 # we already chained an errback, no need to raise an exception |
91 pass | 91 pass |
92 self.conn_deferred.errback() | |
93 | 92 |
94 def isConnected(self): | 93 def isConnected(self): |
95 return self.__connected | 94 return self.__connected |
96 | 95 |
97 def connectionLost(self, connector, unused_reason): | 96 def connectionLost(self, connector, unused_reason): |
98 self.__connected = False | |
99 log.info(_("********** [%s] DISCONNECTED **********") % self.profile) | |
100 try: | 97 try: |
101 self.keep_alife.stop() | 98 self.keep_alife.stop() |
102 except AttributeError: | 99 except AttributeError: |
103 log.debug(_("No keep_alife")) | 100 log.debug(_("No keep_alife")) |
104 self.host_app.bridge.disconnected(self.profile) # we send the signal to the clients | 101 if self.__connected: |
105 self.host_app.purgeClient(self.profile) # and we remove references to this client | 102 log.info(_("********** [%s] DISCONNECTED **********") % self.profile) |
103 self.host_app.bridge.disconnected(self.profile) # we send the signal to the clients | |
104 self.host_app.purgeClient(self.profile) # and we remove references to this client | |
105 self.__connected = False | |
106 | 106 |
107 | 107 |
108 class SatMessageProtocol(xmppim.MessageProtocol): | 108 class SatMessageProtocol(xmppim.MessageProtocol): |
109 | 109 |
110 def __init__(self, host): | 110 def __init__(self, host): |