quich frontend, primivius (chat): better avatar handling:

- new getAvatar method in QuickApp which request vCard if avatar if needed and return default avatar is no avatar is found
    - frontends based on quick frontend can now specify if they handle avatar or not using AVATARS_HANDLER
    - when avatar is updated, occupant widget(s) and all message widget(s) of the concerned entity are updated
This commit is contained in:
Goffi 2016-09-09 23:54:33 +02:00
commit 78750cb265

View file

@ -186,7 +186,8 @@ class ProfilesManager(object):
class QuickApp(object):
"""This class contain the main methods needed for the frontend"""
MB_HANDLE = True # Set to false if the frontend doesn't manage microblog
MB_HANDLER = True # Set to False if the frontend doesn't manage microblog
AVATARS_HANDLER = True # set to False if avatars are not used
def __init__(self, create_bridge, xmlui, check_options=None):
"""Create a frontend application
@ -670,7 +671,7 @@ class QuickApp(object):
"""
service_s = jid.JID(service_s)
if category == C.PS_MICROBLOG and self.MB_HANDLE:
if category == C.PS_MICROBLOG and self.MB_HANDLER:
if event_type == C.PS_PUBLISH:
if not 'content' in data:
log.warning("No content found in microblog data")
@ -831,6 +832,17 @@ class QuickApp(object):
self.bridge.launchAction(callback_id, data, profile, callback=action_cb, errback=self.dialogFailure)
def getAvatar(self, entity, profile):
"""return avatar path for an entity"""
contact_list = self.contact_lists[profile]
avatar = contact_list.getCache(entity, "avatar")
if avatar is None:
self.bridge.getCard(unicode(entity), profile)
contact_list.setCache(entity, "avatar", "")
if not avatar:
avatar = self.getDefaultAvatar(entity)
return avatar
def getDefaultAvatar(self, entity=None):
"""return default avatar to use with given entity