X-Git-Url: https://gitweb.ps.run/matrix_esp_thesis/blobdiff_plain/d43e8671acc5709c192e159e0d91626f0677cdf1..d382d193cb2d550cc769afa76e55823865a39023:/src/matrix.h diff --git a/src/matrix.h b/src/matrix.h index d61c59b..2e7f6e0 100644 --- a/src/matrix.h +++ b/src/matrix.h @@ -8,43 +8,81 @@ +// 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 FixedBuffer { - void * ptr; - int size; - int len; -} FixedBuffer; +typedef struct MatrixClient { + OlmAccount * olmAccount; + OlmSession * olmSession; + + char server[SERVER_SIZE+1]; + char accessTokenBuffer[ACCESS_TOKEN_SIZE]; + char deviceIdBuffer[DEVICE_ID_SIZE]; + char expireMsBuffer[EXPIRE_MS_SIZE]; + char refreshTokenBuffer[REFRESH_TOKEN_SIZE]; + + void * httpUserData; +} MatrixClient; -FixedBuffer -FixedBuf(const char * str); +bool +MatrixClientInit( + MatrixClient * client, + const char * server); +bool +MatrixClientSetAccessToken( + MatrixClient * client, + const char * accessToken); +bool +MatrixClientLoginPassword( + MatrixClient * client, + const char * username, + const char * password, + const char * displayName); + +bool +MatrixClientSendEvent( + MatrixClient * client, + const char * roomId, + const char * msgType, + const char * msgBody); -#define ACCESS_TOKEN_LEN 20 // TODO: fix +bool +MatrixHttpInit( + MatrixClient * client); -typedef struct MatrixClient { - OlmAccount * olmAcc; - char accessToken[ACCESS_TOKEN_LEN]; -} MatrixClient; +bool +MatrixHttpDeinit( + MatrixClient * client); bool -MatrixClientInit( +MatrixHttpGet( MatrixClient * client, - FixedBuffer server -); + const char * url, + char * outResponseBuffer, int outResponseCap, + bool authenticated); bool -MatrixClientLoginPassword( +MatrixHttpPost( MatrixClient * client, - FixedBuffer username, - FixedBuffer password -); + const char * url, + const char * requestBuffer, + char * outResponseBuffer, int outResponseCap, + bool authenticated); bool -MatrixClientGetAccessToken( +MatrixHttpPut( MatrixClient * client, - FixedBuffer * outBuffer -); + const char * url, + const char * requestBuffer, + char * outResponseBuffer, int outResponseCap, + bool authenticated); #endif