2023-10-14 15:59:32 +02:00
|
|
|
#pragma once
|
|
|
|
|
2024-07-31 18:10:52 +02:00
|
|
|
#include <solanaceae/object_store/object_store.hpp>
|
2023-10-14 16:25:01 +02:00
|
|
|
#include <solanaceae/contact/contact_model3.hpp>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2023-10-14 15:59:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
// RIP fishy c=<
|
|
|
|
|
|
|
|
struct ConfigModelI;
|
|
|
|
struct ToxKey;
|
|
|
|
|
2024-07-31 18:10:52 +02:00
|
|
|
class ToxAvatarManager : public ObjectStoreEventI {
|
|
|
|
ObjectStore2& _os;
|
2023-10-14 15:59:32 +02:00
|
|
|
Contact3Registry& _cr;
|
|
|
|
ConfigModelI& _conf;
|
|
|
|
|
|
|
|
struct AcceptEntry {
|
2024-07-31 18:10:52 +02:00
|
|
|
ObjectHandle m;
|
2023-10-14 15:59:32 +02:00
|
|
|
std::string file_path;
|
|
|
|
};
|
|
|
|
std::vector<AcceptEntry> _accept_queue;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ToxAvatarManager(
|
2024-07-31 18:10:52 +02:00
|
|
|
ObjectStore2& os,
|
2023-10-14 15:59:32 +02:00
|
|
|
Contact3Registry& cr,
|
|
|
|
ConfigModelI& conf
|
|
|
|
);
|
|
|
|
|
|
|
|
void iterate(void);
|
|
|
|
|
|
|
|
protected:
|
2024-07-31 18:10:52 +02:00
|
|
|
// TODO: become backend and work in objects instead
|
2023-10-14 15:59:32 +02:00
|
|
|
std::string getAvatarPath(const ToxKey& key) const;
|
|
|
|
void addAvatarFileToContact(const Contact3 c, const ToxKey& key);
|
|
|
|
void clearAvatarFromContact(const Contact3 c);
|
2024-07-31 18:10:52 +02:00
|
|
|
void checkObj(ObjectHandle o);
|
2023-10-14 15:59:32 +02:00
|
|
|
|
2024-07-31 18:10:52 +02:00
|
|
|
protected: // os
|
|
|
|
bool onEvent(const ObjectStore::Events::ObjectConstruct& e) override;
|
|
|
|
bool onEvent(const ObjectStore::Events::ObjectUpdate& e) override;
|
2023-10-14 15:59:32 +02:00
|
|
|
};
|
|
|
|
|