diff options
Diffstat (limited to 'protocols/Tox/libtox/src/toxcore/tox.c')
-rw-r--r-- | protocols/Tox/libtox/src/toxcore/tox.c | 285 |
1 files changed, 159 insertions, 126 deletions
diff --git a/protocols/Tox/libtox/src/toxcore/tox.c b/protocols/Tox/libtox/src/toxcore/tox.c index 085fab2ec1..b02eb4e98b 100644 --- a/protocols/Tox/libtox/src/toxcore/tox.c +++ b/protocols/Tox/libtox/src/toxcore/tox.c @@ -524,7 +524,7 @@ static void tox_group_password_handler(const Messenger *m, uint32_t group_number non_null(1, 5) nullable(8) static void tox_group_message_handler(const Messenger *m, uint32_t group_number, GC_Peer_Id peer_id, unsigned int type, - const uint8_t *message, size_t length, uint32_t message_id, void *user_data) + const uint8_t *message, size_t length, Tox_Group_Message_Id message_id, void *user_data) { struct Tox_Userdata *tox_data = (struct Tox_Userdata *)user_data; @@ -536,16 +536,16 @@ static void tox_group_message_handler(const Messenger *m, uint32_t group_number, } } -non_null(1, 5) nullable(7) +non_null(1, 5) nullable(8) static void tox_group_private_message_handler(const Messenger *m, uint32_t group_number, GC_Peer_Id peer_id, - unsigned int type, const uint8_t *message, size_t length, void *user_data) + unsigned int type, const uint8_t *message, size_t length, Tox_Group_Message_Id message_id, void *user_data) { struct Tox_Userdata *tox_data = (struct Tox_Userdata *)user_data; if (tox_data->tox->group_private_message_callback != nullptr) { tox_unlock(tox_data->tox); tox_data->tox->group_private_message_callback(tox_data->tox, group_number, gc_peer_id_to_int(peer_id), (Tox_Message_Type)type, message, - length, tox_data->user_data); + length, message_id, tox_data->user_data); tox_lock(tox_data->tox); } } @@ -712,7 +712,8 @@ static int tox_load(Tox *tox, const uint8_t *data, uint32_t length) length - cookie_len, STATE_COOKIE_TYPE); } -Tox *tox_new(const struct Tox_Options *options, Tox_Err_New *error) +nullable(1, 2, 3) +static Tox *tox_new_system(const struct Tox_Options *options, Tox_Err_New *error, const Tox_System *sys) { struct Tox_Options *default_options = nullptr; @@ -736,7 +737,6 @@ Tox *tox_new(const struct Tox_Options *options, Tox_Err_New *error) const struct Tox_Options *const opts = options != nullptr ? options : default_options; assert(opts != nullptr); - const Tox_System *sys = tox_options_get_operating_system(opts); const Tox_System default_system = tox_default_system(); if (sys == nullptr) { @@ -1020,6 +1020,37 @@ Tox *tox_new(const struct Tox_Options *options, Tox_Err_New *error) return tox; } +Tox *tox_new(const struct Tox_Options *options, Tox_Err_New *error) +{ + return tox_new_system(options, error, nullptr); +} + +Tox *tox_new_testing(const Tox_Options *options, Tox_Err_New *error, const Tox_Options_Testing *testing, Tox_Err_New_Testing *testing_error) +{ + if (testing == nullptr) { + SET_ERROR_PARAMETER(error, TOX_ERR_NEW_NULL); + SET_ERROR_PARAMETER(testing_error, TOX_ERR_NEW_TESTING_NULL); + return nullptr; + } + + if (testing->operating_system == nullptr) { + SET_ERROR_PARAMETER(error, TOX_ERR_NEW_NULL); + SET_ERROR_PARAMETER(testing_error, TOX_ERR_NEW_TESTING_NULL); + return nullptr; + } + + const Tox_System *sys = testing->operating_system; + + if (sys->rng == nullptr || sys->ns == nullptr || sys->mem == nullptr) { + SET_ERROR_PARAMETER(error, TOX_ERR_NEW_NULL); + SET_ERROR_PARAMETER(testing_error, TOX_ERR_NEW_TESTING_NULL); + return nullptr; + } + + SET_ERROR_PARAMETER(testing_error, TOX_ERR_NEW_TESTING_OK); + return tox_new_system(options, error, sys); +} + void tox_kill(Tox *tox) { if (tox == nullptr) { @@ -1027,7 +1058,7 @@ void tox_kill(Tox *tox) } tox_lock(tox); - LOGGER_ASSERT(tox->m->log, tox->m->msi_packet == nullptr, "Attempted to kill tox while toxav is still alive"); + LOGGER_ASSERT(tox->m->log, tox->toxav_object == nullptr, "Attempted to kill tox while toxav is still alive"); kill_groupchats(tox->m->conferences_object); kill_messenger(tox->m); mono_time_free(tox->sys.mem, tox->mono_time); @@ -2520,6 +2551,12 @@ uint32_t tox_conference_join(Tox *tox, uint32_t friend_number, const uint8_t *co Tox_Err_Conference_Join *error) { assert(tox != nullptr); + + if (cookie == nullptr) { + SET_ERROR_PARAMETER(error, TOX_ERR_CONFERENCE_JOIN_NULL); + return UINT32_MAX; + } + tox_lock(tox); const int ret = join_groupchat(tox->m->conferences_object, friend_number, GROUPCHAT_TYPE_TEXT, cookie, length); tox_unlock(tox); @@ -3688,7 +3725,7 @@ bool tox_group_set_topic(Tox *tox, uint32_t group_number, const uint8_t *topic, return false; } -size_t tox_group_get_topic_size(const Tox *tox, uint32_t group_number, Tox_Err_Group_State_Queries *error) +size_t tox_group_get_topic_size(const Tox *tox, uint32_t group_number, Tox_Err_Group_State_Query *error) { assert(tox != nullptr); @@ -3696,12 +3733,12 @@ size_t tox_group_get_topic_size(const Tox *tox, uint32_t group_number, Tox_Err_G const GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number); if (chat == nullptr) { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_GROUP_NOT_FOUND); tox_unlock(tox); return -1; } - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_OK); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_OK); const size_t ret = gc_get_topic_size(chat); tox_unlock(tox); @@ -3709,7 +3746,7 @@ size_t tox_group_get_topic_size(const Tox *tox, uint32_t group_number, Tox_Err_G return ret; } -bool tox_group_get_topic(const Tox *tox, uint32_t group_number, uint8_t *topic, Tox_Err_Group_State_Queries *error) +bool tox_group_get_topic(const Tox *tox, uint32_t group_number, uint8_t *topic, Tox_Err_Group_State_Query *error) { assert(tox != nullptr); @@ -3717,7 +3754,7 @@ bool tox_group_get_topic(const Tox *tox, uint32_t group_number, uint8_t *topic, const GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number); if (chat == nullptr) { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_GROUP_NOT_FOUND); tox_unlock(tox); return false; } @@ -3725,11 +3762,11 @@ bool tox_group_get_topic(const Tox *tox, uint32_t group_number, uint8_t *topic, gc_get_topic(chat, topic); tox_unlock(tox); - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_OK); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_OK); return true; } -size_t tox_group_get_name_size(const Tox *tox, uint32_t group_number, Tox_Err_Group_State_Queries *error) +size_t tox_group_get_name_size(const Tox *tox, uint32_t group_number, Tox_Err_Group_State_Query *error) { assert(tox != nullptr); @@ -3737,12 +3774,12 @@ size_t tox_group_get_name_size(const Tox *tox, uint32_t group_number, Tox_Err_Gr const GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number); if (chat == nullptr) { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_GROUP_NOT_FOUND); tox_unlock(tox); return -1; } - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_OK); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_OK); const size_t ret = gc_get_group_name_size(chat); tox_unlock(tox); @@ -3750,7 +3787,7 @@ size_t tox_group_get_name_size(const Tox *tox, uint32_t group_number, Tox_Err_Gr return ret; } -bool tox_group_get_name(const Tox *tox, uint32_t group_number, uint8_t *name, Tox_Err_Group_State_Queries *error) +bool tox_group_get_name(const Tox *tox, uint32_t group_number, uint8_t *name, Tox_Err_Group_State_Query *error) { assert(tox != nullptr); @@ -3758,7 +3795,7 @@ bool tox_group_get_name(const Tox *tox, uint32_t group_number, uint8_t *name, To const GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number); if (chat == nullptr) { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_GROUP_NOT_FOUND); tox_unlock(tox); return false; } @@ -3766,12 +3803,12 @@ bool tox_group_get_name(const Tox *tox, uint32_t group_number, uint8_t *name, To gc_get_group_name(chat, name); tox_unlock(tox); - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_OK); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_OK); return true; } -bool tox_group_get_chat_id(const Tox *tox, uint32_t group_number, uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE], Tox_Err_Group_State_Queries *error) +bool tox_group_get_chat_id(const Tox *tox, uint32_t group_number, uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE], Tox_Err_Group_State_Query *error) { assert(tox != nullptr); @@ -3779,12 +3816,12 @@ bool tox_group_get_chat_id(const Tox *tox, uint32_t group_number, uint8_t chat_i const GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number); if (chat == nullptr) { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_GROUP_NOT_FOUND); tox_unlock(tox); return false; } - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_OK); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_OK); gc_get_chat_id(chat, chat_id); tox_unlock(tox); @@ -3803,7 +3840,7 @@ uint32_t tox_group_get_number_groups(const Tox *tox) } Tox_Group_Privacy_State tox_group_get_privacy_state(const Tox *tox, uint32_t group_number, - Tox_Err_Group_State_Queries *error) + Tox_Err_Group_State_Query *error) { assert(tox != nullptr); @@ -3811,12 +3848,12 @@ Tox_Group_Privacy_State tox_group_get_privacy_state(const Tox *tox, uint32_t gro const GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number); if (chat == nullptr) { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_GROUP_NOT_FOUND); tox_unlock(tox); return (Tox_Group_Privacy_State) - 1; } - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_OK); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_OK); const uint8_t state = gc_get_privacy_state(chat); tox_unlock(tox); @@ -3824,7 +3861,7 @@ Tox_Group_Privacy_State tox_group_get_privacy_state(const Tox *tox, uint32_t gro return (Tox_Group_Privacy_State)state; } -Tox_Group_Topic_Lock tox_group_get_topic_lock(const Tox *tox, uint32_t group_number, Tox_Err_Group_State_Queries *error) +Tox_Group_Topic_Lock tox_group_get_topic_lock(const Tox *tox, uint32_t group_number, Tox_Err_Group_State_Query *error) { assert(tox != nullptr); @@ -3832,12 +3869,12 @@ Tox_Group_Topic_Lock tox_group_get_topic_lock(const Tox *tox, uint32_t group_num const GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number); if (chat == nullptr) { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_GROUP_NOT_FOUND); tox_unlock(tox); return (Tox_Group_Topic_Lock) - 1; } - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_OK); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_OK); const Group_Topic_Lock topic_lock = gc_get_topic_lock_state(chat); tox_unlock(tox); @@ -3846,7 +3883,7 @@ Tox_Group_Topic_Lock tox_group_get_topic_lock(const Tox *tox, uint32_t group_num } Tox_Group_Voice_State tox_group_get_voice_state(const Tox *tox, uint32_t group_number, - Tox_Err_Group_State_Queries *error) + Tox_Err_Group_State_Query *error) { assert(tox != nullptr); @@ -3854,12 +3891,12 @@ Tox_Group_Voice_State tox_group_get_voice_state(const Tox *tox, uint32_t group_n const GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number); if (chat == nullptr) { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_GROUP_NOT_FOUND); tox_unlock(tox); return (Tox_Group_Voice_State) - 1; } - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_OK); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_OK); const Group_Voice_State voice_state = gc_get_voice_state(chat); tox_unlock(tox); @@ -3867,7 +3904,7 @@ Tox_Group_Voice_State tox_group_get_voice_state(const Tox *tox, uint32_t group_n return (Tox_Group_Voice_State)voice_state; } -uint16_t tox_group_get_peer_limit(const Tox *tox, uint32_t group_number, Tox_Err_Group_State_Queries *error) +uint16_t tox_group_get_peer_limit(const Tox *tox, uint32_t group_number, Tox_Err_Group_State_Query *error) { assert(tox != nullptr); @@ -3875,12 +3912,12 @@ uint16_t tox_group_get_peer_limit(const Tox *tox, uint32_t group_number, Tox_Err const GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number); if (chat == nullptr) { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_GROUP_NOT_FOUND); tox_unlock(tox); return -1; } - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_OK); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_OK); const uint16_t ret = gc_get_max_peers(chat); tox_unlock(tox); @@ -3888,7 +3925,7 @@ uint16_t tox_group_get_peer_limit(const Tox *tox, uint32_t group_number, Tox_Err return ret; } -size_t tox_group_get_password_size(const Tox *tox, uint32_t group_number, Tox_Err_Group_State_Queries *error) +size_t tox_group_get_password_size(const Tox *tox, uint32_t group_number, Tox_Err_Group_State_Query *error) { assert(tox != nullptr); @@ -3896,12 +3933,12 @@ size_t tox_group_get_password_size(const Tox *tox, uint32_t group_number, Tox_Er const GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number); if (chat == nullptr) { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_GROUP_NOT_FOUND); tox_unlock(tox); return -1; } - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_OK); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_OK); const size_t ret = gc_get_password_size(chat); tox_unlock(tox); @@ -3910,7 +3947,7 @@ size_t tox_group_get_password_size(const Tox *tox, uint32_t group_number, Tox_Er } bool tox_group_get_password(const Tox *tox, uint32_t group_number, uint8_t *password, - Tox_Err_Group_State_Queries *error) + Tox_Err_Group_State_Query *error) { assert(tox != nullptr); @@ -3918,12 +3955,12 @@ bool tox_group_get_password(const Tox *tox, uint32_t group_number, uint8_t *pass const GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number); if (chat == nullptr) { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_GROUP_NOT_FOUND); tox_unlock(tox); return false; } - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_OK); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_OK); gc_get_password(chat, password); tox_unlock(tox); @@ -3932,7 +3969,7 @@ bool tox_group_get_password(const Tox *tox, uint32_t group_number, uint8_t *pass } 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) { assert(tox != nullptr); @@ -3953,7 +3990,7 @@ Tox_Group_Message_Id tox_group_send_message( } 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); switch (ret) { @@ -3994,8 +4031,8 @@ Tox_Group_Message_Id tox_group_send_message( return -1; } -bool 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_Group_Message_Id tox_group_send_private_message(const Tox *tox, uint32_t group_number, uint32_t peer_id, + Tox_Message_Type message_type, const uint8_t *message, size_t length, Tox_Err_Group_Send_Private_Message *error) { assert(tox != nullptr); @@ -4005,59 +4042,60 @@ bool tox_group_send_private_message(const Tox *tox, uint32_t group_number, uint3 if (chat == nullptr) { SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_GROUP_NOT_FOUND); tox_unlock(tox); - return false; + return -1; } if (chat->connection_state == CS_DISCONNECTED) { SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_DISCONNECTED); tox_unlock(tox); - return false; + return -1; } - const int ret = gc_send_private_message(chat, gc_peer_id_from_int(peer_id), type, message, length); + uint32_t message_id = 0; + const int ret = gc_send_private_message(chat, gc_peer_id_from_int(peer_id), message_type, message, length, &message_id); tox_unlock(tox); switch (ret) { case 0: { SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_OK); - return true; + return message_id; } case -1: { SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_TOO_LONG); - return false; + return -1; } case -2: { SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_EMPTY); - return false; + return -1; } case -3: { SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_PEER_NOT_FOUND); - return false; + return -1; } case -4: { SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_BAD_TYPE); - return false; + return -1; } case -5: { SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_PERMISSIONS); - return false; + return -1; } case -6: { SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_FAIL_SEND); - return false; + return -1; } } /* can't happen */ LOGGER_FATAL(tox->m->log, "impossible return value: %d", ret); - return false; + return -1; } bool tox_group_send_custom_packet(const Tox *tox, uint32_t group_number, bool lossless, const uint8_t *data, @@ -4100,11 +4138,6 @@ bool tox_group_send_custom_packet(const Tox *tox, uint32_t group_number, bool lo } case -3: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_CUSTOM_PACKET_PERMISSIONS); - return false; - } - - case -4: { SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_CUSTOM_PACKET_FAIL_SEND); return false; } @@ -4162,11 +4195,6 @@ bool tox_group_send_custom_private_packet(const Tox *tox, uint32_t group_number, } case -4: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_PERMISSIONS); - return false; - } - - case -5: { SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_FAIL_SEND); return false; } @@ -4241,6 +4269,11 @@ uint32_t tox_group_invite_accept(Tox *tox, uint32_t friend_number, const uint8_t { assert(tox != nullptr); + if (invite_data == nullptr || name == nullptr) { + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_INVITE_ACCEPT_NULL); + return UINT32_MAX; + } + tox_lock(tox); const int ret = gc_accept_invite(tox->m->group_handler, friend_number, invite_data, length, name, name_length, password, password_length); @@ -4278,7 +4311,7 @@ uint32_t tox_group_invite_accept(Tox *tox, uint32_t friend_number, const uint8_t } case -6: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_INVITE_ACCEPT_CORE); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_INVITE_ACCEPT_FRIEND_NOT_FOUND); return UINT32_MAX; } @@ -4294,8 +4327,8 @@ uint32_t tox_group_invite_accept(Tox *tox, uint32_t friend_number, const uint8_t return UINT32_MAX; } -bool tox_group_founder_set_password(Tox *tox, uint32_t group_number, const uint8_t *password, size_t length, - Tox_Err_Group_Founder_Set_Password *error) +bool tox_group_set_password(Tox *tox, uint32_t group_number, const uint8_t *password, size_t length, + Tox_Err_Group_Set_Password *error) { assert(tox != nullptr); @@ -4303,13 +4336,13 @@ bool tox_group_founder_set_password(Tox *tox, uint32_t group_number, const uint8 GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number); if (chat == nullptr) { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_GROUP_NOT_FOUND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PASSWORD_GROUP_NOT_FOUND); tox_unlock(tox); return false; } if (chat->connection_state == CS_DISCONNECTED) { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_DISCONNECTED); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PASSWORD_DISCONNECTED); tox_unlock(tox); return false; } @@ -4319,27 +4352,27 @@ bool tox_group_founder_set_password(Tox *tox, uint32_t group_number, const uint8 switch (ret) { case 0: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_OK); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PASSWORD_OK); return true; } case -1: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_PERMISSIONS); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PASSWORD_PERMISSIONS); return false; } case -2: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_TOO_LONG); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PASSWORD_TOO_LONG); return false; } case -3: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_FAIL_SEND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PASSWORD_FAIL_SEND); return false; } case -4: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_MALLOC); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PASSWORD_MALLOC); return false; } } @@ -4350,8 +4383,8 @@ bool tox_group_founder_set_password(Tox *tox, uint32_t group_number, const uint8 return false; } -bool tox_group_founder_set_privacy_state(Tox *tox, uint32_t group_number, Tox_Group_Privacy_State privacy_state, - Tox_Err_Group_Founder_Set_Privacy_State *error) +bool tox_group_set_privacy_state(Tox *tox, uint32_t group_number, Tox_Group_Privacy_State privacy_state, + Tox_Err_Group_Set_Privacy_State *error) { assert(tox != nullptr); @@ -4361,32 +4394,32 @@ bool tox_group_founder_set_privacy_state(Tox *tox, uint32_t group_number, Tox_Gr switch (ret) { case 0: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_OK); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PRIVACY_STATE_OK); return true; } case -1: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_GROUP_NOT_FOUND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PRIVACY_STATE_GROUP_NOT_FOUND); return false; } case -2: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_PERMISSIONS); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PRIVACY_STATE_PERMISSIONS); return false; } case -3: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_DISCONNECTED); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PRIVACY_STATE_DISCONNECTED); return false; } case -4: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_FAIL_SET); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PRIVACY_STATE_FAIL_SET); return false; } case -5: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_FAIL_SEND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PRIVACY_STATE_FAIL_SEND); return false; } } @@ -4397,8 +4430,8 @@ bool tox_group_founder_set_privacy_state(Tox *tox, uint32_t group_number, Tox_Gr return false; } -bool tox_group_founder_set_topic_lock(Tox *tox, uint32_t group_number, Tox_Group_Topic_Lock topic_lock, - Tox_Err_Group_Founder_Set_Topic_Lock *error) +bool tox_group_set_topic_lock(Tox *tox, uint32_t group_number, Tox_Group_Topic_Lock topic_lock, + Tox_Err_Group_Set_Topic_Lock *error) { assert(tox != nullptr); @@ -4408,37 +4441,37 @@ bool tox_group_founder_set_topic_lock(Tox *tox, uint32_t group_number, Tox_Group switch (ret) { case 0: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_OK); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_TOPIC_LOCK_OK); return true; } case -1: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_GROUP_NOT_FOUND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_TOPIC_LOCK_GROUP_NOT_FOUND); return false; } case -2: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_INVALID); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_TOPIC_LOCK_INVALID); return false; } case -3: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_PERMISSIONS); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_TOPIC_LOCK_PERMISSIONS); return false; } case -4: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_DISCONNECTED); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_TOPIC_LOCK_DISCONNECTED); return false; } case -5: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_FAIL_SET); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_TOPIC_LOCK_FAIL_SET); return false; } case -6: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_FAIL_SEND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_TOPIC_LOCK_FAIL_SEND); return false; } } @@ -4449,8 +4482,8 @@ bool tox_group_founder_set_topic_lock(Tox *tox, uint32_t group_number, Tox_Group return false; } -bool tox_group_founder_set_voice_state(Tox *tox, uint32_t group_number, Tox_Group_Voice_State voice_state, - Tox_Err_Group_Founder_Set_Voice_State *error) +bool tox_group_set_voice_state(Tox *tox, uint32_t group_number, Tox_Group_Voice_State voice_state, + Tox_Err_Group_Set_Voice_State *error) { assert(tox != nullptr); @@ -4460,32 +4493,32 @@ bool tox_group_founder_set_voice_state(Tox *tox, uint32_t group_number, Tox_Grou switch (ret) { case 0: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_OK); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_VOICE_STATE_OK); return true; } case -1: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_GROUP_NOT_FOUND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_VOICE_STATE_GROUP_NOT_FOUND); return false; } case -2: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_PERMISSIONS); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_VOICE_STATE_PERMISSIONS); return false; } case -3: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_DISCONNECTED); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_VOICE_STATE_DISCONNECTED); return false; } case -4: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_FAIL_SET); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_VOICE_STATE_FAIL_SET); return false; } case -5: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_FAIL_SEND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_VOICE_STATE_FAIL_SEND); return false; } } @@ -4496,8 +4529,8 @@ bool tox_group_founder_set_voice_state(Tox *tox, uint32_t group_number, Tox_Grou return false; } -bool tox_group_founder_set_peer_limit(Tox *tox, uint32_t group_number, uint16_t peer_limit, - Tox_Err_Group_Founder_Set_Peer_Limit *error) +bool tox_group_set_peer_limit(Tox *tox, uint32_t group_number, uint16_t peer_limit, + Tox_Err_Group_Set_Peer_Limit *error) { assert(tox != nullptr); @@ -4505,13 +4538,13 @@ bool tox_group_founder_set_peer_limit(Tox *tox, uint32_t group_number, uint16_t GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number); if (chat == nullptr) { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_GROUP_NOT_FOUND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PEER_LIMIT_GROUP_NOT_FOUND); tox_unlock(tox); return false; } if (chat->connection_state == CS_DISCONNECTED) { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_DISCONNECTED); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PEER_LIMIT_DISCONNECTED); tox_unlock(tox); return false; } @@ -4521,22 +4554,22 @@ bool tox_group_founder_set_peer_limit(Tox *tox, uint32_t group_number, uint16_t switch (ret) { case 0: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_OK); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PEER_LIMIT_OK); return true; } case -1: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_PERMISSIONS); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PEER_LIMIT_PERMISSIONS); return false; } case -2: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_FAIL_SET); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PEER_LIMIT_FAIL_SET); return false; } case -3: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_FAIL_SEND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PEER_LIMIT_FAIL_SEND); return false; } } @@ -4587,8 +4620,8 @@ bool tox_group_set_ignore(Tox *tox, uint32_t group_number, uint32_t peer_id, boo return false; } -bool tox_group_mod_set_role(Tox *tox, uint32_t group_number, uint32_t peer_id, Tox_Group_Role role, - Tox_Err_Group_Mod_Set_Role *error) +bool tox_group_set_role(Tox *tox, uint32_t group_number, uint32_t peer_id, Tox_Group_Role role, + Tox_Err_Group_Set_Role *error) { assert(tox != nullptr); @@ -4598,37 +4631,37 @@ bool tox_group_mod_set_role(Tox *tox, uint32_t group_number, uint32_t peer_id, T switch (ret) { case 0: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_SET_ROLE_OK); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_ROLE_OK); return true; } case -1: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_SET_ROLE_GROUP_NOT_FOUND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_ROLE_GROUP_NOT_FOUND); return false; } case -2: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_SET_ROLE_PEER_NOT_FOUND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_ROLE_PEER_NOT_FOUND); return false; } case -3: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_SET_ROLE_PERMISSIONS); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_ROLE_PERMISSIONS); return false; } case -4: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_SET_ROLE_ASSIGNMENT); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_ROLE_ASSIGNMENT); return false; } case -5: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_SET_ROLE_FAIL_ACTION); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_ROLE_FAIL_ACTION); return false; } case -6: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_SET_ROLE_SELF); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_ROLE_SELF); return false; } } @@ -4639,8 +4672,8 @@ bool tox_group_mod_set_role(Tox *tox, uint32_t group_number, uint32_t peer_id, T return false; } -bool tox_group_mod_kick_peer(const Tox *tox, uint32_t group_number, uint32_t peer_id, - Tox_Err_Group_Mod_Kick_Peer *error) +bool tox_group_kick_peer(const Tox *tox, uint32_t group_number, uint32_t peer_id, + Tox_Err_Group_Kick_Peer *error) { assert(tox != nullptr); @@ -4650,37 +4683,37 @@ bool tox_group_mod_kick_peer(const Tox *tox, uint32_t group_number, uint32_t pee switch (ret) { case 0: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_KICK_PEER_OK); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_KICK_PEER_OK); return true; } case -1: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_KICK_PEER_GROUP_NOT_FOUND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_KICK_PEER_GROUP_NOT_FOUND); return false; } case -2: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_KICK_PEER_PEER_NOT_FOUND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_KICK_PEER_PEER_NOT_FOUND); return false; } case -3: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_KICK_PEER_PERMISSIONS); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_KICK_PEER_PERMISSIONS); return false; } case -4: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_KICK_PEER_FAIL_ACTION); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_KICK_PEER_FAIL_ACTION); return false; } case -5: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_KICK_PEER_FAIL_SEND); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_KICK_PEER_FAIL_SEND); return false; } case -6: { - SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_KICK_PEER_SELF); + SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_KICK_PEER_SELF); return false; } } |