diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-02-22 15:56:21 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-02-22 15:57:44 +0100 |
commit | 5ca3a769c0b0c93cfcbf6134937b32eed52e2fc2 (patch) | |
tree | baae5147722bdef26a1a8dc99ff6a020a782bcc9 /accounts/gmail | |
parent | cb2b1a35e14031f15155243aee12fc862cb65ebf (diff) | |
download | kube-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.txt | 43 | ||||
-rw-r--r-- | accounts/gmail/gmailaccountplugin.cpp | 29 | ||||
-rw-r--r-- | accounts/gmail/gmailaccountplugin.h | 31 | ||||
-rw-r--r-- | accounts/gmail/gmailsettings.cpp | 58 | ||||
-rw-r--r-- | accounts/gmail/gmailsettings.h | 33 | ||||
-rw-r--r-- | accounts/gmail/package/contents/ui/GmailSettings.qml | 136 | ||||
-rw-r--r-- | accounts/gmail/package/metadata.desktop | 8 | ||||
-rw-r--r-- | accounts/gmail/qmldir | 3 |
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 @@ | |||
1 | project(kube-accounts-gmail) | ||
2 | |||
3 | cmake_minimum_required(VERSION 2.8.12) | ||
4 | |||
5 | include(CPack) | ||
6 | include(FeatureSummary) | ||
7 | find_package(PkgConfig) | ||
8 | |||
9 | ################# set KDE specific information ################# | ||
10 | |||
11 | find_package(ECM 0.0.8 REQUIRED NO_MODULE) | ||
12 | |||
13 | # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked | ||
14 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) | ||
15 | |||
16 | include(KDEInstallDirs) | ||
17 | include(KDECMakeSettings) | ||
18 | include(KDECompilerSettings) | ||
19 | |||
20 | find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui) | ||
21 | |||
22 | set (QT_MIN_VERSION "5.4.0") | ||
23 | find_package(Sink CONFIG REQUIRED) | ||
24 | find_package(KF5Async CONFIG REQUIRED) | ||
25 | find_package(KF5 REQUIRED COMPONENTS Package Mime) | ||
26 | |||
27 | include_directories(SYSTEM ${KDE_INSTALL_FULL_INCLUDEDIR}/KF5/) | ||
28 | #FIXME | ||
29 | include_directories(../../framework/) | ||
30 | |||
31 | set(SRCS | ||
32 | gmailsettings.cpp | ||
33 | gmailaccountplugin.cpp | ||
34 | ) | ||
35 | |||
36 | add_library(gmailaccountplugin SHARED ${SRCS}) | ||
37 | qt5_use_modules(gmailaccountplugin Core Quick Qml) | ||
38 | target_link_libraries(gmailaccountplugin sink settingsplugin mailplugin) | ||
39 | |||
40 | kpackage_install_package(package org.kube.accounts.gmail "genericqml") | ||
41 | |||
42 | install(TARGETS gmailaccountplugin DESTINATION ${QML_INSTALL_DIR}/org/kube/accounts/gmail) | ||
43 | install(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 | |||
25 | void 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 | |||
24 | class GmailAccountPlugin : public QQmlExtensionPlugin | ||
25 | { | ||
26 | Q_OBJECT | ||
27 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") | ||
28 | |||
29 | public: | ||
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 | |||
21 | GmailSettings::GmailSettings(QObject *parent) | ||
22 | : AccountSettings(parent) | ||
23 | { | ||
24 | } | ||
25 | |||
26 | void GmailSettings::load() | ||
27 | { | ||
28 | loadAccount(); | ||
29 | loadImapResource(); | ||
30 | loadMailtransportResource(); | ||
31 | loadIdentity(); | ||
32 | } | ||
33 | |||
34 | void 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 | |||
51 | void 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 | |||
23 | class GmailSettings : public AccountSettings | ||
24 | { | ||
25 | Q_OBJECT | ||
26 | |||
27 | public: | ||
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 | |||
20 | import QtQuick 2.4 | ||
21 | import QtQuick.Controls 1.4 as Controls | ||
22 | import QtQuick.Layouts 1.1 | ||
23 | |||
24 | import org.kde.kirigami 1.0 as Kirigami | ||
25 | |||
26 | import org.kube.framework.settings 1.0 as KubeSettings | ||
27 | import org.kube.accounts.gmail 1.0 as GmailAccount | ||
28 | |||
29 | Item { | ||
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] | ||
2 | Name=Kube GMail Accounts Plugin | ||
3 | X-KDE-PluginInfo-Name=org.kube.accounts.gmail | ||
4 | Exec=kpackagelauncherqml -a org.kube.accounts.gmail | ||
5 | X-Plasma-MainScript=ui/GmailSettings.qml | ||
6 | X-KDE-ServiceTypes=KPackage/GenericQML | ||
7 | Icon=folder | ||
8 | Type=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 @@ | |||
1 | module org.kube.accounts.gmail | ||
2 | |||
3 | plugin gmailaccountplugin | ||