aboutsummaryrefslogtreecommitdiff
path: root/lib/e2ee/e2ee.h
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-09-26 15:20:53 +0200
committerGitHub <noreply@github.com>2022-09-26 15:20:53 +0200
commit4c8dcbc308eb0f4900e416e698f5f30e71daaad8 (patch)
treeaa5fdaa81234a21c6919fac4958f84d7c26cd397 /lib/e2ee/e2ee.h
parent5904a61c59f0eef00aef07ef998658fd791ff139 (diff)
parent15b840d82d4794358fbf1271ea76e446b47db7e5 (diff)
downloadlibquotient-4c8dcbc308eb0f4900e416e698f5f30e71daaad8.tar.gz
libquotient-4c8dcbc308eb0f4900e416e698f5f30e71daaad8.zip
Merge #571: Unify reporting and handling of Olm errors
Diffstat (limited to 'lib/e2ee/e2ee.h')
-rw-r--r--lib/e2ee/e2ee.h38
1 files changed, 11 insertions, 27 deletions
diff --git a/lib/e2ee/e2ee.h b/lib/e2ee/e2ee.h
index 0772b70a..5999c0be 100644
--- a/lib/e2ee/e2ee.h
+++ b/lib/e2ee/e2ee.h
@@ -6,21 +6,20 @@
#pragma once
#include "converters.h"
-#include "expected.h"
-#include "qolmerrors.h"
#include <QtCore/QMetaType>
#include <QtCore/QStringBuilder>
#include <array>
-#include <variant>
-namespace Quotient {
+#ifdef Quotient_E2EE_ENABLED
+# include "expected.h"
+
+# include <olm/error.h>
+# include <variant>
+#endif
-constexpr auto CiphertextKeyL = "ciphertext"_ls;
-constexpr auto SenderKeyKeyL = "sender_key"_ls;
-constexpr auto DeviceIdKeyL = "device_id"_ls;
-constexpr auto SessionIdKeyL = "session_id"_ls;
+namespace Quotient {
constexpr auto AlgorithmKeyL = "algorithm"_ls;
constexpr auto RotationPeriodMsKeyL = "rotation_period_ms"_ls;
@@ -47,6 +46,7 @@ inline bool isSupportedAlgorithm(const QString& algorithm)
!= SupportedAlgorithms.cend();
}
+#ifdef Quotient_E2EE_ENABLED
struct Unencrypted {};
struct Encrypted {
QByteArray key;
@@ -64,7 +64,8 @@ class QOlmOutboundGroupSession;
using QOlmOutboundGroupSessionPtr = std::unique_ptr<QOlmOutboundGroupSession>;
template <typename T>
-using QOlmExpected = Expected<T, QOlmError>;
+using QOlmExpected = Expected<T, OlmErrorCode>;
+#endif
struct IdentityKeys
{
@@ -97,7 +98,7 @@ public:
{}
//! Unpadded Base64-encoded 32-byte Curve25519 public key
- QString key() const { return payload["key"_ls].toString(); }
+ QByteArray key() const { return payload["key"_ls].toString().toLatin1(); }
//! \brief Signatures of the key object
//!
@@ -133,23 +134,6 @@ private:
using OneTimeKeys = QHash<QString, std::variant<QString, SignedOneTimeKey>>;
-template <typename T>
-class asKeyValueRange
-{
-public:
- asKeyValueRange(T& data)
- : m_data { data }
- {}
-
- auto begin() { return m_data.keyValueBegin(); }
- auto end() { return m_data.keyValueEnd(); }
-
-private:
- T &m_data;
-};
-template <typename T>
-asKeyValueRange(T&) -> asKeyValueRange<T>;
-
} // namespace Quotient
Q_DECLARE_METATYPE(Quotient::SignedOneTimeKey)