From 291666a5e3ce0cd357c8b583a5453edf25936738 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Sun, 5 Nov 2006 23:46:06 +0000 Subject: [PATCH] show gc topic changements with timestamp as old conversations (grey) --- src/common/connection_handlers.py | 8 ++++---- src/gajim.py | 13 +++++++++---- src/groupchat_control.py | 12 ++++++++---- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index 4a321887c..516942dde 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -1404,17 +1404,17 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco) self.dispatch('MSGERROR', (frm, msg.getErrorCode(), error_msg, msgtxt, tim)) elif mtype == 'groupchat': + has_timestamp = False + if msg.timestamp: + has_timestamp = True if subject: - self.dispatch('GC_SUBJECT', (frm, subject, msgtxt)) + self.dispatch('GC_SUBJECT', (frm, subject, msgtxt, has_timestamp)) else: if not msg.getTag('body'): #no return # Ignore message from room in which we are not if not self.last_history_line.has_key(jid): return - has_timestamp = False - if msg.timestamp: - has_timestamp = True self.dispatch('GC_MSG', (frm, msgtxt, tim, has_timestamp, msghtml)) if self.name not in no_log_for and not int(float(time.mktime(tim))) <= \ self.last_history_line[jid] and msgtxt: diff --git a/src/gajim.py b/src/gajim.py index eac1246d1..eb0d3ac85 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -914,7 +914,7 @@ class Interface: self.remote_ctrl.raise_signal('GCMessage', (account, array)) def handle_event_gc_subject(self, account, array): - #('GC_SUBJECT', account, (jid, subject, body)) + #('GC_SUBJECT', account, (jid, subject, body, has_timestamp)) jids = array[0].split('/', 1) jid = jids[0] gc_control = self.msg_win_mgr.get_control(jid, account) @@ -922,14 +922,19 @@ class Interface: return gc_control.set_subject(array[1]) # Standard way, the message comes from the occupant who set the subject + text = None if len(jids) > 1: - gc_control.print_conversation('%s has set the subject to %s' % ( - jids[1], array[1])) + text = '%s has set the subject to %s' % (jids[1], array[1]) # Workaround for psi bug http://flyspray.psi-im.org/task/595 , to be # deleted one day. We can receive a subject with a body that contains # "X has set the subject to Y" ... elif array[2]: - gc_control.print_conversation(array[2]) + text = array[2] + if text is not None: + if array[3]: + gc_control.print_old_conversation(text) + else: + gc_control.print_conversation(text) def handle_event_gc_config(self, account, array): #('GC_CONFIG', account, (jid, config)) config is a dict diff --git a/src/groupchat_control.py b/src/groupchat_control.py index 5ded9f69f..d4f77414c 100644 --- a/src/groupchat_control.py +++ b/src/groupchat_control.py @@ -510,13 +510,17 @@ class GroupchatControl(ChatControlBase): gc_count_nicknames_colors = 0 gc_custom_colors = {} - def print_old_conversation(self, text, contact, tim = None, xhtml = None): + def print_old_conversation(self, text, contact = '', tim = None, + xhtml = None): if isinstance(text, str): text = unicode(text, 'utf-8') - if contact == self.nick: # it's us - kind = 'outgoing' + if contact: + if contact == self.nick: # it's us + kind = 'outgoing' + else: + kind = 'incoming' else: - kind = 'incoming' + kind = 'status' if gajim.config.get('restored_messages_small'): small_attr = ['small'] else: