Delete close connection when peer leaves chat.

This commit is contained in:
irungentoo 2014-12-08 13:50:38 -05:00
parent af0d6c0695
commit 7e8ab1b8fe
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98

View File

@ -434,6 +434,30 @@ static int addpeer(Group_Chats *g_c, int groupnumber, const uint8_t *real_pk, co
return (g->numpeers - 1); 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. * 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; Group_Peer *temp;
--g->numpeers; --g->numpeers;
@ -533,29 +563,6 @@ static int settitle(Group_Chats *g_c, int groupnumber, int peer_index, const uin
return 0; 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) 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); Group_c *g = get_group_c(g_c, groupnumber);