X-Git-Url: https://gitweb.ps.run/matrix_esp_thesis/blobdiff_plain/c7aba5979c820958aa08947903afb47ace496a16..8d8ae609f0201ec4640738ff49b768e899695423:/examples/SendEncrypted.c diff --git a/examples/SendEncrypted.c b/examples/SendEncrypted.c index 0005592..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,32 +14,55 @@ main(void) MatrixHttpInit(&client); - MatrixClientSetAccessToken(&client, - ACCESS_TOKEN); - MatrixClientSetDeviceId(&client, - DEVICE_ID); - MatrixClientSetUserId(&client, - USER_ID); + MatrixClientSetUserId(&client, USER_ID); + MatrixClientLoginPassword(&client, + "pscho", + "Wc23EbmB9G3faMq", + "Test1"); - MatrixClientUploadDeviceKeys(&client); + MatrixClientUploadDeviceKey(&client); + MatrixClientGenerateOnetimeKeys(&client, 10); + MatrixClientUploadOnetimeKeys(&client); - MatrixClientSendEventEncrypted(&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, - "m.room.message", - "{\"body\":\"Hello\",\"msgtype\":\"m.text\"}"); + &megolmOutSession); + printf("megolm session id: %.10s... key: %.10s...\n", megolmOutSession->id, megolmOutSession->key); - MatrixClientSendToDeviceEncrypted(&client, - USER_ID, - "ULZZOKJBYN", - "{}", - "m.dummy"); + // // create olmsession + // MatrixOlmSession * olmSession; + // MatrixClientGetOlmSession(&client, + // USER_ID, + // "ULZZOKJBYN", + // &olmSession); + // printf("olm session created\n"); MatrixClientShareMegolmOutSession(&client, USER_ID, "ULZZOKJBYN", - &client.megolmOutSessions[0]); + megolmOutSession); + // MatrixClientShareMegolmOutSessionTest(&client, + // USER_ID, + // "ULZZOKJBYN", + // megolmOutSession); + + MatrixClientSendEventEncrypted(&client, + ROOM_ID, + "m.room.message", + "{\"body\":\"Hello\",\"msgtype\":\"m.text\"}"); + MatrixClientDeleteDevice(&client); + MatrixHttpDeinit(&client); return 0;