summaryrefslogtreecommitdiffstats
path: root/framework
diff options
context:
space:
mode:
Diffstat (limited to 'framework')
-rw-r--r--framework/qml/LoginAccount.qml117
-rw-r--r--framework/qmldir1
-rw-r--r--framework/src/accounts/accountfactory.cpp2
-rw-r--r--framework/src/accounts/accountfactory.h2
-rw-r--r--framework/src/domain/settings/accountsettings.cpp6
-rw-r--r--framework/src/frameworkplugin.cpp9
-rw-r--r--framework/src/keyring.cpp17
-rw-r--r--framework/src/keyring.h14
-rw-r--r--framework/src/sinkfabric.cpp2
9 files changed, 161 insertions, 9 deletions
diff --git a/framework/qml/LoginAccount.qml b/framework/qml/LoginAccount.qml
new file mode 100644
index 00000000..7eaa47f4
--- /dev/null
+++ b/framework/qml/LoginAccount.qml
@@ -0,0 +1,117 @@
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.7
21import QtQuick.Layouts 1.1
22import org.kube.framework 1.0 as Kube
23
24Item {
25 id: root
26 property string accountId
27 property bool canRemove: true
28
29 function login() {
30 loader.item.login()
31 Kube.Fabric.postMessage(Kube.Messages.synchronize, {"accountId": loader.item.accountIdentifier});
32 Kube.Fabric.postMessage(Kube.Messages.componentDone, {})
33 }
34
35 Kube.AccountFactory {
36 id: accountFactory
37 accountId: root.accountId
38 }
39
40 Item {
41
42 anchors {
43 fill: parent
44 margins: Kube.Units.largeSpacing * 2
45 }
46
47 Kube.Heading {
48 id: heading
49 text: loader.item ? loader.item.heading : ""
50 color: Kube.Colors.highlightColor
51 }
52
53 Kube.Label {
54 id: subHeadline
55
56 anchors {
57 left: heading.left
58 top: heading.bottom
59 }
60
61 width: parent.width
62 text: loader.item ? loader.item.subheadline : ""
63 color: Kube.Colors.disabledTextColor
64 wrapMode: Text.Wrap
65 }
66
67 Item {
68 id: accountEdit
69 anchors {
70 top: subHeadline.bottom
71 left: parent.left
72 right: parent.right
73 bottom: footer.top
74 topMargin: Kube.Units.largeSpacing * 2
75 }
76
77 Loader {
78 id: loader
79 anchors {
80 top: parent.top
81 left: parent.left
82 right: parent.right
83 }
84 //The initial size is somehow necessary so the loader is properly anchored
85 height: 10
86 source: accountFactory.loginUi
87 onLoaded: item.accountId = root.accountId
88 }
89 Item {
90 id: spacer
91 anchors {
92 top: loader.bottom
93 left: parent.left
94 right: parent.right
95 bottom: parent.bottom
96 }
97 }
98 }
99 Keys.onReturnPressed: login()
100
101 Item {
102 id: footer
103 anchors {
104 bottom: parent.bottom
105 left: parent.left
106 right: parent.right
107 topMargin: Kube.Units.largeSpacing * 2
108 }
109
110 Kube.Button {
111 anchors.right: parent.right
112 text: qsTr("Login")
113 onClicked: login()
114 }
115 }
116 }
117}
diff --git a/framework/qmldir b/framework/qmldir
index 5eeaaeff..aef845b1 100644
--- a/framework/qmldir
+++ b/framework/qmldir
@@ -8,6 +8,7 @@ InlineAccountSwitcher 1.0 InlineAccountSwitcher.qml
8NewAccountDialog 1.0 NewAccountDialog.qml 8NewAccountDialog 1.0 NewAccountDialog.qml
9EditAccountDialog 1.0 EditAccountDialog.qml 9EditAccountDialog 1.0 EditAccountDialog.qml
10EditAccount 1.0 EditAccount.qml 10EditAccount 1.0 EditAccount.qml
11LoginAccount 1.0 LoginAccount.qml
11OverlayDialog 1.0 OverlayDialog.qml 12OverlayDialog 1.0 OverlayDialog.qml
12Outbox 1.0 Outbox.qml 13Outbox 1.0 Outbox.qml
13People 1.0 People.qml 14People 1.0 People.qml
diff --git a/framework/src/accounts/accountfactory.cpp b/framework/src/accounts/accountfactory.cpp
index f1c4e29c..9726a2e0 100644
--- a/framework/src/accounts/accountfactory.cpp
+++ b/framework/src/accounts/accountfactory.cpp
@@ -64,6 +64,7 @@ void AccountFactory::loadPackage()
64 if (!package.isValid()) { 64 if (!package.isValid()) {
65 qWarning() << "Failed to load account package: " << "org.kube.accounts." + mAccountType; 65 qWarning() << "Failed to load account package: " << "org.kube.accounts." + mAccountType;
66 mUiPath.clear(); 66 mUiPath.clear();
67 mLoginUi.clear();
67 mName.clear(); 68 mName.clear();
68 mIcon.clear(); 69 mIcon.clear();
69 emit accountLoaded(); 70 emit accountLoaded();
@@ -71,6 +72,7 @@ void AccountFactory::loadPackage()
71 } 72 }
72 Q_ASSERT(package.isValid()); 73 Q_ASSERT(package.isValid());
73 mUiPath = package.filePath("mainscript"); 74 mUiPath = package.filePath("mainscript");
75 mLoginUi = package.filePath("ui", "Login.qml");
74 mName = package.metadata().name(); 76 mName = package.metadata().name();
75 mIcon = package.metadata().iconName(); 77 mIcon = package.metadata().iconName();
76 emit accountLoaded(); 78 emit accountLoaded();
diff --git a/framework/src/accounts/accountfactory.h b/framework/src/accounts/accountfactory.h
index b57854e5..21747df5 100644
--- a/framework/src/accounts/accountfactory.h
+++ b/framework/src/accounts/accountfactory.h
@@ -33,6 +33,7 @@ class AccountFactory : public QObject
33 Q_PROPERTY(QString name MEMBER mName READ name NOTIFY accountLoaded); 33 Q_PROPERTY(QString name MEMBER mName READ name NOTIFY accountLoaded);
34 Q_PROPERTY(QString icon MEMBER mIcon NOTIFY accountLoaded); 34 Q_PROPERTY(QString icon MEMBER mIcon NOTIFY accountLoaded);
35 Q_PROPERTY(QString uiPath MEMBER mUiPath NOTIFY accountLoaded); 35 Q_PROPERTY(QString uiPath MEMBER mUiPath NOTIFY accountLoaded);
36 Q_PROPERTY(QString loginUi MEMBER mLoginUi NOTIFY accountLoaded);
36public: 37public:
37 explicit AccountFactory(QObject *parent = Q_NULLPTR); 38 explicit AccountFactory(QObject *parent = Q_NULLPTR);
38 39
@@ -49,5 +50,6 @@ private:
49 QString mName; 50 QString mName;
50 QString mIcon; 51 QString mIcon;
51 QString mUiPath; 52 QString mUiPath;
53 QString mLoginUi;
52 QByteArray mAccountType; 54 QByteArray mAccountType;
53}; 55};
diff --git a/framework/src/domain/settings/accountsettings.cpp b/framework/src/domain/settings/accountsettings.cpp
index 09cdf279..c174adfe 100644
--- a/framework/src/domain/settings/accountsettings.cpp
+++ b/framework/src/domain/settings/accountsettings.cpp
@@ -292,7 +292,7 @@ void AccountSettings::saveImapResource()
292 {"server", mImapServer}, 292 {"server", mImapServer},
293 {"username", mImapUsername} 293 {"username", mImapUsername}
294 }); 294 });
295 Kube::Keyring{mAccountIdentifier}.storePassword(mImapIdentifier, mImapPassword); 295 Kube::AccountKeyring{mAccountIdentifier}.storePassword(mImapIdentifier, mImapPassword);
296} 296}
297 297
298void AccountSettings::saveCardDavResource() 298void AccountSettings::saveCardDavResource()
@@ -301,7 +301,7 @@ void AccountSettings::saveCardDavResource()
301 {"server", mCardDavServer}, 301 {"server", mCardDavServer},
302 {"username", mCardDavUsername} 302 {"username", mCardDavUsername}
303 }); 303 });
304 Kube::Keyring{mAccountIdentifier}.storePassword(mCardDavIdentifier, mCardDavPassword); 304 Kube::AccountKeyring{mAccountIdentifier}.storePassword(mCardDavIdentifier, mCardDavPassword);
305} 305}
306 306
307void AccountSettings::saveMaildirResource() 307void AccountSettings::saveMaildirResource()
@@ -317,7 +317,7 @@ void AccountSettings::saveMailtransportResource()
317 {"server", mSmtpServer}, 317 {"server", mSmtpServer},
318 {"username", mSmtpUsername} 318 {"username", mSmtpUsername}
319 }); 319 });
320 Kube::Keyring{mAccountIdentifier}.storePassword(mMailtransportIdentifier, mSmtpPassword); 320 Kube::AccountKeyring{mAccountIdentifier}.storePassword(mMailtransportIdentifier, mSmtpPassword);
321} 321}
322 322
323void AccountSettings::saveIdentity() 323void AccountSettings::saveIdentity()
diff --git a/framework/src/frameworkplugin.cpp b/framework/src/frameworkplugin.cpp
index b8cad45d..1e1a169e 100644
--- a/framework/src/frameworkplugin.cpp
+++ b/framework/src/frameworkplugin.cpp
@@ -38,6 +38,7 @@
38#include "clipboardproxy.h" 38#include "clipboardproxy.h"
39#include "webengineprofile.h" 39#include "webengineprofile.h"
40#include "startupcheck.h" 40#include "startupcheck.h"
41#include "keyring.h"
41 42
42#include <QtQml> 43#include <QtQml>
43 44
@@ -55,6 +56,13 @@ static QObject *webengineprofile_singletontype_provider(QQmlEngine *engine, QJSE
55 return new WebEngineProfile; 56 return new WebEngineProfile;
56} 57}
57 58
59static QObject *keyring_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
60{
61 Q_UNUSED(engine)
62 Q_UNUSED(scriptEngine)
63 return new Kube::Keyring;
64}
65
58void FrameworkPlugin::registerTypes (const char *uri) 66void FrameworkPlugin::registerTypes (const char *uri)
59{ 67{
60 qmlRegisterType<FolderListModel>(uri, 1, 0, "FolderListModel"); 68 qmlRegisterType<FolderListModel>(uri, 1, 0, "FolderListModel");
@@ -80,4 +88,5 @@ void FrameworkPlugin::registerTypes (const char *uri)
80 qmlRegisterType<ClipboardProxy>(uri, 1, 0, "Clipboard"); 88 qmlRegisterType<ClipboardProxy>(uri, 1, 0, "Clipboard");
81 qmlRegisterType<StartupCheck>(uri, 1, 0, "StartupCheck"); 89 qmlRegisterType<StartupCheck>(uri, 1, 0, "StartupCheck");
82 qmlRegisterSingletonType<WebEngineProfile>(uri, 1, 0, "WebEngineProfile", webengineprofile_singletontype_provider); 90 qmlRegisterSingletonType<WebEngineProfile>(uri, 1, 0, "WebEngineProfile", webengineprofile_singletontype_provider);
91 qmlRegisterSingletonType<Kube::Keyring>(uri, 1, 0, "Keyring", keyring_singletontype_provider);
83} 92}
diff --git a/framework/src/keyring.cpp b/framework/src/keyring.cpp
index 759d0c4c..e3fdb1cb 100644
--- a/framework/src/keyring.cpp
+++ b/framework/src/keyring.cpp
@@ -23,20 +23,31 @@
23 23
24using namespace Kube; 24using namespace Kube;
25 25
26Keyring::Keyring(const QByteArray &accountId, QObject *parent) 26Keyring::Keyring()
27 : QObject()
28{
29
30}
31
32bool Keyring::isUnlocked(const QByteArray &accountId)
33{
34 return false;
35}
36
37AccountKeyring::AccountKeyring(const QByteArray &accountId, QObject *parent)
27 : QObject(parent), 38 : QObject(parent),
28 mAccountIdentifier(accountId) 39 mAccountIdentifier(accountId)
29{ 40{
30} 41}
31 42
32void Keyring::storePassword(const QByteArray &resourceId, const QString &password) 43void AccountKeyring::storePassword(const QByteArray &resourceId, const QString &password)
33{ 44{
34 QSettings settings{mAccountIdentifier + ".keyring", QSettings::IniFormat}; 45 QSettings settings{mAccountIdentifier + ".keyring", QSettings::IniFormat};
35 settings.setValue(resourceId, password); 46 settings.setValue(resourceId, password);
36 Sink::SecretStore::instance().insert(resourceId, password); 47 Sink::SecretStore::instance().insert(resourceId, password);
37} 48}
38 49
39void Keyring::unlock() 50void AccountKeyring::unlock()
40{ 51{
41 QSettings settings{mAccountIdentifier + ".keyring", QSettings::IniFormat}; 52 QSettings settings{mAccountIdentifier + ".keyring", QSettings::IniFormat};
42 for (const auto &resourceId : settings.allKeys()) { 53 for (const auto &resourceId : settings.allKeys()) {
diff --git a/framework/src/keyring.h b/framework/src/keyring.h
index ee9c3577..ce4e137d 100644
--- a/framework/src/keyring.h
+++ b/framework/src/keyring.h
@@ -24,12 +24,22 @@ namespace Kube {
24class Keyring : public QObject { 24class Keyring : public QObject {
25 Q_OBJECT 25 Q_OBJECT
26public: 26public:
27 Keyring(const QByteArray &accountId, QObject *parent = nullptr); 27 Keyring();
28 Q_INVOKABLE bool isUnlocked(const QByteArray &accountId);
29
30private:
31 Q_DISABLE_COPY(Keyring);
32};
33
34class AccountKeyring : public QObject {
35 Q_OBJECT
36public:
37 AccountKeyring(const QByteArray &accountId, QObject *parent = nullptr);
28 void storePassword(const QByteArray &resourceId, const QString &password); 38 void storePassword(const QByteArray &resourceId, const QString &password);
29 void unlock(); 39 void unlock();
30 40
31private: 41private:
32 Q_DISABLE_COPY(Keyring); 42 Q_DISABLE_COPY(AccountKeyring);
33 43
34 QByteArray mAccountIdentifier; 44 QByteArray mAccountIdentifier;
35}; 45};
diff --git a/framework/src/sinkfabric.cpp b/framework/src/sinkfabric.cpp
index 954186bb..87b243e0 100644
--- a/framework/src/sinkfabric.cpp
+++ b/framework/src/sinkfabric.cpp
@@ -135,7 +135,7 @@ public:
135 } 135 }
136 if (id == "unlockKeyring") { 136 if (id == "unlockKeyring") {
137 auto accountId = message["accountId"].value<QByteArray>(); 137 auto accountId = message["accountId"].value<QByteArray>();
138 Kube::Keyring{accountId}.unlock(); 138 Kube::AccountKeyring{accountId}.unlock();
139 } 139 }
140 } 140 }
141 141