From 968762437f375f27805b63841e29be0a9acdc421 Mon Sep 17 00:00:00 2001 From: Nikos Kouremenos Date: Mon, 30 May 2005 21:12:34 +0000 Subject: [PATCH] do not remember lines for transports --- src/chat.py | 43 --------------------------------- src/roster_window.py | 14 +++++------ src/tabbed_chat_window.py | 50 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 50 deletions(-) diff --git a/src/chat.py b/src/chat.py index 054139c5b..823c02e98 100644 --- a/src/chat.py +++ b/src/chat.py @@ -236,7 +236,6 @@ class Chat: try: gtkspell.Spell(message_textview) except gobject.GError, msg: - print msg dialogs.Error_dialog(str(msg) + '\n\n' + _('If that is not your language for which you want to highlight misspelled words, then please set your $LANG as appropriate. Eg. for French do export LANG=fr_FR or export LANG=fr_FR.UTF-8 in ~/.bash_profile or to make it global in /etc/profile.\n\nHighlighting misspelled words will not be used')) gajim.config.set('use_speller', False) @@ -718,45 +717,3 @@ class Chat: self.plugin.systray.add_jid(jid, self.account) self.redraw_tab(jid) self.show_title() - - - def restore_conversation(self, jid): - #How many lines to restore - restore = gajim.config.get('restore_lines') - pos = 0 #position, while reading from history - size = 0 #how many lines we alreay retreived - lines = [] #we'll need to reverse the lines from history - count = gajim.logger.get_nb_line(jid) - - while size <= restore: - if pos == count or size > restore - 1: - #don't try to read beyond history, not read more than required - break - - nb, line = gajim.logger.read(jid, count - 1 - pos, count - pos) - pos = pos + 1 - - if line[0][1] != 'sent' and line[0][1] != 'recv': - # we don't want to display status lines, do we? - continue - - lines.append(line[0]) - size = size + 1 - - lines.reverse() - - for msg in lines: - if msg[1] == 'sent': - kind = 'outgoing' - name = self.plugin.nicks[self.account] - elif msg[1] == 'recv': - kind = 'incoming' - # self.users is not initialized here yet - name = self.plugin.roster.contacts[self.account][jid][0].name - - tim = time.gmtime(float(msg[0])) - if msg[2][-1] == '\n': - text = msg[2][:-1] - else: - text = msg[2] - self.print_conversation_line(text, jid, kind, name, tim) diff --git a/src/roster_window.py b/src/roster_window.py index a6c7c40eb..412734616 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -189,19 +189,19 @@ class Roster_window: host = jid.split('@')[-1] - if host.find('aim.') == 0: + if host.startswith('aim.'): state_images = self.transports_state_images['aim'] - elif host.find('gadugadu.') == 0: + elif host.startswith('gadugadu.'): state_images = self.transports_state_images['gadugadu'] - elif host.find('irc.') == 0: + elif host.startswith('irc.'): state_images = self.transports_state_images['irc'] - elif host.find('icq.') == 0: + elif host.startswith('icq.'): state_images = self.transports_state_images['icq'] - elif host.find('msn.') == 0: + elif host.startswith('msn.'): state_images = self.transports_state_images['msn'] - elif host.find('sms.') == 0: + elif host.startswith('sms.'): state_images = self.transports_state_images['sms'] - elif host.find('yahoo.') == 0: + elif host.startswith('yahoo.'): state_images = self.transports_state_images['yahoo'] else: state_images = self.jabber_state_images diff --git a/src/tabbed_chat_window.py b/src/tabbed_chat_window.py index 2f76f83d3..7dbd50ec4 100644 --- a/src/tabbed_chat_window.py +++ b/src/tabbed_chat_window.py @@ -298,3 +298,53 @@ class Tabbed_chat_window(chat.Chat): name = user.name chat.Chat.print_conversation_line(self, text, jid, kind, name, tim) + + def restore_conversation(self, jid): + is_transport = bool( + jid.startswith('aim.') or jid.startswith('gadugadu.') or\ + jid.startswith('irc.') or jid.startswith('icq.') or\ + jid.startswith('msn.') or jid.startswith('sms.') or\ + jid.startswith('yahoo.') + ) + if is_transport: + return + + #How many lines to restore + restore = gajim.config.get('restore_lines') + pos = 0 #position, while reading from history + size = 0 #how many lines we alreay retreived + lines = [] #we'll need to reverse the lines from history + count = gajim.logger.get_nb_line(jid) + + while size <= restore: + if pos == count or size > restore - 1: + #don't try to read beyond history, not read more than required + break + + nb, line = gajim.logger.read(jid, count - 1 - pos, count - pos) + pos = pos + 1 + + if line[0][1] != 'sent' and line[0][1] != 'recv': + # we don't want to display status lines, do we? + continue + + lines.append(line[0]) + size = size + 1 + + lines.reverse() + + for msg in lines: + if msg[1] == 'sent': + kind = 'outgoing' + name = self.plugin.nicks[self.account] + elif msg[1] == 'recv': + kind = 'incoming' + # self.users is not initialized here yet + name = self.plugin.roster.contacts[self.account][jid][0].name + + tim = time.gmtime(float(msg[0])) + if msg[2][-1] == '\n': + text = msg[2][:-1] + else: + text = msg[2] + self.print_conversation_line(text, jid, kind, name, tim)