summaryrefslogtreecommitdiffstats
path: root/common/clientapi.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/clientapi.h')
-rw-r--r--common/clientapi.h23
1 files changed, 19 insertions, 4 deletions
diff --git a/common/clientapi.h b/common/clientapi.h
index d2b1c9c..2f1c127 100644
--- a/common/clientapi.h
+++ b/common/clientapi.h
@@ -30,6 +30,7 @@
30#include <QtConcurrent/QtConcurrentRun> 30#include <QtConcurrent/QtConcurrentRun>
31#include <functional> 31#include <functional>
32#include "threadboundary.h" 32#include "threadboundary.h"
33#include "async/src/async.h"
33 34
34namespace async { 35namespace async {
35 //This should abstract if we execute from eventloop or in thread. 36 //This should abstract if we execute from eventloop or in thread.
@@ -185,6 +186,11 @@ public:
185 186
186class MemoryBufferAdaptor : public BufferAdaptor { 187class MemoryBufferAdaptor : public BufferAdaptor {
187public: 188public:
189 MemoryBufferAdaptor()
190 : BufferAdaptor()
191 {
192 }
193
188 MemoryBufferAdaptor(const BufferAdaptor &buffer) 194 MemoryBufferAdaptor(const BufferAdaptor &buffer)
189 : BufferAdaptor() 195 : BufferAdaptor()
190 { 196 {
@@ -208,6 +214,11 @@ private:
208 */ 214 */
209class AkonadiDomainType { 215class AkonadiDomainType {
210public: 216public:
217 AkonadiDomainType()
218 :mAdaptor(new MemoryBufferAdaptor())
219 {
220
221 }
211 AkonadiDomainType(const QString &resourceName, const QString &identifier, qint64 revision, const QSharedPointer<BufferAdaptor> &adaptor) 222 AkonadiDomainType(const QString &resourceName, const QString &identifier, qint64 revision, const QSharedPointer<BufferAdaptor> &adaptor)
212 : mAdaptor(adaptor), 223 : mAdaptor(adaptor),
213 mResourceName(resourceName), 224 mResourceName(resourceName),
@@ -310,9 +321,9 @@ class StoreFacade {
310public: 321public:
311 virtual ~StoreFacade(){}; 322 virtual ~StoreFacade(){};
312 QString type() const { return Domain::getTypeName<DomainType>(); } 323 QString type() const { return Domain::getTypeName<DomainType>(); }
313 virtual void create(const DomainType &domainObject) = 0; 324 virtual Async::Job<void> create(const DomainType &domainObject) = 0;
314 virtual void modify(const DomainType &domainObject) = 0; 325 virtual Async::Job<void> modify(const DomainType &domainObject) = 0;
315 virtual void remove(const DomainType &domainObject) = 0; 326 virtual Async::Job<void> remove(const DomainType &domainObject) = 0;
316 virtual void load(const Query &query, const std::function<void(const typename DomainType::Ptr &)> &resultCallback, const std::function<void()> &completeCallback) = 0; 327 virtual void load(const Query &query, const std::function<void(const typename DomainType::Ptr &)> &resultCallback, const std::function<void()> &completeCallback) = 0;
317}; 328};
318 329
@@ -440,11 +451,15 @@ public:
440 /** 451 /**
441 * Create a new entity. 452 * Create a new entity.
442 */ 453 */
454 //TODO return job that tracks progress until resource has stored the message in it's queue?
443 template <class DomainType> 455 template <class DomainType>
444 static void create(const DomainType &domainObject, const QString &resourceIdentifier) { 456 static void create(const DomainType &domainObject, const QString &resourceIdentifier) {
445 //Potentially move to separate thread as well 457 //Potentially move to separate thread as well
446 auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceIdentifier); 458 auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceIdentifier);
447 facade.create(domainObject); 459 auto job = facade->create(domainObject);
460 auto future = job.exec();
461 future.waitForFinished();
462 //TODO return job?
448 } 463 }
449 464
450 /** 465 /**