X-Git-Url: https://gitweb.ps.run/matrix_esp_thesis/blobdiff_plain/9826729ea9eb492b0b25c52b934d9f1283bb70dd..80dc4ce95cbe915a3aaa7e2e18f545916d6ec769:/examples/SendEncrypted.c diff --git a/examples/SendEncrypted.c b/examples/SendEncrypted.c index 0c4a7c8..df1d272 100644 --- a/examples/SendEncrypted.c +++ b/examples/SendEncrypted.c @@ -2,9 +2,8 @@ #include #define SERVER "https://matrix.org" -#define ACCESS_TOKEN "syt_cHNjaG8_yBvTjVTquGCikvsAenOJ_49mBMO" -#define DEVICE_ID "MAZNCCZLBR" -#define ROOM_ID "!koVStwyiiKcBVbXZYz:matrix.org" +#define USER_ID "@pscho:matrix.org" +#define ROOM_ID "!XKFUjAsGrSSrpDFIxB:matrix.org" int main(void) @@ -15,16 +14,46 @@ main(void) MatrixHttpInit(&client); - MatrixClientSetAccessToken(&client, - ACCESS_TOKEN); - MatrixClientSetDeviceId(&client, - DEVICE_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, @@ -32,6 +61,8 @@ main(void) "m.room.message", "{\"body\":\"Hello\",\"msgtype\":\"m.text\"}"); + MatrixClientDeleteDevice(&client); + MatrixHttpDeinit(&client); return 0;