forked from bitshares/bitshares1-qtwallet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ClientWrapper.hpp
69 lines (52 loc) · 1.9 KB
/
ClientWrapper.hpp
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
#pragma once
#include <QObject>
#include <QSettings>
#include <QVariant>
#include <bts/rpc/rpc_server.hpp>
#include <bts/client/client.hpp>
#include <bts/net/upnp.hpp>
class ClientWrapper : public QObject
{
Q_OBJECT
public:
/// Helper interface to send back notifications about startup progressing.
class INotifier
{
public:
virtual void on_config_loaded(const bts::client::config& config) = 0;
protected:
virtual ~INotifier() {}
};
ClientWrapper(QObject *parent = nullptr);
virtual ~ClientWrapper();
///Not done in constructor to allow caller to connect to error()
void initialize(INotifier* notifier);
QUrl http_url() const;
void set_web_package(std::unordered_map<std::string, std::vector<char>>&& web_package);
bool has_web_package() {
return !_web_package.empty();
}
QString get_data_dir();
Q_INVOKABLE QVariant get_info();
Q_INVOKABLE QString get_http_auth_token();
std::shared_ptr<bts::client::client> get_client() { return _client; }
void handle_crash();
public Q_SLOTS:
void set_data_dir(QString data_dir);
void confirm_and_set_approval(QString delegate_name, bool approve);
Q_SIGNALS:
void initialized();
void status_update(QString statusString);
void error(QString errorString);
private:
bts::client::config _cfg;
std::shared_ptr<bts::client::client> _client;
fc::future<void> _client_done;
fc::thread _bitshares_thread;
fc::future<void> _init_complete;
fc::optional<fc::ip::endpoint> _actual_httpd_endpoint;
QSettings _settings;
std::shared_ptr<bts::net::upnp_service> _upnp_service;
std::unordered_map<std::string, std::vector<char>> _web_package;
void get_htdocs_file(const fc::path& filename, const fc::http::server::response& r);
};