X-Git-Url: https://gitweb.ps.run/matrix_esp_thesis/blobdiff_plain/ad9d01050b7b6d592a83ce14eeef7068bd981028..ef693c75de0b5719d47ab404616bf97b9f901524:/examples/SendEncrypted.c diff --git a/examples/SendEncrypted.c b/examples/SendEncrypted.c index db2f83c..3debeab 100644 --- a/examples/SendEncrypted.c +++ b/examples/SendEncrypted.c @@ -2,35 +2,48 @@ #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) { MatrixClient client; - MatrixClientInit(&client, - SERVER); + MatrixClientInit(&client); - MatrixHttpInit(&client); + MatrixHttpInit(&client.hc, SERVER); - MatrixClientSetAccessToken(&client, - ACCESS_TOKEN); + MatrixClientSetUserId(&client, USER_ID); - // MatrixMegolmOutSession megolmOutSession; - // MatrixMegolmOutSessionInit(&megolmOutSession); + MatrixClientLoginPassword(&client, + "pscho", + "Wc23EbmB9G3faMq", + "Test1"); - // MatrixClientSetMegolmOutSession(&client, - // ROOM_ID, - // megolmOutSession); + MatrixClientUploadDeviceKeys(&client); + MatrixClientGenerateOnetimeKeys(&client, 10); + MatrixClientUploadOnetimeKeys(&client); + + // create megolmsession + MatrixMegolmOutSession * megolmOutSession; + MatrixClientNewMegolmOutSession(&client, + ROOM_ID, + &megolmOutSession); + printf("megolm session id: %.10s... key: %.10s...\n", megolmOutSession->id, megolmOutSession->key); + + MatrixClientShareMegolmOutSession(&client, + USER_ID, + "ULZZOKJBYN", + megolmOutSession); MatrixClientSendEventEncrypted(&client, ROOM_ID, "m.room.message", "{\"body\":\"Hello\",\"msgtype\":\"m.text\"}"); - - MatrixHttpDeinit(&client); + + MatrixClientDeleteDevice(&client); + + MatrixHttpDeinit(&client.hc); return 0; }