comparison frontends/src/quick_frontend/quick_chat.py @ 2057:a52a6ed7d48f

quick frontend (chat): added helping properties avatar and contact_list
author Goffi <goffi@goffi.org>
date Mon, 29 Aug 2016 01:21:47 +0200
parents ed33cd382bf9
children 8fa0d95c2142
comparison
equal deleted inserted replaced
2056:7bfa97e533ac 2057:a52a6ed7d48f
113 # if the message was sent before today, we print the full date 113 # if the message was sent before today, we print the full date
114 timestamp = time.localtime(self.timestamp) 114 timestamp = time.localtime(self.timestamp)
115 time_format = u"%c" if timestamp < self.parent.day_change else u"%H:%M" 115 time_format = u"%c" if timestamp < self.parent.day_change else u"%H:%M"
116 return time.strftime(time_format, timestamp).decode(getlocale()[1]) 116 return time.strftime(time_format, timestamp).decode(getlocale()[1])
117 117
118 @property
119 def avatar(self):
120 contact_list = self.host.contact_lists[self.profile]
121 return contact_list.getCache(self.from_jid, "avatar") or self.host.getDefaultAvatar(self.from_jid)
122
118 def getNick(self, entity): 123 def getNick(self, entity):
119 """Return nick of an entity when possible""" 124 """Return nick of an entity when possible"""
120 contact_list = self.host.contact_lists[self.profile] 125 contact_list = self.host.contact_lists[self.profile]
121 if self.type == C.MESS_TYPE_INFO and self.info_type in ROOM_USER_MOVED: 126 if self.type == C.MESS_TYPE_INFO and self.info_type in ROOM_USER_MOVED:
122 try: 127 try:
239 """ 244 """
240 self.historyPrint(profile=self.profile) 245 self.historyPrint(profile=self.profile)
241 if self.subject is not None: 246 if self.subject is not None:
242 self.setSubject(self.subject) 247 self.setSubject(self.subject)
243 248
249 @property
250 def contact_list(self):
251 return self.host.contact_lists[self.profile]
252
244 ## Widget management ## 253 ## Widget management ##
245 254
246 def __str__(self): 255 def __str__(self):
247 return u"Chat Widget [target: {}, type: {}, profile: {}]".format(self.target, self.type, self.profile) 256 return u"Chat Widget [target: {}, type: {}, profile: {}]".format(self.target, self.type, self.profile)
248 257