summaryrefslogtreecommitdiff
path: root/toxcore/group.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/group.c')
-rw-r--r--toxcore/group.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/toxcore/group.c b/toxcore/group.c
index d94349f4..96f5ba2f 100644
--- a/toxcore/group.c
+++ b/toxcore/group.c
@@ -398,8 +398,10 @@ static int addpeer(Group_Chats *g_c, int groupnumber, const uint8_t *real_pk, co
398 ++g->numpeers; 398 ++g->numpeers;
399 399
400 add_to_closest(g_c, groupnumber, real_pk, temp_pk); 400 add_to_closest(g_c, groupnumber, real_pk, temp_pk);
401 //if (g->peer_namelistchange != NULL) 401
402 // (*g->peer_namelistchange)(g, g->numpeers - 1, CHAT_CHANGE_PEER_ADD, g->group_namelistchange_userdata); 402 if (g_c->peer_namelistchange)
403 g_c->peer_namelistchange(g_c->m, groupnumber, g->numpeers - 1, CHAT_CHANGE_PEER_ADD,
404 g_c->group_namelistchange_userdata);
403 405
404 return (g->numpeers - 1); 406 return (g->numpeers - 1);
405} 407}
@@ -445,11 +447,10 @@ static int delpeer(Group_Chats *g_c, int groupnumber, int peer_index)
445 return -1; 447 return -1;
446 448
447 g->group = temp; 449 g->group = temp;
448 /* 450
449 if (g->peer_namelistchange != NULL) { 451 if (g_c->peer_namelistchange)
450 (*g->peer_namelistchange)(g, peer_index, CHAT_CHANGE_PEER_DEL, g->group_namelistchange_userdata); 452 g_c->peer_namelistchange(g_c->m, groupnumber, peer_index, CHAT_CHANGE_PEER_DEL, g_c->group_namelistchange_userdata);
451 } 453
452 */
453 return 0; 454 return 0;
454} 455}
455 456
@@ -781,6 +782,18 @@ void g_callback_group_message(Group_Chats *g_c, void (*function)(Messenger *m, i
781 g_c->message_callback_userdata = userdata; 782 g_c->message_callback_userdata = userdata;
782} 783}
783 784
785/* Set callback function for peer name list changes.
786 *
787 * It gets called every time the name list changes(new peer/name, deleted peer)
788 * Function(Group_Chats *g_c, int groupnumber, int peernumber, TOX_CHAT_CHANGE change, void *userdata)
789 */
790void g_callback_group_namelistchange(Group_Chats *g_c, void (*function)(Messenger *m, int, int, uint8_t, void *),
791 void *userdata)
792{
793 g_c->peer_namelistchange = function;
794 g_c->group_namelistchange_userdata = userdata;
795}
796
784static unsigned int send_message_group(const Group_Chats *g_c, int groupnumber, uint8_t message_id, const uint8_t *data, 797static unsigned int send_message_group(const Group_Chats *g_c, int groupnumber, uint8_t message_id, const uint8_t *data,
785 uint16_t len); 798 uint16_t len);
786 799