This commit is contained in:
Green Sky 2024-10-24 15:55:44 +02:00
parent a0c3336f37
commit ce894c1f88
No known key found for this signature in database
6 changed files with 63 additions and 37 deletions

View File

@ -14,21 +14,23 @@
#include <string_view> #include <string_view>
#include <iostream> #include <iostream>
ToxContactModel2::ToxContactModel2(Contact3Registry& cr, ToxI& t, ToxEventProviderI& tep) : _cr(cr), _t(t), _tep(tep) { ToxContactModel2::ToxContactModel2(Contact3Registry& cr, ToxI& t, ToxEventProviderI& tep) : _cr(cr), _t(t), _tep_sr(tep.newSubRef(this)) {
_tep.subscribe(this, Tox_Event_Type::TOX_EVENT_FRIEND_CONNECTION_STATUS); _tep_sr
_tep.subscribe(this, Tox_Event_Type::TOX_EVENT_FRIEND_STATUS); .subscribe(Tox_Event_Type::TOX_EVENT_FRIEND_CONNECTION_STATUS)
_tep.subscribe(this, Tox_Event_Type::TOX_EVENT_FRIEND_NAME); .subscribe(Tox_Event_Type::TOX_EVENT_FRIEND_STATUS)
_tep.subscribe(this, Tox_Event_Type::TOX_EVENT_FRIEND_STATUS_MESSAGE); .subscribe(Tox_Event_Type::TOX_EVENT_FRIEND_NAME)
_tep.subscribe(this, Tox_Event_Type::TOX_EVENT_FRIEND_REQUEST); .subscribe(Tox_Event_Type::TOX_EVENT_FRIEND_STATUS_MESSAGE)
.subscribe(Tox_Event_Type::TOX_EVENT_FRIEND_REQUEST)
// TODO: conf // TODO: conf
_tep.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_INVITE); .subscribe(Tox_Event_Type::TOX_EVENT_GROUP_INVITE)
_tep.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_SELF_JOIN); .subscribe(Tox_Event_Type::TOX_EVENT_GROUP_SELF_JOIN)
_tep.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_PEER_JOIN); .subscribe(Tox_Event_Type::TOX_EVENT_GROUP_PEER_JOIN)
_tep.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_PEER_EXIT); .subscribe(Tox_Event_Type::TOX_EVENT_GROUP_PEER_EXIT)
_tep.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_PEER_NAME); .subscribe(Tox_Event_Type::TOX_EVENT_GROUP_PEER_NAME)
_tep.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_TOPIC); .subscribe(Tox_Event_Type::TOX_EVENT_GROUP_TOPIC)
;
// add tox profile root // add tox profile root
_root = _cr.create(); _root = _cr.create();

View File

@ -12,7 +12,7 @@ struct ToxI;
class ToxContactModel2 : public ContactModel3I, public ToxEventI { class ToxContactModel2 : public ContactModel3I, public ToxEventI {
Contact3Registry& _cr; Contact3Registry& _cr;
ToxI& _t; ToxI& _t;
ToxEventProviderI& _tep; ToxEventProviderI::SubscriptionReference _tep_sr;
Contact3 _root; Contact3 _root;
Contact3 _friend_self; Contact3 _friend_self;

View File

@ -13,23 +13,38 @@
#include <iostream> #include <iostream>
#include <variant> #include <variant>
ToxMessageManager::ToxMessageManager(RegistryMessageModelI& rmm, Contact3Registry& cr, ToxContactModel2& tcm, ToxI& t, ToxEventProviderI& tep) : _rmm(rmm), _cr(cr), _tcm(tcm), _t(t) { ToxMessageManager::ToxMessageManager(
RegistryMessageModelI& rmm,
Contact3Registry& cr,
ToxContactModel2& tcm,
ToxI& t,
ToxEventProviderI& tep
) :
_rmm(rmm),
_rmm_sr(_rmm.newSubRef(this)),
_cr(cr),
_tcm(tcm),
_t(t),
_tep_sr(tep.newSubRef(this))
{
_tep_sr
// TODO: system messages? // TODO: system messages?
//tep.subscribe(this, Tox_Event::TOX_EVENT_FRIEND_CONNECTION_STATUS); //.subscribe(Tox_Event::TOX_EVENT_FRIEND_CONNECTION_STATUS)
//tep.subscribe(this, Tox_Event::TOX_EVENT_FRIEND_STATUS); //.subscribe(Tox_Event::TOX_EVENT_FRIEND_STATUS)
tep.subscribe(this, Tox_Event_Type::TOX_EVENT_FRIEND_MESSAGE); .subscribe(Tox_Event_Type::TOX_EVENT_FRIEND_MESSAGE)
tep.subscribe(this, Tox_Event_Type::TOX_EVENT_FRIEND_READ_RECEIPT); .subscribe(Tox_Event_Type::TOX_EVENT_FRIEND_READ_RECEIPT)
// TODO: conf // TODO: conf
// TODO: system messages? // TODO: system messages?
//tep.subscribe(this, Tox_Event::TOX_EVENT_GROUP_PEER_JOIN); //.subscribe(Tox_Event::TOX_EVENT_GROUP_PEER_JOIN)
//tep.subscribe(this, Tox_Event::TOX_EVENT_GROUP_SELF_JOIN); //.subscribe(Tox_Event::TOX_EVENT_GROUP_SELF_JOIN)
//tep.subscribe(this, Tox_Event::TOX_EVENT_GROUP_PEER_NAME); //.subscribe(Tox_Event::TOX_EVENT_GROUP_PEER_NAME)
tep.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_MESSAGE); .subscribe(Tox_Event_Type::TOX_EVENT_GROUP_MESSAGE)
tep.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_PRIVATE_MESSAGE); .subscribe(Tox_Event_Type::TOX_EVENT_GROUP_PRIVATE_MESSAGE)
;
_rmm.subscribe(this, RegistryMessageModel_Event::send_text); _rmm_sr.subscribe(RegistryMessageModel_Event::send_text);
} }
ToxMessageManager::~ToxMessageManager(void) { ToxMessageManager::~ToxMessageManager(void) {

View File

@ -10,9 +10,11 @@ struct ToxI;
class ToxMessageManager : public RegistryMessageModelEventI, public ToxEventI { class ToxMessageManager : public RegistryMessageModelEventI, public ToxEventI {
protected: protected:
RegistryMessageModelI& _rmm; RegistryMessageModelI& _rmm;
RegistryMessageModelI::SubscriptionReference _rmm_sr;
Contact3Registry& _cr; Contact3Registry& _cr;
ToxContactModel2& _tcm; ToxContactModel2& _tcm;
ToxI& _t; ToxI& _t;
ToxEventProviderI::SubscriptionReference _tep_sr;
public: public:
ToxMessageManager(RegistryMessageModelI& rmm, Contact3Registry& cr, ToxContactModel2& tcm, ToxI& t, ToxEventProviderI& tep); ToxMessageManager(RegistryMessageModelI& rmm, Contact3Registry& cr, ToxContactModel2& tcm, ToxI& t, ToxEventProviderI& tep);

View File

@ -82,17 +82,21 @@ ToxTransferManager::ToxTransferManager(
ToxI& t, ToxI& t,
ToxEventProviderI& tep, ToxEventProviderI& tep,
ObjectStore2& os ObjectStore2& os
) : _rmm(rmm), _cr(cr), _tcm(tcm), _t(t), _os(os), _ftb(os) { ) : _rmm(rmm), _rmm_sr(_rmm.newSubRef(this)), _cr(cr), _tcm(tcm), _t(t), _tep_sr(tep.newSubRef(this)), _os(os), _os_sr(_os.newSubRef(this)), _ftb(os) {
tep.subscribe(this, Tox_Event_Type::TOX_EVENT_FRIEND_CONNECTION_STATUS); _tep_sr
tep.subscribe(this, Tox_Event_Type::TOX_EVENT_FILE_RECV); .subscribe(Tox_Event_Type::TOX_EVENT_FRIEND_CONNECTION_STATUS)
tep.subscribe(this, Tox_Event_Type::TOX_EVENT_FILE_RECV_CONTROL); .subscribe(Tox_Event_Type::TOX_EVENT_FILE_RECV)
tep.subscribe(this, Tox_Event_Type::TOX_EVENT_FILE_RECV_CHUNK); .subscribe(Tox_Event_Type::TOX_EVENT_FILE_RECV_CONTROL)
tep.subscribe(this, Tox_Event_Type::TOX_EVENT_FILE_CHUNK_REQUEST); .subscribe(Tox_Event_Type::TOX_EVENT_FILE_RECV_CHUNK)
.subscribe(Tox_Event_Type::TOX_EVENT_FILE_CHUNK_REQUEST)
;
_os.subscribe(this, ObjectStore_Event::object_update); _os_sr
_os.subscribe(this, ObjectStore_Event::object_destroy); .subscribe(ObjectStore_Event::object_update)
.subscribe(ObjectStore_Event::object_destroy)
;
_rmm.subscribe(this, RegistryMessageModel_Event::send_file_path); _rmm_sr.subscribe(RegistryMessageModel_Event::send_file_path);
} }
ToxTransferManager::~ToxTransferManager(void) { ToxTransferManager::~ToxTransferManager(void) {

View File

@ -24,10 +24,13 @@ class ToxTransferManager : public RegistryMessageModelEventI, public ObjectStore
protected: protected:
RegistryMessageModelI& _rmm; RegistryMessageModelI& _rmm;
RegistryMessageModelI::SubscriptionReference _rmm_sr;
Contact3Registry& _cr; Contact3Registry& _cr;
ToxContactModel2& _tcm; ToxContactModel2& _tcm;
ToxI& _t; ToxI& _t;
ToxEventProviderI::SubscriptionReference _tep_sr;
ObjectStore2& _os; ObjectStore2& _os;
ObjectStore2::SubscriptionReference _os_sr;
Backends::ToxFTFilesystem _ftb; Backends::ToxFTFilesystem _ftb;
bool _in_obj_update_event {false}; bool _in_obj_update_event {false};