summaryrefslogtreecommitdiff
path: root/protocols/Tox/src/tox_events.cpp
blob: e372b9ee392254f0bc8fcb368cfb804c6bcc21cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "common.h"

int CToxProto::OnContactDeleted(MCONTACT hContact, LPARAM)
{
	if (!IsOnline())
	{
		return 1;
	}

	ToxBinAddress pubKey = ptrA(getStringA(hContact, TOX_SETTINGS_ID));
	if (!isChatRoom(hContact))
	{
		int32_t friendNumber = tox_get_friend_number(tox, pubKey);
		if (friendNumber == TOX_ERROR || tox_del_friend(tox, friendNumber) == TOX_ERROR)
		{
			return 1;
		}
	}
	else
	{
		OnLeaveChatRoom(hContact, 0);
		int groupNumber = 0; // ???
		if (groupNumber == TOX_ERROR || tox_del_groupchat(tox, groupNumber) == TOX_ERROR)
		{
			return 1;
		}
	}

	return 0;
}