Start of device storing

This commit is contained in:
timoreo 2023-12-11 20:58:32 +01:00
parent 25819c346a
commit fb37deb948
Signed by: timoreo
GPG key ID: 121A72C3512BA288
4 changed files with 33 additions and 2 deletions

View file

@ -48,7 +48,7 @@ private:
Store* store; Store* store;
std::string userIdCache; std::string userIdCache;
std::string deviceIdCache; std::string deviceIdCache;
std::atomic_uint32_t requestId = 0; uint32_t requestId = 0; //TODO make atomic
bool stopSyncing = false; bool stopSyncing = false;
bool isSyncing = false; bool isSyncing = false;
Thread syncThread; Thread syncThread;
@ -133,6 +133,8 @@ public:
void save_keys(); void save_keys();
void upload_keys(); void upload_keys();
void start_encryption(); void start_encryption();
void getDevices();
void processToDevice(json_t* data);
}; };
}; // namespace Matrix }; // namespace Matrix

5
source/devicestore.cpp Normal file
View file

@ -0,0 +1,5 @@
//
// Created by timoreo on 11/12/23.
//
#include "devicestore.h"

10
source/devicestore.h Normal file
View file

@ -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

View file

@ -483,6 +483,10 @@ void Client::setRoomLimitedCallback(roomLimitedCallback cb) {
} }
void Client::processSync(json_t* sync) { 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"); json_t* rooms = json_object_get(sync, "rooms");
if (!rooms) { if (!rooms) {
return; // nothing to do return; // nothing to do
@ -490,7 +494,7 @@ void Client::processSync(json_t* sync) {
json_t* leftRooms = json_object_get(rooms, "leave"); json_t* leftRooms = json_object_get(rooms, "leave");
json_t* invitedRooms = json_object_get(rooms, "invite"); json_t* invitedRooms = json_object_get(rooms, "invite");
json_t* joinedRooms = json_object_get(rooms, "join"); json_t* joinedRooms = json_object_get(rooms, "join");
const char* roomId; const char* roomId;
json_t* room; json_t* room;
size_t index; size_t index;
@ -1083,5 +1087,15 @@ void Client::start_encryption() {
ifs.read(reinterpret_cast<char*>(data.get()), static_cast<std::streamsize>(fsize)); ifs.read(reinterpret_cast<char*>(data.get()), static_cast<std::streamsize>(fsize));
olm::unpickle(data.get(), data.get() + fsize, acc); 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 }; // namespace Matrix