Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Remove Tox * from tox_dispatch. #2645

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion auto_tests/auto_test_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void iterate_all_wait(AutoTox *autotoxes, uint32_t tox_count, uint32_t wait)
Tox_Err_Events_Iterate err;
Tox_Events *events = tox_events_iterate(autotoxes[i].tox, true, &err);
ck_assert(err == TOX_ERR_EVENTS_ITERATE_OK);
tox_dispatch_invoke(autotoxes[i].dispatch, events, autotoxes[i].tox, &autotoxes[i]);
tox_dispatch_invoke(autotoxes[i].dispatch, events, &autotoxes[i]);
tox_events_free(events);
} else {
tox_iterate(autotoxes[i].tox, &autotoxes[i]);
Expand Down
10 changes: 5 additions & 5 deletions auto_tests/conference_av_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ typedef struct State {
} State;

static void handle_self_connection_status(
Tox *tox, const Tox_Event_Self_Connection_Status *event, void *user_data)
const Tox_Event_Self_Connection_Status *event, void *user_data)
{
const AutoTox *autotox = (AutoTox *)user_data;

Expand All @@ -36,7 +36,7 @@ static void handle_self_connection_status(
}

static void handle_friend_connection_status(
Tox *tox, const Tox_Event_Friend_Connection_Status *event, void *user_data)
const Tox_Event_Friend_Connection_Status *event, void *user_data)
{
const AutoTox *autotox = (AutoTox *)user_data;

Expand Down Expand Up @@ -74,7 +74,7 @@ static void audio_callback(void *tox, uint32_t groupnumber, uint32_t peernumber,
}

static void handle_conference_invite(
Tox *tox, const Tox_Event_Conference_Invite *event, void *user_data)
const Tox_Event_Conference_Invite *event, void *user_data)
{
const AutoTox *autotox = (AutoTox *)user_data;

Expand All @@ -90,7 +90,7 @@ static void handle_conference_invite(
}

static void handle_conference_connected(
Tox *tox, const Tox_Event_Conference_Connected *event, void *user_data)
const Tox_Event_Conference_Connected *event, void *user_data)
{
const AutoTox *autotox = (AutoTox *)user_data;
State *state = (State *)autotox->state;
Expand Down Expand Up @@ -149,7 +149,7 @@ static void disconnect_toxes(uint32_t tox_count, AutoTox *autotoxes,
if (!disconnect_now[i]) {
Tox_Err_Events_Iterate err;
Tox_Events *events = tox_events_iterate(autotoxes[i].tox, true, &err);
tox_dispatch_invoke(autotoxes[i].dispatch, events, autotoxes[i].tox, &autotoxes[i]);
tox_dispatch_invoke(autotoxes[i].dispatch, events, &autotoxes[i]);
tox_events_free(events);
autotoxes[i].clock += 1000;
}
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/conference_double_invite_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ typedef struct State {
#include "auto_test_support.h"

static void handle_conference_invite(
Tox *tox, const Tox_Event_Conference_Invite *event, void *user_data)
const Tox_Event_Conference_Invite *event, void *user_data)
{
const AutoTox *autotox = (AutoTox *)user_data;
State *state = (State *)autotox->state;
Expand Down
4 changes: 2 additions & 2 deletions auto_tests/conference_invite_merge_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ typedef struct State {
#include "auto_test_support.h"

static void handle_conference_invite(
Tox *tox, const Tox_Event_Conference_Invite *event, void *user_data)
const Tox_Event_Conference_Invite *event, void *user_data)
{
const AutoTox *autotox = (AutoTox *)user_data;
State *state = (State *)autotox->state;
Expand All @@ -31,7 +31,7 @@ static void handle_conference_invite(
}

static void handle_conference_connected(
Tox *tox, const Tox_Event_Conference_Connected *event, void *user_data)
const Tox_Event_Conference_Connected *event, void *user_data)
{
const AutoTox *autotox = (AutoTox *)user_data;
State *state = (State *)autotox->state;
Expand Down
4 changes: 2 additions & 2 deletions auto_tests/conference_peer_nick_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ typedef struct State {
#include "auto_test_support.h"

static void handle_conference_invite(
Tox *tox, const Tox_Event_Conference_Invite *event, void *user_data)
const Tox_Event_Conference_Invite *event, void *user_data)
{
const AutoTox *autotox = (AutoTox *)user_data;
State *state = (State *)autotox->state;
Expand All @@ -35,7 +35,7 @@ static void handle_conference_invite(
state->joined = true;
}

static void handle_peer_list_changed(Tox *tox, const Tox_Event_Conference_Peer_List_Changed *event, void *user_data)
static void handle_peer_list_changed(const Tox_Event_Conference_Peer_List_Changed *event, void *user_data)
{
const AutoTox *autotox = (AutoTox *)user_data;
State *state = (State *)autotox->state;
Expand Down
14 changes: 7 additions & 7 deletions auto_tests/conference_simple_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ typedef struct State {
uint32_t peers;
} State;

static void handle_self_connection_status(Tox *tox, const Tox_Event_Self_Connection_Status *event, void *user_data)
static void handle_self_connection_status(const Tox_Event_Self_Connection_Status *event, void *user_data)
{
State *state = (State *)user_data;

Expand All @@ -32,7 +32,7 @@ static void handle_self_connection_status(Tox *tox, const Tox_Event_Self_Connect
state->self_online = connection_status != TOX_CONNECTION_NONE;
}

static void handle_friend_connection_status(Tox *tox, const Tox_Event_Friend_Connection_Status *event,
static void handle_friend_connection_status(const Tox_Event_Friend_Connection_Status *event,
void *user_data)
{
State *state = (State *)user_data;
Expand All @@ -43,7 +43,7 @@ static void handle_friend_connection_status(Tox *tox, const Tox_Event_Friend_Con
state->friend_online = connection_status != TOX_CONNECTION_NONE;
}

static void handle_conference_invite(Tox *tox, const Tox_Event_Conference_Invite *event, void *user_data)
static void handle_conference_invite(const Tox_Event_Conference_Invite *event, void *user_data)
{
State *state = (State *)user_data;

Expand All @@ -64,7 +64,7 @@ static void handle_conference_invite(Tox *tox, const Tox_Event_Conference_Invite
}
}

static void handle_conference_message(Tox *tox, const Tox_Event_Conference_Message *event, void *user_data)
static void handle_conference_message(const Tox_Event_Conference_Message *event, void *user_data)
{
State *state = (State *)user_data;

Expand All @@ -81,7 +81,7 @@ static void handle_conference_message(Tox *tox, const Tox_Event_Conference_Messa
state->received = true;
}

static void handle_conference_peer_list_changed(Tox *tox, const Tox_Event_Conference_Peer_List_Changed *event, void *user_data)
static void handle_conference_peer_list_changed(const Tox_Event_Conference_Peer_List_Changed *event, void *user_data)
{
State *state = (State *)user_data;

Expand All @@ -101,7 +101,7 @@ static void handle_conference_peer_list_changed(Tox *tox, const Tox_Event_Confer
state->peers = count;
}

static void handle_conference_connected(Tox *tox, const Tox_Event_Conference_Connected *event, void *user_data)
static void handle_conference_connected(const Tox_Event_Conference_Connected *event, void *user_data)
{
State *state = (State *)user_data;

Expand All @@ -122,7 +122,7 @@ static void iterate_one(
Tox_Err_Events_Iterate err;
Tox_Events *events = tox_events_iterate(tox, true, &err);
ck_assert(err == TOX_ERR_EVENTS_ITERATE_OK);
tox_dispatch_invoke(dispatch, events, tox, state);
tox_dispatch_invoke(dispatch, events, state);
tox_events_free(events);
}

Expand Down
2 changes: 1 addition & 1 deletion auto_tests/dht_getnodes_api_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static bool all_nodes_crawled(const AutoTox *autotoxes, uint32_t num_toxes, uint
return true;
}

static void getnodes_response_cb(Tox *tox, const Tox_Event_Dht_Get_Nodes_Response *event, void *user_data)
static void getnodes_response_cb(const Tox_Event_Dht_Get_Nodes_Response *event, void *user_data)
{
ck_assert(user_data != nullptr);

Expand Down
12 changes: 6 additions & 6 deletions auto_tests/file_transfer_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#define TOX_LOCALHOST "127.0.0.1"
#endif

static void accept_friend_request(Tox *m, const Tox_Event_Friend_Request *event, void *userdata)
static void accept_friend_request(const Tox_Event_Friend_Request *event, void *userdata)
{
Tox *tox = (Tox *)userdata;

Expand All @@ -45,7 +45,7 @@ static uint64_t sending_pos;
static uint8_t file_cmp_id[TOX_FILE_ID_LENGTH];
static uint32_t file_accepted;
static uint64_t file_size;
static void tox_file_receive(Tox *tox, const Tox_Event_File_Recv *event, void *userdata)
static void tox_file_receive(const Tox_Event_File_Recv *event, void *userdata)
{
Tox *state_tox = (Tox *)userdata;

Expand Down Expand Up @@ -100,7 +100,7 @@ static void tox_file_receive(Tox *tox, const Tox_Event_File_Recv *event, void *u
}

static uint32_t sendf_ok;
static void file_print_control(Tox *tox, const Tox_Event_File_Recv_Control *event,
static void file_print_control(const Tox_Event_File_Recv_Control *event,
void *userdata)
{
const uint32_t file_number = tox_event_file_recv_control_get_file_number(event);
Expand All @@ -116,7 +116,7 @@ static uint64_t max_sending;
static bool m_send_reached;
static uint8_t sending_num;
static bool file_sending_done;
static void tox_file_chunk_request(Tox *tox, const Tox_Event_File_Chunk_Request *event, void *user_data)
static void tox_file_chunk_request(const Tox_Event_File_Chunk_Request *event, void *user_data)
{
Tox *state_tox = (Tox *)user_data;

Expand Down Expand Up @@ -158,7 +158,7 @@ static void tox_file_chunk_request(Tox *tox, const Tox_Event_File_Chunk_Request

static uint8_t num;
static bool file_recv;
static void write_file(Tox *tox, const Tox_Event_File_Recv_Chunk *event, void *user_data)
static void write_file(const Tox_Event_File_Recv_Chunk *event, void *user_data)
{
const uint64_t position = tox_event_file_recv_chunk_get_position(event);
const uint8_t *data = tox_event_file_recv_chunk_get_data(event);
Expand Down Expand Up @@ -187,7 +187,7 @@ static void iterate_and_dispatch(const Tox_Dispatch *dispatch, Tox *tox)

events = tox_events_iterate(tox, true, &err);
ck_assert(err == TOX_ERR_EVENTS_ITERATE_OK);
tox_dispatch_invoke(dispatch, events, tox, tox);
tox_dispatch_invoke(dispatch, events, tox);
tox_events_free(events);
}

Expand Down
2 changes: 1 addition & 1 deletion auto_tests/friend_request_spam_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ typedef struct State {
bool unused;
} State;

static void accept_friend_request(Tox *tox, const Tox_Event_Friend_Request *event,
static void accept_friend_request(const Tox_Event_Friend_Request *event,
void *userdata)
{
AutoTox *autotox = (AutoTox *)userdata;
Expand Down
6 changes: 3 additions & 3 deletions auto_tests/friend_request_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#define FR_MESSAGE "Gentoo"

static void accept_friend_request(Tox *tox, const Tox_Event_Friend_Request *event,
static void accept_friend_request(const Tox_Event_Friend_Request *event,
void *userdata)
{
Tox *state_tox = (Tox *)userdata;
Expand All @@ -36,12 +36,12 @@ static void iterate2_wait(const Tox_Dispatch *dispatch, Tox *tox1, Tox *tox2)

events = tox_events_iterate(tox1, true, &err);
ck_assert(err == TOX_ERR_EVENTS_ITERATE_OK);
tox_dispatch_invoke(dispatch, events, tox1, tox1);
tox_dispatch_invoke(dispatch, events, tox1);
tox_events_free(events);

events = tox_events_iterate(tox2, true, &err);
ck_assert(err == TOX_ERR_EVENTS_ITERATE_OK);
tox_dispatch_invoke(dispatch, events, tox2, tox2);
tox_dispatch_invoke(dispatch, events, tox2);
tox_events_free(events);

c_sleep(ITERATION_INTERVAL);
Expand Down
10 changes: 5 additions & 5 deletions auto_tests/group_general_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static bool all_group_peers_connected(AutoTox *autotoxes, uint32_t tox_count, ui
return true;
}

static void group_peer_join_handler(Tox *tox, const Tox_Event_Group_Peer_Join *event, void *user_data)
static void group_peer_join_handler(const Tox_Event_Group_Peer_Join *event, void *user_data)
{
AutoTox *autotox = (AutoTox *)user_data;
ck_assert(autotox != nullptr);
Expand Down Expand Up @@ -146,7 +146,7 @@ static void group_peer_join_handler(Tox *tox, const Tox_Event_Group_Peer_Join *e
++state->peer_joined_count;
}

static void group_peer_self_join_handler(Tox *tox, const Tox_Event_Group_Self_Join *event, void *user_data)
static void group_peer_self_join_handler(const Tox_Event_Group_Self_Join *event, void *user_data)
{
AutoTox *autotox = (AutoTox *)user_data;
ck_assert(autotox != nullptr);
Expand Down Expand Up @@ -211,7 +211,7 @@ static void group_peer_self_join_handler(Tox *tox, const Tox_Event_Group_Self_Jo
++state->self_joined_count;
}

static void group_peer_exit_handler(Tox *tox, const Tox_Event_Group_Peer_Exit *event, void *user_data)
static void group_peer_exit_handler(const Tox_Event_Group_Peer_Exit *event, void *user_data)
{
AutoTox *autotox = (AutoTox *)user_data;
ck_assert(autotox != nullptr);
Expand All @@ -230,7 +230,7 @@ static void group_peer_exit_handler(Tox *tox, const Tox_Event_Group_Peer_Exit *e
}
}

static void group_peer_name_handler(Tox *tox, const Tox_Event_Group_Peer_Name *event, void *user_data)
static void group_peer_name_handler(const Tox_Event_Group_Peer_Name *event, void *user_data)
{
AutoTox *autotox = (AutoTox *)user_data;
ck_assert(autotox != nullptr);
Expand All @@ -248,7 +248,7 @@ static void group_peer_name_handler(Tox *tox, const Tox_Event_Group_Peer_Name *e
state->peer_nick = true;
}

static void group_peer_status_handler(Tox *tox, const Tox_Event_Group_Peer_Status *event,
static void group_peer_status_handler(const Tox_Event_Group_Peer_Status *event,
void *user_data)
{
AutoTox *autotox = (AutoTox *)user_data;
Expand Down
6 changes: 3 additions & 3 deletions auto_tests/group_invite_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static bool group_has_full_graph(const AutoTox *autotoxes, uint32_t group_number
return true;
}

static void group_join_fail_handler(Tox *tox, const Tox_Event_Group_Join_Fail *event, void *user_data)
static void group_join_fail_handler(const Tox_Event_Group_Join_Fail *event, void *user_data)
{
AutoTox *autotox = (AutoTox *)user_data;
ck_assert(autotox != nullptr);
Expand Down Expand Up @@ -81,7 +81,7 @@ static void group_join_fail_handler(Tox *tox, const Tox_Event_Group_Join_Fail *e
}
}

static void group_self_join_handler(Tox *tox, const Tox_Event_Group_Self_Join *event, void *user_data)
static void group_self_join_handler(const Tox_Event_Group_Self_Join *event, void *user_data)
{
AutoTox *autotox = (AutoTox *)user_data;
ck_assert(autotox != nullptr);
Expand All @@ -91,7 +91,7 @@ static void group_self_join_handler(Tox *tox, const Tox_Event_Group_Self_Join *e
state->connected = true;
}

static void group_peer_join_handler(Tox *tox, const Tox_Event_Group_Peer_Join *event, void *user_data)
static void group_peer_join_handler(const Tox_Event_Group_Peer_Join *event, void *user_data)
{
AutoTox *autotox = (AutoTox *)user_data;
ck_assert(autotox != nullptr);
Expand Down
Loading
Loading