comparison libervia.py @ 213:8bbac49765d6

browser side: display the day change in chat window fix bug 36
author souliane <souliane@mailoo.org>
date Fri, 06 Sep 2013 16:07:35 +0200
parents 3092f6b1710c
children e830a0c60d32
comparison
equal deleted inserted replaced
212:a05e16f4a343 213:8bbac49765d6
99 class BridgeCall(LiberviaJsonProxy): 99 class BridgeCall(LiberviaJsonProxy):
100 def __init__(self): 100 def __init__(self):
101 LiberviaJsonProxy.__init__(self, "/json_api", 101 LiberviaJsonProxy.__init__(self, "/json_api",
102 ["getContacts", "addContact", "sendMessage", "sendMblog", "sendMblogComment", "getLastMblogs", "getMassiveLastMblogs", "getMblogComments", "getProfileJid", "getHistory", "getPresenceStatus", 102 ["getContacts", "addContact", "sendMessage", "sendMblog", "sendMblogComment", "getLastMblogs", "getMassiveLastMblogs", "getMblogComments", "getProfileJid", "getHistory", "getPresenceStatus",
103 "joinMUC", "mucLeave", "getRoomsJoined", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady", "tarotGameContratChoosed", "tarotGamePlayCards", 103 "joinMUC", "mucLeave", "getRoomsJoined", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady", "tarotGameContratChoosed", "tarotGamePlayCards",
104 "launchRadioCollective", "getWaitingSub", "subscription", "delContact", "updateContact", "getCard", "getEntityData", "getParamsUI", 104 "launchRadioCollective", "getWaitingSub", "subscription", "delContact", "updateContact", "getCard", "getEntityData", "getParamsUI", "chatStateComposing",
105 #"setParam", 105 #"setParam",
106 "launchAction", "disconnect", 106 "launchAction", "disconnect",
107 ]) 107 ])
108 108
109 class BridgeSignals(LiberviaJsonProxy): 109 class BridgeSignals(LiberviaJsonProxy):
337 self._contactDeletedCb(*args) 337 self._contactDeletedCb(*args)
338 elif name == 'newContact': 338 elif name == 'newContact':
339 self._newContactCb(*args) 339 self._newContactCb(*args)
340 elif name == 'entityDataUpdated': 340 elif name == 'entityDataUpdated':
341 self._entityDataUpdatedCb(*args) 341 self._entityDataUpdatedCb(*args)
342 elif name == 'chatStateReceived':
343 self._chatStateReceivedCb(*args)
342 344
343 def _ownBlogsFills(self, mblogs): 345 def _ownBlogsFills(self, mblogs):
344 #put our own microblogs in cache, then fill all panels with them 346 #put our own microblogs in cache, then fill all panels with them
345 for publisher in mblogs: 347 for publisher in mblogs:
346 for mblog in mblogs[publisher]: 348 for mblog in mblogs[publisher]:
554 for lib_wid in self.libervia_widgets: 556 for lib_wid in self.libervia_widgets:
555 if isinstance(lib_wid, panels.MicroblogPanel): 557 if isinstance(lib_wid, panels.MicroblogPanel):
556 if lib_wid.isJidAccepted(entity_jid_s) or (self.whoami and entity_jid_s == self.whoami.bare): 558 if lib_wid.isJidAccepted(entity_jid_s) or (self.whoami and entity_jid_s == self.whoami.bare):
557 lib_wid.updateValue('avatar', entity_jid_s, avatar) 559 lib_wid.updateValue('avatar', entity_jid_s, avatar)
558 560
561 def _chatStateReceivedCb(self, from_jid_s, state, profile):
562 """Callback when a new chat state is received.
563 @param from_jid_s: JID from the contact who sent his state
564 @param state: new state
565 @profile: current profile
566 """
567 _from = JID(from_jid_s).bare if from_jid_s != "@ALL@" else from_jid_s
568 for lib_wid in self.libervia_widgets:
569 if isinstance(lib_wid, panels.ChatPanel):
570 win_from = lib_wid.target.bare
571 good_win = win_from == _from or _from == "@ALL@"
572 if (good_win and lib_wid.type == 'one2one'):
573 if state:
574 lib_wid.setTitle(win_from + " (" + state + ")")
575 else:
576 lib_wid.setTitle(win_from)
577 elif (lib_wid.type == 'group'):
578 # TODO: chat state notification for groupchat
579 pass
559 580
560 if __name__ == '__main__': 581 if __name__ == '__main__':
561 pyjd.setup("http://localhost:8080/libervia.html") 582 pyjd.setup("http://localhost:8080/libervia.html")
562 app = SatWebFrontend() 583 app = SatWebFrontend()
563 app.onModuleLoad() 584 app.onModuleLoad()