blob: 2f00f0357e99c026a60ee4697e90a3ad33044661 (
plain)
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
37
38
39
40
41
42
43
44
45
46
47
|
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include "core_global.h"
#include <QtTaskTree/QTaskTree>
namespace Core {
enum class CredentialOperation { Get, Set, Delete };
class CORE_EXPORT CredentialQuery
{
public:
void setOperation(CredentialOperation operation) { m_operation = operation; }
void setService(const QString &service) { m_service = service; }
void setKey(const QString &key) { m_key = key; }
void setData(const QByteArray &data) { m_data = data; }
CredentialOperation operation() const { return m_operation; }
std::optional<QByteArray> data() const { return m_data; }
QString errorString() const { return m_errorString; }
private:
CredentialOperation m_operation = CredentialOperation::Get;
QString m_service;
QString m_key;
std::optional<QByteArray> m_data; // Used for input when Set and for output when Get.
QString m_errorString;
friend class CredentialQueryTaskAdapter;
};
class CredentialQueryTaskAdapter final
{
public:
CORE_EXPORT ~CredentialQueryTaskAdapter();
CORE_EXPORT void operator()(CredentialQuery *task, QTaskInterface *iface);
private:
std::unique_ptr<QObject> m_guard;
};
using CredentialQueryTask = QCustomTask<CredentialQuery, CredentialQueryTaskAdapter>;
} // Core
|