X-Git-Url: https://gitweb.ps.run/matrix_esp_thesis/blobdiff_plain/07e667e29883740aa0b82199cf0518a2e2684e26..c7aba5979c820958aa08947903afb47ace496a16:/examples/Cli.c 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, " ") + CHECK_ARGS(3, " ") - 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, " ") + CHECK_ARGS(3, " ") + + 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, " ") + CHECK_ARGS(3, " ") + + 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, "") + + 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 }