From 1334d16517ccaa0971301fc819b72618e060c899 Mon Sep 17 00:00:00 2001 From: iphydf Date: Mon, 26 Feb 2018 21:18:48 +0000 Subject: [PATCH] Fix auto_tests to stop using the deprecated conference API. --- auto_tests/selfname_change_conference_test.c | 8 ++--- auto_tests/simple_conference_test.c | 31 +++++++++----------- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/auto_tests/selfname_change_conference_test.c b/auto_tests/selfname_change_conference_test.c index c4e004de..dadfbeb6 100644 --- a/auto_tests/selfname_change_conference_test.c +++ b/auto_tests/selfname_change_conference_test.c @@ -38,15 +38,11 @@ static const char *newname = "chris"; static void cbconfmembers(Tox *tox, uint32_t conference_number, uint32_t peer_number, - TOX_CONFERENCE_STATE_CHANGE change, + const uint8_t *name, size_t length, void *user_data) { uint8_t new_peer_name[TOX_MAX_NAME_LENGTH + 1]; - if (change != TOX_CONFERENCE_STATE_CHANGE_PEER_NAME_CHANGE) { - return; - } - if (!tox_conference_peer_get_name(tox, conference_number, peer_number, new_peer_name, nullptr)) { return; } @@ -69,7 +65,7 @@ int main(void) t = tox_new_log(to, nullptr, nullptr); tox_options_free(to); - tox_callback_conference_namelist_change(t, cbconfmembers); + tox_callback_conference_peer_name(t, cbconfmembers); if (tox_conference_new(t, &conference_err) == UINT32_MAX) { tox_kill(t); diff --git a/auto_tests/simple_conference_test.c b/auto_tests/simple_conference_test.c index 7e07c45a..e6254b79 100644 --- a/auto_tests/simple_conference_test.c +++ b/auto_tests/simple_conference_test.c @@ -81,26 +81,23 @@ static void handle_conference_message(Tox *tox, uint32_t conference_number, uint state->received = true; } -static void handle_conference_namelist_change(Tox *tox, uint32_t conference_number, uint32_t peer_number, - TOX_CONFERENCE_STATE_CHANGE change, void *user_data) +static void handle_conference_peer_list_changed(Tox *tox, uint32_t conference_number, void *user_data) { State *state = (State *)user_data; - fprintf(stderr, "\nhandle_conference_namelist_change(#%d, %d, %d, %d, _)\n", - state->id, conference_number, peer_number, change); + fprintf(stderr, "\nhandle_conference_peer_list_changed(#%d, %d, _)\n", + state->id, conference_number); - if (change != TOX_CONFERENCE_STATE_CHANGE_PEER_NAME_CHANGE) { - TOX_ERR_CONFERENCE_PEER_QUERY err; - uint32_t count = tox_conference_peer_count(tox, conference_number, &err); + TOX_ERR_CONFERENCE_PEER_QUERY err; + uint32_t count = tox_conference_peer_count(tox, conference_number, &err); - if (err != TOX_ERR_CONFERENCE_PEER_QUERY_OK) { - fprintf(stderr, "ERROR: %d\n", err); - exit(EXIT_FAILURE); - } - - fprintf(stderr, "tox%d has %d peers online\n", state->id, count); - state->peers = count; + if (err != TOX_ERR_CONFERENCE_PEER_QUERY_OK) { + fprintf(stderr, "ERROR: %d\n", err); + exit(EXIT_FAILURE); } + + fprintf(stderr, "tox%d has %d peers online\n", state->id, count); + state->peers = count; } int main(void) @@ -153,9 +150,9 @@ int main(void) tox_callback_conference_message(tox2, handle_conference_message); tox_callback_conference_message(tox3, handle_conference_message); - tox_callback_conference_namelist_change(tox1, handle_conference_namelist_change); - tox_callback_conference_namelist_change(tox2, handle_conference_namelist_change); - tox_callback_conference_namelist_change(tox3, handle_conference_namelist_change); + tox_callback_conference_peer_list_changed(tox1, handle_conference_peer_list_changed); + tox_callback_conference_peer_list_changed(tox2, handle_conference_peer_list_changed); + tox_callback_conference_peer_list_changed(tox3, handle_conference_peer_list_changed); // Wait for self connection. fprintf(stderr, "Waiting for toxes to come online");