From ebbf58a05ca112b7e56df8aa072f410398a86dae Mon Sep 17 00:00:00 2001 From: Melvin Keskin Date: Mon, 7 Mar 2022 14:58:29 +0100 Subject: Add parameter 'keyOwnerJid' to trust storages' 'trustLevel()' --- src/client/QXmppAtmManager.cpp | 2 +- src/client/QXmppTrustMemoryStorage.cpp | 4 ++-- src/client/QXmppTrustMemoryStorage.h | 2 +- src/client/QXmppTrustStorage.cpp | 3 ++- src/client/QXmppTrustStorage.h | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src/client') diff --git a/src/client/QXmppAtmManager.cpp b/src/client/QXmppAtmManager.cpp index 2c9a8568..aef42d4d 100644 --- a/src/client/QXmppAtmManager.cpp +++ b/src/client/QXmppAtmManager.cpp @@ -301,7 +301,7 @@ QFuture QXmppAtmManager::handleMessage(const QXmppMessage &message) const auto senderKey = e2eeMetadata ? e2eeMetadata->senderKey() : QByteArray(); const auto encryption = trustMessageElement->encryption(); - auto future = m_trustStorage->trustLevel(encryption, senderKey); + auto future = m_trustStorage->trustLevel(encryption, senderJid, senderKey); await(future, this, [=](const auto &&senderKeyTrustLevel) mutable { const auto isSenderKeyAuthenticated = senderKeyTrustLevel == QXmppTrustStorage::Authenticated; diff --git a/src/client/QXmppTrustMemoryStorage.cpp b/src/client/QXmppTrustMemoryStorage.cpp index 5a1b6e61..c9e2f37f 100644 --- a/src/client/QXmppTrustMemoryStorage.cpp +++ b/src/client/QXmppTrustMemoryStorage.cpp @@ -223,11 +223,11 @@ QFuture QXmppTrustMemoryStorage::setTrustLevel(const QString &encryption, return makeReadyFuture(); } -QFuture QXmppTrustMemoryStorage::trustLevel(const QString &encryption, const QByteArray &keyId) +QFuture QXmppTrustMemoryStorage::trustLevel(const QString &encryption, const QString &keyOwnerJid, const QByteArray &keyId) { const auto keys = d->keys.values(encryption); for (const auto &key : keys) { - if (key.id == keyId) { + if (key.id == keyId && key.ownerJid == keyOwnerJid) { return makeReadyFuture(std::move(QXmppTrustStorage::TrustLevel(key.trustLevel))); } } diff --git a/src/client/QXmppTrustMemoryStorage.h b/src/client/QXmppTrustMemoryStorage.h index abab2d6a..c9d15fe9 100644 --- a/src/client/QXmppTrustMemoryStorage.h +++ b/src/client/QXmppTrustMemoryStorage.h @@ -36,7 +36,7 @@ public: QFuture setTrustLevel(const QString &encryption, const QMultiHash &keyIds, TrustLevel trustLevel) override; QFuture setTrustLevel(const QString &encryption, const QList &keyOwnerJids, TrustLevel oldTrustLevel, TrustLevel newTrustLevel) override; - QFuture trustLevel(const QString &encryption, const QByteArray &keyId) override; + QFuture trustLevel(const QString &encryption, const QString &keyOwnerJid, const QByteArray &keyId) override; QFuture resetAll(const QString &encryption) override; /// \endcond diff --git a/src/client/QXmppTrustStorage.cpp b/src/client/QXmppTrustStorage.cpp index 149eccfe..5cfe5b95 100644 --- a/src/client/QXmppTrustStorage.cpp +++ b/src/client/QXmppTrustStorage.cpp @@ -176,13 +176,14 @@ /// /// -/// \fn QXmppTrustStorage::trustLevel(const QString &encryption, const QByteArray &keyId) +/// \fn QXmppTrustStorage::trustLevel(const QString &encryption, const QString &keyOwnerJid, const QByteArray &keyId) /// /// Returns the trust level of a key. /// /// If the key is not stored, the trust in that key is undecided. /// /// \param encryption encryption protocol namespace +/// \param keyOwnerJid key owner's bare JID /// \param keyId ID of the key /// /// \return the key's trust level diff --git a/src/client/QXmppTrustStorage.h b/src/client/QXmppTrustStorage.h index dffbcfae..c1db773d 100644 --- a/src/client/QXmppTrustStorage.h +++ b/src/client/QXmppTrustStorage.h @@ -55,7 +55,7 @@ public: virtual QFuture setTrustLevel(const QString &encryption, const QMultiHash &keyIds, TrustLevel trustLevel) = 0; virtual QFuture setTrustLevel(const QString &encryption, const QList &keyOwnerJids, TrustLevel oldTrustLevel, TrustLevel newTrustLevel) = 0; - virtual QFuture trustLevel(const QString &encryption, const QByteArray &keyId) = 0; + virtual QFuture trustLevel(const QString &encryption, const QString &keyOwnerJid, const QByteArray &keyId) = 0; virtual QFuture resetAll(const QString &encryption) = 0; }; -- cgit v1.2.3