diff src/core/xmpp.py @ 2109:85f3e12e984d

core (memory/cache): file caching handling, first draft: instead of having file caching handled individually by plugins, a generic module has been added in memory. - Cache can be global or associated to a profile. In the later case, client.cache can be used. - Cache are managed with unique ids (which can be any unique unicode, hash uuid, or something else). - To know if a file is in cache, getFilePath is used: if the file is in cache, its absolute path is returned, else None is returned. - To cache a file, cacheData is used with at list the source of cache (most of time plugin import name), and unique id. The method return file opened in binary writing mode (so cacheData can - and should - be used with "with" statement). - 2 files will be created: a metadata file (named after the unique id), and the actual file. - each file has a end of life time, after it, the cache is invalidated and the file must be requested again.
author Goffi <goffi@goffi.org>
date Thu, 05 Jan 2017 20:23:38 +0100
parents ad88808591ef
children 2d633b3c923d
line wrap: on
line diff
--- a/src/core/xmpp.py	Tue Jan 03 18:51:50 2017 +0100
+++ b/src/core/xmpp.py	Thu Jan 05 20:23:38 2017 +0100
@@ -19,6 +19,7 @@
 
 from sat.core.i18n import _
 from sat.core.constants import Const as C
+from sat.memory import cache
 from twisted.internet import task, defer
 from twisted.words.protocols.jabber.xmlstream import XMPPHandler
 from twisted.words.protocols.jabber import xmlstream
@@ -60,6 +61,7 @@
         self.__connected = False
         self.profile = profile
         self.host_app = host_app
+        self.cache = cache.Cache(host_app, profile)
         self._mess_id_uid = {} # map from message id to uid use in history. Key: (full_jid,message_id) Value: uid
         self.conn_deferred = defer.Deferred()
         self._progress_cb = {}  # callback called when a progress is requested (key = progress id)