]> gitweb.ps.run Git - matrix_esp_thesis/blob - src/matrix.h
2e7f6e0e9a6861fa70839a18b2c8dd8ca27b19b4
[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+1];\r
25     char accessTokenBuffer[ACCESS_TOKEN_SIZE];\r
26     char deviceIdBuffer[DEVICE_ID_SIZE];\r
27     char expireMsBuffer[EXPIRE_MS_SIZE];\r
28     char refreshTokenBuffer[REFRESH_TOKEN_SIZE];\r
29 \r
30     void * httpUserData;\r
31 } MatrixClient;\r
32 \r
33 bool\r
34 MatrixClientInit(\r
35     MatrixClient * client,\r
36     const char * server);\r
37 \r
38 bool\r
39 MatrixClientSetAccessToken(\r
40     MatrixClient * client,\r
41     const char * accessToken);\r
42 \r
43 bool\r
44 MatrixClientLoginPassword(\r
45     MatrixClient * client,\r
46     const char * username,\r
47     const char * password,\r
48     const char * displayName);\r
49     \r
50 bool\r
51 MatrixClientSendEvent(\r
52     MatrixClient * client,\r
53     const char * roomId,\r
54     const char * msgType,\r
55     const char * msgBody);\r
56 \r
57 bool\r
58 MatrixHttpInit(\r
59     MatrixClient * client);\r
60 \r
61 bool\r
62 MatrixHttpDeinit(\r
63     MatrixClient * client);\r
64 \r
65 bool\r
66 MatrixHttpGet(\r
67     MatrixClient * client,\r
68     const char * url,\r
69     char * outResponseBuffer, int outResponseCap,\r
70     bool authenticated);\r
71 \r
72 bool\r
73 MatrixHttpPost(\r
74     MatrixClient * client,\r
75     const char * url,\r
76     const char * requestBuffer,\r
77     char * outResponseBuffer, int outResponseCap,\r
78     bool authenticated);\r
79 \r
80 bool\r
81 MatrixHttpPut(\r
82     MatrixClient * client,\r
83     const char * url,\r
84     const char * requestBuffer,\r
85     char * outResponseBuffer, int outResponseCap,\r
86     bool authenticated);\r
87 \r
88 #endif\r