Commit d343e2be authored by Philipp Hörist's avatar Philipp Hörist

Add PGP Legacy (XEP-0027) module

parent 11dffacf
......@@ -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)
......
......@@ -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
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment