aboutsummaryrefslogtreecommitdiff
path: root/src/base
diff options
context:
space:
mode:
authorMelvin Keskin <melvo@olomono.de>2022-03-26 12:00:17 +0100
committerLinus Jahn <lnj@kaidan.im>2022-04-06 15:02:47 +0200
commit66b718973a9d32cecdabf1c54799e605fca00fbb (patch)
tree910794533bb182f8b1ccc67bf325b69777811e0d /src/base
parent12ef960435bb718c48325ee05754e548ee6528a5 (diff)
downloadqxmpp-66b718973a9d32cecdabf1c54799e605fca00fbb.tar.gz
E2eeMetadata: Add enum and attribute for the used encryption
Diffstat (limited to 'src/base')
-rw-r--r--src/base/QXmppGlobal.h45
-rw-r--r--src/base/QXmppStanza.cpp21
-rw-r--r--src/base/QXmppStanza.h3
3 files changed, 69 insertions, 0 deletions
diff --git a/src/base/QXmppGlobal.h b/src/base/QXmppGlobal.h
index 2e403bd6..40f88801 100644
--- a/src/base/QXmppGlobal.h
+++ b/src/base/QXmppGlobal.h
@@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: 2010 Manjeet Dahiya <manjeetdahiya@gmail.com>
// SPDX-FileCopyrightText: 2017 Niels Ole Salscheider <niels_ole@salscheider-online.de>
// SPDX-FileCopyrightText: 2019 Linus Jahn <lnj@kaidan.im>
+// SPDX-FileCopyrightText: 2022 Melvin Keskin <melvo@olomono.de>
//
// SPDX-License-Identifier: LGPL-2.1-or-later
@@ -49,6 +50,50 @@
namespace QXmpp {
///
+/// This enum describes different end-to-end encryption methods. These can
+/// be used to mark a stanza as encrypted or decrypted with a specific algorithm
+/// (e.g., for \xep{0380, Explicit Message Encryption}).
+///
+/// \since QXmpp 1.5
+///
+enum Encryption {
+ /// No encryption
+ NoEncryption,
+ /// Unknown encryption
+ UnknownEncryption,
+ /// \xep{0364, Current Off-the-Record Messaging Usage}
+ Otr,
+ /// \xep{0027, Current Jabber OpenPGP Usage}
+ LegacyOpenPgp,
+ /// \xep{0373, OpenPGP for XMPP}
+ Ox,
+ /// \xep{0384, OMEMO Encryption}
+ Omemo,
+ /// \xep{0384, OMEMO Encryption} since version 0.4
+ Omemo1,
+ /// \xep{0384, OMEMO Encryption} since version 0.8
+ Omemo2,
+#if QXMPP_DEPRECATED_SINCE(1, 5)
+ /// \xep{0364, Current Off-the-Record Messaging Usage}
+ /// \deprecated This enum is deprecated since QXmpp 1.5. Use
+ /// \c QXmpp::Otr instead.
+ OTR = Otr,
+ /// \xep{0027, Current Jabber OpenPGP Usage}
+ /// \deprecated This enum is deprecated since QXmpp 1.5. Use
+ /// \c QXmpp::LegacyOpenPgp instead.
+ LegacyOpenPGP = LegacyOpenPgp,
+ /// \xep{0373, OpenPGP for XMPP}
+ /// \deprecated This enum is deprecated since QXmpp 1.5. Use
+ /// \c QXmpp::Ox instead.
+ OX = Ox,
+ /// \xep{0384, OMEMO Encryption}
+ /// \deprecated This enum is deprecated since QXmpp 1.5. Use
+ /// \c QXmpp::Omemo instead.
+ OMEMO = Omemo,
+#endif
+};
+
+///
/// Parsing/serialization mode when using Stanza Content Encryption.
///
/// \sa \xep{0420, Stanza Content Encryption}
diff --git a/src/base/QXmppStanza.cpp b/src/base/QXmppStanza.cpp
index 8dabb07a..d90d105b 100644
--- a/src/base/QXmppStanza.cpp
+++ b/src/base/QXmppStanza.cpp
@@ -703,6 +703,7 @@ void QXmppStanza::Error::toXml(QXmlStreamWriter *writer) const
class QXmppE2eeMetadataPrivate : public QSharedData
{
public:
+ QXmpp::Encryption encryption;
QByteArray senderKey;
// XEP-0420: Stanza Content Encryption
@@ -752,6 +753,26 @@ std::optional<QXmppE2eeMetadata> QXmppE2eeMetadata::toOptional() const
QXmppE2eeMetadata &QXmppE2eeMetadata::operator=(const QXmppE2eeMetadata &other) = default;
///
+/// Returns the used encryption protocol.
+///
+/// \return the encryption protocol
+///
+QXmpp::Encryption QXmppE2eeMetadata::encryption() const
+{
+ return d->encryption;
+}
+
+///
+/// Sets the used encryption protocol.
+///
+/// \param encryption encryption protocol
+///
+void QXmppE2eeMetadata::setEncryption(QXmpp::Encryption encryption)
+{
+ d->encryption = encryption;
+}
+
+///
/// Returns the ID of this stanza's sender's public long-term key.
///
/// The sender key ID is not part of a transmitted stanza and thus not de- /
diff --git a/src/base/QXmppStanza.h b/src/base/QXmppStanza.h
index 7a30d43a..d25e3653 100644
--- a/src/base/QXmppStanza.h
+++ b/src/base/QXmppStanza.h
@@ -77,6 +77,9 @@ public:
QXmppE2eeMetadata &operator=(const QXmppE2eeMetadata &other);
+ QXmpp::Encryption encryption() const;
+ void setEncryption(QXmpp::Encryption encryption);
+
QByteArray senderKey() const;
void setSenderKey(const QByteArray &keyId);