Fix auto_tests to stop using the deprecated conference API.

This commit is contained in:
iphydf 2018-02-26 21:18:48 +00:00
parent 0c0977fb8c
commit 1334d16517
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
2 changed files with 16 additions and 23 deletions

View File

@ -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);

View File

@ -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");