aboutsummaryrefslogtreecommitdiff
path: root/lib/events/encryptionevent.cpp
diff options
context:
space:
mode:
authorBlack Hat <bhat@encom.eu.org>2019-09-26 22:22:36 -0700
committerBlack Hat <bhat@encom.eu.org>2019-09-26 22:22:36 -0700
commit363cf452bcdbaf6ff1cf94a83ca66cbb31122346 (patch)
treec64c8fda885e4e1785130e8ee3e7c47fd18cbf67 /lib/events/encryptionevent.cpp
parent412e2cf19449e73aa7da729e9c5de6502687aade (diff)
parent944653463fe4134c82d85e2d01e2bc0fa43fd727 (diff)
downloadlibquotient-363cf452bcdbaf6ff1cf94a83ca66cbb31122346.tar.gz
libquotient-363cf452bcdbaf6ff1cf94a83ca66cbb31122346.zip
Merge branch 'master' of https://github.com/quotient-im/libQuotient into
bhat-libqtolm-update
Diffstat (limited to 'lib/events/encryptionevent.cpp')
-rw-r--r--lib/events/encryptionevent.cpp48
1 files changed, 24 insertions, 24 deletions
diff --git a/lib/events/encryptionevent.cpp b/lib/events/encryptionevent.cpp
index ee6c92b1..073303b0 100644
--- a/lib/events/encryptionevent.cpp
+++ b/lib/events/encryptionevent.cpp
@@ -6,47 +6,47 @@
#include "encryptionevent.h"
#include "converters.h"
-#include "logging.h"
#include "e2ee.h"
+#include "logging.h"
#include <array>
-static const std::array<QString, 1> encryptionStrings = { {
- QMatrixClient::MegolmV1AesSha2AlgoKey
-} };
+static const std::array<QString, 1> encryptionStrings = {
+ { Quotient::MegolmV1AesSha2AlgoKey }
+};
-namespace QMatrixClient {
- template <>
- struct JsonConverter<EncryptionType>
+namespace Quotient {
+template <>
+struct JsonConverter<EncryptionType> {
+ static EncryptionType load(const QJsonValue& jv)
{
- static EncryptionType load(const QJsonValue& jv)
- {
- const auto& encryptionString = jv.toString();
- for (auto it = encryptionStrings.begin();
- it != encryptionStrings.end(); ++it)
- if (encryptionString == *it)
- return EncryptionType(it - encryptionStrings.begin());
-
- qCWarning(EVENTS) << "Unknown EncryptionType: " << encryptionString;
- return EncryptionType::Undefined;
- }
- };
-}
+ const auto& encryptionString = jv.toString();
+ for (auto it = encryptionStrings.begin(); it != encryptionStrings.end();
+ ++it)
+ if (encryptionString == *it)
+ return EncryptionType(it - encryptionStrings.begin());
+
+ qCWarning(EVENTS) << "Unknown EncryptionType: " << encryptionString;
+ return EncryptionType::Undefined;
+ }
+};
+} // namespace Quotient
-using namespace QMatrixClient;
+using namespace Quotient;
EncryptionEventContent::EncryptionEventContent(const QJsonObject& json)
: encryption(fromJson<EncryptionType>(json["algorithm"_ls]))
, algorithm(sanitized(json[AlgorithmKeyL].toString()))
, rotationPeriodMs(json[RotationPeriodMsKeyL].toInt(604800000))
, rotationPeriodMsgs(json[RotationPeriodMsgsKeyL].toInt(100))
-{ }
+{}
void EncryptionEventContent::fillJson(QJsonObject* o) const
{
Q_ASSERT(o);
- Q_ASSERT_X(encryption != EncryptionType::Undefined, __FUNCTION__,
- "The key 'algorithm' must be explicit in EncryptionEventContent");
+ Q_ASSERT_X(
+ encryption != EncryptionType::Undefined, __FUNCTION__,
+ "The key 'algorithm' must be explicit in EncryptionEventContent");
if (encryption != EncryptionType::Undefined)
o->insert(AlgorithmKey, algorithm);
o->insert(RotationPeriodMsKey, rotationPeriodMs);