Mercurial > libervia-backend
changeset 262:af3d4f11fe43
Added management of connection error
- core: connection_error signal is sent if it's impossible to connect
- bridge: added connection_error signal
- quick_frontend: an error_message is shown when a connection_error is received
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 22 Jan 2011 15:53:56 +0100 |
parents | 0ecd9c33fa3a |
children | bfd01aed0a3a |
files | frontends/src/quick_frontend/quick_app.py src/bridge/DBus.py src/sat.tac |
diffstat | 3 files changed, 29 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_app.py Tue Jan 18 15:22:58 2011 +0100 +++ b/frontends/src/quick_frontend/quick_app.py Sat Jan 22 15:53:56 2011 +0100 @@ -46,6 +46,7 @@ sys.exit(1) self.bridge.register("connected", self.connected) self.bridge.register("disconnected", self.disconnected) + self.bridge.register("connection_error", self.connection_error) self.bridge.register("newContact", self.newContact) self.bridge.register("newMessage", self.newMessage) self.bridge.register("newAlert", self.newAlert) @@ -177,7 +178,6 @@ return debug(_("Connected")) self.setStatusOnline(True) - def disconnected(self, profile): """called when the connection is closed""" @@ -188,6 +188,17 @@ self.contactList.clear_contacts() self.setStatusOnline(False) + def connection_error(self, profile, error_type): + """called when something goest wrong with the connection""" + if not self.check_profile(profile): + return + debug(_("Connection Error")) + self.disconnected(profile) + if error_type == "AUTH_ERROR": + self.showDialog(_("Can't connect to account, check your password"), _("Connection error"), "error") + else: + error(_('FIXME: error_type %s not implemented') % error_type) + def newContact(self, JabberId, attributes, groups, profile): if not self.check_profile(profile): return
--- a/src/bridge/DBus.py Tue Jan 18 15:22:58 2011 +0100 +++ b/src/bridge/DBus.py Sat Jan 22 15:53:56 2011 +0100 @@ -54,6 +54,11 @@ debug("Disconnected signal") @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, + signature='ss') + def connection_error(self, profile, error_type): + debug("Connection_error signal") + + @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, signature='sa{ss}ass') def newContact(self, contact, attributes, groups, profile): debug("new contact signal (%s) sended (profile: %s)", contact, profile) @@ -344,6 +349,9 @@ def disconnected(self, profile): self.dbus_bridge.disconnected(profile) + def connection_error(self, profile, error_type): + self.dbus_bridge.connection_error(profile, error_type) + def newContact(self, contact, attributes, groups, profile): self.dbus_bridge.newContact(contact, attributes, groups, profile)
--- a/src/sat.tac Tue Jan 18 15:22:58 2011 +0100 +++ b/src/sat.tac Sat Jan 22 15:53:56 2011 +0100 @@ -106,6 +106,15 @@ self.disco.requestInfo(jid.JID(self.host_app.memory.getParamA("Server", "Connection", profile_key=self.profile))).addCallback(self.host_app.serverDisco) #FIXME: use these informations + def initializationFailed(self, reason): + print ("initializationFailed: %s" % reason) + self.host_app.bridge.connection_error(self.profile,"AUTH_ERROR") + try: + client.XMPPClient.initializationFailed(self, reason) + except: + #we already send an error signal, no need to raise an exception + pass + def isConnected(self): return self.__connected