From efd73e04bfefeec9a5f6884e76a60a574da1c78a Mon Sep 17 00:00:00 2001 From: Jean-Marie Traissard Date: Sun, 4 Jun 2006 17:21:14 +0000 Subject: [PATCH] Also merge metacontacts logs in restore_lines() --- src/chat_control.py | 2 +- src/common/logger.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/chat_control.py b/src/chat_control.py index 89bbfaf01..6738c9255 100644 --- a/src/chat_control.py +++ b/src/chat_control.py @@ -1478,7 +1478,7 @@ class ChatControl(ChatControlBase): pending_how_many += 1 rows = gajim.logger.get_last_conversation_lines(jid, restore_how_many, - pending_how_many, timeout) + pending_how_many, timeout, self.account) local_old_kind = None for row in rows: # row[0] time, row[1] has kind, row[2] the message if not row[2]: # message is empty, we don't print it diff --git a/src/common/logger.py b/src/common/logger.py index 8e761f1a3..bdaa11a39 100644 --- a/src/common/logger.py +++ b/src/common/logger.py @@ -342,7 +342,7 @@ class Logger: return self.commit_to_db(values, write_unread) def get_last_conversation_lines(self, jid, restore_how_many_rows, - pending_how_many, timeout): + pending_how_many, timeout, account): '''accepts how many rows to restore and when to time them out (in minutes) (mark them as too old) and number of messages that are in queue and are already logged but pending to be viewed, @@ -350,15 +350,17 @@ class Logger: list with empty tupple if nothing found to meet our demands''' jid = jid.lower() jid_id = self.get_jid_id(jid) + where_sql = self._build_contact_where(account, jid) + now = int(float(time.time())) timed_out = now - (timeout * 60) # before that they are too old # so if we ask last 5 lines and we have 2 pending we get # 3 - 8 (we avoid the last 2 lines but we still return 5 asked) self.cur.execute(''' SELECT time, kind, message FROM logs - WHERE jid_id = %d AND kind IN (%d, %d, %d, %d) AND time > %d + WHERE %s AND kind IN (%d, %d, %d, %d) AND time > %d ORDER BY time DESC LIMIT %d OFFSET %d - ''' % (jid_id, constants.KIND_SINGLE_MSG_RECV, constants.KIND_CHAT_MSG_RECV, + ''' % (where_sql, constants.KIND_SINGLE_MSG_RECV, constants.KIND_CHAT_MSG_RECV, constants.KIND_SINGLE_MSG_SENT, constants.KIND_CHAT_MSG_SENT, timed_out, restore_how_many_rows, pending_how_many) )