diff options
author | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2022-05-16 17:38:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-16 17:38:34 +0200 |
commit | 77b190d822c1e980b98b84999f0cfb609ed05a49 (patch) | |
tree | 049fc3936343a7af957c0bca20dd1531ae2e5f81 /lib/e2ee/qolmaccount.h | |
parent | 0599ef6e603dce219b2ba000d7322e8d937753b9 (diff) | |
parent | decc676f1e469dc26c80c33da64fad15805de8f2 (diff) | |
download | libquotient-77b190d822c1e980b98b84999f0cfb609ed05a49.tar.gz libquotient-77b190d822c1e980b98b84999f0cfb609ed05a49.zip |
Merge #550: Quotient::Expected and QOlmExpected
Diffstat (limited to 'lib/e2ee/qolmaccount.h')
-rw-r--r-- | lib/e2ee/qolmaccount.h | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/lib/e2ee/qolmaccount.h b/lib/e2ee/qolmaccount.h index 17f43f1a..ee2aa69d 100644 --- a/lib/e2ee/qolmaccount.h +++ b/lib/e2ee/qolmaccount.h @@ -5,21 +5,16 @@ #pragma once -#include "csapi/keys.h" #include "e2ee/e2ee.h" -#include "e2ee/qolmerrors.h" #include "e2ee/qolmmessage.h" -#include "e2ee/qolmsession.h" -#include <QObject> -struct OlmAccount; +#include "csapi/keys.h" -namespace Quotient { +#include <QtCore/QObject> -class QOlmSession; -class Connection; +struct OlmAccount; -using QOlmSessionPtr = std::unique_ptr<QOlmSession>; +namespace Quotient { //! An olm account manages all cryptographic keys used on a device. //! \code{.cpp} @@ -30,7 +25,7 @@ class QUOTIENT_API QOlmAccount : public QObject Q_OBJECT public: QOlmAccount(const QString &userId, const QString &deviceId, QObject *parent = nullptr); - ~QOlmAccount(); + ~QOlmAccount() override; //! Creates a new instance of OlmAccount. During the instantiation //! the Ed25519 fingerprint key pair and the Curve25519 identity key @@ -44,7 +39,7 @@ public: void unpickle(QByteArray &pickled, const PicklingMode &mode); //! Serialises an OlmAccount to encrypted Base64. - std::variant<QByteArray, QOlmError> pickle(const PicklingMode &mode); + QOlmExpected<QByteArray> pickle(const PicklingMode &mode); //! Returns the account's public identity keys already formatted as JSON IdentityKeys identityKeys() const; @@ -61,7 +56,7 @@ public: size_t maxNumberOfOneTimeKeys() const; //! Generates the supplied number of one time keys. - size_t generateOneTimeKeys(size_t numberOfKeys) const; + size_t generateOneTimeKeys(size_t numberOfKeys); //! Gets the OlmAccount's one time keys formatted as JSON. OneTimeKeys oneTimeKeys() const; @@ -79,22 +74,26 @@ public: DeviceKeys deviceKeys() const; //! Remove the one time key used to create the supplied session. - [[nodiscard]] std::optional<QOlmError> removeOneTimeKeys(const QOlmSessionPtr &session) const; + [[nodiscard]] std::optional<QOlmError> removeOneTimeKeys( + const QOlmSession& session); //! Creates an inbound session for sending/receiving messages from a received 'prekey' message. //! //! \param message An Olm pre-key message that was encrypted for this account. - std::variant<QOlmSessionPtr, QOlmError> createInboundSession(const QOlmMessage &preKeyMessage); + QOlmExpected<QOlmSessionPtr> createInboundSession( + const QOlmMessage& preKeyMessage); //! Creates an inbound session for sending/receiving messages from a received 'prekey' message. //! //! \param theirIdentityKey - The identity key of the Olm account that //! encrypted this Olm message. - std::variant<QOlmSessionPtr, QOlmError> createInboundSessionFrom(const QByteArray &theirIdentityKey, const QOlmMessage &preKeyMessage); + QOlmExpected<QOlmSessionPtr> createInboundSessionFrom( + const QByteArray& theirIdentityKey, const QOlmMessage& preKeyMessage); //! Creates an outbound session for sending messages to a specific /// identity and one time key. - std::variant<QOlmSessionPtr, QOlmError> createOutboundSession(const QByteArray &theirIdentityKey, const QByteArray &theirOneTimeKey); + QOlmExpected<QOlmSessionPtr> createOutboundSession( + const QByteArray& theirIdentityKey, const QByteArray& theirOneTimeKey); void markKeysAsPublished(); @@ -103,7 +102,7 @@ public: OlmAccount *data(); Q_SIGNALS: - void needsSave() const; + void needsSave(); private: OlmAccount *m_account = nullptr; // owning |