X-Git-Url: https://gitweb.ps.run/matrix_esp_thesis/blobdiff_plain/b231872efcb97e52856f5972efd161c6e9b03cd6..eab8bbd317aa9887fd09c38a963ee80660d75ca0:/src/matrix.h?ds=sidebyside diff --git a/src/matrix.h b/src/matrix.h index 4037f09..c07c742 100644 --- a/src/matrix.h +++ b/src/matrix.h @@ -47,9 +47,56 @@ #define JSON_ONETIME_KEY_SIGNED_SIZE 256 #define JSON_SIGNATURE_SIZE 256 -#define NUM_MEGOLM_SESSIONS 10 -#define NUM_OLM_SESSIONS 10 -#define NUM_DEVICES 100 +#define NUM_MEGOLM_SESSIONS 2 +#define NUM_OLM_SESSIONS 2 +#define NUM_DEVICES 5 + +// HTTP + +typedef struct MatrixHttpConnection MatrixHttpConnection; + +bool +MatrixHttpInit( + MatrixHttpConnection ** hc, + const char * host); + +// bool +// MatrixHttpConnect( +// MatrixHttpConnection * hc); + +bool +MatrixHttpDeinit( + MatrixHttpConnection ** hc); + +bool +MatrixHttpSetAccessToken( + MatrixHttpConnection * hc, + const char * accessToken); + +bool +MatrixHttpGet( + MatrixHttpConnection * hc, + const char * url, + char * outResponseBuffer, int outResponseCap, + bool authenticated); + +bool +MatrixHttpPost( + MatrixHttpConnection * hc, + const char * url, + const char * requestBuffer, + char * outResponseBuffer, int outResponseCap, + bool authenticated); + +bool +MatrixHttpPut( + MatrixHttpConnection * hc, + const char * url, + const char * requestBuffer, + char * outResponseBuffer, int outResponseCap, + bool authenticated); + + // Matrix Device @@ -212,19 +259,17 @@ typedef struct MatrixClient { // char signingKey[DEVICE_KEY_SIZE]; char userId[USER_ID_SIZE]; - char server[SERVER_SIZE]; char accessToken[ACCESS_TOKEN_SIZE]; char deviceId[DEVICE_ID_SIZE]; char expireMs[EXPIRE_MS_SIZE]; char refreshToken[REFRESH_TOKEN_SIZE]; - void * httpUserData; + MatrixHttpConnection * hc; } MatrixClient; bool MatrixClientInit( - MatrixClient * client, - const char * server); + MatrixClient * client); bool MatrixClientSave( @@ -356,7 +401,14 @@ MatrixClientRequestMegolmInSession( const char * deviceId); // TODO: remove deviceId (query all devices) bool -MatrixClientGetOlmSessionIn( +MatrixClientGetOlmSession( + MatrixClient * client, + const char * userId, + const char * deviceId, + MatrixOlmSession ** outSession); + +bool +MatrixClientNewOlmSessionIn( MatrixClient * client, const char * userId, const char * deviceId, @@ -364,7 +416,7 @@ MatrixClientGetOlmSessionIn( MatrixOlmSession ** outSession); bool -MatrixClientGetOlmSessionOut( +MatrixClientNewOlmSessionOut( MatrixClient * client, const char * userId, const char * deviceId, @@ -413,43 +465,6 @@ MatrixClientDeleteDevice( MatrixClient * client); - - -bool -MatrixHttpInit( - MatrixClient * client); - -bool -MatrixHttpConnect( - MatrixClient * client); - -bool -MatrixHttpDeinit( - MatrixClient * client); - -bool -MatrixHttpGet( - MatrixClient * client, - const char * url, - char * outResponseBuffer, int outResponseCap, - bool authenticated); - -bool -MatrixHttpPost( - MatrixClient * client, - const char * url, - const char * requestBuffer, - char * outResponseBuffer, int outResponseCap, - bool authenticated); - -bool -MatrixHttpPut( - MatrixClient * client, - const char * url, - const char * requestBuffer, - char * outResponseBuffer, int outResponseCap, - bool authenticated); - // util void