玉兔远程控制 0.1.0-bate4
载入中...
搜索中...
未找到
PasswordStore.h
1// Author: Kang Lin <kl222@126.com>
2
3#pragma once
4
5#include <QObject>
6#include <QVariantMap>
7#include "ParameterWebBrowser.h"
8
9/*
10 CPasswordStore using QtKeychain.
11
12 Notes:
13 - Stores credentials in the system keychain using QtKeychain.
14 - Credentials are stored as a small JSON object under a single key per host:
15 { "username": "...", "password": "..." }
16 - getCredentials() blocks briefly waiting for the keychain response (with a timeout).
17 This mirrors the previous synchronous QSettings behavior. In a production app you
18 may prefer asynchronous APIs or to move keychain access to a worker thread.
19 - Requires QtKeychain to be available and linked into the project.
20*/
21class CPasswordStore : public QObject
22{
23 Q_OBJECT
24public:
25 explicit CPasswordStore(CParameterWebBrowser* pPara, QObject *parent = nullptr);
27 // From JS: returns { "username": "...", "password":"..." } or empty map
28 Q_INVOKABLE QVariantMap getCredentials(const QString &host);
29 // From JS: save credentials for host
30 Q_INVOKABLE void saveCredentials(const QString &host, const QString &username, const QString &password);
31Q_SIGNALS:
32 void credentialsSaved(const QString &host);
33 void sigCredentialsReady(const QString &host, const QVariantMap& credentials);
34private:
35 CParameterWebBrowser* m_pPara;
36};