[Dicson] Fix meta contact order by DND. Fixes #4797, #4779

This commit is contained in:
Yann Leboulanger 2009-02-11 17:55:00 +00:00
parent 200069062e
commit 0cf86f5a8f
2 changed files with 23 additions and 4 deletions

View File

@ -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:

View File

@ -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)