5 #include <Quotient/jobs/basejob.h>
7 #include <QtCore/QIODevice>
8 #include <QtNetwork/QNetworkReply>
25 explicit UploadContentJob(QIODevice* content,
const QString& filename = {},
26 const QString& contentType = {});
31 QUrl contentUri()
const {
return loadFromJson<QUrl>(
"content_uri"_L1); }
34 inline auto collectResponse(
const UploadContentJob* job) {
return job->contentUri(); }
58 explicit UploadContentToMXCJob(
const QString& serverName,
const QString& mediaId,
59 QIODevice* content,
const QString& filename = {},
60 const QString& contentType = {});
87 explicit CreateContentJob();
93 static QUrl makeRequestUrl(
const HomeserverData& hsData);
99 QUrl contentUri()
const {
return loadFromJson<QUrl>(
"content_uri"_L1); }
103 std::optional<qint64> unusedExpiresAt()
const
105 return loadFromJson<std::optional<qint64>>(
"unused_expires_at"_L1);
115 std::optional<qint64> unusedExpiresAt{};
119 template <std::derived_from<CreateContentJob> JobT>
120 constexpr inline auto doCollectResponse<JobT> =
121 [](JobT* j) -> CreateContentJob::Response {
return { j->contentUri(), j->unusedExpiresAt() }; };
135 class [[deprecated(
"Check the documentation for details")]]
QUOTIENT_API GetContentJob
162 explicit GetContentJob(
const QString& serverName,
const QString& mediaId,
163 bool allowRemote =
true, qint64 timeoutMs = 20000,
164 bool allowRedirect =
false);
170 static QUrl makeRequestUrl(
const HomeserverData& hsData,
const QString& serverName,
171 const QString& mediaId,
bool allowRemote =
true,
172 qint64 timeoutMs = 20000,
bool allowRedirect =
false);
193 QString contentType()
const {
return QString::fromUtf8(reply()->rawHeader(
"Content-Type")); }
212 QString contentDisposition()
const
214 return QString::fromUtf8(reply()->rawHeader(
"Content-Disposition"));
218 QIODevice* data() {
return reply(); }
237 class [[deprecated(
"Check the documentation for details")]]
QUOTIENT_API GetContentOverrideNameJob
267 explicit GetContentOverrideNameJob(
const QString& serverName,
const QString& mediaId,
268 const QString& fileName,
bool allowRemote =
true,
269 qint64 timeoutMs = 20000,
bool allowRedirect =
false);
275 static QUrl makeRequestUrl(
const HomeserverData& hsData,
const QString& serverName,
276 const QString& mediaId,
const QString& fileName,
277 bool allowRemote =
true, qint64 timeoutMs = 20000,
278 bool allowRedirect =
false);
299 QString contentType()
const {
return QString::fromUtf8(reply()->rawHeader(
"Content-Type")); }
310 QString contentDisposition()
const
312 return QString::fromUtf8(reply()->rawHeader(
"Content-Disposition"));
316 QIODevice* data() {
return reply(); }
334 class [[deprecated(
"Check the documentation for details")]]
QUOTIENT_API GetContentThumbnailJob
389 explicit GetContentThumbnailJob(
const QString& serverName,
const QString& mediaId,
int width,
390 int height,
const QString& method = {},
bool allowRemote =
true,
391 qint64 timeoutMs = 20000,
bool allowRedirect =
false,
392 std::optional<
bool> animated = std::nullopt);
398 static QUrl makeRequestUrl(
const HomeserverData& hsData,
const QString& serverName,
399 const QString& mediaId,
int width,
int height,
400 const QString& method = {},
bool allowRemote =
true,
401 qint64 timeoutMs = 20000,
bool allowRedirect =
false,
402 std::optional<
bool> animated = std::nullopt);
414 QString contentDisposition()
const
416 return QString::fromUtf8(reply()->rawHeader(
"Content-Disposition"));
420 QString contentType()
const {
return QString::fromUtf8(reply()->rawHeader(
"Content-Type")); }
423 QIODevice* data() {
return reply(); }
440 class [[deprecated(
"Check the documentation for details")]]
QUOTIENT_API GetUrlPreviewJob
450 explicit GetUrlPreviewJob(
const QUrl& url, std::optional<qint64> ts = std::nullopt);
456 static QUrl makeRequestUrl(
const HomeserverData& hsData,
const QUrl& url,
457 std::optional<qint64> ts = std::nullopt);
462 std::optional<qint64> matrixImageSize()
const
464 return loadFromJson<std::optional<qint64>>(
"matrix:image:size"_L1);
469 QUrl ogImage()
const {
return loadFromJson<QUrl>(
"og:image"_L1); }
473 std::optional<qint64> matrixImageSize{};
482 QT_WARNING_DISABLE_DEPRECATED
483 template <std::derived_from<GetUrlPreviewJob> JobT>
484 constexpr inline auto doCollectResponse<JobT> =
485 [](JobT* j) -> GetUrlPreviewJob::Response {
return { j->matrixImageSize(), j->ogImage() }; };
504 class [[deprecated(
"Check the documentation for details")]]
QUOTIENT_API GetConfigJob
507 explicit GetConfigJob();
513 static QUrl makeRequestUrl(
const HomeserverData& hsData);
520 std::optional<qint64> uploadSize()
const
522 return loadFromJson<std::optional<qint64>>(
"m.upload.size"_L1);
527 QT_WARNING_DISABLE_DEPRECATED
528 inline auto collectResponse(
const GetConfigJob* job) {
return job->uploadSize(); }