]> gitweb.ps.run Git - matrix_esp_thesis/blobdiff - src/matrix.h
fix examples
[matrix_esp_thesis] / src / matrix.h
index 4037f0968705f717c8b6cbd7f17394672662be4b..c07c742b0f6463a841d5f7810933d7c1d93c25c6 100644 (file)
 #define JSON_ONETIME_KEY_SIGNED_SIZE 256\r
 #define JSON_SIGNATURE_SIZE 256\r
 \r
-#define NUM_MEGOLM_SESSIONS 10\r
-#define NUM_OLM_SESSIONS 10\r
-#define NUM_DEVICES 100\r
+#define NUM_MEGOLM_SESSIONS 2\r
+#define NUM_OLM_SESSIONS 2\r
+#define NUM_DEVICES 5\r
+\r
+// HTTP\r
+\r
+typedef struct MatrixHttpConnection MatrixHttpConnection;\r
+\r
+bool\r
+MatrixHttpInit(\r
+    MatrixHttpConnection ** hc,\r
+    const char * host);\r
+\r
+// bool\r
+// MatrixHttpConnect(\r
+//     MatrixHttpConnection * hc);\r
+\r
+bool\r
+MatrixHttpDeinit(\r
+    MatrixHttpConnection ** hc);\r
+    \r
+bool\r
+MatrixHttpSetAccessToken(\r
+    MatrixHttpConnection * hc,\r
+    const char * accessToken);\r
+\r
+bool\r
+MatrixHttpGet(\r
+    MatrixHttpConnection * hc,\r
+    const char * url,\r
+    char * outResponseBuffer, int outResponseCap,\r
+    bool authenticated);\r
+\r
+bool\r
+MatrixHttpPost(\r
+    MatrixHttpConnection * hc,\r
+    const char * url,\r
+    const char * requestBuffer,\r
+    char * outResponseBuffer, int outResponseCap,\r
+    bool authenticated);\r
+\r
+bool\r
+MatrixHttpPut(\r
+    MatrixHttpConnection * hc,\r
+    const char * url,\r
+    const char * requestBuffer,\r
+    char * outResponseBuffer, int outResponseCap,\r
+    bool authenticated);\r
+\r
+\r
 \r
 // Matrix Device\r
 \r
@@ -212,19 +259,17 @@ typedef struct MatrixClient {
     // char signingKey[DEVICE_KEY_SIZE];\r
 \r
     char userId[USER_ID_SIZE];\r
-    char server[SERVER_SIZE];\r
     char accessToken[ACCESS_TOKEN_SIZE];\r
     char deviceId[DEVICE_ID_SIZE];\r
     char expireMs[EXPIRE_MS_SIZE];\r
     char refreshToken[REFRESH_TOKEN_SIZE];\r
 \r
-    void * httpUserData;\r
+    MatrixHttpConnection * hc;\r
 } MatrixClient;\r
 \r
 bool\r
 MatrixClientInit(\r
-    MatrixClient * client,\r
-    const char * server);\r
+    MatrixClient * client);\r
 \r
 bool\r
 MatrixClientSave(\r
@@ -356,7 +401,14 @@ MatrixClientRequestMegolmInSession(
     const char * deviceId); // TODO: remove deviceId (query all devices)\r
 \r
 bool\r
-MatrixClientGetOlmSessionIn(\r
+MatrixClientGetOlmSession(\r
+    MatrixClient * client,\r
+    const char * userId,\r
+    const char * deviceId,\r
+    MatrixOlmSession ** outSession);\r
+\r
+bool\r
+MatrixClientNewOlmSessionIn(\r
     MatrixClient * client,\r
     const char * userId,\r
     const char * deviceId,\r
@@ -364,7 +416,7 @@ MatrixClientGetOlmSessionIn(
     MatrixOlmSession ** outSession);\r
     \r
 bool\r
-MatrixClientGetOlmSessionOut(\r
+MatrixClientNewOlmSessionOut(\r
     MatrixClient * client,\r
     const char * userId,\r
     const char * deviceId,\r
@@ -413,43 +465,6 @@ MatrixClientDeleteDevice(
     MatrixClient * client);\r
 \r
 \r
-\r
-\r
-bool\r
-MatrixHttpInit(\r
-    MatrixClient * client);\r
-\r
-bool\r
-MatrixHttpConnect(\r
-    MatrixClient * client);\r
-\r
-bool\r
-MatrixHttpDeinit(\r
-    MatrixClient * client);\r
-\r
-bool\r
-MatrixHttpGet(\r
-    MatrixClient * client,\r
-    const char * url,\r
-    char * outResponseBuffer, int outResponseCap,\r
-    bool authenticated);\r
-\r
-bool\r
-MatrixHttpPost(\r
-    MatrixClient * client,\r
-    const char * url,\r
-    const char * requestBuffer,\r
-    char * outResponseBuffer, int outResponseCap,\r
-    bool authenticated);\r
-\r
-bool\r
-MatrixHttpPut(\r
-    MatrixClient * client,\r
-    const char * url,\r
-    const char * requestBuffer,\r
-    char * outResponseBuffer, int outResponseCap,\r
-    bool authenticated);\r
-\r
 // util\r
 \r
 void\r