diff options
Diffstat (limited to 'protocols/Tox/src')
-rw-r--r-- | protocols/Tox/src/main.cpp | 13 | ||||
-rw-r--r-- | protocols/Tox/src/tox_accounts.cpp | 30 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.h | 16 | ||||
-rw-r--r-- | protocols/Tox/src/tox_utils.cpp | 4 |
4 files changed, 10 insertions, 53 deletions
diff --git a/protocols/Tox/src/main.cpp b/protocols/Tox/src/main.cpp index 8cf2c4b80d..9022f56569 100644 --- a/protocols/Tox/src/main.cpp +++ b/protocols/Tox/src/main.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" int hLangpack; +CMPlugin g_plugin; CHAT_MANAGER *pci; CLIST_INTERFACE *pcli; HINSTANCE g_hInstance; @@ -63,15 +64,3 @@ extern "C" int __declspec(dllexport) Unload(void) { return 0; } - -///////////////////////////////////////////////////////////////////////////////////////// - -struct CMPlugin : public CMPluginBase -{ - CMPlugin() : - CMPluginBase("TOX") - { - RegisterProtocol(PROTOTYPE_PROTOCOL, (pfnInitProto)CToxProto::InitAccount, (pfnUninitProto)CToxProto::UninitAccount); - } -} - g_plugin; diff --git a/protocols/Tox/src/tox_accounts.cpp b/protocols/Tox/src/tox_accounts.cpp index d70d6bad54..c9cb35c921 100644 --- a/protocols/Tox/src/tox_accounts.cpp +++ b/protocols/Tox/src/tox_accounts.cpp @@ -1,35 +1,5 @@ #include "stdafx.h"
-LIST<CToxProto> CToxProto::Accounts(1, CToxProto::CompareAccounts);
-
-int CToxProto::CompareAccounts(const CToxProto *p1, const CToxProto *p2)
-{
- return mir_wstrcmp(p1->m_tszUserName, p2->m_tszUserName);
-}
-
-CToxProto* CToxProto::InitAccount(const char *protoName, const wchar_t *userName)
-{
- CToxProto *proto = new CToxProto(protoName, userName);
- Accounts.insert(proto);
- return proto;
-}
-
-int CToxProto::UninitAccount(CToxProto *proto)
-{
- Accounts.remove(proto);
- delete proto;
- return 0;
-}
-
-CToxProto* CToxProto::GetContactAccount(MCONTACT hContact)
-{
- for (auto &it : Accounts)
- if (mir_strcmpi(GetContactProto(hContact), it->m_szModuleName) == 0)
- return it;
-
- return nullptr;
-}
-
int CToxProto::OnAccountLoaded(WPARAM, LPARAM)
{
Clist_GroupCreate(0, m_defaultGroup);
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index 8a4fd782cd..ac71b30686 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -48,10 +48,6 @@ public: virtual int __cdecl OnEvent(PROTOEVENTTYPE iEventType, WPARAM wParam, LPARAM lParam);
- // accounts
- static CToxProto* InitAccount(const char *protoName, const wchar_t *userName);
- static int UninitAccount(CToxProto *proto);
-
// icons
static void InitIcons();
@@ -116,11 +112,6 @@ private: void __cdecl PollingThread(void*);
// accounts
- static LIST<CToxProto> Accounts;
- static int CompareAccounts(const CToxProto *p1, const CToxProto *p2);
-
- static CToxProto* GetContactAccount(MCONTACT hContact);
-
int __cdecl OnAccountLoaded(WPARAM, LPARAM);
int __cdecl OnAccountRenamed(WPARAM, LPARAM);
@@ -256,4 +247,11 @@ private: MEVENT AddEventToDb(MCONTACT hContact, WORD type, DWORD timestamp, DWORD flags, PBYTE pBlob, size_t cbBlob);
};
+struct CMPlugin : public ACCPROTOPLUGIN<CToxProto>
+{
+ CMPlugin() :
+ ACCPROTOPLUGIN<CToxProto>("TOX")
+ {}
+};
+
#endif //_TOX_PROTO_H_
\ No newline at end of file diff --git a/protocols/Tox/src/tox_utils.cpp b/protocols/Tox/src/tox_utils.cpp index d7c2d1408b..231a2b2106 100644 --- a/protocols/Tox/src/tox_utils.cpp +++ b/protocols/Tox/src/tox_utils.cpp @@ -146,11 +146,11 @@ INT_PTR CToxProto::ParseToxUri(WPARAM, LPARAM lParam) if (mir_wstrlen(uri) <= 4)
return 1;
- if (Accounts.getCount() == 0)
+ if (CMPlugin::g_arInstances.getCount() == 0)
return 1;
CToxProto *proto = nullptr;
- for (auto &it : Accounts) {
+ for (auto &it : CMPlugin::g_arInstances) {
if (it->IsOnline()) {
proto = it;
break;
|