From bd8764cbbb0ec003549261586867a6ae6f46f5cd Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 7 Jul 2018 11:05:58 +0900 Subject: Reinstate EventTypeRegistry, keeping EventTypeTraits<> around You can now get a (much more readable) Matrix type (event_mtype_t) for the internal event type code (event_type_t) using EventTypeRegistry::getMatrixType(). --- lib/events/event.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib/events/event.cpp') diff --git a/lib/events/event.cpp b/lib/events/event.cpp index 44bf79a1..2cad1462 100644 --- a/lib/events/event.cpp +++ b/lib/events/event.cpp @@ -24,10 +24,16 @@ using namespace QMatrixClient; -event_type_t QMatrixClient::nextTypeId() +event_type_t EventTypeRegistry::initializeTypeId(event_mtype_t matrixTypeId) { - static event_type_t _id = EventTypeTraits::id; - return ++_id; + const auto id = get().eventTypes.size(); + get().eventTypes.push_back(matrixTypeId); + if (strncmp(matrixTypeId, "", 1) == 0) + qDebug(EVENTS) << "Initialized unknown event type with id" << id; + else + qDebug(EVENTS) << "Initialized event type" << matrixTypeId + << "with id" << id; + return id; } Event::Event(Type type, const QJsonObject& json) -- cgit v1.2.3