Mercurial > libervia-backend
comparison frontends/src/primitivus/contact_list.py @ 1000:6f1e03068b5f
primitivus: fixes contact group update
author | souliane <souliane@mailoo.org> |
---|---|
date | Sun, 27 Apr 2014 18:22:12 +0200 |
parents | b12706d164d7 |
children | 0a9986452bba |
comparison
equal
deleted
inserted
replaced
999:c37a24922f27 | 1000:6f1e03068b5f |
---|---|
232 self.selected = None | 232 self.selected = None |
233 self.unselectAll() | 233 self.unselectAll() |
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 | |
239 @param jid (JID) | |
240 @param groups (list): list of groups or None to ignore the groups membership. | |
241 @param attributes (dict) | |
242 | |
243 XXX: None value for 'groups' has a different meaning than [None] which is for the default group. | |
244 """ | |
238 QuickContactList.replace(self, jid, groups, attributes) | 245 QuickContactList.replace(self, jid, groups, attributes) |
239 if jid.bare in self.specials: | 246 if jid.bare in self.specials: |
240 return | 247 return |
241 if not groups: | |
242 groups = [None] | |
243 if not attributes: | 248 if not attributes: |
244 attributes={} | 249 attributes = {} |
245 assert isinstance(groups, list) | |
246 assert isinstance(jid, JID) | 250 assert isinstance(jid, JID) |
247 for group in groups: | 251 if groups is not None: |
248 if not self.groups.has_key(group): | 252 if not groups: |
249 self.groups[group] = [True,set()] #[unfold,list_of_contacts] | 253 groups = [None] |
250 self.groups[group][1].add(jid.bare) | 254 for group in [group for group in self.groups if group not in groups]: |
255 try: # remove the contact from a previous group | |
256 self.groups[group][1].remove(jid.bare) | |
257 except KeyError: | |
258 pass | |
259 for group in groups: | |
260 if group not in self.groups: | |
261 self.groups[group] = [True, set()] # [unfold, list_of_contacts] | |
262 self.groups[group][1].add(jid.bare) | |
251 self.update() | 263 self.update() |
252 | 264 |
253 def remove(self, jid): | 265 def remove(self, jid): |
254 """remove a contact from the list""" | 266 """remove a contact from the list""" |
255 QuickContactList.remove(self, jid) | 267 QuickContactList.remove(self, jid) |
262 groups_to_remove.append(group) | 274 groups_to_remove.append(group) |
263 for group in groups_to_remove: | 275 for group in groups_to_remove: |
264 del self.groups[group] | 276 del self.groups[group] |
265 self.update() | 277 self.update() |
266 | 278 |
267 def add(self, jid, param_groups=[None]): | 279 def add(self, jid, param_groups=None): |
268 """add a contact to the list""" | 280 """add a contact to the list""" |
269 self.replace(jid,param_groups) | 281 self.replace(jid, param_groups) |
270 | 282 |
271 def setSpecial(self, special_jid, special_type, show=False): | 283 def setSpecial(self, special_jid, special_type, show=False): |
272 """Set entity as a special | 284 """Set entity as a special |
273 @param special_jid: jid of the entity | 285 @param special_jid: jid of the entity |
274 @param special_type: special type (e.g.: "MUC") | 286 @param special_type: special type (e.g.: "MUC") |