diff --git a/openpgp/modules/openpgp.py b/openpgp/modules/openpgp.py index 6054e82..88e41e8 100644 --- a/openpgp/modules/openpgp.py +++ b/openpgp/modules/openpgp.py @@ -18,7 +18,7 @@ import time import logging from pathlib import Path -import nbxmpp +from nbxmpp.namespaces import Namespace from nbxmpp import Node from nbxmpp import StanzaMalformed from nbxmpp.util import is_error_result @@ -72,7 +72,7 @@ class OpenPGP(BaseModule): self.handlers = [ StanzaHandler(name='message', callback=self.decrypt_message, - ns=nbxmpp.NS_OPENPGP, + ns=Namespace.OPENPGP, priority=9), ] @@ -133,7 +133,7 @@ class OpenPGP(BaseModule): log.info('%s => Publish keylist', self._account) self._nbxmpp('OpenPGP').set_keylist(keylist) - @event_node(nbxmpp.NS_OPENPGP_PK) + @event_node(Namespace.OPENPGP_PK) def _keylist_notification_received(self, _con, _stanza, properties): if properties.pubsub_event.retracted: return diff --git a/openpgp/modules/util.py b/openpgp/modules/util.py index 6c759d9..d46ca7e 100644 --- a/openpgp/modules/util.py +++ b/openpgp/modules/util.py @@ -17,17 +17,17 @@ from enum import IntEnum from collections import namedtuple -import nbxmpp +from nbxmpp.namespaces import Namespace ENCRYPTION_NAME = 'OpenPGP' NOT_ENCRYPTED_TAGS = [ - ('no-store', nbxmpp.NS_MSG_HINTS), - ('store', nbxmpp.NS_MSG_HINTS), - ('no-copy', nbxmpp.NS_MSG_HINTS), - ('no-permanent-store', nbxmpp.NS_MSG_HINTS), - ('origin-id', nbxmpp.NS_SID), + ('no-store', Namespace.HINTS), + ('store', Namespace.HINTS), + ('no-copy', Namespace.HINTS), + ('no-permanent-store', Namespace.HINTS), + ('origin-id', Namespace.SID), ('thread', None) ] @@ -42,7 +42,7 @@ class Trust(IntEnum): def prepare_stanza(stanza, payload): - delete_nodes(stanza, 'openpgp', nbxmpp.NS_OPENPGP) + delete_nodes(stanza, 'openpgp', Namespace.OPENPGP) delete_nodes(stanza, 'body') nodes = [(node.getName(), node.getNamespace()) for node in payload] @@ -56,7 +56,7 @@ def prepare_stanza(stanza, payload): def delete_nodes(stanza, name, namespace=None): attrs = None if namespace is not None: - attrs = {'xmlns': nbxmpp.NS_OPENPGP} + attrs = {'xmlns': Namespace.OPENPGP} nodes = stanza.getTags(name, attrs) for node in nodes: stanza.delChild(node) diff --git a/openpgp/pgpplugin.py b/openpgp/pgpplugin.py index ad7843e..bc62dbc 100644 --- a/openpgp/pgpplugin.py +++ b/openpgp/pgpplugin.py @@ -20,7 +20,7 @@ from pathlib import Path from gi.repository import Gtk from gi.repository import Gdk -import nbxmpp +from nbxmpp.namespaces import Namespace from nbxmpp import JID from gajim.common import app @@ -129,7 +129,7 @@ class OpenPGPPlugin(GajimPlugin): @staticmethod def _update_caps(_account, features): - features.append('%s+notify' % nbxmpp.NS_OPENPGP_PK) + features.append('%s+notify' % Namespace.OPENPGP_PK) def activate_encryption(self, chat_control): account = chat_control.account