diff options
author | Marc Deop <marc@marcdeop.com> | 2019-03-02 12:26:57 +0100 |
---|---|---|
committer | Marc Deop <marc@marcdeop.com> | 2019-03-02 12:26:57 +0100 |
commit | aacc4bcb4a487871daae6717f77605aaba444341 (patch) | |
tree | 4f50b6874821667ccb6b91c017e5d041e3846112 /lib/csapi/content-repo.cpp | |
parent | c971b924cd62822ed6fb1a0291c483ae73a3ecda (diff) | |
download | libquotient-aacc4bcb4a487871daae6717f77605aaba444341.tar.gz libquotient-aacc4bcb4a487871daae6717f77605aaba444341.zip |
style: apply .clang-format to all .cpp and .h files
Diffstat (limited to 'lib/csapi/content-repo.cpp')
-rw-r--r-- | lib/csapi/content-repo.cpp | 171 |
1 files changed, 85 insertions, 86 deletions
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 <QtNetwork/QNetworkReply> #include <QtCore/QStringBuilder> +#include <QtNetwork/QNetworkReply> 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<qint64> matrixImageSize; - QString ogImage; + Omittable<qint64> matrixImageSize; + QString ogImage; }; BaseJob::Query queryToGetUrlPreview(const QString& url, Omittable<qint64> ts) @@ -244,20 +252,20 @@ BaseJob::Query queryToGetUrlPreview(const QString& url, Omittable<qint64> ts) return _q; } -QUrl GetUrlPreviewJob::makeRequestUrl(QUrl baseUrl, const QString& url, Omittable<qint64> ts) +QUrl GetUrlPreviewJob::makeRequestUrl(QUrl baseUrl, const QString& url, + Omittable<qint64> 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<qint64> 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<qint64> 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<qint64> uploadSize; + Omittable<qint64> 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<qint64> GetConfigJob::uploadSize() const -{ - return d->uploadSize; -} +Omittable<qint64> 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; } - |