abouttreesummaryrefslogcommitdiff
path: root/src/matrix.h
blob: cd109ce87d81cb863404628606f70fd34beb320f (plain)
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];
    char accessTokenBuffer[ACCESS_TOKEN_SIZE];
    char deviceIdBuffer[DEVICE_ID_SIZE];
    char expireMsBuffer[EXPIRE_MS_SIZE];
    char refreshTokenBuffer[REFRESH_TOKEN_SIZE];

    void * httpUserData;
} MatrixClient;

bool
MatrixClientInit(
    MatrixClient * client,
    const char * server);

bool
MatrixClientLoginPassword(
    MatrixClient * client,
    const char * username,
    const char * password,
    const char * displayName);

bool
MatrixHttpInit(
    MatrixClient * client);

bool
MatrixHttpDeinit(
    MatrixClient * client);

bool
MatrixHttpGet(
    MatrixClient * client,
    const char * url,
    char * outResponseBuffer, int outResponseCap);

bool
MatrixHttpPost(
    MatrixClient * client,
    const char * url,
    const char * requestBuffer,
    char * outResponseBuffer, int outResponseCap);

#endif