diff options
Diffstat (limited to 'dummyresource')
-rw-r--r-- | dummyresource/facade.cpp | 8 | ||||
-rw-r--r-- | dummyresource/facade.h | 2 | ||||
-rw-r--r-- | dummyresource/resourcefactory.cpp | 7 | ||||
-rw-r--r-- | dummyresource/resourcefactory.h | 1 |
4 files changed, 13 insertions, 5 deletions
diff --git a/dummyresource/facade.cpp b/dummyresource/facade.cpp index 1aaec68..fcce871 100644 --- a/dummyresource/facade.cpp +++ b/dummyresource/facade.cpp | |||
@@ -115,16 +115,16 @@ static std::function<bool(const std::string &key, DummyEvent const *buffer, Akon | |||
115 | return preparedQuery; | 115 | return preparedQuery; |
116 | } | 116 | } |
117 | 117 | ||
118 | Async::Job<void> DummyResourceFacade::synchronizeResource(bool sync) | 118 | Async::Job<void> DummyResourceFacade::synchronizeResource(bool sync, bool processAll) |
119 | { | 119 | { |
120 | //TODO check if a sync is necessary | 120 | //TODO check if a sync is necessary |
121 | //TODO Only sync what was requested | 121 | //TODO Only sync what was requested |
122 | //TODO timeout | 122 | //TODO timeout |
123 | 123 | ||
124 | if (sync) { | 124 | if (sync || processAll) { |
125 | return Async::start<void>([=](Async::Future<void> &future) { | 125 | return Async::start<void>([=](Async::Future<void> &future) { |
126 | mResourceAccess->open(); | 126 | mResourceAccess->open(); |
127 | mResourceAccess->synchronizeResource().then<void>([&future](Async::Future<void> &f) { | 127 | mResourceAccess->synchronizeResource(sync, processAll).then<void>([&future](Async::Future<void> &f) { |
128 | future.setFinished(); | 128 | future.setFinished(); |
129 | f.setFinished(); | 129 | f.setFinished(); |
130 | }).exec(); | 130 | }).exec(); |
@@ -195,7 +195,7 @@ void DummyResourceFacade::readValue(QSharedPointer<Akonadi2::Storage> storage, c | |||
195 | 195 | ||
196 | Async::Job<void> DummyResourceFacade::load(const Akonadi2::Query &query, const std::function<void(const Akonadi2::Domain::Event::Ptr &)> &resultCallback) | 196 | Async::Job<void> DummyResourceFacade::load(const Akonadi2::Query &query, const std::function<void(const Akonadi2::Domain::Event::Ptr &)> &resultCallback) |
197 | { | 197 | { |
198 | return synchronizeResource(query.syncOnDemand).then<void>([=](Async::Future<void> &future) { | 198 | return synchronizeResource(query.syncOnDemand, query.processAll).then<void>([=](Async::Future<void> &future) { |
199 | //Now that the sync is complete we can execute the query | 199 | //Now that the sync is complete we can execute the query |
200 | const auto preparedQuery = prepareQuery(query); | 200 | const auto preparedQuery = prepareQuery(query); |
201 | 201 | ||
diff --git a/dummyresource/facade.h b/dummyresource/facade.h index c9c8047..1f69161 100644 --- a/dummyresource/facade.h +++ b/dummyresource/facade.h | |||
@@ -44,7 +44,7 @@ public: | |||
44 | 44 | ||
45 | private: | 45 | private: |
46 | void readValue(QSharedPointer<Akonadi2::Storage> storage, const QByteArray &key, const std::function<void(const Akonadi2::Domain::Event::Ptr &)> &resultCallback, std::function<bool(const std::string &key, DummyCalendar::DummyEvent const *buffer, Akonadi2::Domain::Buffer::Event const *local)>); | 46 | void readValue(QSharedPointer<Akonadi2::Storage> storage, const QByteArray &key, const std::function<void(const Akonadi2::Domain::Event::Ptr &)> &resultCallback, std::function<bool(const std::string &key, DummyCalendar::DummyEvent const *buffer, Akonadi2::Domain::Buffer::Event const *local)>); |
47 | Async::Job<void> synchronizeResource(bool sync); | 47 | Async::Job<void> synchronizeResource(bool sync, bool processAll); |
48 | QSharedPointer<Akonadi2::ResourceAccess> mResourceAccess; | 48 | QSharedPointer<Akonadi2::ResourceAccess> mResourceAccess; |
49 | QSharedPointer<DomainTypeAdaptorFactory<Akonadi2::Domain::Event, Akonadi2::Domain::Buffer::Event, DummyCalendar::DummyEvent> > mFactory; | 49 | QSharedPointer<DomainTypeAdaptorFactory<Akonadi2::Domain::Event, Akonadi2::Domain::Buffer::Event, DummyCalendar::DummyEvent> > mFactory; |
50 | }; | 50 | }; |
diff --git a/dummyresource/resourcefactory.cpp b/dummyresource/resourcefactory.cpp index 18083cb..f510cd5 100644 --- a/dummyresource/resourcefactory.cpp +++ b/dummyresource/resourcefactory.cpp | |||
@@ -387,7 +387,14 @@ Async::Job<void> DummyResource::synchronizeWithSource(Akonadi2::Pipeline *pipeli | |||
387 | } | 387 | } |
388 | } | 388 | } |
389 | //TODO find items to remove | 389 | //TODO find items to remove |
390 | qDebug() << "sync complete"; | ||
391 | f.setFinished(); | ||
392 | }); | ||
393 | } | ||
390 | 394 | ||
395 | Async::Job<void> DummyResource::processAllMessages() | ||
396 | { | ||
397 | return Async::start<void>([this](Async::Future<void> &f) { | ||
391 | //We have to wait for all items to be processed to ensure the synced items are available when a query gets executed. | 398 | //We have to wait for all items to be processed to ensure the synced items are available when a query gets executed. |
392 | //TODO: report errors while processing sync? | 399 | //TODO: report errors while processing sync? |
393 | if (mSynchronizerQueue.isEmpty()) { | 400 | if (mSynchronizerQueue.isEmpty()) { |
diff --git a/dummyresource/resourcefactory.h b/dummyresource/resourcefactory.h index 767eba1..3b99d5e 100644 --- a/dummyresource/resourcefactory.h +++ b/dummyresource/resourcefactory.h | |||
@@ -35,6 +35,7 @@ class DummyResource : public Akonadi2::Resource | |||
35 | public: | 35 | public: |
36 | DummyResource(); | 36 | DummyResource(); |
37 | Async::Job<void> synchronizeWithSource(Akonadi2::Pipeline *pipeline); | 37 | Async::Job<void> synchronizeWithSource(Akonadi2::Pipeline *pipeline); |
38 | Async::Job<void> processAllMessages(); | ||
38 | void processCommand(int commandId, const QByteArray &data, uint size, Akonadi2::Pipeline *pipeline); | 39 | void processCommand(int commandId, const QByteArray &data, uint size, Akonadi2::Pipeline *pipeline); |
39 | void configurePipeline(Akonadi2::Pipeline *pipeline); | 40 | void configurePipeline(Akonadi2::Pipeline *pipeline); |
40 | int error() const; | 41 | int error() const; |