X-Git-Url: https://gitweb.ps.run/matrix_esp_thesis/blobdiff_plain/8d8ae609f0201ec4640738ff49b768e899695423..HEAD:/examples/Cli.c diff --git a/examples/Cli.c b/examples/Cli.c index 56c23e1..bcd3a12 100644 --- a/examples/Cli.c +++ b/examples/Cli.c @@ -4,9 +4,11 @@ #include #include -#define SERVER "https://matrix.org" -#define USER_ID "@pscho:matrix.org" -#define ROOM_ID "!XKFUjAsGrSSrpDFIxB:matrix.org" +#define SERVER "https://matrix.org" +#define USER_ID "@example:matrix.org" +#define USERNAME "" +#define PASSWORD "" +#define DEVICE_NAME "" #define BUFFER_SIZE 1024 #define NUMBER_ARGS 10 @@ -96,7 +98,7 @@ ExecuteCommand( MatrixClientUploadOnetimeKeys(client); } else if (CheckCommand(cmd, "uploaddevicekey")) { - MatrixClientUploadDeviceKey(client); + MatrixClientUploadDeviceKeys(client); } else if (CheckCommand(cmd, "onetimekeys")) { static char buffer[1024]; @@ -130,8 +132,9 @@ ExecuteCommand( } else if (CheckCommand(cmd, "todevice")) { static char buffer[30000]; + static char nextBatch[128]; MatrixClientSync(client, - buffer, 30000); + buffer, 30000, nextBatch, 128); const char * todevice; int todeviceLen; mjson_find(buffer, 30000, @@ -151,16 +154,6 @@ ExecuteCommand( args[1], args[2]); } - else if (CheckCommand(cmd, "save")) { - CHECK_ARGS(1, "") - - MatrixClientSave(client, args[0]); - } - else if (CheckCommand(cmd, "load")) { - CHECK_ARGS(1, "") - - MatrixClientLoad(client, args[0]); - } else if (CheckCommand(cmd, "send")) { CHECK_ARGS(2, " ") @@ -218,26 +211,6 @@ ExecuteCommand( 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, @@ -249,8 +222,10 @@ ExecuteCommand( else if (CheckCommand(cmd, "initsession")) { CHECK_ARGS(1, "") - if (! MatrixClientInitMegolmOutSession(client, - args[0])) + MatrixMegolmOutSession * megolmOutSession; + if (! MatrixClientNewMegolmOutSession(client, + args[0], + &megolmOutSession)) { printf("Maximum number of Megolm sessions reached (%d)\n", NUM_MEGOLM_SESSIONS); } @@ -269,16 +244,15 @@ int main(void) { MatrixClient client; - MatrixClientInit(&client, - SERVER); + MatrixClientInit(&client); - MatrixHttpInit(&client); + MatrixHttpInit(&client.hc, SERVER); MatrixClientSetUserId(&client, USER_ID); - MatrixClientLoginPassword(&client, "@pscho:matrix.org", "Wc23EbmB9G3faMq", "abc"); + MatrixClientLoginPassword(&client, USERNAME, PASSWORD, DEVICE_NAME); MatrixClientGenerateOnetimeKeys(&client, 10); - MatrixClientUploadDeviceKey(&client); + MatrixClientUploadDeviceKeys(&client); MatrixClientUploadOnetimeKeys(&client); @@ -300,7 +274,7 @@ main(void) MatrixClientDeleteDevice(&client); - MatrixHttpDeinit(&client); + MatrixHttpDeinit(&client.hc); return 0; }