From aacc4bcb4a487871daae6717f77605aaba444341 Mon Sep 17 00:00:00 2001 From: Marc Deop Date: Sat, 2 Mar 2019 12:26:57 +0100 Subject: style: apply .clang-format to all .cpp and .h files --- lib/application-service/definitions/location.cpp | 3 +- lib/application-service/definitions/location.h | 9 ++-- lib/application-service/definitions/protocol.cpp | 19 ++++--- lib/application-service/definitions/protocol.h | 64 +++++++++++------------- lib/application-service/definitions/user.cpp | 9 ++-- lib/application-service/definitions/user.h | 9 ++-- 6 files changed, 50 insertions(+), 63 deletions(-) (limited to 'lib/application-service') diff --git a/lib/application-service/definitions/location.cpp b/lib/application-service/definitions/location.cpp index a53db8d7..4da0e69d 100644 --- a/lib/application-service/definitions/location.cpp +++ b/lib/application-service/definitions/location.cpp @@ -15,10 +15,9 @@ void JsonObjectConverter::dumpTo( } void JsonObjectConverter::fillFrom( - const QJsonObject& jo, ThirdPartyLocation& result) + const QJsonObject& jo, ThirdPartyLocation& result) { fromJson(jo.value("alias"_ls), result.alias); fromJson(jo.value("protocol"_ls), result.protocol); fromJson(jo.value("fields"_ls), result.fields); } - diff --git a/lib/application-service/definitions/location.h b/lib/application-service/definitions/location.h index 5586cfc6..f92fa8c5 100644 --- a/lib/application-service/definitions/location.h +++ b/lib/application-service/definitions/location.h @@ -8,12 +8,10 @@ #include -namespace QMatrixClient -{ +namespace QMatrixClient { // Data structures - struct ThirdPartyLocation - { + struct ThirdPartyLocation { /// An alias for a matrix room. QString alias; /// The protocol ID that the third party location is a part of. @@ -21,8 +19,7 @@ namespace QMatrixClient /// Information used to identify this third party location. QJsonObject fields; }; - template <> struct JsonObjectConverter - { + template <> struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const ThirdPartyLocation& pod); static void fillFrom(const QJsonObject& jo, ThirdPartyLocation& pod); }; diff --git a/lib/application-service/definitions/protocol.cpp b/lib/application-service/definitions/protocol.cpp index 2a62b15d..4c148796 100644 --- a/lib/application-service/definitions/protocol.cpp +++ b/lib/application-service/definitions/protocol.cpp @@ -6,22 +6,22 @@ using namespace QMatrixClient; -void JsonObjectConverter::dumpTo( - QJsonObject& jo, const FieldType& pod) +void JsonObjectConverter::dumpTo(QJsonObject& jo, + const FieldType& pod) { addParam<>(jo, QStringLiteral("regexp"), pod.regexp); addParam<>(jo, QStringLiteral("placeholder"), pod.placeholder); } -void JsonObjectConverter::fillFrom( - const QJsonObject& jo, FieldType& result) +void JsonObjectConverter::fillFrom(const QJsonObject& jo, + FieldType& result) { fromJson(jo.value("regexp"_ls), result.regexp); fromJson(jo.value("placeholder"_ls), result.placeholder); } -void JsonObjectConverter::dumpTo( - QJsonObject& jo, const ProtocolInstance& pod) +void JsonObjectConverter::dumpTo(QJsonObject& jo, + const ProtocolInstance& pod) { addParam<>(jo, QStringLiteral("desc"), pod.desc); addParam(jo, QStringLiteral("icon"), pod.icon); @@ -29,8 +29,8 @@ void JsonObjectConverter::dumpTo( addParam<>(jo, QStringLiteral("network_id"), pod.networkId); } -void JsonObjectConverter::fillFrom( - const QJsonObject& jo, ProtocolInstance& result) +void JsonObjectConverter::fillFrom(const QJsonObject& jo, + ProtocolInstance& result) { fromJson(jo.value("desc"_ls), result.desc); fromJson(jo.value("icon"_ls), result.icon); @@ -49,7 +49,7 @@ void JsonObjectConverter::dumpTo( } void JsonObjectConverter::fillFrom( - const QJsonObject& jo, ThirdPartyProtocol& result) + const QJsonObject& jo, ThirdPartyProtocol& result) { fromJson(jo.value("user_fields"_ls), result.userFields); fromJson(jo.value("location_fields"_ls), result.locationFields); @@ -57,4 +57,3 @@ void JsonObjectConverter::fillFrom( fromJson(jo.value("field_types"_ls), result.fieldTypes); fromJson(jo.value("instances"_ls), result.instances); } - diff --git a/lib/application-service/definitions/protocol.h b/lib/application-service/definitions/protocol.h index 0a1f9a21..66012a13 100644 --- a/lib/application-service/definitions/protocol.h +++ b/lib/application-service/definitions/protocol.h @@ -6,76 +6,72 @@ #include "converters.h" +#include "converters.h" #include #include -#include "converters.h" #include -namespace QMatrixClient -{ +namespace QMatrixClient { // Data structures /// Definition of valid values for a field. - struct 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. + struct 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. QString regexp; /// An placeholder serving as a valid example of the field value. QString placeholder; }; - template <> struct JsonObjectConverter - { + template <> struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const FieldType& pod); static void fillFrom(const QJsonObject& jo, FieldType& pod); }; - struct ProtocolInstance - { + struct ProtocolInstance { /// A human-readable description for the protocol, such as the name. QString desc; - /// An optional content URI representing the protocol. Overrides the one provided - /// at the higher level Protocol object. + /// An optional content URI representing the protocol. Overrides the one + /// provided at the higher level Protocol object. QString icon; /// Preset values for ``fields`` the client may use to search by. QJsonObject fields; /// A unique identifier across all instances. QString networkId; }; - template <> struct JsonObjectConverter - { + template <> struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const ProtocolInstance& pod); static void fillFrom(const QJsonObject& jo, ProtocolInstance& pod); }; - struct 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. + struct 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. + /// 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 the ``user_fields`` and - /// ``location_fields``. Each entry in those arrays MUST have an entry here. The + /// The type definitions for the fields defined in the ``user_fields`` + /// and + /// ``location_fields``. Each entry in those arrays MUST have an entry + /// here. The /// ``string`` key for this object is 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. + /// 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 <> struct JsonObjectConverter - { + template <> struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const ThirdPartyProtocol& pod); static void fillFrom(const QJsonObject& jo, ThirdPartyProtocol& pod); }; diff --git a/lib/application-service/definitions/user.cpp b/lib/application-service/definitions/user.cpp index 8ba92321..0f3c3130 100644 --- a/lib/application-service/definitions/user.cpp +++ b/lib/application-service/definitions/user.cpp @@ -6,19 +6,18 @@ using namespace QMatrixClient; -void JsonObjectConverter::dumpTo( - QJsonObject& jo, const ThirdPartyUser& pod) +void JsonObjectConverter::dumpTo(QJsonObject& jo, + const ThirdPartyUser& pod) { addParam<>(jo, QStringLiteral("userid"), pod.userid); addParam<>(jo, QStringLiteral("protocol"), pod.protocol); addParam<>(jo, QStringLiteral("fields"), pod.fields); } -void JsonObjectConverter::fillFrom( - const QJsonObject& jo, ThirdPartyUser& result) +void JsonObjectConverter::fillFrom(const QJsonObject& jo, + ThirdPartyUser& result) { fromJson(jo.value("userid"_ls), result.userid); fromJson(jo.value("protocol"_ls), result.protocol); fromJson(jo.value("fields"_ls), result.fields); } - diff --git a/lib/application-service/definitions/user.h b/lib/application-service/definitions/user.h index 062d2cac..9b314db1 100644 --- a/lib/application-service/definitions/user.h +++ b/lib/application-service/definitions/user.h @@ -8,12 +8,10 @@ #include -namespace QMatrixClient -{ +namespace QMatrixClient { // Data structures - struct ThirdPartyUser - { + struct ThirdPartyUser { /// A Matrix User ID represting a third party user. QString userid; /// The protocol ID that the third party location is a part of. @@ -21,8 +19,7 @@ namespace QMatrixClient /// Information used to identify this third party location. QJsonObject fields; }; - template <> struct JsonObjectConverter - { + template <> struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const ThirdPartyUser& pod); static void fillFrom(const QJsonObject& jo, ThirdPartyUser& pod); }; -- cgit v1.2.3 From 27ca32a1e5a56e09b9cc1d94224d2831004dcf3d Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 7 Jul 2019 19:32:34 +0900 Subject: Namespace: QMatrixClient -> Quotient (with back comp alias) --- examples/qmc-example.cpp | 2 +- lib/application-service/definitions/location.cpp | 2 +- lib/application-service/definitions/location.h | 4 ++-- lib/application-service/definitions/protocol.cpp | 2 +- lib/application-service/definitions/protocol.h | 4 ++-- lib/application-service/definitions/user.cpp | 2 +- lib/application-service/definitions/user.h | 4 ++-- lib/avatar.cpp | 2 +- lib/avatar.h | 6 ++++-- lib/connection.cpp | 6 +++--- lib/connection.h | 6 +++--- lib/connectiondata.cpp | 2 +- lib/connectiondata.h | 4 ++-- lib/converters.cpp | 2 +- lib/converters.h | 4 ++-- lib/csapi/account-data.cpp | 2 +- lib/csapi/account-data.h | 4 ++-- lib/csapi/admin.cpp | 6 +++--- lib/csapi/admin.h | 4 ++-- lib/csapi/administrative_contact.cpp | 10 +++++----- lib/csapi/administrative_contact.h | 4 ++-- lib/csapi/appservice_room_directory.cpp | 2 +- lib/csapi/appservice_room_directory.h | 4 ++-- lib/csapi/banning.cpp | 2 +- lib/csapi/banning.h | 4 ++-- lib/csapi/capabilities.cpp | 6 +++--- lib/csapi/capabilities.h | 4 ++-- lib/csapi/content-repo.cpp | 2 +- lib/csapi/content-repo.h | 4 ++-- lib/csapi/create_room.cpp | 6 +++--- lib/csapi/create_room.h | 4 ++-- lib/csapi/definitions/auth_data.cpp | 2 +- lib/csapi/definitions/auth_data.h | 4 ++-- lib/csapi/definitions/client_device.cpp | 2 +- lib/csapi/definitions/client_device.h | 4 ++-- lib/csapi/definitions/device_keys.cpp | 2 +- lib/csapi/definitions/device_keys.h | 4 ++-- lib/csapi/definitions/event_filter.cpp | 2 +- lib/csapi/definitions/event_filter.h | 4 ++-- lib/csapi/definitions/public_rooms_response.cpp | 2 +- lib/csapi/definitions/public_rooms_response.h | 4 ++-- lib/csapi/definitions/push_condition.cpp | 2 +- lib/csapi/definitions/push_condition.h | 4 ++-- lib/csapi/definitions/push_rule.cpp | 2 +- lib/csapi/definitions/push_rule.h | 4 ++-- lib/csapi/definitions/push_ruleset.cpp | 2 +- lib/csapi/definitions/push_ruleset.h | 4 ++-- lib/csapi/definitions/room_event_filter.cpp | 2 +- lib/csapi/definitions/room_event_filter.h | 4 ++-- lib/csapi/definitions/sync_filter.cpp | 2 +- lib/csapi/definitions/sync_filter.h | 4 ++-- lib/csapi/definitions/user_identifier.cpp | 2 +- lib/csapi/definitions/user_identifier.h | 4 ++-- lib/csapi/definitions/wellknown/full.cpp | 2 +- lib/csapi/definitions/wellknown/full.h | 4 ++-- lib/csapi/definitions/wellknown/homeserver.cpp | 2 +- lib/csapi/definitions/wellknown/homeserver.h | 4 ++-- lib/csapi/definitions/wellknown/identity_server.cpp | 2 +- lib/csapi/definitions/wellknown/identity_server.h | 4 ++-- lib/csapi/device_management.cpp | 2 +- lib/csapi/device_management.h | 4 ++-- lib/csapi/directory.cpp | 2 +- lib/csapi/directory.h | 4 ++-- lib/csapi/event_context.cpp | 2 +- lib/csapi/event_context.h | 4 ++-- lib/csapi/filter.cpp | 2 +- lib/csapi/filter.h | 4 ++-- lib/csapi/inviting.cpp | 2 +- lib/csapi/inviting.h | 4 ++-- lib/csapi/joining.cpp | 10 +++++----- lib/csapi/joining.h | 4 ++-- lib/csapi/keys.cpp | 6 +++--- lib/csapi/keys.h | 4 ++-- lib/csapi/kicking.cpp | 2 +- lib/csapi/kicking.h | 4 ++-- lib/csapi/leaving.cpp | 2 +- lib/csapi/leaving.h | 4 ++-- lib/csapi/list_joined_rooms.cpp | 2 +- lib/csapi/list_joined_rooms.h | 4 ++-- lib/csapi/list_public_rooms.cpp | 6 +++--- lib/csapi/list_public_rooms.h | 4 ++-- lib/csapi/login.cpp | 6 +++--- lib/csapi/login.h | 4 ++-- lib/csapi/logout.cpp | 2 +- lib/csapi/logout.h | 4 ++-- lib/csapi/message_pagination.cpp | 2 +- lib/csapi/message_pagination.h | 4 ++-- lib/csapi/notifications.cpp | 6 +++--- lib/csapi/notifications.h | 4 ++-- lib/csapi/openid.cpp | 2 +- lib/csapi/openid.h | 4 ++-- lib/csapi/peeking_events.cpp | 2 +- lib/csapi/peeking_events.h | 4 ++-- lib/csapi/presence.cpp | 2 +- lib/csapi/presence.h | 4 ++-- lib/csapi/profile.cpp | 2 +- lib/csapi/profile.h | 4 ++-- lib/csapi/pusher.cpp | 10 +++++----- lib/csapi/pusher.h | 4 ++-- lib/csapi/pushrules.cpp | 2 +- lib/csapi/pushrules.h | 4 ++-- lib/csapi/read_markers.cpp | 2 +- lib/csapi/read_markers.h | 4 ++-- lib/csapi/receipts.cpp | 2 +- lib/csapi/receipts.h | 4 ++-- lib/csapi/redaction.cpp | 2 +- lib/csapi/redaction.h | 4 ++-- lib/csapi/registration.cpp | 2 +- lib/csapi/registration.h | 4 ++-- lib/csapi/report_content.cpp | 2 +- lib/csapi/report_content.h | 4 ++-- lib/csapi/room_send.cpp | 2 +- lib/csapi/room_send.h | 4 ++-- lib/csapi/room_state.cpp | 2 +- lib/csapi/room_state.h | 4 ++-- lib/csapi/room_upgrades.cpp | 2 +- lib/csapi/room_upgrades.h | 4 ++-- lib/csapi/rooms.cpp | 6 +++--- lib/csapi/rooms.h | 4 ++-- lib/csapi/search.cpp | 6 +++--- lib/csapi/search.h | 4 ++-- lib/csapi/sso_login_redirect.cpp | 2 +- lib/csapi/sso_login_redirect.h | 4 ++-- lib/csapi/tags.cpp | 6 +++--- lib/csapi/tags.h | 4 ++-- lib/csapi/third_party_lookup.cpp | 2 +- lib/csapi/third_party_lookup.h | 4 ++-- lib/csapi/third_party_membership.cpp | 2 +- lib/csapi/third_party_membership.h | 4 ++-- lib/csapi/to_device.cpp | 2 +- lib/csapi/to_device.h | 4 ++-- lib/csapi/typing.cpp | 2 +- lib/csapi/typing.h | 4 ++-- lib/csapi/users.cpp | 6 +++--- lib/csapi/users.h | 4 ++-- lib/csapi/versions.cpp | 2 +- lib/csapi/versions.h | 4 ++-- lib/csapi/voip.cpp | 2 +- lib/csapi/voip.h | 4 ++-- lib/csapi/wellknown.cpp | 2 +- lib/csapi/wellknown.h | 4 ++-- lib/csapi/whoami.cpp | 2 +- lib/csapi/whoami.h | 4 ++-- lib/csapi/{{base}}.cpp.mustache | 4 ++-- lib/csapi/{{base}}.h.mustache | 4 ++-- lib/e2ee.h | 4 ++-- lib/encryptionmanager.cpp | 2 +- lib/encryptionmanager.h | 4 ++-- lib/eventitem.cpp | 2 +- lib/eventitem.h | 6 +++--- lib/events/accountdataevents.h | 4 ++-- lib/events/callanswerevent.cpp | 2 +- lib/events/callanswerevent.h | 4 ++-- lib/events/callcandidatesevent.h | 4 ++-- lib/events/callhangupevent.cpp | 2 +- lib/events/callhangupevent.h | 4 ++-- lib/events/callinviteevent.cpp | 2 +- lib/events/callinviteevent.h | 4 ++-- lib/events/directchatevent.cpp | 2 +- lib/events/directchatevent.h | 4 ++-- lib/events/encryptedevent.h | 4 ++-- lib/events/encryptionevent.cpp | 6 +++--- lib/events/encryptionevent.h | 4 ++-- lib/events/event.cpp | 2 +- lib/events/event.h | 10 +++++----- lib/events/eventcontent.cpp | 2 +- lib/events/eventcontent.h | 4 ++-- lib/events/eventloader.h | 4 ++-- lib/events/reactionevent.cpp | 4 ++-- lib/events/reactionevent.h | 4 ++-- lib/events/receiptevent.cpp | 2 +- lib/events/receiptevent.h | 4 ++-- lib/events/redactionevent.h | 4 ++-- lib/events/roomavatarevent.h | 4 ++-- lib/events/roomcreateevent.cpp | 2 +- lib/events/roomcreateevent.h | 4 ++-- lib/events/roomevent.cpp | 4 ++-- lib/events/roomevent.h | 8 ++++---- lib/events/roommemberevent.cpp | 6 +++--- lib/events/roommemberevent.h | 4 ++-- lib/events/roommessageevent.cpp | 6 +++--- lib/events/roommessageevent.h | 4 ++-- lib/events/roomtombstoneevent.cpp | 2 +- lib/events/roomtombstoneevent.h | 4 ++-- lib/events/simplestateevents.h | 6 +++--- lib/events/stateevent.cpp | 2 +- lib/events/stateevent.h | 8 ++++---- lib/events/typingevent.cpp | 2 +- lib/events/typingevent.h | 4 ++-- lib/identity/definitions/request_email_validation.cpp | 2 +- lib/identity/definitions/request_email_validation.h | 4 ++-- lib/identity/definitions/request_msisdn_validation.cpp | 2 +- lib/identity/definitions/request_msisdn_validation.h | 4 ++-- lib/identity/definitions/sid.cpp | 2 +- lib/identity/definitions/sid.h | 4 ++-- lib/jobs/basejob.cpp | 2 +- lib/jobs/basejob.h | 4 ++-- lib/jobs/downloadfilejob.cpp | 2 +- lib/jobs/downloadfilejob.h | 4 ++-- lib/jobs/mediathumbnailjob.cpp | 2 +- lib/jobs/mediathumbnailjob.h | 4 ++-- lib/jobs/postreadmarkersjob.h | 2 +- lib/jobs/requestdata.cpp | 2 +- lib/jobs/requestdata.h | 6 ++++-- lib/jobs/syncjob.cpp | 2 +- lib/jobs/syncjob.h | 4 ++-- lib/joinstate.h | 6 +++--- lib/logging.h | 6 ++++-- lib/networkaccessmanager.cpp | 2 +- lib/networkaccessmanager.h | 4 ++-- lib/networksettings.cpp | 2 +- lib/networksettings.h | 2 +- lib/qt_connection_util.h | 4 ++-- lib/room.cpp | 4 ++-- lib/room.h | 10 +++++----- lib/settings.cpp | 2 +- lib/settings.h | 4 ++-- lib/syncdata.cpp | 4 ++-- lib/syncdata.h | 4 ++-- lib/user.cpp | 2 +- lib/user.h | 6 +++--- lib/util.cpp | 14 +++++++------- lib/util.h | 6 ++++-- 223 files changed, 414 insertions(+), 406 deletions(-) (limited to 'lib/application-service') diff --git a/examples/qmc-example.cpp b/examples/qmc-example.cpp index 4a06d9b8..bf4d04c7 100644 --- a/examples/qmc-example.cpp +++ b/examples/qmc-example.cpp @@ -19,7 +19,7 @@ #include #include -using namespace QMatrixClient; +using namespace Quotient; using std::cout; using std::endl; using namespace std::placeholders; diff --git a/lib/application-service/definitions/location.cpp b/lib/application-service/definitions/location.cpp index 2ab83ae9..0a054029 100644 --- a/lib/application-service/definitions/location.cpp +++ b/lib/application-service/definitions/location.cpp @@ -4,7 +4,7 @@ #include "location.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo( QJsonObject& jo, const ThirdPartyLocation& pod) diff --git a/lib/application-service/definitions/location.h b/lib/application-service/definitions/location.h index caf28615..77512514 100644 --- a/lib/application-service/definitions/location.h +++ b/lib/application-service/definitions/location.h @@ -8,7 +8,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Data structures @@ -30,4 +30,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, ThirdPartyLocation& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/application-service/definitions/protocol.cpp b/lib/application-service/definitions/protocol.cpp index e87001fb..8c66aa4d 100644 --- a/lib/application-service/definitions/protocol.cpp +++ b/lib/application-service/definitions/protocol.cpp @@ -4,7 +4,7 @@ #include "protocol.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const FieldType& pod) diff --git a/lib/application-service/definitions/protocol.h b/lib/application-service/definitions/protocol.h index 0d227851..ab99264f 100644 --- a/lib/application-service/definitions/protocol.h +++ b/lib/application-service/definitions/protocol.h @@ -10,7 +10,7 @@ #include #include -namespace QMatrixClient +namespace Quotient { // Data structures @@ -85,4 +85,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, ThirdPartyProtocol& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/application-service/definitions/user.cpp b/lib/application-service/definitions/user.cpp index 0f3c3130..17d15a20 100644 --- a/lib/application-service/definitions/user.cpp +++ b/lib/application-service/definitions/user.cpp @@ -4,7 +4,7 @@ #include "user.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const ThirdPartyUser& pod) diff --git a/lib/application-service/definitions/user.h b/lib/application-service/definitions/user.h index 3fd099d0..34c6829c 100644 --- a/lib/application-service/definitions/user.h +++ b/lib/application-service/definitions/user.h @@ -8,7 +8,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Data structures @@ -30,4 +30,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, ThirdPartyUser& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/avatar.cpp b/lib/avatar.cpp index 614f008d..cb734984 100644 --- a/lib/avatar.cpp +++ b/lib/avatar.cpp @@ -29,7 +29,7 @@ #include #include -using namespace QMatrixClient; +using namespace Quotient; using std::move; class Avatar::Private { diff --git a/lib/avatar.h b/lib/avatar.h index c33e1982..7a566bfa 100644 --- a/lib/avatar.h +++ b/lib/avatar.h @@ -24,7 +24,7 @@ #include #include -namespace QMatrixClient { +namespace Quotient { class Connection; class Avatar { @@ -56,4 +56,6 @@ private: class Private; std::unique_ptr d; }; -} // namespace QMatrixClient +} // namespace Quotient +/// \deprecated Use namespace Quotient instead +namespace QMatrixClient = Quotient; \ No newline at end of file diff --git a/lib/connection.cpp b/lib/connection.cpp index 58d2e01a..22db8e3d 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -53,7 +53,7 @@ #include #include -using namespace QMatrixClient; +using namespace Quotient; // This is very much Qt-specific; STL iterators don't have key() and value() template @@ -1349,9 +1349,9 @@ void Connection::setCacheState(bool newValue) } } -bool QMatrixClient::Connection::lazyLoading() const { return d->lazyLoading; } +bool Connection::lazyLoading() const { return d->lazyLoading; } -void QMatrixClient::Connection::setLazyLoading(bool newValue) +void Connection::setLazyLoading(bool newValue) { if (d->lazyLoading != newValue) { d->lazyLoading = newValue; diff --git a/lib/connection.h b/lib/connection.h index b89c0c65..c807b827 100644 --- a/lib/connection.h +++ b/lib/connection.h @@ -36,7 +36,7 @@ namespace QtOlm { class Account; } -namespace QMatrixClient { +namespace Quotient { class Room; class User; class ConnectionData; @@ -778,5 +778,5 @@ private: static room_factory_t _roomFactory; static user_factory_t _userFactory; }; -} // namespace QMatrixClient -Q_DECLARE_METATYPE(QMatrixClient::Connection*) +} // namespace Quotient +Q_DECLARE_METATYPE(Quotient::Connection*) diff --git a/lib/connectiondata.cpp b/lib/connectiondata.cpp index df4cece2..486de03d 100644 --- a/lib/connectiondata.cpp +++ b/lib/connectiondata.cpp @@ -21,7 +21,7 @@ #include "logging.h" #include "networkaccessmanager.h" -using namespace QMatrixClient; +using namespace Quotient; struct ConnectionData::Private { explicit Private(QUrl url) : baseUrl(std::move(url)) {} diff --git a/lib/connectiondata.h b/lib/connectiondata.h index 9b579b1c..80ace08c 100644 --- a/lib/connectiondata.h +++ b/lib/connectiondata.h @@ -24,7 +24,7 @@ class QNetworkAccessManager; -namespace QMatrixClient { +namespace Quotient { class ConnectionData { public: explicit ConnectionData(QUrl baseUrl); @@ -50,4 +50,4 @@ private: struct Private; std::unique_ptr d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/converters.cpp b/lib/converters.cpp index ef58c85e..9f4b9360 100644 --- a/lib/converters.cpp +++ b/lib/converters.cpp @@ -20,7 +20,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; QJsonValue JsonConverter::dump(const QVariant& v) { diff --git a/lib/converters.h b/lib/converters.h index 0085fa4b..587e4544 100644 --- a/lib/converters.h +++ b/lib/converters.h @@ -55,7 +55,7 @@ struct hash { class QVariant; -namespace QMatrixClient { +namespace Quotient { template struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const T& pod) { jo = pod.toJson(); } @@ -439,4 +439,4 @@ inline void addParam(ContT& container, const QString& key, ValT&& value) _impl::AddNode, Force>::impl(container, key, std::forward(value)); } -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/account-data.cpp b/lib/csapi/account-data.cpp index 7d4f1ad7..2e466fa3 100644 --- a/lib/csapi/account-data.cpp +++ b/lib/csapi/account-data.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/account-data.h b/lib/csapi/account-data.h index 75bb9ce3..7417da0d 100644 --- a/lib/csapi/account-data.h +++ b/lib/csapi/account-data.h @@ -8,7 +8,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -122,4 +122,4 @@ public: const QString& roomId, const QString& type); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/admin.cpp b/lib/csapi/admin.cpp index 58334118..d2c20ba8 100644 --- a/lib/csapi/admin.cpp +++ b/lib/csapi/admin.cpp @@ -8,12 +8,12 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -46,7 +46,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class GetWhoIsJob::Private { diff --git a/lib/csapi/admin.h b/lib/csapi/admin.h index bc27c025..472ccf72 100644 --- a/lib/csapi/admin.h +++ b/lib/csapi/admin.h @@ -11,7 +11,7 @@ #include #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -94,4 +94,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/administrative_contact.cpp b/lib/csapi/administrative_contact.cpp index 067fb68a..32bc8c86 100644 --- a/lib/csapi/administrative_contact.cpp +++ b/lib/csapi/administrative_contact.cpp @@ -8,12 +8,12 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -29,7 +29,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class GetAccount3PIDsJob::Private { @@ -67,7 +67,7 @@ BaseJob::Status GetAccount3PIDsJob::parseJson(const QJsonDocument& data) } // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -82,7 +82,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient static const auto Post3PIDsJobName = QStringLiteral("Post3PIDsJob"); diff --git a/lib/csapi/administrative_contact.h b/lib/csapi/administrative_contact.h index 7f2d0cdc..4ccd7596 100644 --- a/lib/csapi/administrative_contact.h +++ b/lib/csapi/administrative_contact.h @@ -12,7 +12,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -256,4 +256,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/appservice_room_directory.cpp b/lib/csapi/appservice_room_directory.cpp index 74e037cd..87221aa4 100644 --- a/lib/csapi/appservice_room_directory.cpp +++ b/lib/csapi/appservice_room_directory.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/appservice_room_directory.h b/lib/csapi/appservice_room_directory.h index d1c3f89f..e19bf320 100644 --- a/lib/csapi/appservice_room_directory.h +++ b/lib/csapi/appservice_room_directory.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -42,4 +42,4 @@ public: const QString& visibility); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/banning.cpp b/lib/csapi/banning.cpp index a46e78f1..eac09d5a 100644 --- a/lib/csapi/banning.cpp +++ b/lib/csapi/banning.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/banning.h b/lib/csapi/banning.h index 0aa5785b..5df878a8 100644 --- a/lib/csapi/banning.h +++ b/lib/csapi/banning.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -58,4 +58,4 @@ public: explicit UnbanJob(const QString& roomId, const QString& userId); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/capabilities.cpp b/lib/csapi/capabilities.cpp index 9a054fe9..6a544a1e 100644 --- a/lib/csapi/capabilities.cpp +++ b/lib/csapi/capabilities.cpp @@ -8,12 +8,12 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -49,7 +49,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class GetCapabilitiesJob::Private { diff --git a/lib/csapi/capabilities.h b/lib/csapi/capabilities.h index f6e7ad06..b608a2f2 100644 --- a/lib/csapi/capabilities.h +++ b/lib/csapi/capabilities.h @@ -11,7 +11,7 @@ #include #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -84,4 +84,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/content-repo.cpp b/lib/csapi/content-repo.cpp index c2720d63..395337f3 100644 --- a/lib/csapi/content-repo.cpp +++ b/lib/csapi/content-repo.cpp @@ -9,7 +9,7 @@ #include #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/media/r0"); diff --git a/lib/csapi/content-repo.h b/lib/csapi/content-repo.h index 9f267f6c..83069490 100644 --- a/lib/csapi/content-repo.h +++ b/lib/csapi/content-repo.h @@ -10,7 +10,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -282,4 +282,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/create_room.cpp b/lib/csapi/create_room.cpp index e94cb008..68741f13 100644 --- a/lib/csapi/create_room.cpp +++ b/lib/csapi/create_room.cpp @@ -8,12 +8,12 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -38,7 +38,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class CreateRoomJob::Private { diff --git a/lib/csapi/create_room.h b/lib/csapi/create_room.h index a066a3f3..e7000155 100644 --- a/lib/csapi/create_room.h +++ b/lib/csapi/create_room.h @@ -11,7 +11,7 @@ #include #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -235,4 +235,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/auth_data.cpp b/lib/csapi/definitions/auth_data.cpp index 3bb51626..edeb7111 100644 --- a/lib/csapi/definitions/auth_data.cpp +++ b/lib/csapi/definitions/auth_data.cpp @@ -4,7 +4,7 @@ #include "auth_data.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo( QJsonObject& jo, const AuthenticationData& pod) diff --git a/lib/csapi/definitions/auth_data.h b/lib/csapi/definitions/auth_data.h index 9e46812c..1aeea6c2 100644 --- a/lib/csapi/definitions/auth_data.h +++ b/lib/csapi/definitions/auth_data.h @@ -9,7 +9,7 @@ #include #include -namespace QMatrixClient +namespace Quotient { // Data structures @@ -34,4 +34,4 @@ struct JsonObjectConverter static void fillFrom(QJsonObject jo, AuthenticationData& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/client_device.cpp b/lib/csapi/definitions/client_device.cpp index c9e6a223..09544138 100644 --- a/lib/csapi/definitions/client_device.cpp +++ b/lib/csapi/definitions/client_device.cpp @@ -4,7 +4,7 @@ #include "client_device.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const Device& pod) { diff --git a/lib/csapi/definitions/client_device.h b/lib/csapi/definitions/client_device.h index e4accc35..f076c4da 100644 --- a/lib/csapi/definitions/client_device.h +++ b/lib/csapi/definitions/client_device.h @@ -6,7 +6,7 @@ #include "converters.h" -namespace QMatrixClient +namespace Quotient { // Data structures @@ -34,4 +34,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, Device& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/device_keys.cpp b/lib/csapi/definitions/device_keys.cpp index cc5262b7..0583840d 100644 --- a/lib/csapi/definitions/device_keys.cpp +++ b/lib/csapi/definitions/device_keys.cpp @@ -4,7 +4,7 @@ #include "device_keys.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const DeviceKeys& pod) diff --git a/lib/csapi/definitions/device_keys.h b/lib/csapi/definitions/device_keys.h index 6bd96584..d1d8abef 100644 --- a/lib/csapi/definitions/device_keys.h +++ b/lib/csapi/definitions/device_keys.h @@ -8,7 +8,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Data structures @@ -41,4 +41,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, DeviceKeys& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/event_filter.cpp b/lib/csapi/definitions/event_filter.cpp index 9b2c7a33..b21e08b5 100644 --- a/lib/csapi/definitions/event_filter.cpp +++ b/lib/csapi/definitions/event_filter.cpp @@ -4,7 +4,7 @@ #include "event_filter.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const EventFilter& pod) diff --git a/lib/csapi/definitions/event_filter.h b/lib/csapi/definitions/event_filter.h index 9b9b3fa3..b41e2e9e 100644 --- a/lib/csapi/definitions/event_filter.h +++ b/lib/csapi/definitions/event_filter.h @@ -6,7 +6,7 @@ #include "converters.h" -namespace QMatrixClient +namespace Quotient { // Data structures @@ -40,4 +40,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, EventFilter& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/public_rooms_response.cpp b/lib/csapi/definitions/public_rooms_response.cpp index d07b1494..b6009718 100644 --- a/lib/csapi/definitions/public_rooms_response.cpp +++ b/lib/csapi/definitions/public_rooms_response.cpp @@ -4,7 +4,7 @@ #include "public_rooms_response.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const PublicRoomsChunk& pod) diff --git a/lib/csapi/definitions/public_rooms_response.h b/lib/csapi/definitions/public_rooms_response.h index e86e306f..1cb3aad5 100644 --- a/lib/csapi/definitions/public_rooms_response.h +++ b/lib/csapi/definitions/public_rooms_response.h @@ -8,7 +8,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Data structures @@ -67,4 +67,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, PublicRoomsResponse& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/push_condition.cpp b/lib/csapi/definitions/push_condition.cpp index 5bcb845e..343b4f1a 100644 --- a/lib/csapi/definitions/push_condition.cpp +++ b/lib/csapi/definitions/push_condition.cpp @@ -4,7 +4,7 @@ #include "push_condition.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const PushCondition& pod) diff --git a/lib/csapi/definitions/push_condition.h b/lib/csapi/definitions/push_condition.h index 2c17023e..34a183de 100644 --- a/lib/csapi/definitions/push_condition.h +++ b/lib/csapi/definitions/push_condition.h @@ -6,7 +6,7 @@ #include "converters.h" -namespace QMatrixClient +namespace Quotient { // Data structures @@ -36,4 +36,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, PushCondition& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/push_rule.cpp b/lib/csapi/definitions/push_rule.cpp index fc2be2c7..eae7e446 100644 --- a/lib/csapi/definitions/push_rule.cpp +++ b/lib/csapi/definitions/push_rule.cpp @@ -4,7 +4,7 @@ #include "push_rule.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const PushRule& pod) { diff --git a/lib/csapi/definitions/push_rule.h b/lib/csapi/definitions/push_rule.h index fe6eb0e6..e64d6ba8 100644 --- a/lib/csapi/definitions/push_rule.h +++ b/lib/csapi/definitions/push_rule.h @@ -12,7 +12,7 @@ #include #include -namespace QMatrixClient +namespace Quotient { // Data structures @@ -43,4 +43,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, PushRule& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/push_ruleset.cpp b/lib/csapi/definitions/push_ruleset.cpp index 6f48d27b..a2db35d9 100644 --- a/lib/csapi/definitions/push_ruleset.cpp +++ b/lib/csapi/definitions/push_ruleset.cpp @@ -4,7 +4,7 @@ #include "push_ruleset.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const PushRuleset& pod) diff --git a/lib/csapi/definitions/push_ruleset.h b/lib/csapi/definitions/push_ruleset.h index f9aedad8..b6b9670e 100644 --- a/lib/csapi/definitions/push_ruleset.h +++ b/lib/csapi/definitions/push_ruleset.h @@ -10,7 +10,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Data structures @@ -36,4 +36,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, PushRuleset& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/room_event_filter.cpp b/lib/csapi/definitions/room_event_filter.cpp index bd38ebc7..5613d8d2 100644 --- a/lib/csapi/definitions/room_event_filter.cpp +++ b/lib/csapi/definitions/room_event_filter.cpp @@ -4,7 +4,7 @@ #include "room_event_filter.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const RoomEventFilter& pod) diff --git a/lib/csapi/definitions/room_event_filter.h b/lib/csapi/definitions/room_event_filter.h index 72bf34d3..ae06a615 100644 --- a/lib/csapi/definitions/room_event_filter.h +++ b/lib/csapi/definitions/room_event_filter.h @@ -8,7 +8,7 @@ #include "csapi/definitions/event_filter.h" -namespace QMatrixClient +namespace Quotient { // Data structures @@ -35,4 +35,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, RoomEventFilter& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/sync_filter.cpp b/lib/csapi/definitions/sync_filter.cpp index 87274a06..15c4bdc1 100644 --- a/lib/csapi/definitions/sync_filter.cpp +++ b/lib/csapi/definitions/sync_filter.cpp @@ -4,7 +4,7 @@ #include "sync_filter.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const StateFilter& pod) diff --git a/lib/csapi/definitions/sync_filter.h b/lib/csapi/definitions/sync_filter.h index 1d6a845c..9ea39a65 100644 --- a/lib/csapi/definitions/sync_filter.h +++ b/lib/csapi/definitions/sync_filter.h @@ -9,7 +9,7 @@ #include "csapi/definitions/event_filter.h" #include "csapi/definitions/room_event_filter.h" -namespace QMatrixClient +namespace Quotient { // Data structures @@ -104,4 +104,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, Filter& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/user_identifier.cpp b/lib/csapi/definitions/user_identifier.cpp index 52bb1ae6..9e9b4fe9 100644 --- a/lib/csapi/definitions/user_identifier.cpp +++ b/lib/csapi/definitions/user_identifier.cpp @@ -4,7 +4,7 @@ #include "user_identifier.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const UserIdentifier& pod) diff --git a/lib/csapi/definitions/user_identifier.h b/lib/csapi/definitions/user_identifier.h index 51c47cca..74e6ce2b 100644 --- a/lib/csapi/definitions/user_identifier.h +++ b/lib/csapi/definitions/user_identifier.h @@ -8,7 +8,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Data structures @@ -31,4 +31,4 @@ struct JsonObjectConverter static void fillFrom(QJsonObject jo, UserIdentifier& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/wellknown/full.cpp b/lib/csapi/definitions/wellknown/full.cpp index 34d3bfbe..595db0e5 100644 --- a/lib/csapi/definitions/wellknown/full.cpp +++ b/lib/csapi/definitions/wellknown/full.cpp @@ -4,7 +4,7 @@ #include "full.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo( QJsonObject& jo, const DiscoveryInformation& pod) diff --git a/lib/csapi/definitions/wellknown/full.h b/lib/csapi/definitions/wellknown/full.h index ddc06653..92c8afff 100644 --- a/lib/csapi/definitions/wellknown/full.h +++ b/lib/csapi/definitions/wellknown/full.h @@ -12,7 +12,7 @@ #include #include -namespace QMatrixClient +namespace Quotient { // Data structures @@ -39,4 +39,4 @@ struct JsonObjectConverter static void fillFrom(QJsonObject jo, DiscoveryInformation& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/wellknown/homeserver.cpp b/lib/csapi/definitions/wellknown/homeserver.cpp index f5746ede..7b87aa95 100644 --- a/lib/csapi/definitions/wellknown/homeserver.cpp +++ b/lib/csapi/definitions/wellknown/homeserver.cpp @@ -4,7 +4,7 @@ #include "homeserver.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo( QJsonObject& jo, const HomeserverInformation& pod) diff --git a/lib/csapi/definitions/wellknown/homeserver.h b/lib/csapi/definitions/wellknown/homeserver.h index b73cee17..606df88b 100644 --- a/lib/csapi/definitions/wellknown/homeserver.h +++ b/lib/csapi/definitions/wellknown/homeserver.h @@ -6,7 +6,7 @@ #include "converters.h" -namespace QMatrixClient +namespace Quotient { // Data structures @@ -25,4 +25,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, HomeserverInformation& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/definitions/wellknown/identity_server.cpp b/lib/csapi/definitions/wellknown/identity_server.cpp index 922d4665..3b2a5720 100644 --- a/lib/csapi/definitions/wellknown/identity_server.cpp +++ b/lib/csapi/definitions/wellknown/identity_server.cpp @@ -4,7 +4,7 @@ #include "identity_server.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo( QJsonObject& jo, const IdentityServerInformation& pod) diff --git a/lib/csapi/definitions/wellknown/identity_server.h b/lib/csapi/definitions/wellknown/identity_server.h index a35644fc..b4304ef7 100644 --- a/lib/csapi/definitions/wellknown/identity_server.h +++ b/lib/csapi/definitions/wellknown/identity_server.h @@ -6,7 +6,7 @@ #include "converters.h" -namespace QMatrixClient +namespace Quotient { // Data structures @@ -25,4 +25,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, IdentityServerInformation& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/device_management.cpp b/lib/csapi/device_management.cpp index 9135c22d..0889089e 100644 --- a/lib/csapi/device_management.cpp +++ b/lib/csapi/device_management.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/device_management.h b/lib/csapi/device_management.h index 01838c6f..d380a44f 100644 --- a/lib/csapi/device_management.h +++ b/lib/csapi/device_management.h @@ -13,7 +13,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -145,4 +145,4 @@ public: const Omittable& auth = none); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/directory.cpp b/lib/csapi/directory.cpp index 992d1da5..b2689d1e 100644 --- a/lib/csapi/directory.cpp +++ b/lib/csapi/directory.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0/directory"); diff --git a/lib/csapi/directory.h b/lib/csapi/directory.h index f5331db8..7863aa1a 100644 --- a/lib/csapi/directory.h +++ b/lib/csapi/directory.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -93,4 +93,4 @@ public: static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomAlias); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/event_context.cpp b/lib/csapi/event_context.cpp index 936b2430..d233eedb 100644 --- a/lib/csapi/event_context.cpp +++ b/lib/csapi/event_context.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/event_context.h b/lib/csapi/event_context.h index ca06f4b9..755fc662 100644 --- a/lib/csapi/event_context.h +++ b/lib/csapi/event_context.h @@ -9,7 +9,7 @@ #include "events/eventloader.h" #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -71,4 +71,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/filter.cpp b/lib/csapi/filter.cpp index 79dd5ea5..b4160ba4 100644 --- a/lib/csapi/filter.cpp +++ b/lib/csapi/filter.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/filter.h b/lib/csapi/filter.h index 0a5a98ae..5001a492 100644 --- a/lib/csapi/filter.h +++ b/lib/csapi/filter.h @@ -10,7 +10,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -88,4 +88,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/inviting.cpp b/lib/csapi/inviting.cpp index 4ddbe5d0..b60df6f8 100644 --- a/lib/csapi/inviting.cpp +++ b/lib/csapi/inviting.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/inviting.h b/lib/csapi/inviting.h index b0911ea8..faf315b1 100644 --- a/lib/csapi/inviting.h +++ b/lib/csapi/inviting.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -44,4 +44,4 @@ public: explicit InviteUserJob(const QString& roomId, const QString& userId); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/joining.cpp b/lib/csapi/joining.cpp index cb40cb96..2dd617bb 100644 --- a/lib/csapi/joining.cpp +++ b/lib/csapi/joining.cpp @@ -8,12 +8,12 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -29,7 +29,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class JoinRoomByIdJob::Private { @@ -67,7 +67,7 @@ BaseJob::Status JoinRoomByIdJob::parseJson(const QJsonDocument& data) } // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -91,7 +91,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class JoinRoomJob::Private { diff --git a/lib/csapi/joining.h b/lib/csapi/joining.h index a96f323d..cf456da9 100644 --- a/lib/csapi/joining.h +++ b/lib/csapi/joining.h @@ -10,7 +10,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -165,4 +165,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/keys.cpp b/lib/csapi/keys.cpp index 1752b865..cd33ad19 100644 --- a/lib/csapi/keys.cpp +++ b/lib/csapi/keys.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); @@ -50,7 +50,7 @@ BaseJob::Status UploadKeysJob::parseJson(const QJsonDocument& data) } // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -74,7 +74,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class QueryKeysJob::Private { diff --git a/lib/csapi/keys.h b/lib/csapi/keys.h index f69028fd..27867b8c 100644 --- a/lib/csapi/keys.h +++ b/lib/csapi/keys.h @@ -14,7 +14,7 @@ #include #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -231,4 +231,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/kicking.cpp b/lib/csapi/kicking.cpp index 05c4c581..ce7fcdad 100644 --- a/lib/csapi/kicking.cpp +++ b/lib/csapi/kicking.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/kicking.h b/lib/csapi/kicking.h index 9566a9a4..d51edb47 100644 --- a/lib/csapi/kicking.h +++ b/lib/csapi/kicking.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -39,4 +39,4 @@ public: const QString& reason = {}); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/leaving.cpp b/lib/csapi/leaving.cpp index 325b1e04..abf04888 100644 --- a/lib/csapi/leaving.cpp +++ b/lib/csapi/leaving.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/leaving.h b/lib/csapi/leaving.h index 2ed6c8e7..280545b0 100644 --- a/lib/csapi/leaving.h +++ b/lib/csapi/leaving.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -73,4 +73,4 @@ public: static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/list_joined_rooms.cpp b/lib/csapi/list_joined_rooms.cpp index 43c948f7..1260499a 100644 --- a/lib/csapi/list_joined_rooms.cpp +++ b/lib/csapi/list_joined_rooms.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/list_joined_rooms.h b/lib/csapi/list_joined_rooms.h index 1b64a004..5dab9dfc 100644 --- a/lib/csapi/list_joined_rooms.h +++ b/lib/csapi/list_joined_rooms.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -43,4 +43,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/list_public_rooms.cpp b/lib/csapi/list_public_rooms.cpp index 4d96dac3..0e065440 100644 --- a/lib/csapi/list_public_rooms.cpp +++ b/lib/csapi/list_public_rooms.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); @@ -108,7 +108,7 @@ BaseJob::Status GetPublicRoomsJob::parseJson(const QJsonDocument& data) } // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -121,7 +121,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class QueryPublicRoomsJob::Private { diff --git a/lib/csapi/list_public_rooms.h b/lib/csapi/list_public_rooms.h index da68416d..e68030ad 100644 --- a/lib/csapi/list_public_rooms.h +++ b/lib/csapi/list_public_rooms.h @@ -10,7 +10,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -189,4 +189,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/login.cpp b/lib/csapi/login.cpp index 29ee4ab5..02730ff0 100644 --- a/lib/csapi/login.cpp +++ b/lib/csapi/login.cpp @@ -8,12 +8,12 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -26,7 +26,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class GetLoginFlowsJob::Private { diff --git a/lib/csapi/login.h b/lib/csapi/login.h index 3ab0648f..dc944782 100644 --- a/lib/csapi/login.h +++ b/lib/csapi/login.h @@ -13,7 +13,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -143,4 +143,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/logout.cpp b/lib/csapi/logout.cpp index d0bef20e..4b391967 100644 --- a/lib/csapi/logout.cpp +++ b/lib/csapi/logout.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/logout.h b/lib/csapi/logout.h index c03af180..34d5a441 100644 --- a/lib/csapi/logout.h +++ b/lib/csapi/logout.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -55,4 +55,4 @@ public: static QUrl makeRequestUrl(QUrl baseUrl); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/message_pagination.cpp b/lib/csapi/message_pagination.cpp index 3f09bd85..b612ee91 100644 --- a/lib/csapi/message_pagination.cpp +++ b/lib/csapi/message_pagination.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/message_pagination.h b/lib/csapi/message_pagination.h index 03b3d42a..271e1dd9 100644 --- a/lib/csapi/message_pagination.h +++ b/lib/csapi/message_pagination.h @@ -9,7 +9,7 @@ #include "events/eventloader.h" #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -80,4 +80,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/notifications.cpp b/lib/csapi/notifications.cpp index 3a05a0b2..da568a0f 100644 --- a/lib/csapi/notifications.cpp +++ b/lib/csapi/notifications.cpp @@ -8,12 +8,12 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -31,7 +31,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class GetNotificationsJob::Private { diff --git a/lib/csapi/notifications.h b/lib/csapi/notifications.h index 4170d539..eeec5d4e 100644 --- a/lib/csapi/notifications.h +++ b/lib/csapi/notifications.h @@ -13,7 +13,7 @@ #include #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -94,4 +94,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/openid.cpp b/lib/csapi/openid.cpp index 39ba3b9e..8c00df97 100644 --- a/lib/csapi/openid.cpp +++ b/lib/csapi/openid.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/openid.h b/lib/csapi/openid.h index 40f1bc40..b2f003e5 100644 --- a/lib/csapi/openid.h +++ b/lib/csapi/openid.h @@ -10,7 +10,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -64,4 +64,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/peeking_events.cpp b/lib/csapi/peeking_events.cpp index 6962d363..bc29b682 100644 --- a/lib/csapi/peeking_events.cpp +++ b/lib/csapi/peeking_events.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/peeking_events.h b/lib/csapi/peeking_events.h index 1fe63c4d..c5cc07f6 100644 --- a/lib/csapi/peeking_events.h +++ b/lib/csapi/peeking_events.h @@ -9,7 +9,7 @@ #include "events/eventloader.h" #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -74,4 +74,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/presence.cpp b/lib/csapi/presence.cpp index b6e8caf2..0f019026 100644 --- a/lib/csapi/presence.cpp +++ b/lib/csapi/presence.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/presence.h b/lib/csapi/presence.h index 82c3a300..c5ecb987 100644 --- a/lib/csapi/presence.h +++ b/lib/csapi/presence.h @@ -8,7 +8,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -78,4 +78,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/profile.cpp b/lib/csapi/profile.cpp index 630452f6..27168f77 100644 --- a/lib/csapi/profile.cpp +++ b/lib/csapi/profile.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/profile.h b/lib/csapi/profile.h index 95d3ec97..54dc53aa 100644 --- a/lib/csapi/profile.h +++ b/lib/csapi/profile.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -164,4 +164,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/pusher.cpp b/lib/csapi/pusher.cpp index 41a0cffe..90877a95 100644 --- a/lib/csapi/pusher.cpp +++ b/lib/csapi/pusher.cpp @@ -8,12 +8,12 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -43,7 +43,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class GetPushersJob::Private { @@ -79,7 +79,7 @@ BaseJob::Status GetPushersJob::parseJson(const QJsonDocument& data) } // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -92,7 +92,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient static const auto PostPusherJobName = QStringLiteral("PostPusherJob"); diff --git a/lib/csapi/pusher.h b/lib/csapi/pusher.h index a909b9a0..65f8aa15 100644 --- a/lib/csapi/pusher.h +++ b/lib/csapi/pusher.h @@ -10,7 +10,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -169,4 +169,4 @@ public: Omittable append = none); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/pushrules.cpp b/lib/csapi/pushrules.cpp index 5842369f..eae5445f 100644 --- a/lib/csapi/pushrules.cpp +++ b/lib/csapi/pushrules.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/pushrules.h b/lib/csapi/pushrules.h index 9074addb..cb94fe7b 100644 --- a/lib/csapi/pushrules.h +++ b/lib/csapi/pushrules.h @@ -14,7 +14,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -297,4 +297,4 @@ public: const QStringList& actions); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/read_markers.cpp b/lib/csapi/read_markers.cpp index 5ea45f88..a07d09ce 100644 --- a/lib/csapi/read_markers.cpp +++ b/lib/csapi/read_markers.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/read_markers.h b/lib/csapi/read_markers.h index e1fbc263..35c428b2 100644 --- a/lib/csapi/read_markers.h +++ b/lib/csapi/read_markers.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -34,4 +34,4 @@ public: const QString& mRead = {}); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/receipts.cpp b/lib/csapi/receipts.cpp index 28d7032f..f9a45912 100644 --- a/lib/csapi/receipts.cpp +++ b/lib/csapi/receipts.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/receipts.h b/lib/csapi/receipts.h index bb037c08..376d4006 100644 --- a/lib/csapi/receipts.h +++ b/lib/csapi/receipts.h @@ -8,7 +8,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -37,4 +37,4 @@ public: const QJsonObject& receipt = {}); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/redaction.cpp b/lib/csapi/redaction.cpp index f944cdd4..d2dbe19b 100644 --- a/lib/csapi/redaction.cpp +++ b/lib/csapi/redaction.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/redaction.h b/lib/csapi/redaction.h index c75421cb..42022930 100644 --- a/lib/csapi/redaction.h +++ b/lib/csapi/redaction.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -53,4 +53,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index 52b4098d..270011e1 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/registration.h b/lib/csapi/registration.h index 40f1caa6..89aecb80 100644 --- a/lib/csapi/registration.h +++ b/lib/csapi/registration.h @@ -11,7 +11,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -480,4 +480,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/report_content.cpp b/lib/csapi/report_content.cpp index eb62cd12..352f52c9 100644 --- a/lib/csapi/report_content.cpp +++ b/lib/csapi/report_content.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/report_content.h b/lib/csapi/report_content.h index c545d800..c86a4301 100644 --- a/lib/csapi/report_content.h +++ b/lib/csapi/report_content.h @@ -8,7 +8,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -36,4 +36,4 @@ public: int score, const QString& reason); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/room_send.cpp b/lib/csapi/room_send.cpp index a29dd99a..5e970d65 100644 --- a/lib/csapi/room_send.cpp +++ b/lib/csapi/room_send.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/room_send.h b/lib/csapi/room_send.h index aa2efd79..110fc83b 100644 --- a/lib/csapi/room_send.h +++ b/lib/csapi/room_send.h @@ -8,7 +8,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -62,4 +62,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/room_state.cpp b/lib/csapi/room_state.cpp index ef4afcd0..bfcd6e17 100644 --- a/lib/csapi/room_state.cpp +++ b/lib/csapi/room_state.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/room_state.h b/lib/csapi/room_state.h index 6ddd5594..80619d63 100644 --- a/lib/csapi/room_state.h +++ b/lib/csapi/room_state.h @@ -8,7 +8,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -126,4 +126,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/room_upgrades.cpp b/lib/csapi/room_upgrades.cpp index a72304d1..1d6006ef 100644 --- a/lib/csapi/room_upgrades.cpp +++ b/lib/csapi/room_upgrades.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/room_upgrades.h b/lib/csapi/room_upgrades.h index 94520aca..5f9262f1 100644 --- a/lib/csapi/room_upgrades.h +++ b/lib/csapi/room_upgrades.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -41,4 +41,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/rooms.cpp b/lib/csapi/rooms.cpp index 280e8d59..5bfbe44d 100644 --- a/lib/csapi/rooms.cpp +++ b/lib/csapi/rooms.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); @@ -168,7 +168,7 @@ BaseJob::Status GetMembersByRoomJob::parseJson(const QJsonDocument& data) } // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -182,7 +182,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class GetJoinedMembersByRoomJob::Private { diff --git a/lib/csapi/rooms.h b/lib/csapi/rooms.h index 29d7808e..1020fdb1 100644 --- a/lib/csapi/rooms.h +++ b/lib/csapi/rooms.h @@ -12,7 +12,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -269,4 +269,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/search.cpp b/lib/csapi/search.cpp index ee1fa70c..9619f340 100644 --- a/lib/csapi/search.cpp +++ b/lib/csapi/search.cpp @@ -8,12 +8,12 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -144,7 +144,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class SearchJob::Private { diff --git a/lib/csapi/search.h b/lib/csapi/search.h index f965a72a..079ac8e9 100644 --- a/lib/csapi/search.h +++ b/lib/csapi/search.h @@ -16,7 +16,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -200,4 +200,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/sso_login_redirect.cpp b/lib/csapi/sso_login_redirect.cpp index b1dc3674..c2cc81cf 100644 --- a/lib/csapi/sso_login_redirect.cpp +++ b/lib/csapi/sso_login_redirect.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/sso_login_redirect.h b/lib/csapi/sso_login_redirect.h index af9e7780..b932a15e 100644 --- a/lib/csapi/sso_login_redirect.h +++ b/lib/csapi/sso_login_redirect.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -37,4 +37,4 @@ public: static QUrl makeRequestUrl(QUrl baseUrl, const QString& redirectUrl); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/tags.cpp b/lib/csapi/tags.cpp index 13c933e5..3df38074 100644 --- a/lib/csapi/tags.cpp +++ b/lib/csapi/tags.cpp @@ -8,12 +8,12 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -26,7 +26,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class GetRoomTagsJob::Private { diff --git a/lib/csapi/tags.h b/lib/csapi/tags.h index dc20cd3d..8ddebd6b 100644 --- a/lib/csapi/tags.h +++ b/lib/csapi/tags.h @@ -11,7 +11,7 @@ #include #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -123,4 +123,4 @@ public: const QString& roomId, const QString& tag); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/third_party_lookup.cpp b/lib/csapi/third_party_lookup.cpp index 986ead01..678f6b3c 100644 --- a/lib/csapi/third_party_lookup.cpp +++ b/lib/csapi/third_party_lookup.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/third_party_lookup.h b/lib/csapi/third_party_lookup.h index d25c1cf3..63607549 100644 --- a/lib/csapi/third_party_lookup.h +++ b/lib/csapi/third_party_lookup.h @@ -15,7 +15,7 @@ #include #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -253,4 +253,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/third_party_membership.cpp b/lib/csapi/third_party_membership.cpp index 9fe702aa..7e401163 100644 --- a/lib/csapi/third_party_membership.cpp +++ b/lib/csapi/third_party_membership.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/third_party_membership.h b/lib/csapi/third_party_membership.h index 36622c94..bd4c6896 100644 --- a/lib/csapi/third_party_membership.h +++ b/lib/csapi/third_party_membership.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -74,4 +74,4 @@ public: const QString& medium, const QString& address); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/to_device.cpp b/lib/csapi/to_device.cpp index 3fb17109..3f6e8097 100644 --- a/lib/csapi/to_device.cpp +++ b/lib/csapi/to_device.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/to_device.h b/lib/csapi/to_device.h index e0bbbe28..14445439 100644 --- a/lib/csapi/to_device.h +++ b/lib/csapi/to_device.h @@ -9,7 +9,7 @@ #include #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -39,4 +39,4 @@ public: const QHash>& messages = {}); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/typing.cpp b/lib/csapi/typing.cpp index 03499c76..064ebe39 100644 --- a/lib/csapi/typing.cpp +++ b/lib/csapi/typing.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/typing.h b/lib/csapi/typing.h index 0c3f75a8..350c209d 100644 --- a/lib/csapi/typing.h +++ b/lib/csapi/typing.h @@ -8,7 +8,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -38,4 +38,4 @@ public: bool typing, Omittable timeout = none); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/users.cpp b/lib/csapi/users.cpp index 39b05a77..77c297dd 100644 --- a/lib/csapi/users.cpp +++ b/lib/csapi/users.cpp @@ -8,12 +8,12 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -28,7 +28,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class SearchUserDirectoryJob::Private { diff --git a/lib/csapi/users.h b/lib/csapi/users.h index 2e86c009..d9a16a9d 100644 --- a/lib/csapi/users.h +++ b/lib/csapi/users.h @@ -10,7 +10,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -80,4 +80,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/versions.cpp b/lib/csapi/versions.cpp index 1d66b94f..9607a1b6 100644 --- a/lib/csapi/versions.cpp +++ b/lib/csapi/versions.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client"); diff --git a/lib/csapi/versions.h b/lib/csapi/versions.h index 513e7f27..aa8cbac6 100644 --- a/lib/csapi/versions.h +++ b/lib/csapi/versions.h @@ -10,7 +10,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -70,4 +70,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/voip.cpp b/lib/csapi/voip.cpp index 0e83c915..c95afe16 100644 --- a/lib/csapi/voip.cpp +++ b/lib/csapi/voip.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/voip.h b/lib/csapi/voip.h index ab34dcad..38abfa27 100644 --- a/lib/csapi/voip.h +++ b/lib/csapi/voip.h @@ -8,7 +8,7 @@ #include -namespace QMatrixClient +namespace Quotient { // Operations @@ -46,4 +46,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/wellknown.cpp b/lib/csapi/wellknown.cpp index c2bd7822..9a52a2a5 100644 --- a/lib/csapi/wellknown.cpp +++ b/lib/csapi/wellknown.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/.well-known"); diff --git a/lib/csapi/wellknown.h b/lib/csapi/wellknown.h index 66917806..bce67d00 100644 --- a/lib/csapi/wellknown.h +++ b/lib/csapi/wellknown.h @@ -10,7 +10,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -54,4 +54,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/whoami.cpp b/lib/csapi/whoami.cpp index 2ca9c435..fb7f54dc 100644 --- a/lib/csapi/whoami.cpp +++ b/lib/csapi/whoami.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); diff --git a/lib/csapi/whoami.h b/lib/csapi/whoami.h index e62b7dad..bbbb3899 100644 --- a/lib/csapi/whoami.h +++ b/lib/csapi/whoami.h @@ -6,7 +6,7 @@ #include "jobs/basejob.h" -namespace QMatrixClient +namespace Quotient { // Operations @@ -50,4 +50,4 @@ private: QScopedPointer d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/csapi/{{base}}.cpp.mustache b/lib/csapi/{{base}}.cpp.mustache index 8ebac6ef..6cbd1b65 100644 --- a/lib/csapi/{{base}}.cpp.mustache +++ b/lib/csapi/{{base}}.cpp.mustache @@ -8,7 +8,7 @@ {{/producesNonJson?}} #include {{/operations}} -using namespace QMatrixClient; +using namespace Quotient; {{#models.model}} {{#in?}} void JsonObjectConverter<{{qualifiedName}}>::dumpTo(QJsonObject& jo, const {{qualifiedName}}& pod) @@ -38,7 +38,7 @@ void JsonObjectConverter<{{qualifiedName}}>::fillFrom({{>maybeCrefJsonObject}} j static const auto basePath = QStringLiteral("{{basePathWithoutHost}}"); {{#operation}}{{#models}} // Converters -namespace QMatrixClient +namespace Quotient { {{#model}} template <> struct JsonObjectConverter<{{qualifiedName}}> diff --git a/lib/csapi/{{base}}.h.mustache b/lib/csapi/{{base}}.h.mustache index 61380ec6..56044e7d 100644 --- a/lib/csapi/{{base}}.h.mustache +++ b/lib/csapi/{{base}}.h.mustache @@ -8,7 +8,7 @@ {{#imports}} #include {{_}}{{/imports}} -namespace QMatrixClient +namespace Quotient { {{#models}} // Data structures @@ -92,4 +92,4 @@ private: }; {{/ operation}} {{/operations}} -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/e2ee.h b/lib/e2ee.h index c85211be..5a9b83c5 100644 --- a/lib/e2ee.h +++ b/lib/e2ee.h @@ -4,7 +4,7 @@ #include -namespace QMatrixClient { +namespace Quotient { static const auto CiphertextKeyL = "ciphertext"_ls; static const auto SenderKeyKeyL = "sender_key"_ls; static const auto DeviceIdKeyL = "device_id"_ls; @@ -28,4 +28,4 @@ static const auto MegolmV1AesSha2AlgoKey = QStringLiteral("m.megolm.v1.aes-sha2"); static const QStringList SupportedAlgorithms = { OlmV1Curve25519AesSha2AlgoKey, MegolmV1AesSha2AlgoKey }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/encryptionmanager.cpp b/lib/encryptionmanager.cpp index 15723688..22387cf9 100644 --- a/lib/encryptionmanager.cpp +++ b/lib/encryptionmanager.cpp @@ -12,7 +12,7 @@ #include #include -using namespace QMatrixClient; +using namespace Quotient; using namespace QtOlm; using std::move; diff --git a/lib/encryptionmanager.h b/lib/encryptionmanager.h index 79c25a00..b210a85a 100644 --- a/lib/encryptionmanager.h +++ b/lib/encryptionmanager.h @@ -9,7 +9,7 @@ namespace QtOlm { class Account; } -namespace QMatrixClient { +namespace Quotient { class Connection; class EncryptionManager : public QObject { @@ -35,4 +35,4 @@ private: std::unique_ptr d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/eventitem.cpp b/lib/eventitem.cpp index de0a5c9f..2e2b11c0 100644 --- a/lib/eventitem.cpp +++ b/lib/eventitem.cpp @@ -21,7 +21,7 @@ #include "events/roomavatarevent.h" #include "events/roommessageevent.h" -using namespace QMatrixClient; +using namespace Quotient; void PendingEventItem::setFileUploaded(const QUrl& remoteUrl) { diff --git a/lib/eventitem.h b/lib/eventitem.h index 68d1ae06..3a7061d3 100644 --- a/lib/eventitem.h +++ b/lib/eventitem.h @@ -22,7 +22,7 @@ #include -namespace QMatrixClient { +namespace Quotient { class StateEventBase; class EventStatus { @@ -153,5 +153,5 @@ inline QDebug& operator<<(QDebug& d, const TimelineItem& ti) d.nospace() << "(" << ti.index() << "|" << ti->id() << ")"; return d; } -} // namespace QMatrixClient -Q_DECLARE_METATYPE(QMatrixClient::EventStatus) +} // namespace Quotient +Q_DECLARE_METATYPE(Quotient::EventStatus) diff --git a/lib/events/accountdataevents.h b/lib/events/accountdataevents.h index 3f519668..600fa5be 100644 --- a/lib/events/accountdataevents.h +++ b/lib/events/accountdataevents.h @@ -24,7 +24,7 @@ #include "event.h" #include "eventcontent.h" -namespace QMatrixClient { +namespace Quotient { constexpr const char* FavouriteTag = "m.favourite"; constexpr const char* LowPriorityTag = "m.lowpriority"; @@ -93,4 +93,4 @@ DEFINE_SIMPLE_EVENT(IgnoredUsersEvent, "m.ignored_user_list", QSet, DEFINE_EVENTTYPE_ALIAS(Tag, TagEvent) DEFINE_EVENTTYPE_ALIAS(ReadMarker, ReadMarkerEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/callanswerevent.cpp b/lib/events/callanswerevent.cpp index 7ab4a6fb..d6622b30 100644 --- a/lib/events/callanswerevent.cpp +++ b/lib/events/callanswerevent.cpp @@ -44,7 +44,7 @@ m.call.answer } */ -using namespace QMatrixClient; +using namespace Quotient; CallAnswerEvent::CallAnswerEvent(const QJsonObject& obj) : CallEventBase(typeId(), obj) diff --git a/lib/events/callanswerevent.h b/lib/events/callanswerevent.h index 052f732d..e01b39db 100644 --- a/lib/events/callanswerevent.h +++ b/lib/events/callanswerevent.h @@ -20,7 +20,7 @@ #include "roomevent.h" -namespace QMatrixClient { +namespace Quotient { class CallAnswerEvent : public CallEventBase { public: DEFINE_EVENT_TYPEID("m.call.answer", CallAnswerEvent) @@ -43,4 +43,4 @@ public: REGISTER_EVENT_TYPE(CallAnswerEvent) DEFINE_EVENTTYPE_ALIAS(CallAnswer, CallAnswerEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/callcandidatesevent.h b/lib/events/callcandidatesevent.h index 2a915a43..3d13ba8a 100644 --- a/lib/events/callcandidatesevent.h +++ b/lib/events/callcandidatesevent.h @@ -20,7 +20,7 @@ #include "roomevent.h" -namespace QMatrixClient { +namespace Quotient { class CallCandidatesEvent : public CallEventBase { public: DEFINE_EVENT_TYPEID("m.call.candidates", CallCandidatesEvent) @@ -43,4 +43,4 @@ public: REGISTER_EVENT_TYPE(CallCandidatesEvent) DEFINE_EVENTTYPE_ALIAS(CallCandidates, CallCandidatesEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/callhangupevent.cpp b/lib/events/callhangupevent.cpp index 2a4fd3da..d41849c3 100644 --- a/lib/events/callhangupevent.cpp +++ b/lib/events/callhangupevent.cpp @@ -39,7 +39,7 @@ m.call.hangup } */ -using namespace QMatrixClient; +using namespace Quotient; CallHangupEvent::CallHangupEvent(const QJsonObject& obj) : CallEventBase(typeId(), obj) diff --git a/lib/events/callhangupevent.h b/lib/events/callhangupevent.h index 97fa2f52..d23e29db 100644 --- a/lib/events/callhangupevent.h +++ b/lib/events/callhangupevent.h @@ -20,7 +20,7 @@ #include "roomevent.h" -namespace QMatrixClient { +namespace Quotient { class CallHangupEvent : public CallEventBase { public: DEFINE_EVENT_TYPEID("m.call.hangup", CallHangupEvent) @@ -31,4 +31,4 @@ public: REGISTER_EVENT_TYPE(CallHangupEvent) DEFINE_EVENTTYPE_ALIAS(CallHangup, CallHangupEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/callinviteevent.cpp b/lib/events/callinviteevent.cpp index f565fc3e..54faac8d 100644 --- a/lib/events/callinviteevent.cpp +++ b/lib/events/callinviteevent.cpp @@ -44,7 +44,7 @@ m.call.invite } */ -using namespace QMatrixClient; +using namespace Quotient; CallInviteEvent::CallInviteEvent(const QJsonObject& obj) : CallEventBase(typeId(), obj) diff --git a/lib/events/callinviteevent.h b/lib/events/callinviteevent.h index 9b9d0ae5..3e39e0ba 100644 --- a/lib/events/callinviteevent.h +++ b/lib/events/callinviteevent.h @@ -20,7 +20,7 @@ #include "roomevent.h" -namespace QMatrixClient { +namespace Quotient { class CallInviteEvent : public CallEventBase { public: DEFINE_EVENT_TYPEID("m.call.invite", CallInviteEvent) @@ -42,4 +42,4 @@ public: REGISTER_EVENT_TYPE(CallInviteEvent) DEFINE_EVENTTYPE_ALIAS(CallInvite, CallInviteEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/directchatevent.cpp b/lib/events/directchatevent.cpp index 4ba098c2..b4027e16 100644 --- a/lib/events/directchatevent.cpp +++ b/lib/events/directchatevent.cpp @@ -20,7 +20,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; QMultiHash DirectChatEvent::usersToDirectChats() const { diff --git a/lib/events/directchatevent.h b/lib/events/directchatevent.h index 94857a93..b4981f2e 100644 --- a/lib/events/directchatevent.h +++ b/lib/events/directchatevent.h @@ -20,7 +20,7 @@ #include "event.h" -namespace QMatrixClient { +namespace Quotient { class DirectChatEvent : public Event { public: DEFINE_EVENT_TYPEID("m.direct", DirectChatEvent) @@ -31,4 +31,4 @@ public: }; REGISTER_EVENT_TYPE(DirectChatEvent) DEFINE_EVENTTYPE_ALIAS(DirectChat, DirectChatEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/encryptedevent.h b/lib/events/encryptedevent.h index 67298a27..235b2aa4 100644 --- a/lib/events/encryptedevent.h +++ b/lib/events/encryptedevent.h @@ -3,7 +3,7 @@ #include "e2ee.h" #include "roomevent.h" -namespace QMatrixClient { +namespace Quotient { class Room; /* * While the specification states: @@ -63,4 +63,4 @@ public: }; REGISTER_EVENT_TYPE(EncryptedEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/encryptionevent.cpp b/lib/events/encryptionevent.cpp index 0c732a51..945e6696 100644 --- a/lib/events/encryptionevent.cpp +++ b/lib/events/encryptionevent.cpp @@ -12,10 +12,10 @@ #include static const std::array encryptionStrings = { - { QMatrixClient::MegolmV1AesSha2AlgoKey } + { Quotient::MegolmV1AesSha2AlgoKey } }; -namespace QMatrixClient { +namespace Quotient { template <> struct JsonConverter { static EncryptionType load(const QJsonValue& jv) @@ -32,7 +32,7 @@ struct JsonConverter { }; } // namespace QMatrixClient -using namespace QMatrixClient; +using namespace Quotient; EncryptionEventContent::EncryptionEventContent(const QJsonObject& json) : encryption(fromJson(json["algorithm"_ls])) diff --git a/lib/events/encryptionevent.h b/lib/events/encryptionevent.h index debabcae..68e41719 100644 --- a/lib/events/encryptionevent.h +++ b/lib/events/encryptionevent.h @@ -21,7 +21,7 @@ #include "eventcontent.h" #include "stateevent.h" -namespace QMatrixClient { +namespace Quotient { class EncryptionEventContent : public EventContent::Base { public: enum EncryptionType : size_t { MegolmV1AesSha2 = 0, Undefined }; @@ -71,4 +71,4 @@ private: REGISTER_EVENT_TYPE(EncryptionEvent) DEFINE_EVENTTYPE_ALIAS(Encryption, EncryptionEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/event.cpp b/lib/events/event.cpp index 694254fe..96e33864 100644 --- a/lib/events/event.cpp +++ b/lib/events/event.cpp @@ -22,7 +22,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; event_type_t EventTypeRegistry::initializeTypeId(event_mtype_t matrixTypeId) { diff --git a/lib/events/event.h b/lib/events/event.h index 686bd8e0..e96d6897 100644 --- a/lib/events/event.h +++ b/lib/events/event.h @@ -25,7 +25,7 @@ # define USE_EVENTTYPE_ALIAS 1 #endif -namespace QMatrixClient { +namespace Quotient { // === event_ptr_tt<> and type casting facilities === template @@ -292,7 +292,7 @@ using Events = EventsArray; // provide matrixTypeId() and typeId(). #define DEFINE_EVENT_TYPEID(_Id, _Type) \ static constexpr event_mtype_t matrixTypeId() { return _Id; } \ - static auto typeId() { return QMatrixClient::typeId<_Type>(); } \ + static auto typeId() { return Quotient::typeId<_Type>(); } \ // End of macro // This macro should be put after an event class definition (in .h or .cpp) @@ -406,6 +406,6 @@ visit(const BaseEventT& event, FnT1&& visitor1, FnT2&& visitor2, return visit(event, std::forward(visitor2), std::forward(visitors)...); } -} // namespace QMatrixClient -Q_DECLARE_METATYPE(QMatrixClient::Event*) -Q_DECLARE_METATYPE(const QMatrixClient::Event*) +} // namespace Quotient +Q_DECLARE_METATYPE(Quotient::Event*) +Q_DECLARE_METATYPE(const Quotient::Event*) diff --git a/lib/events/eventcontent.cpp b/lib/events/eventcontent.cpp index 814f2787..802d8176 100644 --- a/lib/events/eventcontent.cpp +++ b/lib/events/eventcontent.cpp @@ -23,7 +23,7 @@ #include -using namespace QMatrixClient::EventContent; +using namespace Quotient::EventContent; QJsonObject Base::toJson() const { diff --git a/lib/events/eventcontent.h b/lib/events/eventcontent.h index 5c0f92d1..c26cb931 100644 --- a/lib/events/eventcontent.h +++ b/lib/events/eventcontent.h @@ -26,7 +26,7 @@ #include #include -namespace QMatrixClient { +namespace Quotient { namespace EventContent { /** * A base class for all content types that can be stored @@ -275,4 +275,4 @@ namespace EventContent { */ using FileContent = UrlWithThumbnailContent; } // namespace EventContent -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/eventloader.h b/lib/events/eventloader.h index 9e8bb410..ebb96441 100644 --- a/lib/events/eventloader.h +++ b/lib/events/eventloader.h @@ -20,7 +20,7 @@ #include "stateevent.h" -namespace QMatrixClient { +namespace Quotient { namespace _impl { template static inline auto loadEvent(const QJsonObject& json, @@ -83,4 +83,4 @@ struct JsonConverter> { return loadEvent(jd.object()); } }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/reactionevent.cpp b/lib/events/reactionevent.cpp index 0a080607..df8910fe 100644 --- a/lib/events/reactionevent.cpp +++ b/lib/events/reactionevent.cpp @@ -20,7 +20,7 @@ using namespace QMatrixClient; -void QMatrixClient::JsonObjectConverter::dumpTo( +void JsonObjectConverter::dumpTo( QJsonObject& jo, const EventRelation& pod) { if (pod.type.isEmpty()) { @@ -33,7 +33,7 @@ void QMatrixClient::JsonObjectConverter::dumpTo( jo.insert(QStringLiteral("key"), pod.key); } -void QMatrixClient::JsonObjectConverter::fillFrom( +void JsonObjectConverter::fillFrom( const QJsonObject& jo, EventRelation& pod) { // The experimental logic for generic relationships (MSC1849) diff --git a/lib/events/reactionevent.h b/lib/events/reactionevent.h index b1e04561..75c6528c 100644 --- a/lib/events/reactionevent.h +++ b/lib/events/reactionevent.h @@ -20,7 +20,7 @@ #include "roomevent.h" -namespace QMatrixClient { +namespace Quotient { struct EventRelation { using reltypeid_t = const char*; @@ -70,4 +70,4 @@ private: }; REGISTER_EVENT_TYPE(ReactionEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/receiptevent.cpp b/lib/events/receiptevent.cpp index 4a54b744..bf050cb2 100644 --- a/lib/events/receiptevent.cpp +++ b/lib/events/receiptevent.cpp @@ -38,7 +38,7 @@ Example of a Receipt Event: #include "converters.h" #include "logging.h" -using namespace QMatrixClient; +using namespace Quotient; ReceiptEvent::ReceiptEvent(const QJsonObject& obj) : Event(typeId(), obj) { diff --git a/lib/events/receiptevent.h b/lib/events/receiptevent.h index c32e0543..71cd5de0 100644 --- a/lib/events/receiptevent.h +++ b/lib/events/receiptevent.h @@ -23,7 +23,7 @@ #include #include -namespace QMatrixClient { +namespace Quotient { struct Receipt { QString userId; QDateTime timestamp; @@ -49,4 +49,4 @@ private: }; REGISTER_EVENT_TYPE(ReceiptEvent) DEFINE_EVENTTYPE_ALIAS(Receipt, ReceiptEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/redactionevent.h b/lib/events/redactionevent.h index 3628fb33..eac627d5 100644 --- a/lib/events/redactionevent.h +++ b/lib/events/redactionevent.h @@ -20,7 +20,7 @@ #include "roomevent.h" -namespace QMatrixClient { +namespace Quotient { class RedactionEvent : public RoomEvent { public: DEFINE_EVENT_TYPEID("m.room.redaction", RedactionEvent) @@ -36,4 +36,4 @@ public: }; REGISTER_EVENT_TYPE(RedactionEvent) DEFINE_EVENTTYPE_ALIAS(Redaction, RedactionEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/roomavatarevent.h b/lib/events/roomavatarevent.h index 16aeb070..109f4014 100644 --- a/lib/events/roomavatarevent.h +++ b/lib/events/roomavatarevent.h @@ -21,7 +21,7 @@ #include "eventcontent.h" #include "stateevent.h" -namespace QMatrixClient { +namespace Quotient { class RoomAvatarEvent : public StateEvent { // It's a bit of an overkill to use a full-fledged ImageContent // because in reality m.room.avatar usually only has a single URL, @@ -35,4 +35,4 @@ public: }; REGISTER_EVENT_TYPE(RoomAvatarEvent) DEFINE_EVENTTYPE_ALIAS(RoomAvatar, RoomAvatarEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/roomcreateevent.cpp b/lib/events/roomcreateevent.cpp index cb575f24..c72b5bc2 100644 --- a/lib/events/roomcreateevent.cpp +++ b/lib/events/roomcreateevent.cpp @@ -18,7 +18,7 @@ #include "roomcreateevent.h" -using namespace QMatrixClient; +using namespace Quotient; bool RoomCreateEvent::isFederated() const { diff --git a/lib/events/roomcreateevent.h b/lib/events/roomcreateevent.h index c8ba8c40..91aefe9e 100644 --- a/lib/events/roomcreateevent.h +++ b/lib/events/roomcreateevent.h @@ -20,7 +20,7 @@ #include "stateevent.h" -namespace QMatrixClient { +namespace Quotient { class RoomCreateEvent : public StateEventBase { public: DEFINE_EVENT_TYPEID("m.room.create", RoomCreateEvent) @@ -41,4 +41,4 @@ public: bool isUpgrade() const; }; REGISTER_EVENT_TYPE(RoomCreateEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/roomevent.cpp b/lib/events/roomevent.cpp index 543640ca..e19c03ce 100644 --- a/lib/events/roomevent.cpp +++ b/lib/events/roomevent.cpp @@ -22,7 +22,7 @@ #include "logging.h" #include "redactionevent.h" -using namespace QMatrixClient; +using namespace Quotient; [[gnu::unused]] static auto roomEventTypeInitialised = Event::factory_t::chainFactory(); @@ -48,7 +48,7 @@ QString RoomEvent::id() const { return fullJson()[EventIdKeyL].toString(); } QDateTime RoomEvent::timestamp() const { - return QMatrixClient::fromJson(fullJson()["origin_server_ts"_ls]); + return Quotient::fromJson(fullJson()["origin_server_ts"_ls]); } QString RoomEvent::roomId() const diff --git a/lib/events/roomevent.h b/lib/events/roomevent.h index 155d4600..f943bce4 100644 --- a/lib/events/roomevent.h +++ b/lib/events/roomevent.h @@ -22,7 +22,7 @@ #include -namespace QMatrixClient { +namespace Quotient { class RedactionEvent; /** This class corresponds to m.room.* events */ @@ -102,6 +102,6 @@ public: QString callId() const { return content("call_id"_ls); } int version() const { return content("version"_ls); } }; -} // namespace QMatrixClient -Q_DECLARE_METATYPE(QMatrixClient::RoomEvent*) -Q_DECLARE_METATYPE(const QMatrixClient::RoomEvent*) +} // namespace Quotient +Q_DECLARE_METATYPE(Quotient::RoomEvent*) +Q_DECLARE_METATYPE(const Quotient::RoomEvent*) diff --git a/lib/events/roommemberevent.cpp b/lib/events/roommemberevent.cpp index 3cbf6685..d0787170 100644 --- a/lib/events/roommemberevent.cpp +++ b/lib/events/roommemberevent.cpp @@ -28,7 +28,7 @@ static const std::array membershipStrings = { QStringLiteral("leave"), QStringLiteral("ban") } }; -namespace QMatrixClient { +namespace Quotient { template <> struct JsonConverter { static MembershipType load(const QJsonValue& jv) @@ -43,9 +43,9 @@ struct JsonConverter { return MembershipType::Undefined; } }; -} // namespace QMatrixClient +} // namespace Quotient -using namespace QMatrixClient; +using namespace Quotient; MemberEventContent::MemberEventContent(const QJsonObject& json) : membership(fromJson(json["membership"_ls])) diff --git a/lib/events/roommemberevent.h b/lib/events/roommemberevent.h index 59d59e3a..2a16617a 100644 --- a/lib/events/roommemberevent.h +++ b/lib/events/roommemberevent.h @@ -21,7 +21,7 @@ #include "eventcontent.h" #include "stateevent.h" -namespace QMatrixClient { +namespace Quotient { class MemberEventContent : public EventContent::Base { public: enum MembershipType : size_t { @@ -107,4 +107,4 @@ public: REGISTER_EVENT_TYPE(RoomMemberEvent) DEFINE_EVENTTYPE_ALIAS(RoomMember, RoomMemberEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/roommessageevent.cpp b/lib/events/roommessageevent.cpp index 991931de..09562d65 100644 --- a/lib/events/roommessageevent.cpp +++ b/lib/events/roommessageevent.cpp @@ -25,7 +25,7 @@ #include #include -using namespace QMatrixClient; +using namespace Quotient; using namespace EventContent; using MsgType = RoomMessageEvent::MsgType; @@ -279,7 +279,7 @@ TextContent::TextContent(const QString& text, const QString& contentType, mimeType = QMimeDatabase().mimeTypeForName("text/html"); } -namespace QMatrixClient { +namespace Quotient { // Overload the default fromJson<> logic that defined in converters.h // as we want template <> @@ -295,7 +295,7 @@ Omittable fromJson(const QJsonValue& jv) return RelatesTo { jo.value("rel_type"_ls).toString(), jo.value(EventIdKeyL).toString() }; } -} // namespace QMatrixClient +} // namespace Quotient TextContent::TextContent(const QJsonObject& json) : relatesTo(fromJson>(json[RelatesToKeyL])) diff --git a/lib/events/roommessageevent.h b/lib/events/roommessageevent.h index c7a5cb47..aa515c71 100644 --- a/lib/events/roommessageevent.h +++ b/lib/events/roommessageevent.h @@ -23,7 +23,7 @@ class QFileInfo; -namespace QMatrixClient { +namespace Quotient { namespace MessageEventContent = EventContent; // Back-compatibility /** @@ -217,4 +217,4 @@ namespace EventContent { */ using AudioContent = PlayableContent>; } // namespace EventContent -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/roomtombstoneevent.cpp b/lib/events/roomtombstoneevent.cpp index a74bb367..f93eb60d 100644 --- a/lib/events/roomtombstoneevent.cpp +++ b/lib/events/roomtombstoneevent.cpp @@ -18,7 +18,7 @@ #include "roomtombstoneevent.h" -using namespace QMatrixClient; +using namespace Quotient; QString RoomTombstoneEvent::serverMessage() const { diff --git a/lib/events/roomtombstoneevent.h b/lib/events/roomtombstoneevent.h index 95fed998..2c2f0663 100644 --- a/lib/events/roomtombstoneevent.h +++ b/lib/events/roomtombstoneevent.h @@ -20,7 +20,7 @@ #include "stateevent.h" -namespace QMatrixClient { +namespace Quotient { class RoomTombstoneEvent : public StateEventBase { public: DEFINE_EVENT_TYPEID("m.room.tombstone", RoomTombstoneEvent) @@ -34,4 +34,4 @@ public: QString successorRoomId() const; }; REGISTER_EVENT_TYPE(RoomTombstoneEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/simplestateevents.h b/lib/events/simplestateevents.h index 6dad8020..520f6b4b 100644 --- a/lib/events/simplestateevents.h +++ b/lib/events/simplestateevents.h @@ -20,7 +20,7 @@ #include "stateevent.h" -namespace QMatrixClient { +namespace Quotient { namespace EventContent { template class SimpleContent { @@ -37,7 +37,7 @@ namespace EventContent { {} QJsonObject toJson() const { - return { { key, QMatrixClient::toJson(value) } }; + return { { key, Quotient::toJson(value) } }; } public: @@ -92,4 +92,4 @@ public: QStringList aliases() const { return content().value; } }; REGISTER_EVENT_TYPE(RoomAliasesEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/events/stateevent.cpp b/lib/events/stateevent.cpp index bd228abd..c0bb0794 100644 --- a/lib/events/stateevent.cpp +++ b/lib/events/stateevent.cpp @@ -18,7 +18,7 @@ #include "stateevent.h" -using namespace QMatrixClient; +using namespace Quotient; // Aside from the normal factory to instantiate StateEventBase inheritors // StateEventBase itself can be instantiated if there's a state_key JSON key diff --git a/lib/events/stateevent.h b/lib/events/stateevent.h index 757c94ee..74e36e74 100644 --- a/lib/events/stateevent.h +++ b/lib/events/stateevent.h @@ -20,7 +20,7 @@ #include "roomevent.h" -namespace QMatrixClient { +namespace Quotient { /// Make a minimal correct Matrix state event JSON template @@ -128,12 +128,12 @@ private: ContentT _content; std::unique_ptr> _prev; }; -} // namespace QMatrixClient +} // namespace Quotient namespace std { template <> -struct hash { - size_t operator()(const QMatrixClient::StateEventKey& k) const Q_DECL_NOEXCEPT +struct hash { + size_t operator()(const Quotient::StateEventKey& k) const Q_DECL_NOEXCEPT { return qHash(k); } diff --git a/lib/events/typingevent.cpp b/lib/events/typingevent.cpp index ee3d6b67..0c5fc6ba 100644 --- a/lib/events/typingevent.cpp +++ b/lib/events/typingevent.cpp @@ -20,7 +20,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; TypingEvent::TypingEvent(const QJsonObject& obj) : Event(typeId(), obj) { diff --git a/lib/events/typingevent.h b/lib/events/typingevent.h index c8170865..d659c597 100644 --- a/lib/events/typingevent.h +++ b/lib/events/typingevent.h @@ -20,7 +20,7 @@ #include "event.h" -namespace QMatrixClient { +namespace Quotient { class TypingEvent : public Event { public: DEFINE_EVENT_TYPEID("m.typing", TypingEvent) @@ -34,4 +34,4 @@ private: }; REGISTER_EVENT_TYPE(TypingEvent) DEFINE_EVENTTYPE_ALIAS(Typing, TypingEvent) -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/identity/definitions/request_email_validation.cpp b/lib/identity/definitions/request_email_validation.cpp index 131b9488..22cb0072 100644 --- a/lib/identity/definitions/request_email_validation.cpp +++ b/lib/identity/definitions/request_email_validation.cpp @@ -4,7 +4,7 @@ #include "request_email_validation.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo( QJsonObject& jo, const RequestEmailValidation& pod) diff --git a/lib/identity/definitions/request_email_validation.h b/lib/identity/definitions/request_email_validation.h index 2496d7f5..99487073 100644 --- a/lib/identity/definitions/request_email_validation.h +++ b/lib/identity/definitions/request_email_validation.h @@ -6,7 +6,7 @@ #include "converters.h" -namespace QMatrixClient +namespace Quotient { // Data structures @@ -39,4 +39,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, RequestEmailValidation& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/identity/definitions/request_msisdn_validation.cpp b/lib/identity/definitions/request_msisdn_validation.cpp index 0087d202..6024bf61 100644 --- a/lib/identity/definitions/request_msisdn_validation.cpp +++ b/lib/identity/definitions/request_msisdn_validation.cpp @@ -4,7 +4,7 @@ #include "request_msisdn_validation.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo( QJsonObject& jo, const RequestMsisdnValidation& pod) diff --git a/lib/identity/definitions/request_msisdn_validation.h b/lib/identity/definitions/request_msisdn_validation.h index f8060cfc..ecccf567 100644 --- a/lib/identity/definitions/request_msisdn_validation.h +++ b/lib/identity/definitions/request_msisdn_validation.h @@ -6,7 +6,7 @@ #include "converters.h" -namespace QMatrixClient +namespace Quotient { // Data structures @@ -43,4 +43,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, RequestMsisdnValidation& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/identity/definitions/sid.cpp b/lib/identity/definitions/sid.cpp index cc6973f2..99fe9b59 100644 --- a/lib/identity/definitions/sid.cpp +++ b/lib/identity/definitions/sid.cpp @@ -4,7 +4,7 @@ #include "sid.h" -using namespace QMatrixClient; +using namespace Quotient; void JsonObjectConverter::dumpTo(QJsonObject& jo, const Sid& pod) { diff --git a/lib/identity/definitions/sid.h b/lib/identity/definitions/sid.h index 752d62bb..0f7ce58a 100644 --- a/lib/identity/definitions/sid.h +++ b/lib/identity/definitions/sid.h @@ -6,7 +6,7 @@ #include "converters.h" -namespace QMatrixClient +namespace Quotient { // Data structures @@ -27,4 +27,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, Sid& pod); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/jobs/basejob.cpp b/lib/jobs/basejob.cpp index 5615736e..ec6b8375 100644 --- a/lib/jobs/basejob.cpp +++ b/lib/jobs/basejob.cpp @@ -30,7 +30,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; struct NetworkReplyDeleter : public QScopedPointerDeleteLater { static inline void cleanup(QNetworkReply* reply) diff --git a/lib/jobs/basejob.h b/lib/jobs/basejob.h index c85d2d90..90c20c37 100644 --- a/lib/jobs/basejob.h +++ b/lib/jobs/basejob.h @@ -28,7 +28,7 @@ class QNetworkReply; class QSslError; -namespace QMatrixClient { +namespace Quotient { class ConnectionData; enum class HttpVerb { Get, Put, Post, Delete }; @@ -364,4 +364,4 @@ inline bool isJobRunning(BaseJob* job) { return job && job->error() == BaseJob::Pending; } -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/jobs/downloadfilejob.cpp b/lib/jobs/downloadfilejob.cpp index 9722186c..3a03efde 100644 --- a/lib/jobs/downloadfilejob.cpp +++ b/lib/jobs/downloadfilejob.cpp @@ -4,7 +4,7 @@ #include #include -using namespace QMatrixClient; +using namespace Quotient; class DownloadFileJob::Private { public: diff --git a/lib/jobs/downloadfilejob.h b/lib/jobs/downloadfilejob.h index ebfe5a0d..fa697219 100644 --- a/lib/jobs/downloadfilejob.h +++ b/lib/jobs/downloadfilejob.h @@ -2,7 +2,7 @@ #include "csapi/content-repo.h" -namespace QMatrixClient { +namespace Quotient { class DownloadFileJob : public GetContentJob { public: enum { FileError = BaseJob::UserDefinedError + 1 }; @@ -24,4 +24,4 @@ private: void beforeAbandon(QNetworkReply*) override; Status parseReply(QNetworkReply*) override; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/jobs/mediathumbnailjob.cpp b/lib/jobs/mediathumbnailjob.cpp index db2bbc13..0a346392 100644 --- a/lib/jobs/mediathumbnailjob.cpp +++ b/lib/jobs/mediathumbnailjob.cpp @@ -18,7 +18,7 @@ #include "mediathumbnailjob.h" -using namespace QMatrixClient; +using namespace Quotient; QUrl MediaThumbnailJob::makeRequestUrl(QUrl baseUrl, const QUrl& mxcUri, QSize requestedSize) diff --git a/lib/jobs/mediathumbnailjob.h b/lib/jobs/mediathumbnailjob.h index df0a7f31..75e2e55a 100644 --- a/lib/jobs/mediathumbnailjob.h +++ b/lib/jobs/mediathumbnailjob.h @@ -22,7 +22,7 @@ #include -namespace QMatrixClient { +namespace Quotient { class MediaThumbnailJob : public GetContentThumbnailJob { public: using GetContentThumbnailJob::makeRequestUrl; @@ -42,4 +42,4 @@ protected: private: QImage _thumbnail; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/jobs/postreadmarkersjob.h b/lib/jobs/postreadmarkersjob.h index cf482a9a..5a4d942c 100644 --- a/lib/jobs/postreadmarkersjob.h +++ b/lib/jobs/postreadmarkersjob.h @@ -22,7 +22,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; class PostReadMarkersJob : public BaseJob { public: diff --git a/lib/jobs/requestdata.cpp b/lib/jobs/requestdata.cpp index 6ad7c007..0c70f085 100644 --- a/lib/jobs/requestdata.cpp +++ b/lib/jobs/requestdata.cpp @@ -6,7 +6,7 @@ #include #include -using namespace QMatrixClient; +using namespace Quotient; auto fromData(const QByteArray& data) { diff --git a/lib/jobs/requestdata.h b/lib/jobs/requestdata.h index 55987a3b..020d5ef2 100644 --- a/lib/jobs/requestdata.h +++ b/lib/jobs/requestdata.h @@ -26,7 +26,7 @@ class QJsonArray; class QJsonDocument; class QIODevice; -namespace QMatrixClient { +namespace Quotient { /** * A simple wrapper that represents the request body. * Provides a unified interface to dump an unstructured byte stream @@ -52,4 +52,6 @@ public: private: std::unique_ptr _source; }; -} // namespace QMatrixClient +} // namespace Quotient +/// \deprecated Use namespace Quotient instead +namespace QMatrixClient = Quotient; diff --git a/lib/jobs/syncjob.cpp b/lib/jobs/syncjob.cpp index f660e1b6..cd7709e1 100644 --- a/lib/jobs/syncjob.cpp +++ b/lib/jobs/syncjob.cpp @@ -18,7 +18,7 @@ #include "syncjob.h" -using namespace QMatrixClient; +using namespace Quotient; static size_t jobId = 0; diff --git a/lib/jobs/syncjob.h b/lib/jobs/syncjob.h index 8f925414..df419ba8 100644 --- a/lib/jobs/syncjob.h +++ b/lib/jobs/syncjob.h @@ -22,7 +22,7 @@ #include "../syncdata.h" #include "basejob.h" -namespace QMatrixClient { +namespace Quotient { class SyncJob : public BaseJob { public: explicit SyncJob(const QString& since = {}, const QString& filter = {}, @@ -38,4 +38,4 @@ protected: private: SyncData d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/joinstate.h b/lib/joinstate.h index fcf840ae..718ae3fd 100644 --- a/lib/joinstate.h +++ b/lib/joinstate.h @@ -22,7 +22,7 @@ #include -namespace QMatrixClient { +namespace Quotient { enum class JoinState : unsigned int { Join = 0x1, Invite = 0x2, @@ -43,5 +43,5 @@ inline const char* toCString(JoinState js) ++index; return JoinStateStrings[index]; } -} // namespace QMatrixClient -Q_DECLARE_OPERATORS_FOR_FLAGS(QMatrixClient::JoinStates) +} // namespace Quotient +Q_DECLARE_OPERATORS_FOR_FLAGS(Quotient::JoinStates) diff --git a/lib/logging.h b/lib/logging.h index 24799752..3d13569a 100644 --- a/lib/logging.h +++ b/lib/logging.h @@ -28,7 +28,7 @@ Q_DECLARE_LOGGING_CATEGORY(EPHEMERAL) Q_DECLARE_LOGGING_CATEGORY(JOBS) Q_DECLARE_LOGGING_CATEGORY(SYNCJOB) -namespace QMatrixClient { +namespace Quotient { // QDebug manipulators using QDebugManip = QDebug (*)(QDebug); @@ -75,7 +75,9 @@ inline qint64 profilerMinNsecs() #endif * 1000; } -} // namespace QMatrixClient +} // namespace Quotient +/// \deprecated Use namespace Quotient instead +namespace QMatrixClient = Quotient; inline QDebug operator<<(QDebug debug_object, const QElapsedTimer& et) { diff --git a/lib/networkaccessmanager.cpp b/lib/networkaccessmanager.cpp index 7bff654c..8ee080bf 100644 --- a/lib/networkaccessmanager.cpp +++ b/lib/networkaccessmanager.cpp @@ -21,7 +21,7 @@ #include #include -using namespace QMatrixClient; +using namespace Quotient; class NetworkAccessManager::Private { public: diff --git a/lib/networkaccessmanager.h b/lib/networkaccessmanager.h index dfa388f0..a678b80f 100644 --- a/lib/networkaccessmanager.h +++ b/lib/networkaccessmanager.h @@ -22,7 +22,7 @@ #include -namespace QMatrixClient { +namespace Quotient { class NetworkAccessManager : public QNetworkAccessManager { Q_OBJECT public: @@ -43,4 +43,4 @@ private: class Private; std::unique_ptr d; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/networksettings.cpp b/lib/networksettings.cpp index f5655975..cb071483 100644 --- a/lib/networksettings.cpp +++ b/lib/networksettings.cpp @@ -18,7 +18,7 @@ #include "networksettings.h" -using namespace QMatrixClient; +using namespace Quotient; void NetworkSettings::setupApplicationProxy() const { diff --git a/lib/networksettings.h b/lib/networksettings.h index 75bf726d..a82a44d0 100644 --- a/lib/networksettings.h +++ b/lib/networksettings.h @@ -24,7 +24,7 @@ Q_DECLARE_METATYPE(QNetworkProxy::ProxyType) -namespace QMatrixClient { +namespace Quotient { class NetworkSettings : public SettingsGroup { Q_OBJECT QMC_DECLARE_SETTING(QNetworkProxy::ProxyType, proxyType, setProxyType) diff --git a/lib/qt_connection_util.h b/lib/qt_connection_util.h index 94c1ec60..159e7522 100644 --- a/lib/qt_connection_util.h +++ b/lib/qt_connection_util.h @@ -22,7 +22,7 @@ #include -namespace QMatrixClient { +namespace Quotient { namespace _impl { template inline QMetaObject::Connection @@ -102,4 +102,4 @@ public: private: QObject* subscriber; }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/room.cpp b/lib/room.cpp index 52f86616..d8fee5aa 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -71,7 +71,7 @@ #include // QtOlm #include // QtOlm -using namespace QMatrixClient; +using namespace Quotient; using namespace std::placeholders; using std::move; #if !(defined __GLIBCXX__ && __GLIBCXX__ <= 20150123) @@ -1085,7 +1085,7 @@ QUrl Room::fileSource(const QString& id) const QString Room::prettyPrint(const QString& plainText) const { - return QMatrixClient::prettyPrint(plainText); + return Quotient::prettyPrint(plainText); } QList Room::usersTyping() const { return d->usersTyping; } diff --git a/lib/room.h b/lib/room.h index d6fb8a61..8448815d 100644 --- a/lib/room.h +++ b/lib/room.h @@ -35,7 +35,7 @@ #include #include -namespace QMatrixClient { +namespace Quotient { class Event; class Avatar; class SyncRoomData; @@ -423,7 +423,7 @@ public: Q_INVOKABLE QUrl fileSource(const QString& id) const; /** Pretty-prints plain text into HTML - * As of now, it's exactly the same as QMatrixClient::prettyPrint(); + * As of now, it's exactly the same as Quotient::prettyPrint(); * in the future, it will also linkify room aliases, mxids etc. * using the room context. */ @@ -668,6 +668,6 @@ public: private: const Room* room; }; -} // namespace QMatrixClient -Q_DECLARE_METATYPE(QMatrixClient::FileTransferInfo) -Q_DECLARE_OPERATORS_FOR_FLAGS(QMatrixClient::Room::Changes) +} // namespace Quotient +Q_DECLARE_METATYPE(Quotient::FileTransferInfo) +Q_DECLARE_OPERATORS_FOR_FLAGS(Quotient::Room::Changes) diff --git a/lib/settings.cpp b/lib/settings.cpp index 1278fe33..9c61ab5e 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -4,7 +4,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; QString Settings::legacyOrganizationName {}; QString Settings::legacyApplicationName {}; diff --git a/lib/settings.h b/lib/settings.h index 427f5494..4dcbbea0 100644 --- a/lib/settings.h +++ b/lib/settings.h @@ -24,7 +24,7 @@ class QVariant; -namespace QMatrixClient { +namespace Quotient { class Settings : public QSettings { Q_OBJECT public: @@ -148,4 +148,4 @@ public: void setEncryptionAccountPickle(const QByteArray& encryptionAccountPickle); Q_INVOKABLE void clearEncryptionAccountPickle(); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/syncdata.cpp b/lib/syncdata.cpp index 0c39b438..c784cd7d 100644 --- a/lib/syncdata.cpp +++ b/lib/syncdata.cpp @@ -23,7 +23,7 @@ #include #include -using namespace QMatrixClient; +using namespace Quotient; const QString SyncRoomData::UnreadCountKey = QStringLiteral("x-qmatrixclient.unread_count"); @@ -42,7 +42,7 @@ bool RoomSummary::merge(const RoomSummary& other) | heroes.merge(other.heroes); } -QDebug QMatrixClient::operator<<(QDebug dbg, const RoomSummary& rs) +QDebug Quotient::operator<<(QDebug dbg, const RoomSummary& rs) { QDebugStateSaver _(dbg); QStringList sl; diff --git a/lib/syncdata.h b/lib/syncdata.h index ad9902e4..d55438d7 100644 --- a/lib/syncdata.h +++ b/lib/syncdata.h @@ -22,7 +22,7 @@ #include "events/stateevent.h" -namespace QMatrixClient { +namespace Quotient { /// Room summary, as defined in MSC688 /** * Every member of this structure is an Omittable; as per the MSC, only @@ -111,4 +111,4 @@ private: static QJsonObject loadJson(const QString& fileName); }; -} // namespace QMatrixClient +} // namespace Quotient diff --git a/lib/user.cpp b/lib/user.cpp index 0705aee7..5dea3942 100644 --- a/lib/user.cpp +++ b/lib/user.cpp @@ -37,7 +37,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; using namespace std::placeholders; using std::move; diff --git a/lib/user.h b/lib/user.h index 779efb34..c9e3dbc1 100644 --- a/lib/user.h +++ b/lib/user.h @@ -23,7 +23,7 @@ #include #include -namespace QMatrixClient { +namespace Quotient { class Connection; class Room; class RoomMemberEvent; @@ -160,5 +160,5 @@ private: class Private; QScopedPointer d; }; -} // namespace QMatrixClient -Q_DECLARE_METATYPE(QMatrixClient::User*) +} // namespace Quotient +Q_DECLARE_METATYPE(Quotient::User*) diff --git a/lib/util.cpp b/lib/util.cpp index 1919e811..be9656f8 100644 --- a/lib/util.cpp +++ b/lib/util.cpp @@ -32,7 +32,7 @@ static const auto RegExpOptions = | QRegularExpression::UseUnicodePropertiesOption; // Converts all that looks like a URL into HTML links -void QMatrixClient::linkifyUrls(QString& htmlEscapedText) +void Quotient::linkifyUrls(QString& htmlEscapedText) { // Note: outer parentheses are a part of C++ raw string delimiters, not of // the regex (see http://en.cppreference.com/w/cpp/language/string_literal). @@ -70,7 +70,7 @@ void QMatrixClient::linkifyUrls(QString& htmlEscapedText) QStringLiteral(R"(\1\2)")); } -QString QMatrixClient::sanitized(const QString& plainText) +QString Quotient::sanitized(const QString& plainText) { auto text = plainText; text.remove(QChar(0x202e)); // RLO @@ -79,7 +79,7 @@ QString QMatrixClient::sanitized(const QString& plainText) return text; } -QString QMatrixClient::prettyPrint(const QString& plainText) +QString Quotient::prettyPrint(const QString& plainText) { auto pt = plainText.toHtmlEscaped(); linkifyUrls(pt); @@ -88,7 +88,7 @@ QString QMatrixClient::prettyPrint(const QString& plainText) + QStringLiteral(""); } -QString QMatrixClient::cacheLocation(const QString& dirName) +QString Quotient::cacheLocation(const QString& dirName) { const QString cachePath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) % '/' @@ -99,7 +99,7 @@ QString QMatrixClient::cacheLocation(const QString& dirName) return cachePath; } -qreal QMatrixClient::stringToHueF(const QString& string) +qreal Quotient::stringToHueF(const QString& string) { Q_ASSERT(!string.isEmpty()); QByteArray hash = QCryptographicHash::hash(string.toUtf8(), @@ -118,7 +118,7 @@ static const auto ServerPartRegEx = QStringLiteral( "(?::(\\d{1,5}))?" // Optional port ); -QString QMatrixClient::serverPart(const QString& mxId) +QString Quotient::serverPart(const QString& mxId) { static QString re = "^[@!#$+].+?:(" // Localpart and colon % ServerPartRegEx % ")$"; @@ -135,7 +135,7 @@ QString QMatrixClient::serverPart(const QString& mxId) # pragma clang diagnostic push # pragma ide diagnostic ignored "OCSimplifyInspection" #endif -using namespace QMatrixClient; +using namespace Quotient; int f(); static_assert(std::is_same, int>::value, diff --git a/lib/util.h b/lib/util.h index d055fa46..d94c7321 100644 --- a/lib/util.h +++ b/lib/util.h @@ -63,7 +63,7 @@ static void qAsConst(const T&&) Q_DECL_EQ_DELETE; # define BROKEN_INITIALIZER_LISTS #endif -namespace QMatrixClient { +namespace Quotient { // The below enables pretty-printing of enums in logs #if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) # define REGISTER_ENUM(EnumName) Q_ENUM(EnumName) @@ -330,4 +330,6 @@ qreal stringToHueF(const QString& string); /** Extract the serverpart from MXID */ QString serverPart(const QString& mxId); -} // namespace QMatrixClient +} // namespace Quotient +/// \deprecated Use namespace Quotient instead +namespace QMatrixClient = Quotient; \ No newline at end of file -- cgit v1.2.3 From 7036ed0dcb137cb5cbb6b426dd338c5e2e4c6424 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 17 Apr 2020 07:42:13 +0200 Subject: Regenerate API files using new GTAD and refreshed templates No functional changes. --- lib/application-service/definitions/location.h | 11 +- lib/application-service/definitions/protocol.h | 61 ++++---- lib/application-service/definitions/user.h | 11 +- lib/csapi/account-data.cpp | 18 +-- lib/csapi/account-data.h | 57 ++++---- lib/csapi/admin.cpp | 19 +-- lib/csapi/admin.h | 55 +++---- lib/csapi/administrative_contact.cpp | 48 ++---- lib/csapi/administrative_contact.h | 101 +++++++------ lib/csapi/appservice_room_directory.cpp | 6 +- lib/csapi/appservice_room_directory.h | 15 +- lib/csapi/banning.cpp | 9 +- lib/csapi/banning.h | 23 ++- lib/csapi/capabilities.cpp | 20 +-- lib/csapi/capabilities.h | 37 ++--- lib/csapi/content-repo.cpp | 49 ++----- lib/csapi/content-repo.h | 112 +++++++------- lib/csapi/create_room.cpp | 17 +-- lib/csapi/create_room.h | 161 ++++++++++++--------- lib/csapi/definitions/auth_data.h | 10 +- lib/csapi/definitions/client_device.h | 23 +-- lib/csapi/definitions/device_keys.h | 35 +++-- lib/csapi/definitions/event_filter.h | 13 +- lib/csapi/definitions/public_rooms_response.h | 47 +++--- lib/csapi/definitions/push_condition.h | 32 ++-- lib/csapi/definitions/push_rule.h | 22 +-- lib/csapi/definitions/push_ruleset.h | 10 +- lib/csapi/definitions/room_event_filter.h | 11 +- lib/csapi/definitions/sync_filter.h | 69 +++++---- lib/csapi/definitions/user_identifier.h | 9 +- lib/csapi/definitions/wellknown/full.h | 20 ++- lib/csapi/definitions/wellknown/homeserver.h | 9 +- lib/csapi/definitions/wellknown/identity_server.h | 9 +- lib/csapi/device_management.cpp | 30 ++-- lib/csapi/device_management.h | 67 ++++----- lib/csapi/directory.cpp | 16 +- lib/csapi/directory.h | 50 +++---- lib/csapi/event_context.cpp | 7 +- lib/csapi/event_context.h | 26 ++-- lib/csapi/filter.cpp | 15 +- lib/csapi/filter.h | 32 ++-- lib/csapi/inviting.cpp | 4 +- lib/csapi/inviting.h | 13 +- lib/csapi/joining.cpp | 29 ++-- lib/csapi/joining.h | 54 +++---- lib/csapi/keys.cpp | 42 ++---- lib/csapi/keys.h | 70 ++++----- lib/csapi/kicking.cpp | 4 +- lib/csapi/kicking.h | 13 +- lib/csapi/leaving.cpp | 8 +- lib/csapi/leaving.h | 37 +++-- lib/csapi/list_joined_rooms.cpp | 8 +- lib/csapi/list_joined_rooms.h | 19 +-- lib/csapi/list_public_rooms.cpp | 37 ++--- lib/csapi/list_public_rooms.h | 66 ++++----- lib/csapi/login.cpp | 22 +-- lib/csapi/login.h | 41 +++--- lib/csapi/logout.cpp | 9 +- lib/csapi/logout.h | 33 ++--- lib/csapi/message_pagination.cpp | 14 +- lib/csapi/message_pagination.h | 23 ++- lib/csapi/notifications.cpp | 14 +- lib/csapi/notifications.h | 41 +++--- lib/csapi/openid.cpp | 8 +- lib/csapi/openid.h | 16 +- lib/csapi/peeking_events.cpp | 9 +- lib/csapi/peeking_events.h | 23 ++- lib/csapi/presence.cpp | 11 +- lib/csapi/presence.h | 34 ++--- lib/csapi/profile.cpp | 39 ++--- lib/csapi/profile.h | 78 +++++----- lib/csapi/pusher.cpp | 28 ++-- lib/csapi/pusher.h | 99 ++++++------- lib/csapi/pushrules.cpp | 50 ++----- lib/csapi/pushrules.h | 120 +++++++-------- lib/csapi/read_markers.cpp | 4 +- lib/csapi/read_markers.h | 13 +- lib/csapi/receipts.cpp | 4 +- lib/csapi/receipts.h | 13 +- lib/csapi/redaction.cpp | 7 +- lib/csapi/redaction.h | 13 +- lib/csapi/registration.cpp | 64 +++----- lib/csapi/registration.h | 129 +++++++++-------- lib/csapi/report_content.cpp | 4 +- lib/csapi/report_content.h | 13 +- lib/csapi/room_send.cpp | 7 +- lib/csapi/room_send.h | 13 +- lib/csapi/room_state.cpp | 15 +- lib/csapi/room_state.h | 23 ++- lib/csapi/room_upgrades.cpp | 7 +- lib/csapi/room_upgrades.h | 13 +- lib/csapi/rooms.cpp | 60 +++----- lib/csapi/rooms.h | 112 +++++++------- lib/csapi/sso_login_redirect.cpp | 5 +- lib/csapi/sso_login_redirect.h | 20 ++- lib/csapi/tags.cpp | 21 +-- lib/csapi/tags.h | 56 ++++--- lib/csapi/third_party_lookup.cpp | 56 +++---- lib/csapi/third_party_lookup.h | 115 +++++++-------- lib/csapi/third_party_membership.cpp | 4 +- lib/csapi/third_party_membership.h | 13 +- lib/csapi/to_device.cpp | 4 +- lib/csapi/to_device.h | 13 +- lib/csapi/typing.cpp | 4 +- lib/csapi/typing.h | 13 +- lib/csapi/users.cpp | 14 +- lib/csapi/users.h | 36 ++--- lib/csapi/versions.cpp | 8 +- lib/csapi/versions.h | 20 ++- lib/csapi/voip.cpp | 9 +- lib/csapi/voip.h | 19 +-- lib/csapi/wellknown.cpp | 10 +- lib/csapi/wellknown.h | 19 +-- lib/csapi/whoami.cpp | 8 +- lib/csapi/whoami.h | 19 +-- .../definitions/request_email_validation.h | 37 ++--- .../definitions/request_msisdn_validation.h | 43 +++--- lib/identity/definitions/sid.h | 17 +-- 118 files changed, 1613 insertions(+), 1992 deletions(-) (limited to 'lib/application-service') diff --git a/lib/application-service/definitions/location.h b/lib/application-service/definitions/location.h index 77512514..e4c2d096 100644 --- a/lib/application-service/definitions/location.h +++ b/lib/application-service/definitions/location.h @@ -8,24 +8,23 @@ #include -namespace Quotient -{ +namespace Quotient { // Data structures -struct ThirdPartyLocation -{ +struct ThirdPartyLocation { /// An alias for a matrix room. QString alias; + /// The protocol ID that the third party location is a part of. QString protocol; + /// Information used to identify this third party location. QJsonObject fields; }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const ThirdPartyLocation& pod); static void fillFrom(const QJsonObject& jo, ThirdPartyLocation& pod); }; diff --git a/lib/application-service/definitions/protocol.h b/lib/application-service/definitions/protocol.h index ab99264f..ac1e50e2 100644 --- a/lib/application-service/definitions/protocol.h +++ b/lib/application-service/definitions/protocol.h @@ -10,77 +10,80 @@ #include #include -namespace Quotient -{ +namespace Quotient { // Data structures /// Definition of valid values for a field. -struct FieldType -{ +struct FieldType { /// A regular expression for validation of a field's value. This may be - /// relativelycoarse to verify the value as the application service - /// providing this protocolmay apply additional validation or filtering. + /// relatively coarse to verify the value as the application service + /// providing this protocol may apply additional validation or filtering. QString regexp; + /// An placeholder serving as a valid example of the field value. QString placeholder; }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const FieldType& pod); static void fillFrom(const QJsonObject& jo, FieldType& pod); }; -struct ProtocolInstance -{ +struct ProtocolInstance { /// A human-readable description for the protocol, such as the name. QString desc; + /// An optional content URI representing the protocol. Overrides the one - /// providedat the higher level Protocol object. + /// provided at the higher level Protocol object. QString icon; + /// Preset values for ``fields`` the client may use to search by. QJsonObject fields; + /// A unique identifier across all instances. QString networkId; }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const ProtocolInstance& pod); static void fillFrom(const QJsonObject& jo, ProtocolInstance& pod); }; -struct ThirdPartyProtocol -{ - /// Fields which may be used to identify a third party user. These should - /// beordered to suggest the way that entities may be grouped, where - /// highergroupings are ordered first. For example, the name of a network - /// should besearched before the nickname of a user. +struct 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 beordered to suggest the way that entities may be grouped, where - /// highergroupings are ordered first. For example, the name of a network - /// should besearched before the name of a channel. + /// 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 the ``user_fields`` and /// ``location_fields``. Each entry in those arrays MUST have an entry here. - /// The``string`` key for this object is field name itself.May be an empty - /// object if no fields are defined. + /// The + /// ``string`` key for this object is 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 thesame application service. + + /// 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 <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const ThirdPartyProtocol& pod); static void fillFrom(const QJsonObject& jo, ThirdPartyProtocol& pod); }; diff --git a/lib/application-service/definitions/user.h b/lib/application-service/definitions/user.h index 34c6829c..0d1984b6 100644 --- a/lib/application-service/definitions/user.h +++ b/lib/application-service/definitions/user.h @@ -8,24 +8,23 @@ #include -namespace Quotient -{ +namespace Quotient { // Data structures -struct ThirdPartyUser -{ +struct ThirdPartyUser { /// A Matrix User ID represting a third party user. QString userid; + /// The protocol ID that the third party location is a part of. QString protocol; + /// Information used to identify this third party location. QJsonObject fields; }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const ThirdPartyUser& pod); static void fillFrom(const QJsonObject& jo, ThirdPartyUser& pod); }; diff --git a/lib/csapi/account-data.cpp b/lib/csapi/account-data.cpp index 2e466fa3..b7825718 100644 --- a/lib/csapi/account-data.cpp +++ b/lib/csapi/account-data.cpp @@ -12,11 +12,9 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto SetAccountDataJobName = QStringLiteral("SetAccountDataJob"); - SetAccountDataJob::SetAccountDataJob(const QString& userId, const QString& type, const QJsonObject& content) - : BaseJob(HttpVerb::Put, SetAccountDataJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetAccountDataJob"), basePath % "/user/" % userId % "/account_data/" % type) { setRequestData(Data(toJson(content))); @@ -30,21 +28,16 @@ QUrl GetAccountDataJob::makeRequestUrl(QUrl baseUrl, const QString& userId, % "/account_data/" % type); } -static const auto GetAccountDataJobName = QStringLiteral("GetAccountDataJob"); - GetAccountDataJob::GetAccountDataJob(const QString& userId, const QString& type) - : BaseJob(HttpVerb::Get, GetAccountDataJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetAccountDataJob"), basePath % "/user/" % userId % "/account_data/" % type) {} -static const auto SetAccountDataPerRoomJobName = - QStringLiteral("SetAccountDataPerRoomJob"); - SetAccountDataPerRoomJob::SetAccountDataPerRoomJob(const QString& userId, const QString& roomId, const QString& type, const QJsonObject& content) - : BaseJob(HttpVerb::Put, SetAccountDataPerRoomJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetAccountDataPerRoomJob"), basePath % "/user/" % userId % "/rooms/" % roomId % "/account_data/" % type) { @@ -61,13 +54,10 @@ QUrl GetAccountDataPerRoomJob::makeRequestUrl(QUrl baseUrl, % roomId % "/account_data/" % type); } -static const auto GetAccountDataPerRoomJobName = - QStringLiteral("GetAccountDataPerRoomJob"); - GetAccountDataPerRoomJob::GetAccountDataPerRoomJob(const QString& userId, const QString& roomId, const QString& type) - : BaseJob(HttpVerb::Get, GetAccountDataPerRoomJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetAccountDataPerRoomJob"), basePath % "/user/" % userId % "/rooms/" % roomId % "/account_data/" % type) {} diff --git a/lib/csapi/account-data.h b/lib/csapi/account-data.h index 7417da0d..a8dba5c0 100644 --- a/lib/csapi/account-data.h +++ b/lib/csapi/account-data.h @@ -8,21 +8,20 @@ #include -namespace Quotient -{ +namespace Quotient { // Operations -/// Set some account_data for the user. -/*! +/*! \brief Set some account_data for the user. + * * Set some account_data for the client. This config is only visible to the user * that set the account_data. The config will be synced to clients in the * top-level ``account_data``. */ -class SetAccountDataJob : public BaseJob -{ +class SetAccountDataJob : public BaseJob { public: - /*! Set some account_data for the user. + /*! \brief Set some account_data for the user. + * * \param userId * The ID of the user to set account_data for. The access token must be * authorized to make requests for this user ID. @@ -36,15 +35,15 @@ public: const QJsonObject& content = {}); }; -/// Get some account_data for the user. -/*! +/*! \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 GetAccountDataJob : public BaseJob -{ +class GetAccountDataJob : public BaseJob { public: - /*! Get some account_data for the user. + /*! \brief Get some account_data for the user. + * * \param userId * The ID of the user to get account_data for. The access token must be * authorized to make requests for this user ID. @@ -54,26 +53,25 @@ public: */ explicit GetAccountDataJob(const QString& userId, const QString& type); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetAccountDataJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& type); }; -/// Set some account_data for the user. -/*! +/*! \brief Set some account_data for the user. + * * 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 synced to * clients in the per-room ``account_data``. */ -class SetAccountDataPerRoomJob : public BaseJob -{ +class SetAccountDataPerRoomJob : public BaseJob { public: - /*! Set some account_data for the user. + /*! \brief Set some account_data for the user. + * * \param userId * The ID of the user to set account_data for. The access token must be * authorized to make requests for this user ID. @@ -90,15 +88,15 @@ public: const QJsonObject& content = {}); }; -/// Get some account_data for the user. -/*! +/*! \brief Get some account_data for the user. + * * 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 GetAccountDataPerRoomJob : public BaseJob -{ +class GetAccountDataPerRoomJob : public BaseJob { public: - /*! Get some account_data for the user. + /*! \brief Get some account_data for the user. + * * \param userId * The ID of the user to set account_data for. The access token must be * authorized to make requests for this user ID. @@ -112,11 +110,10 @@ public: const QString& roomId, const QString& type); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetAccountDataPerRoomJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& roomId, const QString& type); diff --git a/lib/csapi/admin.cpp b/lib/csapi/admin.cpp index d2c20ba8..14173e94 100644 --- a/lib/csapi/admin.cpp +++ b/lib/csapi/admin.cpp @@ -13,12 +13,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void fillFrom(const QJsonObject& jo, GetWhoIsJob::ConnectionInfo& result) { @@ -29,8 +27,7 @@ struct JsonObjectConverter }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void fillFrom(const QJsonObject& jo, GetWhoIsJob::SessionInfo& result) { fromJson(jo.value("connections"_ls), result.connections); @@ -38,8 +35,7 @@ struct JsonObjectConverter }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void fillFrom(const QJsonObject& jo, GetWhoIsJob::DeviceInfo& result) { fromJson(jo.value("sessions"_ls), result.sessions); @@ -48,8 +44,7 @@ struct JsonObjectConverter } // namespace Quotient -class GetWhoIsJob::Private -{ +class GetWhoIsJob::Private { public: QString userId; QHash devices; @@ -61,10 +56,8 @@ QUrl GetWhoIsJob::makeRequestUrl(QUrl baseUrl, const QString& userId) basePath % "/admin/whois/" % userId); } -static const auto GetWhoIsJobName = QStringLiteral("GetWhoIsJob"); - GetWhoIsJob::GetWhoIsJob(const QString& userId) - : BaseJob(HttpVerb::Get, GetWhoIsJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetWhoIsJob"), basePath % "/admin/whois/" % userId) , d(new Private) {} diff --git a/lib/csapi/admin.h b/lib/csapi/admin.h index 472ccf72..75ae1eb0 100644 --- a/lib/csapi/admin.h +++ b/lib/csapi/admin.h @@ -11,29 +11,28 @@ #include #include -namespace Quotient -{ +namespace Quotient { // Operations -/// Gets information about a particular user. -/*! +/*! \brief Gets information about a particular user. + * * Gets information about a particular user. * * 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 GetWhoIsJob : public BaseJob -{ +class GetWhoIsJob : public BaseJob { public: // Inner data structures - /// Gets information about a particular user.This API may be restricted to - /// only be called by the user being lookedup, or by a server admin. - /// Server-local administrator privileges are notspecified in this document. - struct ConnectionInfo - { + /// Gets information about a particular user. + /// + /// 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. + struct ConnectionInfo { /// Most recently seen IP address of the session. QString ip; /// Unix timestamp that the session was last active. @@ -42,20 +41,22 @@ public: QString userAgent; }; - /// Gets information about a particular user.This API may be restricted to - /// only be called by the user being lookedup, or by a server admin. - /// Server-local administrator privileges are notspecified in this document. - struct SessionInfo - { + /// Gets information about a particular user. + /// + /// 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. + struct SessionInfo { /// Information particular connections in the session. QVector connections; }; - /// Gets information about a particular user.This API may be restricted to - /// only be called by the user being lookedup, or by a server admin. - /// Server-local administrator privileges are notspecified in this document. - struct DeviceInfo - { + /// Gets information about a particular user. + /// + /// 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. + struct DeviceInfo { /// A user's sessions (i.e. what they did with an access token from one /// login). QVector sessions; @@ -63,26 +64,26 @@ public: // Construction/destruction - /*! Gets information about a particular user. + /*! \brief Gets information about a particular user. + * * \param userId * The user to look up. */ explicit GetWhoIsJob(const QString& userId); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetWhoIsJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId); - ~GetWhoIsJob() override; // Result properties /// The Matrix user ID of the user. const QString& userId() const; + /// Each key is an identitfier for one of the user's devices. const QHash& devices() const; diff --git a/lib/csapi/administrative_contact.cpp b/lib/csapi/administrative_contact.cpp index 32bc8c86..36d93e73 100644 --- a/lib/csapi/administrative_contact.cpp +++ b/lib/csapi/administrative_contact.cpp @@ -13,12 +13,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void fillFrom(const QJsonObject& jo, GetAccount3PIDsJob::ThirdPartyIdentifier& result) { @@ -31,8 +29,7 @@ struct JsonObjectConverter } // namespace Quotient -class GetAccount3PIDsJob::Private -{ +class GetAccount3PIDsJob::Private { public: QVector threepids; }; @@ -43,10 +40,9 @@ QUrl GetAccount3PIDsJob::makeRequestUrl(QUrl baseUrl) basePath % "/account/3pid"); } -static const auto GetAccount3PIDsJobName = QStringLiteral("GetAccount3PIDsJob"); - GetAccount3PIDsJob::GetAccount3PIDsJob() - : BaseJob(HttpVerb::Get, GetAccount3PIDsJobName, basePath % "/account/3pid") + : BaseJob(HttpVerb::Get, QStringLiteral("GetAccount3PIDsJob"), + basePath % "/account/3pid") , d(new Private) {} @@ -67,12 +63,10 @@ BaseJob::Status GetAccount3PIDsJob::parseJson(const QJsonDocument& data) } // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const Post3PIDsJob::ThreePidCredentials& pod) { @@ -84,11 +78,10 @@ struct JsonObjectConverter } // namespace Quotient -static const auto Post3PIDsJobName = QStringLiteral("Post3PIDsJob"); - Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds, Omittable bind) - : BaseJob(HttpVerb::Post, Post3PIDsJobName, basePath % "/account/3pid") + : BaseJob(HttpVerb::Post, QStringLiteral("Post3PIDsJob"), + basePath % "/account/3pid") { QJsonObject _data; addParam<>(_data, QStringLiteral("three_pid_creds"), threePidCreds); @@ -96,12 +89,9 @@ Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds, setRequestData(_data); } -static const auto Delete3pidFromAccountJobName = - QStringLiteral("Delete3pidFromAccountJob"); - Delete3pidFromAccountJob::Delete3pidFromAccountJob(const QString& medium, const QString& address) - : BaseJob(HttpVerb::Post, Delete3pidFromAccountJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("Delete3pidFromAccountJob"), basePath % "/account/3pid/delete") { QJsonObject _data; @@ -110,19 +100,15 @@ Delete3pidFromAccountJob::Delete3pidFromAccountJob(const QString& medium, setRequestData(_data); } -class RequestTokenTo3PIDEmailJob::Private -{ +class RequestTokenTo3PIDEmailJob::Private { public: Sid data; }; -static const auto RequestTokenTo3PIDEmailJobName = - QStringLiteral("RequestTokenTo3PIDEmailJob"); - RequestTokenTo3PIDEmailJob::RequestTokenTo3PIDEmailJob( const QString& clientSecret, const QString& email, int sendAttempt, const QString& idServer, const QString& nextLink) - : BaseJob(HttpVerb::Post, RequestTokenTo3PIDEmailJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenTo3PIDEmailJob"), basePath % "/account/3pid/email/requestToken", false) , d(new Private) { @@ -142,23 +128,20 @@ const Sid& RequestTokenTo3PIDEmailJob::data() const { return d->data; } BaseJob::Status RequestTokenTo3PIDEmailJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -class RequestTokenTo3PIDMSISDNJob::Private -{ +class RequestTokenTo3PIDMSISDNJob::Private { public: Sid data; }; -static const auto RequestTokenTo3PIDMSISDNJobName = - QStringLiteral("RequestTokenTo3PIDMSISDNJob"); - RequestTokenTo3PIDMSISDNJob::RequestTokenTo3PIDMSISDNJob( const QString& clientSecret, const QString& country, const QString& phoneNumber, int sendAttempt, const QString& idServer, const QString& nextLink) - : BaseJob(HttpVerb::Post, RequestTokenTo3PIDMSISDNJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenTo3PIDMSISDNJob"), basePath % "/account/3pid/msisdn/requestToken", false) , d(new Private) { @@ -179,5 +162,6 @@ const Sid& RequestTokenTo3PIDMSISDNJob::data() const { return d->data; } BaseJob::Status RequestTokenTo3PIDMSISDNJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } diff --git a/lib/csapi/administrative_contact.h b/lib/csapi/administrative_contact.h index 4ccd7596..af98fe9c 100644 --- a/lib/csapi/administrative_contact.h +++ b/lib/csapi/administrative_contact.h @@ -12,13 +12,12 @@ #include -namespace Quotient -{ +namespace Quotient { // Operations -/// Gets a list of a user's third party identifiers. -/*! +/*! \brief Gets a list of a user's third party identifiers. + * * Gets a list of the third party identifiers that the homeserver has * associated with the user's account. * @@ -28,25 +27,25 @@ 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 GetAccount3PIDsJob : public BaseJob -{ +class GetAccount3PIDsJob : public BaseJob { public: // Inner data structures - /// Gets a list of the third party identifiers that the homeserver - /// hasassociated with the user's account.This is *not* the same as the list - /// of third party identifiers bound tothe user's Matrix ID in identity - /// servers.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. - struct ThirdPartyIdentifier - { + /// Gets a list of the third party identifiers that the homeserver has + /// associated with the user's account. + /// + /// This is *not* the same as the list of third party identifiers bound to + /// the user's Matrix ID in identity servers. + /// + /// 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. + struct ThirdPartyIdentifier { /// The medium of the third party identifier. QString medium; /// The third party identifier address. QString address; - /// The timestamp, in milliseconds, when the identifier wasvalidated by - /// the identity server. + /// The timestamp, in milliseconds, when the identifier was + /// validated by the identity server. qint64 validatedAt; /// The timestamp, in milliseconds, when the homeserver associated the /// third party identifier with the user. @@ -55,16 +54,15 @@ public: // Construction/destruction + /// Gets a list of a user's third party identifiers. explicit GetAccount3PIDsJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetAccount3PIDsJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetAccount3PIDsJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetAccount3PIDsJob() override; // Result properties @@ -87,18 +85,16 @@ private: QScopedPointer d; }; -/// Adds contact information to the user's account. -/*! +/*! \brief Adds contact information to the user's account. + * * Adds contact information to the user's account. */ -class Post3PIDsJob : public BaseJob -{ +class Post3PIDsJob : public BaseJob { public: // Inner data structures /// The third party credentials to associate with the account. - struct ThreePidCredentials - { + struct ThreePidCredentials { /// The client secret used in the session with the identity server. QString clientSecret; /// The identity server to use. @@ -109,7 +105,8 @@ public: // Construction/destruction - /*! Adds contact information to the user's account. + /*! \brief Adds contact information to the user's account. + * * \param threePidCreds * The third party credentials to associate with the account. * \param bind @@ -121,15 +118,15 @@ public: Omittable bind = none); }; -/// Deletes a third party identifier from the user's account -/*! +/*! \brief Deletes a third party identifier from the user's account + * * Removes a third party identifier from the user's account. This might not * cause an unbind of the identifier from the identity server. */ -class Delete3pidFromAccountJob : public BaseJob -{ +class Delete3pidFromAccountJob : public BaseJob { public: - /*! Deletes a third party identifier from the user's account + /*! \brief Deletes a third party identifier from the user's account + * * \param medium * The medium of the third party identifier being removed. * \param address @@ -139,9 +136,9 @@ public: const QString& address); }; -/// Begins the validation process for an email address for association with the -/// user's account. -/*! +/*! \brief Begins the validation process for an email address for association + * with the user's account. + * * Proxies the Identity Service API ``validate/email/requestToken``, but * first checks that the given email address is **not** already associated * with an account on this homeserver. This API should be used to request @@ -149,13 +146,14 @@ public: * parameters and response are identical to that of the * |/register/email/requestToken|_ endpoint. */ -class RequestTokenTo3PIDEmailJob : public BaseJob -{ +class RequestTokenTo3PIDEmailJob : public BaseJob { public: - /*! Begins the validation process for an email address for association with - * the user's account. \param clientSecret A unique string generated by the - * client, and used to identify the validation attempt. It must be a string - * consisting of the characters + /*! \brief Begins the validation process for an email address for + * association with the user's account. + * + * \param clientSecret + * 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 * must not be empty. * \param email @@ -195,9 +193,9 @@ private: QScopedPointer d; }; -/// Begins the validation process for a phone number for association with the -/// user's account. -/*! +/*! \brief Begins the validation process for a phone number for association with + * the user's account. + * * Proxies the Identity Service API ``validate/msisdn/requestToken``, but * first checks that the given phone number is **not** already associated * with an account on this homeserver. This API should be used to request @@ -205,13 +203,14 @@ private: * parameters and response are identical to that of the * |/register/msisdn/requestToken|_ endpoint. */ -class RequestTokenTo3PIDMSISDNJob : public BaseJob -{ +class RequestTokenTo3PIDMSISDNJob : public BaseJob { public: - /*! Begins the validation process for a phone number for association with - * the user's account. \param clientSecret A unique string generated by the - * client, and used to identify the validation attempt. It must be a string - * consisting of the characters + /*! \brief Begins the validation process for a phone number for association + * with the user's account. + * + * \param clientSecret + * 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 * must not be empty. * \param country diff --git a/lib/csapi/appservice_room_directory.cpp b/lib/csapi/appservice_room_directory.cpp index 87221aa4..bfcab2a7 100644 --- a/lib/csapi/appservice_room_directory.cpp +++ b/lib/csapi/appservice_room_directory.cpp @@ -12,12 +12,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto UpdateAppserviceRoomDirectoryVsibilityJobName = - QStringLiteral("UpdateAppserviceRoomDirectoryVsibilityJob"); - UpdateAppserviceRoomDirectoryVsibilityJob::UpdateAppserviceRoomDirectoryVsibilityJob( const QString& networkId, const QString& roomId, const QString& visibility) - : BaseJob(HttpVerb::Put, UpdateAppserviceRoomDirectoryVsibilityJobName, + : BaseJob(HttpVerb::Put, + QStringLiteral("UpdateAppserviceRoomDirectoryVsibilityJob"), basePath % "/directory/list/appservice/" % networkId % "/" % roomId) { QJsonObject _data; diff --git a/lib/csapi/appservice_room_directory.h b/lib/csapi/appservice_room_directory.h index e19bf320..f0ad78b0 100644 --- a/lib/csapi/appservice_room_directory.h +++ b/lib/csapi/appservice_room_directory.h @@ -6,13 +6,13 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Updates a room's visibility in the application service's room directory. -/*! +/*! \brief Updates a room's visibility in the application service's room + * directory. + * * Updates the visibility of a given room on the application service's room * directory. * @@ -23,10 +23,11 @@ namespace Quotient * (``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 UpdateAppserviceRoomDirectoryVsibilityJob : public BaseJob -{ +class UpdateAppserviceRoomDirectoryVsibilityJob : public BaseJob { public: - /*! Updates a room's visibility in the application service's room directory. + /*! \brief Updates a room's visibility in the application service's room + * directory. + * * \param networkId * The protocol (network) ID to update the room list for. This would * have been provided by the application service as being listed as diff --git a/lib/csapi/banning.cpp b/lib/csapi/banning.cpp index eac09d5a..6ac9b3ba 100644 --- a/lib/csapi/banning.cpp +++ b/lib/csapi/banning.cpp @@ -12,11 +12,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto BanJobName = QStringLiteral("BanJob"); - BanJob::BanJob(const QString& roomId, const QString& userId, const QString& reason) - : BaseJob(HttpVerb::Post, BanJobName, basePath % "/rooms/" % roomId % "/ban") + : BaseJob(HttpVerb::Post, QStringLiteral("BanJob"), + basePath % "/rooms/" % roomId % "/ban") { QJsonObject _data; addParam<>(_data, QStringLiteral("user_id"), userId); @@ -24,10 +23,8 @@ BanJob::BanJob(const QString& roomId, const QString& userId, setRequestData(_data); } -static const auto UnbanJobName = QStringLiteral("UnbanJob"); - UnbanJob::UnbanJob(const QString& roomId, const QString& userId) - : BaseJob(HttpVerb::Post, UnbanJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("UnbanJob"), basePath % "/rooms/" % roomId % "/unban") { QJsonObject _data; diff --git a/lib/csapi/banning.h b/lib/csapi/banning.h index 5df878a8..6bf782e7 100644 --- a/lib/csapi/banning.h +++ b/lib/csapi/banning.h @@ -6,13 +6,12 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Ban a user in the room. -/*! +/*! \brief Ban a user in the room. + * * Ban a user in the room. If the user is currently in the room, also kick them. * * When a user is banned from a room, they may not join it or be invited to it @@ -21,10 +20,10 @@ namespace Quotient * The caller must have the required power level in order to perform this * operation. */ -class BanJob : public BaseJob -{ +class BanJob : public BaseJob { public: - /*! Ban a user in the room. + /*! \brief Ban a user in the room. + * * \param roomId * The room identifier (not alias) from which the user should be banned. * \param userId @@ -37,8 +36,8 @@ public: const QString& reason = {}); }; -/// Unban a user from the room. -/*! +/*! \brief Unban a user from the room. + * * Unban a user from the room. This allows them to be invited to the room, * and join if they would otherwise be allowed to join according to its join * rules. @@ -46,10 +45,10 @@ public: * The caller must have the required power level in order to perform this * operation. */ -class UnbanJob : public BaseJob -{ +class UnbanJob : public BaseJob { public: - /*! Unban a user from the room. + /*! \brief Unban a user from the room. + * * \param roomId * The room identifier (not alias) from which the user should be unbanned. * \param userId diff --git a/lib/csapi/capabilities.cpp b/lib/csapi/capabilities.cpp index 6a544a1e..8c7ed141 100644 --- a/lib/csapi/capabilities.cpp +++ b/lib/csapi/capabilities.cpp @@ -13,12 +13,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void fillFrom(const QJsonObject& jo, GetCapabilitiesJob::ChangePasswordCapability& result) { @@ -27,8 +25,7 @@ struct JsonObjectConverter }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void fillFrom(const QJsonObject& jo, GetCapabilitiesJob::RoomVersionsCapability& result) { @@ -38,8 +35,7 @@ struct JsonObjectConverter }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void fillFrom(QJsonObject jo, GetCapabilitiesJob::Capabilities& result) { @@ -51,8 +47,7 @@ struct JsonObjectConverter } // namespace Quotient -class GetCapabilitiesJob::Private -{ +class GetCapabilitiesJob::Private { public: Capabilities capabilities; }; @@ -63,10 +58,9 @@ QUrl GetCapabilitiesJob::makeRequestUrl(QUrl baseUrl) basePath % "/capabilities"); } -static const auto GetCapabilitiesJobName = QStringLiteral("GetCapabilitiesJob"); - GetCapabilitiesJob::GetCapabilitiesJob() - : BaseJob(HttpVerb::Get, GetCapabilitiesJobName, basePath % "/capabilities") + : BaseJob(HttpVerb::Get, QStringLiteral("GetCapabilitiesJob"), + basePath % "/capabilities") , d(new Private) {} diff --git a/lib/csapi/capabilities.h b/lib/csapi/capabilities.h index b608a2f2..9f46ab2e 100644 --- a/lib/csapi/capabilities.h +++ b/lib/csapi/capabilities.h @@ -11,63 +11,56 @@ #include #include -namespace Quotient -{ +namespace Quotient { // Operations -/// Gets information about the server's capabilities. -/*! +/*! \brief Gets information about the server's capabilities. + * * Gets information about the server's supported feature set * and other relevant capabilities. */ -class GetCapabilitiesJob : public BaseJob -{ +class GetCapabilitiesJob : public BaseJob { public: // Inner data structures /// Capability to indicate if the user can change their password. - struct ChangePasswordCapability - { + struct ChangePasswordCapability { /// True if the user can change their password, false otherwise. bool enabled; }; /// The room versions the server supports. - struct RoomVersionsCapability - { + struct RoomVersionsCapability { /// The default room version the server is using for new rooms. QString defaultVersion; /// A detailed description of the room versions the server supports. QHash available; }; - /// The custom capabilities the server supports, using theJava package - /// naming convention. - struct Capabilities - { + /// The custom capabilities the server supports, using the + /// Java package naming convention. + struct Capabilities { /// Capability to indicate if the user can change their password. Omittable changePassword; /// The room versions the server supports. Omittable roomVersions; - - /// The custom capabilities the server supports, using theJava package - /// naming convention. + /// The custom capabilities the server supports, using the + /// Java package naming convention. QHash additionalProperties; }; // Construction/destruction + /// Gets information about the server's capabilities. explicit GetCapabilitiesJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetCapabilitiesJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetCapabilitiesJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetCapabilitiesJob() override; // Result properties diff --git a/lib/csapi/content-repo.cpp b/lib/csapi/content-repo.cpp index 395337f3..d811426d 100644 --- a/lib/csapi/content-repo.cpp +++ b/lib/csapi/content-repo.cpp @@ -13,8 +13,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/media/r0"); -class UploadContentJob::Private -{ +class UploadContentJob::Private { public: QString contentUri; }; @@ -26,12 +25,10 @@ BaseJob::Query queryToUploadContent(const QString& filename) return _q; } -static const auto UploadContentJobName = QStringLiteral("UploadContentJob"); - UploadContentJob::UploadContentJob(QIODevice* content, const QString& filename, const QString& contentType) - : BaseJob(HttpVerb::Post, UploadContentJobName, basePath % "/upload", - queryToUploadContent(filename)) + : BaseJob(HttpVerb::Post, QStringLiteral("UploadContentJob"), + basePath % "/upload", queryToUploadContent(filename)) , d(new Private) { setRequestHeader("Content-Type", contentType.toLatin1()); @@ -53,8 +50,7 @@ BaseJob::Status UploadContentJob::parseJson(const QJsonDocument& data) return Success; } -class GetContentJob::Private -{ +class GetContentJob::Private { public: QString contentType; QString contentDisposition; @@ -77,11 +73,9 @@ QUrl GetContentJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, queryToGetContent(allowRemote)); } -static const auto GetContentJobName = QStringLiteral("GetContentJob"); - GetContentJob::GetContentJob(const QString& serverName, const QString& mediaId, bool allowRemote) - : BaseJob(HttpVerb::Get, GetContentJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetContentJob"), basePath % "/download/" % serverName % "/" % mediaId, queryToGetContent(allowRemote), {}, false) , d(new Private) @@ -108,8 +102,7 @@ BaseJob::Status GetContentJob::parseReply(QNetworkReply* reply) return Success; } -class GetContentOverrideNameJob::Private -{ +class GetContentOverrideNameJob::Private { public: QString contentType; QString contentDisposition; @@ -135,14 +128,11 @@ QUrl GetContentOverrideNameJob::makeRequestUrl(QUrl baseUrl, queryToGetContentOverrideName(allowRemote)); } -static const auto GetContentOverrideNameJobName = - QStringLiteral("GetContentOverrideNameJob"); - GetContentOverrideNameJob::GetContentOverrideNameJob(const QString& serverName, const QString& mediaId, const QString& fileName, bool allowRemote) - : BaseJob(HttpVerb::Get, GetContentOverrideNameJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetContentOverrideNameJob"), basePath % "/download/" % serverName % "/" % mediaId % "/" % fileName, queryToGetContentOverrideName(allowRemote), {}, false) @@ -173,8 +163,7 @@ BaseJob::Status GetContentOverrideNameJob::parseReply(QNetworkReply* reply) return Success; } -class GetContentThumbnailJob::Private -{ +class GetContentThumbnailJob::Private { public: QString contentType; QIODevice* data; @@ -204,14 +193,11 @@ QUrl GetContentThumbnailJob::makeRequestUrl(QUrl baseUrl, queryToGetContentThumbnail(width, height, method, allowRemote)); } -static const auto GetContentThumbnailJobName = - QStringLiteral("GetContentThumbnailJob"); - GetContentThumbnailJob::GetContentThumbnailJob(const QString& serverName, const QString& mediaId, int width, int height, const QString& method, bool allowRemote) - : BaseJob(HttpVerb::Get, GetContentThumbnailJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetContentThumbnailJob"), basePath % "/thumbnail/" % serverName % "/" % mediaId, queryToGetContentThumbnail(width, height, method, allowRemote), {}, false) @@ -236,8 +222,7 @@ BaseJob::Status GetContentThumbnailJob::parseReply(QNetworkReply* reply) return Success; } -class GetUrlPreviewJob::Private -{ +class GetUrlPreviewJob::Private { public: Omittable matrixImageSize; QString ogImage; @@ -258,11 +243,9 @@ QUrl GetUrlPreviewJob::makeRequestUrl(QUrl baseUrl, const QString& url, queryToGetUrlPreview(url, ts)); } -static const auto GetUrlPreviewJobName = QStringLiteral("GetUrlPreviewJob"); - GetUrlPreviewJob::GetUrlPreviewJob(const QString& url, Omittable ts) - : BaseJob(HttpVerb::Get, GetUrlPreviewJobName, basePath % "/preview_url", - queryToGetUrlPreview(url, ts)) + : BaseJob(HttpVerb::Get, QStringLiteral("GetUrlPreviewJob"), + basePath % "/preview_url", queryToGetUrlPreview(url, ts)) , d(new Private) {} @@ -284,8 +267,7 @@ BaseJob::Status GetUrlPreviewJob::parseJson(const QJsonDocument& data) return Success; } -class GetConfigJob::Private -{ +class GetConfigJob::Private { public: Omittable uploadSize; }; @@ -295,10 +277,9 @@ QUrl GetConfigJob::makeRequestUrl(QUrl baseUrl) return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/config"); } -static const auto GetConfigJobName = QStringLiteral("GetConfigJob"); - GetConfigJob::GetConfigJob() - : BaseJob(HttpVerb::Get, GetConfigJobName, basePath % "/config") + : BaseJob(HttpVerb::Get, QStringLiteral("GetConfigJob"), + basePath % "/config") , d(new Private) {} diff --git a/lib/csapi/content-repo.h b/lib/csapi/content-repo.h index 83069490..6263ef0b 100644 --- a/lib/csapi/content-repo.h +++ b/lib/csapi/content-repo.h @@ -10,17 +10,17 @@ #include -namespace Quotient -{ +namespace Quotient { // Operations -/// Upload some content to the content repository. - -class UploadContentJob : public BaseJob -{ +/*! \brief Upload some content to the content repository. + * + */ +class UploadContentJob : public BaseJob { public: - /*! Upload some content to the content repository. + /*! \brief Upload some content to the content repository. + * * \param content * \param filename * The name of the file being uploaded @@ -45,12 +45,13 @@ private: QScopedPointer d; }; -/// Download content from the content repository. - -class GetContentJob : public BaseJob -{ +/*! \brief Download content from the content repository. + * + */ +class GetContentJob : public BaseJob { public: - /*! Download content from the content repository. + /*! \brief Download content from the content repository. + * * \param serverName * The server name from the ``mxc://`` URI (the authoritory component) * \param mediaId @@ -63,23 +64,23 @@ public: explicit GetContentJob(const QString& serverName, const QString& mediaId, bool allowRemote = true); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetContentJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, bool allowRemote = true); - ~GetContentJob() override; // Result properties /// The content type of the file that was previously uploaded. const QString& contentType() const; + /// The name of the file that was previously uploaded, if set. const QString& contentDisposition() const; + /// The content that was previously uploaded. QIODevice* data() const; @@ -91,12 +92,13 @@ private: QScopedPointer d; }; -/// Download content from the content repository as a given filename. - -class GetContentOverrideNameJob : public BaseJob -{ +/*! \brief Download content from the content repository as a given filename. + * + */ +class GetContentOverrideNameJob : public BaseJob { public: - /*! Download content from the content repository as a given filename. + /*! \brief Download content from the content repository as a given filename. + * * \param serverName * The server name from the ``mxc://`` URI (the authoritory component) * \param mediaId @@ -113,24 +115,24 @@ public: const QString& fileName, bool allowRemote = true); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetContentOverrideNameJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, const QString& fileName, bool allowRemote = true); - ~GetContentOverrideNameJob() override; // Result properties /// The content type of the file that was previously uploaded. const QString& contentType() const; + /// The name of file given in the request const QString& contentDisposition() const; + /// The content that was previously uploaded. QIODevice* data() const; @@ -142,12 +144,13 @@ private: QScopedPointer d; }; -/// Download a thumbnail of the content from the content repository. - -class GetContentThumbnailJob : public BaseJob -{ +/*! \brief Download a thumbnail of the content from the content repository. + * + */ +class GetContentThumbnailJob : public BaseJob { public: - /*! Download a thumbnail of the content from the content repository. + /*! \brief Download a thumbnail of the content from the content repository. + * * \param serverName * The server name from the ``mxc://`` URI (the authoritory component) * \param mediaId @@ -170,23 +173,22 @@ public: int height, const QString& method = {}, bool allowRemote = true); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetContentThumbnailJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, int width, int height, const QString& method = {}, bool allowRemote = true); - ~GetContentThumbnailJob() override; // Result properties /// The content type of the thumbnail. const QString& contentType() const; + /// A thumbnail of the requested content. QIODevice* data() const; @@ -198,12 +200,13 @@ private: QScopedPointer d; }; -/// Get information about a URL for a client - -class GetUrlPreviewJob : public BaseJob -{ +/*! \brief Get information about a URL for a client + * + */ +class GetUrlPreviewJob : public BaseJob { public: - /*! Get information about a URL for a client + /*! \brief Get information about a URL for a client + * * \param url * The URL to get a preview of * \param ts @@ -213,21 +216,20 @@ public: */ explicit GetUrlPreviewJob(const QString& url, Omittable ts = none); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetUrlPreviewJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& url, Omittable ts = none); - ~GetUrlPreviewJob() override; // Result properties /// The byte-size of the image. Omitted if there is no image attached. Omittable matrixImageSize() const; + /// An MXC URI to the image. Omitted if there is no image. const QString& ogImage() const; @@ -239,8 +241,8 @@ private: QScopedPointer d; }; -/// Get the configuration for the content repository. -/*! +/*! \brief Get the configuration for the content repository. + * * This endpoint allows clients to retrieve the configuration of the content * repository, such as upload limitations. * Clients SHOULD use this as a guide when using content repository endpoints. @@ -252,19 +254,17 @@ private: * content repository APIs, for example, proxies may enforce a lower upload size * limit than is advertised by the server on this endpoint. */ -class GetConfigJob : public BaseJob -{ +class GetConfigJob : public BaseJob { public: + /// Get the configuration for the content repository. explicit GetConfigJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetConfigJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetConfigJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetConfigJob() override; // Result properties diff --git a/lib/csapi/create_room.cpp b/lib/csapi/create_room.cpp index 68741f13..ec2a1855 100644 --- a/lib/csapi/create_room.cpp +++ b/lib/csapi/create_room.cpp @@ -13,12 +13,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const CreateRoomJob::Invite3pid& pod) { addParam<>(jo, QStringLiteral("id_server"), pod.idServer); @@ -28,8 +26,7 @@ struct JsonObjectConverter }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const CreateRoomJob::StateEvent& pod) { addParam<>(jo, QStringLiteral("type"), pod.type); @@ -40,14 +37,11 @@ struct JsonObjectConverter } // namespace Quotient -class CreateRoomJob::Private -{ +class CreateRoomJob::Private { public: QString roomId; }; -static const auto CreateRoomJobName = QStringLiteral("CreateRoomJob"); - CreateRoomJob::CreateRoomJob(const QString& visibility, const QString& roomAliasName, const QString& name, const QString& topic, const QStringList& invite, @@ -57,7 +51,8 @@ CreateRoomJob::CreateRoomJob(const QString& visibility, const QVector& initialState, const QString& preset, Omittable isDirect, const QJsonObject& powerLevelContentOverride) - : BaseJob(HttpVerb::Post, CreateRoomJobName, basePath % "/createRoom") + : BaseJob(HttpVerb::Post, QStringLiteral("CreateRoomJob"), + basePath % "/createRoom") , d(new Private) { QJsonObject _data; diff --git a/lib/csapi/create_room.h b/lib/csapi/create_room.h index e7000155..f2bd9333 100644 --- a/lib/csapi/create_room.h +++ b/lib/csapi/create_room.h @@ -11,13 +11,12 @@ #include #include -namespace Quotient -{ +namespace Quotient { // Operations -/// Create a new room -/*! +/*! \brief Create a new room + * * Create a new room with various configuration options. * * The server MUST apply the normal state resolution rules when creating @@ -60,40 +59,55 @@ namespace Quotient * requesting user as the creator, alongside other keys provided in the * ``creation_content``. */ -class CreateRoomJob : public BaseJob -{ +class CreateRoomJob : public BaseJob { public: // Inner data structures - /// Create a new room with various configuration options.The server MUST - /// apply the normal state resolution rules when creatingthe new room, - /// including checking power levels for each event. It MUSTapply the events - /// implied by the request in the following order:0. A default - /// ``m.room.power_levels`` event, giving the room creator (and not other - /// members) permission to send state events. Overridden by the - /// ``power_level_content_override`` parameter.1. Events set by the - /// ``preset``. Currently these are the ``m.room.join_rules``, - /// ``m.room.history_visibility``, and ``m.room.guest_access`` state - /// events.2. Events listed in ``initial_state``, in the order that they are - /// listed.3. Events implied by ``name`` and ``topic`` (``m.room.name`` and - /// ``m.room.topic`` state events).4. Invite events implied by ``invite`` - /// and ``invite_3pid`` (``m.room.member`` with ``membership: invite`` and - /// ``m.room.third_party_invite``).The available presets do the following - /// with respect to room state:======================== ============== - /// ====================== ================ ========= Preset - /// ``join_rules`` ``history_visibility`` ``guest_access`` - /// Other======================== ============== ====================== - /// ================ =========``private_chat`` ``invite`` - /// ``shared`` ``can_join````trusted_private_chat`` ``invite`` - /// ``shared`` ``can_join`` All invitees are given the - /// same power level as the room creator.``public_chat`` ``public`` - /// ``shared`` ``forbidden``======================== - /// ============== ====================== ================ =========The - /// server will create a ``m.room.create`` event in the room with - /// therequesting user as the creator, alongside other keys provided in - /// the``creation_content``. - struct Invite3pid - { + /// Create a new room with various configuration options. + /// + /// The server MUST apply the normal state resolution rules when creating + /// the new room, including checking power levels for each event. It MUST + /// apply the events implied by the request in the following order: + /// + /// 0. A default ``m.room.power_levels`` event, giving the room creator + /// (and not other members) permission to send state events. Overridden + /// by the ``power_level_content_override`` parameter. + /// + /// 1. Events set by the ``preset``. Currently these are the + /// ``m.room.join_rules``, + /// ``m.room.history_visibility``, and ``m.room.guest_access`` state + /// events. + /// + /// 2. Events listed in ``initial_state``, in the order that they are + /// listed. + /// + /// 3. Events implied by ``name`` and ``topic`` (``m.room.name`` and + /// ``m.room.topic`` + /// state events). + /// + /// 4. Invite events implied by ``invite`` and ``invite_3pid`` + /// (``m.room.member`` with + /// ``membership: invite`` and ``m.room.third_party_invite``). + /// + /// The available presets do the following with respect to room state: + /// + /// ======================== ============== ====================== + /// ================ ========= + /// Preset ``join_rules`` ``history_visibility`` + /// ``guest_access`` Other + /// ======================== ============== ====================== + /// ================ ========= + /// ``private_chat`` ``invite`` ``shared`` ``can_join`` + /// ``trusted_private_chat`` ``invite`` ``shared`` ``can_join`` All + /// invitees are given the same power level as the room creator. + /// ``public_chat`` ``public`` ``shared`` ``forbidden`` + /// ======================== ============== ====================== + /// ================ ========= + /// + /// 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``. + struct Invite3pid { /// The hostname+port of the identity server which should be used for /// third party identifier lookups. QString idServer; @@ -104,35 +118,51 @@ public: QString address; }; - /// Create a new room with various configuration options.The server MUST - /// apply the normal state resolution rules when creatingthe new room, - /// including checking power levels for each event. It MUSTapply the events - /// implied by the request in the following order:0. A default - /// ``m.room.power_levels`` event, giving the room creator (and not other - /// members) permission to send state events. Overridden by the - /// ``power_level_content_override`` parameter.1. Events set by the - /// ``preset``. Currently these are the ``m.room.join_rules``, - /// ``m.room.history_visibility``, and ``m.room.guest_access`` state - /// events.2. Events listed in ``initial_state``, in the order that they are - /// listed.3. Events implied by ``name`` and ``topic`` (``m.room.name`` and - /// ``m.room.topic`` state events).4. Invite events implied by ``invite`` - /// and ``invite_3pid`` (``m.room.member`` with ``membership: invite`` and - /// ``m.room.third_party_invite``).The available presets do the following - /// with respect to room state:======================== ============== - /// ====================== ================ ========= Preset - /// ``join_rules`` ``history_visibility`` ``guest_access`` - /// Other======================== ============== ====================== - /// ================ =========``private_chat`` ``invite`` - /// ``shared`` ``can_join````trusted_private_chat`` ``invite`` - /// ``shared`` ``can_join`` All invitees are given the - /// same power level as the room creator.``public_chat`` ``public`` - /// ``shared`` ``forbidden``======================== - /// ============== ====================== ================ =========The - /// server will create a ``m.room.create`` event in the room with - /// therequesting user as the creator, alongside other keys provided in - /// the``creation_content``. - struct StateEvent - { + /// Create a new room with various configuration options. + /// + /// The server MUST apply the normal state resolution rules when creating + /// the new room, including checking power levels for each event. It MUST + /// apply the events implied by the request in the following order: + /// + /// 0. A default ``m.room.power_levels`` event, giving the room creator + /// (and not other members) permission to send state events. Overridden + /// by the ``power_level_content_override`` parameter. + /// + /// 1. Events set by the ``preset``. Currently these are the + /// ``m.room.join_rules``, + /// ``m.room.history_visibility``, and ``m.room.guest_access`` state + /// events. + /// + /// 2. Events listed in ``initial_state``, in the order that they are + /// listed. + /// + /// 3. Events implied by ``name`` and ``topic`` (``m.room.name`` and + /// ``m.room.topic`` + /// state events). + /// + /// 4. Invite events implied by ``invite`` and ``invite_3pid`` + /// (``m.room.member`` with + /// ``membership: invite`` and ``m.room.third_party_invite``). + /// + /// The available presets do the following with respect to room state: + /// + /// ======================== ============== ====================== + /// ================ ========= + /// Preset ``join_rules`` ``history_visibility`` + /// ``guest_access`` Other + /// ======================== ============== ====================== + /// ================ ========= + /// ``private_chat`` ``invite`` ``shared`` ``can_join`` + /// ``trusted_private_chat`` ``invite`` ``shared`` ``can_join`` All + /// invitees are given the same power level as the room creator. + /// ``public_chat`` ``public`` ``shared`` ``forbidden`` + /// ======================== ============== ====================== + /// ================ ========= + /// + /// 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``. + struct StateEvent { /// The type of event to send. QString type; /// The state_key of the state event. Defaults to an empty string. @@ -143,7 +173,8 @@ public: // Construction/destruction - /*! Create a new room + /*! \brief Create a new room + * * \param visibility * A ``public`` visibility indicates that the room will be shown * in the published room list. A ``private`` visibility will hide diff --git a/lib/csapi/definitions/auth_data.h b/lib/csapi/definitions/auth_data.h index 1aeea6c2..e564f7f3 100644 --- a/lib/csapi/definitions/auth_data.h +++ b/lib/csapi/definitions/auth_data.h @@ -9,17 +9,16 @@ #include #include -namespace Quotient -{ +namespace Quotient { // Data structures /// Used by clients to submit authentication information to the /// interactive-authentication API -struct AuthenticationData -{ +struct AuthenticationData { /// The login type that the client is attempting to complete. QString type; + /// The value of the session key given by the homeserver. QString session; @@ -28,8 +27,7 @@ struct AuthenticationData }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const AuthenticationData& pod); static void fillFrom(QJsonObject jo, AuthenticationData& pod); }; diff --git a/lib/csapi/definitions/client_device.h b/lib/csapi/definitions/client_device.h index f076c4da..2cf75950 100644 --- a/lib/csapi/definitions/client_device.h +++ b/lib/csapi/definitions/client_device.h @@ -6,30 +6,31 @@ #include "converters.h" -namespace Quotient -{ +namespace Quotient { // Data structures /// A client device -struct Device -{ +struct Device { /// Identifier of this device. QString deviceId; - /// Display name set by the user for this device. Absent if no name has - /// beenset. + + /// Display name set by the user for this device. Absent if no name has been + /// set. QString displayName; + /// The IP address where this device was last seen. (May be a few minutes - /// outof date, for efficiency reasons). + /// out of date, for efficiency reasons). QString lastSeenIp; - /// The timestamp (in milliseconds since the unix epoch) when this deviceswas - /// last seen. (May be a few minutes out of date, for efficiencyreasons). + + /// The timestamp (in milliseconds since the unix epoch) when this devices + /// was last seen. (May be a few minutes out of date, for efficiency + /// reasons). Omittable lastSeenTs; }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const Device& pod); static void fillFrom(const QJsonObject& jo, Device& pod); }; diff --git a/lib/csapi/definitions/device_keys.h b/lib/csapi/definitions/device_keys.h index d1d8abef..a067b4f3 100644 --- a/lib/csapi/definitions/device_keys.h +++ b/lib/csapi/definitions/device_keys.h @@ -8,35 +8,38 @@ #include -namespace Quotient -{ +namespace Quotient { // Data structures /// Device identity keys -struct DeviceKeys -{ - /// The ID of the user the device belongs to. Must match the user ID - /// usedwhen logging in. +struct DeviceKeys { + /// The ID of the user the device belongs to. Must match the user ID used + /// when logging in. QString userId; - /// The ID of the device these keys belong to. Must match the device ID - /// usedwhen logging in. + + /// The ID of the device these keys belong to. Must match the device ID used + /// when logging in. QString deviceId; + /// The encryption algorithms supported by this device. QStringList algorithms; - /// Public identity keys. The names of the properties should be in theformat - /// ``:``. The keys themselves should beencoded as - /// specified by the key algorithm. + + /// Public identity keys. The names of the properties should be in the + /// format ``:``. The keys themselves should be + /// encoded as specified by the key algorithm. QHash keys; - /// Signatures for the device key object. A map from user ID, to a map - /// from``:`` to the signature.The signature is - /// calculated using the process described at `SigningJSON`_. + + /// Signatures for the device key object. A map from user ID, to a map from + /// ``:`` to the signature. + /// + /// The signature is calculated using the process described at `Signing + /// JSON`_. QHash> signatures; }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const DeviceKeys& pod); static void fillFrom(const QJsonObject& jo, DeviceKeys& pod); }; diff --git a/lib/csapi/definitions/event_filter.h b/lib/csapi/definitions/event_filter.h index b41e2e9e..3958b125 100644 --- a/lib/csapi/definitions/event_filter.h +++ b/lib/csapi/definitions/event_filter.h @@ -6,27 +6,29 @@ #include "converters.h" -namespace Quotient -{ +namespace Quotient { // Data structures -struct EventFilter -{ +struct EventFilter { /// The maximum number of events to return. Omittable limit; + /// A list of sender IDs to exclude. If this list is absent then no senders /// are excluded. A matching sender will be excluded even if it is listed in /// the ``'senders'`` filter. QStringList notSenders; + /// A list of event types to exclude. If this list is absent then no event /// types are excluded. A matching type will be excluded even if it is /// listed in the ``'types'`` filter. A '*' can be used as a wildcard to /// match any sequence of characters. QStringList notTypes; + /// A list of senders IDs to include. If this list is absent then all /// senders are included. QStringList senders; + /// A list of event types to include. If this list is absent then all event /// types are included. A ``'*'`` can be used as a wildcard to match any /// sequence of characters. @@ -34,8 +36,7 @@ struct EventFilter }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const EventFilter& pod); static void fillFrom(const QJsonObject& jo, EventFilter& pod); }; diff --git a/lib/csapi/definitions/public_rooms_response.h b/lib/csapi/definitions/public_rooms_response.h index 1cb3aad5..36aa52b9 100644 --- a/lib/csapi/definitions/public_rooms_response.h +++ b/lib/csapi/definitions/public_rooms_response.h @@ -8,61 +8,68 @@ #include -namespace Quotient -{ +namespace Quotient { // Data structures -struct PublicRoomsChunk -{ +struct PublicRoomsChunk { /// Aliases of the room. May be empty. QStringList aliases; + /// The canonical alias of the room, if any. QString canonicalAlias; + /// The name of the room, if any. QString name; + /// The number of members joined to the room. int numJoinedMembers; + /// The ID of the room. QString roomId; + /// The topic of the room, if any. QString topic; + /// Whether the room may be viewed by guest users without joining. bool worldReadable; - /// Whether guest users may join the room and participate in it.If they can, - /// they will be subject to ordinary power levelrules like any other user. + + /// Whether guest users may join the room and participate in it. + /// If they can, they will be subject to ordinary power level + /// rules like any other user. bool guestCanJoin; + /// The URL for the room's avatar, if one is set. QString avatarUrl; }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const PublicRoomsChunk& pod); static void fillFrom(const QJsonObject& jo, PublicRoomsChunk& pod); }; - /// A list of the rooms on the server. -struct PublicRoomsResponse -{ +struct PublicRoomsResponse { /// A paginated chunk of public rooms. QVector chunk; - /// A pagination token for the response. The absence of this tokenmeans - /// there are no more results to fetch and the client shouldstop paginating. + + /// A pagination token for the response. The absence of this token + /// means there are no more results to fetch and the client should + /// stop paginating. QString nextBatch; - /// A pagination token that allows fetching previous results. Theabsence of - /// this token means there are no results before thisbatch, i.e. this is the - /// first batch. + + /// A pagination token that allows fetching previous results. The + /// absence of this token means there are no results before this + /// batch, i.e. this is the first batch. QString prevBatch; - /// An estimate on the total number of public rooms, if theserver has an - /// estimate. + + /// An estimate on the total number of public rooms, if the + /// server has an estimate. Omittable totalRoomCountEstimate; }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const PublicRoomsResponse& pod); static void fillFrom(const QJsonObject& jo, PublicRoomsResponse& pod); }; diff --git a/lib/csapi/definitions/push_condition.h b/lib/csapi/definitions/push_condition.h index 34a183de..189153b3 100644 --- a/lib/csapi/definitions/push_condition.h +++ b/lib/csapi/definitions/push_condition.h @@ -6,32 +6,32 @@ #include "converters.h" -namespace Quotient -{ +namespace Quotient { // Data structures -struct PushCondition -{ - +struct PushCondition { QString kind; - /// Required for ``event_match`` conditions. The dot-separated field of - /// theevent to match. + + /// Required for ``event_match`` conditions. The dot-separated field of the + /// event to match. QString key; - /// Required for ``event_match`` conditions. The glob-style pattern tomatch - /// against. Patterns with no special glob characters should betreated as - /// having asterisks prepended and appended when testing thecondition. + + /// Required for ``event_match`` conditions. The glob-style pattern to + /// match against. Patterns with no special glob characters should be + /// treated as having asterisks prepended and appended when testing the + /// condition. QString pattern; - /// Required for ``room_member_count`` conditions. A decimal integeroptionally - /// prefixed by one of, ==, <, >, >= or <=. A prefix of < matchesrooms where - /// the member count is strictly less than the given number andso forth. If - /// no prefix is present, this parameter defaults to ==. + + /// Required for ``room_member_count`` conditions. A decimal integer + /// optionally prefixed by one of, ==, <, >, >= or <=. A prefix of < matches + /// rooms where the member count is strictly less than the given number and + /// so forth. If no prefix is present, this parameter defaults to ==. QString is; }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const PushCondition& pod); static void fillFrom(const QJsonObject& jo, PushCondition& pod); }; diff --git a/lib/csapi/definitions/push_rule.h b/lib/csapi/definitions/push_rule.h index e64d6ba8..c09d063f 100644 --- a/lib/csapi/definitions/push_rule.h +++ b/lib/csapi/definitions/push_rule.h @@ -12,33 +12,35 @@ #include #include -namespace Quotient -{ +namespace Quotient { // Data structures -struct PushRule -{ +struct PushRule { /// The actions to perform when this rule is matched. QVector actions; + /// Whether this is a default rule, or has been set explicitly. bool isDefault; + /// Whether the push rule is enabled or not. bool enabled; + /// The ID of this rule. QString ruleId; + /// The conditions that must hold true for an event in order for a rule to - /// beapplied to an event. A rule with no conditions always matches. - /// Onlyapplicable to ``underride`` and ``override`` rules. + /// be applied to an event. A rule with no conditions always matches. Only + /// applicable to ``underride`` and ``override`` rules. QVector conditions; - /// The glob-style pattern to match against. Only applicable to - /// ``content``rules. + + /// The glob-style pattern to match against. Only applicable to ``content`` + /// rules. QString pattern; }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const PushRule& pod); static void fillFrom(const QJsonObject& jo, PushRule& pod); }; diff --git a/lib/csapi/definitions/push_ruleset.h b/lib/csapi/definitions/push_ruleset.h index b6b9670e..98a21408 100644 --- a/lib/csapi/definitions/push_ruleset.h +++ b/lib/csapi/definitions/push_ruleset.h @@ -10,14 +10,11 @@ #include -namespace Quotient -{ +namespace Quotient { // Data structures -struct PushRuleset -{ - +struct PushRuleset { QVector content; QVector override; @@ -30,8 +27,7 @@ struct PushRuleset }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const PushRuleset& pod); static void fillFrom(const QJsonObject& jo, PushRuleset& pod); }; diff --git a/lib/csapi/definitions/room_event_filter.h b/lib/csapi/definitions/room_event_filter.h index ae06a615..756f9ada 100644 --- a/lib/csapi/definitions/room_event_filter.h +++ b/lib/csapi/definitions/room_event_filter.h @@ -8,20 +8,20 @@ #include "csapi/definitions/event_filter.h" -namespace Quotient -{ +namespace Quotient { // Data structures -struct RoomEventFilter : EventFilter -{ +struct RoomEventFilter : EventFilter { /// 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. QStringList notRooms; + /// A list of room IDs to include. If this list is absent then all rooms are /// included. QStringList rooms; + /// If ``true``, includes only events with a ``url`` key in their content. /// If ``false``, excludes those events. If omitted, ``url`` key is not /// considered for filtering. @@ -29,8 +29,7 @@ struct RoomEventFilter : EventFilter }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const RoomEventFilter& pod); static void fillFrom(const QJsonObject& jo, RoomEventFilter& pod); }; diff --git a/lib/csapi/definitions/sync_filter.h b/lib/csapi/definitions/sync_filter.h index 9ea39a65..ad8d055d 100644 --- a/lib/csapi/definitions/sync_filter.h +++ b/lib/csapi/definitions/sync_filter.h @@ -9,97 +9,102 @@ #include "csapi/definitions/event_filter.h" #include "csapi/definitions/room_event_filter.h" -namespace Quotient -{ +namespace Quotient { // Data structures /// The state events to include for rooms. -struct StateFilter : RoomEventFilter -{ - /// If ``true``, the only ``m.room.member`` events returned inthe ``state`` - /// section of the ``/sync`` response are thosewhich are definitely necessary - /// for a client to displaythe ``sender`` of the timeline events in that - /// response.If ``false``, ``m.room.member`` events are not filtered.By - /// default, servers should suppress duplicate redundantlazy-loaded - /// ``m.room.member`` events from being sent to a givenclient across multiple - /// calls to ``/sync``, given that most clientscache membership events (see - /// ``include_redundant_members``to change this behaviour). +struct StateFilter : RoomEventFilter { + /// If ``true``, the only ``m.room.member`` events returned in + /// the ``state`` section of the ``/sync`` response are those + /// which are definitely necessary for a client to display + /// the ``sender`` of the timeline events in that response. + /// If ``false``, ``m.room.member`` events are not filtered. + /// By default, servers should suppress duplicate redundant + /// lazy-loaded ``m.room.member`` events from being sent to a given + /// client across multiple calls to ``/sync``, given that most clients + /// cache membership events (see ``include_redundant_members`` + /// to change this behaviour). Omittable lazyLoadMembers; - /// If ``true``, the ``state`` section of the ``/sync`` response willalways - /// contain the ``m.room.member`` events required to displaythe ``sender`` - /// of the timeline events in that response, assuming``lazy_load_members`` - /// is enabled. This means that redundantduplicate member events may be - /// returned across multiple calls to``/sync``. This is useful for naive - /// clients who never trackmembership data. If ``false``, duplicate - /// ``m.room.member`` eventsmay be suppressed by the server across multiple - /// calls to ``/sync``.If ``lazy_load_members`` is ``false`` this field is - /// ignored. + + /// If ``true``, the ``state`` section of the ``/sync`` response will + /// always contain the ``m.room.member`` events required to display + /// the ``sender`` of the timeline events in that response, assuming + /// ``lazy_load_members`` is enabled. This means that redundant + /// duplicate member events may be returned across multiple calls to + /// ``/sync``. This is useful for naive clients who never track + /// membership data. If ``false``, duplicate ``m.room.member`` events + /// may be suppressed by the server across multiple calls to ``/sync``. + /// If ``lazy_load_members`` is ``false`` this field is ignored. Omittable includeRedundantMembers; }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const StateFilter& pod); static void fillFrom(const QJsonObject& jo, StateFilter& pod); }; - /// Filters to be applied to room data. -struct RoomFilter -{ +struct 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`` QStringList notRooms; + /// A list of room IDs to include. If this list is absent then all rooms are /// included. This filter is applied before the filters in ``ephemeral``, /// ``state``, ``timeline`` or ``account_data`` QStringList rooms; + /// The events that aren't recorded in the room history, e.g. typing and /// receipts, to include for rooms. Omittable ephemeral; + /// Include rooms that the user has left in the sync, default false Omittable includeLeave; + /// The state events to include for rooms. Omittable state; + /// The message and state update events to include for rooms. Omittable timeline; + /// The per user account data to include for rooms. Omittable accountData; }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const RoomFilter& pod); static void fillFrom(const QJsonObject& jo, RoomFilter& pod); }; -struct Filter -{ +struct Filter { /// List of event fields to include. If this list is absent then all fields /// are included. The entries may include '.' charaters to indicate /// sub-fields. So ['content.body'] will include the 'body' field of the /// 'content' object. A literal '.' character in a field name may be escaped /// using a '\\'. A server may include more fields than were requested. QStringList eventFields; + /// The format to use for events. 'client' will return the events in a /// format suitable for clients. 'federation' will return the raw event as /// receieved over federation. The default is 'client'. QString eventFormat; + /// The presence updates to include. Omittable presence; + /// The user account data that isn't associated with rooms to include. Omittable accountData; + /// Filters to be applied to room data. Omittable room; }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const Filter& pod); static void fillFrom(const QJsonObject& jo, Filter& pod); }; diff --git a/lib/csapi/definitions/user_identifier.h b/lib/csapi/definitions/user_identifier.h index 74e6ce2b..72a81677 100644 --- a/lib/csapi/definitions/user_identifier.h +++ b/lib/csapi/definitions/user_identifier.h @@ -8,14 +8,12 @@ #include -namespace Quotient -{ +namespace Quotient { // Data structures /// Identification information for a user -struct UserIdentifier -{ +struct UserIdentifier { /// The type of identification. See `Identifier types`_ for supported /// values and additional property descriptions. QString type; @@ -25,8 +23,7 @@ struct UserIdentifier }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const UserIdentifier& pod); static void fillFrom(QJsonObject jo, UserIdentifier& pod); }; diff --git a/lib/csapi/definitions/wellknown/full.h b/lib/csapi/definitions/wellknown/full.h index 92c8afff..88d7da79 100644 --- a/lib/csapi/definitions/wellknown/full.h +++ b/lib/csapi/definitions/wellknown/full.h @@ -12,20 +12,19 @@ #include #include -namespace Quotient -{ +namespace Quotient { // Data structures -/// Used by clients to determine the homeserver, identity server, and other/// +/// Used by clients to determine the homeserver, identity server, and other /// optional components they should be interacting with. -struct DiscoveryInformation -{ - /// Used by clients to determine the homeserver, identity server, and - /// otheroptional components they should be interacting with. +struct DiscoveryInformation { + /// Used by clients to determine the homeserver, identity server, and other + /// optional components they should be interacting with. HomeserverInformation homeserver; - /// Used by clients to determine the homeserver, identity server, and - /// otheroptional components they should be interacting with. + + /// Used by clients to determine the homeserver, identity server, and other + /// optional components they should be interacting with. Omittable identityServer; /// Application-dependent keys using Java package naming convention. @@ -33,8 +32,7 @@ struct DiscoveryInformation }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const DiscoveryInformation& pod); static void fillFrom(QJsonObject jo, DiscoveryInformation& pod); }; diff --git a/lib/csapi/definitions/wellknown/homeserver.h b/lib/csapi/definitions/wellknown/homeserver.h index 606df88b..7607c8b5 100644 --- a/lib/csapi/definitions/wellknown/homeserver.h +++ b/lib/csapi/definitions/wellknown/homeserver.h @@ -6,21 +6,18 @@ #include "converters.h" -namespace Quotient -{ +namespace Quotient { // Data structures /// Used by clients to discover homeserver information. -struct HomeserverInformation -{ +struct HomeserverInformation { /// The base URL for the homeserver for client-server connections. QString baseUrl; }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const HomeserverInformation& pod); static void fillFrom(const QJsonObject& jo, HomeserverInformation& pod); }; diff --git a/lib/csapi/definitions/wellknown/identity_server.h b/lib/csapi/definitions/wellknown/identity_server.h index b4304ef7..d272e527 100644 --- a/lib/csapi/definitions/wellknown/identity_server.h +++ b/lib/csapi/definitions/wellknown/identity_server.h @@ -6,21 +6,18 @@ #include "converters.h" -namespace Quotient -{ +namespace Quotient { // Data structures /// Used by clients to discover identity server information. -struct IdentityServerInformation -{ +struct IdentityServerInformation { /// The base URL for the identity server for client-server connections. QString baseUrl; }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const IdentityServerInformation& pod); static void fillFrom(const QJsonObject& jo, IdentityServerInformation& pod); }; diff --git a/lib/csapi/device_management.cpp b/lib/csapi/device_management.cpp index 0889089e..ba7570f7 100644 --- a/lib/csapi/device_management.cpp +++ b/lib/csapi/device_management.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class GetDevicesJob::Private -{ +class GetDevicesJob::Private { public: QVector devices; }; @@ -23,10 +22,9 @@ QUrl GetDevicesJob::makeRequestUrl(QUrl baseUrl) return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/devices"); } -static const auto GetDevicesJobName = QStringLiteral("GetDevicesJob"); - GetDevicesJob::GetDevicesJob() - : BaseJob(HttpVerb::Get, GetDevicesJobName, basePath % "/devices") + : BaseJob(HttpVerb::Get, QStringLiteral("GetDevicesJob"), + basePath % "/devices") , d(new Private) {} @@ -42,8 +40,7 @@ BaseJob::Status GetDevicesJob::parseJson(const QJsonDocument& data) return Success; } -class GetDeviceJob::Private -{ +class GetDeviceJob::Private { public: Device data; }; @@ -54,10 +51,9 @@ QUrl GetDeviceJob::makeRequestUrl(QUrl baseUrl, const QString& deviceId) basePath % "/devices/" % deviceId); } -static const auto GetDeviceJobName = QStringLiteral("GetDeviceJob"); - GetDeviceJob::GetDeviceJob(const QString& deviceId) - : BaseJob(HttpVerb::Get, GetDeviceJobName, basePath % "/devices/" % deviceId) + : BaseJob(HttpVerb::Get, QStringLiteral("GetDeviceJob"), + basePath % "/devices/" % deviceId) , d(new Private) {} @@ -68,14 +64,13 @@ const Device& GetDeviceJob::data() const { return d->data; } BaseJob::Status GetDeviceJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -static const auto UpdateDeviceJobName = QStringLiteral("UpdateDeviceJob"); - UpdateDeviceJob::UpdateDeviceJob(const QString& deviceId, const QString& displayName) - : BaseJob(HttpVerb::Put, UpdateDeviceJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("UpdateDeviceJob"), basePath % "/devices/" % deviceId) { QJsonObject _data; @@ -83,11 +78,9 @@ UpdateDeviceJob::UpdateDeviceJob(const QString& deviceId, setRequestData(_data); } -static const auto DeleteDeviceJobName = QStringLiteral("DeleteDeviceJob"); - DeleteDeviceJob::DeleteDeviceJob(const QString& deviceId, const Omittable& auth) - : BaseJob(HttpVerb::Delete, DeleteDeviceJobName, + : BaseJob(HttpVerb::Delete, QStringLiteral("DeleteDeviceJob"), basePath % "/devices/" % deviceId) { QJsonObject _data; @@ -95,11 +88,10 @@ DeleteDeviceJob::DeleteDeviceJob(const QString& deviceId, setRequestData(_data); } -static const auto DeleteDevicesJobName = QStringLiteral("DeleteDevicesJob"); - DeleteDevicesJob::DeleteDevicesJob(const QStringList& devices, const Omittable& auth) - : BaseJob(HttpVerb::Post, DeleteDevicesJobName, basePath % "/delete_devices") + : BaseJob(HttpVerb::Post, QStringLiteral("DeleteDevicesJob"), + basePath % "/delete_devices") { QJsonObject _data; addParam<>(_data, QStringLiteral("devices"), devices); diff --git a/lib/csapi/device_management.h b/lib/csapi/device_management.h index d380a44f..1c57db84 100644 --- a/lib/csapi/device_management.h +++ b/lib/csapi/device_management.h @@ -13,28 +13,25 @@ #include -namespace Quotient -{ +namespace Quotient { // Operations -/// List registered devices for the current user -/*! +/*! \brief List registered devices for the current user + * * Gets information about all devices for the current user. */ -class GetDevicesJob : public BaseJob -{ +class GetDevicesJob : public BaseJob { public: + /// List registered devices for the current user explicit GetDevicesJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetDevicesJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetDevicesJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetDevicesJob() override; // Result properties @@ -50,27 +47,25 @@ private: QScopedPointer d; }; -/// Get a single device -/*! +/*! \brief Get a single device + * * Gets information on a single device, by device id. */ -class GetDeviceJob : public BaseJob -{ +class GetDeviceJob : public BaseJob { public: - /*! Get a single device + /*! \brief Get a single device + * * \param deviceId * The device to retrieve. */ explicit GetDeviceJob(const QString& deviceId); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetDeviceJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& deviceId); - ~GetDeviceJob() override; // Result properties @@ -86,14 +81,14 @@ private: QScopedPointer d; }; -/// Update a device -/*! +/*! \brief Update a device + * * Updates the metadata on the given device. */ -class UpdateDeviceJob : public BaseJob -{ +class UpdateDeviceJob : public BaseJob { public: - /*! Update a device + /*! \brief Update a device + * * \param deviceId * The device to update. * \param displayName @@ -104,16 +99,16 @@ public: const QString& displayName = {}); }; -/// Delete a device -/*! +/*! \brief Delete a device + * * This API endpoint uses the `User-Interactive Authentication API`_. * * Deletes the given device, and invalidates any access token associated with it. */ -class DeleteDeviceJob : public BaseJob -{ +class DeleteDeviceJob : public BaseJob { public: - /*! Delete a device + /*! \brief Delete a device + * * \param deviceId * The device to delete. * \param auth @@ -124,17 +119,17 @@ public: const Omittable& auth = none); }; -/// Bulk deletion of devices -/*! +/*! \brief Bulk deletion of devices + * * This API endpoint uses the `User-Interactive Authentication API`_. * * Deletes the given devices, and invalidates any access token associated with * them. */ -class DeleteDevicesJob : public BaseJob -{ +class DeleteDevicesJob : public BaseJob { public: - /*! Bulk deletion of devices + /*! \brief Bulk deletion of devices + * * \param devices * The list of device IDs to delete. * \param auth diff --git a/lib/csapi/directory.cpp b/lib/csapi/directory.cpp index b2689d1e..0d4029bd 100644 --- a/lib/csapi/directory.cpp +++ b/lib/csapi/directory.cpp @@ -12,10 +12,8 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0/directory"); -static const auto SetRoomAliasJobName = QStringLiteral("SetRoomAliasJob"); - SetRoomAliasJob::SetRoomAliasJob(const QString& roomAlias, const QString& roomId) - : BaseJob(HttpVerb::Put, SetRoomAliasJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomAliasJob"), basePath % "/room/" % roomAlias) { QJsonObject _data; @@ -23,8 +21,7 @@ SetRoomAliasJob::SetRoomAliasJob(const QString& roomAlias, const QString& roomId setRequestData(_data); } -class GetRoomIdByAliasJob::Private -{ +class GetRoomIdByAliasJob::Private { public: QString roomId; QStringList servers; @@ -36,11 +33,8 @@ QUrl GetRoomIdByAliasJob::makeRequestUrl(QUrl baseUrl, const QString& roomAlias) basePath % "/room/" % roomAlias); } -static const auto GetRoomIdByAliasJobName = - QStringLiteral("GetRoomIdByAliasJob"); - GetRoomIdByAliasJob::GetRoomIdByAliasJob(const QString& roomAlias) - : BaseJob(HttpVerb::Get, GetRoomIdByAliasJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomIdByAliasJob"), basePath % "/room/" % roomAlias, false) , d(new Private) {} @@ -66,9 +60,7 @@ QUrl DeleteRoomAliasJob::makeRequestUrl(QUrl baseUrl, const QString& roomAlias) basePath % "/room/" % roomAlias); } -static const auto DeleteRoomAliasJobName = QStringLiteral("DeleteRoomAliasJob"); - DeleteRoomAliasJob::DeleteRoomAliasJob(const QString& roomAlias) - : BaseJob(HttpVerb::Delete, DeleteRoomAliasJobName, + : BaseJob(HttpVerb::Delete, QStringLiteral("DeleteRoomAliasJob"), basePath % "/room/" % roomAlias) {} diff --git a/lib/csapi/directory.h b/lib/csapi/directory.h index 7863aa1a..c13ca20a 100644 --- a/lib/csapi/directory.h +++ b/lib/csapi/directory.h @@ -6,17 +6,17 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Create a new mapping from room alias to room ID. - -class SetRoomAliasJob : public BaseJob -{ +/*! \brief Create a new mapping from room alias to room ID. + * + */ +class SetRoomAliasJob : public BaseJob { public: - /*! Create a new mapping from room alias to room ID. + /*! \brief Create a new mapping from room alias to room ID. + * * \param roomAlias * The room alias to set. * \param roomId @@ -25,37 +25,36 @@ public: explicit SetRoomAliasJob(const QString& roomAlias, const QString& roomId); }; -/// Get the room ID corresponding to this room alias. -/*! +/*! \brief Get the room ID corresponding to this room alias. + * * Requests that the server resolve a room alias to a room ID. * * 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 GetRoomIdByAliasJob : public BaseJob -{ +class GetRoomIdByAliasJob : public BaseJob { public: - /*! Get the room ID corresponding to this room alias. + /*! \brief Get the room ID corresponding to this room alias. + * * \param roomAlias * The room alias. */ explicit GetRoomIdByAliasJob(const QString& roomAlias); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetRoomIdByAliasJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomAlias); - ~GetRoomIdByAliasJob() override; // Result properties /// The room ID for this room alias. const QString& roomId() const; + /// A list of servers that are aware of this room alias. const QStringList& servers() const; @@ -67,28 +66,27 @@ private: QScopedPointer d; }; -/// Remove a mapping of room alias to room ID. -/*! +/*! \brief Remove a mapping of room alias to room ID. + * * Remove a mapping of room alias to room ID. * * Servers may choose to implement additional access control checks here, for * instance that room aliases can only be deleted by their creator or a server * administrator. */ -class DeleteRoomAliasJob : public BaseJob -{ +class DeleteRoomAliasJob : public BaseJob { public: - /*! Remove a mapping of room alias to room ID. + /*! \brief Remove a mapping of room alias to room ID. + * * \param roomAlias * The room alias to remove. */ explicit DeleteRoomAliasJob(const QString& roomAlias); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for DeleteRoomAliasJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomAlias); }; diff --git a/lib/csapi/event_context.cpp b/lib/csapi/event_context.cpp index d233eedb..5bb2222e 100644 --- a/lib/csapi/event_context.cpp +++ b/lib/csapi/event_context.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class GetEventContextJob::Private -{ +class GetEventContextJob::Private { public: QString begin; QString end; @@ -40,12 +39,10 @@ QUrl GetEventContextJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, queryToGetEventContext(limit)); } -static const auto GetEventContextJobName = QStringLiteral("GetEventContextJob"); - GetEventContextJob::GetEventContextJob(const QString& roomId, const QString& eventId, Omittable limit) - : BaseJob(HttpVerb::Get, GetEventContextJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetEventContextJob"), basePath % "/rooms/" % roomId % "/context/" % eventId, queryToGetEventContext(limit)) , d(new Private) diff --git a/lib/csapi/event_context.h b/lib/csapi/event_context.h index 755fc662..54441617 100644 --- a/lib/csapi/event_context.h +++ b/lib/csapi/event_context.h @@ -9,21 +9,20 @@ #include "events/eventloader.h" #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Get events and state around the specified event. -/*! +/*! \brief Get events and state around the specified event. + * * This API returns a number of events that happened just before and * after the specified event. This allows clients to get the context * surrounding an event. */ -class GetEventContextJob : public BaseJob -{ +class GetEventContextJob : public BaseJob { public: - /*! Get events and state around the specified event. + /*! \brief Get events and state around the specified event. + * * \param roomId * The room to get events from. * \param eventId @@ -34,32 +33,35 @@ public: explicit GetEventContextJob(const QString& roomId, const QString& eventId, Omittable limit = none); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetEventContextJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& eventId, Omittable limit = none); - ~GetEventContextJob() override; // Result properties /// A token that can be used to paginate backwards with. const QString& begin() const; + /// A token that can be used to paginate forwards with. const QString& end() const; + /// A list of room events that happened just before the /// requested event, in reverse-chronological order. RoomEvents&& eventsBefore(); + /// Details of the requested event. RoomEventPtr&& event(); + /// A list of room events that happened just after the /// requested event, in chronological order. RoomEvents&& eventsAfter(); + /// The state of the room at the last event returned. StateEvents&& state(); diff --git a/lib/csapi/filter.cpp b/lib/csapi/filter.cpp index b4160ba4..98b85f83 100644 --- a/lib/csapi/filter.cpp +++ b/lib/csapi/filter.cpp @@ -12,16 +12,13 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class DefineFilterJob::Private -{ +class DefineFilterJob::Private { public: QString filterId; }; -static const auto DefineFilterJobName = QStringLiteral("DefineFilterJob"); - DefineFilterJob::DefineFilterJob(const QString& userId, const Filter& filter) - : BaseJob(HttpVerb::Post, DefineFilterJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("DefineFilterJob"), basePath % "/user/" % userId % "/filter") , d(new Private) { @@ -43,8 +40,7 @@ BaseJob::Status DefineFilterJob::parseJson(const QJsonDocument& data) return Success; } -class GetFilterJob::Private -{ +class GetFilterJob::Private { public: Filter data; }; @@ -57,10 +53,8 @@ QUrl GetFilterJob::makeRequestUrl(QUrl baseUrl, const QString& userId, % filterId); } -static const auto GetFilterJobName = QStringLiteral("GetFilterJob"); - GetFilterJob::GetFilterJob(const QString& userId, const QString& filterId) - : BaseJob(HttpVerb::Get, GetFilterJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetFilterJob"), basePath % "/user/" % userId % "/filter/" % filterId) , d(new Private) {} @@ -72,5 +66,6 @@ const Filter& GetFilterJob::data() const { return d->data; } BaseJob::Status GetFilterJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } diff --git a/lib/csapi/filter.h b/lib/csapi/filter.h index 5001a492..7a0f8958 100644 --- a/lib/csapi/filter.h +++ b/lib/csapi/filter.h @@ -10,21 +10,20 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Upload a new filter. -/*! +/*! \brief Upload a new filter. + * * 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 DefineFilterJob : public BaseJob -{ +class DefineFilterJob : public BaseJob { public: - /*! Upload a new filter. + /*! \brief Upload a new filter. + * * \param userId * The id of the user uploading the filter. The access token must be * authorized to make requests for this user id. \param filter Uploads a new @@ -51,12 +50,13 @@ private: QScopedPointer d; }; -/// Download a filter - -class GetFilterJob : public BaseJob -{ +/*! \brief Download a filter + * + */ +class GetFilterJob : public BaseJob { public: - /*! Download a filter + /*! \brief Download a filter + * * \param userId * The user ID to download a filter for. * \param filterId @@ -64,15 +64,13 @@ public: */ explicit GetFilterJob(const QString& userId, const QString& filterId); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetFilterJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& filterId); - ~GetFilterJob() override; // Result properties diff --git a/lib/csapi/inviting.cpp b/lib/csapi/inviting.cpp index b60df6f8..f070c3ce 100644 --- a/lib/csapi/inviting.cpp +++ b/lib/csapi/inviting.cpp @@ -12,10 +12,8 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto InviteUserJobName = QStringLiteral("InviteUserJob"); - InviteUserJob::InviteUserJob(const QString& roomId, const QString& userId) - : BaseJob(HttpVerb::Post, InviteUserJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("InviteUserJob"), basePath % "/rooms/" % roomId % "/invite") { QJsonObject _data; diff --git a/lib/csapi/inviting.h b/lib/csapi/inviting.h index faf315b1..41d78ae6 100644 --- a/lib/csapi/inviting.h +++ b/lib/csapi/inviting.h @@ -6,13 +6,12 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Invite a user to participate in a particular room. -/*! +/*! \brief Invite a user to participate in a particular room. + * * .. _invite-by-user-id-endpoint: * * *Note that there are two forms of this API, which are documented separately. @@ -32,10 +31,10 @@ namespace Quotient * * .. _third party invites section: `invite-by-third-party-id-endpoint`_ */ -class InviteUserJob : public BaseJob -{ +class InviteUserJob : public BaseJob { public: - /*! Invite a user to participate in a particular room. + /*! \brief Invite a user to participate in a particular room. + * * \param roomId * The room identifier (not alias) to which to invite the user. * \param userId diff --git a/lib/csapi/joining.cpp b/lib/csapi/joining.cpp index 2dd617bb..cde179e0 100644 --- a/lib/csapi/joining.cpp +++ b/lib/csapi/joining.cpp @@ -13,12 +13,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const JoinRoomByIdJob::ThirdPartySigned& pod) { @@ -31,17 +29,14 @@ struct JsonObjectConverter } // namespace Quotient -class JoinRoomByIdJob::Private -{ +class JoinRoomByIdJob::Private { public: QString roomId; }; -static const auto JoinRoomByIdJobName = QStringLiteral("JoinRoomByIdJob"); - JoinRoomByIdJob::JoinRoomByIdJob( const QString& roomId, const Omittable& thirdPartySigned) - : BaseJob(HttpVerb::Post, JoinRoomByIdJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("JoinRoomByIdJob"), basePath % "/rooms/" % roomId % "/join") , d(new Private) { @@ -67,12 +62,10 @@ BaseJob::Status JoinRoomByIdJob::parseJson(const QJsonDocument& data) } // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const JoinRoomJob::Signed& pod) { addParam<>(jo, QStringLiteral("sender"), pod.sender); @@ -83,8 +76,7 @@ struct JsonObjectConverter }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const JoinRoomJob::ThirdPartySigned& pod) { addParam<>(jo, QStringLiteral("signed"), pod.signedData); @@ -93,8 +85,7 @@ struct JsonObjectConverter } // namespace Quotient -class JoinRoomJob::Private -{ +class JoinRoomJob::Private { public: QString roomId; }; @@ -106,12 +97,10 @@ BaseJob::Query queryToJoinRoom(const QStringList& serverName) return _q; } -static const auto JoinRoomJobName = QStringLiteral("JoinRoomJob"); - JoinRoomJob::JoinRoomJob(const QString& roomIdOrAlias, const QStringList& serverName, const Omittable& thirdPartySigned) - : BaseJob(HttpVerb::Post, JoinRoomJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("JoinRoomJob"), basePath % "/join/" % roomIdOrAlias, queryToJoinRoom(serverName)) , d(new Private) { diff --git a/lib/csapi/joining.h b/lib/csapi/joining.h index cf456da9..6d93bcb1 100644 --- a/lib/csapi/joining.h +++ b/lib/csapi/joining.h @@ -10,13 +10,12 @@ #include -namespace Quotient -{ +namespace Quotient { // Operations -/// Start the requesting user participating in a particular room. -/*! +/*! \brief Start the requesting user participating in a particular room. + * * *Note that this API requires a room ID, not alias.* ``/join/{roomIdOrAlias}`` * *exists if you have a room alias.* * @@ -32,15 +31,13 @@ namespace Quotient * that it matches a pending ``m.room.third_party_invite`` event in the * room, and perform key validity checking if required by the event. */ -class JoinRoomByIdJob : public BaseJob -{ +class JoinRoomByIdJob : public BaseJob { public: // Inner data structures /// 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 ThirdPartySigned - { + struct ThirdPartySigned { /// The Matrix ID of the user who issued the invite. QString sender; /// The Matrix ID of the invitee. @@ -54,7 +51,8 @@ public: // Construction/destruction - /*! Start the requesting user participating in a particular room. + /*! \brief Start the requesting user participating in a particular room. + * * \param roomId * The room identifier (not alias) to join. * \param thirdPartySigned @@ -80,8 +78,8 @@ private: QScopedPointer d; }; -/// Start the requesting user participating in a particular room. -/*! +/*! \brief Start the requesting user participating in a particular room. + * * *Note that this API takes either a room ID or alias, unlike* * ``/room/{roomId}/join``. * @@ -97,23 +95,25 @@ private: * that it matches a pending ``m.room.third_party_invite`` event in the * room, and perform key validity checking if required by the event. */ -class JoinRoomJob : public BaseJob -{ +class JoinRoomJob : public BaseJob { public: // Inner data structures /// *Note that this API takes either a room ID or alias, unlike* - /// ``/room/{roomId}/join``.This API starts a user participating in a - /// particular room, if that useris allowed to participate in that room. - /// After this call, the client isallowed to see all current state events in - /// the room, and all subsequentevents associated with the room until the - /// user leaves the room.After a user has joined a room, the room will - /// appear as an entry in theresponse of the |/initialSync|_ and |/sync|_ - /// APIs.If a ``third_party_signed`` was supplied, the homeserver must - /// verifythat it matches a pending ``m.room.third_party_invite`` event in - /// theroom, and perform key validity checking if required by the event. - struct Signed - { + /// ``/room/{roomId}/join``. + /// + /// This API starts a user participating 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. + /// + /// After a user has joined a room, the room will appear as an entry in the + /// response of the |/initialSync|_ and |/sync|_ APIs. + /// + /// If a ``third_party_signed`` was supplied, the homeserver must verify + /// that it matches a pending ``m.room.third_party_invite`` event in the + /// room, and perform key validity checking if required by the event. + struct Signed { /// The Matrix ID of the user who issued the invite. QString sender; /// The Matrix ID of the invitee. @@ -127,8 +127,7 @@ public: /// 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 ThirdPartySigned - { + struct ThirdPartySigned { /// 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. Signed signedData; @@ -136,7 +135,8 @@ public: // Construction/destruction - /*! Start the requesting user participating in a particular room. + /*! \brief Start the requesting user participating in a particular room. + * * \param roomIdOrAlias * The room identifier or alias to join. * \param serverName diff --git a/lib/csapi/keys.cpp b/lib/csapi/keys.cpp index cd33ad19..b1a947b3 100644 --- a/lib/csapi/keys.cpp +++ b/lib/csapi/keys.cpp @@ -12,17 +12,15 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class UploadKeysJob::Private -{ +class UploadKeysJob::Private { public: QHash oneTimeKeyCounts; }; -static const auto UploadKeysJobName = QStringLiteral("UploadKeysJob"); - UploadKeysJob::UploadKeysJob(const Omittable& deviceKeys, const QHash& oneTimeKeys) - : BaseJob(HttpVerb::Post, UploadKeysJobName, basePath % "/keys/upload") + : BaseJob(HttpVerb::Post, QStringLiteral("UploadKeysJob"), + basePath % "/keys/upload") , d(new Private) { QJsonObject _data; @@ -50,12 +48,10 @@ BaseJob::Status UploadKeysJob::parseJson(const QJsonDocument& data) } // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void fillFrom(const QJsonObject& jo, QueryKeysJob::UnsignedDeviceInfo& result) { @@ -64,8 +60,7 @@ struct JsonObjectConverter }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void fillFrom(const QJsonObject& jo, QueryKeysJob::DeviceInformation& result) { @@ -76,18 +71,16 @@ struct JsonObjectConverter } // namespace Quotient -class QueryKeysJob::Private -{ +class QueryKeysJob::Private { public: QHash failures; QHash> deviceKeys; }; -static const auto QueryKeysJobName = QStringLiteral("QueryKeysJob"); - QueryKeysJob::QueryKeysJob(const QHash& deviceKeys, Omittable timeout, const QString& token) - : BaseJob(HttpVerb::Post, QueryKeysJobName, basePath % "/keys/query") + : BaseJob(HttpVerb::Post, QStringLiteral("QueryKeysJob"), + basePath % "/keys/query") , d(new Private) { QJsonObject _data; @@ -119,19 +112,17 @@ BaseJob::Status QueryKeysJob::parseJson(const QJsonDocument& data) return Success; } -class ClaimKeysJob::Private -{ +class ClaimKeysJob::Private { public: QHash failures; QHash> oneTimeKeys; }; -static const auto ClaimKeysJobName = QStringLiteral("ClaimKeysJob"); - ClaimKeysJob::ClaimKeysJob( const QHash>& oneTimeKeys, Omittable timeout) - : BaseJob(HttpVerb::Post, ClaimKeysJobName, basePath % "/keys/claim") + : BaseJob(HttpVerb::Post, QStringLiteral("ClaimKeysJob"), + basePath % "/keys/claim") , d(new Private) { QJsonObject _data; @@ -161,8 +152,7 @@ BaseJob::Status ClaimKeysJob::parseJson(const QJsonDocument& data) return Success; } -class GetKeysChangesJob::Private -{ +class GetKeysChangesJob::Private { public: QStringList changed; QStringList left; @@ -184,11 +174,9 @@ QUrl GetKeysChangesJob::makeRequestUrl(QUrl baseUrl, const QString& from, queryToGetKeysChanges(from, to)); } -static const auto GetKeysChangesJobName = QStringLiteral("GetKeysChangesJob"); - GetKeysChangesJob::GetKeysChangesJob(const QString& from, const QString& to) - : BaseJob(HttpVerb::Get, GetKeysChangesJobName, basePath % "/keys/changes", - queryToGetKeysChanges(from, to)) + : BaseJob(HttpVerb::Get, QStringLiteral("GetKeysChangesJob"), + basePath % "/keys/changes", queryToGetKeysChanges(from, to)) , d(new Private) {} diff --git a/lib/csapi/keys.h b/lib/csapi/keys.h index 27867b8c..2673acc5 100644 --- a/lib/csapi/keys.h +++ b/lib/csapi/keys.h @@ -14,19 +14,18 @@ #include #include -namespace Quotient -{ +namespace Quotient { // Operations -/// Upload end-to-end encryption keys. -/*! +/*! \brief Upload end-to-end encryption keys. + * * Publishes end-to-end encryption keys for the device. */ -class UploadKeysJob : public BaseJob -{ +class UploadKeysJob : public BaseJob { public: - /*! Upload end-to-end encryption keys. + /*! \brief Upload end-to-end encryption keys. + * * \param deviceKeys * Identity keys for the device. May be absent if no new * identity keys are required. @@ -57,34 +56,34 @@ private: QScopedPointer d; }; -/// Download device identity keys. -/*! +/*! \brief Download device identity keys. + * * Returns the current devices and identity keys for the given users. */ -class QueryKeysJob : public BaseJob -{ +class QueryKeysJob : public BaseJob { public: // Inner data structures - /// Additional data added to the device key informationby intermediate - /// servers, and not covered by thesignatures. - struct UnsignedDeviceInfo - { + /// Additional data added to the device key information + /// by intermediate servers, and not covered by the + /// signatures. + struct UnsignedDeviceInfo { /// The display name which the user set on the device. QString deviceDisplayName; }; /// Returns the current devices and identity keys for the given users. - struct DeviceInformation : DeviceKeys - { - /// Additional data added to the device key informationby intermediate - /// servers, and not covered by thesignatures. + struct DeviceInformation : DeviceKeys { + /// Additional data added to the device key information + /// by intermediate servers, and not covered by the + /// signatures. Omittable unsignedData; }; // Construction/destruction - /*! Download device identity keys. + /*! \brief Download device identity keys. + * * \param deviceKeys * The keys to be downloaded. A map from user ID, to a list of * device IDs, or to an empty list to indicate all devices for the @@ -114,6 +113,7 @@ public: /// was unknown, no failure is recorded. Instead, the corresponding /// user or device is missing from the ``device_keys`` result. const QHash& failures() const; + /// Information on the queried devices. A map from user ID, to a /// map from device ID to device information. For each device, /// the information returned will be the same as uploaded via @@ -129,14 +129,14 @@ private: QScopedPointer d; }; -/// Claim one-time encryption keys. -/*! +/*! \brief Claim one-time encryption keys. + * * Claims one-time keys for use in pre-key messages. */ -class ClaimKeysJob : public BaseJob -{ +class ClaimKeysJob : public BaseJob { public: - /*! Claim one-time encryption keys. + /*! \brief Claim one-time encryption keys. + * * \param oneTimeKeys * The keys to be claimed. A map from user ID, to a map from * device ID to algorithm name. @@ -160,6 +160,7 @@ public: /// was unknown, no failure is recorded. Instead, the corresponding /// user or device is missing from the ``one_time_keys`` result. const QHash& failures() const; + /// One-time keys for the queried devices. A map from user ID, to a /// map from devices to a map from ``:`` to the key object. const QHash>& oneTimeKeys() const; @@ -172,8 +173,8 @@ private: QScopedPointer d; }; -/// Query users with recent device key updates. -/*! +/*! \brief Query users with recent device key updates. + * * Gets a list of users who have updated their device identity keys since a * previous sync token. * @@ -184,10 +185,10 @@ private: * * added new device identity keys or removed an existing device with * identity keys, between ``from`` and ``to``. */ -class GetKeysChangesJob : public BaseJob -{ +class GetKeysChangesJob : public BaseJob { public: - /*! Query users with recent device key updates. + /*! \brief Query users with recent device key updates. + * * \param from * The desired start point of the list. Should be the ``next_batch`` field * from a response to an earlier call to |/sync|. Users who have not @@ -202,15 +203,13 @@ public: */ explicit GetKeysChangesJob(const QString& from, const QString& to); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetKeysChangesJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& from, const QString& to); - ~GetKeysChangesJob() override; // Result properties @@ -218,6 +217,7 @@ public: /// The Matrix User IDs of all users who updated their device /// identity keys. const QStringList& changed() const; + /// The Matrix User IDs of all users who may have left all /// the end-to-end encrypted rooms they previously shared /// with the user. diff --git a/lib/csapi/kicking.cpp b/lib/csapi/kicking.cpp index ce7fcdad..39125f42 100644 --- a/lib/csapi/kicking.cpp +++ b/lib/csapi/kicking.cpp @@ -12,11 +12,9 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto KickJobName = QStringLiteral("KickJob"); - KickJob::KickJob(const QString& roomId, const QString& userId, const QString& reason) - : BaseJob(HttpVerb::Post, KickJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("KickJob"), basePath % "/rooms/" % roomId % "/kick") { QJsonObject _data; diff --git a/lib/csapi/kicking.h b/lib/csapi/kicking.h index d51edb47..0633a7f6 100644 --- a/lib/csapi/kicking.h +++ b/lib/csapi/kicking.h @@ -6,13 +6,12 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Kick a user from the room. -/*! +/*! \brief Kick a user from the room. + * * Kick a user from the room. * * The caller must have the required power level in order to perform this @@ -23,10 +22,10 @@ namespace Quotient * directly adjust the target member's state by making a request to * ``/rooms//state/m.room.member/``. */ -class KickJob : public BaseJob -{ +class KickJob : public BaseJob { public: - /*! Kick a user from the room. + /*! \brief Kick a user from the room. + * * \param roomId * The room identifier (not alias) from which the user should be kicked. * \param userId diff --git a/lib/csapi/leaving.cpp b/lib/csapi/leaving.cpp index abf04888..2fa1da56 100644 --- a/lib/csapi/leaving.cpp +++ b/lib/csapi/leaving.cpp @@ -18,10 +18,8 @@ QUrl LeaveRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) basePath % "/rooms/" % roomId % "/leave"); } -static const auto LeaveRoomJobName = QStringLiteral("LeaveRoomJob"); - LeaveRoomJob::LeaveRoomJob(const QString& roomId) - : BaseJob(HttpVerb::Post, LeaveRoomJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("LeaveRoomJob"), basePath % "/rooms/" % roomId % "/leave") {} @@ -31,9 +29,7 @@ QUrl ForgetRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) basePath % "/rooms/" % roomId % "/forget"); } -static const auto ForgetRoomJobName = QStringLiteral("ForgetRoomJob"); - ForgetRoomJob::ForgetRoomJob(const QString& roomId) - : BaseJob(HttpVerb::Post, ForgetRoomJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("ForgetRoomJob"), basePath % "/rooms/" % roomId % "/forget") {} diff --git a/lib/csapi/leaving.h b/lib/csapi/leaving.h index 280545b0..45b983f3 100644 --- a/lib/csapi/leaving.h +++ b/lib/csapi/leaving.h @@ -6,13 +6,12 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Stop the requesting user participating in a particular room. -/*! +/*! \brief Stop the requesting user participating in a particular room. + * * This API stops a user participating in a particular room. * * If the user was already in the room, they will no longer be able to see @@ -25,26 +24,25 @@ namespace Quotient * The user will still be allowed to retrieve history from the room which * they were previously allowed to see. */ -class LeaveRoomJob : public BaseJob -{ +class LeaveRoomJob : public BaseJob { public: - /*! Stop the requesting user participating in a particular room. + /*! \brief Stop the requesting user participating in a particular room. + * * \param roomId * The room identifier to leave. */ explicit LeaveRoomJob(const QString& roomId); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * LeaveRoomJob is necessary but the job - * itself isn't. + * This function can be used when a URL for LeaveRoomJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId); }; -/// Stop the requesting user remembering about a particular room. -/*! +/*! \brief Stop the requesting user remembering about a particular room. + * * This API stops a user remembering about a particular room. * * In general, history is a first class citizen in Matrix. After this API @@ -55,20 +53,19 @@ public: * If the user is currently joined to the room, they must leave the room * before calling this API. */ -class ForgetRoomJob : public BaseJob -{ +class ForgetRoomJob : public BaseJob { public: - /*! Stop the requesting user remembering about a particular room. + /*! \brief Stop the requesting user remembering about a particular room. + * * \param roomId * The room identifier to forget. */ explicit ForgetRoomJob(const QString& roomId); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for ForgetRoomJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId); }; diff --git a/lib/csapi/list_joined_rooms.cpp b/lib/csapi/list_joined_rooms.cpp index 1260499a..34eb0d42 100644 --- a/lib/csapi/list_joined_rooms.cpp +++ b/lib/csapi/list_joined_rooms.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class GetJoinedRoomsJob::Private -{ +class GetJoinedRoomsJob::Private { public: QStringList joinedRooms; }; @@ -24,10 +23,9 @@ QUrl GetJoinedRoomsJob::makeRequestUrl(QUrl baseUrl) basePath % "/joined_rooms"); } -static const auto GetJoinedRoomsJobName = QStringLiteral("GetJoinedRoomsJob"); - GetJoinedRoomsJob::GetJoinedRoomsJob() - : BaseJob(HttpVerb::Get, GetJoinedRoomsJobName, basePath % "/joined_rooms") + : BaseJob(HttpVerb::Get, QStringLiteral("GetJoinedRoomsJob"), + basePath % "/joined_rooms") , d(new Private) {} diff --git a/lib/csapi/list_joined_rooms.h b/lib/csapi/list_joined_rooms.h index 5dab9dfc..a170d623 100644 --- a/lib/csapi/list_joined_rooms.h +++ b/lib/csapi/list_joined_rooms.h @@ -6,28 +6,25 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Lists the user's current rooms. -/*! +/*! \brief Lists the user's current rooms. + * * This API returns a list of the user's current rooms. */ -class GetJoinedRoomsJob : public BaseJob -{ +class GetJoinedRoomsJob : public BaseJob { public: + /// Lists the user's current rooms. explicit GetJoinedRoomsJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetJoinedRoomsJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetJoinedRoomsJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetJoinedRoomsJob() override; // Result properties diff --git a/lib/csapi/list_public_rooms.cpp b/lib/csapi/list_public_rooms.cpp index 0e065440..83320ec0 100644 --- a/lib/csapi/list_public_rooms.cpp +++ b/lib/csapi/list_public_rooms.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class GetRoomVisibilityOnDirectoryJob::Private -{ +class GetRoomVisibilityOnDirectoryJob::Private { public: QString visibility; }; @@ -25,12 +24,9 @@ QUrl GetRoomVisibilityOnDirectoryJob::makeRequestUrl(QUrl baseUrl, basePath % "/directory/list/room/" % roomId); } -static const auto GetRoomVisibilityOnDirectoryJobName = - QStringLiteral("GetRoomVisibilityOnDirectoryJob"); - GetRoomVisibilityOnDirectoryJob::GetRoomVisibilityOnDirectoryJob( const QString& roomId) - : BaseJob(HttpVerb::Get, GetRoomVisibilityOnDirectoryJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomVisibilityOnDirectoryJob"), basePath % "/directory/list/room/" % roomId, false) , d(new Private) {} @@ -51,12 +47,9 @@ GetRoomVisibilityOnDirectoryJob::parseJson(const QJsonDocument& data) return Success; } -static const auto SetRoomVisibilityOnDirectoryJobName = - QStringLiteral("SetRoomVisibilityOnDirectoryJob"); - SetRoomVisibilityOnDirectoryJob::SetRoomVisibilityOnDirectoryJob( const QString& roomId, const QString& visibility) - : BaseJob(HttpVerb::Put, SetRoomVisibilityOnDirectoryJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomVisibilityOnDirectoryJob"), basePath % "/directory/list/room/" % roomId) { QJsonObject _data; @@ -64,8 +57,7 @@ SetRoomVisibilityOnDirectoryJob::SetRoomVisibilityOnDirectoryJob( setRequestData(_data); } -class GetPublicRoomsJob::Private -{ +class GetPublicRoomsJob::Private { public: PublicRoomsResponse data; }; @@ -88,11 +80,10 @@ QUrl GetPublicRoomsJob::makeRequestUrl(QUrl baseUrl, Omittable limit, queryToGetPublicRooms(limit, since, server)); } -static const auto GetPublicRoomsJobName = QStringLiteral("GetPublicRoomsJob"); - GetPublicRoomsJob::GetPublicRoomsJob(Omittable limit, const QString& since, const QString& server) - : BaseJob(HttpVerb::Get, GetPublicRoomsJobName, basePath % "/publicRooms", + : BaseJob(HttpVerb::Get, QStringLiteral("GetPublicRoomsJob"), + basePath % "/publicRooms", queryToGetPublicRooms(limit, since, server), {}, false) , d(new Private) {} @@ -104,16 +95,15 @@ const PublicRoomsResponse& GetPublicRoomsJob::data() const { return d->data; } BaseJob::Status GetPublicRoomsJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const QueryPublicRoomsJob::Filter& pod) { addParam(jo, QStringLiteral("generic_search_term"), @@ -123,8 +113,7 @@ struct JsonObjectConverter } // namespace Quotient -class QueryPublicRoomsJob::Private -{ +class QueryPublicRoomsJob::Private { public: PublicRoomsResponse data; }; @@ -136,16 +125,13 @@ BaseJob::Query queryToQueryPublicRooms(const QString& server) return _q; } -static const auto QueryPublicRoomsJobName = - QStringLiteral("QueryPublicRoomsJob"); - QueryPublicRoomsJob::QueryPublicRoomsJob(const QString& server, Omittable limit, const QString& since, const Omittable& filter, Omittable includeAllNetworks, const QString& thirdPartyInstanceId) - : BaseJob(HttpVerb::Post, QueryPublicRoomsJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("QueryPublicRoomsJob"), basePath % "/publicRooms", queryToQueryPublicRooms(server)) , d(new Private) { @@ -167,5 +153,6 @@ const PublicRoomsResponse& QueryPublicRoomsJob::data() const { return d->data; } BaseJob::Status QueryPublicRoomsJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } diff --git a/lib/csapi/list_public_rooms.h b/lib/csapi/list_public_rooms.h index e68030ad..0c9a2620 100644 --- a/lib/csapi/list_public_rooms.h +++ b/lib/csapi/list_public_rooms.h @@ -10,32 +10,29 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Gets the visibility of a room in the directory -/*! +/*! \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 GetRoomVisibilityOnDirectoryJob : public BaseJob -{ +class GetRoomVisibilityOnDirectoryJob : public BaseJob { public: - /*! Gets the visibility of a room in the directory + /*! \brief Gets the visibility of a room in the directory + * * \param roomId * The room ID. */ explicit GetRoomVisibilityOnDirectoryJob(const QString& roomId); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetRoomVisibilityOnDirectoryJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId); - ~GetRoomVisibilityOnDirectoryJob() override; // Result properties @@ -51,8 +48,8 @@ private: QScopedPointer d; }; -/// Sets the visibility of a room in the room directory -/*! +/*! \brief Sets the visibility of a room in the room directory + * * Sets the visibility of a given room in the server's public room * directory. * @@ -60,10 +57,10 @@ private: * here, for instance that room visibility can only be changed by * the room creator or a server administrator. */ -class SetRoomVisibilityOnDirectoryJob : public BaseJob -{ +class SetRoomVisibilityOnDirectoryJob : public BaseJob { public: - /*! Sets the visibility of a room in the room directory + /*! \brief Sets the visibility of a room in the room directory + * * \param roomId * The room ID. * \param visibility @@ -74,17 +71,17 @@ public: const QString& visibility = {}); }; -/// Lists the public rooms on the server. -/*! +/*! \brief Lists the public rooms on the server. + * * Lists the public rooms on the server. * * This API returns paginated responses. The rooms are ordered by the number * of joined members, with the largest rooms first. */ -class GetPublicRoomsJob : public BaseJob -{ +class GetPublicRoomsJob : public BaseJob { public: - /*! Lists the public rooms on the server. + /*! \brief Lists the public rooms on the server. + * * \param limit * Limit the number of results returned. * \param since @@ -100,16 +97,14 @@ public: const QString& since = {}, const QString& server = {}); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetPublicRoomsJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, Omittable limit = none, const QString& since = {}, const QString& server = {}); - ~GetPublicRoomsJob() override; // Result properties @@ -125,29 +120,28 @@ private: QScopedPointer d; }; -/// Lists the public rooms on the server with optional filter. -/*! +/*! \brief Lists the public rooms on the server with optional filter. + * * Lists the public rooms on the server, with optional filter. * * This API returns paginated responses. The rooms are ordered by the number * of joined members, with the largest rooms first. */ -class QueryPublicRoomsJob : public BaseJob -{ +class QueryPublicRoomsJob : public BaseJob { public: // Inner data structures /// Filter to apply to the results. - struct Filter - { - /// A string to search for in the room metadata, e.g. name,topic, - /// canonical alias etc. (Optional). + struct Filter { + /// A string to search for in the room metadata, e.g. name, + /// topic, canonical alias etc. (Optional). QString genericSearchTerm; }; // Construction/destruction - /*! Lists the public rooms on the server with optional filter. + /*! \brief Lists the public rooms on the server with optional filter. + * * \param server * The server to fetch the public room lists from. Defaults to the * local server. diff --git a/lib/csapi/login.cpp b/lib/csapi/login.cpp index 02730ff0..3e98f56b 100644 --- a/lib/csapi/login.cpp +++ b/lib/csapi/login.cpp @@ -13,12 +13,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void fillFrom(const QJsonObject& jo, GetLoginFlowsJob::LoginFlow& result) { @@ -28,8 +26,7 @@ struct JsonObjectConverter } // namespace Quotient -class GetLoginFlowsJob::Private -{ +class GetLoginFlowsJob::Private { public: QVector flows; }; @@ -39,10 +36,9 @@ QUrl GetLoginFlowsJob::makeRequestUrl(QUrl baseUrl) return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/login"); } -static const auto GetLoginFlowsJobName = QStringLiteral("GetLoginFlowsJob"); - GetLoginFlowsJob::GetLoginFlowsJob() - : BaseJob(HttpVerb::Get, GetLoginFlowsJobName, basePath % "/login", false) + : BaseJob(HttpVerb::Get, QStringLiteral("GetLoginFlowsJob"), + basePath % "/login", false) , d(new Private) {} @@ -61,8 +57,7 @@ BaseJob::Status GetLoginFlowsJob::parseJson(const QJsonDocument& data) return Success; } -class LoginJob::Private -{ +class LoginJob::Private { public: QString userId; QString accessToken; @@ -71,15 +66,14 @@ public: Omittable wellKnown; }; -static const auto LoginJobName = QStringLiteral("LoginJob"); - LoginJob::LoginJob(const QString& type, const Omittable& identifier, const QString& password, const QString& token, const QString& deviceId, const QString& initialDeviceDisplayName, const QString& user, const QString& medium, const QString& address) - : BaseJob(HttpVerb::Post, LoginJobName, basePath % "/login", false) + : BaseJob(HttpVerb::Post, QStringLiteral("LoginJob"), basePath % "/login", + false) , d(new Private) { QJsonObject _data; diff --git a/lib/csapi/login.h b/lib/csapi/login.h index dc944782..adecca6f 100644 --- a/lib/csapi/login.h +++ b/lib/csapi/login.h @@ -13,42 +13,39 @@ #include -namespace Quotient -{ +namespace Quotient { // Operations -/// Get the supported login types to authenticate users -/*! +/*! \brief Get the supported login types to authenticate users + * * 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 GetLoginFlowsJob : public BaseJob -{ +class GetLoginFlowsJob : public BaseJob { public: // Inner data structures /// Gets the homeserver's supported login types to authenticate users. - /// Clientsshould pick one of these and supply it as the ``type`` when + /// Clients should pick one of these and supply it as the ``type`` when /// logging in. - struct LoginFlow - { - /// The login type. This is supplied as the ``type`` whenlogging in. + struct LoginFlow { + /// The login type. This is supplied as the ``type`` when + /// logging in. QString type; }; // Construction/destruction + /// Get the supported login types to authenticate users explicit GetLoginFlowsJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetLoginFlowsJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetLoginFlowsJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetLoginFlowsJob() override; // Result properties @@ -64,8 +61,8 @@ private: QScopedPointer d; }; -/// Authenticates the user. -/*! +/*! \brief Authenticates the user. + * * Authenticates the user, and issues an access token they can * use to authorize themself in subsequent requests. * @@ -77,10 +74,10 @@ private: * invalidate any access token previously associated with that device. See * `Relationship between access tokens and devices`_. */ -class LoginJob : public BaseJob -{ +class LoginJob : public BaseJob { public: - /*! Authenticates the user. + /*! \brief Authenticates the user. + * * \param type * The login type being used. * \param identifier @@ -116,9 +113,11 @@ public: /// The fully-qualified Matrix ID that has been registered. const QString& userId() const; + /// An access token for the account. /// This access token can then be used to authorize other requests. const QString& accessToken() const; + /// The server_name of the homeserver on which the account has /// been registered. /// @@ -126,9 +125,11 @@ public: /// ``user_id`` (by splitting at the first colon) if they require /// it. Note also that ``homeserver`` is not spelt this way. const QString& homeServer() const; + /// ID of the logged-in device. Will be the same as the /// corresponding parameter in the request, if one was specified. const QString& deviceId() const; + /// Optional client configuration provided by the server. If present, /// clients SHOULD use the provided object to reconfigure themselves, /// optionally validating the URLs within. This object takes the same diff --git a/lib/csapi/logout.cpp b/lib/csapi/logout.cpp index 4b391967..36281b79 100644 --- a/lib/csapi/logout.cpp +++ b/lib/csapi/logout.cpp @@ -17,10 +17,8 @@ QUrl LogoutJob::makeRequestUrl(QUrl baseUrl) return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/logout"); } -static const auto LogoutJobName = QStringLiteral("LogoutJob"); - LogoutJob::LogoutJob() - : BaseJob(HttpVerb::Post, LogoutJobName, basePath % "/logout") + : BaseJob(HttpVerb::Post, QStringLiteral("LogoutJob"), basePath % "/logout") {} QUrl LogoutAllJob::makeRequestUrl(QUrl baseUrl) @@ -28,8 +26,7 @@ QUrl LogoutAllJob::makeRequestUrl(QUrl baseUrl) return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/logout/all"); } -static const auto LogoutAllJobName = QStringLiteral("LogoutAllJob"); - LogoutAllJob::LogoutAllJob() - : BaseJob(HttpVerb::Post, LogoutAllJobName, basePath % "/logout/all") + : BaseJob(HttpVerb::Post, QStringLiteral("LogoutAllJob"), + basePath % "/logout/all") {} diff --git a/lib/csapi/logout.h b/lib/csapi/logout.h index 34d5a441..2a705620 100644 --- a/lib/csapi/logout.h +++ b/lib/csapi/logout.h @@ -6,32 +6,30 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Invalidates a user access token -/*! +/*! \brief Invalidates a user access token + * * Invalidates an existing access token, so that it can no longer be used for * authorization. */ -class LogoutJob : public BaseJob -{ +class LogoutJob : public BaseJob { public: + /// Invalidates a user access token explicit LogoutJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * LogoutJob is necessary but the job - * itself isn't. + * This function can be used when a URL for LogoutJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); }; -/// Invalidates all access tokens for a user -/*! +/*! \brief Invalidates all access tokens for a user + * * Invalidates all access tokens for a user, so that they can no longer be used * for authorization. This includes the access token that made this request. * @@ -41,16 +39,15 @@ public: * 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 LogoutAllJob : public BaseJob -{ +class LogoutAllJob : public BaseJob { public: + /// Invalidates all access tokens for a user explicit LogoutAllJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * LogoutAllJob is necessary but the job - * itself isn't. + * This function can be used when a URL for LogoutAllJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); }; diff --git a/lib/csapi/message_pagination.cpp b/lib/csapi/message_pagination.cpp index b612ee91..ba982748 100644 --- a/lib/csapi/message_pagination.cpp +++ b/lib/csapi/message_pagination.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class GetRoomEventsJob::Private -{ +class GetRoomEventsJob::Private { public: QString begin; QString end; @@ -38,17 +37,16 @@ QUrl GetRoomEventsJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& to, Omittable limit, const QString& filter) { - return BaseJob::makeRequestUrl( - std::move(baseUrl), basePath % "/rooms/" % roomId % "/messages", - queryToGetRoomEvents(from, to, dir, limit, filter)); + return BaseJob::makeRequestUrl(std::move(baseUrl), + basePath % "/rooms/" % roomId % "/messages", + queryToGetRoomEvents(from, to, dir, limit, + filter)); } -static const auto GetRoomEventsJobName = QStringLiteral("GetRoomEventsJob"); - GetRoomEventsJob::GetRoomEventsJob(const QString& roomId, const QString& from, const QString& dir, const QString& to, Omittable limit, const QString& filter) - : BaseJob(HttpVerb::Get, GetRoomEventsJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomEventsJob"), basePath % "/rooms/" % roomId % "/messages", queryToGetRoomEvents(from, to, dir, limit, filter)) , d(new Private) diff --git a/lib/csapi/message_pagination.h b/lib/csapi/message_pagination.h index 271e1dd9..b0d95bad 100644 --- a/lib/csapi/message_pagination.h +++ b/lib/csapi/message_pagination.h @@ -9,20 +9,19 @@ #include "events/eventloader.h" #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Get a list of events for this room -/*! +/*! \brief Get a list of events for this room + * * This API returns a list of message and state events for a room. It uses * pagination query parameters to paginate history in the room. */ -class GetRoomEventsJob : public BaseJob -{ +class GetRoomEventsJob : public BaseJob { public: - /*! Get a list of events for this room + /*! \brief Get a list of events for this room + * * \param roomId * The room to get events from. * \param from @@ -47,18 +46,16 @@ public: Omittable limit = none, const QString& filter = {}); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetRoomEventsJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& from, const QString& dir, const QString& to = {}, Omittable limit = none, const QString& filter = {}); - ~GetRoomEventsJob() override; // Result properties @@ -66,9 +63,11 @@ public: /// The token the pagination starts from. If ``dir=b`` this will be /// the token supplied in ``from``. const QString& begin() const; + /// The token the pagination ends at. If ``dir=b`` this token should /// be used again to request even earlier events. const QString& end() const; + /// A list of room events. RoomEvents&& chunk(); diff --git a/lib/csapi/notifications.cpp b/lib/csapi/notifications.cpp index da568a0f..d00d5425 100644 --- a/lib/csapi/notifications.cpp +++ b/lib/csapi/notifications.cpp @@ -13,12 +13,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void fillFrom(const QJsonObject& jo, GetNotificationsJob::Notification& result) { @@ -33,8 +31,7 @@ struct JsonObjectConverter } // namespace Quotient -class GetNotificationsJob::Private -{ +class GetNotificationsJob::Private { public: QString nextToken; std::vector notifications; @@ -59,13 +56,10 @@ QUrl GetNotificationsJob::makeRequestUrl(QUrl baseUrl, const QString& from, queryToGetNotifications(from, limit, only)); } -static const auto GetNotificationsJobName = - QStringLiteral("GetNotificationsJob"); - GetNotificationsJob::GetNotificationsJob(const QString& from, Omittable limit, const QString& only) - : BaseJob(HttpVerb::Get, GetNotificationsJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetNotificationsJob"), basePath % "/notifications", queryToGetNotifications(from, limit, only)) , d(new Private) diff --git a/lib/csapi/notifications.h b/lib/csapi/notifications.h index eeec5d4e..0e86e424 100644 --- a/lib/csapi/notifications.h +++ b/lib/csapi/notifications.h @@ -13,45 +13,43 @@ #include #include -namespace Quotient -{ +namespace Quotient { // Operations -/// Gets a list of events that the user has been notified about -/*! +/*! \brief Gets a list of events that the user has been notified about + * * This API is used to paginate through the list of events that the * user has been, or would have been notified about. */ -class GetNotificationsJob : public BaseJob -{ +class GetNotificationsJob : public BaseJob { public: // Inner data structures - /// This API is used to paginate through the list of events that theuser has - /// been, or would have been notified about. - struct Notification - { - /// The action(s) to perform when the conditions for this rule are - /// met.See `Push Rules: API`_. + /// This API is used to paginate through the list of events that the + /// user has been, or would have been notified about. + struct Notification { + /// The action(s) to perform when the conditions for this rule are met. + /// See `Push Rules: API`_. QVector actions; /// The Event object for the event that triggered the notification. EventPtr event; /// The profile tag of the rule that matched this event. QString profileTag; - /// Indicates whether the user has sent a read receipt indicatingthat - /// they have read this message. + /// Indicates whether the user has sent a read receipt indicating + /// that they have read this message. bool read; /// The ID of the room in which the event was posted. QString roomId; - /// The unix timestamp at which the event notification was sent,in - /// milliseconds. + /// The unix timestamp at which the event notification was sent, + /// in milliseconds. int ts; }; // Construction/destruction - /*! Gets a list of events that the user has been notified about + /*! \brief Gets a list of events that the user has been notified about + * * \param from * Pagination token given to retrieve the next set of events. * \param limit @@ -65,16 +63,14 @@ public: Omittable limit = none, const QString& only = {}); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetNotificationsJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& from = {}, Omittable limit = none, const QString& only = {}); - ~GetNotificationsJob() override; // Result properties @@ -83,6 +79,7 @@ public: /// ``/notifications`` request in order to request more /// events. If this is absent, there are no more results. const QString& nextToken() const; + /// The list of events that triggered notifications. std::vector&& notifications(); diff --git a/lib/csapi/openid.cpp b/lib/csapi/openid.cpp index 8c00df97..9def2377 100644 --- a/lib/csapi/openid.cpp +++ b/lib/csapi/openid.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class RequestOpenIdTokenJob::Private -{ +class RequestOpenIdTokenJob::Private { public: QString accessToken; QString tokenType; @@ -21,12 +20,9 @@ public: int expiresIn; }; -static const auto RequestOpenIdTokenJobName = - QStringLiteral("RequestOpenIdTokenJob"); - RequestOpenIdTokenJob::RequestOpenIdTokenJob(const QString& userId, const QJsonObject& body) - : BaseJob(HttpVerb::Post, RequestOpenIdTokenJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("RequestOpenIdTokenJob"), basePath % "/user/" % userId % "/openid/request_token") , d(new Private) { diff --git a/lib/csapi/openid.h b/lib/csapi/openid.h index b2f003e5..bda4ce74 100644 --- a/lib/csapi/openid.h +++ b/lib/csapi/openid.h @@ -10,13 +10,12 @@ #include -namespace Quotient -{ +namespace Quotient { // Operations -/// Get an OpenID token object to verify the requester's identity. -/*! +/*! \brief Get an OpenID token object to verify the requester's identity. + * * Gets an OpenID token object that the requester may supply to another * service to verify their identity in Matrix. The generated token is only * valid for exchanging for user information from the federation API for @@ -26,10 +25,10 @@ namespace Quotient * be used to request another OpenID access token or call ``/sync``, for * example. */ -class RequestOpenIdTokenJob : public BaseJob -{ +class RequestOpenIdTokenJob : public BaseJob { public: - /*! Get an OpenID token object to verify the requester's identity. + /*! \brief Get an OpenID token object to verify the requester's identity. + * * \param userId * The user to request and OpenID token for. Should be the user who * is authenticated for the request. @@ -47,11 +46,14 @@ public: /// the person who generated the token. This is given to the federation /// API ``GET /openid/userinfo``. const QString& accessToken() const; + /// The string ``Bearer``. const QString& tokenType() const; + /// The homeserver domain the consumer should use when attempting to /// verify the user's identity. const QString& matrixServerName() const; + /// The number of seconds before this token expires and a new one must /// be generated. int expiresIn() const; diff --git a/lib/csapi/peeking_events.cpp b/lib/csapi/peeking_events.cpp index bc29b682..4d886812 100644 --- a/lib/csapi/peeking_events.cpp +++ b/lib/csapi/peeking_events.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class PeekEventsJob::Private -{ +class PeekEventsJob::Private { public: QString begin; QString end; @@ -37,12 +36,10 @@ QUrl PeekEventsJob::makeRequestUrl(QUrl baseUrl, const QString& from, queryToPeekEvents(from, timeout, roomId)); } -static const auto PeekEventsJobName = QStringLiteral("PeekEventsJob"); - PeekEventsJob::PeekEventsJob(const QString& from, Omittable timeout, const QString& roomId) - : BaseJob(HttpVerb::Get, PeekEventsJobName, basePath % "/events", - queryToPeekEvents(from, timeout, roomId)) + : BaseJob(HttpVerb::Get, QStringLiteral("PeekEventsJob"), + basePath % "/events", queryToPeekEvents(from, timeout, roomId)) , d(new Private) {} diff --git a/lib/csapi/peeking_events.h b/lib/csapi/peeking_events.h index c5cc07f6..12a66a02 100644 --- a/lib/csapi/peeking_events.h +++ b/lib/csapi/peeking_events.h @@ -9,13 +9,12 @@ #include "events/eventloader.h" #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Listen on the event stream. -/*! +/*! \brief Listen on the event stream. + * * This will listen for new events related to a particular room and return * them to the caller. This will block until an event is received, or until * the ``timeout`` is reached. @@ -27,10 +26,10 @@ namespace Quotient * API will also be deprecated at some point, but its replacement is not * yet known. */ -class PeekEventsJob : public BaseJob -{ +class PeekEventsJob : public BaseJob { public: - /*! Listen on the event stream. + /*! \brief Listen on the event stream. + * * \param from * The token to stream from. This token is either from a previous * request to this API or from the initial sync API. @@ -43,16 +42,14 @@ public: Omittable timeout = none, const QString& roomId = {}); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for PeekEventsJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& from = {}, Omittable timeout = none, const QString& roomId = {}); - ~PeekEventsJob() override; // Result properties @@ -60,9 +57,11 @@ public: /// A token which correlates to the first value in ``chunk``. This /// is usually the same token supplied to ``from=``. const QString& begin() const; + /// A token which correlates to the last value in ``chunk``. This /// token should be used in the next request to ``/events``. const QString& end() const; + /// An array of events. RoomEvents&& chunk(); diff --git a/lib/csapi/presence.cpp b/lib/csapi/presence.cpp index 0f019026..932ccc6e 100644 --- a/lib/csapi/presence.cpp +++ b/lib/csapi/presence.cpp @@ -12,11 +12,9 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto SetPresenceJobName = QStringLiteral("SetPresenceJob"); - SetPresenceJob::SetPresenceJob(const QString& userId, const QString& presence, const QString& statusMsg) - : BaseJob(HttpVerb::Put, SetPresenceJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetPresenceJob"), basePath % "/presence/" % userId % "/status") { QJsonObject _data; @@ -25,8 +23,7 @@ SetPresenceJob::SetPresenceJob(const QString& userId, const QString& presence, setRequestData(_data); } -class GetPresenceJob::Private -{ +class GetPresenceJob::Private { public: QString presence; Omittable lastActiveAgo; @@ -40,10 +37,8 @@ QUrl GetPresenceJob::makeRequestUrl(QUrl baseUrl, const QString& userId) basePath % "/presence/" % userId % "/status"); } -static const auto GetPresenceJobName = QStringLiteral("GetPresenceJob"); - GetPresenceJob::GetPresenceJob(const QString& userId) - : BaseJob(HttpVerb::Get, GetPresenceJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetPresenceJob"), basePath % "/presence/" % userId % "/status") , d(new Private) {} diff --git a/lib/csapi/presence.h b/lib/csapi/presence.h index c5ecb987..21e57603 100644 --- a/lib/csapi/presence.h +++ b/lib/csapi/presence.h @@ -8,22 +8,21 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Update this user's presence state. -/*! +/*! \brief Update this user's presence state. + * * This API sets the given user's presence state. When setting the status, * 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 SetPresenceJob : public BaseJob -{ +class SetPresenceJob : public BaseJob { public: - /*! Update this user's presence state. + /*! \brief Update this user's presence state. + * * \param userId * The user whose presence state to update. * \param presence @@ -35,38 +34,39 @@ public: const QString& statusMsg = {}); }; -/// Get this user's presence state. -/*! +/*! \brief Get this user's presence state. + * * Get the given user's presence state. */ -class GetPresenceJob : public BaseJob -{ +class GetPresenceJob : public BaseJob { public: - /*! Get this user's presence state. + /*! \brief Get this user's presence state. + * * \param userId * The user whose presence state to get. */ explicit GetPresenceJob(const QString& userId); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetPresenceJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId); - ~GetPresenceJob() override; // Result properties /// This user's presence. const QString& presence() const; + /// The length of time in milliseconds since an action was performed /// by this user. Omittable lastActiveAgo() const; + /// The state message for this user if one was set. const QString& statusMsg() const; + /// Whether the user is currently active Omittable currentlyActive() const; diff --git a/lib/csapi/profile.cpp b/lib/csapi/profile.cpp index 27168f77..d86e3bdc 100644 --- a/lib/csapi/profile.cpp +++ b/lib/csapi/profile.cpp @@ -12,11 +12,9 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto SetDisplayNameJobName = QStringLiteral("SetDisplayNameJob"); - SetDisplayNameJob::SetDisplayNameJob(const QString& userId, const QString& displayname) - : BaseJob(HttpVerb::Put, SetDisplayNameJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetDisplayNameJob"), basePath % "/profile/" % userId % "/displayname") { QJsonObject _data; @@ -24,22 +22,20 @@ SetDisplayNameJob::SetDisplayNameJob(const QString& userId, setRequestData(_data); } -class GetDisplayNameJob::Private -{ +class GetDisplayNameJob::Private { public: QString displayname; }; QUrl GetDisplayNameJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { - return BaseJob::makeRequestUrl( - std::move(baseUrl), basePath % "/profile/" % userId % "/displayname"); + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/profile/" + % userId + % "/displayname"); } -static const auto GetDisplayNameJobName = QStringLiteral("GetDisplayNameJob"); - GetDisplayNameJob::GetDisplayNameJob(const QString& userId) - : BaseJob(HttpVerb::Get, GetDisplayNameJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetDisplayNameJob"), basePath % "/profile/" % userId % "/displayname", false) , d(new Private) {} @@ -56,10 +52,8 @@ BaseJob::Status GetDisplayNameJob::parseJson(const QJsonDocument& data) return Success; } -static const auto SetAvatarUrlJobName = QStringLiteral("SetAvatarUrlJob"); - SetAvatarUrlJob::SetAvatarUrlJob(const QString& userId, const QString& avatarUrl) - : BaseJob(HttpVerb::Put, SetAvatarUrlJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetAvatarUrlJob"), basePath % "/profile/" % userId % "/avatar_url") { QJsonObject _data; @@ -67,22 +61,20 @@ SetAvatarUrlJob::SetAvatarUrlJob(const QString& userId, const QString& avatarUrl setRequestData(_data); } -class GetAvatarUrlJob::Private -{ +class GetAvatarUrlJob::Private { public: QString avatarUrl; }; QUrl GetAvatarUrlJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { - return BaseJob::makeRequestUrl( - std::move(baseUrl), basePath % "/profile/" % userId % "/avatar_url"); + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/profile/" + % userId + % "/avatar_url"); } -static const auto GetAvatarUrlJobName = QStringLiteral("GetAvatarUrlJob"); - GetAvatarUrlJob::GetAvatarUrlJob(const QString& userId) - : BaseJob(HttpVerb::Get, GetAvatarUrlJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetAvatarUrlJob"), basePath % "/profile/" % userId % "/avatar_url", false) , d(new Private) {} @@ -99,8 +91,7 @@ BaseJob::Status GetAvatarUrlJob::parseJson(const QJsonDocument& data) return Success; } -class GetUserProfileJob::Private -{ +class GetUserProfileJob::Private { public: QString avatarUrl; QString displayname; @@ -112,10 +103,8 @@ QUrl GetUserProfileJob::makeRequestUrl(QUrl baseUrl, const QString& userId) basePath % "/profile/" % userId); } -static const auto GetUserProfileJobName = QStringLiteral("GetUserProfileJob"); - GetUserProfileJob::GetUserProfileJob(const QString& userId) - : BaseJob(HttpVerb::Get, GetUserProfileJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetUserProfileJob"), basePath % "/profile/" % userId, false) , d(new Private) {} diff --git a/lib/csapi/profile.h b/lib/csapi/profile.h index 54dc53aa..8279fe20 100644 --- a/lib/csapi/profile.h +++ b/lib/csapi/profile.h @@ -6,20 +6,19 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Set the user's display name. -/*! +/*! \brief Set the user's display name. + * * 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 SetDisplayNameJob : public BaseJob -{ +class SetDisplayNameJob : public BaseJob { public: - /*! Set the user's display name. + /*! \brief Set the user's display name. + * * \param userId * The user whose display name to set. * \param displayname @@ -29,29 +28,27 @@ public: const QString& displayname = {}); }; -/// Get the user's display name. -/*! +/*! \brief Get the user's display name. + * * 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 GetDisplayNameJob : public BaseJob -{ +class GetDisplayNameJob : public BaseJob { public: - /*! Get the user's display name. + /*! \brief Get the user's display name. + * * \param userId * The user whose display name to get. */ explicit GetDisplayNameJob(const QString& userId); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetDisplayNameJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId); - ~GetDisplayNameJob() override; // Result properties @@ -67,15 +64,15 @@ private: QScopedPointer d; }; -/// Set the user's avatar URL. -/*! +/*! \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 SetAvatarUrlJob : public BaseJob -{ +class SetAvatarUrlJob : public BaseJob { public: - /*! Set the user's avatar URL. + /*! \brief Set the user's avatar URL. + * * \param userId * The user whose avatar URL to set. * \param avatarUrl @@ -85,29 +82,27 @@ public: const QString& avatarUrl = {}); }; -/// Get the user's avatar URL. -/*! +/*! \brief Get the user's avatar URL. + * * 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 GetAvatarUrlJob : public BaseJob -{ +class GetAvatarUrlJob : public BaseJob { public: - /*! Get the user's avatar URL. + /*! \brief Get the user's avatar URL. + * * \param userId * The user whose avatar URL to get. */ explicit GetAvatarUrlJob(const QString& userId); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetAvatarUrlJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId); - ~GetAvatarUrlJob() override; // Result properties @@ -123,36 +118,35 @@ private: QScopedPointer d; }; -/// Get this user's profile information. -/*! +/*! \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. This API may return keys which are not * limited to ``displayname`` or ``avatar_url``. */ -class GetUserProfileJob : public BaseJob -{ +class GetUserProfileJob : public BaseJob { public: - /*! Get this user's profile information. + /*! \brief Get this user's profile information. + * * \param userId * The user whose profile information to get. */ explicit GetUserProfileJob(const QString& userId); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetUserProfileJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId); - ~GetUserProfileJob() override; // Result properties /// The user's avatar URL if they have set one, otherwise not present. const QString& avatarUrl() const; + /// The user's display name if they have set one, otherwise not present. const QString& displayname() const; diff --git a/lib/csapi/pusher.cpp b/lib/csapi/pusher.cpp index 90877a95..ad51b901 100644 --- a/lib/csapi/pusher.cpp +++ b/lib/csapi/pusher.cpp @@ -13,12 +13,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void fillFrom(const QJsonObject& jo, GetPushersJob::PusherData& result) { @@ -28,8 +26,7 @@ struct JsonObjectConverter }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void fillFrom(const QJsonObject& jo, GetPushersJob::Pusher& result) { fromJson(jo.value("pushkey"_ls), result.pushkey); @@ -45,8 +42,7 @@ struct JsonObjectConverter } // namespace Quotient -class GetPushersJob::Private -{ +class GetPushersJob::Private { public: QVector pushers; }; @@ -56,10 +52,9 @@ QUrl GetPushersJob::makeRequestUrl(QUrl baseUrl) return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/pushers"); } -static const auto GetPushersJobName = QStringLiteral("GetPushersJob"); - GetPushersJob::GetPushersJob() - : BaseJob(HttpVerb::Get, GetPushersJobName, basePath % "/pushers") + : BaseJob(HttpVerb::Get, QStringLiteral("GetPushersJob"), + basePath % "/pushers") , d(new Private) {} @@ -79,12 +74,10 @@ BaseJob::Status GetPushersJob::parseJson(const QJsonDocument& data) } // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const PostPusherJob::PusherData& pod) { addParam(jo, QStringLiteral("url"), pod.url); @@ -94,14 +87,13 @@ struct JsonObjectConverter } // namespace Quotient -static const auto PostPusherJobName = QStringLiteral("PostPusherJob"); - PostPusherJob::PostPusherJob(const QString& pushkey, const QString& kind, const QString& appId, const QString& appDisplayName, const QString& deviceDisplayName, const QString& lang, const PusherData& data, const QString& profileTag, Omittable append) - : BaseJob(HttpVerb::Post, PostPusherJobName, basePath % "/pushers/set") + : BaseJob(HttpVerb::Post, QStringLiteral("PostPusherJob"), + basePath % "/pushers/set") { QJsonObject _data; addParam<>(_data, QStringLiteral("pushkey"), pushkey); diff --git a/lib/csapi/pusher.h b/lib/csapi/pusher.h index 65f8aa15..d60a2b56 100644 --- a/lib/csapi/pusher.h +++ b/lib/csapi/pusher.h @@ -10,69 +10,69 @@ #include -namespace Quotient -{ +namespace Quotient { // Operations -/// Gets the current pushers for the authenticated user -/*! +/*! \brief Gets the current pushers for the authenticated user + * * Gets all currently active pushers for the authenticated user. */ -class GetPushersJob : public BaseJob -{ +class GetPushersJob : public BaseJob { public: // Inner data structures - /// A dictionary of information for the pusher implementationitself. - struct PusherData - { - /// Required if ``kind`` is ``http``. The URL to use to - /// sendnotifications to. + /// A dictionary of information for the pusher implementation + /// itself. + struct PusherData { + /// Required if ``kind`` is ``http``. The URL to use to send + /// notifications to. QString url; - /// The format to use when sending notifications to the PushGateway. + /// The format to use when sending notifications to the Push + /// Gateway. QString format; }; /// Gets all currently active pushers for the authenticated user. - struct Pusher - { - /// This is a unique identifier for this pusher. See ``/set`` formore - /// detail.Max length, 512 bytes. + struct Pusher { + /// This is a unique identifier for this pusher. See ``/set`` for + /// more detail. + /// Max length, 512 bytes. QString pushkey; - /// The kind of pusher. ``"http"`` is a pusher thatsends HTTP pokes. + /// The kind of pusher. ``"http"`` is a pusher that + /// sends HTTP pokes. QString kind; - /// This is a reverse-DNS style identifier for the application.Max - /// length, 64 chars. + /// This is a reverse-DNS style identifier for the application. + /// Max length, 64 chars. QString appId; - /// A string that will allow the user to identify what applicationowns - /// this pusher. + /// A string that will allow the user to identify what application + /// owns this pusher. QString appDisplayName; - /// A string that will allow the user to identify what device ownsthis - /// pusher. + /// A string that will allow the user to identify what device owns + /// this pusher. QString deviceDisplayName; - /// This string determines which set of device specific rules thispusher - /// executes. + /// This string determines which set of device specific rules this + /// pusher executes. QString profileTag; - /// The preferred language for receiving notifications (e.g. 'en'or - /// 'en-US') + /// The preferred language for receiving notifications (e.g. 'en' + /// or 'en-US') QString lang; - /// A dictionary of information for the pusher implementationitself. + /// A dictionary of information for the pusher implementation + /// itself. PusherData data; }; // Construction/destruction + /// Gets the current pushers for the authenticated user explicit GetPushersJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetPushersJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetPushersJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetPushersJob() override; // Result properties @@ -88,35 +88,36 @@ private: QScopedPointer d; }; -/// Modify a pusher for this user on the homeserver. -/*! +/*! \brief Modify a pusher for this user on the homeserver. + * * This endpoint allows the creation, modification and deletion of `pushers`_ * for this user ID. The behaviour of this endpoint varies depending on the * values in the JSON body. */ -class PostPusherJob : public BaseJob -{ +class PostPusherJob : public BaseJob { public: // Inner data structures - /// A dictionary of information for the pusher implementationitself. If - /// ``kind`` is ``http``, this should contain ``url``which is the URL to use - /// to send notifications to. - struct PusherData - { - /// Required if ``kind`` is ``http``. The URL to use to sendnotifications - /// to. MUST be an HTTPS URL with a path of ``/_matrix/push/v1/notify``. + /// 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. + struct 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``. QString url; - /// The format to send notifications in to Push Gateways if the``kind`` - /// is ``http``. The details about what fields thehomeserver should send - /// to the push gateway are defined in the`Push Gateway Specification`_. - /// Currently the only formatavailable is 'event_id_only'. + /// The format to send notifications in to Push Gateways if the + /// ``kind`` is ``http``. The details about what fields the + /// homeserver should send to the push gateway are defined in the + /// `Push Gateway Specification`_. Currently the only format + /// available is 'event_id_only'. QString format; }; // Construction/destruction - /*! Modify a pusher for this user on the homeserver. + /*! \brief Modify a pusher for this user on the homeserver. + * * \param pushkey * This is a unique identifier for this pusher. The value you * should use for this is the routing or destination address diff --git a/lib/csapi/pushrules.cpp b/lib/csapi/pushrules.cpp index eae5445f..cd0fb02d 100644 --- a/lib/csapi/pushrules.cpp +++ b/lib/csapi/pushrules.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class GetPushRulesJob::Private -{ +class GetPushRulesJob::Private { public: PushRuleset global; }; @@ -23,10 +22,9 @@ QUrl GetPushRulesJob::makeRequestUrl(QUrl baseUrl) return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/pushrules"); } -static const auto GetPushRulesJobName = QStringLiteral("GetPushRulesJob"); - GetPushRulesJob::GetPushRulesJob() - : BaseJob(HttpVerb::Get, GetPushRulesJobName, basePath % "/pushrules") + : BaseJob(HttpVerb::Get, QStringLiteral("GetPushRulesJob"), + basePath % "/pushrules") , d(new Private) {} @@ -45,8 +43,7 @@ BaseJob::Status GetPushRulesJob::parseJson(const QJsonDocument& data) return Success; } -class GetPushRuleJob::Private -{ +class GetPushRuleJob::Private { public: PushRule data; }; @@ -59,11 +56,9 @@ QUrl GetPushRuleJob::makeRequestUrl(QUrl baseUrl, const QString& scope, % "/" % ruleId); } -static const auto GetPushRuleJobName = QStringLiteral("GetPushRuleJob"); - GetPushRuleJob::GetPushRuleJob(const QString& scope, const QString& kind, const QString& ruleId) - : BaseJob(HttpVerb::Get, GetPushRuleJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetPushRuleJob"), basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId) , d(new Private) {} @@ -75,6 +70,7 @@ const PushRule& GetPushRuleJob::data() const { return d->data; } BaseJob::Status GetPushRuleJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } @@ -87,11 +83,9 @@ QUrl DeletePushRuleJob::makeRequestUrl(QUrl baseUrl, const QString& scope, % "/" % ruleId); } -static const auto DeletePushRuleJobName = QStringLiteral("DeletePushRuleJob"); - DeletePushRuleJob::DeletePushRuleJob(const QString& scope, const QString& kind, const QString& ruleId) - : BaseJob(HttpVerb::Delete, DeletePushRuleJobName, + : BaseJob(HttpVerb::Delete, QStringLiteral("DeletePushRuleJob"), basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId) {} @@ -103,14 +97,12 @@ BaseJob::Query queryToSetPushRule(const QString& before, const QString& after) return _q; } -static const auto SetPushRuleJobName = QStringLiteral("SetPushRuleJob"); - SetPushRuleJob::SetPushRuleJob(const QString& scope, const QString& kind, const QString& ruleId, const QStringList& actions, const QString& before, const QString& after, const QVector& conditions, const QString& pattern) - : BaseJob(HttpVerb::Put, SetPushRuleJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetPushRuleJob"), basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId, queryToSetPushRule(before, after)) { @@ -121,8 +113,7 @@ SetPushRuleJob::SetPushRuleJob(const QString& scope, const QString& kind, setRequestData(_data); } -class IsPushRuleEnabledJob::Private -{ +class IsPushRuleEnabledJob::Private { public: bool enabled; }; @@ -136,13 +127,10 @@ QUrl IsPushRuleEnabledJob::makeRequestUrl(QUrl baseUrl, const QString& scope, % "/" % ruleId % "/enabled"); } -static const auto IsPushRuleEnabledJobName = - QStringLiteral("IsPushRuleEnabledJob"); - IsPushRuleEnabledJob::IsPushRuleEnabledJob(const QString& scope, const QString& kind, const QString& ruleId) - : BaseJob(HttpVerb::Get, IsPushRuleEnabledJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("IsPushRuleEnabledJob"), basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId % "/enabled") , d(new Private) @@ -163,13 +151,10 @@ BaseJob::Status IsPushRuleEnabledJob::parseJson(const QJsonDocument& data) return Success; } -static const auto SetPushRuleEnabledJobName = - QStringLiteral("SetPushRuleEnabledJob"); - SetPushRuleEnabledJob::SetPushRuleEnabledJob(const QString& scope, const QString& kind, const QString& ruleId, bool enabled) - : BaseJob(HttpVerb::Put, SetPushRuleEnabledJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetPushRuleEnabledJob"), basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId % "/enabled") { @@ -178,8 +163,7 @@ SetPushRuleEnabledJob::SetPushRuleEnabledJob(const QString& scope, setRequestData(_data); } -class GetPushRuleActionsJob::Private -{ +class GetPushRuleActionsJob::Private { public: QStringList actions; }; @@ -193,13 +177,10 @@ QUrl GetPushRuleActionsJob::makeRequestUrl(QUrl baseUrl, const QString& scope, % "/" % ruleId % "/actions"); } -static const auto GetPushRuleActionsJobName = - QStringLiteral("GetPushRuleActionsJob"); - GetPushRuleActionsJob::GetPushRuleActionsJob(const QString& scope, const QString& kind, const QString& ruleId) - : BaseJob(HttpVerb::Get, GetPushRuleActionsJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetPushRuleActionsJob"), basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId % "/actions") , d(new Private) @@ -220,14 +201,11 @@ BaseJob::Status GetPushRuleActionsJob::parseJson(const QJsonDocument& data) return Success; } -static const auto SetPushRuleActionsJobName = - QStringLiteral("SetPushRuleActionsJob"); - SetPushRuleActionsJob::SetPushRuleActionsJob(const QString& scope, const QString& kind, const QString& ruleId, const QStringList& actions) - : BaseJob(HttpVerb::Put, SetPushRuleActionsJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetPushRuleActionsJob"), basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId % "/actions") { diff --git a/lib/csapi/pushrules.h b/lib/csapi/pushrules.h index cb94fe7b..a9169151 100644 --- a/lib/csapi/pushrules.h +++ b/lib/csapi/pushrules.h @@ -14,31 +14,28 @@ #include -namespace Quotient -{ +namespace Quotient { // Operations -/// Retrieve all push rulesets. -/*! +/*! \brief Retrieve all push rulesets. + * * Retrieve all push rulesets for this user. Clients can "drill-down" on * the rulesets by suffixing a ``scope`` to this path e.g. * ``/pushrules/global/``. This will return a subset of this data under the * specified key e.g. the ``global`` key. */ -class GetPushRulesJob : public BaseJob -{ +class GetPushRulesJob : public BaseJob { public: + /// Retrieve all push rulesets. explicit GetPushRulesJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetPushRulesJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetPushRulesJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetPushRulesJob() override; // Result properties @@ -54,14 +51,14 @@ private: QScopedPointer d; }; -/// Retrieve a push rule. -/*! +/*! \brief Retrieve a push rule. + * * Retrieve a single specified push rule. */ -class GetPushRuleJob : public BaseJob -{ +class GetPushRuleJob : public BaseJob { public: - /*! Retrieve a push rule. + /*! \brief Retrieve a push rule. + * * \param scope * ``global`` to specify global rules. * \param kind @@ -72,15 +69,13 @@ public: explicit GetPushRuleJob(const QString& scope, const QString& kind, const QString& ruleId); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetPushRuleJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& kind, const QString& ruleId); - ~GetPushRuleJob() override; // Result properties @@ -96,14 +91,14 @@ private: QScopedPointer d; }; -/// Delete a push rule. -/*! +/*! \brief Delete a push rule. + * * This endpoint removes the push rule defined in the path. */ -class DeletePushRuleJob : public BaseJob -{ +class DeletePushRuleJob : public BaseJob { public: - /*! Delete a push rule. + /*! \brief Delete a push rule. + * * \param scope * ``global`` to specify global rules. * \param kind @@ -114,28 +109,27 @@ public: explicit DeletePushRuleJob(const QString& scope, const QString& kind, const QString& ruleId); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for DeletePushRuleJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& kind, const QString& ruleId); }; -/// Add or change a push rule. -/*! +/*! \brief Add or change a push rule. + * * This endpoint allows the creation, modification and deletion of pushers * for this user ID. The behaviour of this endpoint varies depending on the * values in the JSON body. * * When creating push rules, they MUST be enabled by default. */ -class SetPushRuleJob : public BaseJob -{ +class SetPushRuleJob : public BaseJob { public: - /*! Add or change a push rule. + /*! \brief Add or change a push rule. + * * \param scope * ``global`` to specify global rules. * \param kind @@ -167,14 +161,14 @@ public: const QString& pattern = {}); }; -/// Get whether a push rule is enabled -/*! +/*! \brief Get whether a push rule is enabled + * * This endpoint gets whether the specified push rule is enabled. */ -class IsPushRuleEnabledJob : public BaseJob -{ +class IsPushRuleEnabledJob : public BaseJob { public: - /*! Get whether a push rule is enabled + /*! \brief Get whether a push rule is enabled + * * \param scope * Either ``global`` or ``device/`` to specify global * rules or device rules for the given ``profile_tag``. @@ -186,15 +180,13 @@ public: explicit IsPushRuleEnabledJob(const QString& scope, const QString& kind, const QString& ruleId); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for IsPushRuleEnabledJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& kind, const QString& ruleId); - ~IsPushRuleEnabledJob() override; // Result properties @@ -210,14 +202,14 @@ private: QScopedPointer d; }; -/// Enable or disable a push rule. -/*! +/*! \brief Enable or disable a push rule. + * * This endpoint allows clients to enable or disable the specified push rule. */ -class SetPushRuleEnabledJob : public BaseJob -{ +class SetPushRuleEnabledJob : public BaseJob { public: - /*! Enable or disable a push rule. + /*! \brief Enable or disable a push rule. + * * \param scope * ``global`` to specify global rules. * \param kind @@ -231,14 +223,14 @@ public: const QString& ruleId, bool enabled); }; -/// The actions for a push rule -/*! +/*! \brief The actions for a push rule + * * This endpoint get the actions for the specified push rule. */ -class GetPushRuleActionsJob : public BaseJob -{ +class GetPushRuleActionsJob : public BaseJob { public: - /*! The actions for a push rule + /*! \brief The actions for a push rule + * * \param scope * Either ``global`` or ``device/`` to specify global * rules or device rules for the given ``profile_tag``. @@ -250,15 +242,13 @@ public: explicit GetPushRuleActionsJob(const QString& scope, const QString& kind, const QString& ruleId); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetPushRuleActionsJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& kind, const QString& ruleId); - ~GetPushRuleActionsJob() override; // Result properties @@ -274,15 +264,15 @@ private: QScopedPointer d; }; -/// Set the actions for a push rule. -/*! +/*! \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 SetPushRuleActionsJob : public BaseJob -{ +class SetPushRuleActionsJob : public BaseJob { public: - /*! Set the actions for a push rule. + /*! \brief Set the actions for a push rule. + * * \param scope * ``global`` to specify global rules. * \param kind diff --git a/lib/csapi/read_markers.cpp b/lib/csapi/read_markers.cpp index a07d09ce..76145808 100644 --- a/lib/csapi/read_markers.cpp +++ b/lib/csapi/read_markers.cpp @@ -12,12 +12,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto SetReadMarkerJobName = QStringLiteral("SetReadMarkerJob"); - SetReadMarkerJob::SetReadMarkerJob(const QString& roomId, const QString& mFullyRead, const QString& mRead) - : BaseJob(HttpVerb::Post, SetReadMarkerJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("SetReadMarkerJob"), basePath % "/rooms/" % roomId % "/read_markers") { QJsonObject _data; diff --git a/lib/csapi/read_markers.h b/lib/csapi/read_markers.h index 35c428b2..539aa5e4 100644 --- a/lib/csapi/read_markers.h +++ b/lib/csapi/read_markers.h @@ -6,20 +6,19 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Set the position of the read marker for a room. -/*! +/*! \brief Set the position of the read marker for a room. + * * Sets the position of the read marker for a given room, and optionally * the read receipt's location. */ -class SetReadMarkerJob : public BaseJob -{ +class SetReadMarkerJob : public BaseJob { public: - /*! Set the position of the read marker for a room. + /*! \brief Set the position of the read marker for a room. + * * \param roomId * The room ID to set the read marker in for the user. * \param mFullyRead diff --git a/lib/csapi/receipts.cpp b/lib/csapi/receipts.cpp index f9a45912..87264074 100644 --- a/lib/csapi/receipts.cpp +++ b/lib/csapi/receipts.cpp @@ -12,12 +12,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto PostReceiptJobName = QStringLiteral("PostReceiptJob"); - PostReceiptJob::PostReceiptJob(const QString& roomId, const QString& receiptType, const QString& eventId, const QJsonObject& receipt) - : BaseJob(HttpVerb::Post, PostReceiptJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("PostReceiptJob"), basePath % "/rooms/" % roomId % "/receipt/" % receiptType % "/" % eventId) { diff --git a/lib/csapi/receipts.h b/lib/csapi/receipts.h index 376d4006..eb82fc28 100644 --- a/lib/csapi/receipts.h +++ b/lib/csapi/receipts.h @@ -8,20 +8,19 @@ #include -namespace Quotient -{ +namespace Quotient { // Operations -/// Send a receipt for the given event ID. -/*! +/*! \brief Send a receipt for the given event ID. + * * This API updates the marker for the given receipt type to the event ID * specified. */ -class PostReceiptJob : public BaseJob -{ +class PostReceiptJob : public BaseJob { public: - /*! Send a receipt for the given event ID. + /*! \brief Send a receipt for the given event ID. + * * \param roomId * The room in which to send the event. * \param receiptType diff --git a/lib/csapi/redaction.cpp b/lib/csapi/redaction.cpp index d2dbe19b..2b6417ea 100644 --- a/lib/csapi/redaction.cpp +++ b/lib/csapi/redaction.cpp @@ -12,17 +12,14 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class RedactEventJob::Private -{ +class RedactEventJob::Private { public: QString eventId; }; -static const auto RedactEventJobName = QStringLiteral("RedactEventJob"); - RedactEventJob::RedactEventJob(const QString& roomId, const QString& eventId, const QString& txnId, const QString& reason) - : BaseJob(HttpVerb::Put, RedactEventJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("RedactEventJob"), basePath % "/rooms/" % roomId % "/redact/" % eventId % "/" % txnId) , d(new Private) { diff --git a/lib/csapi/redaction.h b/lib/csapi/redaction.h index 42022930..0e9095d1 100644 --- a/lib/csapi/redaction.h +++ b/lib/csapi/redaction.h @@ -6,13 +6,12 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Strips all non-integrity-critical information out of an event. -/*! +/*! \brief Strips all non-integrity-critical information out of an event. + * * Strips all information out of an event which isn't critical to the * integrity of the server-side representation of the room. * @@ -22,10 +21,10 @@ namespace Quotient * greater than or equal to the `redact` power level of the room may * redact events there. */ -class RedactEventJob : public BaseJob -{ +class RedactEventJob : public BaseJob { public: - /*! Strips all non-integrity-critical information out of an event. + /*! \brief Strips all non-integrity-critical information out of an event. + * * \param roomId * The room from which to redact the event. * \param eventId diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index 270011e1..768617cc 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class RegisterJob::Private -{ +class RegisterJob::Private { public: QString userId; QString accessToken; @@ -28,16 +27,14 @@ BaseJob::Query queryToRegister(const QString& kind) return _q; } -static const auto RegisterJobName = QStringLiteral("RegisterJob"); - RegisterJob::RegisterJob(const QString& kind, const Omittable& auth, Omittable bindEmail, const QString& username, const QString& password, const QString& deviceId, const QString& initialDeviceDisplayName, Omittable inhibitLogin) - : BaseJob(HttpVerb::Post, RegisterJobName, basePath % "/register", - queryToRegister(kind), {}, false) + : BaseJob(HttpVerb::Post, QStringLiteral("RegisterJob"), + basePath % "/register", queryToRegister(kind), {}, false) , d(new Private) { QJsonObject _data; @@ -76,19 +73,15 @@ BaseJob::Status RegisterJob::parseJson(const QJsonDocument& data) return Success; } -class RequestTokenToRegisterEmailJob::Private -{ +class RequestTokenToRegisterEmailJob::Private { public: Sid data; }; -static const auto RequestTokenToRegisterEmailJobName = - QStringLiteral("RequestTokenToRegisterEmailJob"); - RequestTokenToRegisterEmailJob::RequestTokenToRegisterEmailJob( const QString& clientSecret, const QString& email, int sendAttempt, const QString& idServer, const QString& nextLink) - : BaseJob(HttpVerb::Post, RequestTokenToRegisterEmailJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToRegisterEmailJob"), basePath % "/register/email/requestToken", false) , d(new Private) { @@ -109,23 +102,20 @@ BaseJob::Status RequestTokenToRegisterEmailJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -class RequestTokenToRegisterMSISDNJob::Private -{ +class RequestTokenToRegisterMSISDNJob::Private { public: Sid data; }; -static const auto RequestTokenToRegisterMSISDNJobName = - QStringLiteral("RequestTokenToRegisterMSISDNJob"); - RequestTokenToRegisterMSISDNJob::RequestTokenToRegisterMSISDNJob( const QString& clientSecret, const QString& country, const QString& phoneNumber, int sendAttempt, const QString& idServer, const QString& nextLink) - : BaseJob(HttpVerb::Post, RequestTokenToRegisterMSISDNJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToRegisterMSISDNJob"), basePath % "/register/msisdn/requestToken", false) , d(new Private) { @@ -147,14 +137,13 @@ BaseJob::Status RequestTokenToRegisterMSISDNJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -static const auto ChangePasswordJobName = QStringLiteral("ChangePasswordJob"); - ChangePasswordJob::ChangePasswordJob(const QString& newPassword, const Omittable& auth) - : BaseJob(HttpVerb::Post, ChangePasswordJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("ChangePasswordJob"), basePath % "/account/password") { QJsonObject _data; @@ -163,19 +152,16 @@ ChangePasswordJob::ChangePasswordJob(const QString& newPassword, setRequestData(_data); } -class RequestTokenToResetPasswordEmailJob::Private -{ +class RequestTokenToResetPasswordEmailJob::Private { public: Sid data; }; -static const auto RequestTokenToResetPasswordEmailJobName = - QStringLiteral("RequestTokenToResetPasswordEmailJob"); - RequestTokenToResetPasswordEmailJob::RequestTokenToResetPasswordEmailJob( const QString& clientSecret, const QString& email, int sendAttempt, const QString& idServer, const QString& nextLink) - : BaseJob(HttpVerb::Post, RequestTokenToResetPasswordEmailJobName, + : BaseJob(HttpVerb::Post, + QStringLiteral("RequestTokenToResetPasswordEmailJob"), basePath % "/account/password/email/requestToken", false) , d(new Private) { @@ -197,23 +183,21 @@ BaseJob::Status RequestTokenToResetPasswordEmailJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -class RequestTokenToResetPasswordMSISDNJob::Private -{ +class RequestTokenToResetPasswordMSISDNJob::Private { public: Sid data; }; -static const auto RequestTokenToResetPasswordMSISDNJobName = - QStringLiteral("RequestTokenToResetPasswordMSISDNJob"); - RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob( const QString& clientSecret, const QString& country, const QString& phoneNumber, int sendAttempt, const QString& idServer, const QString& nextLink) - : BaseJob(HttpVerb::Post, RequestTokenToResetPasswordMSISDNJobName, + : BaseJob(HttpVerb::Post, + QStringLiteral("RequestTokenToResetPasswordMSISDNJob"), basePath % "/account/password/msisdn/requestToken", false) , d(new Private) { @@ -239,15 +223,13 @@ BaseJob::Status RequestTokenToResetPasswordMSISDNJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -static const auto DeactivateAccountJobName = - QStringLiteral("DeactivateAccountJob"); - DeactivateAccountJob::DeactivateAccountJob( const Omittable& auth) - : BaseJob(HttpVerb::Post, DeactivateAccountJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("DeactivateAccountJob"), basePath % "/account/deactivate") { QJsonObject _data; @@ -255,8 +237,7 @@ DeactivateAccountJob::DeactivateAccountJob( setRequestData(_data); } -class CheckUsernameAvailabilityJob::Private -{ +class CheckUsernameAvailabilityJob::Private { public: Omittable available; }; @@ -276,11 +257,8 @@ QUrl CheckUsernameAvailabilityJob::makeRequestUrl(QUrl baseUrl, queryToCheckUsernameAvailability(username)); } -static const auto CheckUsernameAvailabilityJobName = - QStringLiteral("CheckUsernameAvailabilityJob"); - CheckUsernameAvailabilityJob::CheckUsernameAvailabilityJob(const QString& username) - : BaseJob(HttpVerb::Get, CheckUsernameAvailabilityJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("CheckUsernameAvailabilityJob"), basePath % "/register/available", queryToCheckUsernameAvailability(username), {}, false) , d(new Private) diff --git a/lib/csapi/registration.h b/lib/csapi/registration.h index 89aecb80..2619dd87 100644 --- a/lib/csapi/registration.h +++ b/lib/csapi/registration.h @@ -11,13 +11,12 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Register for an account on this homeserver. -/*! +/*! \brief Register for an account on this homeserver. + * * This API endpoint uses the `User-Interactive Authentication API`_. * * Register for an account on this homeserver. @@ -51,10 +50,10 @@ namespace Quotient * invalidate any access token previously associated with that device. See * `Relationship between access tokens and devices`_. */ -class RegisterJob : public BaseJob -{ +class RegisterJob : public BaseJob { public: - /*! Register for an account on this homeserver. + /*! \brief Register for an account on this homeserver. + * * \param kind * The kind of account to register. Defaults to `user`. * \param auth @@ -104,10 +103,12 @@ public: /// the `Matrix specification /// `_. const QString& userId() const; + /// An access token for the account. /// This access token can then be used to authorize other requests. /// Required if the ``inhibit_login`` option is false. const QString& accessToken() const; + /// The server_name of the homeserver on which the account has /// been registered. /// @@ -115,6 +116,7 @@ public: /// ``user_id`` (by splitting at the first colon) if they require /// it. Note also that ``homeserver`` is not spelt this way. const QString& homeServer() const; + /// ID of the registered device. Will be the same as the /// corresponding parameter in the request, if one was specified. /// Required if the ``inhibit_login`` option is false. @@ -128,20 +130,22 @@ private: QScopedPointer d; }; -/// Begins the validation process for an email to be used during registration. -/*! +/*! \brief Begins the validation process for an email to be used during + * registration. + * * Proxies the Identity Service API ``validate/email/requestToken``, but * first checks that the given email address is not already associated * with an account on this homeserver. See the Identity Service API for * further information. */ -class RequestTokenToRegisterEmailJob : public BaseJob -{ +class RequestTokenToRegisterEmailJob : public BaseJob { public: - /*! Begins the validation process for an email to be used during - * registration. \param clientSecret A unique string generated by the - * client, and used to identify the validation attempt. It must be a string - * consisting of the characters + /*! \brief Begins the validation process for an email to be used during + * registration. + * + * \param clientSecret + * 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 * must not be empty. * \param email @@ -184,21 +188,22 @@ private: QScopedPointer d; }; -/// Requests a validation token be sent to the given phone number for the -/// purpose of registering an account -/*! +/*! \brief Requests a validation token be sent to the given phone number for the + * purpose of registering an account + * * Proxies the Identity Service API ``validate/msisdn/requestToken``, but * first checks that the given phone number is not already associated * with an account on this homeserver. See the Identity Service API for * further information. */ -class RequestTokenToRegisterMSISDNJob : public BaseJob -{ +class RequestTokenToRegisterMSISDNJob : public BaseJob { public: - /*! Requests a validation token be sent to the given phone number for the - * purpose of registering an account \param clientSecret A unique string - * generated by the client, and used to identify the validation attempt. It - * must be a string consisting of the characters + /*! \brief Requests a validation token be sent to the given phone number for + * the purpose of registering an account + * + * \param clientSecret + * 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 * must not be empty. * \param country @@ -245,8 +250,8 @@ private: QScopedPointer d; }; -/// Changes a user's password. -/*! +/*! \brief Changes a user's password. + * * Changes the password for an account on this homeserver. * * This API endpoint uses the `User-Interactive Authentication API`_. @@ -257,10 +262,10 @@ private: * The homeserver may change the flows available depending on whether a * valid access token is provided. */ -class ChangePasswordJob : public BaseJob -{ +class ChangePasswordJob : public BaseJob { public: - /*! Changes a user's password. + /*! \brief Changes a user's password. + * * \param newPassword * The new password for the account. * \param auth @@ -271,9 +276,9 @@ public: const Omittable& auth = none); }; -/// Requests a validation token be sent to the given email address for the -/// purpose of resetting a user's password -/*! +/*! \brief Requests a validation token be sent to the given email address for + * the purpose of resetting a user's password + * * Proxies the Identity Service API ``validate/email/requestToken``, but * first checks that the given email address **is** associated with an account * on this homeserver. This API should be used to request @@ -290,13 +295,14 @@ public: * .. _/register/email/requestToken: * #post-matrix-client-r0-register-email-requesttoken */ -class RequestTokenToResetPasswordEmailJob : public BaseJob -{ +class RequestTokenToResetPasswordEmailJob : public BaseJob { public: - /*! Requests a validation token be sent to the given email address for the - * purpose of resetting a user's password \param clientSecret A unique - * string generated by the client, and used to identify the validation - * attempt. It must be a string consisting of the characters + /*! \brief Requests a validation token be sent to the given email address + * for the purpose of resetting a user's password + * + * \param clientSecret + * 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 * must not be empty. * \param email @@ -337,9 +343,9 @@ private: QScopedPointer d; }; -/// Requests a validation token be sent to the given phone number for the -/// purpose of resetting a user's password. -/*! +/*! \brief Requests a validation token be sent to the given phone number for the + * purpose of resetting a user's password. + * * Proxies the Identity Service API ``validate/msisdn/requestToken``, but * first checks that the given phone number **is** associated with an account * on this homeserver. This API should be used to request @@ -356,13 +362,14 @@ private: * .. _/register/msisdn/requestToken: * #post-matrix-client-r0-register-email-requesttoken */ -class RequestTokenToResetPasswordMSISDNJob : public BaseJob -{ +class RequestTokenToResetPasswordMSISDNJob : public BaseJob { public: - /*! Requests a validation token be sent to the given phone number for the - * purpose of resetting a user's password. \param clientSecret A unique - * string generated by the client, and used to identify the validation - * attempt. It must be a string consisting of the characters + /*! \brief Requests a validation token be sent to the given phone number for + * the purpose of resetting a user's password. + * + * \param clientSecret + * 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 * must not be empty. * \param country @@ -407,8 +414,8 @@ private: QScopedPointer d; }; -/// Deactivate a user's account. -/*! +/*! \brief Deactivate a user's account. + * * Deactivate the user's account, removing all ability for the user to * login again. * @@ -420,10 +427,10 @@ private: * The homeserver may change the flows available depending on whether a * valid access token is provided. */ -class DeactivateAccountJob : public BaseJob -{ +class DeactivateAccountJob : public BaseJob { public: - /*! Deactivate a user's account. + /*! \brief Deactivate a user's account. + * * \param auth * Additional authentication information for the user-interactive * authentication API. @@ -432,8 +439,8 @@ public: const Omittable& auth = none); }; -/// Checks to see if a username is available on the server. -/*! +/*! \brief Checks to see if a username is available on the server. + * * Checks to see if a username is available, and valid, for the server. * * The server should check to ensure that, at the time of the request, the @@ -447,23 +454,21 @@ public: * reserve the username. This can mean that the username becomes unavailable * between checking its availability and attempting to register it. */ -class CheckUsernameAvailabilityJob : public BaseJob -{ +class CheckUsernameAvailabilityJob : public BaseJob { public: - /*! Checks to see if a username is available on the server. + /*! \brief Checks to see if a username is available on the server. + * * \param username * The username to check the availability of. */ explicit CheckUsernameAvailabilityJob(const QString& username); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for CheckUsernameAvailabilityJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& username); - ~CheckUsernameAvailabilityJob() override; // Result properties diff --git a/lib/csapi/report_content.cpp b/lib/csapi/report_content.cpp index 352f52c9..f38b7a9a 100644 --- a/lib/csapi/report_content.cpp +++ b/lib/csapi/report_content.cpp @@ -12,11 +12,9 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto ReportContentJobName = QStringLiteral("ReportContentJob"); - ReportContentJob::ReportContentJob(const QString& roomId, const QString& eventId, int score, const QString& reason) - : BaseJob(HttpVerb::Post, ReportContentJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("ReportContentJob"), basePath % "/rooms/" % roomId % "/report/" % eventId) { QJsonObject _data; diff --git a/lib/csapi/report_content.h b/lib/csapi/report_content.h index c86a4301..0f3cc3d5 100644 --- a/lib/csapi/report_content.h +++ b/lib/csapi/report_content.h @@ -8,20 +8,19 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Reports an event as inappropriate. -/*! +/*! \brief Reports an event as inappropriate. + * * Reports an event as inappropriate to the server, which may then notify * the appropriate people. */ -class ReportContentJob : public BaseJob -{ +class ReportContentJob : public BaseJob { public: - /*! Reports an event as inappropriate. + /*! \brief Reports an event as inappropriate. + * * \param roomId * The room in which the event being reported is located. * \param eventId diff --git a/lib/csapi/room_send.cpp b/lib/csapi/room_send.cpp index 5e970d65..d278433b 100644 --- a/lib/csapi/room_send.cpp +++ b/lib/csapi/room_send.cpp @@ -12,17 +12,14 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class SendMessageJob::Private -{ +class SendMessageJob::Private { public: QString eventId; }; -static const auto SendMessageJobName = QStringLiteral("SendMessageJob"); - SendMessageJob::SendMessageJob(const QString& roomId, const QString& eventType, const QString& txnId, const QJsonObject& body) - : BaseJob(HttpVerb::Put, SendMessageJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SendMessageJob"), basePath % "/rooms/" % roomId % "/send/" % eventType % "/" % txnId) , d(new Private) { diff --git a/lib/csapi/room_send.h b/lib/csapi/room_send.h index 110fc83b..96b111ff 100644 --- a/lib/csapi/room_send.h +++ b/lib/csapi/room_send.h @@ -8,13 +8,12 @@ #include -namespace Quotient -{ +namespace Quotient { // Operations -/// Send a message event to the given room. -/*! +/*! \brief Send a message event to the given room. + * * This endpoint is used to send a message event to a room. Message events * allow access to historical events and pagination, making them suited * for "once-off" activity in a room. @@ -23,10 +22,10 @@ namespace Quotient * fields in this object will vary depending on the type of event. See * `Room Events`_ for the m. event specification. */ -class SendMessageJob : public BaseJob -{ +class SendMessageJob : public BaseJob { public: - /*! Send a message event to the given room. + /*! \brief Send a message event to the given room. + * * \param roomId * The room to send the event to. * \param eventType diff --git a/lib/csapi/room_state.cpp b/lib/csapi/room_state.cpp index bfcd6e17..5973b06b 100644 --- a/lib/csapi/room_state.cpp +++ b/lib/csapi/room_state.cpp @@ -12,20 +12,16 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class SetRoomStateWithKeyJob::Private -{ +class SetRoomStateWithKeyJob::Private { public: QString eventId; }; -static const auto SetRoomStateWithKeyJobName = - QStringLiteral("SetRoomStateWithKeyJob"); - SetRoomStateWithKeyJob::SetRoomStateWithKeyJob(const QString& roomId, const QString& eventType, const QString& stateKey, const QJsonObject& body) - : BaseJob(HttpVerb::Put, SetRoomStateWithKeyJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomStateWithKeyJob"), basePath % "/rooms/" % roomId % "/state/" % eventType % "/" % stateKey) , d(new Private) @@ -45,17 +41,14 @@ BaseJob::Status SetRoomStateWithKeyJob::parseJson(const QJsonDocument& data) return Success; } -class SetRoomStateJob::Private -{ +class SetRoomStateJob::Private { public: QString eventId; }; -static const auto SetRoomStateJobName = QStringLiteral("SetRoomStateJob"); - SetRoomStateJob::SetRoomStateJob(const QString& roomId, const QString& eventType, const QJsonObject& body) - : BaseJob(HttpVerb::Put, SetRoomStateJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomStateJob"), basePath % "/rooms/" % roomId % "/state/" % eventType) , d(new Private) { diff --git a/lib/csapi/room_state.h b/lib/csapi/room_state.h index 80619d63..7843cff4 100644 --- a/lib/csapi/room_state.h +++ b/lib/csapi/room_state.h @@ -8,13 +8,12 @@ #include -namespace Quotient -{ +namespace Quotient { // Operations -/// Send a state event to the given room. -/*! +/*! \brief Send a state event to the given room. + * * State events can be sent using this endpoint. These events will be * overwritten if ````, ```` and ```` all * match. @@ -27,10 +26,10 @@ namespace Quotient * fields in this object will vary depending on the type of event. See * `Room Events`_ for the ``m.`` event specification. */ -class SetRoomStateWithKeyJob : public BaseJob -{ +class SetRoomStateWithKeyJob : public BaseJob { public: - /*! Send a state event to the given room. + /*! \brief Send a state event to the given room. + * * \param roomId * The room to set the state in * \param eventType @@ -70,8 +69,8 @@ private: QScopedPointer d; }; -/// Send a state event to the given room. -/*! +/*! \brief Send a state event to the given room. + * * State events can be sent using this endpoint. This endpoint is * equivalent to calling `/rooms/{roomId}/state/{eventType}/{stateKey}` * with an empty `stateKey`. Previous state events with matching @@ -85,10 +84,10 @@ private: * fields in this object will vary depending on the type of event. See * `Room Events`_ for the ``m.`` event specification. */ -class SetRoomStateJob : public BaseJob -{ +class SetRoomStateJob : public BaseJob { public: - /*! Send a state event to the given room. + /*! \brief Send a state event to the given room. + * * \param roomId * The room to set the state in * \param eventType diff --git a/lib/csapi/room_upgrades.cpp b/lib/csapi/room_upgrades.cpp index 1d6006ef..244f5b74 100644 --- a/lib/csapi/room_upgrades.cpp +++ b/lib/csapi/room_upgrades.cpp @@ -12,16 +12,13 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class UpgradeRoomJob::Private -{ +class UpgradeRoomJob::Private { public: QString replacementRoom; }; -static const auto UpgradeRoomJobName = QStringLiteral("UpgradeRoomJob"); - UpgradeRoomJob::UpgradeRoomJob(const QString& roomId, const QString& newVersion) - : BaseJob(HttpVerb::Post, UpgradeRoomJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("UpgradeRoomJob"), basePath % "/rooms/" % roomId % "/upgrade") , d(new Private) { diff --git a/lib/csapi/room_upgrades.h b/lib/csapi/room_upgrades.h index 5f9262f1..f13a9af4 100644 --- a/lib/csapi/room_upgrades.h +++ b/lib/csapi/room_upgrades.h @@ -6,19 +6,18 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Upgrades a room to a new room version. -/*! +/*! \brief Upgrades a room to a new room version. + * * Upgrades the given room to a particular room version. */ -class UpgradeRoomJob : public BaseJob -{ +class UpgradeRoomJob : public BaseJob { public: - /*! Upgrades a room to a new room version. + /*! \brief Upgrades a room to a new room version. + * * \param roomId * The ID of the room to upgrade. * \param newVersion diff --git a/lib/csapi/rooms.cpp b/lib/csapi/rooms.cpp index 5bfbe44d..234e33df 100644 --- a/lib/csapi/rooms.cpp +++ b/lib/csapi/rooms.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class GetOneRoomEventJob::Private -{ +class GetOneRoomEventJob::Private { public: EventPtr data; }; @@ -26,11 +25,9 @@ QUrl GetOneRoomEventJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, % eventId); } -static const auto GetOneRoomEventJobName = QStringLiteral("GetOneRoomEventJob"); - GetOneRoomEventJob::GetOneRoomEventJob(const QString& roomId, const QString& eventId) - : BaseJob(HttpVerb::Get, GetOneRoomEventJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetOneRoomEventJob"), basePath % "/rooms/" % roomId % "/event/" % eventId) , d(new Private) {} @@ -42,6 +39,7 @@ EventPtr&& GetOneRoomEventJob::data() { return std::move(d->data); } BaseJob::Status GetOneRoomEventJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } @@ -54,13 +52,10 @@ QUrl GetRoomStateWithKeyJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, % eventType % "/" % stateKey); } -static const auto GetRoomStateWithKeyJobName = - QStringLiteral("GetRoomStateWithKeyJob"); - GetRoomStateWithKeyJob::GetRoomStateWithKeyJob(const QString& roomId, const QString& eventType, const QString& stateKey) - : BaseJob(HttpVerb::Get, GetRoomStateWithKeyJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomStateWithKeyJob"), basePath % "/rooms/" % roomId % "/state/" % eventType % "/" % stateKey) {} @@ -73,17 +68,13 @@ QUrl GetRoomStateByTypeJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, % eventType); } -static const auto GetRoomStateByTypeJobName = - QStringLiteral("GetRoomStateByTypeJob"); - GetRoomStateByTypeJob::GetRoomStateByTypeJob(const QString& roomId, const QString& eventType) - : BaseJob(HttpVerb::Get, GetRoomStateByTypeJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomStateByTypeJob"), basePath % "/rooms/" % roomId % "/state/" % eventType) {} -class GetRoomStateJob::Private -{ +class GetRoomStateJob::Private { public: StateEvents data; }; @@ -94,10 +85,8 @@ QUrl GetRoomStateJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) basePath % "/rooms/" % roomId % "/state"); } -static const auto GetRoomStateJobName = QStringLiteral("GetRoomStateJob"); - GetRoomStateJob::GetRoomStateJob(const QString& roomId) - : BaseJob(HttpVerb::Get, GetRoomStateJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomStateJob"), basePath % "/rooms/" % roomId % "/state") , d(new Private) {} @@ -109,11 +98,11 @@ StateEvents&& GetRoomStateJob::data() { return std::move(d->data); } BaseJob::Status GetRoomStateJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -class GetMembersByRoomJob::Private -{ +class GetMembersByRoomJob::Private { public: EventsArray chunk; }; @@ -134,19 +123,17 @@ QUrl GetMembersByRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& membership, const QString& notMembership) { - return BaseJob::makeRequestUrl( - std::move(baseUrl), basePath % "/rooms/" % roomId % "/members", - queryToGetMembersByRoom(at, membership, notMembership)); + return BaseJob::makeRequestUrl(std::move(baseUrl), + basePath % "/rooms/" % roomId % "/members", + queryToGetMembersByRoom(at, membership, + notMembership)); } -static const auto GetMembersByRoomJobName = - QStringLiteral("GetMembersByRoomJob"); - GetMembersByRoomJob::GetMembersByRoomJob(const QString& roomId, const QString& at, const QString& membership, const QString& notMembership) - : BaseJob(HttpVerb::Get, GetMembersByRoomJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetMembersByRoomJob"), basePath % "/rooms/" % roomId % "/members", queryToGetMembersByRoom(at, membership, notMembership)) , d(new Private) @@ -168,12 +155,10 @@ BaseJob::Status GetMembersByRoomJob::parseJson(const QJsonDocument& data) } // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void fillFrom(const QJsonObject& jo, GetJoinedMembersByRoomJob::RoomMember& result) { @@ -184,8 +169,7 @@ struct JsonObjectConverter } // namespace Quotient -class GetJoinedMembersByRoomJob::Private -{ +class GetJoinedMembersByRoomJob::Private { public: QHash joined; }; @@ -193,15 +177,13 @@ public: QUrl GetJoinedMembersByRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { - return BaseJob::makeRequestUrl( - std::move(baseUrl), basePath % "/rooms/" % roomId % "/joined_members"); + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/rooms/" + % roomId + % "/joined_members"); } -static const auto GetJoinedMembersByRoomJobName = - QStringLiteral("GetJoinedMembersByRoomJob"); - GetJoinedMembersByRoomJob::GetJoinedMembersByRoomJob(const QString& roomId) - : BaseJob(HttpVerb::Get, GetJoinedMembersByRoomJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetJoinedMembersByRoomJob"), basePath % "/rooms/" % roomId % "/joined_members") , d(new Private) {} diff --git a/lib/csapi/rooms.h b/lib/csapi/rooms.h index 1020fdb1..05c5b82a 100644 --- a/lib/csapi/rooms.h +++ b/lib/csapi/rooms.h @@ -12,20 +12,19 @@ #include -namespace Quotient -{ +namespace Quotient { // Operations -/// Get a single event by event ID. -/*! +/*! \brief Get a single event by event ID. + * * 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 GetOneRoomEventJob : public BaseJob -{ +class GetOneRoomEventJob : public BaseJob { public: - /*! Get a single event by event ID. + /*! \brief Get a single event by event ID. + * * \param roomId * The ID of the room the event is in. * \param eventId @@ -33,15 +32,13 @@ public: */ explicit GetOneRoomEventJob(const QString& roomId, const QString& eventId); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetOneRoomEventJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& eventId); - ~GetOneRoomEventJob() override; // Result properties @@ -57,17 +54,17 @@ private: QScopedPointer d; }; -/// Get the state identified by the type and key. -/*! +/*! \brief Get the state identified by the type and key. + * * Looks up the contents of a state event in a room. If the user is * 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 GetRoomStateWithKeyJob : public BaseJob -{ +class GetRoomStateWithKeyJob : public BaseJob { public: - /*! Get the state identified by the type and key. + /*! \brief Get the state identified by the type and key. + * * \param roomId * The room to look up the state in. * \param eventType @@ -79,19 +76,18 @@ public: const QString& eventType, const QString& stateKey); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetRoomStateWithKeyJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& eventType, const QString& stateKey); }; -/// Get the state identified by the type, with the empty state key. -/*! +/*! \brief Get the state identified by the type, with the empty state key. + * * Looks up the contents of a state event in a room. If the user is * 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 @@ -99,10 +95,10 @@ public: * * This looks up the state event with the empty state key. */ -class GetRoomStateByTypeJob : public BaseJob -{ +class GetRoomStateByTypeJob : public BaseJob { public: - /*! Get the state identified by the type, with the empty state key. + /*! \brief Get the state identified by the type, with the empty state key. + * * \param roomId * The room to look up the state in. * \param eventType @@ -111,37 +107,34 @@ public: explicit GetRoomStateByTypeJob(const QString& roomId, const QString& eventType); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetRoomStateByTypeJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetRoomStateByTypeJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& eventType); }; -/// Get all state events in the current state of a room. -/*! +/*! \brief Get all state events in the current state of a room. + * * Get the state events for the current state of a room. */ -class GetRoomStateJob : public BaseJob -{ +class GetRoomStateJob : public BaseJob { public: - /*! Get all state events in the current state of a room. + /*! \brief Get all state events in the current state of a room. + * * \param roomId * The room to look up the state for. */ explicit GetRoomStateJob(const QString& roomId); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetRoomStateJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId); - ~GetRoomStateJob() override; // Result properties @@ -160,14 +153,14 @@ private: QScopedPointer d; }; -/// Get the m.room.member events for the room. -/*! +/*! \brief Get the m.room.member events for the room. + * * Get the list of members for this room. */ -class GetMembersByRoomJob : public BaseJob -{ +class GetMembersByRoomJob : public BaseJob { public: - /*! Get the m.room.member events for the room. + /*! \brief Get the m.room.member events for the room. + * * \param roomId * The room to get the member events for. * \param at @@ -184,17 +177,15 @@ public: const QString& membership = {}, const QString& notMembership = {}); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetMembersByRoomJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& at = {}, const QString& membership = {}, const QString& notMembership = {}); - ~GetMembersByRoomJob() override; // Result properties @@ -210,8 +201,8 @@ private: QScopedPointer d; }; -/// Gets the list of currently joined users and their profile data. -/*! +/*! \brief Gets the list of currently joined users and their profile data. + * * This API returns a map of MXIDs to member info objects for members of the * room. The current user 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. @@ -219,8 +210,7 @@ private: * respond than ``/members`` as it can be implemented more efficiently on the * server. */ -class GetJoinedMembersByRoomJob : public BaseJob -{ +class GetJoinedMembersByRoomJob : public BaseJob { public: // Inner data structures @@ -230,8 +220,7 @@ public: /// 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. - struct RoomMember - { + struct RoomMember { /// The display name of the user this object is representing. QString displayName; /// The mxc avatar url of the user this object is representing. @@ -240,20 +229,19 @@ public: // Construction/destruction - /*! Gets the list of currently joined users and their profile data. + /*! \brief Gets the list of currently joined users and their profile data. + * * \param roomId * The room to get the members of. */ explicit GetJoinedMembersByRoomJob(const QString& roomId); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetJoinedMembersByRoomJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId); - ~GetJoinedMembersByRoomJob() override; // Result properties diff --git a/lib/csapi/sso_login_redirect.cpp b/lib/csapi/sso_login_redirect.cpp index c2cc81cf..21fe646e 100644 --- a/lib/csapi/sso_login_redirect.cpp +++ b/lib/csapi/sso_login_redirect.cpp @@ -26,10 +26,9 @@ QUrl RedirectToSSOJob::makeRequestUrl(QUrl baseUrl, const QString& redirectUrl) queryToRedirectToSSO(redirectUrl)); } -static const auto RedirectToSSOJobName = QStringLiteral("RedirectToSSOJob"); - RedirectToSSOJob::RedirectToSSOJob(const QString& redirectUrl) - : BaseJob(HttpVerb::Get, RedirectToSSOJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("RedirectToSSOJob"), basePath % "/login/sso/redirect", queryToRedirectToSSO(redirectUrl), {}, false) + {} diff --git a/lib/csapi/sso_login_redirect.h b/lib/csapi/sso_login_redirect.h index b932a15e..8978c7f7 100644 --- a/lib/csapi/sso_login_redirect.h +++ b/lib/csapi/sso_login_redirect.h @@ -6,33 +6,31 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Redirect the user's browser to the SSO interface. -/*! +/*! \brief Redirect the user's browser to the SSO interface. + * * A web-based Matrix client should instruct the user's browser to * navigate to this endpoint in order to log in via SSO. * * The server MUST respond with an HTTP redirect to the SSO interface. */ -class RedirectToSSOJob : public BaseJob -{ +class RedirectToSSOJob : public BaseJob { public: - /*! Redirect the user's browser to the SSO interface. + /*! \brief Redirect the user's browser to the SSO interface. + * * \param redirectUrl * URI to which the user will be redirected after the homeserver has * authenticated the user with SSO. */ explicit RedirectToSSOJob(const QString& redirectUrl); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for RedirectToSSOJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& redirectUrl); }; diff --git a/lib/csapi/tags.cpp b/lib/csapi/tags.cpp index 3df38074..0e2d122a 100644 --- a/lib/csapi/tags.cpp +++ b/lib/csapi/tags.cpp @@ -13,12 +13,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void fillFrom(QJsonObject jo, GetRoomTagsJob::Tag& result) { fromJson(jo.take("order"_ls), result.order); @@ -28,8 +26,7 @@ struct JsonObjectConverter } // namespace Quotient -class GetRoomTagsJob::Private -{ +class GetRoomTagsJob::Private { public: QHash tags; }; @@ -42,10 +39,8 @@ QUrl GetRoomTagsJob::makeRequestUrl(QUrl baseUrl, const QString& userId, % roomId % "/tags"); } -static const auto GetRoomTagsJobName = QStringLiteral("GetRoomTagsJob"); - GetRoomTagsJob::GetRoomTagsJob(const QString& userId, const QString& roomId) - : BaseJob(HttpVerb::Get, GetRoomTagsJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomTagsJob"), basePath % "/user/" % userId % "/rooms/" % roomId % "/tags") , d(new Private) {} @@ -65,11 +60,9 @@ BaseJob::Status GetRoomTagsJob::parseJson(const QJsonDocument& data) return Success; } -static const auto SetRoomTagJobName = QStringLiteral("SetRoomTagJob"); - SetRoomTagJob::SetRoomTagJob(const QString& userId, const QString& roomId, const QString& tag, Omittable order) - : BaseJob(HttpVerb::Put, SetRoomTagJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomTagJob"), basePath % "/user/" % userId % "/rooms/" % roomId % "/tags/" % tag) { QJsonObject _data; @@ -85,10 +78,8 @@ QUrl DeleteRoomTagJob::makeRequestUrl(QUrl baseUrl, const QString& userId, % roomId % "/tags/" % tag); } -static const auto DeleteRoomTagJobName = QStringLiteral("DeleteRoomTagJob"); - DeleteRoomTagJob::DeleteRoomTagJob(const QString& userId, const QString& roomId, const QString& tag) - : BaseJob(HttpVerb::Delete, DeleteRoomTagJobName, + : BaseJob(HttpVerb::Delete, QStringLiteral("DeleteRoomTagJob"), basePath % "/user/" % userId % "/rooms/" % roomId % "/tags/" % tag) {} diff --git a/lib/csapi/tags.h b/lib/csapi/tags.h index 8ddebd6b..1ffb0f81 100644 --- a/lib/csapi/tags.h +++ b/lib/csapi/tags.h @@ -11,34 +11,31 @@ #include #include -namespace Quotient -{ +namespace Quotient { // Operations -/// List the tags for a room. -/*! +/*! \brief List the tags for a room. + * * List the tags set by a user on a room. */ -class GetRoomTagsJob : public BaseJob -{ +class GetRoomTagsJob : public BaseJob { public: // Inner data structures /// List the tags set by a user on a room. - struct Tag - { - /// A number in a range ``[0,1]`` describing a relativeposition of the - /// room under the given tag. + struct Tag { + /// A number in a range ``[0,1]`` describing a relative + /// position of the room under the given tag. Omittable order; - /// List the tags set by a user on a room. QVariantHash additionalProperties; }; // Construction/destruction - /*! List the tags for a room. + /*! \brief List the tags for a room. + * * \param userId * The id of the user to get tags for. The access token must be * authorized to make requests for this user ID. @@ -47,15 +44,13 @@ public: */ explicit GetRoomTagsJob(const QString& userId, const QString& roomId); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetRoomTagsJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& roomId); - ~GetRoomTagsJob() override; // Result properties @@ -71,14 +66,14 @@ private: QScopedPointer d; }; -/// Add a tag to a room. -/*! +/*! \brief Add a tag to a room. + * * Add a tag to the room. */ -class SetRoomTagJob : public BaseJob -{ +class SetRoomTagJob : public BaseJob { public: - /*! Add a tag to a room. + /*! \brief Add a tag to a room. + * * \param userId * The id of the user to add a tag for. The access token must be * authorized to make requests for this user ID. @@ -94,14 +89,14 @@ public: const QString& tag, Omittable order = none); }; -/// Remove a tag from the room. -/*! +/*! \brief Remove a tag from the room. + * * Remove a tag from the room. */ -class DeleteRoomTagJob : public BaseJob -{ +class DeleteRoomTagJob : public BaseJob { public: - /*! Remove a tag from the room. + /*! \brief Remove a tag from the room. + * * \param userId * The id of the user to remove a tag for. The access token must be * authorized to make requests for this user ID. @@ -113,11 +108,10 @@ public: explicit DeleteRoomTagJob(const QString& userId, const QString& roomId, const QString& tag); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for DeleteRoomTagJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& roomId, const QString& tag); diff --git a/lib/csapi/third_party_lookup.cpp b/lib/csapi/third_party_lookup.cpp index 678f6b3c..9d92e407 100644 --- a/lib/csapi/third_party_lookup.cpp +++ b/lib/csapi/third_party_lookup.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class GetProtocolsJob::Private -{ +class GetProtocolsJob::Private { public: QHash data; }; @@ -24,10 +23,8 @@ QUrl GetProtocolsJob::makeRequestUrl(QUrl baseUrl) basePath % "/thirdparty/protocols"); } -static const auto GetProtocolsJobName = QStringLiteral("GetProtocolsJob"); - GetProtocolsJob::GetProtocolsJob() - : BaseJob(HttpVerb::Get, GetProtocolsJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetProtocolsJob"), basePath % "/thirdparty/protocols") , d(new Private) {} @@ -42,11 +39,11 @@ const QHash& GetProtocolsJob::data() const BaseJob::Status GetProtocolsJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -class GetProtocolMetadataJob::Private -{ +class GetProtocolMetadataJob::Private { public: ThirdPartyProtocol data; }; @@ -54,15 +51,12 @@ public: QUrl GetProtocolMetadataJob::makeRequestUrl(QUrl baseUrl, const QString& protocol) { - return BaseJob::makeRequestUrl( - std::move(baseUrl), basePath % "/thirdparty/protocol/" % protocol); + return BaseJob::makeRequestUrl(std::move(baseUrl), + basePath % "/thirdparty/protocol/" % protocol); } -static const auto GetProtocolMetadataJobName = - QStringLiteral("GetProtocolMetadataJob"); - GetProtocolMetadataJob::GetProtocolMetadataJob(const QString& protocol) - : BaseJob(HttpVerb::Get, GetProtocolMetadataJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetProtocolMetadataJob"), basePath % "/thirdparty/protocol/" % protocol) , d(new Private) {} @@ -77,11 +71,11 @@ const ThirdPartyProtocol& GetProtocolMetadataJob::data() const BaseJob::Status GetProtocolMetadataJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -class QueryLocationByProtocolJob::Private -{ +class QueryLocationByProtocolJob::Private { public: QVector data; }; @@ -102,12 +96,9 @@ QUrl QueryLocationByProtocolJob::makeRequestUrl(QUrl baseUrl, queryToQueryLocationByProtocol(searchFields)); } -static const auto QueryLocationByProtocolJobName = - QStringLiteral("QueryLocationByProtocolJob"); - QueryLocationByProtocolJob::QueryLocationByProtocolJob( const QString& protocol, const QString& searchFields) - : BaseJob(HttpVerb::Get, QueryLocationByProtocolJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("QueryLocationByProtocolJob"), basePath % "/thirdparty/location/" % protocol, queryToQueryLocationByProtocol(searchFields)) , d(new Private) @@ -123,11 +114,11 @@ const QVector& QueryLocationByProtocolJob::data() const BaseJob::Status QueryLocationByProtocolJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -class QueryUserByProtocolJob::Private -{ +class QueryUserByProtocolJob::Private { public: QVector data; }; @@ -148,12 +139,9 @@ QUrl QueryUserByProtocolJob::makeRequestUrl(QUrl baseUrl, queryToQueryUserByProtocol(fields)); } -static const auto QueryUserByProtocolJobName = - QStringLiteral("QueryUserByProtocolJob"); - QueryUserByProtocolJob::QueryUserByProtocolJob(const QString& protocol, const QString& fields) - : BaseJob(HttpVerb::Get, QueryUserByProtocolJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("QueryUserByProtocolJob"), basePath % "/thirdparty/user/" % protocol, queryToQueryUserByProtocol(fields)) , d(new Private) @@ -169,11 +157,11 @@ const QVector& QueryUserByProtocolJob::data() const BaseJob::Status QueryUserByProtocolJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -class QueryLocationByAliasJob::Private -{ +class QueryLocationByAliasJob::Private { public: QVector data; }; @@ -192,11 +180,8 @@ QUrl QueryLocationByAliasJob::makeRequestUrl(QUrl baseUrl, const QString& alias) queryToQueryLocationByAlias(alias)); } -static const auto QueryLocationByAliasJobName = - QStringLiteral("QueryLocationByAliasJob"); - QueryLocationByAliasJob::QueryLocationByAliasJob(const QString& alias) - : BaseJob(HttpVerb::Get, QueryLocationByAliasJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("QueryLocationByAliasJob"), basePath % "/thirdparty/location", queryToQueryLocationByAlias(alias)) , d(new Private) @@ -212,11 +197,11 @@ const QVector& QueryLocationByAliasJob::data() const BaseJob::Status QueryLocationByAliasJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -class QueryUserByIDJob::Private -{ +class QueryUserByIDJob::Private { public: QVector data; }; @@ -235,10 +220,8 @@ QUrl QueryUserByIDJob::makeRequestUrl(QUrl baseUrl, const QString& userid) queryToQueryUserByID(userid)); } -static const auto QueryUserByIDJobName = QStringLiteral("QueryUserByIDJob"); - QueryUserByIDJob::QueryUserByIDJob(const QString& userid) - : BaseJob(HttpVerb::Get, QueryUserByIDJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("QueryUserByIDJob"), basePath % "/thirdparty/user", queryToQueryUserByID(userid)) , d(new Private) {} @@ -253,5 +236,6 @@ const QVector& QueryUserByIDJob::data() const BaseJob::Status QueryUserByIDJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } diff --git a/lib/csapi/third_party_lookup.h b/lib/csapi/third_party_lookup.h index 63607549..c8ca8cbb 100644 --- a/lib/csapi/third_party_lookup.h +++ b/lib/csapi/third_party_lookup.h @@ -15,30 +15,27 @@ #include #include -namespace Quotient -{ +namespace Quotient { // Operations -/// Retrieve metadata about all protocols that a homeserver supports. -/*! +/*! \brief Retrieve metadata about all protocols that a homeserver supports. + * * 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 GetProtocolsJob : public BaseJob -{ +class GetProtocolsJob : public BaseJob { public: + /// Retrieve metadata about all protocols that a homeserver supports. explicit GetProtocolsJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetProtocolsJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetProtocolsJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetProtocolsJob() override; // Result properties @@ -54,27 +51,28 @@ private: QScopedPointer d; }; -/// Retrieve metadata about a specific protocol that the homeserver supports. -/*! +/*! \brief Retrieve metadata about a specific protocol that the homeserver + * supports. + * * Fetches the metadata from the homeserver about a particular third party * protocol. */ -class GetProtocolMetadataJob : public BaseJob -{ +class GetProtocolMetadataJob : public BaseJob { public: - /*! Retrieve metadata about a specific protocol that the homeserver - * supports. \param protocol The name of the protocol. + /*! \brief Retrieve metadata about a specific protocol that the homeserver + * supports. + * + * \param protocol + * The name of the protocol. */ explicit GetProtocolMetadataJob(const QString& protocol); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for GetProtocolMetadataJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& protocol); - ~GetProtocolMetadataJob() override; // Result properties @@ -90,8 +88,8 @@ private: QScopedPointer d; }; -/// Retrieve Matrix-side portals rooms leading to a third party location. -/*! +/*! \brief Retrieve Matrix-side portals rooms leading to a third party location. + * * Requesting this endpoint with a valid protocol name results in a list * of successful mapping results in a JSON array. Each result contains * objects to represent the Matrix room or rooms that represent a portal @@ -101,10 +99,11 @@ private: * identifier. It should attempt to canonicalise the identifier as much * as reasonably possible given the network type. */ -class QueryLocationByProtocolJob : public BaseJob -{ +class QueryLocationByProtocolJob : public BaseJob { public: - /*! Retrieve Matrix-side portals rooms leading to a third party location. + /*! \brief Retrieve Matrix-side portals rooms leading to a third party + * location. + * * \param protocol * The protocol used to communicate to the third party network. * \param searchFields @@ -114,15 +113,13 @@ public: explicit QueryLocationByProtocolJob(const QString& protocol, const QString& searchFields = {}); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for QueryLocationByProtocolJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& protocol, const QString& searchFields = {}); - ~QueryLocationByProtocolJob() override; // Result properties @@ -138,15 +135,15 @@ private: QScopedPointer d; }; -/// Retrieve the Matrix User ID of a corresponding third party user. -/*! +/*! \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 QueryUserByProtocolJob : public BaseJob -{ +class QueryUserByProtocolJob : public BaseJob { public: - /*! Retrieve the Matrix User ID of a corresponding third party user. + /*! \brief Retrieve the Matrix User ID of a corresponding third party user. + * * \param protocol * The name of the protocol. * \param fields @@ -156,15 +153,13 @@ public: explicit QueryUserByProtocolJob(const QString& protocol, const QString& fields = {}); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for QueryUserByProtocolJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& protocol, const QString& fields = {}); - ~QueryUserByProtocolJob() override; // Result properties @@ -180,28 +175,26 @@ private: QScopedPointer d; }; -/// Reverse-lookup third party locations given a Matrix room alias. -/*! +/*! \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 QueryLocationByAliasJob : public BaseJob -{ +class QueryLocationByAliasJob : public BaseJob { public: - /*! Reverse-lookup third party locations given a Matrix room alias. + /*! \brief Reverse-lookup third party locations given a Matrix room alias. + * * \param alias * The Matrix room alias to look up. */ explicit QueryLocationByAliasJob(const QString& alias); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for QueryLocationByAliasJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& alias); - ~QueryLocationByAliasJob() override; // Result properties @@ -217,27 +210,25 @@ private: QScopedPointer d; }; -/// Reverse-lookup third party users given a Matrix User ID. -/*! +/*! \brief Reverse-lookup third party users given a Matrix User ID. + * * Retrieve an array of third party users from a Matrix User ID. */ -class QueryUserByIDJob : public BaseJob -{ +class QueryUserByIDJob : public BaseJob { public: - /*! Reverse-lookup third party users given a Matrix User ID. + /*! \brief Reverse-lookup third party users given a Matrix User ID. + * * \param userid * The Matrix User ID to look up. */ explicit QueryUserByIDJob(const QString& userid); - /*! Construct a URL without creating a full-fledged job object + /*! \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. + * This function can be used when a URL for QueryUserByIDJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userid); - ~QueryUserByIDJob() override; // Result properties diff --git a/lib/csapi/third_party_membership.cpp b/lib/csapi/third_party_membership.cpp index 7e401163..15da6b3c 100644 --- a/lib/csapi/third_party_membership.cpp +++ b/lib/csapi/third_party_membership.cpp @@ -12,11 +12,9 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto InviteBy3PIDJobName = QStringLiteral("InviteBy3PIDJob"); - InviteBy3PIDJob::InviteBy3PIDJob(const QString& roomId, const QString& idServer, const QString& medium, const QString& address) - : BaseJob(HttpVerb::Post, InviteBy3PIDJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("InviteBy3PIDJob"), basePath % "/rooms/" % roomId % "/invite") { QJsonObject _data; diff --git a/lib/csapi/third_party_membership.h b/lib/csapi/third_party_membership.h index bd4c6896..c85e8ab4 100644 --- a/lib/csapi/third_party_membership.h +++ b/lib/csapi/third_party_membership.h @@ -6,13 +6,12 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Invite a user to participate in a particular room. -/*! +/*! \brief Invite a user to participate in a particular room. + * * .. _invite-by-third-party-id-endpoint: * * *Note that there are two forms of this API, which are documented separately. @@ -58,10 +57,10 @@ namespace Quotient * * .. _joining rooms section: `invite-by-user-id-endpoint`_ */ -class InviteBy3PIDJob : public BaseJob -{ +class InviteBy3PIDJob : public BaseJob { public: - /*! Invite a user to participate in a particular room. + /*! \brief Invite a user to participate in a particular room. + * * \param roomId * The room identifier (not alias) to which to invite the user. * \param idServer diff --git a/lib/csapi/to_device.cpp b/lib/csapi/to_device.cpp index 3f6e8097..e277503c 100644 --- a/lib/csapi/to_device.cpp +++ b/lib/csapi/to_device.cpp @@ -12,12 +12,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto SendToDeviceJobName = QStringLiteral("SendToDeviceJob"); - SendToDeviceJob::SendToDeviceJob( const QString& eventType, const QString& txnId, const QHash>& messages) - : BaseJob(HttpVerb::Put, SendToDeviceJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SendToDeviceJob"), basePath % "/sendToDevice/" % eventType % "/" % txnId) { QJsonObject _data; diff --git a/lib/csapi/to_device.h b/lib/csapi/to_device.h index 14445439..48f0ec83 100644 --- a/lib/csapi/to_device.h +++ b/lib/csapi/to_device.h @@ -9,20 +9,19 @@ #include #include -namespace Quotient -{ +namespace Quotient { // Operations -/// Send an event to a given set of devices. -/*! +/*! \brief Send an event to a given set of devices. + * * This endpoint is used to send send-to-device events to a set of * client devices. */ -class SendToDeviceJob : public BaseJob -{ +class SendToDeviceJob : public BaseJob { public: - /*! Send an event to a given set of devices. + /*! \brief Send an event to a given set of devices. + * * \param eventType * The type of event to send. * \param txnId diff --git a/lib/csapi/typing.cpp b/lib/csapi/typing.cpp index 064ebe39..261622c4 100644 --- a/lib/csapi/typing.cpp +++ b/lib/csapi/typing.cpp @@ -12,11 +12,9 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -static const auto SetTypingJobName = QStringLiteral("SetTypingJob"); - SetTypingJob::SetTypingJob(const QString& userId, const QString& roomId, bool typing, Omittable timeout) - : BaseJob(HttpVerb::Put, SetTypingJobName, + : BaseJob(HttpVerb::Put, QStringLiteral("SetTypingJob"), basePath % "/rooms/" % roomId % "/typing/" % userId) { QJsonObject _data; diff --git a/lib/csapi/typing.h b/lib/csapi/typing.h index 350c209d..dbf17a3e 100644 --- a/lib/csapi/typing.h +++ b/lib/csapi/typing.h @@ -8,22 +8,21 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Informs the server that the user has started or stopped typing. -/*! +/*! \brief Informs the server that the user has started or stopped typing. + * * This tells the server that the user is typing for the next N * 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 SetTypingJob : public BaseJob -{ +class SetTypingJob : public BaseJob { public: - /*! Informs the server that the user has started or stopped typing. + /*! \brief Informs the server that the user has started or stopped typing. + * * \param userId * The user who has started to type. * \param roomId diff --git a/lib/csapi/users.cpp b/lib/csapi/users.cpp index 77c297dd..5d2a6133 100644 --- a/lib/csapi/users.cpp +++ b/lib/csapi/users.cpp @@ -13,12 +13,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void fillFrom(const QJsonObject& jo, SearchUserDirectoryJob::User& result) { @@ -30,19 +28,15 @@ struct JsonObjectConverter } // namespace Quotient -class SearchUserDirectoryJob::Private -{ +class SearchUserDirectoryJob::Private { public: QVector results; bool limited; }; -static const auto SearchUserDirectoryJobName = - QStringLiteral("SearchUserDirectoryJob"); - SearchUserDirectoryJob::SearchUserDirectoryJob(const QString& searchTerm, Omittable limit) - : BaseJob(HttpVerb::Post, SearchUserDirectoryJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("SearchUserDirectoryJob"), basePath % "/user_directory/search") , d(new Private) { diff --git a/lib/csapi/users.h b/lib/csapi/users.h index d9a16a9d..de4eb529 100644 --- a/lib/csapi/users.h +++ b/lib/csapi/users.h @@ -10,13 +10,12 @@ #include -namespace Quotient -{ +namespace Quotient { // Operations -/// Searches the user directory. -/*! +/*! \brief Searches the user directory. + * * Performs a search for users on the homeserver. The homeserver may * determine which subset of users are searched, however the homeserver * MUST at a minimum consider the users the requesting user shares a @@ -28,22 +27,21 @@ namespace Quotient * names preferably using a collation determined based upon the * ``Accept-Language`` header provided in the request, if present. */ -class SearchUserDirectoryJob : public BaseJob -{ +class SearchUserDirectoryJob : public BaseJob { public: // Inner data structures - /// Performs a search for users on the homeserver. The homeserver - /// maydetermine which subset of users are searched, however the - /// homeserverMUST at a minimum consider the users the requesting user - /// shares aroom with and those who reside in public rooms (known to the - /// homeserver).The search MUST consider local users to the homeserver, and - /// SHOULDquery remote users as part of the search.The search is performed - /// case-insensitively on user IDs and displaynames preferably using a - /// collation determined based upon the ``Accept-Language`` header provided - /// in the request, if present. - struct User - { + /// Performs a search for users on the homeserver. The homeserver may + /// determine which subset of users are searched, however the homeserver + /// MUST at a minimum consider the users the requesting user shares a + /// room with and those who reside in public rooms (known to the + /// homeserver). The search MUST consider local users to the homeserver, and + /// SHOULD query remote users as part of the search. + /// + /// 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. + struct User { /// The user's matrix user ID. QString userId; /// The display name of the user, if one exists. @@ -54,7 +52,8 @@ public: // Construction/destruction - /*! Searches the user directory. + /*! \brief Searches the user directory. + * * \param searchTerm * The term to search for * \param limit @@ -69,6 +68,7 @@ public: /// Ordered by rank and then whether or not profile info is available. const QVector& results() const; + /// Indicates if the result list has been truncated by the limit. bool limited() const; diff --git a/lib/csapi/versions.cpp b/lib/csapi/versions.cpp index 9607a1b6..8cce03b9 100644 --- a/lib/csapi/versions.cpp +++ b/lib/csapi/versions.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client"); -class GetVersionsJob::Private -{ +class GetVersionsJob::Private { public: QStringList versions; QHash unstableFeatures; @@ -24,10 +23,9 @@ QUrl GetVersionsJob::makeRequestUrl(QUrl baseUrl) return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/versions"); } -static const auto GetVersionsJobName = QStringLiteral("GetVersionsJob"); - GetVersionsJob::GetVersionsJob() - : BaseJob(HttpVerb::Get, GetVersionsJobName, basePath % "/versions", false) + : BaseJob(HttpVerb::Get, QStringLiteral("GetVersionsJob"), + basePath % "/versions", false) , d(new Private) {} diff --git a/lib/csapi/versions.h b/lib/csapi/versions.h index aa8cbac6..4c4f8109 100644 --- a/lib/csapi/versions.h +++ b/lib/csapi/versions.h @@ -10,13 +10,12 @@ #include -namespace Quotient -{ +namespace Quotient { // Operations -/// Gets the versions of the specification supported by the server. -/*! +/*! \brief Gets the versions of the specification supported by the server. + * * Gets the versions of the specification supported by the server. * * Values will take the form ``rX.Y.Z``. @@ -38,25 +37,24 @@ namespace Quotient * upgrade appropriately. Additionally, clients should avoid using unstable * features in their stable releases. */ -class GetVersionsJob : public BaseJob -{ +class GetVersionsJob : public BaseJob { public: + /// Gets the versions of the specification supported by the server. explicit GetVersionsJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetVersionsJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetVersionsJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetVersionsJob() override; // Result properties /// The supported versions. const QStringList& versions() const; + /// Experimental features the server supports. Features not listed here, /// or the lack of this property all together, indicate that a feature is /// not supported. diff --git a/lib/csapi/voip.cpp b/lib/csapi/voip.cpp index c95afe16..c98824b3 100644 --- a/lib/csapi/voip.cpp +++ b/lib/csapi/voip.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class GetTurnServerJob::Private -{ +class GetTurnServerJob::Private { public: QJsonObject data; }; @@ -24,10 +23,9 @@ QUrl GetTurnServerJob::makeRequestUrl(QUrl baseUrl) basePath % "/voip/turnServer"); } -static const auto GetTurnServerJobName = QStringLiteral("GetTurnServerJob"); - GetTurnServerJob::GetTurnServerJob() - : BaseJob(HttpVerb::Get, GetTurnServerJobName, basePath % "/voip/turnServer") + : BaseJob(HttpVerb::Get, QStringLiteral("GetTurnServerJob"), + basePath % "/voip/turnServer") , d(new Private) {} @@ -38,5 +36,6 @@ const QJsonObject& GetTurnServerJob::data() const { return d->data; } BaseJob::Status GetTurnServerJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } diff --git a/lib/csapi/voip.h b/lib/csapi/voip.h index 38abfa27..d3eb3c4b 100644 --- a/lib/csapi/voip.h +++ b/lib/csapi/voip.h @@ -8,29 +8,26 @@ #include -namespace Quotient -{ +namespace Quotient { // Operations -/// Obtain TURN server credentials. -/*! +/*! \brief Obtain TURN server credentials. + * * This API provides credentials for the client to use when initiating * calls. */ -class GetTurnServerJob : public BaseJob -{ +class GetTurnServerJob : public BaseJob { public: + /// Obtain TURN server credentials. explicit GetTurnServerJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetTurnServerJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetTurnServerJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetTurnServerJob() override; // Result properties diff --git a/lib/csapi/wellknown.cpp b/lib/csapi/wellknown.cpp index 9a52a2a5..464068e7 100644 --- a/lib/csapi/wellknown.cpp +++ b/lib/csapi/wellknown.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/.well-known"); -class GetWellknownJob::Private -{ +class GetWellknownJob::Private { public: DiscoveryInformation data; }; @@ -24,11 +23,9 @@ QUrl GetWellknownJob::makeRequestUrl(QUrl baseUrl) basePath % "/matrix/client"); } -static const auto GetWellknownJobName = QStringLiteral("GetWellknownJob"); - GetWellknownJob::GetWellknownJob() - : BaseJob(HttpVerb::Get, GetWellknownJobName, basePath % "/matrix/client", - false) + : BaseJob(HttpVerb::Get, QStringLiteral("GetWellknownJob"), + basePath % "/matrix/client", false) , d(new Private) {} @@ -39,5 +36,6 @@ const DiscoveryInformation& GetWellknownJob::data() const { return d->data; } BaseJob::Status GetWellknownJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } diff --git a/lib/csapi/wellknown.h b/lib/csapi/wellknown.h index bce67d00..94d3631c 100644 --- a/lib/csapi/wellknown.h +++ b/lib/csapi/wellknown.h @@ -10,13 +10,12 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Gets Matrix server discovery information about the domain. -/*! +/*! \brief Gets Matrix server discovery information about the domain. + * * Gets discovery information about the domain. The file may include * additional keys, which MUST follow the Java package naming convention, * e.g. ``com.example.myapp.property``. This ensures property names are @@ -26,19 +25,17 @@ 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 GetWellknownJob : public BaseJob -{ +class GetWellknownJob : public BaseJob { public: + /// Gets Matrix server discovery information about the domain. explicit GetWellknownJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetWellknownJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetWellknownJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetWellknownJob() override; // Result properties diff --git a/lib/csapi/whoami.cpp b/lib/csapi/whoami.cpp index fb7f54dc..8d4681e4 100644 --- a/lib/csapi/whoami.cpp +++ b/lib/csapi/whoami.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class GetTokenOwnerJob::Private -{ +class GetTokenOwnerJob::Private { public: QString userId; }; @@ -24,10 +23,9 @@ QUrl GetTokenOwnerJob::makeRequestUrl(QUrl baseUrl) basePath % "/account/whoami"); } -static const auto GetTokenOwnerJobName = QStringLiteral("GetTokenOwnerJob"); - GetTokenOwnerJob::GetTokenOwnerJob() - : BaseJob(HttpVerb::Get, GetTokenOwnerJobName, basePath % "/account/whoami") + : BaseJob(HttpVerb::Get, QStringLiteral("GetTokenOwnerJob"), + basePath % "/account/whoami") , d(new Private) {} diff --git a/lib/csapi/whoami.h b/lib/csapi/whoami.h index bbbb3899..dda8d8c8 100644 --- a/lib/csapi/whoami.h +++ b/lib/csapi/whoami.h @@ -6,13 +6,12 @@ #include "jobs/basejob.h" -namespace Quotient -{ +namespace Quotient { // Operations -/// Gets information about the owner of an access token. -/*! +/*! \brief Gets information about the owner of an access token. + * * Gets information about the owner of a given access token. * * Note that, as with the rest of the Client-Server API, @@ -22,19 +21,17 @@ namespace Quotient * is registered by the appservice, and return it in the response * body. */ -class GetTokenOwnerJob : public BaseJob -{ +class GetTokenOwnerJob : public BaseJob { public: + /// Gets information about the owner of an access token. explicit GetTokenOwnerJob(); - /*! Construct a URL without creating a full-fledged job object + /*! \brief Construct a URL without creating a full-fledged job object * - * This function can be used when a URL for - * GetTokenOwnerJob is necessary but the job - * itself isn't. + * This function can be used when a URL for GetTokenOwnerJob + * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetTokenOwnerJob() override; // Result properties diff --git a/lib/identity/definitions/request_email_validation.h b/lib/identity/definitions/request_email_validation.h index 99487073..32c6eaaf 100644 --- a/lib/identity/definitions/request_email_validation.h +++ b/lib/identity/definitions/request_email_validation.h @@ -6,35 +6,36 @@ #include "converters.h" -namespace Quotient -{ +namespace Quotient { // Data structures -struct RequestEmailValidation -{ - /// A unique string generated by the client, and used to identify - /// thevalidation attempt. It must be a string consisting of the - /// characters``[0-9a-zA-Z.=_-]``. Its length must not exceed 255 characters - /// and itmust not be empty. +struct RequestEmailValidation { + /// 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 + /// must not be empty. QString clientSecret; + /// The email address to validate. QString 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,scoped to that - /// ``email`` + ``client_secret`` pair. This is toavoid repeatedly sending - /// the same email in the case of requestretries between the POSTing user - /// and the identity server.The client should increment this value if they - /// desire a newemail (e.g. a reminder) to be sent. + + /// The server will only send an email if the ``send_attempt`` + /// is a number greater than the most recent one which it has seen, + /// scoped to that ``email`` + ``client_secret`` pair. This is to + /// avoid repeatedly sending the same email in the case of request + /// retries between the POSTing user and the identity server. + /// The client should increment this value if they desire a new + /// email (e.g. a reminder) to be sent. int sendAttempt; - /// Optional. When the validation is completed, the identityserver will - /// redirect the user to this URL. + + /// Optional. When the validation is completed, the identity + /// server will redirect the user to this URL. QString nextLink; }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const RequestEmailValidation& pod); static void fillFrom(const QJsonObject& jo, RequestEmailValidation& pod); }; diff --git a/lib/identity/definitions/request_msisdn_validation.h b/lib/identity/definitions/request_msisdn_validation.h index ecccf567..90aed7b8 100644 --- a/lib/identity/definitions/request_msisdn_validation.h +++ b/lib/identity/definitions/request_msisdn_validation.h @@ -6,39 +6,40 @@ #include "converters.h" -namespace Quotient -{ +namespace Quotient { // Data structures -struct RequestMsisdnValidation -{ - /// A unique string generated by the client, and used to identify - /// thevalidation attempt. It must be a string consisting of the - /// characters``[0-9a-zA-Z.=_-]``. Its length must not exceed 255 characters - /// and itmust not be empty. +struct RequestMsisdnValidation { + /// 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 + /// must not be empty. QString clientSecret; - /// The two-letter uppercase ISO country code that the number - /// in``phone_number`` should be parsed as if it were dialled from. + + /// The two-letter uppercase ISO country code that the number in + /// ``phone_number`` should be parsed as if it were dialled from. QString country; + /// The phone number to validate. QString phoneNumber; - /// The server will only send an SMS if the ``send_attempt`` is anumber - /// greater than the most recent one which it has seen,scoped to that - /// ``country`` + ``phone_number`` + ``client_secret``triple. This is to - /// avoid repeatedly sending the same SMS inthe case of request retries - /// between the POSTing user and theidentity server. The client should - /// increment this value ifthey desire a new SMS (e.g. a reminder) to be - /// sent. + + /// The server will only send an SMS if the ``send_attempt`` is a + /// number greater than the most recent one which it has seen, + /// scoped to that ``country`` + ``phone_number`` + ``client_secret`` + /// triple. This is to avoid repeatedly sending the same SMS in + /// the case of request retries between the POSTing user and the + /// identity server. The client should increment this value if + /// they desire a new SMS (e.g. a reminder) to be sent. int sendAttempt; - /// Optional. When the validation is completed, the identityserver will - /// redirect the user to this URL. + + /// Optional. When the validation is completed, the identity + /// server will redirect the user to this URL. QString nextLink; }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const RequestMsisdnValidation& pod); static void fillFrom(const QJsonObject& jo, RequestMsisdnValidation& pod); }; diff --git a/lib/identity/definitions/sid.h b/lib/identity/definitions/sid.h index 0f7ce58a..981826f6 100644 --- a/lib/identity/definitions/sid.h +++ b/lib/identity/definitions/sid.h @@ -6,23 +6,20 @@ #include "converters.h" -namespace Quotient -{ +namespace Quotient { // Data structures -struct Sid -{ - /// The session ID. Session IDs are opaque strings generated by the - /// identityserver. They must consist entirely of the - /// characters``[0-9a-zA-Z.=_-]``. Their length must not exceed 255 - /// characters and theymust not be empty. +struct Sid { + /// The session ID. Session IDs are opaque strings generated by the identity + /// server. They must consist entirely of the characters + /// ``[0-9a-zA-Z.=_-]``. Their length must not exceed 255 characters and + /// they must not be empty. QString sid; }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const Sid& pod); static void fillFrom(const QJsonObject& jo, Sid& pod); }; -- cgit v1.2.3 From 32729d9a7519cd2c4cddb0174b8329c6fd4a4a83 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 7 Jun 2020 19:46:40 +0200 Subject: Update generated files according to gtad/* changes --- lib/application-service/definitions/location.cpp | 23 -- lib/application-service/definitions/location.h | 18 +- lib/application-service/definitions/protocol.cpp | 59 --- lib/application-service/definitions/protocol.h | 53 ++- lib/application-service/definitions/user.cpp | 23 -- lib/application-service/definitions/user.h | 18 +- lib/csapi/account-data.cpp | 27 +- lib/csapi/account-data.h | 16 +- lib/csapi/admin.cpp | 66 +--- lib/csapi/admin.h | 48 ++- lib/csapi/administrative_contact.cpp | 174 +++------ lib/csapi/administrative_contact.h | 332 ++++++++++------ lib/csapi/appservice_room_directory.cpp | 9 +- lib/csapi/appservice_room_directory.h | 5 +- lib/csapi/banning.cpp | 13 +- lib/csapi/banning.h | 7 +- lib/csapi/capabilities.cpp | 68 +--- lib/csapi/capabilities.h | 46 ++- lib/csapi/content-repo.cpp | 198 ++-------- lib/csapi/content-repo.h | 166 ++++---- lib/csapi/create_room.cpp | 55 +-- lib/csapi/create_room.h | 118 ++++-- lib/csapi/definitions/auth_data.cpp | 23 -- lib/csapi/definitions/auth_data.h | 20 +- lib/csapi/definitions/client_device.cpp | 23 -- lib/csapi/definitions/client_device.h | 20 +- lib/csapi/definitions/device_keys.cpp | 27 -- lib/csapi/definitions/device_keys.h | 23 +- lib/csapi/definitions/event_filter.cpp | 27 -- lib/csapi/definitions/event_filter.h | 20 +- lib/csapi/definitions/openid_token.h | 48 +++ lib/csapi/definitions/public_rooms_response.cpp | 56 --- lib/csapi/definitions/public_rooms_response.h | 51 ++- lib/csapi/definitions/push_condition.cpp | 25 -- lib/csapi/definitions/push_condition.h | 25 +- lib/csapi/definitions/push_rule.cpp | 28 -- lib/csapi/definitions/push_rule.h | 26 +- lib/csapi/definitions/push_ruleset.cpp | 27 -- lib/csapi/definitions/push_ruleset.h | 22 +- lib/csapi/definitions/request_email_validation.h | 48 +++ lib/csapi/definitions/request_msisdn_validation.h | 48 +++ lib/csapi/definitions/request_token_response.h | 45 +++ lib/csapi/definitions/room_event_filter.cpp | 25 -- lib/csapi/definitions/room_event_filter.h | 38 +- lib/csapi/definitions/sync_filter.cpp | 68 ---- lib/csapi/definitions/sync_filter.h | 97 ++--- lib/csapi/definitions/third_party_signed.h | 44 +++ lib/csapi/definitions/user_identifier.cpp | 21 - lib/csapi/definitions/user_identifier.h | 17 +- lib/csapi/definitions/wellknown/full.cpp | 24 -- lib/csapi/definitions/wellknown/full.h | 21 +- lib/csapi/definitions/wellknown/homeserver.cpp | 19 - lib/csapi/definitions/wellknown/homeserver.h | 13 +- .../definitions/wellknown/identity_server.cpp | 19 - lib/csapi/definitions/wellknown/identity_server.h | 13 +- lib/csapi/device_management.cpp | 62 +-- lib/csapi/device_management.h | 36 +- lib/csapi/directory.cpp | 59 ++- lib/csapi/directory.h | 74 +++- lib/csapi/event_context.cpp | 67 +--- lib/csapi/event_context.h | 52 ++- lib/csapi/filter.cpp | 55 +-- lib/csapi/filter.h | 35 +- lib/csapi/inviting.cpp | 9 +- lib/csapi/inviting.h | 4 +- lib/csapi/joining.cpp | 100 +---- lib/csapi/joining.h | 121 ++---- lib/csapi/keys.cpp | 153 +------- lib/csapi/keys.h | 112 +++--- lib/csapi/kicking.cpp | 8 +- lib/csapi/kicking.h | 5 +- lib/csapi/leaving.cpp | 16 +- lib/csapi/leaving.h | 4 +- lib/csapi/list_joined_rooms.cpp | 33 +- lib/csapi/list_joined_rooms.h | 15 +- lib/csapi/list_public_rooms.cpp | 104 +---- lib/csapi/list_public_rooms.h | 124 ++++-- lib/csapi/login.cpp | 94 +---- lib/csapi/login.h | 83 ++-- lib/csapi/logout.cpp | 17 +- lib/csapi/logout.h | 9 +- lib/csapi/message_pagination.cpp | 47 +-- lib/csapi/message_pagination.h | 41 +- lib/csapi/notifications.cpp | 61 +-- lib/csapi/notifications.h | 38 +- lib/csapi/openid.cpp | 55 +-- lib/csapi/openid.h | 38 +- lib/csapi/peeking_events.cpp | 41 +- lib/csapi/peeking_events.h | 21 +- lib/csapi/presence.cpp | 54 +-- lib/csapi/presence.h | 30 +- lib/csapi/profile.cpp | 97 +---- lib/csapi/profile.h | 47 +-- lib/csapi/pusher.cpp | 79 +--- lib/csapi/pusher.h | 58 ++- lib/csapi/pushrules.cpp | 143 ++----- lib/csapi/pushrules.h | 90 +++-- lib/csapi/read_markers.cpp | 9 +- lib/csapi/read_markers.h | 5 +- lib/csapi/receipts.cpp | 8 +- lib/csapi/receipts.h | 8 +- lib/csapi/redaction.cpp | 27 +- lib/csapi/redaction.h | 23 +- lib/csapi/registration.cpp | 233 ++--------- lib/csapi/registration.h | 428 ++++++++++----------- lib/csapi/report_content.cpp | 9 +- lib/csapi/report_content.h | 8 +- lib/csapi/room_send.cpp | 26 +- lib/csapi/room_send.h | 19 +- lib/csapi/room_state.cpp | 53 +-- lib/csapi/room_state.h | 96 ++--- lib/csapi/room_upgrades.cpp | 34 +- lib/csapi/room_upgrades.h | 18 +- lib/csapi/rooms.cpp | 158 ++------ lib/csapi/rooms.h | 129 +++---- lib/csapi/sso_login_redirect.cpp | 12 +- lib/csapi/sso_login_redirect.h | 3 +- lib/csapi/tags.cpp | 65 +--- lib/csapi/tags.h | 42 +- lib/csapi/third_party_lookup.cpp | 166 ++------ lib/csapi/third_party_lookup.h | 92 ++--- lib/csapi/third_party_membership.cpp | 11 +- lib/csapi/third_party_membership.h | 21 +- lib/csapi/to_device.cpp | 9 +- lib/csapi/to_device.h | 8 +- lib/csapi/typing.cpp | 9 +- lib/csapi/typing.h | 8 +- lib/csapi/users.cpp | 57 +-- lib/csapi/users.h | 42 +- lib/csapi/versions.cpp | 38 +- lib/csapi/versions.h | 24 +- lib/csapi/voip.cpp | 26 +- lib/csapi/voip.h | 14 +- lib/csapi/wellknown.cpp | 26 +- lib/csapi/wellknown.h | 17 +- lib/csapi/whoami.cpp | 30 +- lib/csapi/whoami.h | 12 +- .../definitions/request_email_validation.cpp | 25 -- .../definitions/request_email_validation.h | 26 +- .../definitions/request_msisdn_validation.cpp | 27 -- .../definitions/request_msisdn_validation.h | 29 +- lib/identity/definitions/sid.cpp | 17 - lib/identity/definitions/sid.h | 27 -- 143 files changed, 2564 insertions(+), 4594 deletions(-) delete mode 100644 lib/application-service/definitions/location.cpp delete mode 100644 lib/application-service/definitions/protocol.cpp delete mode 100644 lib/application-service/definitions/user.cpp delete mode 100644 lib/csapi/definitions/auth_data.cpp delete mode 100644 lib/csapi/definitions/client_device.cpp delete mode 100644 lib/csapi/definitions/device_keys.cpp delete mode 100644 lib/csapi/definitions/event_filter.cpp create mode 100644 lib/csapi/definitions/openid_token.h delete mode 100644 lib/csapi/definitions/public_rooms_response.cpp delete mode 100644 lib/csapi/definitions/push_condition.cpp delete mode 100644 lib/csapi/definitions/push_rule.cpp delete mode 100644 lib/csapi/definitions/push_ruleset.cpp create mode 100644 lib/csapi/definitions/request_email_validation.h create mode 100644 lib/csapi/definitions/request_msisdn_validation.h create mode 100644 lib/csapi/definitions/request_token_response.h delete mode 100644 lib/csapi/definitions/room_event_filter.cpp delete mode 100644 lib/csapi/definitions/sync_filter.cpp create mode 100644 lib/csapi/definitions/third_party_signed.h delete mode 100644 lib/csapi/definitions/user_identifier.cpp delete mode 100644 lib/csapi/definitions/wellknown/full.cpp delete mode 100644 lib/csapi/definitions/wellknown/homeserver.cpp delete mode 100644 lib/csapi/definitions/wellknown/identity_server.cpp delete mode 100644 lib/identity/definitions/request_email_validation.cpp delete mode 100644 lib/identity/definitions/request_msisdn_validation.cpp delete mode 100644 lib/identity/definitions/sid.cpp delete mode 100644 lib/identity/definitions/sid.h (limited to 'lib/application-service') diff --git a/lib/application-service/definitions/location.cpp b/lib/application-service/definitions/location.cpp deleted file mode 100644 index 0a054029..00000000 --- a/lib/application-service/definitions/location.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "location.h" - -using namespace Quotient; - -void JsonObjectConverter::dumpTo( - QJsonObject& jo, const ThirdPartyLocation& pod) -{ - addParam<>(jo, QStringLiteral("alias"), pod.alias); - addParam<>(jo, QStringLiteral("protocol"), pod.protocol); - addParam<>(jo, QStringLiteral("fields"), pod.fields); -} - -void JsonObjectConverter::fillFrom(const QJsonObject& jo, - ThirdPartyLocation& result) -{ - fromJson(jo.value("alias"_ls), result.alias); - fromJson(jo.value("protocol"_ls), result.protocol); - fromJson(jo.value("fields"_ls), result.fields); -} diff --git a/lib/application-service/definitions/location.h b/lib/application-service/definitions/location.h index e4c2d096..6801c99f 100644 --- a/lib/application-service/definitions/location.h +++ b/lib/application-service/definitions/location.h @@ -6,12 +6,8 @@ #include "converters.h" -#include - namespace Quotient { -// Data structures - struct ThirdPartyLocation { /// An alias for a matrix room. QString alias; @@ -25,8 +21,18 @@ struct ThirdPartyLocation { template <> struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const ThirdPartyLocation& pod); - static void fillFrom(const QJsonObject& jo, ThirdPartyLocation& pod); + static void dumpTo(QJsonObject& jo, const ThirdPartyLocation& pod) + { + addParam<>(jo, QStringLiteral("alias"), pod.alias); + addParam<>(jo, QStringLiteral("protocol"), pod.protocol); + addParam<>(jo, QStringLiteral("fields"), pod.fields); + } + static void fillFrom(const QJsonObject& jo, ThirdPartyLocation& pod) + { + fromJson(jo.value("alias"_ls), pod.alias); + fromJson(jo.value("protocol"_ls), pod.protocol); + fromJson(jo.value("fields"_ls), pod.fields); + } }; } // namespace Quotient diff --git a/lib/application-service/definitions/protocol.cpp b/lib/application-service/definitions/protocol.cpp deleted file mode 100644 index 8c66aa4d..00000000 --- a/lib/application-service/definitions/protocol.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "protocol.h" - -using namespace Quotient; - -void JsonObjectConverter::dumpTo(QJsonObject& jo, - const FieldType& pod) -{ - addParam<>(jo, QStringLiteral("regexp"), pod.regexp); - addParam<>(jo, QStringLiteral("placeholder"), pod.placeholder); -} - -void JsonObjectConverter::fillFrom(const QJsonObject& jo, - FieldType& result) -{ - fromJson(jo.value("regexp"_ls), result.regexp); - fromJson(jo.value("placeholder"_ls), result.placeholder); -} - -void JsonObjectConverter::dumpTo(QJsonObject& jo, - const ProtocolInstance& pod) -{ - addParam<>(jo, QStringLiteral("desc"), pod.desc); - addParam(jo, QStringLiteral("icon"), pod.icon); - addParam<>(jo, QStringLiteral("fields"), pod.fields); - addParam<>(jo, QStringLiteral("network_id"), pod.networkId); -} - -void JsonObjectConverter::fillFrom(const QJsonObject& jo, - ProtocolInstance& result) -{ - fromJson(jo.value("desc"_ls), result.desc); - fromJson(jo.value("icon"_ls), result.icon); - fromJson(jo.value("fields"_ls), result.fields); - fromJson(jo.value("network_id"_ls), result.networkId); -} - -void JsonObjectConverter::dumpTo( - QJsonObject& jo, const ThirdPartyProtocol& pod) -{ - addParam<>(jo, QStringLiteral("user_fields"), pod.userFields); - addParam<>(jo, QStringLiteral("location_fields"), pod.locationFields); - addParam<>(jo, QStringLiteral("icon"), pod.icon); - addParam<>(jo, QStringLiteral("field_types"), pod.fieldTypes); - addParam<>(jo, QStringLiteral("instances"), pod.instances); -} - -void JsonObjectConverter::fillFrom(const QJsonObject& jo, - ThirdPartyProtocol& result) -{ - fromJson(jo.value("user_fields"_ls), result.userFields); - fromJson(jo.value("location_fields"_ls), result.locationFields); - fromJson(jo.value("icon"_ls), result.icon); - fromJson(jo.value("field_types"_ls), result.fieldTypes); - fromJson(jo.value("instances"_ls), result.instances); -} diff --git a/lib/application-service/definitions/protocol.h b/lib/application-service/definitions/protocol.h index ac1e50e2..6aee9c57 100644 --- a/lib/application-service/definitions/protocol.h +++ b/lib/application-service/definitions/protocol.h @@ -6,14 +6,7 @@ #include "converters.h" -#include -#include -#include - namespace Quotient { - -// Data structures - /// Definition of valid values for a field. struct FieldType { /// A regular expression for validation of a field's value. This may be @@ -27,8 +20,16 @@ struct FieldType { template <> struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const FieldType& pod); - static void fillFrom(const QJsonObject& jo, FieldType& pod); + static void dumpTo(QJsonObject& jo, const FieldType& pod) + { + addParam<>(jo, QStringLiteral("regexp"), pod.regexp); + addParam<>(jo, QStringLiteral("placeholder"), pod.placeholder); + } + static void fillFrom(const QJsonObject& jo, FieldType& pod) + { + fromJson(jo.value("regexp"_ls), pod.regexp); + fromJson(jo.value("placeholder"_ls), pod.placeholder); + } }; struct ProtocolInstance { @@ -48,8 +49,20 @@ struct ProtocolInstance { template <> struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const ProtocolInstance& pod); - static void fillFrom(const QJsonObject& jo, ProtocolInstance& pod); + static void dumpTo(QJsonObject& jo, const ProtocolInstance& pod) + { + addParam<>(jo, QStringLiteral("desc"), pod.desc); + addParam(jo, QStringLiteral("icon"), pod.icon); + addParam<>(jo, QStringLiteral("fields"), pod.fields); + addParam<>(jo, QStringLiteral("network_id"), pod.networkId); + } + static void fillFrom(const QJsonObject& jo, ProtocolInstance& pod) + { + fromJson(jo.value("desc"_ls), pod.desc); + fromJson(jo.value("icon"_ls), pod.icon); + fromJson(jo.value("fields"_ls), pod.fields); + fromJson(jo.value("network_id"_ls), pod.networkId); + } }; struct ThirdPartyProtocol { @@ -84,8 +97,22 @@ struct ThirdPartyProtocol { template <> struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const ThirdPartyProtocol& pod); - static void fillFrom(const QJsonObject& jo, ThirdPartyProtocol& pod); + static void dumpTo(QJsonObject& jo, const ThirdPartyProtocol& pod) + { + addParam<>(jo, QStringLiteral("user_fields"), pod.userFields); + addParam<>(jo, QStringLiteral("location_fields"), pod.locationFields); + addParam<>(jo, QStringLiteral("icon"), pod.icon); + addParam<>(jo, QStringLiteral("field_types"), pod.fieldTypes); + addParam<>(jo, QStringLiteral("instances"), pod.instances); + } + static void fillFrom(const QJsonObject& jo, ThirdPartyProtocol& pod) + { + fromJson(jo.value("user_fields"_ls), pod.userFields); + fromJson(jo.value("location_fields"_ls), pod.locationFields); + fromJson(jo.value("icon"_ls), pod.icon); + fromJson(jo.value("field_types"_ls), pod.fieldTypes); + fromJson(jo.value("instances"_ls), pod.instances); + } }; } // namespace Quotient diff --git a/lib/application-service/definitions/user.cpp b/lib/application-service/definitions/user.cpp deleted file mode 100644 index 17d15a20..00000000 --- a/lib/application-service/definitions/user.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "user.h" - -using namespace Quotient; - -void JsonObjectConverter::dumpTo(QJsonObject& jo, - const ThirdPartyUser& pod) -{ - addParam<>(jo, QStringLiteral("userid"), pod.userid); - addParam<>(jo, QStringLiteral("protocol"), pod.protocol); - addParam<>(jo, QStringLiteral("fields"), pod.fields); -} - -void JsonObjectConverter::fillFrom(const QJsonObject& jo, - ThirdPartyUser& result) -{ - fromJson(jo.value("userid"_ls), result.userid); - fromJson(jo.value("protocol"_ls), result.protocol); - fromJson(jo.value("fields"_ls), result.fields); -} diff --git a/lib/application-service/definitions/user.h b/lib/application-service/definitions/user.h index 0d1984b6..3342ef80 100644 --- a/lib/application-service/definitions/user.h +++ b/lib/application-service/definitions/user.h @@ -6,12 +6,8 @@ #include "converters.h" -#include - namespace Quotient { -// Data structures - struct ThirdPartyUser { /// A Matrix User ID represting a third party user. QString userid; @@ -25,8 +21,18 @@ struct ThirdPartyUser { template <> struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const ThirdPartyUser& pod); - static void fillFrom(const QJsonObject& jo, ThirdPartyUser& pod); + static void dumpTo(QJsonObject& jo, const ThirdPartyUser& pod) + { + addParam<>(jo, QStringLiteral("userid"), pod.userid); + addParam<>(jo, QStringLiteral("protocol"), pod.protocol); + addParam<>(jo, QStringLiteral("fields"), pod.fields); + } + static void fillFrom(const QJsonObject& jo, ThirdPartyUser& pod) + { + fromJson(jo.value("userid"_ls), pod.userid); + fromJson(jo.value("protocol"_ls), pod.protocol); + fromJson(jo.value("fields"_ls), pod.fields); + } }; } // namespace Quotient diff --git a/lib/csapi/account-data.cpp b/lib/csapi/account-data.cpp index b7825718..6a40e908 100644 --- a/lib/csapi/account-data.cpp +++ b/lib/csapi/account-data.cpp @@ -4,18 +4,15 @@ #include "account-data.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - SetAccountDataJob::SetAccountDataJob(const QString& userId, const QString& type, const QJsonObject& content) : BaseJob(HttpVerb::Put, QStringLiteral("SetAccountDataJob"), - basePath % "/user/" % userId % "/account_data/" % type) + QStringLiteral("/_matrix/client/r0") % "/user/" % userId + % "/account_data/" % type) { setRequestData(Data(toJson(content))); } @@ -24,13 +21,14 @@ QUrl GetAccountDataJob::makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& type) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/user/" % userId - % "/account_data/" % type); + QStringLiteral("/_matrix/client/r0") % "/user/" + % userId % "/account_data/" % type); } GetAccountDataJob::GetAccountDataJob(const QString& userId, const QString& type) : BaseJob(HttpVerb::Get, QStringLiteral("GetAccountDataJob"), - basePath % "/user/" % userId % "/account_data/" % type) + QStringLiteral("/_matrix/client/r0") % "/user/" % userId + % "/account_data/" % type) {} SetAccountDataPerRoomJob::SetAccountDataPerRoomJob(const QString& userId, @@ -38,8 +36,8 @@ SetAccountDataPerRoomJob::SetAccountDataPerRoomJob(const QString& userId, const QString& type, const QJsonObject& content) : BaseJob(HttpVerb::Put, QStringLiteral("SetAccountDataPerRoomJob"), - basePath % "/user/" % userId % "/rooms/" % roomId - % "/account_data/" % type) + QStringLiteral("/_matrix/client/r0") % "/user/" % userId + % "/rooms/" % roomId % "/account_data/" % type) { setRequestData(Data(toJson(content))); } @@ -50,14 +48,15 @@ QUrl GetAccountDataPerRoomJob::makeRequestUrl(QUrl baseUrl, const QString& type) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/user/" % userId % "/rooms/" - % roomId % "/account_data/" % type); + QStringLiteral("/_matrix/client/r0") + % "/user/" % userId % "/rooms/" % roomId + % "/account_data/" % type); } GetAccountDataPerRoomJob::GetAccountDataPerRoomJob(const QString& userId, const QString& roomId, const QString& type) : BaseJob(HttpVerb::Get, QStringLiteral("GetAccountDataPerRoomJob"), - basePath % "/user/" % userId % "/rooms/" % roomId - % "/account_data/" % type) + QStringLiteral("/_matrix/client/r0") % "/user/" % userId + % "/rooms/" % roomId % "/account_data/" % type) {} diff --git a/lib/csapi/account-data.h b/lib/csapi/account-data.h index a8dba5c0..1c7b555b 100644 --- a/lib/csapi/account-data.h +++ b/lib/csapi/account-data.h @@ -6,12 +6,8 @@ #include "jobs/basejob.h" -#include - namespace Quotient { -// Operations - /*! \brief Set some account_data for the user. * * Set some account_data for the client. This config is only visible to the user @@ -21,13 +17,16 @@ namespace Quotient { class SetAccountDataJob : public BaseJob { public: /*! \brief Set some account_data for the user. + * * * \param userId * The ID of the user to set account_data for. The access token must be * authorized to make requests for this user ID. + * * \param type * The event type of the account_data to set. Custom types should be * namespaced to avoid clashes. + * * \param content * The content of the account_data */ @@ -43,10 +42,12 @@ public: class GetAccountDataJob : public BaseJob { public: /*! \brief Get some account_data for the user. + * * * \param userId * The ID of the user to get account_data for. The access token must be * authorized to make requests for this user ID. + * * \param type * The event type of the account_data to get. Custom types should be * namespaced to avoid clashes. @@ -71,15 +72,19 @@ public: class SetAccountDataPerRoomJob : public BaseJob { public: /*! \brief Set some account_data for the user. + * * * \param userId * The ID of the user to set account_data for. The access token must be * authorized to make requests for this user ID. + * * \param roomId * The ID of the room to set account_data on. + * * \param type * The event type of the account_data to set. Custom types should be * namespaced to avoid clashes. + * * \param content * The content of the account_data */ @@ -96,12 +101,15 @@ public: class GetAccountDataPerRoomJob : public BaseJob { public: /*! \brief Get some account_data for the user. + * * * \param userId * The ID of the user to set account_data for. The access token must be * authorized to make requests for this user ID. + * * \param roomId * The ID of the room to get account_data for. + * * \param type * The event type of the account_data to get. Custom types should be * namespaced to avoid clashes. diff --git a/lib/csapi/admin.cpp b/lib/csapi/admin.cpp index 14173e94..9619c441 100644 --- a/lib/csapi/admin.cpp +++ b/lib/csapi/admin.cpp @@ -4,78 +4,18 @@ #include "admin.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -// Converters -namespace Quotient { - -template <> -struct JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, - GetWhoIsJob::ConnectionInfo& result) - { - fromJson(jo.value("ip"_ls), result.ip); - fromJson(jo.value("last_seen"_ls), result.lastSeen); - fromJson(jo.value("user_agent"_ls), result.userAgent); - } -}; - -template <> -struct JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, GetWhoIsJob::SessionInfo& result) - { - fromJson(jo.value("connections"_ls), result.connections); - } -}; - -template <> -struct JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, GetWhoIsJob::DeviceInfo& result) - { - fromJson(jo.value("sessions"_ls), result.sessions); - } -}; - -} // namespace Quotient - -class GetWhoIsJob::Private { -public: - QString userId; - QHash devices; -}; - QUrl GetWhoIsJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/admin/whois/" % userId); + QStringLiteral("/_matrix/client/r0") + % "/admin/whois/" % userId); } GetWhoIsJob::GetWhoIsJob(const QString& userId) : BaseJob(HttpVerb::Get, QStringLiteral("GetWhoIsJob"), - basePath % "/admin/whois/" % userId) - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/admin/whois/" % userId) {} - -GetWhoIsJob::~GetWhoIsJob() = default; - -const QString& GetWhoIsJob::userId() const { return d->userId; } - -const QHash& GetWhoIsJob::devices() const -{ - return d->devices; -} - -BaseJob::Status GetWhoIsJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("user_id"_ls), d->userId); - fromJson(json.value("devices"_ls), d->devices); - - return Success; -} diff --git a/lib/csapi/admin.h b/lib/csapi/admin.h index 75ae1eb0..6ad7d08d 100644 --- a/lib/csapi/admin.h +++ b/lib/csapi/admin.h @@ -4,17 +4,10 @@ #pragma once -#include "converters.h" - #include "jobs/basejob.h" -#include -#include - namespace Quotient { -// Operations - /*! \brief Gets information about a particular user. * * Gets information about a particular user. @@ -65,6 +58,7 @@ public: // Construction/destruction /*! \brief Gets information about a particular user. + * * * \param userId * The user to look up. @@ -77,22 +71,44 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId); - ~GetWhoIsJob() override; // Result properties /// The Matrix user ID of the user. - const QString& userId() const; + QString userId() const { return loadFromJson("user_id"_ls); } - /// Each key is an identitfier for one of the user's devices. - const QHash& devices() const; + /// Each key is an identifier for one of the user's devices. + QHash devices() const + { + return loadFromJson>("devices"_ls); + } +}; + +template <> +struct JsonObjectConverter { + static void fillFrom(const QJsonObject& jo, + GetWhoIsJob::ConnectionInfo& result) + { + fromJson(jo.value("ip"_ls), result.ip); + fromJson(jo.value("last_seen"_ls), result.lastSeen); + fromJson(jo.value("user_agent"_ls), result.userAgent); + } +}; -protected: - Status parseJson(const QJsonDocument& data) override; +template <> +struct JsonObjectConverter { + static void fillFrom(const QJsonObject& jo, GetWhoIsJob::SessionInfo& result) + { + fromJson(jo.value("connections"_ls), result.connections); + } +}; -private: - class Private; - QScopedPointer d; +template <> +struct JsonObjectConverter { + static void fillFrom(const QJsonObject& jo, GetWhoIsJob::DeviceInfo& result) + { + fromJson(jo.value("sessions"_ls), result.sessions); + } }; } // namespace Quotient diff --git a/lib/csapi/administrative_contact.cpp b/lib/csapi/administrative_contact.cpp index 36d93e73..fa4f475a 100644 --- a/lib/csapi/administrative_contact.cpp +++ b/lib/csapi/administrative_contact.cpp @@ -4,164 +4,100 @@ #include "administrative_contact.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -// Converters -namespace Quotient { - -template <> -struct JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, - GetAccount3PIDsJob::ThirdPartyIdentifier& result) - { - fromJson(jo.value("medium"_ls), result.medium); - fromJson(jo.value("address"_ls), result.address); - fromJson(jo.value("validated_at"_ls), result.validatedAt); - fromJson(jo.value("added_at"_ls), result.addedAt); - } -}; - -} // namespace Quotient - -class GetAccount3PIDsJob::Private { -public: - QVector threepids; -}; - QUrl GetAccount3PIDsJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/account/3pid"); + QStringLiteral("/_matrix/client/r0") + % "/account/3pid"); } GetAccount3PIDsJob::GetAccount3PIDsJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetAccount3PIDsJob"), - basePath % "/account/3pid") - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/account/3pid") {} -GetAccount3PIDsJob::~GetAccount3PIDsJob() = default; - -const QVector& -GetAccount3PIDsJob::threepids() const +Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds) + : BaseJob(HttpVerb::Post, QStringLiteral("Post3PIDsJob"), + QStringLiteral("/_matrix/client/r0") % "/account/3pid") { - return d->threepids; + QJsonObject _data; + addParam<>(_data, QStringLiteral("three_pid_creds"), threePidCreds); + setRequestData(std::move(_data)); } -BaseJob::Status GetAccount3PIDsJob::parseJson(const QJsonDocument& data) +Add3PIDJob::Add3PIDJob(const QString& clientSecret, const QString& sid, + const Omittable& auth) + : BaseJob(HttpVerb::Post, QStringLiteral("Add3PIDJob"), + QStringLiteral("/_matrix/client/r0") % "/account/3pid/add") { - auto json = data.object(); - fromJson(json.value("threepids"_ls), d->threepids); - - return Success; + QJsonObject _data; + addParam(_data, QStringLiteral("auth"), auth); + addParam<>(_data, QStringLiteral("client_secret"), clientSecret); + addParam<>(_data, QStringLiteral("sid"), sid); + setRequestData(std::move(_data)); } -// Converters -namespace Quotient { - -template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, - const Post3PIDsJob::ThreePidCredentials& pod) - { - addParam<>(jo, QStringLiteral("client_secret"), pod.clientSecret); - addParam<>(jo, QStringLiteral("id_server"), pod.idServer); - addParam<>(jo, QStringLiteral("sid"), pod.sid); - } -}; - -} // namespace Quotient - -Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds, - Omittable bind) - : BaseJob(HttpVerb::Post, QStringLiteral("Post3PIDsJob"), - basePath % "/account/3pid") +Bind3PIDJob::Bind3PIDJob(const QString& clientSecret, const QString& idServer, + const QString& idAccessToken, const QString& sid) + : BaseJob(HttpVerb::Post, QStringLiteral("Bind3PIDJob"), + QStringLiteral("/_matrix/client/r0") % "/account/3pid/bind") { QJsonObject _data; - addParam<>(_data, QStringLiteral("three_pid_creds"), threePidCreds); - addParam(_data, QStringLiteral("bind"), bind); - setRequestData(_data); + addParam<>(_data, QStringLiteral("client_secret"), clientSecret); + addParam<>(_data, QStringLiteral("id_server"), idServer); + addParam<>(_data, QStringLiteral("id_access_token"), idAccessToken); + addParam<>(_data, QStringLiteral("sid"), sid); + setRequestData(std::move(_data)); } Delete3pidFromAccountJob::Delete3pidFromAccountJob(const QString& medium, - const QString& address) + const QString& address, + const QString& idServer) : BaseJob(HttpVerb::Post, QStringLiteral("Delete3pidFromAccountJob"), - basePath % "/account/3pid/delete") + QStringLiteral("/_matrix/client/r0") % "/account/3pid/delete") { QJsonObject _data; + addParam(_data, QStringLiteral("id_server"), idServer); addParam<>(_data, QStringLiteral("medium"), medium); addParam<>(_data, QStringLiteral("address"), address); - setRequestData(_data); + setRequestData(std::move(_data)); + addExpectedKey("id_server_unbind_result"); } -class RequestTokenTo3PIDEmailJob::Private { -public: - Sid data; -}; - -RequestTokenTo3PIDEmailJob::RequestTokenTo3PIDEmailJob( - const QString& clientSecret, const QString& email, int sendAttempt, - const QString& idServer, const QString& nextLink) - : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenTo3PIDEmailJob"), - basePath % "/account/3pid/email/requestToken", false) - , d(new Private) +Unbind3pidFromAccountJob::Unbind3pidFromAccountJob(const QString& medium, + const QString& address, + const QString& idServer) + : BaseJob(HttpVerb::Post, QStringLiteral("Unbind3pidFromAccountJob"), + QStringLiteral("/_matrix/client/r0") % "/account/3pid/unbind") { QJsonObject _data; - addParam<>(_data, QStringLiteral("client_secret"), clientSecret); - addParam<>(_data, QStringLiteral("email"), email); - addParam<>(_data, QStringLiteral("send_attempt"), sendAttempt); - addParam(_data, QStringLiteral("next_link"), nextLink); - addParam<>(_data, QStringLiteral("id_server"), idServer); - setRequestData(_data); + addParam(_data, QStringLiteral("id_server"), idServer); + addParam<>(_data, QStringLiteral("medium"), medium); + addParam<>(_data, QStringLiteral("address"), address); + setRequestData(std::move(_data)); + addExpectedKey("id_server_unbind_result"); } -RequestTokenTo3PIDEmailJob::~RequestTokenTo3PIDEmailJob() = default; - -const Sid& RequestTokenTo3PIDEmailJob::data() const { return d->data; } - -BaseJob::Status RequestTokenTo3PIDEmailJob::parseJson(const QJsonDocument& data) +RequestTokenTo3PIDEmailJob::RequestTokenTo3PIDEmailJob( + const EmailValidationData& body) + : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenTo3PIDEmailJob"), + QStringLiteral("/_matrix/client/r0") + % "/account/3pid/email/requestToken", + false) { - fromJson(data, d->data); - - return Success; + setRequestData(Data(toJson(body))); } -class RequestTokenTo3PIDMSISDNJob::Private { -public: - Sid data; -}; - RequestTokenTo3PIDMSISDNJob::RequestTokenTo3PIDMSISDNJob( - const QString& clientSecret, const QString& country, - const QString& phoneNumber, int sendAttempt, const QString& idServer, - const QString& nextLink) + const MsisdnValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenTo3PIDMSISDNJob"), - basePath % "/account/3pid/msisdn/requestToken", false) - , d(new Private) -{ - QJsonObject _data; - addParam<>(_data, QStringLiteral("client_secret"), clientSecret); - addParam<>(_data, QStringLiteral("country"), country); - addParam<>(_data, QStringLiteral("phone_number"), phoneNumber); - addParam<>(_data, QStringLiteral("send_attempt"), sendAttempt); - addParam(_data, QStringLiteral("next_link"), nextLink); - addParam<>(_data, QStringLiteral("id_server"), idServer); - setRequestData(_data); -} - -RequestTokenTo3PIDMSISDNJob::~RequestTokenTo3PIDMSISDNJob() = default; - -const Sid& RequestTokenTo3PIDMSISDNJob::data() const { return d->data; } - -BaseJob::Status RequestTokenTo3PIDMSISDNJob::parseJson(const QJsonDocument& data) + QStringLiteral("/_matrix/client/r0") + % "/account/3pid/msisdn/requestToken", + false) { - fromJson(data, d->data); - - return Success; + setRequestData(Data(toJson(body))); } diff --git a/lib/csapi/administrative_contact.h b/lib/csapi/administrative_contact.h index af98fe9c..53c89272 100644 --- a/lib/csapi/administrative_contact.h +++ b/lib/csapi/administrative_contact.h @@ -4,18 +4,15 @@ #pragma once -#include "converters.h" - -#include "csapi/../identity/definitions/sid.h" +#include "csapi/./definitions/request_email_validation.h" +#include "csapi/./definitions/request_msisdn_validation.h" +#include "csapi/definitions/auth_data.h" +#include "csapi/definitions/request_token_response.h" #include "jobs/basejob.h" -#include - namespace Quotient { -// Operations - /*! \brief Gets a list of a user's third party identifiers. * * Gets a list of the third party identifiers that the homeserver has @@ -63,7 +60,6 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetAccount3PIDsJob() override; // Result properties @@ -75,19 +71,36 @@ public: /// /// 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. - const QVector& threepids() const; - -protected: - Status parseJson(const QJsonDocument& data) override; + QVector threepids() const + { + return loadFromJson>("threepids"_ls); + } +}; -private: - class Private; - QScopedPointer d; +template <> +struct JsonObjectConverter { + static void fillFrom(const QJsonObject& jo, + GetAccount3PIDsJob::ThirdPartyIdentifier& result) + { + fromJson(jo.value("medium"_ls), result.medium); + fromJson(jo.value("address"_ls), result.address); + fromJson(jo.value("validated_at"_ls), result.validatedAt); + fromJson(jo.value("added_at"_ls), result.addedAt); + } }; /*! \brief Adds contact information to the user's account. * * Adds contact information to the user's account. + * + * This endpoint is deprecated in favour of the more specific ``/3pid/add`` + * and ``/3pid/bind`` endpoints. + * + * .. Note:: + * Previously this endpoint supported a ``bind`` parameter. This parameter + * has been removed, making this endpoint behave as though it was ``false``. + * This results in this endpoint being an equivalent to ``/3pid/bind`` rather + * than dual-purpose. */ class Post3PIDsJob : public BaseJob { public: @@ -99,6 +112,10 @@ public: QString clientSecret; /// The identity server to use. 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 session identifier given by the identity server. QString sid; }; @@ -106,153 +123,248 @@ public: // Construction/destruction /*! \brief Adds contact information to the user's account. + * * * \param threePidCreds * The third party credentials to associate with the account. - * \param bind - * Whether the homeserver should also bind this third party - * identifier to the account's Matrix ID with the passed identity - * server. Default: ``false``. */ - explicit Post3PIDsJob(const ThreePidCredentials& threePidCreds, - Omittable bind = none); + explicit Post3PIDsJob(const ThreePidCredentials& threePidCreds); +}; + +template <> +struct JsonObjectConverter { + static void dumpTo(QJsonObject& jo, + const Post3PIDsJob::ThreePidCredentials& pod) + { + addParam<>(jo, QStringLiteral("client_secret"), pod.clientSecret); + addParam<>(jo, QStringLiteral("id_server"), pod.idServer); + addParam<>(jo, QStringLiteral("id_access_token"), pod.idAccessToken); + addParam<>(jo, QStringLiteral("sid"), pod.sid); + } +}; + +/*! \brief Adds contact information to the user's account. + * + * This API endpoint uses the `User-Interactive Authentication API`_. + * + * Adds contact information to the user's account. Homeservers should use 3PIDs + * added through this endpoint for password resets instead of relying on the + * identity server. + * + * 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 Add3PIDJob : public BaseJob { +public: + /*! \brief Adds contact information to the user's account. + * + * + * \param clientSecret + * The client secret used in the session with the homeserver. + * + * \param sid + * The session identifier given by the homeserver. + * + * \param auth + * Additional authentication information for the + * user-interactive authentication API. + */ + explicit Add3PIDJob(const QString& clientSecret, const QString& sid, + const Omittable& auth = none); +}; + +/*! \brief Binds a 3PID to the user's account through an Identity Service. + * + * Binds a 3PID to the user's account through the specified identity server. + * + * Homeservers should not prevent this request from succeeding if another user + * has bound the 3PID. Homeservers should simply proxy any errors received by + * the identity server to the caller. + * + * Homeservers should track successful binds so they can be unbound later. + */ +class Bind3PIDJob : public BaseJob { +public: + /*! \brief Binds a 3PID to the user's account through an Identity Service. + * + * + * \param clientSecret + * The client secret used in the session with the identity server. + * + * \param idServer + * The identity server to use. + * + * \param idAccessToken + * An access token previously registered with the identity server. + * + * \param sid + * The session identifier given by the identity server. + */ + 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 * * Removes a third party identifier from the user's account. This might not * cause an unbind of the identifier from the identity server. + * + * 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 Delete3pidFromAccountJob : public BaseJob { public: /*! \brief Deletes a third party identifier from the user's account + * * * \param medium * The medium of the third party identifier being removed. + * * \param address * The third party address being removed. + * + * \param idServer + * The identity server to unbind from. If not provided, the homeserver + * 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& address, + const QString& idServer = {}); + + // Result properties + + /// An indicator as to whether or not the homeserver was able to unbind + /// the 3PID from the identity server. ``success`` indicates that the + /// indentity server has unbound the identifier whereas ``no-support`` + /// indicates that the identity server refuses to support the request + /// or the homeserver was not able to determine an identity server to + /// unbind from. + QString idServerUnbindResult() const + { + return loadFromJson("id_server_unbind_result"_ls); + } +}; + +/*! \brief Removes a user's third party identifier from an identity server. + * + * Removes a user's third party identifier from the provided identity server + * without removing it from the homeserver. + * + * 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 Unbind3pidFromAccountJob : public BaseJob { +public: + /*! \brief Removes a user's third party identifier from an identity server. + * + * + * \param medium + * The medium of the third party identifier being removed. + * + * \param address + * The third party address being removed. + * + * \param idServer + * The identity server to unbind from. If not provided, the homeserver + * 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 = {}); + + // Result properties + + /// An indicator as to whether or not the identity server was able to unbind + /// the 3PID. ``success`` indicates that the identity server has unbound the + /// identifier whereas ``no-support`` indicates that the identity server + /// refuses to support the request or the homeserver was not able to + /// determine an identity server to unbind from. + QString idServerUnbindResult() const + { + return loadFromJson("id_server_unbind_result"_ls); + } }; /*! \brief Begins the validation process for an email address for association * with the user's account. * - * Proxies the Identity Service API ``validate/email/requestToken``, but - * first checks that the given email address is **not** already associated - * with an account on this homeserver. This API should be used to request - * validation tokens when adding an email address to an account. This API's - * parameters and response are identical to that of the - * |/register/email/requestToken|_ endpoint. + * The homeserver must check that the given email address is **not** + * already associated with an account on this homeserver. This API should + * be used to request validation tokens when adding an email address to an + * account. This API's parameters and response are identical to that of + * the |/register/email/requestToken|_ 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 RequestTokenTo3PIDEmailJob : public BaseJob { public: /*! \brief Begins the validation process for an email address for * association with the user's account. * - * \param clientSecret - * 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 - * must not be empty. - * \param email - * The email address to validate. - * \param sendAttempt - * The server will only send an email if the ``send_attempt`` - * is a number greater than the most recent one which it has seen, - * scoped to that ``email`` + ``client_secret`` pair. This is to - * avoid repeatedly sending the same email in the case of request - * retries between the POSTing user and the identity server. - * The client should increment this value if they desire a new - * email (e.g. a reminder) to be sent. - * \param idServer - * The hostname of the identity server to communicate with. May - * optionally include a port. - * \param nextLink - * Optional. When the validation is completed, the identity - * server will redirect the user to this URL. + * + * \param body + * The homeserver must check that the given email address is **not** + * already associated with an account on this homeserver. This API should + * be used to request validation tokens when adding an email address to an + * account. This API's parameters and response are identical to that of + * the |/register/email/requestToken|_ endpoint. The homeserver should + * validate the email itself, either by sending a validation email itself or + * by using a service it has control over. */ - explicit RequestTokenTo3PIDEmailJob(const QString& clientSecret, - const QString& email, int sendAttempt, - const QString& idServer, - const QString& nextLink = {}); - - ~RequestTokenTo3PIDEmailJob() override; + explicit RequestTokenTo3PIDEmailJob(const EmailValidationData& body); // Result properties - /// An email was sent to the given address. - const Sid& data() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + /// An email was sent to the given address. Note that this may be an + /// email containing the validation token or it may be informing the + /// user of an error. + RequestTokenResponse data() const + { + return fromJson(jsonData()); + } }; /*! \brief Begins the validation process for a phone number for association with * the user's account. * - * Proxies the Identity Service API ``validate/msisdn/requestToken``, but - * first checks that the given phone number is **not** already associated - * with an account on this homeserver. This API should be used to request - * validation tokens when adding a phone number to an account. This API's - * parameters and response are identical to that of the - * |/register/msisdn/requestToken|_ endpoint. + * The homeserver must check that the given phone number is **not** + * already associated with an account on this homeserver. This API should + * be used to request validation tokens when adding a phone number to an + * account. This API's parameters and response are identical to that of + * the |/register/msisdn/requestToken|_ 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 RequestTokenTo3PIDMSISDNJob : public BaseJob { public: /*! \brief Begins the validation process for a phone number for association * with the user's account. * - * \param clientSecret - * 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 - * must not be empty. - * \param country - * The two-letter uppercase ISO country code that the number in - * ``phone_number`` should be parsed as if it were dialled from. - * \param phoneNumber - * The phone number to validate. - * \param sendAttempt - * The server will only send an SMS if the ``send_attempt`` is a - * number greater than the most recent one which it has seen, - * scoped to that ``country`` + ``phone_number`` + ``client_secret`` - * triple. This is to avoid repeatedly sending the same SMS in - * the case of request retries between the POSTing user and the - * identity server. The client should increment this value if - * they desire a new SMS (e.g. a reminder) to be sent. - * \param idServer - * The hostname of the identity server to communicate with. May - * optionally include a port. - * \param nextLink - * Optional. When the validation is completed, the identity - * server will redirect the user to this URL. + * + * \param body + * The homeserver must check that the given phone number is **not** + * already associated with an account on this homeserver. This API should + * be used to request validation tokens when adding a phone number to an + * account. This API's parameters and response are identical to that of + * the |/register/msisdn/requestToken|_ 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. */ - explicit RequestTokenTo3PIDMSISDNJob(const QString& clientSecret, - const QString& country, - const QString& phoneNumber, - int sendAttempt, - const QString& idServer, - const QString& nextLink = {}); - - ~RequestTokenTo3PIDMSISDNJob() override; + explicit RequestTokenTo3PIDMSISDNJob(const MsisdnValidationData& body); // Result properties /// An SMS message was sent to the given phone number. - const Sid& data() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + RequestTokenResponse data() const + { + return fromJson(jsonData()); + } }; } // namespace Quotient diff --git a/lib/csapi/appservice_room_directory.cpp b/lib/csapi/appservice_room_directory.cpp index bfcab2a7..e8ec55bf 100644 --- a/lib/csapi/appservice_room_directory.cpp +++ b/lib/csapi/appservice_room_directory.cpp @@ -4,21 +4,18 @@ #include "appservice_room_directory.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - UpdateAppserviceRoomDirectoryVsibilityJob::UpdateAppserviceRoomDirectoryVsibilityJob( const QString& networkId, const QString& roomId, const QString& visibility) : BaseJob(HttpVerb::Put, QStringLiteral("UpdateAppserviceRoomDirectoryVsibilityJob"), - basePath % "/directory/list/appservice/" % networkId % "/" % roomId) + QStringLiteral("/_matrix/client/r0") + % "/directory/list/appservice/" % networkId % "/" % roomId) { QJsonObject _data; addParam<>(_data, QStringLiteral("visibility"), visibility); - setRequestData(_data); + setRequestData(std::move(_data)); } diff --git a/lib/csapi/appservice_room_directory.h b/lib/csapi/appservice_room_directory.h index f0ad78b0..d103177c 100644 --- a/lib/csapi/appservice_room_directory.h +++ b/lib/csapi/appservice_room_directory.h @@ -8,8 +8,6 @@ namespace Quotient { -// Operations - /*! \brief Updates a room's visibility in the application service's room * directory. * @@ -28,12 +26,15 @@ public: /*! \brief Updates a room's visibility in the application service's room * directory. * + * * \param networkId * The protocol (network) ID to update the room list for. This would * have been provided by the application service as being listed as * a supported protocol. + * * \param roomId * The room ID to add to the directory. + * * \param visibility * Whether the room should be visible (public) in the directory * or not (private). diff --git a/lib/csapi/banning.cpp b/lib/csapi/banning.cpp index 6ac9b3ba..8a8ec664 100644 --- a/lib/csapi/banning.cpp +++ b/lib/csapi/banning.cpp @@ -4,30 +4,27 @@ #include "banning.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - BanJob::BanJob(const QString& roomId, const QString& userId, const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("BanJob"), - basePath % "/rooms/" % roomId % "/ban") + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId % "/ban") { QJsonObject _data; addParam<>(_data, QStringLiteral("user_id"), userId); addParam(_data, QStringLiteral("reason"), reason); - setRequestData(_data); + setRequestData(std::move(_data)); } UnbanJob::UnbanJob(const QString& roomId, const QString& userId) : BaseJob(HttpVerb::Post, QStringLiteral("UnbanJob"), - basePath % "/rooms/" % roomId % "/unban") + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId + % "/unban") { QJsonObject _data; addParam<>(_data, QStringLiteral("user_id"), userId); - setRequestData(_data); + setRequestData(std::move(_data)); } diff --git a/lib/csapi/banning.h b/lib/csapi/banning.h index 6bf782e7..4faaaa81 100644 --- a/lib/csapi/banning.h +++ b/lib/csapi/banning.h @@ -8,8 +8,6 @@ namespace Quotient { -// Operations - /*! \brief Ban a user in the room. * * Ban a user in the room. If the user is currently in the room, also kick them. @@ -23,11 +21,14 @@ namespace Quotient { class BanJob : public BaseJob { public: /*! \brief Ban a user in the room. + * * * \param roomId * The room identifier (not alias) from which the user should be banned. + * * \param userId * The fully qualified user ID of the user being banned. + * * \param reason * The reason the user has been banned. This will be supplied as the * ``reason`` on the target's updated `m.room.member`_ event. @@ -48,9 +49,11 @@ public: class UnbanJob : public BaseJob { public: /*! \brief Unban a user from the room. + * * * \param roomId * The room identifier (not alias) from which the user should be unbanned. + * * \param userId * The fully qualified user ID of the user being unbanned. */ diff --git a/lib/csapi/capabilities.cpp b/lib/csapi/capabilities.cpp index 8c7ed141..33a53cad 100644 --- a/lib/csapi/capabilities.cpp +++ b/lib/csapi/capabilities.cpp @@ -4,80 +4,20 @@ #include "capabilities.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -// Converters -namespace Quotient { - -template <> -struct JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, - GetCapabilitiesJob::ChangePasswordCapability& result) - { - fromJson(jo.value("enabled"_ls), result.enabled); - } -}; - -template <> -struct JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, - GetCapabilitiesJob::RoomVersionsCapability& result) - { - fromJson(jo.value("default"_ls), result.defaultVersion); - fromJson(jo.value("available"_ls), result.available); - } -}; - -template <> -struct JsonObjectConverter { - static void fillFrom(QJsonObject jo, - GetCapabilitiesJob::Capabilities& result) - { - fromJson(jo.take("m.change_password"_ls), result.changePassword); - fromJson(jo.take("m.room_versions"_ls), result.roomVersions); - fromJson(jo, result.additionalProperties); - } -}; - -} // namespace Quotient - -class GetCapabilitiesJob::Private { -public: - Capabilities capabilities; -}; - QUrl GetCapabilitiesJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/capabilities"); + QStringLiteral("/_matrix/client/r0") + % "/capabilities"); } GetCapabilitiesJob::GetCapabilitiesJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetCapabilitiesJob"), - basePath % "/capabilities") - , d(new Private) -{} - -GetCapabilitiesJob::~GetCapabilitiesJob() = default; - -const GetCapabilitiesJob::Capabilities& GetCapabilitiesJob::capabilities() const + QStringLiteral("/_matrix/client/r0") % "/capabilities") { - return d->capabilities; -} - -BaseJob::Status GetCapabilitiesJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - if (!json.contains("capabilities"_ls)) - return { IncorrectResponse, - "The key 'capabilities' not found in the response" }; - fromJson(json.value("capabilities"_ls), d->capabilities); - - return Success; + addExpectedKey("capabilities"); } diff --git a/lib/csapi/capabilities.h b/lib/csapi/capabilities.h index 9f46ab2e..da50c8c1 100644 --- a/lib/csapi/capabilities.h +++ b/lib/csapi/capabilities.h @@ -4,17 +4,10 @@ #pragma once -#include "converters.h" - #include "jobs/basejob.h" -#include -#include - namespace Quotient { -// Operations - /*! \brief Gets information about the server's capabilities. * * Gets information about the server's supported feature set @@ -61,20 +54,45 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetCapabilitiesJob() override; // Result properties /// The custom capabilities the server supports, using the /// Java package naming convention. - const Capabilities& capabilities() const; + Capabilities capabilities() const + { + return loadFromJson("capabilities"_ls); + } +}; -protected: - Status parseJson(const QJsonDocument& data) override; +template <> +struct JsonObjectConverter { + static void fillFrom(const QJsonObject& jo, + GetCapabilitiesJob::ChangePasswordCapability& result) + { + fromJson(jo.value("enabled"_ls), result.enabled); + } +}; + +template <> +struct JsonObjectConverter { + static void fillFrom(const QJsonObject& jo, + GetCapabilitiesJob::RoomVersionsCapability& result) + { + fromJson(jo.value("default"_ls), result.defaultVersion); + fromJson(jo.value("available"_ls), result.available); + } +}; -private: - class Private; - QScopedPointer d; +template <> +struct JsonObjectConverter { + static void fillFrom(QJsonObject jo, + GetCapabilitiesJob::Capabilities& result) + { + fromJson(jo.take("m.change_password"_ls), result.changePassword); + fromJson(jo.take("m.room_versions"_ls), result.roomVersions); + fromJson(jo, result.additionalProperties); + } }; } // namespace Quotient diff --git a/lib/csapi/content-repo.cpp b/lib/csapi/content-repo.cpp index d811426d..7ae89739 100644 --- a/lib/csapi/content-repo.cpp +++ b/lib/csapi/content-repo.cpp @@ -4,21 +4,11 @@ #include "content-repo.h" -#include "converters.h" - #include -#include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/media/r0"); - -class UploadContentJob::Private { -public: - QString contentUri; -}; - -BaseJob::Query queryToUploadContent(const QString& filename) +auto queryToUploadContent(const QString& filename) { BaseJob::Query _q; addParam(_q, QStringLiteral("filename"), filename); @@ -28,36 +18,15 @@ BaseJob::Query queryToUploadContent(const QString& filename) UploadContentJob::UploadContentJob(QIODevice* content, const QString& filename, const QString& contentType) : BaseJob(HttpVerb::Post, QStringLiteral("UploadContentJob"), - basePath % "/upload", queryToUploadContent(filename)) - , d(new Private) + QStringLiteral("/_matrix/media/r0") % "/upload", + queryToUploadContent(filename)) { setRequestHeader("Content-Type", contentType.toLatin1()); setRequestData(Data(content)); + addExpectedKey("content_uri"); } -UploadContentJob::~UploadContentJob() = default; - -const QString& UploadContentJob::contentUri() const { return d->contentUri; } - -BaseJob::Status UploadContentJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - if (!json.contains("content_uri"_ls)) - return { IncorrectResponse, - "The key 'content_uri' not found in the response" }; - fromJson(json.value("content_uri"_ls), d->contentUri); - - return Success; -} - -class GetContentJob::Private { -public: - QString contentType; - QString contentDisposition; - QIODevice* data; -}; - -BaseJob::Query queryToGetContent(bool allowRemote) +auto queryToGetContent(bool allowRemote) { BaseJob::Query _q; addParam(_q, QStringLiteral("allow_remote"), allowRemote); @@ -68,7 +37,8 @@ QUrl GetContentJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, bool allowRemote) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/download/" % serverName % "/" + QStringLiteral("/_matrix/media/r0") + % "/download/" % serverName % "/" % mediaId, queryToGetContent(allowRemote)); } @@ -76,40 +46,14 @@ QUrl GetContentJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, GetContentJob::GetContentJob(const QString& serverName, const QString& mediaId, bool allowRemote) : BaseJob(HttpVerb::Get, QStringLiteral("GetContentJob"), - basePath % "/download/" % serverName % "/" % mediaId, + QStringLiteral("/_matrix/media/r0") % "/download/" % serverName + % "/" % mediaId, queryToGetContent(allowRemote), {}, false) - , d(new Private) { setExpectedContentTypes({ "*/*" }); } -GetContentJob::~GetContentJob() = default; - -const QString& GetContentJob::contentType() const { return d->contentType; } - -const QString& GetContentJob::contentDisposition() const -{ - return d->contentDisposition; -} - -QIODevice* GetContentJob::data() const { return d->data; } - -BaseJob::Status GetContentJob::parseReply(QNetworkReply* reply) -{ - d->contentType = reply->rawHeader("Content-Type"); - d->contentDisposition = reply->rawHeader("Content-Disposition"); - d->data = reply; - return Success; -} - -class GetContentOverrideNameJob::Private { -public: - QString contentType; - QString contentDisposition; - QIODevice* data; -}; - -BaseJob::Query queryToGetContentOverrideName(bool allowRemote) +auto queryToGetContentOverrideName(bool allowRemote) { BaseJob::Query _q; addParam(_q, QStringLiteral("allow_remote"), allowRemote); @@ -123,7 +67,8 @@ QUrl GetContentOverrideNameJob::makeRequestUrl(QUrl baseUrl, bool allowRemote) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/download/" % serverName % "/" + QStringLiteral("/_matrix/media/r0") + % "/download/" % serverName % "/" % mediaId % "/" % fileName, queryToGetContentOverrideName(allowRemote)); } @@ -133,45 +78,15 @@ GetContentOverrideNameJob::GetContentOverrideNameJob(const QString& serverName, const QString& fileName, bool allowRemote) : BaseJob(HttpVerb::Get, QStringLiteral("GetContentOverrideNameJob"), - basePath % "/download/" % serverName % "/" % mediaId % "/" - % fileName, + QStringLiteral("/_matrix/media/r0") % "/download/" % serverName + % "/" % mediaId % "/" % fileName, queryToGetContentOverrideName(allowRemote), {}, false) - , d(new Private) { setExpectedContentTypes({ "*/*" }); } -GetContentOverrideNameJob::~GetContentOverrideNameJob() = default; - -const QString& GetContentOverrideNameJob::contentType() const -{ - return d->contentType; -} - -const QString& GetContentOverrideNameJob::contentDisposition() const -{ - return d->contentDisposition; -} - -QIODevice* GetContentOverrideNameJob::data() const { return d->data; } - -BaseJob::Status GetContentOverrideNameJob::parseReply(QNetworkReply* reply) -{ - d->contentType = reply->rawHeader("Content-Type"); - d->contentDisposition = reply->rawHeader("Content-Disposition"); - d->data = reply; - return Success; -} - -class GetContentThumbnailJob::Private { -public: - QString contentType; - QIODevice* data; -}; - -BaseJob::Query queryToGetContentThumbnail(int width, int height, - const QString& method, - bool allowRemote) +auto queryToGetContentThumbnail(int width, int height, const QString& method, + bool allowRemote) { BaseJob::Query _q; addParam<>(_q, QStringLiteral("width"), width); @@ -189,7 +104,8 @@ QUrl GetContentThumbnailJob::makeRequestUrl(QUrl baseUrl, { return BaseJob::makeRequestUrl( std::move(baseUrl), - basePath % "/thumbnail/" % serverName % "/" % mediaId, + QStringLiteral("/_matrix/media/r0") % "/thumbnail/" % serverName % "/" + % mediaId, queryToGetContentThumbnail(width, height, method, allowRemote)); } @@ -198,37 +114,15 @@ GetContentThumbnailJob::GetContentThumbnailJob(const QString& serverName, int height, const QString& method, bool allowRemote) : BaseJob(HttpVerb::Get, QStringLiteral("GetContentThumbnailJob"), - basePath % "/thumbnail/" % serverName % "/" % mediaId, + QStringLiteral("/_matrix/media/r0") % "/thumbnail/" % serverName + % "/" % mediaId, queryToGetContentThumbnail(width, height, method, allowRemote), {}, false) - , d(new Private) { setExpectedContentTypes({ "image/jpeg", "image/png" }); } -GetContentThumbnailJob::~GetContentThumbnailJob() = default; - -const QString& GetContentThumbnailJob::contentType() const -{ - return d->contentType; -} - -QIODevice* GetContentThumbnailJob::data() const { return d->data; } - -BaseJob::Status GetContentThumbnailJob::parseReply(QNetworkReply* reply) -{ - d->contentType = reply->rawHeader("Content-Type"); - d->data = reply; - return Success; -} - -class GetUrlPreviewJob::Private { -public: - Omittable matrixImageSize; - QString ogImage; -}; - -BaseJob::Query queryToGetUrlPreview(const QString& url, Omittable ts) +auto queryToGetUrlPreview(const QString& url, Omittable ts) { BaseJob::Query _q; addParam<>(_q, QStringLiteral("url"), url); @@ -239,58 +133,26 @@ BaseJob::Query queryToGetUrlPreview(const QString& url, Omittable ts) QUrl GetUrlPreviewJob::makeRequestUrl(QUrl baseUrl, const QString& url, Omittable ts) { - return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/preview_url", + return BaseJob::makeRequestUrl(std::move(baseUrl), + QStringLiteral("/_matrix/media/r0") + % "/preview_url", queryToGetUrlPreview(url, ts)); } GetUrlPreviewJob::GetUrlPreviewJob(const QString& url, Omittable ts) : BaseJob(HttpVerb::Get, QStringLiteral("GetUrlPreviewJob"), - basePath % "/preview_url", queryToGetUrlPreview(url, ts)) - , d(new Private) + QStringLiteral("/_matrix/media/r0") % "/preview_url", + queryToGetUrlPreview(url, ts)) {} -GetUrlPreviewJob::~GetUrlPreviewJob() = default; - -Omittable GetUrlPreviewJob::matrixImageSize() const -{ - return d->matrixImageSize; -} - -const QString& GetUrlPreviewJob::ogImage() const { return d->ogImage; } - -BaseJob::Status GetUrlPreviewJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("matrix:image:size"_ls), d->matrixImageSize); - fromJson(json.value("og:image"_ls), d->ogImage); - - return Success; -} - -class GetConfigJob::Private { -public: - Omittable uploadSize; -}; - QUrl GetConfigJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/config"); + return BaseJob::makeRequestUrl(std::move(baseUrl), + QStringLiteral("/_matrix/media/r0") + % "/config"); } GetConfigJob::GetConfigJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetConfigJob"), - basePath % "/config") - , d(new Private) + QStringLiteral("/_matrix/media/r0") % "/config") {} - -GetConfigJob::~GetConfigJob() = default; - -Omittable GetConfigJob::uploadSize() const { return d->uploadSize; } - -BaseJob::Status GetConfigJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("m.upload.size"_ls), d->uploadSize); - - return Success; -} diff --git a/lib/csapi/content-repo.h b/lib/csapi/content-repo.h index 6263ef0b..0eb273bc 100644 --- a/lib/csapi/content-repo.h +++ b/lib/csapi/content-repo.h @@ -4,45 +4,40 @@ #pragma once -#include "converters.h" - #include "jobs/basejob.h" #include +#include namespace Quotient { -// Operations - /*! \brief Upload some content to the content repository. * */ class UploadContentJob : public BaseJob { public: /*! \brief Upload some content to the content repository. + * * * \param content + * The content to be uploaded. + * * \param filename * The name of the file being uploaded + * * \param contentType * The content type of the file being uploaded */ explicit UploadContentJob(QIODevice* content, const QString& filename = {}, const QString& contentType = {}); - ~UploadContentJob() override; - // Result properties - /// The MXC URI to the uploaded content. - const QString& contentUri() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + /// The `MXC URI`_ to the uploaded content. + QString contentUri() const + { + return loadFromJson("content_uri"_ls); + } }; /*! \brief Download content from the content repository. @@ -51,11 +46,14 @@ private: class GetContentJob : public BaseJob { public: /*! \brief Download content from the content repository. + * * * \param serverName * The server name from the ``mxc://`` URI (the authoritory component) + * * \param mediaId * The media ID from the ``mxc://`` URI (the path component) + * * \param allowRemote * Indicates to the server that it should not attempt to fetch the media * if it is deemed remote. This is to prevent routing loops where the server @@ -71,44 +69,47 @@ public: */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, bool allowRemote = true); - ~GetContentJob() override; // Result properties /// The content type of the file that was previously uploaded. - const QString& contentType() const; + QString contentType() const { return reply()->rawHeader("Content-Type"); } /// The name of the file that was previously uploaded, if set. - const QString& contentDisposition() const; + QString contentDisposition() const + { + return reply()->rawHeader("Content-Disposition"); + } /// The content that was previously uploaded. - QIODevice* data() const; - -protected: - Status parseReply(QNetworkReply* reply) override; - -private: - class Private; - QScopedPointer d; + QIODevice* data() { return reply(); } }; -/*! \brief Download content from the content repository as a given filename. +/*! \brief Download content from the content repository. This is the same as +the download endpoint above, except permitting a desired file name. * */ class GetContentOverrideNameJob : public BaseJob { public: - /*! \brief Download content from the content repository as a given filename. + /*! \brief Download content from the content repository. This is the same as +the download endpoint above, except permitting a desired file name. + * * * \param serverName * The server name from the ``mxc://`` URI (the authoritory component) + * * \param mediaId * The media ID from the ``mxc://`` URI (the path component) + * * \param fileName - * The filename to give in the Content-Disposition + * A filename to give in the ``Content-Disposition`` header. + * * \param allowRemote * Indicates to the server that it should not attempt to fetch the media - * if it is deemed remote. This is to prevent routing loops where the server - * contacts itself. Defaults to true if not provided. +if it is deemed + * remote. This is to prevent routing loops where the server contacts +itself. Defaults to + * true if not provided. */ explicit GetContentOverrideNameJob(const QString& serverName, const QString& mediaId, @@ -123,50 +124,57 @@ public: static QUrl makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, const QString& fileName, bool allowRemote = true); - ~GetContentOverrideNameJob() override; // Result properties /// The content type of the file that was previously uploaded. - const QString& contentType() const; + QString contentType() const { return reply()->rawHeader("Content-Type"); } - /// The name of file given in the request - const QString& contentDisposition() const; + /// The ``fileName`` requested or the name of the file that was previously + /// uploaded, if set. + QString contentDisposition() const + { + return reply()->rawHeader("Content-Disposition"); + } /// The content that was previously uploaded. - QIODevice* data() const; - -protected: - Status parseReply(QNetworkReply* reply) override; - -private: - class Private; - QScopedPointer d; + QIODevice* data() { return reply(); } }; -/*! \brief Download a thumbnail of the content from the content repository. +/*! \brief Download a thumbnail of content from the content repository. See the +`thumbnailing <#thumbnails>`_ section for more information. * */ class GetContentThumbnailJob : public BaseJob { public: - /*! \brief Download a thumbnail of the content from the content repository. + /*! \brief Download a thumbnail of content from the content repository. See +the `thumbnailing <#thumbnails>`_ section for more information. + * * * \param serverName * The server name from the ``mxc://`` URI (the authoritory component) + * * \param mediaId * The media ID from the ``mxc://`` URI (the path component) + * * \param width - * The *desired* width of the thumbnail. The actual thumbnail may not - * match the size specified. + * The *desired* width of the thumbnail. The actual thumbnail may be + * larger than the size specified. + * * \param height - * The *desired* height of the thumbnail. The actual thumbnail may not - * match the size specified. + * The *desired* height of the thumbnail. The actual thumbnail may be + * larger than the size specified. + * * \param method - * The desired resizing method. + * The desired resizing method. See the `thumbnailing <#thumbnails>`_ + * section for more information. + * * \param allowRemote * Indicates to the server that it should not attempt to fetch the media - * if it is deemed remote. This is to prevent routing loops where the server - * contacts itself. Defaults to true if not provided. +if it is deemed + * remote. This is to prevent routing loops where the server contacts +itself. Defaults to + * true if not provided. */ explicit GetContentThumbnailJob(const QString& serverName, const QString& mediaId, int width, @@ -182,33 +190,35 @@ public: const QString& mediaId, int width, int height, const QString& method = {}, bool allowRemote = true); - ~GetContentThumbnailJob() override; // Result properties /// The content type of the thumbnail. - const QString& contentType() const; + QString contentType() const { return reply()->rawHeader("Content-Type"); } /// A thumbnail of the requested content. - QIODevice* data() const; - -protected: - Status parseReply(QNetworkReply* reply) override; - -private: - class Private; - QScopedPointer d; + QIODevice* data() { return reply(); } }; /*! \brief Get information about a URL for a client * + * Get information about a URL for the client. Typically this is called when a + * client sees a URL in a message and wants to render a preview for the user. + * + * .. Note:: + * Clients should consider avoiding this endpoint for URLs posted in encrypted + * 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 GetUrlPreviewJob : public BaseJob { public: /*! \brief Get information about a URL for a client + * * * \param url - * The URL to get a preview of + * The URL to get a preview of. + * * \param ts * 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 @@ -223,22 +233,17 @@ public: */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& url, Omittable ts = none); - ~GetUrlPreviewJob() override; // Result properties /// The byte-size of the image. Omitted if there is no image attached. - Omittable matrixImageSize() const; + Omittable matrixImageSize() const + { + return loadFromJson>("matrix:image:size"_ls); + } - /// An MXC URI to the image. Omitted if there is no image. - const QString& ogImage() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + /// An `MXC URI`_ to the image. Omitted if there is no image. + QString ogImage() const { return loadFromJson("og:image"_ls); } }; /*! \brief Get the configuration for the content repository. @@ -265,21 +270,16 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetConfigJob() override; // Result properties /// The maximum size an upload can be in bytes. /// Clients SHOULD use this as a guide when uploading content. /// If not listed or null, the size limit should be treated as unknown. - Omittable uploadSize() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + Omittable uploadSize() const + { + return loadFromJson>("m.upload.size"_ls); + } }; } // namespace Quotient diff --git a/lib/csapi/create_room.cpp b/lib/csapi/create_room.cpp index ec2a1855..a94f9951 100644 --- a/lib/csapi/create_room.cpp +++ b/lib/csapi/create_room.cpp @@ -4,44 +4,10 @@ #include "create_room.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -// Converters -namespace Quotient { - -template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const CreateRoomJob::Invite3pid& pod) - { - addParam<>(jo, QStringLiteral("id_server"), pod.idServer); - addParam<>(jo, QStringLiteral("medium"), pod.medium); - addParam<>(jo, QStringLiteral("address"), pod.address); - } -}; - -template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const CreateRoomJob::StateEvent& pod) - { - addParam<>(jo, QStringLiteral("type"), pod.type); - addParam(jo, QStringLiteral("state_key"), pod.stateKey); - addParam<>(jo, QStringLiteral("content"), pod.content); - } -}; - -} // namespace Quotient - -class CreateRoomJob::Private { -public: - QString roomId; -}; - CreateRoomJob::CreateRoomJob(const QString& visibility, const QString& roomAliasName, const QString& name, const QString& topic, const QStringList& invite, @@ -52,8 +18,7 @@ CreateRoomJob::CreateRoomJob(const QString& visibility, const QString& preset, Omittable isDirect, const QJsonObject& powerLevelContentOverride) : BaseJob(HttpVerb::Post, QStringLiteral("CreateRoomJob"), - basePath % "/createRoom") - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/createRoom") { QJsonObject _data; addParam(_data, QStringLiteral("visibility"), visibility); @@ -71,20 +36,6 @@ CreateRoomJob::CreateRoomJob(const QString& visibility, addParam(_data, QStringLiteral("is_direct"), isDirect); addParam(_data, QStringLiteral("power_level_content_override"), powerLevelContentOverride); - setRequestData(_data); -} - -CreateRoomJob::~CreateRoomJob() = default; - -const QString& CreateRoomJob::roomId() const { return d->roomId; } - -BaseJob::Status CreateRoomJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - if (!json.contains("room_id"_ls)) - return { IncorrectResponse, - "The key 'room_id' not found in the response" }; - fromJson(json.value("room_id"_ls), d->roomId); - - return Success; + setRequestData(std::move(_data)); + addExpectedKey("room_id"); } diff --git a/lib/csapi/create_room.h b/lib/csapi/create_room.h index f2bd9333..82db9e59 100644 --- a/lib/csapi/create_room.h +++ b/lib/csapi/create_room.h @@ -4,17 +4,10 @@ #pragma once -#include "converters.h" - #include "jobs/basejob.h" -#include -#include - namespace Quotient { -// Operations - /*! \brief Create a new room * * Create a new room with various configuration options. @@ -23,21 +16,27 @@ namespace Quotient { * the new room, including checking power levels for each event. It MUST * apply the events implied by the request in the following order: * - * 0. A default ``m.room.power_levels`` event, giving the room creator + * 1. The ``m.room.create`` event itself. Must be the first event in the + * room. + * + * 2. An ``m.room.member`` event for the creator to join the room. This is + * needed so the remaining events can be sent. + * + * 3. A default ``m.room.power_levels`` event, giving the room creator * (and not other members) permission to send state events. Overridden * by the ``power_level_content_override`` parameter. * - * 1. Events set by the ``preset``. Currently these are the + * 4. Events set by the ``preset``. Currently these are the * ``m.room.join_rules``, * ``m.room.history_visibility``, and ``m.room.guest_access`` state events. * - * 2. Events listed in ``initial_state``, in the order that they are + * 5. Events listed in ``initial_state``, in the order that they are * listed. * - * 3. Events implied by ``name`` and ``topic`` (``m.room.name`` and + * 6. Events implied by ``name`` and ``topic`` (``m.room.name`` and * ``m.room.topic`` state events). * - * 4. Invite events implied by ``invite`` and ``invite_3pid`` (``m.room.member`` + * 7. Invite events implied by ``invite`` and ``invite_3pid`` (``m.room.member`` * with * ``membership: invite`` and ``m.room.third_party_invite``). * @@ -69,23 +68,29 @@ public: /// the new room, including checking power levels for each event. It MUST /// apply the events implied by the request in the following order: /// - /// 0. A default ``m.room.power_levels`` event, giving the room creator + /// 1. The ``m.room.create`` event itself. Must be the first event in the + /// room. + /// + /// 2. An ``m.room.member`` event for the creator to join the room. This is + /// needed so the remaining events can be sent. + /// + /// 3. A default ``m.room.power_levels`` event, giving the room creator /// (and not other members) permission to send state events. Overridden /// by the ``power_level_content_override`` parameter. /// - /// 1. Events set by the ``preset``. Currently these are the + /// 4. Events set by the ``preset``. Currently these are the /// ``m.room.join_rules``, /// ``m.room.history_visibility``, and ``m.room.guest_access`` state /// events. /// - /// 2. Events listed in ``initial_state``, in the order that they are + /// 5. Events listed in ``initial_state``, in the order that they are /// listed. /// - /// 3. Events implied by ``name`` and ``topic`` (``m.room.name`` and + /// 6. Events implied by ``name`` and ``topic`` (``m.room.name`` and /// ``m.room.topic`` /// state events). /// - /// 4. Invite events implied by ``invite`` and ``invite_3pid`` + /// 7. Invite events implied by ``invite`` and ``invite_3pid`` /// (``m.room.member`` with /// ``membership: invite`` and ``m.room.third_party_invite``). /// @@ -111,6 +116,10 @@ public: /// 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``. QString medium; @@ -124,23 +133,29 @@ public: /// the new room, including checking power levels for each event. It MUST /// apply the events implied by the request in the following order: /// - /// 0. A default ``m.room.power_levels`` event, giving the room creator + /// 1. The ``m.room.create`` event itself. Must be the first event in the + /// room. + /// + /// 2. An ``m.room.member`` event for the creator to join the room. This is + /// needed so the remaining events can be sent. + /// + /// 3. A default ``m.room.power_levels`` event, giving the room creator /// (and not other members) permission to send state events. Overridden /// by the ``power_level_content_override`` parameter. /// - /// 1. Events set by the ``preset``. Currently these are the + /// 4. Events set by the ``preset``. Currently these are the /// ``m.room.join_rules``, /// ``m.room.history_visibility``, and ``m.room.guest_access`` state /// events. /// - /// 2. Events listed in ``initial_state``, in the order that they are + /// 5. Events listed in ``initial_state``, in the order that they are /// listed. /// - /// 3. Events implied by ``name`` and ``topic`` (``m.room.name`` and + /// 6. Events implied by ``name`` and ``topic`` (``m.room.name`` and /// ``m.room.topic`` /// state events). /// - /// 4. Invite events implied by ``invite`` and ``invite_3pid`` + /// 7. Invite events implied by ``invite`` and ``invite_3pid`` /// (``m.room.member`` with /// ``membership: invite`` and ``m.room.third_party_invite``). /// @@ -174,6 +189,7 @@ public: // Construction/destruction /*! \brief Create a new room + * * * \param visibility * A ``public`` visibility indicates that the room will be shown @@ -182,6 +198,7 @@ public: * ``private`` visibility if this key is not included. NB: This * should not be confused with ``join_rules`` which also uses the * word ``public``. + * * \param roomAliasName * The desired room alias **local part**. If this is included, a * room alias will be created and mapped to the newly created @@ -192,35 +209,46 @@ public: * * The complete room alias will become the canonical alias for * the room. + * * \param name * If this is included, an ``m.room.name`` event will be sent * into the room to indicate the name of the room. See Room * Events for more information on ``m.room.name``. + * * \param topic * If this is included, an ``m.room.topic`` event will be sent * into the room to indicate the topic for the room. See Room * Events for more information on ``m.room.topic``. + * * \param invite * A list of user IDs to invite to the room. This will tell the * server to invite everyone in the list to the newly created room. + * * \param invite3pid * A list of objects representing third party IDs to invite into * the room. + * * \param roomVersion * The room version to set for the room. If not provided, the homeserver * is to use its configured default. If provided, the homeserver will return * a 400 error with the errcode ``M_UNSUPPORTED_ROOM_VERSION`` if it does - * not support the room version. \param creationContent Extra keys, such as - * ``m.federate``, to be added to the content of the `m.room.create`_ event. - * The server will clobber the following keys: ``creator``, - * ``room_version``. Future versions of the specification may allow the - * server to clobber other keys. \param initialState A list of state events - * to set in the new room. This allows the user to override the default - * state events set in the new room. The expected format of the state events - * are an object with type, state_key and content keys set. + * not support the room version. + * + * \param creationContent + * Extra keys, such as ``m.federate``, to be added to the content + * of the `m.room.create`_ event. The server will clobber the following + * keys: ``creator``, ``room_version``. Future versions of the + * specification may allow the server to clobber other keys. + * + * \param initialState + * A list of state events to set in the new room. This allows + * the user to override the default state events set in the new + * room. The expected format of the state events are an object + * with type, state_key and content keys set. * * Takes precedence over events set by ``preset``, but gets * overriden by ``name`` and ``topic`` keys. + * * \param preset * Convenience parameter for setting various default state events * based on a preset. @@ -229,10 +257,12 @@ public: * which preset to use. A visbility of ``public`` equates to a preset of * ``public_chat`` and ``private`` visibility equates to a preset of * ``private_chat``. + * * \param isDirect * This flag makes the server set the ``is_direct`` flag on the * ``m.room.member`` events sent to the users in ``invite`` and * ``invite_3pid``. See `Direct Messaging`_ for more information. + * * \param powerLevelContentOverride * The power level content to override in the default power level * event. This object is applied on top of the generated @@ -251,19 +281,31 @@ public: Omittable isDirect = none, const QJsonObject& powerLevelContentOverride = {}); - ~CreateRoomJob() override; - // Result properties /// The created room's ID. - const QString& roomId() const; + QString roomId() const { return loadFromJson("room_id"_ls); } +}; -protected: - Status parseJson(const QJsonDocument& data) override; +template <> +struct JsonObjectConverter { + static void dumpTo(QJsonObject& jo, const CreateRoomJob::Invite3pid& pod) + { + addParam<>(jo, QStringLiteral("id_server"), pod.idServer); + addParam<>(jo, QStringLiteral("id_access_token"), pod.idAccessToken); + addParam<>(jo, QStringLiteral("medium"), pod.medium); + addParam<>(jo, QStringLiteral("address"), pod.address); + } +}; -private: - class Private; - QScopedPointer d; +template <> +struct JsonObjectConverter { + static void dumpTo(QJsonObject& jo, const CreateRoomJob::StateEvent& pod) + { + addParam<>(jo, QStringLiteral("type"), pod.type); + addParam(jo, QStringLiteral("state_key"), pod.stateKey); + addParam<>(jo, QStringLiteral("content"), pod.content); + } }; } // namespace Quotient diff --git a/lib/csapi/definitions/auth_data.cpp b/lib/csapi/definitions/auth_data.cpp deleted file mode 100644 index edeb7111..00000000 --- a/lib/csapi/definitions/auth_data.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "auth_data.h" - -using namespace Quotient; - -void JsonObjectConverter::dumpTo( - QJsonObject& jo, const AuthenticationData& pod) -{ - fillJson(jo, pod.authInfo); - addParam<>(jo, QStringLiteral("type"), pod.type); - addParam(jo, QStringLiteral("session"), pod.session); -} - -void JsonObjectConverter::fillFrom(QJsonObject jo, - AuthenticationData& result) -{ - fromJson(jo.take("type"_ls), result.type); - fromJson(jo.take("session"_ls), result.session); - fromJson(jo, result.authInfo); -} diff --git a/lib/csapi/definitions/auth_data.h b/lib/csapi/definitions/auth_data.h index e564f7f3..e92596d0 100644 --- a/lib/csapi/definitions/auth_data.h +++ b/lib/csapi/definitions/auth_data.h @@ -6,13 +6,7 @@ #include "converters.h" -#include -#include - namespace Quotient { - -// Data structures - /// Used by clients to submit authentication information to the /// interactive-authentication API struct AuthenticationData { @@ -28,8 +22,18 @@ struct AuthenticationData { template <> struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const AuthenticationData& pod); - static void fillFrom(QJsonObject jo, AuthenticationData& pod); + static void dumpTo(QJsonObject& jo, const AuthenticationData& pod) + { + fillJson(jo, pod.authInfo); + addParam<>(jo, QStringLiteral("type"), pod.type); + addParam(jo, QStringLiteral("session"), pod.session); + } + static void fillFrom(QJsonObject jo, AuthenticationData& pod) + { + fromJson(jo.take("type"_ls), pod.type); + fromJson(jo.take("session"_ls), pod.session); + fromJson(jo, pod.authInfo); + } }; } // namespace Quotient diff --git a/lib/csapi/definitions/client_device.cpp b/lib/csapi/definitions/client_device.cpp deleted file mode 100644 index 09544138..00000000 --- a/lib/csapi/definitions/client_device.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "client_device.h" - -using namespace Quotient; - -void JsonObjectConverter::dumpTo(QJsonObject& jo, const Device& pod) -{ - addParam<>(jo, QStringLiteral("device_id"), pod.deviceId); - addParam(jo, QStringLiteral("display_name"), pod.displayName); - addParam(jo, QStringLiteral("last_seen_ip"), pod.lastSeenIp); - addParam(jo, QStringLiteral("last_seen_ts"), pod.lastSeenTs); -} - -void JsonObjectConverter::fillFrom(const QJsonObject& jo, Device& result) -{ - fromJson(jo.value("device_id"_ls), result.deviceId); - fromJson(jo.value("display_name"_ls), result.displayName); - fromJson(jo.value("last_seen_ip"_ls), result.lastSeenIp); - fromJson(jo.value("last_seen_ts"_ls), result.lastSeenTs); -} diff --git a/lib/csapi/definitions/client_device.h b/lib/csapi/definitions/client_device.h index 2cf75950..a5ab1bfc 100644 --- a/lib/csapi/definitions/client_device.h +++ b/lib/csapi/definitions/client_device.h @@ -7,9 +7,6 @@ #include "converters.h" namespace Quotient { - -// Data structures - /// A client device struct Device { /// Identifier of this device. @@ -31,8 +28,21 @@ struct Device { template <> struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const Device& pod); - static void fillFrom(const QJsonObject& jo, Device& pod); + static void dumpTo(QJsonObject& jo, const Device& pod) + { + addParam<>(jo, QStringLiteral("device_id"), pod.deviceId); + addParam(jo, QStringLiteral("display_name"), + pod.displayName); + addParam(jo, QStringLiteral("last_seen_ip"), pod.lastSeenIp); + addParam(jo, QStringLiteral("last_seen_ts"), pod.lastSeenTs); + } + static void fillFrom(const QJsonObject& jo, Device& pod) + { + fromJson(jo.value("device_id"_ls), pod.deviceId); + fromJson(jo.value("display_name"_ls), pod.displayName); + fromJson(jo.value("last_seen_ip"_ls), pod.lastSeenIp); + fromJson(jo.value("last_seen_ts"_ls), pod.lastSeenTs); + } }; } // namespace Quotient diff --git a/lib/csapi/definitions/device_keys.cpp b/lib/csapi/definitions/device_keys.cpp deleted file mode 100644 index 0583840d..00000000 --- a/lib/csapi/definitions/device_keys.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "device_keys.h" - -using namespace Quotient; - -void JsonObjectConverter::dumpTo(QJsonObject& jo, - const DeviceKeys& pod) -{ - addParam<>(jo, QStringLiteral("user_id"), pod.userId); - addParam<>(jo, QStringLiteral("device_id"), pod.deviceId); - addParam<>(jo, QStringLiteral("algorithms"), pod.algorithms); - addParam<>(jo, QStringLiteral("keys"), pod.keys); - addParam<>(jo, QStringLiteral("signatures"), pod.signatures); -} - -void JsonObjectConverter::fillFrom(const QJsonObject& jo, - DeviceKeys& result) -{ - fromJson(jo.value("user_id"_ls), result.userId); - fromJson(jo.value("device_id"_ls), result.deviceId); - fromJson(jo.value("algorithms"_ls), result.algorithms); - fromJson(jo.value("keys"_ls), result.keys); - fromJson(jo.value("signatures"_ls), result.signatures); -} diff --git a/lib/csapi/definitions/device_keys.h b/lib/csapi/definitions/device_keys.h index a067b4f3..3065f218 100644 --- a/lib/csapi/definitions/device_keys.h +++ b/lib/csapi/definitions/device_keys.h @@ -6,12 +6,7 @@ #include "converters.h" -#include - namespace Quotient { - -// Data structures - /// Device identity keys struct DeviceKeys { /// The ID of the user the device belongs to. Must match the user ID used @@ -40,8 +35,22 @@ struct DeviceKeys { template <> struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const DeviceKeys& pod); - static void fillFrom(const QJsonObject& jo, DeviceKeys& pod); + static void dumpTo(QJsonObject& jo, const DeviceKeys& pod) + { + addParam<>(jo, QStringLiteral("user_id"), pod.userId); + addParam<>(jo, QStringLiteral("device_id"), pod.deviceId); + addParam<>(jo, QStringLiteral("algorithms"), pod.algorithms); + addParam<>(jo, QStringLiteral("keys"), pod.keys); + addParam<>(jo, QStringLiteral("signatures"), pod.signatures); + } + static void fillFrom(const QJsonObject& jo, DeviceKeys& pod) + { + fromJson(jo.value("user_id"_ls), pod.userId); + fromJson(jo.value("device_id"_ls), pod.deviceId); + fromJson(jo.value("algorithms"_ls), pod.algorithms); + fromJson(jo.value("keys"_ls), pod.keys); + fromJson(jo.value("signatures"_ls), pod.signatures); + } }; } // namespace Quotient diff --git a/lib/csapi/definitions/event_filter.cpp b/lib/csapi/definitions/event_filter.cpp deleted file mode 100644 index b21e08b5..00000000 --- a/lib/csapi/definitions/event_filter.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "event_filter.h" - -using namespace Quotient; - -void JsonObjectConverter::dumpTo(QJsonObject& jo, - const EventFilter& pod) -{ - addParam(jo, QStringLiteral("limit"), pod.limit); - addParam(jo, QStringLiteral("not_senders"), pod.notSenders); - addParam(jo, QStringLiteral("not_types"), pod.notTypes); - addParam(jo, QStringLiteral("senders"), pod.senders); - addParam(jo, QStringLiteral("types"), pod.types); -} - -void JsonObjectConverter::fillFrom(const QJsonObject& jo, - EventFilter& result) -{ - fromJson(jo.value("limit"_ls), result.limit); - fromJson(jo.value("not_senders"_ls), result.notSenders); - fromJson(jo.value("not_types"_ls), result.notTypes); - fromJson(jo.value("senders"_ls), result.senders); - fromJson(jo.value("types"_ls), result.types); -} diff --git a/lib/csapi/definitions/event_filter.h b/lib/csapi/definitions/event_filter.h index 3958b125..67497412 100644 --- a/lib/csapi/definitions/event_filter.h +++ b/lib/csapi/definitions/event_filter.h @@ -8,8 +8,6 @@ namespace Quotient { -// Data structures - struct EventFilter { /// The maximum number of events to return. Omittable limit; @@ -37,8 +35,22 @@ struct EventFilter { template <> struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const EventFilter& pod); - static void fillFrom(const QJsonObject& jo, EventFilter& pod); + static void dumpTo(QJsonObject& jo, const EventFilter& pod) + { + addParam(jo, QStringLiteral("limit"), pod.limit); + addParam(jo, QStringLiteral("not_senders"), pod.notSenders); + addParam(jo, QStringLiteral("not_types"), pod.notTypes); + addParam(jo, QStringLiteral("senders"), pod.senders); + addParam(jo, QStringLiteral("types"), pod.types); + } + static void fillFrom(const QJsonObject& jo, EventFilter& pod) + { + fromJson(jo.value("limit"_ls), pod.limit); + fromJson(jo.value("not_senders"_ls), pod.notSenders); + fromJson(jo.value("not_types"_ls), pod.notTypes); + fromJson(jo.value("senders"_ls), pod.senders); + fromJson(jo.value("types"_ls), pod.types); + } }; } // namespace Quotient diff --git a/lib/csapi/definitions/openid_token.h b/lib/csapi/definitions/openid_token.h new file mode 100644 index 00000000..5e68c376 --- /dev/null +++ b/lib/csapi/definitions/openid_token.h @@ -0,0 +1,48 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "converters.h" + +namespace Quotient { + +struct OpenidToken { + /// 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. + QString accessToken; + + /// The string ``Bearer``. + QString tokenType; + + /// The homeserver domain the consumer should use when attempting to + /// verify the user's identity. + QString matrixServerName; + + /// The number of seconds before this token expires and a new one must + /// be generated. + int expiresIn; +}; + +template <> +struct JsonObjectConverter { + static void dumpTo(QJsonObject& jo, const OpenidToken& pod) + { + addParam<>(jo, QStringLiteral("access_token"), pod.accessToken); + addParam<>(jo, QStringLiteral("token_type"), pod.tokenType); + addParam<>(jo, QStringLiteral("matrix_server_name"), + pod.matrixServerName); + addParam<>(jo, QStringLiteral("expires_in"), pod.expiresIn); + } + static void fillFrom(const QJsonObject& jo, OpenidToken& pod) + { + fromJson(jo.value("access_token"_ls), pod.accessToken); + fromJson(jo.value("token_type"_ls), pod.tokenType); + fromJson(jo.value("matrix_server_name"_ls), pod.matrixServerName); + fromJson(jo.value("expires_in"_ls), pod.expiresIn); + } +}; + +} // namespace Quotient diff --git a/lib/csapi/definitions/public_rooms_response.cpp b/lib/csapi/definitions/public_rooms_response.cpp deleted file mode 100644 index b6009718..00000000 --- a/lib/csapi/definitions/public_rooms_response.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "public_rooms_response.h" - -using namespace Quotient; - -void JsonObjectConverter::dumpTo(QJsonObject& jo, - const PublicRoomsChunk& pod) -{ - addParam(jo, QStringLiteral("aliases"), pod.aliases); - addParam(jo, QStringLiteral("canonical_alias"), - pod.canonicalAlias); - addParam(jo, QStringLiteral("name"), pod.name); - addParam<>(jo, QStringLiteral("num_joined_members"), pod.numJoinedMembers); - addParam<>(jo, QStringLiteral("room_id"), pod.roomId); - addParam(jo, QStringLiteral("topic"), pod.topic); - addParam<>(jo, QStringLiteral("world_readable"), pod.worldReadable); - addParam<>(jo, QStringLiteral("guest_can_join"), pod.guestCanJoin); - addParam(jo, QStringLiteral("avatar_url"), pod.avatarUrl); -} - -void JsonObjectConverter::fillFrom(const QJsonObject& jo, - PublicRoomsChunk& result) -{ - fromJson(jo.value("aliases"_ls), result.aliases); - fromJson(jo.value("canonical_alias"_ls), result.canonicalAlias); - fromJson(jo.value("name"_ls), result.name); - fromJson(jo.value("num_joined_members"_ls), result.numJoinedMembers); - fromJson(jo.value("room_id"_ls), result.roomId); - fromJson(jo.value("topic"_ls), result.topic); - fromJson(jo.value("world_readable"_ls), result.worldReadable); - fromJson(jo.value("guest_can_join"_ls), result.guestCanJoin); - fromJson(jo.value("avatar_url"_ls), result.avatarUrl); -} - -void JsonObjectConverter::dumpTo( - QJsonObject& jo, const PublicRoomsResponse& pod) -{ - addParam<>(jo, QStringLiteral("chunk"), pod.chunk); - addParam(jo, QStringLiteral("next_batch"), pod.nextBatch); - addParam(jo, QStringLiteral("prev_batch"), pod.prevBatch); - addParam(jo, QStringLiteral("total_room_count_estimate"), - pod.totalRoomCountEstimate); -} - -void JsonObjectConverter::fillFrom( - const QJsonObject& jo, PublicRoomsResponse& result) -{ - fromJson(jo.value("chunk"_ls), result.chunk); - fromJson(jo.value("next_batch"_ls), result.nextBatch); - fromJson(jo.value("prev_batch"_ls), result.prevBatch); - fromJson(jo.value("total_room_count_estimate"_ls), - result.totalRoomCountEstimate); -} diff --git a/lib/csapi/definitions/public_rooms_response.h b/lib/csapi/definitions/public_rooms_response.h index 36aa52b9..8f30e607 100644 --- a/lib/csapi/definitions/public_rooms_response.h +++ b/lib/csapi/definitions/public_rooms_response.h @@ -6,12 +6,8 @@ #include "converters.h" -#include - namespace Quotient { -// Data structures - struct PublicRoomsChunk { /// Aliases of the room. May be empty. QStringList aliases; @@ -45,9 +41,34 @@ struct PublicRoomsChunk { template <> struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const PublicRoomsChunk& pod); - static void fillFrom(const QJsonObject& jo, PublicRoomsChunk& pod); + static void dumpTo(QJsonObject& jo, const PublicRoomsChunk& pod) + { + addParam(jo, QStringLiteral("aliases"), pod.aliases); + addParam(jo, QStringLiteral("canonical_alias"), + pod.canonicalAlias); + addParam(jo, QStringLiteral("name"), pod.name); + addParam<>(jo, QStringLiteral("num_joined_members"), + pod.numJoinedMembers); + addParam<>(jo, QStringLiteral("room_id"), pod.roomId); + addParam(jo, QStringLiteral("topic"), pod.topic); + addParam<>(jo, QStringLiteral("world_readable"), pod.worldReadable); + addParam<>(jo, QStringLiteral("guest_can_join"), pod.guestCanJoin); + addParam(jo, QStringLiteral("avatar_url"), pod.avatarUrl); + } + static void fillFrom(const QJsonObject& jo, PublicRoomsChunk& pod) + { + fromJson(jo.value("aliases"_ls), pod.aliases); + fromJson(jo.value("canonical_alias"_ls), pod.canonicalAlias); + fromJson(jo.value("name"_ls), pod.name); + fromJson(jo.value("num_joined_members"_ls), pod.numJoinedMembers); + fromJson(jo.value("room_id"_ls), pod.roomId); + fromJson(jo.value("topic"_ls), pod.topic); + fromJson(jo.value("world_readable"_ls), pod.worldReadable); + fromJson(jo.value("guest_can_join"_ls), pod.guestCanJoin); + fromJson(jo.value("avatar_url"_ls), pod.avatarUrl); + } }; + /// A list of the rooms on the server. struct PublicRoomsResponse { /// A paginated chunk of public rooms. @@ -70,8 +91,22 @@ struct PublicRoomsResponse { template <> struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const PublicRoomsResponse& pod); - static void fillFrom(const QJsonObject& jo, PublicRoomsResponse& pod); + static void dumpTo(QJsonObject& jo, const PublicRoomsResponse& pod) + { + addParam<>(jo, QStringLiteral("chunk"), pod.chunk); + addParam(jo, QStringLiteral("next_batch"), pod.nextBatch); + addParam(jo, QStringLiteral("prev_batch"), pod.prevBatch); + addParam(jo, QStringLiteral("total_room_count_estimate"), + pod.totalRoomCountEstimate); + } + static void fillFrom(const QJsonObject& jo, PublicRoomsResponse& pod) + { + fromJson(jo.value("chunk"_ls), pod.chunk); + fromJson(jo.value("next_batch"_ls), pod.nextBatch); + fromJson(jo.value("prev_batch"_ls), pod.prevBatch); + fromJson(jo.value("total_room_count_estimate"_ls), + pod.totalRoomCountEstimate); + } }; } // namespace Quotient diff --git a/lib/csapi/definitions/push_condition.cpp b/lib/csapi/definitions/push_condition.cpp deleted file mode 100644 index 343b4f1a..00000000 --- a/lib/csapi/definitions/push_condition.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "push_condition.h" - -using namespace Quotient; - -void JsonObjectConverter::dumpTo(QJsonObject& jo, - const PushCondition& pod) -{ - addParam<>(jo, QStringLiteral("kind"), pod.kind); - addParam(jo, QStringLiteral("key"), pod.key); - addParam(jo, QStringLiteral("pattern"), pod.pattern); - addParam(jo, QStringLiteral("is"), pod.is); -} - -void JsonObjectConverter::fillFrom(const QJsonObject& jo, - PushCondition& result) -{ - fromJson(jo.value("kind"_ls), result.kind); - fromJson(jo.value("key"_ls), result.key); - fromJson(jo.value("pattern"_ls), result.pattern); - fromJson(jo.value("is"_ls), result.is); -} diff --git a/lib/csapi/definitions/push_condition.h b/lib/csapi/definitions/push_condition.h index 189153b3..a6decf1b 100644 --- a/lib/csapi/definitions/push_condition.h +++ b/lib/csapi/definitions/push_condition.h @@ -8,13 +8,18 @@ namespace Quotient { -// Data structures - struct PushCondition { + /// The kind of condition to apply. See `conditions <#conditions>`_ for + /// more information on the allowed kinds and how they work. QString kind; /// Required for ``event_match`` conditions. The dot-separated field of the /// event to match. + /// + /// Required for ``sender_notification_permission`` conditions. The field in + /// the power level event the user needs a minimum power level for. Fields + /// must be specified under the ``notifications`` property in the power + /// level event's ``content``. QString key; /// Required for ``event_match`` conditions. The glob-style pattern to @@ -32,8 +37,20 @@ struct PushCondition { template <> struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const PushCondition& pod); - static void fillFrom(const QJsonObject& jo, PushCondition& pod); + static void dumpTo(QJsonObject& jo, const PushCondition& pod) + { + addParam<>(jo, QStringLiteral("kind"), pod.kind); + addParam(jo, QStringLiteral("key"), pod.key); + addParam(jo, QStringLiteral("pattern"), pod.pattern); + addParam(jo, QStringLiteral("is"), pod.is); + } + static void fillFrom(const QJsonObject& jo, PushCondition& pod) + { + fromJson(jo.value("kind"_ls), pod.kind); + fromJson(jo.value("key"_ls), pod.key); + fromJson(jo.value("pattern"_ls), pod.pattern); + fromJson(jo.value("is"_ls), pod.is); + } }; } // namespace Quotient diff --git a/lib/csapi/definitions/push_rule.cpp b/lib/csapi/definitions/push_rule.cpp deleted file mode 100644 index eae7e446..00000000 --- a/lib/csapi/definitions/push_rule.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "push_rule.h" - -using namespace Quotient; - -void JsonObjectConverter::dumpTo(QJsonObject& jo, const PushRule& pod) -{ - addParam<>(jo, QStringLiteral("actions"), pod.actions); - addParam<>(jo, QStringLiteral("default"), pod.isDefault); - addParam<>(jo, QStringLiteral("enabled"), pod.enabled); - addParam<>(jo, QStringLiteral("rule_id"), pod.ruleId); - addParam(jo, QStringLiteral("conditions"), pod.conditions); - addParam(jo, QStringLiteral("pattern"), pod.pattern); -} - -void JsonObjectConverter::fillFrom(const QJsonObject& jo, - PushRule& result) -{ - fromJson(jo.value("actions"_ls), result.actions); - fromJson(jo.value("default"_ls), result.isDefault); - fromJson(jo.value("enabled"_ls), result.enabled); - fromJson(jo.value("rule_id"_ls), result.ruleId); - fromJson(jo.value("conditions"_ls), result.conditions); - fromJson(jo.value("pattern"_ls), result.pattern); -} diff --git a/lib/csapi/definitions/push_rule.h b/lib/csapi/definitions/push_rule.h index c09d063f..43749bae 100644 --- a/lib/csapi/definitions/push_rule.h +++ b/lib/csapi/definitions/push_rule.h @@ -8,14 +8,8 @@ #include "csapi/definitions/push_condition.h" -#include -#include -#include - namespace Quotient { -// Data structures - struct PushRule { /// The actions to perform when this rule is matched. QVector actions; @@ -41,8 +35,24 @@ struct PushRule { template <> struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const PushRule& pod); - static void fillFrom(const QJsonObject& jo, PushRule& pod); + static void dumpTo(QJsonObject& jo, const PushRule& pod) + { + addParam<>(jo, QStringLiteral("actions"), pod.actions); + addParam<>(jo, QStringLiteral("default"), pod.isDefault); + addParam<>(jo, QStringLiteral("enabled"), pod.enabled); + addParam<>(jo, QStringLiteral("rule_id"), pod.ruleId); + addParam(jo, QStringLiteral("conditions"), pod.conditions); + addParam(jo, QStringLiteral("pattern"), pod.pattern); + } + static void fillFrom(const QJsonObject& jo, PushRule& pod) + { + fromJson(jo.value("actions"_ls), pod.actions); + fromJson(jo.value("default"_ls), pod.isDefault); + fromJson(jo.value("enabled"_ls), pod.enabled); + fromJson(jo.value("rule_id"_ls), pod.ruleId); + fromJson(jo.value("conditions"_ls), pod.conditions); + fromJson(jo.value("pattern"_ls), pod.pattern); + } }; } // namespace Quotient diff --git a/lib/csapi/definitions/push_ruleset.cpp b/lib/csapi/definitions/push_ruleset.cpp deleted file mode 100644 index a2db35d9..00000000 --- a/lib/csapi/definitions/push_ruleset.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "push_ruleset.h" - -using namespace Quotient; - -void JsonObjectConverter::dumpTo(QJsonObject& jo, - const PushRuleset& pod) -{ - addParam(jo, QStringLiteral("content"), pod.content); - addParam(jo, QStringLiteral("override"), pod.override); - addParam(jo, QStringLiteral("room"), pod.room); - addParam(jo, QStringLiteral("sender"), pod.sender); - addParam(jo, QStringLiteral("underride"), pod.underride); -} - -void JsonObjectConverter::fillFrom(const QJsonObject& jo, - PushRuleset& result) -{ - fromJson(jo.value("content"_ls), result.content); - fromJson(jo.value("override"_ls), result.override); - fromJson(jo.value("room"_ls), result.room); - fromJson(jo.value("sender"_ls), result.sender); - fromJson(jo.value("underride"_ls), result.underride); -} diff --git a/lib/csapi/definitions/push_ruleset.h b/lib/csapi/definitions/push_ruleset.h index 98a21408..ba780a33 100644 --- a/lib/csapi/definitions/push_ruleset.h +++ b/lib/csapi/definitions/push_ruleset.h @@ -8,12 +8,8 @@ #include "csapi/definitions/push_rule.h" -#include - namespace Quotient { -// Data structures - struct PushRuleset { QVector content; @@ -28,8 +24,22 @@ struct PushRuleset { template <> struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const PushRuleset& pod); - static void fillFrom(const QJsonObject& jo, PushRuleset& pod); + static void dumpTo(QJsonObject& jo, const PushRuleset& pod) + { + addParam(jo, QStringLiteral("content"), pod.content); + addParam(jo, QStringLiteral("override"), pod.override); + addParam(jo, QStringLiteral("room"), pod.room); + addParam(jo, QStringLiteral("sender"), pod.sender); + addParam(jo, QStringLiteral("underride"), pod.underride); + } + static void fillFrom(const QJsonObject& jo, PushRuleset& pod) + { + fromJson(jo.value("content"_ls), pod.content); + fromJson(jo.value("override"_ls), pod.override); + fromJson(jo.value("room"_ls), pod.room); + fromJson(jo.value("sender"_ls), pod.sender); + fromJson(jo.value("underride"_ls), pod.underride); + } }; } // namespace Quotient diff --git a/lib/csapi/definitions/request_email_validation.h b/lib/csapi/definitions/request_email_validation.h new file mode 100644 index 00000000..e6ab261d --- /dev/null +++ b/lib/csapi/definitions/request_email_validation.h @@ -0,0 +1,48 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "converters.h" + +#include "csapi/./definitions/../../identity/definitions/request_email_validation.h" + +namespace Quotient { + +struct EmailValidationData : RequestEmailValidation { + /// The hostname of the identity server to communicate with. May optionally + /// include a port. This parameter is ignored when the homeserver handles + /// 3PID verification. + /// + /// This parameter is deprecated with a plan to be removed in a future + /// specification version for ``/account/password`` and ``/register`` + /// requests. + 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. + /// + /// Required if an ``id_server`` is supplied. + QString idAccessToken; +}; + +template <> +struct JsonObjectConverter { + static void dumpTo(QJsonObject& jo, const EmailValidationData& pod) + { + fillJson(jo, pod); + addParam(jo, QStringLiteral("id_server"), pod.idServer); + addParam(jo, QStringLiteral("id_access_token"), + pod.idAccessToken); + } + static void fillFrom(const QJsonObject& jo, EmailValidationData& pod) + { + fillFromJson(jo, pod); + fromJson(jo.value("id_server"_ls), pod.idServer); + fromJson(jo.value("id_access_token"_ls), pod.idAccessToken); + } +}; + +} // namespace Quotient diff --git a/lib/csapi/definitions/request_msisdn_validation.h b/lib/csapi/definitions/request_msisdn_validation.h new file mode 100644 index 00000000..6f161f00 --- /dev/null +++ b/lib/csapi/definitions/request_msisdn_validation.h @@ -0,0 +1,48 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "converters.h" + +#include "csapi/./definitions/../../identity/definitions/request_msisdn_validation.h" + +namespace Quotient { + +struct MsisdnValidationData : RequestMsisdnValidation { + /// The hostname of the identity server to communicate with. May optionally + /// include a port. This parameter is ignored when the homeserver handles + /// 3PID verification. + /// + /// This parameter is deprecated with a plan to be removed in a future + /// specification version for ``/account/password`` and ``/register`` + /// requests. + 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. + /// + /// Required if an ``id_server`` is supplied. + QString idAccessToken; +}; + +template <> +struct JsonObjectConverter { + static void dumpTo(QJsonObject& jo, const MsisdnValidationData& pod) + { + fillJson(jo, pod); + addParam(jo, QStringLiteral("id_server"), pod.idServer); + addParam(jo, QStringLiteral("id_access_token"), + pod.idAccessToken); + } + static void fillFrom(const QJsonObject& jo, MsisdnValidationData& pod) + { + fillFromJson(jo, pod); + fromJson(jo.value("id_server"_ls), pod.idServer); + fromJson(jo.value("id_access_token"_ls), pod.idAccessToken); + } +}; + +} // namespace Quotient diff --git a/lib/csapi/definitions/request_token_response.h b/lib/csapi/definitions/request_token_response.h new file mode 100644 index 00000000..00222839 --- /dev/null +++ b/lib/csapi/definitions/request_token_response.h @@ -0,0 +1,45 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "converters.h" + +namespace Quotient { + +struct 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. + QString sid; + + /// An optional field containing a URL where the client must submit the + /// validation token to, with identical parameters to the Identity Service + /// API's ``POST /validate/email/submitToken`` endpoint (without the + /// requirement for an access token). The homeserver must send this token to + /// the user (if applicable), who should then be prompted to provide it to + /// the client. + /// + /// If this field is not present, the client can assume that verification + /// will happen without the client's involvement provided the homeserver + /// advertises this specification version in the ``/versions`` response + /// (ie: r0.5.0). + QString submitUrl; +}; + +template <> +struct JsonObjectConverter { + static void dumpTo(QJsonObject& jo, const RequestTokenResponse& pod) + { + addParam<>(jo, QStringLiteral("sid"), pod.sid); + addParam(jo, QStringLiteral("submit_url"), pod.submitUrl); + } + static void fillFrom(const QJsonObject& jo, RequestTokenResponse& pod) + { + fromJson(jo.value("sid"_ls), pod.sid); + fromJson(jo.value("submit_url"_ls), pod.submitUrl); + } +}; + +} // namespace Quotient diff --git a/lib/csapi/definitions/room_event_filter.cpp b/lib/csapi/definitions/room_event_filter.cpp deleted file mode 100644 index 5613d8d2..00000000 --- a/lib/csapi/definitions/room_event_filter.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "room_event_filter.h" - -using namespace Quotient; - -void JsonObjectConverter::dumpTo(QJsonObject& jo, - const RoomEventFilter& pod) -{ - fillJson(jo, pod); - addParam(jo, QStringLiteral("not_rooms"), pod.notRooms); - addParam(jo, QStringLiteral("rooms"), pod.rooms); - addParam(jo, QStringLiteral("contains_url"), pod.containsUrl); -} - -void JsonObjectConverter::fillFrom(const QJsonObject& jo, - RoomEventFilter& result) -{ - fillFromJson(jo, result); - fromJson(jo.value("not_rooms"_ls), result.notRooms); - fromJson(jo.value("rooms"_ls), result.rooms); - fromJson(jo.value("contains_url"_ls), result.containsUrl); -} diff --git a/lib/csapi/definitions/room_event_filter.h b/lib/csapi/definitions/room_event_filter.h index 756f9ada..11e87fde 100644 --- a/lib/csapi/definitions/room_event_filter.h +++ b/lib/csapi/definitions/room_event_filter.h @@ -10,9 +10,19 @@ namespace Quotient { -// Data structures - struct RoomEventFilter : EventFilter { + /// If ``true``, enables lazy-loading of membership events. See + /// `Lazy-loading room members <#lazy-loading-room-members>`_ + /// for more information. Defaults to ``false``. + Omittable lazyLoadMembers; + + /// If ``true``, sends all membership events for all events, even if they + /// have already been sent to the client. Does not apply unless + /// ``lazy_load_members`` is ``true``. See `Lazy-loading room members + /// <#lazy-loading-room-members>`_ for more information. Defaults to + /// ``false``. + Omittable includeRedundantMembers; + /// 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. @@ -30,8 +40,28 @@ struct RoomEventFilter : EventFilter { template <> struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const RoomEventFilter& pod); - static void fillFrom(const QJsonObject& jo, RoomEventFilter& pod); + static void dumpTo(QJsonObject& jo, const RoomEventFilter& pod) + { + fillJson(jo, pod); + addParam(jo, QStringLiteral("lazy_load_members"), + pod.lazyLoadMembers); + addParam(jo, QStringLiteral("include_redundant_members"), + pod.includeRedundantMembers); + addParam(jo, QStringLiteral("not_rooms"), pod.notRooms); + addParam(jo, QStringLiteral("rooms"), pod.rooms); + addParam(jo, QStringLiteral("contains_url"), + pod.containsUrl); + } + static void fillFrom(const QJsonObject& jo, RoomEventFilter& pod) + { + fillFromJson(jo, pod); + fromJson(jo.value("lazy_load_members"_ls), pod.lazyLoadMembers); + fromJson(jo.value("include_redundant_members"_ls), + pod.includeRedundantMembers); + fromJson(jo.value("not_rooms"_ls), pod.notRooms); + fromJson(jo.value("rooms"_ls), pod.rooms); + fromJson(jo.value("contains_url"_ls), pod.containsUrl); + } }; } // namespace Quotient diff --git a/lib/csapi/definitions/sync_filter.cpp b/lib/csapi/definitions/sync_filter.cpp deleted file mode 100644 index 15c4bdc1..00000000 --- a/lib/csapi/definitions/sync_filter.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "sync_filter.h" - -using namespace Quotient; - -void JsonObjectConverter::dumpTo(QJsonObject& jo, - const StateFilter& pod) -{ - fillJson(jo, pod); - addParam(jo, QStringLiteral("lazy_load_members"), - pod.lazyLoadMembers); - addParam(jo, QStringLiteral("include_redundant_members"), - pod.includeRedundantMembers); -} - -void JsonObjectConverter::fillFrom(const QJsonObject& jo, - StateFilter& result) -{ - fillFromJson(jo, result); - fromJson(jo.value("lazy_load_members"_ls), result.lazyLoadMembers); - fromJson(jo.value("include_redundant_members"_ls), - result.includeRedundantMembers); -} - -void JsonObjectConverter::dumpTo(QJsonObject& jo, - const RoomFilter& pod) -{ - addParam(jo, QStringLiteral("not_rooms"), pod.notRooms); - addParam(jo, QStringLiteral("rooms"), pod.rooms); - addParam(jo, QStringLiteral("ephemeral"), pod.ephemeral); - addParam(jo, QStringLiteral("include_leave"), pod.includeLeave); - addParam(jo, QStringLiteral("state"), pod.state); - addParam(jo, QStringLiteral("timeline"), pod.timeline); - addParam(jo, QStringLiteral("account_data"), pod.accountData); -} - -void JsonObjectConverter::fillFrom(const QJsonObject& jo, - RoomFilter& result) -{ - fromJson(jo.value("not_rooms"_ls), result.notRooms); - fromJson(jo.value("rooms"_ls), result.rooms); - fromJson(jo.value("ephemeral"_ls), result.ephemeral); - fromJson(jo.value("include_leave"_ls), result.includeLeave); - fromJson(jo.value("state"_ls), result.state); - fromJson(jo.value("timeline"_ls), result.timeline); - fromJson(jo.value("account_data"_ls), result.accountData); -} - -void JsonObjectConverter::dumpTo(QJsonObject& jo, const Filter& pod) -{ - addParam(jo, QStringLiteral("event_fields"), pod.eventFields); - addParam(jo, QStringLiteral("event_format"), pod.eventFormat); - addParam(jo, QStringLiteral("presence"), pod.presence); - addParam(jo, QStringLiteral("account_data"), pod.accountData); - addParam(jo, QStringLiteral("room"), pod.room); -} - -void JsonObjectConverter::fillFrom(const QJsonObject& jo, Filter& result) -{ - fromJson(jo.value("event_fields"_ls), result.eventFields); - fromJson(jo.value("event_format"_ls), result.eventFormat); - fromJson(jo.value("presence"_ls), result.presence); - fromJson(jo.value("account_data"_ls), result.accountData); - fromJson(jo.value("room"_ls), result.room); -} diff --git a/lib/csapi/definitions/sync_filter.h b/lib/csapi/definitions/sync_filter.h index ad8d055d..9c8f08d5 100644 --- a/lib/csapi/definitions/sync_filter.h +++ b/lib/csapi/definitions/sync_filter.h @@ -10,40 +10,6 @@ #include "csapi/definitions/room_event_filter.h" namespace Quotient { - -// Data structures - -/// The state events to include for rooms. -struct StateFilter : RoomEventFilter { - /// If ``true``, the only ``m.room.member`` events returned in - /// the ``state`` section of the ``/sync`` response are those - /// which are definitely necessary for a client to display - /// the ``sender`` of the timeline events in that response. - /// If ``false``, ``m.room.member`` events are not filtered. - /// By default, servers should suppress duplicate redundant - /// lazy-loaded ``m.room.member`` events from being sent to a given - /// client across multiple calls to ``/sync``, given that most clients - /// cache membership events (see ``include_redundant_members`` - /// to change this behaviour). - Omittable lazyLoadMembers; - - /// If ``true``, the ``state`` section of the ``/sync`` response will - /// always contain the ``m.room.member`` events required to display - /// the ``sender`` of the timeline events in that response, assuming - /// ``lazy_load_members`` is enabled. This means that redundant - /// duplicate member events may be returned across multiple calls to - /// ``/sync``. This is useful for naive clients who never track - /// membership data. If ``false``, duplicate ``m.room.member`` events - /// may be suppressed by the server across multiple calls to ``/sync``. - /// If ``lazy_load_members`` is ``false`` this field is ignored. - Omittable includeRedundantMembers; -}; - -template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const StateFilter& pod); - static void fillFrom(const QJsonObject& jo, StateFilter& pod); -}; /// Filters to be applied to room data. struct RoomFilter { /// A list of room IDs to exclude. If this list is absent then no rooms are @@ -59,30 +25,50 @@ struct RoomFilter { /// The events that aren't recorded in the room history, e.g. typing and /// receipts, to include for rooms. - Omittable ephemeral; + RoomEventFilter ephemeral; /// Include rooms that the user has left in the sync, default false Omittable includeLeave; /// The state events to include for rooms. - Omittable state; + RoomEventFilter state; /// The message and state update events to include for rooms. - Omittable timeline; + RoomEventFilter timeline; /// The per user account data to include for rooms. - Omittable accountData; + RoomEventFilter accountData; }; template <> struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const RoomFilter& pod); - static void fillFrom(const QJsonObject& jo, RoomFilter& pod); + static void dumpTo(QJsonObject& jo, const RoomFilter& pod) + { + addParam(jo, QStringLiteral("not_rooms"), pod.notRooms); + addParam(jo, QStringLiteral("rooms"), pod.rooms); + addParam(jo, QStringLiteral("ephemeral"), pod.ephemeral); + addParam(jo, QStringLiteral("include_leave"), + pod.includeLeave); + addParam(jo, QStringLiteral("state"), pod.state); + addParam(jo, QStringLiteral("timeline"), pod.timeline); + addParam(jo, QStringLiteral("account_data"), + pod.accountData); + } + static void fillFrom(const QJsonObject& jo, RoomFilter& pod) + { + fromJson(jo.value("not_rooms"_ls), pod.notRooms); + fromJson(jo.value("rooms"_ls), pod.rooms); + fromJson(jo.value("ephemeral"_ls), pod.ephemeral); + fromJson(jo.value("include_leave"_ls), pod.includeLeave); + fromJson(jo.value("state"_ls), pod.state); + fromJson(jo.value("timeline"_ls), pod.timeline); + fromJson(jo.value("account_data"_ls), pod.accountData); + } }; struct Filter { /// List of event fields to include. If this list is absent then all fields - /// are included. The entries may include '.' charaters to indicate + /// are included. The entries may include '.' characters to indicate /// sub-fields. So ['content.body'] will include the 'body' field of the /// 'content' object. A literal '.' character in a field name may be escaped /// using a '\\'. A server may include more fields than were requested. @@ -90,23 +76,40 @@ struct Filter { /// The format to use for events. 'client' will return the events in a /// format suitable for clients. 'federation' will return the raw event as - /// receieved over federation. The default is 'client'. + /// received over federation. The default is 'client'. QString eventFormat; /// The presence updates to include. - Omittable presence; + EventFilter presence; /// The user account data that isn't associated with rooms to include. - Omittable accountData; + EventFilter accountData; /// Filters to be applied to room data. - Omittable room; + RoomFilter room; }; template <> struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const Filter& pod); - static void fillFrom(const QJsonObject& jo, Filter& pod); + static void dumpTo(QJsonObject& jo, const Filter& pod) + { + addParam(jo, QStringLiteral("event_fields"), + pod.eventFields); + addParam(jo, QStringLiteral("event_format"), + pod.eventFormat); + addParam(jo, QStringLiteral("presence"), pod.presence); + addParam(jo, QStringLiteral("account_data"), + pod.accountData); + addParam(jo, QStringLiteral("room"), pod.room); + } + static void fillFrom(const QJsonObject& jo, Filter& pod) + { + fromJson(jo.value("event_fields"_ls), pod.eventFields); + fromJson(jo.value("event_format"_ls), pod.eventFormat); + fromJson(jo.value("presence"_ls), pod.presence); + fromJson(jo.value("account_data"_ls), pod.accountData); + fromJson(jo.value("room"_ls), pod.room); + } }; } // namespace Quotient diff --git a/lib/csapi/definitions/third_party_signed.h b/lib/csapi/definitions/third_party_signed.h new file mode 100644 index 00000000..526545d0 --- /dev/null +++ b/lib/csapi/definitions/third_party_signed.h @@ -0,0 +1,44 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "converters.h" + +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 ThirdPartySigned { + /// The Matrix ID of the user who issued the invite. + QString sender; + + /// The Matrix ID of the invitee. + QString mxid; + + /// The state key of the m.third_party_invite event. + QString token; + + /// A signatures object containing a signature of the entire signed object. + QHash> signatures; +}; + +template <> +struct JsonObjectConverter { + static void dumpTo(QJsonObject& jo, const ThirdPartySigned& pod) + { + addParam<>(jo, QStringLiteral("sender"), pod.sender); + addParam<>(jo, QStringLiteral("mxid"), pod.mxid); + addParam<>(jo, QStringLiteral("token"), pod.token); + addParam<>(jo, QStringLiteral("signatures"), pod.signatures); + } + static void fillFrom(const QJsonObject& jo, ThirdPartySigned& pod) + { + fromJson(jo.value("sender"_ls), pod.sender); + fromJson(jo.value("mxid"_ls), pod.mxid); + fromJson(jo.value("token"_ls), pod.token); + fromJson(jo.value("signatures"_ls), pod.signatures); + } +}; + +} // namespace Quotient diff --git a/lib/csapi/definitions/user_identifier.cpp b/lib/csapi/definitions/user_identifier.cpp deleted file mode 100644 index 9e9b4fe9..00000000 --- a/lib/csapi/definitions/user_identifier.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "user_identifier.h" - -using namespace Quotient; - -void JsonObjectConverter::dumpTo(QJsonObject& jo, - const UserIdentifier& pod) -{ - fillJson(jo, pod.additionalProperties); - addParam<>(jo, QStringLiteral("type"), pod.type); -} - -void JsonObjectConverter::fillFrom(QJsonObject jo, - UserIdentifier& result) -{ - fromJson(jo.take("type"_ls), result.type); - fromJson(jo, result.additionalProperties); -} diff --git a/lib/csapi/definitions/user_identifier.h b/lib/csapi/definitions/user_identifier.h index 72a81677..dadf6f97 100644 --- a/lib/csapi/definitions/user_identifier.h +++ b/lib/csapi/definitions/user_identifier.h @@ -6,12 +6,7 @@ #include "converters.h" -#include - namespace Quotient { - -// Data structures - /// Identification information for a user struct UserIdentifier { /// The type of identification. See `Identifier types`_ for supported @@ -24,8 +19,16 @@ struct UserIdentifier { template <> struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const UserIdentifier& pod); - static void fillFrom(QJsonObject jo, UserIdentifier& pod); + static void dumpTo(QJsonObject& jo, const UserIdentifier& pod) + { + fillJson(jo, pod.additionalProperties); + addParam<>(jo, QStringLiteral("type"), pod.type); + } + static void fillFrom(QJsonObject jo, UserIdentifier& pod) + { + fromJson(jo.take("type"_ls), pod.type); + fromJson(jo, pod.additionalProperties); + } }; } // namespace Quotient diff --git a/lib/csapi/definitions/wellknown/full.cpp b/lib/csapi/definitions/wellknown/full.cpp deleted file mode 100644 index 595db0e5..00000000 --- a/lib/csapi/definitions/wellknown/full.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "full.h" - -using namespace Quotient; - -void JsonObjectConverter::dumpTo( - QJsonObject& jo, const DiscoveryInformation& pod) -{ - fillJson(jo, pod.additionalProperties); - addParam<>(jo, QStringLiteral("m.homeserver"), pod.homeserver); - addParam(jo, QStringLiteral("m.identity_server"), - pod.identityServer); -} - -void JsonObjectConverter::fillFrom( - QJsonObject jo, DiscoveryInformation& result) -{ - fromJson(jo.take("m.homeserver"_ls), result.homeserver); - fromJson(jo.take("m.identity_server"_ls), result.identityServer); - fromJson(jo, result.additionalProperties); -} diff --git a/lib/csapi/definitions/wellknown/full.h b/lib/csapi/definitions/wellknown/full.h index 88d7da79..a0ef2076 100644 --- a/lib/csapi/definitions/wellknown/full.h +++ b/lib/csapi/definitions/wellknown/full.h @@ -9,13 +9,7 @@ #include "csapi/definitions/wellknown/homeserver.h" #include "csapi/definitions/wellknown/identity_server.h" -#include -#include - namespace Quotient { - -// Data structures - /// Used by clients to determine the homeserver, identity server, and other /// optional components they should be interacting with. struct DiscoveryInformation { @@ -33,8 +27,19 @@ struct DiscoveryInformation { template <> struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const DiscoveryInformation& pod); - static void fillFrom(QJsonObject jo, DiscoveryInformation& pod); + static void dumpTo(QJsonObject& jo, const DiscoveryInformation& pod) + { + fillJson(jo, pod.additionalProperties); + addParam<>(jo, QStringLiteral("m.homeserver"), pod.homeserver); + addParam(jo, QStringLiteral("m.identity_server"), + pod.identityServer); + } + static void fillFrom(QJsonObject jo, DiscoveryInformation& pod) + { + fromJson(jo.take("m.homeserver"_ls), pod.homeserver); + fromJson(jo.take("m.identity_server"_ls), pod.identityServer); + fromJson(jo, pod.additionalProperties); + } }; } // namespace Quotient diff --git a/lib/csapi/definitions/wellknown/homeserver.cpp b/lib/csapi/definitions/wellknown/homeserver.cpp deleted file mode 100644 index 7b87aa95..00000000 --- a/lib/csapi/definitions/wellknown/homeserver.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "homeserver.h" - -using namespace Quotient; - -void JsonObjectConverter::dumpTo( - QJsonObject& jo, const HomeserverInformation& pod) -{ - addParam<>(jo, QStringLiteral("base_url"), pod.baseUrl); -} - -void JsonObjectConverter::fillFrom( - const QJsonObject& jo, HomeserverInformation& result) -{ - fromJson(jo.value("base_url"_ls), result.baseUrl); -} diff --git a/lib/csapi/definitions/wellknown/homeserver.h b/lib/csapi/definitions/wellknown/homeserver.h index 7607c8b5..5cfaca24 100644 --- a/lib/csapi/definitions/wellknown/homeserver.h +++ b/lib/csapi/definitions/wellknown/homeserver.h @@ -7,9 +7,6 @@ #include "converters.h" namespace Quotient { - -// Data structures - /// Used by clients to discover homeserver information. struct HomeserverInformation { /// The base URL for the homeserver for client-server connections. @@ -18,8 +15,14 @@ struct HomeserverInformation { template <> struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const HomeserverInformation& pod); - static void fillFrom(const QJsonObject& jo, HomeserverInformation& pod); + static void dumpTo(QJsonObject& jo, const HomeserverInformation& pod) + { + addParam<>(jo, QStringLiteral("base_url"), pod.baseUrl); + } + static void fillFrom(const QJsonObject& jo, HomeserverInformation& pod) + { + fromJson(jo.value("base_url"_ls), pod.baseUrl); + } }; } // namespace Quotient diff --git a/lib/csapi/definitions/wellknown/identity_server.cpp b/lib/csapi/definitions/wellknown/identity_server.cpp deleted file mode 100644 index 3b2a5720..00000000 --- a/lib/csapi/definitions/wellknown/identity_server.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "identity_server.h" - -using namespace Quotient; - -void JsonObjectConverter::dumpTo( - QJsonObject& jo, const IdentityServerInformation& pod) -{ - addParam<>(jo, QStringLiteral("base_url"), pod.baseUrl); -} - -void JsonObjectConverter::fillFrom( - const QJsonObject& jo, IdentityServerInformation& result) -{ - fromJson(jo.value("base_url"_ls), result.baseUrl); -} diff --git a/lib/csapi/definitions/wellknown/identity_server.h b/lib/csapi/definitions/wellknown/identity_server.h index d272e527..3bd07bd1 100644 --- a/lib/csapi/definitions/wellknown/identity_server.h +++ b/lib/csapi/definitions/wellknown/identity_server.h @@ -7,9 +7,6 @@ #include "converters.h" namespace Quotient { - -// Data structures - /// Used by clients to discover identity server information. struct IdentityServerInformation { /// The base URL for the identity server for client-server connections. @@ -18,8 +15,14 @@ struct IdentityServerInformation { template <> struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const IdentityServerInformation& pod); - static void fillFrom(const QJsonObject& jo, IdentityServerInformation& pod); + static void dumpTo(QJsonObject& jo, const IdentityServerInformation& pod) + { + addParam<>(jo, QStringLiteral("base_url"), pod.baseUrl); + } + static void fillFrom(const QJsonObject& jo, IdentityServerInformation& pod) + { + fromJson(jo.value("base_url"_ls), pod.baseUrl); + } }; } // namespace Quotient diff --git a/lib/csapi/device_management.cpp b/lib/csapi/device_management.cpp index ba7570f7..eac9a545 100644 --- a/lib/csapi/device_management.cpp +++ b/lib/csapi/device_management.cpp @@ -4,97 +4,61 @@ #include "device_management.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -class GetDevicesJob::Private { -public: - QVector devices; -}; - QUrl GetDevicesJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/devices"); + return BaseJob::makeRequestUrl(std::move(baseUrl), + QStringLiteral("/_matrix/client/r0") + % "/devices"); } GetDevicesJob::GetDevicesJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetDevicesJob"), - basePath % "/devices") - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/devices") {} -GetDevicesJob::~GetDevicesJob() = default; - -const QVector& GetDevicesJob::devices() const { return d->devices; } - -BaseJob::Status GetDevicesJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("devices"_ls), d->devices); - - return Success; -} - -class GetDeviceJob::Private { -public: - Device data; -}; - QUrl GetDeviceJob::makeRequestUrl(QUrl baseUrl, const QString& deviceId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/devices/" % deviceId); + QStringLiteral("/_matrix/client/r0") + % "/devices/" % deviceId); } GetDeviceJob::GetDeviceJob(const QString& deviceId) : BaseJob(HttpVerb::Get, QStringLiteral("GetDeviceJob"), - basePath % "/devices/" % deviceId) - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/devices/" % deviceId) {} -GetDeviceJob::~GetDeviceJob() = default; - -const Device& GetDeviceJob::data() const { return d->data; } - -BaseJob::Status GetDeviceJob::parseJson(const QJsonDocument& data) -{ - fromJson(data, d->data); - - return Success; -} - UpdateDeviceJob::UpdateDeviceJob(const QString& deviceId, const QString& displayName) : BaseJob(HttpVerb::Put, QStringLiteral("UpdateDeviceJob"), - basePath % "/devices/" % deviceId) + QStringLiteral("/_matrix/client/r0") % "/devices/" % deviceId) { QJsonObject _data; addParam(_data, QStringLiteral("display_name"), displayName); - setRequestData(_data); + setRequestData(std::move(_data)); } DeleteDeviceJob::DeleteDeviceJob(const QString& deviceId, const Omittable& auth) : BaseJob(HttpVerb::Delete, QStringLiteral("DeleteDeviceJob"), - basePath % "/devices/" % deviceId) + QStringLiteral("/_matrix/client/r0") % "/devices/" % deviceId) { QJsonObject _data; addParam(_data, QStringLiteral("auth"), auth); - setRequestData(_data); + setRequestData(std::move(_data)); } DeleteDevicesJob::DeleteDevicesJob(const QStringList& devices, const Omittable& auth) : BaseJob(HttpVerb::Post, QStringLiteral("DeleteDevicesJob"), - basePath % "/delete_devices") + QStringLiteral("/_matrix/client/r0") % "/delete_devices") { QJsonObject _data; addParam<>(_data, QStringLiteral("devices"), devices); addParam(_data, QStringLiteral("auth"), auth); - setRequestData(_data); + setRequestData(std::move(_data)); } diff --git a/lib/csapi/device_management.h b/lib/csapi/device_management.h index 1c57db84..0abd5b84 100644 --- a/lib/csapi/device_management.h +++ b/lib/csapi/device_management.h @@ -4,19 +4,13 @@ #pragma once -#include "converters.h" - #include "csapi/definitions/auth_data.h" #include "csapi/definitions/client_device.h" #include "jobs/basejob.h" -#include - namespace Quotient { -// Operations - /*! \brief List registered devices for the current user * * Gets information about all devices for the current user. @@ -32,19 +26,14 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetDevicesJob() override; // Result properties /// A list of all registered devices for this user. - const QVector& devices() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QVector devices() const + { + return loadFromJson>("devices"_ls); + } }; /*! \brief Get a single device @@ -54,6 +43,7 @@ private: class GetDeviceJob : public BaseJob { public: /*! \brief Get a single device + * * * \param deviceId * The device to retrieve. @@ -66,19 +56,11 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& deviceId); - ~GetDeviceJob() override; // Result properties /// Device information - const Device& data() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + Device data() const { return fromJson(jsonData()); } }; /*! \brief Update a device @@ -88,9 +70,11 @@ private: class UpdateDeviceJob : public BaseJob { public: /*! \brief Update a device + * * * \param deviceId * The device to update. + * * \param displayName * The new display name for this device. If not given, the * display name is unchanged. @@ -108,9 +92,11 @@ public: class DeleteDeviceJob : public BaseJob { public: /*! \brief Delete a device + * * * \param deviceId * The device to delete. + * * \param auth * Additional authentication information for the * user-interactive authentication API. @@ -129,9 +115,11 @@ public: class DeleteDevicesJob : public BaseJob { public: /*! \brief Bulk deletion of devices + * * * \param devices * The list of device IDs to delete. + * * \param auth * Additional authentication information for the * user-interactive authentication API. diff --git a/lib/csapi/directory.cpp b/lib/csapi/directory.cpp index 0d4029bd..25ea82e2 100644 --- a/lib/csapi/directory.cpp +++ b/lib/csapi/directory.cpp @@ -4,63 +4,58 @@ #include "directory.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0/directory"); - SetRoomAliasJob::SetRoomAliasJob(const QString& roomAlias, const QString& roomId) : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomAliasJob"), - basePath % "/room/" % roomAlias) + QStringLiteral("/_matrix/client/r0") % "/directory/room/" + % roomAlias) { QJsonObject _data; addParam<>(_data, QStringLiteral("room_id"), roomId); - setRequestData(_data); + setRequestData(std::move(_data)); } -class GetRoomIdByAliasJob::Private { -public: - QString roomId; - QStringList servers; -}; - QUrl GetRoomIdByAliasJob::makeRequestUrl(QUrl baseUrl, const QString& roomAlias) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/room/" % roomAlias); + QStringLiteral("/_matrix/client/r0") + % "/directory/room/" % roomAlias); } GetRoomIdByAliasJob::GetRoomIdByAliasJob(const QString& roomAlias) : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomIdByAliasJob"), - basePath % "/room/" % roomAlias, false) - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/directory/room/" + % roomAlias, + false) {} -GetRoomIdByAliasJob::~GetRoomIdByAliasJob() = default; - -const QString& GetRoomIdByAliasJob::roomId() const { return d->roomId; } - -const QStringList& GetRoomIdByAliasJob::servers() const { return d->servers; } - -BaseJob::Status GetRoomIdByAliasJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("room_id"_ls), d->roomId); - fromJson(json.value("servers"_ls), d->servers); - - return Success; -} - QUrl DeleteRoomAliasJob::makeRequestUrl(QUrl baseUrl, const QString& roomAlias) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/room/" % roomAlias); + QStringLiteral("/_matrix/client/r0") + % "/directory/room/" % roomAlias); } DeleteRoomAliasJob::DeleteRoomAliasJob(const QString& roomAlias) : BaseJob(HttpVerb::Delete, QStringLiteral("DeleteRoomAliasJob"), - basePath % "/room/" % roomAlias) + QStringLiteral("/_matrix/client/r0") % "/directory/room/" + % roomAlias) {} + +QUrl GetLocalAliasesJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) +{ + return BaseJob::makeRequestUrl(std::move(baseUrl), + QStringLiteral("/_matrix/client/r0") + % "/rooms/" % roomId % "/aliases"); +} + +GetLocalAliasesJob::GetLocalAliasesJob(const QString& roomId) + : BaseJob(HttpVerb::Get, QStringLiteral("GetLocalAliasesJob"), + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId + % "/aliases") +{ + addExpectedKey("aliases"); +} diff --git a/lib/csapi/directory.h b/lib/csapi/directory.h index c13ca20a..7ae44d1d 100644 --- a/lib/csapi/directory.h +++ b/lib/csapi/directory.h @@ -8,17 +8,17 @@ namespace Quotient { -// Operations - /*! \brief Create a new mapping from room alias to room ID. * */ class SetRoomAliasJob : public BaseJob { public: /*! \brief Create a new mapping from room alias to room ID. + * * * \param roomAlias * The room alias to set. + * * \param roomId * The room ID to set. */ @@ -36,6 +36,7 @@ public: class GetRoomIdByAliasJob : public BaseJob { public: /*! \brief Get the room ID corresponding to this room alias. + * * * \param roomAlias * The room alias. @@ -48,22 +49,17 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomAlias); - ~GetRoomIdByAliasJob() override; // Result properties /// The room ID for this room alias. - const QString& roomId() const; + QString roomId() const { return loadFromJson("room_id"_ls); } /// A list of servers that are aware of this room alias. - const QStringList& servers() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QStringList servers() const + { + return loadFromJson("servers"_ls); + } }; /*! \brief Remove a mapping of room alias to room ID. @@ -73,10 +69,19 @@ private: * Servers may choose to implement additional access control checks here, for * instance that room aliases can only be deleted by their creator or a server * administrator. + * + * .. Note:: + * Servers may choose to update the ``alt_aliases`` for the + * ``m.room.canonical_alias`` state event in the room when an alias is removed. + * Servers which choose to update the 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 DeleteRoomAliasJob : public BaseJob { public: /*! \brief Remove a mapping of room alias to room ID. + * * * \param roomAlias * The room alias to remove. @@ -91,4 +96,49 @@ public: static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomAlias); }; +/*! \brief Get a list of local aliases on a given room. + * + * Get a list of aliases maintained by the local server for the + * given room. + * + * This endpoint can be called by users who are in the room (external + * users receive an ``M_FORBIDDEN`` error response). If the room's + * ``m.room.history_visibility`` maps to ``world_readable``, any + * user can call this endpoint. + * + * Servers may choose to implement additional access control checks here, + * such as allowing server administrators to view aliases regardless of + * membership. + * + * .. Note:: + * 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 GetLocalAliasesJob : public BaseJob { +public: + /*! \brief Get a list of local aliases on a given room. + * + * + * \param roomId + * The room ID to find local aliases of. + */ + 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(QUrl baseUrl, const QString& roomId); + + // Result properties + + /// The server's local aliases on the room. Can be empty. + QStringList aliases() const + { + return loadFromJson("aliases"_ls); + } +}; + } // namespace Quotient diff --git a/lib/csapi/event_context.cpp b/lib/csapi/event_context.cpp index 5bb2222e..d2a5f522 100644 --- a/lib/csapi/event_context.cpp +++ b/lib/csapi/event_context.cpp @@ -4,79 +4,36 @@ #include "event_context.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -class GetEventContextJob::Private { -public: - QString begin; - QString end; - RoomEvents eventsBefore; - RoomEventPtr event; - RoomEvents eventsAfter; - StateEvents state; -}; - -BaseJob::Query queryToGetEventContext(Omittable limit) +auto queryToGetEventContext(Omittable limit, const QString& filter) { BaseJob::Query _q; addParam(_q, QStringLiteral("limit"), limit); + addParam(_q, QStringLiteral("filter"), filter); return _q; } QUrl GetEventContextJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& eventId, - Omittable limit) + Omittable limit, + const QString& filter) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/rooms/" % roomId % "/context/" + QStringLiteral("/_matrix/client/r0") + % "/rooms/" % roomId % "/context/" % eventId, - queryToGetEventContext(limit)); + queryToGetEventContext(limit, filter)); } GetEventContextJob::GetEventContextJob(const QString& roomId, const QString& eventId, - Omittable limit) + Omittable limit, + const QString& filter) : BaseJob(HttpVerb::Get, QStringLiteral("GetEventContextJob"), - basePath % "/rooms/" % roomId % "/context/" % eventId, - queryToGetEventContext(limit)) - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId + % "/context/" % eventId, + queryToGetEventContext(limit, filter)) {} - -GetEventContextJob::~GetEventContextJob() = default; - -const QString& GetEventContextJob::begin() const { return d->begin; } - -const QString& GetEventContextJob::end() const { return d->end; } - -RoomEvents&& GetEventContextJob::eventsBefore() -{ - return std::move(d->eventsBefore); -} - -RoomEventPtr&& GetEventContextJob::event() { return std::move(d->event); } - -RoomEvents&& GetEventContextJob::eventsAfter() -{ - return std::move(d->eventsAfter); -} - -StateEvents&& GetEventContextJob::state() { return std::move(d->state); } - -BaseJob::Status GetEventContextJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("start"_ls), d->begin); - fromJson(json.value("end"_ls), d->end); - fromJson(json.value("events_before"_ls), d->eventsBefore); - fromJson(json.value("event"_ls), d->event); - fromJson(json.value("events_after"_ls), d->eventsAfter); - fromJson(json.value("state"_ls), d->state); - - return Success; -} diff --git a/lib/csapi/event_context.h b/lib/csapi/event_context.h index 54441617..2f9c66d8 100644 --- a/lib/csapi/event_context.h +++ b/lib/csapi/event_context.h @@ -4,34 +4,47 @@ #pragma once -#include "converters.h" - #include "events/eventloader.h" #include "jobs/basejob.h" namespace Quotient { -// Operations - /*! \brief Get events and state around the specified event. * * This API returns a number of events that happened just before and * after the specified event. This allows clients to get the context * surrounding an event. + * + * *Note*: This endpoint supports lazy-loading of room member events. See + * `Lazy-loading room members <#lazy-loading-room-members>`_ for more + * information. */ class GetEventContextJob : public BaseJob { public: /*! \brief Get events and state around the specified event. + * * * \param roomId * The room to get events from. + * * \param eventId * The event to get context around. + * * \param limit * The maximum number of events to return. Default: 10. + * + * \param filter + * A JSON ``RoomEventFilter`` to filter the returned events with. The + * filter is only applied to ``events_before``, ``events_after``, and + * ``state``. It is not applied to the ``event`` itself. The filter may + * be applied before or/and after the ``limit`` parameter - whichever the + * homeserver prefers. + * + * See `Filtering <#filtering>`_ for more information. */ explicit GetEventContextJob(const QString& roomId, const QString& eventId, - Omittable limit = none); + Omittable limit = none, + const QString& filter = {}); /*! \brief Construct a URL without creating a full-fledged job object * @@ -40,37 +53,36 @@ public: */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& eventId, - Omittable limit = none); - ~GetEventContextJob() override; + Omittable limit = none, + const QString& filter = {}); // Result properties /// A token that can be used to paginate backwards with. - const QString& begin() const; + QString begin() const { return loadFromJson("start"_ls); } /// A token that can be used to paginate forwards with. - const QString& end() const; + QString end() const { return loadFromJson("end"_ls); } /// A list of room events that happened just before the /// requested event, in reverse-chronological order. - RoomEvents&& eventsBefore(); + RoomEvents eventsBefore() + { + return takeFromJson("events_before"_ls); + } /// Details of the requested event. - RoomEventPtr&& event(); + RoomEventPtr event() { return takeFromJson("event"_ls); } /// A list of room events that happened just after the /// requested event, in chronological order. - RoomEvents&& eventsAfter(); + RoomEvents eventsAfter() + { + return takeFromJson("events_after"_ls); + } /// The state of the room at the last event returned. - StateEvents&& state(); - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + StateEvents state() { return takeFromJson("state"_ls); } }; } // namespace Quotient diff --git a/lib/csapi/filter.cpp b/lib/csapi/filter.cpp index 98b85f83..bb3a893f 100644 --- a/lib/csapi/filter.cpp +++ b/lib/csapi/filter.cpp @@ -4,68 +4,29 @@ #include "filter.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -class DefineFilterJob::Private { -public: - QString filterId; -}; - DefineFilterJob::DefineFilterJob(const QString& userId, const Filter& filter) : BaseJob(HttpVerb::Post, QStringLiteral("DefineFilterJob"), - basePath % "/user/" % userId % "/filter") - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/user/" % userId + % "/filter") { setRequestData(Data(toJson(filter))); + addExpectedKey("filter_id"); } -DefineFilterJob::~DefineFilterJob() = default; - -const QString& DefineFilterJob::filterId() const { return d->filterId; } - -BaseJob::Status DefineFilterJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - if (!json.contains("filter_id"_ls)) - return { IncorrectResponse, - "The key 'filter_id' not found in the response" }; - fromJson(json.value("filter_id"_ls), d->filterId); - - return Success; -} - -class GetFilterJob::Private { -public: - Filter data; -}; - QUrl GetFilterJob::makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& filterId) { - return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/user/" - % userId % "/filter/" - % filterId); + return BaseJob::makeRequestUrl(std::move(baseUrl), + QStringLiteral("/_matrix/client/r0") % "/user/" + % userId % "/filter/" % filterId); } GetFilterJob::GetFilterJob(const QString& userId, const QString& filterId) : BaseJob(HttpVerb::Get, QStringLiteral("GetFilterJob"), - basePath % "/user/" % userId % "/filter/" % filterId) - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/user/" % userId + % "/filter/" % filterId) {} - -GetFilterJob::~GetFilterJob() = default; - -const Filter& GetFilterJob::data() const { return d->data; } - -BaseJob::Status GetFilterJob::parseJson(const QJsonDocument& data) -{ - fromJson(data, d->data); - - return Success; -} diff --git a/lib/csapi/filter.h b/lib/csapi/filter.h index 7a0f8958..9aa7dc79 100644 --- a/lib/csapi/filter.h +++ b/lib/csapi/filter.h @@ -4,16 +4,12 @@ #pragma once -#include "converters.h" - #include "csapi/definitions/sync_filter.h" #include "jobs/basejob.h" namespace Quotient { -// Operations - /*! \brief Upload a new filter. * * Uploads a new filter definition to the homeserver. @@ -23,31 +19,24 @@ namespace Quotient { class DefineFilterJob : public BaseJob { public: /*! \brief Upload a new filter. + * * * \param userId * The id of the user uploading the filter. The access token must be - * authorized to make requests for this user id. \param filter 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. + * authorized to make requests for this user id. + * + * \param filter + * The filter to upload. */ explicit DefineFilterJob(const QString& userId, const Filter& filter); - ~DefineFilterJob() override; - // Result properties /// The ID of the filter that was created. Cannot start /// with a ``{`` as this character is used to determine /// if the filter provided is inline JSON or a previously /// declared filter by homeservers on some APIs. - const QString& filterId() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QString filterId() const { return loadFromJson("filter_id"_ls); } }; /*! \brief Download a filter @@ -56,9 +45,11 @@ private: class GetFilterJob : public BaseJob { public: /*! \brief Download a filter + * * * \param userId * The user ID to download a filter for. + * * \param filterId * The filter ID to download. */ @@ -71,19 +62,11 @@ public: */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& filterId); - ~GetFilterJob() override; // Result properties /// "The filter defintion" - const Filter& data() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + Filter data() const { return fromJson(jsonData()); } }; } // namespace Quotient diff --git a/lib/csapi/inviting.cpp b/lib/csapi/inviting.cpp index f070c3ce..01620f9e 100644 --- a/lib/csapi/inviting.cpp +++ b/lib/csapi/inviting.cpp @@ -4,19 +4,16 @@ #include "inviting.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - InviteUserJob::InviteUserJob(const QString& roomId, const QString& userId) : BaseJob(HttpVerb::Post, QStringLiteral("InviteUserJob"), - basePath % "/rooms/" % roomId % "/invite") + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId + % "/invite") { QJsonObject _data; addParam<>(_data, QStringLiteral("user_id"), userId); - setRequestData(_data); + setRequestData(std::move(_data)); } diff --git a/lib/csapi/inviting.h b/lib/csapi/inviting.h index 41d78ae6..a7ec6093 100644 --- a/lib/csapi/inviting.h +++ b/lib/csapi/inviting.h @@ -8,8 +8,6 @@ namespace Quotient { -// Operations - /*! \brief Invite a user to participate in a particular room. * * .. _invite-by-user-id-endpoint: @@ -34,9 +32,11 @@ namespace Quotient { class InviteUserJob : public BaseJob { public: /*! \brief Invite a user to participate in a particular room. + * * * \param roomId * The room identifier (not alias) to which to invite the user. + * * \param userId * The fully qualified user ID of the invitee. */ diff --git a/lib/csapi/joining.cpp b/lib/csapi/joining.cpp index cde179e0..4761e949 100644 --- a/lib/csapi/joining.cpp +++ b/lib/csapi/joining.cpp @@ -4,93 +4,23 @@ #include "joining.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -// Converters -namespace Quotient { - -template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, - const JoinRoomByIdJob::ThirdPartySigned& pod) - { - addParam<>(jo, QStringLiteral("sender"), pod.sender); - addParam<>(jo, QStringLiteral("mxid"), pod.mxid); - addParam<>(jo, QStringLiteral("token"), pod.token); - addParam<>(jo, QStringLiteral("signatures"), pod.signatures); - } -}; - -} // namespace Quotient - -class JoinRoomByIdJob::Private { -public: - QString roomId; -}; - JoinRoomByIdJob::JoinRoomByIdJob( const QString& roomId, const Omittable& thirdPartySigned) : BaseJob(HttpVerb::Post, QStringLiteral("JoinRoomByIdJob"), - basePath % "/rooms/" % roomId % "/join") - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId % "/join") { QJsonObject _data; addParam(_data, QStringLiteral("third_party_signed"), thirdPartySigned); - setRequestData(_data); + setRequestData(std::move(_data)); + addExpectedKey("room_id"); } -JoinRoomByIdJob::~JoinRoomByIdJob() = default; - -const QString& JoinRoomByIdJob::roomId() const { return d->roomId; } - -BaseJob::Status JoinRoomByIdJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - if (!json.contains("room_id"_ls)) - return { IncorrectResponse, - "The key 'room_id' not found in the response" }; - fromJson(json.value("room_id"_ls), d->roomId); - - return Success; -} - -// Converters -namespace Quotient { - -template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const JoinRoomJob::Signed& pod) - { - addParam<>(jo, QStringLiteral("sender"), pod.sender); - addParam<>(jo, QStringLiteral("mxid"), pod.mxid); - addParam<>(jo, QStringLiteral("token"), pod.token); - addParam<>(jo, QStringLiteral("signatures"), pod.signatures); - } -}; - -template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const JoinRoomJob::ThirdPartySigned& pod) - { - addParam<>(jo, QStringLiteral("signed"), pod.signedData); - } -}; - -} // namespace Quotient - -class JoinRoomJob::Private { -public: - QString roomId; -}; - -BaseJob::Query queryToJoinRoom(const QStringList& serverName) +auto queryToJoinRoom(const QStringList& serverName) { BaseJob::Query _q; addParam(_q, QStringLiteral("server_name"), serverName); @@ -101,26 +31,12 @@ JoinRoomJob::JoinRoomJob(const QString& roomIdOrAlias, const QStringList& serverName, const Omittable& thirdPartySigned) : BaseJob(HttpVerb::Post, QStringLiteral("JoinRoomJob"), - basePath % "/join/" % roomIdOrAlias, queryToJoinRoom(serverName)) - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/join/" % roomIdOrAlias, + queryToJoinRoom(serverName)) { QJsonObject _data; addParam(_data, QStringLiteral("third_party_signed"), thirdPartySigned); - setRequestData(_data); -} - -JoinRoomJob::~JoinRoomJob() = default; - -const QString& JoinRoomJob::roomId() const { return d->roomId; } - -BaseJob::Status JoinRoomJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - if (!json.contains("room_id"_ls)) - return { IncorrectResponse, - "The key 'room_id' not found in the response" }; - fromJson(json.value("room_id"_ls), d->roomId); - - return Success; + setRequestData(std::move(_data)); + addExpectedKey("room_id"); } diff --git a/lib/csapi/joining.h b/lib/csapi/joining.h index 6d93bcb1..6822fbdf 100644 --- a/lib/csapi/joining.h +++ b/lib/csapi/joining.h @@ -4,16 +4,12 @@ #pragma once -#include "converters.h" +#include "csapi/definitions/third_party_signed.h" #include "jobs/basejob.h" -#include - namespace Quotient { -// Operations - /*! \brief Start the requesting user participating in a particular room. * * *Note that this API requires a room ID, not alias.* ``/join/{roomIdOrAlias}`` @@ -33,49 +29,36 @@ namespace Quotient { */ class JoinRoomByIdJob : public BaseJob { public: - // Inner data structures - - /// 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 ThirdPartySigned { - /// The Matrix ID of the user who issued the invite. - QString sender; - /// The Matrix ID of the invitee. - QString mxid; - /// The state key of the m.third_party_invite event. - QString token; - /// A signatures object containing a signature of the entire signed - /// object. - QJsonObject signatures; - }; - - // Construction/destruction - /*! \brief Start the requesting user participating in a particular room. + * * * \param roomId * The room identifier (not alias) to join. + * * \param thirdPartySigned - * 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. + * *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 + * 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. + * + * After a user has joined a room, the room will appear as an entry in the + * response of the |/initialSync|_ and |/sync|_ APIs. + * + * If a ``third_party_signed`` was supplied, the homeserver must verify + * that it matches a pending ``m.room.third_party_invite`` event in the + * room, and perform key validity checking if required by the event. */ explicit JoinRoomByIdJob( const QString& roomId, const Omittable& thirdPartySigned = none); - ~JoinRoomByIdJob() override; - // Result properties /// The joined room ID. - const QString& roomId() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QString roomId() const { return loadFromJson("room_id"_ls); } }; /*! \brief Start the requesting user participating in a particular room. @@ -97,72 +80,40 @@ private: */ class JoinRoomJob : public BaseJob { public: - // Inner data structures - - /// *Note that this API takes either a room ID or alias, unlike* - /// ``/room/{roomId}/join``. - /// - /// This API starts a user participating 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. - /// - /// After a user has joined a room, the room will appear as an entry in the - /// response of the |/initialSync|_ and |/sync|_ APIs. - /// - /// If a ``third_party_signed`` was supplied, the homeserver must verify - /// that it matches a pending ``m.room.third_party_invite`` event in the - /// room, and perform key validity checking if required by the event. - struct Signed { - /// The Matrix ID of the user who issued the invite. - QString sender; - /// The Matrix ID of the invitee. - QString mxid; - /// The state key of the m.third_party_invite event. - QString token; - /// A signatures object containing a signature of the entire signed - /// object. - QJsonObject signatures; - }; - - /// 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 ThirdPartySigned { - /// 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. - Signed signedData; - }; - - // Construction/destruction - /*! \brief Start the requesting user participating in a particular room. + * * * \param roomIdOrAlias * The room identifier or alias to join. + * * \param serverName * The servers to attempt to join the room through. One of the servers * must be participating in the room. + * * \param thirdPartySigned - * 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. + * *Note that this API takes either a room ID or alias, unlike* + * ``/room/{roomId}/join``. + * + * This API starts a user participating 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. + * + * After a user has joined a room, the room will appear as an entry in the + * response of the |/initialSync|_ and |/sync|_ APIs. + * + * If a ``third_party_signed`` was supplied, the homeserver must verify + * that it matches a pending ``m.room.third_party_invite`` event in the + * room, and perform key validity checking if required by the event. */ explicit JoinRoomJob( const QString& roomIdOrAlias, const QStringList& serverName = {}, const Omittable& thirdPartySigned = none); - ~JoinRoomJob() override; - // Result properties /// The joined room ID. - const QString& roomId() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QString roomId() const { return loadFromJson("room_id"_ls); } }; } // namespace Quotient diff --git a/lib/csapi/keys.cpp b/lib/csapi/keys.cpp index b1a947b3..34ab47c9 100644 --- a/lib/csapi/keys.cpp +++ b/lib/csapi/keys.cpp @@ -4,161 +4,48 @@ #include "keys.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -class UploadKeysJob::Private { -public: - QHash oneTimeKeyCounts; -}; - UploadKeysJob::UploadKeysJob(const Omittable& deviceKeys, const QHash& oneTimeKeys) : BaseJob(HttpVerb::Post, QStringLiteral("UploadKeysJob"), - basePath % "/keys/upload") - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/keys/upload") { QJsonObject _data; addParam(_data, QStringLiteral("device_keys"), deviceKeys); addParam(_data, QStringLiteral("one_time_keys"), oneTimeKeys); - setRequestData(_data); -} - -UploadKeysJob::~UploadKeysJob() = default; - -const QHash& UploadKeysJob::oneTimeKeyCounts() const -{ - return d->oneTimeKeyCounts; -} - -BaseJob::Status UploadKeysJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - if (!json.contains("one_time_key_counts"_ls)) - return { IncorrectResponse, - "The key 'one_time_key_counts' not found in the response" }; - fromJson(json.value("one_time_key_counts"_ls), d->oneTimeKeyCounts); - - return Success; + setRequestData(std::move(_data)); + addExpectedKey("one_time_key_counts"); } -// Converters -namespace Quotient { - -template <> -struct JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, - QueryKeysJob::UnsignedDeviceInfo& result) - { - fromJson(jo.value("device_display_name"_ls), result.deviceDisplayName); - } -}; - -template <> -struct JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, - QueryKeysJob::DeviceInformation& result) - { - fillFromJson(jo, result); - fromJson(jo.value("unsigned"_ls), result.unsignedData); - } -}; - -} // namespace Quotient - -class QueryKeysJob::Private { -public: - QHash failures; - QHash> deviceKeys; -}; - QueryKeysJob::QueryKeysJob(const QHash& deviceKeys, Omittable timeout, const QString& token) : BaseJob(HttpVerb::Post, QStringLiteral("QueryKeysJob"), - basePath % "/keys/query") - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/keys/query") { QJsonObject _data; addParam(_data, QStringLiteral("timeout"), timeout); addParam<>(_data, QStringLiteral("device_keys"), deviceKeys); addParam(_data, QStringLiteral("token"), token); - setRequestData(_data); -} - -QueryKeysJob::~QueryKeysJob() = default; - -const QHash& QueryKeysJob::failures() const -{ - return d->failures; -} - -const QHash>& -QueryKeysJob::deviceKeys() const -{ - return d->deviceKeys; + setRequestData(std::move(_data)); } -BaseJob::Status QueryKeysJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("failures"_ls), d->failures); - fromJson(json.value("device_keys"_ls), d->deviceKeys); - - return Success; -} - -class ClaimKeysJob::Private { -public: - QHash failures; - QHash> oneTimeKeys; -}; - ClaimKeysJob::ClaimKeysJob( const QHash>& oneTimeKeys, Omittable timeout) : BaseJob(HttpVerb::Post, QStringLiteral("ClaimKeysJob"), - basePath % "/keys/claim") - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/keys/claim") { QJsonObject _data; addParam(_data, QStringLiteral("timeout"), timeout); addParam<>(_data, QStringLiteral("one_time_keys"), oneTimeKeys); - setRequestData(_data); -} - -ClaimKeysJob::~ClaimKeysJob() = default; - -const QHash& ClaimKeysJob::failures() const -{ - return d->failures; -} - -const QHash>& ClaimKeysJob::oneTimeKeys() const -{ - return d->oneTimeKeys; + setRequestData(std::move(_data)); + addExpectedKey("one_time_keys"); } -BaseJob::Status ClaimKeysJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("failures"_ls), d->failures); - fromJson(json.value("one_time_keys"_ls), d->oneTimeKeys); - - return Success; -} - -class GetKeysChangesJob::Private { -public: - QStringList changed; - QStringList left; -}; - -BaseJob::Query queryToGetKeysChanges(const QString& from, const QString& to) +auto queryToGetKeysChanges(const QString& from, const QString& to) { BaseJob::Query _q; addParam<>(_q, QStringLiteral("from"), from); @@ -170,27 +57,13 @@ QUrl GetKeysChangesJob::makeRequestUrl(QUrl baseUrl, const QString& from, const QString& to) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/keys/changes", + QStringLiteral("/_matrix/client/r0") + % "/keys/changes", queryToGetKeysChanges(from, to)); } GetKeysChangesJob::GetKeysChangesJob(const QString& from, const QString& to) : BaseJob(HttpVerb::Get, QStringLiteral("GetKeysChangesJob"), - basePath % "/keys/changes", queryToGetKeysChanges(from, to)) - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/keys/changes", + queryToGetKeysChanges(from, to)) {} - -GetKeysChangesJob::~GetKeysChangesJob() = default; - -const QStringList& GetKeysChangesJob::changed() const { return d->changed; } - -const QStringList& GetKeysChangesJob::left() const { return d->left; } - -BaseJob::Status GetKeysChangesJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("changed"_ls), d->changed); - fromJson(json.value("left"_ls), d->left); - - return Success; -} diff --git a/lib/csapi/keys.h b/lib/csapi/keys.h index 2673acc5..b7a8dc71 100644 --- a/lib/csapi/keys.h +++ b/lib/csapi/keys.h @@ -4,20 +4,12 @@ #pragma once -#include "converters.h" - #include "csapi/definitions/device_keys.h" #include "jobs/basejob.h" -#include -#include -#include - namespace Quotient { -// Operations - /*! \brief Upload end-to-end encryption keys. * * Publishes end-to-end encryption keys for the device. @@ -25,35 +17,31 @@ namespace Quotient { class UploadKeysJob : public BaseJob { public: /*! \brief Upload end-to-end encryption keys. + * * * \param deviceKeys * Identity keys for the device. May be absent if no new * identity keys are required. + * * \param oneTimeKeys * One-time public keys for "pre-key" messages. The names of * the properties should be in the format * ``:``. The format of the key is determined - * by the key algorithm. + * by the `key algorithm <#key-algorithms>`_. * * May be absent if no new one-time keys are required. */ explicit UploadKeysJob(const Omittable& deviceKeys = none, const QHash& oneTimeKeys = {}); - ~UploadKeysJob() override; - // Result properties /// For each key algorithm, the number of unclaimed one-time keys /// of that type currently held on the server for this device. - const QHash& oneTimeKeyCounts() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QHash oneTimeKeyCounts() const + { + return loadFromJson>("one_time_key_counts"_ls); + } }; /*! \brief Download device identity keys. @@ -73,7 +61,9 @@ public: }; /// Returns the current devices and identity keys for the given users. - struct DeviceInformation : DeviceKeys { + struct DeviceKeys : + + Quotient::DeviceKeys { /// Additional data added to the device key information /// by intermediate servers, and not covered by the /// signatures. @@ -83,14 +73,17 @@ public: // Construction/destruction /*! \brief Download device identity keys. + * * * \param deviceKeys * The keys to be downloaded. A map from user ID, to a list of * device IDs, or to an empty list to indicate all devices for the * corresponding user. + * * \param timeout * The time (in milliseconds) to wait when downloading keys from * remote servers. 10 seconds is the recommended default. + * * \param token * If the client is fetching keys as a result of a device update received * in a sync request, this should be the 'since' token of that sync @@ -101,8 +94,6 @@ public: Omittable timeout = none, const QString& token = {}); - ~QueryKeysJob() override; - // Result properties /// If any remote homeservers could not be reached, they are @@ -112,21 +103,39 @@ public: /// If the homeserver could be reached, but the user or device /// was unknown, no failure is recorded. Instead, the corresponding /// user or device is missing from the ``device_keys`` result. - const QHash& failures() const; + QHash failures() const + { + return loadFromJson>("failures"_ls); + } /// Information on the queried devices. A map from user ID, to a /// map from device ID to device information. For each device, /// the information returned will be the same as uploaded via /// ``/keys/upload``, with the addition of an ``unsigned`` /// property. - const QHash>& deviceKeys() const; + QHash> deviceKeys() const + { + return loadFromJson>>( + "device_keys"_ls); + } +}; -protected: - Status parseJson(const QJsonDocument& data) override; +template <> +struct JsonObjectConverter { + static void fillFrom(const QJsonObject& jo, + QueryKeysJob::UnsignedDeviceInfo& result) + { + fromJson(jo.value("device_display_name"_ls), result.deviceDisplayName); + } +}; -private: - class Private; - QScopedPointer d; +template <> +struct JsonObjectConverter { + static void fillFrom(const QJsonObject& jo, QueryKeysJob::DeviceKeys& result) + { + fillFromJson(jo, result); + fromJson(jo.value("unsigned"_ls), result.unsignedData); + } }; /*! \brief Claim one-time encryption keys. @@ -136,10 +145,12 @@ private: class ClaimKeysJob : public BaseJob { public: /*! \brief Claim one-time encryption keys. + * * * \param oneTimeKeys * The keys to be claimed. A map from user ID, to a map from * device ID to algorithm name. + * * \param timeout * The time (in milliseconds) to wait when downloading keys from * remote servers. 10 seconds is the recommended default. @@ -148,8 +159,6 @@ public: const QHash>& oneTimeKeys, Omittable timeout = none); - ~ClaimKeysJob() override; - // Result properties /// If any remote homeservers could not be reached, they are @@ -159,18 +168,22 @@ public: /// If the homeserver could be reached, but the user or device /// was unknown, no failure is recorded. Instead, the corresponding /// user or device is missing from the ``one_time_keys`` result. - const QHash& failures() const; + QHash failures() const + { + return loadFromJson>("failures"_ls); + } /// One-time keys for the queried devices. A map from user ID, to a - /// map from devices to a map from ``:`` to the key object. - const QHash>& oneTimeKeys() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + /// map from devices to a map from ``:`` to the key + /// object. + /// + /// See the `key algorithms <#key-algorithms>`_ section for information + /// on the Key Object format. + QHash> oneTimeKeys() const + { + return loadFromJson>>( + "one_time_keys"_ls); + } }; /*! \brief Query users with recent device key updates. @@ -188,6 +201,7 @@ private: class GetKeysChangesJob : public BaseJob { public: /*! \brief Query users with recent device key updates. + * * * \param from * The desired start point of the list. Should be the ``next_batch`` field @@ -195,6 +209,7 @@ public: * uploaded new device identity keys since this point, nor deleted * existing devices with identity keys since then, will be excluded * from the results. + * * \param to * The desired end point of the list. Should be the ``next_batch`` * field from a recent call to |/sync| - typically the most recent @@ -210,25 +225,20 @@ public: */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& from, const QString& to); - ~GetKeysChangesJob() override; // Result properties /// The Matrix User IDs of all users who updated their device /// identity keys. - const QStringList& changed() const; + QStringList changed() const + { + return loadFromJson("changed"_ls); + } /// The Matrix User IDs of all users who may have left all /// the end-to-end encrypted rooms they previously shared /// with the user. - const QStringList& left() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QStringList left() const { return loadFromJson("left"_ls); } }; } // namespace Quotient diff --git a/lib/csapi/kicking.cpp b/lib/csapi/kicking.cpp index 39125f42..7de5ce01 100644 --- a/lib/csapi/kicking.cpp +++ b/lib/csapi/kicking.cpp @@ -4,21 +4,17 @@ #include "kicking.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - KickJob::KickJob(const QString& roomId, const QString& userId, const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("KickJob"), - basePath % "/rooms/" % roomId % "/kick") + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId % "/kick") { QJsonObject _data; addParam<>(_data, QStringLiteral("user_id"), userId); addParam(_data, QStringLiteral("reason"), reason); - setRequestData(_data); + setRequestData(std::move(_data)); } diff --git a/lib/csapi/kicking.h b/lib/csapi/kicking.h index 0633a7f6..594f5845 100644 --- a/lib/csapi/kicking.h +++ b/lib/csapi/kicking.h @@ -8,8 +8,6 @@ namespace Quotient { -// Operations - /*! \brief Kick a user from the room. * * Kick a user from the room. @@ -25,11 +23,14 @@ namespace Quotient { class KickJob : public BaseJob { public: /*! \brief Kick a user from the room. + * * * \param roomId * The room identifier (not alias) from which the user should be kicked. + * * \param userId * The fully qualified user ID of the user being kicked. + * * \param reason * The reason the user has been kicked. This will be supplied as the * ``reason`` on the target's updated `m.room.member`_ event. diff --git a/lib/csapi/leaving.cpp b/lib/csapi/leaving.cpp index 2fa1da56..8bd170bf 100644 --- a/lib/csapi/leaving.cpp +++ b/lib/csapi/leaving.cpp @@ -4,32 +4,32 @@ #include "leaving.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - QUrl LeaveRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/rooms/" % roomId % "/leave"); + QStringLiteral("/_matrix/client/r0") + % "/rooms/" % roomId % "/leave"); } LeaveRoomJob::LeaveRoomJob(const QString& roomId) : BaseJob(HttpVerb::Post, QStringLiteral("LeaveRoomJob"), - basePath % "/rooms/" % roomId % "/leave") + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId + % "/leave") {} QUrl ForgetRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/rooms/" % roomId % "/forget"); + QStringLiteral("/_matrix/client/r0") + % "/rooms/" % roomId % "/forget"); } ForgetRoomJob::ForgetRoomJob(const QString& roomId) : BaseJob(HttpVerb::Post, QStringLiteral("ForgetRoomJob"), - basePath % "/rooms/" % roomId % "/forget") + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId + % "/forget") {} diff --git a/lib/csapi/leaving.h b/lib/csapi/leaving.h index 45b983f3..0a4c401c 100644 --- a/lib/csapi/leaving.h +++ b/lib/csapi/leaving.h @@ -8,8 +8,6 @@ namespace Quotient { -// Operations - /*! \brief Stop the requesting user participating in a particular room. * * This API stops a user participating in a particular room. @@ -27,6 +25,7 @@ namespace Quotient { class LeaveRoomJob : public BaseJob { public: /*! \brief Stop the requesting user participating in a particular room. + * * * \param roomId * The room identifier to leave. @@ -56,6 +55,7 @@ public: class ForgetRoomJob : public BaseJob { public: /*! \brief Stop the requesting user remembering about a particular room. + * * * \param roomId * The room identifier to forget. diff --git a/lib/csapi/list_joined_rooms.cpp b/lib/csapi/list_joined_rooms.cpp index 34eb0d42..8d7e267f 100644 --- a/lib/csapi/list_joined_rooms.cpp +++ b/lib/csapi/list_joined_rooms.cpp @@ -4,45 +4,20 @@ #include "list_joined_rooms.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -class GetJoinedRoomsJob::Private { -public: - QStringList joinedRooms; -}; - QUrl GetJoinedRoomsJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/joined_rooms"); + QStringLiteral("/_matrix/client/r0") + % "/joined_rooms"); } GetJoinedRoomsJob::GetJoinedRoomsJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetJoinedRoomsJob"), - basePath % "/joined_rooms") - , d(new Private) -{} - -GetJoinedRoomsJob::~GetJoinedRoomsJob() = default; - -const QStringList& GetJoinedRoomsJob::joinedRooms() const + QStringLiteral("/_matrix/client/r0") % "/joined_rooms") { - return d->joinedRooms; -} - -BaseJob::Status GetJoinedRoomsJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - if (!json.contains("joined_rooms"_ls)) - return { IncorrectResponse, - "The key 'joined_rooms' not found in the response" }; - fromJson(json.value("joined_rooms"_ls), d->joinedRooms); - - return Success; + addExpectedKey("joined_rooms"); } diff --git a/lib/csapi/list_joined_rooms.h b/lib/csapi/list_joined_rooms.h index a170d623..1034aa7b 100644 --- a/lib/csapi/list_joined_rooms.h +++ b/lib/csapi/list_joined_rooms.h @@ -8,8 +8,6 @@ namespace Quotient { -// Operations - /*! \brief Lists the user's current rooms. * * This API returns a list of the user's current rooms. @@ -25,19 +23,14 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetJoinedRoomsJob() override; // Result properties /// The ID of each room in which the user has ``joined`` membership. - const QStringList& joinedRooms() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QStringList joinedRooms() const + { + return loadFromJson("joined_rooms"_ls); + } }; } // namespace Quotient diff --git a/lib/csapi/list_public_rooms.cpp b/lib/csapi/list_public_rooms.cpp index 83320ec0..cdc5c716 100644 --- a/lib/csapi/list_public_rooms.cpp +++ b/lib/csapi/list_public_rooms.cpp @@ -4,66 +4,39 @@ #include "list_public_rooms.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -class GetRoomVisibilityOnDirectoryJob::Private { -public: - QString visibility; -}; - QUrl GetRoomVisibilityOnDirectoryJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/directory/list/room/" % roomId); + QStringLiteral("/_matrix/client/r0") + % "/directory/list/room/" % roomId); } GetRoomVisibilityOnDirectoryJob::GetRoomVisibilityOnDirectoryJob( const QString& roomId) : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomVisibilityOnDirectoryJob"), - basePath % "/directory/list/room/" % roomId, false) - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/directory/list/room/" + % roomId, + false) {} -GetRoomVisibilityOnDirectoryJob::~GetRoomVisibilityOnDirectoryJob() = default; - -const QString& GetRoomVisibilityOnDirectoryJob::visibility() const -{ - return d->visibility; -} - -BaseJob::Status -GetRoomVisibilityOnDirectoryJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("visibility"_ls), d->visibility); - - return Success; -} - SetRoomVisibilityOnDirectoryJob::SetRoomVisibilityOnDirectoryJob( const QString& roomId, const QString& visibility) : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomVisibilityOnDirectoryJob"), - basePath % "/directory/list/room/" % roomId) + QStringLiteral("/_matrix/client/r0") % "/directory/list/room/" + % roomId) { QJsonObject _data; addParam(_data, QStringLiteral("visibility"), visibility); - setRequestData(_data); + setRequestData(std::move(_data)); } -class GetPublicRoomsJob::Private { -public: - PublicRoomsResponse data; -}; - -BaseJob::Query queryToGetPublicRooms(Omittable limit, const QString& since, - const QString& server) +auto queryToGetPublicRooms(Omittable limit, const QString& since, + const QString& server) { BaseJob::Query _q; addParam(_q, QStringLiteral("limit"), limit); @@ -76,49 +49,20 @@ QUrl GetPublicRoomsJob::makeRequestUrl(QUrl baseUrl, Omittable limit, const QString& since, const QString& server) { - return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/publicRooms", + return BaseJob::makeRequestUrl(std::move(baseUrl), + QStringLiteral("/_matrix/client/r0") + % "/publicRooms", queryToGetPublicRooms(limit, since, server)); } GetPublicRoomsJob::GetPublicRoomsJob(Omittable limit, const QString& since, const QString& server) : BaseJob(HttpVerb::Get, QStringLiteral("GetPublicRoomsJob"), - basePath % "/publicRooms", + QStringLiteral("/_matrix/client/r0") % "/publicRooms", queryToGetPublicRooms(limit, since, server), {}, false) - , d(new Private) {} -GetPublicRoomsJob::~GetPublicRoomsJob() = default; - -const PublicRoomsResponse& GetPublicRoomsJob::data() const { return d->data; } - -BaseJob::Status GetPublicRoomsJob::parseJson(const QJsonDocument& data) -{ - fromJson(data, d->data); - - return Success; -} - -// Converters -namespace Quotient { - -template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const QueryPublicRoomsJob::Filter& pod) - { - addParam(jo, QStringLiteral("generic_search_term"), - pod.genericSearchTerm); - } -}; - -} // namespace Quotient - -class QueryPublicRoomsJob::Private { -public: - PublicRoomsResponse data; -}; - -BaseJob::Query queryToQueryPublicRooms(const QString& server) +auto queryToQueryPublicRooms(const QString& server) { BaseJob::Query _q; addParam(_q, QStringLiteral("server"), server); @@ -132,8 +76,8 @@ QueryPublicRoomsJob::QueryPublicRoomsJob(const QString& server, Omittable includeAllNetworks, const QString& thirdPartyInstanceId) : BaseJob(HttpVerb::Post, QStringLiteral("QueryPublicRoomsJob"), - basePath % "/publicRooms", queryToQueryPublicRooms(server)) - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/publicRooms", + queryToQueryPublicRooms(server)) { QJsonObject _data; addParam(_data, QStringLiteral("limit"), limit); @@ -143,16 +87,6 @@ QueryPublicRoomsJob::QueryPublicRoomsJob(const QString& server, includeAllNetworks); addParam(_data, QStringLiteral("third_party_instance_id"), thirdPartyInstanceId); - setRequestData(_data); -} - -QueryPublicRoomsJob::~QueryPublicRoomsJob() = default; - -const PublicRoomsResponse& QueryPublicRoomsJob::data() const { return d->data; } - -BaseJob::Status QueryPublicRoomsJob::parseJson(const QJsonDocument& data) -{ - fromJson(data, d->data); - - return Success; + setRequestData(std::move(_data)); + addExpectedKey("chunk"); } diff --git a/lib/csapi/list_public_rooms.h b/lib/csapi/list_public_rooms.h index 0c9a2620..5ef7c23e 100644 --- a/lib/csapi/list_public_rooms.h +++ b/lib/csapi/list_public_rooms.h @@ -4,16 +4,12 @@ #pragma once -#include "converters.h" - #include "csapi/definitions/public_rooms_response.h" #include "jobs/basejob.h" namespace Quotient { -// Operations - /*! \brief Gets the visibility of a room in the directory * * Gets the visibility of a given room on the server's public room directory. @@ -21,6 +17,7 @@ namespace Quotient { class GetRoomVisibilityOnDirectoryJob : public BaseJob { public: /*! \brief Gets the visibility of a room in the directory + * * * \param roomId * The room ID. @@ -33,19 +30,14 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId); - ~GetRoomVisibilityOnDirectoryJob() override; // Result properties /// The visibility of the room in the directory. - const QString& visibility() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QString visibility() const + { + return loadFromJson("visibility"_ls); + } }; /*! \brief Sets the visibility of a room in the room directory @@ -60,9 +52,11 @@ private: class SetRoomVisibilityOnDirectoryJob : public BaseJob { public: /*! \brief Sets the visibility of a room in the room directory + * * * \param roomId * The room ID. + * * \param visibility * The new visibility setting for the room. * Defaults to 'public'. @@ -81,14 +75,17 @@ public: class GetPublicRoomsJob : public BaseJob { public: /*! \brief Lists the public rooms on the server. + * * * \param limit * Limit the number of results returned. + * * \param since * A pagination token from a previous request, allowing clients to * get the next (or previous) batch of rooms. * The direction of pagination is specified solely by which token * is supplied, rather than via an explicit flag. + * * \param server * The server to fetch the public room lists from. Defaults to the * local server. @@ -105,19 +102,14 @@ public: static QUrl makeRequestUrl(QUrl baseUrl, Omittable limit = none, const QString& since = {}, const QString& server = {}); - ~GetPublicRoomsJob() override; // Result properties /// A list of the rooms on the server. - const PublicRoomsResponse& data() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + PublicRoomsResponse data() const + { + return fromJson(jsonData()); + } }; /*! \brief Lists the public rooms on the server with optional filter. @@ -138,25 +130,58 @@ public: QString genericSearchTerm; }; + /// Lists the public rooms on the server, with optional filter. + /// + /// This API returns paginated responses. The rooms are ordered by the + /// number of joined members, with the largest rooms first. + struct PublicRoomsChunk { + /// Aliases of the room. May be empty. + QStringList aliases; + /// The canonical alias of the room, if any. + QString canonicalAlias; + /// The name of the room, if any. + QString name; + /// The number of members joined to the room. + int numJoinedMembers; + /// The ID of the room. + QString roomId; + /// The topic of the room, if any. + QString topic; + /// Whether the room may be viewed by guest users without joining. + bool worldReadable; + /// Whether guest users may join the room and participate in it. + /// If they can, they will be subject to ordinary power level + /// rules like any other user. + bool guestCanJoin; + /// The URL for the room's avatar, if one is set. + QString avatarUrl; + }; + // Construction/destruction /*! \brief Lists the public rooms on the server with optional filter. + * * * \param server * The server to fetch the public room lists from. Defaults to the * local server. + * * \param limit * Limit the number of results returned. + * * \param since * A pagination token from a previous request, allowing clients * to get the next (or previous) batch of rooms. The direction * of pagination is specified solely by which token is supplied, * rather than via an explicit flag. + * * \param filter * Filter to apply to the results. + * * \param includeAllNetworks * Whether or not to include all known networks/protocols from * application services on the homeserver. Defaults to false. + * * \param thirdPartyInstanceId * The specific third party network/protocol to request from the * homeserver. Can only be used if ``include_all_networks`` is false. @@ -168,19 +193,56 @@ public: Omittable includeAllNetworks = none, const QString& thirdPartyInstanceId = {}); - ~QueryPublicRoomsJob() override; - // Result properties - /// A list of the rooms on the server. - const PublicRoomsResponse& data() const; + /// A paginated chunk of public rooms. + QVector chunk() const + { + return loadFromJson>("chunk"_ls); + } + + /// A pagination token for the response. The absence of this token + /// means there are no more results to fetch and the client should + /// stop paginating. + QString nextBatch() const { return loadFromJson("next_batch"_ls); } + + /// A pagination token that allows fetching previous results. The + /// absence of this token means there are no results before this + /// batch, i.e. this is the first batch. + QString prevBatch() const { return loadFromJson("prev_batch"_ls); } + + /// An estimate on the total number of public rooms, if the + /// server has an estimate. + Omittable totalRoomCountEstimate() const + { + return loadFromJson>("total_room_count_estimate"_ls); + } +}; -protected: - Status parseJson(const QJsonDocument& data) override; +template <> +struct JsonObjectConverter { + static void dumpTo(QJsonObject& jo, const QueryPublicRoomsJob::Filter& pod) + { + addParam(jo, QStringLiteral("generic_search_term"), + pod.genericSearchTerm); + } +}; -private: - class Private; - QScopedPointer d; +template <> +struct JsonObjectConverter { + static void fillFrom(const QJsonObject& jo, + QueryPublicRoomsJob::PublicRoomsChunk& result) + { + fromJson(jo.value("aliases"_ls), result.aliases); + fromJson(jo.value("canonical_alias"_ls), result.canonicalAlias); + fromJson(jo.value("name"_ls), result.name); + fromJson(jo.value("num_joined_members"_ls), result.numJoinedMembers); + fromJson(jo.value("room_id"_ls), result.roomId); + fromJson(jo.value("topic"_ls), result.topic); + fromJson(jo.value("world_readable"_ls), result.worldReadable); + fromJson(jo.value("guest_can_join"_ls), result.guestCanJoin); + fromJson(jo.value("avatar_url"_ls), result.avatarUrl); + } }; } // namespace Quotient diff --git a/lib/csapi/login.cpp b/lib/csapi/login.cpp index 3e98f56b..a5bac9ea 100644 --- a/lib/csapi/login.cpp +++ b/lib/csapi/login.cpp @@ -4,77 +4,29 @@ #include "login.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -// Converters -namespace Quotient { - -template <> -struct JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, - GetLoginFlowsJob::LoginFlow& result) - { - fromJson(jo.value("type"_ls), result.type); - } -}; - -} // namespace Quotient - -class GetLoginFlowsJob::Private { -public: - QVector flows; -}; - QUrl GetLoginFlowsJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/login"); + return BaseJob::makeRequestUrl(std::move(baseUrl), + QStringLiteral("/_matrix/client/r0") + % "/login"); } GetLoginFlowsJob::GetLoginFlowsJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetLoginFlowsJob"), - basePath % "/login", false) - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/login", false) {} -GetLoginFlowsJob::~GetLoginFlowsJob() = default; - -const QVector& GetLoginFlowsJob::flows() const -{ - return d->flows; -} - -BaseJob::Status GetLoginFlowsJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("flows"_ls), d->flows); - - return Success; -} - -class LoginJob::Private { -public: - QString userId; - QString accessToken; - QString homeServer; - QString deviceId; - Omittable wellKnown; -}; - LoginJob::LoginJob(const QString& type, const Omittable& identifier, const QString& password, const QString& token, const QString& deviceId, - const QString& initialDeviceDisplayName, const QString& user, - const QString& medium, const QString& address) - : BaseJob(HttpVerb::Post, QStringLiteral("LoginJob"), basePath % "/login", - false) - , d(new Private) + const QString& initialDeviceDisplayName) + : BaseJob(HttpVerb::Post, QStringLiteral("LoginJob"), + QStringLiteral("/_matrix/client/r0") % "/login", false) { QJsonObject _data; addParam<>(_data, QStringLiteral("type"), type); @@ -84,35 +36,5 @@ LoginJob::LoginJob(const QString& type, addParam(_data, QStringLiteral("device_id"), deviceId); addParam(_data, QStringLiteral("initial_device_display_name"), initialDeviceDisplayName); - addParam(_data, QStringLiteral("user"), user); - addParam(_data, QStringLiteral("medium"), medium); - addParam(_data, QStringLiteral("address"), address); - setRequestData(_data); -} - -LoginJob::~LoginJob() = default; - -const QString& LoginJob::userId() const { return d->userId; } - -const QString& LoginJob::accessToken() const { return d->accessToken; } - -const QString& LoginJob::homeServer() const { return d->homeServer; } - -const QString& LoginJob::deviceId() const { return d->deviceId; } - -const Omittable& LoginJob::wellKnown() const -{ - return d->wellKnown; -} - -BaseJob::Status LoginJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("user_id"_ls), d->userId); - fromJson(json.value("access_token"_ls), d->accessToken); - fromJson(json.value("home_server"_ls), d->homeServer); - fromJson(json.value("device_id"_ls), d->deviceId); - fromJson(json.value("well_known"_ls), d->wellKnown); - - return Success; + setRequestData(std::move(_data)); } diff --git a/lib/csapi/login.h b/lib/csapi/login.h index adecca6f..0483b77c 100644 --- a/lib/csapi/login.h +++ b/lib/csapi/login.h @@ -4,19 +4,13 @@ #pragma once -#include "converters.h" - #include "csapi/definitions/user_identifier.h" #include "csapi/definitions/wellknown/full.h" #include "jobs/basejob.h" -#include - namespace Quotient { -// Operations - /*! \brief Get the supported login types to authenticate users * * Gets the homeserver's supported login types to authenticate users. Clients @@ -46,19 +40,23 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetLoginFlowsJob() override; // Result properties /// The homeserver's supported login types - const QVector& flows() const; - -protected: - Status parseJson(const QJsonDocument& data) override; + QVector flows() const + { + return loadFromJson>("flows"_ls); + } +}; -private: - class Private; - QScopedPointer d; +template <> +struct JsonObjectConverter { + static void fillFrom(const QJsonObject& jo, + GetLoginFlowsJob::LoginFlow& result) + { + fromJson(jo.value("type"_ls), result.type); + } }; /*! \brief Authenticates the user. @@ -77,46 +75,48 @@ private: class LoginJob : public BaseJob { public: /*! \brief Authenticates the user. + * * * \param type * The login type being used. + * * \param identifier * Identification information for the user. + * * \param password * Required when ``type`` is ``m.login.password``. The user's * password. + * * \param token * Required when ``type`` is ``m.login.token``. Part of `Token-based`_ - * login. \param deviceId ID of the client device. If this does not - * correspond to a known client device, a new device will be created. The - * server will auto-generate a device_id if this is not specified. \param - * initialDeviceDisplayName A display name to assign to the newly-created - * device. Ignored if ``device_id`` corresponds to a known device. \param - * user The fully qualified user ID or just local part of the user ID, to - * log in. Deprecated in favour of ``identifier``. \param medium When - * logging in using a third party identifier, the medium of the identifier. - * Must be 'email'. Deprecated in favour of ``identifier``. \param address - * Third party identifier for the user. Deprecated in favour of - * ``identifier``. + * login. + * + * \param deviceId + * ID of the client device. If this does not correspond to a + * known client device, a new device will be created. The server + * will auto-generate a device_id if this is not specified. + * + * \param initialDeviceDisplayName + * A display name to assign to the newly-created device. Ignored + * if ``device_id`` corresponds to a known device. */ explicit LoginJob(const QString& type, const Omittable& identifier = none, const QString& password = {}, const QString& token = {}, const QString& deviceId = {}, - const QString& initialDeviceDisplayName = {}, - const QString& user = {}, const QString& medium = {}, - const QString& address = {}); - - ~LoginJob() override; + const QString& initialDeviceDisplayName = {}); // Result properties /// The fully-qualified Matrix ID that has been registered. - const QString& userId() const; + QString userId() const { return loadFromJson("user_id"_ls); } /// An access token for the account. /// This access token can then be used to authorize other requests. - const QString& accessToken() const; + QString accessToken() const + { + return loadFromJson("access_token"_ls); + } /// The server_name of the homeserver on which the account has /// been registered. @@ -124,24 +124,23 @@ public: /// **Deprecated**. Clients should extract the server_name from /// ``user_id`` (by splitting at the first colon) if they require /// it. Note also that ``homeserver`` is not spelt this way. - const QString& homeServer() const; + QString homeServer() const + { + return loadFromJson("home_server"_ls); + } /// ID of the logged-in device. Will be the same as the /// corresponding parameter in the request, if one was specified. - const QString& deviceId() const; + QString deviceId() const { return loadFromJson("device_id"_ls); } /// Optional client configuration provided by the server. If present, /// clients SHOULD use the provided object to reconfigure themselves, /// optionally validating the URLs within. This object takes the same /// form as the one returned from .well-known autodiscovery. - const Omittable& wellKnown() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + Omittable wellKnown() const + { + return loadFromJson>("well_known"_ls); + } }; } // namespace Quotient diff --git a/lib/csapi/logout.cpp b/lib/csapi/logout.cpp index 36281b79..9583b8ec 100644 --- a/lib/csapi/logout.cpp +++ b/lib/csapi/logout.cpp @@ -4,29 +4,30 @@ #include "logout.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - QUrl LogoutJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/logout"); + return BaseJob::makeRequestUrl(std::move(baseUrl), + QStringLiteral("/_matrix/client/r0") + % "/logout"); } LogoutJob::LogoutJob() - : BaseJob(HttpVerb::Post, QStringLiteral("LogoutJob"), basePath % "/logout") + : BaseJob(HttpVerb::Post, QStringLiteral("LogoutJob"), + QStringLiteral("/_matrix/client/r0") % "/logout") {} QUrl LogoutAllJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/logout/all"); + return BaseJob::makeRequestUrl(std::move(baseUrl), + QStringLiteral("/_matrix/client/r0") + % "/logout/all"); } LogoutAllJob::LogoutAllJob() : BaseJob(HttpVerb::Post, QStringLiteral("LogoutAllJob"), - basePath % "/logout/all") + QStringLiteral("/_matrix/client/r0") % "/logout/all") {} diff --git a/lib/csapi/logout.h b/lib/csapi/logout.h index 2a705620..e9a7ef89 100644 --- a/lib/csapi/logout.h +++ b/lib/csapi/logout.h @@ -8,12 +8,11 @@ namespace Quotient { -// Operations - /*! \brief Invalidates a user access token * * Invalidates an existing access token, so that it can no longer be used for - * authorization. + * authorization. The device associated with the access token is also deleted. + * `Device keys <#device-keys>`_ for the device are deleted alongside the device. */ class LogoutJob : public BaseJob { public: @@ -31,7 +30,9 @@ public: /*! \brief Invalidates all access tokens for a user * * Invalidates all access tokens for a user, so that they can no longer be used - * for authorization. This includes the access token that made this request. + * for authorization. This includes the access token that made this request. All + * devices for the user are also deleted. `Device keys <#device-keys>`_ for the + * device are deleted alongside the device. * * This endpoint does not require UI authorization because UI authorization is * designed to protect against attacks where the someone gets hold of a single diff --git a/lib/csapi/message_pagination.cpp b/lib/csapi/message_pagination.cpp index ba982748..855c051f 100644 --- a/lib/csapi/message_pagination.cpp +++ b/lib/csapi/message_pagination.cpp @@ -4,24 +4,13 @@ #include "message_pagination.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -class GetRoomEventsJob::Private { -public: - QString begin; - QString end; - RoomEvents chunk; -}; - -BaseJob::Query queryToGetRoomEvents(const QString& from, const QString& to, - const QString& dir, Omittable limit, - const QString& filter) +auto queryToGetRoomEvents(const QString& from, const QString& to, + const QString& dir, Omittable limit, + const QString& filter) { BaseJob::Query _q; addParam<>(_q, QStringLiteral("from"), from); @@ -37,35 +26,17 @@ QUrl GetRoomEventsJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& to, Omittable limit, const QString& filter) { - return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/rooms/" % roomId % "/messages", - queryToGetRoomEvents(from, to, dir, limit, - filter)); + return BaseJob::makeRequestUrl( + std::move(baseUrl), + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId % "/messages", + queryToGetRoomEvents(from, to, dir, limit, filter)); } GetRoomEventsJob::GetRoomEventsJob(const QString& roomId, const QString& from, const QString& dir, const QString& to, Omittable limit, const QString& filter) : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomEventsJob"), - basePath % "/rooms/" % roomId % "/messages", + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId + % "/messages", queryToGetRoomEvents(from, to, dir, limit, filter)) - , d(new Private) {} - -GetRoomEventsJob::~GetRoomEventsJob() = default; - -const QString& GetRoomEventsJob::begin() const { return d->begin; } - -const QString& GetRoomEventsJob::end() const { return d->end; } - -RoomEvents&& GetRoomEventsJob::chunk() { return std::move(d->chunk); } - -BaseJob::Status GetRoomEventsJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("start"_ls), d->begin); - fromJson(json.value("end"_ls), d->end); - fromJson(json.value("chunk"_ls), d->chunk); - - return Success; -} diff --git a/lib/csapi/message_pagination.h b/lib/csapi/message_pagination.h index b0d95bad..e9f9e6d4 100644 --- a/lib/csapi/message_pagination.h +++ b/lib/csapi/message_pagination.h @@ -4,40 +4,46 @@ #pragma once -#include "converters.h" - #include "events/eventloader.h" #include "jobs/basejob.h" namespace Quotient { -// Operations - /*! \brief Get a list of events for this room * * This API returns a list of message and state events for a room. It uses * pagination query parameters to paginate history in the room. + * + * *Note*: This endpoint supports lazy-loading of room member events. See + * `Lazy-loading room members <#lazy-loading-room-members>`_ for more + * information. */ class GetRoomEventsJob : public BaseJob { public: /*! \brief Get a list of events for this room + * * * \param roomId * The room to get events from. + * * \param from * The token to start returning events from. This token can be obtained * from a ``prev_batch`` token returned for each room by the sync API, * or from a ``start`` or ``end`` token returned by a previous request * to this endpoint. + * * \param dir * The direction to return events from. + * * \param to * The token to stop returning events at. This token can be obtained from * a ``prev_batch`` token returned for each room by the sync endpoint, * or from a ``start`` or ``end`` token returned by a previous request to * this endpoint. + * * \param limit * The maximum number of events to return. Default: 10. + * * \param filter * A JSON RoomEventFilter to filter returned events with. */ @@ -56,27 +62,32 @@ public: const QString& to = {}, Omittable limit = none, const QString& filter = {}); - ~GetRoomEventsJob() override; // Result properties /// The token the pagination starts from. If ``dir=b`` this will be /// the token supplied in ``from``. - const QString& begin() const; + QString begin() const { return loadFromJson("start"_ls); } /// The token the pagination ends at. If ``dir=b`` this token should /// be used again to request even earlier events. - const QString& end() const; - - /// A list of room events. - RoomEvents&& chunk(); + QString end() const { return loadFromJson("end"_ls); } -protected: - Status parseJson(const QJsonDocument& data) override; + /// A list of room events. The order depends on the ``dir`` parameter. + /// For ``dir=b`` events will be in reverse-chronological order, + /// for ``dir=f`` in chronological order, so that events start + /// at the ``from`` point. + RoomEvents chunk() { return takeFromJson("chunk"_ls); } -private: - class Private; - QScopedPointer d; + /// A list of state events relevant to showing the ``chunk``. For example, if + /// ``lazy_load_members`` is enabled in the filter then this may contain + /// the membership events for the senders of events in the ``chunk``. + /// + /// Unless ``include_redundant_members`` is ``true``, the server + /// may remove membership events which would have already been + /// sent to the client in prior calls to this endpoint, assuming + /// the membership of those members has not changed. + StateEvents state() { return takeFromJson("state"_ls); } }; } // namespace Quotient diff --git a/lib/csapi/notifications.cpp b/lib/csapi/notifications.cpp index d00d5425..a479d500 100644 --- a/lib/csapi/notifications.cpp +++ b/lib/csapi/notifications.cpp @@ -4,41 +4,12 @@ #include "notifications.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -// Converters -namespace Quotient { - -template <> -struct JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, - GetNotificationsJob::Notification& result) - { - fromJson(jo.value("actions"_ls), result.actions); - fromJson(jo.value("event"_ls), result.event); - fromJson(jo.value("profile_tag"_ls), result.profileTag); - fromJson(jo.value("read"_ls), result.read); - fromJson(jo.value("room_id"_ls), result.roomId); - fromJson(jo.value("ts"_ls), result.ts); - } -}; - -} // namespace Quotient - -class GetNotificationsJob::Private { -public: - QString nextToken; - std::vector notifications; -}; - -BaseJob::Query queryToGetNotifications(const QString& from, - Omittable limit, const QString& only) +auto queryToGetNotifications(const QString& from, Omittable limit, + const QString& only) { BaseJob::Query _q; addParam(_q, QStringLiteral("from"), from); @@ -52,7 +23,8 @@ QUrl GetNotificationsJob::makeRequestUrl(QUrl baseUrl, const QString& from, const QString& only) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/notifications", + QStringLiteral("/_matrix/client/r0") + % "/notifications", queryToGetNotifications(from, limit, only)); } @@ -60,29 +32,8 @@ GetNotificationsJob::GetNotificationsJob(const QString& from, Omittable limit, const QString& only) : BaseJob(HttpVerb::Get, QStringLiteral("GetNotificationsJob"), - basePath % "/notifications", + QStringLiteral("/_matrix/client/r0") % "/notifications", queryToGetNotifications(from, limit, only)) - , d(new Private) -{} - -GetNotificationsJob::~GetNotificationsJob() = default; - -const QString& GetNotificationsJob::nextToken() const { return d->nextToken; } - -std::vector&& -GetNotificationsJob::notifications() -{ - return std::move(d->notifications); -} - -BaseJob::Status GetNotificationsJob::parseJson(const QJsonDocument& data) { - auto json = data.object(); - fromJson(json.value("next_token"_ls), d->nextToken); - if (!json.contains("notifications"_ls)) - return { IncorrectResponse, - "The key 'notifications' not found in the response" }; - fromJson(json.value("notifications"_ls), d->notifications); - - return Success; + addExpectedKey("notifications"); } diff --git a/lib/csapi/notifications.h b/lib/csapi/notifications.h index 0e86e424..095e9325 100644 --- a/lib/csapi/notifications.h +++ b/lib/csapi/notifications.h @@ -4,19 +4,11 @@ #pragma once -#include "converters.h" - #include "events/eventloader.h" #include "jobs/basejob.h" -#include -#include -#include - namespace Quotient { -// Operations - /*! \brief Gets a list of events that the user has been notified about * * This API is used to paginate through the list of events that the @@ -49,11 +41,14 @@ public: // Construction/destruction /*! \brief Gets a list of events that the user has been notified about + * * * \param from * Pagination token given to retrieve the next set of events. + * * \param limit * Limit on the number of events to return in this request. + * * \param only * Allows basic filtering of events returned. Supply ``highlight`` * to return only events where the notification had the highlight @@ -71,24 +66,33 @@ public: static QUrl makeRequestUrl(QUrl baseUrl, const QString& from = {}, Omittable limit = none, const QString& only = {}); - ~GetNotificationsJob() override; // Result properties /// 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. - const QString& nextToken() const; + QString nextToken() const { return loadFromJson("next_token"_ls); } /// The list of events that triggered notifications. - std::vector&& notifications(); - -protected: - Status parseJson(const QJsonDocument& data) override; + std::vector notifications() + { + return takeFromJson>("notifications"_ls); + } +}; -private: - class Private; - QScopedPointer d; +template <> +struct JsonObjectConverter { + static void fillFrom(const QJsonObject& jo, + GetNotificationsJob::Notification& result) + { + fromJson(jo.value("actions"_ls), result.actions); + fromJson(jo.value("event"_ls), result.event); + fromJson(jo.value("profile_tag"_ls), result.profileTag); + fromJson(jo.value("read"_ls), result.read); + fromJson(jo.value("room_id"_ls), result.roomId); + fromJson(jo.value("ts"_ls), result.ts); + } }; } // namespace Quotient diff --git a/lib/csapi/openid.cpp b/lib/csapi/openid.cpp index 9def2377..3941e9c0 100644 --- a/lib/csapi/openid.cpp +++ b/lib/csapi/openid.cpp @@ -4,66 +4,15 @@ #include "openid.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -class RequestOpenIdTokenJob::Private { -public: - QString accessToken; - QString tokenType; - QString matrixServerName; - int expiresIn; -}; - RequestOpenIdTokenJob::RequestOpenIdTokenJob(const QString& userId, const QJsonObject& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestOpenIdTokenJob"), - basePath % "/user/" % userId % "/openid/request_token") - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/user/" % userId + % "/openid/request_token") { setRequestData(Data(toJson(body))); } - -RequestOpenIdTokenJob::~RequestOpenIdTokenJob() = default; - -const QString& RequestOpenIdTokenJob::accessToken() const -{ - return d->accessToken; -} - -const QString& RequestOpenIdTokenJob::tokenType() const { return d->tokenType; } - -const QString& RequestOpenIdTokenJob::matrixServerName() const -{ - return d->matrixServerName; -} - -int RequestOpenIdTokenJob::expiresIn() const { return d->expiresIn; } - -BaseJob::Status RequestOpenIdTokenJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - if (!json.contains("access_token"_ls)) - return { IncorrectResponse, - "The key 'access_token' not found in the response" }; - fromJson(json.value("access_token"_ls), d->accessToken); - if (!json.contains("token_type"_ls)) - return { IncorrectResponse, - "The key 'token_type' not found in the response" }; - fromJson(json.value("token_type"_ls), d->tokenType); - if (!json.contains("matrix_server_name"_ls)) - return { IncorrectResponse, - "The key 'matrix_server_name' not found in the response" }; - fromJson(json.value("matrix_server_name"_ls), d->matrixServerName); - if (!json.contains("expires_in"_ls)) - return { IncorrectResponse, - "The key 'expires_in' not found in the response" }; - fromJson(json.value("expires_in"_ls), d->expiresIn); - - return Success; -} diff --git a/lib/csapi/openid.h b/lib/csapi/openid.h index bda4ce74..e69f9ad0 100644 --- a/lib/csapi/openid.h +++ b/lib/csapi/openid.h @@ -4,16 +4,12 @@ #pragma once -#include "converters.h" +#include "csapi/definitions/openid_token.h" #include "jobs/basejob.h" -#include - namespace Quotient { -// Operations - /*! \brief Get an OpenID token object to verify the requester's identity. * * Gets an OpenID token object that the requester may supply to another @@ -28,42 +24,26 @@ namespace Quotient { class RequestOpenIdTokenJob : public BaseJob { public: /*! \brief Get an OpenID token object to verify the requester's identity. + * * * \param userId * The user to request and OpenID token for. Should be the user who * is authenticated for the request. + * * \param body * An empty object. Reserved for future expansion. */ explicit RequestOpenIdTokenJob(const QString& userId, const QJsonObject& body = {}); - ~RequestOpenIdTokenJob() override; - // Result properties - /// 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``. - const QString& accessToken() const; - - /// The string ``Bearer``. - const QString& tokenType() const; - - /// The homeserver domain the consumer should use when attempting to - /// verify the user's identity. - const QString& matrixServerName() const; - - /// The number of seconds before this token expires and a new one must - /// be generated. - int expiresIn() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + /// OpenID token information. This response is nearly compatible with the + /// response documented in the `OpenID 1.0 Specification + /// `_ + /// with the only difference being the lack of an ``id_token``. Instead, + /// the Matrix homeserver's name is provided. + OpenidToken data() const { return fromJson(jsonData()); } }; } // namespace Quotient diff --git a/lib/csapi/peeking_events.cpp b/lib/csapi/peeking_events.cpp index 4d886812..70a5b6f3 100644 --- a/lib/csapi/peeking_events.cpp +++ b/lib/csapi/peeking_events.cpp @@ -4,23 +4,12 @@ #include "peeking_events.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -class PeekEventsJob::Private { -public: - QString begin; - QString end; - RoomEvents chunk; -}; - -BaseJob::Query queryToPeekEvents(const QString& from, Omittable timeout, - const QString& roomId) +auto queryToPeekEvents(const QString& from, Omittable timeout, + const QString& roomId) { BaseJob::Query _q; addParam(_q, QStringLiteral("from"), from); @@ -32,31 +21,15 @@ BaseJob::Query queryToPeekEvents(const QString& from, Omittable timeout, QUrl PeekEventsJob::makeRequestUrl(QUrl baseUrl, const QString& from, Omittable timeout, const QString& roomId) { - return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/events", + return BaseJob::makeRequestUrl(std::move(baseUrl), + QStringLiteral("/_matrix/client/r0") + % "/events", queryToPeekEvents(from, timeout, roomId)); } PeekEventsJob::PeekEventsJob(const QString& from, Omittable timeout, const QString& roomId) : BaseJob(HttpVerb::Get, QStringLiteral("PeekEventsJob"), - basePath % "/events", queryToPeekEvents(from, timeout, roomId)) - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/events", + queryToPeekEvents(from, timeout, roomId)) {} - -PeekEventsJob::~PeekEventsJob() = default; - -const QString& PeekEventsJob::begin() const { return d->begin; } - -const QString& PeekEventsJob::end() const { return d->end; } - -RoomEvents&& PeekEventsJob::chunk() { return std::move(d->chunk); } - -BaseJob::Status PeekEventsJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("start"_ls), d->begin); - fromJson(json.value("end"_ls), d->end); - fromJson(json.value("chunk"_ls), d->chunk); - - return Success; -} diff --git a/lib/csapi/peeking_events.h b/lib/csapi/peeking_events.h index 12a66a02..bfb9e24a 100644 --- a/lib/csapi/peeking_events.h +++ b/lib/csapi/peeking_events.h @@ -4,15 +4,11 @@ #pragma once -#include "converters.h" - #include "events/eventloader.h" #include "jobs/basejob.h" namespace Quotient { -// Operations - /*! \brief Listen on the event stream. * * This will listen for new events related to a particular room and return @@ -29,12 +25,15 @@ namespace Quotient { class PeekEventsJob : public BaseJob { public: /*! \brief Listen on the event stream. + * * * \param from * The token to stream from. This token is either from a previous * request to this API or from the initial sync API. + * * \param timeout * The maximum time in milliseconds to wait for an event. + * * \param roomId * The room ID for which events should be returned. */ @@ -50,27 +49,19 @@ public: static QUrl makeRequestUrl(QUrl baseUrl, const QString& from = {}, Omittable timeout = none, const QString& roomId = {}); - ~PeekEventsJob() override; // Result properties /// A token which correlates to the first value in ``chunk``. This /// is usually the same token supplied to ``from=``. - const QString& begin() const; + QString begin() const { return loadFromJson("start"_ls); } /// A token which correlates to the last value in ``chunk``. This /// token should be used in the next request to ``/events``. - const QString& end() const; + QString end() const { return loadFromJson("end"_ls); } /// An array of events. - RoomEvents&& chunk(); - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + RoomEvents chunk() { return takeFromJson("chunk"_ls); } }; } // namespace Quotient diff --git a/lib/csapi/presence.cpp b/lib/csapi/presence.cpp index 932ccc6e..58d0d157 100644 --- a/lib/csapi/presence.cpp +++ b/lib/csapi/presence.cpp @@ -4,71 +4,33 @@ #include "presence.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - SetPresenceJob::SetPresenceJob(const QString& userId, const QString& presence, const QString& statusMsg) : BaseJob(HttpVerb::Put, QStringLiteral("SetPresenceJob"), - basePath % "/presence/" % userId % "/status") + QStringLiteral("/_matrix/client/r0") % "/presence/" % userId + % "/status") { QJsonObject _data; addParam<>(_data, QStringLiteral("presence"), presence); addParam(_data, QStringLiteral("status_msg"), statusMsg); - setRequestData(_data); + setRequestData(std::move(_data)); } -class GetPresenceJob::Private { -public: - QString presence; - Omittable lastActiveAgo; - QString statusMsg; - Omittable currentlyActive; -}; - QUrl GetPresenceJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/presence/" % userId % "/status"); + QStringLiteral("/_matrix/client/r0") + % "/presence/" % userId % "/status"); } GetPresenceJob::GetPresenceJob(const QString& userId) : BaseJob(HttpVerb::Get, QStringLiteral("GetPresenceJob"), - basePath % "/presence/" % userId % "/status") - , d(new Private) -{} - -GetPresenceJob::~GetPresenceJob() = default; - -const QString& GetPresenceJob::presence() const { return d->presence; } - -Omittable GetPresenceJob::lastActiveAgo() const -{ - return d->lastActiveAgo; -} - -const QString& GetPresenceJob::statusMsg() const { return d->statusMsg; } - -Omittable GetPresenceJob::currentlyActive() const + QStringLiteral("/_matrix/client/r0") % "/presence/" % userId + % "/status") { - return d->currentlyActive; -} - -BaseJob::Status GetPresenceJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - if (!json.contains("presence"_ls)) - return { IncorrectResponse, - "The key 'presence' not found in the response" }; - fromJson(json.value("presence"_ls), d->presence); - fromJson(json.value("last_active_ago"_ls), d->lastActiveAgo); - fromJson(json.value("status_msg"_ls), d->statusMsg); - fromJson(json.value("currently_active"_ls), d->currentlyActive); - - return Success; + addExpectedKey("presence"); } diff --git a/lib/csapi/presence.h b/lib/csapi/presence.h index 21e57603..b34028e7 100644 --- a/lib/csapi/presence.h +++ b/lib/csapi/presence.h @@ -4,14 +4,10 @@ #pragma once -#include "converters.h" - #include "jobs/basejob.h" namespace Quotient { -// Operations - /*! \brief Update this user's presence state. * * This API sets the given user's presence state. When setting the status, @@ -22,11 +18,14 @@ namespace Quotient { class SetPresenceJob : public BaseJob { public: /*! \brief Update this user's presence state. + * * * \param userId * The user whose presence state to update. + * * \param presence * The new presence state. + * * \param statusMsg * The status message to attach to this state. */ @@ -41,6 +40,7 @@ public: class GetPresenceJob : public BaseJob { public: /*! \brief Get this user's presence state. + * * * \param userId * The user whose presence state to get. @@ -53,29 +53,27 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId); - ~GetPresenceJob() override; // Result properties /// This user's presence. - const QString& presence() const; + QString presence() const { return loadFromJson("presence"_ls); } /// The length of time in milliseconds since an action was performed /// by this user. - Omittable lastActiveAgo() const; + Omittable lastActiveAgo() const + { + return loadFromJson>("last_active_ago"_ls); + } /// The state message for this user if one was set. - const QString& statusMsg() const; + QString statusMsg() const { return loadFromJson("status_msg"_ls); } /// Whether the user is currently active - Omittable currentlyActive() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + Omittable currentlyActive() const + { + return loadFromJson>("currently_active"_ls); + } }; } // namespace Quotient diff --git a/lib/csapi/profile.cpp b/lib/csapi/profile.cpp index d86e3bdc..cb8f72be 100644 --- a/lib/csapi/profile.cpp +++ b/lib/csapi/profile.cpp @@ -4,122 +4,67 @@ #include "profile.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - SetDisplayNameJob::SetDisplayNameJob(const QString& userId, const QString& displayname) : BaseJob(HttpVerb::Put, QStringLiteral("SetDisplayNameJob"), - basePath % "/profile/" % userId % "/displayname") + QStringLiteral("/_matrix/client/r0") % "/profile/" % userId + % "/displayname") { QJsonObject _data; addParam(_data, QStringLiteral("displayname"), displayname); - setRequestData(_data); + setRequestData(std::move(_data)); } -class GetDisplayNameJob::Private { -public: - QString displayname; -}; - QUrl GetDisplayNameJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { - return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/profile/" - % userId - % "/displayname"); + return BaseJob::makeRequestUrl(std::move(baseUrl), + QStringLiteral("/_matrix/client/r0") + % "/profile/" % userId % "/displayname"); } GetDisplayNameJob::GetDisplayNameJob(const QString& userId) : BaseJob(HttpVerb::Get, QStringLiteral("GetDisplayNameJob"), - basePath % "/profile/" % userId % "/displayname", false) - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/profile/" % userId + % "/displayname", + false) {} -GetDisplayNameJob::~GetDisplayNameJob() = default; - -const QString& GetDisplayNameJob::displayname() const { return d->displayname; } - -BaseJob::Status GetDisplayNameJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("displayname"_ls), d->displayname); - - return Success; -} - SetAvatarUrlJob::SetAvatarUrlJob(const QString& userId, const QString& avatarUrl) : BaseJob(HttpVerb::Put, QStringLiteral("SetAvatarUrlJob"), - basePath % "/profile/" % userId % "/avatar_url") + QStringLiteral("/_matrix/client/r0") % "/profile/" % userId + % "/avatar_url") { QJsonObject _data; addParam(_data, QStringLiteral("avatar_url"), avatarUrl); - setRequestData(_data); + setRequestData(std::move(_data)); } -class GetAvatarUrlJob::Private { -public: - QString avatarUrl; -}; - QUrl GetAvatarUrlJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { - return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/profile/" - % userId - % "/avatar_url"); + return BaseJob::makeRequestUrl(std::move(baseUrl), + QStringLiteral("/_matrix/client/r0") + % "/profile/" % userId % "/avatar_url"); } GetAvatarUrlJob::GetAvatarUrlJob(const QString& userId) : BaseJob(HttpVerb::Get, QStringLiteral("GetAvatarUrlJob"), - basePath % "/profile/" % userId % "/avatar_url", false) - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/profile/" % userId + % "/avatar_url", + false) {} -GetAvatarUrlJob::~GetAvatarUrlJob() = default; - -const QString& GetAvatarUrlJob::avatarUrl() const { return d->avatarUrl; } - -BaseJob::Status GetAvatarUrlJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("avatar_url"_ls), d->avatarUrl); - - return Success; -} - -class GetUserProfileJob::Private { -public: - QString avatarUrl; - QString displayname; -}; - QUrl GetUserProfileJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/profile/" % userId); + QStringLiteral("/_matrix/client/r0") + % "/profile/" % userId); } GetUserProfileJob::GetUserProfileJob(const QString& userId) : BaseJob(HttpVerb::Get, QStringLiteral("GetUserProfileJob"), - basePath % "/profile/" % userId, false) - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/profile/" % userId, false) {} - -GetUserProfileJob::~GetUserProfileJob() = default; - -const QString& GetUserProfileJob::avatarUrl() const { return d->avatarUrl; } - -const QString& GetUserProfileJob::displayname() const { return d->displayname; } - -BaseJob::Status GetUserProfileJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("avatar_url"_ls), d->avatarUrl); - fromJson(json.value("displayname"_ls), d->displayname); - - return Success; -} diff --git a/lib/csapi/profile.h b/lib/csapi/profile.h index 8279fe20..5b0d06d9 100644 --- a/lib/csapi/profile.h +++ b/lib/csapi/profile.h @@ -8,8 +8,6 @@ namespace Quotient { -// Operations - /*! \brief Set the user's display name. * * This API sets the given user's display name. You must have permission to @@ -18,9 +16,11 @@ namespace Quotient { class SetDisplayNameJob : public BaseJob { public: /*! \brief Set the user's display name. + * * * \param userId * The user whose display name to set. + * * \param displayname * The new display name for this user. */ @@ -37,6 +37,7 @@ public: class GetDisplayNameJob : public BaseJob { public: /*! \brief Get the user's display name. + * * * \param userId * The user whose display name to get. @@ -49,19 +50,14 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId); - ~GetDisplayNameJob() override; // Result properties /// The user's display name if they have set one, otherwise not present. - const QString& displayname() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QString displayname() const + { + return loadFromJson("displayname"_ls); + } }; /*! \brief Set the user's avatar URL. @@ -72,9 +68,11 @@ private: class SetAvatarUrlJob : public BaseJob { public: /*! \brief Set the user's avatar URL. + * * * \param userId * The user whose avatar URL to set. + * * \param avatarUrl * The new avatar URL for this user. */ @@ -91,6 +89,7 @@ public: class GetAvatarUrlJob : public BaseJob { public: /*! \brief Get the user's avatar URL. + * * * \param userId * The user whose avatar URL to get. @@ -103,19 +102,11 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId); - ~GetAvatarUrlJob() override; // Result properties /// The user's avatar URL if they have set one, otherwise not present. - const QString& avatarUrl() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QString avatarUrl() const { return loadFromJson("avatar_url"_ls); } }; /*! \brief Get this user's profile information. @@ -128,6 +119,7 @@ private: class GetUserProfileJob : public BaseJob { public: /*! \brief Get this user's profile information. + * * * \param userId * The user whose profile information to get. @@ -140,22 +132,17 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId); - ~GetUserProfileJob() override; // Result properties /// The user's avatar URL if they have set one, otherwise not present. - const QString& avatarUrl() const; + QString avatarUrl() const { return loadFromJson("avatar_url"_ls); } /// The user's display name if they have set one, otherwise not present. - const QString& displayname() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QString displayname() const + { + return loadFromJson("displayname"_ls); + } }; } // namespace Quotient diff --git a/lib/csapi/pusher.cpp b/lib/csapi/pusher.cpp index ad51b901..028022c5 100644 --- a/lib/csapi/pusher.cpp +++ b/lib/csapi/pusher.cpp @@ -4,96 +4,29 @@ #include "pusher.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -// Converters -namespace Quotient { - -template <> -struct JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, - GetPushersJob::PusherData& result) - { - fromJson(jo.value("url"_ls), result.url); - fromJson(jo.value("format"_ls), result.format); - } -}; - -template <> -struct JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, GetPushersJob::Pusher& result) - { - fromJson(jo.value("pushkey"_ls), result.pushkey); - fromJson(jo.value("kind"_ls), result.kind); - fromJson(jo.value("app_id"_ls), result.appId); - fromJson(jo.value("app_display_name"_ls), result.appDisplayName); - fromJson(jo.value("device_display_name"_ls), result.deviceDisplayName); - fromJson(jo.value("profile_tag"_ls), result.profileTag); - fromJson(jo.value("lang"_ls), result.lang); - fromJson(jo.value("data"_ls), result.data); - } -}; - -} // namespace Quotient - -class GetPushersJob::Private { -public: - QVector pushers; -}; - QUrl GetPushersJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/pushers"); + return BaseJob::makeRequestUrl(std::move(baseUrl), + QStringLiteral("/_matrix/client/r0") + % "/pushers"); } GetPushersJob::GetPushersJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetPushersJob"), - basePath % "/pushers") - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/pushers") {} -GetPushersJob::~GetPushersJob() = default; - -const QVector& GetPushersJob::pushers() const -{ - return d->pushers; -} - -BaseJob::Status GetPushersJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("pushers"_ls), d->pushers); - - return Success; -} - -// Converters -namespace Quotient { - -template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const PostPusherJob::PusherData& pod) - { - addParam(jo, QStringLiteral("url"), pod.url); - addParam(jo, QStringLiteral("format"), pod.format); - } -}; - -} // namespace Quotient - PostPusherJob::PostPusherJob(const QString& pushkey, const QString& kind, const QString& appId, const QString& appDisplayName, const QString& deviceDisplayName, const QString& lang, const PusherData& data, const QString& profileTag, Omittable append) : BaseJob(HttpVerb::Post, QStringLiteral("PostPusherJob"), - basePath % "/pushers/set") + QStringLiteral("/_matrix/client/r0") % "/pushers/set") { QJsonObject _data; addParam<>(_data, QStringLiteral("pushkey"), pushkey); @@ -105,5 +38,5 @@ PostPusherJob::PostPusherJob(const QString& pushkey, const QString& kind, addParam<>(_data, QStringLiteral("lang"), lang); addParam<>(_data, QStringLiteral("data"), data); addParam(_data, QStringLiteral("append"), append); - setRequestData(_data); + setRequestData(std::move(_data)); } diff --git a/lib/csapi/pusher.h b/lib/csapi/pusher.h index d60a2b56..40cd5796 100644 --- a/lib/csapi/pusher.h +++ b/lib/csapi/pusher.h @@ -4,16 +4,10 @@ #pragma once -#include "converters.h" - #include "jobs/basejob.h" -#include - namespace Quotient { -// Operations - /*! \brief Gets the current pushers for the authenticated user * * Gets all currently active pushers for the authenticated user. @@ -73,19 +67,39 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetPushersJob() override; // Result properties /// An array containing the current pushers for the user - const QVector& pushers() const; + QVector pushers() const + { + return loadFromJson>("pushers"_ls); + } +}; -protected: - Status parseJson(const QJsonDocument& data) override; +template <> +struct JsonObjectConverter { + static void fillFrom(const QJsonObject& jo, + GetPushersJob::PusherData& result) + { + fromJson(jo.value("url"_ls), result.url); + fromJson(jo.value("format"_ls), result.format); + } +}; -private: - class Private; - QScopedPointer d; +template <> +struct JsonObjectConverter { + static void fillFrom(const QJsonObject& jo, GetPushersJob::Pusher& result) + { + fromJson(jo.value("pushkey"_ls), result.pushkey); + fromJson(jo.value("kind"_ls), result.kind); + fromJson(jo.value("app_id"_ls), result.appId); + fromJson(jo.value("app_display_name"_ls), result.appDisplayName); + fromJson(jo.value("device_display_name"_ls), result.deviceDisplayName); + fromJson(jo.value("profile_tag"_ls), result.profileTag); + fromJson(jo.value("lang"_ls), result.lang); + fromJson(jo.value("data"_ls), result.data); + } }; /*! \brief Modify a pusher for this user on the homeserver. @@ -117,6 +131,7 @@ public: // Construction/destruction /*! \brief Modify a pusher for this user on the homeserver. + * * * \param pushkey * This is a unique identifier for this pusher. The value you @@ -128,10 +143,12 @@ public: * * If the ``kind`` is ``"email"``, this is the email address to * send notifications to. + * * \param kind * The kind of pusher to configure. ``"http"`` makes a pusher that * sends HTTP pokes. ``"email"`` makes a pusher that emails the * user with unread notifications. ``null`` deletes the pusher. + * * \param appId * This is a reverse-DNS style identifier for the application. * It is recommended that this end with the platform, such that @@ -139,22 +156,28 @@ public: * Max length, 64 chars. * * If the ``kind`` is ``"email"``, this is ``"m.email"``. + * * \param appDisplayName * A string that will allow the user to identify what application * owns this pusher. + * * \param deviceDisplayName * A string that will allow the user to identify what device owns * this pusher. + * * \param lang * The preferred language for receiving notifications (e.g. 'en' * or 'en-US'). + * * \param data * 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. + * * \param profileTag * This string determines which set of device specific rules this * pusher executes. + * * \param append * If true, the homeserver should add another pusher with the * given pushkey and App ID in addition to any others with @@ -170,4 +193,13 @@ public: Omittable append = none); }; +template <> +struct JsonObjectConverter { + static void dumpTo(QJsonObject& jo, const PostPusherJob::PusherData& pod) + { + addParam(jo, QStringLiteral("url"), pod.url); + addParam(jo, QStringLiteral("format"), pod.format); + } +}; + } // namespace Quotient diff --git a/lib/csapi/pushrules.cpp b/lib/csapi/pushrules.cpp index cd0fb02d..f2a16f1b 100644 --- a/lib/csapi/pushrules.cpp +++ b/lib/csapi/pushrules.cpp @@ -4,92 +4,58 @@ #include "pushrules.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -class GetPushRulesJob::Private { -public: - PushRuleset global; -}; - QUrl GetPushRulesJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/pushrules"); + return BaseJob::makeRequestUrl(std::move(baseUrl), + QStringLiteral("/_matrix/client/r0") + % "/pushrules"); } GetPushRulesJob::GetPushRulesJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetPushRulesJob"), - basePath % "/pushrules") - , d(new Private) -{} - -GetPushRulesJob::~GetPushRulesJob() = default; - -const PushRuleset& GetPushRulesJob::global() const { return d->global; } - -BaseJob::Status GetPushRulesJob::parseJson(const QJsonDocument& data) + QStringLiteral("/_matrix/client/r0") % "/pushrules") { - auto json = data.object(); - if (!json.contains("global"_ls)) - return { IncorrectResponse, - "The key 'global' not found in the response" }; - fromJson(json.value("global"_ls), d->global); - - return Success; + addExpectedKey("global"); } -class GetPushRuleJob::Private { -public: - PushRule data; -}; - QUrl GetPushRuleJob::makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& kind, const QString& ruleId) { - return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/pushrules/" - % scope % "/" % kind - % "/" % ruleId); + return BaseJob::makeRequestUrl(std::move(baseUrl), + QStringLiteral("/_matrix/client/r0") + % "/pushrules/" % scope % "/" % kind + % "/" % ruleId); } GetPushRuleJob::GetPushRuleJob(const QString& scope, const QString& kind, const QString& ruleId) : BaseJob(HttpVerb::Get, QStringLiteral("GetPushRuleJob"), - basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId) - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/pushrules/" % scope % "/" + % kind % "/" % ruleId) {} -GetPushRuleJob::~GetPushRuleJob() = default; - -const PushRule& GetPushRuleJob::data() const { return d->data; } - -BaseJob::Status GetPushRuleJob::parseJson(const QJsonDocument& data) -{ - fromJson(data, d->data); - - return Success; -} - QUrl DeletePushRuleJob::makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& kind, const QString& ruleId) { - return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/pushrules/" - % scope % "/" % kind - % "/" % ruleId); + return BaseJob::makeRequestUrl(std::move(baseUrl), + QStringLiteral("/_matrix/client/r0") + % "/pushrules/" % scope % "/" % kind + % "/" % ruleId); } DeletePushRuleJob::DeletePushRuleJob(const QString& scope, const QString& kind, const QString& ruleId) : BaseJob(HttpVerb::Delete, QStringLiteral("DeletePushRuleJob"), - basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId) + QStringLiteral("/_matrix/client/r0") % "/pushrules/" % scope % "/" + % kind % "/" % ruleId) {} -BaseJob::Query queryToSetPushRule(const QString& before, const QString& after) +auto queryToSetPushRule(const QString& before, const QString& after) { BaseJob::Query _q; addParam(_q, QStringLiteral("before"), before); @@ -103,27 +69,24 @@ SetPushRuleJob::SetPushRuleJob(const QString& scope, const QString& kind, const QVector& conditions, const QString& pattern) : BaseJob(HttpVerb::Put, QStringLiteral("SetPushRuleJob"), - basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId, + QStringLiteral("/_matrix/client/r0") % "/pushrules/" % scope % "/" + % kind % "/" % ruleId, queryToSetPushRule(before, after)) { QJsonObject _data; addParam<>(_data, QStringLiteral("actions"), actions); addParam(_data, QStringLiteral("conditions"), conditions); addParam(_data, QStringLiteral("pattern"), pattern); - setRequestData(_data); + setRequestData(std::move(_data)); } -class IsPushRuleEnabledJob::Private { -public: - bool enabled; -}; - QUrl IsPushRuleEnabledJob::makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& kind, const QString& ruleId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/pushrules/" % scope % "/" % kind + QStringLiteral("/_matrix/client/r0") + % "/pushrules/" % scope % "/" % kind % "/" % ruleId % "/enabled"); } @@ -131,49 +94,31 @@ IsPushRuleEnabledJob::IsPushRuleEnabledJob(const QString& scope, const QString& kind, const QString& ruleId) : BaseJob(HttpVerb::Get, QStringLiteral("IsPushRuleEnabledJob"), - basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId - % "/enabled") - , d(new Private) -{} - -IsPushRuleEnabledJob::~IsPushRuleEnabledJob() = default; - -bool IsPushRuleEnabledJob::enabled() const { return d->enabled; } - -BaseJob::Status IsPushRuleEnabledJob::parseJson(const QJsonDocument& data) + QStringLiteral("/_matrix/client/r0") % "/pushrules/" % scope % "/" + % kind % "/" % ruleId % "/enabled") { - auto json = data.object(); - if (!json.contains("enabled"_ls)) - return { IncorrectResponse, - "The key 'enabled' not found in the response" }; - fromJson(json.value("enabled"_ls), d->enabled); - - return Success; + addExpectedKey("enabled"); } SetPushRuleEnabledJob::SetPushRuleEnabledJob(const QString& scope, const QString& kind, const QString& ruleId, bool enabled) : BaseJob(HttpVerb::Put, QStringLiteral("SetPushRuleEnabledJob"), - basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId - % "/enabled") + QStringLiteral("/_matrix/client/r0") % "/pushrules/" % scope % "/" + % kind % "/" % ruleId % "/enabled") { QJsonObject _data; addParam<>(_data, QStringLiteral("enabled"), enabled); - setRequestData(_data); + setRequestData(std::move(_data)); } -class GetPushRuleActionsJob::Private { -public: - QStringList actions; -}; - QUrl GetPushRuleActionsJob::makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& kind, const QString& ruleId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/pushrules/" % scope % "/" % kind + QStringLiteral("/_matrix/client/r0") + % "/pushrules/" % scope % "/" % kind % "/" % ruleId % "/actions"); } @@ -181,24 +126,10 @@ GetPushRuleActionsJob::GetPushRuleActionsJob(const QString& scope, const QString& kind, const QString& ruleId) : BaseJob(HttpVerb::Get, QStringLiteral("GetPushRuleActionsJob"), - basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId - % "/actions") - , d(new Private) -{} - -GetPushRuleActionsJob::~GetPushRuleActionsJob() = default; - -const QStringList& GetPushRuleActionsJob::actions() const { return d->actions; } - -BaseJob::Status GetPushRuleActionsJob::parseJson(const QJsonDocument& data) + QStringLiteral("/_matrix/client/r0") % "/pushrules/" % scope % "/" + % kind % "/" % ruleId % "/actions") { - auto json = data.object(); - if (!json.contains("actions"_ls)) - return { IncorrectResponse, - "The key 'actions' not found in the response" }; - fromJson(json.value("actions"_ls), d->actions); - - return Success; + addExpectedKey("actions"); } SetPushRuleActionsJob::SetPushRuleActionsJob(const QString& scope, @@ -206,10 +137,10 @@ SetPushRuleActionsJob::SetPushRuleActionsJob(const QString& scope, const QString& ruleId, const QStringList& actions) : BaseJob(HttpVerb::Put, QStringLiteral("SetPushRuleActionsJob"), - basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId - % "/actions") + QStringLiteral("/_matrix/client/r0") % "/pushrules/" % scope % "/" + % kind % "/" % ruleId % "/actions") { QJsonObject _data; addParam<>(_data, QStringLiteral("actions"), actions); - setRequestData(_data); + setRequestData(std::move(_data)); } diff --git a/lib/csapi/pushrules.h b/lib/csapi/pushrules.h index a9169151..0971dc6b 100644 --- a/lib/csapi/pushrules.h +++ b/lib/csapi/pushrules.h @@ -4,20 +4,14 @@ #pragma once -#include "converters.h" - #include "csapi/definitions/push_condition.h" #include "csapi/definitions/push_rule.h" #include "csapi/definitions/push_ruleset.h" #include "jobs/basejob.h" -#include - namespace Quotient { -// Operations - /*! \brief Retrieve all push rulesets. * * Retrieve all push rulesets for this user. Clients can "drill-down" on @@ -36,19 +30,14 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetPushRulesJob() override; // Result properties /// The global ruleset. - const PushRuleset& global() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + PushRuleset global() const + { + return loadFromJson("global"_ls); + } }; /*! \brief Retrieve a push rule. @@ -58,11 +47,14 @@ private: class GetPushRuleJob : public BaseJob { public: /*! \brief Retrieve a push rule. + * * * \param scope * ``global`` to specify global rules. + * * \param kind * The kind of rule + * * \param ruleId * The identifier for the rule. */ @@ -76,19 +68,12 @@ public: */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& kind, const QString& ruleId); - ~GetPushRuleJob() override; // Result properties - /// The push rule. - const PushRule& data() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + /// The specific push rule. This will also include keys specific to the + /// rule itself such as the rule's ``actions`` and ``conditions`` if set. + PushRule data() const { return fromJson(jsonData()); } }; /*! \brief Delete a push rule. @@ -98,11 +83,14 @@ private: class DeletePushRuleJob : public BaseJob { public: /*! \brief Delete a push rule. + * * * \param scope * ``global`` to specify global rules. + * * \param kind * The kind of rule + * * \param ruleId * The identifier for the rule. */ @@ -129,29 +117,38 @@ public: class SetPushRuleJob : public BaseJob { public: /*! \brief Add or change a push rule. + * * * \param scope * ``global`` to specify global rules. + * * \param kind * The kind of rule + * * \param ruleId * The identifier for the rule. + * * \param actions * The action(s) to perform when the conditions for this rule are met. + * * \param before * Use 'before' with a ``rule_id`` as its value to make the new rule the * next-most important rule with respect to the given user defined rule. * It is not possible to add a rule relative to a predefined server rule. + * * \param after * This makes the new rule the next-less important rule relative to the * given user defined rule. It is not possible to add a rule relative * to a predefined server rule. + * * \param conditions * The conditions that must hold true for an event in order for a * rule to be applied to an event. A rule with no conditions - * always matches. Only applicable to ``underride`` and ``override`` - * rules. \param pattern Only applicable to ``content`` rules. The - * glob-style pattern to match against. + * always matches. Only applicable to ``underride`` and ``override`` rules. + * + * \param pattern + * Only applicable to ``content`` rules. The glob-style pattern to match + * against. */ explicit SetPushRuleJob(const QString& scope, const QString& kind, const QString& ruleId, const QStringList& actions, @@ -168,12 +165,15 @@ public: class IsPushRuleEnabledJob : public BaseJob { public: /*! \brief Get whether a push rule is enabled + * * * \param scope * Either ``global`` or ``device/`` to specify global * rules or device rules for the given ``profile_tag``. + * * \param kind * The kind of rule + * * \param ruleId * The identifier for the rule. */ @@ -187,19 +187,11 @@ public: */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& kind, const QString& ruleId); - ~IsPushRuleEnabledJob() override; // Result properties /// Whether the push rule is enabled or not. - bool enabled() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + bool enabled() const { return loadFromJson("enabled"_ls); } }; /*! \brief Enable or disable a push rule. @@ -209,13 +201,17 @@ private: class SetPushRuleEnabledJob : public BaseJob { public: /*! \brief Enable or disable a push rule. + * * * \param scope * ``global`` to specify global rules. + * * \param kind * The kind of rule + * * \param ruleId * The identifier for the rule. + * * \param enabled * Whether the push rule is enabled or not. */ @@ -230,12 +226,15 @@ public: class GetPushRuleActionsJob : public BaseJob { public: /*! \brief The actions for a push rule + * * * \param scope * Either ``global`` or ``device/`` to specify global * rules or device rules for the given ``profile_tag``. + * * \param kind * The kind of rule + * * \param ruleId * The identifier for the rule. */ @@ -249,19 +248,14 @@ public: */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& kind, const QString& ruleId); - ~GetPushRuleActionsJob() override; // Result properties /// The action(s) to perform for this rule. - const QStringList& actions() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QStringList actions() const + { + return loadFromJson("actions"_ls); + } }; /*! \brief Set the actions for a push rule. @@ -272,13 +266,17 @@ private: class SetPushRuleActionsJob : public BaseJob { public: /*! \brief Set the actions for a push rule. + * * * \param scope * ``global`` to specify global rules. + * * \param kind * The kind of rule + * * \param ruleId * The identifier for the rule. + * * \param actions * The action(s) to perform for this rule. */ diff --git a/lib/csapi/read_markers.cpp b/lib/csapi/read_markers.cpp index 76145808..39e4d148 100644 --- a/lib/csapi/read_markers.cpp +++ b/lib/csapi/read_markers.cpp @@ -4,22 +4,19 @@ #include "read_markers.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - SetReadMarkerJob::SetReadMarkerJob(const QString& roomId, const QString& mFullyRead, const QString& mRead) : BaseJob(HttpVerb::Post, QStringLiteral("SetReadMarkerJob"), - basePath % "/rooms/" % roomId % "/read_markers") + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId + % "/read_markers") { QJsonObject _data; addParam<>(_data, QStringLiteral("m.fully_read"), mFullyRead); addParam(_data, QStringLiteral("m.read"), mRead); - setRequestData(_data); + setRequestData(std::move(_data)); } diff --git a/lib/csapi/read_markers.h b/lib/csapi/read_markers.h index 539aa5e4..addb9123 100644 --- a/lib/csapi/read_markers.h +++ b/lib/csapi/read_markers.h @@ -8,8 +8,6 @@ namespace Quotient { -// Operations - /*! \brief Set the position of the read marker for a room. * * Sets the position of the read marker for a given room, and optionally @@ -18,12 +16,15 @@ namespace Quotient { class SetReadMarkerJob : public BaseJob { public: /*! \brief Set the position of the read marker for a room. + * * * \param roomId * The room ID to set the read marker in for the user. + * * \param mFullyRead * The event ID the read marker should be located at. The * event MUST belong to the room. + * * \param mRead * The event ID to set the read receipt location at. This is * equivalent to calling ``/receipt/m.read/$elsewhere:example.org`` diff --git a/lib/csapi/receipts.cpp b/lib/csapi/receipts.cpp index 87264074..00d1c28a 100644 --- a/lib/csapi/receipts.cpp +++ b/lib/csapi/receipts.cpp @@ -4,20 +4,16 @@ #include "receipts.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - PostReceiptJob::PostReceiptJob(const QString& roomId, const QString& receiptType, const QString& eventId, const QJsonObject& receipt) : BaseJob(HttpVerb::Post, QStringLiteral("PostReceiptJob"), - basePath % "/rooms/" % roomId % "/receipt/" % receiptType % "/" - % eventId) + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId + % "/receipt/" % receiptType % "/" % eventId) { setRequestData(Data(toJson(receipt))); } diff --git a/lib/csapi/receipts.h b/lib/csapi/receipts.h index eb82fc28..fdec3b88 100644 --- a/lib/csapi/receipts.h +++ b/lib/csapi/receipts.h @@ -6,12 +6,8 @@ #include "jobs/basejob.h" -#include - namespace Quotient { -// Operations - /*! \brief Send a receipt for the given event ID. * * This API updates the marker for the given receipt type to the event ID @@ -20,13 +16,17 @@ namespace Quotient { class PostReceiptJob : public BaseJob { public: /*! \brief Send a receipt for the given event ID. + * * * \param roomId * The room in which to send the event. + * * \param receiptType * The type of receipt to send. + * * \param eventId * The event ID to acknowledge up to. + * * \param receipt * Extra receipt information to attach to ``content`` if any. The * server will automatically set the ``ts`` field. diff --git a/lib/csapi/redaction.cpp b/lib/csapi/redaction.cpp index 2b6417ea..91497064 100644 --- a/lib/csapi/redaction.cpp +++ b/lib/csapi/redaction.cpp @@ -4,38 +4,17 @@ #include "redaction.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -class RedactEventJob::Private { -public: - QString eventId; -}; - RedactEventJob::RedactEventJob(const QString& roomId, const QString& eventId, const QString& txnId, const QString& reason) : BaseJob(HttpVerb::Put, QStringLiteral("RedactEventJob"), - basePath % "/rooms/" % roomId % "/redact/" % eventId % "/" % txnId) - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId + % "/redact/" % eventId % "/" % txnId) { QJsonObject _data; addParam(_data, QStringLiteral("reason"), reason); - setRequestData(_data); -} - -RedactEventJob::~RedactEventJob() = default; - -const QString& RedactEventJob::eventId() const { return d->eventId; } - -BaseJob::Status RedactEventJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("event_id"_ls), d->eventId); - - return Success; + setRequestData(std::move(_data)); } diff --git a/lib/csapi/redaction.h b/lib/csapi/redaction.h index 0e9095d1..c737de41 100644 --- a/lib/csapi/redaction.h +++ b/lib/csapi/redaction.h @@ -8,8 +8,6 @@ namespace Quotient { -// Operations - /*! \brief Strips all non-integrity-critical information out of an event. * * Strips all information out of an event which isn't critical to the @@ -18,38 +16,35 @@ namespace Quotient { * This cannot be undone. * * Users may redact their own events, and any user with a power level - * greater than or equal to the `redact` power level of the room may + * greater than or equal to the ``redact`` power level of the room may * redact events there. */ class RedactEventJob : public BaseJob { public: /*! \brief Strips all non-integrity-critical information out of an event. + * * * \param roomId * The room from which to redact the event. + * * \param eventId * The ID of the event to redact + * * \param txnId * The transaction ID for this event. Clients should generate a * unique ID; it will be used by the server to ensure idempotency of - * requests. \param reason The reason for the event being redacted. + * requests. + * + * \param reason + * The reason for the event being redacted. */ explicit RedactEventJob(const QString& roomId, const QString& eventId, const QString& txnId, const QString& reason = {}); - ~RedactEventJob() override; - // Result properties /// A unique identifier for the event. - const QString& eventId() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QString eventId() const { return loadFromJson("event_id"_ls); } }; } // namespace Quotient diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index 768617cc..9f88ef28 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -4,23 +4,11 @@ #include "registration.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -class RegisterJob::Private { -public: - QString userId; - QString accessToken; - QString homeServer; - QString deviceId; -}; - -BaseJob::Query queryToRegister(const QString& kind) +auto queryToRegister(const QString& kind) { BaseJob::Query _q; addParam(_q, QStringLiteral("kind"), kind); @@ -29,220 +17,94 @@ BaseJob::Query queryToRegister(const QString& kind) RegisterJob::RegisterJob(const QString& kind, const Omittable& auth, - Omittable bindEmail, const QString& username, - const QString& password, const QString& deviceId, + const QString& username, const QString& password, + const QString& deviceId, const QString& initialDeviceDisplayName, Omittable inhibitLogin) : BaseJob(HttpVerb::Post, QStringLiteral("RegisterJob"), - basePath % "/register", queryToRegister(kind), {}, false) - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/register", + queryToRegister(kind), {}, false) { QJsonObject _data; addParam(_data, QStringLiteral("auth"), auth); - addParam(_data, QStringLiteral("bind_email"), bindEmail); addParam(_data, QStringLiteral("username"), username); addParam(_data, QStringLiteral("password"), password); addParam(_data, QStringLiteral("device_id"), deviceId); addParam(_data, QStringLiteral("initial_device_display_name"), initialDeviceDisplayName); addParam(_data, QStringLiteral("inhibit_login"), inhibitLogin); - setRequestData(_data); -} - -RegisterJob::~RegisterJob() = default; - -const QString& RegisterJob::userId() const { return d->userId; } - -const QString& RegisterJob::accessToken() const { return d->accessToken; } - -const QString& RegisterJob::homeServer() const { return d->homeServer; } - -const QString& RegisterJob::deviceId() const { return d->deviceId; } - -BaseJob::Status RegisterJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - if (!json.contains("user_id"_ls)) - return { IncorrectResponse, - "The key 'user_id' not found in the response" }; - fromJson(json.value("user_id"_ls), d->userId); - fromJson(json.value("access_token"_ls), d->accessToken); - fromJson(json.value("home_server"_ls), d->homeServer); - fromJson(json.value("device_id"_ls), d->deviceId); - - return Success; + setRequestData(std::move(_data)); + addExpectedKey("user_id"); } -class RequestTokenToRegisterEmailJob::Private { -public: - Sid data; -}; - RequestTokenToRegisterEmailJob::RequestTokenToRegisterEmailJob( - const QString& clientSecret, const QString& email, int sendAttempt, - const QString& idServer, const QString& nextLink) + const EmailValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToRegisterEmailJob"), - basePath % "/register/email/requestToken", false) - , d(new Private) -{ - QJsonObject _data; - addParam<>(_data, QStringLiteral("client_secret"), clientSecret); - addParam<>(_data, QStringLiteral("email"), email); - addParam<>(_data, QStringLiteral("send_attempt"), sendAttempt); - addParam(_data, QStringLiteral("next_link"), nextLink); - addParam<>(_data, QStringLiteral("id_server"), idServer); - setRequestData(_data); -} - -RequestTokenToRegisterEmailJob::~RequestTokenToRegisterEmailJob() = default; - -const Sid& RequestTokenToRegisterEmailJob::data() const { return d->data; } - -BaseJob::Status -RequestTokenToRegisterEmailJob::parseJson(const QJsonDocument& data) + QStringLiteral("/_matrix/client/r0") + % "/register/email/requestToken", + false) { - fromJson(data, d->data); - - return Success; + setRequestData(Data(toJson(body))); } -class RequestTokenToRegisterMSISDNJob::Private { -public: - Sid data; -}; - RequestTokenToRegisterMSISDNJob::RequestTokenToRegisterMSISDNJob( - const QString& clientSecret, const QString& country, - const QString& phoneNumber, int sendAttempt, const QString& idServer, - const QString& nextLink) + const MsisdnValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToRegisterMSISDNJob"), - basePath % "/register/msisdn/requestToken", false) - , d(new Private) + QStringLiteral("/_matrix/client/r0") + % "/register/msisdn/requestToken", + false) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("client_secret"), clientSecret); - addParam<>(_data, QStringLiteral("country"), country); - addParam<>(_data, QStringLiteral("phone_number"), phoneNumber); - addParam<>(_data, QStringLiteral("send_attempt"), sendAttempt); - addParam(_data, QStringLiteral("next_link"), nextLink); - addParam<>(_data, QStringLiteral("id_server"), idServer); - setRequestData(_data); -} - -RequestTokenToRegisterMSISDNJob::~RequestTokenToRegisterMSISDNJob() = default; - -const Sid& RequestTokenToRegisterMSISDNJob::data() const { return d->data; } - -BaseJob::Status -RequestTokenToRegisterMSISDNJob::parseJson(const QJsonDocument& data) -{ - fromJson(data, d->data); - - return Success; + setRequestData(Data(toJson(body))); } ChangePasswordJob::ChangePasswordJob(const QString& newPassword, + Omittable logoutDevices, const Omittable& auth) : BaseJob(HttpVerb::Post, QStringLiteral("ChangePasswordJob"), - basePath % "/account/password") + QStringLiteral("/_matrix/client/r0") % "/account/password") { QJsonObject _data; addParam<>(_data, QStringLiteral("new_password"), newPassword); + addParam(_data, QStringLiteral("logout_devices"), logoutDevices); addParam(_data, QStringLiteral("auth"), auth); - setRequestData(_data); + setRequestData(std::move(_data)); } -class RequestTokenToResetPasswordEmailJob::Private { -public: - Sid data; -}; - RequestTokenToResetPasswordEmailJob::RequestTokenToResetPasswordEmailJob( - const QString& clientSecret, const QString& email, int sendAttempt, - const QString& idServer, const QString& nextLink) + const EmailValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToResetPasswordEmailJob"), - basePath % "/account/password/email/requestToken", false) - , d(new Private) -{ - QJsonObject _data; - addParam<>(_data, QStringLiteral("client_secret"), clientSecret); - addParam<>(_data, QStringLiteral("email"), email); - addParam<>(_data, QStringLiteral("send_attempt"), sendAttempt); - addParam(_data, QStringLiteral("next_link"), nextLink); - addParam<>(_data, QStringLiteral("id_server"), idServer); - setRequestData(_data); -} - -RequestTokenToResetPasswordEmailJob::~RequestTokenToResetPasswordEmailJob() = - default; - -const Sid& RequestTokenToResetPasswordEmailJob::data() const { return d->data; } - -BaseJob::Status -RequestTokenToResetPasswordEmailJob::parseJson(const QJsonDocument& data) + QStringLiteral("/_matrix/client/r0") + % "/account/password/email/requestToken", + false) { - fromJson(data, d->data); - - return Success; + setRequestData(Data(toJson(body))); } -class RequestTokenToResetPasswordMSISDNJob::Private { -public: - Sid data; -}; - RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob( - const QString& clientSecret, const QString& country, - const QString& phoneNumber, int sendAttempt, const QString& idServer, - const QString& nextLink) + const RequestMsisdnValidation& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToResetPasswordMSISDNJob"), - basePath % "/account/password/msisdn/requestToken", false) - , d(new Private) -{ - QJsonObject _data; - addParam<>(_data, QStringLiteral("client_secret"), clientSecret); - addParam<>(_data, QStringLiteral("country"), country); - addParam<>(_data, QStringLiteral("phone_number"), phoneNumber); - addParam<>(_data, QStringLiteral("send_attempt"), sendAttempt); - addParam(_data, QStringLiteral("next_link"), nextLink); - addParam<>(_data, QStringLiteral("id_server"), idServer); - setRequestData(_data); -} - -RequestTokenToResetPasswordMSISDNJob::~RequestTokenToResetPasswordMSISDNJob() = - default; - -const Sid& RequestTokenToResetPasswordMSISDNJob::data() const + QStringLiteral("/_matrix/client/r0") + % "/account/password/msisdn/requestToken", + false) { - return d->data; -} - -BaseJob::Status -RequestTokenToResetPasswordMSISDNJob::parseJson(const QJsonDocument& data) -{ - fromJson(data, d->data); - - return Success; + setRequestData(Data(toJson(body))); } DeactivateAccountJob::DeactivateAccountJob( - const Omittable& auth) + const Omittable& auth, const QString& idServer) : BaseJob(HttpVerb::Post, QStringLiteral("DeactivateAccountJob"), - basePath % "/account/deactivate") + QStringLiteral("/_matrix/client/r0") % "/account/deactivate") { QJsonObject _data; addParam(_data, QStringLiteral("auth"), auth); - setRequestData(_data); + addParam(_data, QStringLiteral("id_server"), idServer); + setRequestData(std::move(_data)); + addExpectedKey("id_server_unbind_result"); } -class CheckUsernameAvailabilityJob::Private { -public: - Omittable available; -}; - -BaseJob::Query queryToCheckUsernameAvailability(const QString& username) +auto queryToCheckUsernameAvailability(const QString& username) { BaseJob::Query _q; addParam<>(_q, QStringLiteral("username"), username); @@ -253,28 +115,13 @@ QUrl CheckUsernameAvailabilityJob::makeRequestUrl(QUrl baseUrl, const QString& username) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/register/available", + QStringLiteral("/_matrix/client/r0") + % "/register/available", queryToCheckUsernameAvailability(username)); } CheckUsernameAvailabilityJob::CheckUsernameAvailabilityJob(const QString& username) : BaseJob(HttpVerb::Get, QStringLiteral("CheckUsernameAvailabilityJob"), - basePath % "/register/available", + QStringLiteral("/_matrix/client/r0") % "/register/available", queryToCheckUsernameAvailability(username), {}, false) - , d(new Private) {} - -CheckUsernameAvailabilityJob::~CheckUsernameAvailabilityJob() = default; - -Omittable CheckUsernameAvailabilityJob::available() const -{ - return d->available; -} - -BaseJob::Status CheckUsernameAvailabilityJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("available"_ls), d->available); - - return Success; -} diff --git a/lib/csapi/registration.h b/lib/csapi/registration.h index 2619dd87..9d96db32 100644 --- a/lib/csapi/registration.h +++ b/lib/csapi/registration.h @@ -4,20 +4,20 @@ #pragma once -#include "converters.h" - -#include "csapi/../identity/definitions/sid.h" +#include "csapi/../identity/definitions/request_msisdn_validation.h" +#include "csapi/./definitions/request_email_validation.h" +#include "csapi/./definitions/request_msisdn_validation.h" #include "csapi/definitions/auth_data.h" +#include "csapi/definitions/request_token_response.h" #include "jobs/basejob.h" namespace Quotient { -// Operations - /*! \brief Register for an account on this homeserver. * - * This API endpoint uses the `User-Interactive Authentication API`_. + * This API endpoint uses the `User-Interactive Authentication API`_, except in + * the cases where a guest account is being registered. * * Register for an account on this homeserver. * @@ -49,36 +49,46 @@ namespace Quotient { * supplied by the client or generated by the server. The server may * invalidate any access token previously associated with that device. See * `Relationship between access tokens and devices`_. + * + * When registering a guest account, all parameters in the request body + * with the exception of ``initial_device_display_name`` MUST BE ignored + * by the server. The server MUST pick a ``device_id`` for the account + * regardless of input. + * + * Any user ID returned by this API must conform to the grammar given in the + * `Matrix specification <../appendices.html#user-identifiers>`_. */ class RegisterJob : public BaseJob { public: /*! \brief Register for an account on this homeserver. + * * * \param kind - * The kind of account to register. Defaults to `user`. + * The kind of account to register. Defaults to ``user``. + * * \param auth * Additional authentication information for the * user-interactive authentication API. Note that this * information is *not* used to define how the registered user * should be authenticated, but is instead used to - * authenticate the ``register`` call itself. It should be - * left empty, or omitted, unless an earlier call returned an - * response with status code 401. - * \param bindEmail - * If true, the server binds the email used for authentication to - * the Matrix ID with the identity server. + * authenticate the ``register`` call itself. + * * \param username * The basis for the localpart of the desired Matrix ID. If omitted, * the homeserver MUST generate a Matrix ID local part. + * * \param password * The desired password for the account. + * * \param deviceId * ID of the client device. If this does not correspond to a * known client device, a new device will be created. The server * will auto-generate a device_id if this is not specified. + * * \param initialDeviceDisplayName * A display name to assign to the newly-created device. Ignored * if ``device_id`` corresponds to a known device. + * * \param inhibitLogin * If true, an ``access_token`` and ``device_id`` should not be * returned from this call, therefore preventing an automatic @@ -86,28 +96,27 @@ public: */ explicit RegisterJob(const QString& kind = QStringLiteral("user"), const Omittable& auth = none, - Omittable bindEmail = none, const QString& username = {}, const QString& password = {}, const QString& deviceId = {}, const QString& initialDeviceDisplayName = {}, Omittable inhibitLogin = none); - ~RegisterJob() override; - // Result properties /// 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 `Matrix specification - /// `_. - const QString& userId() const; + /// the `Matrix specification <../appendices.html#user-identifiers>`_. + QString userId() const { return loadFromJson("user_id"_ls); } /// An access token for the account. /// This access token can then be used to authorize other requests. /// Required if the ``inhibit_login`` option is false. - const QString& accessToken() const; + QString accessToken() const + { + return loadFromJson("access_token"_ls); + } /// The server_name of the homeserver on which the account has /// been registered. @@ -115,180 +124,141 @@ public: /// **Deprecated**. Clients should extract the server_name from /// ``user_id`` (by splitting at the first colon) if they require /// it. Note also that ``homeserver`` is not spelt this way. - const QString& homeServer() const; + QString homeServer() const + { + return loadFromJson("home_server"_ls); + } /// ID of the registered device. Will be the same as the /// corresponding parameter in the request, if one was specified. /// Required if the ``inhibit_login`` option is false. - const QString& deviceId() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QString deviceId() const { return loadFromJson("device_id"_ls); } }; /*! \brief Begins the validation process for an email to be used during * registration. * - * Proxies the Identity Service API ``validate/email/requestToken``, but - * first checks that the given email address is not already associated - * with an account on this homeserver. See the Identity Service API for - * further information. + * The homeserver must check that the given email address is **not** + * 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 RequestTokenToRegisterEmailJob : public BaseJob { public: /*! \brief Begins the validation process for an email to be used during * registration. * - * \param clientSecret - * 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 - * must not be empty. - * \param email - * The email address to validate. - * \param sendAttempt - * The server will only send an email if the ``send_attempt`` - * is a number greater than the most recent one which it has seen, - * scoped to that ``email`` + ``client_secret`` pair. This is to - * avoid repeatedly sending the same email in the case of request - * retries between the POSTing user and the identity server. - * The client should increment this value if they desire a new - * email (e.g. a reminder) to be sent. - * \param idServer - * The hostname of the identity server to communicate with. May - * optionally include a port. - * \param nextLink - * Optional. When the validation is completed, the identity - * server will redirect the user to this URL. + * + * \param body + * The homeserver must check that the given email address is **not** + * 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. */ - explicit RequestTokenToRegisterEmailJob(const QString& clientSecret, - const QString& email, - int sendAttempt, - const QString& idServer, - const QString& nextLink = {}); - - ~RequestTokenToRegisterEmailJob() override; + explicit RequestTokenToRegisterEmailJob(const EmailValidationData& body); // Result properties - /// An email has been sent to the specified address. - /// Note that this may be an email containing the validation token or it may - /// be informing the user of an error. - const Sid& data() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + /// An email has been sent to the specified address. Note that this + /// may be an email containing the validation token or it may be + /// informing the user of an error. + RequestTokenResponse data() const + { + return fromJson(jsonData()); + } }; /*! \brief Requests a validation token be sent to the given phone number for the * purpose of registering an account * - * Proxies the Identity Service API ``validate/msisdn/requestToken``, but - * first checks that the given phone number is not already associated - * with an account on this homeserver. See the Identity Service API for - * further information. + * The homeserver must check that the given phone number is **not** + * 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 RequestTokenToRegisterMSISDNJob : public BaseJob { public: /*! \brief Requests a validation token be sent to the given phone number for * the purpose of registering an account * - * \param clientSecret - * 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 - * must not be empty. - * \param country - * The two-letter uppercase ISO country code that the number in - * ``phone_number`` should be parsed as if it were dialled from. - * \param phoneNumber - * The phone number to validate. - * \param sendAttempt - * The server will only send an SMS if the ``send_attempt`` is a - * number greater than the most recent one which it has seen, - * scoped to that ``country`` + ``phone_number`` + ``client_secret`` - * triple. This is to avoid repeatedly sending the same SMS in - * the case of request retries between the POSTing user and the - * identity server. The client should increment this value if - * they desire a new SMS (e.g. a reminder) to be sent. - * \param idServer - * The hostname of the identity server to communicate with. May - * optionally include a port. - * \param nextLink - * Optional. When the validation is completed, the identity - * server will redirect the user to this URL. + * + * \param body + * The homeserver must check that the given phone number is **not** + * 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. */ - explicit RequestTokenToRegisterMSISDNJob(const QString& clientSecret, - const QString& country, - const QString& phoneNumber, - int sendAttempt, - const QString& idServer, - const QString& nextLink = {}); - - ~RequestTokenToRegisterMSISDNJob() override; + explicit RequestTokenToRegisterMSISDNJob(const MsisdnValidationData& body); // Result properties - /// An SMS message has been sent to the specified phone number. - /// Note that this may be an SMS message containing the validation token or + /// An SMS message has been sent to the specified phone number. Note + /// that this may be an SMS message containing the validation token or /// it may be informing the user of an error. - const Sid& data() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + RequestTokenResponse data() const + { + return fromJson(jsonData()); + } }; /*! \brief Changes a user's password. * * Changes the password for an account on this homeserver. * - * This API endpoint uses the `User-Interactive Authentication API`_. + * This API endpoint uses the `User-Interactive Authentication API`_ to + * ensure the user changing the password is actually the owner of the + * account. * * An access token should be submitted to this endpoint if the client has * an active session. * * The homeserver may change the flows available depending on whether a - * valid access token is provided. + * 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 ChangePasswordJob : public BaseJob { public: /*! \brief Changes a user's password. + * * * \param newPassword * The new password for the account. + * + * \param logoutDevices + * Whether the user's other access tokens, and their associated devices, + * should be revoked if the request succeeds. Defaults to true. + * + * When ``false``, the server can still take advantage of `the soft logout + * method <#soft-logout>`_ for the user's remaining devices. + * * \param auth * Additional authentication information for the user-interactive * authentication API. */ explicit ChangePasswordJob(const QString& newPassword, + Omittable logoutDevices = none, const Omittable& auth = none); }; /*! \brief Requests a validation token be sent to the given email address for * the purpose of resetting a user's password * - * Proxies the Identity Service API ``validate/email/requestToken``, but - * first checks that the given email address **is** associated with an account - * on this homeserver. This API should be used to request - * validation tokens when authenticating for the - * `account/password` endpoint. This API's parameters and response are - * identical to that of the HS API |/register/email/requestToken|_ except that - * `M_THREEPID_NOT_FOUND` may be returned if no account matching the + * The homeserver must check that the given email address **is + * associated** with an account on this homeserver. This API should be + * used to request validation tokens when authenticating for the + * ``/account/password`` endpoint. + * + * This API's parameters and response are identical to that of the + * |/register/email/requestToken|_ endpoint, except that + * ``M_THREEPID_NOT_FOUND`` may be returned if no account matching the * given email address could be found. The server may instead send an * email to the given address prompting the user to create an account. - * `M_THREEPID_IN_USE` may not be returned. + * ``M_THREEPID_IN_USE`` may not be returned. + * + * The homeserver should validate the email itself, either by sending a + * validation email itself or by using a service it has control over. + * * * .. |/register/email/requestToken| replace:: ``/register/email/requestToken`` * @@ -300,62 +270,58 @@ public: /*! \brief Requests a validation token be sent to the given email address * for the purpose of resetting a user's password * - * \param clientSecret - * 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 - * must not be empty. - * \param email - * The email address to validate. - * \param sendAttempt - * The server will only send an email if the ``send_attempt`` - * is a number greater than the most recent one which it has seen, - * scoped to that ``email`` + ``client_secret`` pair. This is to - * avoid repeatedly sending the same email in the case of request - * retries between the POSTing user and the identity server. - * The client should increment this value if they desire a new - * email (e.g. a reminder) to be sent. - * \param idServer - * The hostname of the identity server to communicate with. May - * optionally include a port. - * \param nextLink - * Optional. When the validation is completed, the identity - * server will redirect the user to this URL. + * + * \param body + * The homeserver must check that the given email address **is + * associated** with an account on this homeserver. This API should be + * used to request validation tokens when authenticating for the + * ``/account/password`` endpoint. + * + * This API's parameters and response are identical to that of the + * |/register/email/requestToken|_ endpoint, except that + * ``M_THREEPID_NOT_FOUND`` may be returned if no account matching the + * given email address could be found. The server may instead send an + * email to the given address prompting the user to create an account. + * ``M_THREEPID_IN_USE`` may not be returned. + * + * The homeserver should validate the email itself, either by sending a + * validation email itself or by using a service it has control over. + * + * + * .. |/register/email/requestToken| replace:: + * ``/register/email/requestToken`` + * + * .. _/register/email/requestToken: + * #post-matrix-client-r0-register-email-requesttoken */ - explicit RequestTokenToResetPasswordEmailJob(const QString& clientSecret, - const QString& email, - int sendAttempt, - const QString& idServer, - const QString& nextLink = {}); - - ~RequestTokenToResetPasswordEmailJob() override; + explicit RequestTokenToResetPasswordEmailJob(const EmailValidationData& body); // Result properties /// An email was sent to the given address. - const Sid& data() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + RequestTokenResponse data() const + { + return fromJson(jsonData()); + } }; /*! \brief Requests a validation token be sent to the given phone number for the * purpose of resetting a user's password. * - * Proxies the Identity Service API ``validate/msisdn/requestToken``, but - * first checks that the given phone number **is** associated with an account - * on this homeserver. This API should be used to request - * validation tokens when authenticating for the - * `account/password` endpoint. This API's parameters and response are - * identical to that of the HS API |/register/msisdn/requestToken|_ except that - * `M_THREEPID_NOT_FOUND` may be returned if no account matching the - * given phone number could be found. The server may instead send an - * SMS message to the given address prompting the user to create an account. - * `M_THREEPID_IN_USE` may not be returned. + * The homeserver must check that the given phone number **is + * associated** with an account on this homeserver. This API should be + * used to request validation tokens when authenticating for the + * ``/account/password`` endpoint. + * + * This API's parameters and response are identical to that of the + * |/register/msisdn/requestToken|_ endpoint, except that + * ``M_THREEPID_NOT_FOUND`` may be returned if no account matching the + * given phone number could be found. The server may instead send the SMS + * to the given phone number prompting the user to create an account. + * ``M_THREEPID_IN_USE`` may not be returned. + * + * The homeserver should validate the phone number itself, either by sending a + * validation message itself or by using a service it has control over. * * .. |/register/msisdn/requestToken| replace:: ``/register/msisdn/requestToken`` * @@ -367,51 +333,39 @@ public: /*! \brief Requests a validation token be sent to the given phone number for * the purpose of resetting a user's password. * - * \param clientSecret - * 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 - * must not be empty. - * \param country - * The two-letter uppercase ISO country code that the number in - * ``phone_number`` should be parsed as if it were dialled from. - * \param phoneNumber - * The phone number to validate. - * \param sendAttempt - * The server will only send an SMS if the ``send_attempt`` is a - * number greater than the most recent one which it has seen, - * scoped to that ``country`` + ``phone_number`` + ``client_secret`` - * triple. This is to avoid repeatedly sending the same SMS in - * the case of request retries between the POSTing user and the - * identity server. The client should increment this value if - * they desire a new SMS (e.g. a reminder) to be sent. - * \param idServer - * The hostname of the identity server to communicate with. May - * optionally include a port. - * \param nextLink - * Optional. When the validation is completed, the identity - * server will redirect the user to this URL. + * + * \param body + * The homeserver must check that the given phone number **is + * associated** with an account on this homeserver. This API should be + * used to request validation tokens when authenticating for the + * ``/account/password`` endpoint. + * + * This API's parameters and response are identical to that of the + * |/register/msisdn/requestToken|_ endpoint, except that + * ``M_THREEPID_NOT_FOUND`` may be returned if no account matching the + * given phone number could be found. The server may instead send the SMS + * to the given phone number prompting the user to create an account. + * ``M_THREEPID_IN_USE`` may not be returned. + * + * The homeserver should validate the phone number itself, either by sending + * a validation message itself or by using a service it has control over. + * + * .. |/register/msisdn/requestToken| replace:: + * ``/register/msisdn/requestToken`` + * + * .. _/register/msisdn/requestToken: + * #post-matrix-client-r0-register-email-requesttoken */ - explicit RequestTokenToResetPasswordMSISDNJob(const QString& clientSecret, - const QString& country, - const QString& phoneNumber, - int sendAttempt, - const QString& idServer, - const QString& nextLink = {}); - - ~RequestTokenToResetPasswordMSISDNJob() override; + explicit RequestTokenToResetPasswordMSISDNJob( + const RequestMsisdnValidation& body); // Result properties /// An SMS message was sent to the given phone number. - const Sid& data() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + RequestTokenResponse data() const + { + return fromJson(jsonData()); + } }; /*! \brief Deactivate a user's account. @@ -426,17 +380,45 @@ private: * * The homeserver may change the flows available depending on whether a * valid access token is provided. + * + * 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 DeactivateAccountJob : public BaseJob { public: /*! \brief Deactivate a user's account. + * * * \param auth * Additional authentication information for the user-interactive * authentication API. + * + * \param idServer + * The identity server to unbind all of the user's 3PIDs from. + * If not provided, the homeserver MUST use the ``id_server`` + * that was originally use to bind each identifier. If the + * homeserver does not know which ``id_server`` that was, + * it must return an ``id_server_unbind_result`` of + * ``no-support``. */ - explicit DeactivateAccountJob( - const Omittable& auth = none); + explicit DeactivateAccountJob(const Omittable& auth = none, + const QString& idServer = {}); + + // Result properties + + /// An indicator as to whether or not the homeserver was able to unbind + /// the user's 3PIDs from the identity server(s). ``success`` indicates + /// that all identifiers have been unbound from the identity server while + /// ``no-support`` indicates that one or more identifiers failed to unbind + /// due to the identity server refusing the request or the homeserver + /// being unable to determine an identity server to unbind from. This + /// must be ``success`` if the homeserver has no identifiers to unbind + /// for the user. + QString idServerUnbindResult() const + { + return loadFromJson("id_server_unbind_result"_ls); + } }; /*! \brief Checks to see if a username is available on the server. @@ -457,6 +439,7 @@ public: class CheckUsernameAvailabilityJob : public BaseJob { public: /*! \brief Checks to see if a username is available on the server. + * * * \param username * The username to check the availability of. @@ -469,20 +452,15 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& username); - ~CheckUsernameAvailabilityJob() override; // Result properties /// A flag to indicate that the username is available. This should always /// be ``true`` when the server replies with 200 OK. - Omittable available() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + Omittable available() const + { + return loadFromJson>("available"_ls); + } }; } // namespace Quotient diff --git a/lib/csapi/report_content.cpp b/lib/csapi/report_content.cpp index f38b7a9a..0a41625f 100644 --- a/lib/csapi/report_content.cpp +++ b/lib/csapi/report_content.cpp @@ -4,21 +4,18 @@ #include "report_content.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - ReportContentJob::ReportContentJob(const QString& roomId, const QString& eventId, int score, const QString& reason) : BaseJob(HttpVerb::Post, QStringLiteral("ReportContentJob"), - basePath % "/rooms/" % roomId % "/report/" % eventId) + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId + % "/report/" % eventId) { QJsonObject _data; addParam<>(_data, QStringLiteral("score"), score); addParam<>(_data, QStringLiteral("reason"), reason); - setRequestData(_data); + setRequestData(std::move(_data)); } diff --git a/lib/csapi/report_content.h b/lib/csapi/report_content.h index 0f3cc3d5..13dc9138 100644 --- a/lib/csapi/report_content.h +++ b/lib/csapi/report_content.h @@ -4,14 +4,10 @@ #pragma once -#include "converters.h" - #include "jobs/basejob.h" namespace Quotient { -// Operations - /*! \brief Reports an event as inappropriate. * * Reports an event as inappropriate to the server, which may then notify @@ -20,14 +16,18 @@ namespace Quotient { class ReportContentJob : public BaseJob { public: /*! \brief Reports an event as inappropriate. + * * * \param roomId * The room in which the event being reported is located. + * * \param eventId * The event to report. + * * \param score * The score to rate this content as where -100 is most offensive * and 0 is inoffensive. + * * \param reason * The reason the content is being reported. May be blank. */ diff --git a/lib/csapi/room_send.cpp b/lib/csapi/room_send.cpp index d278433b..63986c56 100644 --- a/lib/csapi/room_send.cpp +++ b/lib/csapi/room_send.cpp @@ -4,36 +4,16 @@ #include "room_send.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -class SendMessageJob::Private { -public: - QString eventId; -}; - SendMessageJob::SendMessageJob(const QString& roomId, const QString& eventType, const QString& txnId, const QJsonObject& body) : BaseJob(HttpVerb::Put, QStringLiteral("SendMessageJob"), - basePath % "/rooms/" % roomId % "/send/" % eventType % "/" % txnId) - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId + % "/send/" % eventType % "/" % txnId) { setRequestData(Data(toJson(body))); -} - -SendMessageJob::~SendMessageJob() = default; - -const QString& SendMessageJob::eventId() const { return d->eventId; } - -BaseJob::Status SendMessageJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("event_id"_ls), d->eventId); - - return Success; + addExpectedKey("event_id"); } diff --git a/lib/csapi/room_send.h b/lib/csapi/room_send.h index 96b111ff..b1905e53 100644 --- a/lib/csapi/room_send.h +++ b/lib/csapi/room_send.h @@ -6,12 +6,8 @@ #include "jobs/basejob.h" -#include - namespace Quotient { -// Operations - /*! \brief Send a message event to the given room. * * This endpoint is used to send a message event to a room. Message events @@ -25,15 +21,19 @@ namespace Quotient { class SendMessageJob : public BaseJob { public: /*! \brief Send a message event to the given room. + * * * \param roomId * The room to send the event to. + * * \param eventType * The type of event to send. + * * \param txnId * The transaction ID for this event. Clients should generate an * ID unique across requests with the same access token; it will be * used by the server to ensure idempotency of requests. + * * \param body * This endpoint is used to send a message event to a room. Message events * allow access to historical events and pagination, making them suited @@ -46,19 +46,10 @@ public: explicit SendMessageJob(const QString& roomId, const QString& eventType, const QString& txnId, const QJsonObject& body = {}); - ~SendMessageJob() override; - // Result properties /// A unique identifier for the event. - const QString& eventId() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QString eventId() const { return loadFromJson("event_id"_ls); } }; } // namespace Quotient diff --git a/lib/csapi/room_state.cpp b/lib/csapi/room_state.cpp index 5973b06b..e18108ac 100644 --- a/lib/csapi/room_state.cpp +++ b/lib/csapi/room_state.cpp @@ -4,65 +4,18 @@ #include "room_state.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -class SetRoomStateWithKeyJob::Private { -public: - QString eventId; -}; - SetRoomStateWithKeyJob::SetRoomStateWithKeyJob(const QString& roomId, const QString& eventType, const QString& stateKey, const QJsonObject& body) : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomStateWithKeyJob"), - basePath % "/rooms/" % roomId % "/state/" % eventType % "/" - % stateKey) - , d(new Private) -{ - setRequestData(Data(toJson(body))); -} - -SetRoomStateWithKeyJob::~SetRoomStateWithKeyJob() = default; - -const QString& SetRoomStateWithKeyJob::eventId() const { return d->eventId; } - -BaseJob::Status SetRoomStateWithKeyJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("event_id"_ls), d->eventId); - - return Success; -} - -class SetRoomStateJob::Private { -public: - QString eventId; -}; - -SetRoomStateJob::SetRoomStateJob(const QString& roomId, const QString& eventType, - const QJsonObject& body) - : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomStateJob"), - basePath % "/rooms/" % roomId % "/state/" % eventType) - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId + % "/state/" % eventType % "/" % stateKey) { setRequestData(Data(toJson(body))); -} - -SetRoomStateJob::~SetRoomStateJob() = default; - -const QString& SetRoomStateJob::eventId() const { return d->eventId; } - -BaseJob::Status SetRoomStateJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("event_id"_ls), d->eventId); - - return Success; + addExpectedKey("event_id"); } diff --git a/lib/csapi/room_state.h b/lib/csapi/room_state.h index 7843cff4..eeb2b33c 100644 --- a/lib/csapi/room_state.h +++ b/lib/csapi/room_state.h @@ -6,13 +6,12 @@ #include "jobs/basejob.h" -#include - namespace Quotient { -// Operations - /*! \brief Send a state event to the given room. + * + * .. For backwards compatibility with older links... + * .. _`put-matrix-client-r0-rooms-roomid-state-eventtype`: * * State events can be sent using this endpoint. These events will be * overwritten if ````, ```` and ```` all @@ -25,18 +24,32 @@ 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`_ for the ``m.`` event specification. + * + * If the event type being sent is ``m.room.canonical_alias`` servers + * SHOULD ensure that any new aliases being listed in the event are valid + * 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 SetRoomStateWithKeyJob : public BaseJob { public: /*! \brief Send a state event to the given room. + * * * \param roomId * The room to set the state in + * * \param eventType * The type of event to send. + * * \param stateKey - * The state_key for the state to send. Defaults to the empty string. + * 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. + * * \param body + * .. For backwards compatibility with older links... + * .. _`put-matrix-client-r0-rooms-roomid-state-eventtype`: + * * State events can be sent using this endpoint. These events will be * overwritten if ````, ```` and ```` all * match. @@ -48,81 +61,22 @@ public: * 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`_ for the ``m.`` event specification. + * + * If the event type being sent is ``m.room.canonical_alias`` servers + * SHOULD ensure that any new aliases being listed in the event are valid + * 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. */ explicit SetRoomStateWithKeyJob(const QString& roomId, const QString& eventType, const QString& stateKey, const QJsonObject& body = {}); - ~SetRoomStateWithKeyJob() override; - - // Result properties - - /// A unique identifier for the event. - const QString& eventId() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; -}; - -/*! \brief Send a state event to the given room. - * - * State events can be sent using this endpoint. This endpoint is - * equivalent to calling `/rooms/{roomId}/state/{eventType}/{stateKey}` - * with an empty `stateKey`. Previous state events with matching - * `` and ``, and empty ``, will be overwritten. - * - * Requests to this endpoint **cannot use transaction IDs** - * like other ``PUT`` paths because they cannot be differentiated from the - * ``state_key``. Furthermore, ``POST`` is unsupported on state paths. - * - * 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`_ for the ``m.`` event specification. - */ -class SetRoomStateJob : public BaseJob { -public: - /*! \brief Send a state event to the given room. - * - * \param roomId - * The room to set the state in - * \param eventType - * The type of event to send. - * \param body - * State events can be sent using this endpoint. This endpoint is - * equivalent to calling `/rooms/{roomId}/state/{eventType}/{stateKey}` - * with an empty `stateKey`. Previous state events with matching - * `` and ``, and empty ``, will be - * overwritten. - * - * Requests to this endpoint **cannot use transaction IDs** - * like other ``PUT`` paths because they cannot be differentiated from the - * ``state_key``. Furthermore, ``POST`` is unsupported on state paths. - * - * 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`_ for the ``m.`` event specification. - */ - explicit SetRoomStateJob(const QString& roomId, const QString& eventType, - const QJsonObject& body = {}); - - ~SetRoomStateJob() override; - // Result properties /// A unique identifier for the event. - const QString& eventId() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QString eventId() const { return loadFromJson("event_id"_ls); } }; } // namespace Quotient diff --git a/lib/csapi/room_upgrades.cpp b/lib/csapi/room_upgrades.cpp index 244f5b74..e3791b08 100644 --- a/lib/csapi/room_upgrades.cpp +++ b/lib/csapi/room_upgrades.cpp @@ -4,43 +4,17 @@ #include "room_upgrades.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -class UpgradeRoomJob::Private { -public: - QString replacementRoom; -}; - UpgradeRoomJob::UpgradeRoomJob(const QString& roomId, const QString& newVersion) : BaseJob(HttpVerb::Post, QStringLiteral("UpgradeRoomJob"), - basePath % "/rooms/" % roomId % "/upgrade") - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId + % "/upgrade") { QJsonObject _data; addParam<>(_data, QStringLiteral("new_version"), newVersion); - setRequestData(_data); -} - -UpgradeRoomJob::~UpgradeRoomJob() = default; - -const QString& UpgradeRoomJob::replacementRoom() const -{ - return d->replacementRoom; -} - -BaseJob::Status UpgradeRoomJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - if (!json.contains("replacement_room"_ls)) - return { IncorrectResponse, - "The key 'replacement_room' not found in the response" }; - fromJson(json.value("replacement_room"_ls), d->replacementRoom); - - return Success; + setRequestData(std::move(_data)); + addExpectedKey("replacement_room"); } diff --git a/lib/csapi/room_upgrades.h b/lib/csapi/room_upgrades.h index f13a9af4..53601816 100644 --- a/lib/csapi/room_upgrades.h +++ b/lib/csapi/room_upgrades.h @@ -8,8 +8,6 @@ namespace Quotient { -// Operations - /*! \brief Upgrades a room to a new room version. * * Upgrades the given room to a particular room version. @@ -17,27 +15,23 @@ namespace Quotient { class UpgradeRoomJob : public BaseJob { public: /*! \brief Upgrades a room to a new room version. + * * * \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); - ~UpgradeRoomJob() override; - // Result properties /// The ID of the new room. - const QString& replacementRoom() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QString replacementRoom() const + { + return loadFromJson("replacement_room"_ls); + } }; } // namespace Quotient diff --git a/lib/csapi/rooms.cpp b/lib/csapi/rooms.cpp index 234e33df..724d941f 100644 --- a/lib/csapi/rooms.cpp +++ b/lib/csapi/rooms.cpp @@ -4,51 +4,33 @@ #include "rooms.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -class GetOneRoomEventJob::Private { -public: - EventPtr data; -}; - QUrl GetOneRoomEventJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& eventId) { - return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/rooms/" - % roomId % "/event/" - % eventId); + return BaseJob::makeRequestUrl(std::move(baseUrl), + QStringLiteral("/_matrix/client/r0") + % "/rooms/" % roomId % "/event/" + % eventId); } GetOneRoomEventJob::GetOneRoomEventJob(const QString& roomId, const QString& eventId) : BaseJob(HttpVerb::Get, QStringLiteral("GetOneRoomEventJob"), - basePath % "/rooms/" % roomId % "/event/" % eventId) - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId + % "/event/" % eventId) {} -GetOneRoomEventJob::~GetOneRoomEventJob() = default; - -EventPtr&& GetOneRoomEventJob::data() { return std::move(d->data); } - -BaseJob::Status GetOneRoomEventJob::parseJson(const QJsonDocument& data) -{ - fromJson(data, d->data); - - return Success; -} - QUrl GetRoomStateWithKeyJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& eventType, const QString& stateKey) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/rooms/" % roomId % "/state/" + QStringLiteral("/_matrix/client/r0") + % "/rooms/" % roomId % "/state/" % eventType % "/" % stateKey); } @@ -56,60 +38,25 @@ GetRoomStateWithKeyJob::GetRoomStateWithKeyJob(const QString& roomId, const QString& eventType, const QString& stateKey) : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomStateWithKeyJob"), - basePath % "/rooms/" % roomId % "/state/" % eventType % "/" - % stateKey) + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId + % "/state/" % eventType % "/" % stateKey) {} -QUrl GetRoomStateByTypeJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, - const QString& eventType) -{ - return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/rooms/" - % roomId % "/state/" - % eventType); -} - -GetRoomStateByTypeJob::GetRoomStateByTypeJob(const QString& roomId, - const QString& eventType) - : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomStateByTypeJob"), - basePath % "/rooms/" % roomId % "/state/" % eventType) -{} - -class GetRoomStateJob::Private { -public: - StateEvents data; -}; - QUrl GetRoomStateJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/rooms/" % roomId % "/state"); + QStringLiteral("/_matrix/client/r0") + % "/rooms/" % roomId % "/state"); } GetRoomStateJob::GetRoomStateJob(const QString& roomId) : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomStateJob"), - basePath % "/rooms/" % roomId % "/state") - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId + % "/state") {} -GetRoomStateJob::~GetRoomStateJob() = default; - -StateEvents&& GetRoomStateJob::data() { return std::move(d->data); } - -BaseJob::Status GetRoomStateJob::parseJson(const QJsonDocument& data) -{ - fromJson(data, d->data); - - return Success; -} - -class GetMembersByRoomJob::Private { -public: - EventsArray chunk; -}; - -BaseJob::Query queryToGetMembersByRoom(const QString& at, - const QString& membership, - const QString& notMembership) +auto queryToGetMembersByRoom(const QString& at, const QString& membership, + const QString& notMembership) { BaseJob::Query _q; addParam(_q, QStringLiteral("at"), at); @@ -123,10 +70,10 @@ QUrl GetMembersByRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& membership, const QString& notMembership) { - return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/rooms/" % roomId % "/members", - queryToGetMembersByRoom(at, membership, - notMembership)); + return BaseJob::makeRequestUrl( + std::move(baseUrl), + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId % "/members", + queryToGetMembersByRoom(at, membership, notMembership)); } GetMembersByRoomJob::GetMembersByRoomJob(const QString& roomId, @@ -134,72 +81,21 @@ GetMembersByRoomJob::GetMembersByRoomJob(const QString& roomId, const QString& membership, const QString& notMembership) : BaseJob(HttpVerb::Get, QStringLiteral("GetMembersByRoomJob"), - basePath % "/rooms/" % roomId % "/members", + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId + % "/members", queryToGetMembersByRoom(at, membership, notMembership)) - , d(new Private) {} -GetMembersByRoomJob::~GetMembersByRoomJob() = default; - -EventsArray&& GetMembersByRoomJob::chunk() -{ - return std::move(d->chunk); -} - -BaseJob::Status GetMembersByRoomJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("chunk"_ls), d->chunk); - - return Success; -} - -// Converters -namespace Quotient { - -template <> -struct JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, - GetJoinedMembersByRoomJob::RoomMember& result) - { - fromJson(jo.value("display_name"_ls), result.displayName); - fromJson(jo.value("avatar_url"_ls), result.avatarUrl); - } -}; - -} // namespace Quotient - -class GetJoinedMembersByRoomJob::Private { -public: - QHash joined; -}; - QUrl GetJoinedMembersByRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { - return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/rooms/" - % roomId - % "/joined_members"); + return BaseJob::makeRequestUrl(std::move(baseUrl), + QStringLiteral("/_matrix/client/r0") + % "/rooms/" % roomId % "/joined_members"); } GetJoinedMembersByRoomJob::GetJoinedMembersByRoomJob(const QString& roomId) : BaseJob(HttpVerb::Get, QStringLiteral("GetJoinedMembersByRoomJob"), - basePath % "/rooms/" % roomId % "/joined_members") - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId + % "/joined_members") {} - -GetJoinedMembersByRoomJob::~GetJoinedMembersByRoomJob() = default; - -const QHash& -GetJoinedMembersByRoomJob::joined() const -{ - return d->joined; -} - -BaseJob::Status GetJoinedMembersByRoomJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("joined"_ls), d->joined); - - return Success; -} diff --git a/lib/csapi/rooms.h b/lib/csapi/rooms.h index 05c5b82a..6137bcbd 100644 --- a/lib/csapi/rooms.h +++ b/lib/csapi/rooms.h @@ -4,18 +4,12 @@ #pragma once -#include "converters.h" - #include "events/eventloader.h" #include "events/roommemberevent.h" #include "jobs/basejob.h" -#include - namespace Quotient { -// Operations - /*! \brief Get a single event by event ID. * * Get a single event based on ``roomId/eventId``. You must have permission to @@ -24,9 +18,11 @@ namespace Quotient { class GetOneRoomEventJob : public BaseJob { public: /*! \brief Get a single event by event ID. + * * * \param roomId * The ID of the room the event is in. + * * \param eventId * The event ID to get. */ @@ -39,22 +35,17 @@ public: */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& eventId); - ~GetOneRoomEventJob() override; // Result properties /// The full event. - EventPtr&& data(); - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + EventPtr data() { return fromJson(jsonData()); } }; /*! \brief Get the state identified by the type and key. + * + * .. For backwards compatibility with older links... + * .. _`get-matrix-client-r0-rooms-roomid-state-eventtype`: * * Looks up the contents of a state event in a room. If the user is * joined to the room then the state is taken from the current @@ -64,13 +55,17 @@ private: class GetRoomStateWithKeyJob : public BaseJob { public: /*! \brief Get the state identified by the type and key. + * * * \param roomId * The room to look up the state in. + * * \param eventType * The type of state to look up. + * * \param stateKey - * The key of the state to look up. + * 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, @@ -86,36 +81,6 @@ public: const QString& stateKey); }; -/*! \brief Get the state identified by the type, with the empty state key. - * - * Looks up the contents of a state event in a room. If the user is - * 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. - * - * This looks up the state event with the empty state key. - */ -class GetRoomStateByTypeJob : public BaseJob { -public: - /*! \brief Get the state identified by the type, with the empty state key. - * - * \param roomId - * The room to look up the state in. - * \param eventType - * The type of state to look up. - */ - explicit GetRoomStateByTypeJob(const QString& roomId, - const QString& eventType); - - /*! \brief Construct a URL without creating a full-fledged job object - * - * This function can be used when a URL for GetRoomStateByTypeJob - * is necessary but the job itself isn't. - */ - static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, - const QString& eventType); -}; - /*! \brief Get all state events in the current state of a room. * * Get the state events for the current state of a room. @@ -123,6 +88,7 @@ public: class GetRoomStateJob : public BaseJob { public: /*! \brief Get all state events in the current state of a room. + * * * \param roomId * The room to look up the state for. @@ -135,22 +101,11 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId); - ~GetRoomStateJob() override; // Result properties - /// If the user is a member of the room this will be the - /// current state of the room as a list of events. If the user - /// has left the room then this will be the state of the room - /// when they left as a list of events. - StateEvents&& data(); - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + /// The current state of the room + StateEvents data() { return fromJson(jsonData()); } }; /*! \brief Get the m.room.member events for the room. @@ -160,18 +115,27 @@ private: class GetMembersByRoomJob : public BaseJob { public: /*! \brief Get the m.room.member events for the room. + * * * \param roomId * The room to get the member events for. + * * \param at - * The token defining the timeline position as-of which to return - * the list of members. This token can be obtained from a batch token - * returned for each room by the sync API, or from - * a ``start``/``end`` token returned by a ``/messages`` request. + * The point in time (pagination token) to return members for in the room. + * This token can be obtained from a ``prev_batch`` token returned for + * each room by the sync API. Defaults to the current state of the room, + * as determined by the server. + * * \param membership - * Only return users with the specified membership + * The kind of membership to filter for. Defaults to no filtering if + * unspecified. When specified alongside ``not_membership``, the two + * parameters create an 'or' condition: either the membership *is* + * the same as ``membership`` **or** *is not* the same as + * ``not_membership``. + * * \param notMembership - * Only return users with membership state other than specified + * 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 = {}, @@ -186,19 +150,14 @@ public: const QString& at = {}, const QString& membership = {}, const QString& notMembership = {}); - ~GetMembersByRoomJob() override; // Result properties /// Get the list of members for this room. - EventsArray&& chunk(); - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + EventsArray chunk() + { + return takeFromJson>("chunk"_ls); + } }; /*! \brief Gets the list of currently joined users and their profile data. @@ -230,6 +189,7 @@ public: // Construction/destruction /*! \brief Gets the list of currently joined users and their profile data. + * * * \param roomId * The room to get the members of. @@ -242,19 +202,24 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId); - ~GetJoinedMembersByRoomJob() override; // Result properties /// A map from user ID to a RoomMember object. - const QHash& joined() const; - -protected: - Status parseJson(const QJsonDocument& data) override; + QHash joined() const + { + return loadFromJson>("joined"_ls); + } +}; -private: - class Private; - QScopedPointer d; +template <> +struct JsonObjectConverter { + static void fillFrom(const QJsonObject& jo, + GetJoinedMembersByRoomJob::RoomMember& result) + { + fromJson(jo.value("display_name"_ls), result.displayName); + fromJson(jo.value("avatar_url"_ls), result.avatarUrl); + } }; } // namespace Quotient diff --git a/lib/csapi/sso_login_redirect.cpp b/lib/csapi/sso_login_redirect.cpp index 21fe646e..85a18560 100644 --- a/lib/csapi/sso_login_redirect.cpp +++ b/lib/csapi/sso_login_redirect.cpp @@ -4,15 +4,11 @@ #include "sso_login_redirect.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -BaseJob::Query queryToRedirectToSSO(const QString& redirectUrl) +auto queryToRedirectToSSO(const QString& redirectUrl) { BaseJob::Query _q; addParam<>(_q, QStringLiteral("redirectUrl"), redirectUrl); @@ -22,13 +18,13 @@ BaseJob::Query queryToRedirectToSSO(const QString& redirectUrl) QUrl RedirectToSSOJob::makeRequestUrl(QUrl baseUrl, const QString& redirectUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/login/sso/redirect", + QStringLiteral("/_matrix/client/r0") + % "/login/sso/redirect", queryToRedirectToSSO(redirectUrl)); } RedirectToSSOJob::RedirectToSSOJob(const QString& redirectUrl) : BaseJob(HttpVerb::Get, QStringLiteral("RedirectToSSOJob"), - basePath % "/login/sso/redirect", + QStringLiteral("/_matrix/client/r0") % "/login/sso/redirect", queryToRedirectToSSO(redirectUrl), {}, false) - {} diff --git a/lib/csapi/sso_login_redirect.h b/lib/csapi/sso_login_redirect.h index 8978c7f7..20f33da2 100644 --- a/lib/csapi/sso_login_redirect.h +++ b/lib/csapi/sso_login_redirect.h @@ -8,8 +8,6 @@ namespace Quotient { -// Operations - /*! \brief Redirect the user's browser to the SSO interface. * * A web-based Matrix client should instruct the user's browser to @@ -20,6 +18,7 @@ namespace Quotient { class RedirectToSSOJob : public BaseJob { public: /*! \brief Redirect the user's browser to the SSO interface. + * * * \param redirectUrl * URI to which the user will be redirected after the homeserver has diff --git a/lib/csapi/tags.cpp b/lib/csapi/tags.cpp index 0e2d122a..dc22dc18 100644 --- a/lib/csapi/tags.cpp +++ b/lib/csapi/tags.cpp @@ -4,82 +4,49 @@ #include "tags.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -// Converters -namespace Quotient { - -template <> -struct JsonObjectConverter { - static void fillFrom(QJsonObject jo, GetRoomTagsJob::Tag& result) - { - fromJson(jo.take("order"_ls), result.order); - fromJson(jo, result.additionalProperties); - } -}; - -} // namespace Quotient - -class GetRoomTagsJob::Private { -public: - QHash tags; -}; - QUrl GetRoomTagsJob::makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& roomId) { - return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/user/" - % userId % "/rooms/" - % roomId % "/tags"); + return BaseJob::makeRequestUrl(std::move(baseUrl), + QStringLiteral("/_matrix/client/r0") % "/user/" + % userId % "/rooms/" % roomId % "/tags"); } GetRoomTagsJob::GetRoomTagsJob(const QString& userId, const QString& roomId) : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomTagsJob"), - basePath % "/user/" % userId % "/rooms/" % roomId % "/tags") - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/user/" % userId + % "/rooms/" % roomId % "/tags") {} -GetRoomTagsJob::~GetRoomTagsJob() = default; - -const QHash& GetRoomTagsJob::tags() const -{ - return d->tags; -} - -BaseJob::Status GetRoomTagsJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("tags"_ls), d->tags); - - return Success; -} - SetRoomTagJob::SetRoomTagJob(const QString& userId, const QString& roomId, - const QString& tag, Omittable order) + const QString& tag, Omittable order, + const QVariantHash& additionalProperties) : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomTagJob"), - basePath % "/user/" % userId % "/rooms/" % roomId % "/tags/" % tag) + QStringLiteral("/_matrix/client/r0") % "/user/" % userId + % "/rooms/" % roomId % "/tags/" % tag) { QJsonObject _data; + fillJson(_data, additionalProperties); addParam(_data, QStringLiteral("order"), order); - setRequestData(_data); + setRequestData(std::move(_data)); } QUrl DeleteRoomTagJob::makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& roomId, const QString& tag) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/user/" % userId % "/rooms/" - % roomId % "/tags/" % tag); + QStringLiteral("/_matrix/client/r0") + % "/user/" % userId % "/rooms/" % roomId + % "/tags/" % tag); } DeleteRoomTagJob::DeleteRoomTagJob(const QString& userId, const QString& roomId, const QString& tag) : BaseJob(HttpVerb::Delete, QStringLiteral("DeleteRoomTagJob"), - basePath % "/user/" % userId % "/rooms/" % roomId % "/tags/" % tag) + QStringLiteral("/_matrix/client/r0") % "/user/" % userId + % "/rooms/" % roomId % "/tags/" % tag) {} diff --git a/lib/csapi/tags.h b/lib/csapi/tags.h index 1ffb0f81..e6eb9dda 100644 --- a/lib/csapi/tags.h +++ b/lib/csapi/tags.h @@ -4,17 +4,10 @@ #pragma once -#include "converters.h" - #include "jobs/basejob.h" -#include -#include - namespace Quotient { -// Operations - /*! \brief List the tags for a room. * * List the tags set by a user on a room. @@ -35,10 +28,12 @@ public: // Construction/destruction /*! \brief List the tags for a room. + * * * \param userId * The id of the user to get tags for. The access token must be * authorized to make requests for this user ID. + * * \param roomId * The ID of the room to get tags for. */ @@ -51,19 +46,23 @@ public: */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& roomId); - ~GetRoomTagsJob() override; // Result properties /// List the tags set by a user on a room. - const QHash& tags() const; - -protected: - Status parseJson(const QJsonDocument& data) override; + QHash tags() const + { + return loadFromJson>("tags"_ls); + } +}; -private: - class Private; - QScopedPointer d; +template <> +struct JsonObjectConverter { + static void fillFrom(QJsonObject jo, GetRoomTagsJob::Tag& result) + { + fromJson(jo.take("order"_ls), result.order); + fromJson(jo, result.additionalProperties); + } }; /*! \brief Add a tag to a room. @@ -73,20 +72,28 @@ private: class SetRoomTagJob : public BaseJob { public: /*! \brief Add a tag to a room. + * * * \param userId * The id of the user to add a tag for. The access token must be * authorized to make requests for this user ID. + * * \param roomId * The ID of the room to add a tag to. + * * \param tag * The tag to add. + * * \param order * A number in a range ``[0,1]`` describing a relative * position of the room under the given tag. + * + * \param additionalProperties + * Add a tag to the room. */ explicit SetRoomTagJob(const QString& userId, const QString& roomId, - const QString& tag, Omittable order = none); + const QString& tag, Omittable order = none, + const QVariantHash& additionalProperties = {}); }; /*! \brief Remove a tag from the room. @@ -96,12 +103,15 @@ public: class DeleteRoomTagJob : public BaseJob { public: /*! \brief Remove a tag from the room. + * * * \param userId * The id of the user to remove a tag for. The access token must be * authorized to make requests for this user ID. + * * \param roomId * The ID of the room to remove a tag from. + * * \param tag * The tag to remove. */ diff --git a/lib/csapi/third_party_lookup.cpp b/lib/csapi/third_party_lookup.cpp index 9d92e407..baf1fab5 100644 --- a/lib/csapi/third_party_lookup.cpp +++ b/lib/csapi/third_party_lookup.cpp @@ -4,83 +4,37 @@ #include "third_party_lookup.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -class GetProtocolsJob::Private { -public: - QHash data; -}; - QUrl GetProtocolsJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/thirdparty/protocols"); + QStringLiteral("/_matrix/client/r0") + % "/thirdparty/protocols"); } GetProtocolsJob::GetProtocolsJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetProtocolsJob"), - basePath % "/thirdparty/protocols") - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/thirdparty/protocols") {} -GetProtocolsJob::~GetProtocolsJob() = default; - -const QHash& GetProtocolsJob::data() const -{ - return d->data; -} - -BaseJob::Status GetProtocolsJob::parseJson(const QJsonDocument& data) -{ - fromJson(data, d->data); - - return Success; -} - -class GetProtocolMetadataJob::Private { -public: - ThirdPartyProtocol data; -}; - QUrl GetProtocolMetadataJob::makeRequestUrl(QUrl baseUrl, const QString& protocol) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/thirdparty/protocol/" % protocol); + QStringLiteral("/_matrix/client/r0") + % "/thirdparty/protocol/" % protocol); } GetProtocolMetadataJob::GetProtocolMetadataJob(const QString& protocol) : BaseJob(HttpVerb::Get, QStringLiteral("GetProtocolMetadataJob"), - basePath % "/thirdparty/protocol/" % protocol) - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/thirdparty/protocol/" + % protocol) {} -GetProtocolMetadataJob::~GetProtocolMetadataJob() = default; - -const ThirdPartyProtocol& GetProtocolMetadataJob::data() const -{ - return d->data; -} - -BaseJob::Status GetProtocolMetadataJob::parseJson(const QJsonDocument& data) -{ - fromJson(data, d->data); - - return Success; -} - -class QueryLocationByProtocolJob::Private { -public: - QVector data; -}; - -BaseJob::Query queryToQueryLocationByProtocol(const QString& searchFields) +auto queryToQueryLocationByProtocol(const QString& searchFields) { BaseJob::Query _q; addParam(_q, QStringLiteral("searchFields"), searchFields); @@ -92,38 +46,20 @@ QUrl QueryLocationByProtocolJob::makeRequestUrl(QUrl baseUrl, const QString& searchFields) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/thirdparty/location/" % protocol, + QStringLiteral("/_matrix/client/r0") + % "/thirdparty/location/" % protocol, queryToQueryLocationByProtocol(searchFields)); } QueryLocationByProtocolJob::QueryLocationByProtocolJob( const QString& protocol, const QString& searchFields) : BaseJob(HttpVerb::Get, QStringLiteral("QueryLocationByProtocolJob"), - basePath % "/thirdparty/location/" % protocol, + QStringLiteral("/_matrix/client/r0") % "/thirdparty/location/" + % protocol, queryToQueryLocationByProtocol(searchFields)) - , d(new Private) {} -QueryLocationByProtocolJob::~QueryLocationByProtocolJob() = default; - -const QVector& QueryLocationByProtocolJob::data() const -{ - return d->data; -} - -BaseJob::Status QueryLocationByProtocolJob::parseJson(const QJsonDocument& data) -{ - fromJson(data, d->data); - - return Success; -} - -class QueryUserByProtocolJob::Private { -public: - QVector data; -}; - -BaseJob::Query queryToQueryUserByProtocol(const QString& fields) +auto queryToQueryUserByProtocol(const QString& fields) { BaseJob::Query _q; addParam(_q, QStringLiteral("fields..."), fields); @@ -135,38 +71,20 @@ QUrl QueryUserByProtocolJob::makeRequestUrl(QUrl baseUrl, const QString& fields) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/thirdparty/user/" % protocol, + QStringLiteral("/_matrix/client/r0") + % "/thirdparty/user/" % protocol, queryToQueryUserByProtocol(fields)); } QueryUserByProtocolJob::QueryUserByProtocolJob(const QString& protocol, const QString& fields) : BaseJob(HttpVerb::Get, QStringLiteral("QueryUserByProtocolJob"), - basePath % "/thirdparty/user/" % protocol, + QStringLiteral("/_matrix/client/r0") % "/thirdparty/user/" + % protocol, queryToQueryUserByProtocol(fields)) - , d(new Private) {} -QueryUserByProtocolJob::~QueryUserByProtocolJob() = default; - -const QVector& QueryUserByProtocolJob::data() const -{ - return d->data; -} - -BaseJob::Status QueryUserByProtocolJob::parseJson(const QJsonDocument& data) -{ - fromJson(data, d->data); - - return Success; -} - -class QueryLocationByAliasJob::Private { -public: - QVector data; -}; - -BaseJob::Query queryToQueryLocationByAlias(const QString& alias) +auto queryToQueryLocationByAlias(const QString& alias) { BaseJob::Query _q; addParam<>(_q, QStringLiteral("alias"), alias); @@ -176,37 +94,18 @@ BaseJob::Query queryToQueryLocationByAlias(const QString& alias) QUrl QueryLocationByAliasJob::makeRequestUrl(QUrl baseUrl, const QString& alias) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/thirdparty/location", + QStringLiteral("/_matrix/client/r0") + % "/thirdparty/location", queryToQueryLocationByAlias(alias)); } QueryLocationByAliasJob::QueryLocationByAliasJob(const QString& alias) : BaseJob(HttpVerb::Get, QStringLiteral("QueryLocationByAliasJob"), - basePath % "/thirdparty/location", + QStringLiteral("/_matrix/client/r0") % "/thirdparty/location", queryToQueryLocationByAlias(alias)) - , d(new Private) {} -QueryLocationByAliasJob::~QueryLocationByAliasJob() = default; - -const QVector& QueryLocationByAliasJob::data() const -{ - return d->data; -} - -BaseJob::Status QueryLocationByAliasJob::parseJson(const QJsonDocument& data) -{ - fromJson(data, d->data); - - return Success; -} - -class QueryUserByIDJob::Private { -public: - QVector data; -}; - -BaseJob::Query queryToQueryUserByID(const QString& userid) +auto queryToQueryUserByID(const QString& userid) { BaseJob::Query _q; addParam<>(_q, QStringLiteral("userid"), userid); @@ -216,26 +115,13 @@ BaseJob::Query queryToQueryUserByID(const QString& userid) QUrl QueryUserByIDJob::makeRequestUrl(QUrl baseUrl, const QString& userid) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/thirdparty/user", + QStringLiteral("/_matrix/client/r0") + % "/thirdparty/user", queryToQueryUserByID(userid)); } QueryUserByIDJob::QueryUserByIDJob(const QString& userid) : BaseJob(HttpVerb::Get, QStringLiteral("QueryUserByIDJob"), - basePath % "/thirdparty/user", queryToQueryUserByID(userid)) - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/thirdparty/user", + queryToQueryUserByID(userid)) {} - -QueryUserByIDJob::~QueryUserByIDJob() = default; - -const QVector& QueryUserByIDJob::data() const -{ - return d->data; -} - -BaseJob::Status QueryUserByIDJob::parseJson(const QJsonDocument& data) -{ - fromJson(data, d->data); - - return Success; -} diff --git a/lib/csapi/third_party_lookup.h b/lib/csapi/third_party_lookup.h index c8ca8cbb..9329b7a7 100644 --- a/lib/csapi/third_party_lookup.h +++ b/lib/csapi/third_party_lookup.h @@ -4,21 +4,14 @@ #pragma once -#include "converters.h" - #include "csapi/../application-service/definitions/location.h" #include "csapi/../application-service/definitions/protocol.h" #include "csapi/../application-service/definitions/user.h" #include "jobs/basejob.h" -#include -#include - namespace Quotient { -// Operations - /*! \brief Retrieve metadata about all protocols that a homeserver supports. * * Fetches the overall metadata about protocols supported by the @@ -36,19 +29,14 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetProtocolsJob() override; // Result properties /// The protocols supported by the homeserver. - const QHash& data() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QHash data() const + { + return fromJson>(jsonData()); + } }; /*! \brief Retrieve metadata about a specific protocol that the homeserver @@ -62,6 +50,7 @@ public: /*! \brief Retrieve metadata about a specific protocol that the homeserver * supports. * + * * \param protocol * The name of the protocol. */ @@ -73,19 +62,14 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& protocol); - ~GetProtocolMetadataJob() override; // Result properties /// The protocol was found and metadata returned. - const ThirdPartyProtocol& data() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + ThirdPartyProtocol data() const + { + return fromJson(jsonData()); + } }; /*! \brief Retrieve Matrix-side portals rooms leading to a third party location. @@ -104,8 +88,10 @@ public: /*! \brief Retrieve Matrix-side portals rooms leading to a third party * location. * + * * \param protocol * The protocol used to communicate to the third party network. + * * \param searchFields * One or more custom fields to help identify the third party * location. @@ -120,19 +106,14 @@ public: */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& protocol, const QString& searchFields = {}); - ~QueryLocationByProtocolJob() override; // Result properties /// At least one portal room was found. - const QVector& data() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QVector data() const + { + return fromJson>(jsonData()); + } }; /*! \brief Retrieve the Matrix User ID of a corresponding third party user. @@ -143,9 +124,11 @@ private: class QueryUserByProtocolJob : public BaseJob { public: /*! \brief Retrieve the Matrix User ID of a corresponding third party user. + * * * \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. @@ -160,19 +143,14 @@ public: */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& protocol, const QString& fields = {}); - ~QueryUserByProtocolJob() override; // Result properties /// The Matrix User IDs found with the given parameters. - const QVector& data() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QVector data() const + { + return fromJson>(jsonData()); + } }; /*! \brief Reverse-lookup third party locations given a Matrix room alias. @@ -183,6 +161,7 @@ private: class QueryLocationByAliasJob : public BaseJob { public: /*! \brief Reverse-lookup third party locations given a Matrix room alias. + * * * \param alias * The Matrix room alias to look up. @@ -195,19 +174,14 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& alias); - ~QueryLocationByAliasJob() override; // Result properties /// All found third party locations. - const QVector& data() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QVector data() const + { + return fromJson>(jsonData()); + } }; /*! \brief Reverse-lookup third party users given a Matrix User ID. @@ -217,6 +191,7 @@ private: class QueryUserByIDJob : public BaseJob { public: /*! \brief Reverse-lookup third party users given a Matrix User ID. + * * * \param userid * The Matrix User ID to look up. @@ -229,19 +204,14 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userid); - ~QueryUserByIDJob() override; // Result properties /// An array of third party users. - const QVector& data() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QVector data() const + { + return fromJson>(jsonData()); + } }; } // namespace Quotient diff --git a/lib/csapi/third_party_membership.cpp b/lib/csapi/third_party_membership.cpp index 15da6b3c..fda772d2 100644 --- a/lib/csapi/third_party_membership.cpp +++ b/lib/csapi/third_party_membership.cpp @@ -4,22 +4,21 @@ #include "third_party_membership.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - InviteBy3PIDJob::InviteBy3PIDJob(const QString& roomId, const QString& idServer, + const QString& idAccessToken, const QString& medium, const QString& address) : BaseJob(HttpVerb::Post, QStringLiteral("InviteBy3PIDJob"), - basePath % "/rooms/" % roomId % "/invite") + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId + % "/invite") { QJsonObject _data; addParam<>(_data, QStringLiteral("id_server"), idServer); + addParam<>(_data, QStringLiteral("id_access_token"), idAccessToken); addParam<>(_data, QStringLiteral("medium"), medium); addParam<>(_data, QStringLiteral("address"), address); - setRequestData(_data); + setRequestData(std::move(_data)); } diff --git a/lib/csapi/third_party_membership.h b/lib/csapi/third_party_membership.h index c85e8ab4..f8196f6f 100644 --- a/lib/csapi/third_party_membership.h +++ b/lib/csapi/third_party_membership.h @@ -8,8 +8,6 @@ namespace Quotient { -// Operations - /*! \brief Invite a user to participate in a particular room. * * .. _invite-by-third-party-id-endpoint: @@ -60,16 +58,29 @@ namespace Quotient { class InviteBy3PIDJob : public BaseJob { public: /*! \brief Invite a user to participate in a particular room. + * * * \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 medium The kind of address being passed - * in the address field, for example ``email``. \param address The invitee's - * third party identifier. + * 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``. + * + * \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); }; diff --git a/lib/csapi/to_device.cpp b/lib/csapi/to_device.cpp index e277503c..28c4115a 100644 --- a/lib/csapi/to_device.cpp +++ b/lib/csapi/to_device.cpp @@ -4,21 +4,18 @@ #include "to_device.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - SendToDeviceJob::SendToDeviceJob( const QString& eventType, const QString& txnId, const QHash>& messages) : BaseJob(HttpVerb::Put, QStringLiteral("SendToDeviceJob"), - basePath % "/sendToDevice/" % eventType % "/" % txnId) + QStringLiteral("/_matrix/client/r0") % "/sendToDevice/" + % eventType % "/" % txnId) { QJsonObject _data; addParam(_data, QStringLiteral("messages"), messages); - setRequestData(_data); + setRequestData(std::move(_data)); } diff --git a/lib/csapi/to_device.h b/lib/csapi/to_device.h index 48f0ec83..8c82af45 100644 --- a/lib/csapi/to_device.h +++ b/lib/csapi/to_device.h @@ -6,13 +6,8 @@ #include "jobs/basejob.h" -#include -#include - namespace Quotient { -// Operations - /*! \brief Send an event to a given set of devices. * * This endpoint is used to send send-to-device events to a set of @@ -21,13 +16,16 @@ namespace Quotient { class SendToDeviceJob : public BaseJob { public: /*! \brief Send an event to a given set of devices. + * * * \param eventType * The type of event to send. + * * \param txnId * The transaction ID for this event. Clients should generate an * ID unique across requests with the same access token; it will be * used by the server to ensure idempotency of requests. + * * \param messages * The messages to send. A map from user ID, to a map from * device ID to message body. The device ID may also be `*`, diff --git a/lib/csapi/typing.cpp b/lib/csapi/typing.cpp index 261622c4..8e214053 100644 --- a/lib/csapi/typing.cpp +++ b/lib/csapi/typing.cpp @@ -4,21 +4,18 @@ #include "typing.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - SetTypingJob::SetTypingJob(const QString& userId, const QString& roomId, bool typing, Omittable timeout) : BaseJob(HttpVerb::Put, QStringLiteral("SetTypingJob"), - basePath % "/rooms/" % roomId % "/typing/" % userId) + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId + % "/typing/" % userId) { QJsonObject _data; addParam<>(_data, QStringLiteral("typing"), typing); addParam(_data, QStringLiteral("timeout"), timeout); - setRequestData(_data); + setRequestData(std::move(_data)); } diff --git a/lib/csapi/typing.h b/lib/csapi/typing.h index dbf17a3e..f5b67baf 100644 --- a/lib/csapi/typing.h +++ b/lib/csapi/typing.h @@ -4,14 +4,10 @@ #pragma once -#include "converters.h" - #include "jobs/basejob.h" namespace Quotient { -// Operations - /*! \brief Informs the server that the user has started or stopped typing. * * This tells the server that the user is typing for the next N @@ -22,14 +18,18 @@ namespace Quotient { class SetTypingJob : public BaseJob { public: /*! \brief Informs the server that the user has started or stopped typing. + * * * \param userId * The user who has started to type. + * * \param roomId * The room in which the user is typing. + * * \param typing * Whether the user is typing or not. If ``false``, the ``timeout`` * key can be omitted. + * * \param timeout * The length of time in milliseconds to mark this user as typing. */ diff --git a/lib/csapi/users.cpp b/lib/csapi/users.cpp index 5d2a6133..a0279d7e 100644 --- a/lib/csapi/users.cpp +++ b/lib/csapi/users.cpp @@ -4,68 +4,19 @@ #include "users.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -// Converters -namespace Quotient { - -template <> -struct JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, - SearchUserDirectoryJob::User& result) - { - fromJson(jo.value("user_id"_ls), result.userId); - fromJson(jo.value("display_name"_ls), result.displayName); - fromJson(jo.value("avatar_url"_ls), result.avatarUrl); - } -}; - -} // namespace Quotient - -class SearchUserDirectoryJob::Private { -public: - QVector results; - bool limited; -}; - SearchUserDirectoryJob::SearchUserDirectoryJob(const QString& searchTerm, Omittable limit) : BaseJob(HttpVerb::Post, QStringLiteral("SearchUserDirectoryJob"), - basePath % "/user_directory/search") - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/user_directory/search") { QJsonObject _data; addParam<>(_data, QStringLiteral("search_term"), searchTerm); addParam(_data, QStringLiteral("limit"), limit); - setRequestData(_data); -} - -SearchUserDirectoryJob::~SearchUserDirectoryJob() = default; - -const QVector& SearchUserDirectoryJob::results() const -{ - return d->results; -} - -bool SearchUserDirectoryJob::limited() const { return d->limited; } - -BaseJob::Status SearchUserDirectoryJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - if (!json.contains("results"_ls)) - return { IncorrectResponse, - "The key 'results' not found in the response" }; - fromJson(json.value("results"_ls), d->results); - if (!json.contains("limited"_ls)) - return { IncorrectResponse, - "The key 'limited' not found in the response" }; - fromJson(json.value("limited"_ls), d->limited); - - return Success; + setRequestData(std::move(_data)); + addExpectedKey("results"); + addExpectedKey("limited"); } diff --git a/lib/csapi/users.h b/lib/csapi/users.h index de4eb529..adb2a33d 100644 --- a/lib/csapi/users.h +++ b/lib/csapi/users.h @@ -4,19 +4,13 @@ #pragma once -#include "converters.h" - #include "jobs/basejob.h" -#include - namespace Quotient { -// Operations - /*! \brief Searches the user directory. * - * Performs a search for users on the homeserver. The homeserver may + * Performs a search for users. The homeserver may * determine which subset of users are searched, however the homeserver * MUST at a minimum consider the users the requesting user shares a * room with and those who reside in public rooms (known to the homeserver). @@ -31,7 +25,7 @@ class SearchUserDirectoryJob : public BaseJob { public: // Inner data structures - /// Performs a search for users on the homeserver. The homeserver may + /// Performs a search for users. The homeserver may /// determine which subset of users are searched, however the homeserver /// MUST at a minimum consider the users the requesting user shares a /// room with and those who reside in public rooms (known to the @@ -41,7 +35,7 @@ public: /// 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. - struct User { + struct SearchUserDirectory200ThirdPartyUser { /// The user's matrix user ID. QString userId; /// The display name of the user, if one exists. @@ -53,31 +47,41 @@ public: // Construction/destruction /*! \brief Searches the user directory. + * * * \param searchTerm * The term to search for + * * \param limit * The maximum number of results to return. Defaults to 10. */ explicit SearchUserDirectoryJob(const QString& searchTerm, Omittable limit = none); - ~SearchUserDirectoryJob() override; - // Result properties /// Ordered by rank and then whether or not profile info is available. - const QVector& results() const; + QVector results() const + { + return loadFromJson>( + "results"_ls); + } /// Indicates if the result list has been truncated by the limit. - bool limited() const; - -protected: - Status parseJson(const QJsonDocument& data) override; + bool limited() const { return loadFromJson("limited"_ls); } +}; -private: - class Private; - QScopedPointer d; +template <> +struct JsonObjectConverter< + SearchUserDirectoryJob::SearchUserDirectory200ThirdPartyUser> { + static void + fillFrom(const QJsonObject& jo, + SearchUserDirectoryJob::SearchUserDirectory200ThirdPartyUser& result) + { + fromJson(jo.value("user_id"_ls), result.userId); + fromJson(jo.value("display_name"_ls), result.displayName); + fromJson(jo.value("avatar_url"_ls), result.avatarUrl); + } }; } // namespace Quotient diff --git a/lib/csapi/versions.cpp b/lib/csapi/versions.cpp index 8cce03b9..9003e27f 100644 --- a/lib/csapi/versions.cpp +++ b/lib/csapi/versions.cpp @@ -4,48 +4,20 @@ #include "versions.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client"); - -class GetVersionsJob::Private { -public: - QStringList versions; - QHash unstableFeatures; -}; - QUrl GetVersionsJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/versions"); + return BaseJob::makeRequestUrl(std::move(baseUrl), + QStringLiteral("/_matrix/client") + % "/versions"); } GetVersionsJob::GetVersionsJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetVersionsJob"), - basePath % "/versions", false) - , d(new Private) -{} - -GetVersionsJob::~GetVersionsJob() = default; - -const QStringList& GetVersionsJob::versions() const { return d->versions; } - -const QHash& GetVersionsJob::unstableFeatures() const + QStringLiteral("/_matrix/client") % "/versions", false) { - return d->unstableFeatures; -} - -BaseJob::Status GetVersionsJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - if (!json.contains("versions"_ls)) - return { IncorrectResponse, - "The key 'versions' not found in the response" }; - fromJson(json.value("versions"_ls), d->versions); - fromJson(json.value("unstable_features"_ls), d->unstableFeatures); - - return Success; + addExpectedKey("versions"); } diff --git a/lib/csapi/versions.h b/lib/csapi/versions.h index 4c4f8109..828a7eb9 100644 --- a/lib/csapi/versions.h +++ b/lib/csapi/versions.h @@ -4,16 +4,10 @@ #pragma once -#include "converters.h" - #include "jobs/basejob.h" -#include - namespace Quotient { -// Operations - /*! \brief Gets the versions of the specification supported by the server. * * Gets the versions of the specification supported by the server. @@ -48,24 +42,22 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetVersionsJob() override; // Result properties /// The supported versions. - const QStringList& versions() const; + QStringList versions() const + { + return loadFromJson("versions"_ls); + } /// Experimental features the server supports. Features not listed here, /// or the lack of this property all together, indicate that a feature is /// not supported. - const QHash& unstableFeatures() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QHash unstableFeatures() const + { + return loadFromJson>("unstable_features"_ls); + } }; } // namespace Quotient diff --git a/lib/csapi/voip.cpp b/lib/csapi/voip.cpp index c98824b3..43170057 100644 --- a/lib/csapi/voip.cpp +++ b/lib/csapi/voip.cpp @@ -4,38 +4,18 @@ #include "voip.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -class GetTurnServerJob::Private { -public: - QJsonObject data; -}; - QUrl GetTurnServerJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/voip/turnServer"); + QStringLiteral("/_matrix/client/r0") + % "/voip/turnServer"); } GetTurnServerJob::GetTurnServerJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetTurnServerJob"), - basePath % "/voip/turnServer") - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/voip/turnServer") {} - -GetTurnServerJob::~GetTurnServerJob() = default; - -const QJsonObject& GetTurnServerJob::data() const { return d->data; } - -BaseJob::Status GetTurnServerJob::parseJson(const QJsonDocument& data) -{ - fromJson(data, d->data); - - return Success; -} diff --git a/lib/csapi/voip.h b/lib/csapi/voip.h index d3eb3c4b..087ebbbd 100644 --- a/lib/csapi/voip.h +++ b/lib/csapi/voip.h @@ -6,12 +6,8 @@ #include "jobs/basejob.h" -#include - namespace Quotient { -// Operations - /*! \brief Obtain TURN server credentials. * * This API provides credentials for the client to use when initiating @@ -28,19 +24,11 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetTurnServerJob() override; // Result properties /// The TURN server credentials. - const QJsonObject& data() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QJsonObject data() const { return fromJson(jsonData()); } }; } // namespace Quotient diff --git a/lib/csapi/wellknown.cpp b/lib/csapi/wellknown.cpp index 464068e7..1aa0a90b 100644 --- a/lib/csapi/wellknown.cpp +++ b/lib/csapi/wellknown.cpp @@ -4,38 +4,18 @@ #include "wellknown.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/.well-known"); - -class GetWellknownJob::Private { -public: - DiscoveryInformation data; -}; - QUrl GetWellknownJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/matrix/client"); + QStringLiteral("/.well-known") + % "/matrix/client"); } GetWellknownJob::GetWellknownJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetWellknownJob"), - basePath % "/matrix/client", false) - , d(new Private) + QStringLiteral("/.well-known") % "/matrix/client", false) {} - -GetWellknownJob::~GetWellknownJob() = default; - -const DiscoveryInformation& GetWellknownJob::data() const { return d->data; } - -BaseJob::Status GetWellknownJob::parseJson(const QJsonDocument& data) -{ - fromJson(data, d->data); - - return Success; -} diff --git a/lib/csapi/wellknown.h b/lib/csapi/wellknown.h index 94d3631c..b21d9fc7 100644 --- a/lib/csapi/wellknown.h +++ b/lib/csapi/wellknown.h @@ -4,16 +4,12 @@ #pragma once -#include "converters.h" - #include "csapi/definitions/wellknown/full.h" #include "jobs/basejob.h" namespace Quotient { -// Operations - /*! \brief Gets Matrix server discovery information about the domain. * * Gets discovery information about the domain. The file may include @@ -36,19 +32,14 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetWellknownJob() override; // Result properties /// Server discovery information. - const DiscoveryInformation& data() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + DiscoveryInformation data() const + { + return fromJson(jsonData()); + } }; } // namespace Quotient diff --git a/lib/csapi/whoami.cpp b/lib/csapi/whoami.cpp index 8d4681e4..73f0298e 100644 --- a/lib/csapi/whoami.cpp +++ b/lib/csapi/whoami.cpp @@ -4,42 +4,20 @@ #include "whoami.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -class GetTokenOwnerJob::Private { -public: - QString userId; -}; - QUrl GetTokenOwnerJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/account/whoami"); + QStringLiteral("/_matrix/client/r0") + % "/account/whoami"); } GetTokenOwnerJob::GetTokenOwnerJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetTokenOwnerJob"), - basePath % "/account/whoami") - , d(new Private) -{} - -GetTokenOwnerJob::~GetTokenOwnerJob() = default; - -const QString& GetTokenOwnerJob::userId() const { return d->userId; } - -BaseJob::Status GetTokenOwnerJob::parseJson(const QJsonDocument& data) + QStringLiteral("/_matrix/client/r0") % "/account/whoami") { - auto json = data.object(); - if (!json.contains("user_id"_ls)) - return { IncorrectResponse, - "The key 'user_id' not found in the response" }; - fromJson(json.value("user_id"_ls), d->userId); - - return Success; + addExpectedKey("user_id"); } diff --git a/lib/csapi/whoami.h b/lib/csapi/whoami.h index dda8d8c8..af8f1e8a 100644 --- a/lib/csapi/whoami.h +++ b/lib/csapi/whoami.h @@ -8,8 +8,6 @@ namespace Quotient { -// Operations - /*! \brief Gets information about the owner of an access token. * * Gets information about the owner of a given access token. @@ -32,19 +30,11 @@ public: * is necessary but the job itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl); - ~GetTokenOwnerJob() override; // Result properties /// The user id that owns the access token. - const QString& userId() const; - -protected: - Status parseJson(const QJsonDocument& data) override; - -private: - class Private; - QScopedPointer d; + QString userId() const { return loadFromJson("user_id"_ls); } }; } // namespace Quotient diff --git a/lib/identity/definitions/request_email_validation.cpp b/lib/identity/definitions/request_email_validation.cpp deleted file mode 100644 index 22cb0072..00000000 --- a/lib/identity/definitions/request_email_validation.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "request_email_validation.h" - -using namespace Quotient; - -void JsonObjectConverter::dumpTo( - QJsonObject& jo, const RequestEmailValidation& pod) -{ - addParam<>(jo, QStringLiteral("client_secret"), pod.clientSecret); - addParam<>(jo, QStringLiteral("email"), pod.email); - addParam<>(jo, QStringLiteral("send_attempt"), pod.sendAttempt); - addParam(jo, QStringLiteral("next_link"), pod.nextLink); -} - -void JsonObjectConverter::fillFrom( - const QJsonObject& jo, RequestEmailValidation& result) -{ - fromJson(jo.value("client_secret"_ls), result.clientSecret); - fromJson(jo.value("email"_ls), result.email); - fromJson(jo.value("send_attempt"_ls), result.sendAttempt); - fromJson(jo.value("next_link"_ls), result.nextLink); -} diff --git a/lib/identity/definitions/request_email_validation.h b/lib/identity/definitions/request_email_validation.h index 32c6eaaf..079da953 100644 --- a/lib/identity/definitions/request_email_validation.h +++ b/lib/identity/definitions/request_email_validation.h @@ -8,8 +8,6 @@ namespace Quotient { -// Data structures - struct RequestEmailValidation { /// A unique string generated by the client, and used to identify the /// validation attempt. It must be a string consisting of the characters @@ -26,18 +24,32 @@ struct RequestEmailValidation { /// avoid repeatedly sending the same email in the case of request /// retries between the POSTing user and the identity server. /// The client should increment this value if they desire a new - /// email (e.g. a reminder) to be sent. + /// email (e.g. a reminder) to be sent. If they do not, the server + /// should respond with success but not resend the email. int sendAttempt; - /// Optional. When the validation is completed, the identity - /// server will redirect the user to this URL. + /// 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; }; template <> struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const RequestEmailValidation& pod); - static void fillFrom(const QJsonObject& jo, RequestEmailValidation& pod); + static void dumpTo(QJsonObject& jo, const RequestEmailValidation& pod) + { + addParam<>(jo, QStringLiteral("client_secret"), pod.clientSecret); + addParam<>(jo, QStringLiteral("email"), pod.email); + addParam<>(jo, QStringLiteral("send_attempt"), pod.sendAttempt); + addParam(jo, QStringLiteral("next_link"), pod.nextLink); + } + static void fillFrom(const QJsonObject& jo, RequestEmailValidation& pod) + { + fromJson(jo.value("client_secret"_ls), pod.clientSecret); + fromJson(jo.value("email"_ls), pod.email); + fromJson(jo.value("send_attempt"_ls), pod.sendAttempt); + fromJson(jo.value("next_link"_ls), pod.nextLink); + } }; } // namespace Quotient diff --git a/lib/identity/definitions/request_msisdn_validation.cpp b/lib/identity/definitions/request_msisdn_validation.cpp deleted file mode 100644 index 6024bf61..00000000 --- a/lib/identity/definitions/request_msisdn_validation.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "request_msisdn_validation.h" - -using namespace Quotient; - -void JsonObjectConverter::dumpTo( - QJsonObject& jo, const RequestMsisdnValidation& pod) -{ - addParam<>(jo, QStringLiteral("client_secret"), pod.clientSecret); - addParam<>(jo, QStringLiteral("country"), pod.country); - addParam<>(jo, QStringLiteral("phone_number"), pod.phoneNumber); - addParam<>(jo, QStringLiteral("send_attempt"), pod.sendAttempt); - addParam(jo, QStringLiteral("next_link"), pod.nextLink); -} - -void JsonObjectConverter::fillFrom( - const QJsonObject& jo, RequestMsisdnValidation& result) -{ - fromJson(jo.value("client_secret"_ls), result.clientSecret); - fromJson(jo.value("country"_ls), result.country); - fromJson(jo.value("phone_number"_ls), result.phoneNumber); - fromJson(jo.value("send_attempt"_ls), result.sendAttempt); - fromJson(jo.value("next_link"_ls), result.nextLink); -} diff --git a/lib/identity/definitions/request_msisdn_validation.h b/lib/identity/definitions/request_msisdn_validation.h index 90aed7b8..a29fd0de 100644 --- a/lib/identity/definitions/request_msisdn_validation.h +++ b/lib/identity/definitions/request_msisdn_validation.h @@ -8,8 +8,6 @@ namespace Quotient { -// Data structures - struct RequestMsisdnValidation { /// A unique string generated by the client, and used to identify the /// validation attempt. It must be a string consisting of the characters @@ -17,8 +15,8 @@ struct RequestMsisdnValidation { /// must not be empty. QString clientSecret; - /// The two-letter uppercase ISO country code that the number in - /// ``phone_number`` should be parsed as if it were dialled from. + /// The two-letter uppercase ISO-3166-1 alpha-2 country code that the + /// number in ``phone_number`` should be parsed as if it were dialled from. QString country; /// The phone number to validate. @@ -33,15 +31,30 @@ struct RequestMsisdnValidation { /// they desire a new SMS (e.g. a reminder) to be sent. int sendAttempt; - /// Optional. When the validation is completed, the identity - /// server will redirect the user to this URL. + /// 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; }; template <> struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const RequestMsisdnValidation& pod); - static void fillFrom(const QJsonObject& jo, RequestMsisdnValidation& pod); + static void dumpTo(QJsonObject& jo, const RequestMsisdnValidation& pod) + { + addParam<>(jo, QStringLiteral("client_secret"), pod.clientSecret); + addParam<>(jo, QStringLiteral("country"), pod.country); + addParam<>(jo, QStringLiteral("phone_number"), pod.phoneNumber); + addParam<>(jo, QStringLiteral("send_attempt"), pod.sendAttempt); + addParam(jo, QStringLiteral("next_link"), pod.nextLink); + } + static void fillFrom(const QJsonObject& jo, RequestMsisdnValidation& pod) + { + fromJson(jo.value("client_secret"_ls), pod.clientSecret); + fromJson(jo.value("country"_ls), pod.country); + fromJson(jo.value("phone_number"_ls), pod.phoneNumber); + fromJson(jo.value("send_attempt"_ls), pod.sendAttempt); + fromJson(jo.value("next_link"_ls), pod.nextLink); + } }; } // namespace Quotient diff --git a/lib/identity/definitions/sid.cpp b/lib/identity/definitions/sid.cpp deleted file mode 100644 index 99fe9b59..00000000 --- a/lib/identity/definitions/sid.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "sid.h" - -using namespace Quotient; - -void JsonObjectConverter::dumpTo(QJsonObject& jo, const Sid& pod) -{ - addParam<>(jo, QStringLiteral("sid"), pod.sid); -} - -void JsonObjectConverter::fillFrom(const QJsonObject& jo, Sid& result) -{ - fromJson(jo.value("sid"_ls), result.sid); -} diff --git a/lib/identity/definitions/sid.h b/lib/identity/definitions/sid.h deleted file mode 100644 index 981826f6..00000000 --- a/lib/identity/definitions/sid.h +++ /dev/null @@ -1,27 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "converters.h" - -namespace Quotient { - -// Data structures - -struct Sid { - /// The session ID. Session IDs are opaque strings generated by the identity - /// server. They must consist entirely of the characters - /// ``[0-9a-zA-Z.=_-]``. Their length must not exceed 255 characters and - /// they must not be empty. - QString sid; -}; - -template <> -struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const Sid& pod); - static void fillFrom(const QJsonObject& jo, Sid& pod); -}; - -} // namespace Quotient -- cgit v1.2.3