2023-07-23 13:23:49 +02:00
|
|
|
#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;
|
2024-10-24 15:55:44 +02:00
|
|
|
ToxEventProviderI::SubscriptionReference _tep_sr;
|
2023-07-23 13:23:49 +02:00
|
|
|
|
2024-04-18 15:16:44 +02:00
|
|
|
Contact3 _root;
|
2023-07-23 13:23:49 +02:00
|
|
|
Contact3 _friend_self;
|
|
|
|
|
2023-08-19 12:03:53 +02:00
|
|
|
float _group_status_timer {0.f};
|
|
|
|
|
2023-07-23 13:23:49 +02:00
|
|
|
public:
|
2024-11-06 10:32:42 +01:00
|
|
|
static constexpr const char* version {"3"};
|
2024-01-18 00:28:33 +01:00
|
|
|
|
2023-07-23 13:23:49 +02:00
|
|
|
ToxContactModel2(Contact3Registry& cr, ToxI& t, ToxEventProviderI& tep);
|
2023-08-19 12:03:53 +02:00
|
|
|
virtual ~ToxContactModel2(void);
|
2023-07-23 13:23:49 +02:00
|
|
|
|
|
|
|
// TODO: continually fetch group peer connection state, since JF does not want to add cb/event
|
2023-08-19 12:03:53 +02:00
|
|
|
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;
|
|
|
|
|
2023-07-23 13:23:49 +02:00
|
|
|
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);
|
|
|
|
|
2024-11-06 10:32:42 +01:00
|
|
|
// TODO: add proper perm api to contacts
|
|
|
|
bool groupPeerCanSpeak(uint32_t group_number, uint32_t peer_number);
|
|
|
|
|
2023-07-23 13:23:49 +02:00
|
|
|
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;
|
2024-04-22 21:48:42 +02:00
|
|
|
bool onToxEvent(const Tox_Event_Friend_Status_Message* e) override;
|
2023-07-29 20:07:22 +02:00
|
|
|
bool onToxEvent(const Tox_Event_Friend_Request* e) override;
|
2023-07-23 13:23:49 +02:00
|
|
|
|
2023-07-29 20:07:22 +02:00
|
|
|
bool onToxEvent(const Tox_Event_Group_Invite* e) override;
|
2023-07-23 13:23:49 +02:00
|
|
|
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;
|
2024-04-22 21:48:42 +02:00
|
|
|
bool onToxEvent(const Tox_Event_Group_Topic* e) override;
|
2023-07-23 13:23:49 +02:00
|
|
|
};
|
|
|
|
|