# HG changeset patch # User Goffi # Date 1295708036 -3600 # Node ID af3d4f11fe43b5425eecf0fc9ecc93e9a54f3f33 # Parent 0ecd9c33fa3aa3214aa37b7291583ad14f349e34 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 diff -r 0ecd9c33fa3a -r af3d4f11fe43 frontends/src/quick_frontend/quick_app.py --- 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 diff -r 0ecd9c33fa3a -r af3d4f11fe43 src/bridge/DBus.py --- 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) diff -r 0ecd9c33fa3a -r af3d4f11fe43 src/sat.tac --- 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