From b03a92e7eab6e0b7eb84a6a526913a449a36d603 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Wed, 14 Mar 2018 17:59:20 +0100 Subject: Use the new slixmpp filesystem cache to store caps. --- poezio/config.py | 1 + poezio/connection.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/poezio/config.py b/poezio/config.py index 8077a9c6..d4ea7b0b 100644 --- a/poezio/config.py +++ b/poezio/config.py @@ -534,6 +534,7 @@ def check_create_cache_dir(): makedirs(CACHE_DIR) makedirs(path.join(CACHE_DIR, 'avatars')) makedirs(path.join(CACHE_DIR, 'images')) + makedirs(path.join(CACHE_DIR, 'caps')) except OSError: pass diff --git a/poezio/connection.py b/poezio/connection.py index 3ccfa8ce..69259690 100644 --- a/poezio/connection.py +++ b/poezio/connection.py @@ -16,12 +16,15 @@ import subprocess import sys import slixmpp +from slixmpp.xmlstream import ET from slixmpp.plugins.xep_0184 import XEP_0184 +from slixmpp.plugins.xep_0030 import DiscoInfo +from slixmpp.util import FileSystemCache from poezio import common from poezio import fixes from poezio.common import safeJID -from poezio.config import config, options +from poezio.config import config, options, CACHE_DIR class Connection(slixmpp.ClientXMPP): @@ -104,6 +107,12 @@ class Connection(slixmpp.ClientXMPP): self.whitespace_keepalive = False self.register_plugin('xep_0004') self.register_plugin('xep_0012') + # Must be loaded before 0030. + self.register_plugin('xep_0115', { + 'caps_node': 'https://poez.io', + 'cache': FileSystemCache(CACHE_DIR, 'caps', encode=str, + decode=lambda x: DiscoInfo(ET.fromstring(x))), + }) self.register_plugin('xep_0030') self.register_plugin('xep_0045') self.register_plugin('xep_0048') @@ -117,7 +126,6 @@ class Connection(slixmpp.ClientXMPP): self.plugin['xep_0077'].create_account = False self.register_plugin('xep_0084') self.register_plugin('xep_0085') - self.register_plugin('xep_0115') self.register_plugin('xep_0153') # monkey-patch xep_0184 to avoid requesting receipts for messages -- cgit v1.2.3