This repository was archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 196
/
Copy pathasync.h
103 lines (80 loc) · 2.39 KB
/
async.h
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#ifndef SRC_ASYNC_H_
#define SRC_ASYNC_H_
#include <string>
#include "napi.h"
#include "credentials.h"
class SetPasswordWorker : public Napi::AsyncWorker {
public:
SetPasswordWorker(const std::string& service, const std::string& account, const std::string& password,
const Napi::Env &env);
~SetPasswordWorker();
void Execute();
void OnOK();
void OnError(Napi::Error const &error);
Napi::Promise Promise();
private:
const std::string service;
const std::string account;
const std::string password;
Napi::Promise::Deferred deferred;
};
class GetPasswordWorker : public Napi::AsyncWorker {
public:
GetPasswordWorker(const std::string& service, const std::string& account,
const Napi::Env &env);
~GetPasswordWorker();
void Execute();
void OnOK();
void OnError(Napi::Error const &error);
Napi::Promise Promise();
private:
const std::string service;
const std::string account;
std::string password;
bool success;
const Napi::Promise::Deferred deferred;
};
class DeletePasswordWorker : public Napi::AsyncWorker {
public:
DeletePasswordWorker(const std::string& service, const std::string& account,
const Napi::Env &env);
~DeletePasswordWorker();
void Execute();
void OnOK();
void OnError(Napi::Error const &error);
Napi::Promise Promise();
private:
const std::string service;
const std::string account;
bool success;
Napi::Promise::Deferred deferred;
};
class FindPasswordWorker : public Napi::AsyncWorker {
public:
FindPasswordWorker(const std::string& service, const Napi::Env &env);
~FindPasswordWorker();
void Execute();
void OnOK();
void OnError(Napi::Error const &error);
Napi::Promise Promise();
private:
const std::string service;
std::string password;
bool success;
const Napi::Promise::Deferred deferred;
};
class FindCredentialsWorker : public Napi::AsyncWorker {
public:
FindCredentialsWorker(const std::string& service, const Napi::Env &env);
~FindCredentialsWorker();
void Execute();
void OnOK();
void OnError(Napi::Error const &error);
Napi::Promise Promise();
private:
const std::string service;
std::vector<keytar::Credentials> credentials;
bool success;
const Napi::Promise::Deferred deferred;
};
#endif // SRC_ASYNC_H_