summaryrefslogtreecommitdiffstats
path: root/framework/accounts
diff options
context:
space:
mode:
Diffstat (limited to 'framework/accounts')
-rw-r--r--framework/accounts/CMakeLists.txt1
-rw-r--r--framework/accounts/accountsplugin.cpp2
-rw-r--r--framework/accounts/maildircontroller.cpp55
-rw-r--r--framework/accounts/maildircontroller.h44
4 files changed, 102 insertions, 0 deletions
diff --git a/framework/accounts/CMakeLists.txt b/framework/accounts/CMakeLists.txt
index bccafd77..609b26d4 100644
--- a/framework/accounts/CMakeLists.txt
+++ b/framework/accounts/CMakeLists.txt
@@ -2,6 +2,7 @@ set(accountsplugin_SRCS
2 accountsplugin.cpp 2 accountsplugin.cpp
3 accountfactory.cpp 3 accountfactory.cpp
4 accountsmodel.cpp 4 accountsmodel.cpp
5 maildircontroller.cpp
5) 6)
6 7
7add_library(accountsplugin SHARED ${accountsplugin_SRCS}) 8add_library(accountsplugin SHARED ${accountsplugin_SRCS})
diff --git a/framework/accounts/accountsplugin.cpp b/framework/accounts/accountsplugin.cpp
index e980d5f3..51316b52 100644
--- a/framework/accounts/accountsplugin.cpp
+++ b/framework/accounts/accountsplugin.cpp
@@ -20,6 +20,7 @@
20 20
21#include "accountsmodel.h" 21#include "accountsmodel.h"
22#include "accountfactory.h" 22#include "accountfactory.h"
23#include "maildircontroller.h"
23 24
24#include <QtQml> 25#include <QtQml>
25 26
@@ -28,4 +29,5 @@ void AccountsPlugin::registerTypes (const char *uri)
28 Q_ASSERT(uri == QLatin1String("org.kube.framework.accounts")); 29 Q_ASSERT(uri == QLatin1String("org.kube.framework.accounts"));
29 qmlRegisterType<AccountFactory>(uri, 1, 0, "AccountFactory"); 30 qmlRegisterType<AccountFactory>(uri, 1, 0, "AccountFactory");
30 qmlRegisterType<AccountsModel>(uri, 1, 0, "AccountsModel"); 31 qmlRegisterType<AccountsModel>(uri, 1, 0, "AccountsModel");
32 qmlRegisterType<MaildirController>(uri, 1, 0, "MaildirController");
31} 33}
diff --git a/framework/accounts/maildircontroller.cpp b/framework/accounts/maildircontroller.cpp
new file mode 100644
index 00000000..daafccb6
--- /dev/null
+++ b/framework/accounts/maildircontroller.cpp
@@ -0,0 +1,55 @@
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 clear();
49}
50
51void MaildirController::modify() {
52}
53
54void MaildirController::remove() {
55}
diff --git a/framework/accounts/maildircontroller.h b/framework/accounts/maildircontroller.h
new file mode 100644
index 00000000..da2a3a62
--- /dev/null
+++ b/framework/accounts/maildircontroller.h
@@ -0,0 +1,44 @@
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#pragma once
20
21#include <QObject>
22#include <QString>
23#include <QUrl>
24#include <QByteArray>
25
26#include <domain/controller.h>
27
28class MaildirController : public Kube::Controller
29{
30 Q_OBJECT
31
32 //Interface properties
33 KUBE_CONTROLLER_PROPERTY(QString, Name, name)
34 KUBE_CONTROLLER_PROPERTY(QString, Icon, icon)
35 KUBE_CONTROLLER_PROPERTY(QUrl, Path, path)
36
37 //Actions
38 KUBE_CONTROLLER_ACTION(create)
39 KUBE_CONTROLLER_ACTION(modify)
40 KUBE_CONTROLLER_ACTION(remove)
41
42public:
43 explicit MaildirController();
44};