Changeset 9883

Show
Ignore:
Timestamp:
07/04/08 23:29:46 (5 months ago)
Author:
steve-e
Message:

Count metacontacts only once.

Remove timing information for roster drawing.

Location:
trunk/src
Files:
2 modified

Legend:

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

    r9879 r9883  
    324324                                        continue 
    325325                                if common.gajim.jid_is_transport(jid) and not \ 
    326                                         _('Transports') in groups: 
     326                                _('Transports') in groups: 
    327327                                        # do not count transports 
     328                                        continue 
     329                                if self.has_brother(account, jid) and not \ 
     330                                self.is_big_brother(account, jid): 
     331                                        # count metacontacts only once 
    328332                                        continue 
    329333                                contact = self.get_contact_with_highest_priority(account, jid) 
     
    356360        def get_metacontacts_tag(self, account, jid): 
    357361                '''Returns the tag of a jid''' 
    358                 if not self._metacontacts_tags.has_key(account): 
     362                if not account in self._metacontacts_tags: 
    359363                        return None 
    360364                for tag in self._metacontacts_tags[account]: 
     
    400404 
    401405        def has_brother(self, account, jid): 
    402                 for account in self._metacontacts_tags: 
    403                         tag = self.get_metacontacts_tag(account, jid) 
    404                         if tag and len(self._metacontacts_tags[account][tag]) > 1: 
    405                                 return True 
    406                 return False 
     406                tag = self.get_metacontacts_tag(account, jid) 
     407                if not tag: 
     408                        return False 
     409                meta_jids = self.get_metacontacts_jids(tag) 
     410                return len(meta_jids) > 1 or len(meta_jids[account]) > 1 
    407411 
    408412        def is_big_brother(self, account, jid): 
    409                 tag = self.get_metacontacts_tag(account, jid) 
    410                 if tag: 
    411                         family = self.get_metacontacts_family(account, jid) 
     413                family = self.get_metacontacts_family(account, jid) 
     414                if family: 
    412415                        bb_data = self.get_metacontacts_big_brother(family) 
    413                         bb_jid = bb_data['jid'] 
    414                         bb_account = bb_data['account'] 
    415                         if bb_jid == jid and bb_account == account:  
     416                        if bb_data['jid'] == jid and bb_data['account'] == account:  
    416417                                return True 
    417418                return False 
     
    421422                answers = {} 
    422423                for account in self._metacontacts_tags: 
    423                         if self._metacontacts_tags[account].has_key(tag): 
     424                        if tag in self._metacontacts_tags[account]: 
    424425                                answers[account] = [] 
    425426                                for data in self._metacontacts_tags[account][tag]: 
     
    436437                answers = [] 
    437438                for account in self._metacontacts_tags: 
    438                         if self._metacontacts_tags[account].has_key(tag): 
     439                        if tag in self._metacontacts_tags[account]: 
    439440                                for data in self._metacontacts_tags[account][tag]: 
    440441                                        data['account'] = account 
  • trunk/src/roster_window.py

    r9875 r9883  
    286286                draw them and account. 
    287287                ''' 
    288                 c1 = time.clock() 
    289288                self.starting = True 
    290289                jids = gajim.contacts.get_jid_list(account) 
    291290 
    292291                self.tree.freeze_child_notify() 
    293                 c5 = time.clock() 
    294292                for jid in jids: 
    295293                        self.add_contact(jid, account) 
    296                 c6 = time.clock() 
    297294                self.tree.thaw_child_notify() 
    298295 
     
    302299                        self._idle_draw_jids_of_account(jids, account) 
    303300 
    304                 c9 = time.clock() 
    305301                # Draw all known groups 
    306302                for group in gajim.groups[account].keys(): 
     
    308304                self.draw_account(account) 
    309305                self.starting = False 
    310                 c10 = time.clock() 
    311  
    312                 if jids: 
    313                         c4 = time.clock() 
    314  
    315                         print "" 
    316                         print "--- Add account contacts of %s ---------" % account 
    317                         print "Total Time", c4-c1 
    318                         print "Add contact without draw", c6-c5 
    319                         print "Draw groups and account", c10-c9 
    320                         print "--- contacts added -----------------------------" 
    321                         print "" 
    322306 
    323307 
     
    480464 
    481465                        assert len(self._get_contact_iter(_jid, _account, _contact, self.model) 
    482                                 ) == 0, "%s already in roster. \n Family: " % (_jid, nearby_family) 
     466                                ) == 0, "%s already in roster. \n Family: %s" % (_jid, nearby_family) 
    483467                        self._add_entity(_contact, _account, big_brother_contact = \ 
    484468                                big_brother_contact, big_brother_account=big_brother_account) 
     
    11531137                account -- the corresponding account 
    11541138                ''' 
    1155                 def _draw_all_contacts(jids, account, t): 
     1139                def _draw_all_contacts(jids, account): 
    11561140                        for jid in jids: 
    11571141                                self.draw_contact(jid, account) 
    11581142                                self.draw_avatar(jid, account) 
    11591143                                yield True 
    1160                         print "--- Idle draw of %s -----------" % account 
    1161                         print "Draw contact and avatar", time.clock() - t 
    1162                         print "-------------------------------" 
    11631144                        yield False 
    11641145 
    1165                 t = time.clock() 
    1166                 task = _draw_all_contacts(jids, account, t) 
     1146                task = _draw_all_contacts(jids, account) 
    11671147                gobject.idle_add(task.next) 
    11681148