Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
-
d343e2be
by Philipp Hörist at 2019-04-14T10:20:33Z
-
9dc56a27
by Philipp Hörist at 2019-04-14T16:40:22Z
3 changed files:
Changes:
| ... | ... | @@ -50,7 +50,7 @@ from nbxmpp.modules.nickname import Nickname |
| 50 | 50 |
from nbxmpp.modules.delay import Delay
|
| 51 | 51 |
from nbxmpp.modules.muc import MUC
|
| 52 | 52 |
from nbxmpp.modules.idle import Idle
|
| 53 |
-from nbxmpp.modules.signed import Signed
|
|
| 53 |
+from nbxmpp.modules.pgplegacy import PGPLegacy
|
|
| 54 | 54 |
from nbxmpp.modules.vcard_avatar import VCardAvatar
|
| 55 | 55 |
from nbxmpp.modules.captcha import Captcha
|
| 56 | 56 |
from nbxmpp.modules.entity_caps import EntityCaps
|
| ... | ... | @@ -187,7 +187,7 @@ class XMPPDispatcher(PlugIn): |
| 187 | 187 |
self._modules['Delay'] = Delay(self._owner)
|
| 188 | 188 |
self._modules['Captcha'] = Captcha(self._owner)
|
| 189 | 189 |
self._modules['Idle'] = Idle(self._owner)
|
| 190 |
- self._modules['Signed'] = Signed(self._owner)
|
|
| 190 |
+ self._modules['PGPLegacy'] = PGPLegacy(self._owner)
|
|
| 191 | 191 |
self._modules['VCardAvatar'] = VCardAvatar(self._owner)
|
| 192 | 192 |
self._modules['EntityCaps'] = EntityCaps(self._owner)
|
| 193 | 193 |
self._modules['Blocking'] = Blocking(self._owner)
|
| ... | ... | @@ -18,15 +18,20 @@ |
| 18 | 18 |
import logging
|
| 19 | 19 |
|
| 20 | 20 |
from nbxmpp.protocol import NS_SIGNED
|
| 21 |
+from nbxmpp.protocol import NS_ENCRYPTED
|
|
| 21 | 22 |
from nbxmpp.structs import StanzaHandler
|
| 22 | 23 |
|
| 23 | 24 |
log = logging.getLogger('nbxmpp.m.signed')
|
| 24 | 25 |
|
| 25 | 26 |
|
| 26 |
-class Signed:
|
|
| 27 |
+class PGPLegacy:
|
|
| 27 | 28 |
def __init__(self, client):
|
| 28 | 29 |
self._client = client
|
| 29 | 30 |
self.handlers = [
|
| 31 |
+ StanzaHandler(name='message',
|
|
| 32 |
+ callback=self._process_pgplegacy_message,
|
|
| 33 |
+ ns=NS_ENCRYPTED,
|
|
| 34 |
+ priority=7),
|
|
| 30 | 35 |
StanzaHandler(name='presence',
|
| 31 | 36 |
callback=self._process_signed,
|
| 32 | 37 |
ns=NS_SIGNED,
|
| ... | ... | @@ -40,3 +45,20 @@ class Signed: |
| 40 | 45 |
return
|
| 41 | 46 |
|
| 42 | 47 |
properties.signed = signed.getData()
|
| 48 |
+ |
|
| 49 |
+ @staticmethod
|
|
| 50 |
+ def _process_pgplegacy_message(_con, stanza, properties):
|
|
| 51 |
+ pgplegacy = stanza.getTag('x', namespace=NS_ENCRYPTED)
|
|
| 52 |
+ if pgplegacy is None:
|
|
| 53 |
+ log.warning('No x node found')
|
|
| 54 |
+ log.warning(stanza)
|
|
| 55 |
+ return
|
|
| 56 |
+ |
|
| 57 |
+ data = pgplegacy.getData()
|
|
| 58 |
+ if not data:
|
|
| 59 |
+ log.warning('No data in x node found')
|
|
| 60 |
+ log.warning(stanza)
|
|
| 61 |
+ return
|
|
| 62 |
+ |
|
| 63 |
+ log.info('Encrypted message received')
|
|
| 64 |
+ properties.pgp_legacy = data
|
| ... | ... | @@ -124,7 +124,7 @@ class AdHocCommand(namedtuple('AdHocCommand', 'jid node name sessionid status da |
| 124 | 124 |
|
| 125 | 125 |
@property
|
| 126 | 126 |
def is_canceled(self):
|
| 127 |
- return self.status == AdHocStatus.CANCEL
|
|
| 127 |
+ return self.status == AdHocStatus.CANCELED
|
|
| 128 | 128 |
|
| 129 | 129 |
|
| 130 | 130 |
class OMEMOBundle(namedtuple('OMEMOBundle', 'spk spk_signature ik otpks')):
|
| ... | ... | @@ -206,6 +206,7 @@ class MessageProperties: |
| 206 | 206 |
self.openpgp = None
|
| 207 | 207 |
self.omemo = None
|
| 208 | 208 |
self.encrypted = None
|
| 209 |
+ self.pgp_legacy = None
|
|
| 209 | 210 |
|
| 210 | 211 |
@property
|
| 211 | 212 |
def has_user_delay(self):
|
| ... | ... | @@ -223,6 +224,10 @@ class MessageProperties: |
| 223 | 224 |
def is_openpgp(self):
|
| 224 | 225 |
return self.openpgp is not None
|
| 225 | 226 |
|
| 227 |
+ @property
|
|
| 228 |
+ def is_pgp_legacy(self):
|
|
| 229 |
+ return self.pgp_legacy is not None
|
|
| 230 |
+ |
|
| 226 | 231 |
@property
|
| 227 | 232 |
def is_pubsub(self):
|
| 228 | 233 |
return self.pubsub
|