abouttreesummaryrefslogcommitdiff
path: root/examples/SendEncrypted.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/SendEncrypted.c')
-rw-r--r--examples/SendEncrypted.c57
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;