summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/accounts/AccountWizard.qml18
-rw-r--r--components/accounts/CreateGmail.qml192
-rw-r--r--framework/accounts/CMakeLists.txt1
-rw-r--r--framework/accounts/accountsplugin.cpp2
-rw-r--r--framework/accounts/gmailcontroller.cpp89
-rw-r--r--framework/accounts/gmailcontroller.h55
6 files changed, 357 insertions, 0 deletions
diff --git a/components/accounts/AccountWizard.qml b/components/accounts/AccountWizard.qml
index ccac252b..8cc90acb 100644
--- a/components/accounts/AccountWizard.qml
+++ b/components/accounts/AccountWizard.qml
@@ -66,6 +66,17 @@ Controls2.Popup {
66 66
67 Layout.fillWidth: true 67 Layout.fillWidth: true
68 68
69 text: "gmail account"
70
71 onClicked: {
72 stack.push(gmail)
73 }
74 }
75
76 Controls2.Button {
77
78 Layout.fillWidth: true
79
69 text: "imap account" 80 text: "imap account"
70 81
71 onClicked: { 82 onClicked: {
@@ -95,6 +106,13 @@ Controls2.Popup {
95 } 106 }
96 107
97 Component { 108 Component {
109 id: gmail
110
111 CreateGmail {
112 }
113 }
114
115 Component {
98 id: imap 116 id: imap
99 117
100 CreateImap { 118 CreateImap {
diff --git a/components/accounts/CreateGmail.qml b/components/accounts/CreateGmail.qml
new file mode 100644
index 00000000..ca432f1d
--- /dev/null
+++ b/components/accounts/CreateGmail.qml
@@ -0,0 +1,192 @@
1/*
2 * Copyright (C) 2016 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
19import QtQuick 2.7
20import QtQuick.Layouts 1.1
21import QtQuick.Controls 1.4 as Controls
22import QtQuick.Controls 2.0 as Controls2
23import org.kde.kirigami 1.0 as Kirigami
24
25import org.kube.framework.accounts 1.0 as KubeAccounts
26
27Item {
28
29 KubeAccounts.GmailController {
30 id: account
31 }
32
33 Controls.ToolButton {
34 iconName: "go-previous"
35
36 tooltip: "go back"
37
38 onClicked: {
39 stack.pop()
40 }
41 }
42
43 //Item to avoid anchors conflict with stack
44 Item {
45
46 anchors {
47 fill: parent
48 margins: Kirigami.Units.largeSpacing * 2
49 }
50
51 Kirigami.Heading {
52 id: heading
53 text: "Connect your Gmail account"
54
55 color: Kirigami.Theme.highlightColor
56 }
57
58 Kirigami.Label {
59 id: subHeadline
60
61 anchors {
62 left: heading.left
63 top: heading.bottom
64 }
65
66 width: parent.width
67
68 text: "To let Kube access your account, fill in email address, username, password and give the account a title that will be displayed inside Kube."
69
70 color: Kirigami.Theme.disabledTextColor
71
72 wrapMode: Text.Wrap
73 }
74
75 GridLayout {
76 anchors {
77 top:subHeadline.bottom
78 bottom: parent.bottom
79 left: parent.left
80 right: parent.right
81 topMargin: Kirigami.Units.largeSpacing * 2
82 }
83
84 columns: 2
85 columnSpacing: Kirigami.Units.largeSpacing
86 rowSpacing: Kirigami.Units.largeSpacing
87
88 Controls.Label {
89 text: "Title of Account"
90 Layout.alignment: Qt.AlignRight
91 }
92 Controls.TextField {
93 Layout.fillWidth: true
94
95 placeholderText: "E.g. \"Work\", \"Home\" that will be displayed in Kube as name"
96
97 text: account.name
98
99 onTextChanged: {
100 account.name = text
101 }
102 }
103
104 Controls.Label {
105 text: "Email address"
106 Layout.alignment: Qt.AlignRight
107 }
108
109 Controls.TextField {
110 Layout.fillWidth: true
111
112 text: account.emailAddress
113
114 onTextChanged: {
115 account.emailAddress = text
116 }
117
118 placeholderText: "Your email address"
119 }
120
121 Kirigami.Label {
122 text: "Password"
123 Layout.alignment: Qt.AlignRight
124 }
125
126 RowLayout {
127 Layout.fillWidth: true
128
129 Controls.TextField {
130 id: pwField
131 Layout.fillWidth: true
132
133 placeholderText: "Password of your email account"
134
135 text: account.password
136
137 onTextChanged: {
138 account.password = text
139 }
140
141 echoMode: TextInput.Password
142 }
143
144 Controls.CheckBox {
145 text: "Show Password"
146 onClicked: {
147 if(pwField.echoMode == TextInput.Password) {
148 pwField.echoMode = TextInput.Normal;
149 } else {
150 pwField.echoMode = TextInput.Password;
151 }
152 }
153 }
154 }
155
156 Item {
157 Layout.fillHeight: true
158 }
159
160 Kirigami.Label {
161 text: ""
162 }
163
164 Kirigami.Label {
165 text: ""
166 }
167
168 Item {
169 Layout.fillWidth: true
170
171 Controls.Button {
172 text: "Discard"
173
174 onClicked: {
175 popup.close()
176 }
177 }
178
179 Controls.Button {
180 anchors.right: parent.right
181
182 text: "Save"
183
184 onClicked: {
185 account.createAction.execute()
186 popup.close()
187 }
188 }
189 }
190 }
191 }
192}
diff --git a/framework/accounts/CMakeLists.txt b/framework/accounts/CMakeLists.txt
index 327d360e..06fcbf08 100644
--- a/framework/accounts/CMakeLists.txt
+++ b/framework/accounts/CMakeLists.txt
@@ -4,6 +4,7 @@ set(accountsplugin_SRCS
4 accountsmodel.cpp 4 accountsmodel.cpp
5 maildircontroller.cpp 5 maildircontroller.cpp
6 kolabnowcontroller.cpp 6 kolabnowcontroller.cpp
7 gmailcontroller.cpp
7) 8)
8 9
9add_library(accountsplugin SHARED ${accountsplugin_SRCS}) 10add_library(accountsplugin SHARED ${accountsplugin_SRCS})
diff --git a/framework/accounts/accountsplugin.cpp b/framework/accounts/accountsplugin.cpp
index 0d77376b..83ae6f0b 100644
--- a/framework/accounts/accountsplugin.cpp
+++ b/framework/accounts/accountsplugin.cpp
@@ -22,6 +22,7 @@
22#include "accountfactory.h" 22#include "accountfactory.h"
23#include "maildircontroller.h" 23#include "maildircontroller.h"
24#include "kolabnowcontroller.h" 24#include "kolabnowcontroller.h"
25#include "gmailcontroller.h"
25 26
26#include <QtQml> 27#include <QtQml>
27 28
@@ -32,4 +33,5 @@ void AccountsPlugin::registerTypes (const char *uri)
32 qmlRegisterType<AccountsModel>(uri, 1, 0, "AccountsModel"); 33 qmlRegisterType<AccountsModel>(uri, 1, 0, "AccountsModel");
33 qmlRegisterType<MaildirController>(uri, 1, 0, "MaildirController"); 34 qmlRegisterType<MaildirController>(uri, 1, 0, "MaildirController");
34 qmlRegisterType<KolabNowController>(uri, 1, 0, "KolabNowController"); 35 qmlRegisterType<KolabNowController>(uri, 1, 0, "KolabNowController");
36 qmlRegisterType<GmailController>(uri, 1, 0, "GmailController");
35} 37}
diff --git a/framework/accounts/gmailcontroller.cpp b/framework/accounts/gmailcontroller.cpp
new file mode 100644
index 00000000..bc644ae9
--- /dev/null
+++ b/framework/accounts/gmailcontroller.cpp
@@ -0,0 +1,89 @@
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 "gmailcontroller.h"
20
21#include <sink/store.h>
22
23using namespace Sink;
24using namespace Sink::ApplicationDomain;
25
26GmailController::GmailController() : Kube::Controller(),
27action_create{new Kube::ControllerAction{this, &GmailController::create}},
28action_modify{new Kube::ControllerAction{this, &GmailController::modify}},
29action_remove{new Kube::ControllerAction{this, &GmailController::remove}}
30{
31
32}
33
34void GmailController::create() {
35
36 //account
37 auto account = ApplicationDomainType::createEntity<SinkAccount>();
38 account.setProperty("type", "imap");
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.gmail.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.gmail.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 GmailController::modify() {
70 //TODO
71}
72
73void GmailController::remove() {
74 SinkAccount account(m_accountId);
75 Store::remove(account).exec();
76}
77
78void GmailController::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}
89
diff --git a/framework/accounts/gmailcontroller.h b/framework/accounts/gmailcontroller.h
new file mode 100644
index 00000000..2a5ead65
--- /dev/null
+++ b/framework/accounts/gmailcontroller.h
@@ -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#pragma once
20
21#include <QObject>
22#include <QString>
23#include <QByteArray>
24
25#include <domain/controller.h>
26
27class GmailController : 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 GmailController();
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};
55