more group tox interface
This commit is contained in:
parent
2a63dcd3f6
commit
66486e2cee
@ -1,6 +1,7 @@
|
||||
#include "./tox_default_impl.hpp"
|
||||
#include "tox/tox.h"
|
||||
#include "toxcore/tox.h"
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
Tox_Connection ToxDefaultImpl::toxSelfGetConnectionStatus(void) {
|
||||
return tox_self_get_connection_status(_tox);
|
||||
@ -307,6 +308,12 @@ std::optional<bool> ToxDefaultImpl::toxGroupIsConnected(uint32_t group_number) {
|
||||
}
|
||||
}
|
||||
|
||||
Tox_Err_Group_Disconnect ToxDefaultImpl::toxGroupDisconnect(uint32_t group_number) {
|
||||
Tox_Err_Group_Disconnect err = TOX_ERR_GROUP_DISCONNECT_OK;
|
||||
tox_group_disconnect(_tox, group_number, &err);
|
||||
return err;
|
||||
}
|
||||
|
||||
Tox_Err_Group_Reconnect ToxDefaultImpl::toxGroupReconnect(uint32_t group_number) {
|
||||
Tox_Err_Group_Reconnect err = TOX_ERR_GROUP_RECONNECT_OK;
|
||||
tox_group_reconnect(_tox, group_number, &err);
|
||||
@ -319,6 +326,12 @@ Tox_Err_Group_Leave ToxDefaultImpl::toxGroupLeave(uint32_t group_number, std::st
|
||||
return err;
|
||||
}
|
||||
|
||||
Tox_Err_Group_Self_Name_Set ToxDefaultImpl::toxGroupSelfSetName(uint32_t group_number, std::string_view name) {
|
||||
Tox_Err_Group_Self_Name_Set err = TOX_ERR_GROUP_SELF_NAME_SET_OK;
|
||||
tox_group_self_set_name(_tox, group_number, reinterpret_cast<const uint8_t*>(name.data()), name.size(), &err);
|
||||
return err;
|
||||
}
|
||||
|
||||
std::optional<std::string> ToxDefaultImpl::toxGroupSelfGetName(uint32_t group_number) {
|
||||
std::string name;
|
||||
|
||||
@ -338,6 +351,53 @@ std::optional<std::string> ToxDefaultImpl::toxGroupSelfGetName(uint32_t group_nu
|
||||
}
|
||||
}
|
||||
|
||||
Tox_Err_Group_Self_Status_Set ToxDefaultImpl::toxGroupSelfSetStatus(uint32_t group_number, Tox_User_Status status) {
|
||||
Tox_Err_Group_Self_Status_Set err = TOX_ERR_GROUP_SELF_STATUS_SET_OK;
|
||||
tox_group_self_set_status(_tox, group_number, status, &err);
|
||||
return err;
|
||||
}
|
||||
|
||||
std::optional<Tox_User_Status> ToxDefaultImpl::toxGroupSelfGetStatus(uint32_t group_number) {
|
||||
Tox_Err_Group_Self_Query err = TOX_ERR_GROUP_SELF_QUERY_OK;
|
||||
auto res = tox_group_self_get_status(_tox, group_number, &err);
|
||||
if (err == TOX_ERR_GROUP_SELF_QUERY_OK) {
|
||||
return res;
|
||||
} else {
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<Tox_Group_Role> ToxDefaultImpl::toxGroupSelfGetRole(uint32_t group_number) {
|
||||
Tox_Err_Group_Self_Query err = TOX_ERR_GROUP_SELF_QUERY_OK;
|
||||
auto res = tox_group_self_get_role(_tox, group_number, &err);
|
||||
if (err == TOX_ERR_GROUP_SELF_QUERY_OK) {
|
||||
return res;
|
||||
} else {
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<uint32_t> ToxDefaultImpl::toxGroupSelfGetPeerId(uint32_t group_number) {
|
||||
Tox_Err_Group_Self_Query err = TOX_ERR_GROUP_SELF_QUERY_OK;
|
||||
auto res = tox_group_self_get_peer_id(_tox, group_number, &err);
|
||||
if (err == TOX_ERR_GROUP_SELF_QUERY_OK) {
|
||||
return res;
|
||||
} else {
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<std::vector<uint8_t>> ToxDefaultImpl::toxGroupSelfGetPublicKey(uint32_t group_number) {
|
||||
std::vector<uint8_t> public_key(TOX_GROUP_PEER_PUBLIC_KEY_SIZE);
|
||||
Tox_Err_Group_Self_Query err = TOX_ERR_GROUP_SELF_QUERY_OK;
|
||||
tox_group_self_get_public_key(_tox, group_number, public_key.data(), &err);
|
||||
if (err == TOX_ERR_GROUP_SELF_QUERY_OK) {
|
||||
return public_key;
|
||||
} else {
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
std::tuple<std::optional<std::string>, Tox_Err_Group_Peer_Query> ToxDefaultImpl::toxGroupPeerGetName(uint32_t group_number, uint32_t peer_id) {
|
||||
std::string name;
|
||||
|
||||
@ -357,6 +417,26 @@ std::tuple<std::optional<std::string>, Tox_Err_Group_Peer_Query> ToxDefaultImpl:
|
||||
}
|
||||
}
|
||||
|
||||
std::tuple<std::optional<Tox_User_Status>, Tox_Err_Group_Peer_Query> ToxDefaultImpl::toxGroupPeerGetStatus(uint32_t group_number, uint32_t peer_id) {
|
||||
Tox_Err_Group_Peer_Query err = TOX_ERR_GROUP_PEER_QUERY_OK;
|
||||
auto res = tox_group_peer_get_status(_tox, group_number, peer_id, &err);
|
||||
if (err == TOX_ERR_GROUP_PEER_QUERY_OK) {
|
||||
return {res, err};
|
||||
} else {
|
||||
return {std::nullopt, err};
|
||||
}
|
||||
}
|
||||
|
||||
std::tuple<std::optional<Tox_Group_Role>, Tox_Err_Group_Peer_Query> ToxDefaultImpl::toxGroupPeerGetRole(uint32_t group_number, uint32_t peer_id) {
|
||||
Tox_Err_Group_Peer_Query err = TOX_ERR_GROUP_PEER_QUERY_OK;
|
||||
auto res = tox_group_peer_get_role(_tox, group_number, peer_id, &err);
|
||||
if (err == TOX_ERR_GROUP_PEER_QUERY_OK) {
|
||||
return {res, err};
|
||||
} else{
|
||||
return {std::nullopt, err};
|
||||
}
|
||||
}
|
||||
|
||||
std::tuple<std::optional<Tox_Connection>, Tox_Err_Group_Peer_Query> ToxDefaultImpl::toxGroupPeerGetConnectionStatus(uint32_t group_number, uint32_t peer_id) {
|
||||
Tox_Err_Group_Peer_Query err = TOX_ERR_GROUP_PEER_QUERY_OK;
|
||||
auto res = tox_group_peer_get_connection_status(_tox, group_number, peer_id, &err);
|
||||
@ -367,6 +447,17 @@ std::tuple<std::optional<Tox_Connection>, Tox_Err_Group_Peer_Query> ToxDefaultIm
|
||||
}
|
||||
}
|
||||
|
||||
std::tuple<std::optional<std::vector<uint8_t>>, Tox_Err_Group_Peer_Query> ToxDefaultImpl::toxGroupPeerGetPublicKey(uint32_t group_number, uint32_t peer_id) {
|
||||
std::vector<uint8_t> public_key(TOX_GROUP_PEER_PUBLIC_KEY_SIZE);
|
||||
Tox_Err_Group_Peer_Query err = TOX_ERR_GROUP_PEER_QUERY_OK;
|
||||
tox_group_peer_get_public_key(_tox, group_number, peer_id, public_key.data(), &err);
|
||||
if (err == TOX_ERR_GROUP_PEER_QUERY_OK) {
|
||||
return {public_key, err};
|
||||
} else {
|
||||
return {std::nullopt, err};
|
||||
}
|
||||
}
|
||||
|
||||
Tox_Err_Group_Topic_Set ToxDefaultImpl::toxGroupSetTopic(uint32_t group_number, std::string_view topic) {
|
||||
Tox_Err_Group_Topic_Set err = TOX_ERR_GROUP_TOPIC_SET_OK;
|
||||
tox_group_set_topic(_tox, group_number, reinterpret_cast<const uint8_t*>(topic.data()), topic.size(), &err);
|
||||
|
@ -65,23 +65,23 @@ struct ToxDefaultImpl : public ToxI {
|
||||
std::tuple<std::optional<uint32_t>, Tox_Err_Group_New> toxGroupNew(Tox_Group_Privacy_State privacy_state, std::string_view group_name, std::string_view name) override;
|
||||
std::tuple<std::optional<uint32_t>, Tox_Err_Group_Join> toxGroupJoin(const std::vector<uint8_t>& chat_id, std::string_view name, std::string_view password) override;
|
||||
std::optional<bool> toxGroupIsConnected(uint32_t group_number) override;
|
||||
//virtual Tox_Err_Group_Disconnect toxGroupDisconnect(uint32_t group_number) = 0;
|
||||
Tox_Err_Group_Disconnect toxGroupDisconnect(uint32_t group_number) override;
|
||||
Tox_Err_Group_Reconnect toxGroupReconnect(uint32_t group_number) override;
|
||||
Tox_Err_Group_Leave toxGroupLeave(uint32_t group_number, std::string_view part_message) override;
|
||||
|
||||
//virtual Tox_Err_Group_Self_Name_Set toxGroupSelfSetName(uint32_t group_number, std::string_view name) = 0;
|
||||
Tox_Err_Group_Self_Name_Set toxGroupSelfSetName(uint32_t group_number, std::string_view name) override;
|
||||
std::optional<std::string> toxGroupSelfGetName(uint32_t group_number) override;
|
||||
//virtual Tox_Err_Group_Self_Status_Set toxGroupSelfSetStatus(uint32_t group_number, Tox_User_Status status) = 0;
|
||||
//virtual Tox_User_Status toxGroupSelfGetStatus(uint32_t group_number, Tox_Err_Group_Self_Query *error) = 0;
|
||||
//virtual Tox_Group_Role toxGroupSelfGetRole(uint32_t group_number, Tox_Err_Group_Self_Query *error) = 0;
|
||||
//virtual uint32_t toxGroupSelfGetPeerId(uint32_t group_number, Tox_Err_Group_Self_Query *error) = 0;
|
||||
//virtual std::vector<uint8_t> toxGroupSelfGetPublicKey(uint32_t group_number, Tox_Err_Group_Self_Query *error) = 0;
|
||||
Tox_Err_Group_Self_Status_Set toxGroupSelfSetStatus(uint32_t group_number, Tox_User_Status status) override;
|
||||
std::optional<Tox_User_Status> toxGroupSelfGetStatus(uint32_t group_number) override;
|
||||
std::optional<Tox_Group_Role> toxGroupSelfGetRole(uint32_t group_number) override;
|
||||
std::optional<uint32_t> toxGroupSelfGetPeerId(uint32_t group_number) override;
|
||||
std::optional<std::vector<uint8_t>> toxGroupSelfGetPublicKey(uint32_t group_number) override;
|
||||
|
||||
std::tuple<std::optional<std::string>, Tox_Err_Group_Peer_Query> toxGroupPeerGetName(uint32_t group_number, uint32_t peer_id) override;
|
||||
//virtual Tox_User_Status toxGroupPeerGetStatus(uint32_t group_number, uint32_t peer_id, Tox_Err_Group_Peer_Query *error) = 0;
|
||||
//virtual Tox_Group_Role toxGroupPeerGetRole(uint32_t group_number, uint32_t peer_id, Tox_Err_Group_Peer_Query *error) = 0;
|
||||
std::tuple<std::optional<Tox_User_Status>, Tox_Err_Group_Peer_Query> toxGroupPeerGetStatus(uint32_t group_number, uint32_t peer_id) override;
|
||||
std::tuple<std::optional<Tox_Group_Role>, Tox_Err_Group_Peer_Query> toxGroupPeerGetRole(uint32_t group_number, uint32_t peer_id) override;
|
||||
std::tuple<std::optional<Tox_Connection>, Tox_Err_Group_Peer_Query> toxGroupPeerGetConnectionStatus(uint32_t group_number, uint32_t peer_id) override;
|
||||
//virtual std::vector<uint8_t> toxGroupPeerGetPublicKey(uint32_t group_number, uint32_t peer_id, Tox_Err_Group_Peer_Query *error) = 0;
|
||||
std::tuple<std::optional<std::vector<uint8_t>>, Tox_Err_Group_Peer_Query> toxGroupPeerGetPublicKey(uint32_t group_number, uint32_t peer_id) override;
|
||||
|
||||
Tox_Err_Group_Topic_Set toxGroupSetTopic(uint32_t group_number, std::string_view topic) override;
|
||||
std::optional<std::string> toxGroupGetTopic(uint32_t group_number) override;
|
||||
|
@ -108,23 +108,23 @@ struct ToxI_raw {
|
||||
virtual std::tuple<std::optional<uint32_t>, Tox_Err_Group_New> toxGroupNew(Tox_Group_Privacy_State privacy_state, std::string_view group_name, std::string_view name) = 0;
|
||||
virtual std::tuple<std::optional<uint32_t>, Tox_Err_Group_Join> toxGroupJoin(const std::vector<uint8_t>& chat_id, std::string_view name, std::string_view password) = 0;
|
||||
virtual std::optional<bool> toxGroupIsConnected(uint32_t group_number) = 0; // only 1 error type, skip
|
||||
//virtual Tox_Err_Group_Disconnect toxGroupDisconnect(uint32_t group_number) = 0;
|
||||
virtual Tox_Err_Group_Disconnect toxGroupDisconnect(uint32_t group_number) = 0;
|
||||
virtual Tox_Err_Group_Reconnect toxGroupReconnect(uint32_t group_number) = 0;
|
||||
virtual Tox_Err_Group_Leave toxGroupLeave(uint32_t group_number, std::string_view part_message) = 0;
|
||||
|
||||
//virtual Tox_Err_Group_Self_Name_Set toxGroupSelfSetName(uint32_t group_number, std::string_view name) = 0;
|
||||
virtual Tox_Err_Group_Self_Name_Set toxGroupSelfSetName(uint32_t group_number, std::string_view name) = 0;
|
||||
virtual std::optional<std::string> toxGroupSelfGetName(uint32_t group_number) = 0; // only 1 error type, skip
|
||||
//virtual Tox_Err_Group_Self_Status_Set toxGroupSelfSetStatus(uint32_t group_number, Tox_User_Status status) = 0;
|
||||
//virtual Tox_User_Status toxGroupSelfGetStatus(uint32_t group_number, Tox_Err_Group_Self_Query *error) = 0;
|
||||
//virtual Tox_Group_Role toxGroupSelfGetRole(uint32_t group_number, Tox_Err_Group_Self_Query *error) = 0;
|
||||
//virtual uint32_t toxGroupSelfGetPeerId(uint32_t group_number, Tox_Err_Group_Self_Query *error) = 0;
|
||||
//virtual std::vector<uint8_t> toxGroupSelfGetPublicKey(uint32_t group_number, Tox_Err_Group_Self_Query *error) = 0;
|
||||
virtual Tox_Err_Group_Self_Status_Set toxGroupSelfSetStatus(uint32_t group_number, Tox_User_Status status) = 0;
|
||||
virtual std::optional<Tox_User_Status> toxGroupSelfGetStatus(uint32_t group_number) = 0;
|
||||
virtual std::optional<Tox_Group_Role> toxGroupSelfGetRole(uint32_t group_number) = 0;
|
||||
virtual std::optional<uint32_t> toxGroupSelfGetPeerId(uint32_t group_number) = 0;
|
||||
virtual std::optional<std::vector<uint8_t>> toxGroupSelfGetPublicKey(uint32_t group_number) = 0;
|
||||
|
||||
virtual std::tuple<std::optional<std::string>, Tox_Err_Group_Peer_Query> toxGroupPeerGetName(uint32_t group_number, uint32_t peer_id) = 0;
|
||||
//virtual Tox_User_Status toxGroupPeerGetStatus(uint32_t group_number, uint32_t peer_id, Tox_Err_Group_Peer_Query *error) = 0;
|
||||
//virtual Tox_Group_Role toxGroupPeerGetRole(uint32_t group_number, uint32_t peer_id, Tox_Err_Group_Peer_Query *error) = 0;
|
||||
virtual std::tuple<std::optional<Tox_User_Status>, Tox_Err_Group_Peer_Query> toxGroupPeerGetStatus(uint32_t group_number, uint32_t peer_id) = 0;
|
||||
virtual std::tuple<std::optional<Tox_Group_Role>, Tox_Err_Group_Peer_Query> toxGroupPeerGetRole(uint32_t group_number, uint32_t peer_id) = 0;
|
||||
virtual std::tuple<std::optional<Tox_Connection>, Tox_Err_Group_Peer_Query> toxGroupPeerGetConnectionStatus(uint32_t group_number, uint32_t peer_id) = 0;
|
||||
//virtual std::vector<uint8_t> toxGroupPeerGetPublicKey(uint32_t group_number, uint32_t peer_id, Tox_Err_Group_Peer_Query *error) = 0;
|
||||
virtual std::tuple<std::optional<std::vector<uint8_t>>, Tox_Err_Group_Peer_Query> toxGroupPeerGetPublicKey(uint32_t group_number, uint32_t peer_id) = 0;
|
||||
|
||||
virtual Tox_Err_Group_Topic_Set toxGroupSetTopic(uint32_t group_number, std::string_view topic) = 0;
|
||||
virtual std::optional<std::string> toxGroupGetTopic(uint32_t group_number) = 0; // only 1 error type, skip
|
||||
@ -199,6 +199,10 @@ struct ToxI : public ToxI_raw {
|
||||
return toxGroupLeave(group_number, part_message);
|
||||
}
|
||||
|
||||
Tox_Err_Group_Self_Name_Set toxGroupSelfSetName_str(uint32_t group_number, const std::string& name) {
|
||||
return toxGroupSelfSetName(group_number, name);
|
||||
}
|
||||
|
||||
Tox_Err_Group_Topic_Set toxGroupSetTopic_str(uint32_t group_number, const std::string& topic) {
|
||||
return toxGroupSetTopic(group_number, topic);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user