From 9628594881346c8e06594e65d3befafc310e12d5 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 8 Dec 2018 15:36:28 +0900 Subject: EventContent: minor cleanup --- lib/events/eventcontent.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/events/eventcontent.h') diff --git a/lib/events/eventcontent.h b/lib/events/eventcontent.h index 91d7a8c8..bedf0078 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: -- cgit v1.2.3 From 241f7165816624da45fca58578885b17589ec1f7 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Wed, 26 Dec 2018 10:57:50 +0900 Subject: EventContent: allow empty (default-constructed) thumbnails --- lib/events/eventcontent.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'lib/events/eventcontent.h') diff --git a/lib/events/eventcontent.h b/lib/events/eventcontent.h index bedf0078..ea321fb6 100644 --- a/lib/events/eventcontent.h +++ b/lib/events/eventcontent.h @@ -149,10 +149,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 @@ -184,9 +184,7 @@ namespace QMatrixClient class UrlBasedContent : public TypedBase, public InfoT { public: - UrlBasedContent(QUrl url, InfoT&& info, QString filename = {}) - : InfoT(url, std::forward(info), filename) - { } + using InfoT::InfoT; explicit UrlBasedContent(const QJsonObject& json) : TypedBase(json) , InfoT(json["url"].toString(), json["info"].toObject(), @@ -214,7 +212,7 @@ namespace QMatrixClient class UrlWithThumbnailContent : public UrlBasedContent { public: - // TODO: POD constructor + using UrlBasedContent::UrlBasedContent; explicit UrlWithThumbnailContent(const QJsonObject& json) : UrlBasedContent(json) , thumbnail(InfoT::originalInfoJson) -- cgit v1.2.3 From 3ecf762f497a4d4b6ea7583689c0b9b284300201 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 28 Dec 2018 12:47:02 +0900 Subject: EventContent: use qint64 for the payload size --- lib/events/eventcontent.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/events/eventcontent.h') diff --git a/lib/events/eventcontent.h b/lib/events/eventcontent.h index ea321fb6..2a48e910 100644 --- a/lib/events/eventcontent.h +++ b/lib/events/eventcontent.h @@ -88,7 +88,7 @@ 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, @@ -109,7 +109,7 @@ namespace QMatrixClient QJsonObject originalInfoJson; QMimeType mimeType; QUrl url; - int payloadSize; + qint64 payloadSize; QString originalName; }; @@ -127,7 +127,7 @@ 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 = {}); ImageInfo(const QUrl& u, const QJsonObject& infoJson, -- cgit v1.2.3 From 4ec3dd92d2cb5af4cf4893770e29db51d23e0e67 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Wed, 26 Dec 2018 19:31:11 +0900 Subject: Make content in events editable --- lib/events/eventcontent.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/events/eventcontent.h') diff --git a/lib/events/eventcontent.h b/lib/events/eventcontent.h index 2a48e910..2e61276b 100644 --- a/lib/events/eventcontent.h +++ b/lib/events/eventcontent.h @@ -167,6 +167,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; } }; @@ -196,6 +197,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 -- cgit v1.2.3 From e3578b3cc6b978db1c04a1f684e1a03676c33f3b Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 5 Jan 2019 19:59:48 +0900 Subject: EventContent::ImageInfo: support originalFilename in POD constructor It's not mandated by the spec for anything except m.file but hey it's convenient. --- lib/events/eventcontent.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/events/eventcontent.h') diff --git a/lib/events/eventcontent.h b/lib/events/eventcontent.h index 2e61276b..0588c0e2 100644 --- a/lib/events/eventcontent.h +++ b/lib/events/eventcontent.h @@ -129,7 +129,8 @@ namespace QMatrixClient public: 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 = {}); -- cgit v1.2.3 From 23352250c9b9f9fa7d1d46294f8c1a7de1e19f61 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 23 Mar 2019 20:43:02 +0900 Subject: Room::downloadFile(): Tighten URL validations Check the URL before passing over to Connection::downloadFile(), not only the file name. --- lib/events/eventcontent.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/events/eventcontent.h') diff --git a/lib/events/eventcontent.h b/lib/events/eventcontent.h index 0588c0e2..ab31a75d 100644 --- a/lib/events/eventcontent.h +++ b/lib/events/eventcontent.h @@ -94,6 +94,8 @@ namespace QMatrixClient FileInfo(const QUrl& u, const QJsonObject& infoJson, const QString& originalFilename = {}); + bool isValid() const; + void fillInfoJson(QJsonObject* infoJson) const; /** -- cgit v1.2.3