quick frontend (chat): added helping properties avatar and contact_list

This commit is contained in:
Goffi 2016-08-29 01:21:47 +02:00
commit 619f892de0

View file

@ -115,6 +115,11 @@ class Message(object):
time_format = u"%c" if timestamp < self.parent.day_change else u"%H:%M"
return time.strftime(time_format, timestamp).decode(getlocale()[1])
@property
def avatar(self):
contact_list = self.host.contact_lists[self.profile]
return contact_list.getCache(self.from_jid, "avatar") or self.host.getDefaultAvatar(self.from_jid)
def getNick(self, entity):
"""Return nick of an entity when possible"""
contact_list = self.host.contact_lists[self.profile]
@ -241,6 +246,10 @@ class QuickChat(quick_widgets.QuickWidget):
if self.subject is not None:
self.setSubject(self.subject)
@property
def contact_list(self):
return self.host.contact_lists[self.profile]
## Widget management ##
def __str__(self):