forked from cardid/WebCard-IE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWebCardAPI.h
95 lines (76 loc) · 2.68 KB
/
WebCardAPI.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
/**********************************************************\
Auto-generated WebCardAPI.h
\**********************************************************/
#include <string>
#include <sstream>
#include <boost/weak_ptr.hpp>
#include "JSAPIAuto.h"
#include "BrowserHost.h"
#include "WebCard.h"
#include "Reader.h"
#ifndef H_WebCardAPI
#define H_WebCardAPI
class WebCardAPI : public FB::JSAPIAuto
{
public:
////////////////////////////////////////////////////////////////////////////
/// @fn WebCardAPI::WebCardAPI(const WebCardPtr& plugin, const FB::BrowserHostPtr host)
///
/// @brief Constructor for your JSAPI object.
/// You should register your methods, properties, and events
/// that should be accessible to Javascript from here.
///
/// @see FB::JSAPIAuto::registerMethod
/// @see FB::JSAPIAuto::registerProperty
/// @see FB::JSAPIAuto::registerEvent
////////////////////////////////////////////////////////////////////////////
WebCardAPI(const WebCardPtr& plugin, const FB::BrowserHostPtr& host) :
m_plugin(plugin), m_host(host)
{
// Read-only property
registerProperty("readers",
make_property(this,
&WebCardAPI::get_readers));
// Read-only property
registerProperty("version",
make_property(this,
&WebCardAPI::get_version));
InitializeReaders();
}
///////////////////////////////////////////////////////////////////////////////
/// @fn WebCardAPI::~WebCardAPI()
///
/// @brief Destructor. Remember that this object will not be released until
/// the browser is done with it; this will almost definitely be after
/// the plugin is released.
///////////////////////////////////////////////////////////////////////////////
virtual ~WebCardAPI() {
ReleaseReaders();
};
WebCardPtr getPlugin();
// Read-only property ${PROPERTY.ident}
FB::JSObjectPtr get_readers();
// Read-only property ${PROPERTY.ident}
std::string get_version();
// Event helpers
FB_JSAPI_EVENT(cardpresent, 1, (const FB::variant&));
FB_JSAPI_EVENT(cardremoved, 1, (const FB::variant&));
void InitializeReaders();
void ReleaseReaders();
protected:
void threadRun();
private:
WebCardWeakPtr m_plugin;
FB::BrowserHostPtr m_host;
SCARDCONTEXT m_hContext;
LPTSTR m_pmszReaders;
#if defined(__linux__) || defined(_WINDOWS)
LPSCARD_READERSTATE m_rgReaderStates;
#else
LPSCARD_READERSTATE_A m_rgReaderStates;
#endif
int m_cReaders;
FB::JSObjectPtr m_readers;
boost::thread m_thread;
};
#endif // H_WebCardAPI