aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-06-24 15:54:36 +0200
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-06-24 18:41:05 +0200
commit4d4d363b29ff4e471511ff454a58d7d8b88d215d (patch)
tree0836ebd51ba7a4433e0d1be6c9dd792be91573df
parent7fdb1a8653863f580b2672faefc08fb372258df8 (diff)
downloadlibquotient-4d4d363b29ff4e471511ff454a58d7d8b88d215d.tar.gz
libquotient-4d4d363b29ff4e471511ff454a58d7d8b88d215d.zip
Start using C++20's designated initializers
-rw-r--r--lib/e2ee/e2ee.h6
-rw-r--r--lib/e2ee/qolmaccount.cpp22
2 files changed, 14 insertions, 14 deletions
diff --git a/lib/e2ee/e2ee.h b/lib/e2ee/e2ee.h
index 7b9b5820..449e6ef7 100644
--- a/lib/e2ee/e2ee.h
+++ b/lib/e2ee/e2ee.h
@@ -37,11 +37,11 @@ constexpr auto SignedCurve25519Key = "signed_curve25519"_ls;
constexpr auto OlmV1Curve25519AesSha2AlgoKey = "m.olm.v1.curve25519-aes-sha2"_ls;
constexpr auto MegolmV1AesSha2AlgoKey = "m.megolm.v1.aes-sha2"_ls;
+constexpr std::array SupportedAlgorithms { OlmV1Curve25519AesSha2AlgoKey,
+ MegolmV1AesSha2AlgoKey };
+
inline bool isSupportedAlgorithm(const QString& algorithm)
{
- static constexpr std::array SupportedAlgorithms {
- OlmV1Curve25519AesSha2AlgoKey, MegolmV1AesSha2AlgoKey
- };
return std::find(SupportedAlgorithms.cbegin(), SupportedAlgorithms.cend(),
algorithm)
!= SupportedAlgorithms.cend();
diff --git a/lib/e2ee/qolmaccount.cpp b/lib/e2ee/qolmaccount.cpp
index cd10f165..ccb191f4 100644
--- a/lib/e2ee/qolmaccount.cpp
+++ b/lib/e2ee/qolmaccount.cpp
@@ -187,19 +187,19 @@ OlmAccount* QOlmAccount::data() { return m_account; }
DeviceKeys QOlmAccount::deviceKeys() const
{
- DeviceKeys deviceKeys;
- deviceKeys.userId = m_userId;
- deviceKeys.deviceId = m_deviceId;
- deviceKeys.algorithms = QStringList {"m.olm.v1.curve25519-aes-sha2", "m.megolm.v1.aes-sha2"};
+ static QStringList Algorithms(SupportedAlgorithms.cbegin(),
+ SupportedAlgorithms.cend());
const auto idKeys = identityKeys();
- deviceKeys.keys["curve25519:" + m_deviceId] = idKeys.curve25519;
- deviceKeys.keys["ed25519:" + m_deviceId] = idKeys.ed25519;
-
- const auto sign = signIdentityKeys();
- deviceKeys.signatures[m_userId]["ed25519:" + m_deviceId] = sign;
-
- return deviceKeys;
+ return DeviceKeys {
+ .userId = m_userId,
+ .deviceId = m_deviceId,
+ .algorithms = Algorithms,
+ .keys { { "curve25519:" + m_deviceId, idKeys.curve25519 },
+ { "ed25519:" + m_deviceId, idKeys.ed25519 } },
+ .signatures {
+ { m_userId, { { "ed25519:" + m_deviceId, signIdentityKeys() } } } }
+ };
}
UploadKeysJob* QOlmAccount::createUploadKeyRequest(