]> gitweb.ps.run Git - matrix_esp_thesis/blobdiff - src/matrix.h
share, save, load, init, print megolm out sessions
[matrix_esp_thesis] / src / matrix.h
index a06eab9e0edb7c0a510819f3bf4f101ab5019caf..3614b6a74c4f89c91f268d47f8fbc041e654e962 100644 (file)
@@ -11,6 +11,7 @@
 \r
 \r
 #define USER_ID_SIZE 64\r
+#define ROOM_ID_SIZE 128\r
 #define SERVER_SIZE 20\r
 #define ACCESS_TOKEN_SIZE 40\r
 #define DEVICE_ID_SIZE 20\r
 #define NUM_OLM_SESSIONS 10\r
 #define NUM_DEVICES 10\r
 \r
-void\r
-Randomize(uint8_t * random, int randomLen);\r
-\r
-bool\r
-JsonEscape(\r
-    const char * sIn, int sInLen,\r
-    char * sOut, int sOutCap);\r
-    \r
-bool JsonSign(\r
-    const char * sIn, int sInLen,\r
-    char * sOut, int sOutCap);\r
-\r
 // Matrix Device\r
 \r
 typedef struct MatrixDevice {\r
@@ -114,7 +103,7 @@ typedef struct MatrixMegolmInSession {
 } MatrixMegolmInSession;\r
 \r
 typedef struct MatrixMegolmOutSession {\r
-    const char * roomId;\r
+    char roomId[ROOM_ID_SIZE];\r
 \r
     OlmOutboundGroupSession * session;\r
     char memory[MEGOLM_OUTBOUND_SESSION_MEMORY_SIZE];\r
@@ -127,13 +116,25 @@ bool
 MatrixMegolmOutSessionInit(\r
     MatrixMegolmOutSession * session,\r
     const char * roomId);\r
-    \r
+\r
 bool\r
 MatrixMegolmOutSessionEncrypt(\r
     MatrixMegolmOutSession * session,\r
     const char * plaintext,\r
     char * outBuffer, int outBufferCap);\r
 \r
+bool\r
+MatrixMegolmOutSessionSave(\r
+    MatrixMegolmOutSession * session,\r
+    const char * filename,\r
+    const char * key);\r
+    \r
+bool\r
+MatrixMegolmOutSessionLoad(\r
+    MatrixMegolmOutSession * session,\r
+    const char * filename,\r
+    const char * key);\r
+\r
 \r
 // Matrix Client\r
 \r
@@ -168,6 +169,16 @@ MatrixClientInit(
     MatrixClient * client,\r
     const char * server);\r
 \r
+bool\r
+MatrixClientSave(\r
+    MatrixClient * client,\r
+    const char * filename);\r
+\r
+bool\r
+MatrixClientLoad(\r
+    MatrixClient * client,\r
+    const char * filename);\r
+\r
 bool\r
 MatrixClientSetAccessToken(\r
     MatrixClient * client,\r
@@ -254,6 +265,11 @@ MatrixClientSetMegolmOutSession(
     const char * roomId,\r
     MatrixMegolmOutSession session);\r
 \r
+bool\r
+MatrixClientInitMegolmOutSession(\r
+    MatrixClient * client,\r
+    const char * roomId);\r
+\r
 bool\r
 MatrixClientGetOlmSession(\r
     MatrixClient * client,\r
@@ -295,6 +311,7 @@ MatrixClientRequestDeviceKeys(
 \r
 \r
 \r
+\r
 bool\r
 MatrixHttpInit(\r
     MatrixClient * client);\r
@@ -330,4 +347,19 @@ MatrixHttpPut(
     char * outResponseBuffer, int outResponseCap,\r
     bool authenticated);\r
 \r
+// util\r
+\r
+void\r
+Randomize(uint8_t * random, int randomLen);\r
+\r
+bool\r
+JsonEscape(\r
+    const char * sIn, int sInLen,\r
+    char * sOut, int sOutCap);\r
+    \r
+bool JsonSign(\r
+    MatrixClient * client,\r
+    const char * sIn, int sInLen,\r
+    char * sOut, int sOutCap);\r
+\r
 #endif\r