From fb37deb948fd57da3d83aaa40ef5ed1a5d3d6f99 Mon Sep 17 00:00:00 2001 From: timoreo Date: Mon, 11 Dec 2023 20:58:32 +0100 Subject: [PATCH] Start of device storing --- include/matrixclient.h | 4 +++- source/devicestore.cpp | 5 +++++ source/devicestore.h | 10 ++++++++++ source/matrixclient.cpp | 16 +++++++++++++++- 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 source/devicestore.cpp create mode 100644 source/devicestore.h diff --git a/include/matrixclient.h b/include/matrixclient.h index 7d086a4..84abeee 100644 --- a/include/matrixclient.h +++ b/include/matrixclient.h @@ -48,7 +48,7 @@ private: Store* store; std::string userIdCache; std::string deviceIdCache; - std::atomic_uint32_t requestId = 0; + uint32_t requestId = 0; //TODO make atomic bool stopSyncing = false; bool isSyncing = false; Thread syncThread; @@ -133,6 +133,8 @@ public: void save_keys(); void upload_keys(); void start_encryption(); + void getDevices(); + void processToDevice(json_t* data); }; }; // namespace Matrix diff --git a/source/devicestore.cpp b/source/devicestore.cpp new file mode 100644 index 0000000..2f568f9 --- /dev/null +++ b/source/devicestore.cpp @@ -0,0 +1,5 @@ +// +// Created by timoreo on 11/12/23. +// + +#include "devicestore.h" diff --git a/source/devicestore.h b/source/devicestore.h new file mode 100644 index 0000000..f6e4114 --- /dev/null +++ b/source/devicestore.h @@ -0,0 +1,10 @@ +// +// Created by timoreo on 11/12/23. +// + +#ifndef MATRIX_3DS_CLIENT_DEVICESTORE_H +#define MATRIX_3DS_CLIENT_DEVICESTORE_H + +class DeviceStore {}; + +#endif // MATRIX_3DS_CLIENT_DEVICESTORE_H diff --git a/source/matrixclient.cpp b/source/matrixclient.cpp index f437964..56e23cf 100644 --- a/source/matrixclient.cpp +++ b/source/matrixclient.cpp @@ -483,6 +483,10 @@ void Client::setRoomLimitedCallback(roomLimitedCallback cb) { } void Client::processSync(json_t* sync) { + json_t* to_device = json_object_get(sync, "to_device"); + if(to_device){ + processToDevice(to_device); + } json_t* rooms = json_object_get(sync, "rooms"); if (!rooms) { return; // nothing to do @@ -490,7 +494,7 @@ void Client::processSync(json_t* sync) { json_t* leftRooms = json_object_get(rooms, "leave"); json_t* invitedRooms = json_object_get(rooms, "invite"); json_t* joinedRooms = json_object_get(rooms, "join"); - + const char* roomId; json_t* room; size_t index; @@ -1083,5 +1087,15 @@ void Client::start_encryption() { ifs.read(reinterpret_cast(data.get()), static_cast(fsize)); olm::unpickle(data.get(), data.get() + fsize, acc); } +} +void Client::getDevices(){ + // To get the devices, we need to do a /keys/query req + // We then need to keep up to date using /sync to_device (see processToDevice) + // This will need to all be cached + +} + +void Client::processToDevice(json_t* data) { + } }; // namespace Matrix