Merge commit 'a5093c4aa36d66049b6b5ca94e3b17412e77391b'

This commit is contained in:
Green Sky 2024-03-11 11:34:13 +01:00
commit e801626232
No known key found for this signature in database
20 changed files with 203 additions and 199 deletions

View File

@ -284,7 +284,7 @@ static void group_private_message_handler(const Tox_Event_Group_Private_Message
const uint32_t groupnumber = tox_event_group_private_message_get_group_number(event); const uint32_t groupnumber = tox_event_group_private_message_get_group_number(event);
const uint32_t peer_id = tox_event_group_private_message_get_peer_id(event); const uint32_t peer_id = tox_event_group_private_message_get_peer_id(event);
const Tox_Message_Type type = tox_event_group_private_message_get_type(event); const Tox_Message_Type type = tox_event_group_private_message_get_message_type(event);
const uint8_t *message = tox_event_group_private_message_get_message(event); const uint8_t *message = tox_event_group_private_message_get_message(event);
const size_t length = tox_event_group_private_message_get_message_length(event); const size_t length = tox_event_group_private_message_get_message_length(event);
const Tox_Group_Message_Id pseudo_msg_id = tox_event_group_private_message_get_message_id(event); const Tox_Group_Message_Id pseudo_msg_id = tox_event_group_private_message_get_message_id(event);

View File

@ -686,7 +686,7 @@ int main(int argc, char** argv) {
{ {
EventTypeTrivial{"uint32_t", "group_number"}, EventTypeTrivial{"uint32_t", "group_number"},
EventTypeTrivial{"uint32_t", "peer_id"}, EventTypeTrivial{"uint32_t", "peer_id"},
EventTypeByteRange{"name", "name_length", "length"}, // the latter two are ideally the same EventTypeByteRange{"name", "name_length", "name_length"},
} }
}, },
{ {
@ -702,7 +702,7 @@ int main(int argc, char** argv) {
{ {
EventTypeTrivial{"uint32_t", "group_number"}, EventTypeTrivial{"uint32_t", "group_number"},
EventTypeTrivial{"uint32_t", "peer_id"}, EventTypeTrivial{"uint32_t", "peer_id"},
EventTypeByteRange{"topic", "topic_length", "length"}, // the latter two are ideally the same EventTypeByteRange{"topic", "topic_length", "topic_length"},
} }
}, },
{ {
@ -737,7 +737,7 @@ int main(int argc, char** argv) {
"Group_Password", "Group_Password",
{ {
EventTypeTrivial{"uint32_t", "group_number"}, EventTypeTrivial{"uint32_t", "group_number"},
EventTypeByteRange{"password", "password_length", "length"}, // the latter two are ideally the same EventTypeByteRange{"password", "password_length", "password_length"},
} }
}, },
{ {
@ -745,8 +745,8 @@ int main(int argc, char** argv) {
{ {
EventTypeTrivial{"uint32_t", "group_number"}, EventTypeTrivial{"uint32_t", "group_number"},
EventTypeTrivial{"uint32_t", "peer_id"}, EventTypeTrivial{"uint32_t", "peer_id"},
EventTypeTrivial{"Tox_Message_Type", "type"}, EventTypeTrivial{"Tox_Message_Type", "message_type"},
EventTypeByteRange{"message", "message_length", "length"}, // the latter two are ideally the same EventTypeByteRange{"message", "message_length", "message_length"},
EventTypeTrivial{"uint32_t", "message_id"}, EventTypeTrivial{"uint32_t", "message_id"},
} }
}, },
@ -755,8 +755,8 @@ int main(int argc, char** argv) {
{ {
EventTypeTrivial{"uint32_t", "group_number"}, EventTypeTrivial{"uint32_t", "group_number"},
EventTypeTrivial{"uint32_t", "peer_id"}, EventTypeTrivial{"uint32_t", "peer_id"},
EventTypeTrivial{"Tox_Message_Type", "type"}, EventTypeTrivial{"Tox_Message_Type", "message_type"},
EventTypeByteRange{"message", "message_length", "length"}, // the latter two are ideally the same EventTypeByteRange{"message", "message_length", "message_length"},
EventTypeTrivial{"uint32_t", "message_id"}, EventTypeTrivial{"uint32_t", "message_id"},
} }
}, },
@ -765,7 +765,7 @@ int main(int argc, char** argv) {
{ {
EventTypeTrivial{"uint32_t", "group_number"}, EventTypeTrivial{"uint32_t", "group_number"},
EventTypeTrivial{"uint32_t", "peer_id"}, EventTypeTrivial{"uint32_t", "peer_id"},
EventTypeByteRange{"data", "data_length", "length"}, // the latter two are ideally the same EventTypeByteRange{"data", "data_length", "data_length"},
} }
}, },
{ {
@ -773,15 +773,15 @@ int main(int argc, char** argv) {
{ {
EventTypeTrivial{"uint32_t", "group_number"}, EventTypeTrivial{"uint32_t", "group_number"},
EventTypeTrivial{"uint32_t", "peer_id"}, EventTypeTrivial{"uint32_t", "peer_id"},
EventTypeByteRange{"data", "data_length", "length"}, // the latter two are ideally the same EventTypeByteRange{"data", "data_length", "data_length"},
} }
}, },
{ {
"Group_Invite", "Group_Invite",
{ {
EventTypeTrivial{"uint32_t", "friend_number"}, EventTypeTrivial{"uint32_t", "friend_number"},
EventTypeByteRange{"invite_data", "invite_data_length", "length"}, // the latter two are ideally the same EventTypeByteRange{"invite_data", "invite_data_length", "invite_data_length"},
EventTypeByteRange{"group_name", "group_name_length", "group_name_length"}, // they are :) EventTypeByteRange{"group_name", "group_name_length", "group_name_length"},
} }
}, },
{ {
@ -797,8 +797,8 @@ int main(int argc, char** argv) {
EventTypeTrivial{"uint32_t", "group_number"}, EventTypeTrivial{"uint32_t", "group_number"},
EventTypeTrivial{"uint32_t", "peer_id"}, EventTypeTrivial{"uint32_t", "peer_id"},
EventTypeTrivial{"Tox_Group_Exit_Type", "exit_type"}, EventTypeTrivial{"Tox_Group_Exit_Type", "exit_type"},
EventTypeByteRange{"name", "name_length", "name_length"}, // they are :) EventTypeByteRange{"name", "name_length", "name_length"},
EventTypeByteRange{"part_message", "part_message_length", "part_message_length"}, // they are :) EventTypeByteRange{"part_message", "part_message_length", "part_message_length"},
} }
}, },
{ {

View File

@ -14,6 +14,7 @@ sh_test(
args = ["$(locations %s)" % f for f in CIMPLE_FILES] + [ args = ["$(locations %s)" % f for f in CIMPLE_FILES] + [
"-Wno-boolean-return", "-Wno-boolean-return",
"-Wno-callback-names", "-Wno-callback-names",
"-Wno-enum-from-int",
"+RTS", "+RTS",
"-N4", "-N4",
"-RTS", "-RTS",

View File

@ -775,31 +775,31 @@ int m_set_statusmessage(Messenger *m, const uint8_t *status, uint16_t length)
} }
non_null() non_null()
static bool userstatus_from_int(uint8_t status, Userstatus *out) static bool userstatus_from_int(uint8_t status, Userstatus *out_enum)
{ {
switch (status) { switch (status) {
case USERSTATUS_NONE: { case USERSTATUS_NONE: {
*out = USERSTATUS_NONE; *out_enum = USERSTATUS_NONE;
return true; return true;
} }
case USERSTATUS_AWAY: { case USERSTATUS_AWAY: {
*out = USERSTATUS_AWAY; *out_enum = USERSTATUS_AWAY;
return true; return true;
} }
case USERSTATUS_BUSY: { case USERSTATUS_BUSY: {
*out = USERSTATUS_BUSY; *out_enum = USERSTATUS_BUSY;
return true; return true;
} }
case USERSTATUS_INVALID: { case USERSTATUS_INVALID: {
*out = USERSTATUS_INVALID; *out_enum = USERSTATUS_INVALID;
return true; return true;
} }
default: { default: {
*out = USERSTATUS_INVALID; *out_enum = USERSTATUS_INVALID;
return false; return false;
} }
} }

View File

@ -220,7 +220,7 @@ static Tox_Event_Group_Custom_Packet *tox_event_group_custom_packet_alloc(void *
*****************************************************/ *****************************************************/
void tox_events_handle_group_custom_packet( void tox_events_handle_group_custom_packet(
Tox *tox, uint32_t group_number, uint32_t peer_id, const uint8_t *data, size_t length, Tox *tox, uint32_t group_number, uint32_t peer_id, const uint8_t *data, size_t data_length,
void *user_data) void *user_data)
{ {
Tox_Event_Group_Custom_Packet *group_custom_packet = tox_event_group_custom_packet_alloc(user_data); Tox_Event_Group_Custom_Packet *group_custom_packet = tox_event_group_custom_packet_alloc(user_data);
@ -231,5 +231,5 @@ void tox_events_handle_group_custom_packet(
tox_event_group_custom_packet_set_group_number(group_custom_packet, group_number); tox_event_group_custom_packet_set_group_number(group_custom_packet, group_number);
tox_event_group_custom_packet_set_peer_id(group_custom_packet, peer_id); tox_event_group_custom_packet_set_peer_id(group_custom_packet, peer_id);
tox_event_group_custom_packet_set_data(group_custom_packet, data, length); tox_event_group_custom_packet_set_data(group_custom_packet, data, data_length);
} }

View File

@ -220,7 +220,7 @@ static Tox_Event_Group_Custom_Private_Packet *tox_event_group_custom_private_pac
*****************************************************/ *****************************************************/
void tox_events_handle_group_custom_private_packet( void tox_events_handle_group_custom_private_packet(
Tox *tox, uint32_t group_number, uint32_t peer_id, const uint8_t *data, size_t length, Tox *tox, uint32_t group_number, uint32_t peer_id, const uint8_t *data, size_t data_length,
void *user_data) void *user_data)
{ {
Tox_Event_Group_Custom_Private_Packet *group_custom_private_packet = tox_event_group_custom_private_packet_alloc(user_data); Tox_Event_Group_Custom_Private_Packet *group_custom_private_packet = tox_event_group_custom_private_packet_alloc(user_data);
@ -231,5 +231,5 @@ void tox_events_handle_group_custom_private_packet(
tox_event_group_custom_private_packet_set_group_number(group_custom_private_packet, group_number); tox_event_group_custom_private_packet_set_group_number(group_custom_private_packet, group_number);
tox_event_group_custom_private_packet_set_peer_id(group_custom_private_packet, peer_id); tox_event_group_custom_private_packet_set_peer_id(group_custom_private_packet, peer_id);
tox_event_group_custom_private_packet_set_data(group_custom_private_packet, data, length); tox_event_group_custom_private_packet_set_data(group_custom_private_packet, data, data_length);
} }

View File

@ -248,7 +248,7 @@ static Tox_Event_Group_Invite *tox_event_group_invite_alloc(void *user_data)
*****************************************************/ *****************************************************/
void tox_events_handle_group_invite( void tox_events_handle_group_invite(
Tox *tox, uint32_t friend_number, const uint8_t *invite_data, size_t length, const uint8_t *group_name, size_t group_name_length, Tox *tox, uint32_t friend_number, const uint8_t *invite_data, size_t invite_data_length, const uint8_t *group_name, size_t group_name_length,
void *user_data) void *user_data)
{ {
Tox_Event_Group_Invite *group_invite = tox_event_group_invite_alloc(user_data); Tox_Event_Group_Invite *group_invite = tox_event_group_invite_alloc(user_data);
@ -258,6 +258,6 @@ void tox_events_handle_group_invite(
} }
tox_event_group_invite_set_friend_number(group_invite, friend_number); tox_event_group_invite_set_friend_number(group_invite, friend_number);
tox_event_group_invite_set_invite_data(group_invite, invite_data, length); tox_event_group_invite_set_invite_data(group_invite, invite_data, invite_data_length);
tox_event_group_invite_set_group_name(group_invite, group_name, group_name_length); tox_event_group_invite_set_group_name(group_invite, group_name, group_name_length);
} }

View File

@ -27,7 +27,7 @@
struct Tox_Event_Group_Message { struct Tox_Event_Group_Message {
uint32_t group_number; uint32_t group_number;
uint32_t peer_id; uint32_t peer_id;
Tox_Message_Type type; Tox_Message_Type message_type;
uint8_t *message; uint8_t *message;
uint32_t message_length; uint32_t message_length;
uint32_t message_id; uint32_t message_id;
@ -60,16 +60,16 @@ uint32_t tox_event_group_message_get_peer_id(const Tox_Event_Group_Message *grou
} }
non_null() non_null()
static void tox_event_group_message_set_type(Tox_Event_Group_Message *group_message, static void tox_event_group_message_set_message_type(Tox_Event_Group_Message *group_message,
Tox_Message_Type type) Tox_Message_Type message_type)
{ {
assert(group_message != nullptr); assert(group_message != nullptr);
group_message->type = type; group_message->message_type = message_type;
} }
Tox_Message_Type tox_event_group_message_get_type(const Tox_Event_Group_Message *group_message) Tox_Message_Type tox_event_group_message_get_message_type(const Tox_Event_Group_Message *group_message)
{ {
assert(group_message != nullptr); assert(group_message != nullptr);
return group_message->type; return group_message->message_type;
} }
non_null(1) nullable(2) non_null(1) nullable(2)
@ -143,7 +143,7 @@ bool tox_event_group_message_pack(
return bin_pack_array(bp, 5) return bin_pack_array(bp, 5)
&& bin_pack_u32(bp, event->group_number) && bin_pack_u32(bp, event->group_number)
&& bin_pack_u32(bp, event->peer_id) && bin_pack_u32(bp, event->peer_id)
&& tox_message_type_pack(event->type, bp) && tox_message_type_pack(event->message_type, bp)
&& bin_pack_bin(bp, event->message, event->message_length) && bin_pack_bin(bp, event->message, event->message_length)
&& bin_pack_u32(bp, event->message_id); && bin_pack_u32(bp, event->message_id);
} }
@ -159,7 +159,7 @@ static bool tox_event_group_message_unpack_into(
return bin_unpack_u32(bu, &event->group_number) return bin_unpack_u32(bu, &event->group_number)
&& bin_unpack_u32(bu, &event->peer_id) && bin_unpack_u32(bu, &event->peer_id)
&& tox_message_type_unpack(&event->type, bu) && tox_message_type_unpack(&event->message_type, bu)
&& bin_unpack_bin(bu, &event->message, &event->message_length) && bin_unpack_bin(bu, &event->message, &event->message_length)
&& bin_unpack_u32(bu, &event->message_id); && bin_unpack_u32(bu, &event->message_id);
} }
@ -254,7 +254,7 @@ static Tox_Event_Group_Message *tox_event_group_message_alloc(void *user_data)
*****************************************************/ *****************************************************/
void tox_events_handle_group_message( void tox_events_handle_group_message(
Tox *tox, uint32_t group_number, uint32_t peer_id, Tox_Message_Type type, const uint8_t *message, size_t length, uint32_t message_id, Tox *tox, uint32_t group_number, uint32_t peer_id, Tox_Message_Type message_type, const uint8_t *message, size_t message_length, uint32_t message_id,
void *user_data) void *user_data)
{ {
Tox_Event_Group_Message *group_message = tox_event_group_message_alloc(user_data); Tox_Event_Group_Message *group_message = tox_event_group_message_alloc(user_data);
@ -265,7 +265,7 @@ void tox_events_handle_group_message(
tox_event_group_message_set_group_number(group_message, group_number); tox_event_group_message_set_group_number(group_message, group_number);
tox_event_group_message_set_peer_id(group_message, peer_id); tox_event_group_message_set_peer_id(group_message, peer_id);
tox_event_group_message_set_type(group_message, type); tox_event_group_message_set_message_type(group_message, message_type);
tox_event_group_message_set_message(group_message, message, length); tox_event_group_message_set_message(group_message, message, message_length);
tox_event_group_message_set_message_id(group_message, message_id); tox_event_group_message_set_message_id(group_message, message_id);
} }

View File

@ -204,7 +204,7 @@ static Tox_Event_Group_Password *tox_event_group_password_alloc(void *user_data)
*****************************************************/ *****************************************************/
void tox_events_handle_group_password( void tox_events_handle_group_password(
Tox *tox, uint32_t group_number, const uint8_t *password, size_t length, Tox *tox, uint32_t group_number, const uint8_t *password, size_t password_length,
void *user_data) void *user_data)
{ {
Tox_Event_Group_Password *group_password = tox_event_group_password_alloc(user_data); Tox_Event_Group_Password *group_password = tox_event_group_password_alloc(user_data);
@ -214,5 +214,5 @@ void tox_events_handle_group_password(
} }
tox_event_group_password_set_group_number(group_password, group_number); tox_event_group_password_set_group_number(group_password, group_number);
tox_event_group_password_set_password(group_password, password, length); tox_event_group_password_set_password(group_password, password, password_length);
} }

View File

@ -220,7 +220,7 @@ static Tox_Event_Group_Peer_Name *tox_event_group_peer_name_alloc(void *user_dat
*****************************************************/ *****************************************************/
void tox_events_handle_group_peer_name( void tox_events_handle_group_peer_name(
Tox *tox, uint32_t group_number, uint32_t peer_id, const uint8_t *name, size_t length, Tox *tox, uint32_t group_number, uint32_t peer_id, const uint8_t *name, size_t name_length,
void *user_data) void *user_data)
{ {
Tox_Event_Group_Peer_Name *group_peer_name = tox_event_group_peer_name_alloc(user_data); Tox_Event_Group_Peer_Name *group_peer_name = tox_event_group_peer_name_alloc(user_data);
@ -231,5 +231,5 @@ void tox_events_handle_group_peer_name(
tox_event_group_peer_name_set_group_number(group_peer_name, group_number); tox_event_group_peer_name_set_group_number(group_peer_name, group_number);
tox_event_group_peer_name_set_peer_id(group_peer_name, peer_id); tox_event_group_peer_name_set_peer_id(group_peer_name, peer_id);
tox_event_group_peer_name_set_name(group_peer_name, name, length); tox_event_group_peer_name_set_name(group_peer_name, name, name_length);
} }

View File

@ -27,7 +27,7 @@
struct Tox_Event_Group_Private_Message { struct Tox_Event_Group_Private_Message {
uint32_t group_number; uint32_t group_number;
uint32_t peer_id; uint32_t peer_id;
Tox_Message_Type type; Tox_Message_Type message_type;
uint8_t *message; uint8_t *message;
uint32_t message_length; uint32_t message_length;
uint32_t message_id; uint32_t message_id;
@ -60,16 +60,16 @@ uint32_t tox_event_group_private_message_get_peer_id(const Tox_Event_Group_Priva
} }
non_null() non_null()
static void tox_event_group_private_message_set_type(Tox_Event_Group_Private_Message *group_private_message, static void tox_event_group_private_message_set_message_type(Tox_Event_Group_Private_Message *group_private_message,
Tox_Message_Type type) Tox_Message_Type message_type)
{ {
assert(group_private_message != nullptr); assert(group_private_message != nullptr);
group_private_message->type = type; group_private_message->message_type = message_type;
} }
Tox_Message_Type tox_event_group_private_message_get_type(const Tox_Event_Group_Private_Message *group_private_message) Tox_Message_Type tox_event_group_private_message_get_message_type(const Tox_Event_Group_Private_Message *group_private_message)
{ {
assert(group_private_message != nullptr); assert(group_private_message != nullptr);
return group_private_message->type; return group_private_message->message_type;
} }
non_null(1) nullable(2) non_null(1) nullable(2)
@ -143,7 +143,7 @@ bool tox_event_group_private_message_pack(
return bin_pack_array(bp, 5) return bin_pack_array(bp, 5)
&& bin_pack_u32(bp, event->group_number) && bin_pack_u32(bp, event->group_number)
&& bin_pack_u32(bp, event->peer_id) && bin_pack_u32(bp, event->peer_id)
&& tox_message_type_pack(event->type, bp) && tox_message_type_pack(event->message_type, bp)
&& bin_pack_bin(bp, event->message, event->message_length) && bin_pack_bin(bp, event->message, event->message_length)
&& bin_pack_u32(bp, event->message_id); && bin_pack_u32(bp, event->message_id);
} }
@ -159,7 +159,7 @@ static bool tox_event_group_private_message_unpack_into(
return bin_unpack_u32(bu, &event->group_number) return bin_unpack_u32(bu, &event->group_number)
&& bin_unpack_u32(bu, &event->peer_id) && bin_unpack_u32(bu, &event->peer_id)
&& tox_message_type_unpack(&event->type, bu) && tox_message_type_unpack(&event->message_type, bu)
&& bin_unpack_bin(bu, &event->message, &event->message_length) && bin_unpack_bin(bu, &event->message, &event->message_length)
&& bin_unpack_u32(bu, &event->message_id); && bin_unpack_u32(bu, &event->message_id);
} }
@ -254,7 +254,7 @@ static Tox_Event_Group_Private_Message *tox_event_group_private_message_alloc(vo
*****************************************************/ *****************************************************/
void tox_events_handle_group_private_message( void tox_events_handle_group_private_message(
Tox *tox, uint32_t group_number, uint32_t peer_id, Tox_Message_Type type, const uint8_t *message, size_t length, uint32_t message_id, Tox *tox, uint32_t group_number, uint32_t peer_id, Tox_Message_Type message_type, const uint8_t *message, size_t message_length, uint32_t message_id,
void *user_data) void *user_data)
{ {
Tox_Event_Group_Private_Message *group_private_message = tox_event_group_private_message_alloc(user_data); Tox_Event_Group_Private_Message *group_private_message = tox_event_group_private_message_alloc(user_data);
@ -265,7 +265,7 @@ void tox_events_handle_group_private_message(
tox_event_group_private_message_set_group_number(group_private_message, group_number); tox_event_group_private_message_set_group_number(group_private_message, group_number);
tox_event_group_private_message_set_peer_id(group_private_message, peer_id); tox_event_group_private_message_set_peer_id(group_private_message, peer_id);
tox_event_group_private_message_set_type(group_private_message, type); tox_event_group_private_message_set_message_type(group_private_message, message_type);
tox_event_group_private_message_set_message(group_private_message, message, length); tox_event_group_private_message_set_message(group_private_message, message, message_length);
tox_event_group_private_message_set_message_id(group_private_message, message_id); tox_event_group_private_message_set_message_id(group_private_message, message_id);
} }

View File

@ -220,7 +220,7 @@ static Tox_Event_Group_Topic *tox_event_group_topic_alloc(void *user_data)
*****************************************************/ *****************************************************/
void tox_events_handle_group_topic( void tox_events_handle_group_topic(
Tox *tox, uint32_t group_number, uint32_t peer_id, const uint8_t *topic, size_t length, Tox *tox, uint32_t group_number, uint32_t peer_id, const uint8_t *topic, size_t topic_length,
void *user_data) void *user_data)
{ {
Tox_Event_Group_Topic *group_topic = tox_event_group_topic_alloc(user_data); Tox_Event_Group_Topic *group_topic = tox_event_group_topic_alloc(user_data);
@ -231,5 +231,5 @@ void tox_events_handle_group_topic(
tox_event_group_topic_set_group_number(group_topic, group_number); tox_event_group_topic_set_group_number(group_topic, group_number);
tox_event_group_topic_set_peer_id(group_topic, peer_id); tox_event_group_topic_set_peer_id(group_topic, peer_id);
tox_event_group_topic_set_topic(group_topic, topic, length); tox_event_group_topic_set_topic(group_topic, topic, topic_length);
} }

View File

@ -26,46 +26,46 @@
#include "network.h" #include "network.h"
#include "util.h" #include "util.h"
bool group_privacy_state_from_int(uint8_t value, Group_Privacy_State *out) bool group_privacy_state_from_int(uint8_t value, Group_Privacy_State *out_enum)
{ {
switch (value) { switch (value) {
case GI_PUBLIC: { case GI_PUBLIC: {
*out = GI_PUBLIC; *out_enum = GI_PUBLIC;
return true; return true;
} }
case GI_PRIVATE: { case GI_PRIVATE: {
*out = GI_PRIVATE; *out_enum = GI_PRIVATE;
return true; return true;
} }
default: { default: {
*out = GI_PUBLIC; *out_enum = GI_PUBLIC;
return false; return false;
} }
} }
} }
bool group_voice_state_from_int(uint8_t value, Group_Voice_State *out) bool group_voice_state_from_int(uint8_t value, Group_Voice_State *out_enum)
{ {
switch (value) { switch (value) {
case GV_ALL: { case GV_ALL: {
*out = GV_ALL; *out_enum = GV_ALL;
return true; return true;
} }
case GV_MODS: { case GV_MODS: {
*out = GV_MODS; *out_enum = GV_MODS;
return true; return true;
} }
case GV_FOUNDER: { case GV_FOUNDER: {
*out = GV_FOUNDER; *out_enum = GV_FOUNDER;
return true; return true;
} }
default: { default: {
*out = GV_ALL; *out_enum = GV_ALL;
return false; return false;
} }
} }

View File

@ -34,8 +34,8 @@ non_null()
bool gc_load_unpack_group(GC_Chat *chat, Bin_Unpack *bu); bool gc_load_unpack_group(GC_Chat *chat, Bin_Unpack *bu);
non_null() non_null()
bool group_privacy_state_from_int(uint8_t value, Group_Privacy_State *out); bool group_privacy_state_from_int(uint8_t value, Group_Privacy_State *out_enum);
non_null() non_null()
bool group_voice_state_from_int(uint8_t value, Group_Voice_State *out); bool group_voice_state_from_int(uint8_t value, Group_Voice_State *out_enum);
#endif /* C_TOXCORE_TOXCORE_GROUP_PACK_H */ #endif /* C_TOXCORE_TOXCORE_GROUP_PACK_H */

View File

@ -3932,7 +3932,7 @@ bool tox_group_get_password(const Tox *tox, uint32_t group_number, uint8_t *pass
} }
Tox_Group_Message_Id tox_group_send_message( Tox_Group_Message_Id tox_group_send_message(
const Tox *tox, uint32_t group_number, Tox_Message_Type type, const uint8_t *message, const Tox *tox, uint32_t group_number, Tox_Message_Type message_type, const uint8_t *message,
size_t length, Tox_Err_Group_Send_Message *error) size_t length, Tox_Err_Group_Send_Message *error)
{ {
assert(tox != nullptr); assert(tox != nullptr);
@ -3953,7 +3953,7 @@ Tox_Group_Message_Id tox_group_send_message(
} }
uint32_t message_id = 0; uint32_t message_id = 0;
const int ret = gc_send_message(chat, message, length, type, &message_id); const int ret = gc_send_message(chat, message, length, message_type, &message_id);
tox_unlock(tox); tox_unlock(tox);
switch (ret) { switch (ret) {
@ -3995,7 +3995,7 @@ Tox_Group_Message_Id tox_group_send_message(
} }
Tox_Group_Message_Id tox_group_send_private_message(const Tox *tox, uint32_t group_number, uint32_t peer_id, Tox_Group_Message_Id tox_group_send_private_message(const Tox *tox, uint32_t group_number, uint32_t peer_id,
Tox_Message_Type type, const uint8_t *message, size_t length, Tox_Err_Group_Send_Private_Message *error) Tox_Message_Type message_type, const uint8_t *message, size_t length, Tox_Err_Group_Send_Private_Message *error)
{ {
assert(tox != nullptr); assert(tox != nullptr);
@ -4015,7 +4015,7 @@ Tox_Group_Message_Id tox_group_send_private_message(const Tox *tox, uint32_t gro
} }
uint32_t message_id = 0; uint32_t message_id = 0;
const int ret = gc_send_private_message(chat, gc_peer_id_from_int(peer_id), type, message, length, &message_id); const int ret = gc_send_private_message(chat, gc_peer_id_from_int(peer_id), message_type, message, length, &message_id);
tox_unlock(tox); tox_unlock(tox);
switch (ret) { switch (ret) {

View File

@ -4094,11 +4094,11 @@ bool tox_group_peer_get_public_key(
* @param group_number The group number of the group the name change is intended for. * @param group_number The group number of the group the name change is intended for.
* @param peer_id The ID of the peer who has changed their name. * @param peer_id The ID of the peer who has changed their name.
* @param name The name data. * @param name The name data.
* @param length The length of the name. * @param name_length The length of the name.
*/ */
typedef void tox_group_peer_name_cb( typedef void tox_group_peer_name_cb(
Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id,
const uint8_t name[], size_t length, void *user_data); const uint8_t name[], size_t name_length, void *user_data);
/** /**
* Set the callback for the `group_peer_name` event. Pass NULL to unset. * Set the callback for the `group_peer_name` event. Pass NULL to unset.
@ -4235,11 +4235,11 @@ bool tox_group_get_topic(
* @param peer_id The ID of the peer who changed the topic. If the peer who set the topic * @param peer_id The ID of the peer who changed the topic. If the peer who set the topic
* is not present in our peer list this value will be set to 0. * is not present in our peer list this value will be set to 0.
* @param topic The topic data. * @param topic The topic data.
* @param length The topic length. * @param topic_length The topic length.
*/ */
typedef void tox_group_topic_cb( typedef void tox_group_topic_cb(
Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id,
const uint8_t topic[], size_t length, const uint8_t topic[], size_t topic_length,
void *user_data); void *user_data);
/** /**
@ -4416,11 +4416,11 @@ bool tox_group_get_password(
/** /**
* @param group_number The group number of the group for which the password has changed. * @param group_number The group number of the group for which the password has changed.
* @param password The new group password. * @param password The new group password.
* @param length The length of the password. * @param password_length The length of the password.
*/ */
typedef void tox_group_password_cb( typedef void tox_group_password_cb(
Tox *tox, Tox_Group_Number group_number, Tox *tox, Tox_Group_Number group_number,
const uint8_t password[], size_t length, const uint8_t password[], size_t password_length,
void *user_data); void *user_data);
/** /**
@ -4493,7 +4493,7 @@ const char *tox_err_group_send_message_to_string(Tox_Err_Group_Send_Message valu
* then reassemble the fragments. Messages may not be empty. * then reassemble the fragments. Messages may not be empty.
* *
* @param group_number The group number of the group the message is intended for. * @param group_number The group number of the group the message is intended for.
* @param type Message type (normal, action, ...). * @param message_type Message type (normal, action, ...).
* @param message A non-NULL pointer to the first element of a byte array * @param message A non-NULL pointer to the first element of a byte array
* containing the message text. * containing the message text.
* @param length Length of the message to be sent. * @param length Length of the message to be sent.
@ -4502,7 +4502,7 @@ const char *tox_err_group_send_message_to_string(Tox_Err_Group_Send_Message valu
* returned message ID value will be undefined. * returned message ID value will be undefined.
*/ */
Tox_Group_Message_Id tox_group_send_message( Tox_Group_Message_Id tox_group_send_message(
const Tox *tox, Tox_Group_Number group_number, Tox_Message_Type type, const Tox *tox, Tox_Group_Number group_number, Tox_Message_Type message_type,
const uint8_t message[], size_t length, const uint8_t message[], size_t length,
Tox_Err_Group_Send_Message *error); Tox_Err_Group_Send_Message *error);
@ -4533,6 +4533,11 @@ typedef enum Tox_Err_Group_Send_Private_Message {
*/ */
TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_EMPTY, TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_EMPTY,
/**
* The message type is invalid.
*/
TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_BAD_TYPE,
/** /**
* The caller does not have the required permissions to send group messages. * The caller does not have the required permissions to send group messages.
*/ */
@ -4548,11 +4553,6 @@ typedef enum Tox_Err_Group_Send_Private_Message {
*/ */
TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_DISCONNECTED, TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_DISCONNECTED,
/**
* The message type is invalid.
*/
TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_BAD_TYPE,
} Tox_Err_Group_Send_Private_Message; } Tox_Err_Group_Send_Private_Message;
const char *tox_err_group_send_private_message_to_string(Tox_Err_Group_Send_Private_Message value); const char *tox_err_group_send_private_message_to_string(Tox_Err_Group_Send_Private_Message value);
@ -4569,6 +4569,7 @@ const char *tox_err_group_send_private_message_to_string(Tox_Err_Group_Send_Priv
* *
* @param group_number The group number of the group the message is intended for. * @param group_number The group number of the group the message is intended for.
* @param peer_id The ID of the peer the message is intended for. * @param peer_id The ID of the peer the message is intended for.
* @param message_type The type of message (normal, action, ...).
* @param message A non-NULL pointer to the first element of a byte array * @param message A non-NULL pointer to the first element of a byte array
* containing the message text. * containing the message text.
* @param length Length of the message to be sent. * @param length Length of the message to be sent.
@ -4576,7 +4577,7 @@ const char *tox_err_group_send_private_message_to_string(Tox_Err_Group_Send_Priv
* @return true on success. * @return true on success.
*/ */
Tox_Group_Message_Id tox_group_send_private_message( Tox_Group_Message_Id tox_group_send_private_message(
const Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, Tox_Message_Type type, const Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, Tox_Message_Type message_type,
const uint8_t message[], size_t length, const uint8_t message[], size_t length,
Tox_Err_Group_Send_Private_Message *error); Tox_Err_Group_Send_Private_Message *error);
@ -4729,14 +4730,14 @@ bool tox_group_send_custom_private_packet(const Tox *tox, Tox_Group_Number group
/** /**
* @param group_number The group number of the group the message is intended for. * @param group_number The group number of the group the message is intended for.
* @param peer_id The ID of the peer who sent the message. * @param peer_id The ID of the peer who sent the message.
* @param type The type of message (normal, action, ...). * @param message_type The type of message (normal, action, ...).
* @param message The message data. * @param message The message data.
* @param message_length The length of the message.
* @param message_id A pseudo message id that clients can use to uniquely identify this group message. * @param message_id A pseudo message id that clients can use to uniquely identify this group message.
* @param length The length of the message.
*/ */
typedef void tox_group_message_cb( typedef void tox_group_message_cb(
Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, Tox_Message_Type type, Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, Tox_Message_Type message_type,
const uint8_t message[], size_t length, Tox_Group_Message_Id message_id, void *user_data); const uint8_t message[], size_t message_length, Tox_Group_Message_Id message_id, void *user_data);
/** /**
* Set the callback for the `group_message` event. Pass NULL to unset. * Set the callback for the `group_message` event. Pass NULL to unset.
@ -4748,12 +4749,14 @@ void tox_callback_group_message(Tox *tox, tox_group_message_cb *callback);
/** /**
* @param group_number The group number of the group the private message is intended for. * @param group_number The group number of the group the private message is intended for.
* @param peer_id The ID of the peer who sent the private message. * @param peer_id The ID of the peer who sent the private message.
* @param message_type The type of message (normal, action, ...).
* @param message The message data. * @param message The message data.
* @param length The length of the message. * @param message_length The length of the message.
* @param message_id A pseudo message id that clients can use to uniquely identify this group message.
*/ */
typedef void tox_group_private_message_cb( typedef void tox_group_private_message_cb(
Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, Tox_Message_Type type, Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, Tox_Message_Type message_type,
const uint8_t message[], size_t length, Tox_Group_Message_Id message_id, void *user_data); const uint8_t message[], size_t message_length, Tox_Group_Message_Id message_id, void *user_data);
/** /**
* Set the callback for the `group_private_message` event. Pass NULL to unset. * Set the callback for the `group_private_message` event. Pass NULL to unset.
@ -4766,11 +4769,11 @@ void tox_callback_group_private_message(Tox *tox, tox_group_private_message_cb *
* @param group_number The group number of the group the packet is intended for. * @param group_number The group number of the group the packet is intended for.
* @param peer_id The ID of the peer who sent the packet. * @param peer_id The ID of the peer who sent the packet.
* @param data The packet data. * @param data The packet data.
* @param length The length of the data. * @param data_length The length of the data.
*/ */
typedef void tox_group_custom_packet_cb( typedef void tox_group_custom_packet_cb(
Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id,
const uint8_t data[], size_t length, void *user_data); const uint8_t data[], size_t data_length, void *user_data);
/** /**
* Set the callback for the `group_custom_packet` event. Pass NULL to unset. * Set the callback for the `group_custom_packet` event. Pass NULL to unset.
@ -4783,11 +4786,11 @@ void tox_callback_group_custom_packet(Tox *tox, tox_group_custom_packet_cb *call
* @param group_number The group number of the group the packet is intended for. * @param group_number The group number of the group the packet is intended for.
* @param peer_id The ID of the peer who sent the packet. * @param peer_id The ID of the peer who sent the packet.
* @param data The packet data. * @param data The packet data.
* @param length The length of the data. * @param data_length The length of the data.
*/ */
typedef void tox_group_custom_private_packet_cb( typedef void tox_group_custom_private_packet_cb(
Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id,
const uint8_t data[], size_t length, void *user_data); const uint8_t data[], size_t data_length, void *user_data);
/** /**
* Set the callback for the `group_custom_private_packet` event. Pass NULL to unset. * Set the callback for the `group_custom_private_packet` event. Pass NULL to unset.
@ -4923,11 +4926,11 @@ Tox_Group_Number tox_group_invite_accept(
/** /**
* @param friend_number The friend number of the contact who sent the invite. * @param friend_number The friend number of the contact who sent the invite.
* @param invite_data The invite data. * @param invite_data The invite data.
* @param length The length of invite_data. * @param invite_data_length The length of invite_data.
*/ */
typedef void tox_group_invite_cb( typedef void tox_group_invite_cb(
Tox *tox, Tox_Friend_Number friend_number, Tox *tox, Tox_Friend_Number friend_number,
const uint8_t invite_data[], size_t length, const uint8_t invite_data[], size_t invite_data_length,
const uint8_t group_name[], size_t group_name_length, const uint8_t group_name[], size_t group_name_length,
void *user_data); void *user_data);

View File

@ -1340,6 +1340,9 @@ const char *tox_err_group_send_private_message_to_string(Tox_Err_Group_Send_Priv
case TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_EMPTY: case TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_EMPTY:
return "TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_EMPTY"; return "TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_EMPTY";
case TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_BAD_TYPE:
return "TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_BAD_TYPE";
case TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_PERMISSIONS: case TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_PERMISSIONS:
return "TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_PERMISSIONS"; return "TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_PERMISSIONS";
@ -1348,9 +1351,6 @@ const char *tox_err_group_send_private_message_to_string(Tox_Err_Group_Send_Priv
case TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_DISCONNECTED: case TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_DISCONNECTED:
return "TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_DISCONNECTED"; return "TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_DISCONNECTED";
case TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_BAD_TYPE:
return "TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_BAD_TYPE";
} }
return "<invalid Tox_Err_Group_Send_Private_Message>"; return "<invalid Tox_Err_Group_Send_Private_Message>";

View File

@ -725,216 +725,216 @@ bool tox_event_pack(const Tox_Event *event, Bin_Pack *bp)
} }
non_null() non_null()
static bool tox_event_type_from_int(uint32_t value, Tox_Event_Type *out) static bool tox_event_type_from_int(uint32_t value, Tox_Event_Type *out_enum)
{ {
switch (value) { switch (value) {
case TOX_EVENT_SELF_CONNECTION_STATUS: { case TOX_EVENT_SELF_CONNECTION_STATUS: {
*out = TOX_EVENT_SELF_CONNECTION_STATUS; *out_enum = TOX_EVENT_SELF_CONNECTION_STATUS;
return true; return true;
} }
case TOX_EVENT_FRIEND_REQUEST: { case TOX_EVENT_FRIEND_REQUEST: {
*out = TOX_EVENT_FRIEND_REQUEST; *out_enum = TOX_EVENT_FRIEND_REQUEST;
return true; return true;
} }
case TOX_EVENT_FRIEND_CONNECTION_STATUS: { case TOX_EVENT_FRIEND_CONNECTION_STATUS: {
*out = TOX_EVENT_FRIEND_CONNECTION_STATUS; *out_enum = TOX_EVENT_FRIEND_CONNECTION_STATUS;
return true; return true;
} }
case TOX_EVENT_FRIEND_LOSSY_PACKET: { case TOX_EVENT_FRIEND_LOSSY_PACKET: {
*out = TOX_EVENT_FRIEND_LOSSY_PACKET; *out_enum = TOX_EVENT_FRIEND_LOSSY_PACKET;
return true; return true;
} }
case TOX_EVENT_FRIEND_LOSSLESS_PACKET: { case TOX_EVENT_FRIEND_LOSSLESS_PACKET: {
*out = TOX_EVENT_FRIEND_LOSSLESS_PACKET; *out_enum = TOX_EVENT_FRIEND_LOSSLESS_PACKET;
return true; return true;
} }
case TOX_EVENT_FRIEND_NAME: { case TOX_EVENT_FRIEND_NAME: {
*out = TOX_EVENT_FRIEND_NAME; *out_enum = TOX_EVENT_FRIEND_NAME;
return true; return true;
} }
case TOX_EVENT_FRIEND_STATUS: { case TOX_EVENT_FRIEND_STATUS: {
*out = TOX_EVENT_FRIEND_STATUS; *out_enum = TOX_EVENT_FRIEND_STATUS;
return true; return true;
} }
case TOX_EVENT_FRIEND_STATUS_MESSAGE: { case TOX_EVENT_FRIEND_STATUS_MESSAGE: {
*out = TOX_EVENT_FRIEND_STATUS_MESSAGE; *out_enum = TOX_EVENT_FRIEND_STATUS_MESSAGE;
return true; return true;
} }
case TOX_EVENT_FRIEND_MESSAGE: { case TOX_EVENT_FRIEND_MESSAGE: {
*out = TOX_EVENT_FRIEND_MESSAGE; *out_enum = TOX_EVENT_FRIEND_MESSAGE;
return true; return true;
} }
case TOX_EVENT_FRIEND_READ_RECEIPT: { case TOX_EVENT_FRIEND_READ_RECEIPT: {
*out = TOX_EVENT_FRIEND_READ_RECEIPT; *out_enum = TOX_EVENT_FRIEND_READ_RECEIPT;
return true; return true;
} }
case TOX_EVENT_FRIEND_TYPING: { case TOX_EVENT_FRIEND_TYPING: {
*out = TOX_EVENT_FRIEND_TYPING; *out_enum = TOX_EVENT_FRIEND_TYPING;
return true; return true;
} }
case TOX_EVENT_FILE_CHUNK_REQUEST: { case TOX_EVENT_FILE_CHUNK_REQUEST: {
*out = TOX_EVENT_FILE_CHUNK_REQUEST; *out_enum = TOX_EVENT_FILE_CHUNK_REQUEST;
return true; return true;
} }
case TOX_EVENT_FILE_RECV: { case TOX_EVENT_FILE_RECV: {
*out = TOX_EVENT_FILE_RECV; *out_enum = TOX_EVENT_FILE_RECV;
return true; return true;
} }
case TOX_EVENT_FILE_RECV_CHUNK: { case TOX_EVENT_FILE_RECV_CHUNK: {
*out = TOX_EVENT_FILE_RECV_CHUNK; *out_enum = TOX_EVENT_FILE_RECV_CHUNK;
return true; return true;
} }
case TOX_EVENT_FILE_RECV_CONTROL: { case TOX_EVENT_FILE_RECV_CONTROL: {
*out = TOX_EVENT_FILE_RECV_CONTROL; *out_enum = TOX_EVENT_FILE_RECV_CONTROL;
return true; return true;
} }
case TOX_EVENT_CONFERENCE_INVITE: { case TOX_EVENT_CONFERENCE_INVITE: {
*out = TOX_EVENT_CONFERENCE_INVITE; *out_enum = TOX_EVENT_CONFERENCE_INVITE;
return true; return true;
} }
case TOX_EVENT_CONFERENCE_CONNECTED: { case TOX_EVENT_CONFERENCE_CONNECTED: {
*out = TOX_EVENT_CONFERENCE_CONNECTED; *out_enum = TOX_EVENT_CONFERENCE_CONNECTED;
return true; return true;
} }
case TOX_EVENT_CONFERENCE_PEER_LIST_CHANGED: { case TOX_EVENT_CONFERENCE_PEER_LIST_CHANGED: {
*out = TOX_EVENT_CONFERENCE_PEER_LIST_CHANGED; *out_enum = TOX_EVENT_CONFERENCE_PEER_LIST_CHANGED;
return true; return true;
} }
case TOX_EVENT_CONFERENCE_PEER_NAME: { case TOX_EVENT_CONFERENCE_PEER_NAME: {
*out = TOX_EVENT_CONFERENCE_PEER_NAME; *out_enum = TOX_EVENT_CONFERENCE_PEER_NAME;
return true; return true;
} }
case TOX_EVENT_CONFERENCE_TITLE: { case TOX_EVENT_CONFERENCE_TITLE: {
*out = TOX_EVENT_CONFERENCE_TITLE; *out_enum = TOX_EVENT_CONFERENCE_TITLE;
return true; return true;
} }
case TOX_EVENT_CONFERENCE_MESSAGE: { case TOX_EVENT_CONFERENCE_MESSAGE: {
*out = TOX_EVENT_CONFERENCE_MESSAGE; *out_enum = TOX_EVENT_CONFERENCE_MESSAGE;
return true; return true;
} }
case TOX_EVENT_GROUP_PEER_NAME: { case TOX_EVENT_GROUP_PEER_NAME: {
*out = TOX_EVENT_GROUP_PEER_NAME; *out_enum = TOX_EVENT_GROUP_PEER_NAME;
return true; return true;
} }
case TOX_EVENT_GROUP_PEER_STATUS: { case TOX_EVENT_GROUP_PEER_STATUS: {
*out = TOX_EVENT_GROUP_PEER_STATUS; *out_enum = TOX_EVENT_GROUP_PEER_STATUS;
return true; return true;
} }
case TOX_EVENT_GROUP_TOPIC: { case TOX_EVENT_GROUP_TOPIC: {
*out = TOX_EVENT_GROUP_TOPIC; *out_enum = TOX_EVENT_GROUP_TOPIC;
return true; return true;
} }
case TOX_EVENT_GROUP_PRIVACY_STATE: { case TOX_EVENT_GROUP_PRIVACY_STATE: {
*out = TOX_EVENT_GROUP_PRIVACY_STATE; *out_enum = TOX_EVENT_GROUP_PRIVACY_STATE;
return true; return true;
} }
case TOX_EVENT_GROUP_VOICE_STATE: { case TOX_EVENT_GROUP_VOICE_STATE: {
*out = TOX_EVENT_GROUP_VOICE_STATE; *out_enum = TOX_EVENT_GROUP_VOICE_STATE;
return true; return true;
} }
case TOX_EVENT_GROUP_TOPIC_LOCK: { case TOX_EVENT_GROUP_TOPIC_LOCK: {
*out = TOX_EVENT_GROUP_TOPIC_LOCK; *out_enum = TOX_EVENT_GROUP_TOPIC_LOCK;
return true; return true;
} }
case TOX_EVENT_GROUP_PEER_LIMIT: { case TOX_EVENT_GROUP_PEER_LIMIT: {
*out = TOX_EVENT_GROUP_PEER_LIMIT; *out_enum = TOX_EVENT_GROUP_PEER_LIMIT;
return true; return true;
} }
case TOX_EVENT_GROUP_PASSWORD: { case TOX_EVENT_GROUP_PASSWORD: {
*out = TOX_EVENT_GROUP_PASSWORD; *out_enum = TOX_EVENT_GROUP_PASSWORD;
return true; return true;
} }
case TOX_EVENT_GROUP_MESSAGE: { case TOX_EVENT_GROUP_MESSAGE: {
*out = TOX_EVENT_GROUP_MESSAGE; *out_enum = TOX_EVENT_GROUP_MESSAGE;
return true; return true;
} }
case TOX_EVENT_GROUP_PRIVATE_MESSAGE: { case TOX_EVENT_GROUP_PRIVATE_MESSAGE: {
*out = TOX_EVENT_GROUP_PRIVATE_MESSAGE; *out_enum = TOX_EVENT_GROUP_PRIVATE_MESSAGE;
return true; return true;
} }
case TOX_EVENT_GROUP_CUSTOM_PACKET: { case TOX_EVENT_GROUP_CUSTOM_PACKET: {
*out = TOX_EVENT_GROUP_CUSTOM_PACKET; *out_enum = TOX_EVENT_GROUP_CUSTOM_PACKET;
return true; return true;
} }
case TOX_EVENT_GROUP_CUSTOM_PRIVATE_PACKET: { case TOX_EVENT_GROUP_CUSTOM_PRIVATE_PACKET: {
*out = TOX_EVENT_GROUP_CUSTOM_PRIVATE_PACKET; *out_enum = TOX_EVENT_GROUP_CUSTOM_PRIVATE_PACKET;
return true; return true;
} }
case TOX_EVENT_GROUP_INVITE: { case TOX_EVENT_GROUP_INVITE: {
*out = TOX_EVENT_GROUP_INVITE; *out_enum = TOX_EVENT_GROUP_INVITE;
return true; return true;
} }
case TOX_EVENT_GROUP_PEER_JOIN: { case TOX_EVENT_GROUP_PEER_JOIN: {
*out = TOX_EVENT_GROUP_PEER_JOIN; *out_enum = TOX_EVENT_GROUP_PEER_JOIN;
return true; return true;
} }
case TOX_EVENT_GROUP_PEER_EXIT: { case TOX_EVENT_GROUP_PEER_EXIT: {
*out = TOX_EVENT_GROUP_PEER_EXIT; *out_enum = TOX_EVENT_GROUP_PEER_EXIT;
return true; return true;
} }
case TOX_EVENT_GROUP_SELF_JOIN: { case TOX_EVENT_GROUP_SELF_JOIN: {
*out = TOX_EVENT_GROUP_SELF_JOIN; *out_enum = TOX_EVENT_GROUP_SELF_JOIN;
return true; return true;
} }
case TOX_EVENT_GROUP_JOIN_FAIL: { case TOX_EVENT_GROUP_JOIN_FAIL: {
*out = TOX_EVENT_GROUP_JOIN_FAIL; *out_enum = TOX_EVENT_GROUP_JOIN_FAIL;
return true; return true;
} }
case TOX_EVENT_GROUP_MODERATION: { case TOX_EVENT_GROUP_MODERATION: {
*out = TOX_EVENT_GROUP_MODERATION; *out_enum = TOX_EVENT_GROUP_MODERATION;
return true; return true;
} }
case TOX_EVENT_DHT_GET_NODES_RESPONSE: { case TOX_EVENT_DHT_GET_NODES_RESPONSE: {
*out = TOX_EVENT_DHT_GET_NODES_RESPONSE; *out_enum = TOX_EVENT_DHT_GET_NODES_RESPONSE;
return true; return true;
} }
case TOX_EVENT_INVALID: { case TOX_EVENT_INVALID: {
*out = TOX_EVENT_INVALID; *out_enum = TOX_EVENT_INVALID;
return true; return true;
} }
default: { default: {
*out = TOX_EVENT_INVALID; *out_enum = TOX_EVENT_INVALID;
return false; return false;
} }
} }

View File

@ -248,7 +248,7 @@ uint32_t tox_event_group_message_get_group_number(
const Tox_Event_Group_Message *group_message); const Tox_Event_Group_Message *group_message);
uint32_t tox_event_group_message_get_peer_id( uint32_t tox_event_group_message_get_peer_id(
const Tox_Event_Group_Message *group_message); const Tox_Event_Group_Message *group_message);
Tox_Message_Type tox_event_group_message_get_type( Tox_Message_Type tox_event_group_message_get_message_type(
const Tox_Event_Group_Message *group_message); const Tox_Event_Group_Message *group_message);
const uint8_t *tox_event_group_message_get_message( const uint8_t *tox_event_group_message_get_message(
const Tox_Event_Group_Message *group_message); const Tox_Event_Group_Message *group_message);
@ -262,7 +262,7 @@ uint32_t tox_event_group_private_message_get_group_number(
const Tox_Event_Group_Private_Message *group_private_message); const Tox_Event_Group_Private_Message *group_private_message);
uint32_t tox_event_group_private_message_get_peer_id( uint32_t tox_event_group_private_message_get_peer_id(
const Tox_Event_Group_Private_Message *group_private_message); const Tox_Event_Group_Private_Message *group_private_message);
Tox_Message_Type tox_event_group_private_message_get_type( Tox_Message_Type tox_event_group_private_message_get_message_type(
const Tox_Event_Group_Private_Message *group_private_message); const Tox_Event_Group_Private_Message *group_private_message);
const uint8_t *tox_event_group_private_message_get_message( const uint8_t *tox_event_group_private_message_get_message(
const Tox_Event_Group_Private_Message *group_private_message); const Tox_Event_Group_Private_Message *group_private_message);

View File

@ -11,21 +11,21 @@
#include "tox.h" #include "tox.h"
non_null() non_null()
static bool tox_conference_type_from_int(uint32_t value, Tox_Conference_Type *out) static bool tox_conference_type_from_int(uint32_t value, Tox_Conference_Type *out_enum)
{ {
switch (value) { switch (value) {
case TOX_CONFERENCE_TYPE_TEXT: { case TOX_CONFERENCE_TYPE_TEXT: {
*out = TOX_CONFERENCE_TYPE_TEXT; *out_enum = TOX_CONFERENCE_TYPE_TEXT;
return true; return true;
} }
case TOX_CONFERENCE_TYPE_AV: { case TOX_CONFERENCE_TYPE_AV: {
*out = TOX_CONFERENCE_TYPE_AV; *out_enum = TOX_CONFERENCE_TYPE_AV;
return true; return true;
} }
default: { default: {
*out = TOX_CONFERENCE_TYPE_TEXT; *out_enum = TOX_CONFERENCE_TYPE_TEXT;
return false; return false;
} }
} }
@ -38,26 +38,26 @@ bool tox_conference_type_unpack(Tox_Conference_Type *val, Bin_Unpack *bu)
} }
non_null() non_null()
static bool tox_connection_from_int(uint32_t value, Tox_Connection *out) static bool tox_connection_from_int(uint32_t value, Tox_Connection *out_enum)
{ {
switch (value) { switch (value) {
case TOX_CONNECTION_NONE: { case TOX_CONNECTION_NONE: {
*out = TOX_CONNECTION_NONE; *out_enum = TOX_CONNECTION_NONE;
return true; return true;
} }
case TOX_CONNECTION_TCP: { case TOX_CONNECTION_TCP: {
*out = TOX_CONNECTION_TCP; *out_enum = TOX_CONNECTION_TCP;
return true; return true;
} }
case TOX_CONNECTION_UDP: { case TOX_CONNECTION_UDP: {
*out = TOX_CONNECTION_UDP; *out_enum = TOX_CONNECTION_UDP;
return true; return true;
} }
default: { default: {
*out = TOX_CONNECTION_NONE; *out_enum = TOX_CONNECTION_NONE;
return false; return false;
} }
} }
@ -71,26 +71,26 @@ bool tox_connection_unpack(Tox_Connection *val, Bin_Unpack *bu)
} }
non_null() non_null()
static bool tox_file_control_from_int(uint32_t value, Tox_File_Control *out) static bool tox_file_control_from_int(uint32_t value, Tox_File_Control *out_enum)
{ {
switch (value) { switch (value) {
case TOX_FILE_CONTROL_RESUME: { case TOX_FILE_CONTROL_RESUME: {
*out = TOX_FILE_CONTROL_RESUME; *out_enum = TOX_FILE_CONTROL_RESUME;
return true; return true;
} }
case TOX_FILE_CONTROL_PAUSE: { case TOX_FILE_CONTROL_PAUSE: {
*out = TOX_FILE_CONTROL_PAUSE; *out_enum = TOX_FILE_CONTROL_PAUSE;
return true; return true;
} }
case TOX_FILE_CONTROL_CANCEL: { case TOX_FILE_CONTROL_CANCEL: {
*out = TOX_FILE_CONTROL_CANCEL; *out_enum = TOX_FILE_CONTROL_CANCEL;
return true; return true;
} }
default: { default: {
*out = TOX_FILE_CONTROL_RESUME; *out_enum = TOX_FILE_CONTROL_RESUME;
return false; return false;
} }
} }
@ -104,21 +104,21 @@ bool tox_file_control_unpack(Tox_File_Control *val, Bin_Unpack *bu)
} }
non_null() non_null()
static bool tox_message_type_from_int(uint32_t value, Tox_Message_Type *out) static bool tox_message_type_from_int(uint32_t value, Tox_Message_Type *out_enum)
{ {
switch (value) { switch (value) {
case TOX_MESSAGE_TYPE_NORMAL: { case TOX_MESSAGE_TYPE_NORMAL: {
*out = TOX_MESSAGE_TYPE_NORMAL; *out_enum = TOX_MESSAGE_TYPE_NORMAL;
return true; return true;
} }
case TOX_MESSAGE_TYPE_ACTION: { case TOX_MESSAGE_TYPE_ACTION: {
*out = TOX_MESSAGE_TYPE_ACTION; *out_enum = TOX_MESSAGE_TYPE_ACTION;
return true; return true;
} }
default: { default: {
*out = TOX_MESSAGE_TYPE_NORMAL; *out_enum = TOX_MESSAGE_TYPE_NORMAL;
return false; return false;
} }
} }
@ -132,26 +132,26 @@ bool tox_message_type_unpack(Tox_Message_Type *val, Bin_Unpack *bu)
} }
non_null() non_null()
static bool tox_user_status_from_int(uint32_t value, Tox_User_Status *out) static bool tox_user_status_from_int(uint32_t value, Tox_User_Status *out_enum)
{ {
switch (value) { switch (value) {
case TOX_USER_STATUS_NONE: { case TOX_USER_STATUS_NONE: {
*out = TOX_USER_STATUS_NONE; *out_enum = TOX_USER_STATUS_NONE;
return true; return true;
} }
case TOX_USER_STATUS_AWAY: { case TOX_USER_STATUS_AWAY: {
*out = TOX_USER_STATUS_AWAY; *out_enum = TOX_USER_STATUS_AWAY;
return true; return true;
} }
case TOX_USER_STATUS_BUSY: { case TOX_USER_STATUS_BUSY: {
*out = TOX_USER_STATUS_BUSY; *out_enum = TOX_USER_STATUS_BUSY;
return true; return true;
} }
default: { default: {
*out = TOX_USER_STATUS_NONE; *out_enum = TOX_USER_STATUS_NONE;
return false; return false;
} }
} }
@ -165,19 +165,19 @@ bool tox_user_status_unpack(Tox_User_Status *val, Bin_Unpack *bu)
} }
non_null() non_null()
static bool tox_group_privacy_state_from_int(uint32_t value, Tox_Group_Privacy_State *out) static bool tox_group_privacy_state_from_int(uint32_t value, Tox_Group_Privacy_State *out_enum)
{ {
switch (value) { switch (value) {
case TOX_GROUP_PRIVACY_STATE_PUBLIC: { case TOX_GROUP_PRIVACY_STATE_PUBLIC: {
*out = TOX_GROUP_PRIVACY_STATE_PUBLIC; *out_enum = TOX_GROUP_PRIVACY_STATE_PUBLIC;
return true; return true;
} }
case TOX_GROUP_PRIVACY_STATE_PRIVATE: { case TOX_GROUP_PRIVACY_STATE_PRIVATE: {
*out = TOX_GROUP_PRIVACY_STATE_PRIVATE; *out_enum = TOX_GROUP_PRIVACY_STATE_PRIVATE;
return true; return true;
} }
default: { default: {
*out = TOX_GROUP_PRIVACY_STATE_PUBLIC; *out_enum = TOX_GROUP_PRIVACY_STATE_PUBLIC;
return false; return false;
} }
} }
@ -189,23 +189,23 @@ bool tox_group_privacy_state_unpack(Tox_Group_Privacy_State *val, Bin_Unpack *bu
&& tox_group_privacy_state_from_int(u32, val); && tox_group_privacy_state_from_int(u32, val);
} }
non_null() non_null()
static bool tox_group_voice_state_from_int(uint32_t value, Tox_Group_Voice_State *out) static bool tox_group_voice_state_from_int(uint32_t value, Tox_Group_Voice_State *out_enum)
{ {
switch (value) { switch (value) {
case TOX_GROUP_VOICE_STATE_ALL: { case TOX_GROUP_VOICE_STATE_ALL: {
*out = TOX_GROUP_VOICE_STATE_ALL; *out_enum = TOX_GROUP_VOICE_STATE_ALL;
return true; return true;
} }
case TOX_GROUP_VOICE_STATE_MODERATOR: { case TOX_GROUP_VOICE_STATE_MODERATOR: {
*out = TOX_GROUP_VOICE_STATE_MODERATOR; *out_enum = TOX_GROUP_VOICE_STATE_MODERATOR;
return true; return true;
} }
case TOX_GROUP_VOICE_STATE_FOUNDER: { case TOX_GROUP_VOICE_STATE_FOUNDER: {
*out = TOX_GROUP_VOICE_STATE_FOUNDER; *out_enum = TOX_GROUP_VOICE_STATE_FOUNDER;
return true; return true;
} }
default: { default: {
*out = TOX_GROUP_VOICE_STATE_ALL; *out_enum = TOX_GROUP_VOICE_STATE_ALL;
return false; return false;
} }
} }
@ -218,19 +218,19 @@ bool tox_group_voice_state_unpack(Tox_Group_Voice_State *val, Bin_Unpack *bu)
} }
non_null() non_null()
static bool tox_group_topic_lock_from_int(uint32_t value, Tox_Group_Topic_Lock *out) static bool tox_group_topic_lock_from_int(uint32_t value, Tox_Group_Topic_Lock *out_enum)
{ {
switch (value) { switch (value) {
case TOX_GROUP_TOPIC_LOCK_ENABLED: { case TOX_GROUP_TOPIC_LOCK_ENABLED: {
*out = TOX_GROUP_TOPIC_LOCK_ENABLED; *out_enum = TOX_GROUP_TOPIC_LOCK_ENABLED;
return true; return true;
} }
case TOX_GROUP_TOPIC_LOCK_DISABLED: { case TOX_GROUP_TOPIC_LOCK_DISABLED: {
*out = TOX_GROUP_TOPIC_LOCK_DISABLED; *out_enum = TOX_GROUP_TOPIC_LOCK_DISABLED;
return true; return true;
} }
default: { default: {
*out = TOX_GROUP_TOPIC_LOCK_ENABLED; *out_enum = TOX_GROUP_TOPIC_LOCK_ENABLED;
return false; return false;
} }
} }
@ -243,23 +243,23 @@ bool tox_group_topic_lock_unpack(Tox_Group_Topic_Lock *val, Bin_Unpack *bu)
} }
non_null() non_null()
static bool tox_group_join_fail_from_int(uint32_t value, Tox_Group_Join_Fail *out) static bool tox_group_join_fail_from_int(uint32_t value, Tox_Group_Join_Fail *out_enum)
{ {
switch (value) { switch (value) {
case TOX_GROUP_JOIN_FAIL_PEER_LIMIT: { case TOX_GROUP_JOIN_FAIL_PEER_LIMIT: {
*out = TOX_GROUP_JOIN_FAIL_PEER_LIMIT; *out_enum = TOX_GROUP_JOIN_FAIL_PEER_LIMIT;
return true; return true;
} }
case TOX_GROUP_JOIN_FAIL_INVALID_PASSWORD: { case TOX_GROUP_JOIN_FAIL_INVALID_PASSWORD: {
*out = TOX_GROUP_JOIN_FAIL_INVALID_PASSWORD; *out_enum = TOX_GROUP_JOIN_FAIL_INVALID_PASSWORD;
return true; return true;
} }
case TOX_GROUP_JOIN_FAIL_UNKNOWN: { case TOX_GROUP_JOIN_FAIL_UNKNOWN: {
*out = TOX_GROUP_JOIN_FAIL_UNKNOWN; *out_enum = TOX_GROUP_JOIN_FAIL_UNKNOWN;
return true; return true;
} }
default: { default: {
*out = TOX_GROUP_JOIN_FAIL_PEER_LIMIT; *out_enum = TOX_GROUP_JOIN_FAIL_PEER_LIMIT;
return false; return false;
} }
} }
@ -272,27 +272,27 @@ bool tox_group_join_fail_unpack(Tox_Group_Join_Fail *val, Bin_Unpack *bu)
} }
non_null() non_null()
static bool tox_group_mod_event_from_int(uint32_t value, Tox_Group_Mod_Event *out) static bool tox_group_mod_event_from_int(uint32_t value, Tox_Group_Mod_Event *out_enum)
{ {
switch (value) { switch (value) {
case TOX_GROUP_MOD_EVENT_KICK: { case TOX_GROUP_MOD_EVENT_KICK: {
*out = TOX_GROUP_MOD_EVENT_KICK; *out_enum = TOX_GROUP_MOD_EVENT_KICK;
return true; return true;
} }
case TOX_GROUP_MOD_EVENT_OBSERVER: { case TOX_GROUP_MOD_EVENT_OBSERVER: {
*out = TOX_GROUP_MOD_EVENT_OBSERVER; *out_enum = TOX_GROUP_MOD_EVENT_OBSERVER;
return true; return true;
} }
case TOX_GROUP_MOD_EVENT_USER: { case TOX_GROUP_MOD_EVENT_USER: {
*out = TOX_GROUP_MOD_EVENT_USER; *out_enum = TOX_GROUP_MOD_EVENT_USER;
return true; return true;
} }
case TOX_GROUP_MOD_EVENT_MODERATOR: { case TOX_GROUP_MOD_EVENT_MODERATOR: {
*out = TOX_GROUP_MOD_EVENT_MODERATOR; *out_enum = TOX_GROUP_MOD_EVENT_MODERATOR;
return true; return true;
} }
default: { default: {
*out = TOX_GROUP_MOD_EVENT_KICK; *out_enum = TOX_GROUP_MOD_EVENT_KICK;
return false; return false;
} }
} }
@ -305,35 +305,35 @@ bool tox_group_mod_event_unpack(Tox_Group_Mod_Event *val, Bin_Unpack *bu)
} }
non_null() non_null()
static bool tox_group_exit_type_from_int(uint32_t value, Tox_Group_Exit_Type *out) static bool tox_group_exit_type_from_int(uint32_t value, Tox_Group_Exit_Type *out_enum)
{ {
switch (value) { switch (value) {
case TOX_GROUP_EXIT_TYPE_QUIT: { case TOX_GROUP_EXIT_TYPE_QUIT: {
*out = TOX_GROUP_EXIT_TYPE_QUIT; *out_enum = TOX_GROUP_EXIT_TYPE_QUIT;
return true; return true;
} }
case TOX_GROUP_EXIT_TYPE_TIMEOUT: { case TOX_GROUP_EXIT_TYPE_TIMEOUT: {
*out = TOX_GROUP_EXIT_TYPE_TIMEOUT; *out_enum = TOX_GROUP_EXIT_TYPE_TIMEOUT;
return true; return true;
} }
case TOX_GROUP_EXIT_TYPE_DISCONNECTED: { case TOX_GROUP_EXIT_TYPE_DISCONNECTED: {
*out = TOX_GROUP_EXIT_TYPE_DISCONNECTED; *out_enum = TOX_GROUP_EXIT_TYPE_DISCONNECTED;
return true; return true;
} }
case TOX_GROUP_EXIT_TYPE_SELF_DISCONNECTED: { case TOX_GROUP_EXIT_TYPE_SELF_DISCONNECTED: {
*out = TOX_GROUP_EXIT_TYPE_SELF_DISCONNECTED; *out_enum = TOX_GROUP_EXIT_TYPE_SELF_DISCONNECTED;
return true; return true;
} }
case TOX_GROUP_EXIT_TYPE_KICK: { case TOX_GROUP_EXIT_TYPE_KICK: {
*out = TOX_GROUP_EXIT_TYPE_KICK; *out_enum = TOX_GROUP_EXIT_TYPE_KICK;
return true; return true;
} }
case TOX_GROUP_EXIT_TYPE_SYNC_ERROR: { case TOX_GROUP_EXIT_TYPE_SYNC_ERROR: {
*out = TOX_GROUP_EXIT_TYPE_SYNC_ERROR; *out_enum = TOX_GROUP_EXIT_TYPE_SYNC_ERROR;
return true; return true;
} }
default: { default: {
*out = TOX_GROUP_EXIT_TYPE_QUIT; *out_enum = TOX_GROUP_EXIT_TYPE_QUIT;
return false; return false;
} }
} }