diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-02-27 19:51:08 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-02-27 19:51:08 +0900 |
commit | 375bea5ee67a90c6419acf50c06c05ed0435c772 (patch) | |
tree | 76f0a1c830797fe1b17b3bea67ddaf7fb53cbd6a /jobs/syncjob.h | |
parent | e80bfd2fc710d4780a2c22bde9d605a41bd4aaa4 (diff) | |
parent | efeeca097a3c69991683615366f07625855ba2ac (diff) | |
download | libquotient-375bea5ee67a90c6419acf50c06c05ed0435c772.tar.gz libquotient-375bea5ee67a90c6419acf50c06c05ed0435c772.zip |
Merge branch 'master' into kitsune-gtad
Diffstat (limited to 'jobs/syncjob.h')
-rw-r--r-- | jobs/syncjob.h | 36 |
1 files changed, 19 insertions, 17 deletions
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 <typename EventT> + class SyncBatch : public EventsBatch<EventT> { public: - template <typename EventT> - class Batch : public EventsBatch<EventT> + 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<EventT>::fromJson( - roomContents[jsonKey].toObject(), "events"); - } + EventsBatch<EventT>::fromJson( + roomContents[jsonKey].toObject(), "events"); + } - private: - QString jsonKey; - }; + private: + QString jsonKey; + }; + class SyncRoomData + { + public: QString roomId; JoinState joinState; - Batch<RoomEvent> state; - Batch<RoomEvent> timeline; - Batch<Event> ephemeral; - Batch<Event> accountData; + SyncBatch<RoomEvent> state; + SyncBatch<RoomEvent> timeline; + SyncBatch<Event> ephemeral; + SyncBatch<Event> accountData; bool timelineLimited; QString timelinePrevBatch; @@ -68,11 +68,13 @@ namespace QMatrixClient { public: BaseJob::Status parseJson(const QJsonDocument &data); + SyncBatch<Event>&& takeAccountData(); SyncDataList&& takeRoomData(); QString nextBatch() const; private: QString nextBatch_; + SyncBatch<Event> accountData { "account_data" }; SyncDataList roomData; }; |