From 519c9d6a66f04750c8f9b84aef5f3a6cf5b68279 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 7 Aug 2015 18:40:40 +0200 Subject: Return jobs from clientapi --- common/clientapi.h | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'common/clientapi.h') diff --git a/common/clientapi.h b/common/clientapi.h index 3ff8472..6294863 100644 --- a/common/clientapi.h +++ b/common/clientapi.h @@ -180,17 +180,16 @@ public: /** * Create a new entity. */ - //TODO return job that tracks progress until resource has stored the message in it's queue? template - static void create(const DomainType &domainObject, const QByteArray &resourceIdentifier) { + static KAsync::Job create(const DomainType &domainObject, const QByteArray &resourceIdentifier) { //Potentially move to separate thread as well auto facade = FacadeFactory::instance().getFacade(resourceName(resourceIdentifier), resourceIdentifier); if (facade) { - facade->create(domainObject).template then([](){}, [](int errorCode, const QString &error) { + return facade->create(domainObject).template then([facade](){}, [](int errorCode, const QString &error) { Warning() << "Failed to create"; - }).exec().waitForFinished(); + }); } - //TODO return job? + return KAsync::error(-1, "Failed to create a facade"); } /** @@ -199,30 +198,30 @@ public: * This includes moving etc. since these are also simple settings on a property. */ template - static void modify(const DomainType &domainObject, const QByteArray &resourceIdentifier) { + static KAsync::Job modify(const DomainType &domainObject, const QByteArray &resourceIdentifier) { //Potentially move to separate thread as well auto facade = FacadeFactory::instance().getFacade(resourceName(resourceIdentifier), resourceIdentifier); if (facade) { - facade->modify(domainObject).template then([](){}, [](int errorCode, const QString &error) { + return facade->modify(domainObject).template then([facade](){}, [](int errorCode, const QString &error) { Warning() << "Failed to modify"; - }).exec().waitForFinished(); + }); } - //TODO return job? + return KAsync::error(-1, "Failed to create a facade"); } /** * Remove an entity. */ template - static void remove(const DomainType &domainObject, const QByteArray &resourceIdentifier) { + static KAsync::Job remove(const DomainType &domainObject, const QByteArray &resourceIdentifier) { //Potentially move to separate thread as well auto facade = FacadeFactory::instance().getFacade(resourceName(resourceIdentifier), resourceIdentifier); if (facade) { - facade->remove(domainObject).template then([](){}, [](int errorCode, const QString &error) { + facade->remove(domainObject).template then([facade](){}, [](int errorCode, const QString &error) { Warning() << "Failed to remove"; }).exec().waitForFinished(); } - //TODO return job? + return KAsync::error(-1, "Failed to create a facade"); } static void shutdown(const QByteArray &resourceIdentifier); -- cgit v1.2.3