diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-06-24 07:21:13 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-06-24 07:21:13 +0900 |
commit | 63ae79c3e2820efc2ba60d33e2caf2d7b9b3c408 (patch) | |
tree | 2552f5049a6ef7ba0034483b25ca4ab33d1fcb13 /lib/csapi/content-repo.cpp | |
parent | e083d327e6f6581210f8d077d8bbe1151e81e82c (diff) | |
parent | 93f0c8fe89f448d1d58caa757573f17102369471 (diff) | |
download | libquotient-63ae79c3e2820efc2ba60d33e2caf2d7b9b3c408.tar.gz libquotient-63ae79c3e2820efc2ba60d33e2caf2d7b9b3c408.zip |
Merge branch 'master' into clang-format
# Conflicts:
# CMakeLists.txt
# lib/avatar.cpp
# lib/connection.cpp
# lib/connection.h
# lib/connectiondata.cpp
# lib/csapi/account-data.cpp
# lib/csapi/account-data.h
# lib/csapi/capabilities.cpp
# lib/csapi/capabilities.h
# lib/csapi/content-repo.cpp
# lib/csapi/create_room.cpp
# lib/csapi/filter.cpp
# lib/csapi/joining.cpp
# lib/csapi/keys.cpp
# lib/csapi/list_joined_rooms.cpp
# lib/csapi/notifications.cpp
# lib/csapi/openid.cpp
# lib/csapi/presence.cpp
# lib/csapi/pushrules.cpp
# lib/csapi/registration.cpp
# lib/csapi/room_upgrades.cpp
# lib/csapi/room_upgrades.h
# lib/csapi/search.cpp
# lib/csapi/users.cpp
# lib/csapi/versions.cpp
# lib/csapi/whoami.cpp
# lib/csapi/{{base}}.cpp.mustache
# lib/events/accountdataevents.h
# lib/events/eventcontent.h
# lib/events/roommemberevent.cpp
# lib/events/stateevent.cpp
# lib/jobs/basejob.cpp
# lib/jobs/basejob.h
# lib/networkaccessmanager.cpp
# lib/networksettings.cpp
# lib/room.cpp
# lib/room.h
# lib/settings.cpp
# lib/settings.h
# lib/syncdata.cpp
# lib/user.cpp
# lib/user.h
# lib/util.cpp
Diffstat (limited to 'lib/csapi/content-repo.cpp')
-rw-r--r-- | lib/csapi/content-repo.cpp | 72 |
1 files changed, 35 insertions, 37 deletions
diff --git a/lib/csapi/content-repo.cpp b/lib/csapi/content-repo.cpp index d59449b9..c2720d63 100644 --- a/lib/csapi/content-repo.cpp +++ b/lib/csapi/content-repo.cpp @@ -15,7 +15,7 @@ static const auto basePath = QStringLiteral("/_matrix/media/r0"); class UploadContentJob::Private { - public: +public: QString contentUri; }; @@ -31,11 +31,10 @@ 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) + queryToUploadContent(filename)) + , d(new Private) { setRequestHeader("Content-Type", contentType.toLatin1()); - setRequestData(Data(content)); } @@ -47,15 +46,16 @@ 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; } class GetContentJob::Private { - public: +public: QString contentType; QString contentDisposition; QIODevice* data; @@ -73,7 +73,7 @@ QUrl GetContentJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, { return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/download/" % serverName % "/" - % mediaId, + % mediaId, queryToGetContent(allowRemote)); } @@ -83,8 +83,8 @@ GetContentJob::GetContentJob(const QString& serverName, const QString& mediaId, bool allowRemote) : BaseJob(HttpVerb::Get, GetContentJobName, basePath % "/download/" % serverName % "/" % mediaId, - queryToGetContent(allowRemote), {}, false), - d(new Private) + queryToGetContent(allowRemote), {}, false) + , d(new Private) { setExpectedContentTypes({ "*/*" }); } @@ -110,7 +110,7 @@ BaseJob::Status GetContentJob::parseReply(QNetworkReply* reply) class GetContentOverrideNameJob::Private { - public: +public: QString contentType; QString contentDisposition; QIODevice* data; @@ -131,12 +131,12 @@ QUrl GetContentOverrideNameJob::makeRequestUrl(QUrl baseUrl, { return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/download/" % serverName % "/" - % mediaId % "/" % fileName, + % mediaId % "/" % fileName, queryToGetContentOverrideName(allowRemote)); } static const auto GetContentOverrideNameJobName = - QStringLiteral("GetContentOverrideNameJob"); + QStringLiteral("GetContentOverrideNameJob"); GetContentOverrideNameJob::GetContentOverrideNameJob(const QString& serverName, const QString& mediaId, @@ -144,9 +144,9 @@ GetContentOverrideNameJob::GetContentOverrideNameJob(const QString& serverName, bool allowRemote) : BaseJob(HttpVerb::Get, GetContentOverrideNameJobName, basePath % "/download/" % serverName % "/" % mediaId % "/" - % fileName, - queryToGetContentOverrideName(allowRemote), {}, false), - d(new Private) + % fileName, + queryToGetContentOverrideName(allowRemote), {}, false) + , d(new Private) { setExpectedContentTypes({ "*/*" }); } @@ -175,7 +175,7 @@ BaseJob::Status GetContentOverrideNameJob::parseReply(QNetworkReply* reply) class GetContentThumbnailJob::Private { - public: +public: QString contentType; QIODevice* data; }; @@ -199,24 +199,23 @@ QUrl GetContentThumbnailJob::makeRequestUrl(QUrl baseUrl, bool allowRemote) { return BaseJob::makeRequestUrl( - std::move(baseUrl), - basePath % "/thumbnail/" % serverName % "/" % mediaId, - queryToGetContentThumbnail(width, height, method, allowRemote)); + std::move(baseUrl), + basePath % "/thumbnail/" % serverName % "/" % mediaId, + queryToGetContentThumbnail(width, height, method, allowRemote)); } static const auto GetContentThumbnailJobName = - QStringLiteral("GetContentThumbnailJob"); + QStringLiteral("GetContentThumbnailJob"); GetContentThumbnailJob::GetContentThumbnailJob(const QString& serverName, - const QString& mediaId, - int width, int height, - const QString& method, + 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) + {}, false) + , d(new Private) { setExpectedContentTypes({ "image/jpeg", "image/png" }); } @@ -239,7 +238,7 @@ BaseJob::Status GetContentThumbnailJob::parseReply(QNetworkReply* reply) class GetUrlPreviewJob::Private { - public: +public: Omittable<qint64> matrixImageSize; QString ogImage; }; @@ -255,8 +254,7 @@ BaseJob::Query queryToGetUrlPreview(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", + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/preview_url", queryToGetUrlPreview(url, ts)); } @@ -264,10 +262,9 @@ 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) -{ -} + queryToGetUrlPreview(url, ts)) + , d(new Private) +{} GetUrlPreviewJob::~GetUrlPreviewJob() = default; @@ -283,12 +280,13 @@ 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: +public: Omittable<qint64> uploadSize; }; @@ -300,10 +298,9 @@ QUrl GetConfigJob::makeRequestUrl(QUrl baseUrl) 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; @@ -313,5 +310,6 @@ BaseJob::Status GetConfigJob::parseJson(const QJsonDocument& data) { auto json = data.object(); fromJson(json.value("m.upload.size"_ls), d->uploadSize); + return Success; } |