]> gitweb.ps.run Git - matrix_esp_thesis/blobdiff - src/matrix.h
HTTP layer for ESP32, make static specifier in matrix.c optional by defining it as...
[matrix_esp_thesis] / src / matrix.h
index 4037f0968705f717c8b6cbd7f17394672662be4b..d31a7f6abd8f4d9b01173b14e8101b1fde320b72 100644 (file)
 \r
 #define NUM_MEGOLM_SESSIONS 10\r
 #define NUM_OLM_SESSIONS 10\r
-#define NUM_DEVICES 100\r
+#define NUM_DEVICES 10\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
@@ -357,6 +402,13 @@ MatrixClientRequestMegolmInSession(
 \r
 bool\r
 MatrixClientGetOlmSessionIn(\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
@@ -369,6 +421,13 @@ MatrixClientGetOlmSessionOut(
     const char * userId,\r
     const char * deviceId,\r
     MatrixOlmSession ** outSession);\r
+    \r
+bool\r
+MatrixClientNewOlmSessionOut(\r
+    MatrixClient * client,\r
+    const char * userId,\r
+    const char * deviceId,\r
+    MatrixOlmSession ** outSession);\r
 \r
 bool\r
 MatrixClientSendToDevice(\r
@@ -413,43 +472,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