summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/kube/contents/ui/Kube.qml7
-rw-r--r--framework/qml/Messages.qml2
-rw-r--r--framework/src/CMakeLists.txt1
-rw-r--r--framework/src/domain/settings/accountsettings.cpp17
-rw-r--r--framework/src/keyring.cpp46
-rw-r--r--framework/src/keyring.h37
-rw-r--r--framework/src/sinkfabric.cpp10
7 files changed, 109 insertions, 11 deletions
diff --git a/components/kube/contents/ui/Kube.qml b/components/kube/contents/ui/Kube.qml
index 86e0f5bb..a9e8af09 100644
--- a/components/kube/contents/ui/Kube.qml
+++ b/components/kube/contents/ui/Kube.qml
@@ -111,7 +111,12 @@ Controls2.ApplicationWindow {
111 Shortcut { 111 Shortcut {
112 onActivated: Kube.Fabric.postMessage(Kube.Messages.search, {}) 112 onActivated: Kube.Fabric.postMessage(Kube.Messages.search, {})
113 sequence: StandardKey.Find 113 sequence: StandardKey.Find
114 114 }
115 Shortcut {
116 onActivated: {
117 Kube.Fabric.postMessage(Kube.Messages.unlockKeyring, {accountId: app.currentAccount})
118 }
119 sequence: "Ctrl+l"
115 } 120 }
116 Shortcut { 121 Shortcut {
117 id: syncShortcut 122 id: syncShortcut
diff --git a/framework/qml/Messages.qml b/framework/qml/Messages.qml
index 1d2ca002..8d10bc3b 100644
--- a/framework/qml/Messages.qml
+++ b/framework/qml/Messages.qml
@@ -34,6 +34,8 @@ Item {
34 property string toggleImportant: "toggleImportant" 34 property string toggleImportant: "toggleImportant"
35 property string moveToFolder: "moveToFolder" 35 property string moveToFolder: "moveToFolder"
36 property string moveToDrafts: "moveToDrafts" 36 property string moveToDrafts: "moveToDrafts"
37 property string credentials: "credentials"
38 property string unlockKeyring: "unlockKeyring"
37 39
38 property string notification: "notification" 40 property string notification: "notification"
39 property string progressNotification: "progressNotification" 41 property string progressNotification: "progressNotification"
diff --git a/framework/src/CMakeLists.txt b/framework/src/CMakeLists.txt
index 5e9dd269..b66f45ed 100644
--- a/framework/src/CMakeLists.txt
+++ b/framework/src/CMakeLists.txt
@@ -47,6 +47,7 @@ set(SRCS
47 krecursivefilterproxymodel.cpp 47 krecursivefilterproxymodel.cpp
48 webengineprofile.cpp 48 webengineprofile.cpp
49 startupcheck.cpp 49 startupcheck.cpp
50 keyring.cpp
50) 51)
51 52
52add_library(frameworkplugin SHARED ${SRCS}) 53add_library(frameworkplugin SHARED ${SRCS})
diff --git a/framework/src/domain/settings/accountsettings.cpp b/framework/src/domain/settings/accountsettings.cpp
index 232f7aba..09cdf279 100644
--- a/framework/src/domain/settings/accountsettings.cpp
+++ b/framework/src/domain/settings/accountsettings.cpp
@@ -24,6 +24,8 @@
24#include <QDir> 24#include <QDir>
25#include <QUrl> 25#include <QUrl>
26 26
27#include "keyring.h"
28
27using namespace Sink; 29using namespace Sink;
28using namespace Sink::ApplicationDomain; 30using namespace Sink::ApplicationDomain;
29 31
@@ -196,7 +198,6 @@ void AccountSettings::loadImapResource()
196 mImapIdentifier = resource.identifier(); 198 mImapIdentifier = resource.identifier();
197 mImapServer = resource.getProperty("server").toString(); 199 mImapServer = resource.getProperty("server").toString();
198 mImapUsername = resource.getProperty("username").toString(); 200 mImapUsername = resource.getProperty("username").toString();
199 mImapPassword = resource.getProperty("password").toString();
200 emit imapResourceChanged(); 201 emit imapResourceChanged();
201 }).onError([](const KAsync::Error &error) { 202 }).onError([](const KAsync::Error &error) {
202 qWarning() << "Failed to load the imap resource: " << error.errorMessage; 203 qWarning() << "Failed to load the imap resource: " << error.errorMessage;
@@ -222,7 +223,6 @@ void AccountSettings::loadMailtransportResource()
222 mMailtransportIdentifier = resource.identifier(); 223 mMailtransportIdentifier = resource.identifier();
223 mSmtpServer = resource.getProperty("server").toString(); 224 mSmtpServer = resource.getProperty("server").toString();
224 mSmtpUsername = resource.getProperty("username").toString(); 225 mSmtpUsername = resource.getProperty("username").toString();
225 mSmtpPassword = resource.getProperty("password").toString();
226 emit smtpResourceChanged(); 226 emit smtpResourceChanged();
227 }).onError([](const KAsync::Error &error) { 227 }).onError([](const KAsync::Error &error) {
228 SinkWarning() << "Failed to load the smtp resource: " << error.errorMessage; 228 SinkWarning() << "Failed to load the smtp resource: " << error.errorMessage;
@@ -250,7 +250,6 @@ void AccountSettings::loadCardDavResource()
250 mCardDavIdentifier = resource.identifier(); 250 mCardDavIdentifier = resource.identifier();
251 mCardDavServer = resource.getProperty("server").toString(); 251 mCardDavServer = resource.getProperty("server").toString();
252 mCardDavUsername = resource.getProperty("username").toString(); 252 mCardDavUsername = resource.getProperty("username").toString();
253 mCardDavPassword = resource.getProperty("password").toString();
254 emit cardDavResourceChanged(); 253 emit cardDavResourceChanged();
255 }).onError([](const KAsync::Error &error) { 254 }).onError([](const KAsync::Error &error) {
256 qWarning() << "Failed to load the CardDAV resource: " << error.errorMessage; 255 qWarning() << "Failed to load the CardDAV resource: " << error.errorMessage;
@@ -291,18 +290,18 @@ void AccountSettings::saveImapResource()
291{ 290{
292 mImapIdentifier = saveResource<ImapResource>(mAccountIdentifier, mImapIdentifier, { 291 mImapIdentifier = saveResource<ImapResource>(mAccountIdentifier, mImapIdentifier, {
293 {"server", mImapServer}, 292 {"server", mImapServer},
294 {"username", mImapUsername}, 293 {"username", mImapUsername}
295 {"password", mImapPassword},
296 }); 294 });
295 Kube::Keyring{mAccountIdentifier}.storePassword(mImapIdentifier, mImapPassword);
297} 296}
298 297
299void AccountSettings::saveCardDavResource() 298void AccountSettings::saveCardDavResource()
300{ 299{
301 mCardDavIdentifier = saveResource<CardDavResource>(mAccountIdentifier, mCardDavIdentifier, { 300 mCardDavIdentifier = saveResource<CardDavResource>(mAccountIdentifier, mCardDavIdentifier, {
302 {"server", mCardDavServer}, 301 {"server", mCardDavServer},
303 {"username", mCardDavUsername}, 302 {"username", mCardDavUsername}
304 {"password", mCardDavPassword},
305 }); 303 });
304 Kube::Keyring{mAccountIdentifier}.storePassword(mCardDavIdentifier, mCardDavPassword);
306} 305}
307 306
308void AccountSettings::saveMaildirResource() 307void AccountSettings::saveMaildirResource()
@@ -316,9 +315,9 @@ void AccountSettings::saveMailtransportResource()
316{ 315{
317 mMailtransportIdentifier = saveResource<MailtransportResource>(mAccountIdentifier, mMailtransportIdentifier, { 316 mMailtransportIdentifier = saveResource<MailtransportResource>(mAccountIdentifier, mMailtransportIdentifier, {
318 {"server", mSmtpServer}, 317 {"server", mSmtpServer},
319 {"username", mSmtpUsername}, 318 {"username", mSmtpUsername}
320 {"password", mSmtpPassword},
321 }); 319 });
320 Kube::Keyring{mAccountIdentifier}.storePassword(mMailtransportIdentifier, mSmtpPassword);
322} 321}
323 322
324void AccountSettings::saveIdentity() 323void AccountSettings::saveIdentity()
diff --git a/framework/src/keyring.cpp b/framework/src/keyring.cpp
new file mode 100644
index 00000000..759d0c4c
--- /dev/null
+++ b/framework/src/keyring.cpp
@@ -0,0 +1,46 @@
1/*
2 Copyright (c) 2017 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 "keyring.h"
20
21#include <sink/secretstore.h>
22#include <QSettings>
23
24using namespace Kube;
25
26Keyring::Keyring(const QByteArray &accountId, QObject *parent)
27 : QObject(parent),
28 mAccountIdentifier(accountId)
29{
30}
31
32void Keyring::storePassword(const QByteArray &resourceId, const QString &password)
33{
34 QSettings settings{mAccountIdentifier + ".keyring", QSettings::IniFormat};
35 settings.setValue(resourceId, password);
36 Sink::SecretStore::instance().insert(resourceId, password);
37}
38
39void Keyring::unlock()
40{
41 QSettings settings{mAccountIdentifier + ".keyring", QSettings::IniFormat};
42 for (const auto &resourceId : settings.allKeys()) {
43 Sink::SecretStore::instance().insert(resourceId.toLatin1(), settings.value(resourceId).toString());
44 }
45}
46
diff --git a/framework/src/keyring.h b/framework/src/keyring.h
new file mode 100644
index 00000000..ee9c3577
--- /dev/null
+++ b/framework/src/keyring.h
@@ -0,0 +1,37 @@
1/*
2 Copyright (c) 2017 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
20#include <QObject>
21
22namespace Kube {
23
24class Keyring : public QObject {
25 Q_OBJECT
26public:
27 Keyring(const QByteArray &accountId, QObject *parent = nullptr);
28 void storePassword(const QByteArray &resourceId, const QString &password);
29 void unlock();
30
31private:
32 Q_DISABLE_COPY(Keyring);
33
34 QByteArray mAccountIdentifier;
35};
36
37}
diff --git a/framework/src/sinkfabric.cpp b/framework/src/sinkfabric.cpp
index 79afd33b..954186bb 100644
--- a/framework/src/sinkfabric.cpp
+++ b/framework/src/sinkfabric.cpp
@@ -24,8 +24,10 @@
24#include <sink/log.h> 24#include <sink/log.h>
25#include <sink/notification.h> 25#include <sink/notification.h>
26#include <sink/notifier.h> 26#include <sink/notifier.h>
27#include <sink/secretstore.h>
27 28
28#include "fabric.h" 29#include "fabric.h"
30#include "keyring.h"
29 31
30using namespace Kube; 32using namespace Kube;
31using namespace Sink; 33using namespace Sink;
@@ -131,7 +133,10 @@ public:
131 Store::modify(*mail).exec(); 133 Store::modify(*mail).exec();
132 } 134 }
133 } 135 }
134 136 if (id == "unlockKeyring") {
137 auto accountId = message["accountId"].value<QByteArray>();
138 Kube::Keyring{accountId}.unlock();
139 }
135 } 140 }
136 141
137}; 142};
@@ -180,6 +185,9 @@ public:
180 case Sink::ApplicationDomain::ConnectionLostError: 185 case Sink::ApplicationDomain::ConnectionLostError:
181 message["message"] = QObject::tr("Connection lost."); 186 message["message"] = QObject::tr("Connection lost.");
182 break; 187 break;
188 case Sink::ApplicationDomain::MissingCredentialsError:
189 message["message"] = QObject::tr("No credentials available.");
190 break;
183 default: 191 default:
184 message["message"] = QObject::tr("An unknown error occurred."); 192 message["message"] = QObject::tr("An unknown error occurred.");
185 } 193 }