diff --git a/frontends/src/quick_frontend/quick_app.py b/frontends/src/quick_frontend/quick_app.py index 6cd2a4cf..5809ec53 100644 --- a/frontends/src/quick_frontend/quick_app.py +++ b/frontends/src/quick_frontend/quick_app.py @@ -46,6 +46,7 @@ class QuickApp(): 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 @@ class QuickApp(): return debug(_("Connected")) self.setStatusOnline(True) - def disconnected(self, profile): """called when the connection is closed""" @@ -188,6 +188,17 @@ class QuickApp(): 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 diff --git a/src/bridge/DBus.py b/src/bridge/DBus.py index 2814718d..2ecacecf 100755 --- a/src/bridge/DBus.py +++ b/src/bridge/DBus.py @@ -53,6 +53,11 @@ class DbusObject(dbus.service.Object): def disconnected(self, profile): 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): @@ -344,6 +349,9 @@ class DBusBridge(Bridge): 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) diff --git a/src/sat.tac b/src/sat.tac index 6d9f50c4..bceb20b3 100644 --- a/src/sat.tac +++ b/src/sat.tac @@ -106,6 +106,15 @@ class SatXMPPClient(client.XMPPClient): 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