diff options
Diffstat (limited to 'accounts/google')
-rw-r--r-- | accounts/google/CMakeLists.txt | 19 | ||||
-rw-r--r-- | accounts/google/googleaccountplugin.cpp | 29 | ||||
-rw-r--r-- | accounts/google/googleaccountplugin.h | 31 | ||||
-rw-r--r-- | accounts/google/googlesettings.cpp | 63 | ||||
-rw-r--r-- | accounts/google/googlesettings.h | 33 | ||||
-rw-r--r-- | accounts/google/metadata.json | 4 | ||||
-rw-r--r-- | accounts/google/qml/AccountSettings.qml | 92 | ||||
-rw-r--r-- | accounts/google/qml/Login.qml | 60 | ||||
-rw-r--r-- | accounts/google/qmldir | 3 |
9 files changed, 334 insertions, 0 deletions
diff --git a/accounts/google/CMakeLists.txt b/accounts/google/CMakeLists.txt new file mode 100644 index 00000000..3732190d --- /dev/null +++ b/accounts/google/CMakeLists.txt | |||
@@ -0,0 +1,19 @@ | |||
1 | project(kube-accounts-google) | ||
2 | |||
3 | set(SRCS | ||
4 | googlesettings.cpp | ||
5 | googleaccountplugin.cpp | ||
6 | ) | ||
7 | |||
8 | add_library(googleaccountplugin SHARED ${SRCS}) | ||
9 | target_link_libraries(googleaccountplugin | ||
10 | sink | ||
11 | frameworkplugin | ||
12 | Qt5::Core | ||
13 | Qt5::Quick | ||
14 | Qt5::Qml | ||
15 | ) | ||
16 | |||
17 | install(TARGETS googleaccountplugin DESTINATION ${QML_INSTALL_DIR}/org/kube/accounts/google) | ||
18 | install(FILES metadata.json DESTINATION ${QML_INSTALL_DIR}/org/kube/accounts/google) | ||
19 | install_qml_account(google) | ||
diff --git a/accounts/google/googleaccountplugin.cpp b/accounts/google/googleaccountplugin.cpp new file mode 100644 index 00000000..d419e585 --- /dev/null +++ b/accounts/google/googleaccountplugin.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 "googleaccountplugin.h" | ||
20 | |||
21 | #include "googlesettings.h" | ||
22 | |||
23 | #include <QtQml> | ||
24 | |||
25 | void GoogleAccountPlugin::registerTypes (const char *uri) | ||
26 | { | ||
27 | Q_ASSERT(uri == QLatin1String("org.kube.accounts.google")); | ||
28 | qmlRegisterType<GoogleSettings>(uri, 1, 0, "GoogleSettings"); | ||
29 | } | ||
diff --git a/accounts/google/googleaccountplugin.h b/accounts/google/googleaccountplugin.h new file mode 100644 index 00000000..d546c4f9 --- /dev/null +++ b/accounts/google/googleaccountplugin.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 GoogleAccountPlugin : 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/google/googlesettings.cpp b/accounts/google/googlesettings.cpp new file mode 100644 index 00000000..6c4c32de --- /dev/null +++ b/accounts/google/googlesettings.cpp | |||
@@ -0,0 +1,63 @@ | |||
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 "googlesettings.h" | ||
20 | |||
21 | GoogleSettings::GoogleSettings(QObject *parent) | ||
22 | : AccountSettings(parent) | ||
23 | { | ||
24 | } | ||
25 | |||
26 | void GoogleSettings::load() | ||
27 | { | ||
28 | loadAccount(); | ||
29 | loadImapResource(); | ||
30 | loadMailtransportResource(); | ||
31 | loadIdentity(); | ||
32 | } | ||
33 | |||
34 | void GoogleSettings::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 | mCardDavServer = QStringLiteral("https://www.googleapis.com/carddav/v1/principals/") + mEmailAddress + "/"; | ||
43 | mCardDavUsername = mEmailAddress; | ||
44 | |||
45 | mCalDavServer = QStringLiteral("https://www.google.com/calendar/dav/") + mEmailAddress + "/"; | ||
46 | mCalDavUsername = mEmailAddress; | ||
47 | |||
48 | saveAccount(); | ||
49 | saveImapResource(); | ||
50 | saveMailtransportResource(); | ||
51 | saveCardDavResource(); | ||
52 | saveCalDavResource(); | ||
53 | saveIdentity(); | ||
54 | } | ||
55 | |||
56 | void GoogleSettings::remove() | ||
57 | { | ||
58 | removeResource(mMailtransportIdentifier); | ||
59 | removeResource(mImapIdentifier); | ||
60 | removeIdentity(); | ||
61 | removeAccount(); | ||
62 | } | ||
63 | |||
diff --git a/accounts/google/googlesettings.h b/accounts/google/googlesettings.h new file mode 100644 index 00000000..ac7ae61f --- /dev/null +++ b/accounts/google/googlesettings.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 GoogleSettings : public AccountSettings | ||
24 | { | ||
25 | Q_OBJECT | ||
26 | |||
27 | public: | ||
28 | GoogleSettings(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/google/metadata.json b/accounts/google/metadata.json new file mode 100644 index 00000000..0ad786f1 --- /dev/null +++ b/accounts/google/metadata.json | |||
@@ -0,0 +1,4 @@ | |||
1 | { | ||
2 | "Name": "Google", | ||
3 | "RequiresKeyring": true | ||
4 | } | ||
diff --git a/accounts/google/qml/AccountSettings.qml b/accounts/google/qml/AccountSettings.qml new file mode 100644 index 00000000..73cdfbd7 --- /dev/null +++ b/accounts/google/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 | |||
20 | import QtQuick 2.4 | ||
21 | import QtQuick.Layouts 1.1 | ||
22 | import org.kube.framework 1.0 as Kube | ||
23 | import org.kube.accounts.google 1.0 as GoogleAccount | ||
24 | |||
25 | Item { | ||
26 | |||
27 | property string accountId | ||
28 | property string heading: qsTr("Connect your Google 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 | GoogleAccount.GoogleSettings { | ||
34 | id: googleSettings | ||
35 | accountIdentifier: accountId | ||
36 | accountType: "google" | ||
37 | } | ||
38 | |||
39 | function save(){ | ||
40 | googleSettings.save() | ||
41 | } | ||
42 | |||
43 | function remove(){ | ||
44 | googleSettings.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 Google 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: googleSettings.userName | ||
72 | onTextChanged: { | ||
73 | googleSettings.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: googleSettings.emailAddress | ||
85 | onTextChanged: { | ||
86 | googleSettings.emailAddress = text | ||
87 | googleSettings.accountName = text | ||
88 | } | ||
89 | placeholderText: qsTr("Your email address") | ||
90 | } | ||
91 | } | ||
92 | } | ||
diff --git a/accounts/google/qml/Login.qml b/accounts/google/qml/Login.qml new file mode 100644 index 00000000..0a44aa8c --- /dev/null +++ b/accounts/google/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 | |||
20 | import QtQuick 2.4 | ||
21 | import QtQuick.Layouts 1.1 | ||
22 | import org.kube.framework 1.0 as Kube | ||
23 | import org.kube.accounts.google 1.0 as GoogleAccount | ||
24 | |||
25 | Item { | ||
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 | GoogleAccount.GoogleSettings { | ||
32 | id: settings | ||
33 | accountType: "google" | ||
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/google/qmldir b/accounts/google/qmldir new file mode 100644 index 00000000..a4a06cb7 --- /dev/null +++ b/accounts/google/qmldir | |||
@@ -0,0 +1,3 @@ | |||
1 | module org.kube.accounts.google | ||
2 | |||
3 | plugin googleaccountplugin | ||