Count metacontacts only once.
Remove timing information for roster drawing.
This commit is contained in:
parent
2a40072a24
commit
215fdc964a
2 changed files with 19 additions and 38 deletions
|
@ -323,9 +323,13 @@ class Contacts:
|
||||||
if jid == our_jid:
|
if jid == our_jid:
|
||||||
continue
|
continue
|
||||||
if common.gajim.jid_is_transport(jid) and not \
|
if common.gajim.jid_is_transport(jid) and not \
|
||||||
_('Transports') in groups:
|
_('Transports') in groups:
|
||||||
# do not count transports
|
# do not count transports
|
||||||
continue
|
continue
|
||||||
|
if self.has_brother(account, jid) and not \
|
||||||
|
self.is_big_brother(account, jid):
|
||||||
|
# count metacontacts only once
|
||||||
|
continue
|
||||||
contact = self.get_contact_with_highest_priority(account, jid)
|
contact = self.get_contact_with_highest_priority(account, jid)
|
||||||
if _('Not in roster') in contact.groups:
|
if _('Not in roster') in contact.groups:
|
||||||
continue
|
continue
|
||||||
|
@ -355,7 +359,7 @@ class Contacts:
|
||||||
|
|
||||||
def get_metacontacts_tag(self, account, jid):
|
def get_metacontacts_tag(self, account, jid):
|
||||||
'''Returns the tag of a jid'''
|
'''Returns the tag of a jid'''
|
||||||
if not self._metacontacts_tags.has_key(account):
|
if not account in self._metacontacts_tags:
|
||||||
return None
|
return None
|
||||||
for tag in self._metacontacts_tags[account]:
|
for tag in self._metacontacts_tags[account]:
|
||||||
for data in self._metacontacts_tags[account][tag]:
|
for data in self._metacontacts_tags[account][tag]:
|
||||||
|
@ -399,20 +403,17 @@ class Contacts:
|
||||||
break
|
break
|
||||||
|
|
||||||
def has_brother(self, account, jid):
|
def has_brother(self, account, jid):
|
||||||
for account in self._metacontacts_tags:
|
tag = self.get_metacontacts_tag(account, jid)
|
||||||
tag = self.get_metacontacts_tag(account, jid)
|
if not tag:
|
||||||
if tag and len(self._metacontacts_tags[account][tag]) > 1:
|
return False
|
||||||
return True
|
meta_jids = self.get_metacontacts_jids(tag)
|
||||||
return False
|
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):
|
||||||
tag = self.get_metacontacts_tag(account, jid)
|
family = self.get_metacontacts_family(account, jid)
|
||||||
if tag:
|
if family:
|
||||||
family = self.get_metacontacts_family(account, jid)
|
|
||||||
bb_data = self.get_metacontacts_big_brother(family)
|
bb_data = self.get_metacontacts_big_brother(family)
|
||||||
bb_jid = bb_data['jid']
|
if bb_data['jid'] == jid and bb_data['account'] == account:
|
||||||
bb_account = bb_data['account']
|
|
||||||
if bb_jid == jid and bb_account == account:
|
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -420,7 +421,7 @@ class Contacts:
|
||||||
'''Returns all jid for the given tag in the form {acct: [jid1, jid2],.}'''
|
'''Returns all jid for the given tag in the form {acct: [jid1, jid2],.}'''
|
||||||
answers = {}
|
answers = {}
|
||||||
for account in self._metacontacts_tags:
|
for account in self._metacontacts_tags:
|
||||||
if self._metacontacts_tags[account].has_key(tag):
|
if tag in self._metacontacts_tags[account]:
|
||||||
answers[account] = []
|
answers[account] = []
|
||||||
for data in self._metacontacts_tags[account][tag]:
|
for data in self._metacontacts_tags[account][tag]:
|
||||||
answers[account].append(data['jid'])
|
answers[account].append(data['jid'])
|
||||||
|
@ -435,7 +436,7 @@ class Contacts:
|
||||||
return []
|
return []
|
||||||
answers = []
|
answers = []
|
||||||
for account in self._metacontacts_tags:
|
for account in self._metacontacts_tags:
|
||||||
if self._metacontacts_tags[account].has_key(tag):
|
if tag in self._metacontacts_tags[account]:
|
||||||
for data in self._metacontacts_tags[account][tag]:
|
for data in self._metacontacts_tags[account][tag]:
|
||||||
data['account'] = account
|
data['account'] = account
|
||||||
answers.append(data)
|
answers.append(data)
|
||||||
|
|
|
@ -285,15 +285,12 @@ class RosterWindow:
|
||||||
'''Add all contacts and groups of the given account to roster,
|
'''Add all contacts and groups of the given account to roster,
|
||||||
draw them and account.
|
draw them and account.
|
||||||
'''
|
'''
|
||||||
c1 = time.clock()
|
|
||||||
self.starting = True
|
self.starting = True
|
||||||
jids = gajim.contacts.get_jid_list(account)
|
jids = gajim.contacts.get_jid_list(account)
|
||||||
|
|
||||||
self.tree.freeze_child_notify()
|
self.tree.freeze_child_notify()
|
||||||
c5 = time.clock()
|
|
||||||
for jid in jids:
|
for jid in jids:
|
||||||
self.add_contact(jid, account)
|
self.add_contact(jid, account)
|
||||||
c6 = time.clock()
|
|
||||||
self.tree.thaw_child_notify()
|
self.tree.thaw_child_notify()
|
||||||
|
|
||||||
# Do not freeze the GUI when drawing the contacts
|
# Do not freeze the GUI when drawing the contacts
|
||||||
|
@ -301,24 +298,11 @@ class RosterWindow:
|
||||||
# Overhead is big, only invoke when needed
|
# Overhead is big, only invoke when needed
|
||||||
self._idle_draw_jids_of_account(jids, account)
|
self._idle_draw_jids_of_account(jids, account)
|
||||||
|
|
||||||
c9 = time.clock()
|
|
||||||
# Draw all known groups
|
# Draw all known groups
|
||||||
for group in gajim.groups[account].keys():
|
for group in gajim.groups[account].keys():
|
||||||
self.draw_group(group, account)
|
self.draw_group(group, account)
|
||||||
self.draw_account(account)
|
self.draw_account(account)
|
||||||
self.starting = False
|
self.starting = False
|
||||||
c10 = time.clock()
|
|
||||||
|
|
||||||
if jids:
|
|
||||||
c4 = time.clock()
|
|
||||||
|
|
||||||
print ""
|
|
||||||
print "--- Add account contacts of %s ---------" % account
|
|
||||||
print "Total Time", c4-c1
|
|
||||||
print "Add contact without draw", c6-c5
|
|
||||||
print "Draw groups and account", c10-c9
|
|
||||||
print "--- contacts added -----------------------------"
|
|
||||||
print ""
|
|
||||||
|
|
||||||
|
|
||||||
def _add_entity(self, contact, account, groups = None,
|
def _add_entity(self, contact, account, groups = None,
|
||||||
|
@ -479,7 +463,7 @@ class RosterWindow:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
assert len(self._get_contact_iter(_jid, _account, _contact, self.model)
|
assert len(self._get_contact_iter(_jid, _account, _contact, self.model)
|
||||||
) == 0, "%s already in roster. \n Family: " % (_jid, nearby_family)
|
) == 0, "%s already in roster. \n Family: %s" % (_jid, nearby_family)
|
||||||
self._add_entity(_contact, _account, big_brother_contact = \
|
self._add_entity(_contact, _account, big_brother_contact = \
|
||||||
big_brother_contact, big_brother_account=big_brother_account)
|
big_brother_contact, big_brother_account=big_brother_account)
|
||||||
brothers.append((_contact, _account))
|
brothers.append((_contact, _account))
|
||||||
|
@ -1152,18 +1136,14 @@ class RosterWindow:
|
||||||
jids -- a list of jids to draw
|
jids -- a list of jids to draw
|
||||||
account -- the corresponding account
|
account -- the corresponding account
|
||||||
'''
|
'''
|
||||||
def _draw_all_contacts(jids, account, t):
|
def _draw_all_contacts(jids, account):
|
||||||
for jid in jids:
|
for jid in jids:
|
||||||
self.draw_contact(jid, account)
|
self.draw_contact(jid, account)
|
||||||
self.draw_avatar(jid, account)
|
self.draw_avatar(jid, account)
|
||||||
yield True
|
yield True
|
||||||
print "--- Idle draw of %s -----------" % account
|
|
||||||
print "Draw contact and avatar", time.clock() - t
|
|
||||||
print "-------------------------------"
|
|
||||||
yield False
|
yield False
|
||||||
|
|
||||||
t = time.clock()
|
task = _draw_all_contacts(jids, account)
|
||||||
task = _draw_all_contacts(jids, account, t)
|
|
||||||
gobject.idle_add(task.next)
|
gobject.idle_add(task.next)
|
||||||
|
|
||||||
def setup_and_draw_roster(self):
|
def setup_and_draw_roster(self):
|
||||||
|
|
Loading…
Add table
Reference in a new issue