mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Delete close connection when peer leaves chat.
This commit is contained in:
parent
af0d6c0695
commit
7e8ab1b8fe
|
@ -434,6 +434,30 @@ static int addpeer(Group_Chats *g_c, int groupnumber, const uint8_t *real_pk, co
|
|||
return (g->numpeers - 1);
|
||||
}
|
||||
|
||||
static int remove_close_conn(Group_Chats *g_c, int groupnumber, int friendcon_id)
|
||||
{
|
||||
Group_c *g = get_group_c(g_c, groupnumber);
|
||||
|
||||
if (!g)
|
||||
return -1;
|
||||
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < MAX_GROUP_CONNECTIONS; ++i) {
|
||||
if (g->close[i].type == GROUPCHAT_CLOSE_NONE)
|
||||
continue;
|
||||
|
||||
if (g->close[i].number == friendcon_id) {
|
||||
g->close[i].type = GROUPCHAT_CLOSE_NONE;
|
||||
kill_friend_connection(g_c->fr_c, friendcon_id);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Delete a peer from the group chat.
|
||||
*
|
||||
|
@ -457,6 +481,12 @@ static int delpeer(Group_Chats *g_c, int groupnumber, int peer_index)
|
|||
}
|
||||
}
|
||||
|
||||
int friendcon_id = getfriend_conn_id_pk(g_c->fr_c, g->group[peer_index].real_pk);
|
||||
|
||||
if (friendcon_id != -1) {
|
||||
remove_close_conn(g_c, groupnumber, friendcon_id);
|
||||
}
|
||||
|
||||
Group_Peer *temp;
|
||||
--g->numpeers;
|
||||
|
||||
|
@ -533,29 +563,6 @@ static int settitle(Group_Chats *g_c, int groupnumber, int peer_index, const uin
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int remove_close_conn(Group_Chats *g_c, int groupnumber, int friendcon_id)
|
||||
{
|
||||
Group_c *g = get_group_c(g_c, groupnumber);
|
||||
|
||||
if (!g)
|
||||
return -1;
|
||||
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < MAX_GROUP_CONNECTIONS; ++i) {
|
||||
if (g->close[i].type == GROUPCHAT_CLOSE_NONE)
|
||||
continue;
|
||||
|
||||
if (g->close[i].number == friendcon_id) {
|
||||
g->close[i].type = GROUPCHAT_CLOSE_NONE;
|
||||
kill_friend_connection(g_c->fr_c, friendcon_id);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void set_conns_type_close(Group_Chats *g_c, int groupnumber, int friendcon_id, uint8_t type)
|
||||
{
|
||||
Group_c *g = get_group_c(g_c, groupnumber);
|
||||
|
|
Loading…
Reference in New Issue
Block a user