abouttreesummaryrefslogcommitdiff
path: root/examples
diff options
context:
space:
mode:
authorPatrick2023-07-21 23:04:48 +0200
committerPatrick2023-07-21 23:04:48 +0200
commitc7aba5979c820958aa08947903afb47ace496a16 (patch)
tree42dbeb78e724c62199e127ddf1712e662ab14419 /examples
parent07e667e29883740aa0b82199cf0518a2e2684e26 (diff)
downloadmatrix_esp_thesis-c7aba5979c820958aa08947903afb47ace496a16.tar.gz
matrix_esp_thesis-c7aba5979c820958aa08947903afb47ace496a16.zip
share, save, load, init, print megolm out sessions
Diffstat (limited to 'examples')
-rw-r--r--examples/Cli.c52
1 files changed, 40 insertions, 12 deletions
diff --git a/examples/Cli.c b/examples/Cli.c
index 4a8e571..daf79e9 100644
--- a/examples/Cli.c
+++ b/examples/Cli.c
@@ -160,28 +160,56 @@ ExecuteCommand(
body);
}
else if (CheckCommand(cmd, "sharesession")) {
- CHECK_ARGS(2, "<user_id> <device_id>")
+ CHECK_ARGS(3, "<session_index> <user_id> <device_id>")
- MatrixClientShareMegolmOutSession(&client,
- args[0],
+ int sessionIndex = atoi(args[0]);
+
+ MatrixClientShareMegolmOutSession(client,
args[1],
- &client->megolmOutSessions[0]);
+ args[2],
+ &client->megolmOutSessions[sessionIndex]);
}
else if (CheckCommand(cmd, "savesession")) {
- CHECK_ARGS(2, "<filename> <key>")
+ CHECK_ARGS(3, "<session_index> <filename> <key>")
+
+ int sessionIndex = atoi(args[0]);
MatrixMegolmOutSessionSave(
- &client->megolmOutSessions[0],
- args[0],
- args[1]);
+ &client->megolmOutSessions[sessionIndex],
+ args[1],
+ args[2]);
}
else if (CheckCommand(cmd, "loadsession")) {
- CHECK_ARGS(2, "<filename> <key>")
+ CHECK_ARGS(3, "<session_index> <filename> <key>")
+
+ int sessionIndex = atoi(args[0]);
MatrixMegolmOutSessionLoad(
- &client->megolmOutSessions[0],
- args[0],
- args[1]);
+ &client->megolmOutSessions[sessionIndex],
+ args[1],
+ args[2]);
+ }
+ else if (CheckCommand(cmd, "printsessions")) {
+ for (int i = 0; i < client->numMegolmOutSessions; i++) {
+ printf("%d: %s\t%s\t%s\n", i,
+ client->megolmOutSessions[i].roomId,
+ client->megolmOutSessions[i].id,
+ client->megolmOutSessions[i].key);
+ }
+ }
+ else if (CheckCommand(cmd, "initsession")) {
+ CHECK_ARGS(1, "<room_id>")
+
+ if (! MatrixClientInitMegolmOutSession(client,
+ args[0]))
+ {
+ printf("Maximum number of Megolm sessions reached (%d)\n", NUM_MEGOLM_SESSIONS);
+ }
+ }
+
+
+ else {
+ printf("Unknown command\n");
}
#undef CHECK_ARGS
}