summaryrefslogtreecommitdiffstats
path: root/framework/src/keyring.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-09-22 10:23:44 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-09-22 10:27:56 +0200
commit2a60a0723257cfd6855233b9af27dc9735915435 (patch)
tree9dcabe95cff050ad77f7bca03c4b85e51c4ffa10 /framework/src/keyring.cpp
parent1f1ffbceb15dbc9e8a7ff567666a026ef221039e (diff)
downloadkube-2a60a0723257cfd6855233b9af27dc9735915435.tar.gz
kube-2a60a0723257cfd6855233b9af27dc9735915435.zip
Keyring fixes
* Avoid double free * track unlocked state * Ensure we bring up the login screen on startup and after saving the configuration.
Diffstat (limited to 'framework/src/keyring.cpp')
-rw-r--r--framework/src/keyring.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/framework/src/keyring.cpp b/framework/src/keyring.cpp
index e3fdb1cb..7bd406c0 100644
--- a/framework/src/keyring.cpp
+++ b/framework/src/keyring.cpp
@@ -20,18 +20,31 @@
20 20
21#include <sink/secretstore.h> 21#include <sink/secretstore.h>
22#include <QSettings> 22#include <QSettings>
23#include <QtGlobal>
23 24
24using namespace Kube; 25using namespace Kube;
25 26
27Q_GLOBAL_STATIC(Keyring, sKeyring);
28
26Keyring::Keyring() 29Keyring::Keyring()
27 : QObject() 30 : QObject()
28{ 31{
29 32
30} 33}
31 34
35Keyring *Keyring::instance()
36{
37 return sKeyring;
38}
39
32bool Keyring::isUnlocked(const QByteArray &accountId) 40bool Keyring::isUnlocked(const QByteArray &accountId)
33{ 41{
34 return false; 42 return mUnlocked.contains(accountId);
43}
44
45void Keyring::unlock(const QByteArray &accountId)
46{
47 mUnlocked.insert(accountId);
35} 48}
36 49
37AccountKeyring::AccountKeyring(const QByteArray &accountId, QObject *parent) 50AccountKeyring::AccountKeyring(const QByteArray &accountId, QObject *parent)
@@ -45,6 +58,7 @@ void AccountKeyring::storePassword(const QByteArray &resourceId, const QString &
45 QSettings settings{mAccountIdentifier + ".keyring", QSettings::IniFormat}; 58 QSettings settings{mAccountIdentifier + ".keyring", QSettings::IniFormat};
46 settings.setValue(resourceId, password); 59 settings.setValue(resourceId, password);
47 Sink::SecretStore::instance().insert(resourceId, password); 60 Sink::SecretStore::instance().insert(resourceId, password);
61 Keyring::instance()->unlock(mAccountIdentifier);
48} 62}
49 63
50void AccountKeyring::unlock() 64void AccountKeyring::unlock()