From 382150ca27b03b912b43ad07956231497d35cfe8 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 10 Dec 2015 11:14:04 +0100 Subject: A change-replay function --- common/genericresource.cpp | 9 +++++++-- common/genericresource.h | 1 + examples/dummyresource/resourcefactory.cpp | 6 ++++++ examples/dummyresource/resourcefactory.h | 1 + 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/common/genericresource.cpp b/common/genericresource.cpp index 66f5dcf..7b8d9bb 100644 --- a/common/genericresource.cpp +++ b/common/genericresource.cpp @@ -266,8 +266,8 @@ GenericResource::GenericResource(const QByteArray &resourceInstanceIdentifier, c mProcessor = new Processor(mPipeline.data(), QList() << &mUserQueue << &mSynchronizerQueue); QObject::connect(mProcessor, &Processor::error, [this](int errorCode, const QString &msg) { onProcessorError(errorCode, msg); }); QObject::connect(mPipeline.data(), &Pipeline::revisionUpdated, this, &Resource::revisionUpdated); - mSourceChangeReplay = new ChangeReplay(resourceInstanceIdentifier, [](const QByteArray &type, const QByteArray &key, const QByteArray &value) { - return KAsync::null(); + mSourceChangeReplay = new ChangeReplay(resourceInstanceIdentifier, [this](const QByteArray &type, const QByteArray &key, const QByteArray &value) { + return this->replay(type, key, value); }); QObject::connect(mPipeline.data(), &Pipeline::revisionUpdated, mSourceChangeReplay, &ChangeReplay::revisionChanged); QObject::connect(mSourceChangeReplay, &ChangeReplay::changesReplayed, this, &GenericResource::updateLowerBoundRevision); @@ -285,6 +285,11 @@ GenericResource::~GenericResource() delete mSourceChangeReplay; } +KAsync::Job GenericResource::replay(const QByteArray &type, const QByteArray &key, const QByteArray &value) +{ + return KAsync::null(); +} + void GenericResource::removeFromDisk(const QByteArray &instanceIdentifier) { Akonadi2::Storage(Akonadi2::storageLocation(), instanceIdentifier, Akonadi2::Storage::ReadWrite).removeFromDisk(); diff --git a/common/genericresource.h b/common/genericresource.h index 33de0e7..97251a9 100644 --- a/common/genericresource.h +++ b/common/genericresource.h @@ -53,6 +53,7 @@ private Q_SLOTS: void updateLowerBoundRevision(); protected: + virtual KAsync::Job replay(const QByteArray &type, const QByteArray &key, const QByteArray &value); void onProcessorError(int errorCode, const QString &errorMessage); void enqueueCommand(MessageQueue &mq, int commandId, const QByteArray &data); flatbuffers::FlatBufferBuilder m_fbb; diff --git a/examples/dummyresource/resourcefactory.cpp b/examples/dummyresource/resourcefactory.cpp index 91a1229..ddae80e 100644 --- a/examples/dummyresource/resourcefactory.cpp +++ b/examples/dummyresource/resourcefactory.cpp @@ -279,6 +279,12 @@ KAsync::Job DummyResource::synchronizeWithSource() }); } +KAsync::Job DummyResource::replay(const QByteArray &type, const QByteArray &key, const QByteArray &value) +{ + Trace() << "Replaying " << key; + return KAsync::null(); +} + void DummyResource::removeFromDisk(const QByteArray &instanceIdentifier) { GenericResource::removeFromDisk(instanceIdentifier); diff --git a/examples/dummyresource/resourcefactory.h b/examples/dummyresource/resourcefactory.h index 4144985..dc248c0 100644 --- a/examples/dummyresource/resourcefactory.h +++ b/examples/dummyresource/resourcefactory.h @@ -36,6 +36,7 @@ public: KAsync::Job synchronizeWithSource() Q_DECL_OVERRIDE; static void removeFromDisk(const QByteArray &instanceIdentifier); private: + KAsync::Job replay(const QByteArray &type, const QByteArray &key, const QByteArray &value) Q_DECL_OVERRIDE; QString resolveRemoteId(const QByteArray &type, const QString &remoteId, Akonadi2::Storage::Transaction &transaction); void createEvent(const QByteArray &rid, const QMap &data, flatbuffers::FlatBufferBuilder &entityFbb, Akonadi2::Storage::Transaction &); void createMail(const QByteArray &rid, const QMap &data, flatbuffers::FlatBufferBuilder &entityFbb, Akonadi2::Storage::Transaction &); -- cgit v1.2.3