group can speak (temp, waiting for generic contact interface)
This commit is contained in:
parent
30146fc5a5
commit
cd196562af
@ -460,6 +460,30 @@ Contact3Handle ToxContactModel2::getContactGroupPeer(uint32_t group_number, cons
|
||||
return {_cr, c};
|
||||
}
|
||||
|
||||
bool ToxContactModel2::groupPeerCanSpeak(uint32_t group_number, uint32_t peer_number) {
|
||||
auto [role_opt, role_err] = _t.toxGroupPeerGetRole(group_number, peer_number);
|
||||
if (!role_opt) {
|
||||
return false; // group/peer not found, return true instead?
|
||||
}
|
||||
|
||||
if (role_opt.value() == TOX_GROUP_ROLE_OBSERVER) {
|
||||
return false; // no in every case
|
||||
}
|
||||
|
||||
auto vs_opt = _t.toxGroupGetVoiceState(group_number);
|
||||
if (!vs_opt.has_value()) {
|
||||
return false; // group not found, return true instead?
|
||||
}
|
||||
|
||||
if (vs_opt.value() == TOX_GROUP_VOICE_STATE_ALL) {
|
||||
return true;
|
||||
} else if (vs_opt.value() == TOX_GROUP_VOICE_STATE_FOUNDER) {
|
||||
return role_opt.value() == TOX_GROUP_ROLE_FOUNDER;
|
||||
} else { // mod+f
|
||||
return role_opt.value() == TOX_GROUP_ROLE_MODERATOR || role_opt.value() == TOX_GROUP_ROLE_FOUNDER;
|
||||
}
|
||||
}
|
||||
|
||||
bool ToxContactModel2::onToxEvent(const Tox_Event_Friend_Connection_Status* e) {
|
||||
const Tox_Connection connection_status = tox_event_friend_connection_status_get_connection_status(e);
|
||||
auto c = getContactFriend(tox_event_friend_connection_status_get_friend_number(e));
|
||||
|
@ -20,7 +20,7 @@ class ToxContactModel2 : public ContactModel3I, public ToxEventI {
|
||||
float _group_status_timer {0.f};
|
||||
|
||||
public:
|
||||
static constexpr const char* version {"2"};
|
||||
static constexpr const char* version {"3"};
|
||||
|
||||
ToxContactModel2(Contact3Registry& cr, ToxI& t, ToxEventProviderI& tep);
|
||||
virtual ~ToxContactModel2(void);
|
||||
@ -41,6 +41,9 @@ class ToxContactModel2 : public ContactModel3I, public ToxEventI {
|
||||
//Contact3Handle getContactGroupPeer(const ToxKey& group_key, const ToxKey& peer_key);
|
||||
Contact3Handle 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);
|
||||
|
||||
protected: // tox events
|
||||
bool onToxEvent(const Tox_Event_Friend_Connection_Status* e) override;
|
||||
bool onToxEvent(const Tox_Event_Friend_Status* e) override;
|
||||
|
Loading…
Reference in New Issue
Block a user