mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Implemented tox_callback_group_namelist_change callback in group chats.
No names yet though.
This commit is contained in:
parent
c7b3b7acbd
commit
26d119a17b
|
@ -398,8 +398,10 @@ static int addpeer(Group_Chats *g_c, int groupnumber, const uint8_t *real_pk, co
|
|||
++g->numpeers;
|
||||
|
||||
add_to_closest(g_c, groupnumber, real_pk, temp_pk);
|
||||
//if (g->peer_namelistchange != NULL)
|
||||
// (*g->peer_namelistchange)(g, g->numpeers - 1, CHAT_CHANGE_PEER_ADD, g->group_namelistchange_userdata);
|
||||
|
||||
if (g_c->peer_namelistchange)
|
||||
g_c->peer_namelistchange(g_c->m, groupnumber, g->numpeers - 1, CHAT_CHANGE_PEER_ADD,
|
||||
g_c->group_namelistchange_userdata);
|
||||
|
||||
return (g->numpeers - 1);
|
||||
}
|
||||
|
@ -445,11 +447,10 @@ static int delpeer(Group_Chats *g_c, int groupnumber, int peer_index)
|
|||
return -1;
|
||||
|
||||
g->group = temp;
|
||||
/*
|
||||
if (g->peer_namelistchange != NULL) {
|
||||
(*g->peer_namelistchange)(g, peer_index, CHAT_CHANGE_PEER_DEL, g->group_namelistchange_userdata);
|
||||
}
|
||||
*/
|
||||
|
||||
if (g_c->peer_namelistchange)
|
||||
g_c->peer_namelistchange(g_c->m, groupnumber, peer_index, CHAT_CHANGE_PEER_DEL, g_c->group_namelistchange_userdata);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -781,6 +782,18 @@ void g_callback_group_message(Group_Chats *g_c, void (*function)(Messenger *m, i
|
|||
g_c->message_callback_userdata = userdata;
|
||||
}
|
||||
|
||||
/* 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)
|
||||
{
|
||||
g_c->peer_namelistchange = function;
|
||||
g_c->group_namelistchange_userdata = userdata;
|
||||
}
|
||||
|
||||
static unsigned int send_message_group(const Group_Chats *g_c, int groupnumber, uint8_t message_id, const uint8_t *data,
|
||||
uint16_t len);
|
||||
|
||||
|
|
|
@ -103,6 +103,8 @@ typedef struct {
|
|||
void *invite_callback_userdata;
|
||||
void (*message_callback)(Messenger *m, int, int, const uint8_t *, uint16_t, void *);
|
||||
void *message_callback_userdata;
|
||||
void (*peer_namelistchange)(Messenger *m, int, int, uint8_t, void *);
|
||||
void *group_namelistchange_userdata;
|
||||
} Group_Chats;
|
||||
|
||||
/* Set the callback for group invites.
|
||||
|
@ -131,8 +133,13 @@ void g_callback_group_action(Group_Chats *g_c, void (*function)(Messenger *m, in
|
|||
/* 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, void *userdata)
|
||||
* Function(Group_Chats *g_c, int groupnumber, int peernumber, TOX_CHAT_CHANGE change, void *userdata)
|
||||
*/
|
||||
enum {
|
||||
CHAT_CHANGE_PEER_ADD,
|
||||
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);
|
||||
|
||||
|
|
|
@ -586,7 +586,7 @@ void tox_callback_group_action(Tox *tox, void (*function)(Messenger *tox, int, i
|
|||
void tox_callback_group_namelist_change(Tox *tox, void (*function)(Tox *tox, int, int, uint8_t, void *), void *userdata)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
//m_callback_group_namelistchange(m, function, userdata);
|
||||
g_callback_group_namelistchange(m->group_chat_object, function, userdata);
|
||||
}
|
||||
|
||||
/* Creates a new groupchat and puts it in the chats array.
|
||||
|
|
Loading…
Reference in New Issue
Block a user