Changeset 9884

Show
Ignore:
Timestamp:
07/05/08 08:33:49 (5 months ago)
Author:
steve-e
Message:

Correctly count metacontacts in non merged accounts mode if we have metacontacts over several accounts.

Location:
trunk/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/common/contacts.py

    r9883 r9884  
    327327                                        # do not count transports 
    328328                                        continue 
    329                                 if self.has_brother(account, jid) and not \ 
    330                                 self.is_big_brother(account, jid): 
     329                                if self.has_brother(account, jid, accounts) and not \ 
     330                                self.is_big_brother(account, jid, accounts): 
    331331                                        # count metacontacts only once 
    332332                                        continue 
     
    403403                                break 
    404404 
    405         def has_brother(self, account, jid): 
     405        def has_brother(self, account, jid, accounts): 
    406406                tag = self.get_metacontacts_tag(account, jid) 
    407407                if not tag: 
    408408                        return False 
    409                 meta_jids = self.get_metacontacts_jids(tag) 
     409                meta_jids = self.get_metacontacts_jids(tag, accounts) 
    410410                return len(meta_jids) > 1 or len(meta_jids[account]) > 1 
    411411 
    412         def is_big_brother(self, account, jid): 
     412        def is_big_brother(self, account, jid, accounts): 
    413413                family = self.get_metacontacts_family(account, jid) 
    414414                if family: 
    415                         bb_data = self.get_metacontacts_big_brother(family) 
     415                        nearby_family = [data for data in family 
     416                                if account in accounts] 
     417                        bb_data = self.get_metacontacts_big_brother(nearby_family) 
    416418                        if bb_data['jid'] == jid and bb_data['account'] == account:  
    417419                                return True 
    418420                return False 
    419421 
    420         def get_metacontacts_jids(self, tag): 
     422        def get_metacontacts_jids(self, tag, accounts): 
    421423                '''Returns all jid for the given tag in the form {acct: [jid1, jid2],.}''' 
    422424                answers = {} 
    423425                for account in self._metacontacts_tags: 
    424426                        if tag in self._metacontacts_tags[account]: 
     427                                if account not in accounts: 
     428                                        continue 
    425429                                answers[account] = [] 
    426430                                for data in self._metacontacts_tags[account][tag]: 
  • trunk/src/roster_window.py

    r9883 r9884  
    37863786 
    37873787                # Is the contact we drag a meta contact? 
    3788                 is_big_brother = gajim.contacts.is_big_brother(account_source, jid_source) 
     3788                accounts = (self.regroup and gajim.contacts.get_accounts()) or account_source 
     3789                is_big_brother = gajim.contacts.is_big_brother(account_source, jid_source, accounts) 
    37893790 
    37903791                # Contact drop on group row or between two contacts