From 6781f67e80aa5ec86c84b49ef4526dcef9feceda Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 11 Nov 2012 16:01:53 +0100 Subject: =?UTF-8?q?Preload=20history=20into=20discussion=20windows=20(?= =?UTF-8?q?=C3=A0=20la=20mcabber)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - New option load_log defaulting to 200 to indicate the number of lines to be loaded - It’s still very raw, and the format of the message does not match the format of the normal room history, for example - Works in the Private chat, MUC, and Conversation tabs Thanks to labedz for the original code --- src/tabs.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'src/tabs.py') diff --git a/src/tabs.py b/src/tabs.py index 41bb511e..d98382d9 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -389,8 +389,9 @@ class ChatTab(Tab): """ plugin_commands = {} plugin_keys = {} - def __init__(self): + def __init__(self, jid=''): Tab.__init__(self) + self.name = jid self._text_buffer = TextBuffer() self.remote_wants_chatstates = None # change this to True or False when # we know that the remote user wants chatstates, or not. @@ -421,6 +422,24 @@ class ChatTab(Tab): self.update_commands() self.update_keys() + # Get the logs + log_nb = config.get('load_log', 200) + + if isinstance(self, PrivateTab): + logs = logger.get_logs(safeJID(self.get_name()).full.replace('/', '\\'), log_nb) + else: + logs = logger.get_logs(safeJID(self.get_name()).bare, log_nb) + if logs: + for log_line in logs: + log_line = '\x19%s}%s' % (get_theme().COLOR_INFORMATION_TEXT[0], log_line) + self._text_buffer.add_message( + txt=log_line.strip(), + time='', + nickname='', + user='', + str_time='' + ) + def last_words_completion(self): """ Complete the input with words recently said @@ -617,7 +636,7 @@ class MucTab(ChatTab): plugin_keys = {} def __init__(self, jid, nick): self.joined = False - ChatTab.__init__(self) + ChatTab.__init__(self, jid) self.own_nick = nick self.name = jid self.users = [] @@ -1611,7 +1630,7 @@ class PrivateTab(ChatTab): plugin_commands = {} plugin_keys = {} def __init__(self, name, nick): - ChatTab.__init__(self) + ChatTab.__init__(self, name) self.own_nick = nick self.name = name self.text_win = windows.TextWin() @@ -2669,7 +2688,7 @@ class ConversationTab(ChatTab): additional_informations = {} message_type = 'chat' def __init__(self, jid): - ChatTab.__init__(self) + ChatTab.__init__(self, jid) self.state = 'normal' self.name = jid # a conversation tab is linked to one specific full jid OR bare jid self.text_win = windows.TextWin() -- cgit v1.2.3