summaryrefslogtreecommitdiffstats
path: root/common/clientapi.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/clientapi.h')
-rw-r--r--common/clientapi.h86
1 files changed, 6 insertions, 80 deletions
diff --git a/common/clientapi.h b/common/clientapi.h
index c4125bd..4e6db09 100644
--- a/common/clientapi.h
+++ b/common/clientapi.h
@@ -29,13 +29,10 @@
29#include <Async/Async> 29#include <Async/Async>
30 30
31#include "query.h" 31#include "query.h"
32#include "threadboundary.h"
33#include "resultprovider.h" 32#include "resultprovider.h"
34#include "domain/applicationdomaintype.h" 33#include "applicationdomaintype.h"
35#include "resourceconfig.h"
36#include "facadefactory.h" 34#include "facadefactory.h"
37#include "log.h" 35#include "log.h"
38#include "definitions.h"
39 36
40namespace async { 37namespace async {
41 //This should abstract if we execute from eventloop or in thread. 38 //This should abstract if we execute from eventloop or in thread.
@@ -51,42 +48,12 @@ using namespace async;
51 * Store interface used in the client API. 48 * Store interface used in the client API.
52 */ 49 */
53class Store { 50class Store {
54public: 51private:
55 static QString storageLocation() 52 static QList<QByteArray> getResources(const QList<QByteArray> &resourceFilter, const QByteArray &type);
56 {
57 return Akonadi2::storageLocation();
58 }
59 53
60 static QByteArray resourceName(const QByteArray &instanceIdentifier) 54public:
61 { 55 static QString storageLocation();
62 return Akonadi2::resourceName(instanceIdentifier); 56 static QByteArray resourceName(const QByteArray &instanceIdentifier);
63 }
64
65 static QList<QByteArray> getResources(const QList<QByteArray> &resourceFilter, const QByteArray &type)
66 {
67 //Return the global resource (signified by an empty name) for types that don't eblong to a specific resource
68 if (type == "akonadiresource") {
69 return QList<QByteArray>() << "";
70 }
71 QList<QByteArray> resources;
72 const auto configuredResources = ResourceConfig::getResources();
73 if (resourceFilter.isEmpty()) {
74 for (const auto &res : configuredResources) {
75 if (configuredResources.value(res) == type) {
76 resources << res;
77 }
78 }
79 } else {
80 for (const auto &res : resourceFilter) {
81 if (configuredResources.contains(res)) {
82 resources << res;
83 } else {
84 qWarning() << "Resource is not existing: " << res;
85 }
86 }
87 }
88 return resources;
89 }
90 57
91 /** 58 /**
92 * Asynchronusly load a dataset 59 * Asynchronusly load a dataset
@@ -192,47 +159,6 @@ public:
192 static void synchronize(const QByteArray &resourceIdentifier); 159 static void synchronize(const QByteArray &resourceIdentifier);
193}; 160};
194 161
195/**
196 * Configuration interface used in the client API.
197 *
198 * This interface provides convenience API for manipulating resources.
199 * This interface uses internally the same interface that is part of the regular Store API.
200 *
201 * Resources provide their configuration implementation by implementing a StoreFacade for the AkonadiResource type.
202 */
203class Configuration {
204public:
205 static QWidget *getConfigurationWidget(const QByteArray &resourceIdentifier)
206 {
207 //TODO here we want to implement the code to create a configuration widget from the QML config interface provided by the resource
208 return nullptr;
209 }
210
211 static ApplicationDomain::AkonadiResource::Ptr getConfiguration(const QByteArray &resource)
212 {
213 Query query;
214 query.resources << resource;
215 // auto result = Store::load<ApplicationDomain::AkonadiResource>(query);
216 //FIXME retrieve result and return it
217 return ApplicationDomain::AkonadiResource::Ptr::create();
218 }
219
220 static void setConfiguration(const ApplicationDomain::AkonadiResource &resource)
221 {
222 Store::modify<ApplicationDomain::AkonadiResource>(resource);
223 }
224
225 static void createResource(const ApplicationDomain::AkonadiResource &resource)
226 {
227 Store::create<ApplicationDomain::AkonadiResource>(resource);
228 }
229
230 static void removeResource(const QByteArray &resourceIdentifier)
231 {
232 ApplicationDomain::AkonadiResource resource(resourceIdentifier);
233 Store::remove<ApplicationDomain::AkonadiResource>(resource);
234 }
235};
236 162
237} 163}
238 164