summaryrefslogtreecommitdiff
path: root/toxcore
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore')
-rw-r--r--toxcore/group.c13
-rw-r--r--toxcore/group.h9
2 files changed, 11 insertions, 11 deletions
diff --git a/toxcore/group.c b/toxcore/group.c
index 2645416b..5b5455c8 100644
--- a/toxcore/group.c
+++ b/toxcore/group.c
@@ -933,16 +933,15 @@ void g_callback_group_action(Group_Chats *g_c, void (*function)(Messenger *m, in
933} 933}
934 934
935/* Set handlers for custom lossy packets. 935/* Set handlers for custom lossy packets.
936 *
936 * NOTE: Handler must return 0 if packet is to be relayed, -1 if the packet should not be relayed. 937 * NOTE: Handler must return 0 if packet is to be relayed, -1 if the packet should not be relayed.
937 * 938 *
938 * return -1 on failure. 939 * Function(void *group object (set with group_set_object), int groupnumber, int friendgroupnumber, void *group peer object (set with group_peer_set_object), const uint8_t *packet, uint16_t length)
939 * return 0 on success.
940 */ 940 */
941void group_lossy_packet_registerhandler(Group_Chats *g_c, uint8_t byte, int (*function)(Messenger *m, int, int, 941void group_lossy_packet_registerhandler(Group_Chats *g_c, uint8_t byte, int (*function)(void *, int, int, void *,
942 const uint8_t *, uint16_t, void *), void *userdata) 942 const uint8_t *, uint16_t))
943{ 943{
944 g_c->lossy_packethandlers[byte].function = function; 944 g_c->lossy_packethandlers[byte].function = function;
945 g_c->lossy_packethandlers[byte].userdata = userdata;
946} 945}
947 946
948/* Set callback function for peer name list changes. 947/* Set callback function for peer name list changes.
@@ -1814,8 +1813,8 @@ static int handle_lossy(void *object, int friendcon_id, const uint8_t *data, uin
1814 --lossy_length; 1813 --lossy_length;
1815 1814
1816 if (g_c->lossy_packethandlers[message_id].function) { 1815 if (g_c->lossy_packethandlers[message_id].function) {
1817 if (g_c->lossy_packethandlers[message_id].function(g_c->m, groupnumber, index, lossy_data, lossy_length, 1816 if (g_c->lossy_packethandlers[message_id].function(g->object, groupnumber, index, g->group[peer_index].object,
1818 g_c->lossy_packethandlers[message_id].userdata) == -1) { 1817 lossy_data, lossy_length) == -1) {
1819 return -1; 1818 return -1;
1820 } 1819 }
1821 } else { 1820 } else {
diff --git a/toxcore/group.h b/toxcore/group.h
index aa888b33..1a51f83b 100644
--- a/toxcore/group.h
+++ b/toxcore/group.h
@@ -117,8 +117,7 @@ typedef struct {
117 void *group_namelistchange_userdata; 117 void *group_namelistchange_userdata;
118 118
119 struct { 119 struct {
120 int (*function)(Messenger *m, int, int, const uint8_t *, uint16_t, void *); 120 int (*function)(void *, int, int, void *, const uint8_t *, uint16_t);
121 void *userdata;
122 } lossy_packethandlers[256]; 121 } lossy_packethandlers[256];
123} Group_Chats; 122} Group_Chats;
124 123
@@ -231,9 +230,11 @@ int group_names(const Group_Chats *g_c, int groupnumber, uint8_t names[][MAX_NAM
231/* Set handlers for custom lossy packets. 230/* Set handlers for custom lossy packets.
232 * 231 *
233 * NOTE: Handler must return 0 if packet is to be relayed, -1 if the packet should not be relayed. 232 * NOTE: Handler must return 0 if packet is to be relayed, -1 if the packet should not be relayed.
233 *
234 * Function(void *group object (set with group_set_object), int groupnumber, int friendgroupnumber, void *group peer object (set with group_peer_set_object), const uint8_t *packet, uint16_t length)
234 */ 235 */
235void group_lossy_packet_registerhandler(Group_Chats *g_c, uint8_t byte, int (*function)(Messenger *m, int, int, 236void group_lossy_packet_registerhandler(Group_Chats *g_c, uint8_t byte, int (*function)(void *, int, int, void *,
236 const uint8_t *, uint16_t, void *), void *userdata); 237 const uint8_t *, uint16_t));
237 238
238/* High level function to send custom lossy packets. 239/* High level function to send custom lossy packets.
239 * 240 *