comparison libervia.py @ 202:2bc6cf004e61

browser, server: comments handling: - banner in unibar show a specific message when the message will be a comment - comments are inserted in a subpanel, in chronological order
author Goffi <goffi@goffi.org>
date Thu, 20 Jun 2013 12:16:46 +0200
parents 0f5c2f799913
children 5fdea93b2541
comparison
equal deleted inserted replaced
201:aa76793da353 202:2bc6cf004e61
81 ["isRegistered","isConnected","connect"]) 81 ["isRegistered","isConnected","connect"])
82 82
83 class BridgeCall(LiberviaJsonProxy): 83 class BridgeCall(LiberviaJsonProxy):
84 def __init__(self): 84 def __init__(self):
85 LiberviaJsonProxy.__init__(self, "/json_api", 85 LiberviaJsonProxy.__init__(self, "/json_api",
86 ["getContacts", "addContact", "sendMessage", "sendMblog", "getLastMblogs", "getMassiveLastMblogs", "getProfileJid", "getHistory", "getPresenceStatus", 86 ["getContacts", "addContact", "sendMessage", "sendMblog", "sendMblogComment", "getLastMblogs", "getMassiveLastMblogs", "getMblogComments", "getProfileJid", "getHistory", "getPresenceStatus",
87 "joinMUC", "mucLeave", "getRoomsJoined", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady", "tarotGameContratChoosed", 87 "joinMUC", "mucLeave", "getRoomsJoined", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady", "tarotGameContratChoosed",
88 "tarotGamePlayCards", "launchRadioCollective", "getWaitingSub", "subscription", "delContact", "updateContact", "getEntityData", "getParamsUI", 88 "tarotGamePlayCards", "launchRadioCollective", "getWaitingSub", "subscription", "delContact", "updateContact", "getEntityData", "getParamsUI",
89 #"setParam", 89 #"setParam",
90 "launchAction", "disconnect", 90 "launchAction", "disconnect",
91 ]) 91 ])
200 return True 200 return True
201 201
202 def getAvatar(self, jid_str): 202 def getAvatar(self, jid_str):
203 """Return avatar of a jid if in cache, else ask for it""" 203 """Return avatar of a jid if in cache, else ask for it"""
204 def dataReceived(result): 204 def dataReceived(result):
205 if result.has_key('avatar'): 205 if 'avatar' in result:
206 self._entityDataUpdatedCb(jid_str, 'avatar', result['avatar']) 206 self._entityDataUpdatedCb(jid_str, 'avatar', result['avatar'])
207 207
208 if jid_str not in self.avatars_cache: 208 if jid_str not in self.avatars_cache:
209 self.bridge.call('getEntityData', dataReceived, jid_str, ['avatar']) 209 self.bridge.call('getEntityData', dataReceived, jid_str, ['avatar'])
210 self.avatars_cache[jid_str] = "/media/misc/empty_avatar" 210 self.avatars_cache[jid_str] = "/media/misc/empty_avatar"
359 359
360 ## Signals callbacks ## 360 ## Signals callbacks ##
361 361
362 def _personalEventCb(self, sender, event_type, data): 362 def _personalEventCb(self, sender, event_type, data):
363 if event_type == "MICROBLOG": 363 if event_type == "MICROBLOG":
364 if not data.has_key('content'): 364 if not 'content' in data:
365 print ("WARNING: No content found in microblog data") 365 print ("WARNING: No content found in microblog data")
366 return 366 return
367 if data.has_key('groups'): 367 if 'groups' in data:
368 _groups = set(data['groups'].split() if data['groups'] else []) 368 _groups = set(data['groups'].split() if data['groups'] else [])
369 else: 369 else:
370 _groups=None 370 _groups=None
371 mblog_entry = MicroblogItem(data) 371 mblog_entry = MicroblogItem(data)
372 372
383 """Check if an entry can go in MicroblogPanel and add to it 383 """Check if an entry can go in MicroblogPanel and add to it
384 @param mblog_panel: MicroblogPanel instance 384 @param mblog_panel: MicroblogPanel instance
385 @param sender: jid of the entry sender 385 @param sender: jid of the entry sender
386 @param _groups: groups which can receive this entry 386 @param _groups: groups which can receive this entry
387 @param mblog_entry: MicroblogItem instance""" 387 @param mblog_entry: MicroblogItem instance"""
388 if mblog_panel.isJidAccepted(sender) or (_groups == None and self.whoami and sender == self.whoami.bare) \ 388 if mblog_entry.type == "comment" or mblog_panel.isJidAccepted(sender) or (_groups == None and self.whoami and sender == self.whoami.bare) \
389 or (_groups and _groups.intersection(mblog_panel.accepted_groups)): 389 or (_groups and _groups.intersection(mblog_panel.accepted_groups)):
390 mblog_panel.addEntry(mblog_entry) 390 mblog_panel.addEntry(mblog_entry)
391 391
392 def FillMicroblogPanel(self, mblog_panel): 392 def FillMicroblogPanel(self, mblog_panel):
393 """Fill a microblog panel with entries in cache 393 """Fill a microblog panel with entries in cache