From a006a7c953fdd024fd309a3da77b58b945d5cdf7 Mon Sep 17 00:00:00 2001 From: souliane Date: Thu, 5 Feb 2015 12:10:42 +0100 Subject: [PATCH] quick_frontend: add some properties for QuickContactList --- .../src/quick_frontend/quick_contact_list.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/frontends/src/quick_frontend/quick_contact_list.py b/frontends/src/quick_frontend/quick_contact_list.py index b39e1f80..a1e8bad3 100644 --- a/frontends/src/quick_frontend/quick_contact_list.py +++ b/frontends/src/quick_frontend/quick_contact_list.py @@ -83,6 +83,36 @@ class QuickContactList(QuickWidget): return False return entity in self._cache + @property + def roster_entities(self): + """Return all the bare JIDs of the roster entities. + + @return: set(jid.JID) + """ + return self._roster + + @property + def roster_entities_by_group(self): + """Return a dictionary binding the roster groups to their entities bare JIDs. + + @return: dict{unicode: set(jid.JID)} + """ + return {group: self._groups[group]['jids'] for group in self._groups} + + @property + def roster_groups_by_entity(self, contact_jid_s): + """Return a dictionary binding the entities bare JIDs to their roster groups. + + @return: dict{jid.JID: set(unicode)} + """ + result = {} + for group, data in self._groups.iteritems(): + if group is None: + continue + for entity in data['jids']: + result.setdefault(entity, set()).add(group) + return result + def fill(self): """Get all contacts from backend, and fill the widget""" def gotContacts(contacts):