diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-01-06 00:12:05 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-06 00:12:05 +0900 |
commit | 9c08bbce341081a8ccbe0fccf48658b3e75e02cf (patch) | |
tree | 171ff3fcf35acb2c4a707488e6f43a2e35fff56f /lib/events/roommessageevent.h | |
parent | f545d181ade8736dfda93e8abb34ab93ac34e931 (diff) | |
parent | 27555e44dfbaae26a0e030cb3c22eb00ba8371f0 (diff) | |
download | libquotient-9c08bbce341081a8ccbe0fccf48658b3e75e02cf.tar.gz libquotient-9c08bbce341081a8ccbe0fccf48658b3e75e02cf.zip |
Merge pull request #272 from QMatrixClient/kitsune-upload-attachments
Support of attachments uploading
Diffstat (limited to 'lib/events/roommessageevent.h')
-rw-r--r-- | lib/events/roommessageevent.h | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/events/roommessageevent.h b/lib/events/roommessageevent.h index 4c29a93e..d5b570f5 100644 --- a/lib/events/roommessageevent.h +++ b/lib/events/roommessageevent.h @@ -21,6 +21,8 @@ #include "roomevent.h" #include "eventcontent.h" +class QFileInfo; + namespace QMatrixClient { namespace MessageEventContent = EventContent; // Back-compatibility @@ -49,6 +51,9 @@ namespace QMatrixClient explicit RoomMessageEvent(const QString& plainBody, MsgType msgType = MsgType::Text, EventContent::TypedBase* content = nullptr); + explicit RoomMessageEvent(const QString& plainBody, + const QFileInfo& file, + bool asGenericFile = false); explicit RoomMessageEvent(const QJsonObject& obj); MsgType msgtype() const; @@ -56,14 +61,27 @@ namespace QMatrixClient QString plainBody() const; EventContent::TypedBase* content() const { return _content.data(); } + template <typename VisitorT> + void editContent(VisitorT visitor) + { + visitor(*_content); + editJson()[ContentKeyL] = + assembleContentJson(plainBody(), rawMsgtype(), content()); + } QMimeType mimeType() const; bool hasTextContent() const; bool hasFileContent() const; bool hasThumbnail() const; + static QString rawMsgTypeForUrl(const QUrl& url); + static QString rawMsgTypeForFile(const QFileInfo& fi); + private: QScopedPointer<EventContent::TypedBase> _content; + static QJsonObject assembleContentJson(const QString& plainBody, + const QString& jsonMsgType, EventContent::TypedBase* content); + REGISTER_ENUM(MsgType) }; REGISTER_EVENT_TYPE(RoomMessageEvent) @@ -112,7 +130,7 @@ namespace QMatrixClient { public: LocationContent(const QString& geoUri, - const ImageInfo& thumbnail); + const Thumbnail& thumbnail = {}); explicit LocationContent(const QJsonObject& json); QMimeType type() const override; @@ -132,6 +150,7 @@ namespace QMatrixClient class PlayableContent : public ContentT { public: + using ContentT::ContentT; PlayableContent(const QJsonObject& json) : ContentT(json) , duration(ContentT::originalInfoJson["duration"_ls].toInt()) |