diff --git a/src/common/contacts.py b/src/common/contacts.py index 91e7d48c4..ae826d0fe 100644 --- a/src/common/contacts.py +++ b/src/common/contacts.py @@ -379,6 +379,12 @@ class Contacts: #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 @@ class Contacts: [{'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 --git a/src/gajim.py b/src/gajim.py index 5a60993cf..8f1fd9daf 100644 --- a/src/gajim.py +++ b/src/gajim.py @@ -1908,6 +1908,7 @@ class Interface: 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 --git a/src/roster_window.py b/src/roster_window.py index 4111c9fca..95eb90b76 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -565,8 +565,10 @@ class RosterWindow: 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 @@ class RosterWindow: 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 @@ class RosterWindow: 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.