| 1 | /****************************************************************************** |
| 2 | * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN |
| 3 | */ |
| 4 | |
| 5 | #include "content-repo.h" |
| 6 | |
| 7 | using namespace Quotient; |
| 8 | |
| 9 | auto queryToUploadContent(const QString& filename) |
| 10 | { |
| 11 | QUrlQuery _q; |
| 12 | addParam<IfNotEmpty>(container&: _q, QStringLiteral("filename" ), value: filename); |
| 13 | return _q; |
| 14 | } |
| 15 | |
| 16 | UploadContentJob::UploadContentJob(QIODevice* content, const QString& filename, |
| 17 | const QString& contentType) |
| 18 | : BaseJob(HttpVerb::Post, QStringLiteral("UploadContentJob" ), |
| 19 | makePath(parts: "/_matrix" , parts: "/media/v3/upload" ), |
| 20 | queryToUploadContent(filename)) |
| 21 | { |
| 22 | setRequestHeader(headerName: "Content-Type" , headerValue: contentType.toLatin1()); |
| 23 | setRequestData({ content }); |
| 24 | addExpectedKey(key: "content_uri" ); |
| 25 | } |
| 26 | |
| 27 | auto queryToUploadContentToMXC(const QString& filename) |
| 28 | { |
| 29 | QUrlQuery _q; |
| 30 | addParam<IfNotEmpty>(container&: _q, QStringLiteral("filename" ), value: filename); |
| 31 | return _q; |
| 32 | } |
| 33 | |
| 34 | UploadContentToMXCJob::UploadContentToMXCJob(const QString& serverName, |
| 35 | const QString& mediaId, |
| 36 | QIODevice* content, |
| 37 | const QString& filename, |
| 38 | const QString& contentType) |
| 39 | : BaseJob(HttpVerb::Put, QStringLiteral("UploadContentToMXCJob" ), |
| 40 | makePath(parts: "/_matrix" , parts: "/media/v3/upload/" , parts: serverName, parts: "/" , |
| 41 | parts: mediaId), |
| 42 | queryToUploadContentToMXC(filename), {}, false) |
| 43 | { |
| 44 | setRequestHeader(headerName: "Content-Type" , headerValue: contentType.toLatin1()); |
| 45 | setRequestData({ content }); |
| 46 | setExpectedContentTypes({ "application/json" , "*/*" }); |
| 47 | } |
| 48 | |
| 49 | QUrl CreateContentJob::makeRequestUrl(QUrl baseUrl) |
| 50 | { |
| 51 | return BaseJob::makeRequestUrl(baseUrl: std::move(baseUrl), |
| 52 | encodedPath: makePath(parts: "/_matrix" , parts: "/media/v1/create" )); |
| 53 | } |
| 54 | |
| 55 | CreateContentJob::CreateContentJob() |
| 56 | : BaseJob(HttpVerb::Post, QStringLiteral("CreateContentJob" ), |
| 57 | makePath(parts: "/_matrix" , parts: "/media/v1/create" )) |
| 58 | { |
| 59 | addExpectedKey(key: "content_uri" ); |
| 60 | } |
| 61 | |
| 62 | auto queryToGetContent(bool allowRemote, qint64 timeoutMs, bool allowRedirect) |
| 63 | { |
| 64 | QUrlQuery _q; |
| 65 | addParam<IfNotEmpty>(container&: _q, QStringLiteral("allow_remote" ), value&: allowRemote); |
| 66 | addParam<IfNotEmpty>(container&: _q, QStringLiteral("timeout_ms" ), value&: timeoutMs); |
| 67 | addParam<IfNotEmpty>(container&: _q, QStringLiteral("allow_redirect" ), value&: allowRedirect); |
| 68 | return _q; |
| 69 | } |
| 70 | |
| 71 | QUrl GetContentJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, |
| 72 | const QString& mediaId, bool allowRemote, |
| 73 | qint64 timeoutMs, bool allowRedirect) |
| 74 | { |
| 75 | return BaseJob::makeRequestUrl( |
| 76 | baseUrl: std::move(baseUrl), |
| 77 | encodedPath: makePath(parts: "/_matrix" , parts: "/media/v3/download/" , parts: serverName, parts: "/" , parts: mediaId), |
| 78 | query: queryToGetContent(allowRemote, timeoutMs, allowRedirect)); |
| 79 | } |
| 80 | |
| 81 | GetContentJob::GetContentJob(const QString& serverName, const QString& mediaId, |
| 82 | bool allowRemote, qint64 timeoutMs, |
| 83 | bool allowRedirect) |
| 84 | : BaseJob(HttpVerb::Get, QStringLiteral("GetContentJob" ), |
| 85 | makePath(parts: "/_matrix" , parts: "/media/v3/download/" , parts: serverName, parts: "/" , |
| 86 | parts: mediaId), |
| 87 | queryToGetContent(allowRemote, timeoutMs, allowRedirect), {}, |
| 88 | false) |
| 89 | { |
| 90 | setExpectedContentTypes({ "*/*" }); |
| 91 | } |
| 92 | |
| 93 | auto queryToGetContentOverrideName(bool allowRemote, qint64 timeoutMs, |
| 94 | bool allowRedirect) |
| 95 | { |
| 96 | QUrlQuery _q; |
| 97 | addParam<IfNotEmpty>(container&: _q, QStringLiteral("allow_remote" ), value&: allowRemote); |
| 98 | addParam<IfNotEmpty>(container&: _q, QStringLiteral("timeout_ms" ), value&: timeoutMs); |
| 99 | addParam<IfNotEmpty>(container&: _q, QStringLiteral("allow_redirect" ), value&: allowRedirect); |
| 100 | return _q; |
| 101 | } |
| 102 | |
| 103 | QUrl GetContentOverrideNameJob::makeRequestUrl( |
| 104 | QUrl baseUrl, const QString& serverName, const QString& mediaId, |
| 105 | const QString& fileName, bool allowRemote, qint64 timeoutMs, |
| 106 | bool allowRedirect) |
| 107 | { |
| 108 | return BaseJob::makeRequestUrl( |
| 109 | baseUrl: std::move(baseUrl), |
| 110 | encodedPath: makePath(parts: "/_matrix" , parts: "/media/v3/download/" , parts: serverName, parts: "/" , parts: mediaId, |
| 111 | parts: "/" , parts: fileName), |
| 112 | query: queryToGetContentOverrideName(allowRemote, timeoutMs, allowRedirect)); |
| 113 | } |
| 114 | |
| 115 | GetContentOverrideNameJob::GetContentOverrideNameJob( |
| 116 | const QString& serverName, const QString& mediaId, const QString& fileName, |
| 117 | bool allowRemote, qint64 timeoutMs, bool allowRedirect) |
| 118 | : BaseJob(HttpVerb::Get, QStringLiteral("GetContentOverrideNameJob" ), |
| 119 | makePath(parts: "/_matrix" , parts: "/media/v3/download/" , parts: serverName, parts: "/" , |
| 120 | parts: mediaId, parts: "/" , parts: fileName), |
| 121 | queryToGetContentOverrideName(allowRemote, timeoutMs, |
| 122 | allowRedirect), |
| 123 | {}, false) |
| 124 | { |
| 125 | setExpectedContentTypes({ "*/*" }); |
| 126 | } |
| 127 | |
| 128 | auto queryToGetContentThumbnail(int width, int height, const QString& method, |
| 129 | bool allowRemote, qint64 timeoutMs, |
| 130 | bool allowRedirect) |
| 131 | { |
| 132 | QUrlQuery _q; |
| 133 | addParam<>(container&: _q, QStringLiteral("width" ), value&: width); |
| 134 | addParam<>(container&: _q, QStringLiteral("height" ), value&: height); |
| 135 | addParam<IfNotEmpty>(container&: _q, QStringLiteral("method" ), value: method); |
| 136 | addParam<IfNotEmpty>(container&: _q, QStringLiteral("allow_remote" ), value&: allowRemote); |
| 137 | addParam<IfNotEmpty>(container&: _q, QStringLiteral("timeout_ms" ), value&: timeoutMs); |
| 138 | addParam<IfNotEmpty>(container&: _q, QStringLiteral("allow_redirect" ), value&: allowRedirect); |
| 139 | return _q; |
| 140 | } |
| 141 | |
| 142 | QUrl GetContentThumbnailJob::makeRequestUrl(QUrl baseUrl, |
| 143 | const QString& serverName, |
| 144 | const QString& mediaId, int width, |
| 145 | int height, const QString& method, |
| 146 | bool allowRemote, qint64 timeoutMs, |
| 147 | bool allowRedirect) |
| 148 | { |
| 149 | return BaseJob::makeRequestUrl( |
| 150 | baseUrl: std::move(baseUrl), |
| 151 | encodedPath: makePath(parts: "/_matrix" , parts: "/media/v3/thumbnail/" , parts: serverName, parts: "/" , parts: mediaId), |
| 152 | query: queryToGetContentThumbnail(width, height, method, allowRemote, |
| 153 | timeoutMs, allowRedirect)); |
| 154 | } |
| 155 | |
| 156 | GetContentThumbnailJob::GetContentThumbnailJob( |
| 157 | const QString& serverName, const QString& mediaId, int width, int height, |
| 158 | const QString& method, bool allowRemote, qint64 timeoutMs, |
| 159 | bool allowRedirect) |
| 160 | : BaseJob(HttpVerb::Get, QStringLiteral("GetContentThumbnailJob" ), |
| 161 | makePath(parts: "/_matrix" , parts: "/media/v3/thumbnail/" , parts: serverName, parts: "/" , |
| 162 | parts: mediaId), |
| 163 | queryToGetContentThumbnail(width, height, method, allowRemote, |
| 164 | timeoutMs, allowRedirect), |
| 165 | {}, false) |
| 166 | { |
| 167 | setExpectedContentTypes({ "image/jpeg" , "image/png" }); |
| 168 | } |
| 169 | |
| 170 | auto queryToGetUrlPreview(const QUrl& url, Omittable<qint64> ts) |
| 171 | { |
| 172 | QUrlQuery _q; |
| 173 | addParam<>(container&: _q, QStringLiteral("url" ), value: url); |
| 174 | addParam<IfNotEmpty>(container&: _q, QStringLiteral("ts" ), value&: ts); |
| 175 | return _q; |
| 176 | } |
| 177 | |
| 178 | QUrl GetUrlPreviewJob::makeRequestUrl(QUrl baseUrl, const QUrl& url, |
| 179 | Omittable<qint64> ts) |
| 180 | { |
| 181 | return BaseJob::makeRequestUrl(baseUrl: std::move(baseUrl), |
| 182 | encodedPath: makePath(parts: "/_matrix" , |
| 183 | parts: "/media/v3/preview_url" ), |
| 184 | query: queryToGetUrlPreview(url, ts)); |
| 185 | } |
| 186 | |
| 187 | GetUrlPreviewJob::GetUrlPreviewJob(const QUrl& url, Omittable<qint64> ts) |
| 188 | : BaseJob(HttpVerb::Get, QStringLiteral("GetUrlPreviewJob" ), |
| 189 | makePath(parts: "/_matrix" , parts: "/media/v3/preview_url" ), |
| 190 | queryToGetUrlPreview(url, ts)) |
| 191 | {} |
| 192 | |
| 193 | QUrl GetConfigJob::makeRequestUrl(QUrl baseUrl) |
| 194 | { |
| 195 | return BaseJob::makeRequestUrl(baseUrl: std::move(baseUrl), |
| 196 | encodedPath: makePath(parts: "/_matrix" , parts: "/media/v3/config" )); |
| 197 | } |
| 198 | |
| 199 | GetConfigJob::GetConfigJob() |
| 200 | : BaseJob(HttpVerb::Get, QStringLiteral("GetConfigJob" ), |
| 201 | makePath(parts: "/_matrix" , parts: "/media/v3/config" )) |
| 202 | {} |
| 203 | |