comparison frontends/src/quick_frontend/quick_contact_list.py @ 510:886754295efe

quick frontend, primitivus, wix: MUC private messages management /!\ not fully finished, backend part is not done yet /!\ - as resources are discarded to manage chat windows lists, a pretty dirty hack is done to work around this: full jid is escaped using a prefix (it becomes invalid and resource is preserved). - new quick_utils module, with helper methods. escapePrivate and unescapePrivate implementations - MUC private messages are not managed in Wix yet
author Goffi <goffi@goffi.org>
date Thu, 11 Oct 2012 00:48:35 +0200
parents 65ecbb473cbb
children a7f53e778d8e
comparison
equal deleted inserted replaced
509:64ff046dc201 510:886754295efe
26 """This class manage the visual representation of contacts""" 26 """This class manage the visual representation of contacts"""
27 27
28 def __init__(self): 28 def __init__(self):
29 debug(_("Contact List init")) 29 debug(_("Contact List init"))
30 self._cache = {} 30 self._cache = {}
31 self.specials={}
31 32
32 def update_jid(self, jid): 33 def update_jid(self, jid):
33 """Update the jid in the list when something changed""" 34 """Update the jid in the list when something changed"""
34 raise NotImplementedError 35 raise NotImplementedError
35 36
49 def __contains__(self, jid): 50 def __contains__(self, jid):
50 raise NotImplementedError 51 raise NotImplementedError
51 52
52 def clearContacts(self, jid): 53 def clearContacts(self, jid):
53 """Clear all the contact list""" 54 """Clear all the contact list"""
54 raise NotImplementedError 55 self.specials.clear()
55 56
56 def _replace(self, jid, groups=None, attributes=None): 57 def replace(self, jid, groups=None, attributes=None):
58 """add a contact to the list if doesn't exist, else update it"""
57 if attributes and 'name' in attributes: 59 if attributes and 'name' in attributes:
58 self.setCache(jid, 'name', attributes['name']) 60 self.setCache(jid, 'name', attributes['name'])
59 self.replace(jid, groups, attributes)
60
61 def replace(self, jid, groups, attributes):
62 """add a contact to the list if doesn't exist, else update it"""
63 raise NotImplementedError
64 61
65 def remove(self, jid): 62 def remove(self, jid):
66 """remove a contact from the list""" 63 """remove a contact from the list"""
67 raise NotImplementedError 64 try:
65 del self.specials[jid.short]
66 except KeyError:
67 pass
68 68
69 def add(self, jid, param_groups=None): 69 def add(self, jid, param_groups=None):
70 """add a contact to the list""" 70 """add a contact to the list"""
71 raise NotImplementedError 71 raise NotImplementedError
72
73 def getSpecial(self, jid):
74 """Return special type of jid, or None if it's not special"""
75 return self.specials.get(jid.short)
72 76
73 def setSpecial(self, jid, _type): 77 def setSpecial(self, jid, _type):
74 """Set entity as a special 78 """Set entity as a special
75 @param jid: jid of the entity 79 @param jid: jid of the entity
76 @param _type: special type (e.g.: "MUC") 80 @param _type: special type (e.g.: "MUC")
77 """ 81 """
78 raise NotImplementedError 82 self.specials[jid.short] = _type
79 83
80 def updatePresence(self, jid, show, priority, statuses): 84 def updatePresence(self, jid, show, priority, statuses):
81 """Update entity's presence status 85 """Update entity's presence status
82 @param jid: entity to update's jid 86 @param jid: entity to update's jid
83 @param show: availability 87 @param show: availability