diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-06-03 13:22:03 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-06-03 13:22:03 +0900 |
commit | 8a8c645f2a2dc91e9d956b7dee8ef5cf741541f4 (patch) | |
tree | 3cd5af4991d5fe7b3e3de12d1b4c723ef85bbebb /lib | |
parent | 48c7d2de6fda86a5115147bc7d9825c3627a17d9 (diff) | |
download | libquotient-8a8c645f2a2dc91e9d956b7dee8ef5cf741541f4.tar.gz libquotient-8a8c645f2a2dc91e9d956b7dee8ef5cf741541f4.zip |
csapi: Updated to the most recent API definitions
Diffstat (limited to 'lib')
-rw-r--r-- | lib/csapi/content-repo.cpp | 47 | ||||
-rw-r--r-- | lib/csapi/content-repo.h | 12 | ||||
-rw-r--r-- | lib/csapi/logout.cpp | 12 | ||||
-rw-r--r-- | lib/csapi/logout.h | 14 |
4 files changed, 66 insertions, 19 deletions
diff --git a/lib/csapi/content-repo.cpp b/lib/csapi/content-repo.cpp index d0efdb9e..7eebeae5 100644 --- a/lib/csapi/content-repo.cpp +++ b/lib/csapi/content-repo.cpp @@ -63,15 +63,25 @@ class GetContentJob::Private QIODevice* content; }; -QUrl GetContentJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId) +BaseJob::Query queryToGetContent(bool allowRemote) +{ + BaseJob::Query _q; + _q.addQueryItem("allow_remote", QString("%1").arg(allowRemote)); + return _q; +} + +QUrl GetContentJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, bool allowRemote) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/download/" % serverName % "/" % mediaId); + basePath % "/download/" % serverName % "/" % mediaId, + queryToGetContent(allowRemote)); } -GetContentJob::GetContentJob(const QString& serverName, const QString& mediaId) +GetContentJob::GetContentJob(const QString& serverName, const QString& mediaId, bool allowRemote) : BaseJob(HttpVerb::Get, "GetContentJob", - basePath % "/download/" % serverName % "/" % mediaId, false) + basePath % "/download/" % serverName % "/" % mediaId, + queryToGetContent(allowRemote), + {}, false) , d(new Private) { setExpectedContentTypes({ "*/*" }); @@ -110,15 +120,25 @@ class GetContentOverrideNameJob::Private QIODevice* content; }; -QUrl GetContentOverrideNameJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, const QString& fileName) +BaseJob::Query queryToGetContentOverrideName(bool allowRemote) +{ + BaseJob::Query _q; + _q.addQueryItem("allow_remote", QString("%1").arg(allowRemote)); + return _q; +} + +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); + basePath % "/download/" % serverName % "/" % mediaId % "/" % fileName, + queryToGetContentOverrideName(allowRemote)); } -GetContentOverrideNameJob::GetContentOverrideNameJob(const QString& serverName, const QString& mediaId, const QString& fileName) +GetContentOverrideNameJob::GetContentOverrideNameJob(const QString& serverName, const QString& mediaId, const QString& fileName, bool allowRemote) : BaseJob(HttpVerb::Get, "GetContentOverrideNameJob", - basePath % "/download/" % serverName % "/" % mediaId % "/" % fileName, false) + basePath % "/download/" % serverName % "/" % mediaId % "/" % fileName, + queryToGetContentOverrideName(allowRemote), + {}, false) , d(new Private) { setExpectedContentTypes({ "*/*" }); @@ -156,7 +176,7 @@ class GetContentThumbnailJob::Private QIODevice* content; }; -BaseJob::Query queryToGetContentThumbnail(Omittable<int> width, Omittable<int> height, const QString& method) +BaseJob::Query queryToGetContentThumbnail(Omittable<int> width, Omittable<int> height, const QString& method, bool allowRemote) { BaseJob::Query _q; if (width) @@ -165,20 +185,21 @@ BaseJob::Query queryToGetContentThumbnail(Omittable<int> width, Omittable<int> h _q.addQueryItem("height", QString("%1").arg(height.value())); if (!method.isEmpty()) _q.addQueryItem("method", method); + _q.addQueryItem("allow_remote", QString("%1").arg(allowRemote)); return _q; } -QUrl GetContentThumbnailJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, Omittable<int> width, Omittable<int> height, const QString& method) +QUrl GetContentThumbnailJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, Omittable<int> width, Omittable<int> height, const QString& method, bool allowRemote) { return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/thumbnail/" % serverName % "/" % mediaId, - queryToGetContentThumbnail(width, height, method)); + queryToGetContentThumbnail(width, height, method, allowRemote)); } -GetContentThumbnailJob::GetContentThumbnailJob(const QString& serverName, const QString& mediaId, Omittable<int> width, Omittable<int> height, const QString& method) +GetContentThumbnailJob::GetContentThumbnailJob(const QString& serverName, const QString& mediaId, Omittable<int> width, Omittable<int> height, const QString& method, bool allowRemote) : BaseJob(HttpVerb::Get, "GetContentThumbnailJob", basePath % "/thumbnail/" % serverName % "/" % mediaId, - queryToGetContentThumbnail(width, height, method), + queryToGetContentThumbnail(width, height, method, allowRemote), {}, false) , d(new Private) { diff --git a/lib/csapi/content-repo.h b/lib/csapi/content-repo.h index 8d73dc51..582fedab 100644 --- a/lib/csapi/content-repo.h +++ b/lib/csapi/content-repo.h @@ -34,14 +34,14 @@ namespace QMatrixClient class GetContentJob : public BaseJob { public: - explicit GetContentJob(const QString& serverName, const QString& mediaId); + explicit GetContentJob(const QString& serverName, const QString& mediaId, bool allowRemote = true); /** 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); + static QUrl makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, bool allowRemote = true); ~GetContentJob() override; @@ -62,14 +62,14 @@ namespace QMatrixClient class GetContentOverrideNameJob : public BaseJob { public: - explicit GetContentOverrideNameJob(const QString& serverName, const QString& mediaId, const QString& fileName); + explicit GetContentOverrideNameJob(const QString& serverName, const QString& mediaId, const QString& fileName, bool allowRemote = true); /** 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); + static QUrl makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, const QString& fileName, bool allowRemote = true); ~GetContentOverrideNameJob() override; @@ -90,14 +90,14 @@ namespace QMatrixClient class GetContentThumbnailJob : public BaseJob { public: - explicit GetContentThumbnailJob(const QString& serverName, const QString& mediaId, Omittable<int> width = none, Omittable<int> height = none, const QString& method = {}); + explicit GetContentThumbnailJob(const QString& serverName, const QString& mediaId, Omittable<int> width = none, Omittable<int> height = none, const QString& method = {}, bool allowRemote = true); /** 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, Omittable<int> width = none, Omittable<int> height = none, const QString& method = {}); + static QUrl makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, Omittable<int> width = none, Omittable<int> height = none, const QString& method = {}, bool allowRemote = true); ~GetContentThumbnailJob() override; diff --git a/lib/csapi/logout.cpp b/lib/csapi/logout.cpp index b943dcd3..42f99bbc 100644 --- a/lib/csapi/logout.cpp +++ b/lib/csapi/logout.cpp @@ -24,3 +24,15 @@ LogoutJob::LogoutJob() { } +QUrl LogoutAllJob::makeRequestUrl(QUrl baseUrl) +{ + return BaseJob::makeRequestUrl(std::move(baseUrl), + basePath % "/logout/all"); +} + +LogoutAllJob::LogoutAllJob() + : BaseJob(HttpVerb::Post, "LogoutAllJob", + basePath % "/logout/all") +{ +} + diff --git a/lib/csapi/logout.h b/lib/csapi/logout.h index 3d60ad48..7862c930 100644 --- a/lib/csapi/logout.h +++ b/lib/csapi/logout.h @@ -24,4 +24,18 @@ namespace QMatrixClient static QUrl makeRequestUrl(QUrl baseUrl); }; + + class LogoutAllJob : public BaseJob + { + public: + explicit LogoutAllJob(); + + /** Construct a URL out of baseUrl and usual parameters passed to + * LogoutAllJob. This function can be used when + * a URL for LogoutAllJob is necessary but the job + * itself isn't. + */ + static QUrl makeRequestUrl(QUrl baseUrl); + + }; } // namespace QMatrixClient |