solanaceae_tox/solanaceae/tox_contacts/tox_contact_model2.hpp

54 lines
1.8 KiB
C++
Raw Normal View History

#pragma once
#include <solanaceae/toxcore/tox_event_interface.hpp>
#include <solanaceae/contact/contact_model3.hpp>
#include <solanaceae/toxcore/tox_key.hpp>
// fwd
struct ToxI;
// tox contact model for ContactModel3I
class ToxContactModel2 : public ContactModel3I, public ToxEventI {
Contact3Registry& _cr;
ToxI& _t;
ToxEventProviderI& _tep;
Contact3 _friend_self;
float _group_status_timer {0.f};
public:
ToxContactModel2(Contact3Registry& cr, ToxI& t, ToxEventProviderI& tep);
virtual ~ToxContactModel2(void);
// TODO: continually fetch group peer connection state, since JF does not want to add cb/event
void iterate(float delta);
2023-07-29 20:07:22 +02:00
protected: // mmi
// accept incoming request
void acceptRequest(Contact3 c, std::string_view self_name, std::string_view password) override;
public: // util for tox code
// also creates if non existant
Contact3Handle getContactFriend(uint32_t friend_number);
Contact3Handle getContactGroup(uint32_t group_number);
Contact3Handle getContactGroupPeer(uint32_t group_number, uint32_t peer_number);
//Contact3Handle getContactGroupPeer(const ToxKey& group_key, const ToxKey& peer_key);
Contact3Handle getContactGroupPeer(uint32_t group_number, const ToxKey& peer_key);
protected: // tox events
bool onToxEvent(const Tox_Event_Friend_Connection_Status* e) override;
bool onToxEvent(const Tox_Event_Friend_Status* e) override;
bool onToxEvent(const Tox_Event_Friend_Name* e) override;
2023-07-29 20:07:22 +02:00
bool onToxEvent(const Tox_Event_Friend_Request* e) override;
2023-07-29 20:07:22 +02:00
bool onToxEvent(const Tox_Event_Group_Invite* e) override;
bool onToxEvent(const Tox_Event_Group_Self_Join* e) override;
bool onToxEvent(const Tox_Event_Group_Peer_Join* e) override;
bool onToxEvent(const Tox_Event_Group_Peer_Exit* e) override;
bool onToxEvent(const Tox_Event_Group_Peer_Name* e) override;
};