summaryrefslogtreecommitdiffstats
path: root/examples/dummyresource/resourcefacade.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/dummyresource/resourcefacade.cpp')
-rw-r--r--examples/dummyresource/resourcefacade.cpp84
1 files changed, 0 insertions, 84 deletions
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
25DummyResourceConfigFacade::DummyResourceConfigFacade()
26 : Akonadi2::StoreFacade<Akonadi2::ApplicationDomain::AkonadiResource>()
27{
28
29}
30
31DummyResourceConfigFacade::~DummyResourceConfigFacade()
32{
33
34}
35
36QSharedPointer<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
44KAsync::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
51KAsync::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
61KAsync::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
68KAsync::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}