# HG changeset patch # User souliane # Date 1378476455 -7200 # Node ID 8bbac49765d645cf1987919712d9dc4bb4121282 # Parent a05e16f4a343daa82521110f968b4922fbff1a60 browser side: display the day change in chat window fix bug 36 diff -r a05e16f4a343 -r 8bbac49765d6 browser_side/panels.py --- a/browser_side/panels.py Fri Sep 06 15:55:45 2013 +0200 +++ b/browser_side/panels.py Fri Sep 06 16:07:35 2013 +0200 @@ -660,8 +660,15 @@ def historyPrint(self, size=20): """Print the initial history""" def getHistoryCB(history): + # display day change + day_format = "%A, %d %b %Y" + previous_day = datetime.now().strftime(day_format) for line in history: timestamp, from_jid, to_jid, message, mess_type = line + message_day = datetime.fromtimestamp(float(timestamp or time())).strftime(day_format) + if previous_day != message_day: + self.printInfo("* " + message_day) + previous_day = message_day self.printMessage(from_jid, message, timestamp) self.host.bridge.call('getHistory', getHistoryCB, self.host.whoami.bare, self.target.bare, size, True) diff -r a05e16f4a343 -r 8bbac49765d6 libervia.py --- 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")