aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2016-08-24 14:29:54 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2016-08-24 14:29:54 +0900
commit581a6976eeb7c35930cb19e89eae0fd3bf11a785 (patch)
tree08fedb70dfab49a24bb6855f3c5b52f3b3acc6d2
parent958675dccc0a308c02d490d0b246eade0123ce79 (diff)
downloadlibquotient-581a6976eeb7c35930cb19e89eae0fd3bf11a785.tar.gz
libquotient-581a6976eeb7c35930cb19e89eae0fd3bf11a785.zip
Move plain body from Base (former MessageEventContent) inside RoomMessageEvent
According to the spec, this key has the same status as msgtype: both should exist in any message. Besides, it's always supposed to be a plain text so there's no polymorphism allowed here.
-rw-r--r--events/roommessageevent.cpp10
-rw-r--r--events/roommessageevent.h16
2 files changed, 19 insertions, 7 deletions
diff --git a/events/roommessageevent.cpp b/events/roommessageevent.cpp
index 03e84444..a111ef12 100644
--- a/events/roommessageevent.cpp
+++ b/events/roommessageevent.cpp
@@ -31,6 +31,7 @@ class RoomMessageEvent::Private
QString userId;
MessageEventType msgtype;
+ QString plainBody;
QDateTime hsob_ts;
MessageEventContent::Base* content;
};
@@ -57,9 +58,14 @@ MessageEventType RoomMessageEvent::msgtype() const
return d->msgtype;
}
+QString RoomMessageEvent::plainBody() const
+{
+ return d->plainBody;
+}
+
QString RoomMessageEvent::body() const
{
- return d->content->body;
+ return plainBody();
}
QDateTime RoomMessageEvent::hsob_ts() const
@@ -179,7 +185,7 @@ RoomMessageEvent* RoomMessageEvent::fromJson(const QJsonObject& obj)
if( content.contains("body") )
{
- e->d->content->body = content.value("body").toString();
+ e->d->plainBody = content.value("body").toString();
} else {
qDebug() << "RoomMessageEvent: body not found";
}
diff --git a/events/roommessageevent.h b/events/roommessageevent.h
index 219f74f0..27cf5fd8 100644
--- a/events/roommessageevent.h
+++ b/events/roommessageevent.h
@@ -32,11 +32,7 @@ namespace QMatrixClient
namespace MessageEventContent
{
- class Base
- {
- public:
- QString body;
- };
+ class Base { };
}
class RoomMessageEvent: public Event
@@ -47,7 +43,17 @@ namespace QMatrixClient
QString userId() const;
MessageEventType msgtype() const;
+
+ QString plainBody() const;
+
+ /**
+ * Same as plainBody() for now; might change for "best-looking body"
+ * in the future. For richer contents, use content-specific data.
+ *
+ * @deprecated
+ */
QString body() const;
+
QDateTime hsob_ts() const;
MessageEventContent::Base* content() const;