From fe2ec40ad7bae9b7112745d5e048f730a4a2ff68 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger <asterix@lagaule.org> Date: Tue, 11 Apr 2006 20:16:33 +0000 Subject: [PATCH] new metacontacts JEP (not yet published) uses order instead of priority. --- src/common/connection_handlers.py | 6 +++--- src/common/contacts.py | 24 +++++++++++++++--------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index 094d13b7c..842dfdfc3 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -1079,9 +1079,9 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco) jid = meta.getAttr('jid') tag = meta.getAttr('tag') data = {'jid': jid} - prio = meta.getAttr('priority') - if prio != None: - data['priority'] = prio + order = meta.getAttr('order') + if order != None: + data['order'] = order if meta_list.has_key(tag): meta_list[tag].append(data) else: diff --git a/src/common/contacts.py b/src/common/contacts.py index 5ef3e2da8..924f3df08 100644 --- a/src/common/contacts.py +++ b/src/common/contacts.py @@ -293,8 +293,8 @@ class Contacts: def get_metacontacts_family(self, account, jid): '''return the family of the given jid, including jid in the form: - [{'account': acct, 'jid': jid, 'priority': prio}, ] - 'priority' is optional''' + [{'account': acct, 'jid': jid, 'order': order}, ] + 'order' is optional''' tag = self.get_metacontacts_tag(account, jid) if not tag: return [] @@ -308,16 +308,22 @@ class Contacts: def _get_data_score(self, data): '''compute thescore of a gived data - data is {'jid': jid, 'account': account, 'priority': priority} - priority is optional - score = meta_priority*10000 + is_jabber*priority*10 + status''' + data is {'jid': jid, 'account': account, 'order': order} + order is optional + score = (max_order - order)*10000 + is_jabber*priority*10 + status''' jid = data['jid'] account = data['account'] - priority = 0 - if data.has_key('priority'): - priority = data['priority'] + max_order = 0 + order = 0 + if data.has_key('order'): + order = data['order'] + if order: + family = self.get_metacontacts_family(account, jid) + for data_ in family: + if data_.has_key('order') and data_['order'] > max_order: + max_order = data_['order'] contact = self.get_contact_with_highest_priority(account, jid) - score = priority*10000 + score = (max_order - order)*10000 if not common.gajim.jid_is_transport(jid): score += contact.priority*10 score += ['not in roster', 'error', 'offline', 'invisible', 'dnd', 'xa',