diff options
| author | Linus Jahn <lnj@kaidan.im> | 2022-04-06 13:02:29 +0200 |
|---|---|---|
| committer | Linus Jahn <lnj@kaidan.im> | 2022-04-06 15:02:47 +0200 |
| commit | a8fd01e50a3088df8bc6b367d1c14fe1da93be91 (patch) | |
| tree | 415b66cdd850fdb0491e0d2e5fd698ae61f1c1d8 /src/base/QXmppMessage.cpp | |
| parent | a3e110d6a219f2dc3bfd6d8fc238f5d022f30aea (diff) | |
Message: Move encryption namespace parsing into Global private
Diffstat (limited to 'src/base/QXmppMessage.cpp')
| -rw-r--r-- | src/base/QXmppMessage.cpp | 36 |
1 files changed, 6 insertions, 30 deletions
diff --git a/src/base/QXmppMessage.cpp b/src/base/QXmppMessage.cpp index dfb60240..83d05b2e 100644 --- a/src/base/QXmppMessage.cpp +++ b/src/base/QXmppMessage.cpp @@ -9,6 +9,7 @@ #include "QXmppBitsOfBinaryDataList.h" #include "QXmppConstants_p.h" +#include "QXmppGlobal_p.h" #include "QXmppMixInvitation.h" #include "QXmppOmemoElement.h" #include "QXmppTrustMessageElement.h" @@ -43,17 +44,6 @@ static const QStringList MARKER_TYPES = { QStringLiteral("acknowledged") }; -static const QStringList ENCRYPTION_NAMESPACES = { - QString(), - QString(), - ns_otr, - ns_legacy_openpgp, - ns_ox, - ns_omemo, - ns_omemo_1, - ns_omemo_2 -}; - static const QStringList HINT_TYPES = { QStringLiteral("no-permanent-store"), QStringLiteral("no-store"), @@ -61,17 +51,6 @@ static const QStringList HINT_TYPES = { QStringLiteral("store") }; -static const QStringList ENCRYPTION_NAMES = { - QString(), - QString(), - QStringLiteral("OTR"), - QStringLiteral("Legacy OpenPGP"), - QStringLiteral("OpenPGP for XMPP (OX)"), - QStringLiteral("OMEMO"), - QStringLiteral("OMEMO 1"), - QStringLiteral("OMEMO 2") -}; - static bool checkElement(const QDomElement &element, const QString &tagName, const QString &xmlns) { return element.tagName() == tagName && element.namespaceURI() == xmlns; @@ -974,13 +953,10 @@ void QXmppMessage::setMixUserNick(const QString &mixUserNick) /// QXmpp::Encryption QXmppMessage::encryptionMethod() const { - if (d->encryptionMethod.isEmpty()) + if (d->encryptionMethod.isEmpty()) { return QXmpp::NoEncryption; - - int index = ENCRYPTION_NAMESPACES.indexOf(d->encryptionMethod); - if (index < 0) - return QXmpp::UnknownEncryption; - return static_cast<QXmpp::Encryption>(index); + } + return QXmpp::Private::encryptionFromString(d->encryptionMethod).value_or(QXmpp::UnknownEncryption); } /// @@ -991,7 +967,7 @@ QXmpp::Encryption QXmppMessage::encryptionMethod() const /// void QXmppMessage::setEncryptionMethod(QXmpp::Encryption method) { - d->encryptionMethod = ENCRYPTION_NAMESPACES.at(int(method)); + d->encryptionMethod = QXmpp::Private::encryptionToString(method); } /// @@ -1027,7 +1003,7 @@ QString QXmppMessage::encryptionName() const { if (!d->encryptionName.isEmpty()) return d->encryptionName; - return ENCRYPTION_NAMES.at(int(encryptionMethod())); + return QXmpp::Private::encryptionToName(encryptionMethod()); } /// |
