diff frontends/quick_frontend/quick_app.py @ 52:6455fb62ff83

Connection/disconnection signals - wix, sortilege: management of this new signals /!\ sortilege is bugged, the contact list window is not updated correctly
author Goffi <goffi@goffi.org>
date Thu, 07 Jan 2010 01:55:30 +1100
parents 8c67ea98ab91
children 6dfe5bb10008
line wrap: on
line diff
--- a/frontends/quick_frontend/quick_app.py	Thu Jan 07 00:17:27 2010 +1100
+++ b/frontends/quick_frontend/quick_app.py	Thu Jan 07 01:55:30 2010 +1100
@@ -32,6 +32,8 @@
         
         ## bridge ##
         self.bridge=DBusBridgeFrontend()
+        self.bridge.register("connected", self.connected)
+        self.bridge.register("disconnected", self.disconnected)
         self.bridge.register("newContact", self.newContact)
         self.bridge.register("newMessage", self.newMessage)
         self.bridge.register("presenceUpdate", self.presenceUpdate)
@@ -54,6 +56,9 @@
 
         if self.bridge.isConnected():
             self.setStatusOnline(True)
+        else:
+            self.setStatusOnline(False)
+            return
 
         ### now we fill the contact list ###
         for contact in self.bridge.getContacts():
@@ -73,6 +78,18 @@
             self.subscribe(waitingSub[sub], sub)
 
 
+    def connected(self):
+        """called when the connection is made"""
+        debug("Connected")
+        self.setStatusOnline(True)
+
+    def disconnected(self):
+        """called when the connection is closed"""
+        debug("Disconnected")
+        self.CM.clear()
+        self.contactList.clear_contacts()
+        self.setStatusOnline(False)
+    
     def newContact(self, JabberId, attributes, groups):
         entity=JID(JabberId)
         self.rosterList[entity.short]=(dict(attributes), list(groups))