From 87df5133312b5b10b8ebaaf00593ffb16fb7b084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Sun, 13 May 2018 13:12:05 +0200 Subject: [PATCH] xep_0384: Do not init plugin if omemo lib not available The omemo library being GPL at the moment, requiring it unconditionally would also unconditionally make Slixmpp GPL. It's now a packaging issue. --- plugin.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/plugin.py b/plugin.py index 99a58ab..d02a3a2 100644 --- a/plugin.py +++ b/plugin.py @@ -15,7 +15,11 @@ from slixmpp.plugins.base import BasePlugin, register_plugin log = logging.getLogger(__name__) - +HAS_OMEMO = True +try: + import omemo +except ImportError as e: + HAS_OMEMO = False class XEP_0384(BasePlugin): @@ -27,13 +31,22 @@ class XEP_0384(BasePlugin): name = 'xep_0384' description = 'XEP-0384 OMEMO' dependencies = {'xep_0163'} + backend_loaded = HAS_OMEMO device_ids = {} def plugin_init(self): + if not self.backend_loaded: + log.debug("xep_0384 cannot be loaded as the backend omemo library " + "is not available") + return + self.xmpp.add_event_handler('pubsub_publish', self.device_list) def plugin_end(self): + if not self.backend_loaded: + return + self.xmpp.del_event_handler('pubsub_publish', self.device_list) self.xmpp['xep_0163'].remove_interest(OMEMO_DEVICES_NS)