From 0cf86f5a8fb3512b446e3628fd21ef46e3422a3e Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Wed, 11 Feb 2009 17:55:00 +0000 Subject: [PATCH] [Dicson] Fix meta contact order by DND. Fixes #4797, #4779 --- src/common/contacts.py | 14 +++++++++++--- src/roster_window.py | 13 ++++++++++++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/common/contacts.py b/src/common/contacts.py index 51a29b3c2..8c2aca6ab 100644 --- a/src/common/contacts.py +++ b/src/common/contacts.py @@ -389,7 +389,7 @@ class Contacts: return tag return None - def add_metacontact(self, brother_account, brother_jid, account, jid): + def add_metacontact(self, brother_account, brother_jid, account, jid, order=None): tag = self.get_metacontacts_tag(brother_account, brother_jid) if not tag: tag = self.get_new_metacontacts_tag(brother_jid) @@ -406,8 +406,12 @@ class Contacts: if tag not in self._metacontacts_tags[account]: self._metacontacts_tags[account][tag] = [{'jid': jid, 'tag': tag}] else: - self._metacontacts_tags[account][tag].append({'jid': jid, - 'tag': tag}) + if order: + self._metacontacts_tags[account][tag].append({'jid': jid, + 'tag': tag, 'order': order}) + else: + self._metacontacts_tags[account][tag].append({'jid': jid, + 'tag': tag}) common.gajim.connections[account].store_metacontacts( self._metacontacts_tags[account]) @@ -510,6 +514,10 @@ class Contacts: return 1 if data1['order'] < data2['order']: return -1 + if 'order' in data1: + return 1 + if 'order' in data2: + return -1 transport1 = common.gajim.get_transport_name_from_jid(jid1) transport2 = common.gajim.get_transport_name_from_jid(jid2) if transport2 and not transport1: diff --git a/src/roster_window.py b/src/roster_window.py index 0f354331c..1bbd79b32 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -3759,6 +3759,7 @@ class RosterWindow: 'So those information will not be saved on next reconnection.')) def merge_contacts(is_checked=None): + contacts = 0 if is_checked is not None: # dialog has been shown if is_checked: # user does not want to be asked again gajim.config.set('confirm_metacontacts', 'no') @@ -3771,6 +3772,16 @@ class RosterWindow: c_dest.jid) if dest_family: self._remove_metacontact_family(dest_family, account_dest) + source_family = gajim.contacts.get_metacontacts_family(account_source, c_source.jid) + if dest_family == source_family: + n = contacts = len(dest_family) + for tag in source_family: + if tag['jid'] == c_source.jid: + tag['order'] = contacts + continue + if 'order' in tag: + n -= 1 + tag['order'] = n else: self._remove_entity(c_dest, account_dest) @@ -3806,7 +3817,7 @@ class RosterWindow: _contact.groups = c_dest.groups[:] gajim.contacts.add_metacontact(account_dest, c_dest.jid, - _account, _contact.jid) + _account, _contact.jid, contacts) gajim.connections[account_source].update_contact(_contact.jid, _contact.name, _contact.groups)