diff options
| author | Patrick | 2023-08-26 14:41:39 +0200 |
|---|---|---|
| committer | Patrick | 2023-08-26 14:41:39 +0200 |
| commit | 8d8ae609f0201ec4640738ff49b768e899695423 (patch) | |
| tree | 1e70b0cd59d503fa6b02bd3c84eb84ec46325ff0 /examples/SendEncrypted.c | |
| parent | c7aba5979c820958aa08947903afb47ace496a16 (diff) | |
| download | matrix_esp_thesis-8d8ae609f0201ec4640738ff49b768e899695423.tar.gz matrix_esp_thesis-8d8ae609f0201ec4640738ff49b768e899695423.zip | |
able to send encrypted messages :)
Diffstat (limited to 'examples/SendEncrypted.c')
| -rw-r--r-- | examples/SendEncrypted.c | 57 |
1 files changed, 39 insertions, 18 deletions
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 <stdio.h>
#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;
|
