diff options
Diffstat (limited to 'common/clientapi.h')
-rw-r--r-- | common/clientapi.h | 56 |
1 files changed, 56 insertions, 0 deletions
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 | */ | ||
303 | struct 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>(); | |||
309 | template<> | 320 | template<> |
310 | QByteArray getTypeName<Todo>(); | 321 | QByteArray getTypeName<Todo>(); |
311 | 322 | ||
323 | template<> | ||
324 | QByteArray getTypeName<AkonadiResource>(); | ||
325 | |||
312 | } | 326 | } |
313 | 327 | ||
314 | using namespace async; | 328 | using 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 | */ | ||
570 | class Configuration { | ||
571 | public: | ||
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 | ||