aboutsummaryrefslogtreecommitdiff
path: root/lib/events/eventcontent.h
diff options
context:
space:
mode:
authorHubert Chathi <uhoreg@debian.org>2019-06-25 16:33:24 -0400
committerHubert Chathi <uhoreg@debian.org>2019-06-25 16:33:24 -0400
commit72d5660efd0755bb53a8699cd39865155400d288 (patch)
treeed7e7537e6a3eb7e8b92226c4015f9bfc8e11c5a /lib/events/eventcontent.h
parent52407a933bfe1fcc5f3aa1dccaa0b9a8279aa634 (diff)
parent681203f951d13e9e8eaf772435cac28c6d74cd42 (diff)
downloadlibquotient-72d5660efd0755bb53a8699cd39865155400d288.tar.gz
libquotient-72d5660efd0755bb53a8699cd39865155400d288.zip
Merge branch 'upstream' (v0.5.2)
Diffstat (limited to 'lib/events/eventcontent.h')
-rw-r--r--lib/events/eventcontent.h28
1 files changed, 16 insertions, 12 deletions
diff --git a/lib/events/eventcontent.h b/lib/events/eventcontent.h
index 91d7a8c8..ab31a75d 100644
--- a/lib/events/eventcontent.h
+++ b/lib/events/eventcontent.h
@@ -43,9 +43,10 @@ namespace QMatrixClient
class Base
{
public:
- explicit Base (const QJsonObject& o = {}) : originalJson(o) { }
+ explicit Base (QJsonObject o = {}) : originalJson(std::move(o)) { }
virtual ~Base() = default;
+ // FIXME: make toJson() from converters.* work on base classes
QJsonObject toJson() const;
public:
@@ -87,12 +88,14 @@ namespace QMatrixClient
class FileInfo
{
public:
- explicit FileInfo(const QUrl& u, int payloadSize = -1,
+ explicit FileInfo(const QUrl& u, qint64 payloadSize = -1,
const QMimeType& mimeType = {},
const QString& originalFilename = {});
FileInfo(const QUrl& u, const QJsonObject& infoJson,
const QString& originalFilename = {});
+ bool isValid() const;
+
void fillInfoJson(QJsonObject* infoJson) const;
/**
@@ -108,7 +111,7 @@ namespace QMatrixClient
QJsonObject originalInfoJson;
QMimeType mimeType;
QUrl url;
- int payloadSize;
+ qint64 payloadSize;
QString originalName;
};
@@ -126,9 +129,10 @@ namespace QMatrixClient
class ImageInfo : public FileInfo
{
public:
- explicit ImageInfo(const QUrl& u, int fileSize = -1,
+ explicit ImageInfo(const QUrl& u, qint64 fileSize = -1,
QMimeType mimeType = {},
- const QSize& imageSize = {});
+ const QSize& imageSize = {},
+ const QString& originalFilename = {});
ImageInfo(const QUrl& u, const QJsonObject& infoJson,
const QString& originalFilename = {});
@@ -148,10 +152,10 @@ namespace QMatrixClient
class Thumbnail : public ImageInfo
{
public:
+ Thumbnail() : ImageInfo(QUrl()) { } // To allow empty thumbnails
Thumbnail(const QJsonObject& infoJson);
- Thumbnail(const ImageInfo& info)
- : ImageInfo(info)
- { }
+ Thumbnail(const ImageInfo& info) : ImageInfo(info) { }
+ using ImageInfo::ImageInfo;
/**
* Writes thumbnail information to "thumbnail_info" subobject
@@ -166,6 +170,7 @@ namespace QMatrixClient
explicit TypedBase(const QJsonObject& o = {}) : Base(o) { }
virtual QMimeType type() const = 0;
virtual const FileInfo* fileInfo() const { return nullptr; }
+ virtual FileInfo* fileInfo() { return nullptr; }
virtual const Thumbnail* thumbnailInfo() const { return nullptr; }
};
@@ -183,9 +188,7 @@ namespace QMatrixClient
class UrlBasedContent : public TypedBase, public InfoT
{
public:
- UrlBasedContent(QUrl url, InfoT&& info, QString filename = {})
- : InfoT(url, std::forward<InfoT>(info), filename)
- { }
+ using InfoT::InfoT;
explicit UrlBasedContent(const QJsonObject& json)
: TypedBase(json)
, InfoT(json["url"].toString(), json["info"].toObject(),
@@ -197,6 +200,7 @@ namespace QMatrixClient
QMimeType type() const override { return InfoT::mimeType; }
const FileInfo* fileInfo() const override { return this; }
+ FileInfo* fileInfo() override { return this; }
protected:
void fillJson(QJsonObject* json) const override
@@ -213,7 +217,7 @@ namespace QMatrixClient
class UrlWithThumbnailContent : public UrlBasedContent<InfoT>
{
public:
- // TODO: POD constructor
+ using UrlBasedContent<InfoT>::UrlBasedContent;
explicit UrlWithThumbnailContent(const QJsonObject& json)
: UrlBasedContent<InfoT>(json)
, thumbnail(InfoT::originalInfoJson)