Add matrix::events namespace

This commit is contained in:
Konstantinos Sideris 2017-05-03 15:23:06 +03:00
parent 02ef7411e6
commit 8825e072f2
25 changed files with 101 additions and 1 deletions

View file

@ -23,6 +23,10 @@
#include "Deserializable.h"
namespace matrix
{
namespace events
{
class AliasesEventContent : public Deserializable
{
public:
@ -38,5 +42,7 @@ inline QList<QString> AliasesEventContent::aliases() const
{
return aliases_;
}
} // namespace events
} // namespace matrix
#endif // ALIASES_EVENT_CONTENT_H

View file

@ -23,6 +23,10 @@
#include "Deserializable.h"
namespace matrix
{
namespace events
{
/*
* A picture that is associated with the room.
*/
@ -42,5 +46,7 @@ inline QUrl AvatarEventContent::url() const
{
return url_;
}
} // namespace events
} // namespace matrix
#endif // AVATAR_EVENT_CONTENT_H

View file

@ -24,6 +24,10 @@
#include "CanonicalAliasEventContent.h"
#include "Deserializable.h"
namespace matrix
{
namespace events
{
/*
* 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
@ -45,5 +49,7 @@ inline QString CanonicalAliasEventContent::alias() const
{
return alias_;
}
} // namespace events
} // namespace matrix
#endif // CANONICAL_ALIAS_EVENT_CONTENT_H

View file

@ -22,6 +22,10 @@
#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.
*/
@ -42,5 +46,7 @@ inline QString CreateEventContent::creator() const
{
return creator_;
}
} // namespace events
} // namespace matrix
#endif // CREATE_EVENT_CONTENT_H

View file

@ -22,6 +22,10 @@
#include "Deserializable.h"
namespace matrix
{
namespace events
{
enum EventType {
/// m.room.aliases
RoomAliases,
@ -85,5 +89,7 @@ void Event<Content>::deserialize(const QJsonValue &data)
content_.deserialize(object.value("content"));
}
} // namespace events
} // namespace matrix
#endif // MATRIX_EVENT_H

View file

@ -22,6 +22,10 @@
#include "Deserializable.h"
namespace matrix
{
namespace events
{
enum HistoryVisibility {
Invited,
Joined,
@ -44,5 +48,7 @@ inline HistoryVisibility HistoryVisibilityEventContent::historyVisibility() cons
{
return history_visibility_;
}
} // namespace events
} // namespace matrix
#endif // HISTORY_VISIBILITY_EVENT_CONTENT_H

View file

@ -22,6 +22,10 @@
#include "Deserializable.h"
namespace matrix
{
namespace events
{
enum JoinRule {
// A user who wishes to join the room must first receive
// an invite to the room from someone already inside of the room.
@ -56,5 +60,7 @@ inline JoinRule JoinRulesEventContent::joinRule() const
{
return join_rule_;
}
} // namespace events
} // namespace matrix
#endif // JOIN_RULES_EVENT_CONTENT_H

View file

@ -23,6 +23,10 @@
#include "Deserializable.h"
namespace matrix
{
namespace events
{
enum Membership {
// The user is banned.
BanState,
@ -73,5 +77,7 @@ inline Membership MemberEventContent::membershipState() const
{
return membership_state_;
}
} // namespace events
} // namespace matrix
#endif // MEMBER_EVENT_CONTENT_H

View file

@ -22,6 +22,10 @@
#include "Deserializable.h"
namespace matrix
{
namespace events
{
/*
* A human-friendly room name designed to be displayed to the end-user.
*/
@ -41,5 +45,7 @@ inline QString NameEventContent::name() const
{
return name_;
}
} // namespace events
} // namespace matrix
#endif // NAME_EVENT_CONTENT_H

View file

@ -23,6 +23,10 @@
#include "Deserializable.h"
namespace matrix
{
namespace events
{
enum PowerLevels {
User = 0,
Moderator = 50,
@ -98,5 +102,7 @@ inline int PowerLevelsEventContent::usersDefaultLevel() const
{
return users_default_;
}
} // namespace events
} // namespace matrix
#endif // POWER_LEVELS_EVENT_CONTENT_H

View file

@ -23,6 +23,10 @@
#include "Event.h"
namespace matrix
{
namespace events
{
template <class Content>
class RoomEvent : public Event<Content>
{
@ -90,5 +94,7 @@ void RoomEvent<Content>::deserialize(const QJsonValue &data)
sender_ = object.value("sender").toString();
origin_server_ts_ = object.value("origin_server_ts").toDouble();
}
} // namespace events
} // namespace matrix
#endif // MATRIX_ROOM_EVENT_H

View file

@ -22,6 +22,10 @@
#include "RoomEvent.h"
namespace matrix
{
namespace events
{
template <class Content>
class StateEvent : public RoomEvent<Content>
{
@ -63,5 +67,7 @@ void StateEvent<Content>::deserialize(const QJsonValue &data)
if (object.contains("prev_content"))
prev_content_.deserialize(object.value("prev_content"));
}
} // namespace events
} // namespace matrix
#endif // MATRIX_STATE_EVENT_H

View file

@ -22,6 +22,10 @@
#include "Deserializable.h"
namespace matrix
{
namespace events
{
/*
* 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_;
}
} // namespace events
} // namespace matrix
#endif // TOPIC_EVENT_CONTENT_H

View file

@ -19,6 +19,8 @@
#include "AliasesEventContent.h"
using namespace matrix::events;
void AliasesEventContent::deserialize(const QJsonValue &data)
{
if (!data.isObject())

View file

@ -19,6 +19,8 @@
#include "AvatarEventContent.h"
using namespace matrix::events;
void AvatarEventContent::deserialize(const QJsonValue &data)
{
if (!data.isObject())

View file

@ -17,6 +17,8 @@
#include "CanonicalAliasEventContent.h"
using namespace matrix::events;
void CanonicalAliasEventContent::deserialize(const QJsonValue &data)
{
if (!data.isObject())

View file

@ -17,6 +17,8 @@
#include "CreateEventContent.h"
using namespace matrix::events;
void CreateEventContent::deserialize(const QJsonValue &data)
{
if (!data.isObject())

View file

@ -29,7 +29,7 @@
#include "PowerLevelsEventContent.h"
#include "TopicEventContent.h"
EventType extractEventType(const QJsonObject &object)
matrix::events::EventType matrix::events::extractEventType(const QJsonObject &object)
{
if (!object.contains("type"))
throw DeserializationException("Missing event type");

View file

@ -17,6 +17,8 @@
#include "HistoryVisibilityEventContent.h"
using namespace matrix::events;
void HistoryVisibilityEventContent::deserialize(const QJsonValue &data)
{
if (!data.isObject())

View file

@ -17,6 +17,8 @@
#include "JoinRulesEventContent.h"
using namespace matrix::events;
void JoinRulesEventContent::deserialize(const QJsonValue &data)
{
if (!data.isObject())

View file

@ -19,6 +19,8 @@
#include "MemberEventContent.h"
using namespace matrix::events;
void MemberEventContent::deserialize(const QJsonValue &data)
{
if (!data.isObject())

View file

@ -17,6 +17,8 @@
#include "NameEventContent.h"
using namespace matrix::events;
void NameEventContent::deserialize(const QJsonValue &data)
{
if (!data.isObject())

View file

@ -20,6 +20,8 @@
#include "Deserializable.h"
#include "PowerLevelsEventContent.h"
using namespace matrix::events;
void PowerLevelsEventContent::deserialize(const QJsonValue &data)
{
if (!data.isObject())

View file

@ -17,6 +17,8 @@
#include "TopicEventContent.h"
using namespace matrix::events;
void TopicEventContent::deserialize(const QJsonValue &data)
{
if (!data.isObject())

View file

@ -16,6 +16,8 @@
#include "PowerLevelsEventContent.h"
#include "TopicEventContent.h"
using namespace matrix::events;
TEST(BaseEvent, Deserialization)
{
// NameEventContent