X-Git-Url: https://gitweb.ps.run/matrix_esp_thesis/blobdiff_plain/8d8ae609f0201ec4640738ff49b768e899695423..HEAD:/examples/SendEncrypted.c diff --git a/examples/SendEncrypted.c b/examples/SendEncrypted.c index df1d272..749037d 100644 --- a/examples/SendEncrypted.c +++ b/examples/SendEncrypted.c @@ -1,69 +1,56 @@ #include #include -#define SERVER "https://matrix.org" -#define USER_ID "@pscho:matrix.org" -#define ROOM_ID "!XKFUjAsGrSSrpDFIxB:matrix.org" +#define SERVER "https://matrix.org" +#define USER_ID "@example:matrix.org" +#define ROOM_ID "!example:matrix.org" +#define USERNAME "" +#define PASSWORD "" +#define DEVICE_NAME "" + +// device id of another device to share the megolm session with +// I used the device id of a logged in Element web session +#define DEVICE_ID2 "" int main(void) { MatrixClient client; - MatrixClientInit(&client, - SERVER); + MatrixClientInit(&client); - MatrixHttpInit(&client); + MatrixHttpInit(&client.hc, SERVER); MatrixClientSetUserId(&client, USER_ID); MatrixClientLoginPassword(&client, - "pscho", - "Wc23EbmB9G3faMq", - "Test1"); + USERNAME, + PASSWORD, + DEVICE_NAME); - MatrixClientUploadDeviceKey(&client); + MatrixClientUploadDeviceKeys(&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, + MatrixClientNewMegolmOutSession(&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", + DEVICE_ID2, megolmOutSession); - // MatrixClientShareMegolmOutSessionTest(&client, - // USER_ID, - // "ULZZOKJBYN", - // megolmOutSession); MatrixClientSendEventEncrypted(&client, ROOM_ID, "m.room.message", "{\"body\":\"Hello\",\"msgtype\":\"m.text\"}"); - + MatrixClientDeleteDevice(&client); - MatrixHttpDeinit(&client); + MatrixHttpDeinit(&client.hc); return 0; }