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
This commit is contained in:
Goffi 2011-01-22 15:53:56 +01:00
commit a0a70750c6
3 changed files with 29 additions and 1 deletions

View file

@ -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

View file

@ -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)

View file

@ -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