aboutsummaryrefslogtreecommitdiff
path: root/events/roommessageevent.h
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-01-26 09:00:33 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-01-26 09:00:33 +0900
commit76bff84a2aa63db677044cc529b910768fa018fa (patch)
treeefeb34e37b436267313169a1790e45a07e8f7fcb /events/roommessageevent.h
parent7d506f7bebbcc3b5f8a37589f8fda6fa1e7e1efd (diff)
parent2f83e4be20a15013181c1ba6944e21f051ccac9d (diff)
downloadlibquotient-76bff84a2aa63db677044cc529b910768fa018fa.tar.gz
libquotient-76bff84a2aa63db677044cc529b910768fa018fa.zip
Merge branch 'master' into kitsune-gtad
Diffstat (limited to 'events/roommessageevent.h')
-rw-r--r--events/roommessageevent.h29
1 files changed, 20 insertions, 9 deletions
diff --git a/events/roommessageevent.h b/events/roommessageevent.h
index 6b551b76..2a5eeb7e 100644
--- a/events/roommessageevent.h
+++ b/events/roommessageevent.h
@@ -59,6 +59,7 @@ namespace QMatrixClient
EventContent::TypedBase* content() const
{ return _content.data(); }
QMimeType mimeType() const;
+ bool hasTextContent() const;
bool hasFileContent() const;
QJsonObject toJson() const;
@@ -112,7 +113,7 @@ namespace QMatrixClient
* - thumbnail.mimeType
* - thumbnail.imageSize
*/
- class LocationContent: public TypedBase, public WithThumbnail
+ class LocationContent: public TypedBase
{
public:
LocationContent(const QString& geoUri,
@@ -123,21 +124,32 @@ namespace QMatrixClient
public:
QString geoUri;
+ Thumbnail thumbnail;
protected:
void fillJson(QJsonObject* o) const override;
};
/**
- * A mixin class for info types that include duration: audio and video
+ * A base class for info types that include duration: audio and video
*/
- class WithDuration
+ template <typename ContentT>
+ class PlayableContent : public ContentT
{
public:
- explicit WithDuration(int duration) : duration(duration) { }
- WithDuration(const QJsonObject& infoJson);
+ PlayableContent(const QJsonObject& json)
+ : ContentT(json)
+ , duration(ContentT::originalInfoJson["duration"].toInt())
+ { }
- void fillInfoJson(QJsonObject* infoJson) const;
+ protected:
+ void fillJson(QJsonObject* json) const override
+ {
+ ContentT::fillJson(json);
+ auto infoJson = json->take("info").toObject();
+ infoJson.insert("duration", duration);
+ json->insert("info", infoJson);
+ }
public:
int duration;
@@ -162,8 +174,7 @@ namespace QMatrixClient
* - mimeType
* - imageSize
*/
- using VideoContent =
- UrlBasedContent<ImageInfo, WithThumbnail, WithDuration>;
+ using VideoContent = PlayableContent<UrlWithThumbnailContent<ImageInfo>>;
/**
* Content class for m.audio
@@ -177,6 +188,6 @@ namespace QMatrixClient
* - mimeType ("mimetype" in JSON)
* - duration
*/
- using AudioContent = UrlBasedContent<FileInfo, WithDuration>;
+ using AudioContent = PlayableContent<UrlBasedContent<FileInfo>>;
} // namespace EventContent
} // namespace QMatrixClient