X-Git-Url: https://gitweb.ps.run/matrix_esp_thesis/blobdiff_plain/d43e8671acc5709c192e159e0d91626f0677cdf1..464bfb1912d0806143386f61c33dd45fbafc38e8:/examples/SendEncrypted.c diff --git a/examples/SendEncrypted.c b/examples/SendEncrypted.c index 2d3bd74..0005592 100644 --- a/examples/SendEncrypted.c +++ b/examples/SendEncrypted.c @@ -1,32 +1,48 @@ #include +#include -#define SERVER FixedBuf("matrix.org") -#define ACCESS_TOKEN FixedBuf("abc") -#define ROOM_ID FixedBuf("!jhpZBTbckszblMYjMK:matrix.org") +#define SERVER "https://matrix.org" +#define ACCESS_TOKEN "syt_cHNjaG8_yBvTjVTquGCikvsAenOJ_49mBMO" +#define DEVICE_ID "MAZNCCZLBR" +#define USER_ID "@pscho:matrix.org" +#define ROOM_ID "!XKFUjAsGrSSrpDFIxB:matrix.org" int -main( - int argc, - char **argv) +main(void) { MatrixClient client; - MatrixClientCreate(&client, + MatrixClientInit(&client, SERVER); + + MatrixHttpInit(&client); MatrixClientSetAccessToken(&client, ACCESS_TOKEN); + MatrixClientSetDeviceId(&client, + DEVICE_ID); + MatrixClientSetUserId(&client, + USER_ID); - MatrixMegolmSession megolm; - MatrixMegolmSessionInit(&megolm); - - MatrixRoomShareMegolmSession(&client, - ROOM_ID, - megolm); - - MatrixClientSendGroupEncrypted(&client, + + MatrixClientUploadDeviceKeys(&client); + + MatrixClientSendEventEncrypted(&client, ROOM_ID, - FixedBuf("m.room.message"), - FixedBuf("{\"body\":\"Hello\",\"msgtype\":\"m.text\"}")); + "m.room.message", + "{\"body\":\"Hello\",\"msgtype\":\"m.text\"}"); + + MatrixClientSendToDeviceEncrypted(&client, + USER_ID, + "ULZZOKJBYN", + "{}", + "m.dummy"); + + MatrixClientShareMegolmOutSession(&client, + USER_ID, + "ULZZOKJBYN", + &client.megolmOutSessions[0]); + + MatrixHttpDeinit(&client); return 0; -} \ No newline at end of file +}