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
|
#ifndef MATRIX__H
#define MATRIX__H
#include <stdbool.h>
#include <string.h>
#include <olm/olm.h>
// TODO: fix
#define SERVER_SIZE 20
#define ACCESS_TOKEN_SIZE 40
#define DEVICE_ID_SIZE 20
#define EXPIRE_MS_SIZE 20
#define REFRESH_TOKEN_SIZE 20
#define MAX_URL_LEN 128
typedef struct MatrixClient {
OlmAccount * olmAccount;
OlmSession * olmSession;
char server[SERVER_SIZE]; int serverLen;
char accessTokenBuffer[ACCESS_TOKEN_SIZE]; int accessTokenLen;
char deviceIdBuffer[DEVICE_ID_SIZE]; int deviceIdLen;
char expireMsBuffer[EXPIRE_MS_SIZE]; int expireMsLen;
char refreshTokenBuffer[REFRESH_TOKEN_SIZE]; int refreshTokenLen;
void * httpUserData;
} MatrixClient;
bool
MatrixClientInit(
MatrixClient * client,
char * server, int serverLen);
bool
MatrixClientLoginPassword(
MatrixClient * client,
char * username, int usernameLen,
char * password, int passwordLen,
char * displayName, int displayNameLen);
bool
MatrixHttpInit(
MatrixClient * client);
bool
MatrixHttpDeinit(
MatrixClient * client);
bool
MatrixHttpGet(
MatrixClient * client,
const char * url,
char * outResponseBuffer, int outResponseCap, int * outResponseLen);
bool
MatrixHttpPost(
MatrixClient * client,
const char * url,
char * requestBuffer, int requestLen,
char * outResponseBuffer, int outResponseCap, int * outResponseLen);
#endif
|