diff options
| -rw-r--r-- | src/base/QXmppMessage.cpp | 10 | ||||
| -rw-r--r-- | src/base/QXmppMessage.h | 35 | ||||
| -rw-r--r-- | tests/qxmppmessage/tst_qxmppmessage.cpp | 12 |
3 files changed, 26 insertions, 31 deletions
diff --git a/src/base/QXmppMessage.cpp b/src/base/QXmppMessage.cpp index e493cf17..dfb60240 100644 --- a/src/base/QXmppMessage.cpp +++ b/src/base/QXmppMessage.cpp @@ -972,15 +972,15 @@ void QXmppMessage::setMixUserNick(const QString &mixUserNick) /// /// \since QXmpp 1.1 /// -QXmppMessage::EncryptionMethod QXmppMessage::encryptionMethod() const +QXmpp::Encryption QXmppMessage::encryptionMethod() const { if (d->encryptionMethod.isEmpty()) - return QXmppMessage::NoEncryption; + return QXmpp::NoEncryption; int index = ENCRYPTION_NAMESPACES.indexOf(d->encryptionMethod); if (index < 0) - return QXmppMessage::UnknownEncryption; - return static_cast<QXmppMessage::EncryptionMethod>(index); + return QXmpp::UnknownEncryption; + return static_cast<QXmpp::Encryption>(index); } /// @@ -989,7 +989,7 @@ QXmppMessage::EncryptionMethod QXmppMessage::encryptionMethod() const /// /// \since QXmpp 1.1 /// -void QXmppMessage::setEncryptionMethod(QXmppMessage::EncryptionMethod method) +void QXmppMessage::setEncryptionMethod(QXmpp::Encryption method) { d->encryptionMethod = ENCRYPTION_NAMESPACES.at(int(method)); } diff --git a/src/base/QXmppMessage.h b/src/base/QXmppMessage.h index b7db3eab..1f0c81b5 100644 --- a/src/base/QXmppMessage.h +++ b/src/base/QXmppMessage.h @@ -29,6 +29,19 @@ class QXmppTrustMessageElement; class QXMPP_EXPORT QXmppMessage : public QXmppStanza { public: +/// \cond +#if QXMPP_DEPRECATED_SINCE(1, 5) + using EncryptionMethod = QXmpp::Encryption; + + static const EncryptionMethod NoEncryption = EncryptionMethod::NoEncryption; + static const EncryptionMethod UnknownEncryption = EncryptionMethod::UnknownEncryption; + static const EncryptionMethod OTR = EncryptionMethod::Otr; + static const EncryptionMethod LegacyOpenPGP = EncryptionMethod::LegacyOpenPgp; + static const EncryptionMethod OX = EncryptionMethod::Ox; + static const EncryptionMethod OMEMO = EncryptionMethod::Omemo; +#endif +/// \endcond + /// This enum describes a message type. enum Type { Error = 0, @@ -77,24 +90,6 @@ public: Store = 1 << 3 ///< Do store the message }; - /// - /// This enum describes different end-to-end encryption methods. These can - /// be used to mark a message explicitly as encrypted with a specific - /// algorithm. See \xep{0380, Explicit Message Encryption} for details. - /// - /// \since QXmpp 1.1 - /// - enum EncryptionMethod { - NoEncryption, ///< No encryption - UnknownEncryption, ///< Unknown encryption - OTR, ///< \xep{0364, Current Off-the-Record Messaging Usage} - LegacyOpenPGP, ///< \xep{0027, Current Jabber OpenPGP Usage} - OX, ///< \xep{0373, OpenPGP for XMPP} - OMEMO, ///< \xep{0384, OMEMO Encryption} - OMEMO1, ///< \xep{0384, OMEMO Encryption} since version 0.4 - OMEMO2 ///< \xep{0384, OMEMO Encryption} since version 0.8 - }; - QXmppMessage(const QString &from = QString(), const QString &to = QString(), const QString &body = QString(), const QString &thread = QString()); @@ -220,8 +215,8 @@ public: void setMixUserNick(const QString &); // XEP-0380: Explicit Message Encryption - EncryptionMethod encryptionMethod() const; - void setEncryptionMethod(EncryptionMethod); + QXmpp::Encryption encryptionMethod() const; + void setEncryptionMethod(QXmpp::Encryption); QString encryptionMethodNs() const; void setEncryptionMethodNs(const QString &); diff --git a/tests/qxmppmessage/tst_qxmppmessage.cpp b/tests/qxmppmessage/tst_qxmppmessage.cpp index a8e5453e..6bea34cf 100644 --- a/tests/qxmppmessage/tst_qxmppmessage.cpp +++ b/tests/qxmppmessage/tst_qxmppmessage.cpp @@ -136,7 +136,7 @@ void tst_QXmppMessage::testBasic() QCOMPARE(message.isReceiptRequested(), false); QCOMPARE(message.receiptId(), QString()); QCOMPARE(message.xhtml(), QString()); - QCOMPARE(message.encryptionMethod(), QXmppMessage::NoEncryption); + QCOMPARE(message.encryptionMethod(), QXmpp::NoEncryption); QVERIFY(!message.isSpoiler()); QVERIFY(!message.hasHint(QXmppMessage::NoPermanentStore)); QVERIFY(!message.hasHint(QXmppMessage::NoStore)); @@ -776,7 +776,7 @@ void tst_QXmppMessage::testEme() QXmppMessage messageOmemo; parsePacket(messageOmemo, xmlOmemo); QCOMPARE(messageOmemo.encryptionMethodNs(), QString("eu.siacs.conversations.axolotl")); - QCOMPARE(messageOmemo.encryptionMethod(), QXmppMessage::OMEMO); + QCOMPARE(messageOmemo.encryptionMethod(), QXmpp::OMEMO); QCOMPARE(messageOmemo.encryptionName(), QString("OMEMO")); serializePacket(messageOmemo, xmlOmemo); @@ -790,20 +790,20 @@ void tst_QXmppMessage::testEme() QXmppMessage messageCustom; parsePacket(messageCustom, xmlCustom); QCOMPARE(messageCustom.encryptionMethodNs(), QString("im:example:customcrypt:1")); - QCOMPARE(messageCustom.encryptionMethod(), QXmppMessage::UnknownEncryption); + QCOMPARE(messageCustom.encryptionMethod(), QXmpp::UnknownEncryption); QCOMPARE(messageCustom.encryptionName(), QString("CustomCrypt")); serializePacket(messageCustom, xmlCustom); // test setters/getters QXmppMessage message; - message.setEncryptionMethod(QXmppMessage::LegacyOpenPGP); - QCOMPARE(message.encryptionMethod(), QXmppMessage::LegacyOpenPGP); + message.setEncryptionMethod(QXmpp::LegacyOpenPGP); + QCOMPARE(message.encryptionMethod(), QXmpp::LegacyOpenPGP); QCOMPARE(message.encryptionMethodNs(), QString("jabber:x:encrypted")); QCOMPARE(message.encryptionName(), QString("Legacy OpenPGP")); message.setEncryptionMethodNs("fancyorg:encryption:fancycrypt:0"); message.setEncryptionName("FancyCrypt"); - QCOMPARE(message.encryptionMethod(), QXmppMessage::UnknownEncryption); + QCOMPARE(message.encryptionMethod(), QXmpp::UnknownEncryption); QCOMPARE(message.encryptionMethodNs(), QString("fancyorg:encryption:fancycrypt:0")); QCOMPARE(message.encryptionName(), QString("FancyCrypt")); } |
