X-Git-Url: https://gitweb.ps.run/matrix_esp_thesis/blobdiff_plain/464bfb1912d0806143386f61c33dd45fbafc38e8..c7aba5979c820958aa08947903afb47ace496a16:/examples/Cli.c diff --git a/examples/Cli.c b/examples/Cli.c index b2fbe45..daf79e9 100644 --- a/examples/Cli.c +++ b/examples/Cli.c @@ -133,8 +133,6 @@ ExecuteCommand( "{\"body\":\"%s\",\"msgtype\":\"m.text\"}", args[1]); - printf("Sending %s to %s\n", body, args[0]); - MatrixClientSendEvent(client, args[0], "m.room.message", @@ -148,6 +146,71 @@ ExecuteCommand( else if (CheckCommand(cmd, "getuserid")) { printf("User ID: %s\n", client->userId); } + else if (CheckCommand(cmd, "sendencrypted")) { + CHECK_ARGS(2, " ") + + static char body[1024]; + snprintf(body, 1024, + "{\"body\":\"%s\",\"msgtype\":\"m.text\"}", + args[1]); + + MatrixClientSendEventEncrypted(client, + args[0], + "m.room.message", + body); + } + else if (CheckCommand(cmd, "sharesession")) { + CHECK_ARGS(3, " ") + + int sessionIndex = atoi(args[0]); + + MatrixClientShareMegolmOutSession(client, + args[1], + args[2], + &client->megolmOutSessions[sessionIndex]); + } + else if (CheckCommand(cmd, "savesession")) { + CHECK_ARGS(3, " ") + + int sessionIndex = atoi(args[0]); + + MatrixMegolmOutSessionSave( + &client->megolmOutSessions[sessionIndex], + args[1], + args[2]); + } + else if (CheckCommand(cmd, "loadsession")) { + CHECK_ARGS(3, " ") + + int sessionIndex = atoi(args[0]); + + MatrixMegolmOutSessionLoad( + &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 }