From 4a7f6c5eaf2d4fa721e3ce80860d65f48d38b375 Mon Sep 17 00:00:00 2001 From: mathieui Date: Tue, 31 Jul 2012 20:51:18 +0200 Subject: =?UTF-8?q?Sort=20the=20contacts=20in=20the=20roster=20groups=20by?= =?UTF-8?q?=20show=20(xa/away/=E2=80=A6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/contact.py | 6 +++--- src/roster.py | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/contact.py b/src/contact.py index 8d3b2bdf..3de2f496 100644 --- a/src/contact.py +++ b/src/contact.py @@ -33,15 +33,15 @@ class Resource(object): @property def priority(self): - return self._data['priority'] + return self._data.get('priority') or 0 @property def presence(self): - return self._data['show'] + return self._data.get('show') or '' @property def status(self): - return self._data['status'] + return self._data.get('status') or '' def __repr__(self): return '<%s>' % self._jid diff --git a/src/roster.py b/src/roster.py index c86b33ac..818b3025 100644 --- a/src/roster.py +++ b/src/roster.py @@ -247,9 +247,10 @@ class RosterGroup(object): def get_contacts(self, contact_filter): """Return the group contacts, filtered and sorted""" def compare_contact(a): - if not a.get_highest_priority_resource(): + res = a.get_highest_priority_resource() + if not res: return 0 - show = a.get_highest_priority_resource() + show = res.presence if show not in PRESENCE_PRIORITY: return 5 return PRESENCE_PRIORITY[show] -- cgit v1.2.3