diff options
Diffstat (limited to 'lib/jobs/generated')
50 files changed, 3017 insertions, 0 deletions
diff --git a/lib/jobs/generated/account-data.cpp b/lib/jobs/generated/account-data.cpp new file mode 100644 index 00000000..35ee94c0 --- /dev/null +++ b/lib/jobs/generated/account-data.cpp @@ -0,0 +1,28 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "account-data.h" + +#include "converters.h" + +#include <QtCore/QStringBuilder> + +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(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)); +} + diff --git a/lib/jobs/generated/account-data.h b/lib/jobs/generated/account-data.h new file mode 100644 index 00000000..69ad9fb4 --- /dev/null +++ b/lib/jobs/generated/account-data.h @@ -0,0 +1,27 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "../basejob.h" + +#include <QtCore/QJsonObject> + + +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 new file mode 100644 index 00000000..1af57941 --- /dev/null +++ b/lib/jobs/generated/administrative_contact.cpp @@ -0,0 +1,122 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "administrative_contact.h" + +#include <QtCore/QStringBuilder> + +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 +{ + template <> struct FromJson<GetAccount3PIDsJob::ThirdPartyIdentifier> + { + GetAccount3PIDsJob::ThirdPartyIdentifier operator()(QJsonValue jv) + { + QJsonObject o = jv.toObject(); + GetAccount3PIDsJob::ThirdPartyIdentifier result; + result.medium = + fromJson<QString>(o.value("medium")); + result.address = + fromJson<QString>(o.value("address")); + + return result; + } + }; +} // namespace QMatrixClient + +class GetAccount3PIDsJob::Private +{ + public: + QVector<ThirdPartyIdentifier> threepids; +}; + +QUrl GetAccount3PIDsJob::makeRequestUrl(QUrl baseUrl) +{ + return BaseJob::makeRequestUrl(baseUrl, + basePath % "/account/3pid"); +} + +GetAccount3PIDsJob::GetAccount3PIDsJob() + : BaseJob(HttpVerb::Get, "GetAccount3PIDsJob", + basePath % "/account/3pid") + , d(new Private) +{ +} + +GetAccount3PIDsJob::~GetAccount3PIDsJob() = default; + +const QVector<GetAccount3PIDsJob::ThirdPartyIdentifier>& GetAccount3PIDsJob::threepids() const +{ + return d->threepids; +} + +BaseJob::Status GetAccount3PIDsJob::parseJson(const QJsonDocument& data) +{ + auto json = data.object(); + d->threepids = fromJson<QVector<ThirdPartyIdentifier>>(json.value("threepids")); + 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 +{ + template <> struct FromJson<Post3PIDsJob::ThreePidCredentials> + { + Post3PIDsJob::ThreePidCredentials operator()(QJsonValue jv) + { + QJsonObject o = jv.toObject(); + Post3PIDsJob::ThreePidCredentials result; + result.clientSecret = + fromJson<QString>(o.value("client_secret")); + result.idServer = + fromJson<QString>(o.value("id_server")); + result.sid = + fromJson<QString>(o.value("sid")); + + return result; + } + }; +} // 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(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 new file mode 100644 index 00000000..c8429d39 --- /dev/null +++ b/lib/jobs/generated/administrative_contact.h @@ -0,0 +1,83 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "../basejob.h" + +#include <QtCore/QVector> + +#include "converters.h" + +namespace QMatrixClient +{ + // Operations + + class GetAccount3PIDsJob : public BaseJob + { + public: + // Inner data structures + + struct ThirdPartyIdentifier + { + QString medium; + QString address; + + operator QJsonObject() const; + }; + + // End of inner data structures + + /** 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); + + explicit GetAccount3PIDsJob(); + ~GetAccount3PIDsJob() override; + + const QVector<ThirdPartyIdentifier>& threepids() const; + + protected: + Status parseJson(const QJsonDocument& data) override; + + private: + class Private; + QScopedPointer<Private> d; + }; + + class Post3PIDsJob : public BaseJob + { + public: + // Inner data structures + + struct ThreePidCredentials + { + QString clientSecret; + QString idServer; + QString sid; + + operator QJsonObject() const; + }; + + // End of inner data structures + + explicit Post3PIDsJob(const ThreePidCredentials& threePidCreds, bool bind = {}); + }; + + class RequestTokenTo3PIDJob : public BaseJob + { + public: + /** 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); + + explicit RequestTokenTo3PIDJob(); + }; +} // namespace QMatrixClient diff --git a/lib/jobs/generated/banning.cpp b/lib/jobs/generated/banning.cpp new file mode 100644 index 00000000..f66b27b6 --- /dev/null +++ b/lib/jobs/generated/banning.cpp @@ -0,0 +1,34 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "banning.h" + +#include "converters.h" + +#include <QtCore/QStringBuilder> + +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 new file mode 100644 index 00000000..2d6fbd9b --- /dev/null +++ b/lib/jobs/generated/banning.h @@ -0,0 +1,26 @@ +/****************************************************************************** + * 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 new file mode 100644 index 00000000..51011251 --- /dev/null +++ b/lib/jobs/generated/content-repo.cpp @@ -0,0 +1,254 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "content-repo.h" + +#include "converters.h" + +#include <QtNetwork/QNetworkReply> +#include <QtCore/QStringBuilder> + +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<QString>(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(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(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(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: + double matrixImageSize; + QString ogImage; +}; + +BaseJob::Query queryToGetUrlPreview(const QString& url, double 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, double ts) +{ + return BaseJob::makeRequestUrl(baseUrl, + basePath % "/preview_url", + queryToGetUrlPreview(url, ts)); +} + +GetUrlPreviewJob::GetUrlPreviewJob(const QString& url, double ts) + : BaseJob(HttpVerb::Get, "GetUrlPreviewJob", + basePath % "/preview_url", + queryToGetUrlPreview(url, ts)) + , d(new Private) +{ +} + +GetUrlPreviewJob::~GetUrlPreviewJob() = default; + +double 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<double>(json.value("matrix:image:size")); + d->ogImage = fromJson<QString>(json.value("og:image")); + return Success; +} + diff --git a/lib/jobs/generated/content-repo.h b/lib/jobs/generated/content-repo.h new file mode 100644 index 00000000..b4ea562f --- /dev/null +++ b/lib/jobs/generated/content-repo.h @@ -0,0 +1,129 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "../basejob.h" + +#include <QtCore/QIODevice> + + +namespace QMatrixClient +{ + // Operations + + class UploadContentJob : public BaseJob + { + public: + explicit UploadContentJob(QIODevice* content, const QString& filename = {}, const QString& contentType = {}); + ~UploadContentJob() override; + + const QString& contentUri() const; + + protected: + Status parseJson(const QJsonDocument& data) override; + + private: + class Private; + QScopedPointer<Private> d; + }; + + class GetContentJob : public BaseJob + { + public: + /** 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); + + explicit GetContentJob(const QString& serverName, const QString& mediaId); + ~GetContentJob() override; + + const QString& contentType() const; + const QString& contentDisposition() const; + QIODevice* content() const; + + protected: + Status parseReply(QNetworkReply* reply) override; + + private: + class Private; + QScopedPointer<Private> d; + }; + + class GetContentOverrideNameJob : public BaseJob + { + public: + /** 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); + + explicit GetContentOverrideNameJob(const QString& serverName, const QString& mediaId, const QString& fileName); + ~GetContentOverrideNameJob() override; + + const QString& contentType() const; + const QString& contentDisposition() const; + QIODevice* content() const; + + protected: + Status parseReply(QNetworkReply* reply) override; + + private: + class Private; + QScopedPointer<Private> d; + }; + + class GetContentThumbnailJob : public BaseJob + { + public: + /** 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 = {}); + + explicit GetContentThumbnailJob(const QString& serverName, const QString& mediaId, int width = {}, int height = {}, const QString& method = {}); + ~GetContentThumbnailJob() override; + + const QString& contentType() const; + QIODevice* content() const; + + protected: + Status parseReply(QNetworkReply* reply) override; + + private: + class Private; + QScopedPointer<Private> d; + }; + + class GetUrlPreviewJob : public BaseJob + { + public: + /** 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, double ts = {}); + + explicit GetUrlPreviewJob(const QString& url, double ts = {}); + ~GetUrlPreviewJob() override; + + double matrixImageSize() const; + const QString& ogImage() const; + + protected: + Status parseJson(const QJsonDocument& data) override; + + private: + class Private; + QScopedPointer<Private> d; + }; +} // namespace QMatrixClient diff --git a/lib/jobs/generated/create_room.cpp b/lib/jobs/generated/create_room.cpp new file mode 100644 index 00000000..de7807b5 --- /dev/null +++ b/lib/jobs/generated/create_room.cpp @@ -0,0 +1,115 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "create_room.h" + +#include <QtCore/QStringBuilder> + +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 +{ + template <> struct FromJson<CreateRoomJob::Invite3pid> + { + CreateRoomJob::Invite3pid operator()(QJsonValue jv) + { + QJsonObject o = jv.toObject(); + CreateRoomJob::Invite3pid result; + result.idServer = + fromJson<QString>(o.value("id_server")); + result.medium = + fromJson<QString>(o.value("medium")); + result.address = + fromJson<QString>(o.value("address")); + + return result; + } + }; +} // 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 +{ + template <> struct FromJson<CreateRoomJob::StateEvent> + { + CreateRoomJob::StateEvent operator()(QJsonValue jv) + { + QJsonObject o = jv.toObject(); + CreateRoomJob::StateEvent result; + result.type = + fromJson<QString>(o.value("type")); + result.stateKey = + fromJson<QString>(o.value("state_key")); + result.content = + fromJson<QJsonObject>(o.value("content")); + + return result; + } + }; +} // namespace QMatrixClient + +class CreateRoomJob::Private +{ + public: + QString roomId; +}; + +CreateRoomJob::CreateRoomJob(const QString& visibility, const QString& roomAliasName, const QString& name, const QString& topic, const QVector<QString>& invite, const QVector<Invite3pid>& invite3pid, const QJsonObject& creationContent, const QVector<StateEvent>& 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<QString>(json.value("room_id")); + return Success; +} + diff --git a/lib/jobs/generated/create_room.h b/lib/jobs/generated/create_room.h new file mode 100644 index 00000000..b479615a --- /dev/null +++ b/lib/jobs/generated/create_room.h @@ -0,0 +1,55 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "../basejob.h" + +#include <QtCore/QJsonObject> +#include <QtCore/QVector> + +#include "converters.h" + +namespace QMatrixClient +{ + // Operations + + class CreateRoomJob : public BaseJob + { + public: + // Inner data structures + + struct Invite3pid + { + QString idServer; + QString medium; + QString address; + + operator QJsonObject() const; + }; + + struct StateEvent + { + QString type; + QString stateKey; + QJsonObject content; + + operator QJsonObject() const; + }; + + // End of inner data structures + + explicit CreateRoomJob(const QString& visibility = {}, const QString& roomAliasName = {}, const QString& name = {}, const QString& topic = {}, const QVector<QString>& invite = {}, const QVector<Invite3pid>& invite3pid = {}, const QJsonObject& creationContent = {}, const QVector<StateEvent>& initialState = {}, const QString& preset = {}, bool isDirect = {}, bool guestCanJoin = {}); + ~CreateRoomJob() override; + + const QString& roomId() const; + + protected: + Status parseJson(const QJsonDocument& data) override; + + private: + class Private; + QScopedPointer<Private> d; + }; +} // namespace QMatrixClient diff --git a/lib/jobs/generated/directory.cpp b/lib/jobs/generated/directory.cpp new file mode 100644 index 00000000..9428dcee --- /dev/null +++ b/lib/jobs/generated/directory.cpp @@ -0,0 +1,76 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "directory.h" + +#include "converters.h" + +#include <QtCore/QStringBuilder> + +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; + QVector<QString> servers; +}; + +QUrl GetRoomIdByAliasJob::makeRequestUrl(QUrl baseUrl, const QString& roomAlias) +{ + return BaseJob::makeRequestUrl(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 QVector<QString>& GetRoomIdByAliasJob::servers() const +{ + return d->servers; +} + +BaseJob::Status GetRoomIdByAliasJob::parseJson(const QJsonDocument& data) +{ + auto json = data.object(); + d->roomId = fromJson<QString>(json.value("room_id")); + d->servers = fromJson<QVector<QString>>(json.value("servers")); + return Success; +} + +QUrl DeleteRoomAliasJob::makeRequestUrl(QUrl baseUrl, const QString& roomAlias) +{ + return BaseJob::makeRequestUrl(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 new file mode 100644 index 00000000..87591240 --- /dev/null +++ b/lib/jobs/generated/directory.h @@ -0,0 +1,58 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "../basejob.h" + +#include <QtCore/QVector> + + +namespace QMatrixClient +{ + // Operations + + class SetRoomAliasJob : public BaseJob + { + public: + explicit SetRoomAliasJob(const QString& roomAlias, const QString& roomId = {}); + }; + + class GetRoomIdByAliasJob : public BaseJob + { + public: + /** 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); + + explicit GetRoomIdByAliasJob(const QString& roomAlias); + ~GetRoomIdByAliasJob() override; + + const QString& roomId() const; + const QVector<QString>& servers() const; + + protected: + Status parseJson(const QJsonDocument& data) override; + + private: + class Private; + QScopedPointer<Private> d; + }; + + class DeleteRoomAliasJob : public BaseJob + { + public: + /** 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); + + explicit DeleteRoomAliasJob(const QString& roomAlias); + }; +} // namespace QMatrixClient diff --git a/lib/jobs/generated/inviting.cpp b/lib/jobs/generated/inviting.cpp new file mode 100644 index 00000000..d2ee2107 --- /dev/null +++ b/lib/jobs/generated/inviting.cpp @@ -0,0 +1,23 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "inviting.h" + +#include "converters.h" + +#include <QtCore/QStringBuilder> + +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 new file mode 100644 index 00000000..eaa884df --- /dev/null +++ b/lib/jobs/generated/inviting.h @@ -0,0 +1,20 @@ +/****************************************************************************** + * 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/kicking.cpp b/lib/jobs/generated/kicking.cpp new file mode 100644 index 00000000..bf2490b7 --- /dev/null +++ b/lib/jobs/generated/kicking.cpp @@ -0,0 +1,25 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "kicking.h" + +#include "converters.h" + +#include <QtCore/QStringBuilder> + +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 new file mode 100644 index 00000000..3814bef7 --- /dev/null +++ b/lib/jobs/generated/kicking.h @@ -0,0 +1,20 @@ +/****************************************************************************** + * 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 new file mode 100644 index 00000000..fbc40d11 --- /dev/null +++ b/lib/jobs/generated/leaving.cpp @@ -0,0 +1,38 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "leaving.h" + +#include "converters.h" + +#include <QtCore/QStringBuilder> + +using namespace QMatrixClient; + +static const auto basePath = QStringLiteral("/_matrix/client/r0"); + +QUrl LeaveRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) +{ + return BaseJob::makeRequestUrl(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(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 new file mode 100644 index 00000000..9bae2363 --- /dev/null +++ b/lib/jobs/generated/leaving.h @@ -0,0 +1,40 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "../basejob.h" + + + +namespace QMatrixClient +{ + // Operations + + class LeaveRoomJob : public BaseJob + { + public: + /** 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); + + explicit LeaveRoomJob(const QString& roomId); + }; + + class ForgetRoomJob : public BaseJob + { + public: + /** 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); + + explicit ForgetRoomJob(const QString& roomId); + }; +} // namespace QMatrixClient 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/list_public_rooms.cpp b/lib/jobs/generated/list_public_rooms.cpp new file mode 100644 index 00000000..39653300 --- /dev/null +++ b/lib/jobs/generated/list_public_rooms.cpp @@ -0,0 +1,266 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "list_public_rooms.h" + +#include <QtCore/QStringBuilder> + +using namespace QMatrixClient; + +static const auto basePath = QStringLiteral("/_matrix/client/r0"); + +GetPublicRoomsJob::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 +{ + template <> struct FromJson<GetPublicRoomsJob::PublicRoomsChunk> + { + GetPublicRoomsJob::PublicRoomsChunk operator()(QJsonValue jv) + { + QJsonObject o = jv.toObject(); + GetPublicRoomsJob::PublicRoomsChunk result; + result.aliases = + fromJson<QVector<QString>>(o.value("aliases")); + result.canonicalAlias = + fromJson<QString>(o.value("canonical_alias")); + result.name = + fromJson<QString>(o.value("name")); + result.numJoinedMembers = + fromJson<double>(o.value("num_joined_members")); + result.roomId = + fromJson<QString>(o.value("room_id")); + result.topic = + fromJson<QString>(o.value("topic")); + result.worldReadable = + fromJson<bool>(o.value("world_readable")); + result.guestCanJoin = + fromJson<bool>(o.value("guest_can_join")); + result.avatarUrl = + fromJson<QString>(o.value("avatar_url")); + + return result; + } + }; +} // namespace QMatrixClient + +class GetPublicRoomsJob::Private +{ + public: + QVector<PublicRoomsChunk> chunk; + QString nextBatch; + QString prevBatch; + double totalRoomCountEstimate; +}; + +BaseJob::Query queryToGetPublicRooms(double 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, double limit, const QString& since, const QString& server) +{ + return BaseJob::makeRequestUrl(baseUrl, + basePath % "/publicRooms", + queryToGetPublicRooms(limit, since, server)); +} + +GetPublicRoomsJob::GetPublicRoomsJob(double 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::PublicRoomsChunk>& GetPublicRoomsJob::chunk() const +{ + return d->chunk; +} + +const QString& GetPublicRoomsJob::nextBatch() const +{ + return d->nextBatch; +} + +const QString& GetPublicRoomsJob::prevBatch() const +{ + return d->prevBatch; +} + +double 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<QVector<PublicRoomsChunk>>(json.value("chunk")); + d->nextBatch = fromJson<QString>(json.value("next_batch")); + d->prevBatch = fromJson<QString>(json.value("prev_batch")); + d->totalRoomCountEstimate = fromJson<double>(json.value("total_room_count_estimate")); + return Success; +} + +QueryPublicRoomsJob::Filter::operator QJsonObject() const +{ + QJsonObject o; + o.insert("generic_search_term", toJson(genericSearchTerm)); + + return o; +} +namespace QMatrixClient +{ + template <> struct FromJson<QueryPublicRoomsJob::Filter> + { + QueryPublicRoomsJob::Filter operator()(QJsonValue jv) + { + QJsonObject o = jv.toObject(); + QueryPublicRoomsJob::Filter result; + result.genericSearchTerm = + fromJson<QString>(o.value("generic_search_term")); + + return result; + } + }; +} // 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 +{ + template <> struct FromJson<QueryPublicRoomsJob::PublicRoomsChunk> + { + QueryPublicRoomsJob::PublicRoomsChunk operator()(QJsonValue jv) + { + QJsonObject o = jv.toObject(); + QueryPublicRoomsJob::PublicRoomsChunk result; + result.aliases = + fromJson<QVector<QString>>(o.value("aliases")); + result.canonicalAlias = + fromJson<QString>(o.value("canonical_alias")); + result.name = + fromJson<QString>(o.value("name")); + result.numJoinedMembers = + fromJson<double>(o.value("num_joined_members")); + result.roomId = + fromJson<QString>(o.value("room_id")); + result.topic = + fromJson<QString>(o.value("topic")); + result.worldReadable = + fromJson<bool>(o.value("world_readable")); + result.guestCanJoin = + fromJson<bool>(o.value("guest_can_join")); + result.avatarUrl = + fromJson<QString>(o.value("avatar_url")); + + return result; + } + }; +} // namespace QMatrixClient + +class QueryPublicRoomsJob::Private +{ + public: + QVector<PublicRoomsChunk> chunk; + QString nextBatch; + QString prevBatch; + double totalRoomCountEstimate; +}; + +BaseJob::Query queryToQueryPublicRooms(const QString& server) +{ + BaseJob::Query _q; + if (!server.isEmpty()) + _q.addQueryItem("server", server); + return _q; +} + +QueryPublicRoomsJob::QueryPublicRoomsJob(const QString& server, double 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::PublicRoomsChunk>& QueryPublicRoomsJob::chunk() const +{ + return d->chunk; +} + +const QString& QueryPublicRoomsJob::nextBatch() const +{ + return d->nextBatch; +} + +const QString& QueryPublicRoomsJob::prevBatch() const +{ + return d->prevBatch; +} + +double 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<QVector<PublicRoomsChunk>>(json.value("chunk")); + d->nextBatch = fromJson<QString>(json.value("next_batch")); + d->prevBatch = fromJson<QString>(json.value("prev_batch")); + d->totalRoomCountEstimate = fromJson<double>(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 new file mode 100644 index 00000000..5c281de3 --- /dev/null +++ b/lib/jobs/generated/list_public_rooms.h @@ -0,0 +1,106 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "../basejob.h" + +#include <QtCore/QVector> + +#include "converters.h" + +namespace QMatrixClient +{ + // Operations + + class GetPublicRoomsJob : public BaseJob + { + public: + // Inner data structures + + struct PublicRoomsChunk + { + QVector<QString> aliases; + QString canonicalAlias; + QString name; + double numJoinedMembers; + QString roomId; + QString topic; + bool worldReadable; + bool guestCanJoin; + QString avatarUrl; + + operator QJsonObject() const; + }; + + // End of inner data structures + + /** 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, double limit = {}, const QString& since = {}, const QString& server = {}); + + explicit GetPublicRoomsJob(double limit = {}, const QString& since = {}, const QString& server = {}); + ~GetPublicRoomsJob() override; + + const QVector<PublicRoomsChunk>& chunk() const; + const QString& nextBatch() const; + const QString& prevBatch() const; + double totalRoomCountEstimate() const; + + protected: + Status parseJson(const QJsonDocument& data) override; + + private: + class Private; + QScopedPointer<Private> d; + }; + + class QueryPublicRoomsJob : public BaseJob + { + public: + // Inner data structures + + struct Filter + { + QString genericSearchTerm; + + operator QJsonObject() const; + }; + + struct PublicRoomsChunk + { + QVector<QString> aliases; + QString canonicalAlias; + QString name; + double numJoinedMembers; + QString roomId; + QString topic; + bool worldReadable; + bool guestCanJoin; + QString avatarUrl; + + operator QJsonObject() const; + }; + + // End of inner data structures + + explicit QueryPublicRoomsJob(const QString& server = {}, double limit = {}, const QString& since = {}, const Filter& filter = {}); + ~QueryPublicRoomsJob() override; + + const QVector<PublicRoomsChunk>& chunk() const; + const QString& nextBatch() const; + const QString& prevBatch() const; + double totalRoomCountEstimate() const; + + protected: + Status parseJson(const QJsonDocument& data) override; + + private: + class Private; + QScopedPointer<Private> d; + }; +} // namespace QMatrixClient diff --git a/lib/jobs/generated/login.cpp b/lib/jobs/generated/login.cpp new file mode 100644 index 00000000..a4dab428 --- /dev/null +++ b/lib/jobs/generated/login.cpp @@ -0,0 +1,79 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "login.h" + +#include "converters.h" + +#include <QtCore/QStringBuilder> + +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<QString>(json.value("user_id")); + d->accessToken = fromJson<QString>(json.value("access_token")); + d->homeServer = fromJson<QString>(json.value("home_server")); + d->deviceId = fromJson<QString>(json.value("device_id")); + return Success; +} + diff --git a/lib/jobs/generated/login.h b/lib/jobs/generated/login.h new file mode 100644 index 00000000..3ac955d4 --- /dev/null +++ b/lib/jobs/generated/login.h @@ -0,0 +1,33 @@ +/****************************************************************************** + * 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; + + 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<Private> d; + }; +} // namespace QMatrixClient diff --git a/lib/jobs/generated/logout.cpp b/lib/jobs/generated/logout.cpp new file mode 100644 index 00000000..83139842 --- /dev/null +++ b/lib/jobs/generated/logout.cpp @@ -0,0 +1,26 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "logout.h" + +#include "converters.h" + +#include <QtCore/QStringBuilder> + +using namespace QMatrixClient; + +static const auto basePath = QStringLiteral("/_matrix/client/r0"); + +QUrl LogoutJob::makeRequestUrl(QUrl baseUrl) +{ + return BaseJob::makeRequestUrl(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 new file mode 100644 index 00000000..7640ba55 --- /dev/null +++ b/lib/jobs/generated/logout.h @@ -0,0 +1,27 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "../basejob.h" + + + +namespace QMatrixClient +{ + // Operations + + class LogoutJob : public BaseJob + { + public: + /** 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); + + explicit LogoutJob(); + }; +} // namespace QMatrixClient diff --git a/lib/jobs/generated/profile.cpp b/lib/jobs/generated/profile.cpp new file mode 100644 index 00000000..1f7092d7 --- /dev/null +++ b/lib/jobs/generated/profile.cpp @@ -0,0 +1,140 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "profile.h" + +#include "converters.h" + +#include <QtCore/QStringBuilder> + +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(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<QString>(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(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<QString>(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(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<QString>(json.value("avatar_url")); + d->displayname = fromJson<QString>(json.value("displayname")); + return Success; +} + diff --git a/lib/jobs/generated/profile.h b/lib/jobs/generated/profile.h new file mode 100644 index 00000000..024130f5 --- /dev/null +++ b/lib/jobs/generated/profile.h @@ -0,0 +1,96 @@ +/****************************************************************************** + * 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: + /** 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); + + explicit GetDisplayNameJob(const QString& userId); + ~GetDisplayNameJob() override; + + const QString& displayname() const; + + protected: + Status parseJson(const QJsonDocument& data) override; + + private: + class Private; + QScopedPointer<Private> d; + }; + + class SetAvatarUrlJob : public BaseJob + { + public: + explicit SetAvatarUrlJob(const QString& userId, const QString& avatarUrl = {}); + }; + + class GetAvatarUrlJob : public BaseJob + { + public: + /** 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); + + explicit GetAvatarUrlJob(const QString& userId); + ~GetAvatarUrlJob() override; + + const QString& avatarUrl() const; + + protected: + Status parseJson(const QJsonDocument& data) override; + + private: + class Private; + QScopedPointer<Private> d; + }; + + class GetUserProfileJob : public BaseJob + { + public: + /** 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); + + explicit GetUserProfileJob(const QString& userId); + ~GetUserProfileJob() override; + + const QString& avatarUrl() const; + const QString& displayname() 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/receipts.cpp b/lib/jobs/generated/receipts.cpp new file mode 100644 index 00000000..83c38b6f --- /dev/null +++ b/lib/jobs/generated/receipts.cpp @@ -0,0 +1,21 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "receipts.h" + +#include "converters.h" + +#include <QtCore/QStringBuilder> + +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(receipt)); +} + diff --git a/lib/jobs/generated/receipts.h b/lib/jobs/generated/receipts.h new file mode 100644 index 00000000..9eb7a489 --- /dev/null +++ b/lib/jobs/generated/receipts.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 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 new file mode 100644 index 00000000..0da35dfc --- /dev/null +++ b/lib/jobs/generated/redaction.cpp @@ -0,0 +1,45 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "redaction.h" + +#include "converters.h" + +#include <QtCore/QStringBuilder> + +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<QString>(json.value("event_id")); + return Success; +} + diff --git a/lib/jobs/generated/redaction.h b/lib/jobs/generated/redaction.h new file mode 100644 index 00000000..e3b3ff4f --- /dev/null +++ b/lib/jobs/generated/redaction.h @@ -0,0 +1,30 @@ +/****************************************************************************** + * 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; + + 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/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/third_party_membership.cpp b/lib/jobs/generated/third_party_membership.cpp new file mode 100644 index 00000000..b637d481 --- /dev/null +++ b/lib/jobs/generated/third_party_membership.cpp @@ -0,0 +1,25 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "third_party_membership.h" + +#include "converters.h" + +#include <QtCore/QStringBuilder> + +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 new file mode 100644 index 00000000..c7b5214e --- /dev/null +++ b/lib/jobs/generated/third_party_membership.h @@ -0,0 +1,20 @@ +/****************************************************************************** + * 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 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/typing.cpp b/lib/jobs/generated/typing.cpp new file mode 100644 index 00000000..fa700290 --- /dev/null +++ b/lib/jobs/generated/typing.cpp @@ -0,0 +1,24 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "typing.h" + +#include "converters.h" + +#include <QtCore/QStringBuilder> + +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 new file mode 100644 index 00000000..0495ed0a --- /dev/null +++ b/lib/jobs/generated/typing.h @@ -0,0 +1,20 @@ +/****************************************************************************** + * 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 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/generated/versions.cpp b/lib/jobs/generated/versions.cpp new file mode 100644 index 00000000..b12594ca --- /dev/null +++ b/lib/jobs/generated/versions.cpp @@ -0,0 +1,47 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "versions.h" + +#include "converters.h" + +#include <QtCore/QStringBuilder> + +using namespace QMatrixClient; + +static const auto basePath = QStringLiteral("/_matrix/client"); + +class GetVersionsJob::Private +{ + public: + QVector<QString> versions; +}; + +QUrl GetVersionsJob::makeRequestUrl(QUrl baseUrl) +{ + return BaseJob::makeRequestUrl(baseUrl, + basePath % "/versions"); +} + +GetVersionsJob::GetVersionsJob() + : BaseJob(HttpVerb::Get, "GetVersionsJob", + basePath % "/versions", false) + , d(new Private) +{ +} + +GetVersionsJob::~GetVersionsJob() = default; + +const QVector<QString>& GetVersionsJob::versions() const +{ + return d->versions; +} + +BaseJob::Status GetVersionsJob::parseJson(const QJsonDocument& data) +{ + auto json = data.object(); + d->versions = fromJson<QVector<QString>>(json.value("versions")); + return Success; +} + diff --git a/lib/jobs/generated/versions.h b/lib/jobs/generated/versions.h new file mode 100644 index 00000000..18f6bb44 --- /dev/null +++ b/lib/jobs/generated/versions.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 GetVersionsJob : public BaseJob + { + public: + /** 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); + + explicit GetVersionsJob(); + ~GetVersionsJob() override; + + const QVector<QString>& versions() const; + + protected: + Status parseJson(const QJsonDocument& data) override; + + private: + class Private; + QScopedPointer<Private> d; + }; +} // namespace QMatrixClient diff --git a/lib/jobs/generated/whoami.cpp b/lib/jobs/generated/whoami.cpp new file mode 100644 index 00000000..cc38fa4d --- /dev/null +++ b/lib/jobs/generated/whoami.cpp @@ -0,0 +1,50 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "whoami.h" + +#include "converters.h" + +#include <QtCore/QStringBuilder> + +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(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<QString>(json.value("user_id")); + return Success; +} + diff --git a/lib/jobs/generated/whoami.h b/lib/jobs/generated/whoami.h new file mode 100644 index 00000000..835232ee --- /dev/null +++ b/lib/jobs/generated/whoami.h @@ -0,0 +1,37 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "../basejob.h" + + + +namespace QMatrixClient +{ + // Operations + + class GetTokenOwnerJob : public BaseJob + { + public: + /** 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); + + explicit GetTokenOwnerJob(); + ~GetTokenOwnerJob() override; + + const QString& userId() const; + + protected: + Status parseJson(const QJsonDocument& data) override; + + private: + class Private; + QScopedPointer<Private> d; + }; +} // namespace QMatrixClient |