From 9acde16dde30f0a3b81d027b5f7b6fd7f3a8f71e Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Fri, 23 Nov 2007 20:54:25 +0000 Subject: [PATCH] fis metacontact behaviour. fixes #3464 --- src/common/contacts.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/common/contacts.py b/src/common/contacts.py index c615dbbb5..39399f596 100644 --- a/src/common/contacts.py +++ b/src/common/contacts.py @@ -424,29 +424,36 @@ class Contacts: '''compare 2 metacontacts. Data is {'jid': jid, 'account': account, 'order': order} order is optional''' + jid1 = data1['jid'] + jid2 = data2['jid'] + account1 = data1['account'] + account2 = data2['account'] + contact1 = self.get_contact_with_highest_priority(account1, jid1) + contact2 = self.get_contact_with_highest_priority(account2, jid2) + show_list = ['not in roster', 'error', 'offline', 'invisible', 'dnd', + 'xa', 'away', 'chat', 'online', 'requested', 'message'] + show1 = show_list.index(contact1.show) + show2 = show_list.index(contact2.show) + # If only one is offline, it's always second + if show1 > 2 and show2 < 3: + return 1 + if show2 > 2 and show1 < 3: + return -1 if 'order' in data1 and 'order' in data2: if data1['order'] > data2['order']: return 1 if data1['order'] < data2['order']: return -1 - jid1 = data1['jid'] - jid2 = data2['jid'] transport1 = common.gajim.get_transport_name_from_jid(jid1) transport2 = common.gajim.get_transport_name_from_jid(jid2) if transport2 and not transport1: return 1 if transport1 and not transport2: return -1 - contact1 = self.get_contact_with_highest_priority(data1['account'], jid1) - contact2 = self.get_contact_with_highest_priority(data2['account'], jid2) if contact1.priority > contact2.priority: return 1 if contact2.priority > contact1.priority: return -1 - show_list = ['not in roster', 'error', 'offline', 'invisible', 'dnd', - 'xa', 'away', 'chat', 'online', 'requested', 'message'] - show1 = show_list.index(contact1.show) - show2 = show_list.index(contact2.show) if show1 > show2: return 1 if show2 > show1: @@ -456,8 +463,6 @@ class Contacts: if jid2 > jid1: return -1 # If all is the same, compare accounts, they can't be the same - account1 = data1['account'] - account2 = data2['account'] if account1 > account2: return 1 if account2 > account1: