summaryrefslogtreecommitdiffstats
path: root/framework
diff options
context:
space:
mode:
Diffstat (limited to 'framework')
-rw-r--r--framework/accounts/maildircontroller.cpp59
-rw-r--r--framework/accounts/maildircontroller.h7
2 files changed, 48 insertions, 18 deletions
diff --git a/framework/accounts/maildircontroller.cpp b/framework/accounts/maildircontroller.cpp
index daafccb6..481d43d8 100644
--- a/framework/accounts/maildircontroller.cpp
+++ b/framework/accounts/maildircontroller.cpp
@@ -1,20 +1,20 @@
1/* 1/*
2 Copyright (C) 2017 Michael Bohlender, <michael.bohlender@kdemail.net> 2 * Copyright (C) 2017 Michael Bohlender, <michael.bohlender@kdemail.net>
3 3 *
4 This program is free software; you can redistribute it and/or modify 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 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 6 * the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version. 7 * (at your option) any later version.
8 8 *
9 This program is distributed in the hope that it will be useful, 9 * This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 * GNU General Public License for more details.
13 13 *
14 You should have received a copy of the GNU General Public License along 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., 15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17*/ 17 */
18 18
19#include "maildircontroller.h" 19#include "maildircontroller.h"
20 20
@@ -44,12 +44,35 @@ void MaildirController::create() {
44 resource.setProperty("path", getPath().path()); 44 resource.setProperty("path", getPath().path());
45 45
46 Store::create(resource).exec().waitForFinished(); 46 Store::create(resource).exec().waitForFinished();
47
48 clear();
49} 47}
50 48
51void MaildirController::modify() { 49void MaildirController::modify() {
50 SinkResource resource(m_resourceId);
51 resource.setProperty("path", getPath().path());
52 Store::modify(resource).exec();
52} 53}
53 54
54void MaildirController::remove() { 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 .syncThen<void, SinkAccount>([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 .syncThen<void, SinkResource>([this](const SinkResource &resource) {
75 m_resourceId = resource.identifier();
76 setPath(resource.getProperty("path").toString());
77 }).exec();
55} 78}
diff --git a/framework/accounts/maildircontroller.h b/framework/accounts/maildircontroller.h
index da2a3a62..5965f118 100644
--- a/framework/accounts/maildircontroller.h
+++ b/framework/accounts/maildircontroller.h
@@ -41,4 +41,11 @@ class MaildirController : public Kube::Controller
41 41
42public: 42public:
43 explicit MaildirController(); 43 explicit MaildirController();
44
45public slots:
46 void load(const QByteArray &id);
47
48private:
49 QByteArray m_accountId;
50 QByteArray m_resourceId;
44}; 51};