aboutsummaryrefslogtreecommitdiff
path: root/events/roommemberevent.h
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2017-11-28 12:42:03 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2017-11-28 12:42:03 +0900
commit357625eb55e2f4569bb487ffe14a9236188e25f3 (patch)
treed39340ab74f25a23a5855f679973628f7457fd87 /events/roommemberevent.h
parent94e6636d8225a0561ed7df3fa8081c5b0183610c (diff)
parent8f762a2458db773f6db24b568b2e944427297c2b (diff)
downloadlibquotient-357625eb55e2f4569bb487ffe14a9236188e25f3.tar.gz
libquotient-357625eb55e2f4569bb487ffe14a9236188e25f3.zip
Merge branch 'master' into kitsune-gtad
Diffstat (limited to 'events/roommemberevent.h')
-rw-r--r--events/roommemberevent.h43
1 files changed, 31 insertions, 12 deletions
diff --git a/events/roommemberevent.h b/events/roommemberevent.h
index 9ebb75ee..d0c63f15 100644
--- a/events/roommemberevent.h
+++ b/events/roommemberevent.h
@@ -20,30 +20,49 @@
#include "event.h"
+#include "eventcontent.h"
+
#include <QtCore/QUrl>
namespace QMatrixClient
{
- class RoomMemberEvent: public RoomEvent
+ class MemberEventContent: public EventContent::Base
+ {
+ public:
+ enum MembershipType : size_t {Invite = 0, Join, Knock, Leave, Ban};
+
+ MemberEventContent(const QJsonObject& json);
+
+ MembershipType membership;
+ QString displayName;
+ QUrl avatarUrl;
+
+ protected:
+ void fillJson(QJsonObject* o) const override;
+ };
+
+ using MembershipType = MemberEventContent::MembershipType;
+
+ class RoomMemberEvent: public StateEvent<MemberEventContent>
{
Q_GADGET
public:
- enum MembershipType : int {Invite = 0, Join, Knock, Leave, Ban};
+ static constexpr const char* TypeId = "m.room.member";
- explicit RoomMemberEvent(const QJsonObject& obj);
+ using MembershipType = MemberEventContent::MembershipType;
- MembershipType membership() const { return _membership; }
- const QString& userId() const { return _userId; }
- const QString& displayName() const { return _displayName; }
- const QUrl& avatarUrl() const { return _avatarUrl; }
+ explicit RoomMemberEvent(const QJsonObject& obj)
+ : StateEvent(Type::RoomMember, obj)
+ , _userId(obj["state_key"].toString())
+ { }
+
+ MembershipType membership() const { return content().membership; }
+ QString userId() const { return _userId; }
+ QString displayName() const { return content().displayName; }
+ QUrl avatarUrl() const { return content().avatarUrl; }
private:
- MembershipType _membership;
QString _userId;
- QString _displayName;
- QUrl _avatarUrl;
-
REGISTER_ENUM(MembershipType)
};
- using MembershipType = RoomMemberEvent::MembershipType;
} // namespace QMatrixClient