From 564d518c086f2aeab0f0466b7cd1915e20edc7da Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 3 May 2018 21:23:28 +0900 Subject: GetRoomEventsJob (replaces RoomMessagesJob) + refactoring 1. Updates in this commit (see further) allow to generate and build GetRoomEventsJob from message_pagination.yaml; this job completely preempts RoomMessagesJob. 2. EventsBatch<> is no more a thing; there's EventsArray<> to replace it but it's loaded from a JSON array rather than an event batch (a JSON array inside another JSON object). SyncJob that used it extensively has been moved to "conventional" containers (Events, RoomEvents and the newly introduced StateEvents). RoomMessagesJob that also used EventsBatch<> is decommissioned (see above). 3. RoomEventsRange is now an alias for Range, defined in util.h (otherwise almost the same). 4. Connection::getMessages() is no more. Use Room::getPreviousContent() and Connection::callApi() instead. 5. Moving things around in Room, since SyncJob now supplies state events in more specific StateEvents, rather than RoomEvents. --- lib/events/event.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'lib/events/event.cpp') diff --git a/lib/events/event.cpp b/lib/events/event.cpp index 193250de..57049671 100644 --- a/lib/events/event.cpp +++ b/lib/events/event.cpp @@ -160,14 +160,13 @@ void RoomEvent::addId(const QString& id) template <> RoomEventPtr _impl::doMakeEvent(const QJsonObject& obj) { - return RoomEventPtr { makeIfMatches - (obj, obj["type"].toString()) }; -} + // Check more specific event types first + if (auto e = doMakeEvent(obj)) + return e; -StateEventBase::~StateEventBase() = default; + return makeIfMatches(obj, obj["type"].toString()); +} bool StateEventBase::repeatsState() const { @@ -176,3 +175,13 @@ bool StateEventBase::repeatsState() const .toObject().value("prev_content"); return contentJson == prevContentJson; } + +template<> +StateEventPtr _impl::doMakeEvent(const QJsonObject& obj) +{ + return makeIfMatches(obj, obj["type"].toString()); + +} -- cgit v1.2.3 From 28a0d70164e2596d306521cd18d25c0e8c0b5336 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 4 May 2018 12:13:43 +0900 Subject: EvT::TypeId: Use a member function instead of a variable The latter one causes linkage errors when used from a template method (but not from a template class, puzzlingly). --- lib/events/event.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/events/event.cpp') diff --git a/lib/events/event.cpp b/lib/events/event.cpp index 57049671..c2b92a50 100644 --- a/lib/events/event.cpp +++ b/lib/events/event.cpp @@ -76,7 +76,7 @@ template inline event_ptr_tt makeIfMatches(const QJsonObject& o, const QString& selector) { - if (selector == EventT::TypeId) + if (selector == EventT::typeId()) return _impl::create(o); return makeIfMatches(o, selector); -- cgit v1.2.3 From f70ec41accd6da9f223bc41b446ad1d2d77de3f4 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Tue, 1 May 2018 21:08:06 +0900 Subject: Fix building on OSX --- lib/events/event.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/events/event.cpp') diff --git a/lib/events/event.cpp b/lib/events/event.cpp index c2b92a50..576e9426 100644 --- a/lib/events/event.cpp +++ b/lib/events/event.cpp @@ -87,7 +87,7 @@ EventPtr _impl::doMakeEvent(const QJsonObject& obj) { // Check more specific event types first if (auto e = doMakeEvent(obj)) - return e; + return ptrCast(move(e)); return makeIfMatches( @@ -162,7 +162,7 @@ RoomEventPtr _impl::doMakeEvent(const QJsonObject& obj) { // Check more specific event types first if (auto e = doMakeEvent(obj)) - return e; + return ptrCast(move(e)); return makeIfMatches(obj, obj["type"].toString()); -- cgit v1.2.3