diff options
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/group.c | 46 | ||||
-rw-r--r-- | toxcore/group.h | 64 | ||||
-rw-r--r-- | toxcore/tox.api.h | 16 | ||||
-rw-r--r-- | toxcore/tox.c | 16 | ||||
-rw-r--r-- | toxcore/tox.h | 18 |
5 files changed, 98 insertions, 62 deletions
diff --git a/toxcore/group.c b/toxcore/group.c index b42c6b24..75b8697b 100644 --- a/toxcore/group.c +++ b/toxcore/group.c | |||
@@ -1174,33 +1174,25 @@ int join_groupchat(Group_Chats *g_c, uint32_t friendnumber, uint8_t expected_typ | |||
1174 | return -6; | 1174 | return -6; |
1175 | } | 1175 | } |
1176 | 1176 | ||
1177 | /* Set handlers for custom lossy packets. | 1177 | /* Set handlers for custom lossy packets. */ |
1178 | * | ||
1179 | * NOTE: Handler must return 0 if packet is to be relayed, -1 if the packet should not be relayed. | ||
1180 | * | ||
1181 | * Function(void *group object (set with group_set_object), uint32_t groupnumber, uint32_t friendgroupnumber, void *group peer object (set with group_peer_set_object), const uint8_t *packet, uint16_t length) | ||
1182 | */ | ||
1183 | void group_lossy_packet_registerhandler(Group_Chats *g_c, uint8_t byte, lossy_packet_cb *function) | 1178 | void group_lossy_packet_registerhandler(Group_Chats *g_c, uint8_t byte, lossy_packet_cb *function) |
1184 | { | 1179 | { |
1185 | g_c->lossy_packethandlers[byte].function = function; | 1180 | g_c->lossy_packethandlers[byte].function = function; |
1186 | } | 1181 | } |
1187 | 1182 | ||
1188 | /* Set the callback for group invites. | 1183 | /* Set the callback for group invites. */ |
1189 | * | ||
1190 | * Function(Group_Chats *g_c, int32_t friendnumber, uint8_t type, uint8_t *data, size_t length, void *userdata) | ||
1191 | * | ||
1192 | * data of length is what needs to be passed to join_groupchat(). | ||
1193 | */ | ||
1194 | void g_callback_group_invite(Group_Chats *g_c, g_conference_invite_cb *function) | 1184 | void g_callback_group_invite(Group_Chats *g_c, g_conference_invite_cb *function) |
1195 | { | 1185 | { |
1196 | g_c->invite_callback = function; | 1186 | g_c->invite_callback = function; |
1197 | } | 1187 | } |
1198 | 1188 | ||
1199 | // TODO(sudden6): function signatures in comments are incorrect | 1189 | /* Set the callback for group connection. */ |
1200 | /* Set the callback for group messages. | 1190 | void g_callback_group_connected(Group_Chats *g_c, g_conference_connected_cb *function) |
1201 | * | 1191 | { |
1202 | * Function(Group_Chats *g_c, uint32_t groupnumber, uint32_t friendgroupnumber, uint8_t * message, size_t length, void *userdata) | 1192 | g_c->connected_callback = function; |
1203 | */ | 1193 | } |
1194 | |||
1195 | /* Set the callback for group messages. */ | ||
1204 | void g_callback_group_message(Group_Chats *g_c, g_conference_message_cb *function) | 1196 | void g_callback_group_message(Group_Chats *g_c, g_conference_message_cb *function) |
1205 | { | 1197 | { |
1206 | g_c->message_callback = function; | 1198 | g_c->message_callback = function; |
@@ -1209,7 +1201,6 @@ void g_callback_group_message(Group_Chats *g_c, g_conference_message_cb *functio | |||
1209 | /* Set callback function for peer nickname changes. | 1201 | /* Set callback function for peer nickname changes. |
1210 | * | 1202 | * |
1211 | * It gets called every time a peer changes their nickname. | 1203 | * It gets called every time a peer changes their nickname. |
1212 | * Function(Group_Chats *g_c, uint32_t groupnumber, uint32_t peernumber, const uint8_t *nick, size_t nick_len, void *userdata) | ||
1213 | */ | 1204 | */ |
1214 | void g_callback_peer_name(Group_Chats *g_c, peer_name_cb *function) | 1205 | void g_callback_peer_name(Group_Chats *g_c, peer_name_cb *function) |
1215 | { | 1206 | { |
@@ -1219,19 +1210,13 @@ void g_callback_peer_name(Group_Chats *g_c, peer_name_cb *function) | |||
1219 | /* Set callback function for peer list changes. | 1210 | /* Set callback function for peer list changes. |
1220 | * | 1211 | * |
1221 | * It gets called every time the name list changes(new peer, deleted peer) | 1212 | * It gets called every time the name list changes(new peer, deleted peer) |
1222 | * Function(Group_Chats *g_c, uint32_t groupnumber, void *userdata) | ||
1223 | */ | 1213 | */ |
1224 | void g_callback_peer_list_changed(Group_Chats *g_c, peer_list_changed_cb *function) | 1214 | void g_callback_peer_list_changed(Group_Chats *g_c, peer_list_changed_cb *function) |
1225 | { | 1215 | { |
1226 | g_c->peer_list_changed_callback = function; | 1216 | g_c->peer_list_changed_callback = function; |
1227 | } | 1217 | } |
1228 | 1218 | ||
1229 | // TODO(sudden6): function signatures are incorrect | 1219 | /* Set callback function for title changes. */ |
1230 | /* Set callback function for title changes. | ||
1231 | * | ||
1232 | * Function(Group_Chats *g_c, int groupnumber, int friendgroupnumber, uint8_t * title, uint8_t length, void *userdata) | ||
1233 | * if friendgroupnumber == -1, then author is unknown (e.g. initial joining the group) | ||
1234 | */ | ||
1235 | void g_callback_group_title(Group_Chats *g_c, title_cb *function) | 1220 | void g_callback_group_title(Group_Chats *g_c, title_cb *function) |
1236 | { | 1221 | { |
1237 | g_c->title_callback = function; | 1222 | g_c->title_callback = function; |
@@ -1239,8 +1224,6 @@ void g_callback_group_title(Group_Chats *g_c, title_cb *function) | |||
1239 | 1224 | ||
1240 | /* Set a function to be called when a new peer joins a group chat. | 1225 | /* Set a function to be called when a new peer joins a group chat. |
1241 | * | 1226 | * |
1242 | * Function(void *group object (set with group_set_object), uint32_t groupnumber, uint32_t friendgroupnumber) | ||
1243 | * | ||
1244 | * return 0 on success. | 1227 | * return 0 on success. |
1245 | * return -1 on failure. | 1228 | * return -1 on failure. |
1246 | */ | 1229 | */ |
@@ -1258,8 +1241,6 @@ int callback_groupchat_peer_new(const Group_Chats *g_c, uint32_t groupnumber, pe | |||
1258 | 1241 | ||
1259 | /* Set a function to be called when a peer leaves a group chat. | 1242 | /* Set a function to be called when a peer leaves a group chat. |
1260 | * | 1243 | * |
1261 | * Function(void *group object (set with group_set_object), uint32_t groupnumber, uint32_t friendgroupnumber, void *group peer object (set with group_peer_set_object)) | ||
1262 | * | ||
1263 | * return 0 on success. | 1244 | * return 0 on success. |
1264 | * return -1 on failure. | 1245 | * return -1 on failure. |
1265 | */ | 1246 | */ |
@@ -1277,8 +1258,6 @@ int callback_groupchat_peer_delete(Group_Chats *g_c, uint32_t groupnumber, peer_ | |||
1277 | 1258 | ||
1278 | /* Set a function to be called when the group chat is deleted. | 1259 | /* Set a function to be called when the group chat is deleted. |
1279 | * | 1260 | * |
1280 | * Function(void *group object (set with group_set_object), int groupnumber) | ||
1281 | * | ||
1282 | * return 0 on success. | 1261 | * return 0 on success. |
1283 | * return -1 on failure. | 1262 | * return -1 on failure. |
1284 | */ | 1263 | */ |
@@ -1742,6 +1721,11 @@ static int handle_send_peers(Group_Chats *g_c, uint32_t groupnumber, const uint8 | |||
1742 | && public_key_cmp(d, nc_get_self_public_key(g_c->m->net_crypto)) == 0) { | 1721 | && public_key_cmp(d, nc_get_self_public_key(g_c->m->net_crypto)) == 0) { |
1743 | g->peer_number = peer_num; | 1722 | g->peer_number = peer_num; |
1744 | g->status = GROUPCHAT_STATUS_CONNECTED; | 1723 | g->status = GROUPCHAT_STATUS_CONNECTED; |
1724 | |||
1725 | if (g_c->connected_callback) { | ||
1726 | g_c->connected_callback(g_c->m, groupnumber, userdata); | ||
1727 | } | ||
1728 | |||
1745 | group_name_send(g_c, groupnumber, g_c->m->name, g_c->m->name_length); | 1729 | group_name_send(g_c, groupnumber, g_c->m->name, g_c->m->name_length); |
1746 | } | 1730 | } |
1747 | 1731 | ||
diff --git a/toxcore/group.h b/toxcore/group.h index 31e0e7e3..175999ae 100644 --- a/toxcore/group.h +++ b/toxcore/group.h | |||
@@ -132,15 +132,38 @@ typedef struct Group_c { | |||
132 | group_on_delete_cb *group_on_delete; | 132 | group_on_delete_cb *group_on_delete; |
133 | } Group_c; | 133 | } Group_c; |
134 | 134 | ||
135 | /* Callback for group invites. | ||
136 | * | ||
137 | * data of length is what needs to be passed to join_groupchat(). | ||
138 | */ | ||
135 | typedef void g_conference_invite_cb(Messenger *m, uint32_t friend_number, int type, const uint8_t *cookie, | 139 | typedef void g_conference_invite_cb(Messenger *m, uint32_t friend_number, int type, const uint8_t *cookie, |
136 | size_t length, void *user_data); | 140 | size_t length, void *user_data); |
141 | |||
142 | /* Callback for group connection. */ | ||
143 | typedef void g_conference_connected_cb(Messenger *m, uint32_t conference_number, void *user_data); | ||
144 | |||
145 | /* Callback for group messages. */ | ||
137 | typedef void g_conference_message_cb(Messenger *m, uint32_t conference_number, uint32_t peer_number, int type, | 146 | typedef void g_conference_message_cb(Messenger *m, uint32_t conference_number, uint32_t peer_number, int type, |
138 | const uint8_t *message, size_t length, void *user_data); | 147 | const uint8_t *message, size_t length, void *user_data); |
148 | |||
149 | /* Callback for peer nickname changes. */ | ||
139 | typedef void peer_name_cb(Messenger *m, uint32_t conference_number, uint32_t peer_number, const uint8_t *name, | 150 | typedef void peer_name_cb(Messenger *m, uint32_t conference_number, uint32_t peer_number, const uint8_t *name, |
140 | size_t length, void *user_data); | 151 | size_t length, void *user_data); |
152 | |||
153 | /* Set callback function for peer list changes. */ | ||
141 | typedef void peer_list_changed_cb(Messenger *m, uint32_t conference_number, void *user_data); | 154 | typedef void peer_list_changed_cb(Messenger *m, uint32_t conference_number, void *user_data); |
155 | |||
156 | /* Callback for title changes. | ||
157 | * | ||
158 | * If peer_number == -1, then author is unknown (e.g. initial joining the group). | ||
159 | */ | ||
142 | typedef void title_cb(Messenger *m, uint32_t conference_number, uint32_t peer_number, const uint8_t *title, | 160 | typedef void title_cb(Messenger *m, uint32_t conference_number, uint32_t peer_number, const uint8_t *title, |
143 | size_t length, void *user_data); | 161 | size_t length, void *user_data); |
162 | |||
163 | /* Callback for lossy packets. | ||
164 | * | ||
165 | * NOTE: Handler must return 0 if packet is to be relayed, -1 if the packet should not be relayed. | ||
166 | */ | ||
144 | typedef int lossy_packet_cb(void *object, uint32_t conference_number, uint32_t peer_number, void *peer_object, | 167 | typedef int lossy_packet_cb(void *object, uint32_t conference_number, uint32_t peer_number, void *peer_object, |
145 | const uint8_t *packet, uint16_t length); | 168 | const uint8_t *packet, uint16_t length); |
146 | 169 | ||
@@ -156,6 +179,7 @@ typedef struct Group_Chats { | |||
156 | uint16_t num_chats; | 179 | uint16_t num_chats; |
157 | 180 | ||
158 | g_conference_invite_cb *invite_callback; | 181 | g_conference_invite_cb *invite_callback; |
182 | g_conference_connected_cb *connected_callback; | ||
159 | g_conference_message_cb *message_callback; | 183 | g_conference_message_cb *message_callback; |
160 | peer_name_cb *peer_name_callback; | 184 | peer_name_cb *peer_name_callback; |
161 | peer_list_changed_cb *peer_list_changed_callback; | 185 | peer_list_changed_cb *peer_list_changed_callback; |
@@ -164,39 +188,28 @@ typedef struct Group_Chats { | |||
164 | Group_Lossy_Handler lossy_packethandlers[256]; | 188 | Group_Lossy_Handler lossy_packethandlers[256]; |
165 | } Group_Chats; | 189 | } Group_Chats; |
166 | 190 | ||
167 | /* Set the callback for group invites. | 191 | /* Set the callback for group invites. */ |
168 | * | ||
169 | * Function(Group_Chats *g_c, uint32_t friendnumber, uint8_t type, uint8_t *data, uint16_t length, void *userdata) | ||
170 | * | ||
171 | * data of length is what needs to be passed to join_groupchat(). | ||
172 | */ | ||
173 | void g_callback_group_invite(Group_Chats *g_c, g_conference_invite_cb *function); | 192 | void g_callback_group_invite(Group_Chats *g_c, g_conference_invite_cb *function); |
174 | 193 | ||
175 | /* Set the callback for group messages. | 194 | /* Set the callback for group connection. */ |
176 | * | 195 | void g_callback_group_connected(Group_Chats *g_c, g_conference_connected_cb *function); |
177 | * Function(Group_Chats *g_c, uint32_t groupnumber, uint32_t friendgroupnumber, uint8_t * message, uint16_t length, void *userdata) | 196 | |
178 | */ | 197 | /* Set the callback for group messages. */ |
179 | void g_callback_group_message(Group_Chats *g_c, g_conference_message_cb *function); | 198 | void g_callback_group_message(Group_Chats *g_c, g_conference_message_cb *function); |
180 | 199 | ||
181 | 200 | ||
182 | /* Set callback function for title changes. | 201 | /* Set callback function for title changes. */ |
183 | * | ||
184 | * Function(Group_Chats *g_c, uint32_t groupnumber, uint32_t friendgroupnumber, uint8_t * title, uint8_t length, void *userdata) | ||
185 | * if friendgroupnumber == -1, then author is unknown (e.g. initial joining the group) | ||
186 | */ | ||
187 | void g_callback_group_title(Group_Chats *g_c, title_cb *function); | 202 | void g_callback_group_title(Group_Chats *g_c, title_cb *function); |
188 | 203 | ||
189 | /* Set callback function for peer nickname changes. | 204 | /* Set callback function for peer nickname changes. |
190 | * | 205 | * |
191 | * It gets called every time a peer changes their nickname. | 206 | * It gets called every time a peer changes their nickname. |
192 | * Function(Group_Chats *g_c, uint32_t groupnumber, uint32_t peernumber, const uint8_t *nick, size_t nick_len, void *userdata) | ||
193 | */ | 207 | */ |
194 | void g_callback_peer_name(Group_Chats *g_c, peer_name_cb *function); | 208 | void g_callback_peer_name(Group_Chats *g_c, peer_name_cb *function); |
195 | 209 | ||
196 | /* Set callback function for peer list changes. | 210 | /* Set callback function for peer list changes. |
197 | * | 211 | * |
198 | * It gets called every time the name list changes(new peer, deleted peer) | 212 | * It gets called every time the name list changes(new peer, deleted peer) |
199 | * Function(Group_Chats *g_c, uint32_t groupnumber, void *userdata) | ||
200 | */ | 213 | */ |
201 | void g_callback_peer_list_changed(Group_Chats *g_c, peer_list_changed_cb *function); | 214 | void g_callback_peer_list_changed(Group_Chats *g_c, peer_list_changed_cb *function); |
202 | 215 | ||
@@ -327,12 +340,7 @@ int group_peernumber_is_ours(const Group_Chats *g_c, uint32_t groupnumber, int p | |||
327 | int group_names(const Group_Chats *g_c, uint32_t groupnumber, uint8_t names[][MAX_NAME_LENGTH], uint16_t lengths[], | 340 | int group_names(const Group_Chats *g_c, uint32_t groupnumber, uint8_t names[][MAX_NAME_LENGTH], uint16_t lengths[], |
328 | uint16_t length); | 341 | uint16_t length); |
329 | 342 | ||
330 | /* Set handlers for custom lossy packets. | 343 | /* Set handlers for custom lossy packets. */ |
331 | * | ||
332 | * NOTE: Handler must return 0 if packet is to be relayed, -1 if the packet should not be relayed. | ||
333 | * | ||
334 | * Function(void *group object (set with group_set_object), uint32_t groupnumber, uint32_t friendgroupnumber, void *group peer object (set with group_peer_set_object), const uint8_t *packet, uint16_t length) | ||
335 | */ | ||
336 | void group_lossy_packet_registerhandler(Group_Chats *g_c, uint8_t byte, lossy_packet_cb *function); | 344 | void group_lossy_packet_registerhandler(Group_Chats *g_c, uint8_t byte, lossy_packet_cb *function); |
337 | 345 | ||
338 | /* High level function to send custom lossy packets. | 346 | /* High level function to send custom lossy packets. |
@@ -389,14 +397,14 @@ int group_set_object(const Group_Chats *g_c, uint32_t groupnumber, void *object) | |||
389 | */ | 397 | */ |
390 | int group_peer_set_object(const Group_Chats *g_c, uint32_t groupnumber, int peernumber, void *object); | 398 | int group_peer_set_object(const Group_Chats *g_c, uint32_t groupnumber, int peernumber, void *object); |
391 | 399 | ||
392 | /* Return the object tide to the group chat previously set by group_set_object. | 400 | /* Return the object tied to the group chat previously set by group_set_object. |
393 | * | 401 | * |
394 | * return NULL on failure. | 402 | * return NULL on failure. |
395 | * return object on success. | 403 | * return object on success. |
396 | */ | 404 | */ |
397 | void *group_get_object(const Group_Chats *g_c, uint32_t groupnumber); | 405 | void *group_get_object(const Group_Chats *g_c, uint32_t groupnumber); |
398 | 406 | ||
399 | /* Return the object tide to the group chat peer previously set by group_peer_set_object. | 407 | /* Return the object tied to the group chat peer previously set by group_peer_set_object. |
400 | * | 408 | * |
401 | * return NULL on failure. | 409 | * return NULL on failure. |
402 | * return object on success. | 410 | * return object on success. |
@@ -405,8 +413,6 @@ void *group_peer_get_object(const Group_Chats *g_c, uint32_t groupnumber, int pe | |||
405 | 413 | ||
406 | /* Set a function to be called when a new peer joins a group chat. | 414 | /* Set a function to be called when a new peer joins a group chat. |
407 | * | 415 | * |
408 | * Function(void *group object (set with group_set_object), int groupnumber, int friendgroupnumber) | ||
409 | * | ||
410 | * return 0 on success. | 416 | * return 0 on success. |
411 | * return -1 on failure. | 417 | * return -1 on failure. |
412 | */ | 418 | */ |
@@ -414,8 +420,6 @@ int callback_groupchat_peer_new(const Group_Chats *g_c, uint32_t groupnumber, pe | |||
414 | 420 | ||
415 | /* Set a function to be called when a peer leaves a group chat. | 421 | /* Set a function to be called when a peer leaves a group chat. |
416 | * | 422 | * |
417 | * Function(void *group object (set with group_set_object), uint32_t groupnumber, void *group peer object (set with group_peer_set_object)) | ||
418 | * | ||
419 | * return 0 on success. | 423 | * return 0 on success. |
420 | * return -1 on failure. | 424 | * return -1 on failure. |
421 | */ | 425 | */ |
@@ -423,8 +427,6 @@ int callback_groupchat_peer_delete(Group_Chats *g_c, uint32_t groupnumber, peer_ | |||
423 | 427 | ||
424 | /* Set a function to be called when the group chat is deleted. | 428 | /* Set a function to be called when the group chat is deleted. |
425 | * | 429 | * |
426 | * Function(void *group object (set with group_set_object), uint32_t groupnumber) | ||
427 | * | ||
428 | * return 0 on success. | 430 | * return 0 on success. |
429 | * return -1 on failure. | 431 | * return -1 on failure. |
430 | */ | 432 | */ |
diff --git a/toxcore/tox.api.h b/toxcore/tox.api.h index 3254db05..d1e01c74 100644 --- a/toxcore/tox.api.h +++ b/toxcore/tox.api.h | |||
@@ -2157,6 +2157,18 @@ namespace conference { | |||
2157 | 2157 | ||
2158 | 2158 | ||
2159 | /** | 2159 | /** |
2160 | * This event is triggered when the client successfully connects to a | ||
2161 | * conference after joining it with the $join function. | ||
2162 | */ | ||
2163 | event connected const { | ||
2164 | /** | ||
2165 | * @param conference_number The conference number of the conference to which we have connected. | ||
2166 | */ | ||
2167 | typedef void(uint32_t conference_number); | ||
2168 | } | ||
2169 | |||
2170 | |||
2171 | /** | ||
2160 | * This event is triggered when the client receives a conference message. | 2172 | * This event is triggered when the client receives a conference message. |
2161 | */ | 2173 | */ |
2162 | event message const { | 2174 | event message const { |
@@ -2313,6 +2325,10 @@ namespace conference { | |||
2313 | /** | 2325 | /** |
2314 | * Invites a friend to a conference. | 2326 | * Invites a friend to a conference. |
2315 | * | 2327 | * |
2328 | * We must be connected to the conference, meaning that the conference has not | ||
2329 | * been deleted, and either we created the conference with the $new function, | ||
2330 | * or a `${event connected}` event has occurred for the conference. | ||
2331 | * | ||
2316 | * @param friend_number The friend number of the friend we want to invite. | 2332 | * @param friend_number The friend number of the friend we want to invite. |
2317 | * @param conference_number The conference number of the conference we want to invite the friend to. | 2333 | * @param conference_number The conference number of the conference we want to invite the friend to. |
2318 | * | 2334 | * |
diff --git a/toxcore/tox.c b/toxcore/tox.c index f7bdba79..2ccbef82 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -91,6 +91,7 @@ struct Tox { | |||
91 | tox_file_recv_cb *file_recv_callback; | 91 | tox_file_recv_cb *file_recv_callback; |
92 | tox_file_recv_chunk_cb *file_recv_chunk_callback; | 92 | tox_file_recv_chunk_cb *file_recv_chunk_callback; |
93 | tox_conference_invite_cb *conference_invite_callback; | 93 | tox_conference_invite_cb *conference_invite_callback; |
94 | tox_conference_connected_cb *conference_connected_callback; | ||
94 | tox_conference_message_cb *conference_message_callback; | 95 | tox_conference_message_cb *conference_message_callback; |
95 | tox_conference_title_cb *conference_title_callback; | 96 | tox_conference_title_cb *conference_title_callback; |
96 | tox_conference_peer_name_cb *conference_peer_name_callback; | 97 | tox_conference_peer_name_cb *conference_peer_name_callback; |
@@ -247,6 +248,15 @@ static void tox_conference_invite_handler(Messenger *m, uint32_t friend_number, | |||
247 | } | 248 | } |
248 | } | 249 | } |
249 | 250 | ||
251 | static void tox_conference_connected_handler(Messenger *m, uint32_t conference_number, void *user_data) | ||
252 | { | ||
253 | struct Tox_Userdata *tox_data = (struct Tox_Userdata *)user_data; | ||
254 | |||
255 | if (tox_data->tox->conference_connected_callback != nullptr) { | ||
256 | tox_data->tox->conference_connected_callback(tox_data->tox, conference_number, tox_data->user_data); | ||
257 | } | ||
258 | } | ||
259 | |||
250 | static void tox_conference_message_handler(Messenger *m, uint32_t conference_number, uint32_t peer_number, int type, | 260 | static void tox_conference_message_handler(Messenger *m, uint32_t conference_number, uint32_t peer_number, int type, |
251 | const uint8_t *message, size_t length, void *user_data) | 261 | const uint8_t *message, size_t length, void *user_data) |
252 | { | 262 | { |
@@ -488,6 +498,7 @@ Tox *tox_new(const struct Tox_Options *options, Tox_Err_New *error) | |||
488 | callback_file_sendrequest(m, tox_file_recv_handler); | 498 | callback_file_sendrequest(m, tox_file_recv_handler); |
489 | callback_file_data(m, tox_file_recv_chunk_handler); | 499 | callback_file_data(m, tox_file_recv_chunk_handler); |
490 | g_callback_group_invite((Group_Chats *)m->conferences_object, tox_conference_invite_handler); | 500 | g_callback_group_invite((Group_Chats *)m->conferences_object, tox_conference_invite_handler); |
501 | g_callback_group_connected((Group_Chats *)m->conferences_object, tox_conference_connected_handler); | ||
491 | g_callback_group_message((Group_Chats *)m->conferences_object, tox_conference_message_handler); | 502 | g_callback_group_message((Group_Chats *)m->conferences_object, tox_conference_message_handler); |
492 | g_callback_group_title((Group_Chats *)m->conferences_object, tox_conference_title_handler); | 503 | g_callback_group_title((Group_Chats *)m->conferences_object, tox_conference_title_handler); |
493 | g_callback_peer_name((Group_Chats *)m->conferences_object, tox_conference_peer_name_handler); | 504 | g_callback_peer_name((Group_Chats *)m->conferences_object, tox_conference_peer_name_handler); |
@@ -1386,6 +1397,11 @@ void tox_callback_conference_invite(Tox *tox, tox_conference_invite_cb *callback | |||
1386 | tox->conference_invite_callback = callback; | 1397 | tox->conference_invite_callback = callback; |
1387 | } | 1398 | } |
1388 | 1399 | ||
1400 | void tox_callback_conference_connected(Tox *tox, tox_conference_connected_cb *callback) | ||
1401 | { | ||
1402 | tox->conference_connected_callback = callback; | ||
1403 | } | ||
1404 | |||
1389 | void tox_callback_conference_message(Tox *tox, tox_conference_message_cb *callback) | 1405 | void tox_callback_conference_message(Tox *tox, tox_conference_message_cb *callback) |
1390 | { | 1406 | { |
1391 | tox->conference_message_callback = callback; | 1407 | tox->conference_message_callback = callback; |
diff --git a/toxcore/tox.h b/toxcore/tox.h index badae42b..2739e1c4 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h | |||
@@ -2438,6 +2438,20 @@ typedef void tox_conference_invite_cb(Tox *tox, uint32_t friend_number, TOX_CONF | |||
2438 | void tox_callback_conference_invite(Tox *tox, tox_conference_invite_cb *callback); | 2438 | void tox_callback_conference_invite(Tox *tox, tox_conference_invite_cb *callback); |
2439 | 2439 | ||
2440 | /** | 2440 | /** |
2441 | * @param conference_number The conference number of the conference to which we have connected. | ||
2442 | */ | ||
2443 | typedef void tox_conference_connected_cb(Tox *tox, uint32_t conference_number, void *user_data); | ||
2444 | |||
2445 | |||
2446 | /** | ||
2447 | * Set the callback for the `conference_connected` event. Pass NULL to unset. | ||
2448 | * | ||
2449 | * This event is triggered when the client successfully connects to a | ||
2450 | * conference after joining it with the tox_conference_join function. | ||
2451 | */ | ||
2452 | void tox_callback_conference_connected(Tox *tox, tox_conference_connected_cb *callback); | ||
2453 | |||
2454 | /** | ||
2441 | * @param conference_number The conference number of the conference the message is intended for. | 2455 | * @param conference_number The conference number of the conference the message is intended for. |
2442 | * @param peer_number The ID of the peer who sent the message. | 2456 | * @param peer_number The ID of the peer who sent the message. |
2443 | * @param type The type of message (normal, action, ...). | 2457 | * @param type The type of message (normal, action, ...). |
@@ -2645,6 +2659,10 @@ typedef enum TOX_ERR_CONFERENCE_INVITE { | |||
2645 | /** | 2659 | /** |
2646 | * Invites a friend to a conference. | 2660 | * Invites a friend to a conference. |
2647 | * | 2661 | * |
2662 | * We must be connected to the conference, meaning that the conference has not | ||
2663 | * been deleted, and either we created the conference with the tox_conference_new function, | ||
2664 | * or a `conference_connected` event has occurred for the conference. | ||
2665 | * | ||
2648 | * @param friend_number The friend number of the friend we want to invite. | 2666 | * @param friend_number The friend number of the friend we want to invite. |
2649 | * @param conference_number The conference number of the conference we want to invite the friend to. | 2667 | * @param conference_number The conference number of the conference we want to invite the friend to. |
2650 | * | 2668 | * |