From a2f991555bec7b317606093e95ec2b5684b0005a Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 25 Feb 2018 15:09:17 +0900 Subject: SyncJob: parse events from global account data too Closes #123 (room account data were parsed even before). No specific event classes for account data yet, though. --- jobs/syncjob.h | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'jobs/syncjob.h') diff --git a/jobs/syncjob.h b/jobs/syncjob.h index aed36e0b..5956e73b 100644 --- a/jobs/syncjob.h +++ b/jobs/syncjob.h @@ -26,30 +26,30 @@ namespace QMatrixClient { - class SyncRoomData + template + class SyncBatch : public EventsBatch { public: - template - class Batch : public EventsBatch + explicit SyncBatch(QString k) : jsonKey(std::move(k)) { } + void fromJson(const QJsonObject& roomContents) { - public: - explicit Batch(QString k) : jsonKey(std::move(k)) { } - void fromJson(const QJsonObject& roomContents) - { - EventsBatch::fromJson( - roomContents[jsonKey].toObject(), "events"); - } + EventsBatch::fromJson( + roomContents[jsonKey].toObject(), "events"); + } - private: - QString jsonKey; - }; + private: + QString jsonKey; + }; + class SyncRoomData + { + public: QString roomId; JoinState joinState; - Batch state; - Batch timeline; - Batch ephemeral; - Batch accountData; + SyncBatch state; + SyncBatch timeline; + SyncBatch ephemeral; + SyncBatch accountData; bool timelineLimited; QString timelinePrevBatch; @@ -68,11 +68,13 @@ namespace QMatrixClient { public: BaseJob::Status parseJson(const QJsonDocument &data); + SyncBatch&& takeAccountData(); SyncDataList&& takeRoomData(); QString nextBatch() const; private: QString nextBatch_; + SyncBatch accountData { "account_data" }; SyncDataList roomData; }; -- cgit v1.2.3