diff browser_side/contact.py @ 28:258dfaa1035f

browser side: - roomJoined signal added and open a new tab - name refactoring - connected contact are saved - launchTarotGame method used
author Goffi <goffi@goffi.org>
date Sat, 07 May 2011 23:58:57 +0200
parents 586f69e85559
children e70521e6d803
line wrap: on
line diff
--- a/browser_side/contact.py	Sat May 07 23:54:21 2011 +0200
+++ b/browser_side/contact.py	Sat May 07 23:58:57 2011 +0200
@@ -119,6 +119,7 @@
         SimplePanel.__init__(self)
         self.host = host
         self.groups={}
+        self.connected = {} #jid connected as key and their status
 
         self.vPanel = VerticalPanel()
         _title = ContactTitleLabel('Contacts')
@@ -144,10 +145,27 @@
             if not self.groups.has_key(group):
                 self.groups[group] = set()
                 self._groupList.add(group)
-                self.host.uniBox.addKey("@%s: " % group)
+                self.host.uni_box.addKey("@%s: " % group)
             self.groups[group].add(jid)
         self._contactList.add(jid)
 
+    def setConnected(self, jid, resource, availability, priority, statuses):
+        """Set connection status"""
+        if availability=='unavailable':
+            if self.connected.has_key(jid):
+                if self.connected[jid].has_key(resource):
+                    del self.connected[jid][resource]
+                if not self.connected[jid]:
+                    del self.connected[jid]
+        else: 
+            if not self.connected.has_key(jid):
+                self.connected[jid] = {}
+            self.connected[jid][resource] = (availability, priority, statuses)
+
+    def getConnected(self):
+        """return a list of all jid  (bare jid) connected"""
+        return self.connected.keys()
+
     def isContactInGroup(self, group, contact_jid):
        """Test if the contact_jid is in the group
        @param group: string of single group, or list of string