From aacc4bcb4a487871daae6717f77605aaba444341 Mon Sep 17 00:00:00 2001 From: Marc Deop Date: Sat, 2 Mar 2019 12:26:57 +0100 Subject: style: apply .clang-format to all .cpp and .h files --- lib/csapi/content-repo.cpp | 171 ++++++++++++++++++++++----------------------- 1 file changed, 85 insertions(+), 86 deletions(-) (limited to 'lib/csapi/content-repo.cpp') diff --git a/lib/csapi/content-repo.cpp b/lib/csapi/content-repo.cpp index 22223985..d59449b9 100644 --- a/lib/csapi/content-repo.cpp +++ b/lib/csapi/content-repo.cpp @@ -6,8 +6,8 @@ #include "converters.h" -#include #include +#include using namespace QMatrixClient; @@ -16,7 +16,7 @@ static const auto basePath = QStringLiteral("/_matrix/media/r0"); class UploadContentJob::Private { public: - QString contentUri; + QString contentUri; }; BaseJob::Query queryToUploadContent(const QString& filename) @@ -28,11 +28,11 @@ BaseJob::Query queryToUploadContent(const QString& filename) static const auto UploadContentJobName = QStringLiteral("UploadContentJob"); -UploadContentJob::UploadContentJob(QIODevice* content, const QString& filename, const QString& contentType) - : BaseJob(HttpVerb::Post, UploadContentJobName, - basePath % "/upload", - queryToUploadContent(filename)) - , d(new Private) +UploadContentJob::UploadContentJob(QIODevice* content, const QString& filename, + const QString& contentType) + : BaseJob(HttpVerb::Post, UploadContentJobName, basePath % "/upload", + queryToUploadContent(filename)), + d(new Private) { setRequestHeader("Content-Type", contentType.toLatin1()); @@ -41,17 +41,14 @@ UploadContentJob::UploadContentJob(QIODevice* content, const QString& filename, UploadContentJob::~UploadContentJob() = default; -const QString& UploadContentJob::contentUri() const -{ - return d->contentUri; -} +const QString& UploadContentJob::contentUri() const { return d->contentUri; } BaseJob::Status UploadContentJob::parseJson(const QJsonDocument& data) { auto json = data.object(); if (!json.contains("content_uri"_ls)) return { JsonParseError, - "The key 'content_uri' not found in the response" }; + "The key 'content_uri' not found in the response" }; fromJson(json.value("content_uri"_ls), d->contentUri); return Success; } @@ -59,9 +56,9 @@ BaseJob::Status UploadContentJob::parseJson(const QJsonDocument& data) class GetContentJob::Private { public: - QString contentType; - QString contentDisposition; - QIODevice* data; + QString contentType; + QString contentDisposition; + QIODevice* data; }; BaseJob::Query queryToGetContent(bool allowRemote) @@ -71,41 +68,37 @@ BaseJob::Query queryToGetContent(bool allowRemote) return _q; } -QUrl GetContentJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, bool allowRemote) +QUrl GetContentJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, + const QString& mediaId, bool allowRemote) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/download/" % serverName % "/" % mediaId, - queryToGetContent(allowRemote)); + basePath % "/download/" % serverName % "/" + % mediaId, + queryToGetContent(allowRemote)); } static const auto GetContentJobName = QStringLiteral("GetContentJob"); -GetContentJob::GetContentJob(const QString& serverName, const QString& mediaId, bool allowRemote) +GetContentJob::GetContentJob(const QString& serverName, const QString& mediaId, + bool allowRemote) : BaseJob(HttpVerb::Get, GetContentJobName, - basePath % "/download/" % serverName % "/" % mediaId, - queryToGetContent(allowRemote), - {}, false) - , d(new Private) + basePath % "/download/" % serverName % "/" % mediaId, + queryToGetContent(allowRemote), {}, false), + d(new Private) { setExpectedContentTypes({ "*/*" }); } GetContentJob::~GetContentJob() = default; -const QString& GetContentJob::contentType() const -{ - return d->contentType; -} +const QString& GetContentJob::contentType() const { return d->contentType; } const QString& GetContentJob::contentDisposition() const { return d->contentDisposition; } -QIODevice* GetContentJob::data() const -{ - return d->data; -} +QIODevice* GetContentJob::data() const { return d->data; } BaseJob::Status GetContentJob::parseReply(QNetworkReply* reply) { @@ -118,9 +111,9 @@ BaseJob::Status GetContentJob::parseReply(QNetworkReply* reply) class GetContentOverrideNameJob::Private { public: - QString contentType; - QString contentDisposition; - QIODevice* data; + QString contentType; + QString contentDisposition; + QIODevice* data; }; BaseJob::Query queryToGetContentOverrideName(bool allowRemote) @@ -130,21 +123,30 @@ BaseJob::Query queryToGetContentOverrideName(bool allowRemote) return _q; } -QUrl GetContentOverrideNameJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, const QString& fileName, bool allowRemote) +QUrl GetContentOverrideNameJob::makeRequestUrl(QUrl baseUrl, + const QString& serverName, + const QString& mediaId, + const QString& fileName, + bool allowRemote) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/download/" % serverName % "/" % mediaId % "/" % fileName, - queryToGetContentOverrideName(allowRemote)); + basePath % "/download/" % serverName % "/" + % mediaId % "/" % fileName, + queryToGetContentOverrideName(allowRemote)); } -static const auto GetContentOverrideNameJobName = QStringLiteral("GetContentOverrideNameJob"); +static const auto GetContentOverrideNameJobName = + QStringLiteral("GetContentOverrideNameJob"); -GetContentOverrideNameJob::GetContentOverrideNameJob(const QString& serverName, const QString& mediaId, const QString& fileName, bool allowRemote) +GetContentOverrideNameJob::GetContentOverrideNameJob(const QString& serverName, + const QString& mediaId, + const QString& fileName, + bool allowRemote) : BaseJob(HttpVerb::Get, GetContentOverrideNameJobName, - basePath % "/download/" % serverName % "/" % mediaId % "/" % fileName, - queryToGetContentOverrideName(allowRemote), - {}, false) - , d(new Private) + basePath % "/download/" % serverName % "/" % mediaId % "/" + % fileName, + queryToGetContentOverrideName(allowRemote), {}, false), + d(new Private) { setExpectedContentTypes({ "*/*" }); } @@ -161,10 +163,7 @@ const QString& GetContentOverrideNameJob::contentDisposition() const return d->contentDisposition; } -QIODevice* GetContentOverrideNameJob::data() const -{ - return d->data; -} +QIODevice* GetContentOverrideNameJob::data() const { return d->data; } BaseJob::Status GetContentOverrideNameJob::parseReply(QNetworkReply* reply) { @@ -177,11 +176,13 @@ BaseJob::Status GetContentOverrideNameJob::parseReply(QNetworkReply* reply) class GetContentThumbnailJob::Private { public: - QString contentType; - QIODevice* data; + QString contentType; + QIODevice* data; }; -BaseJob::Query queryToGetContentThumbnail(int width, int height, const QString& method, bool allowRemote) +BaseJob::Query queryToGetContentThumbnail(int width, int height, + const QString& method, + bool allowRemote) { BaseJob::Query _q; addParam<>(_q, QStringLiteral("width"), width); @@ -191,21 +192,31 @@ BaseJob::Query queryToGetContentThumbnail(int width, int height, const QString& return _q; } -QUrl GetContentThumbnailJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, int width, int height, const QString& method, bool allowRemote) +QUrl GetContentThumbnailJob::makeRequestUrl(QUrl baseUrl, + const QString& serverName, + const QString& mediaId, int width, + int height, const QString& method, + bool allowRemote) { - return BaseJob::makeRequestUrl(std::move(baseUrl), + return BaseJob::makeRequestUrl( + std::move(baseUrl), basePath % "/thumbnail/" % serverName % "/" % mediaId, queryToGetContentThumbnail(width, height, method, allowRemote)); } -static const auto GetContentThumbnailJobName = QStringLiteral("GetContentThumbnailJob"); +static const auto GetContentThumbnailJobName = + QStringLiteral("GetContentThumbnailJob"); -GetContentThumbnailJob::GetContentThumbnailJob(const QString& serverName, const QString& mediaId, int width, int height, const QString& method, bool allowRemote) +GetContentThumbnailJob::GetContentThumbnailJob(const QString& serverName, + const QString& mediaId, + int width, int height, + const QString& method, + bool allowRemote) : BaseJob(HttpVerb::Get, GetContentThumbnailJobName, - basePath % "/thumbnail/" % serverName % "/" % mediaId, - queryToGetContentThumbnail(width, height, method, allowRemote), - {}, false) - , d(new Private) + basePath % "/thumbnail/" % serverName % "/" % mediaId, + queryToGetContentThumbnail(width, height, method, allowRemote), + {}, false), + d(new Private) { setExpectedContentTypes({ "image/jpeg", "image/png" }); } @@ -217,10 +228,7 @@ const QString& GetContentThumbnailJob::contentType() const return d->contentType; } -QIODevice* GetContentThumbnailJob::data() const -{ - return d->data; -} +QIODevice* GetContentThumbnailJob::data() const { return d->data; } BaseJob::Status GetContentThumbnailJob::parseReply(QNetworkReply* reply) { @@ -232,8 +240,8 @@ BaseJob::Status GetContentThumbnailJob::parseReply(QNetworkReply* reply) class GetUrlPreviewJob::Private { public: - Omittable matrixImageSize; - QString ogImage; + Omittable matrixImageSize; + QString ogImage; }; BaseJob::Query queryToGetUrlPreview(const QString& url, Omittable ts) @@ -244,20 +252,20 @@ BaseJob::Query queryToGetUrlPreview(const QString& url, Omittable ts) return _q; } -QUrl GetUrlPreviewJob::makeRequestUrl(QUrl baseUrl, const QString& url, Omittable ts) +QUrl GetUrlPreviewJob::makeRequestUrl(QUrl baseUrl, const QString& url, + Omittable ts) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/preview_url", - queryToGetUrlPreview(url, ts)); + basePath % "/preview_url", + queryToGetUrlPreview(url, ts)); } static const auto GetUrlPreviewJobName = QStringLiteral("GetUrlPreviewJob"); GetUrlPreviewJob::GetUrlPreviewJob(const QString& url, Omittable ts) - : BaseJob(HttpVerb::Get, GetUrlPreviewJobName, - basePath % "/preview_url", - queryToGetUrlPreview(url, ts)) - , d(new Private) + : BaseJob(HttpVerb::Get, GetUrlPreviewJobName, basePath % "/preview_url", + queryToGetUrlPreview(url, ts)), + d(new Private) { } @@ -268,10 +276,7 @@ Omittable GetUrlPreviewJob::matrixImageSize() const return d->matrixImageSize; } -const QString& GetUrlPreviewJob::ogImage() const -{ - return d->ogImage; -} +const QString& GetUrlPreviewJob::ogImage() const { return d->ogImage; } BaseJob::Status GetUrlPreviewJob::parseJson(const QJsonDocument& data) { @@ -284,30 +289,25 @@ BaseJob::Status GetUrlPreviewJob::parseJson(const QJsonDocument& data) class GetConfigJob::Private { public: - Omittable uploadSize; + Omittable uploadSize; }; QUrl GetConfigJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/config"); + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/config"); } static const auto GetConfigJobName = QStringLiteral("GetConfigJob"); GetConfigJob::GetConfigJob() - : BaseJob(HttpVerb::Get, GetConfigJobName, - basePath % "/config") - , d(new Private) + : BaseJob(HttpVerb::Get, GetConfigJobName, basePath % "/config"), + d(new Private) { } GetConfigJob::~GetConfigJob() = default; -Omittable GetConfigJob::uploadSize() const -{ - return d->uploadSize; -} +Omittable GetConfigJob::uploadSize() const { return d->uploadSize; } BaseJob::Status GetConfigJob::parseJson(const QJsonDocument& data) { @@ -315,4 +315,3 @@ BaseJob::Status GetConfigJob::parseJson(const QJsonDocument& data) fromJson(json.value("m.upload.size"_ls), d->uploadSize); return Success; } - -- cgit v1.2.3 From 93f0c8fe89f448d1d58caa757573f17102369471 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 7 Jun 2019 19:16:33 +0900 Subject: Generated files in csapi/: switch from now-deprecated JsonParserError to IncorrectResponse --- lib/csapi/content-repo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/csapi/content-repo.cpp') diff --git a/lib/csapi/content-repo.cpp b/lib/csapi/content-repo.cpp index 22223985..7e490604 100644 --- a/lib/csapi/content-repo.cpp +++ b/lib/csapi/content-repo.cpp @@ -50,7 +50,7 @@ BaseJob::Status UploadContentJob::parseJson(const QJsonDocument& data) { auto json = data.object(); if (!json.contains("content_uri"_ls)) - return { JsonParseError, + return { IncorrectResponse, "The key 'content_uri' not found in the response" }; fromJson(json.value("content_uri"_ls), d->contentUri); return Success; -- cgit v1.2.3 From 27ca32a1e5a56e09b9cc1d94224d2831004dcf3d Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 7 Jul 2019 19:32:34 +0900 Subject: Namespace: QMatrixClient -> Quotient (with back comp alias) --- lib/csapi/content-repo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/csapi/content-repo.cpp') diff --git a/lib/csapi/content-repo.cpp b/lib/csapi/content-repo.cpp index c2720d63..395337f3 100644 --- a/lib/csapi/content-repo.cpp +++ b/lib/csapi/content-repo.cpp @@ -9,7 +9,7 @@ #include #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/media/r0"); -- cgit v1.2.3 From 7036ed0dcb137cb5cbb6b426dd338c5e2e4c6424 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 17 Apr 2020 07:42:13 +0200 Subject: Regenerate API files using new GTAD and refreshed templates No functional changes. --- lib/csapi/content-repo.cpp | 49 ++++++++++++++-------------------------------- 1 file changed, 15 insertions(+), 34 deletions(-) (limited to 'lib/csapi/content-repo.cpp') diff --git a/lib/csapi/content-repo.cpp b/lib/csapi/content-repo.cpp index 395337f3..d811426d 100644 --- a/lib/csapi/content-repo.cpp +++ b/lib/csapi/content-repo.cpp @@ -13,8 +13,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/media/r0"); -class UploadContentJob::Private -{ +class UploadContentJob::Private { public: QString contentUri; }; @@ -26,12 +25,10 @@ BaseJob::Query queryToUploadContent(const QString& filename) return _q; } -static const auto UploadContentJobName = QStringLiteral("UploadContentJob"); - UploadContentJob::UploadContentJob(QIODevice* content, const QString& filename, const QString& contentType) - : BaseJob(HttpVerb::Post, UploadContentJobName, basePath % "/upload", - queryToUploadContent(filename)) + : BaseJob(HttpVerb::Post, QStringLiteral("UploadContentJob"), + basePath % "/upload", queryToUploadContent(filename)) , d(new Private) { setRequestHeader("Content-Type", contentType.toLatin1()); @@ -53,8 +50,7 @@ BaseJob::Status UploadContentJob::parseJson(const QJsonDocument& data) return Success; } -class GetContentJob::Private -{ +class GetContentJob::Private { public: QString contentType; QString contentDisposition; @@ -77,11 +73,9 @@ QUrl GetContentJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, queryToGetContent(allowRemote)); } -static const auto GetContentJobName = QStringLiteral("GetContentJob"); - GetContentJob::GetContentJob(const QString& serverName, const QString& mediaId, bool allowRemote) - : BaseJob(HttpVerb::Get, GetContentJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetContentJob"), basePath % "/download/" % serverName % "/" % mediaId, queryToGetContent(allowRemote), {}, false) , d(new Private) @@ -108,8 +102,7 @@ BaseJob::Status GetContentJob::parseReply(QNetworkReply* reply) return Success; } -class GetContentOverrideNameJob::Private -{ +class GetContentOverrideNameJob::Private { public: QString contentType; QString contentDisposition; @@ -135,14 +128,11 @@ QUrl GetContentOverrideNameJob::makeRequestUrl(QUrl baseUrl, queryToGetContentOverrideName(allowRemote)); } -static const auto GetContentOverrideNameJobName = - QStringLiteral("GetContentOverrideNameJob"); - GetContentOverrideNameJob::GetContentOverrideNameJob(const QString& serverName, const QString& mediaId, const QString& fileName, bool allowRemote) - : BaseJob(HttpVerb::Get, GetContentOverrideNameJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetContentOverrideNameJob"), basePath % "/download/" % serverName % "/" % mediaId % "/" % fileName, queryToGetContentOverrideName(allowRemote), {}, false) @@ -173,8 +163,7 @@ BaseJob::Status GetContentOverrideNameJob::parseReply(QNetworkReply* reply) return Success; } -class GetContentThumbnailJob::Private -{ +class GetContentThumbnailJob::Private { public: QString contentType; QIODevice* data; @@ -204,14 +193,11 @@ QUrl GetContentThumbnailJob::makeRequestUrl(QUrl baseUrl, queryToGetContentThumbnail(width, height, method, allowRemote)); } -static const auto GetContentThumbnailJobName = - QStringLiteral("GetContentThumbnailJob"); - GetContentThumbnailJob::GetContentThumbnailJob(const QString& serverName, const QString& mediaId, int width, int height, const QString& method, bool allowRemote) - : BaseJob(HttpVerb::Get, GetContentThumbnailJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("GetContentThumbnailJob"), basePath % "/thumbnail/" % serverName % "/" % mediaId, queryToGetContentThumbnail(width, height, method, allowRemote), {}, false) @@ -236,8 +222,7 @@ BaseJob::Status GetContentThumbnailJob::parseReply(QNetworkReply* reply) return Success; } -class GetUrlPreviewJob::Private -{ +class GetUrlPreviewJob::Private { public: Omittable matrixImageSize; QString ogImage; @@ -258,11 +243,9 @@ QUrl GetUrlPreviewJob::makeRequestUrl(QUrl baseUrl, const QString& url, queryToGetUrlPreview(url, ts)); } -static const auto GetUrlPreviewJobName = QStringLiteral("GetUrlPreviewJob"); - GetUrlPreviewJob::GetUrlPreviewJob(const QString& url, Omittable ts) - : BaseJob(HttpVerb::Get, GetUrlPreviewJobName, basePath % "/preview_url", - queryToGetUrlPreview(url, ts)) + : BaseJob(HttpVerb::Get, QStringLiteral("GetUrlPreviewJob"), + basePath % "/preview_url", queryToGetUrlPreview(url, ts)) , d(new Private) {} @@ -284,8 +267,7 @@ BaseJob::Status GetUrlPreviewJob::parseJson(const QJsonDocument& data) return Success; } -class GetConfigJob::Private -{ +class GetConfigJob::Private { public: Omittable uploadSize; }; @@ -295,10 +277,9 @@ QUrl GetConfigJob::makeRequestUrl(QUrl baseUrl) return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/config"); } -static const auto GetConfigJobName = QStringLiteral("GetConfigJob"); - GetConfigJob::GetConfigJob() - : BaseJob(HttpVerb::Get, GetConfigJobName, basePath % "/config") + : BaseJob(HttpVerb::Get, QStringLiteral("GetConfigJob"), + basePath % "/config") , d(new Private) {} -- cgit v1.2.3 From 32729d9a7519cd2c4cddb0174b8329c6fd4a4a83 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 7 Jun 2020 19:46:40 +0200 Subject: Update generated files according to gtad/* changes --- lib/csapi/content-repo.cpp | 198 +++++++-------------------------------------- 1 file changed, 30 insertions(+), 168 deletions(-) (limited to 'lib/csapi/content-repo.cpp') diff --git a/lib/csapi/content-repo.cpp b/lib/csapi/content-repo.cpp index d811426d..7ae89739 100644 --- a/lib/csapi/content-repo.cpp +++ b/lib/csapi/content-repo.cpp @@ -4,21 +4,11 @@ #include "content-repo.h" -#include "converters.h" - #include -#include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/media/r0"); - -class UploadContentJob::Private { -public: - QString contentUri; -}; - -BaseJob::Query queryToUploadContent(const QString& filename) +auto queryToUploadContent(const QString& filename) { BaseJob::Query _q; addParam(_q, QStringLiteral("filename"), filename); @@ -28,36 +18,15 @@ BaseJob::Query queryToUploadContent(const QString& filename) UploadContentJob::UploadContentJob(QIODevice* content, const QString& filename, const QString& contentType) : BaseJob(HttpVerb::Post, QStringLiteral("UploadContentJob"), - basePath % "/upload", queryToUploadContent(filename)) - , d(new Private) + QStringLiteral("/_matrix/media/r0") % "/upload", + queryToUploadContent(filename)) { setRequestHeader("Content-Type", contentType.toLatin1()); setRequestData(Data(content)); + addExpectedKey("content_uri"); } -UploadContentJob::~UploadContentJob() = default; - -const QString& UploadContentJob::contentUri() const { return d->contentUri; } - -BaseJob::Status UploadContentJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - if (!json.contains("content_uri"_ls)) - return { IncorrectResponse, - "The key 'content_uri' not found in the response" }; - fromJson(json.value("content_uri"_ls), d->contentUri); - - return Success; -} - -class GetContentJob::Private { -public: - QString contentType; - QString contentDisposition; - QIODevice* data; -}; - -BaseJob::Query queryToGetContent(bool allowRemote) +auto queryToGetContent(bool allowRemote) { BaseJob::Query _q; addParam(_q, QStringLiteral("allow_remote"), allowRemote); @@ -68,7 +37,8 @@ QUrl GetContentJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, bool allowRemote) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/download/" % serverName % "/" + QStringLiteral("/_matrix/media/r0") + % "/download/" % serverName % "/" % mediaId, queryToGetContent(allowRemote)); } @@ -76,40 +46,14 @@ QUrl GetContentJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, GetContentJob::GetContentJob(const QString& serverName, const QString& mediaId, bool allowRemote) : BaseJob(HttpVerb::Get, QStringLiteral("GetContentJob"), - basePath % "/download/" % serverName % "/" % mediaId, + QStringLiteral("/_matrix/media/r0") % "/download/" % serverName + % "/" % mediaId, queryToGetContent(allowRemote), {}, false) - , d(new Private) { setExpectedContentTypes({ "*/*" }); } -GetContentJob::~GetContentJob() = default; - -const QString& GetContentJob::contentType() const { return d->contentType; } - -const QString& GetContentJob::contentDisposition() const -{ - return d->contentDisposition; -} - -QIODevice* GetContentJob::data() const { return d->data; } - -BaseJob::Status GetContentJob::parseReply(QNetworkReply* reply) -{ - d->contentType = reply->rawHeader("Content-Type"); - d->contentDisposition = reply->rawHeader("Content-Disposition"); - d->data = reply; - return Success; -} - -class GetContentOverrideNameJob::Private { -public: - QString contentType; - QString contentDisposition; - QIODevice* data; -}; - -BaseJob::Query queryToGetContentOverrideName(bool allowRemote) +auto queryToGetContentOverrideName(bool allowRemote) { BaseJob::Query _q; addParam(_q, QStringLiteral("allow_remote"), allowRemote); @@ -123,7 +67,8 @@ QUrl GetContentOverrideNameJob::makeRequestUrl(QUrl baseUrl, bool allowRemote) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/download/" % serverName % "/" + QStringLiteral("/_matrix/media/r0") + % "/download/" % serverName % "/" % mediaId % "/" % fileName, queryToGetContentOverrideName(allowRemote)); } @@ -133,45 +78,15 @@ GetContentOverrideNameJob::GetContentOverrideNameJob(const QString& serverName, const QString& fileName, bool allowRemote) : BaseJob(HttpVerb::Get, QStringLiteral("GetContentOverrideNameJob"), - basePath % "/download/" % serverName % "/" % mediaId % "/" - % fileName, + QStringLiteral("/_matrix/media/r0") % "/download/" % serverName + % "/" % mediaId % "/" % fileName, queryToGetContentOverrideName(allowRemote), {}, false) - , d(new Private) { setExpectedContentTypes({ "*/*" }); } -GetContentOverrideNameJob::~GetContentOverrideNameJob() = default; - -const QString& GetContentOverrideNameJob::contentType() const -{ - return d->contentType; -} - -const QString& GetContentOverrideNameJob::contentDisposition() const -{ - return d->contentDisposition; -} - -QIODevice* GetContentOverrideNameJob::data() const { return d->data; } - -BaseJob::Status GetContentOverrideNameJob::parseReply(QNetworkReply* reply) -{ - d->contentType = reply->rawHeader("Content-Type"); - d->contentDisposition = reply->rawHeader("Content-Disposition"); - d->data = reply; - return Success; -} - -class GetContentThumbnailJob::Private { -public: - QString contentType; - QIODevice* data; -}; - -BaseJob::Query queryToGetContentThumbnail(int width, int height, - const QString& method, - bool allowRemote) +auto queryToGetContentThumbnail(int width, int height, const QString& method, + bool allowRemote) { BaseJob::Query _q; addParam<>(_q, QStringLiteral("width"), width); @@ -189,7 +104,8 @@ QUrl GetContentThumbnailJob::makeRequestUrl(QUrl baseUrl, { return BaseJob::makeRequestUrl( std::move(baseUrl), - basePath % "/thumbnail/" % serverName % "/" % mediaId, + QStringLiteral("/_matrix/media/r0") % "/thumbnail/" % serverName % "/" + % mediaId, queryToGetContentThumbnail(width, height, method, allowRemote)); } @@ -198,37 +114,15 @@ GetContentThumbnailJob::GetContentThumbnailJob(const QString& serverName, int height, const QString& method, bool allowRemote) : BaseJob(HttpVerb::Get, QStringLiteral("GetContentThumbnailJob"), - basePath % "/thumbnail/" % serverName % "/" % mediaId, + QStringLiteral("/_matrix/media/r0") % "/thumbnail/" % serverName + % "/" % mediaId, queryToGetContentThumbnail(width, height, method, allowRemote), {}, false) - , d(new Private) { setExpectedContentTypes({ "image/jpeg", "image/png" }); } -GetContentThumbnailJob::~GetContentThumbnailJob() = default; - -const QString& GetContentThumbnailJob::contentType() const -{ - return d->contentType; -} - -QIODevice* GetContentThumbnailJob::data() const { return d->data; } - -BaseJob::Status GetContentThumbnailJob::parseReply(QNetworkReply* reply) -{ - d->contentType = reply->rawHeader("Content-Type"); - d->data = reply; - return Success; -} - -class GetUrlPreviewJob::Private { -public: - Omittable matrixImageSize; - QString ogImage; -}; - -BaseJob::Query queryToGetUrlPreview(const QString& url, Omittable ts) +auto queryToGetUrlPreview(const QString& url, Omittable ts) { BaseJob::Query _q; addParam<>(_q, QStringLiteral("url"), url); @@ -239,58 +133,26 @@ BaseJob::Query queryToGetUrlPreview(const QString& url, Omittable ts) QUrl GetUrlPreviewJob::makeRequestUrl(QUrl baseUrl, const QString& url, Omittable ts) { - return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/preview_url", + return BaseJob::makeRequestUrl(std::move(baseUrl), + QStringLiteral("/_matrix/media/r0") + % "/preview_url", queryToGetUrlPreview(url, ts)); } GetUrlPreviewJob::GetUrlPreviewJob(const QString& url, Omittable ts) : BaseJob(HttpVerb::Get, QStringLiteral("GetUrlPreviewJob"), - basePath % "/preview_url", queryToGetUrlPreview(url, ts)) - , d(new Private) + QStringLiteral("/_matrix/media/r0") % "/preview_url", + queryToGetUrlPreview(url, ts)) {} -GetUrlPreviewJob::~GetUrlPreviewJob() = default; - -Omittable GetUrlPreviewJob::matrixImageSize() const -{ - return d->matrixImageSize; -} - -const QString& GetUrlPreviewJob::ogImage() const { return d->ogImage; } - -BaseJob::Status GetUrlPreviewJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("matrix:image:size"_ls), d->matrixImageSize); - fromJson(json.value("og:image"_ls), d->ogImage); - - return Success; -} - -class GetConfigJob::Private { -public: - Omittable uploadSize; -}; - QUrl GetConfigJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/config"); + return BaseJob::makeRequestUrl(std::move(baseUrl), + QStringLiteral("/_matrix/media/r0") + % "/config"); } GetConfigJob::GetConfigJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetConfigJob"), - basePath % "/config") - , d(new Private) + QStringLiteral("/_matrix/media/r0") % "/config") {} - -GetConfigJob::~GetConfigJob() = default; - -Omittable GetConfigJob::uploadSize() const { return d->uploadSize; } - -BaseJob::Status GetConfigJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("m.upload.size"_ls), d->uploadSize); - - return Success; -} -- cgit v1.2.3