diff options
Diffstat (limited to 'jobs')
-rw-r--r-- | jobs/passwordlogin.h | 2 | ||||
-rw-r--r-- | jobs/roommessagesjob.cpp | 9 | ||||
-rw-r--r-- | jobs/roommessagesjob.h | 2 | ||||
-rw-r--r-- | jobs/syncjob.cpp | 6 | ||||
-rw-r--r-- | jobs/syncjob.h | 55 |
5 files changed, 37 insertions, 37 deletions
diff --git a/jobs/passwordlogin.h b/jobs/passwordlogin.h index 713a1821..6b7db0b3 100644 --- a/jobs/passwordlogin.h +++ b/jobs/passwordlogin.h @@ -40,4 +40,4 @@ namespace QMatrixClient class Private; Private* d; }; -} +} // namespace QMatrixClient diff --git a/jobs/roommessagesjob.cpp b/jobs/roommessagesjob.cpp index a48403c8..3e603a50 100644 --- a/jobs/roommessagesjob.cpp +++ b/jobs/roommessagesjob.cpp @@ -17,16 +17,15 @@ */ #include "roommessagesjob.h" -#include "../util.h" -#include <QtCore/QJsonArray> +#include "util.h" using namespace QMatrixClient; class RoomMessagesJob::Private { public: - Owning<Events> events; + Owning<RoomEvents> events; QString end; }; @@ -49,7 +48,7 @@ RoomMessagesJob::~RoomMessagesJob() delete d; } -Events RoomMessagesJob::releaseEvents() +RoomEvents RoomMessagesJob::releaseEvents() { return d->events.release(); } @@ -62,7 +61,7 @@ QString RoomMessagesJob::end() BaseJob::Status RoomMessagesJob::parseJson(const QJsonDocument& data) { QJsonObject obj = data.object(); - d->events.assign(eventsFromJson(obj.value("chunk").toArray())); + d->events.assign(makeEvents<RoomEvent>(obj.value("chunk").toArray())); d->end = obj.value("end").toString(); return Success; } diff --git a/jobs/roommessagesjob.h b/jobs/roommessagesjob.h index 2d15d9d4..a029c27c 100644 --- a/jobs/roommessagesjob.h +++ b/jobs/roommessagesjob.h @@ -34,7 +34,7 @@ namespace QMatrixClient FetchDirection dir = FetchDirection::Backward); virtual ~RoomMessagesJob(); - Events releaseEvents(); + RoomEvents releaseEvents(); QString end(); protected: diff --git a/jobs/syncjob.cpp b/jobs/syncjob.cpp index 5984128f..29ddc2e6 100644 --- a/jobs/syncjob.cpp +++ b/jobs/syncjob.cpp @@ -18,7 +18,6 @@ #include "syncjob.h" -#include <QtCore/QJsonArray> #include <QtCore/QElapsedTimer> using namespace QMatrixClient; @@ -96,11 +95,6 @@ BaseJob::Status SyncJob::parseJson(const QJsonDocument& data) return Success; } -void SyncRoomData::EventList::fromJson(const QJsonObject& roomContents) -{ - assign(eventsFromJson(roomContents[jsonKey].toObject()["events"].toArray())); -} - SyncRoomData::SyncRoomData(const QString& roomId_, JoinState joinState_, const QJsonObject& room_) : roomId(roomId_) 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); |