summaryrefslogtreecommitdiffstats
path: root/framework/src/keyring.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-09-18 13:12:38 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-09-22 10:26:27 +0200
commitbc64551d4083e47fad3deefd69f66b745bbbee2d (patch)
tree6dd70a9ad96e7c5a3fa0e7fe7d8b112945ac582f /framework/src/keyring.cpp
parentd373ecc37fd1f2f0a0d980b7f393c29bdf90c855 (diff)
downloadkube-bc64551d4083e47fad3deefd69f66b745bbbee2d.tar.gz
kube-bc64551d4083e47fad3deefd69f66b745bbbee2d.zip
keyring
Diffstat (limited to 'framework/src/keyring.cpp')
-rw-r--r--framework/src/keyring.cpp46
1 files changed, 46 insertions, 0 deletions
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