Mercurial > libervia-backend
comparison frontends/src/primitivus/contact_list.py @ 1058:0a9986452bba
frontends: fixes bug with private message introduced with revision 1000 (6f1e03068b5f) + display messages from contacts not in roster
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 29 May 2014 14:34:01 +0200 |
parents | 6f1e03068b5f |
children | 75025461141f |
comparison
equal
deleted
inserted
replaced
1057:7ea0215e7092 | 1058:0a9986452bba |
---|---|
234 self.update() | 234 self.update() |
235 | 235 |
236 def replace(self, jid, groups=None, attributes=None): | 236 def replace(self, jid, groups=None, attributes=None): |
237 """Add a contact to the list if doesn't exist, else update it. | 237 """Add a contact to the list if doesn't exist, else update it. |
238 | 238 |
239 This method can be called with groups=None for the purpose of updating | |
240 the contact's attributes (e.g. nickname). In that case, the groups | |
241 attribute must not be set to the default group but ignored. If not, | |
242 you may move your contact from its actual group(s) to the default one. | |
243 | |
244 None value for 'groups' has a different meaning than [None] which is for the default group. | |
245 | |
239 @param jid (JID) | 246 @param jid (JID) |
240 @param groups (list): list of groups or None to ignore the groups membership. | 247 @param groups (list): list of groups or None to ignore the groups membership. |
241 @param attributes (dict) | 248 @param attributes (dict) |
242 | |
243 XXX: None value for 'groups' has a different meaning than [None] which is for the default group. | |
244 """ | 249 """ |
245 QuickContactList.replace(self, jid, groups, attributes) | 250 QuickContactList.replace(self, jid, groups, attributes) # eventually change the nickname |
246 if jid.bare in self.specials: | 251 if jid.bare in self.specials: |
247 return | 252 return |
248 if not attributes: | 253 if groups is None: |
249 attributes = {} | 254 self.update() |
255 return | |
250 assert isinstance(jid, JID) | 256 assert isinstance(jid, JID) |
251 if groups is not None: | 257 assert isinstance(groups, list) |
252 if not groups: | 258 if groups == []: |
253 groups = [None] | 259 groups = [None] # [None] is the default group |
254 for group in [group for group in self.groups if group not in groups]: | 260 for group in [group for group in self.groups if group not in groups]: |
255 try: # remove the contact from a previous group | 261 try: # remove the contact from a previous group |
256 self.groups[group][1].remove(jid.bare) | 262 self.groups[group][1].remove(jid.bare) |
257 except KeyError: | 263 except KeyError: |
258 pass | 264 pass |
259 for group in groups: | 265 for group in groups: |
260 if group not in self.groups: | 266 if group not in self.groups: |
261 self.groups[group] = [True, set()] # [unfold, list_of_contacts] | 267 self.groups[group] = [True, set()] # [unfold, list_of_contacts] |
262 self.groups[group][1].add(jid.bare) | 268 self.groups[group][1].add(jid.bare) |
263 self.update() | 269 self.update() |
264 | 270 |
265 def remove(self, jid): | 271 def remove(self, jid): |
266 """remove a contact from the list""" | 272 """remove a contact from the list""" |
267 QuickContactList.remove(self, jid) | 273 QuickContactList.remove(self, jid) |
276 del self.groups[group] | 282 del self.groups[group] |
277 self.update() | 283 self.update() |
278 | 284 |
279 def add(self, jid, param_groups=None): | 285 def add(self, jid, param_groups=None): |
280 """add a contact to the list""" | 286 """add a contact to the list""" |
281 self.replace(jid, param_groups) | 287 self.replace(jid, param_groups if param_groups else [None]) |
282 | 288 |
283 def setSpecial(self, special_jid, special_type, show=False): | 289 def setSpecial(self, special_jid, special_type, show=False): |
284 """Set entity as a special | 290 """Set entity as a special |
285 @param special_jid: jid of the entity | 291 @param special_jid: jid of the entity |
286 @param special_type: special type (e.g.: "MUC") | 292 @param special_type: special type (e.g.: "MUC") |