From 88556fa0f4040792aacb2ad1af28b2f61b365448 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 23 Oct 2015 09:24:55 +0200 Subject: Made headers installable and install headers --- common/CMakeLists.txt | 15 ++++++ common/clientapi.cpp | 39 +++++++++++++++ common/clientapi.h | 86 +++------------------------------ common/domain/applicationdomaintype.cpp | 46 ++++++++++++++++++ common/domain/applicationdomaintype.h | 58 ++++++---------------- common/domain/event.h | 3 -- common/domainadaptor.h | 1 + common/facadefactory.h | 2 +- common/facadeinterface.h | 2 +- 9 files changed, 124 insertions(+), 128 deletions(-) (limited to 'common') diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 61019b3..b4a4703 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -1,4 +1,5 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) +include_directories(domain) project(akonadi2common) @@ -64,3 +65,17 @@ SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX) qt5_use_modules(${PROJECT_NAME} Network) target_link_libraries(${PROJECT_NAME} ${storage_LIBS} KF5::Async) install(TARGETS ${PROJECT_NAME} ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) + +install(FILES + clientapi.h + domain/applicationdomaintype.h + query.h + threadboundary.h + resultprovider.h + facadefactory.h + log.h + listmodelresult.h + bufferadaptor.h + facadeinterface.h + DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME} COMPONENT Devel +) diff --git a/common/clientapi.cpp b/common/clientapi.cpp index 5edab97..df48c3f 100644 --- a/common/clientapi.cpp +++ b/common/clientapi.cpp @@ -5,6 +5,7 @@ #include "resourcefacade.h" #include "log.h" #include "definitions.h" +#include "resourceconfig.h" #include #include @@ -31,6 +32,44 @@ namespace async namespace Akonadi2 { +QString Store::storageLocation() +{ + return Akonadi2::storageLocation(); +} + +QByteArray Store::resourceName(const QByteArray &instanceIdentifier) +{ + return Akonadi2::resourceName(instanceIdentifier); +} + +QList Store::getResources(const QList &resourceFilter, const QByteArray &type) +{ + //Return the global resource (signified by an empty name) for types that don't eblong to a specific resource + if (type == "akonadiresource") { + qWarning() << "Global resource"; + return QList() << ""; + } + QList resources; + const auto configuredResources = ResourceConfig::getResources(); + if (resourceFilter.isEmpty()) { + for (const auto &res : configuredResources) { + if (configuredResources.value(res) == type) { + resources << res; + } + } + } else { + for (const auto &res : resourceFilter) { + if (configuredResources.contains(res)) { + resources << res; + } else { + qWarning() << "Resource is not existing: " << res; + } + } + } + qWarning() << "Found resources: " << resources; + return resources; +} + void Store::shutdown(const QByteArray &identifier) { Trace() << "shutdown"; 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 @@ #include #include "query.h" -#include "threadboundary.h" #include "resultprovider.h" -#include "domain/applicationdomaintype.h" -#include "resourceconfig.h" +#include "applicationdomaintype.h" #include "facadefactory.h" #include "log.h" -#include "definitions.h" namespace async { //This should abstract if we execute from eventloop or in thread. @@ -51,42 +48,12 @@ using namespace async; * Store interface used in the client API. */ class Store { -public: - static QString storageLocation() - { - return Akonadi2::storageLocation(); - } +private: + static QList getResources(const QList &resourceFilter, const QByteArray &type); - static QByteArray resourceName(const QByteArray &instanceIdentifier) - { - return Akonadi2::resourceName(instanceIdentifier); - } - - static QList getResources(const QList &resourceFilter, const QByteArray &type) - { - //Return the global resource (signified by an empty name) for types that don't eblong to a specific resource - if (type == "akonadiresource") { - return QList() << ""; - } - QList resources; - const auto configuredResources = ResourceConfig::getResources(); - if (resourceFilter.isEmpty()) { - for (const auto &res : configuredResources) { - if (configuredResources.value(res) == type) { - resources << res; - } - } - } else { - for (const auto &res : resourceFilter) { - if (configuredResources.contains(res)) { - resources << res; - } else { - qWarning() << "Resource is not existing: " << res; - } - } - } - return resources; - } +public: + static QString storageLocation(); + static QByteArray resourceName(const QByteArray &instanceIdentifier); /** * Asynchronusly load a dataset @@ -192,47 +159,6 @@ public: static void synchronize(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) - { - Store::modify(resource); - } - - static void createResource(const ApplicationDomain::AkonadiResource &resource) - { - Store::create(resource); - } - - static void removeResource(const QByteArray &resourceIdentifier) - { - ApplicationDomain::AkonadiResource resource(resourceIdentifier); - Store::remove(resource); - } -}; } diff --git a/common/domain/applicationdomaintype.cpp b/common/domain/applicationdomaintype.cpp index 3cc075b..78a667e 100644 --- a/common/domain/applicationdomaintype.cpp +++ b/common/domain/applicationdomaintype.cpp @@ -18,10 +18,56 @@ * License along with this library. If not, see . */ #include "applicationdomaintype.h" +#include "../bufferadaptor.h" namespace Akonadi2 { namespace ApplicationDomain { +ApplicationDomainType::ApplicationDomainType() + :mAdaptor(new MemoryBufferAdaptor()) +{ + +} + +ApplicationDomainType::ApplicationDomainType(const QByteArray &resourceInstanceIdentifier) + :mAdaptor(new MemoryBufferAdaptor()), + mResourceInstanceIdentifier(resourceInstanceIdentifier) +{ + +} + +ApplicationDomainType::ApplicationDomainType(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier, qint64 revision, const QSharedPointer &adaptor) + : mAdaptor(adaptor), + mResourceInstanceIdentifier(resourceInstanceIdentifier), + mIdentifier(identifier), + mRevision(revision) +{ +} + +ApplicationDomainType::ApplicationDomainType(const ApplicationDomainType &other) +{ + *this = other; +} + +ApplicationDomainType& ApplicationDomainType::operator=(const ApplicationDomainType &other) +{ + mAdaptor = other.mAdaptor; + mChangeSet = other.mChangeSet; + mResourceInstanceIdentifier = other.mResourceInstanceIdentifier; + mIdentifier = other.mIdentifier; + mRevision = other.mRevision; + return *this; +} + +ApplicationDomainType::~ApplicationDomainType() {} + +QVariant ApplicationDomainType::getProperty(const QByteArray &key) const { return mAdaptor->getProperty(key); } +void ApplicationDomainType::setProperty(const QByteArray &key, const QVariant &value){ mChangeSet.insert(key, value); mAdaptor->setProperty(key, value); } +QByteArrayList ApplicationDomainType::changedProperties() const { return mChangeSet.keys(); } +qint64 ApplicationDomainType::revision() const { return mRevision; } +QByteArray ApplicationDomainType::resourceInstanceIdentifier() const { return mResourceInstanceIdentifier; } +QByteArray ApplicationDomainType::identifier() const { return mIdentifier; } + template<> QByteArray getTypeName() { diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index bd7ff65..137eb65 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h @@ -22,7 +22,7 @@ #include #include #include -#include "../bufferadaptor.h" +#include "bufferadaptor.h" namespace Akonadi2 { @@ -39,41 +39,11 @@ class ApplicationDomainType { public: typedef QSharedPointer Ptr; - ApplicationDomainType() - :mAdaptor(new MemoryBufferAdaptor()) - { - - } - - ApplicationDomainType(const QByteArray &resourceInstanceIdentifier) - :mAdaptor(new MemoryBufferAdaptor()), - mResourceInstanceIdentifier(resourceInstanceIdentifier) - { - - } - - ApplicationDomainType(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier, qint64 revision, const QSharedPointer &adaptor) - : mAdaptor(adaptor), - mResourceInstanceIdentifier(resourceInstanceIdentifier), - mIdentifier(identifier), - mRevision(revision) - { - } - - ApplicationDomainType(const ApplicationDomainType &other) - { - *this = other; - } - - ApplicationDomainType& operator=(const ApplicationDomainType &other) - { - mAdaptor = other.mAdaptor; - mChangeSet = other.mChangeSet; - mResourceInstanceIdentifier = other.mResourceInstanceIdentifier; - mIdentifier = other.mIdentifier; - mRevision = other.mRevision; - return *this; - } + ApplicationDomainType(); + ApplicationDomainType(const QByteArray &resourceInstanceIdentifier); + ApplicationDomainType(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier, qint64 revision, const QSharedPointer &adaptor); + ApplicationDomainType(const ApplicationDomainType &other); + ApplicationDomainType& operator=(const ApplicationDomainType &other); template static typename DomainType::Ptr getInMemoryRepresentation(const ApplicationDomainType &domainType) @@ -84,14 +54,14 @@ public: return QSharedPointer::create(domainType.mResourceInstanceIdentifier, QByteArray(domainType.mIdentifier.constData(), domainType.mIdentifier.size()), domainType.mRevision, memoryAdaptor); } - virtual ~ApplicationDomainType() {} + virtual ~ApplicationDomainType(); - virtual QVariant getProperty(const QByteArray &key) const { return mAdaptor->getProperty(key); } - virtual void setProperty(const QByteArray &key, const QVariant &value){ mChangeSet.insert(key, value); mAdaptor->setProperty(key, value); } - virtual QByteArrayList changedProperties() const { return mChangeSet.keys(); } - qint64 revision() const { return mRevision; } - QByteArray resourceInstanceIdentifier() const { return mResourceInstanceIdentifier; } - QByteArray identifier() const { return mIdentifier; } + virtual QVariant getProperty(const QByteArray &key) const; + virtual void setProperty(const QByteArray &key, const QVariant &value); + virtual QByteArrayList changedProperties() const; + qint64 revision() const; + QByteArray resourceInstanceIdentifier() const; + QByteArray identifier() const; private: QSharedPointer mAdaptor; @@ -186,3 +156,5 @@ class TypeImplementation; Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::ApplicationDomainType) Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr) +Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::Event) +Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::Event::Ptr) diff --git a/common/domain/event.h b/common/domain/event.h index 17a0ad4..f21cd34 100644 --- a/common/domain/event.h +++ b/common/domain/event.h @@ -63,6 +63,3 @@ public: } } - -Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::Event) -Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::Event::Ptr) diff --git a/common/domainadaptor.h b/common/domainadaptor.h index e881b9a..b14fbcd 100644 --- a/common/domainadaptor.h +++ b/common/domainadaptor.h @@ -26,6 +26,7 @@ #include "domain/applicationdomaintype.h" #include "domain/event.h" #include "domain/mail.h" +#include "bufferadaptor.h" #include "entity_generated.h" #include "metadata_generated.h" #include "entitybuffer.h" diff --git a/common/facadefactory.h b/common/facadefactory.h index 4a6a698..19d1f40 100644 --- a/common/facadefactory.h +++ b/common/facadefactory.h @@ -27,7 +27,7 @@ #include #include "facadeinterface.h" -#include "domain/applicationdomaintype.h" +#include "applicationdomaintype.h" #include "log.h" namespace Akonadi2 { diff --git a/common/facadeinterface.h b/common/facadeinterface.h index cd43fa1..3a38db8 100644 --- a/common/facadeinterface.h +++ b/common/facadeinterface.h @@ -23,7 +23,7 @@ #include #include #include -#include "domain/applicationdomaintype.h" +#include "applicationdomaintype.h" #include "resultprovider.h" namespace Akonadi2 { -- cgit v1.2.3