-
-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathPasswordStore.h
More file actions
36 lines (32 loc) · 1.3 KB
/
PasswordStore.h
File metadata and controls
36 lines (32 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Author: Kang Lin <kl222@126.com>
#pragma once
#include <QObject>
#include <QVariantMap>
#include "ParameterWebBrowser.h"
/*
CPasswordStore using QtKeychain.
Notes:
- Stores credentials in the system keychain using QtKeychain.
- Credentials are stored as a small JSON object under a single key per host:
{ "username": "...", "password": "..." }
- getCredentials() blocks briefly waiting for the keychain response (with a timeout).
This mirrors the previous synchronous QSettings behavior. In a production app you
may prefer asynchronous APIs or to move keychain access to a worker thread.
- Requires QtKeychain to be available and linked into the project.
*/
class CPasswordStore : public QObject
{
Q_OBJECT
public:
explicit CPasswordStore(CParameterWebBrowser* pPara, QObject *parent = nullptr);
~CPasswordStore();
// From JS: returns { "username": "...", "password":"..." } or empty map
Q_INVOKABLE QVariantMap getCredentials(const QString &host);
// From JS: save credentials for host
Q_INVOKABLE void saveCredentials(const QString &host, const QString &username, const QString &password);
Q_SIGNALS:
void credentialsSaved(const QString &host);
void sigCredentialsReady(const QString &host, const QVariantMap& credentials);
private:
CParameterWebBrowser* m_pPara;
};