aboutsummaryrefslogtreecommitdiff
path: root/jobs/syncjob.h
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2017-05-28 13:00:44 +0900
committerGitHub <noreply@github.com>2017-05-28 13:00:44 +0900
commit36dbba9c543b819aec526f18c33f1d95b0ee61c7 (patch)
tree49caf6450be52072d8f1e4e40e2dfb8490d73732 /jobs/syncjob.h
parentced7a66686596e74a1f25b5d9634b9b562870943 (diff)
parenta5e14da86c3299ca8d36eb4a4eb58ce2a245dc4e (diff)
downloadlibquotient-36dbba9c543b819aec526f18c33f1d95b0ee61c7.tar.gz
libquotient-36dbba9c543b819aec526f18c33f1d95b0ee61c7.zip
Merge pull request #65 from QMatrixClient/kitsune-simplify-events
Events refactoring
Diffstat (limited to 'jobs/syncjob.h')
-rw-r--r--jobs/syncjob.h55
1 files changed, 31 insertions, 24 deletions
diff --git a/jobs/syncjob.h b/jobs/syncjob.h
index 48be9423..07824e23 100644
--- a/jobs/syncjob.h
+++ b/jobs/syncjob.h
@@ -20,39 +20,46 @@
#include "basejob.h"
-#include "../joinstate.h"
-#include "../events/event.h"
+#include "joinstate.h"
+#include "events/event.h"
#include "util.h"
namespace QMatrixClient
{
class SyncRoomData
{
- public:
- class EventList : public Owning<Events>
- {
- private:
- QString jsonKey;
- public:
- explicit EventList(QString k) : jsonKey(std::move(k)) { }
- void fromJson(const QJsonObject& roomContents);
- };
+ public:
+ template <typename EventT>
+ class Batch : public Owning<EventsBatch<EventT>>
+ {
+ public:
+ explicit Batch(QString k) : jsonKey(std::move(k)) { }
+ void fromJson(const QJsonObject& roomContents)
+ {
+ this->assign(makeEvents<EventT>(
+ roomContents[jsonKey].toObject()["events"].toArray()));
+ }
+
+
+ private:
+ QString jsonKey;
+ };
- QString roomId;
- JoinState joinState;
- EventList state;
- EventList timeline;
- EventList ephemeral;
- EventList accountData;
- EventList inviteState;
+ QString roomId;
+ JoinState joinState;
+ Batch<RoomEvent> state;
+ Batch<RoomEvent> timeline;
+ Batch<Event> ephemeral;
+ Batch<Event> accountData;
+ Batch<Event> inviteState;
- bool timelineLimited;
- QString timelinePrevBatch;
- int highlightCount;
- int notificationCount;
+ bool timelineLimited;
+ QString timelinePrevBatch;
+ int highlightCount;
+ int notificationCount;
- SyncRoomData(const QString& roomId, JoinState joinState_,
- const QJsonObject& room_);
+ SyncRoomData(const QString& roomId, JoinState joinState_,
+ const QJsonObject& room_);
};
} // namespace QMatrixClient
Q_DECLARE_TYPEINFO(QMatrixClient::SyncRoomData, Q_MOVABLE_TYPE);