Skip to content

Commit 5bdaaae

Browse files
committed
refactor: Remove Tox * from tox_dispatch.
User data can contain a tox instance if it needs to.
1 parent e202341 commit 5bdaaae

39 files changed

+331
-342
lines changed

auto_tests/auto_test_support.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ void iterate_all_wait(AutoTox *autotoxes, uint32_t tox_count, uint32_t wait)
138138
Tox_Err_Events_Iterate err;
139139
Tox_Events *events = tox_events_iterate(autotoxes[i].tox, true, &err);
140140
ck_assert(err == TOX_ERR_EVENTS_ITERATE_OK);
141-
tox_dispatch_invoke(autotoxes[i].dispatch, events, autotoxes[i].tox, &autotoxes[i]);
141+
tox_dispatch_invoke(autotoxes[i].dispatch, events, &autotoxes[i]);
142142
tox_events_free(events);
143143
} else {
144144
tox_iterate(autotoxes[i].tox, &autotoxes[i]);

auto_tests/conference_av_test.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ typedef struct State {
2323
} State;
2424

2525
static void handle_self_connection_status(
26-
Tox *tox, const Tox_Event_Self_Connection_Status *event, void *user_data)
26+
const Tox_Event_Self_Connection_Status *event, void *user_data)
2727
{
2828
const AutoTox *autotox = (AutoTox *)user_data;
2929

@@ -36,7 +36,7 @@ static void handle_self_connection_status(
3636
}
3737

3838
static void handle_friend_connection_status(
39-
Tox *tox, const Tox_Event_Friend_Connection_Status *event, void *user_data)
39+
const Tox_Event_Friend_Connection_Status *event, void *user_data)
4040
{
4141
const AutoTox *autotox = (AutoTox *)user_data;
4242

@@ -74,7 +74,7 @@ static void audio_callback(void *tox, uint32_t groupnumber, uint32_t peernumber,
7474
}
7575

7676
static void handle_conference_invite(
77-
Tox *tox, const Tox_Event_Conference_Invite *event, void *user_data)
77+
const Tox_Event_Conference_Invite *event, void *user_data)
7878
{
7979
const AutoTox *autotox = (AutoTox *)user_data;
8080

@@ -90,7 +90,7 @@ static void handle_conference_invite(
9090
}
9191

9292
static void handle_conference_connected(
93-
Tox *tox, const Tox_Event_Conference_Connected *event, void *user_data)
93+
const Tox_Event_Conference_Connected *event, void *user_data)
9494
{
9595
const AutoTox *autotox = (AutoTox *)user_data;
9696
State *state = (State *)autotox->state;
@@ -149,7 +149,7 @@ static void disconnect_toxes(uint32_t tox_count, AutoTox *autotoxes,
149149
if (!disconnect_now[i]) {
150150
Tox_Err_Events_Iterate err;
151151
Tox_Events *events = tox_events_iterate(autotoxes[i].tox, true, &err);
152-
tox_dispatch_invoke(autotoxes[i].dispatch, events, autotoxes[i].tox, &autotoxes[i]);
152+
tox_dispatch_invoke(autotoxes[i].dispatch, events, &autotoxes[i]);
153153
tox_events_free(events);
154154
autotoxes[i].clock += 1000;
155155
}

auto_tests/conference_double_invite_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ typedef struct State {
1212
#include "auto_test_support.h"
1313

1414
static void handle_conference_invite(
15-
Tox *tox, const Tox_Event_Conference_Invite *event, void *user_data)
15+
const Tox_Event_Conference_Invite *event, void *user_data)
1616
{
1717
const AutoTox *autotox = (AutoTox *)user_data;
1818
State *state = (State *)autotox->state;

auto_tests/conference_invite_merge_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ typedef struct State {
1212
#include "auto_test_support.h"
1313

1414
static void handle_conference_invite(
15-
Tox *tox, const Tox_Event_Conference_Invite *event, void *user_data)
15+
const Tox_Event_Conference_Invite *event, void *user_data)
1616
{
1717
const AutoTox *autotox = (AutoTox *)user_data;
1818
State *state = (State *)autotox->state;
@@ -31,7 +31,7 @@ static void handle_conference_invite(
3131
}
3232

3333
static void handle_conference_connected(
34-
Tox *tox, const Tox_Event_Conference_Connected *event, void *user_data)
34+
const Tox_Event_Conference_Connected *event, void *user_data)
3535
{
3636
const AutoTox *autotox = (AutoTox *)user_data;
3737
State *state = (State *)autotox->state;

auto_tests/conference_peer_nick_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ typedef struct State {
1313
#include "auto_test_support.h"
1414

1515
static void handle_conference_invite(
16-
Tox *tox, const Tox_Event_Conference_Invite *event, void *user_data)
16+
const Tox_Event_Conference_Invite *event, void *user_data)
1717
{
1818
const AutoTox *autotox = (AutoTox *)user_data;
1919
State *state = (State *)autotox->state;
@@ -35,7 +35,7 @@ static void handle_conference_invite(
3535
state->joined = true;
3636
}
3737

38-
static void handle_peer_list_changed(Tox *tox, const Tox_Event_Conference_Peer_List_Changed *event, void *user_data)
38+
static void handle_peer_list_changed(const Tox_Event_Conference_Peer_List_Changed *event, void *user_data)
3939
{
4040
const AutoTox *autotox = (AutoTox *)user_data;
4141
State *state = (State *)autotox->state;

auto_tests/conference_simple_test.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ typedef struct State {
2323
uint32_t peers;
2424
} State;
2525

26-
static void handle_self_connection_status(Tox *tox, const Tox_Event_Self_Connection_Status *event, void *user_data)
26+
static void handle_self_connection_status(const Tox_Event_Self_Connection_Status *event, void *user_data)
2727
{
2828
State *state = (State *)user_data;
2929

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

35-
static void handle_friend_connection_status(Tox *tox, const Tox_Event_Friend_Connection_Status *event,
35+
static void handle_friend_connection_status(const Tox_Event_Friend_Connection_Status *event,
3636
void *user_data)
3737
{
3838
State *state = (State *)user_data;
@@ -43,7 +43,7 @@ static void handle_friend_connection_status(Tox *tox, const Tox_Event_Friend_Con
4343
state->friend_online = connection_status != TOX_CONNECTION_NONE;
4444
}
4545

46-
static void handle_conference_invite(Tox *tox, const Tox_Event_Conference_Invite *event, void *user_data)
46+
static void handle_conference_invite(const Tox_Event_Conference_Invite *event, void *user_data)
4747
{
4848
State *state = (State *)user_data;
4949

@@ -64,7 +64,7 @@ static void handle_conference_invite(Tox *tox, const Tox_Event_Conference_Invite
6464
}
6565
}
6666

67-
static void handle_conference_message(Tox *tox, const Tox_Event_Conference_Message *event, void *user_data)
67+
static void handle_conference_message(const Tox_Event_Conference_Message *event, void *user_data)
6868
{
6969
State *state = (State *)user_data;
7070

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

84-
static void handle_conference_peer_list_changed(Tox *tox, const Tox_Event_Conference_Peer_List_Changed *event, void *user_data)
84+
static void handle_conference_peer_list_changed(const Tox_Event_Conference_Peer_List_Changed *event, void *user_data)
8585
{
8686
State *state = (State *)user_data;
8787

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

104-
static void handle_conference_connected(Tox *tox, const Tox_Event_Conference_Connected *event, void *user_data)
104+
static void handle_conference_connected(const Tox_Event_Conference_Connected *event, void *user_data)
105105
{
106106
State *state = (State *)user_data;
107107

@@ -122,7 +122,7 @@ static void iterate_one(
122122
Tox_Err_Events_Iterate err;
123123
Tox_Events *events = tox_events_iterate(tox, true, &err);
124124
ck_assert(err == TOX_ERR_EVENTS_ITERATE_OK);
125-
tox_dispatch_invoke(dispatch, events, tox, state);
125+
tox_dispatch_invoke(dispatch, events, state);
126126
tox_events_free(events);
127127
}
128128

auto_tests/dht_getnodes_api_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static bool all_nodes_crawled(const AutoTox *autotoxes, uint32_t num_toxes, uint
7272
return true;
7373
}
7474

75-
static void getnodes_response_cb(Tox *tox, const Tox_Event_Dht_Get_Nodes_Response *event, void *user_data)
75+
static void getnodes_response_cb(const Tox_Event_Dht_Get_Nodes_Response *event, void *user_data)
7676
{
7777
ck_assert(user_data != nullptr);
7878

auto_tests/file_transfer_test.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#define TOX_LOCALHOST "127.0.0.1"
2727
#endif
2828

29-
static void accept_friend_request(Tox *m, const Tox_Event_Friend_Request *event, void *userdata)
29+
static void accept_friend_request(const Tox_Event_Friend_Request *event, void *userdata)
3030
{
3131
Tox *tox = (Tox *)userdata;
3232

@@ -45,7 +45,7 @@ static uint64_t sending_pos;
4545
static uint8_t file_cmp_id[TOX_FILE_ID_LENGTH];
4646
static uint32_t file_accepted;
4747
static uint64_t file_size;
48-
static void tox_file_receive(Tox *tox, const Tox_Event_File_Recv *event, void *userdata)
48+
static void tox_file_receive(const Tox_Event_File_Recv *event, void *userdata)
4949
{
5050
Tox *state_tox = (Tox *)userdata;
5151

@@ -100,7 +100,7 @@ static void tox_file_receive(Tox *tox, const Tox_Event_File_Recv *event, void *u
100100
}
101101

102102
static uint32_t sendf_ok;
103-
static void file_print_control(Tox *tox, const Tox_Event_File_Recv_Control *event,
103+
static void file_print_control(const Tox_Event_File_Recv_Control *event,
104104
void *userdata)
105105
{
106106
const uint32_t file_number = tox_event_file_recv_control_get_file_number(event);
@@ -116,7 +116,7 @@ static uint64_t max_sending;
116116
static bool m_send_reached;
117117
static uint8_t sending_num;
118118
static bool file_sending_done;
119-
static void tox_file_chunk_request(Tox *tox, const Tox_Event_File_Chunk_Request *event, void *user_data)
119+
static void tox_file_chunk_request(const Tox_Event_File_Chunk_Request *event, void *user_data)
120120
{
121121
Tox *state_tox = (Tox *)user_data;
122122

@@ -158,7 +158,7 @@ static void tox_file_chunk_request(Tox *tox, const Tox_Event_File_Chunk_Request
158158

159159
static uint8_t num;
160160
static bool file_recv;
161-
static void write_file(Tox *tox, const Tox_Event_File_Recv_Chunk *event, void *user_data)
161+
static void write_file(const Tox_Event_File_Recv_Chunk *event, void *user_data)
162162
{
163163
const uint64_t position = tox_event_file_recv_chunk_get_position(event);
164164
const uint8_t *data = tox_event_file_recv_chunk_get_data(event);
@@ -187,7 +187,7 @@ static void iterate_and_dispatch(const Tox_Dispatch *dispatch, Tox *tox)
187187

188188
events = tox_events_iterate(tox, true, &err);
189189
ck_assert(err == TOX_ERR_EVENTS_ITERATE_OK);
190-
tox_dispatch_invoke(dispatch, events, tox, tox);
190+
tox_dispatch_invoke(dispatch, events, tox);
191191
tox_events_free(events);
192192
}
193193

auto_tests/friend_request_spam_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ typedef struct State {
2222
bool unused;
2323
} State;
2424

25-
static void accept_friend_request(Tox *tox, const Tox_Event_Friend_Request *event,
25+
static void accept_friend_request(const Tox_Event_Friend_Request *event,
2626
void *userdata)
2727
{
2828
AutoTox *autotox = (AutoTox *)userdata;

auto_tests/friend_request_test.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#define FR_MESSAGE "Gentoo"
1717

18-
static void accept_friend_request(Tox *tox, const Tox_Event_Friend_Request *event,
18+
static void accept_friend_request(const Tox_Event_Friend_Request *event,
1919
void *userdata)
2020
{
2121
Tox *state_tox = (Tox *)userdata;
@@ -36,12 +36,12 @@ static void iterate2_wait(const Tox_Dispatch *dispatch, Tox *tox1, Tox *tox2)
3636

3737
events = tox_events_iterate(tox1, true, &err);
3838
ck_assert(err == TOX_ERR_EVENTS_ITERATE_OK);
39-
tox_dispatch_invoke(dispatch, events, tox1, tox1);
39+
tox_dispatch_invoke(dispatch, events, tox1);
4040
tox_events_free(events);
4141

4242
events = tox_events_iterate(tox2, true, &err);
4343
ck_assert(err == TOX_ERR_EVENTS_ITERATE_OK);
44-
tox_dispatch_invoke(dispatch, events, tox2, tox2);
44+
tox_dispatch_invoke(dispatch, events, tox2);
4545
tox_events_free(events);
4646

4747
c_sleep(ITERATION_INTERVAL);

0 commit comments

Comments
 (0)