-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMacWifiLib.h
52 lines (45 loc) · 1.36 KB
/
MacWifiLib.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
#ifndef __MACWIFI__
#define __MACWIFI__
#include <string>
#include <functional>
#include <map>
#include "WifiEvents.h"
using namespace std;
class MacWifiResponse
{
public:
bool Success;
unsigned int StatusCode;
string ErrorMsg;
string Content;
long Id;
};
class MacWifiCallback
{
public:
function<void(MacWifiResponse&)> Callback;
long Id;
};
class MacWifiLib
{
public:
MacWifiLib();
void Get(const string& requestUri, function<void(MacWifiResponse&)> onComplete, long id = 0);
void Post(const string& requestUri, const string& content, function<void(MacWifiResponse&)> onComplete, long id = 0);
void Put(const string& requestUri, const string& content, function<void(MacWifiResponse&)> onComplete, long id = 0);
void SetAuthorization(string authorization);
OSErr ProcessReply(AppleEvent* appleEvent);
static string Encode(const string &value);
void Utf8ToMacRoman(bool enabled);
private:
OSType _appSig;
string _authorization;
bool _utf8ToMacRoman;
map<int, MacWifiCallback> _callbacks;
int _callbackIndex = 0;
void SendRequestEvent(const string& method, const string& uri, const string& content, function<void(MacWifiResponse&)> onComplete, long id);
void GetEventAddress(AEAddressDesc* address);
OSErr SendEvent(AppleEvent* appleEvent);
void GetParamAsString(AppleEvent* appleEvent, AEKeyword keyword, string& output);
};
#endif