summaryrefslogtreecommitdiff
path: root/protocols/Steam/src/steam_accounts.cpp
blob: 43ec787c5f89b34c69db5d3f534483fd55a67376 (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
34
35
#include "stdafx.h"

LIST<CSteamProto> CSteamProto::Accounts(1, CSteamProto::CompareProtos);

int CSteamProto::CompareProtos(const CSteamProto *p1, const CSteamProto *p2)
{
	return mir_wstrcmp(p1->m_tszUserName, p2->m_tszUserName);
}

CSteamProto* CSteamProto::InitAccount(const char* protoName, const wchar_t* userName)
{
	CSteamProto *ppro = new CSteamProto(protoName, userName);
	Accounts.insert(ppro);
	return ppro;
}

int CSteamProto::UninitAccount(CSteamProto* ppro)
{
	Accounts.remove(ppro);
	delete ppro;
	return 0;
}

CSteamProto* CSteamProto::GetContactAccount(MCONTACT hContact)
{
	char *proto = GetContactProto(hContact);
	if (proto == nullptr)
		return nullptr;

	for (int i = 0; i < Accounts.getCount(); i++)
		if (!mir_strcmp(proto, Accounts[i]->m_szModuleName))
			return Accounts[i];

	return nullptr;
}