Mercurial > libervia-backend
comparison frontends/src/quick_frontend/quick_contact_list.py @ 2122:3970ebcf8830
quick frontend (contact list): bare_default in getCache now default to True, plus added None:
if None is used, bare_default will be used only if the entity is not in a room
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 15 Jan 2017 16:00:41 +0100 |
parents | df5cb9e7d0b7 |
children | c42aab22c2c0 |
comparison
equal
deleted
inserted
replaced
2121:df5cb9e7d0b7 | 2122:3970ebcf8830 |
---|---|
202 self.host.bridge.getContacts(self.profile, callback=self._gotContacts) | 202 self.host.bridge.getContacts(self.profile, callback=self._gotContacts) |
203 | 203 |
204 def fill(self): | 204 def fill(self): |
205 handler.fill(self.profile) | 205 handler.fill(self.profile) |
206 | 206 |
207 def getCache(self, entity, name=None, bare_default=False): | 207 def getCache(self, entity, name=None, bare_default=True): |
208 """Return a cache value for a contact | 208 """Return a cache value for a contact |
209 | 209 |
210 @param entity(jid.JID): entity of the contact from who we want data (resource is used if given) | 210 @param entity(jid.JID): entity of the contact from who we want data (resource is used if given) |
211 if a resource specific information is requested: | 211 if a resource specific information is requested: |
212 - if no resource is given (bare jid), the main resource is used, according to priority | 212 - if no resource is given (bare jid), the main resource is used, according to priority |
213 - if resource is given, it is used | 213 - if resource is given, it is used |
214 @param name(unicode): name the data to get, or None to get everything | 214 @param name(unicode): name the data to get, or None to get everything |
215 @param bare_default(bool): if True and entity is a full jid, the value of bare jid | 215 @param bare_default(bool, None): if True and entity is a full jid, the value of bare jid |
216 will be returned if not value is found for the requested resource. | 216 will be returned if not value is found for the requested resource. |
217 If False, None is returned if no value is found for the requested resource. | 217 If False, None is returned if no value is found for the requested resource. |
218 If None, bare_default will be set to False if entity is in a room, True else | |
218 @return: full cache if no name is given, or value of "name", or None | 219 @return: full cache if no name is given, or value of "name", or None |
219 """ | 220 """ |
220 # FIXME: resource handling need to be reworked | 221 # FIXME: resource handling need to be reworked |
221 try: | 222 try: |
222 cache = self._cache[entity.bare] | 223 cache = self._cache[entity.bare] |
245 | 246 |
246 elif entity.resource: | 247 elif entity.resource: |
247 try: | 248 try: |
248 return cache[C.CONTACT_RESOURCES][entity.resource][name] | 249 return cache[C.CONTACT_RESOURCES][entity.resource][name] |
249 except KeyError: | 250 except KeyError: |
251 if bare_default is None: | |
252 bare_default = not self.isRoom(entity.bare) | |
250 if not bare_default: | 253 if not bare_default: |
251 return None | 254 return None |
252 | 255 |
253 try: | 256 try: |
254 return cache[name] | 257 return cache[name] |