diff --git a/toxav/toxav_old.c b/toxav/toxav_old.c index d5278623..24b4f1ec 100644 --- a/toxav/toxav_old.c +++ b/toxav/toxav_old.c @@ -39,7 +39,7 @@ int toxav_add_av_groupchat(Tox *tox, void (*audio_callback)(void *, uint32_t, ui uint8_t, uint32_t, void *), void *userdata) { Messenger *m = (Messenger *)tox; - return add_av_groupchat(m->log, (Group_Chats *)m->conferences_object, + return add_av_groupchat(m->log, m->conferences_object, (void (*)(Messenger *, uint32_t, uint32_t, const int16_t *, unsigned int, uint8_t, uint32_t, void *))audio_callback, userdata); } @@ -60,7 +60,7 @@ int toxav_join_av_groupchat(Tox *tox, uint32_t friendnumber, const uint8_t *data void *userdata) { Messenger *m = (Messenger *)tox; - return join_av_groupchat(m->log, (Group_Chats *)m->conferences_object, friendnumber, data, length, + return join_av_groupchat(m->log, m->conferences_object, friendnumber, data, length, (void (*)(Messenger *, uint32_t, uint32_t, const int16_t *, unsigned int, uint8_t, uint32_t, void *))audio_callback, userdata); } @@ -82,5 +82,5 @@ int toxav_group_send_audio(Tox *tox, uint32_t groupnumber, const int16_t *pcm, u uint32_t sample_rate) { Messenger *m = (Messenger *)tox; - return group_send_audio((Group_Chats *)m->conferences_object, groupnumber, pcm, samples, channels, sample_rate); + return group_send_audio(m->conferences_object, groupnumber, pcm, samples, channels, sample_rate); } diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h index 8cab9801..6fc4df02 100644 --- a/toxcore/Messenger.h +++ b/toxcore/Messenger.h @@ -272,7 +272,7 @@ struct Messenger { m_friend_connectionstatuschange_internal_cb *friend_connectionstatuschange_internal; void *friend_connectionstatuschange_internal_userdata; - void *conferences_object; /* Set by new_groupchats()*/ + struct Group_Chats *conferences_object; /* Set by new_groupchats()*/ m_conference_invite_cb *conference_invite; m_file_recv_cb *file_sendrequest; diff --git a/toxcore/group.c b/toxcore/group.c index 75b8697b..1ef3d374 100644 --- a/toxcore/group.c +++ b/toxcore/group.c @@ -1423,7 +1423,7 @@ int group_title_get(const Group_Chats *g_c, uint32_t groupnumber, uint8_t *title static void handle_friend_invite_packet(Messenger *m, uint32_t friendnumber, const uint8_t *data, uint16_t length, void *userdata) { - Group_Chats *g_c = (Group_Chats *)m->conferences_object; + Group_Chats *g_c = m->conferences_object; if (length <= 1) { return; diff --git a/toxcore/tox.c b/toxcore/tox.c index 2ccbef82..b2ea1969 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -497,12 +497,12 @@ Tox *tox_new(const struct Tox_Options *options, Tox_Err_New *error) callback_file_reqchunk(m, tox_file_chunk_request_handler); callback_file_sendrequest(m, tox_file_recv_handler); callback_file_data(m, tox_file_recv_chunk_handler); - g_callback_group_invite((Group_Chats *)m->conferences_object, tox_conference_invite_handler); - g_callback_group_connected((Group_Chats *)m->conferences_object, tox_conference_connected_handler); - g_callback_group_message((Group_Chats *)m->conferences_object, tox_conference_message_handler); - g_callback_group_title((Group_Chats *)m->conferences_object, tox_conference_title_handler); - g_callback_peer_name((Group_Chats *)m->conferences_object, tox_conference_peer_name_handler); - g_callback_peer_list_changed((Group_Chats *)m->conferences_object, tox_conference_peer_list_changed_handler); + g_callback_group_invite(m->conferences_object, tox_conference_invite_handler); + g_callback_group_connected(m->conferences_object, tox_conference_connected_handler); + g_callback_group_message(m->conferences_object, tox_conference_message_handler); + g_callback_group_title(m->conferences_object, tox_conference_title_handler); + g_callback_peer_name(m->conferences_object, tox_conference_peer_name_handler); + g_callback_peer_list_changed(m->conferences_object, tox_conference_peer_list_changed_handler); custom_lossy_packet_registerhandler(m, tox_friend_lossy_packet_handler); custom_lossless_packet_registerhandler(m, tox_friend_lossless_packet_handler); @@ -517,7 +517,7 @@ void tox_kill(Tox *tox) } Messenger *m = tox->m; - kill_groupchats((Group_Chats *)m->conferences_object); + kill_groupchats(m->conferences_object); kill_messenger(m); free(tox); } @@ -656,7 +656,7 @@ void tox_iterate(Tox *tox, void *user_data) Messenger *m = tox->m; struct Tox_Userdata tox_data = { tox, user_data }; do_messenger(m, &tox_data); - do_groupchats((Group_Chats *)m->conferences_object, &tox_data); + do_groupchats(m->conferences_object, &tox_data); } void tox_self_get_address(const Tox *tox, uint8_t *address) @@ -708,7 +708,7 @@ bool tox_self_set_name(Tox *tox, const uint8_t *name, size_t length, Tox_Err_Set if (setname(m, name, length) == 0) { // TODO(irungentoo): function to set different per group names? - send_name_all_groups((Group_Chats *)m->conferences_object); + send_name_all_groups(m->conferences_object); SET_ERROR_PARAMETER(error, TOX_ERR_SET_INFO_OK); return 1; } @@ -1425,7 +1425,7 @@ void tox_callback_conference_peer_list_changed(Tox *tox, tox_conference_peer_lis uint32_t tox_conference_new(Tox *tox, Tox_Err_Conference_New *error) { Messenger *m = tox->m; - int ret = add_groupchat((Group_Chats *)m->conferences_object, GROUPCHAT_TYPE_TEXT); + int ret = add_groupchat(m->conferences_object, GROUPCHAT_TYPE_TEXT); if (ret == -1) { SET_ERROR_PARAMETER(error, TOX_ERR_CONFERENCE_NEW_INIT); @@ -1439,7 +1439,7 @@ uint32_t tox_conference_new(Tox *tox, Tox_Err_Conference_New *error) bool tox_conference_delete(Tox *tox, uint32_t conference_number, Tox_Err_Conference_Delete *error) { Messenger *m = tox->m; - int ret = del_groupchat((Group_Chats *)m->conferences_object, conference_number); + int ret = del_groupchat(m->conferences_object, conference_number); if (ret == -1) { SET_ERROR_PARAMETER(error, TOX_ERR_CONFERENCE_DELETE_CONFERENCE_NOT_FOUND); @@ -1453,7 +1453,7 @@ bool tox_conference_delete(Tox *tox, uint32_t conference_number, Tox_Err_Confere uint32_t tox_conference_peer_count(const Tox *tox, uint32_t conference_number, Tox_Err_Conference_Peer_Query *error) { const Messenger *m = tox->m; - int ret = group_number_peers((Group_Chats *)m->conferences_object, conference_number); + int ret = group_number_peers(m->conferences_object, conference_number); if (ret == -1) { SET_ERROR_PARAMETER(error, TOX_ERR_CONFERENCE_PEER_QUERY_CONFERENCE_NOT_FOUND); @@ -1468,7 +1468,7 @@ size_t tox_conference_peer_get_name_size(const Tox *tox, uint32_t conference_num Tox_Err_Conference_Peer_Query *error) { const Messenger *m = tox->m; - int ret = group_peername_size((Group_Chats *)m->conferences_object, conference_number, peer_number); + int ret = group_peername_size(m->conferences_object, conference_number, peer_number); switch (ret) { case -1: @@ -1488,7 +1488,7 @@ bool tox_conference_peer_get_name(const Tox *tox, uint32_t conference_number, ui Tox_Err_Conference_Peer_Query *error) { const Messenger *m = tox->m; - int ret = group_peername((Group_Chats *)m->conferences_object, conference_number, peer_number, name); + int ret = group_peername(m->conferences_object, conference_number, peer_number, name); switch (ret) { case -1: @@ -1508,7 +1508,7 @@ bool tox_conference_peer_get_public_key(const Tox *tox, uint32_t conference_numb uint8_t *public_key, Tox_Err_Conference_Peer_Query *error) { const Messenger *m = tox->m; - int ret = group_peer_pubkey((Group_Chats *)m->conferences_object, conference_number, peer_number, public_key); + int ret = group_peer_pubkey(m->conferences_object, conference_number, peer_number, public_key); switch (ret) { case -1: @@ -1528,7 +1528,7 @@ bool tox_conference_peer_number_is_ours(const Tox *tox, uint32_t conference_numb Tox_Err_Conference_Peer_Query *error) { const Messenger *m = tox->m; - int ret = group_peernumber_is_ours((Group_Chats *)m->conferences_object, conference_number, peer_number); + int ret = group_peernumber_is_ours(m->conferences_object, conference_number, peer_number); switch (ret) { case -1: @@ -1552,7 +1552,7 @@ bool tox_conference_invite(Tox *tox, uint32_t friend_number, uint32_t conference Tox_Err_Conference_Invite *error) { Messenger *m = tox->m; - int ret = invite_friend((Group_Chats *)m->conferences_object, friend_number, conference_number); + int ret = invite_friend(m->conferences_object, friend_number, conference_number); switch (ret) { case -1: @@ -1576,7 +1576,7 @@ uint32_t tox_conference_join(Tox *tox, uint32_t friend_number, const uint8_t *co Tox_Err_Conference_Join *error) { Messenger *m = tox->m; - int ret = join_groupchat((Group_Chats *)m->conferences_object, friend_number, GROUPCHAT_TYPE_TEXT, cookie, length); + int ret = join_groupchat(m->conferences_object, friend_number, GROUPCHAT_TYPE_TEXT, cookie, length); switch (ret) { case -1: @@ -1615,9 +1615,9 @@ bool tox_conference_send_message(Tox *tox, uint32_t conference_number, Tox_Messa int ret = 0; if (type == TOX_MESSAGE_TYPE_NORMAL) { - ret = group_message_send((Group_Chats *)m->conferences_object, conference_number, message, length); + ret = group_message_send(m->conferences_object, conference_number, message, length); } else { - ret = group_action_send((Group_Chats *)m->conferences_object, conference_number, message, length); + ret = group_action_send(m->conferences_object, conference_number, message, length); } switch (ret) { @@ -1645,7 +1645,7 @@ bool tox_conference_send_message(Tox *tox, uint32_t conference_number, Tox_Messa size_t tox_conference_get_title_size(const Tox *tox, uint32_t conference_number, Tox_Err_Conference_Title *error) { const Messenger *m = tox->m; - int ret = group_title_get_size((Group_Chats *)m->conferences_object, conference_number); + int ret = group_title_get_size(m->conferences_object, conference_number); switch (ret) { case -1: @@ -1665,7 +1665,7 @@ bool tox_conference_get_title(const Tox *tox, uint32_t conference_number, uint8_ Tox_Err_Conference_Title *error) { const Messenger *m = tox->m; - int ret = group_title_get((Group_Chats *)m->conferences_object, conference_number, title); + int ret = group_title_get(m->conferences_object, conference_number, title); switch (ret) { case -1: @@ -1685,7 +1685,7 @@ bool tox_conference_set_title(Tox *tox, uint32_t conference_number, const uint8_ Tox_Err_Conference_Title *error) { Messenger *m = tox->m; - int ret = group_title_send((Group_Chats *)m->conferences_object, conference_number, title, length); + int ret = group_title_send(m->conferences_object, conference_number, title, length); switch (ret) { case -1: @@ -1708,21 +1708,21 @@ bool tox_conference_set_title(Tox *tox, uint32_t conference_number, const uint8_ size_t tox_conference_get_chatlist_size(const Tox *tox) { const Messenger *m = tox->m; - return count_chatlist((Group_Chats *)m->conferences_object); + return count_chatlist(m->conferences_object); } void tox_conference_get_chatlist(const Tox *tox, uint32_t *chatlist) { const Messenger *m = tox->m; size_t list_size = tox_conference_get_chatlist_size(tox); - copy_chatlist((Group_Chats *)m->conferences_object, chatlist, list_size); + copy_chatlist(m->conferences_object, chatlist, list_size); } Tox_Conference_Type tox_conference_get_type(const Tox *tox, uint32_t conference_number, Tox_Err_Conference_Get_Type *error) { const Messenger *m = tox->m; - int ret = group_get_type((Group_Chats *)m->conferences_object, conference_number); + int ret = group_get_type(m->conferences_object, conference_number); if (ret == -1) { SET_ERROR_PARAMETER(error, TOX_ERR_CONFERENCE_GET_TYPE_CONFERENCE_NOT_FOUND); @@ -1735,7 +1735,7 @@ Tox_Conference_Type tox_conference_get_type(const Tox *tox, uint32_t conference_ bool tox_conference_get_id(const Tox *tox, uint32_t conference_number, uint8_t *id /* TOX_CONFERENCE_ID_SIZE bytes */) { - return conference_get_id((Group_Chats *)tox->m->conferences_object, conference_number, id); + return conference_get_id(tox->m->conferences_object, conference_number, id); } // TODO(iphydf): Delete in 0.3.0. @@ -1751,7 +1751,7 @@ uint32_t tox_conference_by_id(const Tox *tox, const uint8_t *id, Tox_Err_Confere return UINT32_MAX; } - int32_t ret = conference_by_id((Group_Chats *)tox->m->conferences_object, id); + int32_t ret = conference_by_id(tox->m->conferences_object, id); if (ret == -1) { SET_ERROR_PARAMETER(error, TOX_ERR_CONFERENCE_BY_ID_NOT_FOUND);