summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/accounts/CreateKolabNow.qml20
-rw-r--r--framework/accounts/CMakeLists.txt1
-rw-r--r--framework/accounts/accountsplugin.cpp2
-rw-r--r--framework/accounts/kolabnowcontroller.cpp88
-rw-r--r--framework/accounts/kolabnowcontroller.h54
5 files changed, 165 insertions, 0 deletions
diff --git a/components/accounts/CreateKolabNow.qml b/components/accounts/CreateKolabNow.qml
index e86f4ec9..c362bef6 100644
--- a/components/accounts/CreateKolabNow.qml
+++ b/components/accounts/CreateKolabNow.qml
@@ -22,8 +22,14 @@ import QtQuick.Controls 1.4 as Controls
22import QtQuick.Controls 2.0 as Controls2 22import QtQuick.Controls 2.0 as Controls2
23import org.kde.kirigami 1.0 as Kirigami 23import org.kde.kirigami 1.0 as Kirigami
24 24
25import org.kube.framework.accounts 1.0 as KubeAccounts
26
25Item { 27Item {
26 28
29 KubeAccounts.KolabNowController {
30 id: account
31 }
32
27 Controls.ToolButton { 33 Controls.ToolButton {
28 iconName: "go-previous" 34 iconName: "go-previous"
29 35
@@ -97,6 +103,12 @@ Item {
97 Controls.TextField { 103 Controls.TextField {
98 Layout.fillWidth: true 104 Layout.fillWidth: true
99 105
106 text: account.emailAddress
107
108 onTextChanged: {
109 account.emailAddress = text
110 }
111
100 placeholderText: "Your email address" 112 placeholderText: "Your email address"
101 } 113 }
102 114
@@ -113,6 +125,13 @@ Item {
113 Layout.fillWidth: true 125 Layout.fillWidth: true
114 126
115 placeholderText: "Password of your email account" 127 placeholderText: "Password of your email account"
128
129 text: account.password
130
131 onTextChanged: {
132 account.password = text
133 }
134
116 echoMode: TextInput.Password 135 echoMode: TextInput.Password
117 } 136 }
118 137
@@ -157,6 +176,7 @@ Item {
157 text: "Save" 176 text: "Save"
158 177
159 onClicked: { 178 onClicked: {
179 account.createAction.execute()
160 popup.close() 180 popup.close()
161 } 181 }
162 } 182 }
diff --git a/framework/accounts/CMakeLists.txt b/framework/accounts/CMakeLists.txt
index 609b26d4..327d360e 100644
--- a/framework/accounts/CMakeLists.txt
+++ b/framework/accounts/CMakeLists.txt
@@ -3,6 +3,7 @@ set(accountsplugin_SRCS
3 accountfactory.cpp 3 accountfactory.cpp
4 accountsmodel.cpp 4 accountsmodel.cpp
5 maildircontroller.cpp 5 maildircontroller.cpp
6 kolabnowcontroller.cpp
6) 7)
7 8
8add_library(accountsplugin SHARED ${accountsplugin_SRCS}) 9add_library(accountsplugin SHARED ${accountsplugin_SRCS})
diff --git a/framework/accounts/accountsplugin.cpp b/framework/accounts/accountsplugin.cpp
index 51316b52..0d77376b 100644
--- a/framework/accounts/accountsplugin.cpp
+++ b/framework/accounts/accountsplugin.cpp
@@ -21,6 +21,7 @@
21#include "accountsmodel.h" 21#include "accountsmodel.h"
22#include "accountfactory.h" 22#include "accountfactory.h"
23#include "maildircontroller.h" 23#include "maildircontroller.h"
24#include "kolabnowcontroller.h"
24 25
25#include <QtQml> 26#include <QtQml>
26 27
@@ -30,4 +31,5 @@ void AccountsPlugin::registerTypes (const char *uri)
30 qmlRegisterType<AccountFactory>(uri, 1, 0, "AccountFactory"); 31 qmlRegisterType<AccountFactory>(uri, 1, 0, "AccountFactory");
31 qmlRegisterType<AccountsModel>(uri, 1, 0, "AccountsModel"); 32 qmlRegisterType<AccountsModel>(uri, 1, 0, "AccountsModel");
32 qmlRegisterType<MaildirController>(uri, 1, 0, "MaildirController"); 33 qmlRegisterType<MaildirController>(uri, 1, 0, "MaildirController");
34 qmlRegisterType<KolabNowController>(uri, 1, 0, "KolabNowController");
33} 35}
diff --git a/framework/accounts/kolabnowcontroller.cpp b/framework/accounts/kolabnowcontroller.cpp
new file mode 100644
index 00000000..94ca2e01
--- /dev/null
+++ b/framework/accounts/kolabnowcontroller.cpp
@@ -0,0 +1,88 @@
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 "kolabnowcontroller.h"
20
21#include <sink/store.h>
22
23using namespace Sink;
24using namespace Sink::ApplicationDomain;
25
26KolabNowController::KolabNowController() : Kube::Controller(),
27action_create{new Kube::ControllerAction{this, &KolabNowController::create}},
28action_modify{new Kube::ControllerAction{this, &KolabNowController::modify}},
29action_remove{new Kube::ControllerAction{this, &KolabNowController::remove}}
30{
31
32}
33
34void KolabNowController::create() {
35
36 //account
37 auto account = ApplicationDomainType::createEntity<SinkAccount>();
38 account.setProperty("type", "kolabnow");
39 account.setProperty("name", getName());
40 Store::create(account).exec().waitForFinished();
41
42 //imap
43 auto resource = ApplicationDomainType::createEntity<SinkResource>();
44 resource.setResourceType("sink.imap");
45 resource.setAccount(account);
46 resource.setProperty("server","imaps://imap.kolabnow.com:993");
47 resource.setProperty("username", getEmailAddress());
48 resource.setProperty("password", getPassword());
49 Store::create(resource).exec().waitForFinished();
50
51 //smtp
52 resource = ApplicationDomainType::createEntity<SinkResource>();
53 resource.setResourceType("sink.smtp");
54 resource.setAccount(account);
55 resource.setProperty("server", "smtps://smtp.kolabnow.com:465");
56 resource.setProperty("username", getEmailAddress());
57 resource.setProperty("password", getPassword());
58 Store::create(resource).exec().waitForFinished();
59
60 //identity
61 auto identity = ApplicationDomainType::createEntity<Identity>();
62 m_identityId = identity.identifier();
63 identity.setAccount(account);
64 identity.setName(getIdentityName());
65 identity.setAddress(getEmailAddress());
66 Store::create(identity).exec();
67}
68
69void KolabNowController::modify() {
70 //TODO
71}
72
73void KolabNowController::remove() {
74 SinkAccount account(m_accountId);
75 Store::remove(account).exec();
76}
77
78void KolabNowController::load(const QByteArray &id) {
79
80 m_accountId = id;
81
82 Store::fetchOne<SinkAccount>(Query().filter(m_accountId))
83 .syncThen<void, SinkAccount>([this](const SinkAccount &account) {
84 setName(account.getName());
85 }).exec();
86
87 //TODO
88}
diff --git a/framework/accounts/kolabnowcontroller.h b/framework/accounts/kolabnowcontroller.h
new file mode 100644
index 00000000..85918800
--- /dev/null
+++ b/framework/accounts/kolabnowcontroller.h
@@ -0,0 +1,54 @@
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 <QByteArray>
24
25#include <domain/controller.h>
26
27class KolabNowController : public Kube::Controller
28{
29 Q_OBJECT
30
31 //Interface properties
32 KUBE_CONTROLLER_PROPERTY(QString, Name, name)
33
34 KUBE_CONTROLLER_PROPERTY(QString, EmailAddress, emailAddress)
35 KUBE_CONTROLLER_PROPERTY(QString, Password, password)
36 KUBE_CONTROLLER_PROPERTY(QString, IdentityName, identityName)
37
38 //Actions
39 KUBE_CONTROLLER_ACTION(create)
40 KUBE_CONTROLLER_ACTION(modify)
41 KUBE_CONTROLLER_ACTION(remove)
42
43public:
44 explicit KolabNowController();
45
46public slots:
47 void load(const QByteArray &id);
48
49private:
50 QByteArray m_accountId;
51 QByteArray m_smtpId;
52 QByteArray m_imapId;
53 QByteArray m_identityId;
54};