diff src/memory/sqlite.py @ 538:2c4016921403

core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles - added profile argument to askConfirmation, actionResult, actionResultExt, entityDataUpdated, confirmationAnswer, getProgress - core, frontends: fixed calls/signals according to new bridge API - user of proper profile namespace for progression indicators and dialogs - memory: getParam* now return bool when param type is bool - memory: added getStringParam* to return string instead of typed value - core, memory, storage, quick_frontend: getHistory now manage properly multi-profiles - plugins XEP-0047, XEP-0054, XEP-0065, XEP-0077, XEP-0096; multi-profiles proper handling
author Goffi <goffi@goffi.org>
date Sat, 10 Nov 2012 16:38:16 +0100
parents 862c0d6ab974
children 9faccd827657
line wrap: on
line diff
--- a/src/memory/sqlite.py	Sun Nov 04 23:53:26 2012 +0100
+++ b/src/memory/sqlite.py	Sat Nov 10 16:38:16 2012 +0100
@@ -183,7 +183,7 @@
         @param _type: message type (see RFC 6121 ยง5.2.2)
         @param timestamp: timestamp in seconds since epoch, or None to use current time
         """
-        assert(profile!=None)
+        assert(profile)
         d = self.dbpool.runQuery("INSERT INTO history(source, source_res, dest, dest_res, timestamp, message, type, profile_id) VALUES (?,?,?,?,?,?,?,?)",
                                 (from_jid.userhost(), from_jid.resource, to_jid.userhost(), to_jid.resource, timestamp or time.time(),
                                 message, _type, self.profiles[profile]))
@@ -191,12 +191,13 @@
                                          {"from_jid":from_jid.full(), "to_jid":to_jid.full(), "message":message})))
         return d
 
-    def getHistory(self, from_jid, to_jid, limit=0, between=True):
+    def getHistory(self, from_jid, to_jid, limit=0, between=True, profile=None):
         """Store a new message in history
         @param from_jid: source JID (full, or bare for catchall
         @param to_jid: dest JID (full, or bare for catchall
         @param size: maximum number of messages to get, or 0 for unlimited
         """
+        assert(profile)
         def sqliteToDict(query_result):
             query_result.reverse()
             result = []
@@ -208,8 +209,8 @@
             return result
 
 
-        query_parts = ["SELECT timestamp, source, source_res, dest, dest_res, message, type FROM history WHERE"]
-        values = []
+        query_parts = ["SELECT timestamp, source, source_res, dest, dest_res, message, type FROM history WHERE profile_id=? AND"]
+        values = [self.profiles[profile]]
 
         def test_jid(_type,_jid):
             values.append(_jid.userhost())