summaryrefslogtreecommitdiff
path: root/toxcore/group.c
diff options
context:
space:
mode:
authorzugz (tox) <mbays+tox@sdf.org>2018-08-02 19:23:34 +0100
committerzugz (tox) <mbays+tox@sdf.org>2018-08-12 22:46:06 +0200
commitd56ab5aaff5fab7ac707a5c914d3701f43eb2ba3 (patch)
tree161278ec297d281d1c39f1f337fe67eb52865c4c /toxcore/group.c
parent4ed6e5999226f9061f546108c5be72fe6f21a775 (diff)
add callback for successful connection to a conference
Diffstat (limited to 'toxcore/group.c')
-rw-r--r--toxcore/group.c46
1 files changed, 15 insertions, 31 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 */
1183void group_lossy_packet_registerhandler(Group_Chats *g_c, uint8_t byte, lossy_packet_cb *function) 1178void 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 */
1194void g_callback_group_invite(Group_Chats *g_c, g_conference_invite_cb *function) 1184void 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. 1190void 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. */
1204void g_callback_group_message(Group_Chats *g_c, g_conference_message_cb *function) 1196void 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 */
1214void g_callback_peer_name(Group_Chats *g_c, peer_name_cb *function) 1205void 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 */
1224void g_callback_peer_list_changed(Group_Chats *g_c, peer_list_changed_cb *function) 1214void 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 */
1235void g_callback_group_title(Group_Chats *g_c, title_cb *function) 1220void 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