Make group callbacks stateless

This commit is contained in:
Jfreegman 2016-09-19 11:30:36 -04:00
parent e59fd26d49
commit dd2965a58f
10 changed files with 111 additions and 108 deletions

View File

@ -1231,7 +1231,7 @@ group_test_restart:
toxes[i] = tox_new(0, 0);
ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i);
tox_callback_friend_request(toxes[i], &g_accept_friend_request);
tox_callback_conference_invite(toxes[i], &print_group_invite_callback, &to_comp);
tox_callback_conference_invite(toxes[i], &print_group_invite_callback);
}
{
@ -1280,7 +1280,7 @@ group_test_restart:
while (1) {
for (i = 0; i < NUM_GROUP_TOX; ++i) {
tox_iterate(toxes[i], NULL);
tox_iterate(toxes[i], &to_comp);
}
if (!invite_counter) {
@ -1336,7 +1336,7 @@ group_test_restart:
printf("group connected\n");
for (i = 0; i < NUM_GROUP_TOX; ++i) {
tox_callback_conference_message(toxes[i], &print_group_message, &to_comp);
tox_callback_conference_message(toxes[i], &print_group_message);
}
ck_assert_msg(
@ -1347,7 +1347,7 @@ group_test_restart:
for (j = 0; j < 20; ++j) {
for (i = 0; i < NUM_GROUP_TOX; ++i) {
tox_iterate(toxes[i], NULL);
tox_iterate(toxes[i], &to_comp);
}
c_sleep(25);
@ -1361,7 +1361,7 @@ group_test_restart:
for (j = 0; j < 10; ++j) {
for (i = 0; i < NUM_GROUP_TOX; ++i) {
tox_iterate(toxes[i], NULL);
tox_iterate(toxes[i], &to_comp);
}
c_sleep(50);

View File

@ -2040,7 +2040,7 @@ namespace conference {
/**
* This event is triggered when the client is invited to join a conference.
*/
event invite {
event invite const {
/**
* The invitation will remain valid until the inviting friend goes offline
* or exits the conference.
@ -2058,7 +2058,7 @@ namespace conference {
/**
* This event is triggered when the client receives a conference message.
*/
event message {
event message const {
/**
* @param conference_number The conference number of the conference the message is intended for.
* @param peer_number The ID of the peer who sent the message.
@ -2076,7 +2076,7 @@ namespace conference {
*
* If peer_number == UINT32_MAX, then author is unknown (e.g. initial joining the conference).
*/
event title {
event title const {
/**
* @param conference_number The conference number of the conference the title change is intended for.
* @param peer_number The ID of the peer who changed the title.
@ -2107,7 +2107,7 @@ namespace conference {
/**
* This event is triggered when the peer list changes (name change, peer join, peer exit).
*/
event namelist_change {
event namelist_change const {
/**
* @param conference_number The conference number of the conference the title change is intended for.
* @param peer_number The ID of the peer who changed the title.

View File

@ -246,8 +246,8 @@ static Tox *init_tox(int argc, char *argv[])
tox_self_set_name(tox, (const uint8_t *)IRC_NAME, sizeof(IRC_NAME) - 1, 0);
tox_callback_friend_message(tox, &callback_friend_message);
tox_callback_conference_invite(tox, &callback_group_invite, NULL);
tox_callback_conference_message(tox, &copy_groupmessage, NULL);
tox_callback_conference_invite(tox, &callback_group_invite);
tox_callback_conference_message(tox, &copy_groupmessage);
char temp_id[128];
printf("\nEnter the address of irc_syncbots master (38 bytes HEX format):\n");

View File

@ -1360,13 +1360,13 @@ int main(int argc, char *argv[])
tox_callback_friend_message(m, print_message);
tox_callback_friend_name(m, print_nickchange);
tox_callback_friend_status_message(m, print_statuschange);
tox_callback_conference_invite(m, print_invite, NULL);
tox_callback_conference_message(m, print_groupmessage, NULL);
tox_callback_conference_invite(m, print_invite);
tox_callback_conference_message(m, print_groupmessage);
tox_callback_conference_namelist_change(m, print_groupnamelistchange);
tox_callback_file_recv_chunk(m, write_file);
tox_callback_file_recv_control(m, file_print_control);
tox_callback_file_recv(m, file_request_accept);
tox_callback_file_chunk_request(m, tox_file_chunk_request);
tox_callback_conference_namelist_change(m, print_groupnamelistchange, NULL);
tox_callback_friend_connection_status(m, print_online);
initscr();

View File

@ -984,9 +984,9 @@ static int write_cryptpacket_id(const Messenger *m, int32_t friendnumber, uint8_
/* Set the callback for group invites.
*
* Function(Messenger *m, uint32_t friendnumber, uint8_t *data, uint16_t length)
* Function(Messenger *m, uint32_t friendnumber, uint8_t *data, uint16_t length, void *userdata)
*/
void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, uint32_t, const uint8_t *, uint16_t))
void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, uint32_t, const uint8_t *, uint16_t, void *))
{
m->group_invite = function;
}
@ -2181,7 +2181,7 @@ static int handle_packet(void *object, int i, const uint8_t *temp, uint16_t len,
}
if (m->group_invite) {
(*m->group_invite)(m, i, data, data_length);
(*m->group_invite)(m, i, data, data_length, userdata);
}
break;

View File

@ -249,8 +249,7 @@ struct Messenger {
void *friend_connectionstatuschange_internal_userdata;
void *group_chat_object; /* Set by new_groupchats()*/
void (*group_invite)(struct Messenger *m, uint32_t, const uint8_t *, uint16_t);
void (*group_message)(struct Messenger *m, uint32_t, const uint8_t *, uint16_t);
void (*group_invite)(struct Messenger *m, uint32_t, const uint8_t *, uint16_t, void *);
void (*file_sendrequest)(struct Messenger *m, uint32_t, uint32_t, uint32_t, uint64_t, const uint8_t *, size_t,
void *);
@ -536,9 +535,9 @@ void m_callback_core_connection(Messenger *m, void (*function)(Messenger *m, uns
/* Set the callback for group invites.
*
* Function(Messenger *m, uint32_t friendnumber, uint8_t *data, uint16_t length)
* Function(Messenger *m, uint32_t friendnumber, uint8_t *data, uint16_t length, void *userdata)
*/
void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, uint32_t, const uint8_t *, uint16_t));
void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, uint32_t, const uint8_t *, uint16_t, void *));
/* Send a group invite packet.
*

View File

@ -399,14 +399,17 @@ static int connect_to_closest(Group_Chats *g_c, int groupnumber, void *userdata)
return 0;
}
/*
* Add a peer to the group chat.
/* Add a peer to the group chat.
*
* do_gc_callback indicates whether we want to trigger callbacks set by the client
* via the public API. This should be set to false if this function is called
* from outside of the tox_iterate() loop.
*
* return peer_index if success or peer already in chat.
* return -1 if error.
*/
static int addpeer(Group_Chats *g_c, int groupnumber, const uint8_t *real_pk, const uint8_t *temp_pk,
uint16_t peer_number)
uint16_t peer_number, void *userdata, bool do_gc_callback)
{
Group_c *g = get_group_c(g_c, groupnumber);
@ -452,9 +455,8 @@ static int addpeer(Group_Chats *g_c, int groupnumber, const uint8_t *real_pk, co
add_to_closest(g_c, groupnumber, real_pk, temp_pk);
if (g_c->group_namelistchange) {
g_c->group_namelistchange(g_c->m, groupnumber, g->numpeers - 1, CHAT_CHANGE_PEER_ADD,
g_c->group_namelistchange_userdata);
if (do_gc_callback && g_c->group_namelistchange) {
g_c->group_namelistchange(g_c->m, groupnumber, g->numpeers - 1, CHAT_CHANGE_PEER_ADD, userdata);
}
if (g->peer_on_join) {
@ -496,7 +498,7 @@ static int remove_close_conn(Group_Chats *g_c, int groupnumber, int friendcon_id
* return 0 if success
* return -1 if error.
*/
static int delpeer(Group_Chats *g_c, int groupnumber, int peer_index)
static int delpeer(Group_Chats *g_c, int groupnumber, int peer_index, void *userdata)
{
Group_c *g = get_group_c(g_c, groupnumber);
@ -543,7 +545,7 @@ static int delpeer(Group_Chats *g_c, int groupnumber, int peer_index)
}
if (g_c->group_namelistchange) {
g_c->group_namelistchange(g_c->m, groupnumber, peer_index, CHAT_CHANGE_PEER_DEL, g_c->group_namelistchange_userdata);
g_c->group_namelistchange(g_c->m, groupnumber, peer_index, CHAT_CHANGE_PEER_DEL, userdata);
}
if (g->peer_on_leave) {
@ -553,7 +555,17 @@ static int delpeer(Group_Chats *g_c, int groupnumber, int peer_index)
return 0;
}
static int setnick(Group_Chats *g_c, int groupnumber, int peer_index, const uint8_t *nick, uint16_t nick_len)
/* Set the nick for a peer.
*
* do_gc_callback indicates whether we want to trigger callbacks set by the client
* via the public API. This should be set to false if this function is called
* from outside of the tox_iterate() loop.
*
* return 0 on success.
* return -1 if error.
*/
static int setnick(Group_Chats *g_c, int groupnumber, int peer_index, const uint8_t *nick, uint16_t nick_len,
void *userdata, bool do_gc_callback)
{
if (nick_len > MAX_NAME_LENGTH) {
return -1;
@ -578,14 +590,15 @@ static int setnick(Group_Chats *g_c, int groupnumber, int peer_index, const uint
g->group[peer_index].nick_len = nick_len;
if (g_c->group_namelistchange) {
g_c->group_namelistchange(g_c->m, groupnumber, peer_index, CHAT_CHANGE_PEER_NAME, g_c->group_namelistchange_userdata);
if (do_gc_callback && g_c->group_namelistchange) {
g_c->group_namelistchange(g_c->m, groupnumber, peer_index, CHAT_CHANGE_PEER_NAME, userdata);
}
return 0;
}
static int settitle(Group_Chats *g_c, int groupnumber, int peer_index, const uint8_t *title, uint8_t title_len)
static int settitle(Group_Chats *g_c, int groupnumber, int peer_index, const uint8_t *title, uint8_t title_len,
void *userdata)
{
if (title_len > MAX_NAME_LENGTH || title_len == 0) {
return -1;
@ -606,7 +619,7 @@ static int settitle(Group_Chats *g_c, int groupnumber, int peer_index, const uin
g->title_len = title_len;
if (g_c->title_callback) {
g_c->title_callback(g_c->m, groupnumber, peer_index, title, title_len, g_c->title_callback_userdata);
g_c->title_callback(g_c->m, groupnumber, peer_index, title, title_len, userdata);
}
return 0;
@ -733,13 +746,13 @@ int add_groupchat(Group_Chats *g_c, uint8_t type)
g->identifier[0] = type;
g->peer_number = 0; /* Founder is peer 0. */
memcpy(g->real_pk, g_c->m->net_crypto->self_public_key, crypto_box_PUBLICKEYBYTES);
int peer_index = addpeer(g_c, groupnumber, g->real_pk, g_c->m->dht->self_public_key, 0);
int peer_index = addpeer(g_c, groupnumber, g->real_pk, g_c->m->dht->self_public_key, 0, NULL, false);
if (peer_index == -1) {
return -1;
}
setnick(g_c, groupnumber, peer_index, g_c->m->name, g_c->m->name_length);
setnick(g_c, groupnumber, peer_index, g_c->m->name, g_c->m->name_length, NULL, false);
return groupnumber;
}
@ -1094,30 +1107,6 @@ int join_groupchat(Group_Chats *g_c, int32_t friendnumber, uint8_t expected_type
return -6;
}
/* Set the callback for group invites.
*
* Function(Group_Chats *g_c, int32_t friendnumber, uint8_t type, uint8_t *data, uint16_t length, void *userdata)
*
* data of length is what needs to be passed to join_groupchat().
*/
void g_callback_group_invite(Group_Chats *g_c, void (*function)(Messenger *m, uint32_t, int, const uint8_t *,
size_t, void *), void *userdata)
{
g_c->invite_callback = function;
g_c->invite_callback_userdata = userdata;
}
/* Set the callback for group messages.
*
* Function(Group_Chats *g_c, int groupnumber, int friendgroupnumber, uint8_t * message, uint16_t length, void *userdata)
*/
void g_callback_group_message(Group_Chats *g_c, void (*function)(Messenger *m, uint32_t, uint32_t, int, const uint8_t *,
size_t, void *), void *userdata)
{
g_c->message_callback = function;
g_c->message_callback_userdata = userdata;
}
/* Set handlers for custom lossy packets.
*
* NOTE: Handler must return 0 if packet is to be relayed, -1 if the packet should not be relayed.
@ -1130,16 +1119,36 @@ void group_lossy_packet_registerhandler(Group_Chats *g_c, uint8_t byte, int (*fu
g_c->lossy_packethandlers[byte].function = function;
}
/* Set the callback for group invites.
*
* Function(Group_Chats *g_c, int32_t friendnumber, uint8_t type, uint8_t *data, uint16_t length, void *userdata)
*
* data of length is what needs to be passed to join_groupchat().
*/
void g_callback_group_invite(Group_Chats *g_c, void (*function)(Messenger *m, uint32_t, int, const uint8_t *,
size_t, void *))
{
g_c->invite_callback = function;
}
/* Set the callback for group messages.
*
* Function(Group_Chats *g_c, int groupnumber, int friendgroupnumber, uint8_t * message, uint16_t length, void *userdata)
*/
void g_callback_group_message(Group_Chats *g_c, void (*function)(Messenger *m, uint32_t, uint32_t, int, const uint8_t *,
size_t, void *))
{
g_c->message_callback = function;
}
/* Set callback function for peer name list changes.
*
* It gets called every time the name list changes(new peer/name, deleted peer)
* Function(Group_Chats *g_c, int groupnumber, int peernumber, TOX_CHAT_CHANGE change, void *userdata)
*/
void g_callback_group_namelistchange(Group_Chats *g_c, void (*function)(Messenger *m, int, int, uint8_t, void *),
void *userdata)
void g_callback_group_namelistchange(Group_Chats *g_c, void (*function)(Messenger *m, int, int, uint8_t, void *))
{
g_c->group_namelistchange = function;
g_c->group_namelistchange_userdata = userdata;
}
/* Set callback function for title changes.
@ -1148,10 +1157,9 @@ void g_callback_group_namelistchange(Group_Chats *g_c, void (*function)(Messenge
* if friendgroupnumber == -1, then author is unknown (e.g. initial joining the group)
*/
void g_callback_group_title(Group_Chats *g_c, void (*function)(Messenger *m, uint32_t, uint32_t, const uint8_t *,
size_t, void *), void *userdata)
size_t, void *))
{
g_c->title_callback = function;
g_c->title_callback_userdata = userdata;
}
/* Set a function to be called when a new peer joins a group chat.
@ -1368,7 +1376,8 @@ int group_title_get(const Group_Chats *g_c, int groupnumber, uint8_t *title)
return g->title_len;
}
static void handle_friend_invite_packet(Messenger *m, uint32_t friendnumber, const uint8_t *data, uint16_t length)
static void handle_friend_invite_packet(Messenger *m, uint32_t friendnumber, const uint8_t *data, uint16_t length,
void *userdata)
{
Group_Chats *g_c = m->group_chat_object;
@ -1389,8 +1398,7 @@ static void handle_friend_invite_packet(Messenger *m, uint32_t friendnumber, con
if (groupnumber == -1) {
if (g_c->invite_callback) {
g_c->invite_callback(m, friendnumber, *(invite_data + sizeof(uint16_t)), invite_data, invite_length,
g_c->invite_callback_userdata);
g_c->invite_callback(m, friendnumber, *(invite_data + sizeof(uint16_t)), invite_data, invite_length, userdata);
}
return;
@ -1440,7 +1448,7 @@ static void handle_friend_invite_packet(Messenger *m, uint32_t friendnumber, con
uint8_t real_pk[crypto_box_PUBLICKEYBYTES], temp_pk[crypto_box_PUBLICKEYBYTES];
get_friendcon_public_keys(real_pk, temp_pk, g_c->fr_c, friendcon_id);
addpeer(g_c, groupnum, real_pk, temp_pk, peer_number);
addpeer(g_c, groupnum, real_pk, temp_pk, peer_number, userdata, true);
int close_index = add_conn_to_groupchat(g_c, friendcon_id, groupnum, 0, 1);
if (close_index != -1) {
@ -1649,7 +1657,7 @@ static unsigned int send_peers(Group_Chats *g_c, int groupnumber, int friendcon_
return sent;
}
static int handle_send_peers(Group_Chats *g_c, int groupnumber, const uint8_t *data, uint16_t length)
static int handle_send_peers(Group_Chats *g_c, int groupnumber, const uint8_t *data, uint16_t length, void *userdata)
{
if (length == 0) {
return -1;
@ -1668,7 +1676,7 @@ static int handle_send_peers(Group_Chats *g_c, int groupnumber, const uint8_t *d
memcpy(&peer_num, d, sizeof(peer_num));
peer_num = ntohs(peer_num);
d += sizeof(uint16_t);
int peer_index = addpeer(g_c, groupnumber, d, d + crypto_box_PUBLICKEYBYTES, peer_num);
int peer_index = addpeer(g_c, groupnumber, d, d + crypto_box_PUBLICKEYBYTES, peer_num, userdata, true);
if (peer_index == -1) {
return -1;
@ -1689,7 +1697,7 @@ static int handle_send_peers(Group_Chats *g_c, int groupnumber, const uint8_t *d
return -1;
}
setnick(g_c, groupnumber, peer_index, d, name_length);
setnick(g_c, groupnumber, peer_index, d, name_length, userdata, true);
d += name_length;
}
@ -1697,7 +1705,7 @@ static int handle_send_peers(Group_Chats *g_c, int groupnumber, const uint8_t *d
}
static void handle_direct_packet(Group_Chats *g_c, int groupnumber, const uint8_t *data, uint16_t length,
int close_index)
int close_index, void *userdata)
{
if (length == 0) {
return;
@ -1732,13 +1740,13 @@ static void handle_direct_packet(Group_Chats *g_c, int groupnumber, const uint8_
break;
case PEER_RESPONSE_ID: {
handle_send_peers(g_c, groupnumber, data + 1, length - 1);
handle_send_peers(g_c, groupnumber, data + 1, length - 1, userdata);
}
break;
case PEER_TITLE_ID: {
settitle(g_c, groupnumber, -1, data + 1, length - 1);
settitle(g_c, groupnumber, -1, data + 1, length - 1, userdata);
}
break;
@ -1980,7 +1988,7 @@ int send_group_lossy_packet(const Group_Chats *g_c, int groupnumber, const uint8
}
static void handle_message_packet_group(Group_Chats *g_c, int groupnumber, const uint8_t *data, uint16_t length,
int close_index)
int close_index, void *userdata)
{
if (length < sizeof(uint16_t) + sizeof(uint32_t) + 1) {
return;
@ -2041,7 +2049,7 @@ static void handle_message_packet_group(Group_Chats *g_c, int groupnumber, const
memcpy(&new_peer_number, msg_data, sizeof(uint16_t));
new_peer_number = ntohs(new_peer_number);
addpeer(g_c, groupnumber, msg_data + sizeof(uint16_t), msg_data + sizeof(uint16_t) + crypto_box_PUBLICKEYBYTES,
new_peer_number);
new_peer_number, userdata, true);
}
break;
@ -2055,7 +2063,7 @@ static void handle_message_packet_group(Group_Chats *g_c, int groupnumber, const
kill_peer_number = ntohs(kill_peer_number);
if (peer_number == kill_peer_number) {
delpeer(g_c, groupnumber, index);
delpeer(g_c, groupnumber, index, userdata);
} else {
return;
// TODO(irungentoo):
@ -2064,14 +2072,14 @@ static void handle_message_packet_group(Group_Chats *g_c, int groupnumber, const
break;
case GROUP_MESSAGE_NAME_ID: {
if (setnick(g_c, groupnumber, index, msg_data, msg_data_len) == -1) {
if (setnick(g_c, groupnumber, index, msg_data, msg_data_len, userdata, true) == -1) {
return;
}
}
break;
case GROUP_MESSAGE_TITLE_ID: {
if (settitle(g_c, groupnumber, index, msg_data, msg_data_len) == -1) {
if (settitle(g_c, groupnumber, index, msg_data, msg_data_len, userdata) == -1) {
return;
}
}
@ -2088,7 +2096,7 @@ static void handle_message_packet_group(Group_Chats *g_c, int groupnumber, const
// TODO(irungentoo):
if (g_c->message_callback) {
g_c->message_callback(g_c->m, groupnumber, index, 0, newmsg, msg_data_len, g_c->message_callback_userdata);
g_c->message_callback(g_c->m, groupnumber, index, 0, newmsg, msg_data_len, userdata);
}
break;
@ -2105,7 +2113,7 @@ static void handle_message_packet_group(Group_Chats *g_c, int groupnumber, const
// TODO(irungentoo):
if (g_c->message_callback) {
g_c->message_callback(g_c->m, groupnumber, index, 1, newmsg, msg_data_len, g_c->message_callback_userdata);
g_c->message_callback(g_c->m, groupnumber, index, 1, newmsg, msg_data_len, userdata);
}
break;
@ -2151,12 +2159,13 @@ static int handle_packet(void *object, int friendcon_id, const uint8_t *data, ui
switch (data[0]) {
case PACKET_ID_DIRECT_GROUPCHAT: {
handle_direct_packet(g_c, groupnumber, data + 1 + sizeof(uint16_t), length - (1 + sizeof(uint16_t)), index);
handle_direct_packet(g_c, groupnumber, data + 1 + sizeof(uint16_t), length - (1 + sizeof(uint16_t)), index, userdata);
break;
}
case PACKET_ID_MESSAGE_GROUPCHAT: {
handle_message_packet_group(g_c, groupnumber, data + 1 + sizeof(uint16_t), length - (1 + sizeof(uint16_t)), index);
handle_message_packet_group(g_c, groupnumber, data + 1 + sizeof(uint16_t), length - (1 + sizeof(uint16_t)), index,
userdata);
break;
}
@ -2388,7 +2397,7 @@ static int ping_groupchat(Group_Chats *g_c, int groupnumber)
return 0;
}
static int groupchat_clear_timedout(Group_Chats *g_c, int groupnumber)
static int groupchat_clear_timedout(Group_Chats *g_c, int groupnumber, void *userdata)
{
Group_c *g = get_group_c(g_c, groupnumber);
@ -2400,7 +2409,7 @@ static int groupchat_clear_timedout(Group_Chats *g_c, int groupnumber)
for (i = 0; i < g->numpeers; ++i) {
if (g->peer_number != g->group[i].peer_number && is_timeout(g->group[i].last_recv, GROUP_PING_INTERVAL * 3)) {
delpeer(g_c, groupnumber, i);
delpeer(g_c, groupnumber, i, userdata);
}
if (g->group == NULL || i >= g->numpeers) {
@ -2466,7 +2475,7 @@ void do_groupchats(Group_Chats *g_c, void *userdata)
if (g->status == GROUPCHAT_STATUS_CONNECTED) {
connect_to_closest(g_c, i, userdata);
ping_groupchat(g_c, i);
groupchat_clear_timedout(g_c, i);
groupchat_clear_timedout(g_c, i, userdata);
}
}

View File

@ -117,13 +117,9 @@ typedef struct {
uint32_t num_chats;
void (*invite_callback)(Messenger *m, uint32_t, int, const uint8_t *, size_t, void *);
void *invite_callback_userdata;
void (*message_callback)(Messenger *m, uint32_t, uint32_t, int, const uint8_t *, size_t, void *);
void *message_callback_userdata;
void (*group_namelistchange)(Messenger *m, int, int, uint8_t, void *);
void *group_namelistchange_userdata;
void (*title_callback)(Messenger *m, uint32_t, uint32_t, const uint8_t *, size_t, void *);
void *title_callback_userdata;
struct {
int (*function)(void *, int, int, void *, const uint8_t *, uint16_t);
@ -137,14 +133,14 @@ typedef struct {
* data of length is what needs to be passed to join_groupchat().
*/
void g_callback_group_invite(Group_Chats *g_c, void (*function)(Messenger *m, uint32_t, int, const uint8_t *,
size_t, void *), void *userdata);
size_t, void *));
/* Set the callback for group messages.
*
* Function(Group_Chats *g_c, int groupnumber, int friendgroupnumber, uint8_t * message, uint16_t length, void *userdata)
*/
void g_callback_group_message(Group_Chats *g_c, void (*function)(Messenger *m, uint32_t, uint32_t, int, const uint8_t *,
size_t, void *), void *userdata);
size_t, void *));
/* Set callback function for title changes.
@ -153,7 +149,7 @@ void g_callback_group_message(Group_Chats *g_c, void (*function)(Messenger *m, u
* if friendgroupnumber == -1, then author is unknown (e.g. initial joining the group)
*/
void g_callback_group_title(Group_Chats *g_c, void (*function)(Messenger *m, uint32_t, uint32_t, const uint8_t *,
size_t, void *), void *userdata);
size_t, void *));
/* Set callback function for peer name list changes.
*
@ -165,8 +161,7 @@ enum {
CHAT_CHANGE_PEER_DEL,
CHAT_CHANGE_PEER_NAME,
};
void g_callback_group_namelistchange(Group_Chats *g_c, void (*function)(Messenger *m, int, int, uint8_t, void *),
void *userdata);
void g_callback_group_namelistchange(Group_Chats *g_c, void (*function)(Messenger *m, int, int, uint8_t, void *));
/* Creates a new groupchat and puts it in the chats array.
*

View File

@ -1216,31 +1216,31 @@ void tox_callback_file_recv_chunk(Tox *tox, tox_file_recv_chunk_cb *callback)
callback_file_data(m, callback);
}
void tox_callback_conference_invite(Tox *tox, tox_conference_invite_cb *callback, void *user_data)
void tox_callback_conference_invite(Tox *tox, tox_conference_invite_cb *callback)
{
Messenger *m = tox;
g_callback_group_invite(m->group_chat_object, (void (*)(Messenger * m, uint32_t, int, const uint8_t *, size_t,
void *))callback, user_data);
void *))callback);
}
void tox_callback_conference_message(Tox *tox, tox_conference_message_cb *callback, void *user_data)
void tox_callback_conference_message(Tox *tox, tox_conference_message_cb *callback)
{
Messenger *m = tox;
g_callback_group_message(m->group_chat_object, (void (*)(Messenger * m, uint32_t, uint32_t, int, const uint8_t *,
size_t, void *))callback, user_data);
size_t, void *))callback);
}
void tox_callback_conference_title(Tox *tox, tox_conference_title_cb *callback, void *user_data)
void tox_callback_conference_title(Tox *tox, tox_conference_title_cb *callback)
{
Messenger *m = tox;
g_callback_group_title(m->group_chat_object, callback, user_data);
g_callback_group_title(m->group_chat_object, callback);
}
void tox_callback_conference_namelist_change(Tox *tox, tox_conference_namelist_change_cb *callback, void *user_data)
void tox_callback_conference_namelist_change(Tox *tox, tox_conference_namelist_change_cb *callback)
{
Messenger *m = tox;
g_callback_group_namelistchange(m->group_chat_object, (void (*)(struct Messenger *, int, int, uint8_t,
void *))callback, user_data);
void *))callback);
}
uint32_t tox_conference_new(Tox *tox, TOX_ERR_CONFERENCE_NEW *error)

View File

@ -2307,7 +2307,7 @@ typedef void tox_conference_invite_cb(Tox *tox, uint32_t friend_number, TOX_CONF
*
* This event is triggered when the client is invited to join a conference.
*/
void tox_callback_conference_invite(Tox *tox, tox_conference_invite_cb *callback, void *user_data);
void tox_callback_conference_invite(Tox *tox, tox_conference_invite_cb *callback);
/**
* @param conference_number The conference number of the conference the message is intended for.
@ -2325,7 +2325,7 @@ typedef void tox_conference_message_cb(Tox *tox, uint32_t conference_number, uin
*
* This event is triggered when the client receives a conference message.
*/
void tox_callback_conference_message(Tox *tox, tox_conference_message_cb *callback, void *user_data);
void tox_callback_conference_message(Tox *tox, tox_conference_message_cb *callback);
/**
* @param conference_number The conference number of the conference the title change is intended for.
@ -2344,7 +2344,7 @@ typedef void tox_conference_title_cb(Tox *tox, uint32_t conference_number, uint3
*
* If peer_number == UINT32_MAX, then author is unknown (e.g. initial joining the conference).
*/
void tox_callback_conference_title(Tox *tox, tox_conference_title_cb *callback, void *user_data);
void tox_callback_conference_title(Tox *tox, tox_conference_title_cb *callback);
/**
* Peer list state change types.
@ -2383,7 +2383,7 @@ typedef void tox_conference_namelist_change_cb(Tox *tox, uint32_t conference_num
*
* This event is triggered when the peer list changes (name change, peer join, peer exit).
*/
void tox_callback_conference_namelist_change(Tox *tox, tox_conference_namelist_change_cb *callback, void *user_data);
void tox_callback_conference_namelist_change(Tox *tox, tox_conference_namelist_change_cb *callback);
typedef enum TOX_ERR_CONFERENCE_NEW {