diff options
| author | Melvin Keskin <melvo@olomono.de> | 2021-09-02 23:41:16 +0200 |
|---|---|---|
| committer | Linus Jahn <lnj@kaidan.im> | 2021-09-03 16:16:15 +0200 |
| commit | 0623aa38f2ead734dddea4cbad899a868f01cb1e (patch) | |
| tree | ce6539732310386d2ba0faf7383c054a4690f3a2 /src/base/QXmppMessage.cpp | |
| parent | 12c63eddded9f02369bd4e569f62acfdd95cc723 (diff) | |
Add QXmppOmemoElement
Co-authored-by: Germán Márquez Mejía <mancho@olomono.de>
Diffstat (limited to 'src/base/QXmppMessage.cpp')
| -rw-r--r-- | src/base/QXmppMessage.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/base/QXmppMessage.cpp b/src/base/QXmppMessage.cpp index f0e74735..f975ae3c 100644 --- a/src/base/QXmppMessage.cpp +++ b/src/base/QXmppMessage.cpp @@ -28,6 +28,7 @@ #include "QXmppBitsOfBinaryDataList.h" #include "QXmppConstants_p.h" #include "QXmppMixInvitation.h" +#include "QXmppOmemoElement.h" #include "QXmppTrustMessageElement.h" #include "QXmppUtils.h" @@ -171,6 +172,9 @@ public: bool isSpoiler; QString spoilerHint; + // XEP-0384: OMEMO Encryption + std::optional<QXmppOmemoElement> omemoElement; + // XEP-0407: Mediated Information eXchange (MIX): Miscellaneous Capabilities std::optional<QXmppMixInvitation> mixInvitation; @@ -1084,6 +1088,26 @@ void QXmppMessage::setSpoilerHint(const QString &spoilerHint) } /// +/// Returns an included OMEMO element as defined by \xep{0384, OMEMO Encryption}. +/// +/// \since QXmpp 1.5 +/// +std::optional<QXmppOmemoElement> QXmppMessage::omemoElement() const +{ + return d->omemoElement; +} + +/// +/// Sets an OMEMO element as defined by \xep{0384, OMEMO Encryption}. +/// +/// \since QXmpp 1.5 +/// +void QXmppMessage::setOmemoElement(const std::optional<QXmppOmemoElement> &omemoElement) +{ + d->omemoElement = omemoElement; +} + +/// /// Returns an included \xep{0369}: Mediated Information eXchange (MIX) /// invitation as defined by \xep{0407}: Mediated Information eXchange (MIX): /// Miscellaneous Capabilities. @@ -1345,6 +1369,11 @@ bool QXmppMessage::parseExtension(const QDomElement &element) // XEP-0382: Spoiler messages d->isSpoiler = true; d->spoilerHint = element.text(); + } else if (QXmppOmemoElement::isOmemoElement(element)) { + // XEP-0384: OMEMO Encryption + QXmppOmemoElement omemoElement; + omemoElement.parse(element); + d->omemoElement = omemoElement; } else if (checkElement(element, QStringLiteral("invitation"), ns_mix_misc)) { // XEP-0407: Mediated Information eXchange (MIX): Miscellaneous Capabilities QXmppMixInvitation mixInvitation; @@ -1543,6 +1572,11 @@ void QXmppMessage::serializeExtensions(QXmlStreamWriter *xmlWriter) const xmlWriter->writeEndElement(); } + // XEP-0384: OMEMO Encryption + if (d->omemoElement) { + d->omemoElement->toXml(xmlWriter); + } + // XEP-0407: Mediated Information eXchange (MIX): Miscellaneous Capabilities if (d->mixInvitation) { d->mixInvitation->toXml(xmlWriter); |
