Skip to content
GitLab
Explore
Sign in
Register
Commits on Source (2)
Add PGP Legacy (XEP-0027) module
· d343e2be
Philipp Hörist
authored
Apr 14, 2019
d343e2be
Fix wrong enum attr
· 9dc56a27
Philipp Hörist
authored
Apr 14, 2019
9dc56a27
Hide whitespace changes
Inline
Side-by-side
nbxmpp/dispatcher.py
View file @
9dc56a27
...
...
@@ -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
View file @
9dc56a27
...
...
@@ -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
View file @
9dc56a27
...
...
@@ -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
.
CANCEL
ED
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
...
...