mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Add matrix::events namespace
This commit is contained in:
parent
02ef7411e6
commit
8825e072f2
25 changed files with 101 additions and 1 deletions
|
@ -23,6 +23,10 @@
|
||||||
|
|
||||||
#include "Deserializable.h"
|
#include "Deserializable.h"
|
||||||
|
|
||||||
|
namespace matrix
|
||||||
|
{
|
||||||
|
namespace events
|
||||||
|
{
|
||||||
class AliasesEventContent : public Deserializable
|
class AliasesEventContent : public Deserializable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -38,5 +42,7 @@ inline QList<QString> AliasesEventContent::aliases() const
|
||||||
{
|
{
|
||||||
return aliases_;
|
return aliases_;
|
||||||
}
|
}
|
||||||
|
} // namespace events
|
||||||
|
} // namespace matrix
|
||||||
|
|
||||||
#endif // ALIASES_EVENT_CONTENT_H
|
#endif // ALIASES_EVENT_CONTENT_H
|
||||||
|
|
|
@ -23,6 +23,10 @@
|
||||||
|
|
||||||
#include "Deserializable.h"
|
#include "Deserializable.h"
|
||||||
|
|
||||||
|
namespace matrix
|
||||||
|
{
|
||||||
|
namespace events
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* A picture that is associated with the room.
|
* A picture that is associated with the room.
|
||||||
*/
|
*/
|
||||||
|
@ -42,5 +46,7 @@ inline QUrl AvatarEventContent::url() const
|
||||||
{
|
{
|
||||||
return url_;
|
return url_;
|
||||||
}
|
}
|
||||||
|
} // namespace events
|
||||||
|
} // namespace matrix
|
||||||
|
|
||||||
#endif // AVATAR_EVENT_CONTENT_H
|
#endif // AVATAR_EVENT_CONTENT_H
|
||||||
|
|
|
@ -24,6 +24,10 @@
|
||||||
#include "CanonicalAliasEventContent.h"
|
#include "CanonicalAliasEventContent.h"
|
||||||
#include "Deserializable.h"
|
#include "Deserializable.h"
|
||||||
|
|
||||||
|
namespace matrix
|
||||||
|
{
|
||||||
|
namespace events
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* This event is used to inform the room about which alias should be considered
|
* This event is used to inform the room about which alias should be considered
|
||||||
* the canonical one. This could be for display purposes or as suggestion to
|
* the canonical one. This could be for display purposes or as suggestion to
|
||||||
|
@ -45,5 +49,7 @@ inline QString CanonicalAliasEventContent::alias() const
|
||||||
{
|
{
|
||||||
return alias_;
|
return alias_;
|
||||||
}
|
}
|
||||||
|
} // namespace events
|
||||||
|
} // namespace matrix
|
||||||
|
|
||||||
#endif // CANONICAL_ALIAS_EVENT_CONTENT_H
|
#endif // CANONICAL_ALIAS_EVENT_CONTENT_H
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
|
|
||||||
#include "Deserializable.h"
|
#include "Deserializable.h"
|
||||||
|
|
||||||
|
namespace matrix
|
||||||
|
{
|
||||||
|
namespace events
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* This is the first event in a room and cannot be changed. It acts as the root of all other events.
|
* This is the first event in a room and cannot be changed. It acts as the root of all other events.
|
||||||
*/
|
*/
|
||||||
|
@ -42,5 +46,7 @@ inline QString CreateEventContent::creator() const
|
||||||
{
|
{
|
||||||
return creator_;
|
return creator_;
|
||||||
}
|
}
|
||||||
|
} // namespace events
|
||||||
|
} // namespace matrix
|
||||||
|
|
||||||
#endif // CREATE_EVENT_CONTENT_H
|
#endif // CREATE_EVENT_CONTENT_H
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
|
|
||||||
#include "Deserializable.h"
|
#include "Deserializable.h"
|
||||||
|
|
||||||
|
namespace matrix
|
||||||
|
{
|
||||||
|
namespace events
|
||||||
|
{
|
||||||
enum EventType {
|
enum EventType {
|
||||||
/// m.room.aliases
|
/// m.room.aliases
|
||||||
RoomAliases,
|
RoomAliases,
|
||||||
|
@ -85,5 +89,7 @@ void Event<Content>::deserialize(const QJsonValue &data)
|
||||||
|
|
||||||
content_.deserialize(object.value("content"));
|
content_.deserialize(object.value("content"));
|
||||||
}
|
}
|
||||||
|
} // namespace events
|
||||||
|
} // namespace matrix
|
||||||
|
|
||||||
#endif // MATRIX_EVENT_H
|
#endif // MATRIX_EVENT_H
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
|
|
||||||
#include "Deserializable.h"
|
#include "Deserializable.h"
|
||||||
|
|
||||||
|
namespace matrix
|
||||||
|
{
|
||||||
|
namespace events
|
||||||
|
{
|
||||||
enum HistoryVisibility {
|
enum HistoryVisibility {
|
||||||
Invited,
|
Invited,
|
||||||
Joined,
|
Joined,
|
||||||
|
@ -44,5 +48,7 @@ inline HistoryVisibility HistoryVisibilityEventContent::historyVisibility() cons
|
||||||
{
|
{
|
||||||
return history_visibility_;
|
return history_visibility_;
|
||||||
}
|
}
|
||||||
|
} // namespace events
|
||||||
|
} // namespace matrix
|
||||||
|
|
||||||
#endif // HISTORY_VISIBILITY_EVENT_CONTENT_H
|
#endif // HISTORY_VISIBILITY_EVENT_CONTENT_H
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
|
|
||||||
#include "Deserializable.h"
|
#include "Deserializable.h"
|
||||||
|
|
||||||
|
namespace matrix
|
||||||
|
{
|
||||||
|
namespace events
|
||||||
|
{
|
||||||
enum JoinRule {
|
enum JoinRule {
|
||||||
// A user who wishes to join the room must first receive
|
// A user who wishes to join the room must first receive
|
||||||
// an invite to the room from someone already inside of the room.
|
// an invite to the room from someone already inside of the room.
|
||||||
|
@ -56,5 +60,7 @@ inline JoinRule JoinRulesEventContent::joinRule() const
|
||||||
{
|
{
|
||||||
return join_rule_;
|
return join_rule_;
|
||||||
}
|
}
|
||||||
|
} // namespace events
|
||||||
|
} // namespace matrix
|
||||||
|
|
||||||
#endif // JOIN_RULES_EVENT_CONTENT_H
|
#endif // JOIN_RULES_EVENT_CONTENT_H
|
||||||
|
|
|
@ -23,6 +23,10 @@
|
||||||
|
|
||||||
#include "Deserializable.h"
|
#include "Deserializable.h"
|
||||||
|
|
||||||
|
namespace matrix
|
||||||
|
{
|
||||||
|
namespace events
|
||||||
|
{
|
||||||
enum Membership {
|
enum Membership {
|
||||||
// The user is banned.
|
// The user is banned.
|
||||||
BanState,
|
BanState,
|
||||||
|
@ -73,5 +77,7 @@ inline Membership MemberEventContent::membershipState() const
|
||||||
{
|
{
|
||||||
return membership_state_;
|
return membership_state_;
|
||||||
}
|
}
|
||||||
|
} // namespace events
|
||||||
|
} // namespace matrix
|
||||||
|
|
||||||
#endif // MEMBER_EVENT_CONTENT_H
|
#endif // MEMBER_EVENT_CONTENT_H
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
|
|
||||||
#include "Deserializable.h"
|
#include "Deserializable.h"
|
||||||
|
|
||||||
|
namespace matrix
|
||||||
|
{
|
||||||
|
namespace events
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* A human-friendly room name designed to be displayed to the end-user.
|
* A human-friendly room name designed to be displayed to the end-user.
|
||||||
*/
|
*/
|
||||||
|
@ -41,5 +45,7 @@ inline QString NameEventContent::name() const
|
||||||
{
|
{
|
||||||
return name_;
|
return name_;
|
||||||
}
|
}
|
||||||
|
} // namespace events
|
||||||
|
} // namespace matrix
|
||||||
|
|
||||||
#endif // NAME_EVENT_CONTENT_H
|
#endif // NAME_EVENT_CONTENT_H
|
||||||
|
|
|
@ -23,6 +23,10 @@
|
||||||
|
|
||||||
#include "Deserializable.h"
|
#include "Deserializable.h"
|
||||||
|
|
||||||
|
namespace matrix
|
||||||
|
{
|
||||||
|
namespace events
|
||||||
|
{
|
||||||
enum PowerLevels {
|
enum PowerLevels {
|
||||||
User = 0,
|
User = 0,
|
||||||
Moderator = 50,
|
Moderator = 50,
|
||||||
|
@ -98,5 +102,7 @@ inline int PowerLevelsEventContent::usersDefaultLevel() const
|
||||||
{
|
{
|
||||||
return users_default_;
|
return users_default_;
|
||||||
}
|
}
|
||||||
|
} // namespace events
|
||||||
|
} // namespace matrix
|
||||||
|
|
||||||
#endif // POWER_LEVELS_EVENT_CONTENT_H
|
#endif // POWER_LEVELS_EVENT_CONTENT_H
|
||||||
|
|
|
@ -23,6 +23,10 @@
|
||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
|
||||||
|
namespace matrix
|
||||||
|
{
|
||||||
|
namespace events
|
||||||
|
{
|
||||||
template <class Content>
|
template <class Content>
|
||||||
class RoomEvent : public Event<Content>
|
class RoomEvent : public Event<Content>
|
||||||
{
|
{
|
||||||
|
@ -90,5 +94,7 @@ void RoomEvent<Content>::deserialize(const QJsonValue &data)
|
||||||
sender_ = object.value("sender").toString();
|
sender_ = object.value("sender").toString();
|
||||||
origin_server_ts_ = object.value("origin_server_ts").toDouble();
|
origin_server_ts_ = object.value("origin_server_ts").toDouble();
|
||||||
}
|
}
|
||||||
|
} // namespace events
|
||||||
|
} // namespace matrix
|
||||||
|
|
||||||
#endif // MATRIX_ROOM_EVENT_H
|
#endif // MATRIX_ROOM_EVENT_H
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
|
|
||||||
#include "RoomEvent.h"
|
#include "RoomEvent.h"
|
||||||
|
|
||||||
|
namespace matrix
|
||||||
|
{
|
||||||
|
namespace events
|
||||||
|
{
|
||||||
template <class Content>
|
template <class Content>
|
||||||
class StateEvent : public RoomEvent<Content>
|
class StateEvent : public RoomEvent<Content>
|
||||||
{
|
{
|
||||||
|
@ -63,5 +67,7 @@ void StateEvent<Content>::deserialize(const QJsonValue &data)
|
||||||
if (object.contains("prev_content"))
|
if (object.contains("prev_content"))
|
||||||
prev_content_.deserialize(object.value("prev_content"));
|
prev_content_.deserialize(object.value("prev_content"));
|
||||||
}
|
}
|
||||||
|
} // namespace events
|
||||||
|
} // namespace matrix
|
||||||
|
|
||||||
#endif // MATRIX_STATE_EVENT_H
|
#endif // MATRIX_STATE_EVENT_H
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
|
|
||||||
#include "Deserializable.h"
|
#include "Deserializable.h"
|
||||||
|
|
||||||
|
namespace matrix
|
||||||
|
{
|
||||||
|
namespace events
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* A topic is a short message detailing what is currently being discussed in the room.
|
* A topic is a short message detailing what is currently being discussed in the room.
|
||||||
*/
|
*/
|
||||||
|
@ -41,5 +45,7 @@ inline QString TopicEventContent::topic() const
|
||||||
{
|
{
|
||||||
return topic_;
|
return topic_;
|
||||||
}
|
}
|
||||||
|
} // namespace events
|
||||||
|
} // namespace matrix
|
||||||
|
|
||||||
#endif // TOPIC_EVENT_CONTENT_H
|
#endif // TOPIC_EVENT_CONTENT_H
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
#include "AliasesEventContent.h"
|
#include "AliasesEventContent.h"
|
||||||
|
|
||||||
|
using namespace matrix::events;
|
||||||
|
|
||||||
void AliasesEventContent::deserialize(const QJsonValue &data)
|
void AliasesEventContent::deserialize(const QJsonValue &data)
|
||||||
{
|
{
|
||||||
if (!data.isObject())
|
if (!data.isObject())
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
#include "AvatarEventContent.h"
|
#include "AvatarEventContent.h"
|
||||||
|
|
||||||
|
using namespace matrix::events;
|
||||||
|
|
||||||
void AvatarEventContent::deserialize(const QJsonValue &data)
|
void AvatarEventContent::deserialize(const QJsonValue &data)
|
||||||
{
|
{
|
||||||
if (!data.isObject())
|
if (!data.isObject())
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
#include "CanonicalAliasEventContent.h"
|
#include "CanonicalAliasEventContent.h"
|
||||||
|
|
||||||
|
using namespace matrix::events;
|
||||||
|
|
||||||
void CanonicalAliasEventContent::deserialize(const QJsonValue &data)
|
void CanonicalAliasEventContent::deserialize(const QJsonValue &data)
|
||||||
{
|
{
|
||||||
if (!data.isObject())
|
if (!data.isObject())
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
#include "CreateEventContent.h"
|
#include "CreateEventContent.h"
|
||||||
|
|
||||||
|
using namespace matrix::events;
|
||||||
|
|
||||||
void CreateEventContent::deserialize(const QJsonValue &data)
|
void CreateEventContent::deserialize(const QJsonValue &data)
|
||||||
{
|
{
|
||||||
if (!data.isObject())
|
if (!data.isObject())
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include "PowerLevelsEventContent.h"
|
#include "PowerLevelsEventContent.h"
|
||||||
#include "TopicEventContent.h"
|
#include "TopicEventContent.h"
|
||||||
|
|
||||||
EventType extractEventType(const QJsonObject &object)
|
matrix::events::EventType matrix::events::extractEventType(const QJsonObject &object)
|
||||||
{
|
{
|
||||||
if (!object.contains("type"))
|
if (!object.contains("type"))
|
||||||
throw DeserializationException("Missing event type");
|
throw DeserializationException("Missing event type");
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
#include "HistoryVisibilityEventContent.h"
|
#include "HistoryVisibilityEventContent.h"
|
||||||
|
|
||||||
|
using namespace matrix::events;
|
||||||
|
|
||||||
void HistoryVisibilityEventContent::deserialize(const QJsonValue &data)
|
void HistoryVisibilityEventContent::deserialize(const QJsonValue &data)
|
||||||
{
|
{
|
||||||
if (!data.isObject())
|
if (!data.isObject())
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
#include "JoinRulesEventContent.h"
|
#include "JoinRulesEventContent.h"
|
||||||
|
|
||||||
|
using namespace matrix::events;
|
||||||
|
|
||||||
void JoinRulesEventContent::deserialize(const QJsonValue &data)
|
void JoinRulesEventContent::deserialize(const QJsonValue &data)
|
||||||
{
|
{
|
||||||
if (!data.isObject())
|
if (!data.isObject())
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
#include "MemberEventContent.h"
|
#include "MemberEventContent.h"
|
||||||
|
|
||||||
|
using namespace matrix::events;
|
||||||
|
|
||||||
void MemberEventContent::deserialize(const QJsonValue &data)
|
void MemberEventContent::deserialize(const QJsonValue &data)
|
||||||
{
|
{
|
||||||
if (!data.isObject())
|
if (!data.isObject())
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
#include "NameEventContent.h"
|
#include "NameEventContent.h"
|
||||||
|
|
||||||
|
using namespace matrix::events;
|
||||||
|
|
||||||
void NameEventContent::deserialize(const QJsonValue &data)
|
void NameEventContent::deserialize(const QJsonValue &data)
|
||||||
{
|
{
|
||||||
if (!data.isObject())
|
if (!data.isObject())
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#include "Deserializable.h"
|
#include "Deserializable.h"
|
||||||
#include "PowerLevelsEventContent.h"
|
#include "PowerLevelsEventContent.h"
|
||||||
|
|
||||||
|
using namespace matrix::events;
|
||||||
|
|
||||||
void PowerLevelsEventContent::deserialize(const QJsonValue &data)
|
void PowerLevelsEventContent::deserialize(const QJsonValue &data)
|
||||||
{
|
{
|
||||||
if (!data.isObject())
|
if (!data.isObject())
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
#include "TopicEventContent.h"
|
#include "TopicEventContent.h"
|
||||||
|
|
||||||
|
using namespace matrix::events;
|
||||||
|
|
||||||
void TopicEventContent::deserialize(const QJsonValue &data)
|
void TopicEventContent::deserialize(const QJsonValue &data)
|
||||||
{
|
{
|
||||||
if (!data.isObject())
|
if (!data.isObject())
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
#include "PowerLevelsEventContent.h"
|
#include "PowerLevelsEventContent.h"
|
||||||
#include "TopicEventContent.h"
|
#include "TopicEventContent.h"
|
||||||
|
|
||||||
|
using namespace matrix::events;
|
||||||
|
|
||||||
TEST(BaseEvent, Deserialization)
|
TEST(BaseEvent, Deserialization)
|
||||||
{
|
{
|
||||||
// NameEventContent
|
// NameEventContent
|
||||||
|
|
Loading…
Reference in a new issue