From 4b1b308f28bdaef598a5dfc249d7af6a0346b367 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 8 Jun 2018 19:05:04 +0900 Subject: SyncJob: Support receiving to_device and presence events --- lib/jobs/syncjob.cpp | 13 ++++++++++++- lib/jobs/syncjob.h | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'lib/jobs') diff --git a/lib/jobs/syncjob.cpp b/lib/jobs/syncjob.cpp index a739ea0d..a366cece 100644 --- a/lib/jobs/syncjob.cpp +++ b/lib/jobs/syncjob.cpp @@ -54,11 +54,21 @@ SyncDataList&& SyncData::takeRoomData() return std::move(roomData); } +Events&& SyncData::takePresenceData() +{ + return std::move(presenceData); +} + Events&& SyncData::takeAccountData() { return std::move(accountData); } +Events&&SyncData::takeToDeviceEvents() +{ + return std::move(toDeviceEvents); +} + template inline EventsArrayT load(const QJsonObject& batches, StrT keyName) { @@ -76,8 +86,9 @@ BaseJob::Status SyncData::parseJson(const QJsonDocument &data) auto json = data.object(); nextBatch_ = json.value("next_batch").toString(); - // TODO: presence + presenceData = load(json, "presence"); accountData = load(json, "account_data"); + toDeviceEvents = load(json, "to_device"); QJsonObject rooms = json.value("rooms").toObject(); JoinStates::Int ii = 1; // ii is used to make a JoinState value diff --git a/lib/jobs/syncjob.h b/lib/jobs/syncjob.h index b12f9fff..ca30848e 100644 --- a/lib/jobs/syncjob.h +++ b/lib/jobs/syncjob.h @@ -56,13 +56,17 @@ namespace QMatrixClient { public: BaseJob::Status parseJson(const QJsonDocument &data); + Events&& takePresenceData(); Events&& takeAccountData(); + Events&& takeToDeviceEvents(); SyncDataList&& takeRoomData(); QString nextBatch() const; private: QString nextBatch_; + Events presenceData; Events accountData; + Events toDeviceEvents; SyncDataList roomData; }; -- cgit v1.2.3