Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim-plugins.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlovetox <philipp@hoerist.com>2020-04-19 23:13:19 +0300
committerlovetox <philipp@hoerist.com>2020-04-19 23:14:06 +0300
commitf85ea81a9b3a2fc05b9cd909a0f9d21db2aca944 (patch)
treea7d32568a417ac8f111f6c8e0deaa5d05f399d15 /pgp/modules
parent4a95f1d5bc1399e6b6097e75dd6cee2a6b54816d (diff)
[pgp] Use nbxmpp.namespaces
Diffstat (limited to 'pgp/modules')
-rw-r--r--pgp/modules/pgp_legacy.py37
-rw-r--r--pgp/modules/util.py4
2 files changed, 21 insertions, 20 deletions
diff --git a/pgp/modules/pgp_legacy.py b/pgp/modules/pgp_legacy.py
index 368d8e3..b2b2880 100644
--- a/pgp/modules/pgp_legacy.py
+++ b/pgp/modules/pgp_legacy.py
@@ -19,6 +19,7 @@ import time
import threading
import nbxmpp
+from nbxmpp.namespaces import Namespace
from nbxmpp.structs import StanzaHandler
from gi.repository import GLib
@@ -41,18 +42,18 @@ from pgp.exceptions import NoKeyIdFound
name = 'PGPLegacy'
zeroconf = True
-ALLOWED_TAGS = [('request', nbxmpp.NS_RECEIPTS),
- ('active', nbxmpp.NS_CHATSTATES),
- ('gone', nbxmpp.NS_CHATSTATES),
- ('inactive', nbxmpp.NS_CHATSTATES),
- ('paused', nbxmpp.NS_CHATSTATES),
- ('composing', nbxmpp.NS_CHATSTATES),
- ('no-store', nbxmpp.NS_MSG_HINTS),
- ('store', nbxmpp.NS_MSG_HINTS),
- ('no-copy', nbxmpp.NS_MSG_HINTS),
- ('no-permanent-store', nbxmpp.NS_MSG_HINTS),
- ('replace', nbxmpp.NS_CORRECT),
- ('origin-id', nbxmpp.NS_SID),
+ALLOWED_TAGS = [('request', Namespace.RECEIPTS),
+ ('active', Namespace.CHATSTATES),
+ ('gone', Namespace.CHATSTATES),
+ ('inactive', Namespace.CHATSTATES),
+ ('paused', Namespace.CHATSTATES),
+ ('composing', Namespace.CHATSTATES),
+ ('no-store', Namespace.HINTS),
+ ('store', Namespace.HINTS),
+ ('no-copy', Namespace.HINTS),
+ ('no-permanent-store', Namespace.HINTS),
+ ('replace', Namespace.CORRECT),
+ ('origin-id', Namespace.SID),
]
@@ -63,11 +64,11 @@ class PGPLegacy(BaseModule):
self.handlers = [
StanzaHandler(name='message',
callback=self._message_received,
- ns=nbxmpp.NS_ENCRYPTED,
+ ns=Namespace.ENCRYPTED,
priority=9),
StanzaHandler(name='presence',
callback=self._on_presence_received,
- ns=nbxmpp.NS_SIGNED,
+ ns=Namespace.SIGNED,
priority=48),
]
@@ -205,10 +206,10 @@ class PGPLegacy(BaseModule):
def _create_pgp_legacy_message(self, stanza, payload):
stanza.setBody(self._get_info_message())
- stanza.setTag('x', namespace=nbxmpp.NS_ENCRYPTED).setData(payload)
+ stanza.setTag('x', namespace=Namespace.ENCRYPTED).setData(payload)
eme_node = nbxmpp.Node('encryption',
- attrs={'xmlns': nbxmpp.NS_EME,
- 'namespace': nbxmpp.NS_ENCRYPTED})
+ attrs={'xmlns': Namespace.EME,
+ 'namespace': Namespace.ENCRYPTED})
stanza.addChild(node=eme_node)
def sign_presence(self, presence, status):
@@ -224,7 +225,7 @@ class PGPLegacy(BaseModule):
return
# self._log.debug(self._pgp.sign.cache_info())
self._log.info('Presence signed')
- presence.setTag(nbxmpp.NS_SIGNED + ' x').setData(result)
+ presence.setTag(Namespace.SIGNED + ' x').setData(result)
@staticmethod
def _get_info_message():
diff --git a/pgp/modules/util.py b/pgp/modules/util.py
index aff48c6..5d11a4d 100644
--- a/pgp/modules/util.py
+++ b/pgp/modules/util.py
@@ -17,11 +17,11 @@
import os
import subprocess
-import nbxmpp
+from nbxmpp.namespaces import Namespace
def prepare_stanza(stanza, plaintext):
- delete_nodes(stanza, 'encrypted', nbxmpp.NS_ENCRYPTED)
+ delete_nodes(stanza, 'encrypted', Namespace.ENCRYPTED)
delete_nodes(stanza, 'body')
stanza.setBody(plaintext)