port to contact4, does not implement create/leave yet
This commit is contained in:
@@ -1,45 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include <solanaceae/toxcore/tox_event_interface.hpp>
|
||||
#include <solanaceae/contact/contact_model3.hpp>
|
||||
#include <solanaceae/contact/contact_model4.hpp>
|
||||
|
||||
#include <solanaceae/toxcore/tox_key.hpp>
|
||||
|
||||
// fwd
|
||||
struct ToxI;
|
||||
|
||||
// tox contact model for ContactModel3I
|
||||
class ToxContactModel2 : public ContactModel3I, public ToxEventI {
|
||||
Contact3Registry& _cr;
|
||||
// tox contact model for ContactModel4I
|
||||
class ToxContactModel2 : public ContactModel4I, public ToxEventI {
|
||||
ContactStore4I& _cs;
|
||||
ToxI& _t;
|
||||
ToxEventProviderI::SubscriptionReference _tep_sr;
|
||||
|
||||
Contact3 _root;
|
||||
Contact3 _friend_self;
|
||||
Contact4 _root;
|
||||
Contact4 _friend_self;
|
||||
|
||||
float _group_status_timer {0.f};
|
||||
|
||||
public:
|
||||
static constexpr const char* version {"3"};
|
||||
static constexpr const char* version {"4"};
|
||||
|
||||
ToxContactModel2(Contact3Registry& cr, ToxI& t, ToxEventProviderI& tep);
|
||||
ToxContactModel2(ContactStore4I& cs, 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);
|
||||
|
||||
protected: // mmi
|
||||
bool addContact(Contact4 c) override;
|
||||
|
||||
// accept incoming request
|
||||
void acceptRequest(Contact3 c, std::string_view self_name, std::string_view password) override;
|
||||
bool acceptRequest(Contact4 c, std::string_view self_name, std::string_view password) override;
|
||||
|
||||
bool leave(Contact4 c, std::string_view reason) override;
|
||||
|
||||
public: // util for tox code
|
||||
// also creates if non existant
|
||||
Contact3Handle getContactFriend(uint32_t friend_number);
|
||||
ContactHandle4 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);
|
||||
ContactHandle4 getContactGroup(uint32_t group_number);
|
||||
ContactHandle4 getContactGroupPeer(uint32_t group_number, uint32_t peer_number);
|
||||
//ContactHandle4 getContactGroupPeer(const ToxKey& group_key, const ToxKey& peer_key);
|
||||
ContactHandle4 getContactGroupPeer(uint32_t group_number, const ToxKey& peer_key);
|
||||
|
||||
// TODO: add proper perm api to contacts
|
||||
bool groupPeerCanSpeak(uint32_t group_number, uint32_t peer_number);
|
||||
|
Reference in New Issue
Block a user