update to new toxcore master (very close to releasing 0.2.19 now)
This commit is contained in:
parent
fa4298d790
commit
49ab40a1ba
@ -511,15 +511,15 @@ Tox_Err_Group_Topic_Set ToxDefaultImpl::toxGroupSetTopic(uint32_t group_number,
|
||||
std::optional<std::string> ToxDefaultImpl::toxGroupGetTopic(uint32_t group_number) {
|
||||
std::string topic;
|
||||
|
||||
Tox_Err_Group_State_Queries err = TOX_ERR_GROUP_STATE_QUERIES_OK;
|
||||
Tox_Err_Group_State_Query err = TOX_ERR_GROUP_STATE_QUERY_OK;
|
||||
const auto size = tox_group_get_topic_size(_tox, group_number, &err);
|
||||
if (err != TOX_ERR_GROUP_STATE_QUERIES_OK) {
|
||||
if (err != TOX_ERR_GROUP_STATE_QUERY_OK) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
topic.resize(size);
|
||||
tox_group_get_topic(_tox, group_number, reinterpret_cast<uint8_t*>(topic.data()), &err);
|
||||
if (err == TOX_ERR_GROUP_STATE_QUERIES_OK) {
|
||||
if (err == TOX_ERR_GROUP_STATE_QUERY_OK) {
|
||||
return topic;
|
||||
} else {
|
||||
return std::nullopt;
|
||||
@ -529,16 +529,16 @@ std::optional<std::string> ToxDefaultImpl::toxGroupGetTopic(uint32_t group_numbe
|
||||
std::optional<std::string> ToxDefaultImpl::toxGroupGetName(uint32_t group_number) {
|
||||
std::string name;
|
||||
|
||||
Tox_Err_Group_State_Queries err = TOX_ERR_GROUP_STATE_QUERIES_OK;
|
||||
Tox_Err_Group_State_Query err = TOX_ERR_GROUP_STATE_QUERY_OK;
|
||||
const auto size = tox_group_get_name_size(_tox, group_number, &err);
|
||||
if (err != TOX_ERR_GROUP_STATE_QUERIES_OK) {
|
||||
if (err != TOX_ERR_GROUP_STATE_QUERY_OK) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
name.resize(size);
|
||||
tox_group_get_name(_tox, group_number, reinterpret_cast<uint8_t*>(name.data()), &err);
|
||||
|
||||
if (err == TOX_ERR_GROUP_STATE_QUERIES_OK) {
|
||||
if (err == TOX_ERR_GROUP_STATE_QUERY_OK) {
|
||||
return name;
|
||||
} else {
|
||||
return std::nullopt;
|
||||
@ -549,9 +549,9 @@ std::optional<std::vector<uint8_t>> ToxDefaultImpl::toxGroupGetChatId(uint32_t g
|
||||
std::vector<uint8_t> chat_id{};
|
||||
chat_id.resize(TOX_GROUP_CHAT_ID_SIZE);
|
||||
|
||||
Tox_Err_Group_State_Queries err = TOX_ERR_GROUP_STATE_QUERIES_OK;
|
||||
Tox_Err_Group_State_Query err = TOX_ERR_GROUP_STATE_QUERY_OK;
|
||||
tox_group_get_chat_id(_tox, group_number, chat_id.data(), &err);
|
||||
if (err == TOX_ERR_GROUP_STATE_QUERIES_OK) {
|
||||
if (err == TOX_ERR_GROUP_STATE_QUERY_OK) {
|
||||
return chat_id;
|
||||
} else {
|
||||
return std::nullopt;
|
||||
@ -588,10 +588,14 @@ std::tuple<std::optional<uint32_t>, Tox_Err_Group_Send_Message> ToxDefaultImpl::
|
||||
}
|
||||
}
|
||||
|
||||
Tox_Err_Group_Send_Private_Message ToxDefaultImpl::toxGroupSendPrivateMessage(uint32_t group_number, uint32_t peer_id, Tox_Message_Type type, std::string_view message) {
|
||||
std::tuple<std::optional<uint32_t>, Tox_Err_Group_Send_Private_Message> ToxDefaultImpl::toxGroupSendPrivateMessage(uint32_t group_number, uint32_t peer_id, Tox_Message_Type type, std::string_view message) {
|
||||
Tox_Err_Group_Send_Private_Message err = TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_OK;
|
||||
tox_group_send_private_message(_tox, group_number, peer_id, type, reinterpret_cast<const uint8_t*>(message.data()), message.size(), &err);
|
||||
return err;
|
||||
uint32_t message_id = tox_group_send_private_message(_tox, group_number, peer_id, type, reinterpret_cast<const uint8_t*>(message.data()), message.size(), &err);
|
||||
if (err == TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_OK) {
|
||||
return {message_id, err};
|
||||
} else {
|
||||
return {std::nullopt, err};
|
||||
}
|
||||
}
|
||||
|
||||
Tox_Err_Group_Send_Custom_Packet ToxDefaultImpl::toxGroupSendCustomPacket(uint32_t group_number, bool lossless, const std::vector<uint8_t>& data) {
|
||||
|
@ -113,7 +113,7 @@ struct ToxDefaultImpl : public ToxI {
|
||||
//virtual std::string toxGroupGetPassword(uint32_t group_number, Tox_Err_Group_State_Queries *error) = 0;
|
||||
|
||||
std::tuple<std::optional<uint32_t>, Tox_Err_Group_Send_Message> toxGroupSendMessage(uint32_t group_number, Tox_Message_Type type, std::string_view message) override;
|
||||
Tox_Err_Group_Send_Private_Message toxGroupSendPrivateMessage(uint32_t group_number, uint32_t peer_id, Tox_Message_Type type, std::string_view message) override;
|
||||
std::tuple<std::optional<uint32_t>, Tox_Err_Group_Send_Private_Message> toxGroupSendPrivateMessage(uint32_t group_number, uint32_t peer_id, Tox_Message_Type type, std::string_view message) override;
|
||||
|
||||
Tox_Err_Group_Send_Custom_Packet toxGroupSendCustomPacket(uint32_t group_number, bool lossless, const std::vector<uint8_t>& data) override;
|
||||
Tox_Err_Group_Send_Custom_Private_Packet toxGroupSendCustomPrivatePacket(uint32_t group_number, uint32_t peer_id, bool lossless, const std::vector<uint8_t>& data) override;
|
||||
|
@ -57,12 +57,14 @@ struct ToxEventI {
|
||||
VIRT_EVENT(Tox_Event_Group_Join_Fail)
|
||||
VIRT_EVENT(Tox_Event_Group_Moderation)
|
||||
|
||||
VIRT_EVENT(Tox_Event_Dht_Get_Nodes_Response);
|
||||
|
||||
#undef VIRT_EVENT
|
||||
};
|
||||
|
||||
// defines the interface where to subscribe
|
||||
struct ToxEventProviderI {
|
||||
static constexpr const char* version {"1"};
|
||||
static constexpr const char* version {"2"};
|
||||
|
||||
virtual ~ToxEventProviderI(void) {}
|
||||
// TODO: unsub
|
||||
|
@ -221,6 +221,15 @@ bool ToxEventLogger::onToxEvent(const Tox_Event_Group_Moderation* e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ToxEventLogger::onToxEvent(const Tox_Event_Dht_Get_Nodes_Response* e) {
|
||||
_out << "TOX_EVENT: " << tox_event_to_string(TOX_EVENT_DHT_GET_NODES_RESPONSE)
|
||||
//<< " pub:" << tox_event_dht_get_nodes_response_get_public_key(e)
|
||||
//<< " ip:" << tox_event_dht_get_nodes_response_get_ip(e)
|
||||
//<< " prt:" << tox_event_dht_get_nodes_response_get_port(e)
|
||||
<< "\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
void ToxEventLogger::subscribeAll(ToxEventProviderI& tep) {
|
||||
// TODO: loop + max event
|
||||
tep.subscribe(this, TOX_EVENT_SELF_CONNECTION_STATUS);
|
||||
@ -272,5 +281,8 @@ void ToxEventLogger::subscribeAll(ToxEventProviderI& tep) {
|
||||
tep.subscribe(this, TOX_EVENT_GROUP_SELF_JOIN);
|
||||
tep.subscribe(this, TOX_EVENT_GROUP_JOIN_FAIL);
|
||||
tep.subscribe(this, TOX_EVENT_GROUP_MODERATION);
|
||||
|
||||
// too spammy
|
||||
//tep.subscribe(this, TOX_EVENT_DHT_GET_NODES_RESPONSE);
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,8 @@ struct ToxEventLogger : public ToxEventI {
|
||||
OVER_EVENT(Tox_Event_Group_Join_Fail)
|
||||
OVER_EVENT(Tox_Event_Group_Moderation)
|
||||
|
||||
OVER_EVENT(Tox_Event_Dht_Get_Nodes_Response)
|
||||
|
||||
#undef OVER_EVENT
|
||||
|
||||
void subscribeAll(ToxEventProviderI& tep);
|
||||
|
@ -63,6 +63,7 @@ void ToxEventProviderBase::dispatchEvents(const Tox_Events* events) {
|
||||
HANDLE_EVENT(GROUP_SELF_JOIN, group_self_join);
|
||||
HANDLE_EVENT(GROUP_JOIN_FAIL, group_join_fail);
|
||||
HANDLE_EVENT(GROUP_MODERATION, group_moderation);
|
||||
HANDLE_EVENT(DHT_GET_NODES_RESPONSE, dht_get_nodes_response);
|
||||
#undef HANDLE_EVENT
|
||||
|
||||
default:
|
||||
|
@ -14,7 +14,7 @@
|
||||
// defines the full interface for tox
|
||||
// HACK: raw
|
||||
struct ToxI_raw {
|
||||
static constexpr const char* version {"6"};
|
||||
static constexpr const char* version {"7"};
|
||||
|
||||
virtual ~ToxI_raw(void) {}
|
||||
|
||||
@ -159,7 +159,7 @@ struct ToxI_raw {
|
||||
|
||||
// returns message_id
|
||||
virtual std::tuple<std::optional<uint32_t>, Tox_Err_Group_Send_Message> toxGroupSendMessage(uint32_t group_number, Tox_Message_Type type, std::string_view message) = 0;
|
||||
virtual Tox_Err_Group_Send_Private_Message toxGroupSendPrivateMessage(uint32_t group_number, uint32_t peer_id, Tox_Message_Type type, std::string_view message) = 0;
|
||||
virtual std::tuple<std::optional<uint32_t>, Tox_Err_Group_Send_Private_Message> toxGroupSendPrivateMessage(uint32_t group_number, uint32_t peer_id, Tox_Message_Type type, std::string_view message) = 0;
|
||||
|
||||
virtual Tox_Err_Group_Send_Custom_Packet toxGroupSendCustomPacket(uint32_t group_number, bool lossless, const std::vector<uint8_t>& data) = 0;
|
||||
virtual Tox_Err_Group_Send_Custom_Private_Packet toxGroupSendCustomPrivatePacket(uint32_t group_number, uint32_t peer_id, bool lossless, const std::vector<uint8_t>& data) = 0;
|
||||
@ -229,7 +229,7 @@ struct ToxI : public ToxI_raw {
|
||||
return toxGroupSendMessage(group_number, type, message);
|
||||
}
|
||||
|
||||
Tox_Err_Group_Send_Private_Message toxGroupSendPrivateMessage_str(uint32_t group_number, uint32_t peer_id, Tox_Message_Type type, const std::string& message) {
|
||||
std::tuple<std::optional<uint32_t>, Tox_Err_Group_Send_Private_Message> toxGroupSendPrivateMessage_str(uint32_t group_number, uint32_t peer_id, Tox_Message_Type type, const std::string& message) {
|
||||
return toxGroupSendPrivateMessage(group_number, peer_id, type, message);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user