diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/dummyresource/CMakeLists.txt | 2 | ||||
-rw-r--r-- | examples/dummyresource/resourcefacade.cpp | 84 | ||||
-rw-r--r-- | examples/dummyresource/resourcefacade.h | 49 |
3 files changed, 1 insertions, 134 deletions
diff --git a/examples/dummyresource/CMakeLists.txt b/examples/dummyresource/CMakeLists.txt index e4b51dd..1e80f81 100644 --- a/examples/dummyresource/CMakeLists.txt +++ b/examples/dummyresource/CMakeLists.txt | |||
@@ -4,7 +4,7 @@ add_definitions(-DQT_PLUGIN) | |||
4 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) | 4 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) |
5 | 5 | ||
6 | 6 | ||
7 | add_library(${PROJECT_NAME} SHARED facade.cpp resourcefactory.cpp domainadaptor.cpp resourcefacade.cpp dummystore.cpp) | 7 | add_library(${PROJECT_NAME} SHARED facade.cpp resourcefactory.cpp domainadaptor.cpp dummystore.cpp) |
8 | generate_flatbuffers(${PROJECT_NAME} dummycalendar) | 8 | generate_flatbuffers(${PROJECT_NAME} dummycalendar) |
9 | qt5_use_modules(${PROJECT_NAME} Core Network) | 9 | qt5_use_modules(${PROJECT_NAME} Core Network) |
10 | target_link_libraries(${PROJECT_NAME} akonadi2common) | 10 | target_link_libraries(${PROJECT_NAME} akonadi2common) |
diff --git a/examples/dummyresource/resourcefacade.cpp b/examples/dummyresource/resourcefacade.cpp deleted file mode 100644 index af0ebe6..0000000 --- a/examples/dummyresource/resourcefacade.cpp +++ /dev/null | |||
@@ -1,84 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Christian Mollekopf <chrigi_1@fastmail.fm> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | |||
20 | #include "resourcefacade.h" | ||
21 | |||
22 | #include <QSettings> | ||
23 | #include <QStandardPaths> | ||
24 | |||
25 | DummyResourceConfigFacade::DummyResourceConfigFacade() | ||
26 | : Akonadi2::StoreFacade<Akonadi2::ApplicationDomain::AkonadiResource>() | ||
27 | { | ||
28 | |||
29 | } | ||
30 | |||
31 | DummyResourceConfigFacade::~DummyResourceConfigFacade() | ||
32 | { | ||
33 | |||
34 | } | ||
35 | |||
36 | QSharedPointer<QSettings> DummyResourceConfigFacade::getSettings() | ||
37 | { | ||
38 | //FIXME deal with resource instances | ||
39 | const QString instanceIdentifier = "dummyresource.instance1"; | ||
40 | //FIXME Use config location | ||
41 | return QSharedPointer<QSettings>::create(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/akonadi2/" + "org.kde." + instanceIdentifier + "/settings.ini", QSettings::IniFormat); | ||
42 | } | ||
43 | |||
44 | KAsync::Job<void> DummyResourceConfigFacade::create(const Akonadi2::ApplicationDomain::AkonadiResource &domainObject) | ||
45 | { | ||
46 | //TODO create resource instance | ||
47 | //This can be generalized in a base implementation | ||
48 | return KAsync::null<void>(); | ||
49 | } | ||
50 | |||
51 | KAsync::Job<void> DummyResourceConfigFacade::modify(const Akonadi2::ApplicationDomain::AkonadiResource &domainObject) | ||
52 | { | ||
53 | //modify configuration | ||
54 | //This part is likely resource specific, but could be partially generalized | ||
55 | return KAsync::start<void>([domainObject, this]() { | ||
56 | auto settings = getSettings(); | ||
57 | //TODO Write properties to file | ||
58 | }); | ||
59 | } | ||
60 | |||
61 | KAsync::Job<void> DummyResourceConfigFacade::remove(const Akonadi2::ApplicationDomain::AkonadiResource &domainObject) | ||
62 | { | ||
63 | //TODO remove resource instance | ||
64 | //This can be generalized in a base implementation | ||
65 | return KAsync::null<void>(); | ||
66 | } | ||
67 | |||
68 | KAsync::Job<void> DummyResourceConfigFacade::load(const Akonadi2::Query &query, Akonadi2::ResultProviderInterface<typename Akonadi2::ApplicationDomain::AkonadiResource::Ptr> &resultProvider) | ||
69 | { | ||
70 | //Read configuration and list all available instances. | ||
71 | //This includes runtime information about runing instances etc. | ||
72 | //Part of this is generic, and part is accessing the resource specific configuration. | ||
73 | //FIXME this currently does not support live queries (because we're not inheriting from GenericFacade) | ||
74 | //FIXME only read what was requested in the query? | ||
75 | return KAsync::start<void>([&resultProvider, this]() { | ||
76 | auto settings = getSettings(); | ||
77 | auto memoryAdaptor = QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create(); | ||
78 | //TODO copy settings to adaptor | ||
79 | // | ||
80 | //TODO use correct instance identifier | ||
81 | //TODO key == instance identifier ? | ||
82 | resultProvider.add(QSharedPointer<Akonadi2::ApplicationDomain::AkonadiResource>::create("org.kde.dummy.instance1", "org.kde.dummy.config", 0, memoryAdaptor)); | ||
83 | }); | ||
84 | } | ||
diff --git a/examples/dummyresource/resourcefacade.h b/examples/dummyresource/resourcefacade.h deleted file mode 100644 index 82e54fd..0000000 --- a/examples/dummyresource/resourcefacade.h +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Christian Mollekopf <chrigi_1@fastmail.fm> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | |||
20 | #pragma once | ||
21 | |||
22 | #include <Async/Async> | ||
23 | #include <common/domain/applicationdomaintype.h> | ||
24 | #include <common/resultprovider.h> | ||
25 | #include <common/facadeinterface.h> | ||
26 | |||
27 | namespace Akonadi2 { | ||
28 | class Query; | ||
29 | } | ||
30 | |||
31 | class QSettings; | ||
32 | |||
33 | class DummyResourceConfigFacade : public Akonadi2::StoreFacade<Akonadi2::ApplicationDomain::AkonadiResource> | ||
34 | { | ||
35 | public: | ||
36 | DummyResourceConfigFacade(); | ||
37 | ~DummyResourceConfigFacade(); | ||
38 | //Create an instance | ||
39 | KAsync::Job<void> create(const Akonadi2::ApplicationDomain::AkonadiResource &domainObject) Q_DECL_OVERRIDE; | ||
40 | //Modify configuration | ||
41 | KAsync::Job<void> modify(const Akonadi2::ApplicationDomain::AkonadiResource &domainObject) Q_DECL_OVERRIDE; | ||
42 | //Remove instance | ||
43 | KAsync::Job<void> remove(const Akonadi2::ApplicationDomain::AkonadiResource &domainObject) Q_DECL_OVERRIDE; | ||
44 | //Read configuration and available instances | ||
45 | KAsync::Job<void> load(const Akonadi2::Query &query, Akonadi2::ResultProviderInterface<typename Akonadi2::ApplicationDomain::AkonadiResource::Ptr> &resultProvider) Q_DECL_OVERRIDE; | ||
46 | |||
47 | private: | ||
48 | QSharedPointer<QSettings> getSettings(); | ||
49 | }; | ||