From f1ffe1e7a3e81c07a07a8416ce307e4413ec8fbc Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 1 Jul 2018 22:48:38 +0900 Subject: Event types system remade to be extensible There were two common points that had to be updated every time a new event is introduced: the EventType enumeration and one of 3 doMakeEvent<> specialisations. The new code has a template class, EventFactory<>, that uses a list of static factory methods to create events instead of typelists used in doMakeEvent<>(); the EventType enumeration is replaced with a namespace populated with constants as necessary. In general, EventType is considered a deprecated mechanism altogether; instead, a set of facilities is provided: is<>() to check if an event has a certain type (to replace comparison against an EventType value) and visit<>() to execute actions based on the event type (replacing switch statements over EventType values). Closes #129. --- lib/connection.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/connection.cpp') diff --git a/lib/connection.cpp b/lib/connection.cpp index 8fd960b6..339be5b9 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -355,9 +355,9 @@ void Connection::onSyncSuccess(SyncData &&data) { continue; } - d->accountData[accountEvent->jsonType()] = + d->accountData[accountEvent->matrixType()] = fromJson(accountEvent->contentJson()); - emit accountDataChanged(accountEvent->jsonType()); + emit accountDataChanged(accountEvent->matrixType()); } } @@ -603,7 +603,7 @@ SendToDeviceJob* Connection::sendToDevices(const QString& eventType, std::for_each(devicesToEvents.begin(), devicesToEvents.end(), [&jsonUser] (const auto& deviceToEvents) { jsonUser.insert(deviceToEvents.first, - deviceToEvents.second.toJson()); + deviceToEvents.second.contentJson()); }); }); return callApi(BackgroundRequest, @@ -1048,4 +1048,3 @@ void Connection::setCacheState(bool newValue) emit cacheStateChanged(); } } - -- cgit v1.2.3