Mercurial > libervia-web
diff 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 |
line wrap: on
line diff
--- a/libervia.py Fri Sep 06 15:55:45 2013 +0200 +++ b/libervia.py Fri Sep 06 16:07:35 2013 +0200 @@ -101,7 +101,7 @@ LiberviaJsonProxy.__init__(self, "/json_api", ["getContacts", "addContact", "sendMessage", "sendMblog", "sendMblogComment", "getLastMblogs", "getMassiveLastMblogs", "getMblogComments", "getProfileJid", "getHistory", "getPresenceStatus", "joinMUC", "mucLeave", "getRoomsJoined", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady", "tarotGameContratChoosed", "tarotGamePlayCards", - "launchRadioCollective", "getWaitingSub", "subscription", "delContact", "updateContact", "getCard", "getEntityData", "getParamsUI", + "launchRadioCollective", "getWaitingSub", "subscription", "delContact", "updateContact", "getCard", "getEntityData", "getParamsUI", "chatStateComposing", #"setParam", "launchAction", "disconnect", ]) @@ -339,6 +339,8 @@ self._newContactCb(*args) elif name == 'entityDataUpdated': self._entityDataUpdatedCb(*args) + elif name == 'chatStateReceived': + self._chatStateReceivedCb(*args) def _ownBlogsFills(self, mblogs): #put our own microblogs in cache, then fill all panels with them @@ -556,6 +558,25 @@ if lib_wid.isJidAccepted(entity_jid_s) or (self.whoami and entity_jid_s == self.whoami.bare): lib_wid.updateValue('avatar', entity_jid_s, avatar) + def _chatStateReceivedCb(self, from_jid_s, state, profile): + """Callback when a new chat state is received. + @param from_jid_s: JID from the contact who sent his state + @param state: new state + @profile: current profile + """ + _from = JID(from_jid_s).bare if from_jid_s != "@ALL@" else from_jid_s + for lib_wid in self.libervia_widgets: + if isinstance(lib_wid, panels.ChatPanel): + win_from = lib_wid.target.bare + good_win = win_from == _from or _from == "@ALL@" + if (good_win and lib_wid.type == 'one2one'): + if state: + lib_wid.setTitle(win_from + " (" + state + ")") + else: + lib_wid.setTitle(win_from) + elif (lib_wid.type == 'group'): + # TODO: chat state notification for groupchat + pass if __name__ == '__main__': pyjd.setup("http://localhost:8080/libervia.html")