]> gitweb.ps.run Git - matrix_esp_thesis/blob - src/matrix.h
mongoose as http client
[matrix_esp_thesis] / src / matrix.h
1 #ifndef MATRIX__H\r
2 #define MATRIX__H\r
3 \r
4 #include <stdbool.h>\r
5 #include <string.h>\r
6 \r
7 #include <olm/olm.h>\r
8 \r
9 \r
10 \r
11 // TODO: fix\r
12 #define SERVER_SIZE 20\r
13 #define ACCESS_TOKEN_SIZE 40\r
14 #define DEVICE_ID_SIZE 20\r
15 #define EXPIRE_MS_SIZE 20\r
16 #define REFRESH_TOKEN_SIZE 20\r
17 #define MAX_URL_LEN 128\r
18 \r
19 \r
20 typedef struct MatrixClient {\r
21     OlmAccount * olmAccount;\r
22     OlmSession * olmSession;\r
23     \r
24     char server[SERVER_SIZE]; int serverLen;\r
25     char accessTokenBuffer[ACCESS_TOKEN_SIZE]; int accessTokenLen;\r
26     char deviceIdBuffer[DEVICE_ID_SIZE]; int deviceIdLen;\r
27     char expireMsBuffer[EXPIRE_MS_SIZE]; int expireMsLen;\r
28     char refreshTokenBuffer[REFRESH_TOKEN_SIZE]; int refreshTokenLen;\r
29 \r
30     void * httpUserData;\r
31 } MatrixClient;\r
32 \r
33 bool\r
34 MatrixClientInit(\r
35     MatrixClient * client,\r
36     char * server, int serverLen);\r
37 \r
38 bool\r
39 MatrixClientLoginPassword(\r
40     MatrixClient * client,\r
41     char * username, int usernameLen,\r
42     char * password, int passwordLen,\r
43     char * displayName, int displayNameLen);\r
44 \r
45 bool\r
46 MatrixHttpInit(\r
47     MatrixClient * client);\r
48 \r
49 bool\r
50 MatrixHttpDeinit(\r
51     MatrixClient * client);\r
52 \r
53 bool\r
54 MatrixHttpGet(\r
55     MatrixClient * client,\r
56     const char * url,\r
57     char * outResponseBuffer, int outResponseCap, int * outResponseLen);\r
58 \r
59 bool\r
60 MatrixHttpPost(\r
61     MatrixClient * client,\r
62     const char * url,\r
63     char * requestBuffer, int requestLen,\r
64     char * outResponseBuffer, int outResponseCap, int * outResponseLen);\r
65 \r
66 #endif\r