summaryrefslogtreecommitdiffstats
path: root/common/clientapi.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/clientapi.h')
-rw-r--r--common/clientapi.h19
1 files changed, 15 insertions, 4 deletions
diff --git a/common/clientapi.h b/common/clientapi.h
index 6054130..d2757e7 100644
--- a/common/clientapi.h
+++ b/common/clientapi.h
@@ -278,7 +278,7 @@ public:
278 virtual void create(const DomainType &domainObject) = 0; 278 virtual void create(const DomainType &domainObject) = 0;
279 virtual void modify(const DomainType &domainObject) = 0; 279 virtual void modify(const DomainType &domainObject) = 0;
280 virtual void remove(const DomainType &domainObject) = 0; 280 virtual void remove(const DomainType &domainObject) = 0;
281 virtual void load(const Query &query, const std::function<void(const typename DomainType::Ptr &)> &resultCallback) = 0; 281 virtual void load(const Query &query, const std::function<void(const typename DomainType::Ptr &)> &resultCallback, const std::function<void()> &completeCallback) = 0;
282}; 282};
283 283
284 284
@@ -353,7 +353,7 @@ class Store {
353public: 353public:
354 static QString storageLocation() 354 static QString storageLocation()
355 { 355 {
356 return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/akonadi2"; 356 return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/akonadi2/storage";
357 } 357 }
358 358
359 /** 359 /**
@@ -371,13 +371,24 @@ public:
371 // Query all resources and aggregate results 371 // Query all resources and aggregate results
372 // query tells us in which resources we're interested 372 // query tells us in which resources we're interested
373 // TODO: queries to individual resources could be parallelized 373 // TODO: queries to individual resources could be parallelized
374 auto eventloop = QSharedPointer<QEventLoop>::create();
375 int completeCounter = 0;
374 for(const QString &resource : query.resources) { 376 for(const QString &resource : query.resources) {
375 auto facade = FacadeFactory::instance().getFacade<DomainType>(resource); 377 auto facade = FacadeFactory::instance().getFacade<DomainType>(resource);
376 //We have to bind an instance to the function callback. Since we use a shared pointer this keeps the result provider instance (and thus also the emitter) alive. 378 //We have to bind an instance to the function callback. Since we use a shared pointer this keeps the result provider instance (and thus also the emitter) alive.
377 std::function<void(const typename DomainType::Ptr &)> addCallback = std::bind(&ResultProvider<typename DomainType::Ptr>::add, resultSet, std::placeholders::_1); 379 std::function<void(const typename DomainType::Ptr &)> addCallback = std::bind(&ResultProvider<typename DomainType::Ptr>::add, resultSet, std::placeholders::_1);
378 facade->load(query, addCallback); 380 //We copy the facade pointer to keep it alive
381 facade->load(query, addCallback, [&completeCounter, &query, resultSet, facade, eventloop]() {
382 //TODO use jobs instead of this counter
383 completeCounter++;
384 if (completeCounter == query.resources.size()) {
385 resultSet->complete();
386 eventloop->quit();
387 }
388 });
379 } 389 }
380 resultSet->complete(); 390 //The thread contains no eventloop, so execute one here
391 eventloop->exec(QEventLoop::ExcludeUserInputEvents);
381 }); 392 });
382 return resultSet->emitter(); 393 return resultSet->emitter();
383 } 394 }