diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index cf80659739f04ac394dd79368dc2b38aaf0e4e90..dc15c9b8e11d845cda78df0b0af2707dcbf27507 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -1387,7 +1387,10 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco) # Ignore message from room in which we are not if not self.last_history_line.has_key(jid): return - self.dispatch('GC_MSG', (frm, msgtxt, tim)) + has_timestamp = False + if msg.timestamp: + has_timestamp = True + self.dispatch('GC_MSG', (frm, msgtxt, tim, has_timestamp)) if self.name not in no_log_for and not int(float(time.mktime(tim))) <= \ self.last_history_line[jid] and msgtxt: gajim.logger.write('gc_msg', frm, msgtxt, tim = tim) @@ -1431,7 +1434,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco) who = str(prs.getFrom()) jid_stripped, resource = gajim.get_room_and_nick_from_fjid(who) self.dispatch('GC_MSG', (jid_stripped, _('Nickname not allowed: %s') % \ - resource, None)) + resource, None, False)) return jid_stripped, resource = gajim.get_room_and_nick_from_fjid(who) timestamp = None diff --git a/src/gajim.py b/src/gajim.py index 3730c7f65a5ef2b4111f62f215560e31b917fdac..a673c7fbc30d86a9673d947cae155bcb4de344d5 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -893,7 +893,7 @@ class Interface: def handle_event_gc_msg(self, account, array): - # ('GC_MSG', account, (jid, msg, time)) + # ('GC_MSG', account, (jid, msg, time, has_timestamp)) jids = array[0].split('/', 1) room_jid = jids[0] gc_control = self.msg_win_mgr.get_control(room_jid, account) @@ -905,7 +905,7 @@ class Interface: else: # message from someone nick = jids[1] - gc_control.on_message(nick, array[1], array[2]) + gc_control.on_message(nick, array[1], array[2], array[3]) if self.remote_ctrl: self.remote_ctrl.raise_signal('GCMessage', (account, array)) diff --git a/src/groupchat_control.py b/src/groupchat_control.py index 05432780619a95b315a94bcc1db9abbe2afabd9c..38e20e5bfe49807f5c14e65643dc8f7eeae61304 100644 --- a/src/groupchat_control.py +++ b/src/groupchat_control.py @@ -430,13 +430,16 @@ class GroupchatControl(ChatControlBase): childs[3].set_sensitive(False) return menu - def on_message(self, nick, msg, tim): + def on_message(self, nick, msg, tim, has_timestamp = False): if not nick: # message from server self.print_conversation(msg, tim = tim) else: # message from someone - self.print_conversation(msg, nick, tim) + if has_timestamp: + self.print_old_conversation(msg, nick, tim) + else: + self.print_conversation(msg, nick, tim) def on_private_message(self, nick, msg, tim): # Do we have a queue? @@ -499,6 +502,21 @@ class GroupchatControl(ChatControlBase): gc_count_nicknames_colors = 0 gc_custom_colors = {} + def print_old_conversation(self, text, contact, tim = None): + if isinstance(text, str): + text = unicode(text, 'utf-8') + if contact == self.nick: # it's us + kind = 'outgoing' + else: + kind = 'incoming' + if gajim.config.get('restored_messages_small'): + small_attr = ['small'] + else: + small_attr = [] + ChatControlBase.print_conversation_line(self, text, kind, contact, tim, + small_attr, small_attr + ['restored_message'], + small_attr + ['restored_message']) + def print_conversation(self, text, contact = '', tim = None): '''Print a line in the conversation: if contact is set: it's a message from someone or an info message (contact