summaryrefslogtreecommitdiff
path: root/protocols/Tox/src/tox_accounts.cpp
blob: afcac8e4a6639ebc329bb741a82604611776d393 (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
31
32
33
#include "common.h"

LIST<CToxProto> CToxProto::accounts(1, CToxProto::CompareAccounts);

int CToxProto::CompareAccounts(const CToxProto *p1, const CToxProto *p2)
{
	return _tcscmp(p1->m_tszUserName, p2->m_tszUserName);
}

CToxProto* CToxProto::InitAccount(const char *protoName, const wchar_t *userName)
{
	ptrA address(db_get_sa(NULL, protoName, TOX_SETTINGS_ID));
	if (address == NULL)
	{
		DialogBoxParam(
			g_hInstance,
			MAKEINTRESOURCE(IDD_PROFILE_IMPORT),
			GetActiveWindow(),
			CToxProto::ToxProfileImportProc,
			(LPARAM)userName);
	}

	CToxProto *proto = new CToxProto(protoName, userName);
	return proto;
}

int CToxProto::UninitAccount(CToxProto *proto)
{
	accounts.remove(proto);
	delete proto;

	return 0;
}