aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/jobs/basejob.cpp1
-rw-r--r--lib/jobs/generated/list_joined_rooms.cpp50
-rw-r--r--lib/jobs/generated/list_joined_rooms.h38
-rw-r--r--lib/jobs/generated/pusher.cpp153
-rw-r--r--lib/jobs/generated/pusher.h81
-rw-r--r--lib/jobs/generated/room_send.cpp42
-rw-r--r--lib/jobs/generated/room_send.h31
-rw-r--r--lib/jobs/generated/tags.cpp66
-rw-r--r--lib/jobs/generated/tags.h57
-rw-r--r--lib/jobs/generated/to_device.cpp23
-rw-r--r--lib/jobs/generated/to_device.h21
-rw-r--r--lib/jobs/generated/users.cpp85
-rw-r--r--lib/jobs/generated/users.h46
-rw-r--r--lib/jobs/gtad.yaml87
-rw-r--r--lib/jobs/preamble.mustache3
-rw-r--r--lib/jobs/{{base}}.cpp.mustache116
-rw-r--r--lib/jobs/{{base}}.h.mustache67
17 files changed, 966 insertions, 1 deletions
diff --git a/lib/jobs/basejob.cpp b/lib/jobs/basejob.cpp
index 4e35cb01..696861fb 100644
--- a/lib/jobs/basejob.cpp
+++ b/lib/jobs/basejob.cpp
@@ -25,7 +25,6 @@
#include <QtNetwork/QNetworkReply>
#include <QtCore/QTimer>
#include <QtCore/QRegularExpression>
-//#include <QtCore/QStringBuilder>
#include <array>
diff --git a/lib/jobs/generated/list_joined_rooms.cpp b/lib/jobs/generated/list_joined_rooms.cpp
new file mode 100644
index 00000000..f902f94c
--- /dev/null
+++ b/lib/jobs/generated/list_joined_rooms.cpp
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "list_joined_rooms.h"
+
+#include "converters.h"
+
+#include <QtCore/QStringBuilder>
+
+using namespace QMatrixClient;
+
+static const auto basePath = QStringLiteral("/_matrix/client/r0");
+
+class GetJoinedRoomsJob::Private
+{
+ public:
+ QVector<QString> joinedRooms;
+};
+
+QUrl GetJoinedRoomsJob::makeRequestUrl(QUrl baseUrl)
+{
+ return BaseJob::makeRequestUrl(baseUrl,
+ basePath % "/joined_rooms");
+}
+
+GetJoinedRoomsJob::GetJoinedRoomsJob()
+ : BaseJob(HttpVerb::Get, "GetJoinedRoomsJob",
+ basePath % "/joined_rooms")
+ , d(new Private)
+{
+}
+
+GetJoinedRoomsJob::~GetJoinedRoomsJob() = default;
+
+const QVector<QString>& 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<QVector<QString>>(json.value("joined_rooms"));
+ return Success;
+}
+
diff --git a/lib/jobs/generated/list_joined_rooms.h b/lib/jobs/generated/list_joined_rooms.h
new file mode 100644
index 00000000..768f5166
--- /dev/null
+++ b/lib/jobs/generated/list_joined_rooms.h
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "../basejob.h"
+
+#include <QtCore/QVector>
+
+
+namespace QMatrixClient
+{
+ // Operations
+
+ class GetJoinedRoomsJob : public BaseJob
+ {
+ public:
+ /** 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);
+
+ explicit GetJoinedRoomsJob();
+ ~GetJoinedRoomsJob() override;
+
+ const QVector<QString>& joinedRooms() const;
+
+ protected:
+ Status parseJson(const QJsonDocument& data) override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> d;
+ };
+} // namespace QMatrixClient
diff --git a/lib/jobs/generated/pusher.cpp b/lib/jobs/generated/pusher.cpp
new file mode 100644
index 00000000..4fddac45
--- /dev/null
+++ b/lib/jobs/generated/pusher.cpp
@@ -0,0 +1,153 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "pusher.h"
+
+#include <QtCore/QStringBuilder>
+
+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
+{
+ template <> struct FromJson<GetPushersJob::PusherData>
+ {
+ GetPushersJob::PusherData operator()(QJsonValue jv)
+ {
+ QJsonObject o = jv.toObject();
+ GetPushersJob::PusherData result;
+ result.url =
+ fromJson<QString>(o.value("url"));
+
+ return result;
+ }
+ };
+} // 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
+{
+ template <> struct FromJson<GetPushersJob::Pusher>
+ {
+ GetPushersJob::Pusher operator()(QJsonValue jv)
+ {
+ QJsonObject o = jv.toObject();
+ GetPushersJob::Pusher result;
+ result.pushkey =
+ fromJson<QString>(o.value("pushkey"));
+ result.kind =
+ fromJson<QString>(o.value("kind"));
+ result.appId =
+ fromJson<QString>(o.value("app_id"));
+ result.appDisplayName =
+ fromJson<QString>(o.value("app_display_name"));
+ result.deviceDisplayName =
+ fromJson<QString>(o.value("device_display_name"));
+ result.profileTag =
+ fromJson<QString>(o.value("profile_tag"));
+ result.lang =
+ fromJson<QString>(o.value("lang"));
+ result.data =
+ fromJson<GetPushersJob::PusherData>(o.value("data"));
+
+ return result;
+ }
+ };
+} // namespace QMatrixClient
+
+class GetPushersJob::Private
+{
+ public:
+ QVector<Pusher> pushers;
+};
+
+QUrl GetPushersJob::makeRequestUrl(QUrl baseUrl)
+{
+ return BaseJob::makeRequestUrl(baseUrl,
+ basePath % "/pushers");
+}
+
+GetPushersJob::GetPushersJob()
+ : BaseJob(HttpVerb::Get, "GetPushersJob",
+ basePath % "/pushers")
+ , d(new Private)
+{
+}
+
+GetPushersJob::~GetPushersJob() = default;
+
+const QVector<GetPushersJob::Pusher>& GetPushersJob::pushers() const
+{
+ return d->pushers;
+}
+
+BaseJob::Status GetPushersJob::parseJson(const QJsonDocument& data)
+{
+ auto json = data.object();
+ d->pushers = fromJson<QVector<Pusher>>(json.value("pushers"));
+ return Success;
+}
+
+PostPusherJob::PusherData::operator QJsonObject() const
+{
+ QJsonObject o;
+ o.insert("url", toJson(url));
+
+ return o;
+}
+namespace QMatrixClient
+{
+ template <> struct FromJson<PostPusherJob::PusherData>
+ {
+ PostPusherJob::PusherData operator()(QJsonValue jv)
+ {
+ QJsonObject o = jv.toObject();
+ PostPusherJob::PusherData result;
+ result.url =
+ fromJson<QString>(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)
+ : 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
new file mode 100644
index 00000000..36576996
--- /dev/null
+++ b/lib/jobs/generated/pusher.h
@@ -0,0 +1,81 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "../basejob.h"
+
+#include <QtCore/QVector>
+
+#include "converters.h"
+
+namespace QMatrixClient
+{
+ // Operations
+
+ class GetPushersJob : public BaseJob
+ {
+ public:
+ // Inner data structures
+
+ struct PusherData
+ {
+ QString url;
+
+ operator QJsonObject() const;
+ };
+
+ struct Pusher
+ {
+ QString pushkey;
+ QString kind;
+ QString appId;
+ QString appDisplayName;
+ QString deviceDisplayName;
+ QString profileTag;
+ QString lang;
+ PusherData data;
+
+ operator QJsonObject() const;
+ };
+
+ // End of inner data structures
+
+ /** 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);
+
+ explicit GetPushersJob();
+ ~GetPushersJob() override;
+
+ const QVector<Pusher>& pushers() const;
+
+ protected:
+ Status parseJson(const QJsonDocument& data) override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> d;
+ };
+
+ class PostPusherJob : public BaseJob
+ {
+ public:
+ // Inner data structures
+
+ struct PusherData
+ {
+ QString url;
+
+ operator QJsonObject() const;
+ };
+
+ // End of inner data structures
+
+ 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/room_send.cpp b/lib/jobs/generated/room_send.cpp
new file mode 100644
index 00000000..c9a3280d
--- /dev/null
+++ b/lib/jobs/generated/room_send.cpp
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "room_send.h"
+
+#include "converters.h"
+
+#include <QtCore/QStringBuilder>
+
+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(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<QString>(json.value("event_id"));
+ return Success;
+}
+
diff --git a/lib/jobs/generated/room_send.h b/lib/jobs/generated/room_send.h
new file mode 100644
index 00000000..d20ce523
--- /dev/null
+++ b/lib/jobs/generated/room_send.h
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "../basejob.h"
+
+#include <QtCore/QJsonObject>
+
+
+namespace QMatrixClient
+{
+ // Operations
+
+ class SendMessageJob : public BaseJob
+ {
+ public:
+ explicit SendMessageJob(const QString& roomId, const QString& eventType, const QString& txnId, const QJsonObject& body = {});
+ ~SendMessageJob() override;
+
+ const QString& eventId() const;
+
+ protected:
+ Status parseJson(const QJsonDocument& data) override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> d;
+ };
+} // namespace QMatrixClient
diff --git a/lib/jobs/generated/tags.cpp b/lib/jobs/generated/tags.cpp
new file mode 100644
index 00000000..dc4faf04
--- /dev/null
+++ b/lib/jobs/generated/tags.cpp
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "tags.h"
+
+#include "converters.h"
+
+#include <QtCore/QStringBuilder>
+
+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(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<QJsonObject>(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(body));
+}
+
+QUrl DeleteRoomTagJob::makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& roomId, const QString& tag)
+{
+ return BaseJob::makeRequestUrl(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
new file mode 100644
index 00000000..7a375527
--- /dev/null
+++ b/lib/jobs/generated/tags.h
@@ -0,0 +1,57 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "../basejob.h"
+
+#include <QtCore/QJsonObject>
+
+
+namespace QMatrixClient
+{
+ // Operations
+
+ class GetRoomTagsJob : public BaseJob
+ {
+ public:
+ /** 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);
+
+ explicit GetRoomTagsJob(const QString& userId, const QString& roomId);
+ ~GetRoomTagsJob() override;
+
+ const QJsonObject& tags() const;
+
+ protected:
+ Status parseJson(const QJsonDocument& data) override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> 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:
+ /** 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);
+
+ explicit DeleteRoomTagJob(const QString& userId, const QString& roomId, const QString& tag);
+ };
+} // namespace QMatrixClient
diff --git a/lib/jobs/generated/to_device.cpp b/lib/jobs/generated/to_device.cpp
new file mode 100644
index 00000000..cfb860c7
--- /dev/null
+++ b/lib/jobs/generated/to_device.cpp
@@ -0,0 +1,23 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "to_device.h"
+
+#include "converters.h"
+
+#include <QtCore/QStringBuilder>
+
+using namespace QMatrixClient;
+
+static const auto basePath = QStringLiteral("/_matrix/client/r0");
+
+SendToDeviceJob::SendToDeviceJob(const QString& eventType, const QString& txnId, const QJsonObject& 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
new file mode 100644
index 00000000..0de8fb0a
--- /dev/null
+++ b/lib/jobs/generated/to_device.h
@@ -0,0 +1,21 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "../basejob.h"
+
+#include <QtCore/QJsonObject>
+
+
+namespace QMatrixClient
+{
+ // Operations
+
+ class SendToDeviceJob : public BaseJob
+ {
+ public:
+ explicit SendToDeviceJob(const QString& eventType, const QString& txnId, const QJsonObject& messages = {});
+ };
+} // namespace QMatrixClient
diff --git a/lib/jobs/generated/users.cpp b/lib/jobs/generated/users.cpp
new file mode 100644
index 00000000..33da4b43
--- /dev/null
+++ b/lib/jobs/generated/users.cpp
@@ -0,0 +1,85 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "users.h"
+
+#include <QtCore/QStringBuilder>
+
+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
+{
+ template <> struct FromJson<SearchUserDirectoryJob::User>
+ {
+ SearchUserDirectoryJob::User operator()(QJsonValue jv)
+ {
+ QJsonObject o = jv.toObject();
+ SearchUserDirectoryJob::User result;
+ result.userId =
+ fromJson<QString>(o.value("user_id"));
+ result.displayName =
+ fromJson<QString>(o.value("display_name"));
+ result.avatarUrl =
+ fromJson<QString>(o.value("avatar_url"));
+
+ return result;
+ }
+ };
+} // namespace QMatrixClient
+
+class SearchUserDirectoryJob::Private
+{
+ public:
+ QVector<User> results;
+ bool limited;
+};
+
+SearchUserDirectoryJob::SearchUserDirectoryJob(const QString& searchTerm, double 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::User>& 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<QVector<User>>(json.value("results"));
+ if (!json.contains("limited"))
+ return { JsonParseError,
+ "The key 'limited' not found in the response" };
+ d->limited = fromJson<bool>(json.value("limited"));
+ return Success;
+}
+
diff --git a/lib/jobs/generated/users.h b/lib/jobs/generated/users.h
new file mode 100644
index 00000000..7be250a5
--- /dev/null
+++ b/lib/jobs/generated/users.h
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "../basejob.h"
+
+#include <QtCore/QVector>
+
+#include "converters.h"
+
+namespace QMatrixClient
+{
+ // Operations
+
+ class SearchUserDirectoryJob : public BaseJob
+ {
+ public:
+ // Inner data structures
+
+ struct User
+ {
+ QString userId;
+ QString displayName;
+ QString avatarUrl;
+
+ operator QJsonObject() const;
+ };
+
+ // End of inner data structures
+
+ explicit SearchUserDirectoryJob(const QString& searchTerm, double limit = {});
+ ~SearchUserDirectoryJob() override;
+
+ const QVector<User>& results() const;
+ bool limited() const;
+
+ protected:
+ Status parseJson(const QJsonDocument& data) override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> d;
+ };
+} // namespace QMatrixClient
diff --git a/lib/jobs/gtad.yaml b/lib/jobs/gtad.yaml
new file mode 100644
index 00000000..78c879e4
--- /dev/null
+++ b/lib/jobs/gtad.yaml
@@ -0,0 +1,87 @@
+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:"
+
+# Structure:
+# swaggerType: <targetTypeSpec>
+# OR
+# swaggerType:
+# - swaggerFormat: <targetTypeSpec>
+# - /swaggerFormatRegEx/: <targetTypeSpec>
+# - //: <targetTypeSpec> # default, if the format doesn't mach anything above
+# WHERE
+# targetTypeSpec = targetType OR
+# { type: targetType, imports: <filename OR [ filenames... ]>, <other attributes...> }
+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: <QtCore/QIODevice>
+ - binary: *ByteStream
+ - date:
+ type: QDate
+ initializer: QDate::fromString("{{defaultValue}}")
+ avoidCopy?: true
+ imports: <QtCore/QDate>
+ - dateTime:
+ type: QDateTime
+ initializer: QDateTime::fromString("{{defaultValue}}")
+ avoidCopy?: true
+ imports: <QtCore/QDateTime>
+ - //:
+ type: QString
+ initializer: QStringLiteral("{{defaultValue}}")
+ string?: true
+ avoidCopy?: true
+ file: *ByteStream
+ object:
+ type: QJsonObject
+ avoidCopy?: true
+ imports: <QtCore/QJsonObject>
+ array:
+ - /.+/:
+ type: "QVector<{{1}}>"
+ avoidCopy?: true
+ imports: <QtCore/QVector>
+ - //: { type: QJsonArray, "avoidCopy?": true, imports: <QtCore/QJsonArray> }
+ schema:
+ avoidCopy?: true
+
+#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: <kitsune-ral@users.sf.net>
+# imports: { set: }
+
+templates:
+- "{{base}}.h.mustache"
+- "{{base}}.cpp.mustache"
+
+#outFilesList: apifiles.txt
+
diff --git a/lib/jobs/preamble.mustache b/lib/jobs/preamble.mustache
new file mode 100644
index 00000000..3ba87d61
--- /dev/null
+++ b/lib/jobs/preamble.mustache
@@ -0,0 +1,3 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
diff --git a/lib/jobs/{{base}}.cpp.mustache b/lib/jobs/{{base}}.cpp.mustache
new file mode 100644
index 00000000..b8532c51
--- /dev/null
+++ b/lib/jobs/{{base}}.cpp.mustache
@@ -0,0 +1,116 @@
+{{#@filePartial}}preamble{{/@filePartial}}
+#include "{{filenameBase}}.h"
+{{^allModels}}
+#include "converters.h"
+{{/allModels}}{{#operations}}
+{{#producesNotJson?}}#include <QtNetwork/QNetworkReply>
+{{/producesNotJson?}}#include <QtCore/QStringBuilder>
+{{/operations}}
+using namespace QMatrixClient;
+{{#models.model}}{{^trivial?}}
+{{qualifiedName}}::operator QJsonValue() const
+{
+ QJsonObject o;
+ {{#vars}}o.insert("{{baseName}}", toJson({{nameCamelCase}}));
+ {{/vars}}
+ return o;
+}
+
+{{qualifiedName}} FromJson<{{qualifiedName}}>::operator()(QJsonValue jv)
+{
+ QJsonObject o = jv.toObject();
+ {{qualifiedName}} result;
+ {{#vars}}result.{{nameCamelCase}} =
+ fromJson<{{dataType.name}}>(o.value("{{baseName}}"));
+ {{/vars}}
+ return result;
+}
+{{/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
+{
+ template <> struct FromJson<{{qualifiedName}}>
+ {
+ {{qualifiedName}} operator()(QJsonValue jv)
+ {
+ QJsonObject o = jv.toObject();
+ {{qualifiedName}} result;
+ {{#vars}}result.{{nameCamelCase}} =
+ fromJson<{{dataType.qualifiedName}}>(o.value("{{baseName}}"));
+ {{/vars}}
+ return result;
+ }
+ };
+} // namespace QMatrixClient
+{{/ trivial?}}{{/models.model}}{{#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(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({{nameCamelCase}}));{{/inlineBody}}{{!
+}}{{^inlineBody}} QJsonObject _data;{{#bodyParams}}
+{{^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}}
+{{# responses}}{{#normalResponse?}}{{#allProperties?}}
+{{camelCaseOperationId}}Job::~{{camelCaseOperationId}}Job() = default;
+{{# allProperties}}
+{{>qualifiedMaybeCrefType}} {{camelCaseOperationId}}Job::{{paramName}}() const
+{
+ return d->{{paramName}};
+}
+{{/ allProperties}}{{#producesNotJson?}}
+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?}}
+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;
+}{{/ producesNotJson?}}
+{{/allProperties?}}{{/normalResponse?}}{{/responses}}{{/operation}}{{/operations}}
diff --git a/lib/jobs/{{base}}.h.mustache b/lib/jobs/{{base}}.h.mustache
new file mode 100644
index 00000000..63aa53e7
--- /dev/null
+++ b/lib/jobs/{{base}}.h.mustache
@@ -0,0 +1,67 @@
+{{#@filePartial}}preamble{{/@filePartial}}
+#pragma once
+
+{{#operations}}#include "../basejob.h"
+{{/operations}}
+{{#imports}}#include {{_}}
+{{/imports}}
+{{#allModels}}#include "converters.h"
+{{/allModels}}
+namespace QMatrixClient
+{
+{{#models}} // Data structures
+{{# model}}{{#trivial?}}
+ using {{name}} = {{parent.name}};
+{{/ trivial?}}{{^trivial?}}
+ struct {{name}}{{#parents?}} : {{#parents}}{{name}}{{#@join}}, {{/@join}}{{/parents}}{{/parents?}}
+ {
+ {{#vars}}{{dataType.name}} {{nameCamelCase}};
+ {{/vars}}
+ operator QJsonObject() const;
+ };
+
+ template <> struct FromJson<{{name}}>
+ {
+ {{name}} operator()(QJsonValue jv);
+ };
+{{/ trivial?}}{{/model}}
+{{/models}}{{#operations}} // Operations
+{{# operation}}
+ class {{camelCaseOperationId}}Job : public BaseJob
+ {
+ public:{{# models}}
+ // Inner data structures
+{{# model}}{{#trivial?}}
+ using {{name}} = {{parent.name}};
+{{/ trivial?}}{{^trivial?}}
+ struct {{name}}{{#parents?}} : {{#parents}}{{name}}{{#@join}}, {{/@join}}{{/parents}}{{/parents?}}
+ {
+ {{#vars}}{{dataType.name}} {{nameCamelCase}};
+ {{/vars}}
+ operator QJsonObject() const;
+ };
+{{/ trivial?}}{{/model}}
+ // End of inner data structures
+{{/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
+ * 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?}}
+ ~{{camelCaseOperationId}}Job() override;
+{{#allProperties}}
+ {{>maybeCrefType}} {{paramName}}() const;{{/allProperties}}
+
+ protected:
+ Status {{#producesNotJson?}}parseReply(QNetworkReply* reply){{/producesNotJson?}}{{^producesNotJson?}}parseJson(const QJsonDocument& data){{/producesNotJson?}} override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> d;{{/allProperties?}}{{/normalResponse?}}{{/responses}}
+ };
+{{/operation}}{{/operations}}{{!skip EOL
+}}} // namespace QMatrixClient