summaryrefslogtreecommitdiffstats
path: root/framework/accounts/maildircontroller.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-02-22 15:56:21 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-02-22 15:57:44 +0100
commit5ca3a769c0b0c93cfcbf6134937b32eed52e2fc2 (patch)
treebaae5147722bdef26a1a8dc99ff6a020a782bcc9 /framework/accounts/maildircontroller.cpp
parentcb2b1a35e14031f15155243aee12fc862cb65ebf (diff)
downloadkube-5ca3a769c0b0c93cfcbf6134937b32eed52e2fc2.tar.gz
kube-5ca3a769c0b0c93cfcbf6134937b32eed52e2fc2.zip
Removed Create/Edit*.qml and controllers, added gmail plugin
The current settings plugin could potentially be replaced by a proper controller, but what we have works so that's low priority.
Diffstat (limited to 'framework/accounts/maildircontroller.cpp')
-rw-r--r--framework/accounts/maildircontroller.cpp78
1 files changed, 0 insertions, 78 deletions
diff --git a/framework/accounts/maildircontroller.cpp b/framework/accounts/maildircontroller.cpp
deleted file mode 100644
index c2e15eb8..00000000
--- a/framework/accounts/maildircontroller.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
1/*
2 * Copyright (C) 2017 Michael Bohlender, <michael.bohlender@kdemail.net>
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 along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19#include "maildircontroller.h"
20
21#include <sink/store.h>
22
23using namespace Sink;
24using namespace Sink::ApplicationDomain;
25
26MaildirController::MaildirController() : Kube::Controller(),
27 action_create{new Kube::ControllerAction{this, &MaildirController::create}},
28 action_modify{new Kube::ControllerAction{this, &MaildirController::modify}},
29 action_remove{new Kube::ControllerAction{this, &MaildirController::remove}}
30{
31
32}
33
34void MaildirController::create() {
35 auto account = ApplicationDomainType::createEntity<SinkAccount>();
36 account.setProperty("type", "maildir");
37 account.setProperty("name", getName());
38 //account.setProperty("icon", getIcon());
39 Store::create(account).exec().waitForFinished();
40
41 auto resource = ApplicationDomainType::createEntity<SinkResource>();
42 resource.setResourceType("sink.maildir");
43 resource.setAccount(account);
44 resource.setProperty("path", getPath().path());
45
46 Store::create(resource).exec().waitForFinished();
47}
48
49void MaildirController::modify() {
50 SinkResource resource(m_resourceId);
51 resource.setProperty("path", getPath().path());
52 Store::modify(resource).exec();
53}
54
55void MaildirController::remove() {
56 SinkAccount account(m_accountId);
57 Store::remove(account).exec();
58
59 clear();
60}
61
62void MaildirController::load(const QByteArray &id) {
63
64 m_accountId = id;
65 clear();
66
67 Store::fetchOne<SinkAccount>(Query().filter(m_accountId))
68 .then([this](const SinkAccount &account) {
69 setIcon(account.getIcon());
70 setName(account.getName());
71 }).exec();
72
73 Store::fetchOne<SinkResource>(Query().filter<SinkResource::Account>(m_accountId).containsFilter<SinkResource::Capabilities>(ResourceCapabilities::Mail::storage))
74 .then([this](const SinkResource &resource) {
75 m_resourceId = resource.identifier();
76 setPath(resource.getProperty("path").toString());
77 }).exec();
78}