From 7fc0070bc073aaa8702e43eb10d887203f10463e Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sun, 19 Apr 2015 14:05:23 +0200 Subject: 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. --- common/clientapi.cpp | 6 ++++++ common/clientapi.h | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) (limited to 'common') 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() return "todo"; } +template<> +QByteArray getTypeName() +{ + return "akonadiresource"; +} + } // namespace Domain void 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 @@ -294,6 +294,17 @@ class Mail : public ApplicationDomainType { class Folder : public ApplicationDomainType { }; +/** + * Represents an akonadi resource. + * + * This type is used for configuration of resources, + * and for creating and removing resource instances. + */ +struct AkonadiResource : public ApplicationDomainType { + typedef QSharedPointer Ptr; + using ApplicationDomainType::ApplicationDomainType; +}; + /** * All types need to be registered here an MUST return a different name. * @@ -309,6 +320,9 @@ QByteArray getTypeName(); template<> QByteArray getTypeName(); +template<> +QByteArray getTypeName(); + } using namespace async; @@ -545,5 +559,47 @@ public: static void shutdown(const QByteArray &resourceIdentifier); }; +/** + * Configuration interface used in the client API. + * + * This interface provides convenience API for manipulating resources. + * This interface uses internally the same interface that is part of the regular Store API. + * + * Resources provide their configuration implementation by implementing a StoreFacade for the AkonadiResource type. + */ +class Configuration { +public: + static QWidget *getConfigurationWidget(const QByteArray &resourceIdentifier) + { + //TODO here we want to implement the code to create a configuration widget from the QML config interface provided by the resource + return nullptr; + } + + static ApplicationDomain::AkonadiResource::Ptr getConfiguration(const QByteArray &resource) + { + Query query; + query.resources << resource; + // auto result = Store::load(query); + //FIXME retrieve result and return it + return ApplicationDomain::AkonadiResource::Ptr::create(); + } + + static void setConfiguration(const ApplicationDomain::AkonadiResource &resource, const QByteArray &resourceIdentifier) + { + Store::modify(resource, resourceIdentifier); + } + + static void createResource(const ApplicationDomain::AkonadiResource &resource, const QByteArray &resourceIdentifier) + { + Store::create(resource, resourceIdentifier); + } + + static void removeResource(const QByteArray &resourceIdentifier) + { + ApplicationDomain::AkonadiResource resource; + Store::remove(resource, resourceIdentifier); + } +}; + } -- cgit v1.2.3