From cb1c0ac7ba16590304c8fe7bd6d87b69dffe5c67 Mon Sep 17 00:00:00 2001 From: Melvin Keskin Date: Mon, 23 May 2022 15:17:12 +0200 Subject: SendStanzaParams: Add accepted trust levels --- src/client/QXmppSendStanzaParams.cpp | 28 ++++++++++++++++++++++++++++ src/client/QXmppSendStanzaParams.h | 6 ++++++ 2 files changed, 34 insertions(+) (limited to 'src') diff --git a/src/client/QXmppSendStanzaParams.cpp b/src/client/QXmppSendStanzaParams.cpp index 3a3beaae..6c8b6ccc 100644 --- a/src/client/QXmppSendStanzaParams.cpp +++ b/src/client/QXmppSendStanzaParams.cpp @@ -18,6 +18,7 @@ class QXmppSendStanzaParamsPrivate : public QSharedData { public: QVector encryptionJids; + QXmppTrustStorage::TrustLevels acceptedTrustLevels; }; QXmppSendStanzaParams::QXmppSendStanzaParams() @@ -56,3 +57,30 @@ void QXmppSendStanzaParams::setEncryptionJids(QVector encryptionJids) { d->encryptionJids = std::move(encryptionJids); } + +/// +/// Returns the possible trust levels a key must have to be used for encryption. +/// +/// If no trust levels are set, the encryption manager uses an own default. +/// +/// \return the trust levels of the keys used for encryption +/// +std::optional QXmppSendStanzaParams::acceptedTrustLevels() const +{ + if (d->acceptedTrustLevels) { + return d->acceptedTrustLevels; + } + return {}; +} + +/// +/// Sets the possible trust levels a key must have to be used for encryption. +/// +/// If no trust levels are set, the encryption manager uses an own default. +/// +/// \param trustLevels trust levels of the keys used for encryption +/// +void QXmppSendStanzaParams::setAcceptedTrustLevels(std::optional trustLevels) +{ + d->acceptedTrustLevels = trustLevels.value_or(QXmppTrustStorage::TrustLevels()); +} diff --git a/src/client/QXmppSendStanzaParams.h b/src/client/QXmppSendStanzaParams.h index af22f7cf..70ef572a 100644 --- a/src/client/QXmppSendStanzaParams.h +++ b/src/client/QXmppSendStanzaParams.h @@ -6,6 +6,9 @@ #define QXMPPSENDSTANZAPARAMS_H #include "QXmppGlobal.h" +#include "QXmppTrustStorage.h" + +#include #include @@ -24,6 +27,9 @@ public: QVector encryptionJids() const; void setEncryptionJids(QVector); + std::optional acceptedTrustLevels() const; + void setAcceptedTrustLevels(std::optional trustLevels); + private: QSharedDataPointer d; }; -- cgit v1.2.3