aboutsummaryrefslogtreecommitdiff
path: root/lib/events/keyverificationevent.h
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-06-09 10:19:14 +0200
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-06-23 07:57:43 +0200
commit19746de7426aeb67eb90e8c48448356691e270b0 (patch)
treea398f362ff7351e86afb4af87b459f335b7efb10 /lib/events/keyverificationevent.h
parent7576f77799c3d446d3376b0801f218a86320480d (diff)
downloadlibquotient-19746de7426aeb67eb90e8c48448356691e270b0.tar.gz
libquotient-19746de7426aeb67eb90e8c48448356691e270b0.zip
Use QUO_CONTENT_GETTER
In keyverificationevent.*, this massively shortens repetitive getter definitions; the remaining few non-trivial ones are moved to keyverificationevent.h, dropping the respective .cpp file and therefore the dedicated translation unit. In roomkeyevent.h, it's just shorter.
Diffstat (limited to 'lib/events/keyverificationevent.h')
-rw-r--r--lib/events/keyverificationevent.h80
1 files changed, 51 insertions, 29 deletions
diff --git a/lib/events/keyverificationevent.h b/lib/events/keyverificationevent.h
index 497e56a2..78457e0c 100644
--- a/lib/events/keyverificationevent.h
+++ b/lib/events/keyverificationevent.h
@@ -14,20 +14,20 @@ public:
explicit KeyVerificationRequestEvent(const QJsonObject& obj);
/// The device ID which is initiating the request.
- QString fromDevice() const;
+ QUO_CONTENT_GETTER(QString, fromDevice)
/// An opaque identifier for the verification request. Must
/// be unique with respect to the devices involved.
- QString transactionId() const;
+ QUO_CONTENT_GETTER(QString, transactionId)
/// The verification methods supported by the sender.
- QStringList methods() const;
+ QUO_CONTENT_GETTER(QStringList, methods)
/// The POSIX timestamp in milliseconds for when the request was
/// made. If the request is in the future by more than 5 minutes or
/// more than 10 minutes in the past, the message should be ignored
/// by the receiver.
- uint64_t timestamp() const;
+ QUO_CONTENT_GETTER(uint64_t, timestamp)
};
REGISTER_EVENT_TYPE(KeyVerificationRequestEvent)
@@ -39,36 +39,52 @@ public:
explicit KeyVerificationStartEvent(const QJsonObject &obj);
/// The device ID which is initiating the process.
- QString fromDevice() const;
+ QUO_CONTENT_GETTER(QString, fromDevice)
/// An opaque identifier for the verification request. Must
/// be unique with respect to the devices involved.
- QString transactionId() const;
+ QUO_CONTENT_GETTER(QString, transactionId)
/// The verification method to use.
- QString method() const;
+ QUO_CONTENT_GETTER(QString, method)
/// Optional method to use to verify the other user's key with.
- Omittable<QString> nextMethod() const;
+ QUO_CONTENT_GETTER(Omittable<QString>, nextMethod)
// SAS.V1 methods
/// The key agreement protocols the sending device understands.
/// \note Only exist if method is m.sas.v1
- QStringList keyAgreementProtocols() const;
+ QStringList keyAgreementProtocols() const
+ {
+ Q_ASSERT(method() == QStringLiteral("m.sas.v1"));
+ return contentPart<QStringList>("key_agreement_protocols"_ls);
+ }
/// The hash methods the sending device understands.
/// \note Only exist if method is m.sas.v1
- QStringList hashes() const;
+ QStringList hashes() const
+ {
+ Q_ASSERT(method() == QStringLiteral("m.sas.v1"));
+ return contentPart<QStringList>("hashes"_ls);
+ }
/// The message authentication codes that the sending device understands.
/// \note Only exist if method is m.sas.v1
- QStringList messageAuthenticationCodes() const;
+ QStringList messageAuthenticationCodes() const
+ {
+ Q_ASSERT(method() == QStringLiteral("m.sas.v1"));
+ return contentPart<QStringList>("message_authentication_codes"_ls);
+ }
/// The SAS methods the sending device (and the sending device's
/// user) understands.
/// \note Only exist if method is m.sas.v1
- QString shortAuthenticationString() const;
+ QString shortAuthenticationString() const
+ {
+ Q_ASSERT(method() == QStringLiteral("m.sas.v1"));
+ return contentPart<QString>("short_authentification_string"_ls);
+ }
};
REGISTER_EVENT_TYPE(KeyVerificationStartEvent)
@@ -81,30 +97,33 @@ public:
explicit KeyVerificationAcceptEvent(const QJsonObject& obj);
/// An opaque identifier for the verification process.
- QString transactionId() const;
+ QUO_CONTENT_GETTER(QString, transactionId)
/// The verification method to use. Must be 'm.sas.v1'.
- QString method() const;
+ QUO_CONTENT_GETTER(QString, method)
/// The key agreement protocol the device is choosing to use, out of
/// the options in the m.key.verification.start message.
- QString keyAgreementProtocol() const;
+ QUO_CONTENT_GETTER(QString, keyAgreementProtocol)
/// The hash method the device is choosing to use, out of the
/// options in the m.key.verification.start message.
- QString hashData() const;
+ QString hashData() const
+ {
+ return contentPart<QString>("hash"_ls);
+ }
/// The message authentication code the device is choosing to use, out
/// of the options in the m.key.verification.start message.
- QString messageAuthenticationCode() const;
+ QUO_CONTENT_GETTER(QString, messageAuthenticationCode)
/// The SAS methods both devices involved in the verification process understand.
- QStringList shortAuthenticationString() const;
+ QUO_CONTENT_GETTER(QStringList, shortAuthenticationString)
/// The hash (encoded as unpadded base64) of the concatenation of the
/// device's ephemeral public key (encoded as unpadded base64) and the
/// canonical JSON representation of the m.key.verification.start message.
- QString commitement() const;
+ QUO_CONTENT_GETTER(QString, commitment)
};
REGISTER_EVENT_TYPE(KeyVerificationAcceptEvent)
@@ -115,14 +134,14 @@ public:
explicit KeyVerificationCancelEvent(const QJsonObject &obj);
/// An opaque identifier for the verification process.
- QString transactionId() const;
+ QUO_CONTENT_GETTER(QString, transactionId)
/// A human readable description of the code. The client should only
/// rely on this string if it does not understand the code.
- QString reason() const;
+ QUO_CONTENT_GETTER(QString, reason)
/// The error code for why the process/request was cancelled by the user.
- QString code() const;
+ QUO_CONTENT_GETTER(QString, code)
};
REGISTER_EVENT_TYPE(KeyVerificationCancelEvent)
@@ -134,11 +153,11 @@ public:
explicit KeyVerificationKeyEvent(const QJsonObject &obj);
- /// An opaque identifier for the verification process.
- QString transactionId() const;
+ /// An opaque identifier for the verification process.
+ QUO_CONTENT_GETTER(QString, transactionId)
/// The device's ephemeral public key, encoded as unpadded base64.
- QString key() const;
+ QUO_CONTENT_GETTER(QString, key)
};
REGISTER_EVENT_TYPE(KeyVerificationKeyEvent)
@@ -149,13 +168,16 @@ public:
explicit KeyVerificationMacEvent(const QJsonObject &obj);
- /// An opaque identifier for the verification process.
- QString transactionId() const;
+ /// An opaque identifier for the verification process.
+ QUO_CONTENT_GETTER(QString, transactionId)
/// The device's ephemeral public key, encoded as unpadded base64.
- QString keys() const;
+ QUO_CONTENT_GETTER(QString, keys)
- QHash<QString, QString> mac() const;
+ QHash<QString, QString> mac() const
+ {
+ return contentPart<QHash<QString, QString>>("mac"_ls);
+ }
};
REGISTER_EVENT_TYPE(KeyVerificationMacEvent)
} // namespace Quotient