summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-12-30 09:32:52 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-12-30 09:32:52 +0100
commit02c311e38b8b9b80814a4e8e582d5c5a56a51056 (patch)
tree914255d577be2f17501c546e6d08b80aa23ca165 /common
parente99453c21eb9100d6fe05ccec153fe6e640bb440 (diff)
downloadsink-02c311e38b8b9b80814a4e8e582d5c5a56a51056.tar.gz
sink-02c311e38b8b9b80814a4e8e582d5c5a56a51056.zip
Don't expose enabling/disabling of changerecording to resource
implementations
Diffstat (limited to 'common')
-rw-r--r--common/genericresource.cpp20
-rw-r--r--common/genericresource.h4
2 files changed, 23 insertions, 1 deletions
diff --git a/common/genericresource.cpp b/common/genericresource.cpp
index 1af9226..9fbcaaa 100644
--- a/common/genericresource.cpp
+++ b/common/genericresource.cpp
@@ -370,6 +370,26 @@ void GenericResource::processCommand(int commandId, const QByteArray &data)
370 } 370 }
371} 371}
372 372
373KAsync::Job<void> GenericResource::synchronizeWithSource()
374{
375 return KAsync::start<void>([this]() {
376 Log() << " Synchronizing";
377 //Changereplay would deadlock otherwise when trying to open the synchronization store
378 enableChangeReplay(false);
379 auto mainStore = QSharedPointer<Akonadi2::Storage>::create(Akonadi2::storageLocation(), mResourceInstanceIdentifier, Akonadi2::Storage::ReadOnly);
380 auto syncStore = QSharedPointer<Akonadi2::Storage>::create(Akonadi2::storageLocation(), mResourceInstanceIdentifier + ".synchronization", Akonadi2::Storage::ReadWrite);
381 synchronizeWithSource(*mainStore, *syncStore).then<void>([this, mainStore, syncStore]() {
382 Log() << "Done Synchronizing";
383 enableChangeReplay(true);
384 }).exec();
385 });
386}
387
388KAsync::Job<void> GenericResource::synchronizeWithSource(Akonadi2::Storage &mainStore, Akonadi2::Storage &synchronizationStore)
389{
390 return KAsync::null<void>();
391}
392
373static void waitForDrained(KAsync::Future<void> &f, MessageQueue &queue) 393static void waitForDrained(KAsync::Future<void> &f, MessageQueue &queue)
374{ 394{
375 if (queue.isEmpty()) { 395 if (queue.isEmpty()) {
diff --git a/common/genericresource.h b/common/genericresource.h
index 9c8b977..ea68a25 100644
--- a/common/genericresource.h
+++ b/common/genericresource.h
@@ -44,7 +44,8 @@ public:
44 virtual ~GenericResource(); 44 virtual ~GenericResource();
45 45
46 virtual void processCommand(int commandId, const QByteArray &data) Q_DECL_OVERRIDE; 46 virtual void processCommand(int commandId, const QByteArray &data) Q_DECL_OVERRIDE;
47 virtual KAsync::Job<void> synchronizeWithSource() Q_DECL_OVERRIDE = 0; 47 virtual KAsync::Job<void> synchronizeWithSource() Q_DECL_OVERRIDE;
48 virtual KAsync::Job<void> synchronizeWithSource(Akonadi2::Storage &mainStore, Akonadi2::Storage &synchronizationStore);
48 virtual KAsync::Job<void> processAllMessages() Q_DECL_OVERRIDE; 49 virtual KAsync::Job<void> processAllMessages() Q_DECL_OVERRIDE;
49 virtual void setLowerBoundRevision(qint64 revision) Q_DECL_OVERRIDE; 50 virtual void setLowerBoundRevision(qint64 revision) Q_DECL_OVERRIDE;
50 51
@@ -52,6 +53,7 @@ public:
52 53
53 static void removeFromDisk(const QByteArray &instanceIdentifier); 54 static void removeFromDisk(const QByteArray &instanceIdentifier);
54 static qint64 diskUsage(const QByteArray &instanceIdentifier); 55 static qint64 diskUsage(const QByteArray &instanceIdentifier);
56
55private Q_SLOTS: 57private Q_SLOTS:
56 void updateLowerBoundRevision(); 58 void updateLowerBoundRevision();
57 59