diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-09-21 17:30:25 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-09-22 10:26:27 +0200 |
commit | 1b1e83aeb820df85ce7f10e81fe1f44deab2174e (patch) | |
tree | 8a137d8f286a3595d9171c24b45655c4b2b03427 | |
parent | 777cb40dae338e79e8f4160882b7c37900b42238 (diff) | |
download | kube-1b1e83aeb820df85ce7f10e81fe1f44deab2174e.tar.gz kube-1b1e83aeb820df85ce7f10e81fe1f44deab2174e.zip |
A login view
-rw-r--r-- | accounts/kolabnow/package/contents/ui/KolabnowAccountSettings.qml | 21 | ||||
-rw-r--r-- | accounts/kolabnow/package/contents/ui/Login.qml | 62 | ||||
-rw-r--r-- | components/kube/contents/ui/Kube.qml | 27 | ||||
-rw-r--r-- | components/kube/contents/ui/LoginView.qml | 39 | ||||
-rw-r--r-- | framework/qml/LoginAccount.qml | 117 | ||||
-rw-r--r-- | framework/qmldir | 1 | ||||
-rw-r--r-- | framework/src/accounts/accountfactory.cpp | 2 | ||||
-rw-r--r-- | framework/src/accounts/accountfactory.h | 2 | ||||
-rw-r--r-- | framework/src/domain/settings/accountsettings.cpp | 6 | ||||
-rw-r--r-- | framework/src/frameworkplugin.cpp | 9 | ||||
-rw-r--r-- | framework/src/keyring.cpp | 17 | ||||
-rw-r--r-- | framework/src/keyring.h | 14 | ||||
-rw-r--r-- | framework/src/sinkfabric.cpp | 2 |
13 files changed, 290 insertions, 29 deletions
diff --git a/accounts/kolabnow/package/contents/ui/KolabnowAccountSettings.qml b/accounts/kolabnow/package/contents/ui/KolabnowAccountSettings.qml index 8d8b6665..482ddc99 100644 --- a/accounts/kolabnow/package/contents/ui/KolabnowAccountSettings.qml +++ b/accounts/kolabnow/package/contents/ui/KolabnowAccountSettings.qml | |||
@@ -26,8 +26,8 @@ Item { | |||
26 | 26 | ||
27 | property string accountId | 27 | property string accountId |
28 | property string heading: qsTr("Connect your Kolab Now account") | 28 | property string heading: qsTr("Connect your Kolab Now account") |
29 | property string subheadline: qsTr("To let Kube access your account, fill in email address, username, password and give the account a title that will be displayed inside Kube.") | 29 | property string subheadline: qsTr("To let Kube access your account, fill in your name, username, password.") |
30 | property bool valid: accountField.acceptableInput && nameField.acceptableInput && emailField.acceptableInput && pwField.acceptableInput | 30 | property bool valid: nameField.acceptableInput && emailField.acceptableInput |
31 | 31 | ||
32 | KolabnowAccount.KolabnowSettings { | 32 | KolabnowAccount.KolabnowSettings { |
33 | id: kolabnowSettings | 33 | id: kolabnowSettings |
@@ -85,23 +85,6 @@ Item { | |||
85 | } | 85 | } |
86 | placeholderText: qsTr("Your email address") | 86 | placeholderText: qsTr("Your email address") |
87 | } | 87 | } |
88 | |||
89 | Kube.Label { | ||
90 | text: qsTr("Password") | ||
91 | Layout.alignment: Qt.AlignRight | ||
92 | } | ||
93 | |||
94 | Kube.PasswordField { | ||
95 | id: pwField | ||
96 | Layout.fillWidth: true | ||
97 | |||
98 | placeholderText: qsTr("Password of your email account") | ||
99 | text: kolabnowSettings.imapPassword | ||
100 | onTextChanged: { | ||
101 | kolabnowSettings.imapPassword = text | ||
102 | kolabnowSettings.smtpPassword = text | ||
103 | } | ||
104 | } | ||
105 | } | 88 | } |
106 | } | 89 | } |
107 | } | 90 | } |
diff --git a/accounts/kolabnow/package/contents/ui/Login.qml b/accounts/kolabnow/package/contents/ui/Login.qml new file mode 100644 index 00000000..ae0213d5 --- /dev/null +++ b/accounts/kolabnow/package/contents/ui/Login.qml | |||
@@ -0,0 +1,62 @@ | |||
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.kolabnow 1.0 as KolabnowAccount | ||
24 | |||
25 | Item { | ||
26 | property string accountId | ||
27 | property string heading: qsTr("Login") | ||
28 | property string subheadline: settings.accountName | ||
29 | |||
30 | KolabnowAccount.KolabnowSettings { | ||
31 | id: settings | ||
32 | accountIdentifier: accountId | ||
33 | accountType: "kolabnow" | ||
34 | } | ||
35 | |||
36 | function login(){ | ||
37 | settings.save() | ||
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 | |||
57 | placeholderText: qsTr("Password of your email account") | ||
58 | text: settings.imapPassword | ||
59 | onTextChanged: settings.imapPassword = text | ||
60 | } | ||
61 | } | ||
62 | } | ||
diff --git a/components/kube/contents/ui/Kube.qml b/components/kube/contents/ui/Kube.qml index a9e8af09..603a499f 100644 --- a/components/kube/contents/ui/Kube.qml +++ b/components/kube/contents/ui/Kube.qml | |||
@@ -246,7 +246,6 @@ Controls2.ApplicationWindow { | |||
246 | bottom: mainContent.bottom | 246 | bottom: mainContent.bottom |
247 | } | 247 | } |
248 | Layout.fillWidth: true | 248 | Layout.fillWidth: true |
249 | initialItem: mailView | ||
250 | 249 | ||
251 | Kube.Listener { | 250 | Kube.Listener { |
252 | filter: Kube.Messages.componentDone | 251 | filter: Kube.Messages.componentDone |
@@ -282,6 +281,10 @@ Controls2.ApplicationWindow { | |||
282 | replaceView(logView) | 281 | replaceView(logView) |
283 | } | 282 | } |
284 | 283 | ||
284 | function setLoginView() { | ||
285 | pushView(loginView, {accountId: currentAccount}) | ||
286 | } | ||
287 | |||
285 | function openComposer(newMessage, recipients) { | 288 | function openComposer(newMessage, recipients) { |
286 | pushView(composerView, {newMessage: newMessage, recipients: recipients}) | 289 | pushView(composerView, {newMessage: newMessage, recipients: recipients}) |
287 | } | 290 | } |
@@ -296,6 +299,17 @@ Controls2.ApplicationWindow { | |||
296 | } | 299 | } |
297 | } | 300 | } |
298 | 301 | ||
302 | Component.onCompleted: { | ||
303 | if (!currentItem) { | ||
304 | if (!Kube.Keyring.isUnlocked(app.currentAccount)) { | ||
305 | setMailView(); | ||
306 | setLoginView() | ||
307 | } else { | ||
308 | setMailView(); | ||
309 | } | ||
310 | } | ||
311 | } | ||
312 | |||
299 | //These items are not visible until pushed onto the stack, so we keep them in resources instead of items | 313 | //These items are not visible until pushed onto the stack, so we keep them in resources instead of items |
300 | resources: [ | 314 | resources: [ |
301 | //Not components so we maintain state | 315 | //Not components so we maintain state |
@@ -303,17 +317,20 @@ Controls2.ApplicationWindow { | |||
303 | id: mailView | 317 | id: mailView |
304 | anchors.fill: parent | 318 | anchors.fill: parent |
305 | Controls2.StackView.onActivated: mailButton.checked = true | 319 | Controls2.StackView.onActivated: mailButton.checked = true |
320 | Controls2.StackView.onDeactivated: mailButton.checked = false | ||
306 | }, | 321 | }, |
307 | PeopleView { | 322 | PeopleView { |
308 | id: peopleView | 323 | id: peopleView |
309 | anchors.fill: parent | 324 | anchors.fill: parent |
310 | Controls2.StackView.onActivated: peopleButton.checked = true | 325 | Controls2.StackView.onActivated: peopleButton.checked = true |
326 | Controls2.StackView.onDeactivated: peopleButton.checked = false | ||
311 | }, | 327 | }, |
312 | //Not a component because otherwise we can't log stuff | 328 | //Not a component because otherwise we can't log stuff |
313 | LogView { | 329 | LogView { |
314 | id: logView | 330 | id: logView |
315 | anchors.fill: parent | 331 | anchors.fill: parent |
316 | Controls2.StackView.onActivated: logButton.checked = true | 332 | Controls2.StackView.onActivated: logButton.checked = true |
333 | Controls2.StackView.onDeactivated: logButton.checked = false | ||
317 | } | 334 | } |
318 | ] | 335 | ] |
319 | //A component so it's always destroyed when we're done | 336 | //A component so it's always destroyed when we're done |
@@ -322,6 +339,7 @@ Controls2.ApplicationWindow { | |||
322 | ComposerView { | 339 | ComposerView { |
323 | anchors.fill: parent | 340 | anchors.fill: parent |
324 | Controls2.StackView.onActivated: composerButton.checked = true | 341 | Controls2.StackView.onActivated: composerButton.checked = true |
342 | Controls2.StackView.onDeactivated: composerButton.checked = false | ||
325 | } | 343 | } |
326 | } | 344 | } |
327 | Component { | 345 | Component { |
@@ -329,6 +347,13 @@ Controls2.ApplicationWindow { | |||
329 | AccountsView { | 347 | AccountsView { |
330 | anchors.fill: parent | 348 | anchors.fill: parent |
331 | Controls2.StackView.onActivated: accountsButton.checked = true | 349 | Controls2.StackView.onActivated: accountsButton.checked = true |
350 | Controls2.StackView.onDeactivated: accountsButton.checked = false | ||
351 | } | ||
352 | } | ||
353 | Component { | ||
354 | id: loginView | ||
355 | LoginView { | ||
356 | anchors.fill: parent | ||
332 | } | 357 | } |
333 | } | 358 | } |
334 | } | 359 | } |
diff --git a/components/kube/contents/ui/LoginView.qml b/components/kube/contents/ui/LoginView.qml new file mode 100644 index 00000000..c5fdc396 --- /dev/null +++ b/components/kube/contents/ui/LoginView.qml | |||
@@ -0,0 +1,39 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2017 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 QtQuick.Controls 1.3 as Controls | ||
23 | import QtQuick.Controls 2.0 | ||
24 | import org.kube.framework 1.0 as Kube | ||
25 | |||
26 | Rectangle { | ||
27 | id: root | ||
28 | property alias accountId: login.accountId | ||
29 | |||
30 | color: Kube.Colors.backgroundColor | ||
31 | |||
32 | Kube.LoginAccount { | ||
33 | id: login | ||
34 | anchors { | ||
35 | fill: parent | ||
36 | bottomMargin: Kube.Units.largeSpacing | ||
37 | } | ||
38 | } | ||
39 | } | ||
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 | |||
20 | import QtQuick 2.7 | ||
21 | import QtQuick.Layouts 1.1 | ||
22 | import org.kube.framework 1.0 as Kube | ||
23 | |||
24 | Item { | ||
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 | |||
8 | NewAccountDialog 1.0 NewAccountDialog.qml | 8 | NewAccountDialog 1.0 NewAccountDialog.qml |
9 | EditAccountDialog 1.0 EditAccountDialog.qml | 9 | EditAccountDialog 1.0 EditAccountDialog.qml |
10 | EditAccount 1.0 EditAccount.qml | 10 | EditAccount 1.0 EditAccount.qml |
11 | LoginAccount 1.0 LoginAccount.qml | ||
11 | OverlayDialog 1.0 OverlayDialog.qml | 12 | OverlayDialog 1.0 OverlayDialog.qml |
12 | Outbox 1.0 Outbox.qml | 13 | Outbox 1.0 Outbox.qml |
13 | People 1.0 People.qml | 14 | People 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); | ||
36 | public: | 37 | public: |
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 | ||
298 | void AccountSettings::saveCardDavResource() | 298 | void 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 | ||
307 | void AccountSettings::saveMaildirResource() | 307 | void 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 | ||
323 | void AccountSettings::saveIdentity() | 323 | void 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 | ||
59 | static QObject *keyring_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine) | ||
60 | { | ||
61 | Q_UNUSED(engine) | ||
62 | Q_UNUSED(scriptEngine) | ||
63 | return new Kube::Keyring; | ||
64 | } | ||
65 | |||
58 | void FrameworkPlugin::registerTypes (const char *uri) | 66 | void 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 | ||
24 | using namespace Kube; | 24 | using namespace Kube; |
25 | 25 | ||
26 | Keyring::Keyring(const QByteArray &accountId, QObject *parent) | 26 | Keyring::Keyring() |
27 | : QObject() | ||
28 | { | ||
29 | |||
30 | } | ||
31 | |||
32 | bool Keyring::isUnlocked(const QByteArray &accountId) | ||
33 | { | ||
34 | return false; | ||
35 | } | ||
36 | |||
37 | AccountKeyring::AccountKeyring(const QByteArray &accountId, QObject *parent) | ||
27 | : QObject(parent), | 38 | : QObject(parent), |
28 | mAccountIdentifier(accountId) | 39 | mAccountIdentifier(accountId) |
29 | { | 40 | { |
30 | } | 41 | } |
31 | 42 | ||
32 | void Keyring::storePassword(const QByteArray &resourceId, const QString &password) | 43 | void 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 | ||
39 | void Keyring::unlock() | 50 | void 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 { | |||
24 | class Keyring : public QObject { | 24 | class Keyring : public QObject { |
25 | Q_OBJECT | 25 | Q_OBJECT |
26 | public: | 26 | public: |
27 | Keyring(const QByteArray &accountId, QObject *parent = nullptr); | 27 | Keyring(); |
28 | Q_INVOKABLE bool isUnlocked(const QByteArray &accountId); | ||
29 | |||
30 | private: | ||
31 | Q_DISABLE_COPY(Keyring); | ||
32 | }; | ||
33 | |||
34 | class AccountKeyring : public QObject { | ||
35 | Q_OBJECT | ||
36 | public: | ||
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 | ||
31 | private: | 41 | private: |
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 | ||