summaryrefslogtreecommitdiffstats
path: root/examples/dummyresource/resourcefacade.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-11-27 17:30:04 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-11-27 17:30:04 +0100
commit5b41b26a349967acf2197f9f9228526193fd826e (patch)
tree166452bcc0757564deefe233bf031d2ccb0564d2 /examples/dummyresource/resourcefacade.cpp
parent13af56e436f49df32d3b2f6f223cf1dec2eabaac (diff)
downloadsink-5b41b26a349967acf2197f9f9228526193fd826e.tar.gz
sink-5b41b26a349967acf2197f9f9228526193fd826e.zip
Introduced a QueryRunner object
The QueryRunner object lives for the duration of the query (so just for the initial query for non-live queries, and for the lifetime of the result model for live queries). It's supposed to handle all the threading internally and decouple the lifetime of the facade.
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}