diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2014-08-07 13:49:07 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2014-08-07 13:49:07 +0000 |
commit | 84f85ceac0f993be95dda89584749ea59fe5b8e7 (patch) | |
tree | 2231a79773b63436a9586f6cf1f35f1893c80793 /protocols/Tox/src/tox_instances.cpp | |
parent | c56192dd999c079ebd935a6736315de3a5d60a05 (diff) |
Tox added from branch
git-svn-id: http://svn.miranda-ng.org/main/trunk@10115 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src/tox_instances.cpp')
-rw-r--r-- | protocols/Tox/src/tox_instances.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/protocols/Tox/src/tox_instances.cpp b/protocols/Tox/src/tox_instances.cpp new file mode 100644 index 0000000000..ea010f894a --- /dev/null +++ b/protocols/Tox/src/tox_instances.cpp @@ -0,0 +1,44 @@ +#include "common.h"
+
+LIST<CToxProto> CToxProto::instanceList(1, CToxProto::CompareProtos);
+
+int CToxProto::CompareProtos(const CToxProto *p1, const CToxProto *p2)
+{
+ return wcscmp(p1->m_tszUserName, p2->m_tszUserName);
+}
+
+CToxProto* CToxProto::InitProtoInstance(const char* protoName, const wchar_t* userName)
+{
+ CToxProto *ppro = new CToxProto(protoName, userName);
+ CToxProto::instanceList.insert(ppro);
+
+ return ppro;
+}
+
+int CToxProto::UninitProtoInstance(CToxProto* ppro)
+{
+ CToxProto::instanceList.remove(ppro);
+
+ delete ppro;
+
+ return 0;
+}
+
+void CToxProto::UninitInstances()
+{
+ CToxProto::instanceList.destroy();
+}
+
+CToxProto* CToxProto::GetContactInstance(MCONTACT hContact)
+{
+ char *proto = (char *)::CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+
+ if (proto == NULL)
+ return NULL;
+
+ for (int i = 0; i < CToxProto::instanceList.getCount(); i++)
+ if ( !::strcmp(proto, CToxProto::instanceList[i]->m_szModuleName))
+ return CToxProto::instanceList[i];
+
+ return NULL;
+}
\ No newline at end of file |