From 578ab26499d803929d5833c88a2215145eb35866 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Sun, 8 Jun 2025 09:28:08 +0200 Subject: [PATCH 1/8] Regenerate API with new ClangFormat config --- .../definitions/location.h | 10 +- .../definitions/protocol.h | 30 ++-- .../application-service/definitions/user.h | 10 +- Quotient/csapi/account-data.cpp | 26 +-- Quotient/csapi/account-data.h | 38 +++-- Quotient/csapi/admin.cpp | 4 +- Quotient/csapi/admin.h | 36 ++-- Quotient/csapi/administrative_contact.cpp | 38 ++--- Quotient/csapi/administrative_contact.h | 77 +++++---- Quotient/csapi/appservice_room_directory.cpp | 4 +- Quotient/csapi/appservice_room_directory.h | 9 +- Quotient/csapi/authed-content-repo.cpp | 48 +++--- Quotient/csapi/authed-content-repo.h | 66 ++++---- Quotient/csapi/banning.cpp | 8 +- Quotient/csapi/banning.h | 10 +- Quotient/csapi/capabilities.cpp | 2 +- Quotient/csapi/capabilities.h | 33 ++-- Quotient/csapi/content-repo.cpp | 64 +++---- Quotient/csapi/content-repo.h | 98 ++++++----- Quotient/csapi/create_room.cpp | 14 +- Quotient/csapi/create_room.h | 35 ++-- Quotient/csapi/cross_signing.cpp | 14 +- Quotient/csapi/cross_signing.h | 19 ++- Quotient/csapi/definitions/auth_data.h | 10 +- Quotient/csapi/definitions/client_device.h | 10 +- .../csapi/definitions/cross_signing_key.h | 10 +- Quotient/csapi/definitions/device_keys.h | 10 +- Quotient/csapi/definitions/event_filter.h | 10 +- Quotient/csapi/definitions/key_backup_data.h | 10 +- Quotient/csapi/definitions/openid_token.h | 10 +- .../csapi/definitions/public_rooms_response.h | 10 +- Quotient/csapi/definitions/push_condition.h | 10 +- Quotient/csapi/definitions/push_rule.h | 11 +- Quotient/csapi/definitions/push_ruleset.h | 11 +- .../definitions/request_email_validation.h | 10 +- .../definitions/request_msisdn_validation.h | 10 +- .../definitions/request_token_response.h | 10 +- .../csapi/definitions/room_event_filter.h | 11 +- Quotient/csapi/definitions/room_key_backup.h | 11 +- Quotient/csapi/definitions/sync_filter.h | 21 ++- Quotient/csapi/definitions/tag.h | 10 +- .../csapi/definitions/third_party_signed.h | 10 +- Quotient/csapi/definitions/user_identifier.h | 10 +- Quotient/csapi/definitions/wellknown/full.h | 11 +- .../csapi/definitions/wellknown/homeserver.h | 10 +- .../definitions/wellknown/identity_server.h | 10 +- Quotient/csapi/device_management.cpp | 22 +-- Quotient/csapi/device_management.h | 36 ++-- Quotient/csapi/directory.cpp | 16 +- Quotient/csapi/directory.h | 33 ++-- Quotient/csapi/event_context.cpp | 12 +- Quotient/csapi/event_context.h | 22 +-- Quotient/csapi/filter.cpp | 10 +- Quotient/csapi/filter.h | 19 ++- Quotient/csapi/inviting.cpp | 4 +- Quotient/csapi/inviting.h | 5 +- Quotient/csapi/joining.cpp | 20 +-- Quotient/csapi/joining.h | 25 +-- Quotient/csapi/key_backup.cpp | 92 +++++----- Quotient/csapi/key_backup.h | 157 ++++++++++-------- Quotient/csapi/keys.cpp | 22 +-- Quotient/csapi/keys.h | 65 ++++---- Quotient/csapi/kicking.cpp | 4 +- Quotient/csapi/kicking.h | 5 +- Quotient/csapi/knocking.cpp | 8 +- Quotient/csapi/knocking.h | 9 +- Quotient/csapi/leaving.cpp | 8 +- Quotient/csapi/leaving.h | 12 +- Quotient/csapi/list_joined_rooms.cpp | 2 +- Quotient/csapi/list_joined_rooms.h | 7 +- Quotient/csapi/list_public_rooms.cpp | 32 ++-- Quotient/csapi/list_public_rooms.h | 59 ++++--- Quotient/csapi/login.cpp | 10 +- Quotient/csapi/login.h | 40 +++-- Quotient/csapi/login_token.cpp | 4 +- Quotient/csapi/login_token.h | 14 +- Quotient/csapi/logout.cpp | 4 +- Quotient/csapi/logout.h | 10 +- Quotient/csapi/message_pagination.cpp | 16 +- Quotient/csapi/message_pagination.h | 22 +-- Quotient/csapi/notifications.cpp | 10 +- Quotient/csapi/notifications.h | 24 +-- Quotient/csapi/openid.cpp | 4 +- Quotient/csapi/openid.h | 8 +- Quotient/csapi/peeking_events.cpp | 8 +- Quotient/csapi/peeking_events.h | 16 +- Quotient/csapi/presence.cpp | 10 +- Quotient/csapi/presence.h | 21 ++- Quotient/csapi/profile.cpp | 20 +-- Quotient/csapi/profile.h | 40 +++-- Quotient/csapi/pusher.cpp | 12 +- Quotient/csapi/pusher.h | 42 +++-- Quotient/csapi/pushrules.cpp | 50 +++--- Quotient/csapi/pushrules.h | 80 +++++---- Quotient/csapi/read_markers.cpp | 6 +- Quotient/csapi/read_markers.h | 7 +- Quotient/csapi/receipts.cpp | 6 +- Quotient/csapi/receipts.h | 7 +- Quotient/csapi/redaction.cpp | 6 +- Quotient/csapi/redaction.h | 9 +- Quotient/csapi/refresh.cpp | 4 +- Quotient/csapi/refresh.h | 12 +- Quotient/csapi/registration.cpp | 46 ++--- Quotient/csapi/registration.h | 72 ++++---- Quotient/csapi/registration_tokens.cpp | 6 +- Quotient/csapi/registration_tokens.h | 9 +- Quotient/csapi/relations.cpp | 50 +++--- Quotient/csapi/relations.h | 76 +++++---- Quotient/csapi/report_content.cpp | 6 +- Quotient/csapi/report_content.h | 7 +- Quotient/csapi/room_event_by_timestamp.cpp | 8 +- Quotient/csapi/room_event_by_timestamp.h | 16 +- Quotient/csapi/room_send.cpp | 6 +- Quotient/csapi/room_send.h | 9 +- Quotient/csapi/room_state.cpp | 6 +- Quotient/csapi/room_state.h | 9 +- Quotient/csapi/room_upgrades.cpp | 4 +- Quotient/csapi/room_upgrades.h | 7 +- Quotient/csapi/rooms.cpp | 36 ++-- Quotient/csapi/rooms.h | 65 ++++---- Quotient/csapi/search.cpp | 6 +- Quotient/csapi/search.h | 96 ++++++----- Quotient/csapi/space_hierarchy.cpp | 10 +- Quotient/csapi/space_hierarchy.h | 26 +-- Quotient/csapi/sso_login_redirect.cpp | 14 +- Quotient/csapi/sso_login_redirect.h | 16 +- Quotient/csapi/support.cpp | 2 +- Quotient/csapi/support.h | 18 +- Quotient/csapi/tags.cpp | 18 +- Quotient/csapi/tags.h | 28 ++-- Quotient/csapi/third_party_lookup.cpp | 38 ++--- Quotient/csapi/third_party_lookup.h | 59 ++++--- Quotient/csapi/third_party_membership.cpp | 8 +- Quotient/csapi/third_party_membership.h | 9 +- Quotient/csapi/threads_list.cpp | 12 +- Quotient/csapi/threads_list.h | 18 +- Quotient/csapi/to_device.cpp | 6 +- Quotient/csapi/to_device.h | 7 +- Quotient/csapi/typing.cpp | 4 +- Quotient/csapi/typing.h | 5 +- Quotient/csapi/users.cpp | 4 +- Quotient/csapi/users.h | 18 +- Quotient/csapi/versions.cpp | 2 +- Quotient/csapi/versions.h | 10 +- Quotient/csapi/voip.cpp | 2 +- Quotient/csapi/voip.h | 7 +- Quotient/csapi/wellknown.cpp | 2 +- Quotient/csapi/wellknown.h | 8 +- Quotient/csapi/whoami.cpp | 2 +- Quotient/csapi/whoami.h | 12 +- 150 files changed, 1680 insertions(+), 1392 deletions(-) diff --git a/Quotient/application-service/definitions/location.h b/Quotient/application-service/definitions/location.h index a23e9e5be..7e3c49b29 100644 --- a/Quotient/application-service/definitions/location.h +++ b/Quotient/application-service/definitions/location.h @@ -6,7 +6,8 @@ namespace Quotient { -struct QUOTIENT_API ThirdPartyLocation { +struct QUOTIENT_API ThirdPartyLocation +{ //! An alias for a matrix room. QString alias; @@ -18,14 +19,15 @@ struct QUOTIENT_API ThirdPartyLocation { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const ThirdPartyLocation& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const ThirdPartyLocation &pod) { addParam(jo, "alias"_L1, pod.alias); addParam(jo, "protocol"_L1, pod.protocol); addParam(jo, "fields"_L1, pod.fields); } - static void fillFrom(const QJsonObject& jo, ThirdPartyLocation& pod) + static void fillFrom(const QJsonObject &jo, ThirdPartyLocation &pod) { fillFromJson(jo.value("alias"_L1), pod.alias); fillFromJson(jo.value("protocol"_L1), pod.protocol); diff --git a/Quotient/application-service/definitions/protocol.h b/Quotient/application-service/definitions/protocol.h index b167369c3..04bf23055 100644 --- a/Quotient/application-service/definitions/protocol.h +++ b/Quotient/application-service/definitions/protocol.h @@ -6,7 +6,8 @@ namespace Quotient { //! Definition of valid values for a field. -struct QUOTIENT_API FieldType { +struct QUOTIENT_API FieldType +{ //! A regular expression for validation of a field's value. This may be relatively //! coarse to verify the value as the application service providing this protocol //! may apply additional validation or filtering. @@ -17,20 +18,22 @@ struct QUOTIENT_API FieldType { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const FieldType& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const FieldType &pod) { addParam(jo, "regexp"_L1, pod.regexp); addParam(jo, "placeholder"_L1, pod.placeholder); } - static void fillFrom(const QJsonObject& jo, FieldType& pod) + static void fillFrom(const QJsonObject &jo, FieldType &pod) { fillFromJson(jo.value("regexp"_L1), pod.regexp); fillFromJson(jo.value("placeholder"_L1), pod.placeholder); } }; -struct QUOTIENT_API ProtocolInstance { +struct QUOTIENT_API ProtocolInstance +{ //! A human-readable description for the protocol, such as the name. QString desc; @@ -46,15 +49,16 @@ struct QUOTIENT_API ProtocolInstance { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const ProtocolInstance& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const ProtocolInstance &pod) { addParam(jo, "desc"_L1, pod.desc); addParam(jo, "fields"_L1, pod.fields); addParam(jo, "network_id"_L1, pod.networkId); addParam(jo, "icon"_L1, pod.icon); } - static void fillFrom(const QJsonObject& jo, ProtocolInstance& pod) + static void fillFrom(const QJsonObject &jo, ProtocolInstance &pod) { fillFromJson(jo.value("desc"_L1), pod.desc); fillFromJson(jo.value("fields"_L1), pod.fields); @@ -63,7 +67,8 @@ struct JsonObjectConverter { } }; -struct QUOTIENT_API ThirdPartyProtocol { +struct QUOTIENT_API ThirdPartyProtocol +{ //! Fields which may be used to identify a third-party user. These should be //! ordered to suggest the way that entities may be grouped, where higher //! groupings are ordered first. For example, the name of a network should be @@ -93,8 +98,9 @@ struct QUOTIENT_API ThirdPartyProtocol { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const ThirdPartyProtocol& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const ThirdPartyProtocol &pod) { addParam(jo, "user_fields"_L1, pod.userFields); addParam(jo, "location_fields"_L1, pod.locationFields); @@ -102,7 +108,7 @@ struct JsonObjectConverter { addParam(jo, "field_types"_L1, pod.fieldTypes); addParam(jo, "instances"_L1, pod.instances); } - static void fillFrom(const QJsonObject& jo, ThirdPartyProtocol& pod) + static void fillFrom(const QJsonObject &jo, ThirdPartyProtocol &pod) { fillFromJson(jo.value("user_fields"_L1), pod.userFields); fillFromJson(jo.value("location_fields"_L1), pod.locationFields); diff --git a/Quotient/application-service/definitions/user.h b/Quotient/application-service/definitions/user.h index e1c795f9b..cdcd92410 100644 --- a/Quotient/application-service/definitions/user.h +++ b/Quotient/application-service/definitions/user.h @@ -6,7 +6,8 @@ namespace Quotient { -struct QUOTIENT_API ThirdPartyUser { +struct QUOTIENT_API ThirdPartyUser +{ //! A Matrix User ID representing a third-party user. QString userid; @@ -18,14 +19,15 @@ struct QUOTIENT_API ThirdPartyUser { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const ThirdPartyUser& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const ThirdPartyUser &pod) { addParam(jo, "userid"_L1, pod.userid); addParam(jo, "protocol"_L1, pod.protocol); addParam(jo, "fields"_L1, pod.fields); } - static void fillFrom(const QJsonObject& jo, ThirdPartyUser& pod) + static void fillFrom(const QJsonObject &jo, ThirdPartyUser &pod) { fillFromJson(jo.value("userid"_L1), pod.userid); fillFromJson(jo.value("protocol"_L1), pod.protocol); diff --git a/Quotient/csapi/account-data.cpp b/Quotient/csapi/account-data.cpp index 0fe71ec60..f76f98ff2 100644 --- a/Quotient/csapi/account-data.cpp +++ b/Quotient/csapi/account-data.cpp @@ -4,44 +4,44 @@ using namespace Quotient; -SetAccountDataJob::SetAccountDataJob(const QString& userId, const QString& type, - const QJsonObject& content) +SetAccountDataJob::SetAccountDataJob(const QString &userId, const QString &type, + const QJsonObject &content) : BaseJob(HttpVerb::Put, u"SetAccountDataJob"_s, makePath("/_matrix/client/v3", "/user/", userId, "/account_data/", type)) { - setRequestData({ toJson(content) }); + setRequestData({toJson(content)}); } -QUrl GetAccountDataJob::makeRequestUrl(const HomeserverData& hsData, const QString& userId, - const QString& type) +QUrl GetAccountDataJob::makeRequestUrl(const HomeserverData &hsData, const QString &userId, + const QString &type) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/user/", userId, "/account_data/", type)); } -GetAccountDataJob::GetAccountDataJob(const QString& userId, const QString& type) +GetAccountDataJob::GetAccountDataJob(const QString &userId, const QString &type) : BaseJob(HttpVerb::Get, u"GetAccountDataJob"_s, makePath("/_matrix/client/v3", "/user/", userId, "/account_data/", type)) {} -SetAccountDataPerRoomJob::SetAccountDataPerRoomJob(const QString& userId, const QString& roomId, - const QString& type, const QJsonObject& content) +SetAccountDataPerRoomJob::SetAccountDataPerRoomJob(const QString &userId, const QString &roomId, + const QString &type, const QJsonObject &content) : BaseJob(HttpVerb::Put, u"SetAccountDataPerRoomJob"_s, makePath("/_matrix/client/v3", "/user/", userId, "/rooms/", roomId, "/account_data/", type)) { - setRequestData({ toJson(content) }); + setRequestData({toJson(content)}); } -QUrl GetAccountDataPerRoomJob::makeRequestUrl(const HomeserverData& hsData, const QString& userId, - const QString& roomId, const QString& type) +QUrl GetAccountDataPerRoomJob::makeRequestUrl(const HomeserverData &hsData, const QString &userId, + const QString &roomId, const QString &type) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/user/", userId, "/rooms/", roomId, "/account_data/", type)); } -GetAccountDataPerRoomJob::GetAccountDataPerRoomJob(const QString& userId, const QString& roomId, - const QString& type) +GetAccountDataPerRoomJob::GetAccountDataPerRoomJob(const QString &userId, const QString &roomId, + const QString &type) : BaseJob(HttpVerb::Get, u"GetAccountDataPerRoomJob"_s, makePath("/_matrix/client/v3", "/user/", userId, "/rooms/", roomId, "/account_data/", type)) diff --git a/Quotient/csapi/account-data.h b/Quotient/csapi/account-data.h index 7dc5bc2ef..0b34bcf1f 100644 --- a/Quotient/csapi/account-data.h +++ b/Quotient/csapi/account-data.h @@ -12,7 +12,8 @@ namespace Quotient { //! that set the account data. The config will be available to clients through the //! top-level `account_data` field in the homeserver response to //! [/sync](#get_matrixclientv3sync). -class QUOTIENT_API SetAccountDataJob : public BaseJob { +class QUOTIENT_API SetAccountDataJob : public BaseJob +{ public: //! \param userId //! The ID of the user to set account data for. The access token must be @@ -24,15 +25,16 @@ class QUOTIENT_API SetAccountDataJob : public BaseJob { //! //! \param content //! The content of the account data. - explicit SetAccountDataJob(const QString& userId, const QString& type, - const QJsonObject& content = {}); + explicit SetAccountDataJob(const QString &userId, const QString &type, + const QJsonObject &content = {}); }; //! \brief Get some account data for the user. //! //! Get some account data for the client. This config is only visible to the user //! that set the account data. -class QUOTIENT_API GetAccountDataJob : public BaseJob { +class QUOTIENT_API GetAccountDataJob : public BaseJob +{ public: //! \param userId //! The ID of the user to get account data for. The access token must be @@ -41,14 +43,14 @@ class QUOTIENT_API GetAccountDataJob : public BaseJob { //! \param type //! The event type of the account data to get. Custom types should be //! namespaced to avoid clashes. - explicit GetAccountDataJob(const QString& userId, const QString& type); + explicit GetAccountDataJob(const QString &userId, const QString &type); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetAccountDataJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& userId, - const QString& type); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &userId, + const QString &type); // Result properties @@ -56,14 +58,15 @@ class QUOTIENT_API GetAccountDataJob : public BaseJob { QJsonObject data() const { return fromJson(jsonData()); } }; -inline auto collectResponse(const GetAccountDataJob* job) { return job->data(); } +inline auto collectResponse(const GetAccountDataJob *job) { return job->data(); } //! \brief Set some account data for the user that is specific to a room. //! //! Set some account data for the client on a given room. This config is only //! visible to the user that set the account data. The config will be delivered to //! clients in the per-room entries via [/sync](#get_matrixclientv3sync). -class QUOTIENT_API SetAccountDataPerRoomJob : public BaseJob { +class QUOTIENT_API SetAccountDataPerRoomJob : public BaseJob +{ public: //! \param userId //! The ID of the user to set account data for. The access token must be @@ -78,15 +81,16 @@ class QUOTIENT_API SetAccountDataPerRoomJob : public BaseJob { //! //! \param content //! The content of the account data. - explicit SetAccountDataPerRoomJob(const QString& userId, const QString& roomId, - const QString& type, const QJsonObject& content = {}); + explicit SetAccountDataPerRoomJob(const QString &userId, const QString &roomId, + const QString &type, const QJsonObject &content = {}); }; //! \brief Get some account data for the user that is specific to a room. //! //! Get some account data for the client on a given room. This config is only //! visible to the user that set the account data. -class QUOTIENT_API GetAccountDataPerRoomJob : public BaseJob { +class QUOTIENT_API GetAccountDataPerRoomJob : public BaseJob +{ public: //! \param userId //! The ID of the user to get account data for. The access token must be @@ -98,15 +102,15 @@ class QUOTIENT_API GetAccountDataPerRoomJob : public BaseJob { //! \param type //! The event type of the account data to get. Custom types should be //! namespaced to avoid clashes. - explicit GetAccountDataPerRoomJob(const QString& userId, const QString& roomId, - const QString& type); + explicit GetAccountDataPerRoomJob(const QString &userId, const QString &roomId, + const QString &type); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetAccountDataPerRoomJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& userId, - const QString& roomId, const QString& type); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &userId, + const QString &roomId, const QString &type); // Result properties @@ -114,6 +118,6 @@ class QUOTIENT_API GetAccountDataPerRoomJob : public BaseJob { QJsonObject data() const { return fromJson(jsonData()); } }; -inline auto collectResponse(const GetAccountDataPerRoomJob* job) { return job->data(); } +inline auto collectResponse(const GetAccountDataPerRoomJob *job) { return job->data(); } } // namespace Quotient diff --git a/Quotient/csapi/admin.cpp b/Quotient/csapi/admin.cpp index 5fce7ec99..e6514486b 100644 --- a/Quotient/csapi/admin.cpp +++ b/Quotient/csapi/admin.cpp @@ -4,12 +4,12 @@ using namespace Quotient; -QUrl GetWhoIsJob::makeRequestUrl(const HomeserverData& hsData, const QString& userId) +QUrl GetWhoIsJob::makeRequestUrl(const HomeserverData &hsData, const QString &userId) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/admin/whois/", userId)); } -GetWhoIsJob::GetWhoIsJob(const QString& userId) +GetWhoIsJob::GetWhoIsJob(const QString &userId) : BaseJob(HttpVerb::Get, u"GetWhoIsJob"_s, makePath("/_matrix/client/v3", "/admin/whois/", userId)) {} diff --git a/Quotient/csapi/admin.h b/Quotient/csapi/admin.h index 75134a193..e8f1ea557 100644 --- a/Quotient/csapi/admin.h +++ b/Quotient/csapi/admin.h @@ -13,11 +13,13 @@ namespace Quotient { //! This API may be restricted to only be called by the user being looked //! up, or by a server admin. Server-local administrator privileges are not //! specified in this document. -class QUOTIENT_API GetWhoIsJob : public BaseJob { +class QUOTIENT_API GetWhoIsJob : public BaseJob +{ public: // Inner data structures - struct QUOTIENT_API ConnectionInfo { + struct QUOTIENT_API ConnectionInfo + { //! Most recently seen IP address of the session. QString ip{}; @@ -28,12 +30,14 @@ class QUOTIENT_API GetWhoIsJob : public BaseJob { QString userAgent{}; }; - struct QUOTIENT_API SessionInfo { + struct QUOTIENT_API SessionInfo + { //! Information particular connections in the session. QVector connections{}; }; - struct QUOTIENT_API DeviceInfo { + struct QUOTIENT_API DeviceInfo + { //! A user's sessions (i.e. what they did with an access token from one login). QVector sessions{}; }; @@ -42,13 +46,13 @@ class QUOTIENT_API GetWhoIsJob : public BaseJob { //! \param userId //! The user to look up. - explicit GetWhoIsJob(const QString& userId); + explicit GetWhoIsJob(const QString &userId); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetWhoIsJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& userId); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &userId); // Result properties @@ -61,7 +65,8 @@ class QUOTIENT_API GetWhoIsJob : public BaseJob { return loadFromJson>("devices"_L1); } - struct Response { + struct Response + { //! The Matrix user ID of the user. QString userId{}; @@ -72,11 +77,12 @@ class QUOTIENT_API GetWhoIsJob : public BaseJob { template JobT> constexpr inline auto doCollectResponse = - [](JobT* j) -> GetWhoIsJob::Response { return { j->userId(), j->devices() }; }; + [](JobT *j) -> GetWhoIsJob::Response { return {j->userId(), j->devices()}; }; template <> -struct QUOTIENT_API JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, GetWhoIsJob::ConnectionInfo& result) +struct QUOTIENT_API JsonObjectConverter +{ + static void fillFrom(const QJsonObject &jo, GetWhoIsJob::ConnectionInfo &result) { fillFromJson(jo.value("ip"_L1), result.ip); fillFromJson(jo.value("last_seen"_L1), result.lastSeen); @@ -85,16 +91,18 @@ struct QUOTIENT_API JsonObjectConverter { }; template <> -struct QUOTIENT_API JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, GetWhoIsJob::SessionInfo& result) +struct QUOTIENT_API JsonObjectConverter +{ + static void fillFrom(const QJsonObject &jo, GetWhoIsJob::SessionInfo &result) { fillFromJson(jo.value("connections"_L1), result.connections); } }; template <> -struct QUOTIENT_API JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, GetWhoIsJob::DeviceInfo& result) +struct QUOTIENT_API JsonObjectConverter +{ + static void fillFrom(const QJsonObject &jo, GetWhoIsJob::DeviceInfo &result) { fillFromJson(jo.value("sessions"_L1), result.sessions); } diff --git a/Quotient/csapi/administrative_contact.cpp b/Quotient/csapi/administrative_contact.cpp index ed88020ea..1846a3499 100644 --- a/Quotient/csapi/administrative_contact.cpp +++ b/Quotient/csapi/administrative_contact.cpp @@ -4,7 +4,7 @@ using namespace Quotient; -QUrl GetAccount3PIDsJob::makeRequestUrl(const HomeserverData& hsData) +QUrl GetAccount3PIDsJob::makeRequestUrl(const HomeserverData &hsData) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/account/3pid")); } @@ -14,27 +14,27 @@ GetAccount3PIDsJob::GetAccount3PIDsJob() makePath("/_matrix/client/v3", "/account/3pid")) {} -Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds) +Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials &threePidCreds) : BaseJob(HttpVerb::Post, u"Post3PIDsJob"_s, makePath("/_matrix/client/v3", "/account/3pid")) { QJsonObject _dataJson; addParam(_dataJson, "three_pid_creds"_L1, threePidCreds); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } -Add3PIDJob::Add3PIDJob(const QString& clientSecret, const QString& sid, - const std::optional& auth) +Add3PIDJob::Add3PIDJob(const QString &clientSecret, const QString &sid, + const std::optional &auth) : BaseJob(HttpVerb::Post, u"Add3PIDJob"_s, makePath("/_matrix/client/v3", "/account/3pid/add")) { QJsonObject _dataJson; addParam(_dataJson, "auth"_L1, auth); addParam(_dataJson, "client_secret"_L1, clientSecret); addParam(_dataJson, "sid"_L1, sid); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } -Bind3PIDJob::Bind3PIDJob(const QString& clientSecret, const QString& idServer, - const QString& idAccessToken, const QString& sid) +Bind3PIDJob::Bind3PIDJob(const QString &clientSecret, const QString &idServer, + const QString &idAccessToken, const QString &sid) : BaseJob(HttpVerb::Post, u"Bind3PIDJob"_s, makePath("/_matrix/client/v3", "/account/3pid/bind")) { QJsonObject _dataJson; @@ -42,11 +42,11 @@ Bind3PIDJob::Bind3PIDJob(const QString& clientSecret, const QString& idServer, addParam(_dataJson, "id_server"_L1, idServer); addParam(_dataJson, "id_access_token"_L1, idAccessToken); addParam(_dataJson, "sid"_L1, sid); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } -Delete3pidFromAccountJob::Delete3pidFromAccountJob(const QString& medium, const QString& address, - const QString& idServer) +Delete3pidFromAccountJob::Delete3pidFromAccountJob(const QString &medium, const QString &address, + const QString &idServer) : BaseJob(HttpVerb::Post, u"Delete3pidFromAccountJob"_s, makePath("/_matrix/client/v3", "/account/3pid/delete")) { @@ -54,12 +54,12 @@ Delete3pidFromAccountJob::Delete3pidFromAccountJob(const QString& medium, const addParam(_dataJson, "id_server"_L1, idServer); addParam(_dataJson, "medium"_L1, medium); addParam(_dataJson, "address"_L1, address); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); addExpectedKey(u"id_server_unbind_result"_s); } -Unbind3pidFromAccountJob::Unbind3pidFromAccountJob(const QString& medium, const QString& address, - const QString& idServer) +Unbind3pidFromAccountJob::Unbind3pidFromAccountJob(const QString &medium, const QString &address, + const QString &idServer) : BaseJob(HttpVerb::Post, u"Unbind3pidFromAccountJob"_s, makePath("/_matrix/client/v3", "/account/3pid/unbind")) { @@ -67,20 +67,20 @@ Unbind3pidFromAccountJob::Unbind3pidFromAccountJob(const QString& medium, const addParam(_dataJson, "id_server"_L1, idServer); addParam(_dataJson, "medium"_L1, medium); addParam(_dataJson, "address"_L1, address); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); addExpectedKey(u"id_server_unbind_result"_s); } -RequestTokenTo3PIDEmailJob::RequestTokenTo3PIDEmailJob(const EmailValidationData& data) +RequestTokenTo3PIDEmailJob::RequestTokenTo3PIDEmailJob(const EmailValidationData &data) : BaseJob(HttpVerb::Post, u"RequestTokenTo3PIDEmailJob"_s, makePath("/_matrix/client/v3", "/account/3pid/email/requestToken"), false) { - setRequestData({ toJson(data) }); + setRequestData({toJson(data)}); } -RequestTokenTo3PIDMSISDNJob::RequestTokenTo3PIDMSISDNJob(const MsisdnValidationData& data) +RequestTokenTo3PIDMSISDNJob::RequestTokenTo3PIDMSISDNJob(const MsisdnValidationData &data) : BaseJob(HttpVerb::Post, u"RequestTokenTo3PIDMSISDNJob"_s, makePath("/_matrix/client/v3", "/account/3pid/msisdn/requestToken"), false) { - setRequestData({ toJson(data) }); + setRequestData({toJson(data)}); } diff --git a/Quotient/csapi/administrative_contact.h b/Quotient/csapi/administrative_contact.h index ec6dcbaa4..fe937caba 100644 --- a/Quotient/csapi/administrative_contact.h +++ b/Quotient/csapi/administrative_contact.h @@ -6,7 +6,6 @@ #include #include #include - #include namespace Quotient { @@ -21,11 +20,13 @@ namespace Quotient { //! //! Identifiers in this list may be used by the homeserver as, for example, //! identifiers that it will accept to reset the user's account password. -class QUOTIENT_API GetAccount3PIDsJob : public BaseJob { +class QUOTIENT_API GetAccount3PIDsJob : public BaseJob +{ public: // Inner data structures - struct QUOTIENT_API ThirdPartyIdentifier { + struct QUOTIENT_API ThirdPartyIdentifier + { //! The medium of the third-party identifier. QString medium; @@ -49,7 +50,7 @@ class QUOTIENT_API GetAccount3PIDsJob : public BaseJob { //! //! This function can be used when a URL for GetAccount3PIDsJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData); + static QUrl makeRequestUrl(const HomeserverData &hsData); // Result properties @@ -59,11 +60,12 @@ class QUOTIENT_API GetAccount3PIDsJob : public BaseJob { } }; -inline auto collectResponse(const GetAccount3PIDsJob* job) { return job->threepids(); } +inline auto collectResponse(const GetAccount3PIDsJob *job) { return job->threepids(); } template <> -struct QUOTIENT_API JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, GetAccount3PIDsJob::ThirdPartyIdentifier& result) +struct QUOTIENT_API JsonObjectConverter +{ + static void fillFrom(const QJsonObject &jo, GetAccount3PIDsJob::ThirdPartyIdentifier &result) { fillFromJson(jo.value("medium"_L1), result.medium); fillFromJson(jo.value("address"_L1), result.address); @@ -85,12 +87,14 @@ struct QUOTIENT_API JsonObjectConvertersubmitUrl(); } +inline auto collectResponse(const Post3PIDsJob *job) { return job->submitUrl(); } QT_WARNING_POP QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED template <> -struct QUOTIENT_API JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const Post3PIDsJob::ThreePidCredentials& pod) +struct QUOTIENT_API JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const Post3PIDsJob::ThreePidCredentials &pod) { addParam(jo, "client_secret"_L1, pod.clientSecret); addParam(jo, "id_server"_L1, pod.idServer); @@ -158,7 +163,8 @@ QT_WARNING_POP //! //! Homeservers should prevent the caller from adding a 3PID to their account if it has //! already been added to another user's account on the homeserver. -class QUOTIENT_API Add3PIDJob : public BaseJob { +class QUOTIENT_API Add3PIDJob : public BaseJob +{ public: //! \param clientSecret //! The client secret used in the session with the homeserver. @@ -169,8 +175,8 @@ class QUOTIENT_API Add3PIDJob : public BaseJob { //! \param auth //! Additional authentication information for the //! user-interactive authentication API. - explicit Add3PIDJob(const QString& clientSecret, const QString& sid, - const std::optional& auth = std::nullopt); + explicit Add3PIDJob(const QString &clientSecret, const QString &sid, + const std::optional &auth = std::nullopt); }; //! \brief Binds a 3PID to the user's account through an Identity Service. @@ -182,7 +188,8 @@ class QUOTIENT_API Add3PIDJob : public BaseJob { //! the identity server to the caller. //! //! Homeservers should track successful binds so they can be unbound later. -class QUOTIENT_API Bind3PIDJob : public BaseJob { +class QUOTIENT_API Bind3PIDJob : public BaseJob +{ public: //! \param clientSecret //! The client secret used in the session with the identity server. @@ -195,8 +202,8 @@ class QUOTIENT_API Bind3PIDJob : public BaseJob { //! //! \param sid //! The session identifier given by the identity server. - explicit Bind3PIDJob(const QString& clientSecret, const QString& idServer, - const QString& idAccessToken, const QString& sid); + explicit Bind3PIDJob(const QString &clientSecret, const QString &idServer, + const QString &idAccessToken, const QString &sid); }; //! \brief Deletes a third-party identifier from the user's account @@ -207,7 +214,8 @@ class QUOTIENT_API Bind3PIDJob : public BaseJob { //! Unlike other endpoints, this endpoint does not take an `id_access_token` //! parameter because the homeserver is expected to sign the request to the //! identity server instead. -class QUOTIENT_API Delete3pidFromAccountJob : public BaseJob { +class QUOTIENT_API Delete3pidFromAccountJob : public BaseJob +{ public: //! \param medium //! The medium of the third-party identifier being removed. @@ -220,8 +228,8 @@ class QUOTIENT_API Delete3pidFromAccountJob : public BaseJob { //! MUST use the `id_server` the identifier was added through. If the //! homeserver does not know the original `id_server`, it MUST return //! a `id_server_unbind_result` of `no-support`. - explicit Delete3pidFromAccountJob(const QString& medium, const QString& address, - const QString& idServer = {}); + explicit Delete3pidFromAccountJob(const QString &medium, const QString &address, + const QString &idServer = {}); // Result properties @@ -237,7 +245,7 @@ class QUOTIENT_API Delete3pidFromAccountJob : public BaseJob { } }; -inline auto collectResponse(const Delete3pidFromAccountJob* job) +inline auto collectResponse(const Delete3pidFromAccountJob *job) { return job->idServerUnbindResult(); } @@ -250,7 +258,8 @@ inline auto collectResponse(const Delete3pidFromAccountJob* job) //! Unlike other endpoints, this endpoint does not take an `id_access_token` //! parameter because the homeserver is expected to sign the request to the //! identity server instead. -class QUOTIENT_API Unbind3pidFromAccountJob : public BaseJob { +class QUOTIENT_API Unbind3pidFromAccountJob : public BaseJob +{ public: //! \param medium //! The medium of the third-party identifier being removed. @@ -263,8 +272,8 @@ class QUOTIENT_API Unbind3pidFromAccountJob : public BaseJob { //! MUST use the `id_server` the identifier was added through. If the //! homeserver does not know the original `id_server`, it MUST return //! a `id_server_unbind_result` of `no-support`. - explicit Unbind3pidFromAccountJob(const QString& medium, const QString& address, - const QString& idServer = {}); + explicit Unbind3pidFromAccountJob(const QString &medium, const QString &address, + const QString &idServer = {}); // Result properties @@ -279,7 +288,7 @@ class QUOTIENT_API Unbind3pidFromAccountJob : public BaseJob { } }; -inline auto collectResponse(const Unbind3pidFromAccountJob* job) +inline auto collectResponse(const Unbind3pidFromAccountJob *job) { return job->idServerUnbindResult(); } @@ -296,9 +305,10 @@ inline auto collectResponse(const Unbind3pidFromAccountJob* job) //! endpoint. The homeserver should validate //! the email itself, either by sending a validation email itself or by using //! a service it has control over. -class QUOTIENT_API RequestTokenTo3PIDEmailJob : public BaseJob { +class QUOTIENT_API RequestTokenTo3PIDEmailJob : public BaseJob +{ public: - explicit RequestTokenTo3PIDEmailJob(const EmailValidationData& data); + explicit RequestTokenTo3PIDEmailJob(const EmailValidationData &data); // Result properties @@ -308,7 +318,7 @@ class QUOTIENT_API RequestTokenTo3PIDEmailJob : public BaseJob { RequestTokenResponse response() const { return fromJson(jsonData()); } }; -inline auto collectResponse(const RequestTokenTo3PIDEmailJob* job) { return job->response(); } +inline auto collectResponse(const RequestTokenTo3PIDEmailJob *job) { return job->response(); } //! \brief Begins the validation process for a phone number for association with the user's account. //! @@ -321,9 +331,10 @@ inline auto collectResponse(const RequestTokenTo3PIDEmailJob* job) { return job- //! endpoint. The homeserver should validate //! the phone number itself, either by sending a validation message itself or by using //! a service it has control over. -class QUOTIENT_API RequestTokenTo3PIDMSISDNJob : public BaseJob { +class QUOTIENT_API RequestTokenTo3PIDMSISDNJob : public BaseJob +{ public: - explicit RequestTokenTo3PIDMSISDNJob(const MsisdnValidationData& data); + explicit RequestTokenTo3PIDMSISDNJob(const MsisdnValidationData &data); // Result properties @@ -331,6 +342,6 @@ class QUOTIENT_API RequestTokenTo3PIDMSISDNJob : public BaseJob { RequestTokenResponse response() const { return fromJson(jsonData()); } }; -inline auto collectResponse(const RequestTokenTo3PIDMSISDNJob* job) { return job->response(); } +inline auto collectResponse(const RequestTokenTo3PIDMSISDNJob *job) { return job->response(); } } // namespace Quotient diff --git a/Quotient/csapi/appservice_room_directory.cpp b/Quotient/csapi/appservice_room_directory.cpp index 62deb01a1..24ec764f3 100644 --- a/Quotient/csapi/appservice_room_directory.cpp +++ b/Quotient/csapi/appservice_room_directory.cpp @@ -5,12 +5,12 @@ using namespace Quotient; UpdateAppserviceRoomDirectoryVisibilityJob::UpdateAppserviceRoomDirectoryVisibilityJob( - const QString& networkId, const QString& roomId, const QString& visibility) + const QString &networkId, const QString &roomId, const QString &visibility) : BaseJob(HttpVerb::Put, u"UpdateAppserviceRoomDirectoryVisibilityJob"_s, makePath("/_matrix/client/v3", "/directory/list/appservice/", networkId, "/", roomId), false) { QJsonObject _dataJson; addParam(_dataJson, "visibility"_L1, visibility); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } diff --git a/Quotient/csapi/appservice_room_directory.h b/Quotient/csapi/appservice_room_directory.h index 2b2148d20..71d2a9708 100644 --- a/Quotient/csapi/appservice_room_directory.h +++ b/Quotient/csapi/appservice_room_directory.h @@ -17,7 +17,8 @@ namespace Quotient { //! This API requires the use of an application service access token (`as_token`) //! instead of a typical client's access_token. This API cannot be invoked by //! users who are not identified as application services. -class QUOTIENT_API UpdateAppserviceRoomDirectoryVisibilityJob : public BaseJob { +class QUOTIENT_API UpdateAppserviceRoomDirectoryVisibilityJob : public BaseJob +{ public: //! \param networkId //! The protocol (network) ID to update the room list for. This would @@ -30,9 +31,9 @@ class QUOTIENT_API UpdateAppserviceRoomDirectoryVisibilityJob : public BaseJob { //! \param visibility //! Whether the room should be visible (public) in the directory //! or not (private). - explicit UpdateAppserviceRoomDirectoryVisibilityJob(const QString& networkId, - const QString& roomId, - const QString& visibility); + explicit UpdateAppserviceRoomDirectoryVisibilityJob(const QString &networkId, + const QString &roomId, + const QString &visibility); }; } // namespace Quotient diff --git a/Quotient/csapi/authed-content-repo.cpp b/Quotient/csapi/authed-content-repo.cpp index d8a114322..54a38409d 100644 --- a/Quotient/csapi/authed-content-repo.cpp +++ b/Quotient/csapi/authed-content-repo.cpp @@ -11,8 +11,8 @@ auto queryToGetContentAuthed(qint64 timeoutMs) return _q; } -QUrl GetContentAuthedJob::makeRequestUrl(const HomeserverData& hsData, const QString& serverName, - const QString& mediaId, qint64 timeoutMs) +QUrl GetContentAuthedJob::makeRequestUrl(const HomeserverData &hsData, const QString &serverName, + const QString &mediaId, qint64 timeoutMs) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v1", "/media/download/", serverName, @@ -20,13 +20,13 @@ QUrl GetContentAuthedJob::makeRequestUrl(const HomeserverData& hsData, const QSt queryToGetContentAuthed(timeoutMs)); } -GetContentAuthedJob::GetContentAuthedJob(const QString& serverName, const QString& mediaId, +GetContentAuthedJob::GetContentAuthedJob(const QString &serverName, const QString &mediaId, qint64 timeoutMs) : BaseJob(HttpVerb::Get, u"GetContentAuthedJob"_s, makePath("/_matrix/client/v1", "/media/download/", serverName, "/", mediaId), queryToGetContentAuthed(timeoutMs)) { - setExpectedContentTypes({ "application/octet-stream" }); + setExpectedContentTypes({"application/octet-stream"}); } auto queryToGetContentOverrideNameAuthed(qint64 timeoutMs) @@ -36,10 +36,10 @@ auto queryToGetContentOverrideNameAuthed(qint64 timeoutMs) return _q; } -QUrl GetContentOverrideNameAuthedJob::makeRequestUrl(const HomeserverData& hsData, - const QString& serverName, - const QString& mediaId, - const QString& fileName, qint64 timeoutMs) +QUrl GetContentOverrideNameAuthedJob::makeRequestUrl(const HomeserverData &hsData, + const QString &serverName, + const QString &mediaId, + const QString &fileName, qint64 timeoutMs) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v1", "/media/download/", serverName, @@ -47,19 +47,19 @@ QUrl GetContentOverrideNameAuthedJob::makeRequestUrl(const HomeserverData& hsDat queryToGetContentOverrideNameAuthed(timeoutMs)); } -GetContentOverrideNameAuthedJob::GetContentOverrideNameAuthedJob(const QString& serverName, - const QString& mediaId, - const QString& fileName, +GetContentOverrideNameAuthedJob::GetContentOverrideNameAuthedJob(const QString &serverName, + const QString &mediaId, + const QString &fileName, qint64 timeoutMs) : BaseJob(HttpVerb::Get, u"GetContentOverrideNameAuthedJob"_s, makePath("/_matrix/client/v1", "/media/download/", serverName, "/", mediaId, "/", fileName), queryToGetContentOverrideNameAuthed(timeoutMs)) { - setExpectedContentTypes({ "application/octet-stream" }); + setExpectedContentTypes({"application/octet-stream"}); } -auto queryToGetContentThumbnailAuthed(int width, int height, const QString& method, +auto queryToGetContentThumbnailAuthed(int width, int height, const QString &method, qint64 timeoutMs, std::optional animated) { QUrlQuery _q; @@ -71,9 +71,9 @@ auto queryToGetContentThumbnailAuthed(int width, int height, const QString& meth return _q; } -QUrl GetContentThumbnailAuthedJob::makeRequestUrl(const HomeserverData& hsData, - const QString& serverName, const QString& mediaId, - int width, int height, const QString& method, +QUrl GetContentThumbnailAuthedJob::makeRequestUrl(const HomeserverData &hsData, + const QString &serverName, const QString &mediaId, + int width, int height, const QString &method, qint64 timeoutMs, std::optional animated) { return BaseJob::makeRequestUrl( @@ -81,19 +81,19 @@ QUrl GetContentThumbnailAuthedJob::makeRequestUrl(const HomeserverData& hsData, queryToGetContentThumbnailAuthed(width, height, method, timeoutMs, animated)); } -GetContentThumbnailAuthedJob::GetContentThumbnailAuthedJob(const QString& serverName, - const QString& mediaId, int width, - int height, const QString& method, +GetContentThumbnailAuthedJob::GetContentThumbnailAuthedJob(const QString &serverName, + const QString &mediaId, int width, + int height, const QString &method, qint64 timeoutMs, std::optional animated) : BaseJob(HttpVerb::Get, u"GetContentThumbnailAuthedJob"_s, makePath("/_matrix/client/v1", "/media/thumbnail/", serverName, "/", mediaId), queryToGetContentThumbnailAuthed(width, height, method, timeoutMs, animated)) { - setExpectedContentTypes({ "image/jpeg", "image/png", "image/apng", "image/gif", "image/webp" }); + setExpectedContentTypes({"image/jpeg", "image/png", "image/apng", "image/gif", "image/webp"}); } -auto queryToGetUrlPreviewAuthed(const QUrl& url, std::optional ts) +auto queryToGetUrlPreviewAuthed(const QUrl &url, std::optional ts) { QUrlQuery _q; addParam(_q, u"url"_s, url); @@ -101,20 +101,20 @@ auto queryToGetUrlPreviewAuthed(const QUrl& url, std::optional ts) return _q; } -QUrl GetUrlPreviewAuthedJob::makeRequestUrl(const HomeserverData& hsData, const QUrl& url, +QUrl GetUrlPreviewAuthedJob::makeRequestUrl(const HomeserverData &hsData, const QUrl &url, std::optional ts) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v1", "/media/preview_url"), queryToGetUrlPreviewAuthed(url, ts)); } -GetUrlPreviewAuthedJob::GetUrlPreviewAuthedJob(const QUrl& url, std::optional ts) +GetUrlPreviewAuthedJob::GetUrlPreviewAuthedJob(const QUrl &url, std::optional ts) : BaseJob(HttpVerb::Get, u"GetUrlPreviewAuthedJob"_s, makePath("/_matrix/client/v1", "/media/preview_url"), queryToGetUrlPreviewAuthed(url, ts)) {} -QUrl GetConfigAuthedJob::makeRequestUrl(const HomeserverData& hsData) +QUrl GetConfigAuthedJob::makeRequestUrl(const HomeserverData &hsData) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v1", "/media/config")); } diff --git a/Quotient/csapi/authed-content-repo.h b/Quotient/csapi/authed-content-repo.h index 2c26aa63b..9ec5b6b86 100644 --- a/Quotient/csapi/authed-content-repo.h +++ b/Quotient/csapi/authed-content-repo.h @@ -19,7 +19,8 @@ namespace Quotient { //! Clients MAY be redirected using the 307/308 responses below to download //! the request object. This is typical when the homeserver uses a Content //! Delivery Network (CDN). -class QUOTIENT_API GetContentAuthedJob : public BaseJob { +class QUOTIENT_API GetContentAuthedJob : public BaseJob +{ public: //! \param serverName //! The server name from the `mxc://` URI (the authority component). @@ -33,15 +34,15 @@ class QUOTIENT_API GetContentAuthedJob : public BaseJob { //! uploaded. The default value is 20000 (20 seconds). The content //! repository SHOULD impose a maximum value for this parameter. The //! content repository MAY respond before the timeout. - explicit GetContentAuthedJob(const QString& serverName, const QString& mediaId, - qint64 timeoutMs = 20000); + explicit GetContentAuthedJob(const QString &serverName, const QString &mediaId, + qint64 timeoutMs = 20'000); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetContentAuthedJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& serverName, - const QString& mediaId, qint64 timeoutMs = 20000); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &serverName, + const QString &mediaId, qint64 timeoutMs = 20'000); // Result properties @@ -87,7 +88,7 @@ class QUOTIENT_API GetContentAuthedJob : public BaseJob { } //! The content that was previously uploaded. - QIODevice* data() { return reply(); } + QIODevice *data() { return reply(); } }; //! \brief Download content from the content repository overriding the file name. @@ -104,7 +105,8 @@ class QUOTIENT_API GetContentAuthedJob : public BaseJob { //! Clients MAY be redirected using the 307/308 responses below to download //! the request object. This is typical when the homeserver uses a Content //! Delivery Network (CDN). -class QUOTIENT_API GetContentOverrideNameAuthedJob : public BaseJob { +class QUOTIENT_API GetContentOverrideNameAuthedJob : public BaseJob +{ public: //! \param serverName //! The server name from the `mxc://` URI (the authority component). @@ -121,16 +123,16 @@ class QUOTIENT_API GetContentOverrideNameAuthedJob : public BaseJob { //! uploaded. The default value is 20000 (20 seconds). The content //! repository SHOULD impose a maximum value for this parameter. The //! content repository MAY respond before the timeout. - explicit GetContentOverrideNameAuthedJob(const QString& serverName, const QString& mediaId, - const QString& fileName, qint64 timeoutMs = 20000); + explicit GetContentOverrideNameAuthedJob(const QString &serverName, const QString &mediaId, + const QString &fileName, qint64 timeoutMs = 20'000); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetContentOverrideNameAuthedJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& serverName, - const QString& mediaId, const QString& fileName, - qint64 timeoutMs = 20000); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &serverName, + const QString &mediaId, const QString &fileName, + qint64 timeoutMs = 20'000); // Result properties @@ -168,7 +170,7 @@ class QUOTIENT_API GetContentOverrideNameAuthedJob : public BaseJob { } //! The content that was previously uploaded. - QIODevice* data() { return reply(); } + QIODevice *data() { return reply(); } }; //! \brief Download a thumbnail of content from the content repository @@ -184,7 +186,8 @@ class QUOTIENT_API GetContentOverrideNameAuthedJob : public BaseJob { //! Clients MAY be redirected using the 307/308 responses below to download //! the request object. This is typical when the homeserver uses a Content //! Delivery Network (CDN). -class QUOTIENT_API GetContentThumbnailAuthedJob : public BaseJob { +class QUOTIENT_API GetContentThumbnailAuthedJob : public BaseJob +{ public: //! \param serverName //! The server name from the `mxc://` URI (the authority component). @@ -226,18 +229,18 @@ class QUOTIENT_API GetContentThumbnailAuthedJob : public BaseJob { //! //! When `true` and the media cannot be animated, such as in the case of a JPEG or PDF, the //! server SHOULD behave as though `animated` is `false`. - explicit GetContentThumbnailAuthedJob(const QString& serverName, const QString& mediaId, - int width, int height, const QString& method = {}, - qint64 timeoutMs = 20000, + explicit GetContentThumbnailAuthedJob(const QString &serverName, const QString &mediaId, + int width, int height, const QString &method = {}, + qint64 timeoutMs = 20'000, std::optional animated = std::nullopt); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetContentThumbnailAuthedJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& serverName, - const QString& mediaId, int width, int height, - const QString& method = {}, qint64 timeoutMs = 20000, + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &serverName, + const QString &mediaId, int width, int height, + const QString &method = {}, qint64 timeoutMs = 20'000, std::optional animated = std::nullopt); // Result properties @@ -259,7 +262,7 @@ class QUOTIENT_API GetContentThumbnailAuthedJob : public BaseJob { QString contentType() const { return QString::fromUtf8(reply()->rawHeader("Content-Type")); } //! A thumbnail of the requested content. - QIODevice* data() { return reply(); } + QIODevice *data() { return reply(); } }; //! \brief Get information about a URL for a client @@ -272,7 +275,8 @@ class QUOTIENT_API GetContentThumbnailAuthedJob : public BaseJob { //! rooms. Encrypted rooms often contain more sensitive information the users //! do not want to share with the homeserver, and this can mean that the URLs //! being shared should also not be shared with the homeserver. -class QUOTIENT_API GetUrlPreviewAuthedJob : public BaseJob { +class QUOTIENT_API GetUrlPreviewAuthedJob : public BaseJob +{ public: //! \param url //! The URL to get a preview of. @@ -281,13 +285,13 @@ class QUOTIENT_API GetUrlPreviewAuthedJob : public BaseJob { //! The preferred point in time to return a preview for. The server may //! return a newer version if it does not have the requested version //! available. - explicit GetUrlPreviewAuthedJob(const QUrl& url, std::optional ts = std::nullopt); + explicit GetUrlPreviewAuthedJob(const QUrl &url, std::optional ts = std::nullopt); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetUrlPreviewAuthedJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QUrl& url, + static QUrl makeRequestUrl(const HomeserverData &hsData, const QUrl &url, std::optional ts = std::nullopt); // Result properties @@ -302,7 +306,8 @@ class QUOTIENT_API GetUrlPreviewAuthedJob : public BaseJob { //! there is no image. QUrl ogImage() const { return loadFromJson("og:image"_L1); } - struct Response { + struct Response + { //! The byte-size of the image. Omitted if there is no image attached. std::optional matrixImageSize{}; @@ -313,8 +318,8 @@ class QUOTIENT_API GetUrlPreviewAuthedJob : public BaseJob { }; template JobT> -constexpr inline auto doCollectResponse = [](JobT* j) -> GetUrlPreviewAuthedJob::Response { - return { j->matrixImageSize(), j->ogImage() }; +constexpr inline auto doCollectResponse = [](JobT *j) -> GetUrlPreviewAuthedJob::Response { + return {j->matrixImageSize(), j->ogImage()}; }; //! \brief Get the configuration for the content repository. @@ -330,7 +335,8 @@ constexpr inline auto doCollectResponse = [](JobT* j) -> GetUrlPreviewAuth //! between the client and the server may affect the apparent behaviour of content //! repository APIs, for example, proxies may enforce a lower upload size limit //! than is advertised by the server on this endpoint. -class QUOTIENT_API GetConfigAuthedJob : public BaseJob { +class QUOTIENT_API GetConfigAuthedJob : public BaseJob +{ public: explicit GetConfigAuthedJob(); @@ -338,7 +344,7 @@ class QUOTIENT_API GetConfigAuthedJob : public BaseJob { //! //! This function can be used when a URL for GetConfigAuthedJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData); + static QUrl makeRequestUrl(const HomeserverData &hsData); // Result properties @@ -351,6 +357,6 @@ class QUOTIENT_API GetConfigAuthedJob : public BaseJob { } }; -inline auto collectResponse(const GetConfigAuthedJob* job) { return job->uploadSize(); } +inline auto collectResponse(const GetConfigAuthedJob *job) { return job->uploadSize(); } } // namespace Quotient diff --git a/Quotient/csapi/banning.cpp b/Quotient/csapi/banning.cpp index 32ef3129b..4d01ae147 100644 --- a/Quotient/csapi/banning.cpp +++ b/Quotient/csapi/banning.cpp @@ -4,21 +4,21 @@ using namespace Quotient; -BanJob::BanJob(const QString& roomId, const QString& userId, const QString& reason) +BanJob::BanJob(const QString &roomId, const QString &userId, const QString &reason) : BaseJob(HttpVerb::Post, u"BanJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/ban")) { QJsonObject _dataJson; addParam(_dataJson, "user_id"_L1, userId); addParam(_dataJson, "reason"_L1, reason); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } -UnbanJob::UnbanJob(const QString& roomId, const QString& userId, const QString& reason) +UnbanJob::UnbanJob(const QString &roomId, const QString &userId, const QString &reason) : BaseJob(HttpVerb::Post, u"UnbanJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/unban")) { QJsonObject _dataJson; addParam(_dataJson, "user_id"_L1, userId); addParam(_dataJson, "reason"_L1, reason); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } diff --git a/Quotient/csapi/banning.h b/Quotient/csapi/banning.h index 4cb632849..583f5d267 100644 --- a/Quotient/csapi/banning.h +++ b/Quotient/csapi/banning.h @@ -14,7 +14,8 @@ namespace Quotient { //! unbanned. //! //! The caller must have the required power level in order to perform this operation. -class QUOTIENT_API BanJob : public BaseJob { +class QUOTIENT_API BanJob : public BaseJob +{ public: //! \param roomId //! The room identifier (not alias) from which the user should be banned. @@ -25,7 +26,7 @@ class QUOTIENT_API BanJob : public BaseJob { //! \param reason //! The reason the user has been banned. This will be supplied as the `reason` on the target's //! updated [`m.room.member`](/client-server-api/#mroommember) event. - explicit BanJob(const QString& roomId, const QString& userId, const QString& reason = {}); + explicit BanJob(const QString &roomId, const QString &userId, const QString &reason = {}); }; //! \brief Unban a user from the room. @@ -34,7 +35,8 @@ class QUOTIENT_API BanJob : public BaseJob { //! and join if they would otherwise be allowed to join according to its join rules. //! //! The caller must have the required power level in order to perform this operation. -class QUOTIENT_API UnbanJob : public BaseJob { +class QUOTIENT_API UnbanJob : public BaseJob +{ public: //! \param roomId //! The room identifier (not alias) from which the user should be unbanned. @@ -45,7 +47,7 @@ class QUOTIENT_API UnbanJob : public BaseJob { //! \param reason //! Optional reason to be included as the `reason` on the subsequent //! membership event. - explicit UnbanJob(const QString& roomId, const QString& userId, const QString& reason = {}); + explicit UnbanJob(const QString &roomId, const QString &userId, const QString &reason = {}); }; } // namespace Quotient diff --git a/Quotient/csapi/capabilities.cpp b/Quotient/csapi/capabilities.cpp index d48cd6037..bfada8520 100644 --- a/Quotient/csapi/capabilities.cpp +++ b/Quotient/csapi/capabilities.cpp @@ -4,7 +4,7 @@ using namespace Quotient; -QUrl GetCapabilitiesJob::makeRequestUrl(const HomeserverData& hsData) +QUrl GetCapabilitiesJob::makeRequestUrl(const HomeserverData &hsData) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/capabilities")); } diff --git a/Quotient/csapi/capabilities.h b/Quotient/csapi/capabilities.h index aeff86d7e..1900e8051 100644 --- a/Quotient/csapi/capabilities.h +++ b/Quotient/csapi/capabilities.h @@ -6,18 +6,20 @@ namespace Quotient { -struct QUOTIENT_API BooleanCapability { +struct QUOTIENT_API BooleanCapability +{ //! True if the user can perform the action, false otherwise. bool enabled; }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const BooleanCapability& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const BooleanCapability &pod) { addParam(jo, "enabled"_L1, pod.enabled); } - static void fillFrom(const QJsonObject& jo, BooleanCapability& pod) + static void fillFrom(const QJsonObject &jo, BooleanCapability &pod) { fillFromJson(jo.value("enabled"_L1), pod.enabled); } @@ -27,12 +29,14 @@ struct JsonObjectConverter { //! //! Gets information about the server's supported feature set //! and other relevant capabilities. -class QUOTIENT_API GetCapabilitiesJob : public BaseJob { +class QUOTIENT_API GetCapabilitiesJob : public BaseJob +{ public: // Inner data structures //! The room versions the server supports. - struct QUOTIENT_API RoomVersionsCapability { + struct QUOTIENT_API RoomVersionsCapability + { //! The default room version the server is using for new rooms. QString defaultVersion; @@ -42,7 +46,8 @@ class QUOTIENT_API GetCapabilitiesJob : public BaseJob { //! The custom capabilities the server supports, using the //! Java package naming convention. - struct QUOTIENT_API Capabilities { + struct QUOTIENT_API Capabilities + { //! Capability to indicate if the user can change their password. std::optional changePassword{}; @@ -76,7 +81,7 @@ class QUOTIENT_API GetCapabilitiesJob : public BaseJob { //! //! This function can be used when a URL for GetCapabilitiesJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData); + static QUrl makeRequestUrl(const HomeserverData &hsData); // Result properties @@ -85,11 +90,12 @@ class QUOTIENT_API GetCapabilitiesJob : public BaseJob { Capabilities capabilities() const { return loadFromJson("capabilities"_L1); } }; -inline auto collectResponse(const GetCapabilitiesJob* job) { return job->capabilities(); } +inline auto collectResponse(const GetCapabilitiesJob *job) { return job->capabilities(); } template <> -struct QUOTIENT_API JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, GetCapabilitiesJob::RoomVersionsCapability& result) +struct QUOTIENT_API JsonObjectConverter +{ + static void fillFrom(const QJsonObject &jo, GetCapabilitiesJob::RoomVersionsCapability &result) { fillFromJson(jo.value("default"_L1), result.defaultVersion); fillFromJson(jo.value("available"_L1), result.available); @@ -97,8 +103,9 @@ struct QUOTIENT_API JsonObjectConverter -struct QUOTIENT_API JsonObjectConverter { - static void fillFrom(QJsonObject jo, GetCapabilitiesJob::Capabilities& result) +struct QUOTIENT_API JsonObjectConverter +{ + static void fillFrom(QJsonObject jo, GetCapabilitiesJob::Capabilities &result) { fillFromJson(jo.take("m.change_password"_L1), result.changePassword); fillFromJson(jo.take("m.room_versions"_L1), result.roomVersions); diff --git a/Quotient/csapi/content-repo.cpp b/Quotient/csapi/content-repo.cpp index 5c856627f..37861a8fd 100644 --- a/Quotient/csapi/content-repo.cpp +++ b/Quotient/csapi/content-repo.cpp @@ -4,42 +4,42 @@ using namespace Quotient; -auto queryToUploadContent(const QString& filename) +auto queryToUploadContent(const QString &filename) { QUrlQuery _q; addParam(_q, u"filename"_s, filename); return _q; } -UploadContentJob::UploadContentJob(QIODevice* content, const QString& filename, - const QString& contentType) +UploadContentJob::UploadContentJob(QIODevice *content, const QString &filename, + const QString &contentType) : BaseJob(HttpVerb::Post, u"UploadContentJob"_s, makePath("/_matrix", "/media/v3/upload"), queryToUploadContent(filename)) { setRequestHeader("Content-Type", contentType.toLatin1()); - setRequestData({ content }); + setRequestData({content}); addExpectedKey(u"content_uri"_s); } -auto queryToUploadContentToMXC(const QString& filename) +auto queryToUploadContentToMXC(const QString &filename) { QUrlQuery _q; addParam(_q, u"filename"_s, filename); return _q; } -UploadContentToMXCJob::UploadContentToMXCJob(const QString& serverName, const QString& mediaId, - QIODevice* content, const QString& filename, - const QString& contentType) +UploadContentToMXCJob::UploadContentToMXCJob(const QString &serverName, const QString &mediaId, + QIODevice *content, const QString &filename, + const QString &contentType) : BaseJob(HttpVerb::Put, u"UploadContentToMXCJob"_s, makePath("/_matrix", "/media/v3/upload/", serverName, "/", mediaId), queryToUploadContentToMXC(filename)) { setRequestHeader("Content-Type", contentType.toLatin1()); - setRequestData({ content }); + setRequestData({content}); } -QUrl CreateContentJob::makeRequestUrl(const HomeserverData& hsData) +QUrl CreateContentJob::makeRequestUrl(const HomeserverData &hsData) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix", "/media/v1/create")); } @@ -59,8 +59,8 @@ auto queryToGetContent(bool allowRemote, qint64 timeoutMs, bool allowRedirect) return _q; } -QUrl GetContentJob::makeRequestUrl(const HomeserverData& hsData, const QString& serverName, - const QString& mediaId, bool allowRemote, qint64 timeoutMs, +QUrl GetContentJob::makeRequestUrl(const HomeserverData &hsData, const QString &serverName, + const QString &mediaId, bool allowRemote, qint64 timeoutMs, bool allowRedirect) { return BaseJob::makeRequestUrl(hsData, @@ -69,13 +69,13 @@ QUrl GetContentJob::makeRequestUrl(const HomeserverData& hsData, const QString& queryToGetContent(allowRemote, timeoutMs, allowRedirect)); } -GetContentJob::GetContentJob(const QString& serverName, const QString& mediaId, bool allowRemote, +GetContentJob::GetContentJob(const QString &serverName, const QString &mediaId, bool allowRemote, qint64 timeoutMs, bool allowRedirect) : BaseJob(HttpVerb::Get, u"GetContentJob"_s, makePath("/_matrix", "/media/v3/download/", serverName, "/", mediaId), queryToGetContent(allowRemote, timeoutMs, allowRedirect), {}, false) { - setExpectedContentTypes({ "application/octet-stream" }); + setExpectedContentTypes({"application/octet-stream"}); } auto queryToGetContentOverrideName(bool allowRemote, qint64 timeoutMs, bool allowRedirect) @@ -87,9 +87,9 @@ auto queryToGetContentOverrideName(bool allowRemote, qint64 timeoutMs, bool allo return _q; } -QUrl GetContentOverrideNameJob::makeRequestUrl(const HomeserverData& hsData, - const QString& serverName, const QString& mediaId, - const QString& fileName, bool allowRemote, +QUrl GetContentOverrideNameJob::makeRequestUrl(const HomeserverData &hsData, + const QString &serverName, const QString &mediaId, + const QString &fileName, bool allowRemote, qint64 timeoutMs, bool allowRedirect) { return BaseJob::makeRequestUrl( @@ -97,18 +97,18 @@ QUrl GetContentOverrideNameJob::makeRequestUrl(const HomeserverData& hsData, queryToGetContentOverrideName(allowRemote, timeoutMs, allowRedirect)); } -GetContentOverrideNameJob::GetContentOverrideNameJob(const QString& serverName, - const QString& mediaId, - const QString& fileName, bool allowRemote, +GetContentOverrideNameJob::GetContentOverrideNameJob(const QString &serverName, + const QString &mediaId, + const QString &fileName, bool allowRemote, qint64 timeoutMs, bool allowRedirect) : BaseJob(HttpVerb::Get, u"GetContentOverrideNameJob"_s, makePath("/_matrix", "/media/v3/download/", serverName, "/", mediaId, "/", fileName), queryToGetContentOverrideName(allowRemote, timeoutMs, allowRedirect), {}, false) { - setExpectedContentTypes({ "application/octet-stream" }); + setExpectedContentTypes({"application/octet-stream"}); } -auto queryToGetContentThumbnail(int width, int height, const QString& method, bool allowRemote, +auto queryToGetContentThumbnail(int width, int height, const QString &method, bool allowRemote, qint64 timeoutMs, bool allowRedirect, std::optional animated) { QUrlQuery _q; @@ -122,9 +122,9 @@ auto queryToGetContentThumbnail(int width, int height, const QString& method, bo return _q; } -QUrl GetContentThumbnailJob::makeRequestUrl(const HomeserverData& hsData, const QString& serverName, - const QString& mediaId, int width, int height, - const QString& method, bool allowRemote, +QUrl GetContentThumbnailJob::makeRequestUrl(const HomeserverData &hsData, const QString &serverName, + const QString &mediaId, int width, int height, + const QString &method, bool allowRemote, qint64 timeoutMs, bool allowRedirect, std::optional animated) { @@ -135,8 +135,8 @@ QUrl GetContentThumbnailJob::makeRequestUrl(const HomeserverData& hsData, const timeoutMs, allowRedirect, animated)); } -GetContentThumbnailJob::GetContentThumbnailJob(const QString& serverName, const QString& mediaId, - int width, int height, const QString& method, +GetContentThumbnailJob::GetContentThumbnailJob(const QString &serverName, const QString &mediaId, + int width, int height, const QString &method, bool allowRemote, qint64 timeoutMs, bool allowRedirect, std::optional animated) : BaseJob(HttpVerb::Get, u"GetContentThumbnailJob"_s, @@ -145,10 +145,10 @@ GetContentThumbnailJob::GetContentThumbnailJob(const QString& serverName, const allowRedirect, animated), {}, false) { - setExpectedContentTypes({ "image/jpeg", "image/png", "image/apng", "image/gif", "image/webp" }); + setExpectedContentTypes({"image/jpeg", "image/png", "image/apng", "image/gif", "image/webp"}); } -auto queryToGetUrlPreview(const QUrl& url, std::optional ts) +auto queryToGetUrlPreview(const QUrl &url, std::optional ts) { QUrlQuery _q; addParam(_q, u"url"_s, url); @@ -156,19 +156,19 @@ auto queryToGetUrlPreview(const QUrl& url, std::optional ts) return _q; } -QUrl GetUrlPreviewJob::makeRequestUrl(const HomeserverData& hsData, const QUrl& url, +QUrl GetUrlPreviewJob::makeRequestUrl(const HomeserverData &hsData, const QUrl &url, std::optional ts) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix", "/media/v3/preview_url"), queryToGetUrlPreview(url, ts)); } -GetUrlPreviewJob::GetUrlPreviewJob(const QUrl& url, std::optional ts) +GetUrlPreviewJob::GetUrlPreviewJob(const QUrl &url, std::optional ts) : BaseJob(HttpVerb::Get, u"GetUrlPreviewJob"_s, makePath("/_matrix", "/media/v3/preview_url"), queryToGetUrlPreview(url, ts)) {} -QUrl GetConfigJob::makeRequestUrl(const HomeserverData& hsData) +QUrl GetConfigJob::makeRequestUrl(const HomeserverData &hsData) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix", "/media/v3/config")); } diff --git a/Quotient/csapi/content-repo.h b/Quotient/csapi/content-repo.h index 9c864d750..a75ece770 100644 --- a/Quotient/csapi/content-repo.h +++ b/Quotient/csapi/content-repo.h @@ -10,7 +10,8 @@ namespace Quotient { //! \brief Upload some content to the content repository. -class QUOTIENT_API UploadContentJob : public BaseJob { +class QUOTIENT_API UploadContentJob : public BaseJob +{ public: //! //! \param filename @@ -22,8 +23,8 @@ class QUOTIENT_API UploadContentJob : public BaseJob { //! Clients SHOULD always supply this header. //! //! Defaults to `application/octet-stream` if it is not set. - explicit UploadContentJob(QIODevice* content, const QString& filename = {}, - const QString& contentType = {}); + explicit UploadContentJob(QIODevice *content, const QString &filename = {}, + const QString &contentType = {}); // Result properties @@ -31,13 +32,14 @@ class QUOTIENT_API UploadContentJob : public BaseJob { QUrl contentUri() const { return loadFromJson("content_uri"_L1); } }; -inline auto collectResponse(const UploadContentJob* job) { return job->contentUri(); } +inline auto collectResponse(const UploadContentJob *job) { return job->contentUri(); } //! \brief Upload content to an `mxc://` URI that was created earlier. //! //! This endpoint permits uploading content to an `mxc://` URI that was created //! earlier via [POST /_matrix/media/v1/create](/client-server-api/#post_matrixmediav1create). -class QUOTIENT_API UploadContentToMXCJob : public BaseJob { +class QUOTIENT_API UploadContentToMXCJob : public BaseJob +{ public: //! \param serverName //! The server name from the `mxc://` URI (the authority component). @@ -55,9 +57,9 @@ class QUOTIENT_API UploadContentToMXCJob : public BaseJob { //! Clients SHOULD always supply this header. //! //! Defaults to `application/octet-stream` if it is not set. - explicit UploadContentToMXCJob(const QString& serverName, const QString& mediaId, - QIODevice* content, const QString& filename = {}, - const QString& contentType = {}); + explicit UploadContentToMXCJob(const QString &serverName, const QString &mediaId, + QIODevice *content, const QString &filename = {}, + const QString &contentType = {}); }; //! \brief Create a new `mxc://` URI without uploading the content. @@ -82,7 +84,8 @@ class QUOTIENT_API UploadContentToMXCJob : public BaseJob { //! `unused_expires_at` timestamp has not yet passed). In both cases, the //! server should respond with an HTTP 429 error with an errcode of //! `M_LIMIT_EXCEEDED`. -class QUOTIENT_API CreateContentJob : public BaseJob { +class QUOTIENT_API CreateContentJob : public BaseJob +{ public: explicit CreateContentJob(); @@ -90,7 +93,7 @@ class QUOTIENT_API CreateContentJob : public BaseJob { //! //! This function can be used when a URL for CreateContentJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData); + static QUrl makeRequestUrl(const HomeserverData &hsData); // Result properties @@ -105,7 +108,8 @@ class QUOTIENT_API CreateContentJob : public BaseJob { return loadFromJson>("unused_expires_at"_L1); } - struct Response { + struct Response + { //! The [`mxc://` URI](/client-server-api/#matrix-content-mxc-uris) at //! which the content will be available, once it is uploaded. QUrl contentUri{}; @@ -118,7 +122,7 @@ class QUOTIENT_API CreateContentJob : public BaseJob { template JobT> constexpr inline auto doCollectResponse = - [](JobT* j) -> CreateContentJob::Response { return { j->contentUri(), j->unusedExpiresAt() }; }; + [](JobT *j) -> CreateContentJob::Response { return {j->contentUri(), j->unusedExpiresAt()}; }; //! \brief Download content from the content repository. //! @@ -133,7 +137,8 @@ constexpr inline auto doCollectResponse = //! media access. See [Client Behaviour](/client-server-api/#content-repo-client-behaviour) for more //! information. class [[deprecated("Check the documentation for details")]] QUOTIENT_API GetContentJob - : public BaseJob { + : public BaseJob +{ public: //! \param serverName //! The server name from the `mxc://` URI (the authority component). @@ -159,17 +164,17 @@ class [[deprecated("Check the documentation for details")]] QUOTIENT_API GetCont //! Indicates to the server that it may return a 307 or 308 redirect //! response that points at the relevant media content. When not explicitly //! set to `true` the server must return the media content itself. - explicit GetContentJob(const QString& serverName, const QString& mediaId, - bool allowRemote = true, qint64 timeoutMs = 20000, + explicit GetContentJob(const QString &serverName, const QString &mediaId, + bool allowRemote = true, qint64 timeoutMs = 20'000, bool allowRedirect = false); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetContentJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& serverName, - const QString& mediaId, bool allowRemote = true, - qint64 timeoutMs = 20000, bool allowRedirect = false); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &serverName, + const QString &mediaId, bool allowRemote = true, + qint64 timeoutMs = 20'000, bool allowRedirect = false); // Result properties @@ -215,7 +220,7 @@ class [[deprecated("Check the documentation for details")]] QUOTIENT_API GetCont } //! The content that was previously uploaded. - QIODevice* data() { return reply(); } + QIODevice *data() { return reply(); } }; //! \brief Download content from the content repository overriding the file name @@ -235,7 +240,8 @@ class [[deprecated("Check the documentation for details")]] QUOTIENT_API GetCont //! media access. See [Client Behaviour](/client-server-api/#content-repo-client-behaviour) for more //! information. class [[deprecated("Check the documentation for details")]] QUOTIENT_API GetContentOverrideNameJob - : public BaseJob { + : public BaseJob +{ public: //! \param serverName //! The server name from the `mxc://` URI (the authority component). @@ -264,17 +270,17 @@ class [[deprecated("Check the documentation for details")]] QUOTIENT_API GetCont //! Indicates to the server that it may return a 307 or 308 redirect //! response that points at the relevant media content. When not explicitly //! set to `true` the server must return the media content itself. - explicit GetContentOverrideNameJob(const QString& serverName, const QString& mediaId, - const QString& fileName, bool allowRemote = true, - qint64 timeoutMs = 20000, bool allowRedirect = false); + explicit GetContentOverrideNameJob(const QString &serverName, const QString &mediaId, + const QString &fileName, bool allowRemote = true, + qint64 timeoutMs = 20'000, bool allowRedirect = false); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetContentOverrideNameJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& serverName, - const QString& mediaId, const QString& fileName, - bool allowRemote = true, qint64 timeoutMs = 20000, + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &serverName, + const QString &mediaId, const QString &fileName, + bool allowRemote = true, qint64 timeoutMs = 20'000, bool allowRedirect = false); // Result properties @@ -313,7 +319,7 @@ class [[deprecated("Check the documentation for details")]] QUOTIENT_API GetCont } //! The content that was previously uploaded. - QIODevice* data() { return reply(); } + QIODevice *data() { return reply(); } }; //! \brief Download a thumbnail of content from the content repository @@ -332,7 +338,8 @@ class [[deprecated("Check the documentation for details")]] QUOTIENT_API GetCont //! media access. See [Client Behaviour](/client-server-api/#content-repo-client-behaviour) for more //! information. class [[deprecated("Check the documentation for details")]] QUOTIENT_API GetContentThumbnailJob - : public BaseJob { + : public BaseJob +{ public: //! \param serverName //! The server name from the `mxc://` URI (the authority component). @@ -386,19 +393,19 @@ class [[deprecated("Check the documentation for details")]] QUOTIENT_API GetCont //! //! When `true` and the media cannot be animated, such as in the case of a JPEG or PDF, the //! server SHOULD behave as though `animated` is `false`. - explicit GetContentThumbnailJob(const QString& serverName, const QString& mediaId, int width, - int height, const QString& method = {}, bool allowRemote = true, - qint64 timeoutMs = 20000, bool allowRedirect = false, + explicit GetContentThumbnailJob(const QString &serverName, const QString &mediaId, int width, + int height, const QString &method = {}, bool allowRemote = true, + qint64 timeoutMs = 20'000, bool allowRedirect = false, std::optional animated = std::nullopt); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetContentThumbnailJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& serverName, - const QString& mediaId, int width, int height, - const QString& method = {}, bool allowRemote = true, - qint64 timeoutMs = 20000, bool allowRedirect = false, + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &serverName, + const QString &mediaId, int width, int height, + const QString &method = {}, bool allowRemote = true, + qint64 timeoutMs = 20'000, bool allowRedirect = false, std::optional animated = std::nullopt); // Result properties @@ -420,7 +427,7 @@ class [[deprecated("Check the documentation for details")]] QUOTIENT_API GetCont QString contentType() const { return QString::fromUtf8(reply()->rawHeader("Content-Type")); } //! A thumbnail of the requested content. - QIODevice* data() { return reply(); } + QIODevice *data() { return reply(); } }; //! \brief Get information about a URL for a client @@ -438,7 +445,8 @@ class [[deprecated("Check the documentation for details")]] QUOTIENT_API GetCont //! do not want to share with the homeserver, and this can mean that the URLs //! being shared should also not be shared with the homeserver. class [[deprecated("Check the documentation for details")]] QUOTIENT_API GetUrlPreviewJob - : public BaseJob { + : public BaseJob +{ public: //! \param url //! The URL to get a preview of. @@ -447,13 +455,13 @@ class [[deprecated("Check the documentation for details")]] QUOTIENT_API GetUrlP //! The preferred point in time to return a preview for. The server may //! return a newer version if it does not have the requested version //! available. - explicit GetUrlPreviewJob(const QUrl& url, std::optional ts = std::nullopt); + explicit GetUrlPreviewJob(const QUrl &url, std::optional ts = std::nullopt); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetUrlPreviewJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QUrl& url, + static QUrl makeRequestUrl(const HomeserverData &hsData, const QUrl &url, std::optional ts = std::nullopt); // Result properties @@ -468,7 +476,8 @@ class [[deprecated("Check the documentation for details")]] QUOTIENT_API GetUrlP //! there is no image. QUrl ogImage() const { return loadFromJson("og:image"_L1); } - struct Response { + struct Response + { //! The byte-size of the image. Omitted if there is no image attached. std::optional matrixImageSize{}; @@ -482,7 +491,7 @@ QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED template JobT> constexpr inline auto doCollectResponse = - [](JobT* j) -> GetUrlPreviewJob::Response { return { j->matrixImageSize(), j->ogImage() }; }; + [](JobT *j) -> GetUrlPreviewJob::Response { return {j->matrixImageSize(), j->ogImage()}; }; QT_WARNING_POP //! \brief Get the configuration for the content repository. @@ -502,7 +511,8 @@ QT_WARNING_POP //! repository APIs, for example, proxies may enforce a lower upload size limit //! than is advertised by the server on this endpoint. class [[deprecated("Check the documentation for details")]] QUOTIENT_API GetConfigJob - : public BaseJob { + : public BaseJob +{ public: explicit GetConfigJob(); @@ -510,7 +520,7 @@ class [[deprecated("Check the documentation for details")]] QUOTIENT_API GetConf //! //! This function can be used when a URL for GetConfigJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData); + static QUrl makeRequestUrl(const HomeserverData &hsData); // Result properties @@ -525,7 +535,7 @@ class [[deprecated("Check the documentation for details")]] QUOTIENT_API GetConf QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED -inline auto collectResponse(const GetConfigJob* job) { return job->uploadSize(); } +inline auto collectResponse(const GetConfigJob *job) { return job->uploadSize(); } QT_WARNING_POP } // namespace Quotient diff --git a/Quotient/csapi/create_room.cpp b/Quotient/csapi/create_room.cpp index bc727e1f4..c91c9cf14 100644 --- a/Quotient/csapi/create_room.cpp +++ b/Quotient/csapi/create_room.cpp @@ -4,13 +4,13 @@ using namespace Quotient; -CreateRoomJob::CreateRoomJob(const QString& visibility, const QString& roomAliasName, - const QString& name, const QString& topic, const QStringList& invite, - const QVector& invite3pid, const QString& roomVersion, - const QJsonObject& creationContent, - const QVector& initialState, const QString& preset, +CreateRoomJob::CreateRoomJob(const QString &visibility, const QString &roomAliasName, + const QString &name, const QString &topic, const QStringList &invite, + const QVector &invite3pid, const QString &roomVersion, + const QJsonObject &creationContent, + const QVector &initialState, const QString &preset, std::optional isDirect, - const QJsonObject& powerLevelContentOverride) + const QJsonObject &powerLevelContentOverride) : BaseJob(HttpVerb::Post, u"CreateRoomJob"_s, makePath("/_matrix/client/v3", "/createRoom")) { QJsonObject _dataJson; @@ -26,6 +26,6 @@ CreateRoomJob::CreateRoomJob(const QString& visibility, const QString& roomAlias addParam(_dataJson, "preset"_L1, preset); addParam(_dataJson, "is_direct"_L1, isDirect); addParam(_dataJson, "power_level_content_override"_L1, powerLevelContentOverride); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); addExpectedKey(u"room_id"_s); } diff --git a/Quotient/csapi/create_room.h b/Quotient/csapi/create_room.h index 3e0b83e46..ccd22ece6 100644 --- a/Quotient/csapi/create_room.h +++ b/Quotient/csapi/create_room.h @@ -50,11 +50,13 @@ namespace Quotient { //! The server will create a `m.room.create` event in the room with the //! requesting user as the creator, alongside other keys provided in the //! `creation_content`. -class QUOTIENT_API CreateRoomJob : public BaseJob { +class QUOTIENT_API CreateRoomJob : public BaseJob +{ public: // Inner data structures - struct QUOTIENT_API Invite3pid { + struct QUOTIENT_API Invite3pid + { //! The hostname+port of the identity server which should be used for third-party identifier //! lookups. QString idServer; @@ -72,7 +74,8 @@ class QUOTIENT_API CreateRoomJob : public BaseJob { QString address; }; - struct QUOTIENT_API StateEvent { + struct QUOTIENT_API StateEvent + { //! The type of event to send. QString type; @@ -165,14 +168,14 @@ class QUOTIENT_API CreateRoomJob : public BaseJob { //! [`m.room.power_levels`](/client-server-api/#mroompower_levels) //! event content prior to it being sent to the room. Defaults to //! overriding nothing. - explicit CreateRoomJob(const QString& visibility = {}, const QString& roomAliasName = {}, - const QString& name = {}, const QString& topic = {}, - const QStringList& invite = {}, - const QVector& invite3pid = {}, - const QString& roomVersion = {}, const QJsonObject& creationContent = {}, - const QVector& initialState = {}, const QString& preset = {}, + explicit CreateRoomJob(const QString &visibility = {}, const QString &roomAliasName = {}, + const QString &name = {}, const QString &topic = {}, + const QStringList &invite = {}, + const QVector &invite3pid = {}, + const QString &roomVersion = {}, const QJsonObject &creationContent = {}, + const QVector &initialState = {}, const QString &preset = {}, std::optional isDirect = std::nullopt, - const QJsonObject& powerLevelContentOverride = {}); + const QJsonObject &powerLevelContentOverride = {}); // Result properties @@ -180,11 +183,12 @@ class QUOTIENT_API CreateRoomJob : public BaseJob { QString roomId() const { return loadFromJson("room_id"_L1); } }; -inline auto collectResponse(const CreateRoomJob* job) { return job->roomId(); } +inline auto collectResponse(const CreateRoomJob *job) { return job->roomId(); } template <> -struct QUOTIENT_API JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const CreateRoomJob::Invite3pid& pod) +struct QUOTIENT_API JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const CreateRoomJob::Invite3pid &pod) { addParam(jo, "id_server"_L1, pod.idServer); addParam(jo, "id_access_token"_L1, pod.idAccessToken); @@ -194,8 +198,9 @@ struct QUOTIENT_API JsonObjectConverter { }; template <> -struct QUOTIENT_API JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const CreateRoomJob::StateEvent& pod) +struct QUOTIENT_API JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const CreateRoomJob::StateEvent &pod) { addParam(jo, "type"_L1, pod.type); addParam(jo, "content"_L1, pod.content); diff --git a/Quotient/csapi/cross_signing.cpp b/Quotient/csapi/cross_signing.cpp index 1eedfca7b..3baa52ddd 100644 --- a/Quotient/csapi/cross_signing.cpp +++ b/Quotient/csapi/cross_signing.cpp @@ -5,10 +5,10 @@ using namespace Quotient; UploadCrossSigningKeysJob::UploadCrossSigningKeysJob( - const std::optional& masterKey, - const std::optional& selfSigningKey, - const std::optional& userSigningKey, - const std::optional& auth) + const std::optional &masterKey, + const std::optional &selfSigningKey, + const std::optional &userSigningKey, + const std::optional &auth) : BaseJob(HttpVerb::Post, u"UploadCrossSigningKeysJob"_s, makePath("/_matrix/client/v3", "/keys/device_signing/upload")) { @@ -17,13 +17,13 @@ UploadCrossSigningKeysJob::UploadCrossSigningKeysJob( addParam(_dataJson, "self_signing_key"_L1, selfSigningKey); addParam(_dataJson, "user_signing_key"_L1, userSigningKey); addParam(_dataJson, "auth"_L1, auth); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } UploadCrossSigningSignaturesJob::UploadCrossSigningSignaturesJob( - const QHash>& signatures) + const QHash> &signatures) : BaseJob(HttpVerb::Post, u"UploadCrossSigningSignaturesJob"_s, makePath("/_matrix/client/v3", "/keys/signatures/upload")) { - setRequestData({ toJson(signatures) }); + setRequestData({toJson(signatures)}); } diff --git a/Quotient/csapi/cross_signing.h b/Quotient/csapi/cross_signing.h index 991f2896f..2af33e5e1 100644 --- a/Quotient/csapi/cross_signing.h +++ b/Quotient/csapi/cross_signing.h @@ -4,7 +4,6 @@ #include #include - #include namespace Quotient { @@ -28,7 +27,8 @@ namespace Quotient { //! they already exist. Allowing clients to upload the same set of keys more than once //! makes this endpoint idempotent in the case where the response is lost over the network, //! which would otherwise cause a UIA challenge upon retry. -class QUOTIENT_API UploadCrossSigningKeysJob : public BaseJob { +class QUOTIENT_API UploadCrossSigningKeysJob : public BaseJob +{ public: //! \param masterKey //! Optional. The user\'s master key. @@ -49,10 +49,10 @@ class QUOTIENT_API UploadCrossSigningKeysJob : public BaseJob { //! Additional authentication information for the //! user-interactive authentication API. explicit UploadCrossSigningKeysJob( - const std::optional& masterKey = std::nullopt, - const std::optional& selfSigningKey = std::nullopt, - const std::optional& userSigningKey = std::nullopt, - const std::optional& auth = std::nullopt); + const std::optional &masterKey = std::nullopt, + const std::optional &selfSigningKey = std::nullopt, + const std::optional &userSigningKey = std::nullopt, + const std::optional &auth = std::nullopt); }; //! \brief Upload cross-signing signatures. @@ -62,13 +62,14 @@ class QUOTIENT_API UploadCrossSigningKeysJob : public BaseJob { //! The signed JSON object must match the key previously uploaded or //! retrieved for the given key ID, with the exception of the `signatures` //! property, which contains the new signature(s) to add. -class QUOTIENT_API UploadCrossSigningSignaturesJob : public BaseJob { +class QUOTIENT_API UploadCrossSigningSignaturesJob : public BaseJob +{ public: //! \param signatures //! A map from user ID to key ID to signed JSON objects containing the //! signatures to be published. explicit UploadCrossSigningSignaturesJob( - const QHash>& signatures); + const QHash> &signatures); // Result properties @@ -81,6 +82,6 @@ class QUOTIENT_API UploadCrossSigningSignaturesJob : public BaseJob { } }; -inline auto collectResponse(const UploadCrossSigningSignaturesJob* job) { return job->failures(); } +inline auto collectResponse(const UploadCrossSigningSignaturesJob *job) { return job->failures(); } } // namespace Quotient diff --git a/Quotient/csapi/definitions/auth_data.h b/Quotient/csapi/definitions/auth_data.h index f1eea2052..b8b118b1f 100644 --- a/Quotient/csapi/definitions/auth_data.h +++ b/Quotient/csapi/definitions/auth_data.h @@ -6,7 +6,8 @@ namespace Quotient { //! Used by clients to submit authentication information to the interactive-authentication API -struct QUOTIENT_API AuthenticationData { +struct QUOTIENT_API AuthenticationData +{ //! The authentication type that the client is attempting to complete. //! May be omitted if `session` is given, and the client is reissuing a //! request which it believes has been completed out-of-band (for example, @@ -21,14 +22,15 @@ struct QUOTIENT_API AuthenticationData { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const AuthenticationData& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const AuthenticationData &pod) { fillJson(jo, pod.authInfo); addParam(jo, "type"_L1, pod.type); addParam(jo, "session"_L1, pod.session); } - static void fillFrom(QJsonObject jo, AuthenticationData& pod) + static void fillFrom(QJsonObject jo, AuthenticationData &pod) { fillFromJson(jo.take("type"_L1), pod.type); fillFromJson(jo.take("session"_L1), pod.session); diff --git a/Quotient/csapi/definitions/client_device.h b/Quotient/csapi/definitions/client_device.h index 4a9c2b8e1..0a371d652 100644 --- a/Quotient/csapi/definitions/client_device.h +++ b/Quotient/csapi/definitions/client_device.h @@ -6,7 +6,8 @@ namespace Quotient { //! A client device -struct QUOTIENT_API Device { +struct QUOTIENT_API Device +{ //! Identifier of this device. QString deviceId; @@ -25,15 +26,16 @@ struct QUOTIENT_API Device { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const Device& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const Device &pod) { addParam(jo, "device_id"_L1, pod.deviceId); addParam(jo, "display_name"_L1, pod.displayName); addParam(jo, "last_seen_ip"_L1, pod.lastSeenIp); addParam(jo, "last_seen_ts"_L1, pod.lastSeenTs); } - static void fillFrom(const QJsonObject& jo, Device& pod) + static void fillFrom(const QJsonObject &jo, Device &pod) { fillFromJson(jo.value("device_id"_L1), pod.deviceId); fillFromJson(jo.value("display_name"_L1), pod.displayName); diff --git a/Quotient/csapi/definitions/cross_signing_key.h b/Quotient/csapi/definitions/cross_signing_key.h index de1258475..aaa6fb1e7 100644 --- a/Quotient/csapi/definitions/cross_signing_key.h +++ b/Quotient/csapi/definitions/cross_signing_key.h @@ -6,7 +6,8 @@ namespace Quotient { //! Cross signing key -struct QUOTIENT_API CrossSigningKey { +struct QUOTIENT_API CrossSigningKey +{ //! The ID of the user the key belongs to. QString userId; @@ -25,15 +26,16 @@ struct QUOTIENT_API CrossSigningKey { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const CrossSigningKey& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const CrossSigningKey &pod) { addParam(jo, "user_id"_L1, pod.userId); addParam(jo, "usage"_L1, pod.usage); addParam(jo, "keys"_L1, pod.keys); addParam(jo, "signatures"_L1, pod.signatures); } - static void fillFrom(const QJsonObject& jo, CrossSigningKey& pod) + static void fillFrom(const QJsonObject &jo, CrossSigningKey &pod) { fillFromJson(jo.value("user_id"_L1), pod.userId); fillFromJson(jo.value("usage"_L1), pod.usage); diff --git a/Quotient/csapi/definitions/device_keys.h b/Quotient/csapi/definitions/device_keys.h index 5b64290db..159557f9b 100644 --- a/Quotient/csapi/definitions/device_keys.h +++ b/Quotient/csapi/definitions/device_keys.h @@ -6,7 +6,8 @@ namespace Quotient { //! Device identity keys -struct QUOTIENT_API DeviceKeys { +struct QUOTIENT_API DeviceKeys +{ //! The ID of the user the device belongs to. Must match the user ID used //! when logging in. QString userId; @@ -32,8 +33,9 @@ struct QUOTIENT_API DeviceKeys { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const DeviceKeys& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const DeviceKeys &pod) { addParam(jo, "user_id"_L1, pod.userId); addParam(jo, "device_id"_L1, pod.deviceId); @@ -41,7 +43,7 @@ struct JsonObjectConverter { addParam(jo, "keys"_L1, pod.keys); addParam(jo, "signatures"_L1, pod.signatures); } - static void fillFrom(const QJsonObject& jo, DeviceKeys& pod) + static void fillFrom(const QJsonObject &jo, DeviceKeys &pod) { fillFromJson(jo.value("user_id"_L1), pod.userId); fillFromJson(jo.value("device_id"_L1), pod.deviceId); diff --git a/Quotient/csapi/definitions/event_filter.h b/Quotient/csapi/definitions/event_filter.h index 3bf2f7dea..d674fe839 100644 --- a/Quotient/csapi/definitions/event_filter.h +++ b/Quotient/csapi/definitions/event_filter.h @@ -6,7 +6,8 @@ namespace Quotient { -struct QUOTIENT_API EventFilter { +struct QUOTIENT_API EventFilter +{ //! The maximum number of events to return, must be an integer greater than 0. //! //! Servers should apply a default value, and impose a maximum value to avoid @@ -31,8 +32,9 @@ struct QUOTIENT_API EventFilter { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const EventFilter& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const EventFilter &pod) { addParam(jo, "limit"_L1, pod.limit); addParam(jo, "not_senders"_L1, pod.notSenders); @@ -40,7 +42,7 @@ struct JsonObjectConverter { addParam(jo, "senders"_L1, pod.senders); addParam(jo, "types"_L1, pod.types); } - static void fillFrom(const QJsonObject& jo, EventFilter& pod) + static void fillFrom(const QJsonObject &jo, EventFilter &pod) { fillFromJson(jo.value("limit"_L1), pod.limit); fillFromJson(jo.value("not_senders"_L1), pod.notSenders); diff --git a/Quotient/csapi/definitions/key_backup_data.h b/Quotient/csapi/definitions/key_backup_data.h index e5c06b6b9..564bd9614 100644 --- a/Quotient/csapi/definitions/key_backup_data.h +++ b/Quotient/csapi/definitions/key_backup_data.h @@ -6,7 +6,8 @@ namespace Quotient { //! The key data -struct QUOTIENT_API KeyBackupData { +struct QUOTIENT_API KeyBackupData +{ //! The index of the first message in the session that the key can decrypt. int firstMessageIndex; @@ -24,15 +25,16 @@ struct QUOTIENT_API KeyBackupData { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const KeyBackupData& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const KeyBackupData &pod) { addParam(jo, "first_message_index"_L1, pod.firstMessageIndex); addParam(jo, "forwarded_count"_L1, pod.forwardedCount); addParam(jo, "is_verified"_L1, pod.isVerified); addParam(jo, "session_data"_L1, pod.sessionData); } - static void fillFrom(const QJsonObject& jo, KeyBackupData& pod) + static void fillFrom(const QJsonObject &jo, KeyBackupData &pod) { fillFromJson(jo.value("first_message_index"_L1), pod.firstMessageIndex); fillFromJson(jo.value("forwarded_count"_L1), pod.forwardedCount); diff --git a/Quotient/csapi/definitions/openid_token.h b/Quotient/csapi/definitions/openid_token.h index d469f6730..a8fb71959 100644 --- a/Quotient/csapi/definitions/openid_token.h +++ b/Quotient/csapi/definitions/openid_token.h @@ -6,7 +6,8 @@ namespace Quotient { -struct QUOTIENT_API OpenIdCredentials { +struct QUOTIENT_API OpenIdCredentials +{ //! An access token the consumer may use to verify the identity of //! the person who generated the token. This is given to the federation //! API `GET /openid/userinfo` to verify the user's identity. @@ -25,15 +26,16 @@ struct QUOTIENT_API OpenIdCredentials { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const OpenIdCredentials& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const OpenIdCredentials &pod) { addParam(jo, "access_token"_L1, pod.accessToken); addParam(jo, "token_type"_L1, pod.tokenType); addParam(jo, "matrix_server_name"_L1, pod.matrixServerName); addParam(jo, "expires_in"_L1, pod.expiresIn); } - static void fillFrom(const QJsonObject& jo, OpenIdCredentials& pod) + static void fillFrom(const QJsonObject &jo, OpenIdCredentials &pod) { fillFromJson(jo.value("access_token"_L1), pod.accessToken); fillFromJson(jo.value("token_type"_L1), pod.tokenType); diff --git a/Quotient/csapi/definitions/public_rooms_response.h b/Quotient/csapi/definitions/public_rooms_response.h index e5c4a98a1..78bf94c55 100644 --- a/Quotient/csapi/definitions/public_rooms_response.h +++ b/Quotient/csapi/definitions/public_rooms_response.h @@ -6,7 +6,8 @@ namespace Quotient { -struct QUOTIENT_API PublicRoomsChunk { +struct QUOTIENT_API PublicRoomsChunk +{ //! The number of members joined to the room. int numJoinedMembers; @@ -44,8 +45,9 @@ struct QUOTIENT_API PublicRoomsChunk { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const PublicRoomsChunk& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const PublicRoomsChunk &pod) { addParam(jo, "num_joined_members"_L1, pod.numJoinedMembers); addParam(jo, "room_id"_L1, pod.roomId); @@ -58,7 +60,7 @@ struct JsonObjectConverter { addParam(jo, "join_rule"_L1, pod.joinRule); addParam(jo, "room_type"_L1, pod.roomType); } - static void fillFrom(const QJsonObject& jo, PublicRoomsChunk& pod) + static void fillFrom(const QJsonObject &jo, PublicRoomsChunk &pod) { fillFromJson(jo.value("num_joined_members"_L1), pod.numJoinedMembers); fillFromJson(jo.value("room_id"_L1), pod.roomId); diff --git a/Quotient/csapi/definitions/push_condition.h b/Quotient/csapi/definitions/push_condition.h index 13dc37d6c..031af334d 100644 --- a/Quotient/csapi/definitions/push_condition.h +++ b/Quotient/csapi/definitions/push_condition.h @@ -6,7 +6,8 @@ namespace Quotient { -struct QUOTIENT_API PushCondition { +struct QUOTIENT_API PushCondition +{ //! The kind of condition to apply. See [conditions](/client-server-api/#conditions-1) for //! more information on the allowed kinds and how they work. QString kind; @@ -37,8 +38,9 @@ struct QUOTIENT_API PushCondition { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const PushCondition& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const PushCondition &pod) { addParam(jo, "kind"_L1, pod.kind); addParam(jo, "key"_L1, pod.key); @@ -46,7 +48,7 @@ struct JsonObjectConverter { addParam(jo, "is"_L1, pod.is); addParam(jo, "value"_L1, pod.value); } - static void fillFrom(const QJsonObject& jo, PushCondition& pod) + static void fillFrom(const QJsonObject &jo, PushCondition &pod) { fillFromJson(jo.value("kind"_L1), pod.kind); fillFromJson(jo.value("key"_L1), pod.key); diff --git a/Quotient/csapi/definitions/push_rule.h b/Quotient/csapi/definitions/push_rule.h index 5bbb9cd36..a215f0554 100644 --- a/Quotient/csapi/definitions/push_rule.h +++ b/Quotient/csapi/definitions/push_rule.h @@ -3,12 +3,12 @@ #pragma once #include - #include namespace Quotient { -struct QUOTIENT_API PushRule { +struct QUOTIENT_API PushRule +{ //! The actions to perform when this rule is matched. QVector actions; @@ -32,8 +32,9 @@ struct QUOTIENT_API PushRule { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const PushRule& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const PushRule &pod) { addParam(jo, "actions"_L1, pod.actions); addParam(jo, "default"_L1, pod.isDefault); @@ -42,7 +43,7 @@ struct JsonObjectConverter { addParam(jo, "conditions"_L1, pod.conditions); addParam(jo, "pattern"_L1, pod.pattern); } - static void fillFrom(const QJsonObject& jo, PushRule& pod) + static void fillFrom(const QJsonObject &jo, PushRule &pod) { fillFromJson(jo.value("actions"_L1), pod.actions); fillFromJson(jo.value("default"_L1), pod.isDefault); diff --git a/Quotient/csapi/definitions/push_ruleset.h b/Quotient/csapi/definitions/push_ruleset.h index cbe86cd18..b6c0c849d 100644 --- a/Quotient/csapi/definitions/push_ruleset.h +++ b/Quotient/csapi/definitions/push_ruleset.h @@ -3,12 +3,12 @@ #pragma once #include - #include namespace Quotient { -struct QUOTIENT_API PushRuleset { +struct QUOTIENT_API PushRuleset +{ QVector content{}; QVector override{}; @@ -21,8 +21,9 @@ struct QUOTIENT_API PushRuleset { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const PushRuleset& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const PushRuleset &pod) { addParam(jo, "content"_L1, pod.content); addParam(jo, "override"_L1, pod.override); @@ -30,7 +31,7 @@ struct JsonObjectConverter { addParam(jo, "sender"_L1, pod.sender); addParam(jo, "underride"_L1, pod.underride); } - static void fillFrom(const QJsonObject& jo, PushRuleset& pod) + static void fillFrom(const QJsonObject &jo, PushRuleset &pod) { fillFromJson(jo.value("content"_L1), pod.content); fillFromJson(jo.value("override"_L1), pod.override); diff --git a/Quotient/csapi/definitions/request_email_validation.h b/Quotient/csapi/definitions/request_email_validation.h index 24d93a04c..d2255043b 100644 --- a/Quotient/csapi/definitions/request_email_validation.h +++ b/Quotient/csapi/definitions/request_email_validation.h @@ -6,7 +6,8 @@ namespace Quotient { -struct QUOTIENT_API EmailValidationData { +struct QUOTIENT_API EmailValidationData +{ //! A unique string generated by the client, and used to identify the //! validation attempt. It must be a string consisting of the characters //! `[0-9a-zA-Z.=_-]`. Its length must not exceed 255 characters and it @@ -48,8 +49,9 @@ struct QUOTIENT_API EmailValidationData { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const EmailValidationData& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const EmailValidationData &pod) { addParam(jo, "client_secret"_L1, pod.clientSecret); addParam(jo, "email"_L1, pod.email); @@ -58,7 +60,7 @@ struct JsonObjectConverter { addParam(jo, "id_server"_L1, pod.idServer); addParam(jo, "id_access_token"_L1, pod.idAccessToken); } - static void fillFrom(const QJsonObject& jo, EmailValidationData& pod) + static void fillFrom(const QJsonObject &jo, EmailValidationData &pod) { fillFromJson(jo.value("client_secret"_L1), pod.clientSecret); fillFromJson(jo.value("email"_L1), pod.email); diff --git a/Quotient/csapi/definitions/request_msisdn_validation.h b/Quotient/csapi/definitions/request_msisdn_validation.h index 13c69418b..798dbb912 100644 --- a/Quotient/csapi/definitions/request_msisdn_validation.h +++ b/Quotient/csapi/definitions/request_msisdn_validation.h @@ -6,7 +6,8 @@ namespace Quotient { -struct QUOTIENT_API MsisdnValidationData { +struct QUOTIENT_API MsisdnValidationData +{ //! A unique string generated by the client, and used to identify the //! validation attempt. It must be a string consisting of the characters //! `[0-9a-zA-Z.=_-]`. Its length must not exceed 255 characters and it @@ -51,8 +52,9 @@ struct QUOTIENT_API MsisdnValidationData { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const MsisdnValidationData& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const MsisdnValidationData &pod) { addParam(jo, "client_secret"_L1, pod.clientSecret); addParam(jo, "country"_L1, pod.country); @@ -62,7 +64,7 @@ struct JsonObjectConverter { addParam(jo, "id_server"_L1, pod.idServer); addParam(jo, "id_access_token"_L1, pod.idAccessToken); } - static void fillFrom(const QJsonObject& jo, MsisdnValidationData& pod) + static void fillFrom(const QJsonObject &jo, MsisdnValidationData &pod) { fillFromJson(jo.value("client_secret"_L1), pod.clientSecret); fillFromJson(jo.value("country"_L1), pod.country); diff --git a/Quotient/csapi/definitions/request_token_response.h b/Quotient/csapi/definitions/request_token_response.h index 5ba7ea68a..ae7d2fd3c 100644 --- a/Quotient/csapi/definitions/request_token_response.h +++ b/Quotient/csapi/definitions/request_token_response.h @@ -6,7 +6,8 @@ namespace Quotient { -struct QUOTIENT_API RequestTokenResponse { +struct QUOTIENT_API RequestTokenResponse +{ //! The session ID. Session IDs are opaque strings that must consist entirely //! of the characters `[0-9a-zA-Z.=_-]`. Their length must not exceed 255 //! characters and they must not be empty. @@ -26,13 +27,14 @@ struct QUOTIENT_API RequestTokenResponse { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const RequestTokenResponse& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const RequestTokenResponse &pod) { addParam(jo, "sid"_L1, pod.sid); addParam(jo, "submit_url"_L1, pod.submitUrl); } - static void fillFrom(const QJsonObject& jo, RequestTokenResponse& pod) + static void fillFrom(const QJsonObject &jo, RequestTokenResponse &pod) { fillFromJson(jo.value("sid"_L1), pod.sid); fillFromJson(jo.value("submit_url"_L1), pod.submitUrl); diff --git a/Quotient/csapi/definitions/room_event_filter.h b/Quotient/csapi/definitions/room_event_filter.h index 963b7b909..298bca4b7 100644 --- a/Quotient/csapi/definitions/room_event_filter.h +++ b/Quotient/csapi/definitions/room_event_filter.h @@ -3,12 +3,12 @@ #pragma once #include - #include namespace Quotient { -struct QUOTIENT_API RoomEventFilter : EventFilter { +struct QUOTIENT_API RoomEventFilter : EventFilter +{ //! If `true`, enables per-[thread](/client-server-api/#threading) notification //! counts. Only applies to the `/sync` endpoint. Defaults to `false`. std::optional unreadThreadNotifications{}; @@ -38,8 +38,9 @@ struct QUOTIENT_API RoomEventFilter : EventFilter { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const RoomEventFilter& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const RoomEventFilter &pod) { fillJson(jo, pod); addParam(jo, "unread_thread_notifications"_L1, pod.unreadThreadNotifications); @@ -49,7 +50,7 @@ struct JsonObjectConverter { addParam(jo, "rooms"_L1, pod.rooms); addParam(jo, "contains_url"_L1, pod.containsUrl); } - static void fillFrom(const QJsonObject& jo, RoomEventFilter& pod) + static void fillFrom(const QJsonObject &jo, RoomEventFilter &pod) { fillFromJson(jo, pod); fillFromJson(jo.value("unread_thread_notifications"_L1), pod.unreadThreadNotifications); diff --git a/Quotient/csapi/definitions/room_key_backup.h b/Quotient/csapi/definitions/room_key_backup.h index 165ca2e40..a3ad99642 100644 --- a/Quotient/csapi/definitions/room_key_backup.h +++ b/Quotient/csapi/definitions/room_key_backup.h @@ -3,23 +3,24 @@ #pragma once #include - #include namespace Quotient { //! The backed up keys for a room. -struct QUOTIENT_API RoomKeyBackup { +struct QUOTIENT_API RoomKeyBackup +{ //! A map of session IDs to key data. QHash sessions; }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const RoomKeyBackup& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const RoomKeyBackup &pod) { addParam(jo, "sessions"_L1, pod.sessions); } - static void fillFrom(const QJsonObject& jo, RoomKeyBackup& pod) + static void fillFrom(const QJsonObject &jo, RoomKeyBackup &pod) { fillFromJson(jo.value("sessions"_L1), pod.sessions); } diff --git a/Quotient/csapi/definitions/sync_filter.h b/Quotient/csapi/definitions/sync_filter.h index 3179604cf..7ff697907 100644 --- a/Quotient/csapi/definitions/sync_filter.h +++ b/Quotient/csapi/definitions/sync_filter.h @@ -4,12 +4,12 @@ #include #include - #include namespace Quotient { //! Filters to be applied to room data. -struct QUOTIENT_API RoomFilter { +struct QUOTIENT_API RoomFilter +{ //! A list of room IDs to exclude. If this list is absent then no rooms are excluded. A matching //! room will be excluded even if it is listed in the `'rooms'` filter. This filter is applied //! before the filters in `ephemeral`, `state`, `timeline` or `account_data` @@ -37,8 +37,9 @@ struct QUOTIENT_API RoomFilter { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const RoomFilter& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const RoomFilter &pod) { addParam(jo, "not_rooms"_L1, pod.notRooms); addParam(jo, "rooms"_L1, pod.rooms); @@ -48,7 +49,7 @@ struct JsonObjectConverter { addParam(jo, "timeline"_L1, pod.timeline); addParam(jo, "account_data"_L1, pod.accountData); } - static void fillFrom(const QJsonObject& jo, RoomFilter& pod) + static void fillFrom(const QJsonObject &jo, RoomFilter &pod) { fillFromJson(jo.value("not_rooms"_L1), pod.notRooms); fillFromJson(jo.value("rooms"_L1), pod.rooms); @@ -60,7 +61,8 @@ struct JsonObjectConverter { } }; -struct QUOTIENT_API Filter { +struct QUOTIENT_API Filter +{ //! List of event fields to include. If this list is absent then all fields are included. The //! entries are [dot-separated paths for each property](/appendices#dot-separated-property-paths) //! to include. So ['content.body'] will include the 'body' field of the 'content' object. A @@ -83,8 +85,9 @@ struct QUOTIENT_API Filter { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const Filter& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const Filter &pod) { addParam(jo, "event_fields"_L1, pod.eventFields); addParam(jo, "event_format"_L1, pod.eventFormat); @@ -92,7 +95,7 @@ struct JsonObjectConverter { addParam(jo, "account_data"_L1, pod.accountData); addParam(jo, "room"_L1, pod.room); } - static void fillFrom(const QJsonObject& jo, Filter& pod) + static void fillFrom(const QJsonObject &jo, Filter &pod) { fillFromJson(jo.value("event_fields"_L1), pod.eventFields); fillFromJson(jo.value("event_format"_L1), pod.eventFormat); diff --git a/Quotient/csapi/definitions/tag.h b/Quotient/csapi/definitions/tag.h index d7ea1f1f7..9106191d7 100644 --- a/Quotient/csapi/definitions/tag.h +++ b/Quotient/csapi/definitions/tag.h @@ -6,19 +6,21 @@ namespace Quotient { -struct QUOTIENT_API Tag { +struct QUOTIENT_API Tag +{ //! A number in a range `[0,1]` describing a relative //! position of the room under the given tag. std::optional order{}; }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const Tag& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const Tag &pod) { addParam(jo, "order"_L1, pod.order); } - static void fillFrom(const QJsonObject& jo, Tag& pod) + static void fillFrom(const QJsonObject &jo, Tag &pod) { fillFromJson(jo.value("order"_L1), pod.order); } diff --git a/Quotient/csapi/definitions/third_party_signed.h b/Quotient/csapi/definitions/third_party_signed.h index 5fbecdf1c..c6c797d72 100644 --- a/Quotient/csapi/definitions/third_party_signed.h +++ b/Quotient/csapi/definitions/third_party_signed.h @@ -7,7 +7,8 @@ namespace Quotient { //! A signature of an `m.third_party_invite` token to prove that this user //! owns a third-party identity which has been invited to the room. -struct QUOTIENT_API ThirdPartySigned { +struct QUOTIENT_API ThirdPartySigned +{ //! The Matrix ID of the user who issued the invite. QString sender; @@ -22,15 +23,16 @@ struct QUOTIENT_API ThirdPartySigned { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const ThirdPartySigned& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const ThirdPartySigned &pod) { addParam(jo, "sender"_L1, pod.sender); addParam(jo, "mxid"_L1, pod.mxid); addParam(jo, "token"_L1, pod.token); addParam(jo, "signatures"_L1, pod.signatures); } - static void fillFrom(const QJsonObject& jo, ThirdPartySigned& pod) + static void fillFrom(const QJsonObject &jo, ThirdPartySigned &pod) { fillFromJson(jo.value("sender"_L1), pod.sender); fillFromJson(jo.value("mxid"_L1), pod.mxid); diff --git a/Quotient/csapi/definitions/user_identifier.h b/Quotient/csapi/definitions/user_identifier.h index bbaef7cf1..76546a917 100644 --- a/Quotient/csapi/definitions/user_identifier.h +++ b/Quotient/csapi/definitions/user_identifier.h @@ -6,7 +6,8 @@ namespace Quotient { //! Identification information for a user -struct QUOTIENT_API UserIdentifier { +struct QUOTIENT_API UserIdentifier +{ //! The type of identification. See [Identifier types](/client-server-api/#identifier-types) //! for supported values and additional property descriptions. QString type; @@ -16,13 +17,14 @@ struct QUOTIENT_API UserIdentifier { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const UserIdentifier& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const UserIdentifier &pod) { fillJson(jo, pod.additionalProperties); addParam(jo, "type"_L1, pod.type); } - static void fillFrom(QJsonObject jo, UserIdentifier& pod) + static void fillFrom(QJsonObject jo, UserIdentifier &pod) { fillFromJson(jo.take("type"_L1), pod.type); fromJson(jo, pod.additionalProperties); diff --git a/Quotient/csapi/definitions/wellknown/full.h b/Quotient/csapi/definitions/wellknown/full.h index aaf5b946a..1abea5044 100644 --- a/Quotient/csapi/definitions/wellknown/full.h +++ b/Quotient/csapi/definitions/wellknown/full.h @@ -4,13 +4,13 @@ #include #include - #include namespace Quotient { //! Used by clients to determine the homeserver, identity server, and other //! optional components they should be interacting with. -struct QUOTIENT_API DiscoveryInformation { +struct QUOTIENT_API DiscoveryInformation +{ HomeserverInformation homeserver; std::optional identityServer{}; @@ -20,14 +20,15 @@ struct QUOTIENT_API DiscoveryInformation { }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const DiscoveryInformation& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const DiscoveryInformation &pod) { fillJson(jo, pod.additionalProperties); addParam(jo, "m.homeserver"_L1, pod.homeserver); addParam(jo, "m.identity_server"_L1, pod.identityServer); } - static void fillFrom(QJsonObject jo, DiscoveryInformation& pod) + static void fillFrom(QJsonObject jo, DiscoveryInformation &pod) { fillFromJson(jo.take("m.homeserver"_L1), pod.homeserver); fillFromJson(jo.take("m.identity_server"_L1), pod.identityServer); diff --git a/Quotient/csapi/definitions/wellknown/homeserver.h b/Quotient/csapi/definitions/wellknown/homeserver.h index a14d2ba02..6eb051591 100644 --- a/Quotient/csapi/definitions/wellknown/homeserver.h +++ b/Quotient/csapi/definitions/wellknown/homeserver.h @@ -6,18 +6,20 @@ namespace Quotient { //! Used by clients to discover homeserver information. -struct QUOTIENT_API HomeserverInformation { +struct QUOTIENT_API HomeserverInformation +{ //! The base URL for the homeserver for client-server connections. QUrl baseUrl; }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const HomeserverInformation& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const HomeserverInformation &pod) { addParam(jo, "base_url"_L1, pod.baseUrl); } - static void fillFrom(const QJsonObject& jo, HomeserverInformation& pod) + static void fillFrom(const QJsonObject &jo, HomeserverInformation &pod) { fillFromJson(jo.value("base_url"_L1), pod.baseUrl); } diff --git a/Quotient/csapi/definitions/wellknown/identity_server.h b/Quotient/csapi/definitions/wellknown/identity_server.h index 2daeadfad..564812a4f 100644 --- a/Quotient/csapi/definitions/wellknown/identity_server.h +++ b/Quotient/csapi/definitions/wellknown/identity_server.h @@ -6,18 +6,20 @@ namespace Quotient { //! Used by clients to discover identity server information. -struct QUOTIENT_API IdentityServerInformation { +struct QUOTIENT_API IdentityServerInformation +{ //! The base URL for the identity server for client-server connections. QUrl baseUrl; }; template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const IdentityServerInformation& pod) +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const IdentityServerInformation &pod) { addParam(jo, "base_url"_L1, pod.baseUrl); } - static void fillFrom(const QJsonObject& jo, IdentityServerInformation& pod) + static void fillFrom(const QJsonObject &jo, IdentityServerInformation &pod) { fillFromJson(jo.value("base_url"_L1), pod.baseUrl); } diff --git a/Quotient/csapi/device_management.cpp b/Quotient/csapi/device_management.cpp index 3095749f2..d9dbf75e7 100644 --- a/Quotient/csapi/device_management.cpp +++ b/Quotient/csapi/device_management.cpp @@ -4,7 +4,7 @@ using namespace Quotient; -QUrl GetDevicesJob::makeRequestUrl(const HomeserverData& hsData) +QUrl GetDevicesJob::makeRequestUrl(const HomeserverData &hsData) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/devices")); } @@ -13,42 +13,42 @@ GetDevicesJob::GetDevicesJob() : BaseJob(HttpVerb::Get, u"GetDevicesJob"_s, makePath("/_matrix/client/v3", "/devices")) {} -QUrl GetDeviceJob::makeRequestUrl(const HomeserverData& hsData, const QString& deviceId) +QUrl GetDeviceJob::makeRequestUrl(const HomeserverData &hsData, const QString &deviceId) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/devices/", deviceId)); } -GetDeviceJob::GetDeviceJob(const QString& deviceId) +GetDeviceJob::GetDeviceJob(const QString &deviceId) : BaseJob(HttpVerb::Get, u"GetDeviceJob"_s, makePath("/_matrix/client/v3", "/devices/", deviceId)) {} -UpdateDeviceJob::UpdateDeviceJob(const QString& deviceId, const QString& displayName) +UpdateDeviceJob::UpdateDeviceJob(const QString &deviceId, const QString &displayName) : BaseJob(HttpVerb::Put, u"UpdateDeviceJob"_s, makePath("/_matrix/client/v3", "/devices/", deviceId)) { QJsonObject _dataJson; addParam(_dataJson, "display_name"_L1, displayName); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } -DeleteDeviceJob::DeleteDeviceJob(const QString& deviceId, - const std::optional& auth) +DeleteDeviceJob::DeleteDeviceJob(const QString &deviceId, + const std::optional &auth) : BaseJob(HttpVerb::Delete, u"DeleteDeviceJob"_s, makePath("/_matrix/client/v3", "/devices/", deviceId)) { QJsonObject _dataJson; addParam(_dataJson, "auth"_L1, auth); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } -DeleteDevicesJob::DeleteDevicesJob(const QStringList& devices, - const std::optional& auth) +DeleteDevicesJob::DeleteDevicesJob(const QStringList &devices, + const std::optional &auth) : BaseJob(HttpVerb::Post, u"DeleteDevicesJob"_s, makePath("/_matrix/client/v3", "/delete_devices")) { QJsonObject _dataJson; addParam(_dataJson, "devices"_L1, devices); addParam(_dataJson, "auth"_L1, auth); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } diff --git a/Quotient/csapi/device_management.h b/Quotient/csapi/device_management.h index 883d61936..3ce737b5b 100644 --- a/Quotient/csapi/device_management.h +++ b/Quotient/csapi/device_management.h @@ -4,7 +4,6 @@ #include #include - #include namespace Quotient { @@ -12,7 +11,8 @@ namespace Quotient { //! \brief List registered devices for the current user //! //! Gets information about all devices for the current user. -class QUOTIENT_API GetDevicesJob : public BaseJob { +class QUOTIENT_API GetDevicesJob : public BaseJob +{ public: explicit GetDevicesJob(); @@ -20,7 +20,7 @@ class QUOTIENT_API GetDevicesJob : public BaseJob { //! //! This function can be used when a URL for GetDevicesJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData); + static QUrl makeRequestUrl(const HomeserverData &hsData); // Result properties @@ -28,22 +28,23 @@ class QUOTIENT_API GetDevicesJob : public BaseJob { QVector devices() const { return loadFromJson>("devices"_L1); } }; -inline auto collectResponse(const GetDevicesJob* job) { return job->devices(); } +inline auto collectResponse(const GetDevicesJob *job) { return job->devices(); } //! \brief Get a single device //! //! Gets information on a single device, by device id. -class QUOTIENT_API GetDeviceJob : public BaseJob { +class QUOTIENT_API GetDeviceJob : public BaseJob +{ public: //! \param deviceId //! The device to retrieve. - explicit GetDeviceJob(const QString& deviceId); + explicit GetDeviceJob(const QString &deviceId); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetDeviceJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& deviceId); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &deviceId); // Result properties @@ -51,12 +52,13 @@ class QUOTIENT_API GetDeviceJob : public BaseJob { Device device() const { return fromJson(jsonData()); } }; -inline auto collectResponse(const GetDeviceJob* job) { return job->device(); } +inline auto collectResponse(const GetDeviceJob *job) { return job->device(); } //! \brief Update a device //! //! Updates the metadata on the given device. -class QUOTIENT_API UpdateDeviceJob : public BaseJob { +class QUOTIENT_API UpdateDeviceJob : public BaseJob +{ public: //! \param deviceId //! The device to update. @@ -64,7 +66,7 @@ class QUOTIENT_API UpdateDeviceJob : public BaseJob { //! \param displayName //! The new display name for this device. If not given, the //! display name is unchanged. - explicit UpdateDeviceJob(const QString& deviceId, const QString& displayName = {}); + explicit UpdateDeviceJob(const QString &deviceId, const QString &displayName = {}); }; //! \brief Delete a device @@ -73,7 +75,8 @@ class QUOTIENT_API UpdateDeviceJob : public BaseJob { //! API](/client-server-api/#user-interactive-authentication-api). //! //! Deletes the given device, and invalidates any access token associated with it. -class QUOTIENT_API DeleteDeviceJob : public BaseJob { +class QUOTIENT_API DeleteDeviceJob : public BaseJob +{ public: //! \param deviceId //! The device to delete. @@ -81,8 +84,8 @@ class QUOTIENT_API DeleteDeviceJob : public BaseJob { //! \param auth //! Additional authentication information for the //! user-interactive authentication API. - explicit DeleteDeviceJob(const QString& deviceId, - const std::optional& auth = std::nullopt); + explicit DeleteDeviceJob(const QString &deviceId, + const std::optional &auth = std::nullopt); }; //! \brief Bulk deletion of devices @@ -91,7 +94,8 @@ class QUOTIENT_API DeleteDeviceJob : public BaseJob { //! API](/client-server-api/#user-interactive-authentication-api). //! //! Deletes the given devices, and invalidates any access token associated with them. -class QUOTIENT_API DeleteDevicesJob : public BaseJob { +class QUOTIENT_API DeleteDevicesJob : public BaseJob +{ public: //! \param devices //! The list of device IDs to delete. @@ -99,8 +103,8 @@ class QUOTIENT_API DeleteDevicesJob : public BaseJob { //! \param auth //! Additional authentication information for the //! user-interactive authentication API. - explicit DeleteDevicesJob(const QStringList& devices, - const std::optional& auth = std::nullopt); + explicit DeleteDevicesJob(const QStringList &devices, + const std::optional &auth = std::nullopt); }; } // namespace Quotient diff --git a/Quotient/csapi/directory.cpp b/Quotient/csapi/directory.cpp index 4edabfd28..2af52306e 100644 --- a/Quotient/csapi/directory.cpp +++ b/Quotient/csapi/directory.cpp @@ -4,44 +4,44 @@ using namespace Quotient; -SetRoomAliasJob::SetRoomAliasJob(const QString& roomAlias, const QString& roomId) +SetRoomAliasJob::SetRoomAliasJob(const QString &roomAlias, const QString &roomId) : BaseJob(HttpVerb::Put, u"SetRoomAliasJob"_s, makePath("/_matrix/client/v3", "/directory/room/", roomAlias)) { QJsonObject _dataJson; addParam(_dataJson, "room_id"_L1, roomId); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } -QUrl GetRoomIdByAliasJob::makeRequestUrl(const HomeserverData& hsData, const QString& roomAlias) +QUrl GetRoomIdByAliasJob::makeRequestUrl(const HomeserverData &hsData, const QString &roomAlias) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/directory/room/", roomAlias)); } -GetRoomIdByAliasJob::GetRoomIdByAliasJob(const QString& roomAlias) +GetRoomIdByAliasJob::GetRoomIdByAliasJob(const QString &roomAlias) : BaseJob(HttpVerb::Get, u"GetRoomIdByAliasJob"_s, makePath("/_matrix/client/v3", "/directory/room/", roomAlias), false) {} -QUrl DeleteRoomAliasJob::makeRequestUrl(const HomeserverData& hsData, const QString& roomAlias) +QUrl DeleteRoomAliasJob::makeRequestUrl(const HomeserverData &hsData, const QString &roomAlias) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/directory/room/", roomAlias)); } -DeleteRoomAliasJob::DeleteRoomAliasJob(const QString& roomAlias) +DeleteRoomAliasJob::DeleteRoomAliasJob(const QString &roomAlias) : BaseJob(HttpVerb::Delete, u"DeleteRoomAliasJob"_s, makePath("/_matrix/client/v3", "/directory/room/", roomAlias)) {} -QUrl GetLocalAliasesJob::makeRequestUrl(const HomeserverData& hsData, const QString& roomId) +QUrl GetLocalAliasesJob::makeRequestUrl(const HomeserverData &hsData, const QString &roomId) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/rooms/", roomId, "/aliases")); } -GetLocalAliasesJob::GetLocalAliasesJob(const QString& roomId) +GetLocalAliasesJob::GetLocalAliasesJob(const QString &roomId) : BaseJob(HttpVerb::Get, u"GetLocalAliasesJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/aliases")) { diff --git a/Quotient/csapi/directory.h b/Quotient/csapi/directory.h index 4024a351d..556ddbaaa 100644 --- a/Quotient/csapi/directory.h +++ b/Quotient/csapi/directory.h @@ -7,7 +7,8 @@ namespace Quotient { //! \brief Create a new mapping from room alias to room ID. -class QUOTIENT_API SetRoomAliasJob : public BaseJob { +class QUOTIENT_API SetRoomAliasJob : public BaseJob +{ public: //! \param roomAlias //! The room alias to set. Its format is defined @@ -15,7 +16,7 @@ class QUOTIENT_API SetRoomAliasJob : public BaseJob { //! //! \param roomId //! The room ID to set. - explicit SetRoomAliasJob(const QString& roomAlias, const QString& roomId); + explicit SetRoomAliasJob(const QString &roomAlias, const QString &roomId); }; //! \brief Get the room ID corresponding to this room alias. @@ -25,18 +26,19 @@ class QUOTIENT_API SetRoomAliasJob : public BaseJob { //! The server will use the federation API to resolve the alias if the //! domain part of the alias does not correspond to the server's own //! domain. -class QUOTIENT_API GetRoomIdByAliasJob : public BaseJob { +class QUOTIENT_API GetRoomIdByAliasJob : public BaseJob +{ public: //! \param roomAlias //! The room alias. Its format is defined //! [in the appendices](/appendices/#room-aliases). - explicit GetRoomIdByAliasJob(const QString& roomAlias); + explicit GetRoomIdByAliasJob(const QString &roomAlias); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetRoomIdByAliasJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomAlias); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &roomAlias); // Result properties @@ -46,7 +48,8 @@ class QUOTIENT_API GetRoomIdByAliasJob : public BaseJob { //! A list of servers that are aware of this room alias. QStringList servers() const { return loadFromJson("servers"_L1); } - struct Response { + struct Response + { //! The room ID for this room alias. QString roomId{}; @@ -57,7 +60,7 @@ class QUOTIENT_API GetRoomIdByAliasJob : public BaseJob { template JobT> constexpr inline auto doCollectResponse = - [](JobT* j) -> GetRoomIdByAliasJob::Response { return { j->roomId(), j->servers() }; }; + [](JobT *j) -> GetRoomIdByAliasJob::Response { return {j->roomId(), j->servers()}; }; //! \brief Remove a mapping of room alias to room ID. //! @@ -72,18 +75,19 @@ constexpr inline auto doCollectResponse = //! canonical alias event are recommended to, in addition to their other relevant permission //! checks, delete the alias and return a successful response even if the user does not //! have permission to update the `m.room.canonical_alias` event. -class QUOTIENT_API DeleteRoomAliasJob : public BaseJob { +class QUOTIENT_API DeleteRoomAliasJob : public BaseJob +{ public: //! \param roomAlias //! The room alias to remove. Its format is defined //! [in the appendices](/appendices/#room-aliases). - explicit DeleteRoomAliasJob(const QString& roomAlias); + explicit DeleteRoomAliasJob(const QString &roomAlias); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for DeleteRoomAliasJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomAlias); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &roomAlias); }; //! \brief Get a list of local aliases on a given room. @@ -104,17 +108,18 @@ class QUOTIENT_API DeleteRoomAliasJob : public BaseJob { //! Clients are recommended not to display this list of aliases prominently //! as they are not curated, unlike those listed in the `m.room.canonical_alias` //! state event. -class QUOTIENT_API GetLocalAliasesJob : public BaseJob { +class QUOTIENT_API GetLocalAliasesJob : public BaseJob +{ public: //! \param roomId //! The room ID to find local aliases of. - explicit GetLocalAliasesJob(const QString& roomId); + explicit GetLocalAliasesJob(const QString &roomId); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetLocalAliasesJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomId); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &roomId); // Result properties @@ -122,6 +127,6 @@ class QUOTIENT_API GetLocalAliasesJob : public BaseJob { QStringList aliases() const { return loadFromJson("aliases"_L1); } }; -inline auto collectResponse(const GetLocalAliasesJob* job) { return job->aliases(); } +inline auto collectResponse(const GetLocalAliasesJob *job) { return job->aliases(); } } // namespace Quotient diff --git a/Quotient/csapi/event_context.cpp b/Quotient/csapi/event_context.cpp index 100386c2c..f0f9d5c13 100644 --- a/Quotient/csapi/event_context.cpp +++ b/Quotient/csapi/event_context.cpp @@ -4,7 +4,7 @@ using namespace Quotient; -auto queryToGetEventContext(std::optional limit, const QString& filter) +auto queryToGetEventContext(std::optional limit, const QString &filter) { QUrlQuery _q; addParam(_q, u"limit"_s, limit); @@ -12,9 +12,9 @@ auto queryToGetEventContext(std::optional limit, const QString& filter) return _q; } -QUrl GetEventContextJob::makeRequestUrl(const HomeserverData& hsData, const QString& roomId, - const QString& eventId, std::optional limit, - const QString& filter) +QUrl GetEventContextJob::makeRequestUrl(const HomeserverData &hsData, const QString &roomId, + const QString &eventId, std::optional limit, + const QString &filter) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/rooms/", roomId, "/context/", @@ -22,8 +22,8 @@ QUrl GetEventContextJob::makeRequestUrl(const HomeserverData& hsData, const QStr queryToGetEventContext(limit, filter)); } -GetEventContextJob::GetEventContextJob(const QString& roomId, const QString& eventId, - std::optional limit, const QString& filter) +GetEventContextJob::GetEventContextJob(const QString &roomId, const QString &eventId, + std::optional limit, const QString &filter) : BaseJob(HttpVerb::Get, u"GetEventContextJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/context/", eventId), queryToGetEventContext(limit, filter)) diff --git a/Quotient/csapi/event_context.h b/Quotient/csapi/event_context.h index 430c1fb5c..13a3b5323 100644 --- a/Quotient/csapi/event_context.h +++ b/Quotient/csapi/event_context.h @@ -16,7 +16,8 @@ namespace Quotient { //! //! *Note*: This endpoint supports lazy-loading of room member events. See //! [Lazy-loading room members](/client-server-api/#lazy-loading-room-members) for more information. -class QUOTIENT_API GetEventContextJob : public BaseJob { +class QUOTIENT_API GetEventContextJob : public BaseJob +{ public: //! \param roomId //! The room to get events from. @@ -38,16 +39,16 @@ class QUOTIENT_API GetEventContextJob : public BaseJob { //! homeserver prefers. //! //! See [Filtering](/client-server-api/#filtering) for more information. - explicit GetEventContextJob(const QString& roomId, const QString& eventId, - std::optional limit = std::nullopt, const QString& filter = {}); + explicit GetEventContextJob(const QString &roomId, const QString &eventId, + std::optional limit = std::nullopt, const QString &filter = {}); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetEventContextJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomId, - const QString& eventId, std::optional limit = std::nullopt, - const QString& filter = {}); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &roomId, + const QString &eventId, std::optional limit = std::nullopt, + const QString &filter = {}); // Result properties @@ -71,7 +72,8 @@ class QUOTIENT_API GetEventContextJob : public BaseJob { //! The state of the room at the last event returned. StateEvents state() { return takeFromJson("state"_L1); } - struct Response { + struct Response + { //! A token that can be used to paginate backwards with. QString begin{}; @@ -95,9 +97,9 @@ class QUOTIENT_API GetEventContextJob : public BaseJob { }; template JobT> -constexpr inline auto doCollectResponse = [](JobT* j) -> GetEventContextJob::Response { - return { j->begin(), j->end(), j->eventsBefore(), - j->requestedEvent(), j->eventsAfter(), j->state() }; +constexpr inline auto doCollectResponse = [](JobT *j) -> GetEventContextJob::Response { + return {j->begin(), j->end(), j->eventsBefore(), + j->requestedEvent(), j->eventsAfter(), j->state()}; }; } // namespace Quotient diff --git a/Quotient/csapi/filter.cpp b/Quotient/csapi/filter.cpp index d900ca208..1b5d0d0ae 100644 --- a/Quotient/csapi/filter.cpp +++ b/Quotient/csapi/filter.cpp @@ -4,22 +4,22 @@ using namespace Quotient; -DefineFilterJob::DefineFilterJob(const QString& userId, const Filter& filter) +DefineFilterJob::DefineFilterJob(const QString &userId, const Filter &filter) : BaseJob(HttpVerb::Post, u"DefineFilterJob"_s, makePath("/_matrix/client/v3", "/user/", userId, "/filter")) { - setRequestData({ toJson(filter) }); + setRequestData({toJson(filter)}); addExpectedKey(u"filter_id"_s); } -QUrl GetFilterJob::makeRequestUrl(const HomeserverData& hsData, const QString& userId, - const QString& filterId) +QUrl GetFilterJob::makeRequestUrl(const HomeserverData &hsData, const QString &userId, + const QString &filterId) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/user/", userId, "/filter/", filterId)); } -GetFilterJob::GetFilterJob(const QString& userId, const QString& filterId) +GetFilterJob::GetFilterJob(const QString &userId, const QString &filterId) : BaseJob(HttpVerb::Get, u"GetFilterJob"_s, makePath("/_matrix/client/v3", "/user/", userId, "/filter/", filterId)) {} diff --git a/Quotient/csapi/filter.h b/Quotient/csapi/filter.h index dc781f726..f99695299 100644 --- a/Quotient/csapi/filter.h +++ b/Quotient/csapi/filter.h @@ -3,7 +3,6 @@ #pragma once #include - #include namespace Quotient { @@ -13,7 +12,8 @@ namespace Quotient { //! Uploads a new filter definition to the homeserver. //! Returns a filter ID that may be used in future requests to //! restrict which events are returned to the client. -class QUOTIENT_API DefineFilterJob : public BaseJob { +class QUOTIENT_API DefineFilterJob : public BaseJob +{ public: //! \param userId //! The id of the user uploading the filter. The access token must be authorized to make @@ -21,7 +21,7 @@ class QUOTIENT_API DefineFilterJob : public BaseJob { //! //! \param filter //! The filter to upload. - explicit DefineFilterJob(const QString& userId, const Filter& filter); + explicit DefineFilterJob(const QString &userId, const Filter &filter); // Result properties @@ -32,24 +32,25 @@ class QUOTIENT_API DefineFilterJob : public BaseJob { QString filterId() const { return loadFromJson("filter_id"_L1); } }; -inline auto collectResponse(const DefineFilterJob* job) { return job->filterId(); } +inline auto collectResponse(const DefineFilterJob *job) { return job->filterId(); } //! \brief Download a filter -class QUOTIENT_API GetFilterJob : public BaseJob { +class QUOTIENT_API GetFilterJob : public BaseJob +{ public: //! \param userId //! The user ID to download a filter for. //! //! \param filterId //! The filter ID to download. - explicit GetFilterJob(const QString& userId, const QString& filterId); + explicit GetFilterJob(const QString &userId, const QString &filterId); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetFilterJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& userId, - const QString& filterId); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &userId, + const QString &filterId); // Result properties @@ -57,6 +58,6 @@ class QUOTIENT_API GetFilterJob : public BaseJob { Filter filter() const { return fromJson(jsonData()); } }; -inline auto collectResponse(const GetFilterJob* job) { return job->filter(); } +inline auto collectResponse(const GetFilterJob *job) { return job->filter(); } } // namespace Quotient diff --git a/Quotient/csapi/inviting.cpp b/Quotient/csapi/inviting.cpp index c91d0b3aa..8217dd3c2 100644 --- a/Quotient/csapi/inviting.cpp +++ b/Quotient/csapi/inviting.cpp @@ -4,12 +4,12 @@ using namespace Quotient; -InviteUserJob::InviteUserJob(const QString& roomId, const QString& userId, const QString& reason) +InviteUserJob::InviteUserJob(const QString &roomId, const QString &userId, const QString &reason) : BaseJob(HttpVerb::Post, u"InviteUserJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/invite")) { QJsonObject _dataJson; addParam(_dataJson, "user_id"_L1, userId); addParam(_dataJson, "reason"_L1, reason); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } diff --git a/Quotient/csapi/inviting.h b/Quotient/csapi/inviting.h index 7e3c6eb12..428bb7525 100644 --- a/Quotient/csapi/inviting.h +++ b/Quotient/csapi/inviting.h @@ -22,7 +22,8 @@ namespace Quotient { //! //! If the user was invited to the room, the homeserver will append a //! `m.room.member` event to the room. -class QUOTIENT_API InviteUserJob : public BaseJob { +class QUOTIENT_API InviteUserJob : public BaseJob +{ public: //! \param roomId //! The room identifier (not alias) to which to invite the user. @@ -33,7 +34,7 @@ class QUOTIENT_API InviteUserJob : public BaseJob { //! \param reason //! Optional reason to be included as the `reason` on the subsequent //! membership event. - explicit InviteUserJob(const QString& roomId, const QString& userId, const QString& reason = {}); + explicit InviteUserJob(const QString &roomId, const QString &userId, const QString &reason = {}); }; } // namespace Quotient diff --git a/Quotient/csapi/joining.cpp b/Quotient/csapi/joining.cpp index ffd4b5acb..77494a6e2 100644 --- a/Quotient/csapi/joining.cpp +++ b/Quotient/csapi/joining.cpp @@ -4,20 +4,20 @@ using namespace Quotient; -JoinRoomByIdJob::JoinRoomByIdJob(const QString& roomId, - const std::optional& thirdPartySigned, - const QString& reason) +JoinRoomByIdJob::JoinRoomByIdJob(const QString &roomId, + const std::optional &thirdPartySigned, + const QString &reason) : BaseJob(HttpVerb::Post, u"JoinRoomByIdJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/join")) { QJsonObject _dataJson; addParam(_dataJson, "third_party_signed"_L1, thirdPartySigned); addParam(_dataJson, "reason"_L1, reason); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); addExpectedKey(u"room_id"_s); } -auto queryToJoinRoom(const QStringList& serverName, const QStringList& via) +auto queryToJoinRoom(const QStringList &serverName, const QStringList &via) { QUrlQuery _q; addParam(_q, u"server_name"_s, serverName); @@ -25,10 +25,10 @@ auto queryToJoinRoom(const QStringList& serverName, const QStringList& via) return _q; } -JoinRoomJob::JoinRoomJob(const QString& roomIdOrAlias, const QStringList& serverName, - const QStringList& via, - const std::optional& thirdPartySigned, - const QString& reason) +JoinRoomJob::JoinRoomJob(const QString &roomIdOrAlias, const QStringList &serverName, + const QStringList &via, + const std::optional &thirdPartySigned, + const QString &reason) : BaseJob(HttpVerb::Post, u"JoinRoomJob"_s, makePath("/_matrix/client/v3", "/join/", roomIdOrAlias), queryToJoinRoom(serverName, via)) @@ -36,6 +36,6 @@ JoinRoomJob::JoinRoomJob(const QString& roomIdOrAlias, const QStringList& server QJsonObject _dataJson; addParam(_dataJson, "third_party_signed"_L1, thirdPartySigned); addParam(_dataJson, "reason"_L1, reason); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); addExpectedKey(u"room_id"_s); } diff --git a/Quotient/csapi/joining.h b/Quotient/csapi/joining.h index 0387a164c..f0cdbfa66 100644 --- a/Quotient/csapi/joining.h +++ b/Quotient/csapi/joining.h @@ -3,7 +3,6 @@ #pragma once #include - #include namespace Quotient { @@ -21,7 +20,8 @@ namespace Quotient { //! After a user has joined a room, the room will appear as an entry in the //! response of the [`/initialSync`](/client-server-api/#get_matrixclientv3initialsync) //! and [`/sync`](/client-server-api/#get_matrixclientv3sync) APIs. -class QUOTIENT_API JoinRoomByIdJob : public BaseJob { +class QUOTIENT_API JoinRoomByIdJob : public BaseJob +{ public: //! \param roomId //! The room identifier (not alias) to join. @@ -34,9 +34,9 @@ class QUOTIENT_API JoinRoomByIdJob : public BaseJob { //! \param reason //! Optional reason to be included as the `reason` on the subsequent //! membership event. - explicit JoinRoomByIdJob(const QString& roomId, - const std::optional& thirdPartySigned = std::nullopt, - const QString& reason = {}); + explicit JoinRoomByIdJob(const QString &roomId, + const std::optional &thirdPartySigned = std::nullopt, + const QString &reason = {}); // Result properties @@ -44,7 +44,7 @@ class QUOTIENT_API JoinRoomByIdJob : public BaseJob { QString roomId() const { return loadFromJson("room_id"_L1); } }; -inline auto collectResponse(const JoinRoomByIdJob* job) { return job->roomId(); } +inline auto collectResponse(const JoinRoomByIdJob *job) { return job->roomId(); } //! \brief Start the requesting user participating in a particular room. //! @@ -58,7 +58,8 @@ inline auto collectResponse(const JoinRoomByIdJob* job) { return job->roomId(); //! After a user has joined a room, the room will appear as an entry in the //! response of the [`/initialSync`](/client-server-api/#get_matrixclientv3initialsync) //! and [`/sync`](/client-server-api/#get_matrixclientv3sync) APIs. -class QUOTIENT_API JoinRoomJob : public BaseJob { +class QUOTIENT_API JoinRoomJob : public BaseJob +{ public: //! \param roomIdOrAlias //! The room identifier or alias to join. @@ -79,10 +80,10 @@ class QUOTIENT_API JoinRoomJob : public BaseJob { //! \param reason //! Optional reason to be included as the `reason` on the subsequent //! membership event. - explicit JoinRoomJob(const QString& roomIdOrAlias, const QStringList& serverName = {}, - const QStringList& via = {}, - const std::optional& thirdPartySigned = std::nullopt, - const QString& reason = {}); + explicit JoinRoomJob(const QString &roomIdOrAlias, const QStringList &serverName = {}, + const QStringList &via = {}, + const std::optional &thirdPartySigned = std::nullopt, + const QString &reason = {}); // Result properties @@ -90,6 +91,6 @@ class QUOTIENT_API JoinRoomJob : public BaseJob { QString roomId() const { return loadFromJson("room_id"_L1); } }; -inline auto collectResponse(const JoinRoomJob* job) { return job->roomId(); } +inline auto collectResponse(const JoinRoomJob *job) { return job->roomId(); } } // namespace Quotient diff --git a/Quotient/csapi/key_backup.cpp b/Quotient/csapi/key_backup.cpp index ea20585f4..676327664 100644 --- a/Quotient/csapi/key_backup.cpp +++ b/Quotient/csapi/key_backup.cpp @@ -4,18 +4,18 @@ using namespace Quotient; -PostRoomKeysVersionJob::PostRoomKeysVersionJob(const QString& algorithm, const QJsonObject& authData) +PostRoomKeysVersionJob::PostRoomKeysVersionJob(const QString &algorithm, const QJsonObject &authData) : BaseJob(HttpVerb::Post, u"PostRoomKeysVersionJob"_s, makePath("/_matrix/client/v3", "/room_keys/version")) { QJsonObject _dataJson; addParam(_dataJson, "algorithm"_L1, algorithm); addParam(_dataJson, "auth_data"_L1, authData); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); addExpectedKey(u"version"_s); } -QUrl GetRoomKeysVersionCurrentJob::makeRequestUrl(const HomeserverData& hsData) +QUrl GetRoomKeysVersionCurrentJob::makeRequestUrl(const HomeserverData &hsData) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/room_keys/version")); } @@ -31,13 +31,13 @@ GetRoomKeysVersionCurrentJob::GetRoomKeysVersionCurrentJob() addExpectedKey(u"version"_s); } -QUrl GetRoomKeysVersionJob::makeRequestUrl(const HomeserverData& hsData, const QString& version) +QUrl GetRoomKeysVersionJob::makeRequestUrl(const HomeserverData &hsData, const QString &version) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/room_keys/version/", version)); } -GetRoomKeysVersionJob::GetRoomKeysVersionJob(const QString& version) +GetRoomKeysVersionJob::GetRoomKeysVersionJob(const QString &version) : BaseJob(HttpVerb::Get, u"GetRoomKeysVersionJob"_s, makePath("/_matrix/client/v3", "/room_keys/version/", version)) { @@ -48,55 +48,55 @@ GetRoomKeysVersionJob::GetRoomKeysVersionJob(const QString& version) addExpectedKey(u"version"_s); } -PutRoomKeysVersionJob::PutRoomKeysVersionJob(const QString& version, const QString& algorithm, - const QJsonObject& authData) +PutRoomKeysVersionJob::PutRoomKeysVersionJob(const QString &version, const QString &algorithm, + const QJsonObject &authData) : BaseJob(HttpVerb::Put, u"PutRoomKeysVersionJob"_s, makePath("/_matrix/client/v3", "/room_keys/version/", version)) { QJsonObject _dataJson; addParam(_dataJson, "algorithm"_L1, algorithm); addParam(_dataJson, "auth_data"_L1, authData); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } -QUrl DeleteRoomKeysVersionJob::makeRequestUrl(const HomeserverData& hsData, const QString& version) +QUrl DeleteRoomKeysVersionJob::makeRequestUrl(const HomeserverData &hsData, const QString &version) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/room_keys/version/", version)); } -DeleteRoomKeysVersionJob::DeleteRoomKeysVersionJob(const QString& version) +DeleteRoomKeysVersionJob::DeleteRoomKeysVersionJob(const QString &version) : BaseJob(HttpVerb::Delete, u"DeleteRoomKeysVersionJob"_s, makePath("/_matrix/client/v3", "/room_keys/version/", version)) {} -auto queryToPutRoomKeyBySessionId(const QString& version) +auto queryToPutRoomKeyBySessionId(const QString &version) { QUrlQuery _q; addParam(_q, u"version"_s, version); return _q; } -PutRoomKeyBySessionIdJob::PutRoomKeyBySessionIdJob(const QString& roomId, const QString& sessionId, - const QString& version, const KeyBackupData& data) +PutRoomKeyBySessionIdJob::PutRoomKeyBySessionIdJob(const QString &roomId, const QString &sessionId, + const QString &version, const KeyBackupData &data) : BaseJob(HttpVerb::Put, u"PutRoomKeyBySessionIdJob"_s, makePath("/_matrix/client/v3", "/room_keys/keys/", roomId, "/", sessionId), queryToPutRoomKeyBySessionId(version)) { - setRequestData({ toJson(data) }); + setRequestData({toJson(data)}); addExpectedKey(u"etag"_s); addExpectedKey(u"count"_s); } -auto queryToGetRoomKeyBySessionId(const QString& version) +auto queryToGetRoomKeyBySessionId(const QString &version) { QUrlQuery _q; addParam(_q, u"version"_s, version); return _q; } -QUrl GetRoomKeyBySessionIdJob::makeRequestUrl(const HomeserverData& hsData, const QString& roomId, - const QString& sessionId, const QString& version) +QUrl GetRoomKeyBySessionIdJob::makeRequestUrl(const HomeserverData &hsData, const QString &roomId, + const QString &sessionId, const QString &version) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/room_keys/keys/", roomId, "/", @@ -104,22 +104,22 @@ QUrl GetRoomKeyBySessionIdJob::makeRequestUrl(const HomeserverData& hsData, cons queryToGetRoomKeyBySessionId(version)); } -GetRoomKeyBySessionIdJob::GetRoomKeyBySessionIdJob(const QString& roomId, const QString& sessionId, - const QString& version) +GetRoomKeyBySessionIdJob::GetRoomKeyBySessionIdJob(const QString &roomId, const QString &sessionId, + const QString &version) : BaseJob(HttpVerb::Get, u"GetRoomKeyBySessionIdJob"_s, makePath("/_matrix/client/v3", "/room_keys/keys/", roomId, "/", sessionId), queryToGetRoomKeyBySessionId(version)) {} -auto queryToDeleteRoomKeyBySessionId(const QString& version) +auto queryToDeleteRoomKeyBySessionId(const QString &version) { QUrlQuery _q; addParam(_q, u"version"_s, version); return _q; } -QUrl DeleteRoomKeyBySessionIdJob::makeRequestUrl(const HomeserverData& hsData, const QString& roomId, - const QString& sessionId, const QString& version) +QUrl DeleteRoomKeyBySessionIdJob::makeRequestUrl(const HomeserverData &hsData, const QString &roomId, + const QString &sessionId, const QString &version) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/room_keys/keys/", roomId, "/", @@ -127,9 +127,9 @@ QUrl DeleteRoomKeyBySessionIdJob::makeRequestUrl(const HomeserverData& hsData, c queryToDeleteRoomKeyBySessionId(version)); } -DeleteRoomKeyBySessionIdJob::DeleteRoomKeyBySessionIdJob(const QString& roomId, - const QString& sessionId, - const QString& version) +DeleteRoomKeyBySessionIdJob::DeleteRoomKeyBySessionIdJob(const QString &roomId, + const QString &sessionId, + const QString &version) : BaseJob(HttpVerb::Delete, u"DeleteRoomKeyBySessionIdJob"_s, makePath("/_matrix/client/v3", "/room_keys/keys/", roomId, "/", sessionId), queryToDeleteRoomKeyBySessionId(version)) @@ -138,61 +138,61 @@ DeleteRoomKeyBySessionIdJob::DeleteRoomKeyBySessionIdJob(const QString& roomId, addExpectedKey(u"count"_s); } -auto queryToPutRoomKeysByRoomId(const QString& version) +auto queryToPutRoomKeysByRoomId(const QString &version) { QUrlQuery _q; addParam(_q, u"version"_s, version); return _q; } -PutRoomKeysByRoomIdJob::PutRoomKeysByRoomIdJob(const QString& roomId, const QString& version, - const RoomKeyBackup& backupData) +PutRoomKeysByRoomIdJob::PutRoomKeysByRoomIdJob(const QString &roomId, const QString &version, + const RoomKeyBackup &backupData) : BaseJob(HttpVerb::Put, u"PutRoomKeysByRoomIdJob"_s, makePath("/_matrix/client/v3", "/room_keys/keys/", roomId), queryToPutRoomKeysByRoomId(version)) { - setRequestData({ toJson(backupData) }); + setRequestData({toJson(backupData)}); addExpectedKey(u"etag"_s); addExpectedKey(u"count"_s); } -auto queryToGetRoomKeysByRoomId(const QString& version) +auto queryToGetRoomKeysByRoomId(const QString &version) { QUrlQuery _q; addParam(_q, u"version"_s, version); return _q; } -QUrl GetRoomKeysByRoomIdJob::makeRequestUrl(const HomeserverData& hsData, const QString& roomId, - const QString& version) +QUrl GetRoomKeysByRoomIdJob::makeRequestUrl(const HomeserverData &hsData, const QString &roomId, + const QString &version) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/room_keys/keys/", roomId), queryToGetRoomKeysByRoomId(version)); } -GetRoomKeysByRoomIdJob::GetRoomKeysByRoomIdJob(const QString& roomId, const QString& version) +GetRoomKeysByRoomIdJob::GetRoomKeysByRoomIdJob(const QString &roomId, const QString &version) : BaseJob(HttpVerb::Get, u"GetRoomKeysByRoomIdJob"_s, makePath("/_matrix/client/v3", "/room_keys/keys/", roomId), queryToGetRoomKeysByRoomId(version)) {} -auto queryToDeleteRoomKeysByRoomId(const QString& version) +auto queryToDeleteRoomKeysByRoomId(const QString &version) { QUrlQuery _q; addParam(_q, u"version"_s, version); return _q; } -QUrl DeleteRoomKeysByRoomIdJob::makeRequestUrl(const HomeserverData& hsData, const QString& roomId, - const QString& version) +QUrl DeleteRoomKeysByRoomIdJob::makeRequestUrl(const HomeserverData &hsData, const QString &roomId, + const QString &version) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/room_keys/keys/", roomId), queryToDeleteRoomKeysByRoomId(version)); } -DeleteRoomKeysByRoomIdJob::DeleteRoomKeysByRoomIdJob(const QString& roomId, const QString& version) +DeleteRoomKeysByRoomIdJob::DeleteRoomKeysByRoomIdJob(const QString &roomId, const QString &version) : BaseJob(HttpVerb::Delete, u"DeleteRoomKeysByRoomIdJob"_s, makePath("/_matrix/client/v3", "/room_keys/keys/", roomId), queryToDeleteRoomKeysByRoomId(version)) @@ -201,58 +201,58 @@ DeleteRoomKeysByRoomIdJob::DeleteRoomKeysByRoomIdJob(const QString& roomId, cons addExpectedKey(u"count"_s); } -auto queryToPutRoomKeys(const QString& version) +auto queryToPutRoomKeys(const QString &version) { QUrlQuery _q; addParam(_q, u"version"_s, version); return _q; } -PutRoomKeysJob::PutRoomKeysJob(const QString& version, const QHash& rooms) +PutRoomKeysJob::PutRoomKeysJob(const QString &version, const QHash &rooms) : BaseJob(HttpVerb::Put, u"PutRoomKeysJob"_s, makePath("/_matrix/client/v3", "/room_keys/keys"), queryToPutRoomKeys(version)) { QJsonObject _dataJson; addParam(_dataJson, "rooms"_L1, rooms); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); addExpectedKey(u"etag"_s); addExpectedKey(u"count"_s); } -auto queryToGetRoomKeys(const QString& version) +auto queryToGetRoomKeys(const QString &version) { QUrlQuery _q; addParam(_q, u"version"_s, version); return _q; } -QUrl GetRoomKeysJob::makeRequestUrl(const HomeserverData& hsData, const QString& version) +QUrl GetRoomKeysJob::makeRequestUrl(const HomeserverData &hsData, const QString &version) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/room_keys/keys"), queryToGetRoomKeys(version)); } -GetRoomKeysJob::GetRoomKeysJob(const QString& version) +GetRoomKeysJob::GetRoomKeysJob(const QString &version) : BaseJob(HttpVerb::Get, u"GetRoomKeysJob"_s, makePath("/_matrix/client/v3", "/room_keys/keys"), queryToGetRoomKeys(version)) { addExpectedKey(u"rooms"_s); } -auto queryToDeleteRoomKeys(const QString& version) +auto queryToDeleteRoomKeys(const QString &version) { QUrlQuery _q; addParam(_q, u"version"_s, version); return _q; } -QUrl DeleteRoomKeysJob::makeRequestUrl(const HomeserverData& hsData, const QString& version) +QUrl DeleteRoomKeysJob::makeRequestUrl(const HomeserverData &hsData, const QString &version) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/room_keys/keys"), queryToDeleteRoomKeys(version)); } -DeleteRoomKeysJob::DeleteRoomKeysJob(const QString& version) +DeleteRoomKeysJob::DeleteRoomKeysJob(const QString &version) : BaseJob(HttpVerb::Delete, u"DeleteRoomKeysJob"_s, makePath("/_matrix/client/v3", "/room_keys/keys"), queryToDeleteRoomKeys(version)) { diff --git a/Quotient/csapi/key_backup.h b/Quotient/csapi/key_backup.h index 8523ada66..203c91aa1 100644 --- a/Quotient/csapi/key_backup.h +++ b/Quotient/csapi/key_backup.h @@ -4,7 +4,6 @@ #include #include - #include namespace Quotient { @@ -12,7 +11,8 @@ namespace Quotient { //! \brief Create a new backup. //! //! Creates a new backup. -class QUOTIENT_API PostRoomKeysVersionJob : public BaseJob { +class QUOTIENT_API PostRoomKeysVersionJob : public BaseJob +{ public: //! \param algorithm //! The algorithm used for storing backups. @@ -21,7 +21,7 @@ class QUOTIENT_API PostRoomKeysVersionJob : public BaseJob { //! Algorithm-dependent data. See the documentation for the backup //! algorithms in [Server-side key backups](/client-server-api/#server-side-key-backups) for //! more information on the expected format of the data. - explicit PostRoomKeysVersionJob(const QString& algorithm, const QJsonObject& authData); + explicit PostRoomKeysVersionJob(const QString &algorithm, const QJsonObject &authData); // Result properties @@ -29,12 +29,13 @@ class QUOTIENT_API PostRoomKeysVersionJob : public BaseJob { QString version() const { return loadFromJson("version"_L1); } }; -inline auto collectResponse(const PostRoomKeysVersionJob* job) { return job->version(); } +inline auto collectResponse(const PostRoomKeysVersionJob *job) { return job->version(); } //! \brief Get information about the latest backup version. //! //! Get information about the latest backup version. -class QUOTIENT_API GetRoomKeysVersionCurrentJob : public BaseJob { +class QUOTIENT_API GetRoomKeysVersionCurrentJob : public BaseJob +{ public: explicit GetRoomKeysVersionCurrentJob(); @@ -42,7 +43,7 @@ class QUOTIENT_API GetRoomKeysVersionCurrentJob : public BaseJob { //! //! This function can be used when a URL for GetRoomKeysVersionCurrentJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData); + static QUrl makeRequestUrl(const HomeserverData &hsData); // Result properties @@ -66,7 +67,8 @@ class QUOTIENT_API GetRoomKeysVersionCurrentJob : public BaseJob { //! The backup version. QString version() const { return loadFromJson("version"_L1); } - struct Response { + struct Response + { //! The algorithm used for storing backups. QString algorithm{}; @@ -91,14 +93,15 @@ class QUOTIENT_API GetRoomKeysVersionCurrentJob : public BaseJob { template JobT> constexpr inline auto doCollectResponse = - [](JobT* j) -> GetRoomKeysVersionCurrentJob::Response { - return { j->algorithm(), j->authData(), j->count(), j->etag(), j->version() }; + [](JobT *j) -> GetRoomKeysVersionCurrentJob::Response { + return {j->algorithm(), j->authData(), j->count(), j->etag(), j->version()}; }; //! \brief Get information about an existing backup. //! //! Get information about an existing backup. -class QUOTIENT_API GetRoomKeysVersionJob : public BaseJob { +class QUOTIENT_API GetRoomKeysVersionJob : public BaseJob +{ public: //! \param version //! The backup version to get, as returned in the `version` parameter @@ -106,13 +109,13 @@ class QUOTIENT_API GetRoomKeysVersionJob : public BaseJob { //! [`POST //! /_matrix/client/v3/room_keys/version`](/client-server-api/#post_matrixclientv3room_keysversion) //! or this endpoint. - explicit GetRoomKeysVersionJob(const QString& version); + explicit GetRoomKeysVersionJob(const QString &version); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetRoomKeysVersionJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& version); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &version); // Result properties @@ -136,7 +139,8 @@ class QUOTIENT_API GetRoomKeysVersionJob : public BaseJob { //! The backup version. QString version() const { return loadFromJson("version"_L1); } - struct Response { + struct Response + { //! The algorithm used for storing backups. QString algorithm{}; @@ -160,14 +164,15 @@ class QUOTIENT_API GetRoomKeysVersionJob : public BaseJob { }; template JobT> -constexpr inline auto doCollectResponse = [](JobT* j) -> GetRoomKeysVersionJob::Response { - return { j->algorithm(), j->authData(), j->count(), j->etag(), j->version() }; +constexpr inline auto doCollectResponse = [](JobT *j) -> GetRoomKeysVersionJob::Response { + return {j->algorithm(), j->authData(), j->count(), j->etag(), j->version()}; }; //! \brief Update information about an existing backup. //! //! Update information about an existing backup. Only `auth_data` can be modified. -class QUOTIENT_API PutRoomKeysVersionJob : public BaseJob { +class QUOTIENT_API PutRoomKeysVersionJob : public BaseJob +{ public: //! \param version //! The backup version to update, as returned in the `version` @@ -185,15 +190,16 @@ class QUOTIENT_API PutRoomKeysVersionJob : public BaseJob { //! Algorithm-dependent data. See the documentation for the backup //! algorithms in [Server-side key backups](/client-server-api/#server-side-key-backups) for //! more information on the expected format of the data. - explicit PutRoomKeysVersionJob(const QString& version, const QString& algorithm, - const QJsonObject& authData); + explicit PutRoomKeysVersionJob(const QString &version, const QString &algorithm, + const QJsonObject &authData); }; //! \brief Delete an existing key backup. //! //! Delete an existing key backup. Both the information about the backup, //! as well as all key data related to the backup will be deleted. -class QUOTIENT_API DeleteRoomKeysVersionJob : public BaseJob { +class QUOTIENT_API DeleteRoomKeysVersionJob : public BaseJob +{ public: //! \param version //! The backup version to delete, as returned in the `version` @@ -202,19 +208,20 @@ class QUOTIENT_API DeleteRoomKeysVersionJob : public BaseJob { //! /_matrix/client/v3/room_keys/version`](/client-server-api/#post_matrixclientv3room_keysversion) //! or [`GET //! /_matrix/client/v3/room_keys/version/{version}`](/client-server-api/#get_matrixclientv3room_keysversionversion). - explicit DeleteRoomKeysVersionJob(const QString& version); + explicit DeleteRoomKeysVersionJob(const QString &version); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for DeleteRoomKeysVersionJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& version); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &version); }; //! \brief Store a key in the backup. //! //! Store a key in the backup. -class QUOTIENT_API PutRoomKeyBySessionIdJob : public BaseJob { +class QUOTIENT_API PutRoomKeyBySessionIdJob : public BaseJob +{ public: //! \param roomId //! The ID of the room that the key is for. @@ -227,8 +234,8 @@ class QUOTIENT_API PutRoomKeyBySessionIdJob : public BaseJob { //! //! \param data //! The key data. - explicit PutRoomKeyBySessionIdJob(const QString& roomId, const QString& sessionId, - const QString& version, const KeyBackupData& data); + explicit PutRoomKeyBySessionIdJob(const QString &roomId, const QString &sessionId, + const QString &version, const KeyBackupData &data); // Result properties @@ -239,7 +246,8 @@ class QUOTIENT_API PutRoomKeyBySessionIdJob : public BaseJob { //! The number of keys stored in the backup int count() const { return loadFromJson("count"_L1); } - struct Response { + struct Response + { //! The new etag value representing stored keys in the backup. //! See `GET /room_keys/version/{version}` for more details. QString etag{}; @@ -251,12 +259,13 @@ class QUOTIENT_API PutRoomKeyBySessionIdJob : public BaseJob { template JobT> constexpr inline auto doCollectResponse = - [](JobT* j) -> PutRoomKeyBySessionIdJob::Response { return { j->etag(), j->count() }; }; + [](JobT *j) -> PutRoomKeyBySessionIdJob::Response { return {j->etag(), j->count()}; }; //! \brief Retrieve a key from the backup. //! //! Retrieve a key from the backup. -class QUOTIENT_API GetRoomKeyBySessionIdJob : public BaseJob { +class QUOTIENT_API GetRoomKeyBySessionIdJob : public BaseJob +{ public: //! \param roomId //! The ID of the room that the requested key is for. @@ -266,15 +275,15 @@ class QUOTIENT_API GetRoomKeyBySessionIdJob : public BaseJob { //! //! \param version //! The backup from which to retrieve the key. - explicit GetRoomKeyBySessionIdJob(const QString& roomId, const QString& sessionId, - const QString& version); + explicit GetRoomKeyBySessionIdJob(const QString &roomId, const QString &sessionId, + const QString &version); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetRoomKeyBySessionIdJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomId, - const QString& sessionId, const QString& version); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &roomId, + const QString &sessionId, const QString &version); // Result properties @@ -282,12 +291,13 @@ class QUOTIENT_API GetRoomKeyBySessionIdJob : public BaseJob { KeyBackupData data() const { return fromJson(jsonData()); } }; -inline auto collectResponse(const GetRoomKeyBySessionIdJob* job) { return job->data(); } +inline auto collectResponse(const GetRoomKeyBySessionIdJob *job) { return job->data(); } //! \brief Delete a key from the backup. //! //! Delete a key from the backup. -class QUOTIENT_API DeleteRoomKeyBySessionIdJob : public BaseJob { +class QUOTIENT_API DeleteRoomKeyBySessionIdJob : public BaseJob +{ public: //! \param roomId //! The ID of the room that the specified key is for. @@ -297,15 +307,15 @@ class QUOTIENT_API DeleteRoomKeyBySessionIdJob : public BaseJob { //! //! \param version //! The backup from which to delete the key - explicit DeleteRoomKeyBySessionIdJob(const QString& roomId, const QString& sessionId, - const QString& version); + explicit DeleteRoomKeyBySessionIdJob(const QString &roomId, const QString &sessionId, + const QString &version); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for DeleteRoomKeyBySessionIdJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomId, - const QString& sessionId, const QString& version); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &roomId, + const QString &sessionId, const QString &version); // Result properties @@ -316,7 +326,8 @@ class QUOTIENT_API DeleteRoomKeyBySessionIdJob : public BaseJob { //! The number of keys stored in the backup int count() const { return loadFromJson("count"_L1); } - struct Response { + struct Response + { //! The new etag value representing stored keys in the backup. //! See `GET /room_keys/version/{version}` for more details. QString etag{}; @@ -328,12 +339,13 @@ class QUOTIENT_API DeleteRoomKeyBySessionIdJob : public BaseJob { template JobT> constexpr inline auto doCollectResponse = - [](JobT* j) -> DeleteRoomKeyBySessionIdJob::Response { return { j->etag(), j->count() }; }; + [](JobT *j) -> DeleteRoomKeyBySessionIdJob::Response { return {j->etag(), j->count()}; }; //! \brief Store several keys in the backup for a given room. //! //! Store several keys in the backup for a given room. -class QUOTIENT_API PutRoomKeysByRoomIdJob : public BaseJob { +class QUOTIENT_API PutRoomKeysByRoomIdJob : public BaseJob +{ public: //! \param roomId //! The ID of the room that the keys are for. @@ -343,8 +355,8 @@ class QUOTIENT_API PutRoomKeysByRoomIdJob : public BaseJob { //! //! \param backupData //! The backup data - explicit PutRoomKeysByRoomIdJob(const QString& roomId, const QString& version, - const RoomKeyBackup& backupData); + explicit PutRoomKeysByRoomIdJob(const QString &roomId, const QString &version, + const RoomKeyBackup &backupData); // Result properties @@ -355,7 +367,8 @@ class QUOTIENT_API PutRoomKeysByRoomIdJob : public BaseJob { //! The number of keys stored in the backup int count() const { return loadFromJson("count"_L1); } - struct Response { + struct Response + { //! The new etag value representing stored keys in the backup. //! See `GET /room_keys/version/{version}` for more details. QString etag{}; @@ -367,26 +380,27 @@ class QUOTIENT_API PutRoomKeysByRoomIdJob : public BaseJob { template JobT> constexpr inline auto doCollectResponse = - [](JobT* j) -> PutRoomKeysByRoomIdJob::Response { return { j->etag(), j->count() }; }; + [](JobT *j) -> PutRoomKeysByRoomIdJob::Response { return {j->etag(), j->count()}; }; //! \brief Retrieve the keys from the backup for a given room. //! //! Retrieve the keys from the backup for a given room. -class QUOTIENT_API GetRoomKeysByRoomIdJob : public BaseJob { +class QUOTIENT_API GetRoomKeysByRoomIdJob : public BaseJob +{ public: //! \param roomId //! The ID of the room that the requested key is for. //! //! \param version //! The backup from which to retrieve the key. - explicit GetRoomKeysByRoomIdJob(const QString& roomId, const QString& version); + explicit GetRoomKeysByRoomIdJob(const QString &roomId, const QString &version); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetRoomKeysByRoomIdJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomId, - const QString& version); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &roomId, + const QString &version); // Result properties @@ -395,26 +409,27 @@ class QUOTIENT_API GetRoomKeysByRoomIdJob : public BaseJob { RoomKeyBackup data() const { return fromJson(jsonData()); } }; -inline auto collectResponse(const GetRoomKeysByRoomIdJob* job) { return job->data(); } +inline auto collectResponse(const GetRoomKeysByRoomIdJob *job) { return job->data(); } //! \brief Delete the keys from the backup for a given room. //! //! Delete the keys from the backup for a given room. -class QUOTIENT_API DeleteRoomKeysByRoomIdJob : public BaseJob { +class QUOTIENT_API DeleteRoomKeysByRoomIdJob : public BaseJob +{ public: //! \param roomId //! The ID of the room that the specified key is for. //! //! \param version //! The backup from which to delete the key. - explicit DeleteRoomKeysByRoomIdJob(const QString& roomId, const QString& version); + explicit DeleteRoomKeysByRoomIdJob(const QString &roomId, const QString &version); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for DeleteRoomKeysByRoomIdJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomId, - const QString& version); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &roomId, + const QString &version); // Result properties @@ -425,7 +440,8 @@ class QUOTIENT_API DeleteRoomKeysByRoomIdJob : public BaseJob { //! The number of keys stored in the backup int count() const { return loadFromJson("count"_L1); } - struct Response { + struct Response + { //! The new etag value representing stored keys in the backup. //! See `GET /room_keys/version/{version}` for more details. QString etag{}; @@ -437,19 +453,20 @@ class QUOTIENT_API DeleteRoomKeysByRoomIdJob : public BaseJob { template JobT> constexpr inline auto doCollectResponse = - [](JobT* j) -> DeleteRoomKeysByRoomIdJob::Response { return { j->etag(), j->count() }; }; + [](JobT *j) -> DeleteRoomKeysByRoomIdJob::Response { return {j->etag(), j->count()}; }; //! \brief Store several keys in the backup. //! //! Store several keys in the backup. -class QUOTIENT_API PutRoomKeysJob : public BaseJob { +class QUOTIENT_API PutRoomKeysJob : public BaseJob +{ public: //! \param version //! The backup in which to store the keys. Must be the current backup. //! //! \param rooms //! A map of room IDs to room key backup data. - explicit PutRoomKeysJob(const QString& version, const QHash& rooms); + explicit PutRoomKeysJob(const QString &version, const QHash &rooms); // Result properties @@ -460,7 +477,8 @@ class QUOTIENT_API PutRoomKeysJob : public BaseJob { //! The number of keys stored in the backup int count() const { return loadFromJson("count"_L1); } - struct Response { + struct Response + { //! The new etag value representing stored keys in the backup. //! See `GET /room_keys/version/{version}` for more details. QString etag{}; @@ -472,22 +490,23 @@ class QUOTIENT_API PutRoomKeysJob : public BaseJob { template JobT> constexpr inline auto doCollectResponse = - [](JobT* j) -> PutRoomKeysJob::Response { return { j->etag(), j->count() }; }; + [](JobT *j) -> PutRoomKeysJob::Response { return {j->etag(), j->count()}; }; //! \brief Retrieve the keys from the backup. //! //! Retrieve the keys from the backup. -class QUOTIENT_API GetRoomKeysJob : public BaseJob { +class QUOTIENT_API GetRoomKeysJob : public BaseJob +{ public: //! \param version //! The backup from which to retrieve the keys. - explicit GetRoomKeysJob(const QString& version); + explicit GetRoomKeysJob(const QString &version); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetRoomKeysJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& version); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &version); // Result properties @@ -498,22 +517,23 @@ class QUOTIENT_API GetRoomKeysJob : public BaseJob { } }; -inline auto collectResponse(const GetRoomKeysJob* job) { return job->rooms(); } +inline auto collectResponse(const GetRoomKeysJob *job) { return job->rooms(); } //! \brief Delete the keys from the backup. //! //! Delete the keys from the backup. -class QUOTIENT_API DeleteRoomKeysJob : public BaseJob { +class QUOTIENT_API DeleteRoomKeysJob : public BaseJob +{ public: //! \param version //! The backup from which to delete the key - explicit DeleteRoomKeysJob(const QString& version); + explicit DeleteRoomKeysJob(const QString &version); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for DeleteRoomKeysJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& version); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &version); // Result properties @@ -524,7 +544,8 @@ class QUOTIENT_API DeleteRoomKeysJob : public BaseJob { //! The number of keys stored in the backup int count() const { return loadFromJson("count"_L1); } - struct Response { + struct Response + { //! The new etag value representing stored keys in the backup. //! See `GET /room_keys/version/{version}` for more details. QString etag{}; @@ -536,6 +557,6 @@ class QUOTIENT_API DeleteRoomKeysJob : public BaseJob { template JobT> constexpr inline auto doCollectResponse = - [](JobT* j) -> DeleteRoomKeysJob::Response { return { j->etag(), j->count() }; }; + [](JobT *j) -> DeleteRoomKeysJob::Response { return {j->etag(), j->count()}; }; } // namespace Quotient diff --git a/Quotient/csapi/keys.cpp b/Quotient/csapi/keys.cpp index 32385189d..da7139692 100644 --- a/Quotient/csapi/keys.cpp +++ b/Quotient/csapi/keys.cpp @@ -4,39 +4,39 @@ using namespace Quotient; -UploadKeysJob::UploadKeysJob(const std::optional& deviceKeys, - const OneTimeKeys& oneTimeKeys, const OneTimeKeys& fallbackKeys) +UploadKeysJob::UploadKeysJob(const std::optional &deviceKeys, + const OneTimeKeys &oneTimeKeys, const OneTimeKeys &fallbackKeys) : BaseJob(HttpVerb::Post, u"UploadKeysJob"_s, makePath("/_matrix/client/v3", "/keys/upload")) { QJsonObject _dataJson; addParam(_dataJson, "device_keys"_L1, deviceKeys); addParam(_dataJson, "one_time_keys"_L1, oneTimeKeys); addParam(_dataJson, "fallback_keys"_L1, fallbackKeys); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); addExpectedKey(u"one_time_key_counts"_s); } -QueryKeysJob::QueryKeysJob(const QHash& deviceKeys, std::optional timeout) +QueryKeysJob::QueryKeysJob(const QHash &deviceKeys, std::optional timeout) : BaseJob(HttpVerb::Post, u"QueryKeysJob"_s, makePath("/_matrix/client/v3", "/keys/query")) { QJsonObject _dataJson; addParam(_dataJson, "timeout"_L1, timeout); addParam(_dataJson, "device_keys"_L1, deviceKeys); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } -ClaimKeysJob::ClaimKeysJob(const QHash>& oneTimeKeys, +ClaimKeysJob::ClaimKeysJob(const QHash> &oneTimeKeys, std::optional timeout) : BaseJob(HttpVerb::Post, u"ClaimKeysJob"_s, makePath("/_matrix/client/v3", "/keys/claim")) { QJsonObject _dataJson; addParam(_dataJson, "timeout"_L1, timeout); addParam(_dataJson, "one_time_keys"_L1, oneTimeKeys); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); addExpectedKey(u"one_time_keys"_s); } -auto queryToGetKeysChanges(const QString& from, const QString& to) +auto queryToGetKeysChanges(const QString &from, const QString &to) { QUrlQuery _q; addParam(_q, u"from"_s, from); @@ -44,14 +44,14 @@ auto queryToGetKeysChanges(const QString& from, const QString& to) return _q; } -QUrl GetKeysChangesJob::makeRequestUrl(const HomeserverData& hsData, const QString& from, - const QString& to) +QUrl GetKeysChangesJob::makeRequestUrl(const HomeserverData &hsData, const QString &from, + const QString &to) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/keys/changes"), queryToGetKeysChanges(from, to)); } -GetKeysChangesJob::GetKeysChangesJob(const QString& from, const QString& to) +GetKeysChangesJob::GetKeysChangesJob(const QString &from, const QString &to) : BaseJob(HttpVerb::Get, u"GetKeysChangesJob"_s, makePath("/_matrix/client/v3", "/keys/changes"), queryToGetKeysChanges(from, to)) {} diff --git a/Quotient/csapi/keys.h b/Quotient/csapi/keys.h index 785bcf695..3658bd7fe 100644 --- a/Quotient/csapi/keys.h +++ b/Quotient/csapi/keys.h @@ -4,9 +4,7 @@ #include #include - #include - #include namespace Quotient { @@ -14,7 +12,8 @@ namespace Quotient { //! \brief Upload end-to-end encryption keys. //! //! Publishes end-to-end encryption keys for the device. -class QUOTIENT_API UploadKeysJob : public BaseJob { +class QUOTIENT_API UploadKeysJob : public BaseJob +{ public: //! \param deviceKeys //! Identity keys for the device. May be absent if no new @@ -42,9 +41,9 @@ class QUOTIENT_API UploadKeysJob : public BaseJob { //! be included to denote that the key is a fallback key. //! //! May be absent if a new fallback key is not required. - explicit UploadKeysJob(const std::optional& deviceKeys = std::nullopt, - const OneTimeKeys& oneTimeKeys = {}, - const OneTimeKeys& fallbackKeys = {}); + explicit UploadKeysJob(const std::optional &deviceKeys = std::nullopt, + const OneTimeKeys &oneTimeKeys = {}, + const OneTimeKeys &fallbackKeys = {}); // Result properties @@ -58,24 +57,27 @@ class QUOTIENT_API UploadKeysJob : public BaseJob { } }; -inline auto collectResponse(const UploadKeysJob* job) { return job->oneTimeKeyCounts(); } +inline auto collectResponse(const UploadKeysJob *job) { return job->oneTimeKeyCounts(); } //! \brief Download device identity keys. //! //! Returns the current devices and identity keys for the given users. -class QUOTIENT_API QueryKeysJob : public BaseJob { +class QUOTIENT_API QueryKeysJob : public BaseJob +{ public: // Inner data structures //! Additional data added to the device key information //! by intermediate servers, and not covered by the //! signatures. - struct QUOTIENT_API UnsignedDeviceInfo { + struct QUOTIENT_API UnsignedDeviceInfo + { //! The display name which the user set on the device. QString deviceDisplayName{}; }; - struct QUOTIENT_API DeviceInformation : DeviceKeys { + struct QUOTIENT_API DeviceInformation : DeviceKeys + { //! Additional data added to the device key information //! by intermediate servers, and not covered by the //! signatures. @@ -92,7 +94,7 @@ class QUOTIENT_API QueryKeysJob : public BaseJob { //! \param timeout //! The time (in milliseconds) to wait when downloading keys from //! remote servers. 10 seconds is the recommended default. - explicit QueryKeysJob(const QHash& deviceKeys, + explicit QueryKeysJob(const QHash &deviceKeys, std::optional timeout = std::nullopt); // Result properties @@ -149,7 +151,8 @@ class QUOTIENT_API QueryKeysJob : public BaseJob { return loadFromJson>("user_signing_keys"_L1); } - struct Response { + struct Response + { //! If any remote homeservers could not be reached, they are //! recorded here. The names of the properties are the names of //! the unreachable servers. @@ -190,22 +193,24 @@ class QUOTIENT_API QueryKeysJob : public BaseJob { }; template JobT> -constexpr inline auto doCollectResponse = [](JobT* j) -> QueryKeysJob::Response { - return { j->failures(), j->deviceKeys(), j->masterKeys(), j->selfSigningKeys(), - j->userSigningKeys() }; +constexpr inline auto doCollectResponse = [](JobT *j) -> QueryKeysJob::Response { + return {j->failures(), j->deviceKeys(), j->masterKeys(), j->selfSigningKeys(), + j->userSigningKeys()}; }; template <> -struct QUOTIENT_API JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, QueryKeysJob::UnsignedDeviceInfo& result) +struct QUOTIENT_API JsonObjectConverter +{ + static void fillFrom(const QJsonObject &jo, QueryKeysJob::UnsignedDeviceInfo &result) { fillFromJson(jo.value("device_display_name"_L1), result.deviceDisplayName); } }; template <> -struct QUOTIENT_API JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, QueryKeysJob::DeviceInformation& result) +struct QUOTIENT_API JsonObjectConverter +{ + static void fillFrom(const QJsonObject &jo, QueryKeysJob::DeviceInformation &result) { fillFromJson(jo, result); fillFromJson(jo.value("unsigned"_L1), result.unsignedData); @@ -215,7 +220,8 @@ struct QUOTIENT_API JsonObjectConverter { //! \brief Claim one-time encryption keys. //! //! Claims one-time keys for use in pre-key messages. -class QUOTIENT_API ClaimKeysJob : public BaseJob { +class QUOTIENT_API ClaimKeysJob : public BaseJob +{ public: //! \param oneTimeKeys //! The keys to be claimed. A map from user ID, to a map from @@ -224,7 +230,7 @@ class QUOTIENT_API ClaimKeysJob : public BaseJob { //! \param timeout //! The time (in milliseconds) to wait when downloading keys from //! remote servers. 10 seconds is the recommended default. - explicit ClaimKeysJob(const QHash>& oneTimeKeys, + explicit ClaimKeysJob(const QHash> &oneTimeKeys, std::optional timeout = std::nullopt); // Result properties @@ -254,7 +260,8 @@ class QUOTIENT_API ClaimKeysJob : public BaseJob { return loadFromJson>>("one_time_keys"_L1); } - struct Response { + struct Response + { //! If any remote homeservers could not be reached, they are //! recorded here. The names of the properties are the names of //! the unreachable servers. @@ -278,7 +285,7 @@ class QUOTIENT_API ClaimKeysJob : public BaseJob { template JobT> constexpr inline auto doCollectResponse = - [](JobT* j) -> ClaimKeysJob::Response { return { j->failures(), j->oneTimeKeys() }; }; + [](JobT *j) -> ClaimKeysJob::Response { return {j->failures(), j->oneTimeKeys()}; }; //! \brief Query users with recent device key updates. //! @@ -291,7 +298,8 @@ constexpr inline auto doCollectResponse = //! membership state `join`); *and* //! * added new device identity keys or removed an existing device with //! identity keys, between `from` and `to`. -class QUOTIENT_API GetKeysChangesJob : public BaseJob { +class QUOTIENT_API GetKeysChangesJob : public BaseJob +{ public: //! \param from //! The desired start point of the list. Should be the `next_batch` field @@ -305,13 +313,13 @@ class QUOTIENT_API GetKeysChangesJob : public BaseJob { //! field from a recent call to [`/sync`](/client-server-api/#get_matrixclientv3sync) - //! typically the most recent such call. This may be used by the server as a hint to check its //! caches are up to date. - explicit GetKeysChangesJob(const QString& from, const QString& to); + explicit GetKeysChangesJob(const QString &from, const QString &to); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetKeysChangesJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& from, const QString& to); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &from, const QString &to); // Result properties @@ -324,7 +332,8 @@ class QUOTIENT_API GetKeysChangesJob : public BaseJob { //! with the user. QStringList left() const { return loadFromJson("left"_L1); } - struct Response { + struct Response + { //! The Matrix User IDs of all users who updated their device //! identity keys. QStringList changed{}; @@ -338,6 +347,6 @@ class QUOTIENT_API GetKeysChangesJob : public BaseJob { template JobT> constexpr inline auto doCollectResponse = - [](JobT* j) -> GetKeysChangesJob::Response { return { j->changed(), j->left() }; }; + [](JobT *j) -> GetKeysChangesJob::Response { return {j->changed(), j->left()}; }; } // namespace Quotient diff --git a/Quotient/csapi/kicking.cpp b/Quotient/csapi/kicking.cpp index bf61bdedb..0c84c129d 100644 --- a/Quotient/csapi/kicking.cpp +++ b/Quotient/csapi/kicking.cpp @@ -4,12 +4,12 @@ using namespace Quotient; -KickJob::KickJob(const QString& roomId, const QString& userId, const QString& reason) +KickJob::KickJob(const QString &roomId, const QString &userId, const QString &reason) : BaseJob(HttpVerb::Post, u"KickJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/kick")) { QJsonObject _dataJson; addParam(_dataJson, "user_id"_L1, userId); addParam(_dataJson, "reason"_L1, reason); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } diff --git a/Quotient/csapi/kicking.h b/Quotient/csapi/kicking.h index 74f6c0341..7b6689f56 100644 --- a/Quotient/csapi/kicking.h +++ b/Quotient/csapi/kicking.h @@ -16,7 +16,8 @@ namespace Quotient { //! optional `reason`. Like with other membership changes, a user can directly adjust //! the target member's state by making a request to `/rooms//state/m.room.member/`. -class QUOTIENT_API KickJob : public BaseJob { +class QUOTIENT_API KickJob : public BaseJob +{ public: //! \param roomId //! The room identifier (not alias) from which the user should be kicked. @@ -27,7 +28,7 @@ class QUOTIENT_API KickJob : public BaseJob { //! \param reason //! The reason the user has been kicked. This will be supplied as the //! `reason` on the target's updated [`m.room.member`](/client-server-api/#mroommember) event. - explicit KickJob(const QString& roomId, const QString& userId, const QString& reason = {}); + explicit KickJob(const QString &roomId, const QString &userId, const QString &reason = {}); }; } // namespace Quotient diff --git a/Quotient/csapi/knocking.cpp b/Quotient/csapi/knocking.cpp index f3e121e42..0cc4fdd22 100644 --- a/Quotient/csapi/knocking.cpp +++ b/Quotient/csapi/knocking.cpp @@ -4,7 +4,7 @@ using namespace Quotient; -auto queryToKnockRoom(const QStringList& serverName, const QStringList& via) +auto queryToKnockRoom(const QStringList &serverName, const QStringList &via) { QUrlQuery _q; addParam(_q, u"server_name"_s, serverName); @@ -12,14 +12,14 @@ auto queryToKnockRoom(const QStringList& serverName, const QStringList& via) return _q; } -KnockRoomJob::KnockRoomJob(const QString& roomIdOrAlias, const QStringList& serverName, - const QStringList& via, const QString& reason) +KnockRoomJob::KnockRoomJob(const QString &roomIdOrAlias, const QStringList &serverName, + const QStringList &via, const QString &reason) : BaseJob(HttpVerb::Post, u"KnockRoomJob"_s, makePath("/_matrix/client/v3", "/knock/", roomIdOrAlias), queryToKnockRoom(serverName, via)) { QJsonObject _dataJson; addParam(_dataJson, "reason"_L1, reason); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); addExpectedKey(u"room_id"_s); } diff --git a/Quotient/csapi/knocking.h b/Quotient/csapi/knocking.h index 69105f783..c4d26e332 100644 --- a/Quotient/csapi/knocking.h +++ b/Quotient/csapi/knocking.h @@ -23,7 +23,8 @@ namespace Quotient { //! //! The knock will appear as an entry in the response of the //! [`/sync`](/client-server-api/#get_matrixclientv3sync) API. -class QUOTIENT_API KnockRoomJob : public BaseJob { +class QUOTIENT_API KnockRoomJob : public BaseJob +{ public: //! \param roomIdOrAlias //! The room identifier or alias to knock upon. @@ -39,8 +40,8 @@ class QUOTIENT_API KnockRoomJob : public BaseJob { //! \param reason //! Optional reason to be included as the `reason` on the subsequent //! membership event. - explicit KnockRoomJob(const QString& roomIdOrAlias, const QStringList& serverName = {}, - const QStringList& via = {}, const QString& reason = {}); + explicit KnockRoomJob(const QString &roomIdOrAlias, const QStringList &serverName = {}, + const QStringList &via = {}, const QString &reason = {}); // Result properties @@ -48,6 +49,6 @@ class QUOTIENT_API KnockRoomJob : public BaseJob { QString roomId() const { return loadFromJson("room_id"_L1); } }; -inline auto collectResponse(const KnockRoomJob* job) { return job->roomId(); } +inline auto collectResponse(const KnockRoomJob *job) { return job->roomId(); } } // namespace Quotient diff --git a/Quotient/csapi/leaving.cpp b/Quotient/csapi/leaving.cpp index 27a37c501..d35f0307e 100644 --- a/Quotient/csapi/leaving.cpp +++ b/Quotient/csapi/leaving.cpp @@ -4,22 +4,22 @@ using namespace Quotient; -LeaveRoomJob::LeaveRoomJob(const QString& roomId, const QString& reason) +LeaveRoomJob::LeaveRoomJob(const QString &roomId, const QString &reason) : BaseJob(HttpVerb::Post, u"LeaveRoomJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/leave")) { QJsonObject _dataJson; addParam(_dataJson, "reason"_L1, reason); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } -QUrl ForgetRoomJob::makeRequestUrl(const HomeserverData& hsData, const QString& roomId) +QUrl ForgetRoomJob::makeRequestUrl(const HomeserverData &hsData, const QString &roomId) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/rooms/", roomId, "/forget")); } -ForgetRoomJob::ForgetRoomJob(const QString& roomId) +ForgetRoomJob::ForgetRoomJob(const QString &roomId) : BaseJob(HttpVerb::Post, u"ForgetRoomJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/forget")) {} diff --git a/Quotient/csapi/leaving.h b/Quotient/csapi/leaving.h index 08bc06889..ef114ff3a 100644 --- a/Quotient/csapi/leaving.h +++ b/Quotient/csapi/leaving.h @@ -19,7 +19,8 @@ namespace Quotient { //! //! The user will still be allowed to retrieve history from the room which //! they were previously allowed to see. -class QUOTIENT_API LeaveRoomJob : public BaseJob { +class QUOTIENT_API LeaveRoomJob : public BaseJob +{ public: //! \param roomId //! The room identifier to leave. @@ -27,7 +28,7 @@ class QUOTIENT_API LeaveRoomJob : public BaseJob { //! \param reason //! Optional reason to be included as the `reason` on the subsequent //! membership event. - explicit LeaveRoomJob(const QString& roomId, const QString& reason = {}); + explicit LeaveRoomJob(const QString &roomId, const QString &reason = {}); }; //! \brief Stop the requesting user remembering about a particular room. @@ -41,17 +42,18 @@ class QUOTIENT_API LeaveRoomJob : public BaseJob { //! //! If the user is currently joined to the room, they must leave the room //! before calling this API. -class QUOTIENT_API ForgetRoomJob : public BaseJob { +class QUOTIENT_API ForgetRoomJob : public BaseJob +{ public: //! \param roomId //! The room identifier to forget. - explicit ForgetRoomJob(const QString& roomId); + explicit ForgetRoomJob(const QString &roomId); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for ForgetRoomJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomId); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &roomId); }; } // namespace Quotient diff --git a/Quotient/csapi/list_joined_rooms.cpp b/Quotient/csapi/list_joined_rooms.cpp index d85cb6604..20686aa20 100644 --- a/Quotient/csapi/list_joined_rooms.cpp +++ b/Quotient/csapi/list_joined_rooms.cpp @@ -4,7 +4,7 @@ using namespace Quotient; -QUrl GetJoinedRoomsJob::makeRequestUrl(const HomeserverData& hsData) +QUrl GetJoinedRoomsJob::makeRequestUrl(const HomeserverData &hsData) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/joined_rooms")); } diff --git a/Quotient/csapi/list_joined_rooms.h b/Quotient/csapi/list_joined_rooms.h index 766bf61aa..25964f4fc 100644 --- a/Quotient/csapi/list_joined_rooms.h +++ b/Quotient/csapi/list_joined_rooms.h @@ -9,7 +9,8 @@ namespace Quotient { //! \brief Lists the user's current rooms. //! //! This API returns a list of the user's current rooms. -class QUOTIENT_API GetJoinedRoomsJob : public BaseJob { +class QUOTIENT_API GetJoinedRoomsJob : public BaseJob +{ public: explicit GetJoinedRoomsJob(); @@ -17,7 +18,7 @@ class QUOTIENT_API GetJoinedRoomsJob : public BaseJob { //! //! This function can be used when a URL for GetJoinedRoomsJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData); + static QUrl makeRequestUrl(const HomeserverData &hsData); // Result properties @@ -25,6 +26,6 @@ class QUOTIENT_API GetJoinedRoomsJob : public BaseJob { QStringList joinedRooms() const { return loadFromJson("joined_rooms"_L1); } }; -inline auto collectResponse(const GetJoinedRoomsJob* job) { return job->joinedRooms(); } +inline auto collectResponse(const GetJoinedRoomsJob *job) { return job->joinedRooms(); } } // namespace Quotient diff --git a/Quotient/csapi/list_public_rooms.cpp b/Quotient/csapi/list_public_rooms.cpp index 471a3b22d..db7938b4d 100644 --- a/Quotient/csapi/list_public_rooms.cpp +++ b/Quotient/csapi/list_public_rooms.cpp @@ -4,29 +4,29 @@ using namespace Quotient; -QUrl GetRoomVisibilityOnDirectoryJob::makeRequestUrl(const HomeserverData& hsData, - const QString& roomId) +QUrl GetRoomVisibilityOnDirectoryJob::makeRequestUrl(const HomeserverData &hsData, + const QString &roomId) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/directory/list/room/", roomId)); } -GetRoomVisibilityOnDirectoryJob::GetRoomVisibilityOnDirectoryJob(const QString& roomId) +GetRoomVisibilityOnDirectoryJob::GetRoomVisibilityOnDirectoryJob(const QString &roomId) : BaseJob(HttpVerb::Get, u"GetRoomVisibilityOnDirectoryJob"_s, makePath("/_matrix/client/v3", "/directory/list/room/", roomId), false) {} -SetRoomVisibilityOnDirectoryJob::SetRoomVisibilityOnDirectoryJob(const QString& roomId, - const QString& visibility) +SetRoomVisibilityOnDirectoryJob::SetRoomVisibilityOnDirectoryJob(const QString &roomId, + const QString &visibility) : BaseJob(HttpVerb::Put, u"SetRoomVisibilityOnDirectoryJob"_s, makePath("/_matrix/client/v3", "/directory/list/room/", roomId)) { QJsonObject _dataJson; addParam(_dataJson, "visibility"_L1, visibility); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } -auto queryToGetPublicRooms(std::optional limit, const QString& since, const QString& server) +auto queryToGetPublicRooms(std::optional limit, const QString &since, const QString &server) { QUrlQuery _q; addParam(_q, u"limit"_s, limit); @@ -35,32 +35,32 @@ auto queryToGetPublicRooms(std::optional limit, const QString& since, const return _q; } -QUrl GetPublicRoomsJob::makeRequestUrl(const HomeserverData& hsData, std::optional limit, - const QString& since, const QString& server) +QUrl GetPublicRoomsJob::makeRequestUrl(const HomeserverData &hsData, std::optional limit, + const QString &since, const QString &server) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/publicRooms"), queryToGetPublicRooms(limit, since, server)); } -GetPublicRoomsJob::GetPublicRoomsJob(std::optional limit, const QString& since, - const QString& server) +GetPublicRoomsJob::GetPublicRoomsJob(std::optional limit, const QString &since, + const QString &server) : BaseJob(HttpVerb::Get, u"GetPublicRoomsJob"_s, makePath("/_matrix/client/v3", "/publicRooms"), queryToGetPublicRooms(limit, since, server), {}, false) { addExpectedKey(u"chunk"_s); } -auto queryToQueryPublicRooms(const QString& server) +auto queryToQueryPublicRooms(const QString &server) { QUrlQuery _q; addParam(_q, u"server"_s, server); return _q; } -QueryPublicRoomsJob::QueryPublicRoomsJob(const QString& server, std::optional limit, - const QString& since, const std::optional& filter, +QueryPublicRoomsJob::QueryPublicRoomsJob(const QString &server, std::optional limit, + const QString &since, const std::optional &filter, std::optional includeAllNetworks, - const QString& thirdPartyInstanceId) + const QString &thirdPartyInstanceId) : BaseJob(HttpVerb::Post, u"QueryPublicRoomsJob"_s, makePath("/_matrix/client/v3", "/publicRooms"), queryToQueryPublicRooms(server)) { @@ -70,6 +70,6 @@ QueryPublicRoomsJob::QueryPublicRoomsJob(const QString& server, std::optional(_dataJson, "filter"_L1, filter); addParam(_dataJson, "include_all_networks"_L1, includeAllNetworks); addParam(_dataJson, "third_party_instance_id"_L1, thirdPartyInstanceId); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); addExpectedKey(u"chunk"_s); } diff --git a/Quotient/csapi/list_public_rooms.h b/Quotient/csapi/list_public_rooms.h index bca2643f1..be1774578 100644 --- a/Quotient/csapi/list_public_rooms.h +++ b/Quotient/csapi/list_public_rooms.h @@ -3,7 +3,6 @@ #pragma once #include - #include namespace Quotient { @@ -11,17 +10,18 @@ namespace Quotient { //! \brief Gets the visibility of a room in the directory //! //! Gets the visibility of a given room on the server's public room directory. -class QUOTIENT_API GetRoomVisibilityOnDirectoryJob : public BaseJob { +class QUOTIENT_API GetRoomVisibilityOnDirectoryJob : public BaseJob +{ public: //! \param roomId //! The room ID. - explicit GetRoomVisibilityOnDirectoryJob(const QString& roomId); + explicit GetRoomVisibilityOnDirectoryJob(const QString &roomId); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetRoomVisibilityOnDirectoryJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomId); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &roomId); // Result properties @@ -29,7 +29,7 @@ class QUOTIENT_API GetRoomVisibilityOnDirectoryJob : public BaseJob { QString visibility() const { return loadFromJson("visibility"_L1); } }; -inline auto collectResponse(const GetRoomVisibilityOnDirectoryJob* job) +inline auto collectResponse(const GetRoomVisibilityOnDirectoryJob *job) { return job->visibility(); } @@ -42,7 +42,8 @@ inline auto collectResponse(const GetRoomVisibilityOnDirectoryJob* job) //! Servers may choose to implement additional access control checks //! here, for instance that room visibility can only be changed by //! the room creator or a server administrator. -class QUOTIENT_API SetRoomVisibilityOnDirectoryJob : public BaseJob { +class QUOTIENT_API SetRoomVisibilityOnDirectoryJob : public BaseJob +{ public: //! \param roomId //! The room ID. @@ -50,7 +51,7 @@ class QUOTIENT_API SetRoomVisibilityOnDirectoryJob : public BaseJob { //! \param visibility //! The new visibility setting for the room. //! Defaults to 'public'. - explicit SetRoomVisibilityOnDirectoryJob(const QString& roomId, const QString& visibility = {}); + explicit SetRoomVisibilityOnDirectoryJob(const QString &roomId, const QString &visibility = {}); }; //! \brief Lists the public rooms on the server. @@ -59,7 +60,8 @@ class QUOTIENT_API SetRoomVisibilityOnDirectoryJob : public BaseJob { //! //! This API returns paginated responses. The rooms are ordered by the number //! of joined members, with the largest rooms first. -class QUOTIENT_API GetPublicRoomsJob : public BaseJob { +class QUOTIENT_API GetPublicRoomsJob : public BaseJob +{ public: //! \param limit //! Limit the number of results returned. @@ -73,15 +75,15 @@ class QUOTIENT_API GetPublicRoomsJob : public BaseJob { //! \param server //! The server to fetch the public room lists from. Defaults to the //! local server. Case sensitive. - explicit GetPublicRoomsJob(std::optional limit = std::nullopt, const QString& since = {}, - const QString& server = {}); + explicit GetPublicRoomsJob(std::optional limit = std::nullopt, const QString &since = {}, + const QString &server = {}); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetPublicRoomsJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, std::optional limit = std::nullopt, - const QString& since = {}, const QString& server = {}); + static QUrl makeRequestUrl(const HomeserverData &hsData, std::optional limit = std::nullopt, + const QString &since = {}, const QString &server = {}); // Result properties @@ -108,7 +110,8 @@ class QUOTIENT_API GetPublicRoomsJob : public BaseJob { return loadFromJson>("total_room_count_estimate"_L1); } - struct Response { + struct Response + { //! A paginated chunk of public rooms. QVector chunk{}; @@ -129,8 +132,8 @@ class QUOTIENT_API GetPublicRoomsJob : public BaseJob { }; template JobT> -constexpr inline auto doCollectResponse = [](JobT* j) -> GetPublicRoomsJob::Response { - return { j->chunk(), j->nextBatch(), j->prevBatch(), j->totalRoomCountEstimate() }; +constexpr inline auto doCollectResponse = [](JobT *j) -> GetPublicRoomsJob::Response { + return {j->chunk(), j->nextBatch(), j->prevBatch(), j->totalRoomCountEstimate()}; }; //! \brief Lists the public rooms on the server with optional filter. @@ -139,12 +142,14 @@ constexpr inline auto doCollectResponse = [](JobT* j) -> GetPublicRoomsJob //! //! This API returns paginated responses. The rooms are ordered by the number //! of joined members, with the largest rooms first. -class QUOTIENT_API QueryPublicRoomsJob : public BaseJob { +class QUOTIENT_API QueryPublicRoomsJob : public BaseJob +{ public: // Inner data structures //! Filter to apply to the results. - struct QUOTIENT_API Filter { + struct QUOTIENT_API Filter + { //! An optional string to search for in the room metadata, e.g. name, //! topic, canonical alias, etc. QString genericSearchTerm{}; @@ -181,11 +186,11 @@ class QUOTIENT_API QueryPublicRoomsJob : public BaseJob { //! \param thirdPartyInstanceId //! The specific third-party network/protocol to request from the //! homeserver. Can only be used if `include_all_networks` is false. - explicit QueryPublicRoomsJob(const QString& server = {}, - std::optional limit = std::nullopt, const QString& since = {}, - const std::optional& filter = std::nullopt, + explicit QueryPublicRoomsJob(const QString &server = {}, + std::optional limit = std::nullopt, const QString &since = {}, + const std::optional &filter = std::nullopt, std::optional includeAllNetworks = std::nullopt, - const QString& thirdPartyInstanceId = {}); + const QString &thirdPartyInstanceId = {}); // Result properties @@ -212,7 +217,8 @@ class QUOTIENT_API QueryPublicRoomsJob : public BaseJob { return loadFromJson>("total_room_count_estimate"_L1); } - struct Response { + struct Response + { //! A paginated chunk of public rooms. QVector chunk{}; @@ -233,13 +239,14 @@ class QUOTIENT_API QueryPublicRoomsJob : public BaseJob { }; template JobT> -constexpr inline auto doCollectResponse = [](JobT* j) -> QueryPublicRoomsJob::Response { - return { j->chunk(), j->nextBatch(), j->prevBatch(), j->totalRoomCountEstimate() }; +constexpr inline auto doCollectResponse = [](JobT *j) -> QueryPublicRoomsJob::Response { + return {j->chunk(), j->nextBatch(), j->prevBatch(), j->totalRoomCountEstimate()}; }; template <> -struct QUOTIENT_API JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const QueryPublicRoomsJob::Filter& pod) +struct QUOTIENT_API JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const QueryPublicRoomsJob::Filter &pod) { addParam(jo, "generic_search_term"_L1, pod.genericSearchTerm); addParam(jo, "room_types"_L1, pod.roomTypes); diff --git a/Quotient/csapi/login.cpp b/Quotient/csapi/login.cpp index 6e14290ca..268d51ad4 100644 --- a/Quotient/csapi/login.cpp +++ b/Quotient/csapi/login.cpp @@ -4,7 +4,7 @@ using namespace Quotient; -QUrl GetLoginFlowsJob::makeRequestUrl(const HomeserverData& hsData) +QUrl GetLoginFlowsJob::makeRequestUrl(const HomeserverData &hsData) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/login")); } @@ -13,9 +13,9 @@ GetLoginFlowsJob::GetLoginFlowsJob() : BaseJob(HttpVerb::Get, u"GetLoginFlowsJob"_s, makePath("/_matrix/client/v3", "/login"), false) {} -LoginJob::LoginJob(const QString& type, const std::optional& identifier, - const QString& password, const QString& token, const QString& deviceId, - const QString& initialDeviceDisplayName, std::optional refreshToken) +LoginJob::LoginJob(const QString &type, const std::optional &identifier, + const QString &password, const QString &token, const QString &deviceId, + const QString &initialDeviceDisplayName, std::optional refreshToken) : BaseJob(HttpVerb::Post, u"LoginJob"_s, makePath("/_matrix/client/v3", "/login"), false) { QJsonObject _dataJson; @@ -26,7 +26,7 @@ LoginJob::LoginJob(const QString& type, const std::optional& ide addParam(_dataJson, "device_id"_L1, deviceId); addParam(_dataJson, "initial_device_display_name"_L1, initialDeviceDisplayName); addParam(_dataJson, "refresh_token"_L1, refreshToken); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); addExpectedKey(u"user_id"_s); addExpectedKey(u"access_token"_s); addExpectedKey(u"device_id"_s); diff --git a/Quotient/csapi/login.h b/Quotient/csapi/login.h index 1a5c1bbd8..fde38dcf5 100644 --- a/Quotient/csapi/login.h +++ b/Quotient/csapi/login.h @@ -4,7 +4,6 @@ #include #include - #include namespace Quotient { @@ -13,11 +12,13 @@ namespace Quotient { //! //! Gets the homeserver's supported login types to authenticate users. Clients //! should pick one of these and supply it as the `type` when logging in. -class QUOTIENT_API GetLoginFlowsJob : public BaseJob { +class QUOTIENT_API GetLoginFlowsJob : public BaseJob +{ public: // Inner data structures - struct QUOTIENT_API LoginFlow { + struct QUOTIENT_API LoginFlow + { //! The login type. This is supplied as the `type` when //! logging in. QString type; @@ -28,9 +29,9 @@ class QUOTIENT_API GetLoginFlowsJob : public BaseJob { //! endpoint. Note that supporting the endpoint does not //! necessarily indicate that the user attempting to log in will //! be able to generate such a token. - bool getLoginToken{ false }; + bool getLoginToken{false}; - bool delegatedOidcCompatibility{ false }; + bool delegatedOidcCompatibility{false}; }; // Construction/destruction @@ -41,7 +42,7 @@ class QUOTIENT_API GetLoginFlowsJob : public BaseJob { //! //! This function can be used when a URL for GetLoginFlowsJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData); + static QUrl makeRequestUrl(const HomeserverData &hsData); // Result properties @@ -49,11 +50,12 @@ class QUOTIENT_API GetLoginFlowsJob : public BaseJob { QVector flows() const { return loadFromJson>("flows"_L1); } }; -inline auto collectResponse(const GetLoginFlowsJob* job) { return job->flows(); } +inline auto collectResponse(const GetLoginFlowsJob *job) { return job->flows(); } template <> -struct QUOTIENT_API JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, GetLoginFlowsJob::LoginFlow& result) +struct QUOTIENT_API JsonObjectConverter +{ + static void fillFrom(const QJsonObject &jo, GetLoginFlowsJob::LoginFlow &result) { fillFromJson(jo.value("type"_L1), result.type); fillFromJson(jo.value("get_login_token"_L1), result.getLoginToken); @@ -75,7 +77,8 @@ struct QUOTIENT_API JsonObjectConverter { //! invalidate any access token previously associated with that device. See //! [Relationship between access tokens and //! devices](/client-server-api/#relationship-between-access-tokens-and-devices). -class QUOTIENT_API LoginJob : public BaseJob { +class QUOTIENT_API LoginJob : public BaseJob +{ public: //! \param type //! The login type being used. @@ -106,10 +109,10 @@ class QUOTIENT_API LoginJob : public BaseJob { //! //! \param refreshToken //! If true, the client supports refresh tokens. - explicit LoginJob(const QString& type, - const std::optional& identifier = std::nullopt, - const QString& password = {}, const QString& token = {}, - const QString& deviceId = {}, const QString& initialDeviceDisplayName = {}, + explicit LoginJob(const QString &type, + const std::optional &identifier = std::nullopt, + const QString &password = {}, const QString &token = {}, + const QString &deviceId = {}, const QString &initialDeviceDisplayName = {}, std::optional refreshToken = std::nullopt); // Result properties @@ -150,7 +153,8 @@ class QUOTIENT_API LoginJob : public BaseJob { return loadFromJson>("well_known"_L1); } - struct Response { + struct Response + { //! The fully-qualified Matrix ID for the account. QString userId{}; @@ -184,9 +188,9 @@ class QUOTIENT_API LoginJob : public BaseJob { }; template JobT> -constexpr inline auto doCollectResponse = [](JobT* j) -> LoginJob::Response { - return { j->userId(), j->accessToken(), j->refreshToken(), - j->expiresInMs(), j->deviceId(), j->wellKnown() }; +constexpr inline auto doCollectResponse = [](JobT *j) -> LoginJob::Response { + return {j->userId(), j->accessToken(), j->refreshToken(), + j->expiresInMs(), j->deviceId(), j->wellKnown()}; }; } // namespace Quotient diff --git a/Quotient/csapi/login_token.cpp b/Quotient/csapi/login_token.cpp index 3ad217734..c4017a748 100644 --- a/Quotient/csapi/login_token.cpp +++ b/Quotient/csapi/login_token.cpp @@ -4,13 +4,13 @@ using namespace Quotient; -GenerateLoginTokenJob::GenerateLoginTokenJob(const std::optional& auth) +GenerateLoginTokenJob::GenerateLoginTokenJob(const std::optional &auth) : BaseJob(HttpVerb::Post, u"GenerateLoginTokenJob"_s, makePath("/_matrix/client/v1", "/login/get_token")) { QJsonObject _dataJson; addParam(_dataJson, "auth"_L1, auth); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); addExpectedKey(u"login_token"_s); addExpectedKey(u"expires_in_ms"_s); } diff --git a/Quotient/csapi/login_token.h b/Quotient/csapi/login_token.h index 73a9c4d8f..32c3d2d6a 100644 --- a/Quotient/csapi/login_token.h +++ b/Quotient/csapi/login_token.h @@ -3,7 +3,6 @@ #pragma once #include - #include namespace Quotient { @@ -43,11 +42,12 @@ namespace Quotient { //! //! Servers are encouraged to apply stricter than normal rate limiting to this endpoint, such as //! maximum of 1 request per minute. -class QUOTIENT_API GenerateLoginTokenJob : public BaseJob { +class QUOTIENT_API GenerateLoginTokenJob : public BaseJob +{ public: //! \param auth //! Additional authentication information for the user-interactive authentication API. - explicit GenerateLoginTokenJob(const std::optional& auth = std::nullopt); + explicit GenerateLoginTokenJob(const std::optional &auth = std::nullopt); // Result properties @@ -58,7 +58,8 @@ class QUOTIENT_API GenerateLoginTokenJob : public BaseJob { //! `120000` (2 minutes) is recommended as a default. int expiresInMs() const { return loadFromJson("expires_in_ms"_L1); } - struct Response { + struct Response + { //! The login token for the `m.login.token` login flow. QString loginToken{}; @@ -69,8 +70,7 @@ class QUOTIENT_API GenerateLoginTokenJob : public BaseJob { }; template JobT> -constexpr inline auto doCollectResponse = [](JobT* j) -> GenerateLoginTokenJob::Response { - return { j->loginToken(), j->expiresInMs() }; -}; +constexpr inline auto doCollectResponse = + [](JobT *j) -> GenerateLoginTokenJob::Response { return {j->loginToken(), j->expiresInMs()}; }; } // namespace Quotient diff --git a/Quotient/csapi/logout.cpp b/Quotient/csapi/logout.cpp index e3bfb875c..69edd21bd 100644 --- a/Quotient/csapi/logout.cpp +++ b/Quotient/csapi/logout.cpp @@ -4,7 +4,7 @@ using namespace Quotient; -QUrl LogoutJob::makeRequestUrl(const HomeserverData& hsData) +QUrl LogoutJob::makeRequestUrl(const HomeserverData &hsData) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/logout")); } @@ -13,7 +13,7 @@ LogoutJob::LogoutJob() : BaseJob(HttpVerb::Post, u"LogoutJob"_s, makePath("/_matrix/client/v3", "/logout")) {} -QUrl LogoutAllJob::makeRequestUrl(const HomeserverData& hsData) +QUrl LogoutAllJob::makeRequestUrl(const HomeserverData &hsData) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/logout/all")); } diff --git a/Quotient/csapi/logout.h b/Quotient/csapi/logout.h index 7f3be42fa..8f92ab1ab 100644 --- a/Quotient/csapi/logout.h +++ b/Quotient/csapi/logout.h @@ -11,7 +11,8 @@ namespace Quotient { //! Invalidates an existing access token, so that it can no longer be used for //! authorization. The device associated with the access token is also deleted. //! [Device keys](/client-server-api/#device-keys) for the device are deleted alongside the device. -class QUOTIENT_API LogoutJob : public BaseJob { +class QUOTIENT_API LogoutJob : public BaseJob +{ public: explicit LogoutJob(); @@ -19,7 +20,7 @@ class QUOTIENT_API LogoutJob : public BaseJob { //! //! This function can be used when a URL for LogoutJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData); + static QUrl makeRequestUrl(const HomeserverData &hsData); }; //! \brief Invalidates all access tokens for a user @@ -35,7 +36,8 @@ class QUOTIENT_API LogoutJob : public BaseJob { //! access token then takes over the account. This endpoint invalidates all access tokens for the //! user, including the token used in the request, and therefore the attacker is unable to take over //! the account in this way. -class QUOTIENT_API LogoutAllJob : public BaseJob { +class QUOTIENT_API LogoutAllJob : public BaseJob +{ public: explicit LogoutAllJob(); @@ -43,7 +45,7 @@ class QUOTIENT_API LogoutAllJob : public BaseJob { //! //! This function can be used when a URL for LogoutAllJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData); + static QUrl makeRequestUrl(const HomeserverData &hsData); }; } // namespace Quotient diff --git a/Quotient/csapi/message_pagination.cpp b/Quotient/csapi/message_pagination.cpp index dde1ec960..6d6a6b8f3 100644 --- a/Quotient/csapi/message_pagination.cpp +++ b/Quotient/csapi/message_pagination.cpp @@ -4,8 +4,8 @@ using namespace Quotient; -auto queryToGetRoomEvents(const QString& from, const QString& to, const QString& dir, - std::optional limit, const QString& filter) +auto queryToGetRoomEvents(const QString &from, const QString &to, const QString &dir, + std::optional limit, const QString &filter) { QUrlQuery _q; addParam(_q, u"from"_s, from); @@ -16,18 +16,18 @@ auto queryToGetRoomEvents(const QString& from, const QString& to, const QString& return _q; } -QUrl GetRoomEventsJob::makeRequestUrl(const HomeserverData& hsData, const QString& roomId, - const QString& dir, const QString& from, const QString& to, - std::optional limit, const QString& filter) +QUrl GetRoomEventsJob::makeRequestUrl(const HomeserverData &hsData, const QString &roomId, + const QString &dir, const QString &from, const QString &to, + std::optional limit, const QString &filter) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/rooms/", roomId, "/messages"), queryToGetRoomEvents(from, to, dir, limit, filter)); } -GetRoomEventsJob::GetRoomEventsJob(const QString& roomId, const QString& dir, const QString& from, - const QString& to, std::optional limit, - const QString& filter) +GetRoomEventsJob::GetRoomEventsJob(const QString &roomId, const QString &dir, const QString &from, + const QString &to, std::optional limit, + const QString &filter) : BaseJob(HttpVerb::Get, u"GetRoomEventsJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/messages"), queryToGetRoomEvents(from, to, dir, limit, filter)) diff --git a/Quotient/csapi/message_pagination.h b/Quotient/csapi/message_pagination.h index 8839ab562..ee963a08b 100644 --- a/Quotient/csapi/message_pagination.h +++ b/Quotient/csapi/message_pagination.h @@ -14,7 +14,8 @@ namespace Quotient { //! //! *Note*: This endpoint supports lazy-loading of room member events. See //! [Lazy-loading room members](/client-server-api/#lazy-loading-room-members) for more information. -class QUOTIENT_API GetRoomEventsJob : public BaseJob { +class QUOTIENT_API GetRoomEventsJob : public BaseJob +{ public: //! \param roomId //! The room to get events from. @@ -48,17 +49,17 @@ class QUOTIENT_API GetRoomEventsJob : public BaseJob { //! //! \param filter //! A JSON RoomEventFilter to filter returned events with. - explicit GetRoomEventsJob(const QString& roomId, const QString& dir, const QString& from = {}, - const QString& to = {}, std::optional limit = std::nullopt, - const QString& filter = {}); + explicit GetRoomEventsJob(const QString &roomId, const QString &dir, const QString &from = {}, + const QString &to = {}, std::optional limit = std::nullopt, + const QString &filter = {}); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetRoomEventsJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomId, - const QString& dir, const QString& from = {}, const QString& to = {}, - std::optional limit = std::nullopt, const QString& filter = {}); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &roomId, + const QString &dir, const QString &from = {}, const QString &to = {}, + std::optional limit = std::nullopt, const QString &filter = {}); // Result properties @@ -95,7 +96,8 @@ class QUOTIENT_API GetRoomEventsJob : public BaseJob { //! the membership of those members has not changed. RoomEvents state() { return takeFromJson("state"_L1); } - struct Response { + struct Response + { //! A token corresponding to the start of `chunk`. This will be the same as //! the value given in `from`. QString begin{}; @@ -132,8 +134,8 @@ class QUOTIENT_API GetRoomEventsJob : public BaseJob { }; template JobT> -constexpr inline auto doCollectResponse = [](JobT* j) -> GetRoomEventsJob::Response { - return { j->begin(), j->end(), j->chunk(), j->state() }; +constexpr inline auto doCollectResponse = [](JobT *j) -> GetRoomEventsJob::Response { + return {j->begin(), j->end(), j->chunk(), j->state()}; }; } // namespace Quotient diff --git a/Quotient/csapi/notifications.cpp b/Quotient/csapi/notifications.cpp index bef2049f9..faf6f4981 100644 --- a/Quotient/csapi/notifications.cpp +++ b/Quotient/csapi/notifications.cpp @@ -4,7 +4,7 @@ using namespace Quotient; -auto queryToGetNotifications(const QString& from, std::optional limit, const QString& only) +auto queryToGetNotifications(const QString &from, std::optional limit, const QString &only) { QUrlQuery _q; addParam(_q, u"from"_s, from); @@ -13,15 +13,15 @@ auto queryToGetNotifications(const QString& from, std::optional limit, cons return _q; } -QUrl GetNotificationsJob::makeRequestUrl(const HomeserverData& hsData, const QString& from, - std::optional limit, const QString& only) +QUrl GetNotificationsJob::makeRequestUrl(const HomeserverData &hsData, const QString &from, + std::optional limit, const QString &only) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/notifications"), queryToGetNotifications(from, limit, only)); } -GetNotificationsJob::GetNotificationsJob(const QString& from, std::optional limit, - const QString& only) +GetNotificationsJob::GetNotificationsJob(const QString &from, std::optional limit, + const QString &only) : BaseJob(HttpVerb::Get, u"GetNotificationsJob"_s, makePath("/_matrix/client/v3", "/notifications"), queryToGetNotifications(from, limit, only)) diff --git a/Quotient/csapi/notifications.h b/Quotient/csapi/notifications.h index a7112e42e..9c9ba5983 100644 --- a/Quotient/csapi/notifications.h +++ b/Quotient/csapi/notifications.h @@ -11,11 +11,13 @@ namespace Quotient { //! //! This API is used to paginate through the list of events that the //! user has been, or would have been notified about. -class QUOTIENT_API GetNotificationsJob : public BaseJob { +class QUOTIENT_API GetNotificationsJob : public BaseJob +{ public: // Inner data structures - struct QUOTIENT_API Notification { + struct QUOTIENT_API Notification + { //! The action(s) to perform when the conditions for this rule are met. //! See [Push Rules: API](/client-server-api/#push-rules-api). QVector actions; @@ -51,15 +53,15 @@ class QUOTIENT_API GetNotificationsJob : public BaseJob { //! Allows basic filtering of events returned. Supply `highlight` //! to return only events where the notification had the highlight //! tweak set. - explicit GetNotificationsJob(const QString& from = {}, std::optional limit = std::nullopt, - const QString& only = {}); + explicit GetNotificationsJob(const QString &from = {}, std::optional limit = std::nullopt, + const QString &only = {}); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetNotificationsJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& from = {}, - std::optional limit = std::nullopt, const QString& only = {}); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &from = {}, + std::optional limit = std::nullopt, const QString &only = {}); // Result properties @@ -74,7 +76,8 @@ class QUOTIENT_API GetNotificationsJob : public BaseJob { return takeFromJson>("notifications"_L1); } - struct Response { + struct Response + { //! The token to supply in the `from` param of the next //! `/notifications` request in order to request more //! events. If this is absent, there are no more results. @@ -87,11 +90,12 @@ class QUOTIENT_API GetNotificationsJob : public BaseJob { template JobT> constexpr inline auto doCollectResponse = - [](JobT* j) -> GetNotificationsJob::Response { return { j->nextToken(), j->notifications() }; }; + [](JobT *j) -> GetNotificationsJob::Response { return {j->nextToken(), j->notifications()}; }; template <> -struct QUOTIENT_API JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, GetNotificationsJob::Notification& result) +struct QUOTIENT_API JsonObjectConverter +{ + static void fillFrom(const QJsonObject &jo, GetNotificationsJob::Notification &result) { fillFromJson(jo.value("actions"_L1), result.actions); fillFromJson(jo.value("event"_L1), result.event); diff --git a/Quotient/csapi/openid.cpp b/Quotient/csapi/openid.cpp index 2e2db221c..50ba3e097 100644 --- a/Quotient/csapi/openid.cpp +++ b/Quotient/csapi/openid.cpp @@ -4,9 +4,9 @@ using namespace Quotient; -RequestOpenIdTokenJob::RequestOpenIdTokenJob(const QString& userId, const QJsonObject& dontUse) +RequestOpenIdTokenJob::RequestOpenIdTokenJob(const QString &userId, const QJsonObject &dontUse) : BaseJob(HttpVerb::Post, u"RequestOpenIdTokenJob"_s, makePath("/_matrix/client/v3", "/user/", userId, "/openid/request_token")) { - setRequestData({ toJson(dontUse) }); + setRequestData({toJson(dontUse)}); } diff --git a/Quotient/csapi/openid.h b/Quotient/csapi/openid.h index a11c62515..6f9ef95cc 100644 --- a/Quotient/csapi/openid.h +++ b/Quotient/csapi/openid.h @@ -3,7 +3,6 @@ #pragma once #include - #include namespace Quotient { @@ -18,7 +17,8 @@ namespace Quotient { //! The access token generated is only valid for the OpenID API. It cannot //! be used to request another OpenID access token or call `/sync`, for //! example. -class QUOTIENT_API RequestOpenIdTokenJob : public BaseJob { +class QUOTIENT_API RequestOpenIdTokenJob : public BaseJob +{ public: //! \param userId //! The user to request an OpenID token for. Should be the user who @@ -26,7 +26,7 @@ class QUOTIENT_API RequestOpenIdTokenJob : public BaseJob { //! //! \param dontUse //! An empty object. Reserved for future expansion. - explicit RequestOpenIdTokenJob(const QString& userId, const QJsonObject& dontUse = {}); + explicit RequestOpenIdTokenJob(const QString &userId, const QJsonObject &dontUse = {}); // Result properties @@ -39,6 +39,6 @@ class QUOTIENT_API RequestOpenIdTokenJob : public BaseJob { OpenIdCredentials tokenData() const { return fromJson(jsonData()); } }; -inline auto collectResponse(const RequestOpenIdTokenJob* job) { return job->tokenData(); } +inline auto collectResponse(const RequestOpenIdTokenJob *job) { return job->tokenData(); } } // namespace Quotient diff --git a/Quotient/csapi/peeking_events.cpp b/Quotient/csapi/peeking_events.cpp index dd2592f23..fdc09a2e8 100644 --- a/Quotient/csapi/peeking_events.cpp +++ b/Quotient/csapi/peeking_events.cpp @@ -4,7 +4,7 @@ using namespace Quotient; -auto queryToPeekEvents(const QString& from, std::optional timeout, const QString& roomId) +auto queryToPeekEvents(const QString &from, std::optional timeout, const QString &roomId) { QUrlQuery _q; addParam(_q, u"from"_s, from); @@ -13,14 +13,14 @@ auto queryToPeekEvents(const QString& from, std::optional timeout, const QS return _q; } -QUrl PeekEventsJob::makeRequestUrl(const HomeserverData& hsData, const QString& from, - std::optional timeout, const QString& roomId) +QUrl PeekEventsJob::makeRequestUrl(const HomeserverData &hsData, const QString &from, + std::optional timeout, const QString &roomId) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/events"), queryToPeekEvents(from, timeout, roomId)); } -PeekEventsJob::PeekEventsJob(const QString& from, std::optional timeout, const QString& roomId) +PeekEventsJob::PeekEventsJob(const QString &from, std::optional timeout, const QString &roomId) : BaseJob(HttpVerb::Get, u"PeekEventsJob"_s, makePath("/_matrix/client/v3", "/events"), queryToPeekEvents(from, timeout, roomId)) {} diff --git a/Quotient/csapi/peeking_events.h b/Quotient/csapi/peeking_events.h index 8b12e94d0..685e1b036 100644 --- a/Quotient/csapi/peeking_events.h +++ b/Quotient/csapi/peeking_events.h @@ -19,7 +19,8 @@ namespace Quotient { //! Note that the normal `/events` endpoint has been deprecated. This //! API will also be deprecated at some point, but its replacement is not //! yet known. -class QUOTIENT_API PeekEventsJob : public BaseJob { +class QUOTIENT_API PeekEventsJob : public BaseJob +{ public: //! \param from //! The token to stream from. This token is either from a previous @@ -30,16 +31,16 @@ class QUOTIENT_API PeekEventsJob : public BaseJob { //! //! \param roomId //! The room ID for which events should be returned. - explicit PeekEventsJob(const QString& from = {}, std::optional timeout = std::nullopt, - const QString& roomId = {}); + explicit PeekEventsJob(const QString &from = {}, std::optional timeout = std::nullopt, + const QString &roomId = {}); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for PeekEventsJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& from = {}, + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &from = {}, std::optional timeout = std::nullopt, - const QString& roomId = {}); + const QString &roomId = {}); // Result properties @@ -54,7 +55,8 @@ class QUOTIENT_API PeekEventsJob : public BaseJob { //! An array of events. RoomEvents chunk() { return takeFromJson("chunk"_L1); } - struct Response { + struct Response + { //! A token which correlates to the first value in `chunk`. This //! is usually the same token supplied to `from=`. QString begin{}; @@ -70,6 +72,6 @@ class QUOTIENT_API PeekEventsJob : public BaseJob { template JobT> constexpr inline auto doCollectResponse = - [](JobT* j) -> PeekEventsJob::Response { return { j->begin(), j->end(), j->chunk() }; }; + [](JobT *j) -> PeekEventsJob::Response { return {j->begin(), j->end(), j->chunk()}; }; } // namespace Quotient diff --git a/Quotient/csapi/presence.cpp b/Quotient/csapi/presence.cpp index 0045ba2ea..84b3f4ed8 100644 --- a/Quotient/csapi/presence.cpp +++ b/Quotient/csapi/presence.cpp @@ -4,24 +4,24 @@ using namespace Quotient; -SetPresenceJob::SetPresenceJob(const QString& userId, const QString& presence, - const QString& statusMsg) +SetPresenceJob::SetPresenceJob(const QString &userId, const QString &presence, + const QString &statusMsg) : BaseJob(HttpVerb::Put, u"SetPresenceJob"_s, makePath("/_matrix/client/v3", "/presence/", userId, "/status")) { QJsonObject _dataJson; addParam(_dataJson, "presence"_L1, presence); addParam(_dataJson, "status_msg"_L1, statusMsg); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } -QUrl GetPresenceJob::makeRequestUrl(const HomeserverData& hsData, const QString& userId) +QUrl GetPresenceJob::makeRequestUrl(const HomeserverData &hsData, const QString &userId) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/presence/", userId, "/status")); } -GetPresenceJob::GetPresenceJob(const QString& userId) +GetPresenceJob::GetPresenceJob(const QString &userId) : BaseJob(HttpVerb::Get, u"GetPresenceJob"_s, makePath("/_matrix/client/v3", "/presence/", userId, "/status")) { diff --git a/Quotient/csapi/presence.h b/Quotient/csapi/presence.h index 8f89055cb..7d8ebf312 100644 --- a/Quotient/csapi/presence.h +++ b/Quotient/csapi/presence.h @@ -12,7 +12,8 @@ namespace Quotient { //! the activity time is updated to reflect that activity; the client does //! not need to specify the `last_active_ago` field. You cannot set the //! presence state of another user. -class QUOTIENT_API SetPresenceJob : public BaseJob { +class QUOTIENT_API SetPresenceJob : public BaseJob +{ public: //! \param userId //! The user whose presence state to update. @@ -22,24 +23,25 @@ class QUOTIENT_API SetPresenceJob : public BaseJob { //! //! \param statusMsg //! The status message to attach to this state. - explicit SetPresenceJob(const QString& userId, const QString& presence, - const QString& statusMsg = {}); + explicit SetPresenceJob(const QString &userId, const QString &presence, + const QString &statusMsg = {}); }; //! \brief Get this user's presence state. //! //! Get the given user's presence state. -class QUOTIENT_API GetPresenceJob : public BaseJob { +class QUOTIENT_API GetPresenceJob : public BaseJob +{ public: //! \param userId //! The user whose presence state to get. - explicit GetPresenceJob(const QString& userId); + explicit GetPresenceJob(const QString &userId); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetPresenceJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& userId); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &userId); // Result properties @@ -62,7 +64,8 @@ class QUOTIENT_API GetPresenceJob : public BaseJob { return loadFromJson>("currently_active"_L1); } - struct Response { + struct Response + { //! This user's presence. QString presence{}; @@ -79,8 +82,8 @@ class QUOTIENT_API GetPresenceJob : public BaseJob { }; template JobT> -constexpr inline auto doCollectResponse = [](JobT* j) -> GetPresenceJob::Response { - return { j->presence(), j->lastActiveAgo(), j->statusMsg(), j->currentlyActive() }; +constexpr inline auto doCollectResponse = [](JobT *j) -> GetPresenceJob::Response { + return {j->presence(), j->lastActiveAgo(), j->statusMsg(), j->currentlyActive()}; }; } // namespace Quotient diff --git a/Quotient/csapi/profile.cpp b/Quotient/csapi/profile.cpp index 7d35fb414..daa61662e 100644 --- a/Quotient/csapi/profile.cpp +++ b/Quotient/csapi/profile.cpp @@ -4,52 +4,52 @@ using namespace Quotient; -SetDisplayNameJob::SetDisplayNameJob(const QString& userId, const QString& displayname) +SetDisplayNameJob::SetDisplayNameJob(const QString &userId, const QString &displayname) : BaseJob(HttpVerb::Put, u"SetDisplayNameJob"_s, makePath("/_matrix/client/v3", "/profile/", userId, "/displayname")) { QJsonObject _dataJson; addParam(_dataJson, "displayname"_L1, displayname); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } -QUrl GetDisplayNameJob::makeRequestUrl(const HomeserverData& hsData, const QString& userId) +QUrl GetDisplayNameJob::makeRequestUrl(const HomeserverData &hsData, const QString &userId) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/profile/", userId, "/displayname")); } -GetDisplayNameJob::GetDisplayNameJob(const QString& userId) +GetDisplayNameJob::GetDisplayNameJob(const QString &userId) : BaseJob(HttpVerb::Get, u"GetDisplayNameJob"_s, makePath("/_matrix/client/v3", "/profile/", userId, "/displayname")) {} -SetAvatarUrlJob::SetAvatarUrlJob(const QString& userId, const QUrl& avatarUrl) +SetAvatarUrlJob::SetAvatarUrlJob(const QString &userId, const QUrl &avatarUrl) : BaseJob(HttpVerb::Put, u"SetAvatarUrlJob"_s, makePath("/_matrix/client/v3", "/profile/", userId, "/avatar_url")) { QJsonObject _dataJson; addParam(_dataJson, "avatar_url"_L1, avatarUrl); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } -QUrl GetAvatarUrlJob::makeRequestUrl(const HomeserverData& hsData, const QString& userId) +QUrl GetAvatarUrlJob::makeRequestUrl(const HomeserverData &hsData, const QString &userId) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/profile/", userId, "/avatar_url")); } -GetAvatarUrlJob::GetAvatarUrlJob(const QString& userId) +GetAvatarUrlJob::GetAvatarUrlJob(const QString &userId) : BaseJob(HttpVerb::Get, u"GetAvatarUrlJob"_s, makePath("/_matrix/client/v3", "/profile/", userId, "/avatar_url")) {} -QUrl GetUserProfileJob::makeRequestUrl(const HomeserverData& hsData, const QString& userId) +QUrl GetUserProfileJob::makeRequestUrl(const HomeserverData &hsData, const QString &userId) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/profile/", userId)); } -GetUserProfileJob::GetUserProfileJob(const QString& userId) +GetUserProfileJob::GetUserProfileJob(const QString &userId) : BaseJob(HttpVerb::Get, u"GetUserProfileJob"_s, makePath("/_matrix/client/v3", "/profile/", userId)) {} diff --git a/Quotient/csapi/profile.h b/Quotient/csapi/profile.h index a96789503..f8d2be38e 100644 --- a/Quotient/csapi/profile.h +++ b/Quotient/csapi/profile.h @@ -10,14 +10,15 @@ namespace Quotient { //! //! This API sets the given user's display name. You must have permission to //! set this user's display name, e.g. you need to have their `access_token`. -class QUOTIENT_API SetDisplayNameJob : public BaseJob { +class QUOTIENT_API SetDisplayNameJob : public BaseJob +{ public: //! \param userId //! The user whose display name to set. //! //! \param displayname //! The new display name for this user. - explicit SetDisplayNameJob(const QString& userId, const QString& displayname); + explicit SetDisplayNameJob(const QString &userId, const QString &displayname); }; //! \brief Get the user's display name. @@ -25,17 +26,18 @@ class QUOTIENT_API SetDisplayNameJob : public BaseJob { //! Get the user's display name. This API may be used to fetch the user's //! own displayname or to query the name of other users; either locally or //! on remote homeservers. -class QUOTIENT_API GetDisplayNameJob : public BaseJob { +class QUOTIENT_API GetDisplayNameJob : public BaseJob +{ public: //! \param userId //! The user whose display name to get. - explicit GetDisplayNameJob(const QString& userId); + explicit GetDisplayNameJob(const QString &userId); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetDisplayNameJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& userId); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &userId); // Result properties @@ -43,20 +45,21 @@ class QUOTIENT_API GetDisplayNameJob : public BaseJob { QString displayname() const { return loadFromJson("displayname"_L1); } }; -inline auto collectResponse(const GetDisplayNameJob* job) { return job->displayname(); } +inline auto collectResponse(const GetDisplayNameJob *job) { return job->displayname(); } //! \brief Set the user's avatar URL. //! //! This API sets the given user's avatar URL. You must have permission to //! set this user's avatar URL, e.g. you need to have their `access_token`. -class QUOTIENT_API SetAvatarUrlJob : public BaseJob { +class QUOTIENT_API SetAvatarUrlJob : public BaseJob +{ public: //! \param userId //! The user whose avatar URL to set. //! //! \param avatarUrl //! The new avatar URL for this user. - explicit SetAvatarUrlJob(const QString& userId, const QUrl& avatarUrl); + explicit SetAvatarUrlJob(const QString &userId, const QUrl &avatarUrl); }; //! \brief Get the user's avatar URL. @@ -64,17 +67,18 @@ class QUOTIENT_API SetAvatarUrlJob : public BaseJob { //! Get the user's avatar URL. This API may be used to fetch the user's //! own avatar URL or to query the URL of other users; either locally or //! on remote homeservers. -class QUOTIENT_API GetAvatarUrlJob : public BaseJob { +class QUOTIENT_API GetAvatarUrlJob : public BaseJob +{ public: //! \param userId //! The user whose avatar URL to get. - explicit GetAvatarUrlJob(const QString& userId); + explicit GetAvatarUrlJob(const QString &userId); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetAvatarUrlJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& userId); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &userId); // Result properties @@ -82,24 +86,25 @@ class QUOTIENT_API GetAvatarUrlJob : public BaseJob { QUrl avatarUrl() const { return loadFromJson("avatar_url"_L1); } }; -inline auto collectResponse(const GetAvatarUrlJob* job) { return job->avatarUrl(); } +inline auto collectResponse(const GetAvatarUrlJob *job) { return job->avatarUrl(); } //! \brief Get this user's profile information. //! //! Get the combined profile information for this user. This API may be used //! to fetch the user's own profile information or other users; either //! locally or on remote homeservers. -class QUOTIENT_API GetUserProfileJob : public BaseJob { +class QUOTIENT_API GetUserProfileJob : public BaseJob +{ public: //! \param userId //! The user whose profile information to get. - explicit GetUserProfileJob(const QString& userId); + explicit GetUserProfileJob(const QString &userId); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetUserProfileJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& userId); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &userId); // Result properties @@ -109,7 +114,8 @@ class QUOTIENT_API GetUserProfileJob : public BaseJob { //! The user's display name if they have set one, otherwise not present. QString displayname() const { return loadFromJson("displayname"_L1); } - struct Response { + struct Response + { //! The user's avatar URL if they have set one, otherwise not present. QUrl avatarUrl{}; @@ -120,6 +126,6 @@ class QUOTIENT_API GetUserProfileJob : public BaseJob { template JobT> constexpr inline auto doCollectResponse = - [](JobT* j) -> GetUserProfileJob::Response { return { j->avatarUrl(), j->displayname() }; }; + [](JobT *j) -> GetUserProfileJob::Response { return {j->avatarUrl(), j->displayname()}; }; } // namespace Quotient diff --git a/Quotient/csapi/pusher.cpp b/Quotient/csapi/pusher.cpp index 62be5c9d8..4d54620f7 100644 --- a/Quotient/csapi/pusher.cpp +++ b/Quotient/csapi/pusher.cpp @@ -4,7 +4,7 @@ using namespace Quotient; -QUrl GetPushersJob::makeRequestUrl(const HomeserverData& hsData) +QUrl GetPushersJob::makeRequestUrl(const HomeserverData &hsData) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/pushers")); } @@ -13,10 +13,10 @@ GetPushersJob::GetPushersJob() : BaseJob(HttpVerb::Get, u"GetPushersJob"_s, makePath("/_matrix/client/v3", "/pushers")) {} -PostPusherJob::PostPusherJob(const QString& pushkey, const QString& kind, const QString& appId, - const QString& appDisplayName, const QString& deviceDisplayName, - const QString& profileTag, const QString& lang, - const std::optional& data, std::optional append) +PostPusherJob::PostPusherJob(const QString &pushkey, const QString &kind, const QString &appId, + const QString &appDisplayName, const QString &deviceDisplayName, + const QString &profileTag, const QString &lang, + const std::optional &data, std::optional append) : BaseJob(HttpVerb::Post, u"PostPusherJob"_s, makePath("/_matrix/client/v3", "/pushers/set")) { QJsonObject _dataJson; @@ -29,5 +29,5 @@ PostPusherJob::PostPusherJob(const QString& pushkey, const QString& kind, const addParam(_dataJson, "lang"_L1, lang); addParam(_dataJson, "data"_L1, data); addParam(_dataJson, "append"_L1, append); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } diff --git a/Quotient/csapi/pusher.h b/Quotient/csapi/pusher.h index 146661015..3cae75956 100644 --- a/Quotient/csapi/pusher.h +++ b/Quotient/csapi/pusher.h @@ -9,13 +9,15 @@ namespace Quotient { //! \brief Gets the current pushers for the authenticated user //! //! Gets all currently active pushers for the authenticated user. -class QUOTIENT_API GetPushersJob : public BaseJob { +class QUOTIENT_API GetPushersJob : public BaseJob +{ public: // Inner data structures //! A dictionary of information for the pusher implementation //! itself. - struct QUOTIENT_API PusherData { + struct QUOTIENT_API PusherData + { //! Required if `kind` is `http`. The URL to use to send //! notifications to. QUrl url{}; @@ -25,7 +27,8 @@ class QUOTIENT_API GetPushersJob : public BaseJob { QString format{}; }; - struct QUOTIENT_API Pusher { + struct QUOTIENT_API Pusher + { //! This is a unique identifier for this pusher. See `/set` for //! more detail. //! Max length, 512 bytes. @@ -68,7 +71,7 @@ class QUOTIENT_API GetPushersJob : public BaseJob { //! //! This function can be used when a URL for GetPushersJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData); + static QUrl makeRequestUrl(const HomeserverData &hsData); // Result properties @@ -76,11 +79,12 @@ class QUOTIENT_API GetPushersJob : public BaseJob { QVector pushers() const { return loadFromJson>("pushers"_L1); } }; -inline auto collectResponse(const GetPushersJob* job) { return job->pushers(); } +inline auto collectResponse(const GetPushersJob *job) { return job->pushers(); } template <> -struct QUOTIENT_API JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, GetPushersJob::PusherData& result) +struct QUOTIENT_API JsonObjectConverter +{ + static void fillFrom(const QJsonObject &jo, GetPushersJob::PusherData &result) { fillFromJson(jo.value("url"_L1), result.url); fillFromJson(jo.value("format"_L1), result.format); @@ -88,8 +92,9 @@ struct QUOTIENT_API JsonObjectConverter { }; template <> -struct QUOTIENT_API JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, GetPushersJob::Pusher& result) +struct QUOTIENT_API JsonObjectConverter +{ + static void fillFrom(const QJsonObject &jo, GetPushersJob::Pusher &result) { fillFromJson(jo.value("pushkey"_L1), result.pushkey); fillFromJson(jo.value("kind"_L1), result.kind); @@ -112,7 +117,8 @@ struct QUOTIENT_API JsonObjectConverter { //! for this user is updated, or it is created if it doesn't exist. If //! `kind` is `null`, the pusher with this `app_id` and `pushkey` for this //! user is deleted. -class QUOTIENT_API PostPusherJob : public BaseJob { +class QUOTIENT_API PostPusherJob : public BaseJob +{ public: // Inner data structures @@ -120,7 +126,8 @@ class QUOTIENT_API PostPusherJob : public BaseJob { //! for the pusher implementation itself. If `kind` is `http`, //! this should contain `url` which is the URL to use to send //! notifications to. - struct QUOTIENT_API PusherData { + struct QUOTIENT_API PusherData + { //! Required if `kind` is `http`. The URL to use to send //! notifications to. MUST be an HTTPS URL with a path of //! `/_matrix/push/v1/notify`. @@ -188,16 +195,17 @@ class QUOTIENT_API PostPusherJob : public BaseJob { //! different user IDs. Otherwise, the homeserver must remove any //! other pushers with the same App ID and pushkey for different //! users. The default is `false`. - explicit PostPusherJob(const QString& pushkey, const QString& kind, const QString& appId, - const QString& appDisplayName = {}, const QString& deviceDisplayName = {}, - const QString& profileTag = {}, const QString& lang = {}, - const std::optional& data = std::nullopt, + explicit PostPusherJob(const QString &pushkey, const QString &kind, const QString &appId, + const QString &appDisplayName = {}, const QString &deviceDisplayName = {}, + const QString &profileTag = {}, const QString &lang = {}, + const std::optional &data = std::nullopt, std::optional append = std::nullopt); }; template <> -struct QUOTIENT_API JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const PostPusherJob::PusherData& pod) +struct QUOTIENT_API JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const PostPusherJob::PusherData &pod) { addParam(jo, "url"_L1, pod.url); addParam(jo, "format"_L1, pod.format); diff --git a/Quotient/csapi/pushrules.cpp b/Quotient/csapi/pushrules.cpp index 58370c351..61d2959c5 100644 --- a/Quotient/csapi/pushrules.cpp +++ b/Quotient/csapi/pushrules.cpp @@ -4,7 +4,7 @@ using namespace Quotient; -QUrl GetPushRulesJob::makeRequestUrl(const HomeserverData& hsData) +QUrl GetPushRulesJob::makeRequestUrl(const HomeserverData &hsData) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/pushrules")); } @@ -15,7 +15,7 @@ GetPushRulesJob::GetPushRulesJob() addExpectedKey(u"global"_s); } -QUrl GetPushRulesGlobalJob::makeRequestUrl(const HomeserverData& hsData) +QUrl GetPushRulesGlobalJob::makeRequestUrl(const HomeserverData &hsData) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/pushrules/global")); } @@ -25,31 +25,31 @@ GetPushRulesGlobalJob::GetPushRulesGlobalJob() makePath("/_matrix/client/v3", "/pushrules/global")) {} -QUrl GetPushRuleJob::makeRequestUrl(const HomeserverData& hsData, const QString& kind, - const QString& ruleId) +QUrl GetPushRuleJob::makeRequestUrl(const HomeserverData &hsData, const QString &kind, + const QString &ruleId) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/pushrules/global/", kind, "/", ruleId)); } -GetPushRuleJob::GetPushRuleJob(const QString& kind, const QString& ruleId) +GetPushRuleJob::GetPushRuleJob(const QString &kind, const QString &ruleId) : BaseJob(HttpVerb::Get, u"GetPushRuleJob"_s, makePath("/_matrix/client/v3", "/pushrules/global/", kind, "/", ruleId)) {} -QUrl DeletePushRuleJob::makeRequestUrl(const HomeserverData& hsData, const QString& kind, - const QString& ruleId) +QUrl DeletePushRuleJob::makeRequestUrl(const HomeserverData &hsData, const QString &kind, + const QString &ruleId) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/pushrules/global/", kind, "/", ruleId)); } -DeletePushRuleJob::DeletePushRuleJob(const QString& kind, const QString& ruleId) +DeletePushRuleJob::DeletePushRuleJob(const QString &kind, const QString &ruleId) : BaseJob(HttpVerb::Delete, u"DeletePushRuleJob"_s, makePath("/_matrix/client/v3", "/pushrules/global/", kind, "/", ruleId)) {} -auto queryToSetPushRule(const QString& before, const QString& after) +auto queryToSetPushRule(const QString &before, const QString &after) { QUrlQuery _q; addParam(_q, u"before"_s, before); @@ -57,10 +57,10 @@ auto queryToSetPushRule(const QString& before, const QString& after) return _q; } -SetPushRuleJob::SetPushRuleJob(const QString& kind, const QString& ruleId, - const QVector& actions, const QString& before, - const QString& after, const QVector& conditions, - const QString& pattern) +SetPushRuleJob::SetPushRuleJob(const QString &kind, const QString &ruleId, + const QVector &actions, const QString &before, + const QString &after, const QVector &conditions, + const QString &pattern) : BaseJob(HttpVerb::Put, u"SetPushRuleJob"_s, makePath("/_matrix/client/v3", "/pushrules/global/", kind, "/", ruleId), queryToSetPushRule(before, after)) @@ -69,53 +69,53 @@ SetPushRuleJob::SetPushRuleJob(const QString& kind, const QString& ruleId, addParam(_dataJson, "actions"_L1, actions); addParam(_dataJson, "conditions"_L1, conditions); addParam(_dataJson, "pattern"_L1, pattern); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } -QUrl IsPushRuleEnabledJob::makeRequestUrl(const HomeserverData& hsData, const QString& kind, - const QString& ruleId) +QUrl IsPushRuleEnabledJob::makeRequestUrl(const HomeserverData &hsData, const QString &kind, + const QString &ruleId) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/pushrules/global/", kind, "/", ruleId, "/enabled")); } -IsPushRuleEnabledJob::IsPushRuleEnabledJob(const QString& kind, const QString& ruleId) +IsPushRuleEnabledJob::IsPushRuleEnabledJob(const QString &kind, const QString &ruleId) : BaseJob(HttpVerb::Get, u"IsPushRuleEnabledJob"_s, makePath("/_matrix/client/v3", "/pushrules/global/", kind, "/", ruleId, "/enabled")) { addExpectedKey(u"enabled"_s); } -SetPushRuleEnabledJob::SetPushRuleEnabledJob(const QString& kind, const QString& ruleId, +SetPushRuleEnabledJob::SetPushRuleEnabledJob(const QString &kind, const QString &ruleId, bool enabled) : BaseJob(HttpVerb::Put, u"SetPushRuleEnabledJob"_s, makePath("/_matrix/client/v3", "/pushrules/global/", kind, "/", ruleId, "/enabled")) { QJsonObject _dataJson; addParam(_dataJson, "enabled"_L1, enabled); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } -QUrl GetPushRuleActionsJob::makeRequestUrl(const HomeserverData& hsData, const QString& kind, - const QString& ruleId) +QUrl GetPushRuleActionsJob::makeRequestUrl(const HomeserverData &hsData, const QString &kind, + const QString &ruleId) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/pushrules/global/", kind, "/", ruleId, "/actions")); } -GetPushRuleActionsJob::GetPushRuleActionsJob(const QString& kind, const QString& ruleId) +GetPushRuleActionsJob::GetPushRuleActionsJob(const QString &kind, const QString &ruleId) : BaseJob(HttpVerb::Get, u"GetPushRuleActionsJob"_s, makePath("/_matrix/client/v3", "/pushrules/global/", kind, "/", ruleId, "/actions")) { addExpectedKey(u"actions"_s); } -SetPushRuleActionsJob::SetPushRuleActionsJob(const QString& kind, const QString& ruleId, - const QVector& actions) +SetPushRuleActionsJob::SetPushRuleActionsJob(const QString &kind, const QString &ruleId, + const QVector &actions) : BaseJob(HttpVerb::Put, u"SetPushRuleActionsJob"_s, makePath("/_matrix/client/v3", "/pushrules/global/", kind, "/", ruleId, "/actions")) { QJsonObject _dataJson; addParam(_dataJson, "actions"_L1, actions); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } diff --git a/Quotient/csapi/pushrules.h b/Quotient/csapi/pushrules.h index dafe2dc70..b6d8660d2 100644 --- a/Quotient/csapi/pushrules.h +++ b/Quotient/csapi/pushrules.h @@ -5,7 +5,6 @@ #include #include #include - #include namespace Quotient { @@ -14,7 +13,8 @@ namespace Quotient { //! //! Retrieve all push rulesets for this user. Currently the only push ruleset //! defined is `global`. -class QUOTIENT_API GetPushRulesJob : public BaseJob { +class QUOTIENT_API GetPushRulesJob : public BaseJob +{ public: explicit GetPushRulesJob(); @@ -22,7 +22,7 @@ class QUOTIENT_API GetPushRulesJob : public BaseJob { //! //! This function can be used when a URL for GetPushRulesJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData); + static QUrl makeRequestUrl(const HomeserverData &hsData); // Result properties @@ -30,12 +30,13 @@ class QUOTIENT_API GetPushRulesJob : public BaseJob { PushRuleset global() const { return loadFromJson("global"_L1); } }; -inline auto collectResponse(const GetPushRulesJob* job) { return job->global(); } +inline auto collectResponse(const GetPushRulesJob *job) { return job->global(); } //! \brief Retrieve all push rules. //! //! Retrieve all push rules for this user. -class QUOTIENT_API GetPushRulesGlobalJob : public BaseJob { +class QUOTIENT_API GetPushRulesGlobalJob : public BaseJob +{ public: explicit GetPushRulesGlobalJob(); @@ -43,7 +44,7 @@ class QUOTIENT_API GetPushRulesGlobalJob : public BaseJob { //! //! This function can be used when a URL for GetPushRulesGlobalJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData); + static QUrl makeRequestUrl(const HomeserverData &hsData); // Result properties @@ -51,26 +52,27 @@ class QUOTIENT_API GetPushRulesGlobalJob : public BaseJob { PushRuleset data() const { return fromJson(jsonData()); } }; -inline auto collectResponse(const GetPushRulesGlobalJob* job) { return job->data(); } +inline auto collectResponse(const GetPushRulesGlobalJob *job) { return job->data(); } //! \brief Retrieve a push rule. //! //! Retrieve a single specified push rule. -class QUOTIENT_API GetPushRuleJob : public BaseJob { +class QUOTIENT_API GetPushRuleJob : public BaseJob +{ public: //! \param kind //! The kind of rule //! //! \param ruleId //! The identifier for the rule. - explicit GetPushRuleJob(const QString& kind, const QString& ruleId); + explicit GetPushRuleJob(const QString &kind, const QString &ruleId); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetPushRuleJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& kind, - const QString& ruleId); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &kind, + const QString &ruleId); // Result properties @@ -79,26 +81,27 @@ class QUOTIENT_API GetPushRuleJob : public BaseJob { PushRule pushRule() const { return fromJson(jsonData()); } }; -inline auto collectResponse(const GetPushRuleJob* job) { return job->pushRule(); } +inline auto collectResponse(const GetPushRuleJob *job) { return job->pushRule(); } //! \brief Delete a push rule. //! //! This endpoint removes the push rule defined in the path. -class QUOTIENT_API DeletePushRuleJob : public BaseJob { +class QUOTIENT_API DeletePushRuleJob : public BaseJob +{ public: //! \param kind //! The kind of rule //! //! \param ruleId //! The identifier for the rule. - explicit DeletePushRuleJob(const QString& kind, const QString& ruleId); + explicit DeletePushRuleJob(const QString &kind, const QString &ruleId); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for DeletePushRuleJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& kind, - const QString& ruleId); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &kind, + const QString &ruleId); }; //! \brief Add or change a push rule. @@ -119,7 +122,8 @@ class QUOTIENT_API DeletePushRuleJob : public BaseJob { //! the same kind. //! //! When creating push rules, they MUST be enabled by default. -class QUOTIENT_API SetPushRuleJob : public BaseJob { +class QUOTIENT_API SetPushRuleJob : public BaseJob +{ public: //! \param kind //! The kind of rule @@ -149,30 +153,31 @@ class QUOTIENT_API SetPushRuleJob : public BaseJob { //! //! \param pattern //! Only applicable to `content` rules. The glob-style pattern to match against. - explicit SetPushRuleJob(const QString& kind, const QString& ruleId, - const QVector& actions, const QString& before = {}, - const QString& after = {}, const QVector& conditions = {}, - const QString& pattern = {}); + explicit SetPushRuleJob(const QString &kind, const QString &ruleId, + const QVector &actions, const QString &before = {}, + const QString &after = {}, const QVector &conditions = {}, + const QString &pattern = {}); }; //! \brief Get whether a push rule is enabled //! //! This endpoint gets whether the specified push rule is enabled. -class QUOTIENT_API IsPushRuleEnabledJob : public BaseJob { +class QUOTIENT_API IsPushRuleEnabledJob : public BaseJob +{ public: //! \param kind //! The kind of rule //! //! \param ruleId //! The identifier for the rule. - explicit IsPushRuleEnabledJob(const QString& kind, const QString& ruleId); + explicit IsPushRuleEnabledJob(const QString &kind, const QString &ruleId); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for IsPushRuleEnabledJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& kind, - const QString& ruleId); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &kind, + const QString &ruleId); // Result properties @@ -180,12 +185,13 @@ class QUOTIENT_API IsPushRuleEnabledJob : public BaseJob { bool enabled() const { return loadFromJson("enabled"_L1); } }; -inline auto collectResponse(const IsPushRuleEnabledJob* job) { return job->enabled(); } +inline auto collectResponse(const IsPushRuleEnabledJob *job) { return job->enabled(); } //! \brief Enable or disable a push rule. //! //! This endpoint allows clients to enable or disable the specified push rule. -class QUOTIENT_API SetPushRuleEnabledJob : public BaseJob { +class QUOTIENT_API SetPushRuleEnabledJob : public BaseJob +{ public: //! \param kind //! The kind of rule @@ -195,27 +201,28 @@ class QUOTIENT_API SetPushRuleEnabledJob : public BaseJob { //! //! \param enabled //! Whether the push rule is enabled or not. - explicit SetPushRuleEnabledJob(const QString& kind, const QString& ruleId, bool enabled); + explicit SetPushRuleEnabledJob(const QString &kind, const QString &ruleId, bool enabled); }; //! \brief The actions for a push rule //! //! This endpoint get the actions for the specified push rule. -class QUOTIENT_API GetPushRuleActionsJob : public BaseJob { +class QUOTIENT_API GetPushRuleActionsJob : public BaseJob +{ public: //! \param kind //! The kind of rule //! //! \param ruleId //! The identifier for the rule. - explicit GetPushRuleActionsJob(const QString& kind, const QString& ruleId); + explicit GetPushRuleActionsJob(const QString &kind, const QString &ruleId); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetPushRuleActionsJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& kind, - const QString& ruleId); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &kind, + const QString &ruleId); // Result properties @@ -223,13 +230,14 @@ class QUOTIENT_API GetPushRuleActionsJob : public BaseJob { QVector actions() const { return loadFromJson>("actions"_L1); } }; -inline auto collectResponse(const GetPushRuleActionsJob* job) { return job->actions(); } +inline auto collectResponse(const GetPushRuleActionsJob *job) { return job->actions(); } //! \brief Set the actions for a push rule. //! //! This endpoint allows clients to change the actions of a push rule. //! This can be used to change the actions of builtin rules. -class QUOTIENT_API SetPushRuleActionsJob : public BaseJob { +class QUOTIENT_API SetPushRuleActionsJob : public BaseJob +{ public: //! \param kind //! The kind of rule @@ -239,8 +247,8 @@ class QUOTIENT_API SetPushRuleActionsJob : public BaseJob { //! //! \param actions //! The action(s) to perform for this rule. - explicit SetPushRuleActionsJob(const QString& kind, const QString& ruleId, - const QVector& actions); + explicit SetPushRuleActionsJob(const QString &kind, const QString &ruleId, + const QVector &actions); }; } // namespace Quotient diff --git a/Quotient/csapi/read_markers.cpp b/Quotient/csapi/read_markers.cpp index 6f53b7f0d..c2b4a490e 100644 --- a/Quotient/csapi/read_markers.cpp +++ b/Quotient/csapi/read_markers.cpp @@ -4,8 +4,8 @@ using namespace Quotient; -SetReadMarkerJob::SetReadMarkerJob(const QString& roomId, const QString& fullyRead, - const QString& read, const QString& readPrivate) +SetReadMarkerJob::SetReadMarkerJob(const QString &roomId, const QString &fullyRead, + const QString &read, const QString &readPrivate) : BaseJob(HttpVerb::Post, u"SetReadMarkerJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/read_markers")) { @@ -13,5 +13,5 @@ SetReadMarkerJob::SetReadMarkerJob(const QString& roomId, const QString& fullyRe addParam(_dataJson, "m.fully_read"_L1, fullyRead); addParam(_dataJson, "m.read"_L1, read); addParam(_dataJson, "m.read.private"_L1, readPrivate); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } diff --git a/Quotient/csapi/read_markers.h b/Quotient/csapi/read_markers.h index c1e67cd86..e7a41dff1 100644 --- a/Quotient/csapi/read_markers.h +++ b/Quotient/csapi/read_markers.h @@ -10,7 +10,8 @@ namespace Quotient { //! //! Sets the position of the read marker for a given room, and optionally //! the read receipt's location. -class QUOTIENT_API SetReadMarkerJob : public BaseJob { +class QUOTIENT_API SetReadMarkerJob : public BaseJob +{ public: //! \param roomId //! The room ID to set the read marker in for the user. @@ -28,8 +29,8 @@ class QUOTIENT_API SetReadMarkerJob : public BaseJob { //! The event ID to set the *private* read receipt location at. This //! equivalent to calling `/receipt/m.read.private/$elsewhere:example.org` //! and is provided here to save that extra call. - explicit SetReadMarkerJob(const QString& roomId, const QString& fullyRead = {}, - const QString& read = {}, const QString& readPrivate = {}); + explicit SetReadMarkerJob(const QString &roomId, const QString &fullyRead = {}, + const QString &read = {}, const QString &readPrivate = {}); }; } // namespace Quotient diff --git a/Quotient/csapi/receipts.cpp b/Quotient/csapi/receipts.cpp index e96a3e46c..b4a01c7cd 100644 --- a/Quotient/csapi/receipts.cpp +++ b/Quotient/csapi/receipts.cpp @@ -4,13 +4,13 @@ using namespace Quotient; -PostReceiptJob::PostReceiptJob(const QString& roomId, const QString& receiptType, - const QString& eventId, const QString& threadId) +PostReceiptJob::PostReceiptJob(const QString &roomId, const QString &receiptType, + const QString &eventId, const QString &threadId) : BaseJob(HttpVerb::Post, u"PostReceiptJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/receipt/", receiptType, "/", eventId)) { QJsonObject _dataJson; addParam(_dataJson, "thread_id"_L1, threadId); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } diff --git a/Quotient/csapi/receipts.h b/Quotient/csapi/receipts.h index a2ad3aee7..02b7f1362 100644 --- a/Quotient/csapi/receipts.h +++ b/Quotient/csapi/receipts.h @@ -10,7 +10,8 @@ namespace Quotient { //! //! This API updates the marker for the given receipt type to the event ID //! specified. -class QUOTIENT_API PostReceiptJob : public BaseJob { +class QUOTIENT_API PostReceiptJob : public BaseJob +{ public: //! \param roomId //! The room in which to send the event. @@ -32,8 +33,8 @@ class QUOTIENT_API PostReceiptJob : public BaseJob { //! thread this receipt is intended to be under. If //! not specified, the read receipt is *unthreaded* //! (default). - explicit PostReceiptJob(const QString& roomId, const QString& receiptType, - const QString& eventId, const QString& threadId = {}); + explicit PostReceiptJob(const QString &roomId, const QString &receiptType, + const QString &eventId, const QString &threadId = {}); }; } // namespace Quotient diff --git a/Quotient/csapi/redaction.cpp b/Quotient/csapi/redaction.cpp index 30071b7c0..50a25d4a6 100644 --- a/Quotient/csapi/redaction.cpp +++ b/Quotient/csapi/redaction.cpp @@ -4,12 +4,12 @@ using namespace Quotient; -RedactEventJob::RedactEventJob(const QString& roomId, const QString& eventId, const QString& txnId, - const QString& reason) +RedactEventJob::RedactEventJob(const QString &roomId, const QString &eventId, const QString &txnId, + const QString &reason) : BaseJob(HttpVerb::Put, u"RedactEventJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/redact/", eventId, "/", txnId)) { QJsonObject _dataJson; addParam(_dataJson, "reason"_L1, reason); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } diff --git a/Quotient/csapi/redaction.h b/Quotient/csapi/redaction.h index 21f441a67..fa09a47de 100644 --- a/Quotient/csapi/redaction.h +++ b/Quotient/csapi/redaction.h @@ -19,7 +19,8 @@ namespace Quotient { //! of the room, the user may redact events sent by other users. //! //! Server administrators may redact events sent by users on their server. -class QUOTIENT_API RedactEventJob : public BaseJob { +class QUOTIENT_API RedactEventJob : public BaseJob +{ public: //! \param roomId //! The room from which to redact the event. @@ -34,8 +35,8 @@ class QUOTIENT_API RedactEventJob : public BaseJob { //! //! \param reason //! The reason for the event being redacted. - explicit RedactEventJob(const QString& roomId, const QString& eventId, const QString& txnId, - const QString& reason = {}); + explicit RedactEventJob(const QString &roomId, const QString &eventId, const QString &txnId, + const QString &reason = {}); // Result properties @@ -43,6 +44,6 @@ class QUOTIENT_API RedactEventJob : public BaseJob { QString eventId() const { return loadFromJson("event_id"_L1); } }; -inline auto collectResponse(const RedactEventJob* job) { return job->eventId(); } +inline auto collectResponse(const RedactEventJob *job) { return job->eventId(); } } // namespace Quotient diff --git a/Quotient/csapi/refresh.cpp b/Quotient/csapi/refresh.cpp index 0137c69c2..022a69d5a 100644 --- a/Quotient/csapi/refresh.cpp +++ b/Quotient/csapi/refresh.cpp @@ -4,11 +4,11 @@ using namespace Quotient; -RefreshJob::RefreshJob(const QString& refreshToken) +RefreshJob::RefreshJob(const QString &refreshToken) : BaseJob(HttpVerb::Post, u"RefreshJob"_s, makePath("/_matrix/client/v3", "/refresh"), false) { QJsonObject _dataJson; addParam(_dataJson, "refresh_token"_L1, refreshToken); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); addExpectedKey(u"access_token"_s); } diff --git a/Quotient/csapi/refresh.h b/Quotient/csapi/refresh.h index a1f26f355..928712078 100644 --- a/Quotient/csapi/refresh.h +++ b/Quotient/csapi/refresh.h @@ -25,11 +25,12 @@ namespace Quotient { //! access token. Authentication is provided via the refresh token. //! //! Application Service identity assertion is disabled for this endpoint. -class QUOTIENT_API RefreshJob : public BaseJob { +class QUOTIENT_API RefreshJob : public BaseJob +{ public: //! \param refreshToken //! The refresh token - explicit RefreshJob(const QString& refreshToken); + explicit RefreshJob(const QString &refreshToken); // Result properties @@ -49,7 +50,8 @@ class QUOTIENT_API RefreshJob : public BaseJob { return loadFromJson>("expires_in_ms"_L1); } - struct Response { + struct Response + { //! The new access token to use. QString accessToken{}; @@ -66,8 +68,8 @@ class QUOTIENT_API RefreshJob : public BaseJob { }; template JobT> -constexpr inline auto doCollectResponse = [](JobT* j) -> RefreshJob::Response { - return { j->accessToken(), j->refreshToken(), j->expiresInMs() }; +constexpr inline auto doCollectResponse = [](JobT *j) -> RefreshJob::Response { + return {j->accessToken(), j->refreshToken(), j->expiresInMs()}; }; } // namespace Quotient diff --git a/Quotient/csapi/registration.cpp b/Quotient/csapi/registration.cpp index b7a1d699d..86c88900f 100644 --- a/Quotient/csapi/registration.cpp +++ b/Quotient/csapi/registration.cpp @@ -4,16 +4,16 @@ using namespace Quotient; -auto queryToRegister(const QString& kind) +auto queryToRegister(const QString &kind) { QUrlQuery _q; addParam(_q, u"kind"_s, kind); return _q; } -RegisterJob::RegisterJob(const QString& kind, const std::optional& auth, - const QString& username, const QString& password, const QString& deviceId, - const QString& initialDeviceDisplayName, std::optional inhibitLogin, +RegisterJob::RegisterJob(const QString &kind, const std::optional &auth, + const QString &username, const QString &password, const QString &deviceId, + const QString &initialDeviceDisplayName, std::optional inhibitLogin, std::optional refreshToken) : BaseJob(HttpVerb::Post, u"RegisterJob"_s, makePath("/_matrix/client/v3", "/register"), queryToRegister(kind), {}, false) @@ -26,26 +26,26 @@ RegisterJob::RegisterJob(const QString& kind, const std::optional(_dataJson, "initial_device_display_name"_L1, initialDeviceDisplayName); addParam(_dataJson, "inhibit_login"_L1, inhibitLogin); addParam(_dataJson, "refresh_token"_L1, refreshToken); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); addExpectedKey(u"user_id"_s); } -RequestTokenToRegisterEmailJob::RequestTokenToRegisterEmailJob(const EmailValidationData& data) +RequestTokenToRegisterEmailJob::RequestTokenToRegisterEmailJob(const EmailValidationData &data) : BaseJob(HttpVerb::Post, u"RequestTokenToRegisterEmailJob"_s, makePath("/_matrix/client/v3", "/register/email/requestToken"), false) { - setRequestData({ toJson(data) }); + setRequestData({toJson(data)}); } -RequestTokenToRegisterMSISDNJob::RequestTokenToRegisterMSISDNJob(const MsisdnValidationData& data) +RequestTokenToRegisterMSISDNJob::RequestTokenToRegisterMSISDNJob(const MsisdnValidationData &data) : BaseJob(HttpVerb::Post, u"RequestTokenToRegisterMSISDNJob"_s, makePath("/_matrix/client/v3", "/register/msisdn/requestToken"), false) { - setRequestData({ toJson(data) }); + setRequestData({toJson(data)}); } -ChangePasswordJob::ChangePasswordJob(const QString& newPassword, bool logoutDevices, - const std::optional& auth) +ChangePasswordJob::ChangePasswordJob(const QString &newPassword, bool logoutDevices, + const std::optional &auth) : BaseJob(HttpVerb::Post, u"ChangePasswordJob"_s, makePath("/_matrix/client/v3", "/account/password")) { @@ -53,27 +53,27 @@ ChangePasswordJob::ChangePasswordJob(const QString& newPassword, bool logoutDevi addParam(_dataJson, "new_password"_L1, newPassword); addParam(_dataJson, "logout_devices"_L1, logoutDevices); addParam(_dataJson, "auth"_L1, auth); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } RequestTokenToResetPasswordEmailJob::RequestTokenToResetPasswordEmailJob( - const EmailValidationData& data) + const EmailValidationData &data) : BaseJob(HttpVerb::Post, u"RequestTokenToResetPasswordEmailJob"_s, makePath("/_matrix/client/v3", "/account/password/email/requestToken"), false) { - setRequestData({ toJson(data) }); + setRequestData({toJson(data)}); } RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob( - const MsisdnValidationData& data) + const MsisdnValidationData &data) : BaseJob(HttpVerb::Post, u"RequestTokenToResetPasswordMSISDNJob"_s, makePath("/_matrix/client/v3", "/account/password/msisdn/requestToken"), false) { - setRequestData({ toJson(data) }); + setRequestData({toJson(data)}); } -DeactivateAccountJob::DeactivateAccountJob(const std::optional& auth, - const QString& idServer, std::optional erase) +DeactivateAccountJob::DeactivateAccountJob(const std::optional &auth, + const QString &idServer, std::optional erase) : BaseJob(HttpVerb::Post, u"DeactivateAccountJob"_s, makePath("/_matrix/client/v3", "/account/deactivate")) { @@ -81,25 +81,25 @@ DeactivateAccountJob::DeactivateAccountJob(const std::optional(_dataJson, "auth"_L1, auth); addParam(_dataJson, "id_server"_L1, idServer); addParam(_dataJson, "erase"_L1, erase); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); addExpectedKey(u"id_server_unbind_result"_s); } -auto queryToCheckUsernameAvailability(const QString& username) +auto queryToCheckUsernameAvailability(const QString &username) { QUrlQuery _q; addParam(_q, u"username"_s, username); return _q; } -QUrl CheckUsernameAvailabilityJob::makeRequestUrl(const HomeserverData& hsData, - const QString& username) +QUrl CheckUsernameAvailabilityJob::makeRequestUrl(const HomeserverData &hsData, + const QString &username) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/register/available"), queryToCheckUsernameAvailability(username)); } -CheckUsernameAvailabilityJob::CheckUsernameAvailabilityJob(const QString& username) +CheckUsernameAvailabilityJob::CheckUsernameAvailabilityJob(const QString &username) : BaseJob(HttpVerb::Get, u"CheckUsernameAvailabilityJob"_s, makePath("/_matrix/client/v3", "/register/available"), queryToCheckUsernameAvailability(username), {}, false) diff --git a/Quotient/csapi/registration.h b/Quotient/csapi/registration.h index d1fcbd657..bf5b8e18a 100644 --- a/Quotient/csapi/registration.h +++ b/Quotient/csapi/registration.h @@ -6,7 +6,6 @@ #include #include #include - #include namespace Quotient { @@ -55,7 +54,8 @@ namespace Quotient { //! //! Any user ID returned by this API must conform to the grammar given in the //! [Matrix specification](/appendices/#user-identifiers). -class QUOTIENT_API RegisterJob : public BaseJob { +class QUOTIENT_API RegisterJob : public BaseJob +{ public: //! \param kind //! The kind of account to register. Defaults to `user`. @@ -90,10 +90,10 @@ class QUOTIENT_API RegisterJob : public BaseJob { //! //! \param refreshToken //! If true, the client supports refresh tokens. - explicit RegisterJob(const QString& kind = u"user"_s, - const std::optional& auth = std::nullopt, - const QString& username = {}, const QString& password = {}, - const QString& deviceId = {}, const QString& initialDeviceDisplayName = {}, + explicit RegisterJob(const QString &kind = u"user"_s, + const std::optional &auth = std::nullopt, + const QString &username = {}, const QString &password = {}, + const QString &deviceId = {}, const QString &initialDeviceDisplayName = {}, std::optional inhibitLogin = std::nullopt, std::optional refreshToken = std::nullopt); @@ -135,7 +135,8 @@ class QUOTIENT_API RegisterJob : public BaseJob { //! Required if the `inhibit_login` option is false. QString deviceId() const { return loadFromJson("device_id"_L1); } - struct Response { + struct Response + { //! The fully-qualified Matrix user ID (MXID) that has been registered. //! //! Any user ID returned by this API must conform to the grammar given in the @@ -172,8 +173,8 @@ class QUOTIENT_API RegisterJob : public BaseJob { }; template JobT> -constexpr inline auto doCollectResponse = [](JobT* j) -> RegisterJob::Response { - return { j->userId(), j->accessToken(), j->refreshToken(), j->expiresInMs(), j->deviceId() }; +constexpr inline auto doCollectResponse = [](JobT *j) -> RegisterJob::Response { + return {j->userId(), j->accessToken(), j->refreshToken(), j->expiresInMs(), j->deviceId()}; }; //! \brief Begins the validation process for an email to be used during registration. @@ -182,9 +183,10 @@ constexpr inline auto doCollectResponse = [](JobT* j) -> RegisterJob::Resp //! already associated with an account on this homeserver. The homeserver //! should validate the email itself, either by sending a validation email //! itself or by using a service it has control over. -class QUOTIENT_API RequestTokenToRegisterEmailJob : public BaseJob { +class QUOTIENT_API RequestTokenToRegisterEmailJob : public BaseJob +{ public: - explicit RequestTokenToRegisterEmailJob(const EmailValidationData& data); + explicit RequestTokenToRegisterEmailJob(const EmailValidationData &data); // Result properties @@ -194,7 +196,7 @@ class QUOTIENT_API RequestTokenToRegisterEmailJob : public BaseJob { RequestTokenResponse response() const { return fromJson(jsonData()); } }; -inline auto collectResponse(const RequestTokenToRegisterEmailJob* job) { return job->response(); } +inline auto collectResponse(const RequestTokenToRegisterEmailJob *job) { return job->response(); } //! \brief Requests a validation token be sent to the given phone number for the purpose of //! registering an account @@ -203,9 +205,10 @@ inline auto collectResponse(const RequestTokenToRegisterEmailJob* job) { return //! already associated with an account on this homeserver. The homeserver //! should validate the phone number itself, either by sending a validation //! message itself or by using a service it has control over. -class QUOTIENT_API RequestTokenToRegisterMSISDNJob : public BaseJob { +class QUOTIENT_API RequestTokenToRegisterMSISDNJob : public BaseJob +{ public: - explicit RequestTokenToRegisterMSISDNJob(const MsisdnValidationData& data); + explicit RequestTokenToRegisterMSISDNJob(const MsisdnValidationData &data); // Result properties @@ -215,7 +218,7 @@ class QUOTIENT_API RequestTokenToRegisterMSISDNJob : public BaseJob { RequestTokenResponse response() const { return fromJson(jsonData()); } }; -inline auto collectResponse(const RequestTokenToRegisterMSISDNJob* job) { return job->response(); } +inline auto collectResponse(const RequestTokenToRegisterMSISDNJob *job) { return job->response(); } //! \brief Changes a user's password. //! @@ -232,7 +235,8 @@ inline auto collectResponse(const RequestTokenToRegisterMSISDNJob* job) { return //! valid access token is provided. The homeserver SHOULD NOT revoke the //! access token provided in the request. Whether other access tokens for //! the user are revoked depends on the request parameters. -class QUOTIENT_API ChangePasswordJob : public BaseJob { +class QUOTIENT_API ChangePasswordJob : public BaseJob +{ public: //! \param newPassword //! The new password for the account. @@ -246,8 +250,8 @@ class QUOTIENT_API ChangePasswordJob : public BaseJob { //! //! \param auth //! Additional authentication information for the user-interactive authentication API. - explicit ChangePasswordJob(const QString& newPassword, bool logoutDevices = true, - const std::optional& auth = std::nullopt); + explicit ChangePasswordJob(const QString &newPassword, bool logoutDevices = true, + const std::optional &auth = std::nullopt); }; //! \brief Requests a validation token be sent to the given email address for the purpose of @@ -268,9 +272,10 @@ class QUOTIENT_API ChangePasswordJob : public BaseJob { //! //! The homeserver should validate the email itself, either by sending a //! validation email itself or by using a service it has control over. -class QUOTIENT_API RequestTokenToResetPasswordEmailJob : public BaseJob { +class QUOTIENT_API RequestTokenToResetPasswordEmailJob : public BaseJob +{ public: - explicit RequestTokenToResetPasswordEmailJob(const EmailValidationData& data); + explicit RequestTokenToResetPasswordEmailJob(const EmailValidationData &data); // Result properties @@ -278,7 +283,7 @@ class QUOTIENT_API RequestTokenToResetPasswordEmailJob : public BaseJob { RequestTokenResponse response() const { return fromJson(jsonData()); } }; -inline auto collectResponse(const RequestTokenToResetPasswordEmailJob* job) +inline auto collectResponse(const RequestTokenToResetPasswordEmailJob *job) { return job->response(); } @@ -301,9 +306,10 @@ inline auto collectResponse(const RequestTokenToResetPasswordEmailJob* job) //! //! The homeserver should validate the phone number itself, either by sending a //! validation message itself or by using a service it has control over. -class QUOTIENT_API RequestTokenToResetPasswordMSISDNJob : public BaseJob { +class QUOTIENT_API RequestTokenToResetPasswordMSISDNJob : public BaseJob +{ public: - explicit RequestTokenToResetPasswordMSISDNJob(const MsisdnValidationData& data); + explicit RequestTokenToResetPasswordMSISDNJob(const MsisdnValidationData &data); // Result properties @@ -311,7 +317,7 @@ class QUOTIENT_API RequestTokenToResetPasswordMSISDNJob : public BaseJob { RequestTokenResponse response() const { return fromJson(jsonData()); } }; -inline auto collectResponse(const RequestTokenToResetPasswordMSISDNJob* job) +inline auto collectResponse(const RequestTokenToResetPasswordMSISDNJob *job) { return job->response(); } @@ -333,7 +339,8 @@ inline auto collectResponse(const RequestTokenToResetPasswordMSISDNJob* job) //! Unlike other endpoints, this endpoint does not take an `id_access_token` //! parameter because the homeserver is expected to sign the request to the //! identity server instead. -class QUOTIENT_API DeactivateAccountJob : public BaseJob { +class QUOTIENT_API DeactivateAccountJob : public BaseJob +{ public: //! \param auth //! Additional authentication information for the user-interactive authentication API. @@ -364,8 +371,8 @@ class QUOTIENT_API DeactivateAccountJob : public BaseJob { //! 3PIDs](/client-server-api/#adding-account-administrative-contact-information). //! //! Defaults to `false` if not present. - explicit DeactivateAccountJob(const std::optional& auth = std::nullopt, - const QString& idServer = {}, + explicit DeactivateAccountJob(const std::optional &auth = std::nullopt, + const QString &idServer = {}, std::optional erase = std::nullopt); // Result properties @@ -384,7 +391,7 @@ class QUOTIENT_API DeactivateAccountJob : public BaseJob { } }; -inline auto collectResponse(const DeactivateAccountJob* job) { return job->idServerUnbindResult(); } +inline auto collectResponse(const DeactivateAccountJob *job) { return job->idServerUnbindResult(); } //! \brief Checks to see if a username is available on the server. //! @@ -400,17 +407,18 @@ inline auto collectResponse(const DeactivateAccountJob* job) { return job->idSer //! however the clients must also be aware that using this API does not normally //! reserve the username. This can mean that the username becomes unavailable //! between checking its availability and attempting to register it. -class QUOTIENT_API CheckUsernameAvailabilityJob : public BaseJob { +class QUOTIENT_API CheckUsernameAvailabilityJob : public BaseJob +{ public: //! \param username //! The username to check the availability of. - explicit CheckUsernameAvailabilityJob(const QString& username); + explicit CheckUsernameAvailabilityJob(const QString &username); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for CheckUsernameAvailabilityJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& username); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &username); // Result properties @@ -422,6 +430,6 @@ class QUOTIENT_API CheckUsernameAvailabilityJob : public BaseJob { } }; -inline auto collectResponse(const CheckUsernameAvailabilityJob* job) { return job->available(); } +inline auto collectResponse(const CheckUsernameAvailabilityJob *job) { return job->available(); } } // namespace Quotient diff --git a/Quotient/csapi/registration_tokens.cpp b/Quotient/csapi/registration_tokens.cpp index a8ed75ee6..8234cd78a 100644 --- a/Quotient/csapi/registration_tokens.cpp +++ b/Quotient/csapi/registration_tokens.cpp @@ -4,14 +4,14 @@ using namespace Quotient; -auto queryToRegistrationTokenValidity(const QString& token) +auto queryToRegistrationTokenValidity(const QString &token) { QUrlQuery _q; addParam(_q, u"token"_s, token); return _q; } -QUrl RegistrationTokenValidityJob::makeRequestUrl(const HomeserverData& hsData, const QString& token) +QUrl RegistrationTokenValidityJob::makeRequestUrl(const HomeserverData &hsData, const QString &token) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v1", @@ -19,7 +19,7 @@ QUrl RegistrationTokenValidityJob::makeRequestUrl(const HomeserverData& hsData, queryToRegistrationTokenValidity(token)); } -RegistrationTokenValidityJob::RegistrationTokenValidityJob(const QString& token) +RegistrationTokenValidityJob::RegistrationTokenValidityJob(const QString &token) : BaseJob(HttpVerb::Get, u"RegistrationTokenValidityJob"_s, makePath("/_matrix/client/v1", "/register/m.login.registration_token/validity"), queryToRegistrationTokenValidity(token), {}, false) diff --git a/Quotient/csapi/registration_tokens.h b/Quotient/csapi/registration_tokens.h index 9c7991045..84dfbdfee 100644 --- a/Quotient/csapi/registration_tokens.h +++ b/Quotient/csapi/registration_tokens.h @@ -14,17 +14,18 @@ namespace Quotient { //! //! Servers should be sure to rate limit this endpoint to avoid brute force //! attacks. -class QUOTIENT_API RegistrationTokenValidityJob : public BaseJob { +class QUOTIENT_API RegistrationTokenValidityJob : public BaseJob +{ public: //! \param token //! The token to check validity of. - explicit RegistrationTokenValidityJob(const QString& token); + explicit RegistrationTokenValidityJob(const QString &token); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for RegistrationTokenValidityJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& token); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &token); // Result properties @@ -34,6 +35,6 @@ class QUOTIENT_API RegistrationTokenValidityJob : public BaseJob { bool valid() const { return loadFromJson("valid"_L1); } }; -inline auto collectResponse(const RegistrationTokenValidityJob* job) { return job->valid(); } +inline auto collectResponse(const RegistrationTokenValidityJob *job) { return job->valid(); } } // namespace Quotient diff --git a/Quotient/csapi/relations.cpp b/Quotient/csapi/relations.cpp index ab850c079..4986984e2 100644 --- a/Quotient/csapi/relations.cpp +++ b/Quotient/csapi/relations.cpp @@ -4,8 +4,8 @@ using namespace Quotient; -auto queryToGetRelatingEvents(const QString& from, const QString& to, std::optional limit, - const QString& dir, std::optional recurse) +auto queryToGetRelatingEvents(const QString &from, const QString &to, std::optional limit, + const QString &dir, std::optional recurse) { QUrlQuery _q; addParam(_q, u"from"_s, from); @@ -16,10 +16,10 @@ auto queryToGetRelatingEvents(const QString& from, const QString& to, std::optio return _q; } -QUrl GetRelatingEventsJob::makeRequestUrl(const HomeserverData& hsData, const QString& roomId, - const QString& eventId, const QString& from, - const QString& to, std::optional limit, - const QString& dir, std::optional recurse) +QUrl GetRelatingEventsJob::makeRequestUrl(const HomeserverData &hsData, const QString &roomId, + const QString &eventId, const QString &from, + const QString &to, std::optional limit, + const QString &dir, std::optional recurse) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v1", "/rooms/", roomId, "/relations/", @@ -27,9 +27,9 @@ QUrl GetRelatingEventsJob::makeRequestUrl(const HomeserverData& hsData, const QS queryToGetRelatingEvents(from, to, limit, dir, recurse)); } -GetRelatingEventsJob::GetRelatingEventsJob(const QString& roomId, const QString& eventId, - const QString& from, const QString& to, - std::optional limit, const QString& dir, +GetRelatingEventsJob::GetRelatingEventsJob(const QString &roomId, const QString &eventId, + const QString &from, const QString &to, + std::optional limit, const QString &dir, std::optional recurse) : BaseJob(HttpVerb::Get, u"GetRelatingEventsJob"_s, makePath("/_matrix/client/v1", "/rooms/", roomId, "/relations/", eventId), @@ -38,8 +38,8 @@ GetRelatingEventsJob::GetRelatingEventsJob(const QString& roomId, const QString& addExpectedKey(u"chunk"_s); } -auto queryToGetRelatingEventsWithRelType(const QString& from, const QString& to, - std::optional limit, const QString& dir, +auto queryToGetRelatingEventsWithRelType(const QString &from, const QString &to, + std::optional limit, const QString &dir, std::optional recurse) { QUrlQuery _q; @@ -51,11 +51,11 @@ auto queryToGetRelatingEventsWithRelType(const QString& from, const QString& to, return _q; } -QUrl GetRelatingEventsWithRelTypeJob::makeRequestUrl(const HomeserverData& hsData, - const QString& roomId, const QString& eventId, - const QString& relType, const QString& from, - const QString& to, std::optional limit, - const QString& dir, std::optional recurse) +QUrl GetRelatingEventsWithRelTypeJob::makeRequestUrl(const HomeserverData &hsData, + const QString &roomId, const QString &eventId, + const QString &relType, const QString &from, + const QString &to, std::optional limit, + const QString &dir, std::optional recurse) { return BaseJob::makeRequestUrl( hsData, @@ -64,8 +64,8 @@ QUrl GetRelatingEventsWithRelTypeJob::makeRequestUrl(const HomeserverData& hsDat } GetRelatingEventsWithRelTypeJob::GetRelatingEventsWithRelTypeJob( - const QString& roomId, const QString& eventId, const QString& relType, const QString& from, - const QString& to, std::optional limit, const QString& dir, std::optional recurse) + const QString &roomId, const QString &eventId, const QString &relType, const QString &from, + const QString &to, std::optional limit, const QString &dir, std::optional recurse) : BaseJob(HttpVerb::Get, u"GetRelatingEventsWithRelTypeJob"_s, makePath("/_matrix/client/v1", "/rooms/", roomId, "/relations/", eventId, "/", relType), @@ -74,8 +74,8 @@ GetRelatingEventsWithRelTypeJob::GetRelatingEventsWithRelTypeJob( addExpectedKey(u"chunk"_s); } -auto queryToGetRelatingEventsWithRelTypeAndEventType(const QString& from, const QString& to, - std::optional limit, const QString& dir, +auto queryToGetRelatingEventsWithRelTypeAndEventType(const QString &from, const QString &to, + std::optional limit, const QString &dir, std::optional recurse) { QUrlQuery _q; @@ -88,9 +88,9 @@ auto queryToGetRelatingEventsWithRelTypeAndEventType(const QString& from, const } QUrl GetRelatingEventsWithRelTypeAndEventTypeJob::makeRequestUrl( - const HomeserverData& hsData, const QString& roomId, const QString& eventId, - const QString& relType, const QString& eventType, const QString& from, const QString& to, - std::optional limit, const QString& dir, std::optional recurse) + const HomeserverData &hsData, const QString &roomId, const QString &eventId, + const QString &relType, const QString &eventType, const QString &from, const QString &to, + std::optional limit, const QString &dir, std::optional recurse) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v1", "/rooms/", roomId, "/relations/", @@ -100,8 +100,8 @@ QUrl GetRelatingEventsWithRelTypeAndEventTypeJob::makeRequestUrl( } GetRelatingEventsWithRelTypeAndEventTypeJob::GetRelatingEventsWithRelTypeAndEventTypeJob( - const QString& roomId, const QString& eventId, const QString& relType, const QString& eventType, - const QString& from, const QString& to, std::optional limit, const QString& dir, + const QString &roomId, const QString &eventId, const QString &relType, const QString &eventType, + const QString &from, const QString &to, std::optional limit, const QString &dir, std::optional recurse) : BaseJob(HttpVerb::Get, u"GetRelatingEventsWithRelTypeAndEventTypeJob"_s, makePath("/_matrix/client/v1", "/rooms/", roomId, "/relations/", eventId, "/", diff --git a/Quotient/csapi/relations.h b/Quotient/csapi/relations.h index a8d8f669b..adcca2bb1 100644 --- a/Quotient/csapi/relations.h +++ b/Quotient/csapi/relations.h @@ -18,7 +18,8 @@ namespace Quotient { //! For example, passing a `from` token from page 2 of the results, and a `to` token //! from page 1, would return the empty set. The caller can use a `from` token from //! page 1 and a `to` token from page 2 to paginate over the same range, however. -class QUOTIENT_API GetRelatingEventsJob : public BaseJob { +class QUOTIENT_API GetRelatingEventsJob : public BaseJob +{ public: //! \param roomId //! The ID of the room containing the parent event. @@ -67,19 +68,19 @@ class QUOTIENT_API GetRelatingEventsJob : public BaseJob { //! to not infinitely recurse. //! //! The default value is `false`. - explicit GetRelatingEventsJob(const QString& roomId, const QString& eventId, - const QString& from = {}, const QString& to = {}, - std::optional limit = std::nullopt, const QString& dir = {}, + explicit GetRelatingEventsJob(const QString &roomId, const QString &eventId, + const QString &from = {}, const QString &to = {}, + std::optional limit = std::nullopt, const QString &dir = {}, std::optional recurse = std::nullopt); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetRelatingEventsJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomId, - const QString& eventId, const QString& from = {}, - const QString& to = {}, std::optional limit = std::nullopt, - const QString& dir = {}, std::optional recurse = std::nullopt); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &roomId, + const QString &eventId, const QString &from = {}, + const QString &to = {}, std::optional limit = std::nullopt, + const QString &dir = {}, std::optional recurse = std::nullopt); // Result properties @@ -102,7 +103,8 @@ class QUOTIENT_API GetRelatingEventsJob : public BaseJob { //! The child events of the requested event, ordered topologically most-recent first. RoomEvents chunk() { return takeFromJson("chunk"_L1); } - struct Response { + struct Response + { //! An opaque string representing a pagination token. The absence of this token //! means there are no more results to fetch and the client should stop paginating. QString nextBatch{}; @@ -122,8 +124,8 @@ class QUOTIENT_API GetRelatingEventsJob : public BaseJob { }; template JobT> -constexpr inline auto doCollectResponse = [](JobT* j) -> GetRelatingEventsJob::Response { - return { j->nextBatch(), j->prevBatch(), j->recursionDepth(), j->chunk() }; +constexpr inline auto doCollectResponse = [](JobT *j) -> GetRelatingEventsJob::Response { + return {j->nextBatch(), j->prevBatch(), j->recursionDepth(), j->chunk()}; }; //! \brief Get the child events for a given parent event, with a given `relType`. @@ -138,7 +140,8 @@ constexpr inline auto doCollectResponse = [](JobT* j) -> GetRelatingEvents //! For example, passing a `from` token from page 2 of the results, and a `to` token //! from page 1, would return the empty set. The caller can use a `from` token from //! page 1 and a `to` token from page 2 to paginate over the same range, however. -class QUOTIENT_API GetRelatingEventsWithRelTypeJob : public BaseJob { +class QUOTIENT_API GetRelatingEventsWithRelTypeJob : public BaseJob +{ public: //! \param roomId //! The ID of the room containing the parent event. @@ -190,21 +193,21 @@ class QUOTIENT_API GetRelatingEventsWithRelTypeJob : public BaseJob { //! to not infinitely recurse. //! //! The default value is `false`. - explicit GetRelatingEventsWithRelTypeJob(const QString& roomId, const QString& eventId, - const QString& relType, const QString& from = {}, - const QString& to = {}, + explicit GetRelatingEventsWithRelTypeJob(const QString &roomId, const QString &eventId, + const QString &relType, const QString &from = {}, + const QString &to = {}, std::optional limit = std::nullopt, - const QString& dir = {}, + const QString &dir = {}, std::optional recurse = std::nullopt); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetRelatingEventsWithRelTypeJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomId, - const QString& eventId, const QString& relType, - const QString& from = {}, const QString& to = {}, - std::optional limit = std::nullopt, const QString& dir = {}, + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &roomId, + const QString &eventId, const QString &relType, + const QString &from = {}, const QString &to = {}, + std::optional limit = std::nullopt, const QString &dir = {}, std::optional recurse = std::nullopt); // Result properties @@ -230,7 +233,8 @@ class QUOTIENT_API GetRelatingEventsWithRelTypeJob : public BaseJob { //! supplied in the URL. RoomEvents chunk() { return takeFromJson("chunk"_L1); } - struct Response { + struct Response + { //! An opaque string representing a pagination token. The absence of this token //! means there are no more results to fetch and the client should stop paginating. QString nextBatch{}; @@ -253,8 +257,8 @@ class QUOTIENT_API GetRelatingEventsWithRelTypeJob : public BaseJob { template JobT> constexpr inline auto doCollectResponse = - [](JobT* j) -> GetRelatingEventsWithRelTypeJob::Response { - return { j->nextBatch(), j->prevBatch(), j->recursionDepth(), j->chunk() }; + [](JobT *j) -> GetRelatingEventsWithRelTypeJob::Response { + return {j->nextBatch(), j->prevBatch(), j->recursionDepth(), j->chunk()}; }; //! \brief Get the child events for a given parent event, with a given `relType` and `eventType`. @@ -269,7 +273,8 @@ constexpr inline auto doCollectResponse = //! For example, passing a `from` token from page 2 of the results, and a `to` token //! from page 1, would return the empty set. The caller can use a `from` token from //! page 1 and a `to` token from page 2 to paginate over the same range, however. -class QUOTIENT_API GetRelatingEventsWithRelTypeAndEventTypeJob : public BaseJob { +class QUOTIENT_API GetRelatingEventsWithRelTypeAndEventTypeJob : public BaseJob +{ public: //! \param roomId //! The ID of the room containing the parent event. @@ -328,20 +333,20 @@ class QUOTIENT_API GetRelatingEventsWithRelTypeAndEventTypeJob : public BaseJob //! //! The default value is `false`. explicit GetRelatingEventsWithRelTypeAndEventTypeJob( - const QString& roomId, const QString& eventId, const QString& relType, - const QString& eventType, const QString& from = {}, const QString& to = {}, - std::optional limit = std::nullopt, const QString& dir = {}, + const QString &roomId, const QString &eventId, const QString &relType, + const QString &eventType, const QString &from = {}, const QString &to = {}, + std::optional limit = std::nullopt, const QString &dir = {}, std::optional recurse = std::nullopt); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetRelatingEventsWithRelTypeAndEventTypeJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomId, - const QString& eventId, const QString& relType, - const QString& eventType, const QString& from = {}, - const QString& to = {}, std::optional limit = std::nullopt, - const QString& dir = {}, std::optional recurse = std::nullopt); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &roomId, + const QString &eventId, const QString &relType, + const QString &eventType, const QString &from = {}, + const QString &to = {}, std::optional limit = std::nullopt, + const QString &dir = {}, std::optional recurse = std::nullopt); // Result properties @@ -366,7 +371,8 @@ class QUOTIENT_API GetRelatingEventsWithRelTypeAndEventTypeJob : public BaseJob //! in the URL. RoomEvents chunk() { return takeFromJson("chunk"_L1); } - struct Response { + struct Response + { //! An opaque string representing a pagination token. The absence of this token //! means there are no more results to fetch and the client should stop paginating. QString nextBatch{}; @@ -389,8 +395,8 @@ class QUOTIENT_API GetRelatingEventsWithRelTypeAndEventTypeJob : public BaseJob template JobT> constexpr inline auto doCollectResponse = - [](JobT* j) -> GetRelatingEventsWithRelTypeAndEventTypeJob::Response { - return { j->nextBatch(), j->prevBatch(), j->recursionDepth(), j->chunk() }; + [](JobT *j) -> GetRelatingEventsWithRelTypeAndEventTypeJob::Response { + return {j->nextBatch(), j->prevBatch(), j->recursionDepth(), j->chunk()}; }; } // namespace Quotient diff --git a/Quotient/csapi/report_content.cpp b/Quotient/csapi/report_content.cpp index e0102eca6..29c3ab7ad 100644 --- a/Quotient/csapi/report_content.cpp +++ b/Quotient/csapi/report_content.cpp @@ -4,13 +4,13 @@ using namespace Quotient; -ReportContentJob::ReportContentJob(const QString& roomId, const QString& eventId, - std::optional score, const QString& reason) +ReportContentJob::ReportContentJob(const QString &roomId, const QString &eventId, + std::optional score, const QString &reason) : BaseJob(HttpVerb::Post, u"ReportContentJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/report/", eventId)) { QJsonObject _dataJson; addParam(_dataJson, "score"_L1, score); addParam(_dataJson, "reason"_L1, reason); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } diff --git a/Quotient/csapi/report_content.h b/Quotient/csapi/report_content.h index 53e849a96..f5851aca3 100644 --- a/Quotient/csapi/report_content.h +++ b/Quotient/csapi/report_content.h @@ -17,7 +17,8 @@ namespace Quotient { //! will require the homeserver to check whether a user is joined to //! the room. To combat this, homeserver implementations should add //! a random delay when generating a response. -class QUOTIENT_API ReportContentJob : public BaseJob { +class QUOTIENT_API ReportContentJob : public BaseJob +{ public: //! \param roomId //! The room in which the event being reported is located. @@ -31,8 +32,8 @@ class QUOTIENT_API ReportContentJob : public BaseJob { //! //! \param reason //! The reason the content is being reported. May be blank. - explicit ReportContentJob(const QString& roomId, const QString& eventId, - std::optional score = std::nullopt, const QString& reason = {}); + explicit ReportContentJob(const QString &roomId, const QString &eventId, + std::optional score = std::nullopt, const QString &reason = {}); }; } // namespace Quotient diff --git a/Quotient/csapi/room_event_by_timestamp.cpp b/Quotient/csapi/room_event_by_timestamp.cpp index 01c98ffae..3943a4968 100644 --- a/Quotient/csapi/room_event_by_timestamp.cpp +++ b/Quotient/csapi/room_event_by_timestamp.cpp @@ -4,7 +4,7 @@ using namespace Quotient; -auto queryToGetEventByTimestamp(int ts, const QString& dir) +auto queryToGetEventByTimestamp(int ts, const QString &dir) { QUrlQuery _q; addParam(_q, u"ts"_s, ts); @@ -12,8 +12,8 @@ auto queryToGetEventByTimestamp(int ts, const QString& dir) return _q; } -QUrl GetEventByTimestampJob::makeRequestUrl(const HomeserverData& hsData, const QString& roomId, - int ts, const QString& dir) +QUrl GetEventByTimestampJob::makeRequestUrl(const HomeserverData &hsData, const QString &roomId, + int ts, const QString &dir) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v1", "/rooms/", roomId, @@ -21,7 +21,7 @@ QUrl GetEventByTimestampJob::makeRequestUrl(const HomeserverData& hsData, const queryToGetEventByTimestamp(ts, dir)); } -GetEventByTimestampJob::GetEventByTimestampJob(const QString& roomId, int ts, const QString& dir) +GetEventByTimestampJob::GetEventByTimestampJob(const QString &roomId, int ts, const QString &dir) : BaseJob(HttpVerb::Get, u"GetEventByTimestampJob"_s, makePath("/_matrix/client/v1", "/rooms/", roomId, "/timestamp_to_event"), queryToGetEventByTimestamp(ts, dir)) diff --git a/Quotient/csapi/room_event_by_timestamp.h b/Quotient/csapi/room_event_by_timestamp.h index df51ec52e..265e7f7bd 100644 --- a/Quotient/csapi/room_event_by_timestamp.h +++ b/Quotient/csapi/room_event_by_timestamp.h @@ -32,7 +32,8 @@ namespace Quotient { //! paginating in the opposite direction. The client could also simply //! paginate in one direction and inform the user that the closest event //! found in that direction is outside of the expected range. -class QUOTIENT_API GetEventByTimestampJob : public BaseJob { +class QUOTIENT_API GetEventByTimestampJob : public BaseJob +{ public: //! \param roomId //! The ID of the room to search @@ -43,14 +44,14 @@ class QUOTIENT_API GetEventByTimestampJob : public BaseJob { //! //! \param dir //! The direction in which to search. `f` for forwards, `b` for backwards. - explicit GetEventByTimestampJob(const QString& roomId, int ts, const QString& dir); + explicit GetEventByTimestampJob(const QString &roomId, int ts, const QString &dir); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetEventByTimestampJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomId, int ts, - const QString& dir); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &roomId, int ts, + const QString &dir); // Result properties @@ -63,7 +64,8 @@ class QUOTIENT_API GetEventByTimestampJob : public BaseJob { //! use case. int originServerTimestamp() const { return loadFromJson("origin_server_ts"_L1); } - struct Response { + struct Response + { //! The ID of the event found QString eventId{}; @@ -76,8 +78,8 @@ class QUOTIENT_API GetEventByTimestampJob : public BaseJob { }; template JobT> -constexpr inline auto doCollectResponse = [](JobT* j) -> GetEventByTimestampJob::Response { - return { j->eventId(), j->originServerTimestamp() }; +constexpr inline auto doCollectResponse = [](JobT *j) -> GetEventByTimestampJob::Response { + return {j->eventId(), j->originServerTimestamp()}; }; } // namespace Quotient diff --git a/Quotient/csapi/room_send.cpp b/Quotient/csapi/room_send.cpp index 8f8da7c0d..e4b82dcc1 100644 --- a/Quotient/csapi/room_send.cpp +++ b/Quotient/csapi/room_send.cpp @@ -4,11 +4,11 @@ using namespace Quotient; -SendMessageJob::SendMessageJob(const QString& roomId, const QString& eventType, - const QString& txnId, const QJsonObject& content) +SendMessageJob::SendMessageJob(const QString &roomId, const QString &eventType, + const QString &txnId, const QJsonObject &content) : BaseJob(HttpVerb::Put, u"SendMessageJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/send/", eventType, "/", txnId)) { - setRequestData({ toJson(content) }); + setRequestData({toJson(content)}); addExpectedKey(u"event_id"_s); } diff --git a/Quotient/csapi/room_send.h b/Quotient/csapi/room_send.h index cb3325086..e258a4322 100644 --- a/Quotient/csapi/room_send.h +++ b/Quotient/csapi/room_send.h @@ -15,7 +15,8 @@ namespace Quotient { //! The body of the request should be the content object of the event; the //! fields in this object will vary depending on the type of event. See //! [Room Events](/client-server-api/#room-events) for the m. event specification. -class QUOTIENT_API SendMessageJob : public BaseJob { +class QUOTIENT_API SendMessageJob : public BaseJob +{ public: //! \param roomId //! The room to send the event to. @@ -28,8 +29,8 @@ class QUOTIENT_API SendMessageJob : public BaseJob { //! should generate an ID unique across requests with the same access token; it will be used //! by the server to ensure idempotency of requests. //! - explicit SendMessageJob(const QString& roomId, const QString& eventType, const QString& txnId, - const QJsonObject& content = {}); + explicit SendMessageJob(const QString &roomId, const QString &eventType, const QString &txnId, + const QJsonObject &content = {}); // Result properties @@ -37,6 +38,6 @@ class QUOTIENT_API SendMessageJob : public BaseJob { QString eventId() const { return loadFromJson("event_id"_L1); } }; -inline auto collectResponse(const SendMessageJob* job) { return job->eventId(); } +inline auto collectResponse(const SendMessageJob *job) { return job->eventId(); } } // namespace Quotient diff --git a/Quotient/csapi/room_state.cpp b/Quotient/csapi/room_state.cpp index d2da130c4..e671cba9c 100644 --- a/Quotient/csapi/room_state.cpp +++ b/Quotient/csapi/room_state.cpp @@ -4,11 +4,11 @@ using namespace Quotient; -SetRoomStateWithKeyJob::SetRoomStateWithKeyJob(const QString& roomId, const QString& eventType, - const QString& stateKey, const QJsonObject& content) +SetRoomStateWithKeyJob::SetRoomStateWithKeyJob(const QString &roomId, const QString &eventType, + const QString &stateKey, const QJsonObject &content) : BaseJob(HttpVerb::Put, u"SetRoomStateWithKeyJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/state/", eventType, "/", stateKey)) { - setRequestData({ toJson(content) }); + setRequestData({toJson(content)}); addExpectedKey(u"event_id"_s); } diff --git a/Quotient/csapi/room_state.h b/Quotient/csapi/room_state.h index 7fc2cf91e..f8e5e935c 100644 --- a/Quotient/csapi/room_state.h +++ b/Quotient/csapi/room_state.h @@ -25,7 +25,8 @@ namespace Quotient { //! per their grammar/syntax and that they point to the room ID where the //! state event is to be sent. Servers do not validate aliases which are //! being removed or are already present in the state event. -class QUOTIENT_API SetRoomStateWithKeyJob : public BaseJob { +class QUOTIENT_API SetRoomStateWithKeyJob : public BaseJob +{ public: //! \param roomId //! The room to set the state in @@ -37,8 +38,8 @@ class QUOTIENT_API SetRoomStateWithKeyJob : public BaseJob { //! The state_key for the state to send. Defaults to the empty string. When //! an empty string, the trailing slash on this endpoint is optional. //! - explicit SetRoomStateWithKeyJob(const QString& roomId, const QString& eventType, - const QString& stateKey, const QJsonObject& content = {}); + explicit SetRoomStateWithKeyJob(const QString &roomId, const QString &eventType, + const QString &stateKey, const QJsonObject &content = {}); // Result properties @@ -46,6 +47,6 @@ class QUOTIENT_API SetRoomStateWithKeyJob : public BaseJob { QString eventId() const { return loadFromJson("event_id"_L1); } }; -inline auto collectResponse(const SetRoomStateWithKeyJob* job) { return job->eventId(); } +inline auto collectResponse(const SetRoomStateWithKeyJob *job) { return job->eventId(); } } // namespace Quotient diff --git a/Quotient/csapi/room_upgrades.cpp b/Quotient/csapi/room_upgrades.cpp index 0f8a15877..92ba51d54 100644 --- a/Quotient/csapi/room_upgrades.cpp +++ b/Quotient/csapi/room_upgrades.cpp @@ -4,12 +4,12 @@ using namespace Quotient; -UpgradeRoomJob::UpgradeRoomJob(const QString& roomId, const QString& newVersion) +UpgradeRoomJob::UpgradeRoomJob(const QString &roomId, const QString &newVersion) : BaseJob(HttpVerb::Post, u"UpgradeRoomJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/upgrade")) { QJsonObject _dataJson; addParam(_dataJson, "new_version"_L1, newVersion); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); addExpectedKey(u"replacement_room"_s); } diff --git a/Quotient/csapi/room_upgrades.h b/Quotient/csapi/room_upgrades.h index 611d2505c..ebd3e4d0e 100644 --- a/Quotient/csapi/room_upgrades.h +++ b/Quotient/csapi/room_upgrades.h @@ -9,14 +9,15 @@ namespace Quotient { //! \brief Upgrades a room to a new room version. //! //! Upgrades the given room to a particular room version. -class QUOTIENT_API UpgradeRoomJob : public BaseJob { +class QUOTIENT_API UpgradeRoomJob : public BaseJob +{ public: //! \param roomId //! The ID of the room to upgrade. //! //! \param newVersion //! The new version for the room. - explicit UpgradeRoomJob(const QString& roomId, const QString& newVersion); + explicit UpgradeRoomJob(const QString &roomId, const QString &newVersion); // Result properties @@ -24,6 +25,6 @@ class QUOTIENT_API UpgradeRoomJob : public BaseJob { QString replacementRoom() const { return loadFromJson("replacement_room"_L1); } }; -inline auto collectResponse(const UpgradeRoomJob* job) { return job->replacementRoom(); } +inline auto collectResponse(const UpgradeRoomJob *job) { return job->replacementRoom(); } } // namespace Quotient diff --git a/Quotient/csapi/rooms.cpp b/Quotient/csapi/rooms.cpp index decce3381..9a9b33e82 100644 --- a/Quotient/csapi/rooms.cpp +++ b/Quotient/csapi/rooms.cpp @@ -4,44 +4,44 @@ using namespace Quotient; -QUrl GetOneRoomEventJob::makeRequestUrl(const HomeserverData& hsData, const QString& roomId, - const QString& eventId) +QUrl GetOneRoomEventJob::makeRequestUrl(const HomeserverData &hsData, const QString &roomId, + const QString &eventId) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/rooms/", roomId, "/event/", eventId)); } -GetOneRoomEventJob::GetOneRoomEventJob(const QString& roomId, const QString& eventId) +GetOneRoomEventJob::GetOneRoomEventJob(const QString &roomId, const QString &eventId) : BaseJob(HttpVerb::Get, u"GetOneRoomEventJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/event/", eventId)) {} -QUrl GetRoomStateWithKeyJob::makeRequestUrl(const HomeserverData& hsData, const QString& roomId, - const QString& eventType, const QString& stateKey) +QUrl GetRoomStateWithKeyJob::makeRequestUrl(const HomeserverData &hsData, const QString &roomId, + const QString &eventType, const QString &stateKey) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/rooms/", roomId, "/state/", eventType, "/", stateKey)); } -GetRoomStateWithKeyJob::GetRoomStateWithKeyJob(const QString& roomId, const QString& eventType, - const QString& stateKey) +GetRoomStateWithKeyJob::GetRoomStateWithKeyJob(const QString &roomId, const QString &eventType, + const QString &stateKey) : BaseJob(HttpVerb::Get, u"GetRoomStateWithKeyJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/state/", eventType, "/", stateKey)) {} -QUrl GetRoomStateJob::makeRequestUrl(const HomeserverData& hsData, const QString& roomId) +QUrl GetRoomStateJob::makeRequestUrl(const HomeserverData &hsData, const QString &roomId) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/rooms/", roomId, "/state")); } -GetRoomStateJob::GetRoomStateJob(const QString& roomId) +GetRoomStateJob::GetRoomStateJob(const QString &roomId) : BaseJob(HttpVerb::Get, u"GetRoomStateJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/state")) {} -auto queryToGetMembersByRoom(const QString& at, const QString& membership, - const QString& notMembership) +auto queryToGetMembersByRoom(const QString &at, const QString &membership, + const QString ¬Membership) { QUrlQuery _q; addParam(_q, u"at"_s, at); @@ -50,29 +50,29 @@ auto queryToGetMembersByRoom(const QString& at, const QString& membership, return _q; } -QUrl GetMembersByRoomJob::makeRequestUrl(const HomeserverData& hsData, const QString& roomId, - const QString& at, const QString& membership, - const QString& notMembership) +QUrl GetMembersByRoomJob::makeRequestUrl(const HomeserverData &hsData, const QString &roomId, + const QString &at, const QString &membership, + const QString ¬Membership) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/rooms/", roomId, "/members"), queryToGetMembersByRoom(at, membership, notMembership)); } -GetMembersByRoomJob::GetMembersByRoomJob(const QString& roomId, const QString& at, - const QString& membership, const QString& notMembership) +GetMembersByRoomJob::GetMembersByRoomJob(const QString &roomId, const QString &at, + const QString &membership, const QString ¬Membership) : BaseJob(HttpVerb::Get, u"GetMembersByRoomJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/members"), queryToGetMembersByRoom(at, membership, notMembership)) {} -QUrl GetJoinedMembersByRoomJob::makeRequestUrl(const HomeserverData& hsData, const QString& roomId) +QUrl GetJoinedMembersByRoomJob::makeRequestUrl(const HomeserverData &hsData, const QString &roomId) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/rooms/", roomId, "/joined_members")); } -GetJoinedMembersByRoomJob::GetJoinedMembersByRoomJob(const QString& roomId) +GetJoinedMembersByRoomJob::GetJoinedMembersByRoomJob(const QString &roomId) : BaseJob(HttpVerb::Get, u"GetJoinedMembersByRoomJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/joined_members")) {} diff --git a/Quotient/csapi/rooms.h b/Quotient/csapi/rooms.h index 30f5f90b2..6d5bb1db5 100644 --- a/Quotient/csapi/rooms.h +++ b/Quotient/csapi/rooms.h @@ -12,21 +12,22 @@ namespace Quotient { //! //! Get a single event based on `roomId/eventId`. You must have permission to //! retrieve this event e.g. by being a member in the room for this event. -class QUOTIENT_API GetOneRoomEventJob : public BaseJob { +class QUOTIENT_API GetOneRoomEventJob : public BaseJob +{ public: //! \param roomId //! The ID of the room the event is in. //! //! \param eventId //! The event ID to get. - explicit GetOneRoomEventJob(const QString& roomId, const QString& eventId); + explicit GetOneRoomEventJob(const QString &roomId, const QString &eventId); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetOneRoomEventJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomId, - const QString& eventId); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &roomId, + const QString &eventId); // Result properties @@ -34,7 +35,7 @@ class QUOTIENT_API GetOneRoomEventJob : public BaseJob { RoomEventPtr requestedEvent() { return fromJson(jsonData()); } }; -inline auto collectResponse(GetOneRoomEventJob* job) { return job->requestedEvent(); } +inline auto collectResponse(GetOneRoomEventJob *job) { return job->requestedEvent(); } //! \brief Get the state identified by the type and key. //! @@ -42,7 +43,8 @@ inline auto collectResponse(GetOneRoomEventJob* job) { return job->requestedEven //! joined to the room then the state is taken from the current //! state of the room. If the user has left the room then the state is //! taken from the state of the room when they left. -class QUOTIENT_API GetRoomStateWithKeyJob : public BaseJob { +class QUOTIENT_API GetRoomStateWithKeyJob : public BaseJob +{ public: //! \param roomId //! The room to look up the state in. @@ -53,15 +55,15 @@ class QUOTIENT_API GetRoomStateWithKeyJob : public BaseJob { //! \param stateKey //! The key of the state to look up. Defaults to an empty string. When //! an empty string, the trailing slash on this endpoint is optional. - explicit GetRoomStateWithKeyJob(const QString& roomId, const QString& eventType, - const QString& stateKey); + explicit GetRoomStateWithKeyJob(const QString &roomId, const QString &eventType, + const QString &stateKey); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetRoomStateWithKeyJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomId, - const QString& eventType, const QString& stateKey); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &roomId, + const QString &eventType, const QString &stateKey); // Result properties @@ -69,22 +71,23 @@ class QUOTIENT_API GetRoomStateWithKeyJob : public BaseJob { QJsonObject content() const { return fromJson(jsonData()); } }; -inline auto collectResponse(const GetRoomStateWithKeyJob* job) { return job->content(); } +inline auto collectResponse(const GetRoomStateWithKeyJob *job) { return job->content(); } //! \brief Get all state events in the current state of a room. //! //! Get the state events for the current state of a room. -class QUOTIENT_API GetRoomStateJob : public BaseJob { +class QUOTIENT_API GetRoomStateJob : public BaseJob +{ public: //! \param roomId //! The room to look up the state for. - explicit GetRoomStateJob(const QString& roomId); + explicit GetRoomStateJob(const QString &roomId); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetRoomStateJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomId); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &roomId); // Result properties @@ -92,12 +95,13 @@ class QUOTIENT_API GetRoomStateJob : public BaseJob { StateEvents events() { return fromJson(jsonData()); } }; -inline auto collectResponse(GetRoomStateJob* job) { return job->events(); } +inline auto collectResponse(GetRoomStateJob *job) { return job->events(); } //! \brief Get the m.room.member events for the room. //! //! Get the list of members for this room. -class QUOTIENT_API GetMembersByRoomJob : public BaseJob { +class QUOTIENT_API GetMembersByRoomJob : public BaseJob +{ public: //! \param roomId //! The room to get the member events for. @@ -117,23 +121,23 @@ class QUOTIENT_API GetMembersByRoomJob : public BaseJob { //! \param notMembership //! The kind of membership to exclude from the results. Defaults to no //! filtering if unspecified. - explicit GetMembersByRoomJob(const QString& roomId, const QString& at = {}, - const QString& membership = {}, const QString& notMembership = {}); + explicit GetMembersByRoomJob(const QString &roomId, const QString &at = {}, + const QString &membership = {}, const QString ¬Membership = {}); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetMembersByRoomJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomId, - const QString& at = {}, const QString& membership = {}, - const QString& notMembership = {}); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &roomId, + const QString &at = {}, const QString &membership = {}, + const QString ¬Membership = {}); // Result properties StateEvents chunk() { return takeFromJson("chunk"_L1); } }; -inline auto collectResponse(GetMembersByRoomJob* job) { return job->chunk(); } +inline auto collectResponse(GetMembersByRoomJob *job) { return job->chunk(); } //! \brief Gets the list of currently joined users and their profile data. //! @@ -141,11 +145,13 @@ inline auto collectResponse(GetMembersByRoomJob* job) { return job->chunk(); } //! must be in the room for it to work, unless it is an Application Service in which case any of the //! AS's users must be in the room. This API is primarily for Application Services and should be //! faster to respond than `/members` as it can be implemented more efficiently on the server. -class QUOTIENT_API GetJoinedMembersByRoomJob : public BaseJob { +class QUOTIENT_API GetJoinedMembersByRoomJob : public BaseJob +{ public: // Inner data structures - struct QUOTIENT_API RoomMember { + struct QUOTIENT_API RoomMember + { //! The display name of the user this object is representing. QString displayName{}; @@ -158,13 +164,13 @@ class QUOTIENT_API GetJoinedMembersByRoomJob : public BaseJob { //! \param roomId //! The room to get the members of. - explicit GetJoinedMembersByRoomJob(const QString& roomId); + explicit GetJoinedMembersByRoomJob(const QString &roomId); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetJoinedMembersByRoomJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomId); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &roomId); // Result properties @@ -175,11 +181,12 @@ class QUOTIENT_API GetJoinedMembersByRoomJob : public BaseJob { } }; -inline auto collectResponse(const GetJoinedMembersByRoomJob* job) { return job->joined(); } +inline auto collectResponse(const GetJoinedMembersByRoomJob *job) { return job->joined(); } template <> -struct QUOTIENT_API JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, GetJoinedMembersByRoomJob::RoomMember& result) +struct QUOTIENT_API JsonObjectConverter +{ + static void fillFrom(const QJsonObject &jo, GetJoinedMembersByRoomJob::RoomMember &result) { fillFromJson(jo.value("display_name"_L1), result.displayName); fillFromJson(jo.value("avatar_url"_L1), result.avatarUrl); diff --git a/Quotient/csapi/search.cpp b/Quotient/csapi/search.cpp index 8664a4123..46dedda57 100644 --- a/Quotient/csapi/search.cpp +++ b/Quotient/csapi/search.cpp @@ -4,19 +4,19 @@ using namespace Quotient; -auto queryToSearch(const QString& nextBatch) +auto queryToSearch(const QString &nextBatch) { QUrlQuery _q; addParam(_q, u"next_batch"_s, nextBatch); return _q; } -SearchJob::SearchJob(const Categories& searchCategories, const QString& nextBatch) +SearchJob::SearchJob(const Categories &searchCategories, const QString &nextBatch) : BaseJob(HttpVerb::Post, u"SearchJob"_s, makePath("/_matrix/client/v3", "/search"), queryToSearch(nextBatch)) { QJsonObject _dataJson; addParam(_dataJson, "search_categories"_L1, searchCategories); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); addExpectedKey(u"search_categories"_s); } diff --git a/Quotient/csapi/search.h b/Quotient/csapi/search.h index fa66267f7..df4e52610 100644 --- a/Quotient/csapi/search.h +++ b/Quotient/csapi/search.h @@ -3,7 +3,6 @@ #pragma once #include - #include #include #include @@ -13,13 +12,15 @@ namespace Quotient { //! \brief Perform a server-side search. //! //! Performs a full text search across different categories. -class QUOTIENT_API SearchJob : public BaseJob { +class QUOTIENT_API SearchJob : public BaseJob +{ public: // Inner data structures //! Configures whether any context for the events //! returned are included in the response. - struct QUOTIENT_API IncludeEventContext { + struct QUOTIENT_API IncludeEventContext + { //! How many events before the result are //! returned. By default, this is `5`. std::optional beforeLimit{}; @@ -36,20 +37,23 @@ class QUOTIENT_API SearchJob : public BaseJob { }; //! Configuration for group. - struct QUOTIENT_API Group { + struct QUOTIENT_API Group + { //! Key that defines the group. QString key{}; }; //! Requests that the server partitions the result set //! based on the provided list of keys. - struct QUOTIENT_API Groupings { + struct QUOTIENT_API Groupings + { //! List of groups to request. QVector groupBy{}; }; //! Mapping of category name to search criteria. - struct QUOTIENT_API RoomEventsCriteria { + struct QUOTIENT_API RoomEventsCriteria + { //! The string to search events for QString searchTerm; @@ -77,19 +81,22 @@ class QUOTIENT_API SearchJob : public BaseJob { }; //! Describes which categories to search in and their criteria. - struct QUOTIENT_API Categories { + struct QUOTIENT_API Categories + { //! Mapping of category name to search criteria. std::optional roomEvents{}; }; - struct QUOTIENT_API UserProfile { + struct QUOTIENT_API UserProfile + { QString displayname{}; QUrl avatarUrl{}; }; //! Context for result, if requested. - struct QUOTIENT_API EventContext { + struct QUOTIENT_API EventContext + { //! Pagination token for the start of the chunk QString begin{}; @@ -111,7 +118,8 @@ class QUOTIENT_API SearchJob : public BaseJob { }; //! The result object. - struct QUOTIENT_API Result { + struct QUOTIENT_API Result + { //! A number that describes how closely this result matches the search. Higher is closer. std::optional rank{}; @@ -123,7 +131,8 @@ class QUOTIENT_API SearchJob : public BaseJob { }; //! The results for a particular group value. - struct QUOTIENT_API GroupValue { + struct QUOTIENT_API GroupValue + { //! Token that can be used to get the next batch //! of results in the group, by passing as the //! `next_batch` parameter to the next call. If @@ -140,7 +149,8 @@ class QUOTIENT_API SearchJob : public BaseJob { }; //! Mapping of category name to search criteria. - struct QUOTIENT_API ResultRoomEvents { + struct QUOTIENT_API ResultRoomEvents + { //! An approximate count of the total number of results found. std::optional count{}; @@ -174,7 +184,8 @@ class QUOTIENT_API SearchJob : public BaseJob { }; //! Describes which categories to search in and their criteria. - struct QUOTIENT_API ResultCategories { + struct QUOTIENT_API ResultCategories + { //! Mapping of category name to search criteria. std::optional roomEvents{}; }; @@ -187,7 +198,7 @@ class QUOTIENT_API SearchJob : public BaseJob { //! \param nextBatch //! The point to return events from. If given, this should be a //! `next_batch` result from a previous call to this endpoint. - explicit SearchJob(const Categories& searchCategories, const QString& nextBatch = {}); + explicit SearchJob(const Categories &searchCategories, const QString &nextBatch = {}); // Result properties @@ -198,11 +209,12 @@ class QUOTIENT_API SearchJob : public BaseJob { } }; -inline auto collectResponse(const SearchJob* job) { return job->searchCategories(); } +inline auto collectResponse(const SearchJob *job) { return job->searchCategories(); } template <> -struct QUOTIENT_API JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const SearchJob::IncludeEventContext& pod) +struct QUOTIENT_API JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const SearchJob::IncludeEventContext &pod) { addParam(jo, "before_limit"_L1, pod.beforeLimit); addParam(jo, "after_limit"_L1, pod.afterLimit); @@ -211,24 +223,27 @@ struct QUOTIENT_API JsonObjectConverter { }; template <> -struct QUOTIENT_API JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const SearchJob::Group& pod) +struct QUOTIENT_API JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const SearchJob::Group &pod) { addParam(jo, "key"_L1, pod.key); } }; template <> -struct QUOTIENT_API JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const SearchJob::Groupings& pod) +struct QUOTIENT_API JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const SearchJob::Groupings &pod) { addParam(jo, "group_by"_L1, pod.groupBy); } }; template <> -struct QUOTIENT_API JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const SearchJob::RoomEventsCriteria& pod) +struct QUOTIENT_API JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const SearchJob::RoomEventsCriteria &pod) { addParam(jo, "search_term"_L1, pod.searchTerm); addParam(jo, "keys"_L1, pod.keys); @@ -241,16 +256,18 @@ struct QUOTIENT_API JsonObjectConverter { }; template <> -struct QUOTIENT_API JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const SearchJob::Categories& pod) +struct QUOTIENT_API JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const SearchJob::Categories &pod) { addParam(jo, "room_events"_L1, pod.roomEvents); } }; template <> -struct QUOTIENT_API JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, SearchJob::UserProfile& result) +struct QUOTIENT_API JsonObjectConverter +{ + static void fillFrom(const QJsonObject &jo, SearchJob::UserProfile &result) { fillFromJson(jo.value("displayname"_L1), result.displayname); fillFromJson(jo.value("avatar_url"_L1), result.avatarUrl); @@ -258,8 +275,9 @@ struct QUOTIENT_API JsonObjectConverter { }; template <> -struct QUOTIENT_API JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, SearchJob::EventContext& result) +struct QUOTIENT_API JsonObjectConverter +{ + static void fillFrom(const QJsonObject &jo, SearchJob::EventContext &result) { fillFromJson(jo.value("start"_L1), result.begin); fillFromJson(jo.value("end"_L1), result.end); @@ -270,8 +288,9 @@ struct QUOTIENT_API JsonObjectConverter { }; template <> -struct QUOTIENT_API JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, SearchJob::Result& result) +struct QUOTIENT_API JsonObjectConverter +{ + static void fillFrom(const QJsonObject &jo, SearchJob::Result &result) { fillFromJson(jo.value("rank"_L1), result.rank); fillFromJson(jo.value("result"_L1), result.result); @@ -280,8 +299,9 @@ struct QUOTIENT_API JsonObjectConverter { }; template <> -struct QUOTIENT_API JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, SearchJob::GroupValue& result) +struct QUOTIENT_API JsonObjectConverter +{ + static void fillFrom(const QJsonObject &jo, SearchJob::GroupValue &result) { fillFromJson(jo.value("next_batch"_L1), result.nextBatch); fillFromJson(jo.value("order"_L1), result.order); @@ -290,8 +310,9 @@ struct QUOTIENT_API JsonObjectConverter { }; template <> -struct QUOTIENT_API JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, SearchJob::ResultRoomEvents& result) +struct QUOTIENT_API JsonObjectConverter +{ + static void fillFrom(const QJsonObject &jo, SearchJob::ResultRoomEvents &result) { fillFromJson(jo.value("count"_L1), result.count); fillFromJson(jo.value("highlights"_L1), result.highlights); @@ -303,8 +324,9 @@ struct QUOTIENT_API JsonObjectConverter { }; template <> -struct QUOTIENT_API JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, SearchJob::ResultCategories& result) +struct QUOTIENT_API JsonObjectConverter +{ + static void fillFrom(const QJsonObject &jo, SearchJob::ResultCategories &result) { fillFromJson(jo.value("room_events"_L1), result.roomEvents); } diff --git a/Quotient/csapi/space_hierarchy.cpp b/Quotient/csapi/space_hierarchy.cpp index ca13d191f..203795ea9 100644 --- a/Quotient/csapi/space_hierarchy.cpp +++ b/Quotient/csapi/space_hierarchy.cpp @@ -5,7 +5,7 @@ using namespace Quotient; auto queryToGetSpaceHierarchy(std::optional suggestedOnly, std::optional limit, - std::optional maxDepth, const QString& from) + std::optional maxDepth, const QString &from) { QUrlQuery _q; addParam(_q, u"suggested_only"_s, suggestedOnly); @@ -15,19 +15,19 @@ auto queryToGetSpaceHierarchy(std::optional suggestedOnly, std::optional suggestedOnly, std::optional limit, std::optional maxDepth, - const QString& from) + const QString &from) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v1", "/rooms/", roomId, "/hierarchy"), queryToGetSpaceHierarchy(suggestedOnly, limit, maxDepth, from)); } -GetSpaceHierarchyJob::GetSpaceHierarchyJob(const QString& roomId, std::optional suggestedOnly, +GetSpaceHierarchyJob::GetSpaceHierarchyJob(const QString &roomId, std::optional suggestedOnly, std::optional limit, std::optional maxDepth, - const QString& from) + const QString &from) : BaseJob(HttpVerb::Get, u"GetSpaceHierarchyJob"_s, makePath("/_matrix/client/v1", "/rooms/", roomId, "/hierarchy"), queryToGetSpaceHierarchy(suggestedOnly, limit, maxDepth, from)) diff --git a/Quotient/csapi/space_hierarchy.h b/Quotient/csapi/space_hierarchy.h index 44e3dfbdf..c421ea37c 100644 --- a/Quotient/csapi/space_hierarchy.h +++ b/Quotient/csapi/space_hierarchy.h @@ -16,11 +16,13 @@ namespace Quotient { //! //! Only [`m.space.child`](#mspacechild) state events of the room are considered. Invalid child //! rooms and parent events are not covered by this endpoint. -class QUOTIENT_API GetSpaceHierarchyJob : public BaseJob { +class QUOTIENT_API GetSpaceHierarchyJob : public BaseJob +{ public: // Inner data structures - struct QUOTIENT_API SpaceHierarchyRoomsChunk { + struct QUOTIENT_API SpaceHierarchyRoomsChunk + { //! The number of members joined to the room. int numJoinedMembers; @@ -89,20 +91,20 @@ class QUOTIENT_API GetSpaceHierarchyJob : public BaseJob { //! \param from //! A pagination token from a previous result. If specified, `max_depth` and `suggested_only` //! cannot be changed from the first request. - explicit GetSpaceHierarchyJob(const QString& roomId, + explicit GetSpaceHierarchyJob(const QString &roomId, std::optional suggestedOnly = std::nullopt, std::optional limit = std::nullopt, std::optional maxDepth = std::nullopt, - const QString& from = {}); + const QString &from = {}); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetSpaceHierarchyJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomId, + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &roomId, std::optional suggestedOnly = std::nullopt, std::optional limit = std::nullopt, - std::optional maxDepth = std::nullopt, const QString& from = {}); + std::optional maxDepth = std::nullopt, const QString &from = {}); // Result properties @@ -116,7 +118,8 @@ class QUOTIENT_API GetSpaceHierarchyJob : public BaseJob { //! no further results. QString nextBatch() const { return loadFromJson("next_batch"_L1); } - struct Response { + struct Response + { //! The rooms for the current page, with the current filters. std::vector rooms{}; @@ -128,12 +131,13 @@ class QUOTIENT_API GetSpaceHierarchyJob : public BaseJob { template JobT> constexpr inline auto doCollectResponse = - [](JobT* j) -> GetSpaceHierarchyJob::Response { return { j->rooms(), j->nextBatch() }; }; + [](JobT *j) -> GetSpaceHierarchyJob::Response { return {j->rooms(), j->nextBatch()}; }; template <> -struct QUOTIENT_API JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, - GetSpaceHierarchyJob::SpaceHierarchyRoomsChunk& result) +struct QUOTIENT_API JsonObjectConverter +{ + static void fillFrom(const QJsonObject &jo, + GetSpaceHierarchyJob::SpaceHierarchyRoomsChunk &result) { fillFromJson(jo.value("num_joined_members"_L1), result.numJoinedMembers); fillFromJson(jo.value("room_id"_L1), result.roomId); diff --git a/Quotient/csapi/sso_login_redirect.cpp b/Quotient/csapi/sso_login_redirect.cpp index b94fbdce8..2dc39bdcc 100644 --- a/Quotient/csapi/sso_login_redirect.cpp +++ b/Quotient/csapi/sso_login_redirect.cpp @@ -4,41 +4,41 @@ using namespace Quotient; -auto queryToRedirectToSSO(const QString& redirectUrl) +auto queryToRedirectToSSO(const QString &redirectUrl) { QUrlQuery _q; addParam(_q, u"redirectUrl"_s, redirectUrl); return _q; } -QUrl RedirectToSSOJob::makeRequestUrl(const HomeserverData& hsData, const QString& redirectUrl) +QUrl RedirectToSSOJob::makeRequestUrl(const HomeserverData &hsData, const QString &redirectUrl) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/login/sso/redirect"), queryToRedirectToSSO(redirectUrl)); } -RedirectToSSOJob::RedirectToSSOJob(const QString& redirectUrl) +RedirectToSSOJob::RedirectToSSOJob(const QString &redirectUrl) : BaseJob(HttpVerb::Get, u"RedirectToSSOJob"_s, makePath("/_matrix/client/v3", "/login/sso/redirect"), queryToRedirectToSSO(redirectUrl), {}, false) {} -auto queryToRedirectToIdP(const QString& redirectUrl) +auto queryToRedirectToIdP(const QString &redirectUrl) { QUrlQuery _q; addParam(_q, u"redirectUrl"_s, redirectUrl); return _q; } -QUrl RedirectToIdPJob::makeRequestUrl(const HomeserverData& hsData, const QString& idpId, - const QString& redirectUrl) +QUrl RedirectToIdPJob::makeRequestUrl(const HomeserverData &hsData, const QString &idpId, + const QString &redirectUrl) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/login/sso/redirect/", idpId), queryToRedirectToIdP(redirectUrl)); } -RedirectToIdPJob::RedirectToIdPJob(const QString& idpId, const QString& redirectUrl) +RedirectToIdPJob::RedirectToIdPJob(const QString &idpId, const QString &redirectUrl) : BaseJob(HttpVerb::Get, u"RedirectToIdPJob"_s, makePath("/_matrix/client/v3", "/login/sso/redirect/", idpId), queryToRedirectToIdP(redirectUrl), {}, false) diff --git a/Quotient/csapi/sso_login_redirect.h b/Quotient/csapi/sso_login_redirect.h index dd2cb64c6..7611f0628 100644 --- a/Quotient/csapi/sso_login_redirect.h +++ b/Quotient/csapi/sso_login_redirect.h @@ -14,18 +14,19 @@ namespace Quotient { //! The server MUST respond with an HTTP redirect to the SSO interface, //! or present a page which lets the user select an IdP to continue //! with in the event multiple are supported by the server. -class QUOTIENT_API RedirectToSSOJob : public BaseJob { +class QUOTIENT_API RedirectToSSOJob : public BaseJob +{ public: //! \param redirectUrl //! URI to which the user will be redirected after the homeserver has //! authenticated the user with SSO. - explicit RedirectToSSOJob(const QString& redirectUrl); + explicit RedirectToSSOJob(const QString &redirectUrl); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for RedirectToSSOJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& redirectUrl); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &redirectUrl); }; //! \brief Redirect the user's browser to the SSO interface for an IdP. @@ -36,7 +37,8 @@ class QUOTIENT_API RedirectToSSOJob : public BaseJob { //! //! The server MUST respond with an HTTP redirect to the SSO interface //! for that IdP. -class QUOTIENT_API RedirectToIdPJob : public BaseJob { +class QUOTIENT_API RedirectToIdPJob : public BaseJob +{ public: //! \param idpId //! The `id` of the IdP from the `m.login.sso` `identity_providers` @@ -45,14 +47,14 @@ class QUOTIENT_API RedirectToIdPJob : public BaseJob { //! \param redirectUrl //! URI to which the user will be redirected after the homeserver has //! authenticated the user with SSO. - explicit RedirectToIdPJob(const QString& idpId, const QString& redirectUrl); + explicit RedirectToIdPJob(const QString &idpId, const QString &redirectUrl); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for RedirectToIdPJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& idpId, - const QString& redirectUrl); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &idpId, + const QString &redirectUrl); }; } // namespace Quotient diff --git a/Quotient/csapi/support.cpp b/Quotient/csapi/support.cpp index deef13fe6..85bd13bcd 100644 --- a/Quotient/csapi/support.cpp +++ b/Quotient/csapi/support.cpp @@ -4,7 +4,7 @@ using namespace Quotient; -QUrl GetWellknownSupportJob::makeRequestUrl(const HomeserverData& hsData) +QUrl GetWellknownSupportJob::makeRequestUrl(const HomeserverData &hsData) { return BaseJob::makeRequestUrl(hsData, makePath("/.well-known", "/matrix/support")); } diff --git a/Quotient/csapi/support.h b/Quotient/csapi/support.h index 1a52f988d..571ca4f94 100644 --- a/Quotient/csapi/support.h +++ b/Quotient/csapi/support.h @@ -17,12 +17,14 @@ namespace Quotient { //! Note that this endpoint is not necessarily handled by the homeserver. //! It may be served by another webserver, used for discovering support //! information for the homeserver. -class QUOTIENT_API GetWellknownSupportJob : public BaseJob { +class QUOTIENT_API GetWellknownSupportJob : public BaseJob +{ public: // Inner data structures //! A way to contact the server administrator. - struct QUOTIENT_API Contact { + struct QUOTIENT_API Contact + { //! An informal description of what the contact methods //! are used for. //! @@ -60,7 +62,7 @@ class QUOTIENT_API GetWellknownSupportJob : public BaseJob { //! //! This function can be used when a URL for GetWellknownSupportJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData); + static QUrl makeRequestUrl(const HomeserverData &hsData); // Result properties @@ -77,7 +79,8 @@ class QUOTIENT_API GetWellknownSupportJob : public BaseJob { //! At least one of `contacts` or `support_page` is required. QString supportPage() const { return loadFromJson("support_page"_L1); } - struct Response { + struct Response + { //! Ways to contact the server administrator. //! //! At least one of `contacts` or `support_page` is required. @@ -95,11 +98,12 @@ class QUOTIENT_API GetWellknownSupportJob : public BaseJob { template JobT> constexpr inline auto doCollectResponse = - [](JobT* j) -> GetWellknownSupportJob::Response { return { j->contacts(), j->supportPage() }; }; + [](JobT *j) -> GetWellknownSupportJob::Response { return {j->contacts(), j->supportPage()}; }; template <> -struct QUOTIENT_API JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, GetWellknownSupportJob::Contact& result) +struct QUOTIENT_API JsonObjectConverter +{ + static void fillFrom(const QJsonObject &jo, GetWellknownSupportJob::Contact &result) { fillFromJson(jo.value("role"_L1), result.role); fillFromJson(jo.value("matrix_id"_L1), result.matrixId); diff --git a/Quotient/csapi/tags.cpp b/Quotient/csapi/tags.cpp index 45b43d3a4..4025e7f24 100644 --- a/Quotient/csapi/tags.cpp +++ b/Quotient/csapi/tags.cpp @@ -4,34 +4,34 @@ using namespace Quotient; -QUrl GetRoomTagsJob::makeRequestUrl(const HomeserverData& hsData, const QString& userId, - const QString& roomId) +QUrl GetRoomTagsJob::makeRequestUrl(const HomeserverData &hsData, const QString &userId, + const QString &roomId) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/user/", userId, "/rooms/", roomId, "/tags")); } -GetRoomTagsJob::GetRoomTagsJob(const QString& userId, const QString& roomId) +GetRoomTagsJob::GetRoomTagsJob(const QString &userId, const QString &roomId) : BaseJob(HttpVerb::Get, u"GetRoomTagsJob"_s, makePath("/_matrix/client/v3", "/user/", userId, "/rooms/", roomId, "/tags")) {} -SetRoomTagJob::SetRoomTagJob(const QString& userId, const QString& roomId, const QString& tag, - const Tag& data) +SetRoomTagJob::SetRoomTagJob(const QString &userId, const QString &roomId, const QString &tag, + const Tag &data) : BaseJob(HttpVerb::Put, u"SetRoomTagJob"_s, makePath("/_matrix/client/v3", "/user/", userId, "/rooms/", roomId, "/tags/", tag)) { - setRequestData({ toJson(data) }); + setRequestData({toJson(data)}); } -QUrl DeleteRoomTagJob::makeRequestUrl(const HomeserverData& hsData, const QString& userId, - const QString& roomId, const QString& tag) +QUrl DeleteRoomTagJob::makeRequestUrl(const HomeserverData &hsData, const QString &userId, + const QString &roomId, const QString &tag) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/user/", userId, "/rooms/", roomId, "/tags/", tag)); } -DeleteRoomTagJob::DeleteRoomTagJob(const QString& userId, const QString& roomId, const QString& tag) +DeleteRoomTagJob::DeleteRoomTagJob(const QString &userId, const QString &roomId, const QString &tag) : BaseJob(HttpVerb::Delete, u"DeleteRoomTagJob"_s, makePath("/_matrix/client/v3", "/user/", userId, "/rooms/", roomId, "/tags/", tag)) {} diff --git a/Quotient/csapi/tags.h b/Quotient/csapi/tags.h index 7338c99c8..3891f628e 100644 --- a/Quotient/csapi/tags.h +++ b/Quotient/csapi/tags.h @@ -3,7 +3,6 @@ #pragma once #include - #include namespace Quotient { @@ -11,7 +10,8 @@ namespace Quotient { //! \brief List the tags for a room. //! //! List the tags set by a user on a room. -class QUOTIENT_API GetRoomTagsJob : public BaseJob { +class QUOTIENT_API GetRoomTagsJob : public BaseJob +{ public: //! \param userId //! The id of the user to get tags for. The access token must be @@ -19,26 +19,27 @@ class QUOTIENT_API GetRoomTagsJob : public BaseJob { //! //! \param roomId //! The ID of the room to get tags for. - explicit GetRoomTagsJob(const QString& userId, const QString& roomId); + explicit GetRoomTagsJob(const QString &userId, const QString &roomId); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetRoomTagsJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& userId, - const QString& roomId); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &userId, + const QString &roomId); // Result properties QHash tags() const { return loadFromJson>("tags"_L1); } }; -inline auto collectResponse(const GetRoomTagsJob* job) { return job->tags(); } +inline auto collectResponse(const GetRoomTagsJob *job) { return job->tags(); } //! \brief Add a tag to a room. //! //! Add a tag to the room. -class QUOTIENT_API SetRoomTagJob : public BaseJob { +class QUOTIENT_API SetRoomTagJob : public BaseJob +{ public: //! \param userId //! The id of the user to add a tag for. The access token must be @@ -52,14 +53,15 @@ class QUOTIENT_API SetRoomTagJob : public BaseJob { //! //! \param data //! Extra data for the tag, e.g. ordering. - explicit SetRoomTagJob(const QString& userId, const QString& roomId, const QString& tag, - const Tag& data); + explicit SetRoomTagJob(const QString &userId, const QString &roomId, const QString &tag, + const Tag &data); }; //! \brief Remove a tag from the room. //! //! Remove a tag from the room. -class QUOTIENT_API DeleteRoomTagJob : public BaseJob { +class QUOTIENT_API DeleteRoomTagJob : public BaseJob +{ public: //! \param userId //! The id of the user to remove a tag for. The access token must be @@ -70,14 +72,14 @@ class QUOTIENT_API DeleteRoomTagJob : public BaseJob { //! //! \param tag //! The tag to remove. - explicit DeleteRoomTagJob(const QString& userId, const QString& roomId, const QString& tag); + explicit DeleteRoomTagJob(const QString &userId, const QString &roomId, const QString &tag); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for DeleteRoomTagJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& userId, - const QString& roomId, const QString& tag); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &userId, + const QString &roomId, const QString &tag); }; } // namespace Quotient diff --git a/Quotient/csapi/third_party_lookup.cpp b/Quotient/csapi/third_party_lookup.cpp index 1387d8d46..e243f15a6 100644 --- a/Quotient/csapi/third_party_lookup.cpp +++ b/Quotient/csapi/third_party_lookup.cpp @@ -4,7 +4,7 @@ using namespace Quotient; -QUrl GetProtocolsJob::makeRequestUrl(const HomeserverData& hsData) +QUrl GetProtocolsJob::makeRequestUrl(const HomeserverData &hsData) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/thirdparty/protocols")); } @@ -14,94 +14,94 @@ GetProtocolsJob::GetProtocolsJob() makePath("/_matrix/client/v3", "/thirdparty/protocols")) {} -QUrl GetProtocolMetadataJob::makeRequestUrl(const HomeserverData& hsData, const QString& protocol) +QUrl GetProtocolMetadataJob::makeRequestUrl(const HomeserverData &hsData, const QString &protocol) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/thirdparty/protocol/", protocol)); } -GetProtocolMetadataJob::GetProtocolMetadataJob(const QString& protocol) +GetProtocolMetadataJob::GetProtocolMetadataJob(const QString &protocol) : BaseJob(HttpVerb::Get, u"GetProtocolMetadataJob"_s, makePath("/_matrix/client/v3", "/thirdparty/protocol/", protocol)) {} -auto queryToQueryLocationByProtocol(const QString& searchFields) +auto queryToQueryLocationByProtocol(const QString &searchFields) { QUrlQuery _q; addParam(_q, u"searchFields"_s, searchFields); return _q; } -QUrl QueryLocationByProtocolJob::makeRequestUrl(const HomeserverData& hsData, - const QString& protocol, const QString& searchFields) +QUrl QueryLocationByProtocolJob::makeRequestUrl(const HomeserverData &hsData, + const QString &protocol, const QString &searchFields) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/thirdparty/location/", protocol), queryToQueryLocationByProtocol(searchFields)); } -QueryLocationByProtocolJob::QueryLocationByProtocolJob(const QString& protocol, - const QString& searchFields) +QueryLocationByProtocolJob::QueryLocationByProtocolJob(const QString &protocol, + const QString &searchFields) : BaseJob(HttpVerb::Get, u"QueryLocationByProtocolJob"_s, makePath("/_matrix/client/v3", "/thirdparty/location/", protocol), queryToQueryLocationByProtocol(searchFields)) {} -auto queryToQueryUserByProtocol(const QHash& fields) +auto queryToQueryUserByProtocol(const QHash &fields) { QUrlQuery _q; addParam(_q, u"fields"_s, fields); return _q; } -QUrl QueryUserByProtocolJob::makeRequestUrl(const HomeserverData& hsData, const QString& protocol, - const QHash& fields) +QUrl QueryUserByProtocolJob::makeRequestUrl(const HomeserverData &hsData, const QString &protocol, + const QHash &fields) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/thirdparty/user/", protocol), queryToQueryUserByProtocol(fields)); } -QueryUserByProtocolJob::QueryUserByProtocolJob(const QString& protocol, - const QHash& fields) +QueryUserByProtocolJob::QueryUserByProtocolJob(const QString &protocol, + const QHash &fields) : BaseJob(HttpVerb::Get, u"QueryUserByProtocolJob"_s, makePath("/_matrix/client/v3", "/thirdparty/user/", protocol), queryToQueryUserByProtocol(fields)) {} -auto queryToQueryLocationByAlias(const QString& alias) +auto queryToQueryLocationByAlias(const QString &alias) { QUrlQuery _q; addParam(_q, u"alias"_s, alias); return _q; } -QUrl QueryLocationByAliasJob::makeRequestUrl(const HomeserverData& hsData, const QString& alias) +QUrl QueryLocationByAliasJob::makeRequestUrl(const HomeserverData &hsData, const QString &alias) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/thirdparty/location"), queryToQueryLocationByAlias(alias)); } -QueryLocationByAliasJob::QueryLocationByAliasJob(const QString& alias) +QueryLocationByAliasJob::QueryLocationByAliasJob(const QString &alias) : BaseJob(HttpVerb::Get, u"QueryLocationByAliasJob"_s, makePath("/_matrix/client/v3", "/thirdparty/location"), queryToQueryLocationByAlias(alias)) {} -auto queryToQueryUserByID(const QString& userid) +auto queryToQueryUserByID(const QString &userid) { QUrlQuery _q; addParam(_q, u"userid"_s, userid); return _q; } -QUrl QueryUserByIDJob::makeRequestUrl(const HomeserverData& hsData, const QString& userid) +QUrl QueryUserByIDJob::makeRequestUrl(const HomeserverData &hsData, const QString &userid) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/thirdparty/user"), queryToQueryUserByID(userid)); } -QueryUserByIDJob::QueryUserByIDJob(const QString& userid) +QueryUserByIDJob::QueryUserByIDJob(const QString &userid) : BaseJob(HttpVerb::Get, u"QueryUserByIDJob"_s, makePath("/_matrix/client/v3", "/thirdparty/user"), queryToQueryUserByID(userid)) {} diff --git a/Quotient/csapi/third_party_lookup.h b/Quotient/csapi/third_party_lookup.h index 819da2c3e..2cf0b5a02 100644 --- a/Quotient/csapi/third_party_lookup.h +++ b/Quotient/csapi/third_party_lookup.h @@ -3,7 +3,6 @@ #pragma once #include - #include #include #include @@ -15,7 +14,8 @@ namespace Quotient { //! Fetches the overall metadata about protocols supported by the //! homeserver. Includes both the available protocols and all fields //! required for queries against each protocol. -class QUOTIENT_API GetProtocolsJob : public BaseJob { +class QUOTIENT_API GetProtocolsJob : public BaseJob +{ public: explicit GetProtocolsJob(); @@ -23,7 +23,7 @@ class QUOTIENT_API GetProtocolsJob : public BaseJob { //! //! This function can be used when a URL for GetProtocolsJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData); + static QUrl makeRequestUrl(const HomeserverData &hsData); // Result properties @@ -34,22 +34,23 @@ class QUOTIENT_API GetProtocolsJob : public BaseJob { } }; -inline auto collectResponse(const GetProtocolsJob* job) { return job->protocols(); } +inline auto collectResponse(const GetProtocolsJob *job) { return job->protocols(); } //! \brief Retrieve metadata about a specific protocol that the homeserver supports. //! //! Fetches the metadata from the homeserver about a particular third-party protocol. -class QUOTIENT_API GetProtocolMetadataJob : public BaseJob { +class QUOTIENT_API GetProtocolMetadataJob : public BaseJob +{ public: //! \param protocol //! The name of the protocol. - explicit GetProtocolMetadataJob(const QString& protocol); + explicit GetProtocolMetadataJob(const QString &protocol); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetProtocolMetadataJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& protocol); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &protocol); // Result properties @@ -57,7 +58,7 @@ class QUOTIENT_API GetProtocolMetadataJob : public BaseJob { ThirdPartyProtocol data() const { return fromJson(jsonData()); } }; -inline auto collectResponse(const GetProtocolMetadataJob* job) { return job->data(); } +inline auto collectResponse(const GetProtocolMetadataJob *job) { return job->data(); } //! \brief Retrieve Matrix-side portals rooms leading to a third-party location. //! @@ -69,7 +70,8 @@ inline auto collectResponse(const GetProtocolMetadataJob* job) { return job->dat //! object containing the network-specific fields that comprise this //! identifier. It should attempt to canonicalise the identifier as much //! as reasonably possible given the network type. -class QUOTIENT_API QueryLocationByProtocolJob : public BaseJob { +class QUOTIENT_API QueryLocationByProtocolJob : public BaseJob +{ public: //! \param protocol //! The protocol used to communicate to the third-party network. @@ -77,14 +79,14 @@ class QUOTIENT_API QueryLocationByProtocolJob : public BaseJob { //! \param searchFields //! One or more custom fields to help identify the third-party //! location. - explicit QueryLocationByProtocolJob(const QString& protocol, const QString& searchFields = {}); + explicit QueryLocationByProtocolJob(const QString &protocol, const QString &searchFields = {}); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for QueryLocationByProtocolJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& protocol, - const QString& searchFields = {}); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &protocol, + const QString &searchFields = {}); // Result properties @@ -95,28 +97,29 @@ class QUOTIENT_API QueryLocationByProtocolJob : public BaseJob { } }; -inline auto collectResponse(const QueryLocationByProtocolJob* job) { return job->data(); } +inline auto collectResponse(const QueryLocationByProtocolJob *job) { return job->data(); } //! \brief Retrieve the Matrix User ID of a corresponding third-party user. //! //! Retrieve a Matrix User ID linked to a user on the third-party service, given //! a set of user parameters. -class QUOTIENT_API QueryUserByProtocolJob : public BaseJob { +class QUOTIENT_API QueryUserByProtocolJob : public BaseJob +{ public: //! \param protocol //! The name of the protocol. //! //! \param fields //! One or more custom fields that are passed to the AS to help identify the user. - explicit QueryUserByProtocolJob(const QString& protocol, - const QHash& fields = {}); + explicit QueryUserByProtocolJob(const QString &protocol, + const QHash &fields = {}); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for QueryUserByProtocolJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& protocol, - const QHash& fields = {}); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &protocol, + const QHash &fields = {}); // Result properties @@ -124,23 +127,24 @@ class QUOTIENT_API QueryUserByProtocolJob : public BaseJob { QVector data() const { return fromJson>(jsonData()); } }; -inline auto collectResponse(const QueryUserByProtocolJob* job) { return job->data(); } +inline auto collectResponse(const QueryUserByProtocolJob *job) { return job->data(); } //! \brief Reverse-lookup third-party locations given a Matrix room alias. //! //! Retrieve an array of third-party network locations from a Matrix room //! alias. -class QUOTIENT_API QueryLocationByAliasJob : public BaseJob { +class QUOTIENT_API QueryLocationByAliasJob : public BaseJob +{ public: //! \param alias //! The Matrix room alias to look up. - explicit QueryLocationByAliasJob(const QString& alias); + explicit QueryLocationByAliasJob(const QString &alias); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for QueryLocationByAliasJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& alias); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &alias); // Result properties @@ -151,22 +155,23 @@ class QUOTIENT_API QueryLocationByAliasJob : public BaseJob { } }; -inline auto collectResponse(const QueryLocationByAliasJob* job) { return job->data(); } +inline auto collectResponse(const QueryLocationByAliasJob *job) { return job->data(); } //! \brief Reverse-lookup third-party users given a Matrix User ID. //! //! Retrieve an array of third-party users from a Matrix User ID. -class QUOTIENT_API QueryUserByIDJob : public BaseJob { +class QUOTIENT_API QueryUserByIDJob : public BaseJob +{ public: //! \param userid //! The Matrix User ID to look up. - explicit QueryUserByIDJob(const QString& userid); + explicit QueryUserByIDJob(const QString &userid); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for QueryUserByIDJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& userid); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &userid); // Result properties @@ -174,6 +179,6 @@ class QUOTIENT_API QueryUserByIDJob : public BaseJob { QVector data() const { return fromJson>(jsonData()); } }; -inline auto collectResponse(const QueryUserByIDJob* job) { return job->data(); } +inline auto collectResponse(const QueryUserByIDJob *job) { return job->data(); } } // namespace Quotient diff --git a/Quotient/csapi/third_party_membership.cpp b/Quotient/csapi/third_party_membership.cpp index 6cd3ba9fb..3f6e7a05f 100644 --- a/Quotient/csapi/third_party_membership.cpp +++ b/Quotient/csapi/third_party_membership.cpp @@ -4,9 +4,9 @@ using namespace Quotient; -InviteBy3PIDJob::InviteBy3PIDJob(const QString& roomId, const QString& idServer, - const QString& idAccessToken, const QString& medium, - const QString& address) +InviteBy3PIDJob::InviteBy3PIDJob(const QString &roomId, const QString &idServer, + const QString &idAccessToken, const QString &medium, + const QString &address) : BaseJob(HttpVerb::Post, u"InviteBy3PIDJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/invite")) { @@ -15,5 +15,5 @@ InviteBy3PIDJob::InviteBy3PIDJob(const QString& roomId, const QString& idServer, addParam(_dataJson, "id_access_token"_L1, idAccessToken); addParam(_dataJson, "medium"_L1, medium); addParam(_dataJson, "address"_L1, address); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } diff --git a/Quotient/csapi/third_party_membership.h b/Quotient/csapi/third_party_membership.h index 6dc61d3f5..0ad7591d3 100644 --- a/Quotient/csapi/third_party_membership.h +++ b/Quotient/csapi/third_party_membership.h @@ -48,7 +48,8 @@ namespace Quotient { //! //! If a token is requested from the identity server, the homeserver will //! append a `m.room.third_party_invite` event to the room. -class QUOTIENT_API InviteBy3PIDJob : public BaseJob { +class QUOTIENT_API InviteBy3PIDJob : public BaseJob +{ public: //! \param roomId //! The room identifier (not alias) to which to invite the user. @@ -68,9 +69,9 @@ class QUOTIENT_API InviteBy3PIDJob : public BaseJob { //! //! \param address //! The invitee's third-party identifier. - explicit InviteBy3PIDJob(const QString& roomId, const QString& idServer, - const QString& idAccessToken, const QString& medium, - const QString& address); + explicit InviteBy3PIDJob(const QString &roomId, const QString &idServer, + const QString &idAccessToken, const QString &medium, + const QString &address); }; } // namespace Quotient diff --git a/Quotient/csapi/threads_list.cpp b/Quotient/csapi/threads_list.cpp index 65edc5ab4..799092824 100644 --- a/Quotient/csapi/threads_list.cpp +++ b/Quotient/csapi/threads_list.cpp @@ -4,7 +4,7 @@ using namespace Quotient; -auto queryToGetThreadRoots(const QString& include, std::optional limit, const QString& from) +auto queryToGetThreadRoots(const QString &include, std::optional limit, const QString &from) { QUrlQuery _q; addParam(_q, u"include"_s, include); @@ -13,17 +13,17 @@ auto queryToGetThreadRoots(const QString& include, std::optional limit, con return _q; } -QUrl GetThreadRootsJob::makeRequestUrl(const HomeserverData& hsData, const QString& roomId, - const QString& include, std::optional limit, - const QString& from) +QUrl GetThreadRootsJob::makeRequestUrl(const HomeserverData &hsData, const QString &roomId, + const QString &include, std::optional limit, + const QString &from) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v1", "/rooms/", roomId, "/threads"), queryToGetThreadRoots(include, limit, from)); } -GetThreadRootsJob::GetThreadRootsJob(const QString& roomId, const QString& include, - std::optional limit, const QString& from) +GetThreadRootsJob::GetThreadRootsJob(const QString &roomId, const QString &include, + std::optional limit, const QString &from) : BaseJob(HttpVerb::Get, u"GetThreadRootsJob"_s, makePath("/_matrix/client/v1", "/rooms/", roomId, "/threads"), queryToGetThreadRoots(include, limit, from)) diff --git a/Quotient/csapi/threads_list.h b/Quotient/csapi/threads_list.h index 63550a1f0..faf011681 100644 --- a/Quotient/csapi/threads_list.h +++ b/Quotient/csapi/threads_list.h @@ -13,7 +13,8 @@ namespace Quotient { //! //! Optionally, the returned list may be filtered according to whether the requesting //! user has participated in the thread. -class QUOTIENT_API GetThreadRootsJob : public BaseJob { +class QUOTIENT_API GetThreadRootsJob : public BaseJob +{ public: //! \param roomId //! The room ID where the thread roots are located. @@ -36,16 +37,16 @@ class QUOTIENT_API GetThreadRootsJob : public BaseJob { //! A pagination token from a previous result. When not provided, the server starts paginating //! from the most recent event visible to the user (as per history visibility rules; //! topologically). - explicit GetThreadRootsJob(const QString& roomId, const QString& include = {}, - std::optional limit = std::nullopt, const QString& from = {}); + explicit GetThreadRootsJob(const QString &roomId, const QString &include = {}, + std::optional limit = std::nullopt, const QString &from = {}); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for GetThreadRootsJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomId, - const QString& include = {}, std::optional limit = std::nullopt, - const QString& from = {}); + static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &roomId, + const QString &include = {}, std::optional limit = std::nullopt, + const QString &from = {}); // Result properties @@ -62,7 +63,8 @@ class QUOTIENT_API GetThreadRootsJob : public BaseJob { //! no further results. QString nextBatch() const { return loadFromJson("next_batch"_L1); } - struct Response { + struct Response + { //! The thread roots, ordered by the `latest_event` in each event's aggregated children. All //! events returned include bundled //! [aggregations](/client-server-api/#aggregations-of-child-events). @@ -81,6 +83,6 @@ class QUOTIENT_API GetThreadRootsJob : public BaseJob { template JobT> constexpr inline auto doCollectResponse = - [](JobT* j) -> GetThreadRootsJob::Response { return { j->chunk(), j->nextBatch() }; }; + [](JobT *j) -> GetThreadRootsJob::Response { return {j->chunk(), j->nextBatch()}; }; } // namespace Quotient diff --git a/Quotient/csapi/to_device.cpp b/Quotient/csapi/to_device.cpp index 788d4c19c..cd96dcdcd 100644 --- a/Quotient/csapi/to_device.cpp +++ b/Quotient/csapi/to_device.cpp @@ -4,12 +4,12 @@ using namespace Quotient; -SendToDeviceJob::SendToDeviceJob(const QString& eventType, const QString& txnId, - const QHash>& messages) +SendToDeviceJob::SendToDeviceJob(const QString &eventType, const QString &txnId, + const QHash> &messages) : BaseJob(HttpVerb::Put, u"SendToDeviceJob"_s, makePath("/_matrix/client/v3", "/sendToDevice/", eventType, "/", txnId)) { QJsonObject _dataJson; addParam(_dataJson, "messages"_L1, messages); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } diff --git a/Quotient/csapi/to_device.h b/Quotient/csapi/to_device.h index b316f383e..ee5578bcd 100644 --- a/Quotient/csapi/to_device.h +++ b/Quotient/csapi/to_device.h @@ -10,7 +10,8 @@ namespace Quotient { //! //! This endpoint is used to send send-to-device events to a set of //! client devices. -class QUOTIENT_API SendToDeviceJob : public BaseJob { +class QUOTIENT_API SendToDeviceJob : public BaseJob +{ public: //! \param eventType //! The type of event to send. @@ -24,8 +25,8 @@ class QUOTIENT_API SendToDeviceJob : public BaseJob { //! The messages to send. A map from user ID, to a map from //! device ID to message body. The device ID may also be `*`, //! meaning all known devices for the user. - explicit SendToDeviceJob(const QString& eventType, const QString& txnId, - const QHash>& messages); + explicit SendToDeviceJob(const QString &eventType, const QString &txnId, + const QHash> &messages); }; } // namespace Quotient diff --git a/Quotient/csapi/typing.cpp b/Quotient/csapi/typing.cpp index dc93f7a71..116a37885 100644 --- a/Quotient/csapi/typing.cpp +++ b/Quotient/csapi/typing.cpp @@ -4,7 +4,7 @@ using namespace Quotient; -SetTypingJob::SetTypingJob(const QString& userId, const QString& roomId, bool typing, +SetTypingJob::SetTypingJob(const QString &userId, const QString &roomId, bool typing, std::optional timeout) : BaseJob(HttpVerb::Put, u"SetTypingJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/typing/", userId)) @@ -12,5 +12,5 @@ SetTypingJob::SetTypingJob(const QString& userId, const QString& roomId, bool ty QJsonObject _dataJson; addParam(_dataJson, "typing"_L1, typing); addParam(_dataJson, "timeout"_L1, timeout); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); } diff --git a/Quotient/csapi/typing.h b/Quotient/csapi/typing.h index a9f74d31b..f7a9a7672 100644 --- a/Quotient/csapi/typing.h +++ b/Quotient/csapi/typing.h @@ -12,7 +12,8 @@ namespace Quotient { //! milliseconds where N is the value specified in the `timeout` key. //! Alternatively, if `typing` is `false`, it tells the server that the //! user has stopped typing. -class QUOTIENT_API SetTypingJob : public BaseJob { +class QUOTIENT_API SetTypingJob : public BaseJob +{ public: //! \param userId //! The user who has started to type. @@ -26,7 +27,7 @@ class QUOTIENT_API SetTypingJob : public BaseJob { //! //! \param timeout //! The length of time in milliseconds to mark this user as typing. - explicit SetTypingJob(const QString& userId, const QString& roomId, bool typing, + explicit SetTypingJob(const QString &userId, const QString &roomId, bool typing, std::optional timeout = std::nullopt); }; diff --git a/Quotient/csapi/users.cpp b/Quotient/csapi/users.cpp index 9ca256aec..4627262e6 100644 --- a/Quotient/csapi/users.cpp +++ b/Quotient/csapi/users.cpp @@ -4,14 +4,14 @@ using namespace Quotient; -SearchUserDirectoryJob::SearchUserDirectoryJob(const QString& searchTerm, std::optional limit) +SearchUserDirectoryJob::SearchUserDirectoryJob(const QString &searchTerm, std::optional limit) : BaseJob(HttpVerb::Post, u"SearchUserDirectoryJob"_s, makePath("/_matrix/client/v3", "/user_directory/search")) { QJsonObject _dataJson; addParam(_dataJson, "search_term"_L1, searchTerm); addParam(_dataJson, "limit"_L1, limit); - setRequestData({ _dataJson }); + setRequestData({_dataJson}); addExpectedKey(u"results"_s); addExpectedKey(u"limited"_s); } diff --git a/Quotient/csapi/users.h b/Quotient/csapi/users.h index d458928a0..8bf7bb7bd 100644 --- a/Quotient/csapi/users.h +++ b/Quotient/csapi/users.h @@ -18,11 +18,13 @@ namespace Quotient { //! The search is performed case-insensitively on user IDs and display //! names preferably using a collation determined based upon the //! `Accept-Language` header provided in the request, if present. -class QUOTIENT_API SearchUserDirectoryJob : public BaseJob { +class QUOTIENT_API SearchUserDirectoryJob : public BaseJob +{ public: // Inner data structures - struct QUOTIENT_API User { + struct QUOTIENT_API User + { //! The user's matrix user ID. QString userId; @@ -41,7 +43,7 @@ class QUOTIENT_API SearchUserDirectoryJob : public BaseJob { //! //! \param limit //! The maximum number of results to return. Defaults to 10. - explicit SearchUserDirectoryJob(const QString& searchTerm, + explicit SearchUserDirectoryJob(const QString &searchTerm, std::optional limit = std::nullopt); // Result properties @@ -52,7 +54,8 @@ class QUOTIENT_API SearchUserDirectoryJob : public BaseJob { //! Indicates if the result list has been truncated by the limit. bool limited() const { return loadFromJson("limited"_L1); } - struct Response { + struct Response + { //! Ordered by rank and then whether or not profile info is available. QVector results{}; @@ -63,11 +66,12 @@ class QUOTIENT_API SearchUserDirectoryJob : public BaseJob { template JobT> constexpr inline auto doCollectResponse = - [](JobT* j) -> SearchUserDirectoryJob::Response { return { j->results(), j->limited() }; }; + [](JobT *j) -> SearchUserDirectoryJob::Response { return {j->results(), j->limited()}; }; template <> -struct QUOTIENT_API JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, SearchUserDirectoryJob::User& result) +struct QUOTIENT_API JsonObjectConverter +{ + static void fillFrom(const QJsonObject &jo, SearchUserDirectoryJob::User &result) { fillFromJson(jo.value("user_id"_L1), result.userId); fillFromJson(jo.value("display_name"_L1), result.displayName); diff --git a/Quotient/csapi/versions.cpp b/Quotient/csapi/versions.cpp index c8817d57c..6ee1f0f4c 100644 --- a/Quotient/csapi/versions.cpp +++ b/Quotient/csapi/versions.cpp @@ -4,7 +4,7 @@ using namespace Quotient; -QUrl GetVersionsJob::makeRequestUrl(const HomeserverData& hsData) +QUrl GetVersionsJob::makeRequestUrl(const HomeserverData &hsData) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client", "/versions")); } diff --git a/Quotient/csapi/versions.h b/Quotient/csapi/versions.h index 1362927c9..705db298c 100644 --- a/Quotient/csapi/versions.h +++ b/Quotient/csapi/versions.h @@ -30,7 +30,8 @@ namespace Quotient { //! here after they've been released into the spec to give clients a chance //! to upgrade appropriately. Additionally, clients should avoid using //! unstable features in their stable releases. -class QUOTIENT_API GetVersionsJob : public BaseJob { +class QUOTIENT_API GetVersionsJob : public BaseJob +{ public: explicit GetVersionsJob(); @@ -38,7 +39,7 @@ class QUOTIENT_API GetVersionsJob : public BaseJob { //! //! This function can be used when a URL for GetVersionsJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData); + static QUrl makeRequestUrl(const HomeserverData &hsData); // Result properties @@ -53,7 +54,8 @@ class QUOTIENT_API GetVersionsJob : public BaseJob { return loadFromJson>("unstable_features"_L1); } - struct Response { + struct Response + { //! The supported versions. QStringList versions{}; @@ -66,6 +68,6 @@ class QUOTIENT_API GetVersionsJob : public BaseJob { template JobT> constexpr inline auto doCollectResponse = - [](JobT* j) -> GetVersionsJob::Response { return { j->versions(), j->unstableFeatures() }; }; + [](JobT *j) -> GetVersionsJob::Response { return {j->versions(), j->unstableFeatures()}; }; } // namespace Quotient diff --git a/Quotient/csapi/voip.cpp b/Quotient/csapi/voip.cpp index 7fdd914dd..4814e418e 100644 --- a/Quotient/csapi/voip.cpp +++ b/Quotient/csapi/voip.cpp @@ -4,7 +4,7 @@ using namespace Quotient; -QUrl GetTurnServerJob::makeRequestUrl(const HomeserverData& hsData) +QUrl GetTurnServerJob::makeRequestUrl(const HomeserverData &hsData) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/voip/turnServer")); } diff --git a/Quotient/csapi/voip.h b/Quotient/csapi/voip.h index c4eee3b6f..3ef726e1d 100644 --- a/Quotient/csapi/voip.h +++ b/Quotient/csapi/voip.h @@ -10,7 +10,8 @@ namespace Quotient { //! //! This API provides credentials for the client to use when initiating //! calls. -class QUOTIENT_API GetTurnServerJob : public BaseJob { +class QUOTIENT_API GetTurnServerJob : public BaseJob +{ public: explicit GetTurnServerJob(); @@ -18,7 +19,7 @@ class QUOTIENT_API GetTurnServerJob : public BaseJob { //! //! This function can be used when a URL for GetTurnServerJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData); + static QUrl makeRequestUrl(const HomeserverData &hsData); // Result properties @@ -26,6 +27,6 @@ class QUOTIENT_API GetTurnServerJob : public BaseJob { QJsonObject data() const { return fromJson(jsonData()); } }; -inline auto collectResponse(const GetTurnServerJob* job) { return job->data(); } +inline auto collectResponse(const GetTurnServerJob *job) { return job->data(); } } // namespace Quotient diff --git a/Quotient/csapi/wellknown.cpp b/Quotient/csapi/wellknown.cpp index e87bffd28..1d31131da 100644 --- a/Quotient/csapi/wellknown.cpp +++ b/Quotient/csapi/wellknown.cpp @@ -4,7 +4,7 @@ using namespace Quotient; -QUrl GetWellknownJob::makeRequestUrl(const HomeserverData& hsData) +QUrl GetWellknownJob::makeRequestUrl(const HomeserverData &hsData) { return BaseJob::makeRequestUrl(hsData, makePath("/.well-known", "/matrix/client")); } diff --git a/Quotient/csapi/wellknown.h b/Quotient/csapi/wellknown.h index e50dffd89..2fb25cac6 100644 --- a/Quotient/csapi/wellknown.h +++ b/Quotient/csapi/wellknown.h @@ -3,7 +3,6 @@ #pragma once #include - #include namespace Quotient { @@ -18,7 +17,8 @@ namespace Quotient { //! //! Note that this endpoint is not necessarily handled by the homeserver, //! but by another webserver, to be used for discovering the homeserver URL. -class QUOTIENT_API GetWellknownJob : public BaseJob { +class QUOTIENT_API GetWellknownJob : public BaseJob +{ public: explicit GetWellknownJob(); @@ -26,7 +26,7 @@ class QUOTIENT_API GetWellknownJob : public BaseJob { //! //! This function can be used when a URL for GetWellknownJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData); + static QUrl makeRequestUrl(const HomeserverData &hsData); // Result properties @@ -34,6 +34,6 @@ class QUOTIENT_API GetWellknownJob : public BaseJob { DiscoveryInformation data() const { return fromJson(jsonData()); } }; -inline auto collectResponse(const GetWellknownJob* job) { return job->data(); } +inline auto collectResponse(const GetWellknownJob *job) { return job->data(); } } // namespace Quotient diff --git a/Quotient/csapi/whoami.cpp b/Quotient/csapi/whoami.cpp index 5eaac35cf..856c5a5c9 100644 --- a/Quotient/csapi/whoami.cpp +++ b/Quotient/csapi/whoami.cpp @@ -4,7 +4,7 @@ using namespace Quotient; -QUrl GetTokenOwnerJob::makeRequestUrl(const HomeserverData& hsData) +QUrl GetTokenOwnerJob::makeRequestUrl(const HomeserverData &hsData) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/account/whoami")); } diff --git a/Quotient/csapi/whoami.h b/Quotient/csapi/whoami.h index a1f97b188..986e9e6d1 100644 --- a/Quotient/csapi/whoami.h +++ b/Quotient/csapi/whoami.h @@ -16,7 +16,8 @@ namespace Quotient { //! situation, the server should verify that the given `user_id` //! is registered by the appservice, and return it in the response //! body. -class QUOTIENT_API GetTokenOwnerJob : public BaseJob { +class QUOTIENT_API GetTokenOwnerJob : public BaseJob +{ public: explicit GetTokenOwnerJob(); @@ -24,7 +25,7 @@ class QUOTIENT_API GetTokenOwnerJob : public BaseJob { //! //! This function can be used when a URL for GetTokenOwnerJob //! is necessary but the job itself isn't. - static QUrl makeRequestUrl(const HomeserverData& hsData); + static QUrl makeRequestUrl(const HomeserverData &hsData); // Result properties @@ -42,7 +43,8 @@ class QUOTIENT_API GetTokenOwnerJob : public BaseJob { //! user. std::optional isGuest() const { return loadFromJson>("is_guest"_L1); } - struct Response { + struct Response + { //! The user ID that owns the access token. QString userId{}; @@ -60,8 +62,8 @@ class QUOTIENT_API GetTokenOwnerJob : public BaseJob { }; template JobT> -constexpr inline auto doCollectResponse = [](JobT* j) -> GetTokenOwnerJob::Response { - return { j->userId(), j->deviceId(), j->isGuest() }; +constexpr inline auto doCollectResponse = [](JobT *j) -> GetTokenOwnerJob::Response { + return {j->userId(), j->deviceId(), j->isGuest()}; }; } // namespace Quotient From 74d5a2fc0aa76034de692d3a8541d48ca710b61a Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Tue, 10 Jun 2025 19:35:29 +0200 Subject: [PATCH 2/8] Update gtad to version 0.11.0 --- gtad/gtad | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtad/gtad b/gtad/gtad index 4d62000b3..ed85da320 160000 --- a/gtad/gtad +++ b/gtad/gtad @@ -1 +1 @@ -Subproject commit 4d62000b3db86a8eba15a107d915cb477060b85b +Subproject commit ed85da3206ae3a94b07239264385283b249d7191 From 80853f5151dbfc030b781d8cba2329417cfd94c6 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Tue, 10 Jun 2025 19:36:20 +0200 Subject: [PATCH 3/8] Update template files and gtad.yaml to work with Matrix 1.14 --- gtad/gtad.yaml | 4 +++- gtad/operation.h.mustache | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gtad/gtad.yaml b/gtad/gtad.yaml index 40c2eb09a..7bb21b7ee 100644 --- a/gtad/gtad.yaml +++ b/gtad/gtad.yaml @@ -3,7 +3,7 @@ analyzer: # Escaping open braces because GTAD always treats subst keys as regexes, unlike other places '\{\{% boxes/note %}}': '\note' '\{\{% boxes/warning %}}': '\warning' - '\{\{< changed-in v="([^ ]+)" >}}': '[Changed in v$1]' + '\{\{[<%] changed-in v="([^ ]+)" [>%]}}': '[Changed in v$1]' '( +)\{\{% /boxes/[a-z]+ %}}\n': '' # Delete lines with the closing handlebar entirely identifiers: signed: signedData @@ -89,6 +89,7 @@ analyzer: - uri: &Url type: QUrl initializer: QUrl::fromEncoded("{{defaultValue}}"_L1) + - email: *Url - mx-mxc-uri: *Url - mx-user-id: UserId - mx-room-id: RoomId @@ -143,6 +144,7 @@ analyzer: inline: # Inline whatever is used from the identity spec - /identity/definitions/ + - /protocol_instance.yaml$/ # Despite being used in two calls, it's more practical to have those # fields available as getters right from the respective job classes - /public_rooms_response.yaml$/ diff --git a/gtad/operation.h.mustache b/gtad/operation.h.mustache index 44196dddc..49dfd48f9 100644 --- a/gtad/operation.h.mustache +++ b/gtad/operation.h.mustache @@ -97,7 +97,7 @@ constexpr inline auto doCollectResponse = }; {{>closeIgnoreDeprecations}}{{/properties?}}{{/singleValue?}} {{/allProperties?}}{{/normalResponse?}}{{/responses}} - {{#models.model}} + {{#models}}{{#model?}}{{#model}} {{>openIgnoreDeprecations}} template <> struct QUOTIENT_API JsonObjectConverter<{{qualifiedName}}> { @@ -126,7 +126,7 @@ template <> struct QUOTIENT_API JsonObjectConverter<{{qualifiedName}}> { {{/out?}} }; {{>closeIgnoreDeprecations}} - {{/models.model}} + {{/model}}{{/model?}}{{/models}} {{/operations.operation}} } // namespace Quotient From fd72fbe46ddcab4e5b46d055953b8d377749bdfe Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Tue, 10 Jun 2025 20:55:39 +0200 Subject: [PATCH 4/8] Update GTAD to 0.11.1 GTAD 0.11.0 was broken. --- gtad/gtad | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtad/gtad b/gtad/gtad index ed85da320..aa265e2f8 160000 --- a/gtad/gtad +++ b/gtad/gtad @@ -1 +1 @@ -Subproject commit ed85da3206ae3a94b07239264385283b249d7191 +Subproject commit aa265e2f8aa4cfe14439ce35f9ca7ddc74f904a8 From 91c672c2e7cf84d6f5f0cc958fccf875a0f51d4a Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Tue, 10 Jun 2025 21:37:07 +0200 Subject: [PATCH 5/8] Regenerate API files with Matrix 1.14 --- .../{protocol.h => protocol_base.h} | 42 ----- Quotient/csapi/account-data.h | 4 +- Quotient/csapi/create_room.h | 32 +--- Quotient/csapi/definitions/auth_data.h | 2 +- Quotient/csapi/definitions/invite_3pid.h | 47 +++++ Quotient/csapi/definitions/protocol.h | 85 ++++++++++ .../definitions/request_email_validation.h | 4 +- .../definitions/request_msisdn_validation.h | 2 +- Quotient/csapi/joining.h | 8 +- Quotient/csapi/key_backup.cpp | 21 +-- Quotient/csapi/key_backup.h | 160 +++++------------- Quotient/csapi/keys.h | 14 ++ Quotient/csapi/list_public_rooms.h | 4 + Quotient/csapi/login.h | 4 +- Quotient/csapi/pusher.h | 24 ++- Quotient/csapi/redaction.h | 4 +- Quotient/csapi/registration.h | 4 +- Quotient/csapi/report_content.cpp | 24 ++- Quotient/csapi/report_content.h | 77 ++++++++- Quotient/csapi/room_event_by_timestamp.h | 2 +- Quotient/csapi/space_hierarchy.h | 42 ++++- Quotient/csapi/support.h | 8 +- Quotient/csapi/third_party_lookup.cpp | 13 +- Quotient/csapi/third_party_lookup.h | 15 +- Quotient/csapi/third_party_membership.cpp | 11 +- Quotient/csapi/third_party_membership.h | 20 +-- Quotient/csapi/whoami.h | 16 +- 27 files changed, 389 insertions(+), 300 deletions(-) rename Quotient/application-service/definitions/{protocol.h => protocol_base.h} (66%) create mode 100644 Quotient/csapi/definitions/invite_3pid.h create mode 100644 Quotient/csapi/definitions/protocol.h diff --git a/Quotient/application-service/definitions/protocol.h b/Quotient/application-service/definitions/protocol_base.h similarity index 66% rename from Quotient/application-service/definitions/protocol.h rename to Quotient/application-service/definitions/protocol_base.h index 04bf23055..817c6d202 100644 --- a/Quotient/application-service/definitions/protocol.h +++ b/Quotient/application-service/definitions/protocol_base.h @@ -32,41 +32,6 @@ struct JsonObjectConverter } }; -struct QUOTIENT_API ProtocolInstance -{ - //! A human-readable description for the protocol, such as the name. - QString desc; - - //! Preset values for `fields` the client may use to search by. - QJsonObject fields; - - //! A unique identifier across all instances. - QString networkId; - - //! An optional content URI representing the protocol. Overrides the one provided - //! at the higher level Protocol object. - QString icon{}; -}; - -template <> -struct JsonObjectConverter -{ - static void dumpTo(QJsonObject &jo, const ProtocolInstance &pod) - { - addParam(jo, "desc"_L1, pod.desc); - addParam(jo, "fields"_L1, pod.fields); - addParam(jo, "network_id"_L1, pod.networkId); - addParam(jo, "icon"_L1, pod.icon); - } - static void fillFrom(const QJsonObject &jo, ProtocolInstance &pod) - { - fillFromJson(jo.value("desc"_L1), pod.desc); - fillFromJson(jo.value("fields"_L1), pod.fields); - fillFromJson(jo.value("network_id"_L1), pod.networkId); - fillFromJson(jo.value("icon"_L1), pod.icon); - } -}; - struct QUOTIENT_API ThirdPartyProtocol { //! Fields which may be used to identify a third-party user. These should be @@ -90,11 +55,6 @@ struct QUOTIENT_API ThirdPartyProtocol //! //! May be an empty object if no fields are defined. QHash fieldTypes; - - //! A list of objects representing independent instances of configuration. - //! For example, multiple networks on IRC if multiple are provided by the - //! same application service. - QVector instances; }; template <> @@ -106,7 +66,6 @@ struct JsonObjectConverter addParam(jo, "location_fields"_L1, pod.locationFields); addParam(jo, "icon"_L1, pod.icon); addParam(jo, "field_types"_L1, pod.fieldTypes); - addParam(jo, "instances"_L1, pod.instances); } static void fillFrom(const QJsonObject &jo, ThirdPartyProtocol &pod) { @@ -114,7 +73,6 @@ struct JsonObjectConverter fillFromJson(jo.value("location_fields"_L1), pod.locationFields); fillFromJson(jo.value("icon"_L1), pod.icon); fillFromJson(jo.value("field_types"_L1), pod.fieldTypes); - fillFromJson(jo.value("instances"_L1), pod.instances); } }; diff --git a/Quotient/csapi/account-data.h b/Quotient/csapi/account-data.h index 0b34bcf1f..d427b29c5 100644 --- a/Quotient/csapi/account-data.h +++ b/Quotient/csapi/account-data.h @@ -11,7 +11,7 @@ namespace Quotient { //! Set some account data for the client. This config is only visible to the user //! that set the account data. The config will be available to clients through the //! top-level `account_data` field in the homeserver response to -//! [/sync](#get_matrixclientv3sync). +//! [/sync](/client-server-api/#get_matrixclientv3sync). class QUOTIENT_API SetAccountDataJob : public BaseJob { public: @@ -64,7 +64,7 @@ inline auto collectResponse(const GetAccountDataJob *job) { return job->data(); //! //! Set some account data for the client on a given room. This config is only //! visible to the user that set the account data. The config will be delivered to -//! clients in the per-room entries via [/sync](#get_matrixclientv3sync). +//! clients in the per-room entries via [/sync](/client-server-api/#get_matrixclientv3sync). class QUOTIENT_API SetAccountDataPerRoomJob : public BaseJob { public: diff --git a/Quotient/csapi/create_room.h b/Quotient/csapi/create_room.h index ccd22ece6..2626ddd3e 100644 --- a/Quotient/csapi/create_room.h +++ b/Quotient/csapi/create_room.h @@ -2,6 +2,7 @@ #pragma once +#include #include namespace Quotient { @@ -55,25 +56,6 @@ class QUOTIENT_API CreateRoomJob : public BaseJob public: // Inner data structures - struct QUOTIENT_API Invite3pid - { - //! The hostname+port of the identity server which should be used for third-party identifier - //! lookups. - QString idServer; - - //! An access token previously registered with the identity server. Servers - //! can treat this as optional to distinguish between r0.5-compatible clients - //! and this specification version. - QString idAccessToken; - - //! The kind of address being passed in the address field, for example `email` - //! (see [the list of recognised values](/appendices/#3pid-types)). - QString medium; - - //! The invitee's third-party identifier. - QString address; - }; - struct QUOTIENT_API StateEvent { //! The type of event to send. @@ -185,18 +167,6 @@ class QUOTIENT_API CreateRoomJob : public BaseJob inline auto collectResponse(const CreateRoomJob *job) { return job->roomId(); } -template <> -struct QUOTIENT_API JsonObjectConverter -{ - static void dumpTo(QJsonObject &jo, const CreateRoomJob::Invite3pid &pod) - { - addParam(jo, "id_server"_L1, pod.idServer); - addParam(jo, "id_access_token"_L1, pod.idAccessToken); - addParam(jo, "medium"_L1, pod.medium); - addParam(jo, "address"_L1, pod.address); - } -}; - template <> struct QUOTIENT_API JsonObjectConverter { diff --git a/Quotient/csapi/definitions/auth_data.h b/Quotient/csapi/definitions/auth_data.h index b8b118b1f..62bb9e9c7 100644 --- a/Quotient/csapi/definitions/auth_data.h +++ b/Quotient/csapi/definitions/auth_data.h @@ -11,7 +11,7 @@ struct QUOTIENT_API AuthenticationData //! The authentication type that the client is attempting to complete. //! May be omitted if `session` is given, and the client is reissuing a //! request which it believes has been completed out-of-band (for example, - //! via the [fallback mechanism](#fallback)). + //! via the [fallback mechanism](/client-server-api/#fallback)). QString type{}; //! The value of the session key given by the homeserver. diff --git a/Quotient/csapi/definitions/invite_3pid.h b/Quotient/csapi/definitions/invite_3pid.h new file mode 100644 index 000000000..f43bbf310 --- /dev/null +++ b/Quotient/csapi/definitions/invite_3pid.h @@ -0,0 +1,47 @@ +// THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + +#pragma once + +#include + +namespace Quotient { + +struct QUOTIENT_API Invite3pid +{ + //! The hostname+port of the identity server which should be used for third-party identifier + //! lookups. + QString idServer; + + //! An access token previously registered with the identity server. Servers + //! can treat this as optional to distinguish between r0.5-compatible clients + //! and this specification version. + QString idAccessToken; + + //! The kind of address being passed in the address field, for example `email` + //! (see [the list of recognised values](/appendices/#3pid-types)). + QString medium; + + //! The invitee's third-party identifier. + QString address; +}; + +template <> +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const Invite3pid &pod) + { + addParam(jo, "id_server"_L1, pod.idServer); + addParam(jo, "id_access_token"_L1, pod.idAccessToken); + addParam(jo, "medium"_L1, pod.medium); + addParam(jo, "address"_L1, pod.address); + } + static void fillFrom(const QJsonObject &jo, Invite3pid &pod) + { + fillFromJson(jo.value("id_server"_L1), pod.idServer); + fillFromJson(jo.value("id_access_token"_L1), pod.idAccessToken); + fillFromJson(jo.value("medium"_L1), pod.medium); + fillFromJson(jo.value("address"_L1), pod.address); + } +}; + +} // namespace Quotient diff --git a/Quotient/csapi/definitions/protocol.h b/Quotient/csapi/definitions/protocol.h new file mode 100644 index 000000000..4b4c547cc --- /dev/null +++ b/Quotient/csapi/definitions/protocol.h @@ -0,0 +1,85 @@ +// THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + +#pragma once + +#include +#include + +namespace Quotient { + +struct QUOTIENT_API ProtocolInstance +{ + //! A human-readable description for the protocol, such as the name. + QString desc; + + //! Preset values for `fields` the client may use to search by. + QJsonObject fields; + + //! A unique identifier across all instances. + QString networkId; + + //! An optional content URI representing the protocol. Overrides the one provided + //! at the higher level Protocol object. + QString icon{}; + + //! A unique identifier for this instance on the homeserver. This field is added + //! to the response of [`GET + //! /_matrix/app/v1/thirdparty/protocol/{protocol}`](/application-service-api/#get_matrixappv1thirdpartyprotocolprotocol) + //! by the homeserver. + //! + //! This is the identifier to use as the `third_party_instance_id` in a request to + //! [`POST /_matrix/client/v3/publicRooms`](/client-server-api/#post_matrixclientv3publicrooms). + QString instanceId{}; +}; + +template <> +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const ProtocolInstance &pod) + { + addParam(jo, "desc"_L1, pod.desc); + addParam(jo, "fields"_L1, pod.fields); + addParam(jo, "network_id"_L1, pod.networkId); + addParam(jo, "icon"_L1, pod.icon); + addParam(jo, "instance_id"_L1, pod.instanceId); + } + static void fillFrom(const QJsonObject &jo, ProtocolInstance &pod) + { + fillFromJson(jo.value("desc"_L1), pod.desc); + fillFromJson(jo.value("fields"_L1), pod.fields); + fillFromJson(jo.value("network_id"_L1), pod.networkId); + fillFromJson(jo.value("icon"_L1), pod.icon); + fillFromJson(jo.value("instance_id"_L1), pod.instanceId); + } +}; + +struct QUOTIENT_API Protocol : ThirdPartyProtocol +{ + //! A list of objects representing independent instances of configuration. + //! For example, multiple networks on IRC if multiple are provided by the + //! same application service. + //! + //! The instances are modified by the homeserver from the response of + //! [`GET + //! /_matrix/app/v1/thirdparty/protocol/{protocol}`](/application-service-api/#get_matrixappv1thirdpartyprotocolprotocol) + //! to include an `instance_id` to serve as a unique identifier for each + //! instance on the homeserver. + QVector instances{}; +}; + +template <> +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const Protocol &pod) + { + fillJson(jo, pod); + addParam(jo, "instances"_L1, pod.instances); + } + static void fillFrom(const QJsonObject &jo, Protocol &pod) + { + fillFromJson(jo, pod); + fillFromJson(jo.value("instances"_L1), pod.instances); + } +}; + +} // namespace Quotient diff --git a/Quotient/csapi/definitions/request_email_validation.h b/Quotient/csapi/definitions/request_email_validation.h index d2255043b..9feb4a04f 100644 --- a/Quotient/csapi/definitions/request_email_validation.h +++ b/Quotient/csapi/definitions/request_email_validation.h @@ -15,7 +15,7 @@ struct QUOTIENT_API EmailValidationData QString clientSecret; //! The email address to validate. - QString email; + QUrl email; //! The server will only send an email if the `send_attempt` //! is a number greater than the most recent one which it has seen, @@ -30,7 +30,7 @@ struct QUOTIENT_API EmailValidationData //! Optional. When the validation is completed, the identity server will //! redirect the user to this URL. This option is ignored when submitting //! 3PID validation information through a POST request. - QString nextLink{}; + QUrl nextLink{}; //! The hostname of the identity server to communicate with. May optionally //! include a port. This parameter is ignored when the homeserver handles diff --git a/Quotient/csapi/definitions/request_msisdn_validation.h b/Quotient/csapi/definitions/request_msisdn_validation.h index 798dbb912..d4cd34794 100644 --- a/Quotient/csapi/definitions/request_msisdn_validation.h +++ b/Quotient/csapi/definitions/request_msisdn_validation.h @@ -33,7 +33,7 @@ struct QUOTIENT_API MsisdnValidationData //! Optional. When the validation is completed, the identity server will //! redirect the user to this URL. This option is ignored when submitting //! 3PID validation information through a POST request. - QString nextLink{}; + QUrl nextLink{}; //! The hostname of the identity server to communicate with. May optionally //! include a port. This parameter is ignored when the homeserver handles diff --git a/Quotient/csapi/joining.h b/Quotient/csapi/joining.h index f0cdbfa66..d017ca51d 100644 --- a/Quotient/csapi/joining.h +++ b/Quotient/csapi/joining.h @@ -7,12 +7,12 @@ namespace Quotient { -//! \brief Start the requesting user participating in a particular room. +//! \brief Join the requesting user to a particular room. //! //! *Note that this API requires a room ID, not alias.* //! `/join/{roomIdOrAlias}` *exists if you have a room alias.* //! -//! This API starts a user participating in a particular room, if that user +//! This API starts a user's participation in a particular room, if that user //! is allowed to participate in that room. After this call, the client is //! allowed to see all current state events in the room, and all subsequent //! events associated with the room until the user leaves the room. @@ -46,11 +46,11 @@ class QUOTIENT_API JoinRoomByIdJob : public BaseJob inline auto collectResponse(const JoinRoomByIdJob *job) { return job->roomId(); } -//! \brief Start the requesting user participating in a particular room. +//! \brief Join the requesting user to a particular room. //! //! *Note that this API takes either a room ID or alias, unlike* `/rooms/{roomId}/join`. //! -//! This API starts a user participating in a particular room, if that user +//! This API starts a user's participation in a particular room, if that user //! is allowed to participate in that room. After this call, the client is //! allowed to see all current state events in the room, and all subsequent //! events associated with the room until the user leaves the room. diff --git a/Quotient/csapi/key_backup.cpp b/Quotient/csapi/key_backup.cpp index 676327664..f3a8d4312 100644 --- a/Quotient/csapi/key_backup.cpp +++ b/Quotient/csapi/key_backup.cpp @@ -84,8 +84,6 @@ PutRoomKeyBySessionIdJob::PutRoomKeyBySessionIdJob(const QString &roomId, const queryToPutRoomKeyBySessionId(version)) { setRequestData({toJson(data)}); - addExpectedKey(u"etag"_s); - addExpectedKey(u"count"_s); } auto queryToGetRoomKeyBySessionId(const QString &version) @@ -133,10 +131,7 @@ DeleteRoomKeyBySessionIdJob::DeleteRoomKeyBySessionIdJob(const QString &roomId, : BaseJob(HttpVerb::Delete, u"DeleteRoomKeyBySessionIdJob"_s, makePath("/_matrix/client/v3", "/room_keys/keys/", roomId, "/", sessionId), queryToDeleteRoomKeyBySessionId(version)) -{ - addExpectedKey(u"etag"_s); - addExpectedKey(u"count"_s); -} +{} auto queryToPutRoomKeysByRoomId(const QString &version) { @@ -152,8 +147,6 @@ PutRoomKeysByRoomIdJob::PutRoomKeysByRoomIdJob(const QString &roomId, const QStr queryToPutRoomKeysByRoomId(version)) { setRequestData({toJson(backupData)}); - addExpectedKey(u"etag"_s); - addExpectedKey(u"count"_s); } auto queryToGetRoomKeysByRoomId(const QString &version) @@ -196,10 +189,7 @@ DeleteRoomKeysByRoomIdJob::DeleteRoomKeysByRoomIdJob(const QString &roomId, cons : BaseJob(HttpVerb::Delete, u"DeleteRoomKeysByRoomIdJob"_s, makePath("/_matrix/client/v3", "/room_keys/keys/", roomId), queryToDeleteRoomKeysByRoomId(version)) -{ - addExpectedKey(u"etag"_s); - addExpectedKey(u"count"_s); -} +{} auto queryToPutRoomKeys(const QString &version) { @@ -215,8 +205,6 @@ PutRoomKeysJob::PutRoomKeysJob(const QString &version, const QHash +struct JsonObjectConverter +{ + static void dumpTo(QJsonObject &jo, const RoomKeysUpdateResponse &pod) + { + addParam(jo, "etag"_L1, pod.etag); + addParam(jo, "count"_L1, pod.count); + } + static void fillFrom(const QJsonObject &jo, RoomKeysUpdateResponse &pod) + { + fillFromJson(jo.value("etag"_L1), pod.etag); + fillFromJson(jo.value("count"_L1), pod.count); + } +}; + //! \brief Create a new backup. //! //! Creates a new backup. @@ -239,27 +267,11 @@ class QUOTIENT_API PutRoomKeyBySessionIdJob : public BaseJob // Result properties - //! The new etag value representing stored keys in the backup. - //! See `GET /room_keys/version/{version}` for more details. - QString etag() const { return loadFromJson("etag"_L1); } - - //! The number of keys stored in the backup - int count() const { return loadFromJson("count"_L1); } - - struct Response - { - //! The new etag value representing stored keys in the backup. - //! See `GET /room_keys/version/{version}` for more details. - QString etag{}; - - //! The number of keys stored in the backup - int count{}; - }; + //! The update succeeded. + RoomKeysUpdateResponse data() const { return fromJson(jsonData()); } }; -template JobT> -constexpr inline auto doCollectResponse = - [](JobT *j) -> PutRoomKeyBySessionIdJob::Response { return {j->etag(), j->count()}; }; +inline auto collectResponse(const PutRoomKeyBySessionIdJob *job) { return job->data(); } //! \brief Retrieve a key from the backup. //! @@ -319,27 +331,11 @@ class QUOTIENT_API DeleteRoomKeyBySessionIdJob : public BaseJob // Result properties - //! The new etag value representing stored keys in the backup. - //! See `GET /room_keys/version/{version}` for more details. - QString etag() const { return loadFromJson("etag"_L1); } - - //! The number of keys stored in the backup - int count() const { return loadFromJson("count"_L1); } - - struct Response - { - //! The new etag value representing stored keys in the backup. - //! See `GET /room_keys/version/{version}` for more details. - QString etag{}; - - //! The number of keys stored in the backup - int count{}; - }; + //! The update succeeded + RoomKeysUpdateResponse data() const { return fromJson(jsonData()); } }; -template JobT> -constexpr inline auto doCollectResponse = - [](JobT *j) -> DeleteRoomKeyBySessionIdJob::Response { return {j->etag(), j->count()}; }; +inline auto collectResponse(const DeleteRoomKeyBySessionIdJob *job) { return job->data(); } //! \brief Store several keys in the backup for a given room. //! @@ -360,27 +356,11 @@ class QUOTIENT_API PutRoomKeysByRoomIdJob : public BaseJob // Result properties - //! The new etag value representing stored keys in the backup. - //! See `GET /room_keys/version/{version}` for more details. - QString etag() const { return loadFromJson("etag"_L1); } - - //! The number of keys stored in the backup - int count() const { return loadFromJson("count"_L1); } - - struct Response - { - //! The new etag value representing stored keys in the backup. - //! See `GET /room_keys/version/{version}` for more details. - QString etag{}; - - //! The number of keys stored in the backup - int count{}; - }; + //! The update succeeded + RoomKeysUpdateResponse data() const { return fromJson(jsonData()); } }; -template JobT> -constexpr inline auto doCollectResponse = - [](JobT *j) -> PutRoomKeysByRoomIdJob::Response { return {j->etag(), j->count()}; }; +inline auto collectResponse(const PutRoomKeysByRoomIdJob *job) { return job->data(); } //! \brief Retrieve the keys from the backup for a given room. //! @@ -433,27 +413,11 @@ class QUOTIENT_API DeleteRoomKeysByRoomIdJob : public BaseJob // Result properties - //! The new etag value representing stored keys in the backup. - //! See `GET /room_keys/version/{version}` for more details. - QString etag() const { return loadFromJson("etag"_L1); } - - //! The number of keys stored in the backup - int count() const { return loadFromJson("count"_L1); } - - struct Response - { - //! The new etag value representing stored keys in the backup. - //! See `GET /room_keys/version/{version}` for more details. - QString etag{}; - - //! The number of keys stored in the backup - int count{}; - }; + //! The update succeeded + RoomKeysUpdateResponse data() const { return fromJson(jsonData()); } }; -template JobT> -constexpr inline auto doCollectResponse = - [](JobT *j) -> DeleteRoomKeysByRoomIdJob::Response { return {j->etag(), j->count()}; }; +inline auto collectResponse(const DeleteRoomKeysByRoomIdJob *job) { return job->data(); } //! \brief Store several keys in the backup. //! @@ -470,27 +434,11 @@ class QUOTIENT_API PutRoomKeysJob : public BaseJob // Result properties - //! The new etag value representing stored keys in the backup. - //! See `GET /room_keys/version/{version}` for more details. - QString etag() const { return loadFromJson("etag"_L1); } - - //! The number of keys stored in the backup - int count() const { return loadFromJson("count"_L1); } - - struct Response - { - //! The new etag value representing stored keys in the backup. - //! See `GET /room_keys/version/{version}` for more details. - QString etag{}; - - //! The number of keys stored in the backup - int count{}; - }; + //! The update succeeded + RoomKeysUpdateResponse data() const { return fromJson(jsonData()); } }; -template JobT> -constexpr inline auto doCollectResponse = - [](JobT *j) -> PutRoomKeysJob::Response { return {j->etag(), j->count()}; }; +inline auto collectResponse(const PutRoomKeysJob *job) { return job->data(); } //! \brief Retrieve the keys from the backup. //! @@ -537,26 +485,10 @@ class QUOTIENT_API DeleteRoomKeysJob : public BaseJob // Result properties - //! The new etag value representing stored keys in the backup. - //! See `GET /room_keys/version/{version}` for more details. - QString etag() const { return loadFromJson("etag"_L1); } - - //! The number of keys stored in the backup - int count() const { return loadFromJson("count"_L1); } - - struct Response - { - //! The new etag value representing stored keys in the backup. - //! See `GET /room_keys/version/{version}` for more details. - QString etag{}; - - //! The number of keys stored in the backup - int count{}; - }; + //! The update succeeded + RoomKeysUpdateResponse data() const { return fromJson(jsonData()); } }; -template JobT> -constexpr inline auto doCollectResponse = - [](JobT *j) -> DeleteRoomKeysJob::Response { return {j->etag(), j->count()}; }; +inline auto collectResponse(const DeleteRoomKeysJob *job) { return job->data(); } } // namespace Quotient diff --git a/Quotient/csapi/keys.h b/Quotient/csapi/keys.h index 3658bd7fe..58e71311d 100644 --- a/Quotient/csapi/keys.h +++ b/Quotient/csapi/keys.h @@ -220,6 +220,20 @@ struct QUOTIENT_API JsonObjectConverter //! \brief Claim one-time encryption keys. //! //! Claims one-time keys for use in pre-key messages. +//! +//! The request contains the user ID, device ID and algorithm name of the +//! keys that are required. If a key matching these requirements can be +//! found, the response contains it. The returned key is a one-time key +//! if one is available, and otherwise a fallback key. +//! +//! One-time keys are given out in the order that they were uploaded via +//! [/keys/upload](/client-server-api/#post_matrixclientv3keysupload). (All +//! keys uploaded within a given call to `/keys/upload` are considered +//! equivalent in this regard; no ordering is specified within them.) +//! +//! Servers must ensure that each one-time key is returned at most once, +//! so when a key has been returned, no other request will ever return +//! the same key. class QUOTIENT_API ClaimKeysJob : public BaseJob { public: diff --git a/Quotient/csapi/list_public_rooms.h b/Quotient/csapi/list_public_rooms.h index be1774578..90ef07064 100644 --- a/Quotient/csapi/list_public_rooms.h +++ b/Quotient/csapi/list_public_rooms.h @@ -186,6 +186,10 @@ class QUOTIENT_API QueryPublicRoomsJob : public BaseJob //! \param thirdPartyInstanceId //! The specific third-party network/protocol to request from the //! homeserver. Can only be used if `include_all_networks` is false. + //! + //! This is the `instance_id` of a `Protocol Instance` returned by + //! [`GET + //! /_matrix/client/v3/thirdparty/protocols`](/client-server-api/#get_matrixclientv3thirdpartyprotocols). explicit QueryPublicRoomsJob(const QString &server = {}, std::optional limit = std::nullopt, const QString &since = {}, const std::optional &filter = std::nullopt, diff --git a/Quotient/csapi/login.h b/Quotient/csapi/login.h index fde38dcf5..23394da99 100644 --- a/Quotient/csapi/login.h +++ b/Quotient/csapi/login.h @@ -118,7 +118,7 @@ class QUOTIENT_API LoginJob : public BaseJob // Result properties //! The fully-qualified Matrix ID for the account. - QString userId() const { return loadFromJson("user_id"_L1); } + UserId userId() const { return loadFromJson("user_id"_L1); } //! An access token for the account. //! This access token can then be used to authorize other requests. @@ -156,7 +156,7 @@ class QUOTIENT_API LoginJob : public BaseJob struct Response { //! The fully-qualified Matrix ID for the account. - QString userId{}; + UserId userId{}; //! An access token for the account. //! This access token can then be used to authorize other requests. diff --git a/Quotient/csapi/pusher.h b/Quotient/csapi/pusher.h index 3cae75956..9a76357ca 100644 --- a/Quotient/csapi/pusher.h +++ b/Quotient/csapi/pusher.h @@ -123,13 +123,17 @@ class QUOTIENT_API PostPusherJob : public BaseJob // Inner data structures //! Required if `kind` is not `null`. A dictionary of information - //! for the pusher implementation itself. If `kind` is `http`, - //! this should contain `url` which is the URL to use to send - //! notifications to. + //! for the pusher implementation itself. + //! + //! If `kind` is `http`, this MUST contain `url` which is the URL + //! to use for sending notifications. Clients MAY use this object + //! to pass custom data to their push gateway. Servers MUST forward + //! the entire content including `format` and any custom keys but excluding `url` + //! when calling [`/_matrix/push/v1/notify`](/push-gateway-api/#post_matrixpushv1notify). struct QUOTIENT_API PusherData { - //! Required if `kind` is `http`. The URL to use to send - //! notifications to. MUST be an HTTPS URL with a path of + //! Required if `kind` is `http`. The URL to use for sending + //! notifications. MUST be an HTTPS URL with a path of //! `/_matrix/push/v1/notify`. QUrl url{}; @@ -185,9 +189,13 @@ class QUOTIENT_API PostPusherJob : public BaseJob //! //! \param data //! Required if `kind` is not `null`. A dictionary of information - //! for the pusher implementation itself. If `kind` is `http`, - //! this should contain `url` which is the URL to use to send - //! notifications to. + //! for the pusher implementation itself. + //! + //! If `kind` is `http`, this MUST contain `url` which is the URL + //! to use for sending notifications. Clients MAY use this object + //! to pass custom data to their push gateway. Servers MUST forward + //! the entire content including `format` and any custom keys but excluding `url` + //! when calling [`/_matrix/push/v1/notify`](/push-gateway-api/#post_matrixpushv1notify). //! //! \param append //! If true, the homeserver should add another pusher with the diff --git a/Quotient/csapi/redaction.h b/Quotient/csapi/redaction.h index fa09a47de..2ee0b64e8 100644 --- a/Quotient/csapi/redaction.h +++ b/Quotient/csapi/redaction.h @@ -15,8 +15,8 @@ namespace Quotient { //! //! Any user with a power level greater than or equal to the `m.room.redaction` //! event power level may send redaction events in the room. If the user's power -//! level greater is also greater than or equal to the `redact` power level -//! of the room, the user may redact events sent by other users. +//! level is also greater than or equal to the `redact` power level of the room, +//! the user may redact events sent by other users. //! //! Server administrators may redact events sent by users on their server. class QUOTIENT_API RedactEventJob : public BaseJob diff --git a/Quotient/csapi/registration.h b/Quotient/csapi/registration.h index bf5b8e18a..43ab00d5d 100644 --- a/Quotient/csapi/registration.h +++ b/Quotient/csapi/registration.h @@ -103,7 +103,7 @@ class QUOTIENT_API RegisterJob : public BaseJob //! //! Any user ID returned by this API must conform to the grammar given in the //! [Matrix specification](/appendices/#user-identifiers). - QString userId() const { return loadFromJson("user_id"_L1); } + UserId userId() const { return loadFromJson("user_id"_L1); } //! An access token for the account. //! This access token can then be used to authorize other requests. @@ -141,7 +141,7 @@ class QUOTIENT_API RegisterJob : public BaseJob //! //! Any user ID returned by this API must conform to the grammar given in the //! [Matrix specification](/appendices/#user-identifiers). - QString userId{}; + UserId userId{}; //! An access token for the account. //! This access token can then be used to authorize other requests. diff --git a/Quotient/csapi/report_content.cpp b/Quotient/csapi/report_content.cpp index 29c3ab7ad..ce398586f 100644 --- a/Quotient/csapi/report_content.cpp +++ b/Quotient/csapi/report_content.cpp @@ -4,9 +4,18 @@ using namespace Quotient; -ReportContentJob::ReportContentJob(const QString &roomId, const QString &eventId, - std::optional score, const QString &reason) - : BaseJob(HttpVerb::Post, u"ReportContentJob"_s, +ReportRoomJob::ReportRoomJob(const QString &roomId, const QString &reason) + : BaseJob(HttpVerb::Post, u"ReportRoomJob"_s, + makePath("/_matrix/client/v3", "/rooms/", roomId, "/report")) +{ + QJsonObject _dataJson; + addParam(_dataJson, "reason"_L1, reason); + setRequestData({_dataJson}); +} + +ReportEventJob::ReportEventJob(const QString &roomId, const QString &eventId, + std::optional score, const QString &reason) + : BaseJob(HttpVerb::Post, u"ReportEventJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/report/", eventId)) { QJsonObject _dataJson; @@ -14,3 +23,12 @@ ReportContentJob::ReportContentJob(const QString &roomId, const QString &eventId addParam(_dataJson, "reason"_L1, reason); setRequestData({_dataJson}); } + +ReportUserJob::ReportUserJob(const UserId &userId, const QString &reason) + : BaseJob(HttpVerb::Post, u"ReportUserJob"_s, + makePath("/_matrix/client/v3", "/users/", userId, "/report")) +{ + QJsonObject _dataJson; + addParam(_dataJson, "reason"_L1, reason); + setRequestData({_dataJson}); +} diff --git a/Quotient/csapi/report_content.h b/Quotient/csapi/report_content.h index f5851aca3..de03f54a7 100644 --- a/Quotient/csapi/report_content.h +++ b/Quotient/csapi/report_content.h @@ -6,18 +6,41 @@ namespace Quotient { +//! \brief Report a room as inappropriate. +//! +//! Reports a room as inappropriate to the server, which may then notify +//! the appropriate people. How such information is delivered is left up to +//! implementations. The caller is not required to be joined to the room to +//! report it. +class QUOTIENT_API ReportRoomJob : public BaseJob +{ +public: + //! \param roomId + //! The room being reported. + //! + //! \param reason + //! The reason the room is being reported. May be blank. + explicit ReportRoomJob(const QString &roomId, const QString &reason); + + // Result properties + + //! The room has been reported successfully. + QJsonObject data() const { return fromJson(jsonData()); } +}; + +inline auto collectResponse(const ReportRoomJob *job) { return job->data(); } + //! \brief Report an event in a joined room as inappropriate. //! //! Reports an event as inappropriate to the server, which may then notify //! the appropriate people. The caller must be joined to the room to report //! it. //! -//! It might be possible for clients to deduce whether an event exists by -//! timing the response, as only a report for an event that does exist -//! will require the homeserver to check whether a user is joined to -//! the room. To combat this, homeserver implementations should add -//! a random delay when generating a response. -class QUOTIENT_API ReportContentJob : public BaseJob +//! Furthermore, it might be possible for clients to deduce whether a reported +//! event exists by timing the response. This is because only a report for an +//! existing event will require the homeserver to do further processing. To +//! combat this, homeservers MAY add a random delay when generating a response. +class QUOTIENT_API ReportEventJob : public BaseJob { public: //! \param roomId @@ -31,9 +54,45 @@ class QUOTIENT_API ReportContentJob : public BaseJob //! and 0 is inoffensive. //! //! \param reason - //! The reason the content is being reported. May be blank. - explicit ReportContentJob(const QString &roomId, const QString &eventId, - std::optional score = std::nullopt, const QString &reason = {}); + //! The reason the content is being reported. + explicit ReportEventJob(const QString &roomId, const QString &eventId, + std::optional score = std::nullopt, const QString &reason = {}); +}; + +//! \brief Report a user as inappropriate. +//! +//! Reports a user as inappropriate to the server, which may then notify +//! the appropriate people. How such information is delivered is left up to +//! implementations. The caller is not required to be joined to any rooms +//! that the reported user is joined to. +//! +//! Clients may wish to [ignore](#ignoring-users) users after reporting them. +//! +//! Clients could infer whether a reported user exists based on the 404 response. +//! Homeservers that wish to conceal this information MAY return 200 responses +//! regardless of the existence of the reported user. +//! +//! Furthermore, it might be possible for clients to deduce whether a reported +//! user exists by timing the response. This is because only a report for an +//! existing user will require the homeserver to do further processing. To +//! combat this, homeservers MAY add a random delay when generating a response. +class QUOTIENT_API ReportUserJob : public BaseJob +{ +public: + //! \param userId + //! The user being reported. + //! + //! \param reason + //! The reason the room is being reported. May be blank. + explicit ReportUserJob(const UserId &userId, const QString &reason); + + // Result properties + + //! The user has been reported successfully or the server chose + //! to not disclose whether the users exists. + QJsonObject data() const { return fromJson(jsonData()); } }; +inline auto collectResponse(const ReportUserJob *job) { return job->data(); } + } // namespace Quotient diff --git a/Quotient/csapi/room_event_by_timestamp.h b/Quotient/csapi/room_event_by_timestamp.h index 265e7f7bd..9b64a11cd 100644 --- a/Quotient/csapi/room_event_by_timestamp.h +++ b/Quotient/csapi/room_event_by_timestamp.h @@ -18,7 +18,7 @@ namespace Quotient { //! servers for a suitable event. //! //! After calling this endpoint, clients can call -//! [`/rooms/{roomId}/context/{eventId}`](#get_matrixclientv3roomsroomidcontexteventid) +//! [`/rooms/{roomId}/context/{eventId}`](/client-server-api/#get_matrixclientv3roomsroomidcontexteventid) //! to obtain a pagination token to retrieve the events around the returned event. //! //! The event returned by this endpoint could be an event that the client diff --git a/Quotient/csapi/space_hierarchy.h b/Quotient/csapi/space_hierarchy.h index c421ea37c..43cb3c821 100644 --- a/Quotient/csapi/space_hierarchy.h +++ b/Quotient/csapi/space_hierarchy.h @@ -14,8 +14,8 @@ namespace Quotient { //! Where a child room is unknown to the local server, federation is used to fill in the details. //! The servers listed in the `via` array should be contacted to attempt to fill in missing rooms. //! -//! Only [`m.space.child`](#mspacechild) state events of the room are considered. Invalid child -//! rooms and parent events are not covered by this endpoint. +//! Only [`m.space.child`](/client-server-api/#mspacechild) state events of the room are considered. +//! Invalid child rooms and parent events are not covered by this endpoint. class QUOTIENT_API GetSpaceHierarchyJob : public BaseJob { public: @@ -37,8 +37,9 @@ class QUOTIENT_API GetSpaceHierarchyJob : public BaseJob //! rules like any other user. bool guestCanJoin; - //! The [`m.space.child`](#mspacechild) events of the space-room, represented - //! as [Stripped State Events](#stripped-state) with an added `origin_server_ts` key. + //! The [`m.space.child`](/client-server-api/#mspacechild) events of the space-room, + //! represented as [Stripped State Events](/client-server-api/#stripped-state) with an added + //! `origin_server_ts` key. //! //! If the room is not a space-room, this should be empty. StateEvents childrenState; @@ -70,8 +71,8 @@ class QUOTIENT_API GetSpaceHierarchyJob : public BaseJob //! //! \param suggestedOnly //! Optional (default `false`) flag to indicate whether or not the server should only consider - //! suggested rooms. Suggested rooms are annotated in their [`m.space.child`](#mspacechild) - //! event contents. + //! suggested rooms. Suggested rooms are annotated in their + //! [`m.space.child`](/client-server-api/#mspacechild) event contents. //! //! \param limit //! Optional limit for the maximum number of rooms to include per response. Must be an integer @@ -109,6 +110,20 @@ class QUOTIENT_API GetSpaceHierarchyJob : public BaseJob // Result properties //! The rooms for the current page, with the current filters. + //! + //! The server should return any rooms where at least one of the following conditions is true: + //! + //! * The requesting user is currently a member (their [room membership](#room-membership) is + //! `join`). + //! * The requesting user already has permission to join, i.e. one of the following: + //! * The user's room membership is `invite`. + //! * The room's [join rules](#mroomjoin_rules) are set to `public`. + //! * The room's join rules are set to [`restricted`](#restricted-rooms), provided the user + //! meets one of the specified conditions. + //! * The room is "knockable" (the room's join rules are set to `knock`, or `knock_restricted`, + //! in a room version that supports those settings). + //! * The room's [`m.room.history_visibility`](#room-history-visibility) is set to + //! `world_readable`. std::vector rooms() { return takeFromJson>("rooms"_L1); @@ -121,6 +136,21 @@ class QUOTIENT_API GetSpaceHierarchyJob : public BaseJob struct Response { //! The rooms for the current page, with the current filters. + //! + //! The server should return any rooms where at least one of the following conditions is + //! true: + //! + //! * The requesting user is currently a member (their [room membership](#room-membership) + //! is `join`). + //! * The requesting user already has permission to join, i.e. one of the following: + //! * The user's room membership is `invite`. + //! * The room's [join rules](#mroomjoin_rules) are set to `public`. + //! * The room's join rules are set to [`restricted`](#restricted-rooms), provided the + //! user meets one of the specified conditions. + //! * The room is "knockable" (the room's join rules are set to `knock`, or + //! `knock_restricted`, in a room version that supports those settings). + //! * The room's [`m.room.history_visibility`](#room-history-visibility) is set to + //! `world_readable`. std::vector rooms{}; //! A token to supply to `from` to keep paginating the responses. Not present when there are diff --git a/Quotient/csapi/support.h b/Quotient/csapi/support.h index 571ca4f94..470b291bb 100644 --- a/Quotient/csapi/support.h +++ b/Quotient/csapi/support.h @@ -45,13 +45,13 @@ class QUOTIENT_API GetWellknownSupportJob : public BaseJob //! //! At least one of `matrix_id` or `email_address` is //! required. - QString matrixId{}; + UserId matrixId{}; //! An email address to reach the administrator. //! //! At least one of `matrix_id` or `email_address` is //! required. - QString emailAddress{}; + QUrl emailAddress{}; }; // Construction/destruction @@ -77,7 +77,7 @@ class QUOTIENT_API GetWellknownSupportJob : public BaseJob //! homeserver, like extra login/registration steps. //! //! At least one of `contacts` or `support_page` is required. - QString supportPage() const { return loadFromJson("support_page"_L1); } + QUrl supportPage() const { return loadFromJson("support_page"_L1); } struct Response { @@ -92,7 +92,7 @@ class QUOTIENT_API GetWellknownSupportJob : public BaseJob //! homeserver, like extra login/registration steps. //! //! At least one of `contacts` or `support_page` is required. - QString supportPage{}; + QUrl supportPage{}; }; }; diff --git a/Quotient/csapi/third_party_lookup.cpp b/Quotient/csapi/third_party_lookup.cpp index e243f15a6..cd3ed6c58 100644 --- a/Quotient/csapi/third_party_lookup.cpp +++ b/Quotient/csapi/third_party_lookup.cpp @@ -25,26 +25,27 @@ GetProtocolMetadataJob::GetProtocolMetadataJob(const QString &protocol) makePath("/_matrix/client/v3", "/thirdparty/protocol/", protocol)) {} -auto queryToQueryLocationByProtocol(const QString &searchFields) +auto queryToQueryLocationByProtocol(const QHash &fields) { QUrlQuery _q; - addParam(_q, u"searchFields"_s, searchFields); + addParam(_q, u"fields"_s, fields); return _q; } QUrl QueryLocationByProtocolJob::makeRequestUrl(const HomeserverData &hsData, - const QString &protocol, const QString &searchFields) + const QString &protocol, + const QHash &fields) { return BaseJob::makeRequestUrl(hsData, makePath("/_matrix/client/v3", "/thirdparty/location/", protocol), - queryToQueryLocationByProtocol(searchFields)); + queryToQueryLocationByProtocol(fields)); } QueryLocationByProtocolJob::QueryLocationByProtocolJob(const QString &protocol, - const QString &searchFields) + const QHash &fields) : BaseJob(HttpVerb::Get, u"QueryLocationByProtocolJob"_s, makePath("/_matrix/client/v3", "/thirdparty/location/", protocol), - queryToQueryLocationByProtocol(searchFields)) + queryToQueryLocationByProtocol(fields)) {} auto queryToQueryUserByProtocol(const QHash &fields) diff --git a/Quotient/csapi/third_party_lookup.h b/Quotient/csapi/third_party_lookup.h index 2cf0b5a02..f60a20aa6 100644 --- a/Quotient/csapi/third_party_lookup.h +++ b/Quotient/csapi/third_party_lookup.h @@ -2,9 +2,9 @@ #pragma once +#include #include #include -#include #include namespace Quotient { @@ -28,9 +28,9 @@ class QUOTIENT_API GetProtocolsJob : public BaseJob // Result properties //! The protocols supported by the homeserver. - QHash protocols() const + QHash protocols() const { - return fromJson>(jsonData()); + return fromJson>(jsonData()); } }; @@ -55,7 +55,7 @@ class QUOTIENT_API GetProtocolMetadataJob : public BaseJob // Result properties //! The protocol was found and metadata returned. - ThirdPartyProtocol data() const { return fromJson(jsonData()); } + Protocol data() const { return fromJson(jsonData()); } }; inline auto collectResponse(const GetProtocolMetadataJob *job) { return job->data(); } @@ -76,17 +76,18 @@ class QUOTIENT_API QueryLocationByProtocolJob : public BaseJob //! \param protocol //! The protocol used to communicate to the third-party network. //! - //! \param searchFields + //! \param fields //! One or more custom fields to help identify the third-party //! location. - explicit QueryLocationByProtocolJob(const QString &protocol, const QString &searchFields = {}); + explicit QueryLocationByProtocolJob(const QString &protocol, + const QHash &fields = {}); //! \brief Construct a URL without creating a full-fledged job object //! //! This function can be used when a URL for QueryLocationByProtocolJob //! is necessary but the job itself isn't. static QUrl makeRequestUrl(const HomeserverData &hsData, const QString &protocol, - const QString &searchFields = {}); + const QHash &fields = {}); // Result properties diff --git a/Quotient/csapi/third_party_membership.cpp b/Quotient/csapi/third_party_membership.cpp index 3f6e7a05f..2752ca258 100644 --- a/Quotient/csapi/third_party_membership.cpp +++ b/Quotient/csapi/third_party_membership.cpp @@ -4,16 +4,9 @@ using namespace Quotient; -InviteBy3PIDJob::InviteBy3PIDJob(const QString &roomId, const QString &idServer, - const QString &idAccessToken, const QString &medium, - const QString &address) +InviteBy3PIDJob::InviteBy3PIDJob(const QString &roomId, const Invite3pid &data) : BaseJob(HttpVerb::Post, u"InviteBy3PIDJob"_s, makePath("/_matrix/client/v3", "/rooms/", roomId, "/invite")) { - QJsonObject _dataJson; - addParam(_dataJson, "id_server"_L1, idServer); - addParam(_dataJson, "id_access_token"_L1, idAccessToken); - addParam(_dataJson, "medium"_L1, medium); - addParam(_dataJson, "address"_L1, address); - setRequestData({_dataJson}); + setRequestData({toJson(data)}); } diff --git a/Quotient/csapi/third_party_membership.h b/Quotient/csapi/third_party_membership.h index 0ad7591d3..e9a371fba 100644 --- a/Quotient/csapi/third_party_membership.h +++ b/Quotient/csapi/third_party_membership.h @@ -2,6 +2,7 @@ #pragma once +#include #include namespace Quotient { @@ -54,24 +55,7 @@ class QUOTIENT_API InviteBy3PIDJob : public BaseJob //! \param roomId //! The room identifier (not alias) to which to invite the user. //! - //! \param idServer - //! The hostname+port of the identity server which should be used for third-party identifier - //! lookups. - //! - //! \param idAccessToken - //! An access token previously registered with the identity server. Servers - //! can treat this as optional to distinguish between r0.5-compatible clients - //! and this specification version. - //! - //! \param medium - //! The kind of address being passed in the address field, for example - //! `email` (see [the list of recognised values](/appendices/#3pid-types)). - //! - //! \param address - //! The invitee's third-party identifier. - explicit InviteBy3PIDJob(const QString &roomId, const QString &idServer, - const QString &idAccessToken, const QString &medium, - const QString &address); + explicit InviteBy3PIDJob(const QString &roomId, const Invite3pid &data); }; } // namespace Quotient diff --git a/Quotient/csapi/whoami.h b/Quotient/csapi/whoami.h index 986e9e6d1..475bdfe14 100644 --- a/Quotient/csapi/whoami.h +++ b/Quotient/csapi/whoami.h @@ -30,7 +30,7 @@ class QUOTIENT_API GetTokenOwnerJob : public BaseJob // Result properties //! The user ID that owns the access token. - QString userId() const { return loadFromJson("user_id"_L1); } + UserId userId() const { return loadFromJson("user_id"_L1); } //! Device ID associated with the access token. If no device //! is associated with the access token (such as in the case @@ -38,15 +38,15 @@ class QUOTIENT_API GetTokenOwnerJob : public BaseJob //! Otherwise this is required. QString deviceId() const { return loadFromJson("device_id"_L1); } - //! When `true`, the user is a [Guest User](#guest-access). When - //! not present or `false`, the user is presumed to be a non-guest - //! user. + //! When `true`, the user is a [Guest User](/client-server-api/#guest-access). + //! When not present or `false`, the user is presumed to be a + //! non-guest user. std::optional isGuest() const { return loadFromJson>("is_guest"_L1); } struct Response { //! The user ID that owns the access token. - QString userId{}; + UserId userId{}; //! Device ID associated with the access token. If no device //! is associated with the access token (such as in the case @@ -54,9 +54,9 @@ class QUOTIENT_API GetTokenOwnerJob : public BaseJob //! Otherwise this is required. QString deviceId{}; - //! When `true`, the user is a [Guest User](#guest-access). When - //! not present or `false`, the user is presumed to be a non-guest - //! user. + //! When `true`, the user is a [Guest User](/client-server-api/#guest-access). + //! When not present or `false`, the user is presumed to be a + //! non-guest user. std::optional isGuest{}; }; }; From 6581c2ef1e27e1a45aa14a358533c948fb7c58fc Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Tue, 10 Jun 2025 21:40:52 +0200 Subject: [PATCH 6/8] Update the rest of the codebase to new API files Actually, it's just one place. --- Quotient/connection.cpp | 8 ++++---- Quotient/connection.h | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Quotient/connection.cpp b/Quotient/connection.cpp index 4facd61f1..d4cb85928 100644 --- a/Quotient/connection.cpp +++ b/Quotient/connection.cpp @@ -794,10 +794,10 @@ JobHandle Connection::downloadFile(const QUrl& url, } JobHandle Connection::createRoom( - RoomVisibility visibility, const QString& alias, const QString& name, const QString& topic, - QStringList invites, const QString& presetName, const QString& roomVersion, bool isDirect, - const QVector& initialState, - const QVector& invite3pids, const QJsonObject& creationContent) + RoomVisibility visibility, const QString &alias, const QString &name, const QString &topic, + QStringList invites, const QString &presetName, const QString &roomVersion, bool isDirect, + const QVector &initialState, const QVector &invite3pids, + const QJsonObject &creationContent) { invites.removeOne(userId()); // The creator is by definition in the room return callApi(visibility == PublishRoom ? u"public"_s : u"private"_s, diff --git a/Quotient/connection.h b/Quotient/connection.h index 8291ddf1f..f168bd047 100644 --- a/Quotient/connection.h +++ b/Quotient/connection.h @@ -742,13 +742,13 @@ public Q_SLOTS: //! //! This method allows to customize room entirely to your liking, //! providing all the attributes the original CS API provides. - JobHandle createRoom(RoomVisibility visibility, const QString& alias, - const QString& name, const QString& topic, QStringList invites, - const QString& presetName = {}, const QString& roomVersion = {}, - bool isDirect = false, - const QVector& initialState = {}, - const QVector& invite3pids = {}, - const QJsonObject& creationContent = {}); + JobHandle createRoom(RoomVisibility visibility, const QString &alias, + const QString &name, const QString &topic, + QStringList invites, const QString &presetName = {}, + const QString &roomVersion = {}, bool isDirect = false, + const QVector &initialState = {}, + const QVector &invite3pids = {}, + const QJsonObject &creationContent = {}); //! \brief Get a direct chat with a single user //! From 8767ceb0b513999d62c48ea1d497358ea4ba1ad3 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Wed, 11 Jun 2025 09:50:37 +0200 Subject: [PATCH 7/8] gtad.yaml: inline protocol_base.h too --- gtad/gtad.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gtad/gtad.yaml b/gtad/gtad.yaml index 7bb21b7ee..6d261ad00 100644 --- a/gtad/gtad.yaml +++ b/gtad/gtad.yaml @@ -144,7 +144,9 @@ analyzer: inline: # Inline whatever is used from the identity spec - /identity/definitions/ - - /protocol_instance.yaml$/ + # These two are only used once each within CS (the other use is in AS API), with CS adding + # fields to each - excess normalisation for our needs, so denormalise back + - /protocol_(base|instance).yaml$/ # Despite being used in two calls, it's more practical to have those # fields available as getters right from the respective job classes - /public_rooms_response.yaml$/ From 174077e02ab8ba6613e2febb9b367d094d2e5c47 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Wed, 11 Jun 2025 09:56:49 +0200 Subject: [PATCH 8/8] Regenerate API files Note: aside from changes in gtad.yaml, matrix-spec was also changed to suppress unneeded QJsonObjects by new jobs in report_content.h --- .../definitions/protocol_base.h | 44 ------------------- Quotient/csapi/definitions/protocol.h | 40 ++++++++++++++--- Quotient/csapi/report_content.h | 15 ------- Quotient/csapi/third_party_lookup.h | 6 +-- 4 files changed, 37 insertions(+), 68 deletions(-) diff --git a/Quotient/application-service/definitions/protocol_base.h b/Quotient/application-service/definitions/protocol_base.h index 817c6d202..0822a4ba2 100644 --- a/Quotient/application-service/definitions/protocol_base.h +++ b/Quotient/application-service/definitions/protocol_base.h @@ -32,48 +32,4 @@ struct JsonObjectConverter } }; -struct QUOTIENT_API ThirdPartyProtocol -{ - //! Fields which may be used to identify a third-party user. These should be - //! ordered to suggest the way that entities may be grouped, where higher - //! groupings are ordered first. For example, the name of a network should be - //! searched before the nickname of a user. - QStringList userFields; - - //! Fields which may be used to identify a third-party location. These should be - //! ordered to suggest the way that entities may be grouped, where higher - //! groupings are ordered first. For example, the name of a network should be - //! searched before the name of a channel. - QStringList locationFields; - - //! A content URI representing an icon for the third-party protocol. - QString icon; - - //! The type definitions for the fields defined in `user_fields` and - //! `location_fields`. Each entry in those arrays MUST have an entry here. - //! The `string` key for this object is the field name itself. - //! - //! May be an empty object if no fields are defined. - QHash fieldTypes; -}; - -template <> -struct JsonObjectConverter -{ - static void dumpTo(QJsonObject &jo, const ThirdPartyProtocol &pod) - { - addParam(jo, "user_fields"_L1, pod.userFields); - addParam(jo, "location_fields"_L1, pod.locationFields); - addParam(jo, "icon"_L1, pod.icon); - addParam(jo, "field_types"_L1, pod.fieldTypes); - } - static void fillFrom(const QJsonObject &jo, ThirdPartyProtocol &pod) - { - fillFromJson(jo.value("user_fields"_L1), pod.userFields); - fillFromJson(jo.value("location_fields"_L1), pod.locationFields); - fillFromJson(jo.value("icon"_L1), pod.icon); - fillFromJson(jo.value("field_types"_L1), pod.fieldTypes); - } -}; - } // namespace Quotient diff --git a/Quotient/csapi/definitions/protocol.h b/Quotient/csapi/definitions/protocol.h index 4b4c547cc..fa0b5f277 100644 --- a/Quotient/csapi/definitions/protocol.h +++ b/Quotient/csapi/definitions/protocol.h @@ -53,8 +53,30 @@ struct JsonObjectConverter } }; -struct QUOTIENT_API Protocol : ThirdPartyProtocol +struct QUOTIENT_API ThirdPartyProtocol { + //! Fields which may be used to identify a third-party user. These should be + //! ordered to suggest the way that entities may be grouped, where higher + //! groupings are ordered first. For example, the name of a network should be + //! searched before the nickname of a user. + QStringList userFields; + + //! Fields which may be used to identify a third-party location. These should be + //! ordered to suggest the way that entities may be grouped, where higher + //! groupings are ordered first. For example, the name of a network should be + //! searched before the name of a channel. + QStringList locationFields; + + //! A content URI representing an icon for the third-party protocol. + QString icon; + + //! The type definitions for the fields defined in `user_fields` and + //! `location_fields`. Each entry in those arrays MUST have an entry here. + //! The `string` key for this object is the field name itself. + //! + //! May be an empty object if no fields are defined. + QHash fieldTypes; + //! A list of objects representing independent instances of configuration. //! For example, multiple networks on IRC if multiple are provided by the //! same application service. @@ -68,16 +90,22 @@ struct QUOTIENT_API Protocol : ThirdPartyProtocol }; template <> -struct JsonObjectConverter +struct JsonObjectConverter { - static void dumpTo(QJsonObject &jo, const Protocol &pod) + static void dumpTo(QJsonObject &jo, const ThirdPartyProtocol &pod) { - fillJson(jo, pod); + addParam(jo, "user_fields"_L1, pod.userFields); + addParam(jo, "location_fields"_L1, pod.locationFields); + addParam(jo, "icon"_L1, pod.icon); + addParam(jo, "field_types"_L1, pod.fieldTypes); addParam(jo, "instances"_L1, pod.instances); } - static void fillFrom(const QJsonObject &jo, Protocol &pod) + static void fillFrom(const QJsonObject &jo, ThirdPartyProtocol &pod) { - fillFromJson(jo, pod); + fillFromJson(jo.value("user_fields"_L1), pod.userFields); + fillFromJson(jo.value("location_fields"_L1), pod.locationFields); + fillFromJson(jo.value("icon"_L1), pod.icon); + fillFromJson(jo.value("field_types"_L1), pod.fieldTypes); fillFromJson(jo.value("instances"_L1), pod.instances); } }; diff --git a/Quotient/csapi/report_content.h b/Quotient/csapi/report_content.h index de03f54a7..5cebcc246 100644 --- a/Quotient/csapi/report_content.h +++ b/Quotient/csapi/report_content.h @@ -21,15 +21,8 @@ class QUOTIENT_API ReportRoomJob : public BaseJob //! \param reason //! The reason the room is being reported. May be blank. explicit ReportRoomJob(const QString &roomId, const QString &reason); - - // Result properties - - //! The room has been reported successfully. - QJsonObject data() const { return fromJson(jsonData()); } }; -inline auto collectResponse(const ReportRoomJob *job) { return job->data(); } - //! \brief Report an event in a joined room as inappropriate. //! //! Reports an event as inappropriate to the server, which may then notify @@ -85,14 +78,6 @@ class QUOTIENT_API ReportUserJob : public BaseJob //! \param reason //! The reason the room is being reported. May be blank. explicit ReportUserJob(const UserId &userId, const QString &reason); - - // Result properties - - //! The user has been reported successfully or the server chose - //! to not disclose whether the users exists. - QJsonObject data() const { return fromJson(jsonData()); } }; -inline auto collectResponse(const ReportUserJob *job) { return job->data(); } - } // namespace Quotient diff --git a/Quotient/csapi/third_party_lookup.h b/Quotient/csapi/third_party_lookup.h index f60a20aa6..d9da9a0cb 100644 --- a/Quotient/csapi/third_party_lookup.h +++ b/Quotient/csapi/third_party_lookup.h @@ -28,9 +28,9 @@ class QUOTIENT_API GetProtocolsJob : public BaseJob // Result properties //! The protocols supported by the homeserver. - QHash protocols() const + QHash protocols() const { - return fromJson>(jsonData()); + return fromJson>(jsonData()); } }; @@ -55,7 +55,7 @@ class QUOTIENT_API GetProtocolMetadataJob : public BaseJob // Result properties //! The protocol was found and metadata returned. - Protocol data() const { return fromJson(jsonData()); } + ThirdPartyProtocol data() const { return fromJson(jsonData()); } }; inline auto collectResponse(const GetProtocolMetadataJob *job) { return job->data(); }