comparison frontends/src/quick_frontend/quick_contact_list.py @ 1328:7a3a232d4938 frontends_multi_profiles

quick_frontend (quick_contact_list): add property roster_entities_connected and method getSpecials
author souliane <souliane@mailoo.org>
date Sat, 21 Feb 2015 12:39:04 +0100
parents 789e86a8919d
children 0f92b6a150ff
comparison
equal deleted inserted replaced
1327:89dc29afe01c 1328:7a3a232d4938
90 @return: set(jid.JID) 90 @return: set(jid.JID)
91 """ 91 """
92 return self._roster 92 return self._roster
93 93
94 @property 94 @property
95 def roster_entities_connected(self):
96 """Return all the bare JIDs of the roster entities that are connected.
97
98 @return: set(jid.JID)
99 """
100 return set([entity for entity in self._roster if self.getCache(entity, C.PRESENCE_SHOW) is not None])
101
102 @property
95 def roster_entities_by_group(self): 103 def roster_entities_by_group(self):
96 """Return a dictionary binding the roster groups to their entities bare JIDs. 104 """Return a dictionary binding the roster groups to their entities bare
105 JIDs. This also includes the empty group (None key).
97 106
98 @return: dict{unicode: set(jid.JID)} 107 @return: dict{unicode: set(jid.JID)}
99 """ 108 """
100 return {group: self._groups[group]['jids'] for group in self._groups} 109 return {group: self._groups[group]['jids'] for group in self._groups}
101 110
102 @property 111 @property
103 def roster_groups_by_entity(self, contact_jid_s): 112 def roster_groups_by_entity(self):
104 """Return a dictionary binding the entities bare JIDs to their roster groups. 113 """Return a dictionary binding the entities bare JIDs to their roster
114 groups. The empty group is filtered out.
105 115
106 @return: dict{jid.JID: set(unicode)} 116 @return: dict{jid.JID: set(unicode)}
107 """ 117 """
108 result = {} 118 result = {}
109 for group, data in self._groups.iteritems(): 119 for group, data in self._groups.iteritems():
194 @param entity(jid.JID): jid of the special entity 204 @param entity(jid.JID): jid of the special entity
195 @param special_type: one of special type (e.g. C.CONTACT_SPECIAL_GROUP) or None to remove special flag 205 @param special_type: one of special type (e.g. C.CONTACT_SPECIAL_GROUP) or None to remove special flag
196 """ 206 """
197 assert special_type in C.CONTACT_SPECIAL_ALLOWED + (None,) 207 assert special_type in C.CONTACT_SPECIAL_ALLOWED + (None,)
198 self.setCache(entity, C.CONTACT_SPECIAL, special_type) 208 self.setCache(entity, C.CONTACT_SPECIAL, special_type)
209
210 def getSpecials(self, special_type=None):
211 """Return all the bare JIDs of the special roster entities of the type
212 specified by special_type. If special_type is None, return all specials.
213
214 @param special_type: one of special type (e.g. C.CONTACT_SPECIAL_GROUP) or None to return all specials.
215 @return: set(jid.JID)
216 """
217 if special_type is None:
218 return self._specials
219 return set([entity for entity in self._specials if self.getCache(entity, C.CONTACT_SPECIAL) == special_type])
199 220
200 def clearContacts(self): 221 def clearContacts(self):
201 """Clear all the contact list""" 222 """Clear all the contact list"""
202 self.unselectAll() 223 self.unselectAll()
203 self._cache.clear() 224 self._cache.clear()