X-Git-Url: https://gitweb.ps.run/matrix_esp_thesis/blobdiff_plain/fb5f3a8652d1cd3e4d8207f8718359f90636b5b3..b231872efcb97e52856f5972efd161c6e9b03cd6:/examples/SendEncrypted.c diff --git a/examples/SendEncrypted.c b/examples/SendEncrypted.c index f2bb8df..df1d272 100644 --- a/examples/SendEncrypted.c +++ b/examples/SendEncrypted.c @@ -2,8 +2,6 @@ #include #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" @@ -16,29 +14,55 @@ main(void) MatrixHttpInit(&client); - MatrixClientSetAccessToken(&client, - ACCESS_TOKEN); - MatrixClientSetDeviceId(&client, - DEVICE_ID); - MatrixClientSetUserId(&client, - USER_ID); + MatrixClientSetUserId(&client, USER_ID); - // MatrixMegolmOutSession megolmOutSession; - // MatrixMegolmOutSessionInit(&megolmOutSession); + MatrixClientLoginPassword(&client, + "pscho", + "Wc23EbmB9G3faMq", + "Test1"); - // MatrixClientSetMegolmOutSession(&client, - // ROOM_ID, + MatrixClientUploadDeviceKey(&client); + MatrixClientGenerateOnetimeKeys(&client, 10); + MatrixClientUploadOnetimeKeys(&client); + + // // get device key + // static char deviceKey[128]; + // MatrixClientGetDeviceKey(&client, + // "ULZZOKJBYN", + // deviceKey, 128); + // printf("device key for %s: %s\n", "ULZZOKJBYN", deviceKey); + + // create megolmsession + MatrixMegolmOutSession * megolmOutSession; + MatrixClientGetMegolmOutSession(&client, + ROOM_ID, + &megolmOutSession); + printf("megolm session id: %.10s... key: %.10s...\n", megolmOutSession->id, megolmOutSession->key); + + // // create olmsession + // MatrixOlmSession * olmSession; + // MatrixClientGetOlmSession(&client, + // USER_ID, + // "ULZZOKJBYN", + // &olmSession); + // printf("olm session created\n"); + + MatrixClientShareMegolmOutSession(&client, + USER_ID, + "ULZZOKJBYN", + megolmOutSession); + // MatrixClientShareMegolmOutSessionTest(&client, + // USER_ID, + // "ULZZOKJBYN", // megolmOutSession); MatrixClientSendEventEncrypted(&client, ROOM_ID, "m.room.message", "{\"body\":\"Hello\",\"msgtype\":\"m.text\"}"); - - MatrixClientShareMegolmOutSessionTest(&client, - "ULZZOKJBYN", - &client.megolmOutSessions[0]); + MatrixClientDeleteDevice(&client); + MatrixHttpDeinit(&client); return 0;