summaryrefslogtreecommitdiffstats
path: root/accounts/gmail
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-02-22 15:56:21 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-02-22 15:57:44 +0100
commit5ca3a769c0b0c93cfcbf6134937b32eed52e2fc2 (patch)
treebaae5147722bdef26a1a8dc99ff6a020a782bcc9 /accounts/gmail
parentcb2b1a35e14031f15155243aee12fc862cb65ebf (diff)
downloadkube-5ca3a769c0b0c93cfcbf6134937b32eed52e2fc2.tar.gz
kube-5ca3a769c0b0c93cfcbf6134937b32eed52e2fc2.zip
Removed Create/Edit*.qml and controllers, added gmail plugin
The current settings plugin could potentially be replaced by a proper controller, but what we have works so that's low priority.
Diffstat (limited to 'accounts/gmail')
-rw-r--r--accounts/gmail/CMakeLists.txt43
-rw-r--r--accounts/gmail/gmailaccountplugin.cpp29
-rw-r--r--accounts/gmail/gmailaccountplugin.h31
-rw-r--r--accounts/gmail/gmailsettings.cpp58
-rw-r--r--accounts/gmail/gmailsettings.h33
-rw-r--r--accounts/gmail/package/contents/ui/GmailSettings.qml136
-rw-r--r--accounts/gmail/package/metadata.desktop8
-rw-r--r--accounts/gmail/qmldir3
8 files changed, 341 insertions, 0 deletions
diff --git a/accounts/gmail/CMakeLists.txt b/accounts/gmail/CMakeLists.txt
new file mode 100644
index 00000000..f75cf388
--- /dev/null
+++ b/accounts/gmail/CMakeLists.txt
@@ -0,0 +1,43 @@
1project(kube-accounts-gmail)
2
3cmake_minimum_required(VERSION 2.8.12)
4
5include(CPack)
6include(FeatureSummary)
7find_package(PkgConfig)
8
9################# set KDE specific information #################
10
11find_package(ECM 0.0.8 REQUIRED NO_MODULE)
12
13# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
14set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
15
16include(KDEInstallDirs)
17include(KDECMakeSettings)
18include(KDECompilerSettings)
19
20find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui)
21
22set (QT_MIN_VERSION "5.4.0")
23find_package(Sink CONFIG REQUIRED)
24find_package(KF5Async CONFIG REQUIRED)
25find_package(KF5 REQUIRED COMPONENTS Package Mime)
26
27include_directories(SYSTEM ${KDE_INSTALL_FULL_INCLUDEDIR}/KF5/)
28#FIXME
29include_directories(../../framework/)
30
31set(SRCS
32 gmailsettings.cpp
33 gmailaccountplugin.cpp
34)
35
36add_library(gmailaccountplugin SHARED ${SRCS})
37qt5_use_modules(gmailaccountplugin Core Quick Qml)
38target_link_libraries(gmailaccountplugin sink settingsplugin mailplugin)
39
40kpackage_install_package(package org.kube.accounts.gmail "genericqml")
41
42install(TARGETS gmailaccountplugin DESTINATION ${QML_INSTALL_DIR}/org/kube/accounts/gmail)
43install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kube/accounts/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..428b164a
--- /dev/null
+++ b/accounts/gmail/gmailsettings.cpp
@@ -0,0 +1,58 @@
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 mUsername = mEmailAddress;
37 mImapServer = "imaps://imap.gmail.com:993";
38 mImapUsername = mEmailAddress;
39 // mImapPassword = mPassword;
40
41 mSmtpServer = "smtps://smtp.gmail.com:465";
42 mSmtpUsername = mEmailAddress;
43 mSmtpPassword = mImapPassword;
44
45 saveAccount();
46 saveImapResource();
47 saveMailtransportResource();
48 saveIdentity();
49}
50
51void GmailSettings::remove()
52{
53 removeResource(mMailtransportIdentifier);
54 removeResource(mImapIdentifier);
55 removeIdentity();
56 removeAccount();
57}
58
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/package/contents/ui/GmailSettings.qml b/accounts/gmail/package/contents/ui/GmailSettings.qml
new file mode 100644
index 00000000..33dafe8d
--- /dev/null
+++ b/accounts/gmail/package/contents/ui/GmailSettings.qml
@@ -0,0 +1,136 @@
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.Controls 1.4 as Controls
22import QtQuick.Layouts 1.1
23
24import org.kde.kirigami 1.0 as Kirigami
25
26import org.kube.framework.settings 1.0 as KubeSettings
27import org.kube.accounts.gmail 1.0 as GmailAccount
28
29Item {
30
31 property string accountId
32 property string heading: "Connect your GMail account"
33 property string subheadline: "To let Kube access your account, fill in email address, username, password and give the account a title that will be displayed inside Kube."
34
35 GmailAccount.GmailSettings {
36 id: gmailSettings
37 accountIdentifier: accountId
38 accountType: "gmail"
39 }
40
41 function save(){
42 gmailSettings.save()
43 }
44
45 function remove(){
46 gmailSettings.remove()
47 }
48
49 Item {
50 anchors {
51 fill: parent
52 }
53
54 GridLayout {
55 anchors {
56 fill: parent
57 }
58 columns: 2
59 columnSpacing: Kirigami.Units.largeSpacing
60 rowSpacing: Kirigami.Units.largeSpacing
61
62 Controls.Label {
63 text: "Title of Account"
64 Layout.alignment: Qt.AlignRight
65 }
66 Controls.TextField {
67 Layout.fillWidth: true
68 placeholderText: "E.g. \"Work\", \"Home\" that will be displayed in Kube as name"
69 text: gmailSettings.accountName
70 onTextChanged: {
71 gmailSettings.accountName = text
72 }
73 }
74
75 Controls.Label {
76 text: "Name"
77 Layout.alignment: Qt.AlignRight
78 }
79 Controls.TextField {
80 Layout.fillWidth: true
81 placeholderText: "Your name"
82 text: gmailSettings.userName
83 onTextChanged: {
84 gmailSettings.userName = text
85 }
86 }
87
88 Controls.Label {
89 text: "Email address"
90 Layout.alignment: Qt.AlignRight
91 }
92 Controls.TextField {
93 Layout.fillWidth: true
94
95 text: gmailSettings.emailAddress
96 onTextChanged: {
97 gmailSettings.emailAddress = text
98 }
99 placeholderText: "Your email address"
100 }
101
102 Controls.Label {
103 text: "Password"
104 Layout.alignment: Qt.AlignRight
105 }
106 RowLayout {
107 Layout.fillWidth: true
108
109 Controls.TextField {
110 id: pwField
111 Layout.fillWidth: true
112
113 placeholderText: "Password of your email account"
114 text: gmailSettings.imapPassword
115 onTextChanged: {
116 gmailSettings.imapPassword = text
117 gmailSettings.smtpPassword = text
118 }
119
120 echoMode: TextInput.Password
121 }
122
123 Controls.CheckBox {
124 text: "Show Password"
125 onClicked: {
126 if(pwField.echoMode == TextInput.Password) {
127 pwField.echoMode = TextInput.Normal;
128 } else {
129 pwField.echoMode = TextInput.Password;
130 }
131 }
132 }
133 }
134 }
135 }
136}
diff --git a/accounts/gmail/package/metadata.desktop b/accounts/gmail/package/metadata.desktop
new file mode 100644
index 00000000..e2b71ec9
--- /dev/null
+++ b/accounts/gmail/package/metadata.desktop
@@ -0,0 +1,8 @@
1[Desktop Entry]
2Name=Kube GMail Accounts Plugin
3X-KDE-PluginInfo-Name=org.kube.accounts.gmail
4Exec=kpackagelauncherqml -a org.kube.accounts.gmail
5X-Plasma-MainScript=ui/GmailSettings.qml
6X-KDE-ServiceTypes=KPackage/GenericQML
7Icon=folder
8Type=Service
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