frontends: fixes bug with private message introduced with revision 1000 (6f1e03068b5f) + display messages from contacts not in roster
This commit is contained in:
parent
2afa53f755
commit
f09fb76752
1 changed files with 49 additions and 30 deletions
|
|
@ -236,30 +236,36 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
def replace(self, jid, groups=None, attributes=None):
|
||||
"""Add a contact to the list if doesn't exist, else update it.
|
||||
|
||||
This method can be called with groups=None for the purpose of updating
|
||||
the contact's attributes (e.g. nickname). In that case, the groups
|
||||
attribute must not be set to the default group but ignored. If not,
|
||||
you may move your contact from its actual group(s) to the default one.
|
||||
|
||||
None value for 'groups' has a different meaning than [None] which is for the default group.
|
||||
|
||||
@param jid (JID)
|
||||
@param groups (list): list of groups or None to ignore the groups membership.
|
||||
@param attributes (dict)
|
||||
|
||||
XXX: None value for 'groups' has a different meaning than [None] which is for the default group.
|
||||
"""
|
||||
QuickContactList.replace(self, jid, groups, attributes)
|
||||
QuickContactList.replace(self, jid, groups, attributes) # eventually change the nickname
|
||||
if jid.bare in self.specials:
|
||||
return
|
||||
if not attributes:
|
||||
attributes = {}
|
||||
if groups is None:
|
||||
self.update()
|
||||
return
|
||||
assert isinstance(jid, JID)
|
||||
if groups is not None:
|
||||
if not groups:
|
||||
groups = [None]
|
||||
for group in [group for group in self.groups if group not in groups]:
|
||||
try: # remove the contact from a previous group
|
||||
self.groups[group][1].remove(jid.bare)
|
||||
except KeyError:
|
||||
pass
|
||||
for group in groups:
|
||||
if group not in self.groups:
|
||||
self.groups[group] = [True, set()] # [unfold, list_of_contacts]
|
||||
self.groups[group][1].add(jid.bare)
|
||||
assert isinstance(groups, list)
|
||||
if groups == []:
|
||||
groups = [None] # [None] is the default group
|
||||
for group in [group for group in self.groups if group not in groups]:
|
||||
try: # remove the contact from a previous group
|
||||
self.groups[group][1].remove(jid.bare)
|
||||
except KeyError:
|
||||
pass
|
||||
for group in groups:
|
||||
if group not in self.groups:
|
||||
self.groups[group] = [True, set()] # [unfold, list_of_contacts]
|
||||
self.groups[group][1].add(jid.bare)
|
||||
self.update()
|
||||
|
||||
def remove(self, jid):
|
||||
|
|
@ -278,7 +284,7 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
|
||||
def add(self, jid, param_groups=None):
|
||||
"""add a contact to the list"""
|
||||
self.replace(jid, param_groups)
|
||||
self.replace(jid, param_groups if param_groups else [None])
|
||||
|
||||
def setSpecial(self, special_jid, special_type, show=False):
|
||||
"""Set entity as a special
|
||||
|
|
|
|||
Loading…
Reference in a new issue