summaryrefslogtreecommitdiffstats
path: root/common/clientapi.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/clientapi.h')
-rw-r--r--common/clientapi.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/common/clientapi.h b/common/clientapi.h
index 38ec1ee..4948c59 100644
--- a/common/clientapi.h
+++ b/common/clientapi.h
@@ -193,6 +193,13 @@ public:
193 return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/akonadi2/storage"; 193 return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/akonadi2/storage";
194 } 194 }
195 195
196 static QByteArray resourceName(const QByteArray &instanceIdentifier)
197 {
198 auto split = instanceIdentifier.split('.');
199 split.removeLast();
200 return split.join('.');
201 }
202
196 /** 203 /**
197 * Asynchronusly load a dataset 204 * Asynchronusly load a dataset
198 */ 205 */
@@ -209,7 +216,7 @@ public:
209 KAsync::iterate(query.resources) 216 KAsync::iterate(query.resources)
210 .template each<void, QByteArray>([query, resultSet](const QByteArray &resource, KAsync::Future<void> &future) { 217 .template each<void, QByteArray>([query, resultSet](const QByteArray &resource, KAsync::Future<void> &future) {
211 //TODO pass resource identifier to factory 218 //TODO pass resource identifier to factory
212 auto facade = FacadeFactory::instance().getFacade<DomainType>(resource); 219 auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceName(resource));
213 if (facade) { 220 if (facade) {
214 facade->load(query, resultSet).template then<void>([&future](){future.setFinished();}).exec(); 221 facade->load(query, resultSet).template then<void>([&future](){future.setFinished();}).exec();
215 //Keep the facade alive for the lifetime of the resultSet. 222 //Keep the facade alive for the lifetime of the resultSet.
@@ -254,7 +261,7 @@ public:
254 template <class DomainType> 261 template <class DomainType>
255 static void create(const DomainType &domainObject, const QByteArray &resourceIdentifier) { 262 static void create(const DomainType &domainObject, const QByteArray &resourceIdentifier) {
256 //Potentially move to separate thread as well 263 //Potentially move to separate thread as well
257 auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceIdentifier); 264 auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceName(resourceIdentifier));
258 facade->create(domainObject).exec().waitForFinished(); 265 facade->create(domainObject).exec().waitForFinished();
259 //TODO return job? 266 //TODO return job?
260 } 267 }
@@ -267,7 +274,7 @@ public:
267 template <class DomainType> 274 template <class DomainType>
268 static void modify(const DomainType &domainObject, const QByteArray &resourceIdentifier) { 275 static void modify(const DomainType &domainObject, const QByteArray &resourceIdentifier) {
269 //Potentially move to separate thread as well 276 //Potentially move to separate thread as well
270 auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceIdentifier); 277 auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceName(resourceIdentifier));
271 facade->modify(domainObject).exec().waitForFinished(); 278 facade->modify(domainObject).exec().waitForFinished();
272 //TODO return job? 279 //TODO return job?
273 } 280 }
@@ -278,7 +285,7 @@ public:
278 template <class DomainType> 285 template <class DomainType>
279 static void remove(const DomainType &domainObject, const QByteArray &resourceIdentifier) { 286 static void remove(const DomainType &domainObject, const QByteArray &resourceIdentifier) {
280 //Potentially move to separate thread as well 287 //Potentially move to separate thread as well
281 auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceIdentifier); 288 auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceName(resourceIdentifier));
282 facade->remove(domainObject).exec().waitForFinished(); 289 facade->remove(domainObject).exec().waitForFinished();
283 //TODO return job? 290 //TODO return job?
284 } 291 }