Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
d343e2be by Philipp Hörist at 2019-04-14T10:20:33Z
Add PGP Legacy (XEP-0027) module
- - - - -
9dc56a27 by Philipp Hörist at 2019-04-14T16:40:22Z
Fix wrong enum attr
- - - - -
3 changed files:
- nbxmpp/dispatcher.py
- nbxmpp/modules/signed.py → nbxmpp/modules/pgplegacy.py
- nbxmpp/structs.py
Changes:
=====================================
nbxmpp/dispatcher.py
=====================================
@@ -50,7 +50,7 @@ from nbxmpp.modules.nickname import Nickname
from nbxmpp.modules.delay import Delay
from nbxmpp.modules.muc import MUC
from nbxmpp.modules.idle import Idle
-from nbxmpp.modules.signed import Signed
+from nbxmpp.modules.pgplegacy import PGPLegacy
from nbxmpp.modules.vcard_avatar import VCardAvatar
from nbxmpp.modules.captcha import Captcha
from nbxmpp.modules.entity_caps import EntityCaps
@@ -187,7 +187,7 @@ class XMPPDispatcher(PlugIn):
self._modules['Delay'] = Delay(self._owner)
self._modules['Captcha'] = Captcha(self._owner)
self._modules['Idle'] = Idle(self._owner)
- self._modules['Signed'] = Signed(self._owner)
+ self._modules['PGPLegacy'] = PGPLegacy(self._owner)
self._modules['VCardAvatar'] = VCardAvatar(self._owner)
self._modules['EntityCaps'] = EntityCaps(self._owner)
self._modules['Blocking'] = Blocking(self._owner)
=====================================
nbxmpp/modules/signed.py → nbxmpp/modules/pgplegacy.py
=====================================
@@ -18,15 +18,20 @@
import logging
from nbxmpp.protocol import NS_SIGNED
+from nbxmpp.protocol import NS_ENCRYPTED
from nbxmpp.structs import StanzaHandler
log = logging.getLogger('nbxmpp.m.signed')
-class Signed:
+class PGPLegacy:
def __init__(self, client):
self._client = client
self.handlers = [
+ StanzaHandler(name='message',
+ callback=self._process_pgplegacy_message,
+ ns=NS_ENCRYPTED,
+ priority=7),
StanzaHandler(name='presence',
callback=self._process_signed,
ns=NS_SIGNED,
@@ -40,3 +45,20 @@ class Signed:
return
properties.signed = signed.getData()
+
+ @staticmethod
+ def _process_pgplegacy_message(_con, stanza, properties):
+ pgplegacy = stanza.getTag('x', namespace=NS_ENCRYPTED)
+ if pgplegacy is None:
+ log.warning('No x node found')
+ log.warning(stanza)
+ return
+
+ data = pgplegacy.getData()
+ if not data:
+ log.warning('No data in x node found')
+ log.warning(stanza)
+ return
+
+ log.info('Encrypted message received')
+ properties.pgp_legacy = data
=====================================
nbxmpp/structs.py
=====================================
@@ -124,7 +124,7 @@ class AdHocCommand(namedtuple('AdHocCommand', 'jid node
name sessionid status da
@property
def is_canceled(self):
- return self.status == AdHocStatus.CANCEL
+ return self.status == AdHocStatus.CANCELED
class OMEMOBundle(namedtuple('OMEMOBundle', 'spk spk_signature ik otpks')):
@@ -206,6 +206,7 @@ class MessageProperties:
self.openpgp = None
self.omemo = None
self.encrypted = None
+ self.pgp_legacy = None
@property
def has_user_delay(self):
@@ -223,6 +224,10 @@ class MessageProperties:
def is_openpgp(self):
return self.openpgp is not None
+ @property
+ def is_pgp_legacy(self):
+ return self.pgp_legacy is not None
+
@property
def is_pubsub(self):
return self.pubsub
View it on GitLab:
https://dev.gajim.org/gajim/python-nbxmpp/compare/11dffacfefb7db839ab5bdd47749edc935089dfa...9dc56a27832e38564459d5083b4a07b809256871
--
View it on GitLab:
https://dev.gajim.org/gajim/python-nbxmpp/compare/11dffacfefb7db839ab5bdd47749edc935089dfa...9dc56a27832e38564459d5083b4a07b809256871
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits