def roster_updated(self, item=None): with traceguard: roster = self.roster from util.primitives.structures import oset with self.root_group.frozen(): jcontact = self.contact_class buddies = self.buddies root_group = self.root_group del root_group[:] groups = odict({None: self.root_group}) # for item in roster: #roster groups i_groups = oset(filter(None, item.groups)) #profile group p_groups = oset( filter(None, (profile.get_contact_info( self.buddies[item.jid], 'group'), ))) #plus default group group = (p_groups | i_groups | oset([None]))[0] #CAS: optimize this to not create a group every time. g = groups.setdefault(group, Group(group, self, group)) contact = jcontact(self.buddies[item.jid](item), group) g.append(contact) for _gid, g in groups.iteritems(): if not self.filter_group(g): if g is not root_group: root_group.append(g) g[:] = [c for c in g if not self.filter_contact(c)]
def roster_updated(self, item=None): with traceguard: roster = self.roster from util.primitives.structures import oset with self.root_group.frozen(): jcontact = self.contact_class buddies = self.buddies root_group = self.root_group del root_group[:] groups = odict({None: self.root_group}) # for item in roster: #roster groups i_groups = oset(filter(None, item.groups)) #profile group p_groups = oset(filter(None, (profile.get_contact_info(self.buddies[item.jid], 'group'),))) #plus default group group = (p_groups | i_groups | oset([None]))[0] #CAS: optimize this to not create a group every time. g = groups.setdefault(group, Group(group, self, group)) contact = jcontact(self.buddies[item.jid](item), group) g.append(contact) for _gid, g in groups.iteritems(): if not self.filter_group(g): if g is not root_group: root_group.append(g) g[:] = [c for c in g if not self.filter_contact(c)]
def alias(self): a = profile.get_contact_info(self, 'alias') if a: return a a = getattr(self, 'local_alias', None) if a: return a a = getattr(self, 'remote_alias', None) if a: return a return self.name
def alias(self): a = profile.get_contact_info(self, 'alias') if a: return a for attr in ('local_alias', 'remote_alias', 'nice_name'): try: a = getattr(self, attr, None) except Exception: traceback.print_exc() continue if a: return a return self.name
def find_alias_suggestion(self): 'Returns a suggestion for the alias for this metacontact.' if self.metacontact: # Is this already a metacontact? If so, it already has an alias: # use that. return self.metacontact.alias # Otherwise use the first available alias. for contact in self.contacts: a = profile.get_contact_info(contact, 'alias') if a: return a # No suggestion. return ''
def get_alias(self): # overridden from Buddy.alias property to show nice_name val = None a = profile.get_contact_info(self, 'alias') if a and a.strip(): val = a else: for attr in ('local_alias', 'remote_alias', '_friendly_name', 'nice_name'): val = getattr(self, attr, None) if val: break else: val = self.name return val.decode('fuzzy utf-8')