[openpgp] Use nbxmpp.namespaces

This commit is contained in:
lovetox
2020-04-19 22:12:31 +02:00
parent fcaa83e3d2
commit 4a95f1d5bc
3 changed files with 13 additions and 13 deletions

View File

@@ -18,7 +18,7 @@ import time
import logging import logging
from pathlib import Path from pathlib import Path
import nbxmpp from nbxmpp.namespaces import Namespace
from nbxmpp import Node from nbxmpp import Node
from nbxmpp import StanzaMalformed from nbxmpp import StanzaMalformed
from nbxmpp.util import is_error_result from nbxmpp.util import is_error_result
@@ -72,7 +72,7 @@ class OpenPGP(BaseModule):
self.handlers = [ self.handlers = [
StanzaHandler(name='message', StanzaHandler(name='message',
callback=self.decrypt_message, callback=self.decrypt_message,
ns=nbxmpp.NS_OPENPGP, ns=Namespace.OPENPGP,
priority=9), priority=9),
] ]
@@ -133,7 +133,7 @@ class OpenPGP(BaseModule):
log.info('%s => Publish keylist', self._account) log.info('%s => Publish keylist', self._account)
self._nbxmpp('OpenPGP').set_keylist(keylist) 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): def _keylist_notification_received(self, _con, _stanza, properties):
if properties.pubsub_event.retracted: if properties.pubsub_event.retracted:
return return

View File

@@ -17,17 +17,17 @@
from enum import IntEnum from enum import IntEnum
from collections import namedtuple from collections import namedtuple
import nbxmpp from nbxmpp.namespaces import Namespace
ENCRYPTION_NAME = 'OpenPGP' ENCRYPTION_NAME = 'OpenPGP'
NOT_ENCRYPTED_TAGS = [ NOT_ENCRYPTED_TAGS = [
('no-store', nbxmpp.NS_MSG_HINTS), ('no-store', Namespace.HINTS),
('store', nbxmpp.NS_MSG_HINTS), ('store', Namespace.HINTS),
('no-copy', nbxmpp.NS_MSG_HINTS), ('no-copy', Namespace.HINTS),
('no-permanent-store', nbxmpp.NS_MSG_HINTS), ('no-permanent-store', Namespace.HINTS),
('origin-id', nbxmpp.NS_SID), ('origin-id', Namespace.SID),
('thread', None) ('thread', None)
] ]
@@ -42,7 +42,7 @@ class Trust(IntEnum):
def prepare_stanza(stanza, payload): def prepare_stanza(stanza, payload):
delete_nodes(stanza, 'openpgp', nbxmpp.NS_OPENPGP) delete_nodes(stanza, 'openpgp', Namespace.OPENPGP)
delete_nodes(stanza, 'body') delete_nodes(stanza, 'body')
nodes = [(node.getName(), node.getNamespace()) for node in payload] 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): def delete_nodes(stanza, name, namespace=None):
attrs = None attrs = None
if namespace is not None: if namespace is not None:
attrs = {'xmlns': nbxmpp.NS_OPENPGP} attrs = {'xmlns': Namespace.OPENPGP}
nodes = stanza.getTags(name, attrs) nodes = stanza.getTags(name, attrs)
for node in nodes: for node in nodes:
stanza.delChild(node) stanza.delChild(node)

View File

@@ -20,7 +20,7 @@ from pathlib import Path
from gi.repository import Gtk from gi.repository import Gtk
from gi.repository import Gdk from gi.repository import Gdk
import nbxmpp from nbxmpp.namespaces import Namespace
from nbxmpp import JID from nbxmpp import JID
from gajim.common import app from gajim.common import app
@@ -129,7 +129,7 @@ class OpenPGPPlugin(GajimPlugin):
@staticmethod @staticmethod
def _update_caps(_account, features): 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): def activate_encryption(self, chat_control):
account = chat_control.account account = chat_control.account