diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-05-22 10:22:28 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-05-22 10:22:28 +0900 |
commit | be838b2f4f294a7e1b3f8a771f91d9d1eac14431 (patch) | |
tree | f720ae5a5a52bdd48fdaec17dea3c1c32fe10cd9 /events/roomaliasesevent.cpp | |
parent | 34764f3020c360ebc769cfe154e79b9e7e98f0f7 (diff) | |
download | libquotient-be838b2f4f294a7e1b3f8a771f91d9d1eac14431.tar.gz libquotient-be838b2f4f294a7e1b3f8a771f91d9d1eac14431.zip |
Refactored Events
The biggest change is we have no pimpls in Event objects anymore - because it's two new's instead of one per Event, and we have thousands and even more of Events created during initial sync. The other big change is introduction of RoomEvent, so that now the structure of events almost precisely reflects the CS API spec. The refactoring made UnknownEvent unnecessary as a separate class; a respective base class (either RoomEvent or Event) is used for this purpose now. All the other changes are consequences of these (mostly of RoomEvent introduction).
Diffstat (limited to 'events/roomaliasesevent.cpp')
-rw-r--r-- | events/roomaliasesevent.cpp | 42 |
1 files changed, 4 insertions, 38 deletions
diff --git a/events/roomaliasesevent.cpp b/events/roomaliasesevent.cpp index ab414498..344b4367 100644 --- a/events/roomaliasesevent.cpp +++ b/events/roomaliasesevent.cpp @@ -34,44 +34,10 @@ #include "roomaliasesevent.h" -#include "logging.h" - -#include <QtCore/QJsonArray> - using namespace QMatrixClient; -class RoomAliasesEvent::Private -{ - public: - QStringList aliases; -}; - -RoomAliasesEvent::RoomAliasesEvent() - : Event(EventType::RoomAliases) - , d(new Private) -{ -} - -RoomAliasesEvent::~RoomAliasesEvent() -{ - delete d; -} - -QStringList RoomAliasesEvent::aliases() const -{ - return d->aliases; -} +RoomAliasesEvent::RoomAliasesEvent(const QJsonObject& obj) + : RoomEvent(Type::RoomAliases, obj) + , _aliases(toStringList(contentJson()["aliases"])) +{ } -RoomAliasesEvent* RoomAliasesEvent::fromJson(const QJsonObject& obj) -{ - RoomAliasesEvent* e = new RoomAliasesEvent(); - e->parseJson(obj); - const QJsonObject contents = obj.value("content").toObject(); - const QJsonArray aliases = contents.value("aliases").toArray(); - for( const QJsonValue& alias : aliases ) - { - e->d->aliases << alias.toString(); - } - qCDebug(EVENTS) << "RoomAliasesEvent:" << e->d->aliases; - return e; -} |