changeset b24f17156faa in /home/hg/repos/gajim

details:http://hg.gajim.org/gajim?cmd=changeset;node=b24f17156faa
description: restore metacontct correctly when we connect to server and we 
already have contacts in roster (stored locally). Fixes #5156

diffstat:

 src/common/contacts.py |   9 +++++++++
 src/gajim.py           |   1 +
 src/roster_window.py   |  26 +++++++++++++++++++++++++-
 3 files changed, 35 insertions(+), 1 deletions(-)

diffs (88 lines):

diff -r 6ffc7b04487d -r b24f17156faa src/common/contacts.py
--- a/src/common/contacts.py    Sat Jul 11 09:58:06 2009 +0200
+++ b/src/common/contacts.py    Sun Jul 12 13:33:29 2009 +0200
@@ -379,6 +379,12 @@
                #FIXME: can this append ?
                assert False
 
+       def get_metacontacts_tags(self, account):
+               '''return a list of tags for a given account'''
+               if not account in self._metacontacts_tags:
+                       return []
+               return self._metacontacts_tags[account].keys()
+
        def get_metacontacts_tag(self, account, jid):
                '''Returns the tag of a jid'''
                if not account in self._metacontacts_tags:
@@ -462,6 +468,9 @@
                [{'account': acct, 'jid': jid, 'order': order}, ]
                'order' is optional'''
                tag = self.get_metacontacts_tag(account, jid)
+               return self.get_metacontacts_family_from_tag(account, tag)
+
+       def get_metacontacts_family_from_tag(self, account, tag):
                if not tag:
                        return []
                answers = []
diff -r 6ffc7b04487d -r b24f17156faa src/gajim.py
--- a/src/gajim.py      Sat Jul 11 09:58:06 2009 +0200
+++ b/src/gajim.py      Sun Jul 12 13:33:29 2009 +0200
@@ -1908,6 +1908,7 @@
 
        def handle_event_metacontacts(self, account, tags_list):
                gajim.contacts.define_metacontacts(account, tags_list)
+               self.roster.redraw_metacontacts(account)
 
        def handle_atom_entry(self, account, data):
                atom_entry, = data
diff -r 6ffc7b04487d -r b24f17156faa src/roster_window.py
--- a/src/roster_window.py      Sat Jul 11 09:58:06 2009 +0200
+++ b/src/roster_window.py      Sun Jul 12 13:33:29 2009 +0200
@@ -565,8 +565,10 @@
                brothers = []
                nearby_family, big_brother_jid, big_brother_account = \
                        self._get_nearby_family_and_big_brother(family, account)
+               big_brother_contact = 
gajim.contacts.get_contact(big_brother_account,
+                       big_brother_jid)
                child_iters = self._get_contact_iter(big_brother_jid, 
big_brother_account,
-                       model = self.model)
+                       model=self.model)
                parent_iter = self.model.iter_parent(child_iters[0])
                parent_type = self.model[parent_iter][C_TYPE]
 
@@ -583,6 +585,23 @@
                        for c, acc in brothers:
                                self.draw_completely(c.jid, acc)
 
+               # Check is small brothers are under the big brother
+               for child in nearby_family:
+                       _jid = child['jid']
+                       _account = child['account']
+                       if _account == big_brother_account and _jid == 
big_brother_jid:
+                               continue
+                       child_iters = self._get_contact_iter(_jid, _account, 
model=self.model)
+                       if not child_iters:
+                               continue
+                       parent_iter = self.model.iter_parent(child_iters[0])
+                       parent_type = self.model[parent_iter][C_TYPE]
+                       if parent_type != 'contact':
+                               _contact = gajim.contacts.get_contact(_account, 
_jid)
+                               self._remove_entity(_contact, _account)
+                               self._add_entity(_contact, _account, 
groups=None,
+                                       big_brother_contact=big_brother_contact,
+                                       big_brother_account=big_brother_account)
 
        def _get_nearby_family_and_big_brother(self, family, account):
                '''Return the nearby family and its Big Brother
@@ -631,6 +650,11 @@
                return contact
 
 
+       def redraw_metacontacts(self, account):
+               for tag in gajim.contacts.get_metacontacts_tags(account):
+                       family = 
gajim.contacts.get_metacontacts_family_from_tag(account, tag)
+                       self._recalibrate_metacontact_family(family, account)
+
        def add_contact(self, jid, account):
                '''Add contact to roster and draw him.
 
_______________________________________________
Commits mailing list
[email protected]
http://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to