summaryrefslogtreecommitdiff
path: root/protocols/Steam/src/steam_accounts.cpp
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2018-01-14 22:02:44 +0300
committeraunsane <aunsane@gmail.com>2018-01-14 22:03:16 +0300
commit7cb1539b0dbcf585472dd2341129adf174bb0bb5 (patch)
tree6879adfdd3ebf5f64557525df118e0753969fd95 /protocols/Steam/src/steam_accounts.cpp
parenta6b0d0df4854ffda2577e2b61844467253eb9e0f (diff)
Steam: refactoring pt.2
Diffstat (limited to 'protocols/Steam/src/steam_accounts.cpp')
-rw-r--r--protocols/Steam/src/steam_accounts.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/protocols/Steam/src/steam_accounts.cpp b/protocols/Steam/src/steam_accounts.cpp
new file mode 100644
index 0000000000..43ec787c5f
--- /dev/null
+++ b/protocols/Steam/src/steam_accounts.cpp
@@ -0,0 +1,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;
+} \ No newline at end of file