Author: steve-e Date: 2008-07-05 08:33:49 +0200 (Sat, 05 Jul 2008) New Revision: 9884
Modified: trunk/src/common/contacts.py trunk/src/roster_window.py Log: Correctly count metacontacts in non merged accounts mode if we have metacontacts over several accounts.
Modified: trunk/src/common/contacts.py =================================================================== --- trunk/src/common/contacts.py 2008-07-04 21:29:46 UTC (rev 9883) +++ trunk/src/common/contacts.py 2008-07-05 06:33:49 UTC (rev 9884) @@ -326,8 +326,8 @@ _('Transports') in groups: # do not count transports continue - if self.has_brother(account, jid) and not \ - self.is_big_brother(account, jid): + if self.has_brother(account, jid, accounts) and not \ + self.is_big_brother(account, jid, accounts): # count metacontacts only once continue contact = self.get_contact_with_highest_priority(account, jid) @@ -402,26 +402,30 @@ self._metacontacts_tags[account]) break
- def has_brother(self, account, jid): + def has_brother(self, account, jid, accounts): tag = self.get_metacontacts_tag(account, jid) if not tag: return False - meta_jids = self.get_metacontacts_jids(tag) + meta_jids = self.get_metacontacts_jids(tag, accounts) return len(meta_jids) > 1 or len(meta_jids[account]) > 1
- def is_big_brother(self, account, jid): + def is_big_brother(self, account, jid, accounts): family = self.get_metacontacts_family(account, jid) if family: - bb_data = self.get_metacontacts_big_brother(family) + nearby_family = [data for data in family + if account in accounts] + bb_data = self.get_metacontacts_big_brother(nearby_family) if bb_data['jid'] == jid and bb_data['account'] == account: return True return False
- def get_metacontacts_jids(self, tag): + def get_metacontacts_jids(self, tag, accounts): '''Returns all jid for the given tag in the form {acct: [jid1, jid2],.}''' answers = {} for account in self._metacontacts_tags: if tag in self._metacontacts_tags[account]: + if account not in accounts: + continue answers[account] = [] for data in self._metacontacts_tags[account][tag]: answers[account].append(data['jid'])
Modified: trunk/src/roster_window.py =================================================================== --- trunk/src/roster_window.py 2008-07-04 21:29:46 UTC (rev 9883) +++ trunk/src/roster_window.py 2008-07-05 06:33:49 UTC (rev 9884) @@ -3785,7 +3785,8 @@ return
# Is the contact we drag a meta contact? - is_big_brother = gajim.contacts.is_big_brother(account_source, jid_source) + accounts = (self.regroup and gajim.contacts.get_accounts()) or account_source + is_big_brother = gajim.contacts.is_big_brother(account_source, jid_source, accounts)
# Contact drop on group row or between two contacts if type_dest == 'group' or position == gtk.TREE_VIEW_DROP_BEFORE or \