summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2018-03-14 17:59:20 +0100
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2018-03-31 00:28:09 +0200
commitb03a92e7eab6e0b7eb84a6a526913a449a36d603 (patch)
treec523e4d7e61af81eee8eeab9987e5c5baf24a1f9
parent326de0f16155dc8a5729bffe0057282c3232141b (diff)
downloadpoezio-b03a92e7eab6e0b7eb84a6a526913a449a36d603.tar.gz
poezio-b03a92e7eab6e0b7eb84a6a526913a449a36d603.tar.bz2
poezio-b03a92e7eab6e0b7eb84a6a526913a449a36d603.tar.xz
poezio-b03a92e7eab6e0b7eb84a6a526913a449a36d603.zip
Use the new slixmpp filesystem cache to store caps.
-rw-r--r--poezio/config.py1
-rw-r--r--poezio/connection.py12
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