summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-04-19 14:05:23 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-04-19 14:05:23 +0200
commit7fc0070bc073aaa8702e43eb10d887203f10463e (patch)
tree1ab2cd899d98c89372a8b398870999bbeac824b3
parent3d7522b83f2c3f87116244bd064a751306a5411d (diff)
downloadsink-7fc0070bc073aaa8702e43eb10d887203f10463e.tar.gz
sink-7fc0070bc073aaa8702e43eb10d887203f10463e.zip
Stub for akonadi configuration.
Instead of dealing with dedicated configuration facades, we'll integrate that directly into the domain interface. That way it should be rather natural for applications to i.e. query for available resources, and then configure them in the same way some other domain object would be modified.
-rw-r--r--common/clientapi.cpp6
-rw-r--r--common/clientapi.h56
2 files changed, 62 insertions, 0 deletions
diff --git a/common/clientapi.cpp b/common/clientapi.cpp
index 48de1b0..c6f5582 100644
--- a/common/clientapi.cpp
+++ b/common/clientapi.cpp
@@ -29,6 +29,12 @@ QByteArray getTypeName<Todo>()
29 return "todo"; 29 return "todo";
30} 30}
31 31
32template<>
33QByteArray getTypeName<AkonadiResource>()
34{
35 return "akonadiresource";
36}
37
32} // namespace Domain 38} // namespace Domain
33 39
34void Store::shutdown(const QByteArray &identifier) 40void Store::shutdown(const QByteArray &identifier)
diff --git a/common/clientapi.h b/common/clientapi.h
index 75a4d24..af8a15e 100644
--- a/common/clientapi.h
+++ b/common/clientapi.h
@@ -295,6 +295,17 @@ class Folder : public ApplicationDomainType {
295}; 295};
296 296
297/** 297/**
298 * Represents an akonadi resource.
299 *
300 * This type is used for configuration of resources,
301 * and for creating and removing resource instances.
302 */
303struct AkonadiResource : public ApplicationDomainType {
304 typedef QSharedPointer<AkonadiResource> Ptr;
305 using ApplicationDomainType::ApplicationDomainType;
306};
307
308/**
298 * All types need to be registered here an MUST return a different name. 309 * All types need to be registered here an MUST return a different name.
299 * 310 *
300 * Do not store these types to disk, they may change over time. 311 * Do not store these types to disk, they may change over time.
@@ -309,6 +320,9 @@ QByteArray getTypeName<Event>();
309template<> 320template<>
310QByteArray getTypeName<Todo>(); 321QByteArray getTypeName<Todo>();
311 322
323template<>
324QByteArray getTypeName<AkonadiResource>();
325
312} 326}
313 327
314using namespace async; 328using namespace async;
@@ -545,5 +559,47 @@ public:
545 static void shutdown(const QByteArray &resourceIdentifier); 559 static void shutdown(const QByteArray &resourceIdentifier);
546}; 560};
547 561
562/**
563 * Configuration interface used in the client API.
564 *
565 * This interface provides convenience API for manipulating resources.
566 * This interface uses internally the same interface that is part of the regular Store API.
567 *
568 * Resources provide their configuration implementation by implementing a StoreFacade for the AkonadiResource type.
569 */
570class Configuration {
571public:
572 static QWidget *getConfigurationWidget(const QByteArray &resourceIdentifier)
573 {
574 //TODO here we want to implement the code to create a configuration widget from the QML config interface provided by the resource
575 return nullptr;
576 }
577
578 static ApplicationDomain::AkonadiResource::Ptr getConfiguration(const QByteArray &resource)
579 {
580 Query query;
581 query.resources << resource;
582 // auto result = Store::load<ApplicationDomain::AkonadiResource>(query);
583 //FIXME retrieve result and return it
584 return ApplicationDomain::AkonadiResource::Ptr::create();
585 }
586
587 static void setConfiguration(const ApplicationDomain::AkonadiResource &resource, const QByteArray &resourceIdentifier)
588 {
589 Store::modify<ApplicationDomain::AkonadiResource>(resource, resourceIdentifier);
590 }
591
592 static void createResource(const ApplicationDomain::AkonadiResource &resource, const QByteArray &resourceIdentifier)
593 {
594 Store::create<ApplicationDomain::AkonadiResource>(resource, resourceIdentifier);
595 }
596
597 static void removeResource(const QByteArray &resourceIdentifier)
598 {
599 ApplicationDomain::AkonadiResource resource;
600 Store::remove<ApplicationDomain::AkonadiResource>(resource, resourceIdentifier);
601 }
602};
603
548} 604}
549 605