summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/clientapi.h23
1 files changed, 11 insertions, 12 deletions
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:
180 /** 180 /**
181 * Create a new entity. 181 * Create a new entity.
182 */ 182 */
183 //TODO return job that tracks progress until resource has stored the message in it's queue?
184 template <class DomainType> 183 template <class DomainType>
185 static void create(const DomainType &domainObject, const QByteArray &resourceIdentifier) { 184 static KAsync::Job<void> create(const DomainType &domainObject, const QByteArray &resourceIdentifier) {
186 //Potentially move to separate thread as well 185 //Potentially move to separate thread as well
187 auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceName(resourceIdentifier), resourceIdentifier); 186 auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceName(resourceIdentifier), resourceIdentifier);
188 if (facade) { 187 if (facade) {
189 facade->create(domainObject).template then<void>([](){}, [](int errorCode, const QString &error) { 188 return facade->create(domainObject).template then<void>([facade](){}, [](int errorCode, const QString &error) {
190 Warning() << "Failed to create"; 189 Warning() << "Failed to create";
191 }).exec().waitForFinished(); 190 });
192 } 191 }
193 //TODO return job? 192 return KAsync::error<void>(-1, "Failed to create a facade");
194 } 193 }
195 194
196 /** 195 /**
@@ -199,30 +198,30 @@ public:
199 * This includes moving etc. since these are also simple settings on a property. 198 * This includes moving etc. since these are also simple settings on a property.
200 */ 199 */
201 template <class DomainType> 200 template <class DomainType>
202 static void modify(const DomainType &domainObject, const QByteArray &resourceIdentifier) { 201 static KAsync::Job<void> modify(const DomainType &domainObject, const QByteArray &resourceIdentifier) {
203 //Potentially move to separate thread as well 202 //Potentially move to separate thread as well
204 auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceName(resourceIdentifier), resourceIdentifier); 203 auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceName(resourceIdentifier), resourceIdentifier);
205 if (facade) { 204 if (facade) {
206 facade->modify(domainObject).template then<void>([](){}, [](int errorCode, const QString &error) { 205 return facade->modify(domainObject).template then<void>([facade](){}, [](int errorCode, const QString &error) {
207 Warning() << "Failed to modify"; 206 Warning() << "Failed to modify";
208 }).exec().waitForFinished(); 207 });
209 } 208 }
210 //TODO return job? 209 return KAsync::error<void>(-1, "Failed to create a facade");
211 } 210 }
212 211
213 /** 212 /**
214 * Remove an entity. 213 * Remove an entity.
215 */ 214 */
216 template <class DomainType> 215 template <class DomainType>
217 static void remove(const DomainType &domainObject, const QByteArray &resourceIdentifier) { 216 static KAsync::Job<void> remove(const DomainType &domainObject, const QByteArray &resourceIdentifier) {
218 //Potentially move to separate thread as well 217 //Potentially move to separate thread as well
219 auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceName(resourceIdentifier), resourceIdentifier); 218 auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceName(resourceIdentifier), resourceIdentifier);
220 if (facade) { 219 if (facade) {
221 facade->remove(domainObject).template then<void>([](){}, [](int errorCode, const QString &error) { 220 facade->remove(domainObject).template then<void>([facade](){}, [](int errorCode, const QString &error) {
222 Warning() << "Failed to remove"; 221 Warning() << "Failed to remove";
223 }).exec().waitForFinished(); 222 }).exec().waitForFinished();
224 } 223 }
225 //TODO return job? 224 return KAsync::error<void>(-1, "Failed to create a facade");
226 } 225 }
227 226
228 static void shutdown(const QByteArray &resourceIdentifier); 227 static void shutdown(const QByteArray &resourceIdentifier);