From 81ce57622c3166830b23eae534dacc6b008c659d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 28 Mar 2018 16:34:30 +0300 Subject: common protocol instance management code went into template --- protocols/MRA/src/Mra.cpp | 30 ++---------------------------- protocols/MRA/src/MraProto.cpp | 2 +- protocols/MRA/src/MraProto.h | 7 +++++++ protocols/MRA/src/Mra_proto.cpp | 2 +- protocols/MRA/src/stdafx.h | 9 --------- 5 files changed, 11 insertions(+), 39 deletions(-) (limited to 'protocols/MRA') diff --git a/protocols/MRA/src/Mra.cpp b/protocols/MRA/src/Mra.cpp index 49eded7d0a..79dfebf977 100644 --- a/protocols/MRA/src/Mra.cpp +++ b/protocols/MRA/src/Mra.cpp @@ -1,9 +1,9 @@ #include "stdafx.h" -LIST g_Instances(1, PtrKeySortT); +CMPlugin g_plugin; -CLIST_INTERFACE *pcli; int hLangpack; +CLIST_INTERFACE *pcli; PLUGININFOEX pluginInfoEx = { sizeof(PLUGININFOEX), @@ -78,29 +78,3 @@ extern "C" __declspec(dllexport) int Unload(void) return 0; } - -///////////////////////////////////////////////////////////////////////////////////////// - -static PROTO_INTERFACE* mraProtoInit(const char* pszProtoName, const wchar_t* tszUserName) -{ - CMraProto *ppro = new CMraProto(pszProtoName, tszUserName); - g_Instances.insert(ppro); - return ppro; -} - -static int mraProtoUninit(PROTO_INTERFACE *ppro) -{ - g_Instances.remove((CMraProto*)ppro); - delete (CMraProto*)ppro; - return 0; -} - -struct CMPlugin : public CMPluginBase -{ - CMPlugin() : - CMPluginBase("MRA") - { - RegisterProtocol(PROTOTYPE_PROTOCOL, mraProtoInit, mraProtoUninit); - } -} - g_plugin; diff --git a/protocols/MRA/src/MraProto.cpp b/protocols/MRA/src/MraProto.cpp index 5fd2a0f03f..89f2046dae 100644 --- a/protocols/MRA/src/MraProto.cpp +++ b/protocols/MRA/src/MraProto.cpp @@ -2,7 +2,7 @@ static int MraExtraIconsApplyAll(WPARAM, LPARAM) { - for (auto &it : g_Instances) + for (auto &it : CMPlugin::g_arInstances) it->MraExtraIconsApply(0, 0); return 0; } diff --git a/protocols/MRA/src/MraProto.h b/protocols/MRA/src/MraProto.h index a9a95fbc07..b6f2bede82 100644 --- a/protocols/MRA/src/MraProto.h +++ b/protocols/MRA/src/MraProto.h @@ -339,3 +339,10 @@ struct CMraProto : public PROTO void __cdecl MraAvatarsThreadProc(LPVOID lpParameter); }; + +struct CMPlugin : public ACCPROTOPLUGIN +{ + CMPlugin() : + ACCPROTOPLUGIN("MRA") + {} +}; diff --git a/protocols/MRA/src/Mra_proto.cpp b/protocols/MRA/src/Mra_proto.cpp index 35faa0405c..bad5ab3340 100644 --- a/protocols/MRA/src/Mra_proto.cpp +++ b/protocols/MRA/src/Mra_proto.cpp @@ -1647,7 +1647,7 @@ DWORD CMraProto::MraRecvCommand_Message(DWORD dwTime, DWORD dwFlags, CMStringA & debugLogA("Processing message: %08X, from '%s', text '%S'\n", dwFlags, plpsFrom.c_str(), wszMessage.c_str()); // processing - if (dwFlags & (MESSAGE_FLAG_SMS | MESSAGE_SMS_DELIVERY_REPORT)) {// SMS //if (IsPhone(plpsFrom->lpszData, plpsFrom->dwSize)) + if (dwFlags & (MESSAGE_FLAG_SMS | MESSAGE_SMS_DELIVERY_REPORT)) { // SMS INTERNET_TIME itTime; InternetTimeGetCurrentTime(&itTime); CMStringA szTime = InternetTimeGetString(&itTime); diff --git a/protocols/MRA/src/stdafx.h b/protocols/MRA/src/stdafx.h index dd94bdfbb9..df92980ad9 100644 --- a/protocols/MRA/src/stdafx.h +++ b/protocols/MRA/src/stdafx.h @@ -169,12 +169,8 @@ extern WCHAR g_szMirWorkDirPath[MAX_FILEPATH]; ///////////////////////////////////////////////////////////////////////////////////////// // External variables -extern LIST g_Instances; - extern HANDLE hXStatusAdvancedStatusIcons[]; -void InitExtraIcons(); - CMStringA MraGetSelfVersionString(); #define SetBit(bytes, bitpos) bytes |= (1<