diff browser_side/contact.py @ 54:f25c4077f6b9

addind contact + subscription management + misc - removed bad html_sanitize (not needed in Label !) - added isContactInRoster method in ContactPanel
author Goffi <goffi@goffi.org>
date Sat, 28 May 2011 20:18:14 +0200
parents 9f19e16187ff
children d5266c41ca24
line wrap: on
line diff
--- a/browser_side/contact.py	Sat May 28 20:14:38 2011 +0200
+++ b/browser_side/contact.py	Sat May 28 20:18:14 2011 +0200
@@ -30,7 +30,6 @@
 from pyjamas.dnd import makeDraggable
 from pyjamas.ui.DragWidget import DragWidget, DragContainer
 from jid import JID
-from tools import html_sanitize
 
 class DragLabel(DragWidget):
 
@@ -66,7 +65,7 @@
 class GroupLabel(DragLabel, Label):
     def __init__(self, group):
         self.group = group
-        Label.__init__(self, html_sanitize(group)) #, Element=DOM.createElement('div')
+        Label.__init__(self, group) #, Element=DOM.createElement('div')
         self.setStyleName('group')
         DragLabel.__init__(self, group, "GROUP")
     
@@ -75,7 +74,7 @@
     def __init__(self, jid, name=None):
         if not name:
             name=jid
-        Label.__init__(self, html_sanitize(name))
+        Label.__init__(self, name)
         self.jid=jid
         self.setStyleName('contact')
         DragLabel.__init__(self, jid, "CONTACT")
@@ -141,14 +140,14 @@
         _title = ContactTitleLabel('Contacts')
         DOM.setStyleAttribute(_title.getElement(), "cursor", "pointer")
 
-        self._contactList = ContactList()
-        self._contactList.setStyleName('contactList')
+        self._contact_list = ContactList()
+        self._contact_list.setStyleName('contactList')
         self._groupList = GroupList(self)
         self._groupList.setStyleName('groupList')
         
         self.vPanel.add(_title)
         self.vPanel.add(self._groupList)
-        self.vPanel.add(self._contactList)
+        self.vPanel.add(self._contact_list)
         self.add(self.vPanel)
         self.setStyleName('contactBox')
 
@@ -163,7 +162,7 @@
                 self._groupList.add(group)
                 self.host.uni_box.addKey("@%s: " % group)
             self.groups[group].add(jid)
-        self._contactList.add(jid)
+        self._contact_list.add(jid)
 
     def setConnected(self, jid, resource, availability, priority, statuses):
         """Set connection status"""
@@ -177,7 +176,7 @@
             if not self.connected.has_key(jid):
                 self.connected[jid] = {}
             self.connected[jid][resource] = (availability, priority, statuses)
-        self._contactList.setState(jid, availability)
+        self._contact_list.setState(jid, availability)
 
     def getConnected(self):
         """return a list of all jid (bare jid) connected"""
@@ -192,6 +191,13 @@
            return True
        return False
 
+    def isContactInRoster(self, contact_jid):
+        """Test if the contact is in our roster list"""
+        for _contact_label in self._contact_list:
+            if contact_jid == _contact_label.jid:
+                return True
+        return False
+
     def getGroups(self):
         return self.groups.keys()
 
@@ -206,12 +212,12 @@
 
     def onMouseEnter(self, sender):
         if isinstance(sender, GroupLabel):
-            for contact in self._contactList:
+            for contact in self._contact_list:
                 if contact.jid in self.groups[sender.group]:
                     contact.addStyleName("selected")
     
     def onMouseLeave(self, sender):
         if isinstance(sender, GroupLabel):
-            for contact in self._contactList:
+            for contact in self._contact_list:
                 if contact.jid in self.groups[sender.group]:
                     contact.removeStyleName("selected")