summaryrefslogtreecommitdiffstats
path: root/accounts/gmail
diff options
context:
space:
mode:
Diffstat (limited to 'accounts/gmail')
-rw-r--r--accounts/gmail/CMakeLists.txt19
-rw-r--r--accounts/gmail/gmailaccountplugin.cpp29
-rw-r--r--accounts/gmail/gmailaccountplugin.h31
-rw-r--r--accounts/gmail/gmailsettings.cpp55
-rw-r--r--accounts/gmail/gmailsettings.h33
-rw-r--r--accounts/gmail/metadata.json4
-rw-r--r--accounts/gmail/qml/AccountSettings.qml92
-rw-r--r--accounts/gmail/qml/Login.qml60
-rw-r--r--accounts/gmail/qmldir3
9 files changed, 326 insertions, 0 deletions
diff --git a/accounts/gmail/CMakeLists.txt b/accounts/gmail/CMakeLists.txt
new file mode 100644
index 00000000..f8baee04
--- /dev/null
+++ b/accounts/gmail/CMakeLists.txt
@@ -0,0 +1,19 @@
1project(kube-accounts-gmail)
2
3set(SRCS
4 gmailsettings.cpp
5 gmailaccountplugin.cpp
6)
7
8add_library(gmailaccountplugin SHARED ${SRCS})
9target_link_libraries(gmailaccountplugin
10 sink
11 frameworkplugin
12 Qt5::Core
13 Qt5::Quick
14 Qt5::Qml
15)
16
17install(TARGETS gmailaccountplugin DESTINATION ${QML_INSTALL_DIR}/org/kube/accounts/gmail)
18install(FILES metadata.json DESTINATION ${QML_INSTALL_DIR}/org/kube/accounts/gmail)
19install_qml_account(gmail)
diff --git a/accounts/gmail/gmailaccountplugin.cpp b/accounts/gmail/gmailaccountplugin.cpp
new file mode 100644
index 00000000..53218939
--- /dev/null
+++ b/accounts/gmail/gmailaccountplugin.cpp
@@ -0,0 +1,29 @@
1/*
2 Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19#include "gmailaccountplugin.h"
20
21#include "gmailsettings.h"
22
23#include <QtQml>
24
25void GmailAccountPlugin::registerTypes (const char *uri)
26{
27 Q_ASSERT(uri == QLatin1String("org.kube.accounts.gmail"));
28 qmlRegisterType<GmailSettings>(uri, 1, 0, "GmailSettings");
29}
diff --git a/accounts/gmail/gmailaccountplugin.h b/accounts/gmail/gmailaccountplugin.h
new file mode 100644
index 00000000..5876e393
--- /dev/null
+++ b/accounts/gmail/gmailaccountplugin.h
@@ -0,0 +1,31 @@
1/*
2 Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19#pragma once
20
21#include <QQmlEngine>
22#include <QQmlExtensionPlugin>
23
24class GmailAccountPlugin : public QQmlExtensionPlugin
25{
26 Q_OBJECT
27 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
28
29public:
30 virtual void registerTypes(const char *uri);
31};
diff --git a/accounts/gmail/gmailsettings.cpp b/accounts/gmail/gmailsettings.cpp
new file mode 100644
index 00000000..a50668b8
--- /dev/null
+++ b/accounts/gmail/gmailsettings.cpp
@@ -0,0 +1,55 @@
1/*
2 Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19#include "gmailsettings.h"
20
21GmailSettings::GmailSettings(QObject *parent)
22 : AccountSettings(parent)
23{
24}
25
26void GmailSettings::load()
27{
28 loadAccount();
29 loadImapResource();
30 loadMailtransportResource();
31 loadIdentity();
32}
33
34void GmailSettings::save()
35{
36 mImapServer = "imaps://imap.gmail.com:993";
37 mImapUsername = mEmailAddress;
38
39 mSmtpServer = "smtps://smtp.gmail.com:587";
40 mSmtpUsername = mEmailAddress;
41
42 saveAccount();
43 saveImapResource();
44 saveMailtransportResource();
45 saveIdentity();
46}
47
48void GmailSettings::remove()
49{
50 removeResource(mMailtransportIdentifier);
51 removeResource(mImapIdentifier);
52 removeIdentity();
53 removeAccount();
54}
55
diff --git a/accounts/gmail/gmailsettings.h b/accounts/gmail/gmailsettings.h
new file mode 100644
index 00000000..708cb94b
--- /dev/null
+++ b/accounts/gmail/gmailsettings.h
@@ -0,0 +1,33 @@
1/*
2 Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19#pragma once
20
21#include <domain/settings/accountsettings.h>
22
23class GmailSettings : public AccountSettings
24{
25 Q_OBJECT
26
27public:
28 GmailSettings(QObject *parent = 0);
29
30 Q_INVOKABLE virtual void load() Q_DECL_OVERRIDE;
31 Q_INVOKABLE virtual void save() Q_DECL_OVERRIDE;
32 Q_INVOKABLE virtual void remove() Q_DECL_OVERRIDE;
33};
diff --git a/accounts/gmail/metadata.json b/accounts/gmail/metadata.json
new file mode 100644
index 00000000..68c06971
--- /dev/null
+++ b/accounts/gmail/metadata.json
@@ -0,0 +1,4 @@
1{
2 "Name": "GMail",
3 "RequiresKeyring": true
4}
diff --git a/accounts/gmail/qml/AccountSettings.qml b/accounts/gmail/qml/AccountSettings.qml
new file mode 100644
index 00000000..d7df5eaf
--- /dev/null
+++ b/accounts/gmail/qml/AccountSettings.qml
@@ -0,0 +1,92 @@
1/*
2 Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net>
3 Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsys.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18*/
19
20import QtQuick 2.4
21import QtQuick.Layouts 1.1
22import org.kube.framework 1.0 as Kube
23import org.kube.accounts.gmail 1.0 as GmailAccount
24
25Item {
26
27 property string accountId
28 property string heading: qsTr("Connect your GMail account")
29 property string subheadline: qsTr("To let Kube access your account, fill in email address, username and give the account a title that will be displayed inside Kube.")
30 property bool valid: true
31 implicitHeight: grid.implicitHeight
32
33 GmailAccount.GmailSettings {
34 id: gmailSettings
35 accountIdentifier: accountId
36 accountType: "gmail"
37 }
38
39 function save(){
40 gmailSettings.save()
41 }
42
43 function remove(){
44 gmailSettings.remove()
45 }
46
47 GridLayout {
48 id: grid
49 anchors.fill: parent
50 columns: 2
51 columnSpacing: Kube.Units.largeSpacing
52 rowSpacing: Kube.Units.largeSpacing
53
54 Kube.Label {
55 text: "Please note that GMail requires you to configure your account to allow IMAP connections from Kube:
56<ol type=''>
57<li> See <a href='https://support.google.com/mail/answer/7126229'>https://support.google.com/mail/answer/7126229</a> to configure your account to allow IMAP connections.
58<li> Visit <a href='https://myaccount.google.com/lesssecureapps'>https://myaccount.google.com/lesssecureapps</a> and enable the setting to allow Kube to connect to your account."
59 Layout.alignment: Qt.AlignCenter
60 Layout.columnSpan: 2
61 textFormat: Text.StyledText
62 }
63
64 Kube.Label {
65 text: qsTr("Name")
66 Layout.alignment: Qt.AlignRight
67 }
68 Kube.TextField {
69 Layout.fillWidth: true
70 placeholderText: qsTr("Your name")
71 text: gmailSettings.userName
72 onTextChanged: {
73 gmailSettings.userName = text
74 }
75 }
76
77 Kube.Label {
78 text: qsTr("Email address")
79 Layout.alignment: Qt.AlignRight
80 }
81 Kube.TextField {
82 Layout.fillWidth: true
83
84 text: gmailSettings.emailAddress
85 onTextChanged: {
86 gmailSettings.emailAddress = text
87 gmailSettings.accountName = text
88 }
89 placeholderText: qsTr("Your email address")
90 }
91 }
92}
diff --git a/accounts/gmail/qml/Login.qml b/accounts/gmail/qml/Login.qml
new file mode 100644
index 00000000..bcab19be
--- /dev/null
+++ b/accounts/gmail/qml/Login.qml
@@ -0,0 +1,60 @@
1/*
2 Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net>
3 Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsys.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18*/
19
20import QtQuick 2.4
21import QtQuick.Layouts 1.1
22import org.kube.framework 1.0 as Kube
23import org.kube.accounts.gmail 1.0 as GmailAccount
24
25Item {
26 property alias accountId: settings.accountIdentifier
27 property string heading: qsTr("Login")
28 property string subheadline: settings.accountName
29 property bool valid: pwField.acceptableInput
30
31 GmailAccount.GmailSettings {
32 id: settings
33 accountType: "gmail"
34 }
35
36 function login(){
37 settings.login({accountSecret: pwField.text})
38 }
39
40 GridLayout {
41 anchors {
42 fill: parent
43 }
44 columns: 2
45 columnSpacing: Kube.Units.largeSpacing
46 rowSpacing: Kube.Units.largeSpacing
47
48 Kube.Label {
49 text: qsTr("Password")
50 Layout.alignment: Qt.AlignRight
51 }
52
53 Kube.PasswordField {
54 id: pwField
55 Layout.fillWidth: true
56 focus: true
57 placeholderText: qsTr("Password of your IMAP account")
58 }
59 }
60}
diff --git a/accounts/gmail/qmldir b/accounts/gmail/qmldir
new file mode 100644
index 00000000..78a9e5b7
--- /dev/null
+++ b/accounts/gmail/qmldir
@@ -0,0 +1,3 @@
1module org.kube.accounts.gmail
2
3plugin gmailaccountplugin