From 07d2b179bb08c4b941eca3f20b9ef31740ad95bd Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 14 Apr 2018 14:08:44 +0900 Subject: Mustache: {{#producesNonJson?}} -> {{#producesNotJson?}} According to the most recent changes in GTAD. --- lib/jobs/{{base}}.cpp.mustache | 14 +++++++------- lib/jobs/{{base}}.h.mustache | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'lib/jobs') diff --git a/lib/jobs/{{base}}.cpp.mustache b/lib/jobs/{{base}}.cpp.mustache index b8532c51..5e94dcf0 100644 --- a/lib/jobs/{{base}}.cpp.mustache +++ b/lib/jobs/{{base}}.cpp.mustache @@ -3,8 +3,8 @@ {{^allModels}} #include "converters.h" {{/allModels}}{{#operations}} -{{#producesNotJson?}}#include -{{/producesNotJson?}}#include +{{#producesNonJson?}}#include +{{/producesNonJson?}}#include {{/operations}} using namespace QMatrixClient; {{#models.model}}{{^trivial?}} @@ -88,8 +88,8 @@ QUrl {{camelCaseOperationId}}Job::makeRequestUrl(QUrl baseUrl{{#allParams?}}, {{ {{^required?}}{{#string?}} if (!{{paramName}}.isEmpty()) {{/string?}}{{/required?}} _data.insert("{{baseName}}", toJson({{paramName}}));{{/bodyParams}} setRequestData(_data);{{/inlineBody}} -{{/bodyParams?}}{{#producesNotJson?}} setExpectedContentTypes({ {{#produces}}"{{_}}"{{#@join}}, {{/@join}}{{/produces}} }); -{{/producesNotJson?}}}{{!<- mind the actual brace}} +{{/bodyParams?}}{{#producesNonJson?}} setExpectedContentTypes({ {{#produces}}"{{_}}"{{#@join}}, {{/@join}}{{/produces}} }); +{{/producesNonJson?}}}{{!<- mind the actual brace}} {{# responses}}{{#normalResponse?}}{{#allProperties?}} {{camelCaseOperationId}}Job::~{{camelCaseOperationId}}Job() = default; {{# allProperties}} @@ -97,13 +97,13 @@ QUrl {{camelCaseOperationId}}Job::makeRequestUrl(QUrl baseUrl{{#allParams?}}, {{ { return d->{{paramName}}; } -{{/ allProperties}}{{#producesNotJson?}} +{{/ allProperties}}{{#producesNonJson?}} BaseJob::Status {{camelCaseOperationId}}Job::parseReply(QNetworkReply* reply) { {{#headers}}d->{{paramName}} = reply->rawHeader("{{baseName}}"); {{! We don't check for required headers yet }} {{/headers}}{{#properties}}d->{{paramName}} = reply;{{/properties}} return Success; -}{{/ producesNotJson?}}{{^producesNotJson?}} +}{{/ producesNonJson?}}{{^producesNonJson?}} BaseJob::Status {{camelCaseOperationId}}Job::parseJson(const QJsonDocument& data) { auto json = data.object(); @@ -112,5 +112,5 @@ BaseJob::Status {{camelCaseOperationId}}Job::parseJson(const QJsonDocument& data "The key '{{baseName}}' not found in the response" }; {{/required?}}d->{{paramName}} = fromJson<{{dataType.name}}>(json.value("{{baseName}}")); {{/ properties}}return Success; -}{{/ producesNotJson?}} +}{{/ producesNonJson?}} {{/allProperties?}}{{/normalResponse?}}{{/responses}}{{/operation}}{{/operations}} diff --git a/lib/jobs/{{base}}.h.mustache b/lib/jobs/{{base}}.h.mustache index 63aa53e7..12633604 100644 --- a/lib/jobs/{{base}}.h.mustache +++ b/lib/jobs/{{base}}.h.mustache @@ -57,7 +57,7 @@ namespace QMatrixClient {{>maybeCrefType}} {{paramName}}() const;{{/allProperties}} protected: - Status {{#producesNotJson?}}parseReply(QNetworkReply* reply){{/producesNotJson?}}{{^producesNotJson?}}parseJson(const QJsonDocument& data){{/producesNotJson?}} override; + Status {{#producesNonJson?}}parseReply(QNetworkReply* reply){{/producesNonJson?}}{{^producesNonJson?}}parseJson(const QJsonDocument& data){{/producesNonJson?}} override; private: class Private; -- cgit v1.2.3 From e5cb9b6380040e40de1b3766ac90296d3828375a Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 14 Apr 2018 14:10:33 +0900 Subject: Mustache templates: Overload toJson() instead of operator QJsonObject()/QJsonValue() It slightly reduces the header interface and shortcuts the actual call chain (not that it had any performance implications, just easier reasoning). --- lib/jobs/{{base}}.cpp.mustache | 36 +++++++++++++++++++++--------------- lib/jobs/{{base}}.h.mustache | 4 ++-- 2 files changed, 23 insertions(+), 17 deletions(-) (limited to 'lib/jobs') diff --git a/lib/jobs/{{base}}.cpp.mustache b/lib/jobs/{{base}}.cpp.mustache index 5e94dcf0..e44e6a2a 100644 --- a/lib/jobs/{{base}}.cpp.mustache +++ b/lib/jobs/{{base}}.cpp.mustache @@ -8,12 +8,15 @@ {{/operations}} using namespace QMatrixClient; {{#models.model}}{{^trivial?}} -{{qualifiedName}}::operator QJsonValue() const +namespace QMatrixClient { - QJsonObject o; - {{#vars}}o.insert("{{baseName}}", toJson({{nameCamelCase}})); - {{/vars}} - return o; + QJsonObject toJson(const {{qualifiedName}}& pod) + { + QJsonObject o; + {{#vars}}o.insert("{{baseName}}", toJson(pod.{{nameCamelCase}})); + {{/vars}} + return o; + } } {{qualifiedName}} FromJson<{{qualifiedName}}>::operator()(QJsonValue jv) @@ -28,15 +31,16 @@ using namespace QMatrixClient; {{/trivial?}}{{/models.model}}{{#operations}} static const auto basePath = QStringLiteral("{{basePathWithoutHost}}"); {{# operation}}{{#models.model}}{{^trivial?}} -{{qualifiedName}}::operator QJsonObject() const -{ - QJsonObject o; - {{#vars}}o.insert("{{baseName}}", toJson({{nameCamelCase}})); - {{/vars}} - return o; -} namespace QMatrixClient { + QJsonObject toJson(const {{qualifiedName}}& pod) + { + QJsonObject o; + {{#vars}}o.insert("{{baseName}}", toJson(pod.{{nameCamelCase}})); + {{/vars}} + return o; + } + template <> struct FromJson<{{qualifiedName}}> { {{qualifiedName}} operator()(QJsonValue jv) @@ -81,9 +85,11 @@ QUrl {{camelCaseOperationId}}Job::makeRequestUrl(QUrl baseUrl{{#allParams?}}, {{ { {{#headerParams?}}{{#headerParams}} setRequestHeader("{{baseName}}", {{paramName}}.toLatin1()); {{/headerParams}} -{{/headerParams?}}{{! -}}{{#bodyParams?}}{{! -}}{{#inlineBody}} setRequestData(Data({{nameCamelCase}}));{{/inlineBody}}{{! +{{/headerParams? +}}{{#bodyParams? +}}{{#inlineBody}} setRequestData(Data({{! + }}{{#consumesNonJson?}}{{nameCamelCase}}{{/consumesNonJson? + }}{{^consumesNonJson?}}toJson({{nameCamelCase}}){{/consumesNonJson?}}));{{/inlineBody }}{{^inlineBody}} QJsonObject _data;{{#bodyParams}} {{^required?}}{{#string?}} if (!{{paramName}}.isEmpty()) {{/string?}}{{/required?}} _data.insert("{{baseName}}", toJson({{paramName}}));{{/bodyParams}} diff --git a/lib/jobs/{{base}}.h.mustache b/lib/jobs/{{base}}.h.mustache index 12633604..8606e251 100644 --- a/lib/jobs/{{base}}.h.mustache +++ b/lib/jobs/{{base}}.h.mustache @@ -17,9 +17,10 @@ namespace QMatrixClient { {{#vars}}{{dataType.name}} {{nameCamelCase}}; {{/vars}} - operator QJsonObject() const; }; + QJsonObject toJson(const {{name}}& pod); + template <> struct FromJson<{{name}}> { {{name}} operator()(QJsonValue jv); @@ -38,7 +39,6 @@ namespace QMatrixClient { {{#vars}}{{dataType.name}} {{nameCamelCase}}; {{/vars}} - operator QJsonObject() const; }; {{/ trivial?}}{{/model}} // End of inner data structures -- cgit v1.2.3 From 4ced9792f27ed3d891c1f7772ae30d9fe452dd79 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 14 Apr 2018 14:12:03 +0900 Subject: jobs/generated: Overload toJson() instead of operator QJsonObject()/QJsonValue() It slightly reduces the header interface and shortcuts the actual call chain (not that it had any performance implications, just easier reasoning). --- lib/jobs/generated/account-data.cpp | 4 +- lib/jobs/generated/administrative_contact.cpp | 36 ++++---- lib/jobs/generated/administrative_contact.h | 2 - lib/jobs/generated/create_room.cpp | 38 +++++---- lib/jobs/generated/create_room.h | 2 - lib/jobs/generated/list_public_rooms.cpp | 116 ++++++++++++++++++-------- lib/jobs/generated/list_public_rooms.h | 32 ++++++- lib/jobs/generated/pusher.cpp | 59 ++++++------- lib/jobs/generated/pusher.h | 3 - lib/jobs/generated/receipts.cpp | 2 +- lib/jobs/generated/room_send.cpp | 2 +- lib/jobs/generated/tags.cpp | 2 +- lib/jobs/generated/users.cpp | 19 +++-- lib/jobs/generated/users.h | 1 - 14 files changed, 195 insertions(+), 123 deletions(-) (limited to 'lib/jobs') diff --git a/lib/jobs/generated/account-data.cpp b/lib/jobs/generated/account-data.cpp index 35ee94c0..ac45cb85 100644 --- a/lib/jobs/generated/account-data.cpp +++ b/lib/jobs/generated/account-data.cpp @@ -16,13 +16,13 @@ SetAccountDataJob::SetAccountDataJob(const QString& userId, const QString& type, : BaseJob(HttpVerb::Put, "SetAccountDataJob", basePath % "/user/" % userId % "/account_data/" % type) { - setRequestData(Data(content)); + setRequestData(Data(toJson(content))); } SetAccountDataPerRoomJob::SetAccountDataPerRoomJob(const QString& userId, const QString& roomId, const QString& type, const QJsonObject& content) : BaseJob(HttpVerb::Put, "SetAccountDataPerRoomJob", basePath % "/user/" % userId % "/rooms/" % roomId % "/account_data/" % type) { - setRequestData(Data(content)); + setRequestData(Data(toJson(content))); } diff --git a/lib/jobs/generated/administrative_contact.cpp b/lib/jobs/generated/administrative_contact.cpp index 1af57941..78eb21fe 100644 --- a/lib/jobs/generated/administrative_contact.cpp +++ b/lib/jobs/generated/administrative_contact.cpp @@ -10,16 +10,17 @@ using namespace QMatrixClient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -GetAccount3PIDsJob::ThirdPartyIdentifier::operator QJsonObject() const -{ - QJsonObject o; - o.insert("medium", toJson(medium)); - o.insert("address", toJson(address)); - - return o; -} namespace QMatrixClient { + QJsonObject toJson(const GetAccount3PIDsJob::ThirdPartyIdentifier& pod) + { + QJsonObject o; + o.insert("medium", toJson(pod.medium)); + o.insert("address", toJson(pod.address)); + + return o; + } + template <> struct FromJson { GetAccount3PIDsJob::ThirdPartyIdentifier operator()(QJsonValue jv) @@ -69,17 +70,18 @@ BaseJob::Status GetAccount3PIDsJob::parseJson(const QJsonDocument& data) return Success; } -Post3PIDsJob::ThreePidCredentials::operator QJsonObject() const -{ - QJsonObject o; - o.insert("client_secret", toJson(clientSecret)); - o.insert("id_server", toJson(idServer)); - o.insert("sid", toJson(sid)); - - return o; -} namespace QMatrixClient { + QJsonObject toJson(const Post3PIDsJob::ThreePidCredentials& pod) + { + QJsonObject o; + o.insert("client_secret", toJson(pod.clientSecret)); + o.insert("id_server", toJson(pod.idServer)); + o.insert("sid", toJson(pod.sid)); + + return o; + } + template <> struct FromJson { Post3PIDsJob::ThreePidCredentials operator()(QJsonValue jv) diff --git a/lib/jobs/generated/administrative_contact.h b/lib/jobs/generated/administrative_contact.h index c8429d39..bd70f07b 100644 --- a/lib/jobs/generated/administrative_contact.h +++ b/lib/jobs/generated/administrative_contact.h @@ -24,7 +24,6 @@ namespace QMatrixClient QString medium; QString address; - operator QJsonObject() const; }; // End of inner data structures @@ -60,7 +59,6 @@ namespace QMatrixClient QString idServer; QString sid; - operator QJsonObject() const; }; // End of inner data structures diff --git a/lib/jobs/generated/create_room.cpp b/lib/jobs/generated/create_room.cpp index de7807b5..008bc697 100644 --- a/lib/jobs/generated/create_room.cpp +++ b/lib/jobs/generated/create_room.cpp @@ -10,17 +10,18 @@ using namespace QMatrixClient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -CreateRoomJob::Invite3pid::operator QJsonObject() const -{ - QJsonObject o; - o.insert("id_server", toJson(idServer)); - o.insert("medium", toJson(medium)); - o.insert("address", toJson(address)); - - return o; -} namespace QMatrixClient { + QJsonObject toJson(const CreateRoomJob::Invite3pid& pod) + { + QJsonObject o; + o.insert("id_server", toJson(pod.idServer)); + o.insert("medium", toJson(pod.medium)); + o.insert("address", toJson(pod.address)); + + return o; + } + template <> struct FromJson { CreateRoomJob::Invite3pid operator()(QJsonValue jv) @@ -39,17 +40,18 @@ namespace QMatrixClient }; } // namespace QMatrixClient -CreateRoomJob::StateEvent::operator QJsonObject() const -{ - QJsonObject o; - o.insert("type", toJson(type)); - o.insert("state_key", toJson(stateKey)); - o.insert("content", toJson(content)); - - return o; -} namespace QMatrixClient { + QJsonObject toJson(const CreateRoomJob::StateEvent& pod) + { + QJsonObject o; + o.insert("type", toJson(pod.type)); + o.insert("state_key", toJson(pod.stateKey)); + o.insert("content", toJson(pod.content)); + + return o; + } + template <> struct FromJson { CreateRoomJob::StateEvent operator()(QJsonValue jv) diff --git a/lib/jobs/generated/create_room.h b/lib/jobs/generated/create_room.h index b479615a..fdb11ada 100644 --- a/lib/jobs/generated/create_room.h +++ b/lib/jobs/generated/create_room.h @@ -26,7 +26,6 @@ namespace QMatrixClient QString medium; QString address; - operator QJsonObject() const; }; struct StateEvent @@ -35,7 +34,6 @@ namespace QMatrixClient QString stateKey; QJsonObject content; - operator QJsonObject() const; }; // End of inner data structures diff --git a/lib/jobs/generated/list_public_rooms.cpp b/lib/jobs/generated/list_public_rooms.cpp index 39653300..2ae7f5d3 100644 --- a/lib/jobs/generated/list_public_rooms.cpp +++ b/lib/jobs/generated/list_public_rooms.cpp @@ -10,23 +10,67 @@ using namespace QMatrixClient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -GetPublicRoomsJob::PublicRoomsChunk::operator QJsonObject() const +class GetRoomVisibilityOnDirectoryJob::Private { - QJsonObject o; - o.insert("aliases", toJson(aliases)); - o.insert("canonical_alias", toJson(canonicalAlias)); - o.insert("name", toJson(name)); - o.insert("num_joined_members", toJson(numJoinedMembers)); - o.insert("room_id", toJson(roomId)); - o.insert("topic", toJson(topic)); - o.insert("world_readable", toJson(worldReadable)); - o.insert("guest_can_join", toJson(guestCanJoin)); - o.insert("avatar_url", toJson(avatarUrl)); - - return o; + public: + QString visibility; +}; + +QUrl GetRoomVisibilityOnDirectoryJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) +{ + return BaseJob::makeRequestUrl(baseUrl, + basePath % "/directory/list/room/" % roomId); +} + +GetRoomVisibilityOnDirectoryJob::GetRoomVisibilityOnDirectoryJob(const QString& roomId) + : BaseJob(HttpVerb::Get, "GetRoomVisibilityOnDirectoryJob", + basePath % "/directory/list/room/" % roomId, false) + , d(new Private) +{ +} + +GetRoomVisibilityOnDirectoryJob::~GetRoomVisibilityOnDirectoryJob() = default; + +const QString& GetRoomVisibilityOnDirectoryJob::visibility() const +{ + return d->visibility; +} + +BaseJob::Status GetRoomVisibilityOnDirectoryJob::parseJson(const QJsonDocument& data) +{ + auto json = data.object(); + d->visibility = fromJson(json.value("visibility")); + return Success; } + +SetRoomVisibilityOnDirectoryJob::SetRoomVisibilityOnDirectoryJob(const QString& roomId, const QString& visibility) + : BaseJob(HttpVerb::Put, "SetRoomVisibilityOnDirectoryJob", + basePath % "/directory/list/room/" % roomId) +{ + QJsonObject _data; + if (!visibility.isEmpty()) + _data.insert("visibility", toJson(visibility)); + setRequestData(_data); +} + namespace QMatrixClient { + QJsonObject toJson(const GetPublicRoomsJob::PublicRoomsChunk& pod) + { + QJsonObject o; + o.insert("aliases", toJson(pod.aliases)); + o.insert("canonical_alias", toJson(pod.canonicalAlias)); + o.insert("name", toJson(pod.name)); + o.insert("num_joined_members", toJson(pod.numJoinedMembers)); + o.insert("room_id", toJson(pod.roomId)); + o.insert("topic", toJson(pod.topic)); + o.insert("world_readable", toJson(pod.worldReadable)); + o.insert("guest_can_join", toJson(pod.guestCanJoin)); + o.insert("avatar_url", toJson(pod.avatarUrl)); + + return o; + } + template <> struct FromJson { GetPublicRoomsJob::PublicRoomsChunk operator()(QJsonValue jv) @@ -128,15 +172,16 @@ BaseJob::Status GetPublicRoomsJob::parseJson(const QJsonDocument& data) return Success; } -QueryPublicRoomsJob::Filter::operator QJsonObject() const -{ - QJsonObject o; - o.insert("generic_search_term", toJson(genericSearchTerm)); - - return o; -} namespace QMatrixClient { + QJsonObject toJson(const QueryPublicRoomsJob::Filter& pod) + { + QJsonObject o; + o.insert("generic_search_term", toJson(pod.genericSearchTerm)); + + return o; + } + template <> struct FromJson { QueryPublicRoomsJob::Filter operator()(QJsonValue jv) @@ -151,23 +196,24 @@ namespace QMatrixClient }; } // namespace QMatrixClient -QueryPublicRoomsJob::PublicRoomsChunk::operator QJsonObject() const -{ - QJsonObject o; - o.insert("aliases", toJson(aliases)); - o.insert("canonical_alias", toJson(canonicalAlias)); - o.insert("name", toJson(name)); - o.insert("num_joined_members", toJson(numJoinedMembers)); - o.insert("room_id", toJson(roomId)); - o.insert("topic", toJson(topic)); - o.insert("world_readable", toJson(worldReadable)); - o.insert("guest_can_join", toJson(guestCanJoin)); - o.insert("avatar_url", toJson(avatarUrl)); - - return o; -} namespace QMatrixClient { + QJsonObject toJson(const QueryPublicRoomsJob::PublicRoomsChunk& pod) + { + QJsonObject o; + o.insert("aliases", toJson(pod.aliases)); + o.insert("canonical_alias", toJson(pod.canonicalAlias)); + o.insert("name", toJson(pod.name)); + o.insert("num_joined_members", toJson(pod.numJoinedMembers)); + o.insert("room_id", toJson(pod.roomId)); + o.insert("topic", toJson(pod.topic)); + o.insert("world_readable", toJson(pod.worldReadable)); + o.insert("guest_can_join", toJson(pod.guestCanJoin)); + o.insert("avatar_url", toJson(pod.avatarUrl)); + + return o; + } + template <> struct FromJson { QueryPublicRoomsJob::PublicRoomsChunk operator()(QJsonValue jv) diff --git a/lib/jobs/generated/list_public_rooms.h b/lib/jobs/generated/list_public_rooms.h index 5c281de3..c8adccb4 100644 --- a/lib/jobs/generated/list_public_rooms.h +++ b/lib/jobs/generated/list_public_rooms.h @@ -14,6 +14,35 @@ namespace QMatrixClient { // Operations + class GetRoomVisibilityOnDirectoryJob : public BaseJob + { + public: + /** Construct a URL out of baseUrl and usual parameters passed to + * GetRoomVisibilityOnDirectoryJob. 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); + + explicit GetRoomVisibilityOnDirectoryJob(const QString& roomId); + ~GetRoomVisibilityOnDirectoryJob() override; + + const QString& visibility() const; + + protected: + Status parseJson(const QJsonDocument& data) override; + + private: + class Private; + QScopedPointer d; + }; + + class SetRoomVisibilityOnDirectoryJob : public BaseJob + { + public: + explicit SetRoomVisibilityOnDirectoryJob(const QString& roomId, const QString& visibility = {}); + }; + class GetPublicRoomsJob : public BaseJob { public: @@ -31,7 +60,6 @@ namespace QMatrixClient bool guestCanJoin; QString avatarUrl; - operator QJsonObject() const; }; // End of inner data structures @@ -68,7 +96,6 @@ namespace QMatrixClient { QString genericSearchTerm; - operator QJsonObject() const; }; struct PublicRoomsChunk @@ -83,7 +110,6 @@ namespace QMatrixClient bool guestCanJoin; QString avatarUrl; - operator QJsonObject() const; }; // End of inner data structures diff --git a/lib/jobs/generated/pusher.cpp b/lib/jobs/generated/pusher.cpp index 4fddac45..2937c124 100644 --- a/lib/jobs/generated/pusher.cpp +++ b/lib/jobs/generated/pusher.cpp @@ -10,15 +10,16 @@ using namespace QMatrixClient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -GetPushersJob::PusherData::operator QJsonObject() const -{ - QJsonObject o; - o.insert("url", toJson(url)); - - return o; -} namespace QMatrixClient { + QJsonObject toJson(const GetPushersJob::PusherData& pod) + { + QJsonObject o; + o.insert("url", toJson(pod.url)); + + return o; + } + template <> struct FromJson { GetPushersJob::PusherData operator()(QJsonValue jv) @@ -33,22 +34,23 @@ namespace QMatrixClient }; } // namespace QMatrixClient -GetPushersJob::Pusher::operator QJsonObject() const -{ - QJsonObject o; - o.insert("pushkey", toJson(pushkey)); - o.insert("kind", toJson(kind)); - o.insert("app_id", toJson(appId)); - o.insert("app_display_name", toJson(appDisplayName)); - o.insert("device_display_name", toJson(deviceDisplayName)); - o.insert("profile_tag", toJson(profileTag)); - o.insert("lang", toJson(lang)); - o.insert("data", toJson(data)); - - return o; -} namespace QMatrixClient { + QJsonObject toJson(const GetPushersJob::Pusher& pod) + { + QJsonObject o; + o.insert("pushkey", toJson(pod.pushkey)); + o.insert("kind", toJson(pod.kind)); + o.insert("app_id", toJson(pod.appId)); + o.insert("app_display_name", toJson(pod.appDisplayName)); + o.insert("device_display_name", toJson(pod.deviceDisplayName)); + o.insert("profile_tag", toJson(pod.profileTag)); + o.insert("lang", toJson(pod.lang)); + o.insert("data", toJson(pod.data)); + + return o; + } + template <> struct FromJson { GetPushersJob::Pusher operator()(QJsonValue jv) @@ -110,15 +112,16 @@ BaseJob::Status GetPushersJob::parseJson(const QJsonDocument& data) return Success; } -PostPusherJob::PusherData::operator QJsonObject() const -{ - QJsonObject o; - o.insert("url", toJson(url)); - - return o; -} namespace QMatrixClient { + QJsonObject toJson(const PostPusherJob::PusherData& pod) + { + QJsonObject o; + o.insert("url", toJson(pod.url)); + + return o; + } + template <> struct FromJson { PostPusherJob::PusherData operator()(QJsonValue jv) diff --git a/lib/jobs/generated/pusher.h b/lib/jobs/generated/pusher.h index 36576996..23cd3fb6 100644 --- a/lib/jobs/generated/pusher.h +++ b/lib/jobs/generated/pusher.h @@ -23,7 +23,6 @@ namespace QMatrixClient { QString url; - operator QJsonObject() const; }; struct Pusher @@ -37,7 +36,6 @@ namespace QMatrixClient QString lang; PusherData data; - operator QJsonObject() const; }; // End of inner data structures @@ -71,7 +69,6 @@ namespace QMatrixClient { QString url; - operator QJsonObject() const; }; // End of inner data structures diff --git a/lib/jobs/generated/receipts.cpp b/lib/jobs/generated/receipts.cpp index 83c38b6f..945e8673 100644 --- a/lib/jobs/generated/receipts.cpp +++ b/lib/jobs/generated/receipts.cpp @@ -16,6 +16,6 @@ PostReceiptJob::PostReceiptJob(const QString& roomId, const QString& receiptType : BaseJob(HttpVerb::Post, "PostReceiptJob", basePath % "/rooms/" % roomId % "/receipt/" % receiptType % "/" % eventId) { - setRequestData(Data(receipt)); + setRequestData(Data(toJson(receipt))); } diff --git a/lib/jobs/generated/room_send.cpp b/lib/jobs/generated/room_send.cpp index c9a3280d..9637a205 100644 --- a/lib/jobs/generated/room_send.cpp +++ b/lib/jobs/generated/room_send.cpp @@ -23,7 +23,7 @@ SendMessageJob::SendMessageJob(const QString& roomId, const QString& eventType, basePath % "/rooms/" % roomId % "/send/" % eventType % "/" % txnId) , d(new Private) { - setRequestData(Data(body)); + setRequestData(Data(toJson(body))); } SendMessageJob::~SendMessageJob() = default; diff --git a/lib/jobs/generated/tags.cpp b/lib/jobs/generated/tags.cpp index dc4faf04..ef3b5f34 100644 --- a/lib/jobs/generated/tags.cpp +++ b/lib/jobs/generated/tags.cpp @@ -49,7 +49,7 @@ SetRoomTagJob::SetRoomTagJob(const QString& userId, const QString& roomId, const : BaseJob(HttpVerb::Put, "SetRoomTagJob", basePath % "/user/" % userId % "/rooms/" % roomId % "/tags/" % tag) { - setRequestData(Data(body)); + setRequestData(Data(toJson(body))); } QUrl DeleteRoomTagJob::makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& roomId, const QString& tag) diff --git a/lib/jobs/generated/users.cpp b/lib/jobs/generated/users.cpp index 33da4b43..b222cac5 100644 --- a/lib/jobs/generated/users.cpp +++ b/lib/jobs/generated/users.cpp @@ -10,17 +10,18 @@ using namespace QMatrixClient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -SearchUserDirectoryJob::User::operator QJsonObject() const -{ - QJsonObject o; - o.insert("user_id", toJson(userId)); - o.insert("display_name", toJson(displayName)); - o.insert("avatar_url", toJson(avatarUrl)); - - return o; -} namespace QMatrixClient { + QJsonObject toJson(const SearchUserDirectoryJob::User& pod) + { + QJsonObject o; + o.insert("user_id", toJson(pod.userId)); + o.insert("display_name", toJson(pod.displayName)); + o.insert("avatar_url", toJson(pod.avatarUrl)); + + return o; + } + template <> struct FromJson { SearchUserDirectoryJob::User operator()(QJsonValue jv) diff --git a/lib/jobs/generated/users.h b/lib/jobs/generated/users.h index 7be250a5..ce7f5aba 100644 --- a/lib/jobs/generated/users.h +++ b/lib/jobs/generated/users.h @@ -25,7 +25,6 @@ namespace QMatrixClient QString displayName; QString avatarUrl; - operator QJsonObject() const; }; // End of inner data structures -- cgit v1.2.3 From 228d379967ca0627564e1db5669029792f72bf06 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Mon, 30 Apr 2018 22:15:39 +0900 Subject: Mustache templates: cleanup C++ --- lib/jobs/{{base}}.cpp.mustache | 10 +++++----- lib/jobs/{{base}}.h.mustache | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/jobs') diff --git a/lib/jobs/{{base}}.cpp.mustache b/lib/jobs/{{base}}.cpp.mustache index e44e6a2a..87205caa 100644 --- a/lib/jobs/{{base}}.cpp.mustache +++ b/lib/jobs/{{base}}.cpp.mustache @@ -19,9 +19,9 @@ namespace QMatrixClient } } -{{qualifiedName}} FromJson<{{qualifiedName}}>::operator()(QJsonValue jv) +{{qualifiedName}} FromJson<{{qualifiedName}}>::operator()(const QJsonValue& jv) { - QJsonObject o = jv.toObject(); + const auto& o = jv.toObject(); {{qualifiedName}} result; {{#vars}}result.{{nameCamelCase}} = fromJson<{{dataType.name}}>(o.value("{{baseName}}")); @@ -43,12 +43,12 @@ namespace QMatrixClient template <> struct FromJson<{{qualifiedName}}> { - {{qualifiedName}} operator()(QJsonValue jv) + {{qualifiedName}} operator()(const QJsonValue& jv) { - QJsonObject o = jv.toObject(); + const auto& o = jv.toObject(); {{qualifiedName}} result; {{#vars}}result.{{nameCamelCase}} = - fromJson<{{dataType.qualifiedName}}>(o.value("{{baseName}}")); + fromJson<{{dataType.qualifiedName}}>(o.value("{{baseName}}")); {{/vars}} return result; } diff --git a/lib/jobs/{{base}}.h.mustache b/lib/jobs/{{base}}.h.mustache index 8606e251..941662de 100644 --- a/lib/jobs/{{base}}.h.mustache +++ b/lib/jobs/{{base}}.h.mustache @@ -23,7 +23,7 @@ namespace QMatrixClient template <> struct FromJson<{{name}}> { - {{name}} operator()(QJsonValue jv); + {{name}} operator()(const QJsonValue& jv); }; {{/ trivial?}}{{/model}} {{/models}}{{#operations}} // Operations -- cgit v1.2.3 From cbb7c2d7eff7ac8724d766ade2c3e659d15d97e2 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Mon, 30 Apr 2018 22:17:04 +0900 Subject: jobs/generated: cleanup C++ --- lib/jobs/generated/administrative_contact.cpp | 18 +++++----- lib/jobs/generated/create_room.cpp | 20 +++++------ lib/jobs/generated/list_public_rooms.cpp | 50 +++++++++++++-------------- lib/jobs/generated/pusher.cpp | 32 ++++++++--------- lib/jobs/generated/users.cpp | 10 +++--- 5 files changed, 65 insertions(+), 65 deletions(-) (limited to 'lib/jobs') diff --git a/lib/jobs/generated/administrative_contact.cpp b/lib/jobs/generated/administrative_contact.cpp index 78eb21fe..fc75fd85 100644 --- a/lib/jobs/generated/administrative_contact.cpp +++ b/lib/jobs/generated/administrative_contact.cpp @@ -23,14 +23,14 @@ namespace QMatrixClient template <> struct FromJson { - GetAccount3PIDsJob::ThirdPartyIdentifier operator()(QJsonValue jv) + GetAccount3PIDsJob::ThirdPartyIdentifier operator()(const QJsonValue& jv) { - QJsonObject o = jv.toObject(); + const auto& o = jv.toObject(); GetAccount3PIDsJob::ThirdPartyIdentifier result; result.medium = - fromJson(o.value("medium")); + fromJson(o.value("medium")); result.address = - fromJson(o.value("address")); + fromJson(o.value("address")); return result; } @@ -84,16 +84,16 @@ namespace QMatrixClient template <> struct FromJson { - Post3PIDsJob::ThreePidCredentials operator()(QJsonValue jv) + Post3PIDsJob::ThreePidCredentials operator()(const QJsonValue& jv) { - QJsonObject o = jv.toObject(); + const auto& o = jv.toObject(); Post3PIDsJob::ThreePidCredentials result; result.clientSecret = - fromJson(o.value("client_secret")); + fromJson(o.value("client_secret")); result.idServer = - fromJson(o.value("id_server")); + fromJson(o.value("id_server")); result.sid = - fromJson(o.value("sid")); + fromJson(o.value("sid")); return result; } diff --git a/lib/jobs/generated/create_room.cpp b/lib/jobs/generated/create_room.cpp index 008bc697..4fc75974 100644 --- a/lib/jobs/generated/create_room.cpp +++ b/lib/jobs/generated/create_room.cpp @@ -24,16 +24,16 @@ namespace QMatrixClient template <> struct FromJson { - CreateRoomJob::Invite3pid operator()(QJsonValue jv) + CreateRoomJob::Invite3pid operator()(const QJsonValue& jv) { - QJsonObject o = jv.toObject(); + const auto& o = jv.toObject(); CreateRoomJob::Invite3pid result; result.idServer = - fromJson(o.value("id_server")); + fromJson(o.value("id_server")); result.medium = - fromJson(o.value("medium")); + fromJson(o.value("medium")); result.address = - fromJson(o.value("address")); + fromJson(o.value("address")); return result; } @@ -54,16 +54,16 @@ namespace QMatrixClient template <> struct FromJson { - CreateRoomJob::StateEvent operator()(QJsonValue jv) + CreateRoomJob::StateEvent operator()(const QJsonValue& jv) { - QJsonObject o = jv.toObject(); + const auto& o = jv.toObject(); CreateRoomJob::StateEvent result; result.type = - fromJson(o.value("type")); + fromJson(o.value("type")); result.stateKey = - fromJson(o.value("state_key")); + fromJson(o.value("state_key")); result.content = - fromJson(o.value("content")); + fromJson(o.value("content")); return result; } diff --git a/lib/jobs/generated/list_public_rooms.cpp b/lib/jobs/generated/list_public_rooms.cpp index 2ae7f5d3..35a670fb 100644 --- a/lib/jobs/generated/list_public_rooms.cpp +++ b/lib/jobs/generated/list_public_rooms.cpp @@ -73,28 +73,28 @@ namespace QMatrixClient template <> struct FromJson { - GetPublicRoomsJob::PublicRoomsChunk operator()(QJsonValue jv) + GetPublicRoomsJob::PublicRoomsChunk operator()(const QJsonValue& jv) { - QJsonObject o = jv.toObject(); + const auto& o = jv.toObject(); GetPublicRoomsJob::PublicRoomsChunk result; result.aliases = - fromJson>(o.value("aliases")); + fromJson>(o.value("aliases")); result.canonicalAlias = - fromJson(o.value("canonical_alias")); + fromJson(o.value("canonical_alias")); result.name = - fromJson(o.value("name")); + fromJson(o.value("name")); result.numJoinedMembers = - fromJson(o.value("num_joined_members")); + fromJson(o.value("num_joined_members")); result.roomId = - fromJson(o.value("room_id")); + fromJson(o.value("room_id")); result.topic = - fromJson(o.value("topic")); + fromJson(o.value("topic")); result.worldReadable = - fromJson(o.value("world_readable")); + fromJson(o.value("world_readable")); result.guestCanJoin = - fromJson(o.value("guest_can_join")); + fromJson(o.value("guest_can_join")); result.avatarUrl = - fromJson(o.value("avatar_url")); + fromJson(o.value("avatar_url")); return result; } @@ -184,12 +184,12 @@ namespace QMatrixClient template <> struct FromJson { - QueryPublicRoomsJob::Filter operator()(QJsonValue jv) + QueryPublicRoomsJob::Filter operator()(const QJsonValue& jv) { - QJsonObject o = jv.toObject(); + const auto& o = jv.toObject(); QueryPublicRoomsJob::Filter result; result.genericSearchTerm = - fromJson(o.value("generic_search_term")); + fromJson(o.value("generic_search_term")); return result; } @@ -216,28 +216,28 @@ namespace QMatrixClient template <> struct FromJson { - QueryPublicRoomsJob::PublicRoomsChunk operator()(QJsonValue jv) + QueryPublicRoomsJob::PublicRoomsChunk operator()(const QJsonValue& jv) { - QJsonObject o = jv.toObject(); + const auto& o = jv.toObject(); QueryPublicRoomsJob::PublicRoomsChunk result; result.aliases = - fromJson>(o.value("aliases")); + fromJson>(o.value("aliases")); result.canonicalAlias = - fromJson(o.value("canonical_alias")); + fromJson(o.value("canonical_alias")); result.name = - fromJson(o.value("name")); + fromJson(o.value("name")); result.numJoinedMembers = - fromJson(o.value("num_joined_members")); + fromJson(o.value("num_joined_members")); result.roomId = - fromJson(o.value("room_id")); + fromJson(o.value("room_id")); result.topic = - fromJson(o.value("topic")); + fromJson(o.value("topic")); result.worldReadable = - fromJson(o.value("world_readable")); + fromJson(o.value("world_readable")); result.guestCanJoin = - fromJson(o.value("guest_can_join")); + fromJson(o.value("guest_can_join")); result.avatarUrl = - fromJson(o.value("avatar_url")); + fromJson(o.value("avatar_url")); return result; } diff --git a/lib/jobs/generated/pusher.cpp b/lib/jobs/generated/pusher.cpp index 2937c124..4a9bde95 100644 --- a/lib/jobs/generated/pusher.cpp +++ b/lib/jobs/generated/pusher.cpp @@ -22,12 +22,12 @@ namespace QMatrixClient template <> struct FromJson { - GetPushersJob::PusherData operator()(QJsonValue jv) + GetPushersJob::PusherData operator()(const QJsonValue& jv) { - QJsonObject o = jv.toObject(); + const auto& o = jv.toObject(); GetPushersJob::PusherData result; result.url = - fromJson(o.value("url")); + fromJson(o.value("url")); return result; } @@ -53,26 +53,26 @@ namespace QMatrixClient template <> struct FromJson { - GetPushersJob::Pusher operator()(QJsonValue jv) + GetPushersJob::Pusher operator()(const QJsonValue& jv) { - QJsonObject o = jv.toObject(); + const auto& o = jv.toObject(); GetPushersJob::Pusher result; result.pushkey = - fromJson(o.value("pushkey")); + fromJson(o.value("pushkey")); result.kind = - fromJson(o.value("kind")); + fromJson(o.value("kind")); result.appId = - fromJson(o.value("app_id")); + fromJson(o.value("app_id")); result.appDisplayName = - fromJson(o.value("app_display_name")); + fromJson(o.value("app_display_name")); result.deviceDisplayName = - fromJson(o.value("device_display_name")); + fromJson(o.value("device_display_name")); result.profileTag = - fromJson(o.value("profile_tag")); + fromJson(o.value("profile_tag")); result.lang = - fromJson(o.value("lang")); + fromJson(o.value("lang")); result.data = - fromJson(o.value("data")); + fromJson(o.value("data")); return result; } @@ -124,12 +124,12 @@ namespace QMatrixClient template <> struct FromJson { - PostPusherJob::PusherData operator()(QJsonValue jv) + PostPusherJob::PusherData operator()(const QJsonValue& jv) { - QJsonObject o = jv.toObject(); + const auto& o = jv.toObject(); PostPusherJob::PusherData result; result.url = - fromJson(o.value("url")); + fromJson(o.value("url")); return result; } diff --git a/lib/jobs/generated/users.cpp b/lib/jobs/generated/users.cpp index b222cac5..6af3be3c 100644 --- a/lib/jobs/generated/users.cpp +++ b/lib/jobs/generated/users.cpp @@ -24,16 +24,16 @@ namespace QMatrixClient template <> struct FromJson { - SearchUserDirectoryJob::User operator()(QJsonValue jv) + SearchUserDirectoryJob::User operator()(const QJsonValue& jv) { - QJsonObject o = jv.toObject(); + const auto& o = jv.toObject(); SearchUserDirectoryJob::User result; result.userId = - fromJson(o.value("user_id")); + fromJson(o.value("user_id")); result.displayName = - fromJson(o.value("display_name")); + fromJson(o.value("display_name")); result.avatarUrl = - fromJson(o.value("avatar_url")); + fromJson(o.value("avatar_url")); return result; } -- cgit v1.2.3 From dbb70c537f017e94bd7e97c05357e89f38f6e69c Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Mon, 30 Apr 2018 22:18:17 +0900 Subject: gtad.yaml: Migrate to GTAD 0.5 config format --- lib/jobs/gtad.yaml | 160 +++++++++++++++++++++++++++-------------------------- 1 file changed, 81 insertions(+), 79 deletions(-) (limited to 'lib/jobs') diff --git a/lib/jobs/gtad.yaml b/lib/jobs/gtad.yaml index 78c879e4..7cfbab8f 100644 --- a/lib/jobs/gtad.yaml +++ b/lib/jobs/gtad.yaml @@ -1,87 +1,89 @@ -preprocess: - "%CLIENT_RELEASE_LABEL%": r0 - "%CLIENT_MAJOR_VERSION%": r0 - # FIXME: the below only fixes C++ compilation but not actual work - the code - # will try to reach out for wrong values in JSON payloads - #"signed:": "signedData:" - #"unsigned:": "unsignedData:" - #"default:": "isDefault:" +analyzer: + subst: + "%CLIENT_RELEASE_LABEL%": r0 + "%CLIENT_MAJOR_VERSION%": r0 + identifiers: + signed: signedData + unsigned: unsignedData + default: isDefault + origin_server_ts: originServerTimestamp -# Structure: -# swaggerType: -# OR -# swaggerType: -# - swaggerFormat: -# - /swaggerFormatRegEx/: -# - //: # default, if the format doesn't mach anything above -# WHERE -# targetTypeSpec = targetType OR -# { type: targetType, imports: , } -types: - integer: - - int64: qint64 - - int32: qint32 - - //: int - number: - - float: float - - //: double - boolean: { type: bool, initializer: false } - string: - - byte: &ByteStream - type: QIODevice* - #initializer: '"{{defaultValue}}"' - #string?: true - imports: - - binary: *ByteStream - - date: - type: QDate - initializer: QDate::fromString("{{defaultValue}}") + types: + # Structure: + # swaggerType: + # OR + # swaggerType: + # - swaggerFormat: + # - /swaggerFormatRegEx/: + # - //: # default, if the format doesn't mach anything above + # WHERE + # targetTypeSpec = targetType OR + # { type: targetType, imports: , } + integer: + - int64: qint64 + - int32: qint32 + - //: int + number: + - float: float + - //: double + boolean: { type: bool, initializer: false } + string: + - byte: &ByteStream + type: QIODevice* + #initializer: '"{{defaultValue}}"' + #string?: true + imports: + - binary: *ByteStream + - date: + type: QDate + initializer: QDate::fromString("{{defaultValue}}") + avoidCopy?: true + imports: + - dateTime: + type: QDateTime + initializer: QDateTime::fromString("{{defaultValue}}") + avoidCopy?: true + imports: + - //: + type: QString + initializer: QStringLiteral("{{defaultValue}}") + string?: true + avoidCopy?: true + file: *ByteStream + object: + type: QJsonObject avoidCopy?: true - imports: - - dateTime: - type: QDateTime - initializer: QDateTime::fromString("{{defaultValue}}") + imports: + array: + - /.+/: + type: "QVector<{{1}}>" + avoidCopy?: true + imports: + - //: { type: QJsonArray, "avoidCopy?": true, imports: } + schema: avoidCopy?: true - imports: - - //: - type: QString - initializer: QStringLiteral("{{defaultValue}}") - string?: true - avoidCopy?: true - file: *ByteStream - object: - type: QJsonObject - avoidCopy?: true - imports: - array: - - /.+/: - type: "QVector<{{1}}>" - avoidCopy?: true - imports: - - //: { type: QJsonArray, "avoidCopy?": true, imports: } - schema: - avoidCopy?: true -#operations: + #operations: -env: - _scopeRenderer: "{{scopeCamelCase}}Job::" - _literalQuote: '"' - maybeCrefType: "{{#avoidCopy?}}const {{/avoidCopy?}}{{dataType.name}}{{#avoidCopy?}}&{{/avoidCopy?}}" - qualifiedMaybeCrefType: "{{#avoidCopy?}}const {{/avoidCopy?}}{{dataType.qualifiedName}}{{#avoidCopy?}}&{{/avoidCopy?}}" - initializeDefaultValue: "{{#defaultValue}}{{>initializer}}{{/defaultValue}}{{^defaultValue}}{}{{/defaultValue}}" - joinedParamDecl: '{{>maybeCrefType}} {{paramName}}{{^required?}} = {{>initializeDefaultValue}}{{/required?}}{{#@join}}, {{/@join}}' - joinedParamDef: '{{>maybeCrefType}} {{paramName}}{{#@join}}, {{/@join}}' - passQueryParams: '{{#queryParams}}{{paramName}}{{#@join}}, {{/@join}}{{/queryParams}}' - paramToString: '{{#string?}}{{nameCamelCase}}{{/string?}}{{^string?}}QString("%1").arg({{nameCamelCase}}){{/string?}}' -# preamble: preamble.mustache - copyrightName: Kitsune Ral - copyrightEmail: -# imports: { set: } +mustache: + definitions: + _scopeRenderer: "{{scopeCamelCase}}Job::" + _literalQuote: '"' + maybeCrefType: "{{#avoidCopy?}}const {{/avoidCopy?}}{{dataType.name}}{{#avoidCopy?}}&{{/avoidCopy?}}" + qualifiedMaybeCrefType: "{{#avoidCopy?}}const {{/avoidCopy?}}{{dataType.qualifiedName}}{{#avoidCopy?}}&{{/avoidCopy?}}" + initializeDefaultValue: "{{#defaultValue}}{{>initializer}}{{/defaultValue}}{{^defaultValue}}{}{{/defaultValue}}" + joinedParamDecl: '{{>maybeCrefType}} {{paramName}}{{^required?}} = {{>initializeDefaultValue}}{{/required?}}{{#@join}}, {{/@join}}' + joinedParamDef: '{{>maybeCrefType}} {{paramName}}{{#@join}}, {{/@join}}' + passQueryParams: '{{#queryParams}}{{paramName}}{{#@join}}, {{/@join}}{{/queryParams}}' + paramToString: '{{#string?}}{{nameCamelCase}}{{/string?}}{{^string?}}QString("%1").arg({{nameCamelCase}}){{/string?}}' + # preamble: preamble.mustache + copyrightName: Kitsune Ral + copyrightEmail: + # imports: { set: } -templates: -- "{{base}}.h.mustache" -- "{{base}}.cpp.mustache" + templates: + - "{{base}}.h.mustache" + - "{{base}}.cpp.mustache" -#outFilesList: apifiles.txt + #outFilesList: apifiles.txt -- cgit v1.2.3 From f79544e0fad0b531d49dba9be001995805f18974 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Mon, 30 Apr 2018 22:33:45 +0900 Subject: jobs/generated: GetNotificationsJob --- lib/jobs/generated/notifications.cpp | 182 +++++++++++++++++++++++++++++++++++ lib/jobs/generated/notifications.h | 77 +++++++++++++++ 2 files changed, 259 insertions(+) create mode 100644 lib/jobs/generated/notifications.cpp create mode 100644 lib/jobs/generated/notifications.h (limited to 'lib/jobs') diff --git a/lib/jobs/generated/notifications.cpp b/lib/jobs/generated/notifications.cpp new file mode 100644 index 00000000..e3558097 --- /dev/null +++ b/lib/jobs/generated/notifications.cpp @@ -0,0 +1,182 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "notifications.h" + +#include + +using namespace QMatrixClient; + +static const auto basePath = QStringLiteral("/_matrix/client/r0"); + +namespace QMatrixClient +{ + QJsonObject toJson(const GetNotificationsJob::Unsigned& pod) + { + QJsonObject o; + o.insert("age", toJson(pod.age)); + o.insert("prev_content", toJson(pod.prevContent)); + o.insert("transaction_id", toJson(pod.transactionId)); + o.insert("redacted_because", toJson(pod.redactedBecause)); + + return o; + } + + template <> struct FromJson + { + GetNotificationsJob::Unsigned operator()(const QJsonValue& jv) + { + const auto& o = jv.toObject(); + GetNotificationsJob::Unsigned result; + result.age = + fromJson(o.value("age")); + result.prevContent = + fromJson(o.value("prev_content")); + result.transactionId = + fromJson(o.value("transaction_id")); + result.redactedBecause = + fromJson(o.value("redacted_because")); + + return result; + } + }; +} // namespace QMatrixClient + +namespace QMatrixClient +{ + QJsonObject toJson(const GetNotificationsJob::Event& pod) + { + QJsonObject o; + o.insert("event_id", toJson(pod.eventId)); + o.insert("content", toJson(pod.content)); + o.insert("origin_server_ts", toJson(pod.originServerTimestamp)); + o.insert("sender", toJson(pod.sender)); + o.insert("state_key", toJson(pod.stateKey)); + o.insert("type", toJson(pod.type)); + o.insert("unsigned", toJson(pod.unsignedData)); + + return o; + } + + template <> struct FromJson + { + GetNotificationsJob::Event operator()(const QJsonValue& jv) + { + const auto& o = jv.toObject(); + GetNotificationsJob::Event result; + result.eventId = + fromJson(o.value("event_id")); + result.content = + fromJson(o.value("content")); + result.originServerTimestamp = + fromJson(o.value("origin_server_ts")); + result.sender = + fromJson(o.value("sender")); + result.stateKey = + fromJson(o.value("state_key")); + result.type = + fromJson(o.value("type")); + result.unsignedData = + fromJson(o.value("unsigned")); + + return result; + } + }; +} // namespace QMatrixClient + +namespace QMatrixClient +{ + QJsonObject toJson(const GetNotificationsJob::Notification& pod) + { + QJsonObject o; + o.insert("actions", toJson(pod.actions)); + o.insert("event", toJson(pod.event)); + o.insert("profile_tag", toJson(pod.profileTag)); + o.insert("read", toJson(pod.read)); + o.insert("room_id", toJson(pod.roomId)); + o.insert("ts", toJson(pod.ts)); + + return o; + } + + template <> struct FromJson + { + GetNotificationsJob::Notification operator()(const QJsonValue& jv) + { + const auto& o = jv.toObject(); + GetNotificationsJob::Notification result; + result.actions = + fromJson>(o.value("actions")); + result.event = + fromJson(o.value("event")); + result.profileTag = + fromJson(o.value("profile_tag")); + result.read = + fromJson(o.value("read")); + result.roomId = + fromJson(o.value("room_id")); + result.ts = + fromJson(o.value("ts")); + + return result; + } + }; +} // namespace QMatrixClient + +class GetNotificationsJob::Private +{ + public: + QString nextToken; + QVector notifications; +}; + +BaseJob::Query queryToGetNotifications(const QString& from, int limit, const QString& only) +{ + BaseJob::Query _q; + if (!from.isEmpty()) + _q.addQueryItem("from", from); + _q.addQueryItem("limit", QString("%1").arg(limit)); + if (!only.isEmpty()) + _q.addQueryItem("only", only); + return _q; +} + +QUrl GetNotificationsJob::makeRequestUrl(QUrl baseUrl, const QString& from, int limit, const QString& only) +{ + return BaseJob::makeRequestUrl(baseUrl, + basePath % "/notifications", + queryToGetNotifications(from, limit, only)); +} + +GetNotificationsJob::GetNotificationsJob(const QString& from, int limit, const QString& only) + : BaseJob(HttpVerb::Get, "GetNotificationsJob", + basePath % "/notifications", + queryToGetNotifications(from, limit, only)) + , d(new Private) +{ +} + +GetNotificationsJob::~GetNotificationsJob() = default; + +const QString& GetNotificationsJob::nextToken() const +{ + return d->nextToken; +} + +const QVector& GetNotificationsJob::notifications() const +{ + return d->notifications; +} + +BaseJob::Status GetNotificationsJob::parseJson(const QJsonDocument& data) +{ + auto json = data.object(); + d->nextToken = fromJson(json.value("next_token")); + if (!json.contains("notifications")) + return { JsonParseError, + "The key 'notifications' not found in the response" }; + d->notifications = fromJson>(json.value("notifications")); + return Success; +} + diff --git a/lib/jobs/generated/notifications.h b/lib/jobs/generated/notifications.h new file mode 100644 index 00000000..9249a1b7 --- /dev/null +++ b/lib/jobs/generated/notifications.h @@ -0,0 +1,77 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "../basejob.h" + +#include +#include + +#include "converters.h" + +namespace QMatrixClient +{ + // Operations + + class GetNotificationsJob : public BaseJob + { + public: + // Inner data structures + + struct Unsigned + { + qint64 age; + QJsonObject prevContent; + QString transactionId; + QJsonObject redactedBecause; + + }; + + struct Event + { + QString eventId; + QJsonObject content; + qint64 originServerTimestamp; + QString sender; + QString stateKey; + QString type; + Unsigned unsignedData; + + }; + + struct Notification + { + QVector actions; + Event event; + QString profileTag; + bool read; + QString roomId; + qint64 ts; + + }; + + // End of inner data structures + + /** Construct a URL out of baseUrl and usual parameters passed to + * GetNotificationsJob. 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 = {}, int limit = {}, const QString& only = {}); + + explicit GetNotificationsJob(const QString& from = {}, int limit = {}, const QString& only = {}); + ~GetNotificationsJob() override; + + const QString& nextToken() const; + const QVector& notifications() const; + + protected: + Status parseJson(const QJsonDocument& data) override; + + private: + class Private; + QScopedPointer d; + }; +} // namespace QMatrixClient -- cgit v1.2.3 From df268cad0ad517a75c813606bf3ef11bdba6f4e6 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Tue, 1 May 2018 12:53:00 +0900 Subject: Mustache: more C++ tidying and empty lines removal --- lib/jobs/{{base}}.cpp.mustache | 2 +- lib/jobs/{{base}}.h.mustache | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/jobs') diff --git a/lib/jobs/{{base}}.cpp.mustache b/lib/jobs/{{base}}.cpp.mustache index 87205caa..1ca23799 100644 --- a/lib/jobs/{{base}}.cpp.mustache +++ b/lib/jobs/{{base}}.cpp.mustache @@ -71,7 +71,7 @@ BaseJob::Query queryTo{{camelCaseOperationId}}({{#queryParams}}{{>joinedParamDef {{/queryParams?}}{{^bodyParams}} QUrl {{camelCaseOperationId}}Job::makeRequestUrl(QUrl baseUrl{{#allParams?}}, {{#allParams}}{{>joinedParamDef}}{{/allParams}}{{/allParams?}}) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath{{#pathParts}} % {{_}}{{/pathParts}}{{#queryParams?}}, queryTo{{camelCaseOperationId}}({{>passQueryParams}}){{/queryParams?}}); } diff --git a/lib/jobs/{{base}}.h.mustache b/lib/jobs/{{base}}.h.mustache index 941662de..f49945d4 100644 --- a/lib/jobs/{{base}}.h.mustache +++ b/lib/jobs/{{base}}.h.mustache @@ -16,8 +16,8 @@ namespace QMatrixClient struct {{name}}{{#parents?}} : {{#parents}}{{name}}{{#@join}}, {{/@join}}{{/parents}}{{/parents?}} { {{#vars}}{{dataType.name}} {{nameCamelCase}}; - {{/vars}} - }; + {{/vars}}{{! +}} }; QJsonObject toJson(const {{name}}& pod); -- cgit v1.2.3 From ea363441269c9100c4bcc8076d4b3d125333a649 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Tue, 1 May 2018 20:03:32 +0900 Subject: gtad.yaml: Use EventPtr for Notifications.Event; add variant type to the map Variants are not yet supported but just in case, let's have the line, it's very obvious. --- lib/jobs/gtad.yaml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/jobs') diff --git a/lib/jobs/gtad.yaml b/lib/jobs/gtad.yaml index 7cfbab8f..052d8301 100644 --- a/lib/jobs/gtad.yaml +++ b/lib/jobs/gtad.yaml @@ -51,15 +51,24 @@ analyzer: avoidCopy?: true file: *ByteStream object: - type: QJsonObject - avoidCopy?: true - imports: + - definitions/event.yaml: + type: EventPtr + imports: '"events/event.h"' + - //: + type: QJsonObject + avoidCopy?: true + imports: array: + - Notification: + type: "std::vector<{{1}}>" + avoidCopy?: true + imports: - /.+/: type: "QVector<{{1}}>" avoidCopy?: true imports: - //: { type: QJsonArray, "avoidCopy?": true, imports: } + variant: { type: QVariant, "avoidCopy?": true, imports: } schema: avoidCopy?: true -- cgit v1.2.3 From 38934c2310b426be640988dc10f48de88a3d92bc Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Tue, 1 May 2018 20:04:51 +0900 Subject: jobs/generated: use std::move in baseURL; type updates from the API files The type updates are a matter of pending PR to matrix-doc yet. --- lib/jobs/generated/administrative_contact.cpp | 4 +- lib/jobs/generated/content-repo.cpp | 20 +++--- lib/jobs/generated/content-repo.h | 6 +- lib/jobs/generated/directory.cpp | 4 +- lib/jobs/generated/leaving.cpp | 4 +- lib/jobs/generated/list_joined_rooms.cpp | 2 +- lib/jobs/generated/list_public_rooms.cpp | 28 ++++---- lib/jobs/generated/list_public_rooms.h | 14 ++-- lib/jobs/generated/logout.cpp | 2 +- lib/jobs/generated/notifications.cpp | 96 ++------------------------- lib/jobs/generated/notifications.h | 25 ++----- lib/jobs/generated/profile.cpp | 6 +- lib/jobs/generated/pusher.cpp | 2 +- lib/jobs/generated/tags.cpp | 4 +- lib/jobs/generated/users.cpp | 2 +- lib/jobs/generated/users.h | 2 +- lib/jobs/generated/versions.cpp | 2 +- lib/jobs/generated/whoami.cpp | 2 +- 18 files changed, 60 insertions(+), 165 deletions(-) (limited to 'lib/jobs') diff --git a/lib/jobs/generated/administrative_contact.cpp b/lib/jobs/generated/administrative_contact.cpp index fc75fd85..b003c92d 100644 --- a/lib/jobs/generated/administrative_contact.cpp +++ b/lib/jobs/generated/administrative_contact.cpp @@ -45,7 +45,7 @@ class GetAccount3PIDsJob::Private QUrl GetAccount3PIDsJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/account/3pid"); } @@ -112,7 +112,7 @@ Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds, bool bind) QUrl RequestTokenTo3PIDJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/account/3pid/email/requestToken"); } diff --git a/lib/jobs/generated/content-repo.cpp b/lib/jobs/generated/content-repo.cpp index 51011251..95fc5aed 100644 --- a/lib/jobs/generated/content-repo.cpp +++ b/lib/jobs/generated/content-repo.cpp @@ -65,7 +65,7 @@ class GetContentJob::Private QUrl GetContentJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/download/" % serverName % "/" % mediaId); } @@ -112,7 +112,7 @@ class GetContentOverrideNameJob::Private QUrl GetContentOverrideNameJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, const QString& fileName) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/download/" % serverName % "/" % mediaId % "/" % fileName); } @@ -168,7 +168,7 @@ BaseJob::Query queryToGetContentThumbnail(int width, int height, const QString& QUrl GetContentThumbnailJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, int width, int height, const QString& method) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/thumbnail/" % serverName % "/" % mediaId, queryToGetContentThumbnail(width, height, method)); } @@ -205,11 +205,11 @@ BaseJob::Status GetContentThumbnailJob::parseReply(QNetworkReply* reply) class GetUrlPreviewJob::Private { public: - double matrixImageSize; + qint64 matrixImageSize; QString ogImage; }; -BaseJob::Query queryToGetUrlPreview(const QString& url, double ts) +BaseJob::Query queryToGetUrlPreview(const QString& url, qint64 ts) { BaseJob::Query _q; _q.addQueryItem("url", url); @@ -217,14 +217,14 @@ BaseJob::Query queryToGetUrlPreview(const QString& url, double ts) return _q; } -QUrl GetUrlPreviewJob::makeRequestUrl(QUrl baseUrl, const QString& url, double ts) +QUrl GetUrlPreviewJob::makeRequestUrl(QUrl baseUrl, const QString& url, qint64 ts) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/preview_url", queryToGetUrlPreview(url, ts)); } -GetUrlPreviewJob::GetUrlPreviewJob(const QString& url, double ts) +GetUrlPreviewJob::GetUrlPreviewJob(const QString& url, qint64 ts) : BaseJob(HttpVerb::Get, "GetUrlPreviewJob", basePath % "/preview_url", queryToGetUrlPreview(url, ts)) @@ -234,7 +234,7 @@ GetUrlPreviewJob::GetUrlPreviewJob(const QString& url, double ts) GetUrlPreviewJob::~GetUrlPreviewJob() = default; -double GetUrlPreviewJob::matrixImageSize() const +qint64 GetUrlPreviewJob::matrixImageSize() const { return d->matrixImageSize; } @@ -247,7 +247,7 @@ const QString& GetUrlPreviewJob::ogImage() const BaseJob::Status GetUrlPreviewJob::parseJson(const QJsonDocument& data) { auto json = data.object(); - d->matrixImageSize = fromJson(json.value("matrix:image:size")); + d->matrixImageSize = fromJson(json.value("matrix:image:size")); d->ogImage = fromJson(json.value("og:image")); return Success; } diff --git a/lib/jobs/generated/content-repo.h b/lib/jobs/generated/content-repo.h index b4ea562f..e1e58f88 100644 --- a/lib/jobs/generated/content-repo.h +++ b/lib/jobs/generated/content-repo.h @@ -111,12 +111,12 @@ namespace QMatrixClient * a URL for GetUrlPreviewJob is necessary but the job * itself isn't. */ - static QUrl makeRequestUrl(QUrl baseUrl, const QString& url, double ts = {}); + static QUrl makeRequestUrl(QUrl baseUrl, const QString& url, qint64 ts = {}); - explicit GetUrlPreviewJob(const QString& url, double ts = {}); + explicit GetUrlPreviewJob(const QString& url, qint64 ts = {}); ~GetUrlPreviewJob() override; - double matrixImageSize() const; + qint64 matrixImageSize() const; const QString& ogImage() const; protected: diff --git a/lib/jobs/generated/directory.cpp b/lib/jobs/generated/directory.cpp index 9428dcee..6324a1f5 100644 --- a/lib/jobs/generated/directory.cpp +++ b/lib/jobs/generated/directory.cpp @@ -31,7 +31,7 @@ class GetRoomIdByAliasJob::Private QUrl GetRoomIdByAliasJob::makeRequestUrl(QUrl baseUrl, const QString& roomAlias) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/room/" % roomAlias); } @@ -64,7 +64,7 @@ BaseJob::Status GetRoomIdByAliasJob::parseJson(const QJsonDocument& data) QUrl DeleteRoomAliasJob::makeRequestUrl(QUrl baseUrl, const QString& roomAlias) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/room/" % roomAlias); } diff --git a/lib/jobs/generated/leaving.cpp b/lib/jobs/generated/leaving.cpp index fbc40d11..afc4adbd 100644 --- a/lib/jobs/generated/leaving.cpp +++ b/lib/jobs/generated/leaving.cpp @@ -14,7 +14,7 @@ static const auto basePath = QStringLiteral("/_matrix/client/r0"); QUrl LeaveRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/rooms/" % roomId % "/leave"); } @@ -26,7 +26,7 @@ LeaveRoomJob::LeaveRoomJob(const QString& roomId) QUrl ForgetRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/rooms/" % roomId % "/forget"); } diff --git a/lib/jobs/generated/list_joined_rooms.cpp b/lib/jobs/generated/list_joined_rooms.cpp index f902f94c..8ea44721 100644 --- a/lib/jobs/generated/list_joined_rooms.cpp +++ b/lib/jobs/generated/list_joined_rooms.cpp @@ -20,7 +20,7 @@ class GetJoinedRoomsJob::Private QUrl GetJoinedRoomsJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/joined_rooms"); } diff --git a/lib/jobs/generated/list_public_rooms.cpp b/lib/jobs/generated/list_public_rooms.cpp index 35a670fb..9b4174cb 100644 --- a/lib/jobs/generated/list_public_rooms.cpp +++ b/lib/jobs/generated/list_public_rooms.cpp @@ -18,7 +18,7 @@ class GetRoomVisibilityOnDirectoryJob::Private QUrl GetRoomVisibilityOnDirectoryJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/directory/list/room/" % roomId); } @@ -84,7 +84,7 @@ namespace QMatrixClient result.name = fromJson(o.value("name")); result.numJoinedMembers = - fromJson(o.value("num_joined_members")); + fromJson(o.value("num_joined_members")); result.roomId = fromJson(o.value("room_id")); result.topic = @@ -107,10 +107,10 @@ class GetPublicRoomsJob::Private QVector chunk; QString nextBatch; QString prevBatch; - double totalRoomCountEstimate; + qint64 totalRoomCountEstimate; }; -BaseJob::Query queryToGetPublicRooms(double limit, const QString& since, const QString& server) +BaseJob::Query queryToGetPublicRooms(int limit, const QString& since, const QString& server) { BaseJob::Query _q; _q.addQueryItem("limit", QString("%1").arg(limit)); @@ -121,14 +121,14 @@ BaseJob::Query queryToGetPublicRooms(double limit, const QString& since, const Q return _q; } -QUrl GetPublicRoomsJob::makeRequestUrl(QUrl baseUrl, double limit, const QString& since, const QString& server) +QUrl GetPublicRoomsJob::makeRequestUrl(QUrl baseUrl, int limit, const QString& since, const QString& server) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/publicRooms", queryToGetPublicRooms(limit, since, server)); } -GetPublicRoomsJob::GetPublicRoomsJob(double limit, const QString& since, const QString& server) +GetPublicRoomsJob::GetPublicRoomsJob(int limit, const QString& since, const QString& server) : BaseJob(HttpVerb::Get, "GetPublicRoomsJob", basePath % "/publicRooms", queryToGetPublicRooms(limit, since, server), @@ -154,7 +154,7 @@ const QString& GetPublicRoomsJob::prevBatch() const return d->prevBatch; } -double GetPublicRoomsJob::totalRoomCountEstimate() const +qint64 GetPublicRoomsJob::totalRoomCountEstimate() const { return d->totalRoomCountEstimate; } @@ -168,7 +168,7 @@ BaseJob::Status GetPublicRoomsJob::parseJson(const QJsonDocument& data) d->chunk = fromJson>(json.value("chunk")); d->nextBatch = fromJson(json.value("next_batch")); d->prevBatch = fromJson(json.value("prev_batch")); - d->totalRoomCountEstimate = fromJson(json.value("total_room_count_estimate")); + d->totalRoomCountEstimate = fromJson(json.value("total_room_count_estimate")); return Success; } @@ -227,7 +227,7 @@ namespace QMatrixClient result.name = fromJson(o.value("name")); result.numJoinedMembers = - fromJson(o.value("num_joined_members")); + fromJson(o.value("num_joined_members")); result.roomId = fromJson(o.value("room_id")); result.topic = @@ -250,7 +250,7 @@ class QueryPublicRoomsJob::Private QVector chunk; QString nextBatch; QString prevBatch; - double totalRoomCountEstimate; + qint64 totalRoomCountEstimate; }; BaseJob::Query queryToQueryPublicRooms(const QString& server) @@ -261,7 +261,7 @@ BaseJob::Query queryToQueryPublicRooms(const QString& server) return _q; } -QueryPublicRoomsJob::QueryPublicRoomsJob(const QString& server, double limit, const QString& since, const Filter& filter) +QueryPublicRoomsJob::QueryPublicRoomsJob(const QString& server, int limit, const QString& since, const Filter& filter) : BaseJob(HttpVerb::Post, "QueryPublicRoomsJob", basePath % "/publicRooms", queryToQueryPublicRooms(server)) @@ -292,7 +292,7 @@ const QString& QueryPublicRoomsJob::prevBatch() const return d->prevBatch; } -double QueryPublicRoomsJob::totalRoomCountEstimate() const +qint64 QueryPublicRoomsJob::totalRoomCountEstimate() const { return d->totalRoomCountEstimate; } @@ -306,7 +306,7 @@ BaseJob::Status QueryPublicRoomsJob::parseJson(const QJsonDocument& data) d->chunk = fromJson>(json.value("chunk")); d->nextBatch = fromJson(json.value("next_batch")); d->prevBatch = fromJson(json.value("prev_batch")); - d->totalRoomCountEstimate = fromJson(json.value("total_room_count_estimate")); + d->totalRoomCountEstimate = fromJson(json.value("total_room_count_estimate")); return Success; } diff --git a/lib/jobs/generated/list_public_rooms.h b/lib/jobs/generated/list_public_rooms.h index c8adccb4..1e44e8b2 100644 --- a/lib/jobs/generated/list_public_rooms.h +++ b/lib/jobs/generated/list_public_rooms.h @@ -53,7 +53,7 @@ namespace QMatrixClient QVector aliases; QString canonicalAlias; QString name; - double numJoinedMembers; + qint64 numJoinedMembers; QString roomId; QString topic; bool worldReadable; @@ -69,15 +69,15 @@ namespace QMatrixClient * a URL for GetPublicRoomsJob is necessary but the job * itself isn't. */ - static QUrl makeRequestUrl(QUrl baseUrl, double limit = {}, const QString& since = {}, const QString& server = {}); + static QUrl makeRequestUrl(QUrl baseUrl, int limit = {}, const QString& since = {}, const QString& server = {}); - explicit GetPublicRoomsJob(double limit = {}, const QString& since = {}, const QString& server = {}); + explicit GetPublicRoomsJob(int limit = {}, const QString& since = {}, const QString& server = {}); ~GetPublicRoomsJob() override; const QVector& chunk() const; const QString& nextBatch() const; const QString& prevBatch() const; - double totalRoomCountEstimate() const; + qint64 totalRoomCountEstimate() const; protected: Status parseJson(const QJsonDocument& data) override; @@ -103,7 +103,7 @@ namespace QMatrixClient QVector aliases; QString canonicalAlias; QString name; - double numJoinedMembers; + qint64 numJoinedMembers; QString roomId; QString topic; bool worldReadable; @@ -114,13 +114,13 @@ namespace QMatrixClient // End of inner data structures - explicit QueryPublicRoomsJob(const QString& server = {}, double limit = {}, const QString& since = {}, const Filter& filter = {}); + explicit QueryPublicRoomsJob(const QString& server = {}, int limit = {}, const QString& since = {}, const Filter& filter = {}); ~QueryPublicRoomsJob() override; const QVector& chunk() const; const QString& nextBatch() const; const QString& prevBatch() const; - double totalRoomCountEstimate() const; + qint64 totalRoomCountEstimate() const; protected: Status parseJson(const QJsonDocument& data) override; diff --git a/lib/jobs/generated/logout.cpp b/lib/jobs/generated/logout.cpp index 83139842..b943dcd3 100644 --- a/lib/jobs/generated/logout.cpp +++ b/lib/jobs/generated/logout.cpp @@ -14,7 +14,7 @@ static const auto basePath = QStringLiteral("/_matrix/client/r0"); QUrl LogoutJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/logout"); } diff --git a/lib/jobs/generated/notifications.cpp b/lib/jobs/generated/notifications.cpp index e3558097..ffd17b8a 100644 --- a/lib/jobs/generated/notifications.cpp +++ b/lib/jobs/generated/notifications.cpp @@ -12,94 +12,6 @@ static const auto basePath = QStringLiteral("/_matrix/client/r0"); namespace QMatrixClient { - QJsonObject toJson(const GetNotificationsJob::Unsigned& pod) - { - QJsonObject o; - o.insert("age", toJson(pod.age)); - o.insert("prev_content", toJson(pod.prevContent)); - o.insert("transaction_id", toJson(pod.transactionId)); - o.insert("redacted_because", toJson(pod.redactedBecause)); - - return o; - } - - template <> struct FromJson - { - GetNotificationsJob::Unsigned operator()(const QJsonValue& jv) - { - const auto& o = jv.toObject(); - GetNotificationsJob::Unsigned result; - result.age = - fromJson(o.value("age")); - result.prevContent = - fromJson(o.value("prev_content")); - result.transactionId = - fromJson(o.value("transaction_id")); - result.redactedBecause = - fromJson(o.value("redacted_because")); - - return result; - } - }; -} // namespace QMatrixClient - -namespace QMatrixClient -{ - QJsonObject toJson(const GetNotificationsJob::Event& pod) - { - QJsonObject o; - o.insert("event_id", toJson(pod.eventId)); - o.insert("content", toJson(pod.content)); - o.insert("origin_server_ts", toJson(pod.originServerTimestamp)); - o.insert("sender", toJson(pod.sender)); - o.insert("state_key", toJson(pod.stateKey)); - o.insert("type", toJson(pod.type)); - o.insert("unsigned", toJson(pod.unsignedData)); - - return o; - } - - template <> struct FromJson - { - GetNotificationsJob::Event operator()(const QJsonValue& jv) - { - const auto& o = jv.toObject(); - GetNotificationsJob::Event result; - result.eventId = - fromJson(o.value("event_id")); - result.content = - fromJson(o.value("content")); - result.originServerTimestamp = - fromJson(o.value("origin_server_ts")); - result.sender = - fromJson(o.value("sender")); - result.stateKey = - fromJson(o.value("state_key")); - result.type = - fromJson(o.value("type")); - result.unsignedData = - fromJson(o.value("unsigned")); - - return result; - } - }; -} // namespace QMatrixClient - -namespace QMatrixClient -{ - QJsonObject toJson(const GetNotificationsJob::Notification& pod) - { - QJsonObject o; - o.insert("actions", toJson(pod.actions)); - o.insert("event", toJson(pod.event)); - o.insert("profile_tag", toJson(pod.profileTag)); - o.insert("read", toJson(pod.read)); - o.insert("room_id", toJson(pod.roomId)); - o.insert("ts", toJson(pod.ts)); - - return o; - } - template <> struct FromJson { GetNotificationsJob::Notification operator()(const QJsonValue& jv) @@ -128,7 +40,7 @@ class GetNotificationsJob::Private { public: QString nextToken; - QVector notifications; + std::vector notifications; }; BaseJob::Query queryToGetNotifications(const QString& from, int limit, const QString& only) @@ -144,7 +56,7 @@ BaseJob::Query queryToGetNotifications(const QString& from, int limit, const QSt QUrl GetNotificationsJob::makeRequestUrl(QUrl baseUrl, const QString& from, int limit, const QString& only) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/notifications", queryToGetNotifications(from, limit, only)); } @@ -164,7 +76,7 @@ const QString& GetNotificationsJob::nextToken() const return d->nextToken; } -const QVector& GetNotificationsJob::notifications() const +const std::vector& GetNotificationsJob::notifications() const { return d->notifications; } @@ -176,7 +88,7 @@ BaseJob::Status GetNotificationsJob::parseJson(const QJsonDocument& data) if (!json.contains("notifications")) return { JsonParseError, "The key 'notifications' not found in the response" }; - d->notifications = fromJson>(json.value("notifications")); + d->notifications = fromJson>(json.value("notifications")); return Success; } diff --git a/lib/jobs/generated/notifications.h b/lib/jobs/generated/notifications.h index 9249a1b7..72318f69 100644 --- a/lib/jobs/generated/notifications.h +++ b/lib/jobs/generated/notifications.h @@ -6,6 +6,8 @@ #include "../basejob.h" +#include +#include "events/event.h" #include #include @@ -20,26 +22,7 @@ namespace QMatrixClient public: // Inner data structures - struct Unsigned - { - qint64 age; - QJsonObject prevContent; - QString transactionId; - QJsonObject redactedBecause; - - }; - - struct Event - { - QString eventId; - QJsonObject content; - qint64 originServerTimestamp; - QString sender; - QString stateKey; - QString type; - Unsigned unsignedData; - - }; + using Event = EventPtr; struct Notification { @@ -65,7 +48,7 @@ namespace QMatrixClient ~GetNotificationsJob() override; const QString& nextToken() const; - const QVector& notifications() const; + const std::vector& notifications() const; protected: Status parseJson(const QJsonDocument& data) override; diff --git a/lib/jobs/generated/profile.cpp b/lib/jobs/generated/profile.cpp index 1f7092d7..d8ddbc14 100644 --- a/lib/jobs/generated/profile.cpp +++ b/lib/jobs/generated/profile.cpp @@ -30,7 +30,7 @@ class GetDisplayNameJob::Private QUrl GetDisplayNameJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/profile/" % userId % "/displayname"); } @@ -73,7 +73,7 @@ class GetAvatarUrlJob::Private QUrl GetAvatarUrlJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/profile/" % userId % "/avatar_url"); } @@ -107,7 +107,7 @@ class GetUserProfileJob::Private QUrl GetUserProfileJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/profile/" % userId); } diff --git a/lib/jobs/generated/pusher.cpp b/lib/jobs/generated/pusher.cpp index 4a9bde95..7d5e80d1 100644 --- a/lib/jobs/generated/pusher.cpp +++ b/lib/jobs/generated/pusher.cpp @@ -87,7 +87,7 @@ class GetPushersJob::Private QUrl GetPushersJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/pushers"); } diff --git a/lib/jobs/generated/tags.cpp b/lib/jobs/generated/tags.cpp index ef3b5f34..9cd78aec 100644 --- a/lib/jobs/generated/tags.cpp +++ b/lib/jobs/generated/tags.cpp @@ -20,7 +20,7 @@ class GetRoomTagsJob::Private QUrl GetRoomTagsJob::makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& roomId) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/user/" % userId % "/rooms/" % roomId % "/tags"); } @@ -54,7 +54,7 @@ SetRoomTagJob::SetRoomTagJob(const QString& userId, const QString& roomId, const QUrl DeleteRoomTagJob::makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& roomId, const QString& tag) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/user/" % userId % "/rooms/" % roomId % "/tags/" % tag); } diff --git a/lib/jobs/generated/users.cpp b/lib/jobs/generated/users.cpp index 6af3be3c..f82a2a64 100644 --- a/lib/jobs/generated/users.cpp +++ b/lib/jobs/generated/users.cpp @@ -47,7 +47,7 @@ class SearchUserDirectoryJob::Private bool limited; }; -SearchUserDirectoryJob::SearchUserDirectoryJob(const QString& searchTerm, double limit) +SearchUserDirectoryJob::SearchUserDirectoryJob(const QString& searchTerm, int limit) : BaseJob(HttpVerb::Post, "SearchUserDirectoryJob", basePath % "/user_directory/search") , d(new Private) diff --git a/lib/jobs/generated/users.h b/lib/jobs/generated/users.h index ce7f5aba..bfa688c8 100644 --- a/lib/jobs/generated/users.h +++ b/lib/jobs/generated/users.h @@ -29,7 +29,7 @@ namespace QMatrixClient // End of inner data structures - explicit SearchUserDirectoryJob(const QString& searchTerm, double limit = {}); + explicit SearchUserDirectoryJob(const QString& searchTerm, int limit = {}); ~SearchUserDirectoryJob() override; const QVector& results() const; diff --git a/lib/jobs/generated/versions.cpp b/lib/jobs/generated/versions.cpp index b12594ca..3b03172c 100644 --- a/lib/jobs/generated/versions.cpp +++ b/lib/jobs/generated/versions.cpp @@ -20,7 +20,7 @@ class GetVersionsJob::Private QUrl GetVersionsJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/versions"); } diff --git a/lib/jobs/generated/whoami.cpp b/lib/jobs/generated/whoami.cpp index cc38fa4d..4c231b5f 100644 --- a/lib/jobs/generated/whoami.cpp +++ b/lib/jobs/generated/whoami.cpp @@ -20,7 +20,7 @@ class GetTokenOwnerJob::Private QUrl GetTokenOwnerJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/account/whoami"); } -- cgit v1.2.3 From 37700bbf2df8b96c82a193c25764d9020b1140e9 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 3 May 2018 20:14:19 +0900 Subject: GTAD: Use QMatrixClient::Event-derived classes in generated jobs + Mustache cleanup This should make generated jobs buildable across the whole CS API (sync.yaml is disabled as the manual implementation is still considerably better). --- lib/jobs/gtad.yaml | 40 +++++++++++++++++++++++++++++++++------- lib/jobs/{{base}}.cpp.mustache | 41 ++++++++++++++++++++--------------------- lib/jobs/{{base}}.h.mustache | 32 +++++++++++++------------------- 3 files changed, 66 insertions(+), 47 deletions(-) (limited to 'lib/jobs') diff --git a/lib/jobs/gtad.yaml b/lib/jobs/gtad.yaml index 052d8301..4ef55bce 100644 --- a/lib/jobs/gtad.yaml +++ b/lib/jobs/gtad.yaml @@ -6,7 +6,8 @@ analyzer: signed: signedData unsigned: unsignedData default: isDefault - origin_server_ts: originServerTimestamp + origin_server_ts: originServerTimestamp # Instead of originServerTs + start: begin # Because start() is a method in BaseJob types: # Structure: @@ -51,18 +52,42 @@ analyzer: avoidCopy?: true file: *ByteStream object: - - definitions/event.yaml: + - /.+m\.room\.member/: # A stub for EventsBatch + type: none + - /.+state_event.yaml/: + type: StateEventPtr + noCopy?: true + imports: '"events/event.h"' + - /.*room_event.yaml/: + type: RoomEventPtr + noCopy?: true + imports: '"events/event.h"' + - /.*event.yaml/: type: EventPtr + noCopy?: true imports: '"events/event.h"' - //: type: QJsonObject avoidCopy?: true imports: array: - - Notification: + - /^Notification|Result$/: type: "std::vector<{{1}}>" - avoidCopy?: true - imports: + noCopy?: true + imports: '"events/event.h"' + - /.+m\.room\.member/: + type: "EventsArray" + noCopy?: true + imports: '"events/roommemberevent.h"' + - /.+state_event.yaml/: + type: StateEvents + noCopy?: true + - /.+room_event.yaml/: + type: RoomEvents + noCopy?: true + - /.+event.yaml/: + type: Events + noCopy?: true - /.+/: type: "QVector<{{1}}>" avoidCopy?: true @@ -78,8 +103,9 @@ mustache: definitions: _scopeRenderer: "{{scopeCamelCase}}Job::" _literalQuote: '"' - maybeCrefType: "{{#avoidCopy?}}const {{/avoidCopy?}}{{dataType.name}}{{#avoidCopy?}}&{{/avoidCopy?}}" - qualifiedMaybeCrefType: "{{#avoidCopy?}}const {{/avoidCopy?}}{{dataType.qualifiedName}}{{#avoidCopy?}}&{{/avoidCopy?}}" + maybeCrefType: "{{#avoidCopy?}}const {{/avoidCopy?}}{{dataType.name}}{{#avoidCopy?}}&{{/avoidCopy?}}{{#noCopy?}}&&{{/noCopy?}}" + qualifiedMaybeCrefType: + "{{#avoidCopy?}}const {{/avoidCopy?}}{{dataType.qualifiedName}}{{#avoidCopy?}}&{{/avoidCopy?}}{{#noCopy?}}&&{{/noCopy?}}" initializeDefaultValue: "{{#defaultValue}}{{>initializer}}{{/defaultValue}}{{^defaultValue}}{}{{/defaultValue}}" joinedParamDecl: '{{>maybeCrefType}} {{paramName}}{{^required?}} = {{>initializeDefaultValue}}{{/required?}}{{#@join}}, {{/@join}}' joinedParamDef: '{{>maybeCrefType}} {{paramName}}{{#@join}}, {{/@join}}' diff --git a/lib/jobs/{{base}}.cpp.mustache b/lib/jobs/{{base}}.cpp.mustache index 1ca23799..d3726f1e 100644 --- a/lib/jobs/{{base}}.cpp.mustache +++ b/lib/jobs/{{base}}.cpp.mustache @@ -7,18 +7,15 @@ {{/producesNonJson?}}#include {{/operations}} using namespace QMatrixClient; -{{#models.model}}{{^trivial?}} -namespace QMatrixClient +{{#models.model}}{{#in?}} +QJsonObject QMatrixClient::toJson(const {{qualifiedName}}& pod) { - QJsonObject toJson(const {{qualifiedName}}& pod) - { - QJsonObject o; - {{#vars}}o.insert("{{baseName}}", toJson(pod.{{nameCamelCase}})); - {{/vars}} - return o; - } + QJsonObject o; +{{#vars}} o.insert("{{baseName}}", toJson(pod.{{nameCamelCase}})); +{{/vars}} + return o; } - +{{/in?}}{{#out?}} {{qualifiedName}} FromJson<{{qualifiedName}}>::operator()(const QJsonValue& jv) { const auto& o = jv.toObject(); @@ -28,33 +25,35 @@ namespace QMatrixClient {{/vars}} return result; } -{{/trivial?}}{{/models.model}}{{#operations}} +{{/out?}}{{/models.model}}{{#operations}} static const auto basePath = QStringLiteral("{{basePathWithoutHost}}"); -{{# operation}}{{#models.model}}{{^trivial?}} +{{# operation}}{{#models}} namespace QMatrixClient { + // Converters +{{#model}}{{#in?}} QJsonObject toJson(const {{qualifiedName}}& pod) { QJsonObject o; - {{#vars}}o.insert("{{baseName}}", toJson(pod.{{nameCamelCase}})); - {{/vars}} +{{#vars}} o.insert("{{baseName}}", toJson(pod.{{nameCamelCase}})); +{{/vars}} return o; } - +{{/in?}}{{#out?}} template <> struct FromJson<{{qualifiedName}}> { {{qualifiedName}} operator()(const QJsonValue& jv) { const auto& o = jv.toObject(); {{qualifiedName}} result; - {{#vars}}result.{{nameCamelCase}} = +{{#vars}} result.{{nameCamelCase}} = fromJson<{{dataType.qualifiedName}}>(o.value("{{baseName}}")); - {{/vars}} +{{/vars}} return result; } }; -} // namespace QMatrixClient -{{/ trivial?}}{{/models.model}}{{#responses}}{{#normalResponse?}}{{#allProperties?}} +{{/out?}}{{/model}}} // namespace QMatrixClient +{{/ models}}{{#responses}}{{#normalResponse?}}{{#allProperties?}} class {{camelCaseOperationId}}Job::Private { public:{{#allProperties}} @@ -99,9 +98,9 @@ QUrl {{camelCaseOperationId}}Job::makeRequestUrl(QUrl baseUrl{{#allParams?}}, {{ {{# responses}}{{#normalResponse?}}{{#allProperties?}} {{camelCaseOperationId}}Job::~{{camelCaseOperationId}}Job() = default; {{# allProperties}} -{{>qualifiedMaybeCrefType}} {{camelCaseOperationId}}Job::{{paramName}}() const +{{>qualifiedMaybeCrefType}} {{camelCaseOperationId}}Job::{{paramName}}(){{^noCopy?}} const{{/noCopy?}} { - return d->{{paramName}}; + return {{#noCopy?}}std::move({{/noCopy?}}d->{{paramName}}{{#noCopy?}}){{/noCopy?}}; } {{/ allProperties}}{{#producesNonJson?}} BaseJob::Status {{camelCaseOperationId}}Job::parseReply(QNetworkReply* reply) diff --git a/lib/jobs/{{base}}.h.mustache b/lib/jobs/{{base}}.h.mustache index f49945d4..ff9a7e7a 100644 --- a/lib/jobs/{{base}}.h.mustache +++ b/lib/jobs/{{base}}.h.mustache @@ -10,39 +10,33 @@ namespace QMatrixClient { {{#models}} // Data structures -{{# model}}{{#trivial?}} - using {{name}} = {{parent.name}}; -{{/ trivial?}}{{^trivial?}} +{{# model}} struct {{name}}{{#parents?}} : {{#parents}}{{name}}{{#@join}}, {{/@join}}{{/parents}}{{/parents?}} { - {{#vars}}{{dataType.name}} {{nameCamelCase}}; - {{/vars}}{{! -}} }; - +{{#vars}} {{dataType.name}} {{nameCamelCase}}; +{{/vars}} }; +{{#in?}} QJsonObject toJson(const {{name}}& pod); - +{{/in?}}{{#out?}} template <> struct FromJson<{{name}}> { {{name}} operator()(const QJsonValue& jv); }; -{{/ trivial?}}{{/model}} +{{/ out?}}{{/model}} {{/models}}{{#operations}} // Operations {{# operation}} class {{camelCaseOperationId}}Job : public BaseJob { - public:{{# models}} + public:{{#models}} // Inner data structures -{{# model}}{{#trivial?}} - using {{name}} = {{parent.name}}; -{{/ trivial?}}{{^trivial?}} +{{# model}} struct {{name}}{{#parents?}} : {{#parents}}{{name}}{{#@join}}, {{/@join}}{{/parents}}{{/parents?}} { - {{#vars}}{{dataType.name}} {{nameCamelCase}}; - {{/vars}} - }; -{{/ trivial?}}{{/model}} +{{#vars}} {{dataType.name}} {{nameCamelCase}}; +{{/vars}} }; +{{/ model}} // End of inner data structures -{{/models}}{{^bodyParams}} +{{/ models}}{{^bodyParams}} /** Construct a URL out of baseUrl and usual parameters passed to * {{camelCaseOperationId}}Job. This function can be used when * a URL for {{camelCaseOperationId}}Job is necessary but the job @@ -54,7 +48,7 @@ namespace QMatrixClient }}{{# responses}}{{#normalResponse?}}{{#allProperties?}} ~{{camelCaseOperationId}}Job() override; {{#allProperties}} - {{>maybeCrefType}} {{paramName}}() const;{{/allProperties}} + {{>maybeCrefType}} {{paramName}}(){{^noCopy?}} const{{/noCopy?}};{{/allProperties}} protected: Status {{#producesNonJson?}}parseReply(QNetworkReply* reply){{/producesNonJson?}}{{^producesNonJson?}}parseJson(const QJsonDocument& data){{/producesNonJson?}} override; -- cgit v1.2.3 From 564d518c086f2aeab0f0466b7cd1915e20edc7da Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 3 May 2018 21:23:28 +0900 Subject: GetRoomEventsJob (replaces RoomMessagesJob) + refactoring 1. Updates in this commit (see further) allow to generate and build GetRoomEventsJob from message_pagination.yaml; this job completely preempts RoomMessagesJob. 2. EventsBatch<> is no more a thing; there's EventsArray<> to replace it but it's loaded from a JSON array rather than an event batch (a JSON array inside another JSON object). SyncJob that used it extensively has been moved to "conventional" containers (Events, RoomEvents and the newly introduced StateEvents). RoomMessagesJob that also used EventsBatch<> is decommissioned (see above). 3. RoomEventsRange is now an alias for Range, defined in util.h (otherwise almost the same). 4. Connection::getMessages() is no more. Use Room::getPreviousContent() and Connection::callApi() instead. 5. Moving things around in Room, since SyncJob now supplies state events in more specific StateEvents, rather than RoomEvents. --- lib/jobs/generated/message_pagination.cpp | 76 +++++++++++++++++++++++++++++++ lib/jobs/generated/message_pagination.h | 40 ++++++++++++++++ lib/jobs/roommessagesjob.cpp | 65 -------------------------- lib/jobs/roommessagesjob.h | 47 ------------------- lib/jobs/syncjob.cpp | 43 +++++++++-------- lib/jobs/syncjob.h | 27 +++-------- 6 files changed, 143 insertions(+), 155 deletions(-) create mode 100644 lib/jobs/generated/message_pagination.cpp create mode 100644 lib/jobs/generated/message_pagination.h delete mode 100644 lib/jobs/roommessagesjob.cpp delete mode 100644 lib/jobs/roommessagesjob.h (limited to 'lib/jobs') diff --git a/lib/jobs/generated/message_pagination.cpp b/lib/jobs/generated/message_pagination.cpp new file mode 100644 index 00000000..f89ccd03 --- /dev/null +++ b/lib/jobs/generated/message_pagination.cpp @@ -0,0 +1,76 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "message_pagination.h" + +#include "converters.h" + +#include + +using namespace QMatrixClient; + +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, int limit, const QString& filter) +{ + BaseJob::Query _q; + _q.addQueryItem("from", from); + if (!to.isEmpty()) + _q.addQueryItem("to", to); + _q.addQueryItem("dir", dir); + _q.addQueryItem("limit", QString("%1").arg(limit)); + if (!filter.isEmpty()) + _q.addQueryItem("filter", filter); + return _q; +} + +QUrl GetRoomEventsJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& from, const QString& dir, const QString& to, int limit, const QString& filter) +{ + return BaseJob::makeRequestUrl(std::move(baseUrl), + basePath % "/rooms/" % roomId % "/messages", + queryToGetRoomEvents(from, to, dir, limit, filter)); +} + +GetRoomEventsJob::GetRoomEventsJob(const QString& roomId, const QString& from, const QString& dir, const QString& to, int limit, const QString& filter) + : BaseJob(HttpVerb::Get, "GetRoomEventsJob", + basePath % "/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(); + d->begin = fromJson(json.value("start")); + d->end = fromJson(json.value("end")); + d->chunk = fromJson(json.value("chunk")); + return Success; +} + diff --git a/lib/jobs/generated/message_pagination.h b/lib/jobs/generated/message_pagination.h new file mode 100644 index 00000000..b8588ad1 --- /dev/null +++ b/lib/jobs/generated/message_pagination.h @@ -0,0 +1,40 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "../basejob.h" + +#include "events/event.h" + + +namespace QMatrixClient +{ + // Operations + + class GetRoomEventsJob : public BaseJob + { + public: + /** Construct a URL out of baseUrl and usual parameters passed to + * GetRoomEventsJob. 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 = {}, int limit = {}, const QString& filter = {}); + + explicit GetRoomEventsJob(const QString& roomId, const QString& from, const QString& dir, const QString& to = {}, int limit = {}, const QString& filter = {}); + ~GetRoomEventsJob() override; + + const QString& begin() const; + const QString& end() const; + RoomEvents&& chunk(); + + protected: + Status parseJson(const QJsonDocument& data) override; + + private: + class Private; + QScopedPointer d; + }; +} // namespace QMatrixClient diff --git a/lib/jobs/roommessagesjob.cpp b/lib/jobs/roommessagesjob.cpp deleted file mode 100644 index e5568f17..00000000 --- a/lib/jobs/roommessagesjob.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2016 Felix Rohrbach - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "roommessagesjob.h" - -using namespace QMatrixClient; - -class RoomMessagesJob::Private -{ - public: - RoomEvents events; - QString end; -}; - -RoomMessagesJob::RoomMessagesJob(const QString& roomId, const QString& from, - int limit, FetchDirection dir) - : BaseJob(HttpVerb::Get, "RoomMessagesJob", - QStringLiteral("/_matrix/client/r0/rooms/%1/messages").arg(roomId), - Query( - { { "from", from } - , { "dir", dir == FetchDirection::Backward ? "b" : "f" } - , { "limit", QString::number(limit) } - })) - , d(new Private) -{ - qCDebug(JOBS) << "Room messages query:" << query().toString(QUrl::PrettyDecoded); -} - -RoomMessagesJob::~RoomMessagesJob() -{ - delete d; -} - -RoomEvents&& RoomMessagesJob::releaseEvents() -{ - return move(d->events); -} - -QString RoomMessagesJob::end() const -{ - return d->end; -} - -BaseJob::Status RoomMessagesJob::parseJson(const QJsonDocument& data) -{ - const auto obj = data.object(); - d->events.fromJson(obj, "chunk"); - d->end = obj.value("end").toString(); - return Success; -} diff --git a/lib/jobs/roommessagesjob.h b/lib/jobs/roommessagesjob.h deleted file mode 100644 index 7b3fd9c9..00000000 --- a/lib/jobs/roommessagesjob.h +++ /dev/null @@ -1,47 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2016 Felix Rohrbach - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#pragma once - -#include "basejob.h" - -#include "../events/event.h" - -namespace QMatrixClient -{ - enum class FetchDirection { Backward, Forward }; - - class RoomMessagesJob: public BaseJob - { - public: - RoomMessagesJob(const QString& roomId, const QString& from, - int limit = 10, - FetchDirection dir = FetchDirection::Backward); - virtual ~RoomMessagesJob(); - - RoomEvents&& releaseEvents(); - QString end() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - Private* d; - }; -} // namespace QMatrixClient diff --git a/lib/jobs/syncjob.cpp b/lib/jobs/syncjob.cpp index 435dfd0e..a739ea0d 100644 --- a/lib/jobs/syncjob.cpp +++ b/lib/jobs/syncjob.cpp @@ -54,11 +54,17 @@ SyncDataList&& SyncData::takeRoomData() return std::move(roomData); } -SyncBatch&& SyncData::takeAccountData() +Events&& SyncData::takeAccountData() { return std::move(accountData); } +template +inline EventsArrayT load(const QJsonObject& batches, StrT keyName) +{ + return fromJson(batches[keyName].toObject().value("events")); +} + BaseJob::Status SyncJob::parseJson(const QJsonDocument& data) { return d.parseJson(data); @@ -71,7 +77,7 @@ BaseJob::Status SyncData::parseJson(const QJsonDocument &data) auto json = data.object(); nextBatch_ = json.value("next_batch").toString(); // TODO: presence - accountData.fromJson(json); + accountData = load(json, "account_data"); QJsonObject rooms = json.value("rooms").toObject(); JoinStates::Int ii = 1; // ii is used to make a JoinState value @@ -96,33 +102,26 @@ SyncRoomData::SyncRoomData(const QString& roomId_, JoinState joinState_, const QJsonObject& room_) : roomId(roomId_) , joinState(joinState_) - , state(joinState == JoinState::Invite ? "invite_state" : "state") - , timeline("timeline") - , ephemeral("ephemeral") - , accountData("account_data") + , state(load(room_, + joinState == JoinState::Invite ? "invite_state" : "state")) { switch (joinState) { - case JoinState::Invite: - state.fromJson(room_); - break; case JoinState::Join: - state.fromJson(room_); - timeline.fromJson(room_); - ephemeral.fromJson(room_); - accountData.fromJson(room_); - break; + ephemeral = load(room_, "ephemeral"); + accountData = load(room_, "account_data"); + // [[fallthrough]] case JoinState::Leave: - state.fromJson(room_); - timeline.fromJson(room_); + { + timeline = load(room_, "timeline"); + auto timelineJson = room_.value("timeline").toObject(); + timelineLimited = timelineJson.value("limited").toBool(); + timelinePrevBatch = timelineJson.value("prev_batch").toString(); + break; - default: - qCWarning(SYNCJOB) << "SyncRoomData: Unknown JoinState value, ignoring:" << int(joinState); + } + default: /* nothing on top of state */; } - auto timelineJson = room_.value("timeline").toObject(); - timelineLimited = timelineJson.value("limited").toBool(); - timelinePrevBatch = timelineJson.value("prev_batch").toString(); - auto unreadJson = room_.value("unread_notifications").toObject(); unreadCount = unreadJson.value(UnreadCountKey).toInt(-2); highlightCount = unreadJson.value("highlight_count").toInt(); diff --git a/lib/jobs/syncjob.h b/lib/jobs/syncjob.h index 919060be..b12f9fff 100644 --- a/lib/jobs/syncjob.h +++ b/lib/jobs/syncjob.h @@ -26,30 +26,15 @@ namespace QMatrixClient { - template - class SyncBatch : public EventsBatch - { - public: - explicit SyncBatch(QString k) : jsonKey(std::move(k)) { } - void fromJson(const QJsonObject& roomContents) - { - EventsBatch::fromJson( - roomContents[jsonKey].toObject(), "events"); - } - - private: - QString jsonKey; - }; - class SyncRoomData { public: QString roomId; JoinState joinState; - SyncBatch state; - SyncBatch timeline; - SyncBatch ephemeral; - SyncBatch accountData; + StateEvents state; + RoomEvents timeline; + Events ephemeral; + Events accountData; bool timelineLimited; QString timelinePrevBatch; @@ -71,13 +56,13 @@ namespace QMatrixClient { public: BaseJob::Status parseJson(const QJsonDocument &data); - SyncBatch&& takeAccountData(); + Events&& takeAccountData(); SyncDataList&& takeRoomData(); QString nextBatch() const; private: QString nextBatch_; - SyncBatch accountData { "account_data" }; + Events accountData; SyncDataList roomData; }; -- cgit v1.2.3 From f3927ca0c16a61fcb0933333ecff8095917a5b47 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 3 May 2018 20:10:14 +0900 Subject: jobs/generated: Drop unused code --- lib/jobs/generated/administrative_contact.cpp | 32 +++------------- lib/jobs/generated/administrative_contact.h | 2 - lib/jobs/generated/create_room.cpp | 43 ++------------------- lib/jobs/generated/create_room.h | 2 - lib/jobs/generated/list_public_rooms.cpp | 54 +++------------------------ lib/jobs/generated/list_public_rooms.h | 3 -- lib/jobs/generated/notifications.cpp | 8 ++-- lib/jobs/generated/notifications.h | 4 +- lib/jobs/generated/pusher.cpp | 47 +++-------------------- lib/jobs/generated/pusher.h | 3 -- lib/jobs/generated/users.cpp | 12 +----- lib/jobs/generated/users.h | 1 - 12 files changed, 28 insertions(+), 183 deletions(-) (limited to 'lib/jobs') diff --git a/lib/jobs/generated/administrative_contact.cpp b/lib/jobs/generated/administrative_contact.cpp index b003c92d..ec7c77c3 100644 --- a/lib/jobs/generated/administrative_contact.cpp +++ b/lib/jobs/generated/administrative_contact.cpp @@ -12,14 +12,7 @@ static const auto basePath = QStringLiteral("/_matrix/client/r0"); namespace QMatrixClient { - QJsonObject toJson(const GetAccount3PIDsJob::ThirdPartyIdentifier& pod) - { - QJsonObject o; - o.insert("medium", toJson(pod.medium)); - o.insert("address", toJson(pod.address)); - - return o; - } + // Converters template <> struct FromJson { @@ -31,7 +24,7 @@ namespace QMatrixClient fromJson(o.value("medium")); result.address = fromJson(o.value("address")); - + return result; } }; @@ -72,32 +65,17 @@ BaseJob::Status GetAccount3PIDsJob::parseJson(const QJsonDocument& data) namespace QMatrixClient { + // Converters + QJsonObject toJson(const Post3PIDsJob::ThreePidCredentials& pod) { QJsonObject o; o.insert("client_secret", toJson(pod.clientSecret)); o.insert("id_server", toJson(pod.idServer)); o.insert("sid", toJson(pod.sid)); - + return o; } - - template <> struct FromJson - { - Post3PIDsJob::ThreePidCredentials operator()(const QJsonValue& jv) - { - const auto& o = jv.toObject(); - Post3PIDsJob::ThreePidCredentials result; - result.clientSecret = - fromJson(o.value("client_secret")); - result.idServer = - fromJson(o.value("id_server")); - result.sid = - fromJson(o.value("sid")); - - return result; - } - }; } // namespace QMatrixClient Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds, bool bind) diff --git a/lib/jobs/generated/administrative_contact.h b/lib/jobs/generated/administrative_contact.h index bd70f07b..9cb09a3c 100644 --- a/lib/jobs/generated/administrative_contact.h +++ b/lib/jobs/generated/administrative_contact.h @@ -23,7 +23,6 @@ namespace QMatrixClient { QString medium; QString address; - }; // End of inner data structures @@ -58,7 +57,6 @@ namespace QMatrixClient QString clientSecret; QString idServer; QString sid; - }; // End of inner data structures diff --git a/lib/jobs/generated/create_room.cpp b/lib/jobs/generated/create_room.cpp index 4fc75974..a417c2b1 100644 --- a/lib/jobs/generated/create_room.cpp +++ b/lib/jobs/generated/create_room.cpp @@ -12,62 +12,27 @@ static const auto basePath = QStringLiteral("/_matrix/client/r0"); namespace QMatrixClient { + // Converters + QJsonObject toJson(const CreateRoomJob::Invite3pid& pod) { QJsonObject o; o.insert("id_server", toJson(pod.idServer)); o.insert("medium", toJson(pod.medium)); o.insert("address", toJson(pod.address)); - + return o; } - template <> struct FromJson - { - CreateRoomJob::Invite3pid operator()(const QJsonValue& jv) - { - const auto& o = jv.toObject(); - CreateRoomJob::Invite3pid result; - result.idServer = - fromJson(o.value("id_server")); - result.medium = - fromJson(o.value("medium")); - result.address = - fromJson(o.value("address")); - - return result; - } - }; -} // namespace QMatrixClient - -namespace QMatrixClient -{ QJsonObject toJson(const CreateRoomJob::StateEvent& pod) { QJsonObject o; o.insert("type", toJson(pod.type)); o.insert("state_key", toJson(pod.stateKey)); o.insert("content", toJson(pod.content)); - + return o; } - - template <> struct FromJson - { - CreateRoomJob::StateEvent operator()(const QJsonValue& jv) - { - const auto& o = jv.toObject(); - CreateRoomJob::StateEvent result; - result.type = - fromJson(o.value("type")); - result.stateKey = - fromJson(o.value("state_key")); - result.content = - fromJson(o.value("content")); - - return result; - } - }; } // namespace QMatrixClient class CreateRoomJob::Private diff --git a/lib/jobs/generated/create_room.h b/lib/jobs/generated/create_room.h index fdb11ada..526463b0 100644 --- a/lib/jobs/generated/create_room.h +++ b/lib/jobs/generated/create_room.h @@ -25,7 +25,6 @@ namespace QMatrixClient QString idServer; QString medium; QString address; - }; struct StateEvent @@ -33,7 +32,6 @@ namespace QMatrixClient QString type; QString stateKey; QJsonObject content; - }; // End of inner data structures diff --git a/lib/jobs/generated/list_public_rooms.cpp b/lib/jobs/generated/list_public_rooms.cpp index 9b4174cb..03664def 100644 --- a/lib/jobs/generated/list_public_rooms.cpp +++ b/lib/jobs/generated/list_public_rooms.cpp @@ -55,21 +55,7 @@ SetRoomVisibilityOnDirectoryJob::SetRoomVisibilityOnDirectoryJob(const QString& namespace QMatrixClient { - QJsonObject toJson(const GetPublicRoomsJob::PublicRoomsChunk& pod) - { - QJsonObject o; - o.insert("aliases", toJson(pod.aliases)); - o.insert("canonical_alias", toJson(pod.canonicalAlias)); - o.insert("name", toJson(pod.name)); - o.insert("num_joined_members", toJson(pod.numJoinedMembers)); - o.insert("room_id", toJson(pod.roomId)); - o.insert("topic", toJson(pod.topic)); - o.insert("world_readable", toJson(pod.worldReadable)); - o.insert("guest_can_join", toJson(pod.guestCanJoin)); - o.insert("avatar_url", toJson(pod.avatarUrl)); - - return o; - } + // Converters template <> struct FromJson { @@ -95,7 +81,7 @@ namespace QMatrixClient fromJson(o.value("guest_can_join")); result.avatarUrl = fromJson(o.value("avatar_url")); - + return result; } }; @@ -174,43 +160,13 @@ BaseJob::Status GetPublicRoomsJob::parseJson(const QJsonDocument& data) namespace QMatrixClient { + // Converters + QJsonObject toJson(const QueryPublicRoomsJob::Filter& pod) { QJsonObject o; o.insert("generic_search_term", toJson(pod.genericSearchTerm)); - - return o; - } - template <> struct FromJson - { - QueryPublicRoomsJob::Filter operator()(const QJsonValue& jv) - { - const auto& o = jv.toObject(); - QueryPublicRoomsJob::Filter result; - result.genericSearchTerm = - fromJson(o.value("generic_search_term")); - - return result; - } - }; -} // namespace QMatrixClient - -namespace QMatrixClient -{ - QJsonObject toJson(const QueryPublicRoomsJob::PublicRoomsChunk& pod) - { - QJsonObject o; - o.insert("aliases", toJson(pod.aliases)); - o.insert("canonical_alias", toJson(pod.canonicalAlias)); - o.insert("name", toJson(pod.name)); - o.insert("num_joined_members", toJson(pod.numJoinedMembers)); - o.insert("room_id", toJson(pod.roomId)); - o.insert("topic", toJson(pod.topic)); - o.insert("world_readable", toJson(pod.worldReadable)); - o.insert("guest_can_join", toJson(pod.guestCanJoin)); - o.insert("avatar_url", toJson(pod.avatarUrl)); - return o; } @@ -238,7 +194,7 @@ namespace QMatrixClient fromJson(o.value("guest_can_join")); result.avatarUrl = fromJson(o.value("avatar_url")); - + return result; } }; diff --git a/lib/jobs/generated/list_public_rooms.h b/lib/jobs/generated/list_public_rooms.h index 1e44e8b2..8e8fddca 100644 --- a/lib/jobs/generated/list_public_rooms.h +++ b/lib/jobs/generated/list_public_rooms.h @@ -59,7 +59,6 @@ namespace QMatrixClient bool worldReadable; bool guestCanJoin; QString avatarUrl; - }; // End of inner data structures @@ -95,7 +94,6 @@ namespace QMatrixClient struct Filter { QString genericSearchTerm; - }; struct PublicRoomsChunk @@ -109,7 +107,6 @@ namespace QMatrixClient bool worldReadable; bool guestCanJoin; QString avatarUrl; - }; // End of inner data structures diff --git a/lib/jobs/generated/notifications.cpp b/lib/jobs/generated/notifications.cpp index df6b10ba..04ad0175 100644 --- a/lib/jobs/generated/notifications.cpp +++ b/lib/jobs/generated/notifications.cpp @@ -12,6 +12,8 @@ static const auto basePath = QStringLiteral("/_matrix/client/r0"); namespace QMatrixClient { + // Converters + template <> struct FromJson { GetNotificationsJob::Notification operator()(const QJsonValue& jv) @@ -30,7 +32,7 @@ namespace QMatrixClient fromJson(o.value("room_id")); result.ts = fromJson(o.value("ts")); - + return result; } }; @@ -76,9 +78,9 @@ const QString& GetNotificationsJob::nextToken() const return d->nextToken; } -const std::vector& GetNotificationsJob::notifications() const +std::vector&& GetNotificationsJob::notifications() { - return d->notifications; + return std::move(d->notifications); } BaseJob::Status GetNotificationsJob::parseJson(const QJsonDocument& data) diff --git a/lib/jobs/generated/notifications.h b/lib/jobs/generated/notifications.h index 798b9576..d66e15be 100644 --- a/lib/jobs/generated/notifications.h +++ b/lib/jobs/generated/notifications.h @@ -6,7 +6,6 @@ #include "../basejob.h" -#include #include "events/event.h" #include #include @@ -30,7 +29,6 @@ namespace QMatrixClient bool read; QString roomId; qint64 ts; - }; // End of inner data structures @@ -46,7 +44,7 @@ namespace QMatrixClient ~GetNotificationsJob() override; const QString& nextToken() const; - const std::vector& notifications() const; + std::vector&& notifications(); protected: Status parseJson(const QJsonDocument& data) override; diff --git a/lib/jobs/generated/pusher.cpp b/lib/jobs/generated/pusher.cpp index 7d5e80d1..dea7cf8b 100644 --- a/lib/jobs/generated/pusher.cpp +++ b/lib/jobs/generated/pusher.cpp @@ -12,13 +12,7 @@ static const auto basePath = QStringLiteral("/_matrix/client/r0"); namespace QMatrixClient { - QJsonObject toJson(const GetPushersJob::PusherData& pod) - { - QJsonObject o; - o.insert("url", toJson(pod.url)); - - return o; - } + // Converters template <> struct FromJson { @@ -28,28 +22,10 @@ namespace QMatrixClient GetPushersJob::PusherData result; result.url = fromJson(o.value("url")); - + return result; } }; -} // namespace QMatrixClient - -namespace QMatrixClient -{ - QJsonObject toJson(const GetPushersJob::Pusher& pod) - { - QJsonObject o; - o.insert("pushkey", toJson(pod.pushkey)); - o.insert("kind", toJson(pod.kind)); - o.insert("app_id", toJson(pod.appId)); - o.insert("app_display_name", toJson(pod.appDisplayName)); - o.insert("device_display_name", toJson(pod.deviceDisplayName)); - o.insert("profile_tag", toJson(pod.profileTag)); - o.insert("lang", toJson(pod.lang)); - o.insert("data", toJson(pod.data)); - - return o; - } template <> struct FromJson { @@ -73,7 +49,7 @@ namespace QMatrixClient fromJson(o.value("lang")); result.data = fromJson(o.value("data")); - + return result; } }; @@ -114,26 +90,15 @@ BaseJob::Status GetPushersJob::parseJson(const QJsonDocument& data) namespace QMatrixClient { + // Converters + QJsonObject toJson(const PostPusherJob::PusherData& pod) { QJsonObject o; o.insert("url", toJson(pod.url)); - + return o; } - - template <> struct FromJson - { - PostPusherJob::PusherData operator()(const QJsonValue& jv) - { - const auto& o = jv.toObject(); - PostPusherJob::PusherData result; - result.url = - fromJson(o.value("url")); - - return result; - } - }; } // namespace QMatrixClient 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, bool append) diff --git a/lib/jobs/generated/pusher.h b/lib/jobs/generated/pusher.h index 23cd3fb6..06a2c832 100644 --- a/lib/jobs/generated/pusher.h +++ b/lib/jobs/generated/pusher.h @@ -22,7 +22,6 @@ namespace QMatrixClient struct PusherData { QString url; - }; struct Pusher @@ -35,7 +34,6 @@ namespace QMatrixClient QString profileTag; QString lang; PusherData data; - }; // End of inner data structures @@ -68,7 +66,6 @@ namespace QMatrixClient struct PusherData { QString url; - }; // End of inner data structures diff --git a/lib/jobs/generated/users.cpp b/lib/jobs/generated/users.cpp index f82a2a64..fd2944e4 100644 --- a/lib/jobs/generated/users.cpp +++ b/lib/jobs/generated/users.cpp @@ -12,15 +12,7 @@ static const auto basePath = QStringLiteral("/_matrix/client/r0"); namespace QMatrixClient { - QJsonObject toJson(const SearchUserDirectoryJob::User& pod) - { - QJsonObject o; - o.insert("user_id", toJson(pod.userId)); - o.insert("display_name", toJson(pod.displayName)); - o.insert("avatar_url", toJson(pod.avatarUrl)); - - return o; - } + // Converters template <> struct FromJson { @@ -34,7 +26,7 @@ namespace QMatrixClient fromJson(o.value("display_name")); result.avatarUrl = fromJson(o.value("avatar_url")); - + return result; } }; diff --git a/lib/jobs/generated/users.h b/lib/jobs/generated/users.h index bfa688c8..50b8b648 100644 --- a/lib/jobs/generated/users.h +++ b/lib/jobs/generated/users.h @@ -24,7 +24,6 @@ namespace QMatrixClient QString userId; QString displayName; QString avatarUrl; - }; // End of inner data structures -- cgit v1.2.3 From a5b6d786878ab5c67a7b436ba475e8ac4d22f1f0 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 3 May 2018 22:41:12 +0900 Subject: Preempt jobs/joinroomjob.* with jobs/generated/joining.* Enables responding to third-party invites. --- lib/jobs/generated/joining.cpp | 118 +++++++++++++++++++++++++++++++++++++++++ lib/jobs/generated/joining.h | 77 +++++++++++++++++++++++++++ lib/jobs/joinroomjob.cpp | 58 -------------------- lib/jobs/joinroomjob.h | 40 -------------- 4 files changed, 195 insertions(+), 98 deletions(-) create mode 100644 lib/jobs/generated/joining.cpp create mode 100644 lib/jobs/generated/joining.h delete mode 100644 lib/jobs/joinroomjob.cpp delete mode 100644 lib/jobs/joinroomjob.h (limited to 'lib/jobs') diff --git a/lib/jobs/generated/joining.cpp b/lib/jobs/generated/joining.cpp new file mode 100644 index 00000000..705e8f83 --- /dev/null +++ b/lib/jobs/generated/joining.cpp @@ -0,0 +1,118 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "joining.h" + +#include + +using namespace QMatrixClient; + +static const auto basePath = QStringLiteral("/_matrix/client/r0"); + +namespace QMatrixClient +{ + // Converters + + QJsonObject toJson(const JoinRoomByIdJob::ThirdPartySigned& pod) + { + QJsonObject o; + o.insert("sender", toJson(pod.sender)); + o.insert("mxid", toJson(pod.mxid)); + o.insert("token", toJson(pod.token)); + o.insert("signatures", toJson(pod.signatures)); + + return o; + } +} // namespace QMatrixClient + +class JoinRoomByIdJob::Private +{ + public: + QString roomId; +}; + +JoinRoomByIdJob::JoinRoomByIdJob(const QString& roomId, const ThirdPartySigned& thirdPartySigned) + : BaseJob(HttpVerb::Post, "JoinRoomByIdJob", + basePath % "/rooms/" % roomId % "/join") + , d(new Private) +{ + QJsonObject _data; + _data.insert("third_party_signed", toJson(thirdPartySigned)); + setRequestData(_data); +} + +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")) + return { JsonParseError, + "The key 'room_id' not found in the response" }; + d->roomId = fromJson(json.value("room_id")); + return Success; +} + +namespace QMatrixClient +{ + // Converters + + QJsonObject toJson(const JoinRoomJob::Signed& pod) + { + QJsonObject o; + o.insert("sender", toJson(pod.sender)); + o.insert("mxid", toJson(pod.mxid)); + o.insert("token", toJson(pod.token)); + o.insert("signatures", toJson(pod.signatures)); + + return o; + } + + QJsonObject toJson(const JoinRoomJob::ThirdPartySigned& pod) + { + QJsonObject o; + o.insert("signed", toJson(pod.signedData)); + + return o; + } +} // namespace QMatrixClient + +class JoinRoomJob::Private +{ + public: + QString roomId; +}; + +JoinRoomJob::JoinRoomJob(const QString& roomIdOrAlias, const ThirdPartySigned& thirdPartySigned) + : BaseJob(HttpVerb::Post, "JoinRoomJob", + basePath % "/join/" % roomIdOrAlias) + , d(new Private) +{ + QJsonObject _data; + _data.insert("third_party_signed", toJson(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")) + return { JsonParseError, + "The key 'room_id' not found in the response" }; + d->roomId = fromJson(json.value("room_id")); + return Success; +} + diff --git a/lib/jobs/generated/joining.h b/lib/jobs/generated/joining.h new file mode 100644 index 00000000..76edb339 --- /dev/null +++ b/lib/jobs/generated/joining.h @@ -0,0 +1,77 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "../basejob.h" + +#include + +#include "converters.h" + +namespace QMatrixClient +{ + // Operations + + class JoinRoomByIdJob : public BaseJob + { + public: + // Inner data structures + + struct ThirdPartySigned + { + QString sender; + QString mxid; + QString token; + QJsonObject signatures; + }; + + // End of inner data structures + + explicit JoinRoomByIdJob(const QString& roomId, const ThirdPartySigned& thirdPartySigned = {}); + ~JoinRoomByIdJob() override; + + const QString& roomId() const; + + protected: + Status parseJson(const QJsonDocument& data) override; + + private: + class Private; + QScopedPointer d; + }; + + class JoinRoomJob : public BaseJob + { + public: + // Inner data structures + + struct Signed + { + QString sender; + QString mxid; + QString token; + QJsonObject signatures; + }; + + struct ThirdPartySigned + { + Signed signedData; + }; + + // End of inner data structures + + explicit JoinRoomJob(const QString& roomIdOrAlias, const ThirdPartySigned& thirdPartySigned = {}); + ~JoinRoomJob() override; + + const QString& roomId() const; + + protected: + Status parseJson(const QJsonDocument& data) override; + + private: + class Private; + QScopedPointer d; + }; +} // namespace QMatrixClient diff --git a/lib/jobs/joinroomjob.cpp b/lib/jobs/joinroomjob.cpp deleted file mode 100644 index 66a75089..00000000 --- a/lib/jobs/joinroomjob.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2015 Felix Rohrbach - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "joinroomjob.h" -#include "util.h" - -using namespace QMatrixClient; - -class JoinRoomJob::Private -{ - public: - QString roomId; -}; - -JoinRoomJob::JoinRoomJob(const QString& roomAlias) - : BaseJob(HttpVerb::Post, "JoinRoomJob", - QStringLiteral("_matrix/client/r0/join/%1").arg(roomAlias)) - , d(new Private) -{ -} - -JoinRoomJob::~JoinRoomJob() -{ - delete d; -} - -QString JoinRoomJob::roomId() -{ - return d->roomId; -} - -BaseJob::Status JoinRoomJob::parseJson(const QJsonDocument& data) -{ - QJsonObject json = data.object(); - if( json.contains("room_id") ) - { - d->roomId = json.value("room_id").toString(); - return Success; - } - - qCDebug(JOBS) << data; - return { UserDefinedError, "No room_id in the JSON response" }; -} diff --git a/lib/jobs/joinroomjob.h b/lib/jobs/joinroomjob.h deleted file mode 100644 index f3ba216f..00000000 --- a/lib/jobs/joinroomjob.h +++ /dev/null @@ -1,40 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2015 Felix Rohrbach - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#pragma once - -#include "basejob.h" - -namespace QMatrixClient -{ - class JoinRoomJob: public BaseJob - { - public: - explicit JoinRoomJob(const QString& roomAlias); - virtual ~JoinRoomJob(); - - QString roomId(); - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - Private* d; - }; -} // namespace QMatrixClient -- cgit v1.2.3 From 90868cac42ab8ad69cb3f3a29949e0815cc5a7ce Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 3 May 2018 23:15:06 +0900 Subject: gtad.yaml: Update regexes to match string parts According to KitsuneRal/gtad#31. --- lib/jobs/gtad.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib/jobs') diff --git a/lib/jobs/gtad.yaml b/lib/jobs/gtad.yaml index 4ef55bce..89862da2 100644 --- a/lib/jobs/gtad.yaml +++ b/lib/jobs/gtad.yaml @@ -52,17 +52,17 @@ analyzer: avoidCopy?: true file: *ByteStream object: - - /.+m\.room\.member/: # A stub for EventsBatch + - /m\.room\.member$/: # A stub for EventsBatch type: none - - /.+state_event.yaml/: + - /state_event.yaml$/: type: StateEventPtr noCopy?: true imports: '"events/event.h"' - - /.*room_event.yaml/: + - /room_event.yaml$/: type: RoomEventPtr noCopy?: true imports: '"events/event.h"' - - /.*event.yaml/: + - /event.yaml$/: type: EventPtr noCopy?: true imports: '"events/event.h"' @@ -75,17 +75,17 @@ analyzer: type: "std::vector<{{1}}>" noCopy?: true imports: '"events/event.h"' - - /.+m\.room\.member/: + - /m\.room\.member$/: type: "EventsArray" noCopy?: true imports: '"events/roommemberevent.h"' - - /.+state_event.yaml/: + - /state_event.yaml$/: type: StateEvents noCopy?: true - - /.+room_event.yaml/: + - /room_event.yaml$/: type: RoomEvents noCopy?: true - - /.+event.yaml/: + - /event.yaml$/: type: Events noCopy?: true - /.+/: -- cgit v1.2.3 From 28a0d70164e2596d306521cd18d25c0e8c0b5336 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 4 May 2018 12:13:43 +0900 Subject: EvT::TypeId: Use a member function instead of a variable The latter one causes linkage errors when used from a template method (but not from a template class, puzzlingly). --- lib/jobs/sendeventjob.h | 2 +- lib/jobs/setroomstatejob.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/jobs') diff --git a/lib/jobs/sendeventjob.h b/lib/jobs/sendeventjob.h index 3a11eb6a..a3e9a291 100644 --- a/lib/jobs/sendeventjob.h +++ b/lib/jobs/sendeventjob.h @@ -32,7 +32,7 @@ namespace QMatrixClient SendEventJob(const QString& roomId, const EvT& event) : BaseJob(HttpVerb::Put, QStringLiteral("SendEventJob"), QStringLiteral("_matrix/client/r0/rooms/%1/send/%2/") - .arg(roomId, EvT::TypeId), // See also beforeStart() + .arg(roomId, EvT::typeId()), // See also beforeStart() Query(), Data(event.toJson())) { } diff --git a/lib/jobs/setroomstatejob.h b/lib/jobs/setroomstatejob.h index b7e6d4a1..36047667 100644 --- a/lib/jobs/setroomstatejob.h +++ b/lib/jobs/setroomstatejob.h @@ -36,7 +36,7 @@ namespace QMatrixClient const EvT& event) : BaseJob(HttpVerb::Put, "SetRoomStateJob", QStringLiteral("_matrix/client/r0/rooms/%1/state/%2/%3") - .arg(roomId, EvT::TypeId, stateKey), + .arg(roomId, EvT::typeId(), stateKey), Query(), Data(event.toJson())) { } @@ -48,7 +48,7 @@ namespace QMatrixClient SetRoomStateJob(const QString& roomId, const EvT& event) : BaseJob(HttpVerb::Put, "SetRoomStateJob", QStringLiteral("_matrix/client/r0/rooms/%1/state/%2") - .arg(roomId, EvT::TypeId), + .arg(roomId, EvT::typeId()), Query(), Data(event.toJson())) { } -- cgit v1.2.3 From 4cbe1a5fe9b0ae17e89425c3127db2af9b328320 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 4 May 2018 12:12:07 +0900 Subject: Preempt job/setroomstatejob.* with jobs/generated/room_state.* The template part (not exposed in the auto-generated class) goes to Room::Private::requestSetState(). Also, Room::setMemberState() to interface with User class. --- lib/jobs/generated/room_state.cpp | 70 +++++++++++++++++++++++++++++++++++++++ lib/jobs/generated/room_state.h | 47 ++++++++++++++++++++++++++ lib/jobs/setroomstatejob.cpp | 32 ------------------ lib/jobs/setroomstatejob.h | 64 ----------------------------------- 4 files changed, 117 insertions(+), 96 deletions(-) create mode 100644 lib/jobs/generated/room_state.cpp create mode 100644 lib/jobs/generated/room_state.h delete mode 100644 lib/jobs/setroomstatejob.cpp delete mode 100644 lib/jobs/setroomstatejob.h (limited to 'lib/jobs') diff --git a/lib/jobs/generated/room_state.cpp b/lib/jobs/generated/room_state.cpp new file mode 100644 index 00000000..39f36afb --- /dev/null +++ b/lib/jobs/generated/room_state.cpp @@ -0,0 +1,70 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "room_state.h" + +#include "converters.h" + +#include + +using namespace QMatrixClient; + +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, "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(); + d->eventId = fromJson(json.value("event_id")); + return Success; +} + +class SetRoomStateJob::Private +{ + public: + QString eventId; +}; + +SetRoomStateJob::SetRoomStateJob(const QString& roomId, const QString& eventType, const QJsonObject& body) + : BaseJob(HttpVerb::Put, "SetRoomStateJob", + basePath % "/rooms/" % roomId % "/state/" % eventType) + , d(new Private) +{ + 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(); + d->eventId = fromJson(json.value("event_id")); + return Success; +} + diff --git a/lib/jobs/generated/room_state.h b/lib/jobs/generated/room_state.h new file mode 100644 index 00000000..5d16b2a6 --- /dev/null +++ b/lib/jobs/generated/room_state.h @@ -0,0 +1,47 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "../basejob.h" + +#include + + +namespace QMatrixClient +{ + // Operations + + class SetRoomStateWithKeyJob : public BaseJob + { + public: + explicit SetRoomStateWithKeyJob(const QString& roomId, const QString& eventType, const QString& stateKey, const QJsonObject& body = {}); + ~SetRoomStateWithKeyJob() override; + + const QString& eventId() const; + + protected: + Status parseJson(const QJsonDocument& data) override; + + private: + class Private; + QScopedPointer d; + }; + + class SetRoomStateJob : public BaseJob + { + public: + explicit SetRoomStateJob(const QString& roomId, const QString& eventType, const QJsonObject& body = {}); + ~SetRoomStateJob() override; + + const QString& eventId() const; + + protected: + Status parseJson(const QJsonDocument& data) override; + + private: + class Private; + QScopedPointer d; + }; +} // namespace QMatrixClient diff --git a/lib/jobs/setroomstatejob.cpp b/lib/jobs/setroomstatejob.cpp deleted file mode 100644 index c2beb87b..00000000 --- a/lib/jobs/setroomstatejob.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2015 Felix Rohrbach - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "setroomstatejob.h" - -using namespace QMatrixClient; - -BaseJob::Status SetRoomStateJob::parseJson(const QJsonDocument& data) -{ - _eventId = data.object().value("event_id").toString(); - if (!_eventId.isEmpty()) - return Success; - - qCDebug(JOBS) << data; - return { UserDefinedError, "No event_id in the JSON response" }; -} - diff --git a/lib/jobs/setroomstatejob.h b/lib/jobs/setroomstatejob.h deleted file mode 100644 index 36047667..00000000 --- a/lib/jobs/setroomstatejob.h +++ /dev/null @@ -1,64 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2015 Felix Rohrbach - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#pragma once - -#include "basejob.h" - -#include "connectiondata.h" - -namespace QMatrixClient -{ - class SetRoomStateJob: public BaseJob - { - public: - /** - * Constructs a job that sets a state using an arbitrary room event - * with a state key. - */ - template - SetRoomStateJob(const QString& roomId, const QString& stateKey, - const EvT& event) - : BaseJob(HttpVerb::Put, "SetRoomStateJob", - QStringLiteral("_matrix/client/r0/rooms/%1/state/%2/%3") - .arg(roomId, EvT::typeId(), stateKey), - Query(), - Data(event.toJson())) - { } - /** - * Constructs a job that sets a state using an arbitrary room event - * without a state key. - */ - template - SetRoomStateJob(const QString& roomId, const EvT& event) - : BaseJob(HttpVerb::Put, "SetRoomStateJob", - QStringLiteral("_matrix/client/r0/rooms/%1/state/%2") - .arg(roomId, EvT::typeId()), - Query(), - Data(event.toJson())) - { } - - QString eventId() const { return _eventId; } - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - QString _eventId; - }; -} // namespace QMatrixClient -- cgit v1.2.3 From 4289e72fdbe14b92d14fc18b9aa23cd0e2ae7eba Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 4 May 2018 18:00:28 +0900 Subject: gtad.yaml: Support OpenAPI value maps (aka additionalProperties) This is useful for things like tags map in m.tags event, or the map-of-maps-of-messages in SendToDeviceJob (coming in the next commit). Requires GTAD 0.4.9 or later. --- lib/jobs/gtad.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/jobs') diff --git a/lib/jobs/gtad.yaml b/lib/jobs/gtad.yaml index 89862da2..f606481e 100644 --- a/lib/jobs/gtad.yaml +++ b/lib/jobs/gtad.yaml @@ -93,6 +93,15 @@ analyzer: avoidCopy?: true imports: - //: { type: QJsonArray, "avoidCopy?": true, imports: } + map: + - /.+/: + type: QHash + avoidCopy?: true + imports: + - //: + type: QVariantHash + avoidCopy?: true + imports: variant: { type: QVariant, "avoidCopy?": true, imports: } schema: avoidCopy?: true -- cgit v1.2.3 From b71f291d1979355c5efd7f53988d1d1acf294b09 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 4 May 2018 18:07:28 +0900 Subject: SendToDeviceJob: use a map-of-maps for messages instead of an opaque QJsonObject --- lib/jobs/generated/to_device.cpp | 2 +- lib/jobs/generated/to_device.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/jobs') diff --git a/lib/jobs/generated/to_device.cpp b/lib/jobs/generated/to_device.cpp index cfb860c7..e893fa44 100644 --- a/lib/jobs/generated/to_device.cpp +++ b/lib/jobs/generated/to_device.cpp @@ -12,7 +12,7 @@ using namespace QMatrixClient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -SendToDeviceJob::SendToDeviceJob(const QString& eventType, const QString& txnId, const QJsonObject& messages) +SendToDeviceJob::SendToDeviceJob(const QString& eventType, const QString& txnId, const QHash>& messages) : BaseJob(HttpVerb::Put, "SendToDeviceJob", basePath % "/sendToDevice/" % eventType % "/" % txnId) { diff --git a/lib/jobs/generated/to_device.h b/lib/jobs/generated/to_device.h index 0de8fb0a..f5910e44 100644 --- a/lib/jobs/generated/to_device.h +++ b/lib/jobs/generated/to_device.h @@ -7,6 +7,7 @@ #include "../basejob.h" #include +#include namespace QMatrixClient @@ -16,6 +17,6 @@ namespace QMatrixClient class SendToDeviceJob : public BaseJob { public: - explicit SendToDeviceJob(const QString& eventType, const QString& txnId, const QJsonObject& messages = {}); + explicit SendToDeviceJob(const QString& eventType, const QString& txnId, const QHash>& messages = {}); }; } // namespace QMatrixClient -- cgit v1.2.3 From 33b1c4f9748f0d33da1d18a3abe861014c116b5c Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 4 May 2018 18:56:03 +0900 Subject: {{base}}.h.mustache: better code ordering, more comments --- lib/jobs/{{base}}.h.mustache | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'lib/jobs') diff --git a/lib/jobs/{{base}}.h.mustache b/lib/jobs/{{base}}.h.mustache index ff9a7e7a..e4f45d85 100644 --- a/lib/jobs/{{base}}.h.mustache +++ b/lib/jobs/{{base}}.h.mustache @@ -35,18 +35,20 @@ namespace QMatrixClient {{#vars}} {{dataType.name}} {{nameCamelCase}}; {{/vars}} }; {{/ model}} - // End of inner data structures -{{/ models}}{{^bodyParams}} + // Construction/destruction +{{/ models}} + explicit {{camelCaseOperationId}}Job({{#allParams}}{{>joinedParamDecl}}{{/allParams}});{{^bodyParams}} + /** Construct a URL out of baseUrl and usual parameters passed to * {{camelCaseOperationId}}Job. This function can be used when * a URL for {{camelCaseOperationId}}Job is necessary but the job * itself isn't. */ static QUrl makeRequestUrl(QUrl baseUrl{{#allParams?}}, {{#allParams}}{{>joinedParamDecl}}{{/allParams}}{{/allParams?}}); -{{/bodyParams}} - explicit {{camelCaseOperationId}}Job({{#allParams}}{{>joinedParamDecl}}{{/allParams}});{{!skip EOL -}}{{# responses}}{{#normalResponse?}}{{#allProperties?}} +{{/bodyParams}}{{# responses}}{{#normalResponse?}}{{#allProperties?}} ~{{camelCaseOperationId}}Job() override; + + // Result properties {{#allProperties}} {{>maybeCrefType}} {{paramName}}(){{^noCopy?}} const{{/noCopy?}};{{/allProperties}} -- cgit v1.2.3 From c5b3de1732ca49c78c8ed8cf77f9e9fa414d2f04 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 4 May 2018 18:59:01 +0900 Subject: gtad.yaml: Support maps of events Use std::unordered_map<> (now supported by GTAD and converters.h) for that. --- lib/jobs/gtad.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/jobs') diff --git a/lib/jobs/gtad.yaml b/lib/jobs/gtad.yaml index f606481e..788c0d91 100644 --- a/lib/jobs/gtad.yaml +++ b/lib/jobs/gtad.yaml @@ -94,8 +94,12 @@ analyzer: imports: - //: { type: QJsonArray, "avoidCopy?": true, imports: } map: + - /state_event.yaml$/: + type: "std::unordered_map" + noCopy?: true + imports: - /.+/: - type: QHash + type: "QHash" avoidCopy?: true imports: - //: -- cgit v1.2.3 From c71c4eb027cc7bb3b6b1a9bd41c048fcdfe4aa90 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 4 May 2018 19:02:39 +0900 Subject: jobs/generated: code ordering, more comments --- lib/jobs/generated/administrative_contact.h | 12 ++++++++---- lib/jobs/generated/content-repo.h | 22 ++++++++++++++++++---- lib/jobs/generated/create_room.h | 4 +++- lib/jobs/generated/directory.h | 8 ++++++-- lib/jobs/generated/joining.h | 8 ++++++-- lib/jobs/generated/leaving.h | 6 ++++-- lib/jobs/generated/list_joined_rooms.h | 5 ++++- lib/jobs/generated/list_public_rooms.h | 16 ++++++++++++---- lib/jobs/generated/login.h | 2 ++ lib/jobs/generated/logout.h | 3 ++- lib/jobs/generated/message_pagination.h | 5 ++++- lib/jobs/generated/notifications.h | 7 +++++-- lib/jobs/generated/profile.h | 15 ++++++++++++--- lib/jobs/generated/pusher.h | 9 ++++++--- lib/jobs/generated/redaction.h | 2 ++ lib/jobs/generated/room_send.h | 2 ++ lib/jobs/generated/room_state.h | 4 ++++ lib/jobs/generated/tags.h | 8 ++++++-- lib/jobs/generated/users.h | 4 +++- lib/jobs/generated/versions.h | 5 ++++- lib/jobs/generated/whoami.h | 5 ++++- 21 files changed, 117 insertions(+), 35 deletions(-) (limited to 'lib/jobs') diff --git a/lib/jobs/generated/administrative_contact.h b/lib/jobs/generated/administrative_contact.h index 9cb09a3c..4afd068f 100644 --- a/lib/jobs/generated/administrative_contact.h +++ b/lib/jobs/generated/administrative_contact.h @@ -25,7 +25,9 @@ namespace QMatrixClient QString address; }; - // End of inner data structures + // Construction/destruction + + explicit GetAccount3PIDsJob(); /** Construct a URL out of baseUrl and usual parameters passed to * GetAccount3PIDsJob. This function can be used when @@ -34,9 +36,10 @@ namespace QMatrixClient */ static QUrl makeRequestUrl(QUrl baseUrl); - explicit GetAccount3PIDsJob(); ~GetAccount3PIDsJob() override; + // Result properties + const QVector& threepids() const; protected: @@ -59,7 +62,7 @@ namespace QMatrixClient QString sid; }; - // End of inner data structures + // Construction/destruction explicit Post3PIDsJob(const ThreePidCredentials& threePidCreds, bool bind = {}); }; @@ -67,6 +70,8 @@ namespace QMatrixClient class RequestTokenTo3PIDJob : public BaseJob { public: + explicit RequestTokenTo3PIDJob(); + /** Construct a URL out of baseUrl and usual parameters passed to * RequestTokenTo3PIDJob. This function can be used when * a URL for RequestTokenTo3PIDJob is necessary but the job @@ -74,6 +79,5 @@ namespace QMatrixClient */ static QUrl makeRequestUrl(QUrl baseUrl); - explicit RequestTokenTo3PIDJob(); }; } // namespace QMatrixClient diff --git a/lib/jobs/generated/content-repo.h b/lib/jobs/generated/content-repo.h index e1e58f88..cae8e588 100644 --- a/lib/jobs/generated/content-repo.h +++ b/lib/jobs/generated/content-repo.h @@ -19,6 +19,8 @@ namespace QMatrixClient explicit UploadContentJob(QIODevice* content, const QString& filename = {}, const QString& contentType = {}); ~UploadContentJob() override; + // Result properties + const QString& contentUri() const; protected: @@ -32,6 +34,8 @@ namespace QMatrixClient class GetContentJob : public BaseJob { public: + explicit GetContentJob(const QString& serverName, const QString& mediaId); + /** Construct a URL out of baseUrl and usual parameters passed to * GetContentJob. This function can be used when * a URL for GetContentJob is necessary but the job @@ -39,9 +43,10 @@ namespace QMatrixClient */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId); - explicit GetContentJob(const QString& serverName, const QString& mediaId); ~GetContentJob() override; + // Result properties + const QString& contentType() const; const QString& contentDisposition() const; QIODevice* content() const; @@ -57,6 +62,8 @@ namespace QMatrixClient class GetContentOverrideNameJob : public BaseJob { public: + explicit GetContentOverrideNameJob(const QString& serverName, const QString& mediaId, const QString& fileName); + /** Construct a URL out of baseUrl and usual parameters passed to * GetContentOverrideNameJob. This function can be used when * a URL for GetContentOverrideNameJob is necessary but the job @@ -64,9 +71,10 @@ namespace QMatrixClient */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, const QString& fileName); - explicit GetContentOverrideNameJob(const QString& serverName, const QString& mediaId, const QString& fileName); ~GetContentOverrideNameJob() override; + // Result properties + const QString& contentType() const; const QString& contentDisposition() const; QIODevice* content() const; @@ -82,6 +90,8 @@ namespace QMatrixClient class GetContentThumbnailJob : public BaseJob { public: + explicit GetContentThumbnailJob(const QString& serverName, const QString& mediaId, int width = {}, int height = {}, const QString& method = {}); + /** Construct a URL out of baseUrl and usual parameters passed to * GetContentThumbnailJob. This function can be used when * a URL for GetContentThumbnailJob is necessary but the job @@ -89,9 +99,10 @@ namespace QMatrixClient */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, int width = {}, int height = {}, const QString& method = {}); - explicit GetContentThumbnailJob(const QString& serverName, const QString& mediaId, int width = {}, int height = {}, const QString& method = {}); ~GetContentThumbnailJob() override; + // Result properties + const QString& contentType() const; QIODevice* content() const; @@ -106,6 +117,8 @@ namespace QMatrixClient class GetUrlPreviewJob : public BaseJob { public: + explicit GetUrlPreviewJob(const QString& url, qint64 ts = {}); + /** Construct a URL out of baseUrl and usual parameters passed to * GetUrlPreviewJob. This function can be used when * a URL for GetUrlPreviewJob is necessary but the job @@ -113,9 +126,10 @@ namespace QMatrixClient */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& url, qint64 ts = {}); - explicit GetUrlPreviewJob(const QString& url, qint64 ts = {}); ~GetUrlPreviewJob() override; + // Result properties + qint64 matrixImageSize() const; const QString& ogImage() const; diff --git a/lib/jobs/generated/create_room.h b/lib/jobs/generated/create_room.h index 526463b0..8e38774f 100644 --- a/lib/jobs/generated/create_room.h +++ b/lib/jobs/generated/create_room.h @@ -34,11 +34,13 @@ namespace QMatrixClient QJsonObject content; }; - // End of inner data structures + // Construction/destruction explicit CreateRoomJob(const QString& visibility = {}, const QString& roomAliasName = {}, const QString& name = {}, const QString& topic = {}, const QVector& invite = {}, const QVector& invite3pid = {}, const QJsonObject& creationContent = {}, const QVector& initialState = {}, const QString& preset = {}, bool isDirect = {}, bool guestCanJoin = {}); ~CreateRoomJob() override; + // Result properties + const QString& roomId() const; protected: diff --git a/lib/jobs/generated/directory.h b/lib/jobs/generated/directory.h index 87591240..e01ba024 100644 --- a/lib/jobs/generated/directory.h +++ b/lib/jobs/generated/directory.h @@ -22,6 +22,8 @@ namespace QMatrixClient class GetRoomIdByAliasJob : public BaseJob { public: + explicit GetRoomIdByAliasJob(const QString& roomAlias); + /** Construct a URL out of baseUrl and usual parameters passed to * GetRoomIdByAliasJob. This function can be used when * a URL for GetRoomIdByAliasJob is necessary but the job @@ -29,9 +31,10 @@ namespace QMatrixClient */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomAlias); - explicit GetRoomIdByAliasJob(const QString& roomAlias); ~GetRoomIdByAliasJob() override; + // Result properties + const QString& roomId() const; const QVector& servers() const; @@ -46,6 +49,8 @@ namespace QMatrixClient class DeleteRoomAliasJob : public BaseJob { public: + explicit DeleteRoomAliasJob(const QString& roomAlias); + /** Construct a URL out of baseUrl and usual parameters passed to * DeleteRoomAliasJob. This function can be used when * a URL for DeleteRoomAliasJob is necessary but the job @@ -53,6 +58,5 @@ namespace QMatrixClient */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomAlias); - explicit DeleteRoomAliasJob(const QString& roomAlias); }; } // namespace QMatrixClient diff --git a/lib/jobs/generated/joining.h b/lib/jobs/generated/joining.h index 76edb339..7aa3e3a2 100644 --- a/lib/jobs/generated/joining.h +++ b/lib/jobs/generated/joining.h @@ -27,11 +27,13 @@ namespace QMatrixClient QJsonObject signatures; }; - // End of inner data structures + // Construction/destruction explicit JoinRoomByIdJob(const QString& roomId, const ThirdPartySigned& thirdPartySigned = {}); ~JoinRoomByIdJob() override; + // Result properties + const QString& roomId() const; protected: @@ -60,11 +62,13 @@ namespace QMatrixClient Signed signedData; }; - // End of inner data structures + // Construction/destruction explicit JoinRoomJob(const QString& roomIdOrAlias, const ThirdPartySigned& thirdPartySigned = {}); ~JoinRoomJob() override; + // Result properties + const QString& roomId() const; protected: diff --git a/lib/jobs/generated/leaving.h b/lib/jobs/generated/leaving.h index 9bae2363..7e914dd1 100644 --- a/lib/jobs/generated/leaving.h +++ b/lib/jobs/generated/leaving.h @@ -15,6 +15,8 @@ namespace QMatrixClient class LeaveRoomJob : public BaseJob { public: + explicit LeaveRoomJob(const QString& roomId); + /** Construct a URL out of baseUrl and usual parameters passed to * LeaveRoomJob. This function can be used when * a URL for LeaveRoomJob is necessary but the job @@ -22,12 +24,13 @@ namespace QMatrixClient */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId); - explicit LeaveRoomJob(const QString& roomId); }; class ForgetRoomJob : public BaseJob { public: + explicit ForgetRoomJob(const QString& roomId); + /** Construct a URL out of baseUrl and usual parameters passed to * ForgetRoomJob. This function can be used when * a URL for ForgetRoomJob is necessary but the job @@ -35,6 +38,5 @@ namespace QMatrixClient */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId); - explicit ForgetRoomJob(const QString& roomId); }; } // namespace QMatrixClient diff --git a/lib/jobs/generated/list_joined_rooms.h b/lib/jobs/generated/list_joined_rooms.h index 768f5166..3df2d1ae 100644 --- a/lib/jobs/generated/list_joined_rooms.h +++ b/lib/jobs/generated/list_joined_rooms.h @@ -16,6 +16,8 @@ namespace QMatrixClient class GetJoinedRoomsJob : public BaseJob { public: + explicit GetJoinedRoomsJob(); + /** Construct a URL out of baseUrl and usual parameters passed to * GetJoinedRoomsJob. This function can be used when * a URL for GetJoinedRoomsJob is necessary but the job @@ -23,9 +25,10 @@ namespace QMatrixClient */ static QUrl makeRequestUrl(QUrl baseUrl); - explicit GetJoinedRoomsJob(); ~GetJoinedRoomsJob() override; + // Result properties + const QVector& joinedRooms() const; protected: diff --git a/lib/jobs/generated/list_public_rooms.h b/lib/jobs/generated/list_public_rooms.h index 8e8fddca..3e06f21a 100644 --- a/lib/jobs/generated/list_public_rooms.h +++ b/lib/jobs/generated/list_public_rooms.h @@ -17,6 +17,8 @@ namespace QMatrixClient class GetRoomVisibilityOnDirectoryJob : public BaseJob { public: + explicit GetRoomVisibilityOnDirectoryJob(const QString& roomId); + /** Construct a URL out of baseUrl and usual parameters passed to * GetRoomVisibilityOnDirectoryJob. This function can be used when * a URL for GetRoomVisibilityOnDirectoryJob is necessary but the job @@ -24,9 +26,10 @@ namespace QMatrixClient */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId); - explicit GetRoomVisibilityOnDirectoryJob(const QString& roomId); ~GetRoomVisibilityOnDirectoryJob() override; + // Result properties + const QString& visibility() const; protected: @@ -61,7 +64,9 @@ namespace QMatrixClient QString avatarUrl; }; - // End of inner data structures + // Construction/destruction + + explicit GetPublicRoomsJob(int limit = {}, const QString& since = {}, const QString& server = {}); /** Construct a URL out of baseUrl and usual parameters passed to * GetPublicRoomsJob. This function can be used when @@ -70,9 +75,10 @@ namespace QMatrixClient */ static QUrl makeRequestUrl(QUrl baseUrl, int limit = {}, const QString& since = {}, const QString& server = {}); - explicit GetPublicRoomsJob(int limit = {}, const QString& since = {}, const QString& server = {}); ~GetPublicRoomsJob() override; + // Result properties + const QVector& chunk() const; const QString& nextBatch() const; const QString& prevBatch() const; @@ -109,11 +115,13 @@ namespace QMatrixClient QString avatarUrl; }; - // End of inner data structures + // Construction/destruction explicit QueryPublicRoomsJob(const QString& server = {}, int limit = {}, const QString& since = {}, const Filter& filter = {}); ~QueryPublicRoomsJob() override; + // Result properties + const QVector& chunk() const; const QString& nextBatch() const; const QString& prevBatch() const; diff --git a/lib/jobs/generated/login.h b/lib/jobs/generated/login.h index 3ac955d4..8bf52d6b 100644 --- a/lib/jobs/generated/login.h +++ b/lib/jobs/generated/login.h @@ -18,6 +18,8 @@ namespace QMatrixClient explicit LoginJob(const QString& type, const QString& user = {}, const QString& medium = {}, const QString& address = {}, const QString& password = {}, const QString& token = {}, const QString& deviceId = {}, const QString& initialDeviceDisplayName = {}); ~LoginJob() override; + // Result properties + const QString& userId() const; const QString& accessToken() const; const QString& homeServer() const; diff --git a/lib/jobs/generated/logout.h b/lib/jobs/generated/logout.h index 7640ba55..1f60bd75 100644 --- a/lib/jobs/generated/logout.h +++ b/lib/jobs/generated/logout.h @@ -15,6 +15,8 @@ namespace QMatrixClient class LogoutJob : public BaseJob { public: + explicit LogoutJob(); + /** Construct a URL out of baseUrl and usual parameters passed to * LogoutJob. This function can be used when * a URL for LogoutJob is necessary but the job @@ -22,6 +24,5 @@ namespace QMatrixClient */ static QUrl makeRequestUrl(QUrl baseUrl); - explicit LogoutJob(); }; } // namespace QMatrixClient diff --git a/lib/jobs/generated/message_pagination.h b/lib/jobs/generated/message_pagination.h index b8588ad1..284895fd 100644 --- a/lib/jobs/generated/message_pagination.h +++ b/lib/jobs/generated/message_pagination.h @@ -16,6 +16,8 @@ namespace QMatrixClient class GetRoomEventsJob : public BaseJob { public: + explicit GetRoomEventsJob(const QString& roomId, const QString& from, const QString& dir, const QString& to = {}, int limit = {}, const QString& filter = {}); + /** Construct a URL out of baseUrl and usual parameters passed to * GetRoomEventsJob. This function can be used when * a URL for GetRoomEventsJob is necessary but the job @@ -23,9 +25,10 @@ namespace QMatrixClient */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& from, const QString& dir, const QString& to = {}, int limit = {}, const QString& filter = {}); - explicit GetRoomEventsJob(const QString& roomId, const QString& from, const QString& dir, const QString& to = {}, int limit = {}, const QString& filter = {}); ~GetRoomEventsJob() override; + // Result properties + const QString& begin() const; const QString& end() const; RoomEvents&& chunk(); diff --git a/lib/jobs/generated/notifications.h b/lib/jobs/generated/notifications.h index d66e15be..428995ae 100644 --- a/lib/jobs/generated/notifications.h +++ b/lib/jobs/generated/notifications.h @@ -31,7 +31,9 @@ namespace QMatrixClient qint64 ts; }; - // End of inner data structures + // Construction/destruction + + explicit GetNotificationsJob(const QString& from = {}, int limit = {}, const QString& only = {}); /** Construct a URL out of baseUrl and usual parameters passed to * GetNotificationsJob. This function can be used when @@ -40,9 +42,10 @@ namespace QMatrixClient */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& from = {}, int limit = {}, const QString& only = {}); - explicit GetNotificationsJob(const QString& from = {}, int limit = {}, const QString& only = {}); ~GetNotificationsJob() override; + // Result properties + const QString& nextToken() const; std::vector&& notifications(); diff --git a/lib/jobs/generated/profile.h b/lib/jobs/generated/profile.h index 024130f5..9afc037b 100644 --- a/lib/jobs/generated/profile.h +++ b/lib/jobs/generated/profile.h @@ -21,6 +21,8 @@ namespace QMatrixClient class GetDisplayNameJob : public BaseJob { public: + explicit GetDisplayNameJob(const QString& userId); + /** Construct a URL out of baseUrl and usual parameters passed to * GetDisplayNameJob. This function can be used when * a URL for GetDisplayNameJob is necessary but the job @@ -28,9 +30,10 @@ namespace QMatrixClient */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId); - explicit GetDisplayNameJob(const QString& userId); ~GetDisplayNameJob() override; + // Result properties + const QString& displayname() const; protected: @@ -50,6 +53,8 @@ namespace QMatrixClient class GetAvatarUrlJob : public BaseJob { public: + explicit GetAvatarUrlJob(const QString& userId); + /** Construct a URL out of baseUrl and usual parameters passed to * GetAvatarUrlJob. This function can be used when * a URL for GetAvatarUrlJob is necessary but the job @@ -57,9 +62,10 @@ namespace QMatrixClient */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId); - explicit GetAvatarUrlJob(const QString& userId); ~GetAvatarUrlJob() override; + // Result properties + const QString& avatarUrl() const; protected: @@ -73,6 +79,8 @@ namespace QMatrixClient class GetUserProfileJob : public BaseJob { public: + explicit GetUserProfileJob(const QString& userId); + /** Construct a URL out of baseUrl and usual parameters passed to * GetUserProfileJob. This function can be used when * a URL for GetUserProfileJob is necessary but the job @@ -80,9 +88,10 @@ namespace QMatrixClient */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId); - explicit GetUserProfileJob(const QString& userId); ~GetUserProfileJob() override; + // Result properties + const QString& avatarUrl() const; const QString& displayname() const; diff --git a/lib/jobs/generated/pusher.h b/lib/jobs/generated/pusher.h index 06a2c832..4d99d4d0 100644 --- a/lib/jobs/generated/pusher.h +++ b/lib/jobs/generated/pusher.h @@ -36,7 +36,9 @@ namespace QMatrixClient PusherData data; }; - // End of inner data structures + // Construction/destruction + + explicit GetPushersJob(); /** Construct a URL out of baseUrl and usual parameters passed to * GetPushersJob. This function can be used when @@ -45,9 +47,10 @@ namespace QMatrixClient */ static QUrl makeRequestUrl(QUrl baseUrl); - explicit GetPushersJob(); ~GetPushersJob() override; + // Result properties + const QVector& pushers() const; protected: @@ -68,7 +71,7 @@ namespace QMatrixClient QString url; }; - // End of inner data structures + // Construction/destruction explicit 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 = {}, bool append = {}); }; diff --git a/lib/jobs/generated/redaction.h b/lib/jobs/generated/redaction.h index e3b3ff4f..974dfde5 100644 --- a/lib/jobs/generated/redaction.h +++ b/lib/jobs/generated/redaction.h @@ -18,6 +18,8 @@ namespace QMatrixClient explicit RedactEventJob(const QString& roomId, const QString& eventId, const QString& txnId, const QString& reason = {}); ~RedactEventJob() override; + // Result properties + const QString& eventId() const; protected: diff --git a/lib/jobs/generated/room_send.h b/lib/jobs/generated/room_send.h index d20ce523..370f2865 100644 --- a/lib/jobs/generated/room_send.h +++ b/lib/jobs/generated/room_send.h @@ -19,6 +19,8 @@ namespace QMatrixClient explicit SendMessageJob(const QString& roomId, const QString& eventType, const QString& txnId, const QJsonObject& body = {}); ~SendMessageJob() override; + // Result properties + const QString& eventId() const; protected: diff --git a/lib/jobs/generated/room_state.h b/lib/jobs/generated/room_state.h index 5d16b2a6..aea32263 100644 --- a/lib/jobs/generated/room_state.h +++ b/lib/jobs/generated/room_state.h @@ -19,6 +19,8 @@ namespace QMatrixClient explicit SetRoomStateWithKeyJob(const QString& roomId, const QString& eventType, const QString& stateKey, const QJsonObject& body = {}); ~SetRoomStateWithKeyJob() override; + // Result properties + const QString& eventId() const; protected: @@ -35,6 +37,8 @@ namespace QMatrixClient explicit SetRoomStateJob(const QString& roomId, const QString& eventType, const QJsonObject& body = {}); ~SetRoomStateJob() override; + // Result properties + const QString& eventId() const; protected: diff --git a/lib/jobs/generated/tags.h b/lib/jobs/generated/tags.h index 7a375527..f62bd7ad 100644 --- a/lib/jobs/generated/tags.h +++ b/lib/jobs/generated/tags.h @@ -16,6 +16,8 @@ namespace QMatrixClient class GetRoomTagsJob : public BaseJob { public: + explicit GetRoomTagsJob(const QString& userId, const QString& roomId); + /** Construct a URL out of baseUrl and usual parameters passed to * GetRoomTagsJob. This function can be used when * a URL for GetRoomTagsJob is necessary but the job @@ -23,9 +25,10 @@ namespace QMatrixClient */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& roomId); - explicit GetRoomTagsJob(const QString& userId, const QString& roomId); ~GetRoomTagsJob() override; + // Result properties + const QJsonObject& tags() const; protected: @@ -45,6 +48,8 @@ namespace QMatrixClient class DeleteRoomTagJob : public BaseJob { public: + explicit DeleteRoomTagJob(const QString& userId, const QString& roomId, const QString& tag); + /** Construct a URL out of baseUrl and usual parameters passed to * DeleteRoomTagJob. This function can be used when * a URL for DeleteRoomTagJob is necessary but the job @@ -52,6 +57,5 @@ namespace QMatrixClient */ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& roomId, const QString& tag); - explicit DeleteRoomTagJob(const QString& userId, const QString& roomId, const QString& tag); }; } // namespace QMatrixClient diff --git a/lib/jobs/generated/users.h b/lib/jobs/generated/users.h index 50b8b648..fa0d4335 100644 --- a/lib/jobs/generated/users.h +++ b/lib/jobs/generated/users.h @@ -26,11 +26,13 @@ namespace QMatrixClient QString avatarUrl; }; - // End of inner data structures + // Construction/destruction explicit SearchUserDirectoryJob(const QString& searchTerm, int limit = {}); ~SearchUserDirectoryJob() override; + // Result properties + const QVector& results() const; bool limited() const; diff --git a/lib/jobs/generated/versions.h b/lib/jobs/generated/versions.h index 18f6bb44..249d3de4 100644 --- a/lib/jobs/generated/versions.h +++ b/lib/jobs/generated/versions.h @@ -16,6 +16,8 @@ namespace QMatrixClient class GetVersionsJob : public BaseJob { public: + explicit GetVersionsJob(); + /** Construct a URL out of baseUrl and usual parameters passed to * GetVersionsJob. This function can be used when * a URL for GetVersionsJob is necessary but the job @@ -23,9 +25,10 @@ namespace QMatrixClient */ static QUrl makeRequestUrl(QUrl baseUrl); - explicit GetVersionsJob(); ~GetVersionsJob() override; + // Result properties + const QVector& versions() const; protected: diff --git a/lib/jobs/generated/whoami.h b/lib/jobs/generated/whoami.h index 835232ee..2b0e7375 100644 --- a/lib/jobs/generated/whoami.h +++ b/lib/jobs/generated/whoami.h @@ -15,6 +15,8 @@ namespace QMatrixClient class GetTokenOwnerJob : public BaseJob { public: + explicit GetTokenOwnerJob(); + /** Construct a URL out of baseUrl and usual parameters passed to * GetTokenOwnerJob. This function can be used when * a URL for GetTokenOwnerJob is necessary but the job @@ -22,9 +24,10 @@ namespace QMatrixClient */ static QUrl makeRequestUrl(QUrl baseUrl); - explicit GetTokenOwnerJob(); ~GetTokenOwnerJob() override; + // Result properties + const QString& userId() const; protected: -- cgit v1.2.3 From a83eb9350def2b1537affe4390ea54d37ffbc777 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 4 May 2018 18:59:33 +0900 Subject: gtad.yaml: Use QStringList instead of QVector QStringList's API is richer, after all. --- lib/jobs/gtad.yaml | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/jobs') diff --git a/lib/jobs/gtad.yaml b/lib/jobs/gtad.yaml index 788c0d91..d1b9018d 100644 --- a/lib/jobs/gtad.yaml +++ b/lib/jobs/gtad.yaml @@ -71,6 +71,10 @@ analyzer: avoidCopy?: true imports: array: + - string: + type: QStringList + avoidCopy?: true + imports: - /^Notification|Result$/: type: "std::vector<{{1}}>" noCopy?: true -- cgit v1.2.3 From e49a842e877d17a1c6cbbb2349c2816639447721 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 4 May 2018 19:09:57 +0900 Subject: Connection, jobs/generated: Use QStringList instead of QVector QStringList's API is richer, after all. --- lib/jobs/generated/create_room.cpp | 2 +- lib/jobs/generated/create_room.h | 5 +++-- lib/jobs/generated/directory.cpp | 6 +++--- lib/jobs/generated/directory.h | 4 ++-- lib/jobs/generated/list_joined_rooms.cpp | 6 +++--- lib/jobs/generated/list_joined_rooms.h | 4 ++-- lib/jobs/generated/list_public_rooms.cpp | 4 ++-- lib/jobs/generated/list_public_rooms.h | 5 +++-- lib/jobs/generated/versions.cpp | 6 +++--- lib/jobs/generated/versions.h | 4 ++-- 10 files changed, 24 insertions(+), 22 deletions(-) (limited to 'lib/jobs') diff --git a/lib/jobs/generated/create_room.cpp b/lib/jobs/generated/create_room.cpp index a417c2b1..0a7eb208 100644 --- a/lib/jobs/generated/create_room.cpp +++ b/lib/jobs/generated/create_room.cpp @@ -41,7 +41,7 @@ class CreateRoomJob::Private QString roomId; }; -CreateRoomJob::CreateRoomJob(const QString& visibility, const QString& roomAliasName, const QString& name, const QString& topic, const QVector& invite, const QVector& invite3pid, const QJsonObject& creationContent, const QVector& initialState, const QString& preset, bool isDirect, bool guestCanJoin) +CreateRoomJob::CreateRoomJob(const QString& visibility, const QString& roomAliasName, const QString& name, const QString& topic, const QStringList& invite, const QVector& invite3pid, const QJsonObject& creationContent, const QVector& initialState, const QString& preset, bool isDirect, bool guestCanJoin) : BaseJob(HttpVerb::Post, "CreateRoomJob", basePath % "/createRoom") , d(new Private) diff --git a/lib/jobs/generated/create_room.h b/lib/jobs/generated/create_room.h index 8e38774f..88ad7895 100644 --- a/lib/jobs/generated/create_room.h +++ b/lib/jobs/generated/create_room.h @@ -6,8 +6,9 @@ #include "../basejob.h" -#include #include +#include +#include #include "converters.h" @@ -36,7 +37,7 @@ namespace QMatrixClient // Construction/destruction - explicit CreateRoomJob(const QString& visibility = {}, const QString& roomAliasName = {}, const QString& name = {}, const QString& topic = {}, const QVector& invite = {}, const QVector& invite3pid = {}, const QJsonObject& creationContent = {}, const QVector& initialState = {}, const QString& preset = {}, bool isDirect = {}, bool guestCanJoin = {}); + explicit CreateRoomJob(const QString& visibility = {}, const QString& roomAliasName = {}, const QString& name = {}, const QString& topic = {}, const QStringList& invite = {}, const QVector& invite3pid = {}, const QJsonObject& creationContent = {}, const QVector& initialState = {}, const QString& preset = {}, bool isDirect = {}, bool guestCanJoin = {}); ~CreateRoomJob() override; // Result properties diff --git a/lib/jobs/generated/directory.cpp b/lib/jobs/generated/directory.cpp index 6324a1f5..3066ebe2 100644 --- a/lib/jobs/generated/directory.cpp +++ b/lib/jobs/generated/directory.cpp @@ -26,7 +26,7 @@ class GetRoomIdByAliasJob::Private { public: QString roomId; - QVector servers; + QStringList servers; }; QUrl GetRoomIdByAliasJob::makeRequestUrl(QUrl baseUrl, const QString& roomAlias) @@ -49,7 +49,7 @@ const QString& GetRoomIdByAliasJob::roomId() const return d->roomId; } -const QVector& GetRoomIdByAliasJob::servers() const +const QStringList& GetRoomIdByAliasJob::servers() const { return d->servers; } @@ -58,7 +58,7 @@ BaseJob::Status GetRoomIdByAliasJob::parseJson(const QJsonDocument& data) { auto json = data.object(); d->roomId = fromJson(json.value("room_id")); - d->servers = fromJson>(json.value("servers")); + d->servers = fromJson(json.value("servers")); return Success; } diff --git a/lib/jobs/generated/directory.h b/lib/jobs/generated/directory.h index e01ba024..861040b6 100644 --- a/lib/jobs/generated/directory.h +++ b/lib/jobs/generated/directory.h @@ -6,7 +6,7 @@ #include "../basejob.h" -#include +#include namespace QMatrixClient @@ -36,7 +36,7 @@ namespace QMatrixClient // Result properties const QString& roomId() const; - const QVector& servers() const; + const QStringList& servers() const; protected: Status parseJson(const QJsonDocument& data) override; diff --git a/lib/jobs/generated/list_joined_rooms.cpp b/lib/jobs/generated/list_joined_rooms.cpp index 8ea44721..82ec8849 100644 --- a/lib/jobs/generated/list_joined_rooms.cpp +++ b/lib/jobs/generated/list_joined_rooms.cpp @@ -15,7 +15,7 @@ static const auto basePath = QStringLiteral("/_matrix/client/r0"); class GetJoinedRoomsJob::Private { public: - QVector joinedRooms; + QStringList joinedRooms; }; QUrl GetJoinedRoomsJob::makeRequestUrl(QUrl baseUrl) @@ -33,7 +33,7 @@ GetJoinedRoomsJob::GetJoinedRoomsJob() GetJoinedRoomsJob::~GetJoinedRoomsJob() = default; -const QVector& GetJoinedRoomsJob::joinedRooms() const +const QStringList& GetJoinedRoomsJob::joinedRooms() const { return d->joinedRooms; } @@ -44,7 +44,7 @@ BaseJob::Status GetJoinedRoomsJob::parseJson(const QJsonDocument& data) if (!json.contains("joined_rooms")) return { JsonParseError, "The key 'joined_rooms' not found in the response" }; - d->joinedRooms = fromJson>(json.value("joined_rooms")); + d->joinedRooms = fromJson(json.value("joined_rooms")); return Success; } diff --git a/lib/jobs/generated/list_joined_rooms.h b/lib/jobs/generated/list_joined_rooms.h index 3df2d1ae..442e2cf9 100644 --- a/lib/jobs/generated/list_joined_rooms.h +++ b/lib/jobs/generated/list_joined_rooms.h @@ -6,7 +6,7 @@ #include "../basejob.h" -#include +#include namespace QMatrixClient @@ -29,7 +29,7 @@ namespace QMatrixClient // Result properties - const QVector& joinedRooms() const; + const QStringList& joinedRooms() const; protected: Status parseJson(const QJsonDocument& data) override; diff --git a/lib/jobs/generated/list_public_rooms.cpp b/lib/jobs/generated/list_public_rooms.cpp index 03664def..b27bdd58 100644 --- a/lib/jobs/generated/list_public_rooms.cpp +++ b/lib/jobs/generated/list_public_rooms.cpp @@ -64,7 +64,7 @@ namespace QMatrixClient const auto& o = jv.toObject(); GetPublicRoomsJob::PublicRoomsChunk result; result.aliases = - fromJson>(o.value("aliases")); + fromJson(o.value("aliases")); result.canonicalAlias = fromJson(o.value("canonical_alias")); result.name = @@ -177,7 +177,7 @@ namespace QMatrixClient const auto& o = jv.toObject(); QueryPublicRoomsJob::PublicRoomsChunk result; result.aliases = - fromJson>(o.value("aliases")); + fromJson(o.value("aliases")); result.canonicalAlias = fromJson(o.value("canonical_alias")); result.name = diff --git a/lib/jobs/generated/list_public_rooms.h b/lib/jobs/generated/list_public_rooms.h index 3e06f21a..46c055b5 100644 --- a/lib/jobs/generated/list_public_rooms.h +++ b/lib/jobs/generated/list_public_rooms.h @@ -7,6 +7,7 @@ #include "../basejob.h" #include +#include #include "converters.h" @@ -53,7 +54,7 @@ namespace QMatrixClient struct PublicRoomsChunk { - QVector aliases; + QStringList aliases; QString canonicalAlias; QString name; qint64 numJoinedMembers; @@ -104,7 +105,7 @@ namespace QMatrixClient struct PublicRoomsChunk { - QVector aliases; + QStringList aliases; QString canonicalAlias; QString name; qint64 numJoinedMembers; diff --git a/lib/jobs/generated/versions.cpp b/lib/jobs/generated/versions.cpp index 3b03172c..7b55b94f 100644 --- a/lib/jobs/generated/versions.cpp +++ b/lib/jobs/generated/versions.cpp @@ -15,7 +15,7 @@ static const auto basePath = QStringLiteral("/_matrix/client"); class GetVersionsJob::Private { public: - QVector versions; + QStringList versions; }; QUrl GetVersionsJob::makeRequestUrl(QUrl baseUrl) @@ -33,7 +33,7 @@ GetVersionsJob::GetVersionsJob() GetVersionsJob::~GetVersionsJob() = default; -const QVector& GetVersionsJob::versions() const +const QStringList& GetVersionsJob::versions() const { return d->versions; } @@ -41,7 +41,7 @@ const QVector& GetVersionsJob::versions() const BaseJob::Status GetVersionsJob::parseJson(const QJsonDocument& data) { auto json = data.object(); - d->versions = fromJson>(json.value("versions")); + d->versions = fromJson(json.value("versions")); return Success; } diff --git a/lib/jobs/generated/versions.h b/lib/jobs/generated/versions.h index 249d3de4..4fe8d9d0 100644 --- a/lib/jobs/generated/versions.h +++ b/lib/jobs/generated/versions.h @@ -6,7 +6,7 @@ #include "../basejob.h" -#include +#include namespace QMatrixClient @@ -29,7 +29,7 @@ namespace QMatrixClient // Result properties - const QVector& versions() const; + const QStringList& versions() const; protected: Status parseJson(const QJsonDocument& data) override; -- cgit v1.2.3 From 7f202c6a09ff34b063f5de94e8afc385bbf8379b Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 4 May 2018 19:53:55 +0900 Subject: gtad.yaml: Even more concise type stubbing With most recent GTAD. --- lib/jobs/gtad.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/jobs') diff --git a/lib/jobs/gtad.yaml b/lib/jobs/gtad.yaml index d1b9018d..d6b0b51f 100644 --- a/lib/jobs/gtad.yaml +++ b/lib/jobs/gtad.yaml @@ -53,7 +53,6 @@ analyzer: file: *ByteStream object: - /m\.room\.member$/: # A stub for EventsBatch - type: none - /state_event.yaml$/: type: StateEventPtr noCopy?: true @@ -98,7 +97,7 @@ analyzer: imports: - //: { type: QJsonArray, "avoidCopy?": true, imports: } map: - - /state_event.yaml$/: + - RoomState: type: "std::unordered_map" noCopy?: true imports: -- cgit v1.2.3 From 7681802be815ca1a03f219b82e3bd1b02863d34e Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 4 May 2018 20:05:52 +0900 Subject: gtad.yaml: Cleanup --- lib/jobs/gtad.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/jobs') diff --git a/lib/jobs/gtad.yaml b/lib/jobs/gtad.yaml index d6b0b51f..7f6a97e0 100644 --- a/lib/jobs/gtad.yaml +++ b/lib/jobs/gtad.yaml @@ -110,7 +110,7 @@ analyzer: avoidCopy?: true imports: variant: { type: QVariant, "avoidCopy?": true, imports: } - schema: + schema: # Properties of inline structure definitions avoidCopy?: true #operations: @@ -130,7 +130,6 @@ mustache: # preamble: preamble.mustache copyrightName: Kitsune Ral copyrightEmail: - # imports: { set: } templates: - "{{base}}.h.mustache" -- cgit v1.2.3 From 49022915fde72b83d9f18944c268110b01fa3469 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 4 May 2018 23:04:04 +0900 Subject: New home for the generated code - lib/csapi --- lib/jobs/downloadfilejob.h | 2 +- lib/jobs/generated/account-data.cpp | 28 --- lib/jobs/generated/account-data.h | 27 --- lib/jobs/generated/administrative_contact.cpp | 102 ---------- lib/jobs/generated/administrative_contact.h | 83 -------- lib/jobs/generated/banning.cpp | 34 ---- lib/jobs/generated/banning.h | 26 --- lib/jobs/generated/content-repo.cpp | 254 ------------------------ lib/jobs/generated/content-repo.h | 143 -------------- lib/jobs/generated/create_room.cpp | 82 -------- lib/jobs/generated/create_room.h | 54 ------ lib/jobs/generated/directory.cpp | 76 -------- lib/jobs/generated/directory.h | 62 ------ lib/jobs/generated/inviting.cpp | 23 --- lib/jobs/generated/inviting.h | 20 -- lib/jobs/generated/joining.cpp | 118 ------------ lib/jobs/generated/joining.h | 81 -------- lib/jobs/generated/kicking.cpp | 25 --- lib/jobs/generated/kicking.h | 20 -- lib/jobs/generated/leaving.cpp | 38 ---- lib/jobs/generated/leaving.h | 42 ---- lib/jobs/generated/list_joined_rooms.cpp | 50 ----- lib/jobs/generated/list_joined_rooms.h | 41 ---- lib/jobs/generated/list_public_rooms.cpp | 268 -------------------------- lib/jobs/generated/list_public_rooms.h | 138 ------------- lib/jobs/generated/login.cpp | 79 -------- lib/jobs/generated/login.h | 35 ---- lib/jobs/generated/logout.cpp | 26 --- lib/jobs/generated/logout.h | 28 --- lib/jobs/generated/message_pagination.cpp | 76 -------- lib/jobs/generated/message_pagination.h | 43 ----- lib/jobs/generated/notifications.cpp | 96 --------- lib/jobs/generated/notifications.h | 59 ------ lib/jobs/generated/profile.cpp | 140 -------------- lib/jobs/generated/profile.h | 105 ---------- lib/jobs/generated/pusher.cpp | 121 ------------ lib/jobs/generated/pusher.h | 78 -------- lib/jobs/generated/receipts.cpp | 21 -- lib/jobs/generated/receipts.h | 21 -- lib/jobs/generated/redaction.cpp | 45 ----- lib/jobs/generated/redaction.h | 32 --- lib/jobs/generated/room_send.cpp | 42 ---- lib/jobs/generated/room_send.h | 33 ---- lib/jobs/generated/room_state.cpp | 70 ------- lib/jobs/generated/room_state.h | 51 ----- lib/jobs/generated/tags.cpp | 66 ------- lib/jobs/generated/tags.h | 61 ------ lib/jobs/generated/third_party_membership.cpp | 25 --- lib/jobs/generated/third_party_membership.h | 20 -- lib/jobs/generated/to_device.cpp | 23 --- lib/jobs/generated/to_device.h | 22 --- lib/jobs/generated/typing.cpp | 24 --- lib/jobs/generated/typing.h | 20 -- lib/jobs/generated/users.cpp | 78 -------- lib/jobs/generated/users.h | 46 ----- lib/jobs/generated/versions.cpp | 47 ----- lib/jobs/generated/versions.h | 41 ---- lib/jobs/generated/whoami.cpp | 50 ----- lib/jobs/generated/whoami.h | 40 ---- lib/jobs/gtad.yaml | 139 ------------- lib/jobs/mediathumbnailjob.h | 2 +- lib/jobs/preamble.mustache | 3 - lib/jobs/{{base}}.cpp.mustache | 121 ------------ lib/jobs/{{base}}.h.mustache | 63 ------ 64 files changed, 2 insertions(+), 3927 deletions(-) delete mode 100644 lib/jobs/generated/account-data.cpp delete mode 100644 lib/jobs/generated/account-data.h delete mode 100644 lib/jobs/generated/administrative_contact.cpp delete mode 100644 lib/jobs/generated/administrative_contact.h delete mode 100644 lib/jobs/generated/banning.cpp delete mode 100644 lib/jobs/generated/banning.h delete mode 100644 lib/jobs/generated/content-repo.cpp delete mode 100644 lib/jobs/generated/content-repo.h delete mode 100644 lib/jobs/generated/create_room.cpp delete mode 100644 lib/jobs/generated/create_room.h delete mode 100644 lib/jobs/generated/directory.cpp delete mode 100644 lib/jobs/generated/directory.h delete mode 100644 lib/jobs/generated/inviting.cpp delete mode 100644 lib/jobs/generated/inviting.h delete mode 100644 lib/jobs/generated/joining.cpp delete mode 100644 lib/jobs/generated/joining.h delete mode 100644 lib/jobs/generated/kicking.cpp delete mode 100644 lib/jobs/generated/kicking.h delete mode 100644 lib/jobs/generated/leaving.cpp delete mode 100644 lib/jobs/generated/leaving.h delete mode 100644 lib/jobs/generated/list_joined_rooms.cpp delete mode 100644 lib/jobs/generated/list_joined_rooms.h delete mode 100644 lib/jobs/generated/list_public_rooms.cpp delete mode 100644 lib/jobs/generated/list_public_rooms.h delete mode 100644 lib/jobs/generated/login.cpp delete mode 100644 lib/jobs/generated/login.h delete mode 100644 lib/jobs/generated/logout.cpp delete mode 100644 lib/jobs/generated/logout.h delete mode 100644 lib/jobs/generated/message_pagination.cpp delete mode 100644 lib/jobs/generated/message_pagination.h delete mode 100644 lib/jobs/generated/notifications.cpp delete mode 100644 lib/jobs/generated/notifications.h delete mode 100644 lib/jobs/generated/profile.cpp delete mode 100644 lib/jobs/generated/profile.h delete mode 100644 lib/jobs/generated/pusher.cpp delete mode 100644 lib/jobs/generated/pusher.h delete mode 100644 lib/jobs/generated/receipts.cpp delete mode 100644 lib/jobs/generated/receipts.h delete mode 100644 lib/jobs/generated/redaction.cpp delete mode 100644 lib/jobs/generated/redaction.h delete mode 100644 lib/jobs/generated/room_send.cpp delete mode 100644 lib/jobs/generated/room_send.h delete mode 100644 lib/jobs/generated/room_state.cpp delete mode 100644 lib/jobs/generated/room_state.h delete mode 100644 lib/jobs/generated/tags.cpp delete mode 100644 lib/jobs/generated/tags.h delete mode 100644 lib/jobs/generated/third_party_membership.cpp delete mode 100644 lib/jobs/generated/third_party_membership.h delete mode 100644 lib/jobs/generated/to_device.cpp delete mode 100644 lib/jobs/generated/to_device.h delete mode 100644 lib/jobs/generated/typing.cpp delete mode 100644 lib/jobs/generated/typing.h delete mode 100644 lib/jobs/generated/users.cpp delete mode 100644 lib/jobs/generated/users.h delete mode 100644 lib/jobs/generated/versions.cpp delete mode 100644 lib/jobs/generated/versions.h delete mode 100644 lib/jobs/generated/whoami.cpp delete mode 100644 lib/jobs/generated/whoami.h delete mode 100644 lib/jobs/gtad.yaml delete mode 100644 lib/jobs/preamble.mustache delete mode 100644 lib/jobs/{{base}}.cpp.mustache delete mode 100644 lib/jobs/{{base}}.h.mustache (limited to 'lib/jobs') diff --git a/lib/jobs/downloadfilejob.h b/lib/jobs/downloadfilejob.h index 1815a7c8..ce47ab1c 100644 --- a/lib/jobs/downloadfilejob.h +++ b/lib/jobs/downloadfilejob.h @@ -1,6 +1,6 @@ #pragma once -#include "generated/content-repo.h" +#include "csapi/content-repo.h" namespace QMatrixClient { diff --git a/lib/jobs/generated/account-data.cpp b/lib/jobs/generated/account-data.cpp deleted file mode 100644 index ac45cb85..00000000 --- a/lib/jobs/generated/account-data.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "account-data.h" - -#include "converters.h" - -#include - -using namespace QMatrixClient; - -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -SetAccountDataJob::SetAccountDataJob(const QString& userId, const QString& type, const QJsonObject& content) - : BaseJob(HttpVerb::Put, "SetAccountDataJob", - basePath % "/user/" % userId % "/account_data/" % type) -{ - setRequestData(Data(toJson(content))); -} - -SetAccountDataPerRoomJob::SetAccountDataPerRoomJob(const QString& userId, const QString& roomId, const QString& type, const QJsonObject& content) - : BaseJob(HttpVerb::Put, "SetAccountDataPerRoomJob", - basePath % "/user/" % userId % "/rooms/" % roomId % "/account_data/" % type) -{ - setRequestData(Data(toJson(content))); -} - diff --git a/lib/jobs/generated/account-data.h b/lib/jobs/generated/account-data.h deleted file mode 100644 index 69ad9fb4..00000000 --- a/lib/jobs/generated/account-data.h +++ /dev/null @@ -1,27 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - -#include - - -namespace QMatrixClient -{ - // Operations - - class SetAccountDataJob : public BaseJob - { - public: - explicit SetAccountDataJob(const QString& userId, const QString& type, const QJsonObject& content = {}); - }; - - class SetAccountDataPerRoomJob : public BaseJob - { - public: - explicit SetAccountDataPerRoomJob(const QString& userId, const QString& roomId, const QString& type, const QJsonObject& content = {}); - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/administrative_contact.cpp b/lib/jobs/generated/administrative_contact.cpp deleted file mode 100644 index ec7c77c3..00000000 --- a/lib/jobs/generated/administrative_contact.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "administrative_contact.h" - -#include - -using namespace QMatrixClient; - -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -namespace QMatrixClient -{ - // Converters - - template <> struct FromJson - { - GetAccount3PIDsJob::ThirdPartyIdentifier operator()(const QJsonValue& jv) - { - const auto& o = jv.toObject(); - GetAccount3PIDsJob::ThirdPartyIdentifier result; - result.medium = - fromJson(o.value("medium")); - result.address = - fromJson(o.value("address")); - - return result; - } - }; -} // namespace QMatrixClient - -class GetAccount3PIDsJob::Private -{ - public: - QVector threepids; -}; - -QUrl GetAccount3PIDsJob::makeRequestUrl(QUrl baseUrl) -{ - return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/account/3pid"); -} - -GetAccount3PIDsJob::GetAccount3PIDsJob() - : BaseJob(HttpVerb::Get, "GetAccount3PIDsJob", - basePath % "/account/3pid") - , d(new Private) -{ -} - -GetAccount3PIDsJob::~GetAccount3PIDsJob() = default; - -const QVector& GetAccount3PIDsJob::threepids() const -{ - return d->threepids; -} - -BaseJob::Status GetAccount3PIDsJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - d->threepids = fromJson>(json.value("threepids")); - return Success; -} - -namespace QMatrixClient -{ - // Converters - - QJsonObject toJson(const Post3PIDsJob::ThreePidCredentials& pod) - { - QJsonObject o; - o.insert("client_secret", toJson(pod.clientSecret)); - o.insert("id_server", toJson(pod.idServer)); - o.insert("sid", toJson(pod.sid)); - - return o; - } -} // namespace QMatrixClient - -Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds, bool bind) - : BaseJob(HttpVerb::Post, "Post3PIDsJob", - basePath % "/account/3pid") -{ - QJsonObject _data; - _data.insert("three_pid_creds", toJson(threePidCreds)); - _data.insert("bind", toJson(bind)); - setRequestData(_data); -} - -QUrl RequestTokenTo3PIDJob::makeRequestUrl(QUrl baseUrl) -{ - return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/account/3pid/email/requestToken"); -} - -RequestTokenTo3PIDJob::RequestTokenTo3PIDJob() - : BaseJob(HttpVerb::Post, "RequestTokenTo3PIDJob", - basePath % "/account/3pid/email/requestToken", false) -{ -} - diff --git a/lib/jobs/generated/administrative_contact.h b/lib/jobs/generated/administrative_contact.h deleted file mode 100644 index 4afd068f..00000000 --- a/lib/jobs/generated/administrative_contact.h +++ /dev/null @@ -1,83 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - -#include - -#include "converters.h" - -namespace QMatrixClient -{ - // Operations - - class GetAccount3PIDsJob : public BaseJob - { - public: - // Inner data structures - - struct ThirdPartyIdentifier - { - QString medium; - QString address; - }; - - // Construction/destruction - - explicit GetAccount3PIDsJob(); - - /** Construct a URL out of baseUrl and usual parameters passed to - * GetAccount3PIDsJob. 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 - - const QVector& threepids() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; - - class Post3PIDsJob : public BaseJob - { - public: - // Inner data structures - - struct ThreePidCredentials - { - QString clientSecret; - QString idServer; - QString sid; - }; - - // Construction/destruction - - explicit Post3PIDsJob(const ThreePidCredentials& threePidCreds, bool bind = {}); - }; - - class RequestTokenTo3PIDJob : public BaseJob - { - public: - explicit RequestTokenTo3PIDJob(); - - /** Construct a URL out of baseUrl and usual parameters passed to - * RequestTokenTo3PIDJob. This function can be used when - * a URL for RequestTokenTo3PIDJob is necessary but the job - * itself isn't. - */ - static QUrl makeRequestUrl(QUrl baseUrl); - - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/banning.cpp b/lib/jobs/generated/banning.cpp deleted file mode 100644 index f66b27b6..00000000 --- a/lib/jobs/generated/banning.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "banning.h" - -#include "converters.h" - -#include - -using namespace QMatrixClient; - -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -BanJob::BanJob(const QString& roomId, const QString& userId, const QString& reason) - : BaseJob(HttpVerb::Post, "BanJob", - basePath % "/rooms/" % roomId % "/ban") -{ - QJsonObject _data; - _data.insert("user_id", toJson(userId)); - if (!reason.isEmpty()) - _data.insert("reason", toJson(reason)); - setRequestData(_data); -} - -UnbanJob::UnbanJob(const QString& roomId, const QString& userId) - : BaseJob(HttpVerb::Post, "UnbanJob", - basePath % "/rooms/" % roomId % "/unban") -{ - QJsonObject _data; - _data.insert("user_id", toJson(userId)); - setRequestData(_data); -} - diff --git a/lib/jobs/generated/banning.h b/lib/jobs/generated/banning.h deleted file mode 100644 index 2d6fbd9b..00000000 --- a/lib/jobs/generated/banning.h +++ /dev/null @@ -1,26 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - - - -namespace QMatrixClient -{ - // Operations - - class BanJob : public BaseJob - { - public: - explicit BanJob(const QString& roomId, const QString& userId, const QString& reason = {}); - }; - - class UnbanJob : public BaseJob - { - public: - explicit UnbanJob(const QString& roomId, const QString& userId); - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/content-repo.cpp b/lib/jobs/generated/content-repo.cpp deleted file mode 100644 index 95fc5aed..00000000 --- a/lib/jobs/generated/content-repo.cpp +++ /dev/null @@ -1,254 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "content-repo.h" - -#include "converters.h" - -#include -#include - -using namespace QMatrixClient; - -static const auto basePath = QStringLiteral("/_matrix/media/r0"); - -class UploadContentJob::Private -{ - public: - QString contentUri; -}; - -BaseJob::Query queryToUploadContent(const QString& filename) -{ - BaseJob::Query _q; - if (!filename.isEmpty()) - _q.addQueryItem("filename", filename); - return _q; -} - -UploadContentJob::UploadContentJob(QIODevice* content, const QString& filename, const QString& contentType) - : BaseJob(HttpVerb::Post, "UploadContentJob", - basePath % "/upload", - queryToUploadContent(filename)) - , d(new Private) -{ - setRequestHeader("Content-Type", contentType.toLatin1()); - - setRequestData(Data(content)); -} - -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")) - return { JsonParseError, - "The key 'content_uri' not found in the response" }; - d->contentUri = fromJson(json.value("content_uri")); - return Success; -} - -class GetContentJob::Private -{ - public: - QString contentType; - QString contentDisposition; - QIODevice* content; -}; - -QUrl GetContentJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId) -{ - return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/download/" % serverName % "/" % mediaId); -} - -GetContentJob::GetContentJob(const QString& serverName, const QString& mediaId) - : BaseJob(HttpVerb::Get, "GetContentJob", - basePath % "/download/" % serverName % "/" % mediaId, 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::content() const -{ - return d->content; -} - -BaseJob::Status GetContentJob::parseReply(QNetworkReply* reply) -{ - d->contentType = reply->rawHeader("Content-Type"); - d->contentDisposition = reply->rawHeader("Content-Disposition"); - d->content = reply; - return Success; -} - -class GetContentOverrideNameJob::Private -{ - public: - QString contentType; - QString contentDisposition; - QIODevice* content; -}; - -QUrl GetContentOverrideNameJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, const QString& fileName) -{ - return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/download/" % serverName % "/" % mediaId % "/" % fileName); -} - -GetContentOverrideNameJob::GetContentOverrideNameJob(const QString& serverName, const QString& mediaId, const QString& fileName) - : BaseJob(HttpVerb::Get, "GetContentOverrideNameJob", - basePath % "/download/" % serverName % "/" % mediaId % "/" % fileName, 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::content() const -{ - return d->content; -} - -BaseJob::Status GetContentOverrideNameJob::parseReply(QNetworkReply* reply) -{ - d->contentType = reply->rawHeader("Content-Type"); - d->contentDisposition = reply->rawHeader("Content-Disposition"); - d->content = reply; - return Success; -} - -class GetContentThumbnailJob::Private -{ - public: - QString contentType; - QIODevice* content; -}; - -BaseJob::Query queryToGetContentThumbnail(int width, int height, const QString& method) -{ - BaseJob::Query _q; - _q.addQueryItem("width", QString("%1").arg(width)); - _q.addQueryItem("height", QString("%1").arg(height)); - if (!method.isEmpty()) - _q.addQueryItem("method", method); - return _q; -} - -QUrl GetContentThumbnailJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, int width, int height, const QString& method) -{ - return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/thumbnail/" % serverName % "/" % mediaId, - queryToGetContentThumbnail(width, height, method)); -} - -GetContentThumbnailJob::GetContentThumbnailJob(const QString& serverName, const QString& mediaId, int width, int height, const QString& method) - : BaseJob(HttpVerb::Get, "GetContentThumbnailJob", - basePath % "/thumbnail/" % serverName % "/" % mediaId, - queryToGetContentThumbnail(width, height, method), - {}, false) - , d(new Private) -{ - setExpectedContentTypes({ "image/jpeg", "image/png" }); -} - -GetContentThumbnailJob::~GetContentThumbnailJob() = default; - -const QString& GetContentThumbnailJob::contentType() const -{ - return d->contentType; -} - -QIODevice* GetContentThumbnailJob::content() const -{ - return d->content; -} - -BaseJob::Status GetContentThumbnailJob::parseReply(QNetworkReply* reply) -{ - d->contentType = reply->rawHeader("Content-Type"); - d->content = reply; - return Success; -} - -class GetUrlPreviewJob::Private -{ - public: - qint64 matrixImageSize; - QString ogImage; -}; - -BaseJob::Query queryToGetUrlPreview(const QString& url, qint64 ts) -{ - BaseJob::Query _q; - _q.addQueryItem("url", url); - _q.addQueryItem("ts", QString("%1").arg(ts)); - return _q; -} - -QUrl GetUrlPreviewJob::makeRequestUrl(QUrl baseUrl, const QString& url, qint64 ts) -{ - return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/preview_url", - queryToGetUrlPreview(url, ts)); -} - -GetUrlPreviewJob::GetUrlPreviewJob(const QString& url, qint64 ts) - : BaseJob(HttpVerb::Get, "GetUrlPreviewJob", - basePath % "/preview_url", - queryToGetUrlPreview(url, ts)) - , d(new Private) -{ -} - -GetUrlPreviewJob::~GetUrlPreviewJob() = default; - -qint64 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(); - d->matrixImageSize = fromJson(json.value("matrix:image:size")); - d->ogImage = fromJson(json.value("og:image")); - return Success; -} - diff --git a/lib/jobs/generated/content-repo.h b/lib/jobs/generated/content-repo.h deleted file mode 100644 index cae8e588..00000000 --- a/lib/jobs/generated/content-repo.h +++ /dev/null @@ -1,143 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - -#include - - -namespace QMatrixClient -{ - // Operations - - class UploadContentJob : public BaseJob - { - public: - explicit UploadContentJob(QIODevice* content, const QString& filename = {}, const QString& contentType = {}); - ~UploadContentJob() override; - - // Result properties - - const QString& contentUri() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; - - class GetContentJob : public BaseJob - { - public: - explicit GetContentJob(const QString& serverName, const QString& mediaId); - - /** Construct a URL out of baseUrl and usual parameters passed to - * GetContentJob. 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); - - ~GetContentJob() override; - - // Result properties - - const QString& contentType() const; - const QString& contentDisposition() const; - QIODevice* content() const; - - protected: - Status parseReply(QNetworkReply* reply) override; - - private: - class Private; - QScopedPointer d; - }; - - class GetContentOverrideNameJob : public BaseJob - { - public: - explicit GetContentOverrideNameJob(const QString& serverName, const QString& mediaId, const QString& fileName); - - /** Construct a URL out of baseUrl and usual parameters passed to - * GetContentOverrideNameJob. 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); - - ~GetContentOverrideNameJob() override; - - // Result properties - - const QString& contentType() const; - const QString& contentDisposition() const; - QIODevice* content() const; - - protected: - Status parseReply(QNetworkReply* reply) override; - - private: - class Private; - QScopedPointer d; - }; - - class GetContentThumbnailJob : public BaseJob - { - public: - explicit GetContentThumbnailJob(const QString& serverName, const QString& mediaId, int width = {}, int height = {}, const QString& method = {}); - - /** Construct a URL out of baseUrl and usual parameters passed to - * GetContentThumbnailJob. 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 = {}); - - ~GetContentThumbnailJob() override; - - // Result properties - - const QString& contentType() const; - QIODevice* content() const; - - protected: - Status parseReply(QNetworkReply* reply) override; - - private: - class Private; - QScopedPointer d; - }; - - class GetUrlPreviewJob : public BaseJob - { - public: - explicit GetUrlPreviewJob(const QString& url, qint64 ts = {}); - - /** Construct a URL out of baseUrl and usual parameters passed to - * GetUrlPreviewJob. 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, qint64 ts = {}); - - ~GetUrlPreviewJob() override; - - // Result properties - - qint64 matrixImageSize() const; - const QString& ogImage() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/create_room.cpp b/lib/jobs/generated/create_room.cpp deleted file mode 100644 index 0a7eb208..00000000 --- a/lib/jobs/generated/create_room.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "create_room.h" - -#include - -using namespace QMatrixClient; - -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -namespace QMatrixClient -{ - // Converters - - QJsonObject toJson(const CreateRoomJob::Invite3pid& pod) - { - QJsonObject o; - o.insert("id_server", toJson(pod.idServer)); - o.insert("medium", toJson(pod.medium)); - o.insert("address", toJson(pod.address)); - - return o; - } - - QJsonObject toJson(const CreateRoomJob::StateEvent& pod) - { - QJsonObject o; - o.insert("type", toJson(pod.type)); - o.insert("state_key", toJson(pod.stateKey)); - o.insert("content", toJson(pod.content)); - - return o; - } -} // namespace QMatrixClient - -class CreateRoomJob::Private -{ - public: - QString roomId; -}; - -CreateRoomJob::CreateRoomJob(const QString& visibility, const QString& roomAliasName, const QString& name, const QString& topic, const QStringList& invite, const QVector& invite3pid, const QJsonObject& creationContent, const QVector& initialState, const QString& preset, bool isDirect, bool guestCanJoin) - : BaseJob(HttpVerb::Post, "CreateRoomJob", - basePath % "/createRoom") - , d(new Private) -{ - QJsonObject _data; - if (!visibility.isEmpty()) - _data.insert("visibility", toJson(visibility)); - if (!roomAliasName.isEmpty()) - _data.insert("room_alias_name", toJson(roomAliasName)); - if (!name.isEmpty()) - _data.insert("name", toJson(name)); - if (!topic.isEmpty()) - _data.insert("topic", toJson(topic)); - _data.insert("invite", toJson(invite)); - _data.insert("invite_3pid", toJson(invite3pid)); - _data.insert("creation_content", toJson(creationContent)); - _data.insert("initial_state", toJson(initialState)); - if (!preset.isEmpty()) - _data.insert("preset", toJson(preset)); - _data.insert("is_direct", toJson(isDirect)); - _data.insert("guest_can_join", toJson(guestCanJoin)); - setRequestData(_data); -} - -CreateRoomJob::~CreateRoomJob() = default; - -const QString& CreateRoomJob::roomId() const -{ - return d->roomId; -} - -BaseJob::Status CreateRoomJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - d->roomId = fromJson(json.value("room_id")); - return Success; -} - diff --git a/lib/jobs/generated/create_room.h b/lib/jobs/generated/create_room.h deleted file mode 100644 index 88ad7895..00000000 --- a/lib/jobs/generated/create_room.h +++ /dev/null @@ -1,54 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - -#include -#include -#include - -#include "converters.h" - -namespace QMatrixClient -{ - // Operations - - class CreateRoomJob : public BaseJob - { - public: - // Inner data structures - - struct Invite3pid - { - QString idServer; - QString medium; - QString address; - }; - - struct StateEvent - { - QString type; - QString stateKey; - QJsonObject content; - }; - - // Construction/destruction - - explicit CreateRoomJob(const QString& visibility = {}, const QString& roomAliasName = {}, const QString& name = {}, const QString& topic = {}, const QStringList& invite = {}, const QVector& invite3pid = {}, const QJsonObject& creationContent = {}, const QVector& initialState = {}, const QString& preset = {}, bool isDirect = {}, bool guestCanJoin = {}); - ~CreateRoomJob() override; - - // Result properties - - const QString& roomId() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/directory.cpp b/lib/jobs/generated/directory.cpp deleted file mode 100644 index 3066ebe2..00000000 --- a/lib/jobs/generated/directory.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "directory.h" - -#include "converters.h" - -#include - -using namespace QMatrixClient; - -static const auto basePath = QStringLiteral("/_matrix/client/r0/directory"); - -SetRoomAliasJob::SetRoomAliasJob(const QString& roomAlias, const QString& roomId) - : BaseJob(HttpVerb::Put, "SetRoomAliasJob", - basePath % "/room/" % roomAlias) -{ - QJsonObject _data; - if (!roomId.isEmpty()) - _data.insert("room_id", toJson(roomId)); - setRequestData(_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); -} - -GetRoomIdByAliasJob::GetRoomIdByAliasJob(const QString& roomAlias) - : BaseJob(HttpVerb::Get, "GetRoomIdByAliasJob", - basePath % "/room/" % roomAlias, false) - , d(new Private) -{ -} - -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(); - d->roomId = fromJson(json.value("room_id")); - d->servers = fromJson(json.value("servers")); - return Success; -} - -QUrl DeleteRoomAliasJob::makeRequestUrl(QUrl baseUrl, const QString& roomAlias) -{ - return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/room/" % roomAlias); -} - -DeleteRoomAliasJob::DeleteRoomAliasJob(const QString& roomAlias) - : BaseJob(HttpVerb::Delete, "DeleteRoomAliasJob", - basePath % "/room/" % roomAlias) -{ -} - diff --git a/lib/jobs/generated/directory.h b/lib/jobs/generated/directory.h deleted file mode 100644 index 861040b6..00000000 --- a/lib/jobs/generated/directory.h +++ /dev/null @@ -1,62 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - -#include - - -namespace QMatrixClient -{ - // Operations - - class SetRoomAliasJob : public BaseJob - { - public: - explicit SetRoomAliasJob(const QString& roomAlias, const QString& roomId = {}); - }; - - class GetRoomIdByAliasJob : public BaseJob - { - public: - explicit GetRoomIdByAliasJob(const QString& roomAlias); - - /** Construct a URL out of baseUrl and usual parameters passed to - * GetRoomIdByAliasJob. 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 - - const QString& roomId() const; - const QStringList& servers() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; - - class DeleteRoomAliasJob : public BaseJob - { - public: - explicit DeleteRoomAliasJob(const QString& roomAlias); - - /** Construct a URL out of baseUrl and usual parameters passed to - * DeleteRoomAliasJob. 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); - - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/inviting.cpp b/lib/jobs/generated/inviting.cpp deleted file mode 100644 index d2ee2107..00000000 --- a/lib/jobs/generated/inviting.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "inviting.h" - -#include "converters.h" - -#include - -using namespace QMatrixClient; - -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -InviteUserJob::InviteUserJob(const QString& roomId, const QString& userId) - : BaseJob(HttpVerb::Post, "InviteUserJob", - basePath % "/rooms/" % roomId % "/invite") -{ - QJsonObject _data; - _data.insert("user_id", toJson(userId)); - setRequestData(_data); -} - diff --git a/lib/jobs/generated/inviting.h b/lib/jobs/generated/inviting.h deleted file mode 100644 index eaa884df..00000000 --- a/lib/jobs/generated/inviting.h +++ /dev/null @@ -1,20 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - - - -namespace QMatrixClient -{ - // Operations - - class InviteUserJob : public BaseJob - { - public: - explicit InviteUserJob(const QString& roomId, const QString& userId); - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/joining.cpp b/lib/jobs/generated/joining.cpp deleted file mode 100644 index 705e8f83..00000000 --- a/lib/jobs/generated/joining.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "joining.h" - -#include - -using namespace QMatrixClient; - -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -namespace QMatrixClient -{ - // Converters - - QJsonObject toJson(const JoinRoomByIdJob::ThirdPartySigned& pod) - { - QJsonObject o; - o.insert("sender", toJson(pod.sender)); - o.insert("mxid", toJson(pod.mxid)); - o.insert("token", toJson(pod.token)); - o.insert("signatures", toJson(pod.signatures)); - - return o; - } -} // namespace QMatrixClient - -class JoinRoomByIdJob::Private -{ - public: - QString roomId; -}; - -JoinRoomByIdJob::JoinRoomByIdJob(const QString& roomId, const ThirdPartySigned& thirdPartySigned) - : BaseJob(HttpVerb::Post, "JoinRoomByIdJob", - basePath % "/rooms/" % roomId % "/join") - , d(new Private) -{ - QJsonObject _data; - _data.insert("third_party_signed", toJson(thirdPartySigned)); - setRequestData(_data); -} - -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")) - return { JsonParseError, - "The key 'room_id' not found in the response" }; - d->roomId = fromJson(json.value("room_id")); - return Success; -} - -namespace QMatrixClient -{ - // Converters - - QJsonObject toJson(const JoinRoomJob::Signed& pod) - { - QJsonObject o; - o.insert("sender", toJson(pod.sender)); - o.insert("mxid", toJson(pod.mxid)); - o.insert("token", toJson(pod.token)); - o.insert("signatures", toJson(pod.signatures)); - - return o; - } - - QJsonObject toJson(const JoinRoomJob::ThirdPartySigned& pod) - { - QJsonObject o; - o.insert("signed", toJson(pod.signedData)); - - return o; - } -} // namespace QMatrixClient - -class JoinRoomJob::Private -{ - public: - QString roomId; -}; - -JoinRoomJob::JoinRoomJob(const QString& roomIdOrAlias, const ThirdPartySigned& thirdPartySigned) - : BaseJob(HttpVerb::Post, "JoinRoomJob", - basePath % "/join/" % roomIdOrAlias) - , d(new Private) -{ - QJsonObject _data; - _data.insert("third_party_signed", toJson(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")) - return { JsonParseError, - "The key 'room_id' not found in the response" }; - d->roomId = fromJson(json.value("room_id")); - return Success; -} - diff --git a/lib/jobs/generated/joining.h b/lib/jobs/generated/joining.h deleted file mode 100644 index 7aa3e3a2..00000000 --- a/lib/jobs/generated/joining.h +++ /dev/null @@ -1,81 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - -#include - -#include "converters.h" - -namespace QMatrixClient -{ - // Operations - - class JoinRoomByIdJob : public BaseJob - { - public: - // Inner data structures - - struct ThirdPartySigned - { - QString sender; - QString mxid; - QString token; - QJsonObject signatures; - }; - - // Construction/destruction - - explicit JoinRoomByIdJob(const QString& roomId, const ThirdPartySigned& thirdPartySigned = {}); - ~JoinRoomByIdJob() override; - - // Result properties - - const QString& roomId() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; - - class JoinRoomJob : public BaseJob - { - public: - // Inner data structures - - struct Signed - { - QString sender; - QString mxid; - QString token; - QJsonObject signatures; - }; - - struct ThirdPartySigned - { - Signed signedData; - }; - - // Construction/destruction - - explicit JoinRoomJob(const QString& roomIdOrAlias, const ThirdPartySigned& thirdPartySigned = {}); - ~JoinRoomJob() override; - - // Result properties - - const QString& roomId() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/kicking.cpp b/lib/jobs/generated/kicking.cpp deleted file mode 100644 index bf2490b7..00000000 --- a/lib/jobs/generated/kicking.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "kicking.h" - -#include "converters.h" - -#include - -using namespace QMatrixClient; - -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -KickJob::KickJob(const QString& roomId, const QString& userId, const QString& reason) - : BaseJob(HttpVerb::Post, "KickJob", - basePath % "/rooms/" % roomId % "/kick") -{ - QJsonObject _data; - _data.insert("user_id", toJson(userId)); - if (!reason.isEmpty()) - _data.insert("reason", toJson(reason)); - setRequestData(_data); -} - diff --git a/lib/jobs/generated/kicking.h b/lib/jobs/generated/kicking.h deleted file mode 100644 index 3814bef7..00000000 --- a/lib/jobs/generated/kicking.h +++ /dev/null @@ -1,20 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - - - -namespace QMatrixClient -{ - // Operations - - class KickJob : public BaseJob - { - public: - explicit KickJob(const QString& roomId, const QString& userId, const QString& reason = {}); - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/leaving.cpp b/lib/jobs/generated/leaving.cpp deleted file mode 100644 index afc4adbd..00000000 --- a/lib/jobs/generated/leaving.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "leaving.h" - -#include "converters.h" - -#include - -using namespace QMatrixClient; - -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"); -} - -LeaveRoomJob::LeaveRoomJob(const QString& roomId) - : BaseJob(HttpVerb::Post, "LeaveRoomJob", - basePath % "/rooms/" % roomId % "/leave") -{ -} - -QUrl ForgetRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) -{ - return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/rooms/" % roomId % "/forget"); -} - -ForgetRoomJob::ForgetRoomJob(const QString& roomId) - : BaseJob(HttpVerb::Post, "ForgetRoomJob", - basePath % "/rooms/" % roomId % "/forget") -{ -} - diff --git a/lib/jobs/generated/leaving.h b/lib/jobs/generated/leaving.h deleted file mode 100644 index 7e914dd1..00000000 --- a/lib/jobs/generated/leaving.h +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - - - -namespace QMatrixClient -{ - // Operations - - class LeaveRoomJob : public BaseJob - { - public: - explicit LeaveRoomJob(const QString& roomId); - - /** Construct a URL out of baseUrl and usual parameters passed to - * LeaveRoomJob. 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); - - }; - - class ForgetRoomJob : public BaseJob - { - public: - explicit ForgetRoomJob(const QString& roomId); - - /** Construct a URL out of baseUrl and usual parameters passed to - * ForgetRoomJob. 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); - - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/list_joined_rooms.cpp b/lib/jobs/generated/list_joined_rooms.cpp deleted file mode 100644 index 82ec8849..00000000 --- a/lib/jobs/generated/list_joined_rooms.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "list_joined_rooms.h" - -#include "converters.h" - -#include - -using namespace QMatrixClient; - -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"); -} - -GetJoinedRoomsJob::GetJoinedRoomsJob() - : BaseJob(HttpVerb::Get, "GetJoinedRoomsJob", - basePath % "/joined_rooms") - , d(new Private) -{ -} - -GetJoinedRoomsJob::~GetJoinedRoomsJob() = default; - -const QStringList& GetJoinedRoomsJob::joinedRooms() const -{ - return d->joinedRooms; -} - -BaseJob::Status GetJoinedRoomsJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - if (!json.contains("joined_rooms")) - return { JsonParseError, - "The key 'joined_rooms' not found in the response" }; - d->joinedRooms = fromJson(json.value("joined_rooms")); - return Success; -} - diff --git a/lib/jobs/generated/list_joined_rooms.h b/lib/jobs/generated/list_joined_rooms.h deleted file mode 100644 index 442e2cf9..00000000 --- a/lib/jobs/generated/list_joined_rooms.h +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - -#include - - -namespace QMatrixClient -{ - // Operations - - class GetJoinedRoomsJob : public BaseJob - { - public: - explicit GetJoinedRoomsJob(); - - /** Construct a URL out of baseUrl and usual parameters passed to - * GetJoinedRoomsJob. 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 - - const QStringList& joinedRooms() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/list_public_rooms.cpp b/lib/jobs/generated/list_public_rooms.cpp deleted file mode 100644 index b27bdd58..00000000 --- a/lib/jobs/generated/list_public_rooms.cpp +++ /dev/null @@ -1,268 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "list_public_rooms.h" - -#include - -using namespace QMatrixClient; - -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); -} - -GetRoomVisibilityOnDirectoryJob::GetRoomVisibilityOnDirectoryJob(const QString& roomId) - : BaseJob(HttpVerb::Get, "GetRoomVisibilityOnDirectoryJob", - basePath % "/directory/list/room/" % roomId, false) - , d(new Private) -{ -} - -GetRoomVisibilityOnDirectoryJob::~GetRoomVisibilityOnDirectoryJob() = default; - -const QString& GetRoomVisibilityOnDirectoryJob::visibility() const -{ - return d->visibility; -} - -BaseJob::Status GetRoomVisibilityOnDirectoryJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - d->visibility = fromJson(json.value("visibility")); - return Success; -} - -SetRoomVisibilityOnDirectoryJob::SetRoomVisibilityOnDirectoryJob(const QString& roomId, const QString& visibility) - : BaseJob(HttpVerb::Put, "SetRoomVisibilityOnDirectoryJob", - basePath % "/directory/list/room/" % roomId) -{ - QJsonObject _data; - if (!visibility.isEmpty()) - _data.insert("visibility", toJson(visibility)); - setRequestData(_data); -} - -namespace QMatrixClient -{ - // Converters - - template <> struct FromJson - { - GetPublicRoomsJob::PublicRoomsChunk operator()(const QJsonValue& jv) - { - const auto& o = jv.toObject(); - GetPublicRoomsJob::PublicRoomsChunk result; - result.aliases = - fromJson(o.value("aliases")); - result.canonicalAlias = - fromJson(o.value("canonical_alias")); - result.name = - fromJson(o.value("name")); - result.numJoinedMembers = - fromJson(o.value("num_joined_members")); - result.roomId = - fromJson(o.value("room_id")); - result.topic = - fromJson(o.value("topic")); - result.worldReadable = - fromJson(o.value("world_readable")); - result.guestCanJoin = - fromJson(o.value("guest_can_join")); - result.avatarUrl = - fromJson(o.value("avatar_url")); - - return result; - } - }; -} // namespace QMatrixClient - -class GetPublicRoomsJob::Private -{ - public: - QVector chunk; - QString nextBatch; - QString prevBatch; - qint64 totalRoomCountEstimate; -}; - -BaseJob::Query queryToGetPublicRooms(int limit, const QString& since, const QString& server) -{ - BaseJob::Query _q; - _q.addQueryItem("limit", QString("%1").arg(limit)); - if (!since.isEmpty()) - _q.addQueryItem("since", since); - if (!server.isEmpty()) - _q.addQueryItem("server", server); - return _q; -} - -QUrl GetPublicRoomsJob::makeRequestUrl(QUrl baseUrl, int limit, const QString& since, const QString& server) -{ - return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/publicRooms", - queryToGetPublicRooms(limit, since, server)); -} - -GetPublicRoomsJob::GetPublicRoomsJob(int limit, const QString& since, const QString& server) - : BaseJob(HttpVerb::Get, "GetPublicRoomsJob", - basePath % "/publicRooms", - queryToGetPublicRooms(limit, since, server), - {}, false) - , d(new Private) -{ -} - -GetPublicRoomsJob::~GetPublicRoomsJob() = default; - -const QVector& GetPublicRoomsJob::chunk() const -{ - return d->chunk; -} - -const QString& GetPublicRoomsJob::nextBatch() const -{ - return d->nextBatch; -} - -const QString& GetPublicRoomsJob::prevBatch() const -{ - return d->prevBatch; -} - -qint64 GetPublicRoomsJob::totalRoomCountEstimate() const -{ - return d->totalRoomCountEstimate; -} - -BaseJob::Status GetPublicRoomsJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - if (!json.contains("chunk")) - return { JsonParseError, - "The key 'chunk' not found in the response" }; - d->chunk = fromJson>(json.value("chunk")); - d->nextBatch = fromJson(json.value("next_batch")); - d->prevBatch = fromJson(json.value("prev_batch")); - d->totalRoomCountEstimate = fromJson(json.value("total_room_count_estimate")); - return Success; -} - -namespace QMatrixClient -{ - // Converters - - QJsonObject toJson(const QueryPublicRoomsJob::Filter& pod) - { - QJsonObject o; - o.insert("generic_search_term", toJson(pod.genericSearchTerm)); - - return o; - } - - template <> struct FromJson - { - QueryPublicRoomsJob::PublicRoomsChunk operator()(const QJsonValue& jv) - { - const auto& o = jv.toObject(); - QueryPublicRoomsJob::PublicRoomsChunk result; - result.aliases = - fromJson(o.value("aliases")); - result.canonicalAlias = - fromJson(o.value("canonical_alias")); - result.name = - fromJson(o.value("name")); - result.numJoinedMembers = - fromJson(o.value("num_joined_members")); - result.roomId = - fromJson(o.value("room_id")); - result.topic = - fromJson(o.value("topic")); - result.worldReadable = - fromJson(o.value("world_readable")); - result.guestCanJoin = - fromJson(o.value("guest_can_join")); - result.avatarUrl = - fromJson(o.value("avatar_url")); - - return result; - } - }; -} // namespace QMatrixClient - -class QueryPublicRoomsJob::Private -{ - public: - QVector chunk; - QString nextBatch; - QString prevBatch; - qint64 totalRoomCountEstimate; -}; - -BaseJob::Query queryToQueryPublicRooms(const QString& server) -{ - BaseJob::Query _q; - if (!server.isEmpty()) - _q.addQueryItem("server", server); - return _q; -} - -QueryPublicRoomsJob::QueryPublicRoomsJob(const QString& server, int limit, const QString& since, const Filter& filter) - : BaseJob(HttpVerb::Post, "QueryPublicRoomsJob", - basePath % "/publicRooms", - queryToQueryPublicRooms(server)) - , d(new Private) -{ - QJsonObject _data; - _data.insert("limit", toJson(limit)); - if (!since.isEmpty()) - _data.insert("since", toJson(since)); - _data.insert("filter", toJson(filter)); - setRequestData(_data); -} - -QueryPublicRoomsJob::~QueryPublicRoomsJob() = default; - -const QVector& QueryPublicRoomsJob::chunk() const -{ - return d->chunk; -} - -const QString& QueryPublicRoomsJob::nextBatch() const -{ - return d->nextBatch; -} - -const QString& QueryPublicRoomsJob::prevBatch() const -{ - return d->prevBatch; -} - -qint64 QueryPublicRoomsJob::totalRoomCountEstimate() const -{ - return d->totalRoomCountEstimate; -} - -BaseJob::Status QueryPublicRoomsJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - if (!json.contains("chunk")) - return { JsonParseError, - "The key 'chunk' not found in the response" }; - d->chunk = fromJson>(json.value("chunk")); - d->nextBatch = fromJson(json.value("next_batch")); - d->prevBatch = fromJson(json.value("prev_batch")); - d->totalRoomCountEstimate = fromJson(json.value("total_room_count_estimate")); - return Success; -} - diff --git a/lib/jobs/generated/list_public_rooms.h b/lib/jobs/generated/list_public_rooms.h deleted file mode 100644 index 46c055b5..00000000 --- a/lib/jobs/generated/list_public_rooms.h +++ /dev/null @@ -1,138 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - -#include -#include - -#include "converters.h" - -namespace QMatrixClient -{ - // Operations - - class GetRoomVisibilityOnDirectoryJob : public BaseJob - { - public: - explicit GetRoomVisibilityOnDirectoryJob(const QString& roomId); - - /** Construct a URL out of baseUrl and usual parameters passed to - * GetRoomVisibilityOnDirectoryJob. 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 - - const QString& visibility() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; - - class SetRoomVisibilityOnDirectoryJob : public BaseJob - { - public: - explicit SetRoomVisibilityOnDirectoryJob(const QString& roomId, const QString& visibility = {}); - }; - - class GetPublicRoomsJob : public BaseJob - { - public: - // Inner data structures - - struct PublicRoomsChunk - { - QStringList aliases; - QString canonicalAlias; - QString name; - qint64 numJoinedMembers; - QString roomId; - QString topic; - bool worldReadable; - bool guestCanJoin; - QString avatarUrl; - }; - - // Construction/destruction - - explicit GetPublicRoomsJob(int limit = {}, const QString& since = {}, const QString& server = {}); - - /** Construct a URL out of baseUrl and usual parameters passed to - * GetPublicRoomsJob. This function can be used when - * a URL for GetPublicRoomsJob is necessary but the job - * itself isn't. - */ - static QUrl makeRequestUrl(QUrl baseUrl, int limit = {}, const QString& since = {}, const QString& server = {}); - - ~GetPublicRoomsJob() override; - - // Result properties - - const QVector& chunk() const; - const QString& nextBatch() const; - const QString& prevBatch() const; - qint64 totalRoomCountEstimate() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; - - class QueryPublicRoomsJob : public BaseJob - { - public: - // Inner data structures - - struct Filter - { - QString genericSearchTerm; - }; - - struct PublicRoomsChunk - { - QStringList aliases; - QString canonicalAlias; - QString name; - qint64 numJoinedMembers; - QString roomId; - QString topic; - bool worldReadable; - bool guestCanJoin; - QString avatarUrl; - }; - - // Construction/destruction - - explicit QueryPublicRoomsJob(const QString& server = {}, int limit = {}, const QString& since = {}, const Filter& filter = {}); - ~QueryPublicRoomsJob() override; - - // Result properties - - const QVector& chunk() const; - const QString& nextBatch() const; - const QString& prevBatch() const; - qint64 totalRoomCountEstimate() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/login.cpp b/lib/jobs/generated/login.cpp deleted file mode 100644 index a4dab428..00000000 --- a/lib/jobs/generated/login.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "login.h" - -#include "converters.h" - -#include - -using namespace QMatrixClient; - -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -class LoginJob::Private -{ - public: - QString userId; - QString accessToken; - QString homeServer; - QString deviceId; -}; - -LoginJob::LoginJob(const QString& type, const QString& user, const QString& medium, const QString& address, const QString& password, const QString& token, const QString& deviceId, const QString& initialDeviceDisplayName) - : BaseJob(HttpVerb::Post, "LoginJob", - basePath % "/login", false) - , d(new Private) -{ - QJsonObject _data; - _data.insert("type", toJson(type)); - if (!user.isEmpty()) - _data.insert("user", toJson(user)); - if (!medium.isEmpty()) - _data.insert("medium", toJson(medium)); - if (!address.isEmpty()) - _data.insert("address", toJson(address)); - if (!password.isEmpty()) - _data.insert("password", toJson(password)); - if (!token.isEmpty()) - _data.insert("token", toJson(token)); - if (!deviceId.isEmpty()) - _data.insert("device_id", toJson(deviceId)); - if (!initialDeviceDisplayName.isEmpty()) - _data.insert("initial_device_display_name", toJson(initialDeviceDisplayName)); - 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; -} - -BaseJob::Status LoginJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - d->userId = fromJson(json.value("user_id")); - d->accessToken = fromJson(json.value("access_token")); - d->homeServer = fromJson(json.value("home_server")); - d->deviceId = fromJson(json.value("device_id")); - return Success; -} - diff --git a/lib/jobs/generated/login.h b/lib/jobs/generated/login.h deleted file mode 100644 index 8bf52d6b..00000000 --- a/lib/jobs/generated/login.h +++ /dev/null @@ -1,35 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - - - -namespace QMatrixClient -{ - // Operations - - class LoginJob : public BaseJob - { - public: - explicit LoginJob(const QString& type, const QString& user = {}, const QString& medium = {}, const QString& address = {}, const QString& password = {}, const QString& token = {}, const QString& deviceId = {}, const QString& initialDeviceDisplayName = {}); - ~LoginJob() override; - - // Result properties - - const QString& userId() const; - const QString& accessToken() const; - const QString& homeServer() const; - const QString& deviceId() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/logout.cpp b/lib/jobs/generated/logout.cpp deleted file mode 100644 index b943dcd3..00000000 --- a/lib/jobs/generated/logout.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "logout.h" - -#include "converters.h" - -#include - -using namespace QMatrixClient; - -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -QUrl LogoutJob::makeRequestUrl(QUrl baseUrl) -{ - return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/logout"); -} - -LogoutJob::LogoutJob() - : BaseJob(HttpVerb::Post, "LogoutJob", - basePath % "/logout") -{ -} - diff --git a/lib/jobs/generated/logout.h b/lib/jobs/generated/logout.h deleted file mode 100644 index 1f60bd75..00000000 --- a/lib/jobs/generated/logout.h +++ /dev/null @@ -1,28 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - - - -namespace QMatrixClient -{ - // Operations - - class LogoutJob : public BaseJob - { - public: - explicit LogoutJob(); - - /** Construct a URL out of baseUrl and usual parameters passed to - * LogoutJob. This function can be used when - * a URL for LogoutJob is necessary but the job - * itself isn't. - */ - static QUrl makeRequestUrl(QUrl baseUrl); - - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/message_pagination.cpp b/lib/jobs/generated/message_pagination.cpp deleted file mode 100644 index f89ccd03..00000000 --- a/lib/jobs/generated/message_pagination.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "message_pagination.h" - -#include "converters.h" - -#include - -using namespace QMatrixClient; - -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, int limit, const QString& filter) -{ - BaseJob::Query _q; - _q.addQueryItem("from", from); - if (!to.isEmpty()) - _q.addQueryItem("to", to); - _q.addQueryItem("dir", dir); - _q.addQueryItem("limit", QString("%1").arg(limit)); - if (!filter.isEmpty()) - _q.addQueryItem("filter", filter); - return _q; -} - -QUrl GetRoomEventsJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& from, const QString& dir, const QString& to, int limit, const QString& filter) -{ - return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/rooms/" % roomId % "/messages", - queryToGetRoomEvents(from, to, dir, limit, filter)); -} - -GetRoomEventsJob::GetRoomEventsJob(const QString& roomId, const QString& from, const QString& dir, const QString& to, int limit, const QString& filter) - : BaseJob(HttpVerb::Get, "GetRoomEventsJob", - basePath % "/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(); - d->begin = fromJson(json.value("start")); - d->end = fromJson(json.value("end")); - d->chunk = fromJson(json.value("chunk")); - return Success; -} - diff --git a/lib/jobs/generated/message_pagination.h b/lib/jobs/generated/message_pagination.h deleted file mode 100644 index 284895fd..00000000 --- a/lib/jobs/generated/message_pagination.h +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - -#include "events/event.h" - - -namespace QMatrixClient -{ - // Operations - - class GetRoomEventsJob : public BaseJob - { - public: - explicit GetRoomEventsJob(const QString& roomId, const QString& from, const QString& dir, const QString& to = {}, int limit = {}, const QString& filter = {}); - - /** Construct a URL out of baseUrl and usual parameters passed to - * GetRoomEventsJob. 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 = {}, int limit = {}, const QString& filter = {}); - - ~GetRoomEventsJob() override; - - // Result properties - - const QString& begin() const; - const QString& end() const; - RoomEvents&& chunk(); - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/notifications.cpp b/lib/jobs/generated/notifications.cpp deleted file mode 100644 index 04ad0175..00000000 --- a/lib/jobs/generated/notifications.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "notifications.h" - -#include - -using namespace QMatrixClient; - -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -namespace QMatrixClient -{ - // Converters - - template <> struct FromJson - { - GetNotificationsJob::Notification operator()(const QJsonValue& jv) - { - const auto& o = jv.toObject(); - GetNotificationsJob::Notification result; - result.actions = - fromJson>(o.value("actions")); - result.event = - fromJson(o.value("event")); - result.profileTag = - fromJson(o.value("profile_tag")); - result.read = - fromJson(o.value("read")); - result.roomId = - fromJson(o.value("room_id")); - result.ts = - fromJson(o.value("ts")); - - return result; - } - }; -} // namespace QMatrixClient - -class GetNotificationsJob::Private -{ - public: - QString nextToken; - std::vector notifications; -}; - -BaseJob::Query queryToGetNotifications(const QString& from, int limit, const QString& only) -{ - BaseJob::Query _q; - if (!from.isEmpty()) - _q.addQueryItem("from", from); - _q.addQueryItem("limit", QString("%1").arg(limit)); - if (!only.isEmpty()) - _q.addQueryItem("only", only); - return _q; -} - -QUrl GetNotificationsJob::makeRequestUrl(QUrl baseUrl, const QString& from, int limit, const QString& only) -{ - return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/notifications", - queryToGetNotifications(from, limit, only)); -} - -GetNotificationsJob::GetNotificationsJob(const QString& from, int limit, const QString& only) - : BaseJob(HttpVerb::Get, "GetNotificationsJob", - basePath % "/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(); - d->nextToken = fromJson(json.value("next_token")); - if (!json.contains("notifications")) - return { JsonParseError, - "The key 'notifications' not found in the response" }; - d->notifications = fromJson>(json.value("notifications")); - return Success; -} - diff --git a/lib/jobs/generated/notifications.h b/lib/jobs/generated/notifications.h deleted file mode 100644 index 428995ae..00000000 --- a/lib/jobs/generated/notifications.h +++ /dev/null @@ -1,59 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - -#include "events/event.h" -#include -#include - -#include "converters.h" - -namespace QMatrixClient -{ - // Operations - - class GetNotificationsJob : public BaseJob - { - public: - // Inner data structures - - struct Notification - { - QVector actions; - EventPtr event; - QString profileTag; - bool read; - QString roomId; - qint64 ts; - }; - - // Construction/destruction - - explicit GetNotificationsJob(const QString& from = {}, int limit = {}, const QString& only = {}); - - /** Construct a URL out of baseUrl and usual parameters passed to - * GetNotificationsJob. 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 = {}, int limit = {}, const QString& only = {}); - - ~GetNotificationsJob() override; - - // Result properties - - const QString& nextToken() const; - std::vector&& notifications(); - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/profile.cpp b/lib/jobs/generated/profile.cpp deleted file mode 100644 index d8ddbc14..00000000 --- a/lib/jobs/generated/profile.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "profile.h" - -#include "converters.h" - -#include - -using namespace QMatrixClient; - -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -SetDisplayNameJob::SetDisplayNameJob(const QString& userId, const QString& displayname) - : BaseJob(HttpVerb::Put, "SetDisplayNameJob", - basePath % "/profile/" % userId % "/displayname") -{ - QJsonObject _data; - if (!displayname.isEmpty()) - _data.insert("displayname", toJson(displayname)); - setRequestData(_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"); -} - -GetDisplayNameJob::GetDisplayNameJob(const QString& userId) - : BaseJob(HttpVerb::Get, "GetDisplayNameJob", - basePath % "/profile/" % userId % "/displayname", false) - , d(new Private) -{ -} - -GetDisplayNameJob::~GetDisplayNameJob() = default; - -const QString& GetDisplayNameJob::displayname() const -{ - return d->displayname; -} - -BaseJob::Status GetDisplayNameJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - d->displayname = fromJson(json.value("displayname")); - return Success; -} - -SetAvatarUrlJob::SetAvatarUrlJob(const QString& userId, const QString& avatarUrl) - : BaseJob(HttpVerb::Put, "SetAvatarUrlJob", - basePath % "/profile/" % userId % "/avatar_url") -{ - QJsonObject _data; - if (!avatarUrl.isEmpty()) - _data.insert("avatar_url", toJson(avatarUrl)); - setRequestData(_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"); -} - -GetAvatarUrlJob::GetAvatarUrlJob(const QString& userId) - : BaseJob(HttpVerb::Get, "GetAvatarUrlJob", - basePath % "/profile/" % userId % "/avatar_url", false) - , d(new Private) -{ -} - -GetAvatarUrlJob::~GetAvatarUrlJob() = default; - -const QString& GetAvatarUrlJob::avatarUrl() const -{ - return d->avatarUrl; -} - -BaseJob::Status GetAvatarUrlJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - d->avatarUrl = fromJson(json.value("avatar_url")); - 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); -} - -GetUserProfileJob::GetUserProfileJob(const QString& userId) - : BaseJob(HttpVerb::Get, "GetUserProfileJob", - basePath % "/profile/" % userId, false) - , d(new Private) -{ -} - -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(); - d->avatarUrl = fromJson(json.value("avatar_url")); - d->displayname = fromJson(json.value("displayname")); - return Success; -} - diff --git a/lib/jobs/generated/profile.h b/lib/jobs/generated/profile.h deleted file mode 100644 index 9afc037b..00000000 --- a/lib/jobs/generated/profile.h +++ /dev/null @@ -1,105 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - - - -namespace QMatrixClient -{ - // Operations - - class SetDisplayNameJob : public BaseJob - { - public: - explicit SetDisplayNameJob(const QString& userId, const QString& displayname = {}); - }; - - class GetDisplayNameJob : public BaseJob - { - public: - explicit GetDisplayNameJob(const QString& userId); - - /** Construct a URL out of baseUrl and usual parameters passed to - * GetDisplayNameJob. 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 - - const QString& displayname() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; - - class SetAvatarUrlJob : public BaseJob - { - public: - explicit SetAvatarUrlJob(const QString& userId, const QString& avatarUrl = {}); - }; - - class GetAvatarUrlJob : public BaseJob - { - public: - explicit GetAvatarUrlJob(const QString& userId); - - /** Construct a URL out of baseUrl and usual parameters passed to - * GetAvatarUrlJob. 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 - - const QString& avatarUrl() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; - - class GetUserProfileJob : public BaseJob - { - public: - explicit GetUserProfileJob(const QString& userId); - - /** Construct a URL out of baseUrl and usual parameters passed to - * GetUserProfileJob. 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 - - const QString& avatarUrl() const; - const QString& displayname() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/pusher.cpp b/lib/jobs/generated/pusher.cpp deleted file mode 100644 index dea7cf8b..00000000 --- a/lib/jobs/generated/pusher.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "pusher.h" - -#include - -using namespace QMatrixClient; - -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -namespace QMatrixClient -{ - // Converters - - template <> struct FromJson - { - GetPushersJob::PusherData operator()(const QJsonValue& jv) - { - const auto& o = jv.toObject(); - GetPushersJob::PusherData result; - result.url = - fromJson(o.value("url")); - - return result; - } - }; - - template <> struct FromJson - { - GetPushersJob::Pusher operator()(const QJsonValue& jv) - { - const auto& o = jv.toObject(); - GetPushersJob::Pusher result; - result.pushkey = - fromJson(o.value("pushkey")); - result.kind = - fromJson(o.value("kind")); - result.appId = - fromJson(o.value("app_id")); - result.appDisplayName = - fromJson(o.value("app_display_name")); - result.deviceDisplayName = - fromJson(o.value("device_display_name")); - result.profileTag = - fromJson(o.value("profile_tag")); - result.lang = - fromJson(o.value("lang")); - result.data = - fromJson(o.value("data")); - - return result; - } - }; -} // namespace QMatrixClient - -class GetPushersJob::Private -{ - public: - QVector pushers; -}; - -QUrl GetPushersJob::makeRequestUrl(QUrl baseUrl) -{ - return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/pushers"); -} - -GetPushersJob::GetPushersJob() - : BaseJob(HttpVerb::Get, "GetPushersJob", - basePath % "/pushers") - , d(new Private) -{ -} - -GetPushersJob::~GetPushersJob() = default; - -const QVector& GetPushersJob::pushers() const -{ - return d->pushers; -} - -BaseJob::Status GetPushersJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - d->pushers = fromJson>(json.value("pushers")); - return Success; -} - -namespace QMatrixClient -{ - // Converters - - QJsonObject toJson(const PostPusherJob::PusherData& pod) - { - QJsonObject o; - o.insert("url", toJson(pod.url)); - - return o; - } -} // namespace QMatrixClient - -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, bool append) - : BaseJob(HttpVerb::Post, "PostPusherJob", - basePath % "/pushers/set") -{ - QJsonObject _data; - _data.insert("pushkey", toJson(pushkey)); - _data.insert("kind", toJson(kind)); - _data.insert("app_id", toJson(appId)); - _data.insert("app_display_name", toJson(appDisplayName)); - _data.insert("device_display_name", toJson(deviceDisplayName)); - if (!profileTag.isEmpty()) - _data.insert("profile_tag", toJson(profileTag)); - _data.insert("lang", toJson(lang)); - _data.insert("data", toJson(data)); - _data.insert("append", toJson(append)); - setRequestData(_data); -} - diff --git a/lib/jobs/generated/pusher.h b/lib/jobs/generated/pusher.h deleted file mode 100644 index 4d99d4d0..00000000 --- a/lib/jobs/generated/pusher.h +++ /dev/null @@ -1,78 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - -#include - -#include "converters.h" - -namespace QMatrixClient -{ - // Operations - - class GetPushersJob : public BaseJob - { - public: - // Inner data structures - - struct PusherData - { - QString url; - }; - - struct Pusher - { - QString pushkey; - QString kind; - QString appId; - QString appDisplayName; - QString deviceDisplayName; - QString profileTag; - QString lang; - PusherData data; - }; - - // Construction/destruction - - explicit GetPushersJob(); - - /** Construct a URL out of baseUrl and usual parameters passed to - * GetPushersJob. 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 - - const QVector& pushers() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; - - class PostPusherJob : public BaseJob - { - public: - // Inner data structures - - struct PusherData - { - QString url; - }; - - // Construction/destruction - - explicit 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 = {}, bool append = {}); - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/receipts.cpp b/lib/jobs/generated/receipts.cpp deleted file mode 100644 index 945e8673..00000000 --- a/lib/jobs/generated/receipts.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "receipts.h" - -#include "converters.h" - -#include - -using namespace QMatrixClient; - -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, "PostReceiptJob", - basePath % "/rooms/" % roomId % "/receipt/" % receiptType % "/" % eventId) -{ - setRequestData(Data(toJson(receipt))); -} - diff --git a/lib/jobs/generated/receipts.h b/lib/jobs/generated/receipts.h deleted file mode 100644 index 9eb7a489..00000000 --- a/lib/jobs/generated/receipts.h +++ /dev/null @@ -1,21 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - -#include - - -namespace QMatrixClient -{ - // Operations - - class PostReceiptJob : public BaseJob - { - public: - explicit PostReceiptJob(const QString& roomId, const QString& receiptType, const QString& eventId, const QJsonObject& receipt = {}); - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/redaction.cpp b/lib/jobs/generated/redaction.cpp deleted file mode 100644 index 0da35dfc..00000000 --- a/lib/jobs/generated/redaction.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "redaction.h" - -#include "converters.h" - -#include - -using namespace QMatrixClient; - -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, "RedactEventJob", - basePath % "/rooms/" % roomId % "/redact/" % eventId % "/" % txnId) - , d(new Private) -{ - QJsonObject _data; - if (!reason.isEmpty()) - _data.insert("reason", toJson(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(); - d->eventId = fromJson(json.value("event_id")); - return Success; -} - diff --git a/lib/jobs/generated/redaction.h b/lib/jobs/generated/redaction.h deleted file mode 100644 index 974dfde5..00000000 --- a/lib/jobs/generated/redaction.h +++ /dev/null @@ -1,32 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - - - -namespace QMatrixClient -{ - // Operations - - class RedactEventJob : public BaseJob - { - public: - explicit RedactEventJob(const QString& roomId, const QString& eventId, const QString& txnId, const QString& reason = {}); - ~RedactEventJob() override; - - // Result properties - - const QString& eventId() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/room_send.cpp b/lib/jobs/generated/room_send.cpp deleted file mode 100644 index 9637a205..00000000 --- a/lib/jobs/generated/room_send.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "room_send.h" - -#include "converters.h" - -#include - -using namespace QMatrixClient; - -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, "SendMessageJob", - basePath % "/rooms/" % roomId % "/send/" % eventType % "/" % txnId) - , d(new Private) -{ - 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(); - d->eventId = fromJson(json.value("event_id")); - return Success; -} - diff --git a/lib/jobs/generated/room_send.h b/lib/jobs/generated/room_send.h deleted file mode 100644 index 370f2865..00000000 --- a/lib/jobs/generated/room_send.h +++ /dev/null @@ -1,33 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - -#include - - -namespace QMatrixClient -{ - // Operations - - class SendMessageJob : public BaseJob - { - public: - explicit SendMessageJob(const QString& roomId, const QString& eventType, const QString& txnId, const QJsonObject& body = {}); - ~SendMessageJob() override; - - // Result properties - - const QString& eventId() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/room_state.cpp b/lib/jobs/generated/room_state.cpp deleted file mode 100644 index 39f36afb..00000000 --- a/lib/jobs/generated/room_state.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "room_state.h" - -#include "converters.h" - -#include - -using namespace QMatrixClient; - -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, "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(); - d->eventId = fromJson(json.value("event_id")); - return Success; -} - -class SetRoomStateJob::Private -{ - public: - QString eventId; -}; - -SetRoomStateJob::SetRoomStateJob(const QString& roomId, const QString& eventType, const QJsonObject& body) - : BaseJob(HttpVerb::Put, "SetRoomStateJob", - basePath % "/rooms/" % roomId % "/state/" % eventType) - , d(new Private) -{ - 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(); - d->eventId = fromJson(json.value("event_id")); - return Success; -} - diff --git a/lib/jobs/generated/room_state.h b/lib/jobs/generated/room_state.h deleted file mode 100644 index aea32263..00000000 --- a/lib/jobs/generated/room_state.h +++ /dev/null @@ -1,51 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - -#include - - -namespace QMatrixClient -{ - // Operations - - class SetRoomStateWithKeyJob : public BaseJob - { - public: - explicit SetRoomStateWithKeyJob(const QString& roomId, const QString& eventType, const QString& stateKey, const QJsonObject& body = {}); - ~SetRoomStateWithKeyJob() override; - - // Result properties - - const QString& eventId() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; - - class SetRoomStateJob : public BaseJob - { - public: - explicit SetRoomStateJob(const QString& roomId, const QString& eventType, const QJsonObject& body = {}); - ~SetRoomStateJob() override; - - // Result properties - - const QString& eventId() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/tags.cpp b/lib/jobs/generated/tags.cpp deleted file mode 100644 index 9cd78aec..00000000 --- a/lib/jobs/generated/tags.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "tags.h" - -#include "converters.h" - -#include - -using namespace QMatrixClient; - -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -class GetRoomTagsJob::Private -{ - public: - QJsonObject tags; -}; - -QUrl GetRoomTagsJob::makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& roomId) -{ - return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/user/" % userId % "/rooms/" % roomId % "/tags"); -} - -GetRoomTagsJob::GetRoomTagsJob(const QString& userId, const QString& roomId) - : BaseJob(HttpVerb::Get, "GetRoomTagsJob", - basePath % "/user/" % userId % "/rooms/" % roomId % "/tags") - , d(new Private) -{ -} - -GetRoomTagsJob::~GetRoomTagsJob() = default; - -const QJsonObject& GetRoomTagsJob::tags() const -{ - return d->tags; -} - -BaseJob::Status GetRoomTagsJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - d->tags = fromJson(json.value("tags")); - return Success; -} - -SetRoomTagJob::SetRoomTagJob(const QString& userId, const QString& roomId, const QString& tag, const QJsonObject& body) - : BaseJob(HttpVerb::Put, "SetRoomTagJob", - basePath % "/user/" % userId % "/rooms/" % roomId % "/tags/" % tag) -{ - setRequestData(Data(toJson(body))); -} - -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); -} - -DeleteRoomTagJob::DeleteRoomTagJob(const QString& userId, const QString& roomId, const QString& tag) - : BaseJob(HttpVerb::Delete, "DeleteRoomTagJob", - basePath % "/user/" % userId % "/rooms/" % roomId % "/tags/" % tag) -{ -} - diff --git a/lib/jobs/generated/tags.h b/lib/jobs/generated/tags.h deleted file mode 100644 index f62bd7ad..00000000 --- a/lib/jobs/generated/tags.h +++ /dev/null @@ -1,61 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - -#include - - -namespace QMatrixClient -{ - // Operations - - class GetRoomTagsJob : public BaseJob - { - public: - explicit GetRoomTagsJob(const QString& userId, const QString& roomId); - - /** Construct a URL out of baseUrl and usual parameters passed to - * GetRoomTagsJob. 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 - - const QJsonObject& tags() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; - - class SetRoomTagJob : public BaseJob - { - public: - explicit SetRoomTagJob(const QString& userId, const QString& roomId, const QString& tag, const QJsonObject& body = {}); - }; - - class DeleteRoomTagJob : public BaseJob - { - public: - explicit DeleteRoomTagJob(const QString& userId, const QString& roomId, const QString& tag); - - /** Construct a URL out of baseUrl and usual parameters passed to - * DeleteRoomTagJob. 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); - - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/third_party_membership.cpp b/lib/jobs/generated/third_party_membership.cpp deleted file mode 100644 index b637d481..00000000 --- a/lib/jobs/generated/third_party_membership.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "third_party_membership.h" - -#include "converters.h" - -#include - -using namespace QMatrixClient; - -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -InviteBy3PIDJob::InviteBy3PIDJob(const QString& roomId, const QString& idServer, const QString& medium, const QString& address) - : BaseJob(HttpVerb::Post, "InviteBy3PIDJob", - basePath % "/rooms/" % roomId % "/invite") -{ - QJsonObject _data; - _data.insert("id_server", toJson(idServer)); - _data.insert("medium", toJson(medium)); - _data.insert("address", toJson(address)); - setRequestData(_data); -} - diff --git a/lib/jobs/generated/third_party_membership.h b/lib/jobs/generated/third_party_membership.h deleted file mode 100644 index c7b5214e..00000000 --- a/lib/jobs/generated/third_party_membership.h +++ /dev/null @@ -1,20 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - - - -namespace QMatrixClient -{ - // Operations - - class InviteBy3PIDJob : public BaseJob - { - public: - explicit InviteBy3PIDJob(const QString& roomId, const QString& idServer, const QString& medium, const QString& address); - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/to_device.cpp b/lib/jobs/generated/to_device.cpp deleted file mode 100644 index e893fa44..00000000 --- a/lib/jobs/generated/to_device.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "to_device.h" - -#include "converters.h" - -#include - -using namespace QMatrixClient; - -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -SendToDeviceJob::SendToDeviceJob(const QString& eventType, const QString& txnId, const QHash>& messages) - : BaseJob(HttpVerb::Put, "SendToDeviceJob", - basePath % "/sendToDevice/" % eventType % "/" % txnId) -{ - QJsonObject _data; - _data.insert("messages", toJson(messages)); - setRequestData(_data); -} - diff --git a/lib/jobs/generated/to_device.h b/lib/jobs/generated/to_device.h deleted file mode 100644 index f5910e44..00000000 --- a/lib/jobs/generated/to_device.h +++ /dev/null @@ -1,22 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - -#include -#include - - -namespace QMatrixClient -{ - // Operations - - class SendToDeviceJob : public BaseJob - { - public: - explicit SendToDeviceJob(const QString& eventType, const QString& txnId, const QHash>& messages = {}); - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/typing.cpp b/lib/jobs/generated/typing.cpp deleted file mode 100644 index fa700290..00000000 --- a/lib/jobs/generated/typing.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "typing.h" - -#include "converters.h" - -#include - -using namespace QMatrixClient; - -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -SetTypingJob::SetTypingJob(const QString& userId, const QString& roomId, bool typing, int timeout) - : BaseJob(HttpVerb::Put, "SetTypingJob", - basePath % "/rooms/" % roomId % "/typing/" % userId) -{ - QJsonObject _data; - _data.insert("typing", toJson(typing)); - _data.insert("timeout", toJson(timeout)); - setRequestData(_data); -} - diff --git a/lib/jobs/generated/typing.h b/lib/jobs/generated/typing.h deleted file mode 100644 index 0495ed0a..00000000 --- a/lib/jobs/generated/typing.h +++ /dev/null @@ -1,20 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - - - -namespace QMatrixClient -{ - // Operations - - class SetTypingJob : public BaseJob - { - public: - explicit SetTypingJob(const QString& userId, const QString& roomId, bool typing, int timeout = {}); - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/users.cpp b/lib/jobs/generated/users.cpp deleted file mode 100644 index fd2944e4..00000000 --- a/lib/jobs/generated/users.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "users.h" - -#include - -using namespace QMatrixClient; - -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -namespace QMatrixClient -{ - // Converters - - template <> struct FromJson - { - SearchUserDirectoryJob::User operator()(const QJsonValue& jv) - { - const auto& o = jv.toObject(); - SearchUserDirectoryJob::User result; - result.userId = - fromJson(o.value("user_id")); - result.displayName = - fromJson(o.value("display_name")); - result.avatarUrl = - fromJson(o.value("avatar_url")); - - return result; - } - }; -} // namespace QMatrixClient - -class SearchUserDirectoryJob::Private -{ - public: - QVector results; - bool limited; -}; - -SearchUserDirectoryJob::SearchUserDirectoryJob(const QString& searchTerm, int limit) - : BaseJob(HttpVerb::Post, "SearchUserDirectoryJob", - basePath % "/user_directory/search") - , d(new Private) -{ - QJsonObject _data; - _data.insert("search_term", toJson(searchTerm)); - _data.insert("limit", toJson(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")) - return { JsonParseError, - "The key 'results' not found in the response" }; - d->results = fromJson>(json.value("results")); - if (!json.contains("limited")) - return { JsonParseError, - "The key 'limited' not found in the response" }; - d->limited = fromJson(json.value("limited")); - return Success; -} - diff --git a/lib/jobs/generated/users.h b/lib/jobs/generated/users.h deleted file mode 100644 index fa0d4335..00000000 --- a/lib/jobs/generated/users.h +++ /dev/null @@ -1,46 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - -#include - -#include "converters.h" - -namespace QMatrixClient -{ - // Operations - - class SearchUserDirectoryJob : public BaseJob - { - public: - // Inner data structures - - struct User - { - QString userId; - QString displayName; - QString avatarUrl; - }; - - // Construction/destruction - - explicit SearchUserDirectoryJob(const QString& searchTerm, int limit = {}); - ~SearchUserDirectoryJob() override; - - // Result properties - - const QVector& results() const; - bool limited() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/versions.cpp b/lib/jobs/generated/versions.cpp deleted file mode 100644 index 7b55b94f..00000000 --- a/lib/jobs/generated/versions.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "versions.h" - -#include "converters.h" - -#include - -using namespace QMatrixClient; - -static const auto basePath = QStringLiteral("/_matrix/client"); - -class GetVersionsJob::Private -{ - public: - QStringList versions; -}; - -QUrl GetVersionsJob::makeRequestUrl(QUrl baseUrl) -{ - return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/versions"); -} - -GetVersionsJob::GetVersionsJob() - : BaseJob(HttpVerb::Get, "GetVersionsJob", - basePath % "/versions", false) - , d(new Private) -{ -} - -GetVersionsJob::~GetVersionsJob() = default; - -const QStringList& GetVersionsJob::versions() const -{ - return d->versions; -} - -BaseJob::Status GetVersionsJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - d->versions = fromJson(json.value("versions")); - return Success; -} - diff --git a/lib/jobs/generated/versions.h b/lib/jobs/generated/versions.h deleted file mode 100644 index 4fe8d9d0..00000000 --- a/lib/jobs/generated/versions.h +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - -#include - - -namespace QMatrixClient -{ - // Operations - - class GetVersionsJob : public BaseJob - { - public: - explicit GetVersionsJob(); - - /** Construct a URL out of baseUrl and usual parameters passed to - * GetVersionsJob. 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 - - const QStringList& versions() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; -} // namespace QMatrixClient diff --git a/lib/jobs/generated/whoami.cpp b/lib/jobs/generated/whoami.cpp deleted file mode 100644 index 4c231b5f..00000000 --- a/lib/jobs/generated/whoami.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "whoami.h" - -#include "converters.h" - -#include - -using namespace QMatrixClient; - -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"); -} - -GetTokenOwnerJob::GetTokenOwnerJob() - : BaseJob(HttpVerb::Get, "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) -{ - auto json = data.object(); - if (!json.contains("user_id")) - return { JsonParseError, - "The key 'user_id' not found in the response" }; - d->userId = fromJson(json.value("user_id")); - return Success; -} - diff --git a/lib/jobs/generated/whoami.h b/lib/jobs/generated/whoami.h deleted file mode 100644 index 2b0e7375..00000000 --- a/lib/jobs/generated/whoami.h +++ /dev/null @@ -1,40 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#pragma once - -#include "../basejob.h" - - - -namespace QMatrixClient -{ - // Operations - - class GetTokenOwnerJob : public BaseJob - { - public: - explicit GetTokenOwnerJob(); - - /** Construct a URL out of baseUrl and usual parameters passed to - * GetTokenOwnerJob. 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 - - const QString& userId() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer d; - }; -} // namespace QMatrixClient diff --git a/lib/jobs/gtad.yaml b/lib/jobs/gtad.yaml deleted file mode 100644 index 7f6a97e0..00000000 --- a/lib/jobs/gtad.yaml +++ /dev/null @@ -1,139 +0,0 @@ -analyzer: - subst: - "%CLIENT_RELEASE_LABEL%": r0 - "%CLIENT_MAJOR_VERSION%": r0 - identifiers: - signed: signedData - unsigned: unsignedData - default: isDefault - origin_server_ts: originServerTimestamp # Instead of originServerTs - start: begin # Because start() is a method in BaseJob - - types: - # Structure: - # swaggerType: - # OR - # swaggerType: - # - swaggerFormat: - # - /swaggerFormatRegEx/: - # - //: # default, if the format doesn't mach anything above - # WHERE - # targetTypeSpec = targetType OR - # { type: targetType, imports: , } - integer: - - int64: qint64 - - int32: qint32 - - //: int - number: - - float: float - - //: double - boolean: { type: bool, initializer: false } - string: - - byte: &ByteStream - type: QIODevice* - #initializer: '"{{defaultValue}}"' - #string?: true - imports: - - binary: *ByteStream - - date: - type: QDate - initializer: QDate::fromString("{{defaultValue}}") - avoidCopy?: true - imports: - - dateTime: - type: QDateTime - initializer: QDateTime::fromString("{{defaultValue}}") - avoidCopy?: true - imports: - - //: - type: QString - initializer: QStringLiteral("{{defaultValue}}") - string?: true - avoidCopy?: true - file: *ByteStream - object: - - /m\.room\.member$/: # A stub for EventsBatch - - /state_event.yaml$/: - type: StateEventPtr - noCopy?: true - imports: '"events/event.h"' - - /room_event.yaml$/: - type: RoomEventPtr - noCopy?: true - imports: '"events/event.h"' - - /event.yaml$/: - type: EventPtr - noCopy?: true - imports: '"events/event.h"' - - //: - type: QJsonObject - avoidCopy?: true - imports: - array: - - string: - type: QStringList - avoidCopy?: true - imports: - - /^Notification|Result$/: - type: "std::vector<{{1}}>" - noCopy?: true - imports: '"events/event.h"' - - /m\.room\.member$/: - type: "EventsArray" - noCopy?: true - imports: '"events/roommemberevent.h"' - - /state_event.yaml$/: - type: StateEvents - noCopy?: true - - /room_event.yaml$/: - type: RoomEvents - noCopy?: true - - /event.yaml$/: - type: Events - noCopy?: true - - /.+/: - type: "QVector<{{1}}>" - avoidCopy?: true - imports: - - //: { type: QJsonArray, "avoidCopy?": true, imports: } - map: - - RoomState: - type: "std::unordered_map" - noCopy?: true - imports: - - /.+/: - type: "QHash" - avoidCopy?: true - imports: - - //: - type: QVariantHash - avoidCopy?: true - imports: - variant: { type: QVariant, "avoidCopy?": true, imports: } - schema: # Properties of inline structure definitions - avoidCopy?: true - - #operations: - -mustache: - definitions: - _scopeRenderer: "{{scopeCamelCase}}Job::" - _literalQuote: '"' - maybeCrefType: "{{#avoidCopy?}}const {{/avoidCopy?}}{{dataType.name}}{{#avoidCopy?}}&{{/avoidCopy?}}{{#noCopy?}}&&{{/noCopy?}}" - qualifiedMaybeCrefType: - "{{#avoidCopy?}}const {{/avoidCopy?}}{{dataType.qualifiedName}}{{#avoidCopy?}}&{{/avoidCopy?}}{{#noCopy?}}&&{{/noCopy?}}" - initializeDefaultValue: "{{#defaultValue}}{{>initializer}}{{/defaultValue}}{{^defaultValue}}{}{{/defaultValue}}" - joinedParamDecl: '{{>maybeCrefType}} {{paramName}}{{^required?}} = {{>initializeDefaultValue}}{{/required?}}{{#@join}}, {{/@join}}' - joinedParamDef: '{{>maybeCrefType}} {{paramName}}{{#@join}}, {{/@join}}' - passQueryParams: '{{#queryParams}}{{paramName}}{{#@join}}, {{/@join}}{{/queryParams}}' - paramToString: '{{#string?}}{{nameCamelCase}}{{/string?}}{{^string?}}QString("%1").arg({{nameCamelCase}}){{/string?}}' - # preamble: preamble.mustache - copyrightName: Kitsune Ral - copyrightEmail: - - templates: - - "{{base}}.h.mustache" - - "{{base}}.cpp.mustache" - - #outFilesList: apifiles.txt - diff --git a/lib/jobs/mediathumbnailjob.h b/lib/jobs/mediathumbnailjob.h index 6e0b94f3..7963796e 100644 --- a/lib/jobs/mediathumbnailjob.h +++ b/lib/jobs/mediathumbnailjob.h @@ -18,7 +18,7 @@ #pragma once -#include "generated/content-repo.h" +#include "csapi/content-repo.h" #include diff --git a/lib/jobs/preamble.mustache b/lib/jobs/preamble.mustache deleted file mode 100644 index 3ba87d61..00000000 --- a/lib/jobs/preamble.mustache +++ /dev/null @@ -1,3 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ diff --git a/lib/jobs/{{base}}.cpp.mustache b/lib/jobs/{{base}}.cpp.mustache deleted file mode 100644 index d3726f1e..00000000 --- a/lib/jobs/{{base}}.cpp.mustache +++ /dev/null @@ -1,121 +0,0 @@ -{{#@filePartial}}preamble{{/@filePartial}} -#include "{{filenameBase}}.h" -{{^allModels}} -#include "converters.h" -{{/allModels}}{{#operations}} -{{#producesNonJson?}}#include -{{/producesNonJson?}}#include -{{/operations}} -using namespace QMatrixClient; -{{#models.model}}{{#in?}} -QJsonObject QMatrixClient::toJson(const {{qualifiedName}}& pod) -{ - QJsonObject o; -{{#vars}} o.insert("{{baseName}}", toJson(pod.{{nameCamelCase}})); -{{/vars}} - return o; -} -{{/in?}}{{#out?}} -{{qualifiedName}} FromJson<{{qualifiedName}}>::operator()(const QJsonValue& jv) -{ - const auto& o = jv.toObject(); - {{qualifiedName}} result; - {{#vars}}result.{{nameCamelCase}} = - fromJson<{{dataType.name}}>(o.value("{{baseName}}")); - {{/vars}} - return result; -} -{{/out?}}{{/models.model}}{{#operations}} -static const auto basePath = QStringLiteral("{{basePathWithoutHost}}"); -{{# operation}}{{#models}} -namespace QMatrixClient -{ - // Converters -{{#model}}{{#in?}} - QJsonObject toJson(const {{qualifiedName}}& pod) - { - QJsonObject o; -{{#vars}} o.insert("{{baseName}}", toJson(pod.{{nameCamelCase}})); -{{/vars}} - return o; - } -{{/in?}}{{#out?}} - template <> struct FromJson<{{qualifiedName}}> - { - {{qualifiedName}} operator()(const QJsonValue& jv) - { - const auto& o = jv.toObject(); - {{qualifiedName}} result; -{{#vars}} result.{{nameCamelCase}} = - fromJson<{{dataType.qualifiedName}}>(o.value("{{baseName}}")); -{{/vars}} - return result; - } - }; -{{/out?}}{{/model}}} // namespace QMatrixClient -{{/ models}}{{#responses}}{{#normalResponse?}}{{#allProperties?}} -class {{camelCaseOperationId}}Job::Private -{ - public:{{#allProperties}} - {{dataType.name}} {{paramName}};{{/allProperties}} -}; -{{/ allProperties?}}{{/normalResponse?}}{{/responses}}{{#queryParams?}} -BaseJob::Query queryTo{{camelCaseOperationId}}({{#queryParams}}{{>joinedParamDef}}{{/queryParams}}) -{ - BaseJob::Query _q;{{#queryParams}} -{{^required?}}{{#string?}} if (!{{nameCamelCase}}.isEmpty()) - {{/string?}}{{/required?}} _q.addQueryItem("{{baseName}}", {{>paramToString}});{{/queryParams}} - return _q; -} -{{/queryParams?}}{{^bodyParams}} -QUrl {{camelCaseOperationId}}Job::makeRequestUrl(QUrl baseUrl{{#allParams?}}, {{#allParams}}{{>joinedParamDef}}{{/allParams}}{{/allParams?}}) -{ - return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath{{#pathParts}} % {{_}}{{/pathParts}}{{#queryParams?}}, - queryTo{{camelCaseOperationId}}({{>passQueryParams}}){{/queryParams?}}); -} -{{/ bodyParams}} -{{camelCaseOperationId}}Job::{{camelCaseOperationId}}Job({{#allParams}}{{>joinedParamDef}}{{/allParams}}) - : BaseJob(HttpVerb::{{#@cap}}{{#@tolower}}{{httpMethod}}{{/@tolower}}{{/@cap}}, "{{camelCaseOperationId}}Job", - basePath{{#pathParts}} % {{_}}{{/pathParts}}{{#queryParams?}}, - queryTo{{camelCaseOperationId}}({{>passQueryParams}}){{/queryParams?}}{{#skipAuth}}{{#queryParams?}}, - {}{{/queryParams?}}, false{{/skipAuth}}){{#responses}}{{#normalResponse?}}{{#allProperties?}} - , d(new Private){{/allProperties?}}{{/normalResponse?}}{{/responses}} -{ -{{#headerParams?}}{{#headerParams}} setRequestHeader("{{baseName}}", {{paramName}}.toLatin1()); -{{/headerParams}} -{{/headerParams? -}}{{#bodyParams? -}}{{#inlineBody}} setRequestData(Data({{! - }}{{#consumesNonJson?}}{{nameCamelCase}}{{/consumesNonJson? - }}{{^consumesNonJson?}}toJson({{nameCamelCase}}){{/consumesNonJson?}}));{{/inlineBody -}}{{^inlineBody}} QJsonObject _data;{{#bodyParams}} -{{^required?}}{{#string?}} if (!{{paramName}}.isEmpty()) - {{/string?}}{{/required?}} _data.insert("{{baseName}}", toJson({{paramName}}));{{/bodyParams}} - setRequestData(_data);{{/inlineBody}} -{{/bodyParams?}}{{#producesNonJson?}} setExpectedContentTypes({ {{#produces}}"{{_}}"{{#@join}}, {{/@join}}{{/produces}} }); -{{/producesNonJson?}}}{{!<- mind the actual brace}} -{{# responses}}{{#normalResponse?}}{{#allProperties?}} -{{camelCaseOperationId}}Job::~{{camelCaseOperationId}}Job() = default; -{{# allProperties}} -{{>qualifiedMaybeCrefType}} {{camelCaseOperationId}}Job::{{paramName}}(){{^noCopy?}} const{{/noCopy?}} -{ - return {{#noCopy?}}std::move({{/noCopy?}}d->{{paramName}}{{#noCopy?}}){{/noCopy?}}; -} -{{/ allProperties}}{{#producesNonJson?}} -BaseJob::Status {{camelCaseOperationId}}Job::parseReply(QNetworkReply* reply) -{ - {{#headers}}d->{{paramName}} = reply->rawHeader("{{baseName}}"); {{! We don't check for required headers yet }} - {{/headers}}{{#properties}}d->{{paramName}} = reply;{{/properties}} - return Success; -}{{/ producesNonJson?}}{{^producesNonJson?}} -BaseJob::Status {{camelCaseOperationId}}Job::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - {{# properties}}{{#required?}}if (!json.contains("{{baseName}}")) - return { JsonParseError, - "The key '{{baseName}}' not found in the response" }; - {{/required?}}d->{{paramName}} = fromJson<{{dataType.name}}>(json.value("{{baseName}}")); - {{/ properties}}return Success; -}{{/ producesNonJson?}} -{{/allProperties?}}{{/normalResponse?}}{{/responses}}{{/operation}}{{/operations}} diff --git a/lib/jobs/{{base}}.h.mustache b/lib/jobs/{{base}}.h.mustache deleted file mode 100644 index e4f45d85..00000000 --- a/lib/jobs/{{base}}.h.mustache +++ /dev/null @@ -1,63 +0,0 @@ -{{#@filePartial}}preamble{{/@filePartial}} -#pragma once - -{{#operations}}#include "../basejob.h" -{{/operations}} -{{#imports}}#include {{_}} -{{/imports}} -{{#allModels}}#include "converters.h" -{{/allModels}} -namespace QMatrixClient -{ -{{#models}} // Data structures -{{# model}} - struct {{name}}{{#parents?}} : {{#parents}}{{name}}{{#@join}}, {{/@join}}{{/parents}}{{/parents?}} - { -{{#vars}} {{dataType.name}} {{nameCamelCase}}; -{{/vars}} }; -{{#in?}} - QJsonObject toJson(const {{name}}& pod); -{{/in?}}{{#out?}} - template <> struct FromJson<{{name}}> - { - {{name}} operator()(const QJsonValue& jv); - }; -{{/ out?}}{{/model}} -{{/models}}{{#operations}} // Operations -{{# operation}} - class {{camelCaseOperationId}}Job : public BaseJob - { - public:{{#models}} - // Inner data structures -{{# model}} - struct {{name}}{{#parents?}} : {{#parents}}{{name}}{{#@join}}, {{/@join}}{{/parents}}{{/parents?}} - { -{{#vars}} {{dataType.name}} {{nameCamelCase}}; -{{/vars}} }; -{{/ model}} - // Construction/destruction -{{/ models}} - explicit {{camelCaseOperationId}}Job({{#allParams}}{{>joinedParamDecl}}{{/allParams}});{{^bodyParams}} - - /** Construct a URL out of baseUrl and usual parameters passed to - * {{camelCaseOperationId}}Job. This function can be used when - * a URL for {{camelCaseOperationId}}Job is necessary but the job - * itself isn't. - */ - static QUrl makeRequestUrl(QUrl baseUrl{{#allParams?}}, {{#allParams}}{{>joinedParamDecl}}{{/allParams}}{{/allParams?}}); -{{/bodyParams}}{{# responses}}{{#normalResponse?}}{{#allProperties?}} - ~{{camelCaseOperationId}}Job() override; - - // Result properties -{{#allProperties}} - {{>maybeCrefType}} {{paramName}}(){{^noCopy?}} const{{/noCopy?}};{{/allProperties}} - - protected: - Status {{#producesNonJson?}}parseReply(QNetworkReply* reply){{/producesNonJson?}}{{^producesNonJson?}}parseJson(const QJsonDocument& data){{/producesNonJson?}} override; - - private: - class Private; - QScopedPointer d;{{/allProperties?}}{{/normalResponse?}}{{/responses}} - }; -{{/operation}}{{/operations}}{{!skip EOL -}}} // namespace QMatrixClient -- cgit v1.2.3