aboutsummaryrefslogtreecommitdiff
path: root/lib/events/roommemberevent.h
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-04 21:34:00 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-04 21:34:00 +0900
commit6a9de91752dfe75e185bf90ab856367b2c804582 (patch)
tree2a12ecc84bf0055e317ef2e4aeec3439d92b2035 /lib/events/roommemberevent.h
parentd5397fe5ae2ca34d5cfb11394dac17728a2b50ce (diff)
parent5d1dd53890611376873f6f959e206d5a56cfff70 (diff)
downloadlibquotient-6a9de91752dfe75e185bf90ab856367b2c804582.tar.gz
libquotient-6a9de91752dfe75e185bf90ab856367b2c804582.zip
Merge branch 'kitsune-events-rewritten'
Diffstat (limited to 'lib/events/roommemberevent.h')
-rw-r--r--lib/events/roommemberevent.h27
1 files changed, 16 insertions, 11 deletions
diff --git a/lib/events/roommemberevent.h b/lib/events/roommemberevent.h
index 8e0cc0a4..f3e4f53a 100644
--- a/lib/events/roommemberevent.h
+++ b/lib/events/roommemberevent.h
@@ -18,12 +18,9 @@
#pragma once
-#include "event.h"
-
+#include "stateevent.h"
#include "eventcontent.h"
-#include <QtCore/QUrl>
-
namespace QMatrixClient
{
class MemberEventContent: public EventContent::Base
@@ -36,6 +33,9 @@ namespace QMatrixClient
: membership(mt)
{ }
explicit MemberEventContent(const QJsonObject& json);
+ explicit MemberEventContent(const QJsonValue& jv)
+ : MemberEventContent(jv.toObject())
+ { }
MembershipType membership;
bool isDirect = false;
@@ -52,23 +52,26 @@ namespace QMatrixClient
{
Q_GADGET
public:
- static constexpr const char* typeId() { return "m.room.member"; }
+ DEFINE_EVENT_TYPEID("m.room.member", RoomMemberEvent)
using MembershipType = MemberEventContent::MembershipType;
- explicit RoomMemberEvent(Type type, const QJsonObject& obj)
- : StateEvent(type, obj)
+ explicit RoomMemberEvent(const QJsonObject& obj)
+ : StateEvent(typeId(), obj)
{ }
RoomMemberEvent(MemberEventContent&& c)
- : StateEvent(Type::RoomMember, c)
+ : StateEvent(typeId(), matrixTypeId(), c.toJson())
{ }
- explicit RoomMemberEvent(const QJsonObject& obj)
- : RoomMemberEvent(Type::RoomMember, obj)
+
+ // This is a special constructor enabling RoomMemberEvent to be
+ // a base class for more specific member events.
+ RoomMemberEvent(Type type, const QJsonObject& fullJson)
+ : StateEvent(type, fullJson)
{ }
MembershipType membership() const { return content().membership; }
QString userId() const
- { return originalJsonObject().value("state_key").toString(); }
+ { return fullJson()["state_key"_ls].toString(); }
bool isDirect() const { return content().isDirect; }
QString displayName() const { return content().displayName; }
QUrl avatarUrl() const { return content().avatarUrl; }
@@ -76,4 +79,6 @@ namespace QMatrixClient
private:
REGISTER_ENUM(MembershipType)
};
+ REGISTER_EVENT_TYPE(RoomMemberEvent)
+ DEFINE_EVENTTYPE_ALIAS(RoomMember, RoomMemberEvent)
} // namespace QMatrixClient