-
Notifications
You must be signed in to change notification settings - Fork 3
/
apis.h
58 lines (48 loc) · 1.4 KB
/
apis.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
#pragma once
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <boost/thread.hpp>
#include <boost/bind.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/exception/all.hpp>
#include "JSAPIAuto.h"
#include "BrowserHost.h"
#include "global/config.h"
#include "plugin.h"
#include "utils.h"
/// Structure wrapping a device descriptor for the JS API.
struct DeviceAPI : public FB::JSAPIAuto
{
public:
DeviceDescriptor device;
public:
DeviceAPI(const DeviceDescriptor &device);
virtual ~DeviceAPI() {}
};
/// Root plugin API object.
class PluginAPI : public FB::JSAPIAuto
{
private:
BitcoinTrezorPluginWeakPtr _plugin;
FB::BrowserHostPtr _host;
public:
PluginAPI(const BitcoinTrezorPluginPtr &plugin,
const FB::BrowserHostPtr &host);
virtual ~PluginAPI() {}
public:
std::vector<FB::JSAPIPtr> devices();
void configure(const std::string &config_str_hex);
void close(const FB::JSAPIPtr &device,
const FB::JSObjectPtr &callbacks);
void call(const FB::JSAPIPtr &device,
bool use_timeout,
const std::string &type_name,
const FB::VariantMap &message_map,
const FB::JSObjectPtr &callbacks);
FB::VariantMap derive_child_node(const FB::VariantMap &node_map,
unsigned int index);
private:
BitcoinTrezorPluginPtr acquire_plugin();
};