summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2018-08-18 10:55:08 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-08-18 10:55:08 +0200
commite2f86e32a295cddacc6053936933150d1e7c665b (patch)
tree35467b1419afa2253d354f3e564f5eca82b16aee
parent108913be58ecb014ab575247f3adc9776feafa59 (diff)
downloadkube-e2f86e32a295cddacc6053936933150d1e7c665b.tar.gz
kube-e2f86e32a295cddacc6053936933150d1e7c665b.zip
A generic account.
This is intended to eventually replace the protocol specific accounts. The account is used to group together several protocols to one logical service, and thus it makes sense to set it up as one.
-rw-r--r--CMakeLists.txt2
-rw-r--r--accounts/CMakeLists.txt1
-rw-r--r--accounts/generic/CMakeLists.txt23
-rw-r--r--accounts/generic/accountplugin.cpp29
-rw-r--r--accounts/generic/accountplugin.h31
-rw-r--r--accounts/generic/qml/AccountSettings.qml157
-rw-r--r--accounts/generic/qml/Login.qml60
-rw-r--r--accounts/generic/qmldir3
-rw-r--r--accounts/generic/settings.cpp55
-rw-r--r--accounts/generic/settings.h33
-rw-r--r--accounts/kolabnow/kolabnowsettings.cpp1
11 files changed, 394 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2f3fcb3b..d07269d7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,7 +13,7 @@ cmake_policy(SET CMP0063 NEW)
13option(EXPERIMENTAL_VIEWS "Install experimental views" OFF) 13option(EXPERIMENTAL_VIEWS "Install experimental views" OFF)
14#Do not enable this unless you actually distribute a custom extension. 14#Do not enable this unless you actually distribute a custom extension.
15option(ENABLE_EXTENSION "Enable custom kube extensions" OFF) 15option(ENABLE_EXTENSION "Enable custom kube extensions" OFF)
16set(AVAILABLE_ACCOUNT_PLUGINS "kolabnow" "imap" "maildir" "gmail" CACHE STRING "List of enabled account plugins (provide as semicolon separated string)" ) 16set(AVAILABLE_ACCOUNT_PLUGINS "kolabnow" "imap" "maildir" "gmail" "generic" CACHE STRING "List of enabled account plugins (provide as semicolon separated string)" )
17 17
18include(CPack) 18include(CPack)
19include(FeatureSummary) 19include(FeatureSummary)
diff --git a/accounts/CMakeLists.txt b/accounts/CMakeLists.txt
index bf116942..76a11c54 100644
--- a/accounts/CMakeLists.txt
+++ b/accounts/CMakeLists.txt
@@ -13,3 +13,4 @@ add_subdirectory(maildir)
13add_subdirectory(imap) 13add_subdirectory(imap)
14add_subdirectory(kolabnow) 14add_subdirectory(kolabnow)
15add_subdirectory(gmail) 15add_subdirectory(gmail)
16add_subdirectory(generic)
diff --git a/accounts/generic/CMakeLists.txt b/accounts/generic/CMakeLists.txt
new file mode 100644
index 00000000..f609c2e1
--- /dev/null
+++ b/accounts/generic/CMakeLists.txt
@@ -0,0 +1,23 @@
1project(kube-accounts-generic)
2
3find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Core Quick Qml)
4
5find_package(Sink CONFIG REQUIRED)
6find_package(KAsync CONFIG REQUIRED)
7
8set(SRCS
9 settings.cpp
10 accountplugin.cpp
11)
12
13add_library(genericaccountplugin SHARED ${SRCS})
14target_link_libraries(genericaccountplugin
15 sink
16 frameworkplugin
17 Qt5::Core
18 Qt5::Quick
19 Qt5::Qml
20)
21
22install(TARGETS genericaccountplugin DESTINATION ${QML_INSTALL_DIR}/org/kube/accounts/generic)
23install_qml_account(generic)
diff --git a/accounts/generic/accountplugin.cpp b/accounts/generic/accountplugin.cpp
new file mode 100644
index 00000000..ef1d0af7
--- /dev/null
+++ b/accounts/generic/accountplugin.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 "accountplugin.h"
20
21#include "settings.h"
22
23#include <QtQml>
24
25void AccountPlugin::registerTypes (const char *uri)
26{
27 Q_ASSERT(uri == QLatin1String("org.kube.accounts.generic"));
28 qmlRegisterType<Settings>(uri, 1, 0, "Settings");
29}
diff --git a/accounts/generic/accountplugin.h b/accounts/generic/accountplugin.h
new file mode 100644
index 00000000..9b1bb931
--- /dev/null
+++ b/accounts/generic/accountplugin.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 AccountPlugin : 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/generic/qml/AccountSettings.qml b/accounts/generic/qml/AccountSettings.qml
new file mode 100644
index 00000000..c75a526c
--- /dev/null
+++ b/accounts/generic/qml/AccountSettings.qml
@@ -0,0 +1,157 @@
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.generic 1.0 as GenericAccount
24
25Item {
26
27 property string accountId
28 property string heading: qsTr("Connect your account")
29 property string subheadline: qsTr("To let Kube access your account, fill in email address, username and the relevant server addresses. For information about the server details, please contact your email provider.")
30 property bool valid: true
31 implicitHeight: grid.implicitHeight
32
33 GenericAccount.Settings {
34 id: settings
35 accountIdentifier: accountId
36 accountType: "generic"
37 }
38
39 function save(){
40 settings.save()
41 }
42
43 function remove(){
44 settings.remove()
45 }
46 GridLayout {
47 id: grid
48 anchors.fill: parent
49 columns: 2
50 columnSpacing: Kube.Units.largeSpacing
51 rowSpacing: Kube.Units.largeSpacing
52
53 Kube.Label {
54 text: qsTr("Name")
55 Layout.alignment: Qt.AlignRight
56 }
57 Kube.RequiredTextField {
58 Layout.fillWidth: true
59 placeholderText: qsTr("Your name")
60 text: settings.userName
61 onTextChanged: {
62 settings.userName = text
63 }
64 }
65
66 Kube.Label {
67 text: qsTr("Email address")
68 Layout.alignment: Qt.AlignRight
69 }
70 Kube.RequiredTextField {
71 Layout.fillWidth: true
72
73 text: settings.emailAddress
74 onTextChanged: {
75 settings.emailAddress = text
76 settings.accountName = text
77 }
78 placeholderText: qsTr("Your email address")
79 }
80 Kube.Label {
81 text: qsTr("Username")
82 Layout.alignment: Qt.AlignRight
83 }
84 Kube.RequiredTextField {
85 Layout.fillWidth: true
86
87 text: settings.imapUsername
88 onTextChanged: {
89 settings.imapUsername = text
90 settings.smtpUsername = text
91 settings.carddavUsername = text
92 settings.caldavUsername = text
93 }
94 placeholderText: qsTr("Your username for server access.")
95 }
96
97 Kube.Label {
98 text: qsTr("IMAP address")
99 Layout.alignment: Qt.AlignRight
100 }
101 Kube.RequiredTextField {
102 id: imapServer
103
104 Layout.fillWidth: true
105
106 placeholderText: "imaps://mainserver.example.net:993"
107 text: settings.imapServer
108 onTextChanged: {
109 settings.imapServer = text
110 }
111 validator: settings.imapServerValidator
112 }
113
114 Kube.Label {
115 text: qsTr("SMTP address")
116 Layout.alignment: Qt.AlignRight
117 }
118 Kube.RequiredTextField {
119 Layout.fillWidth: true
120
121 placeholderText: "smtps://mainserver.example.net:587"
122 text: settings.smtpServer
123 onTextChanged: {
124 settings.smtpServer = text
125 }
126 validator: settings.smtpServerValidator
127 }
128
129 Kube.Label {
130 text: qsTr("CardDAV address")
131 Layout.alignment: Qt.AlignRight
132 }
133 Kube.RequiredTextField {
134 Layout.fillWidth: true
135
136 placeholderText: "https://mainserver.example.net"
137 text: settings.carddavServer
138 onTextChanged: {
139 settings.carddavServer = text
140 }
141 }
142
143 Kube.Label {
144 text: qsTr("CalDAV address")
145 Layout.alignment: Qt.AlignRight
146 }
147 Kube.RequiredTextField {
148 Layout.fillWidth: true
149
150 placeholderText: "https://mainserver.example.net"
151 text: settings.caldavServer
152 onTextChanged: {
153 settings.caldavServer = text
154 }
155 }
156 }
157}
diff --git a/accounts/generic/qml/Login.qml b/accounts/generic/qml/Login.qml
new file mode 100644
index 00000000..7b5b4221
--- /dev/null
+++ b/accounts/generic/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.generic 1.0 as GenericAccount
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 GenericAccount.Settings {
32 id: settings
33 accountType: "generic"
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 account")
58 }
59 }
60}
diff --git a/accounts/generic/qmldir b/accounts/generic/qmldir
new file mode 100644
index 00000000..ad052cac
--- /dev/null
+++ b/accounts/generic/qmldir
@@ -0,0 +1,3 @@
1module org.kube.accounts.generic
2
3plugin genericaccountplugin
diff --git a/accounts/generic/settings.cpp b/accounts/generic/settings.cpp
new file mode 100644
index 00000000..3f0277b3
--- /dev/null
+++ b/accounts/generic/settings.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 "settings.h"
20
21Settings::Settings(QObject *parent)
22 : AccountSettings(parent)
23{
24}
25
26void Settings::load()
27{
28 loadAccount();
29 loadImapResource();
30 loadMailtransportResource();
31 loadCardDavResource();
32 loadCalDavResource();
33 loadIdentity();
34}
35
36void Settings::save()
37{
38 saveAccount();
39 saveImapResource();
40 saveMailtransportResource();
41 saveCardDavResource();
42 saveCalDavResource();
43 saveIdentity();
44}
45
46void Settings::remove()
47{
48 removeResource(mMailtransportIdentifier);
49 removeResource(mImapIdentifier);
50 removeResource(mCardDavIdentifier);
51 removeResource(mCalDavIdentifier);
52 removeIdentity();
53 removeAccount();
54}
55
diff --git a/accounts/generic/settings.h b/accounts/generic/settings.h
new file mode 100644
index 00000000..65f2f359
--- /dev/null
+++ b/accounts/generic/settings.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 Settings : public AccountSettings
24{
25 Q_OBJECT
26
27public:
28 Settings(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/kolabnow/kolabnowsettings.cpp b/accounts/kolabnow/kolabnowsettings.cpp
index 6f1f6502..8411b5e5 100644
--- a/accounts/kolabnow/kolabnowsettings.cpp
+++ b/accounts/kolabnow/kolabnowsettings.cpp
@@ -29,6 +29,7 @@ void KolabnowSettings::load()
29 loadImapResource(); 29 loadImapResource();
30 loadMailtransportResource(); 30 loadMailtransportResource();
31 loadCardDavResource(); 31 loadCardDavResource();
32 loadCalDavResource();
32 loadIdentity(); 33 loadIdentity();
33} 34}
34 35