diff options
author | George Hazan <ghazan@miranda.im> | 2018-03-28 16:34:30 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-03-28 16:34:30 +0300 |
commit | 81ce57622c3166830b23eae534dacc6b008c659d (patch) | |
tree | 6d6ac74667f733a20b94fa27cc01c2f45688c533 /protocols/IcqOscarJ | |
parent | c2bb7727483b9b5620e8cc0ce6adae35ee78d0a4 (diff) |
common protocol instance management code went into template
Diffstat (limited to 'protocols/IcqOscarJ')
-rw-r--r-- | protocols/IcqOscarJ/src/icq_menu.cpp | 28 | ||||
-rw-r--r-- | protocols/IcqOscarJ/src/icq_proto.h | 7 | ||||
-rw-r--r-- | protocols/IcqOscarJ/src/init.cpp | 26 | ||||
-rw-r--r-- | protocols/IcqOscarJ/src/stdafx.h | 1 |
4 files changed, 12 insertions, 50 deletions
diff --git a/protocols/IcqOscarJ/src/icq_menu.cpp b/protocols/IcqOscarJ/src/icq_menu.cpp index 97fa93ab52..827f3e9c09 100644 --- a/protocols/IcqOscarJ/src/icq_menu.cpp +++ b/protocols/IcqOscarJ/src/icq_menu.cpp @@ -30,41 +30,21 @@ HGENMENU g_hContactMenuItems[3];
HANDLE g_hContactMenuSvc[3];
-static int sttCompareProtocols(const CIcqProto *p1, const CIcqProto *p2)
-{
- return mir_strcmp(p1->m_szModuleName, p2->m_szModuleName);
-}
-
-LIST<CIcqProto> g_Instances(1, sttCompareProtocols);
-
-static CIcqProto* IcqGetInstanceByHContact(MCONTACT hContact)
-{
- char* szProto = GetContactProto(hContact);
- if (szProto == nullptr)
- return nullptr;
-
- for (auto &it : g_Instances)
- if (!mir_strcmp(szProto, it->m_szModuleName))
- return it;
-
- return nullptr;
-}
-
static INT_PTR IcqMenuHandleAddServContact(WPARAM wParam, LPARAM lParam)
{
- CIcqProto* ppro = IcqGetInstanceByHContact(wParam);
+ CIcqProto* ppro = CMPlugin::getInstance(wParam);
return (ppro) ? ppro->AddServerContact(wParam, lParam) : 0;
}
static INT_PTR IcqMenuHandleXStatusDetails(WPARAM wParam, LPARAM lParam)
{
- CIcqProto* ppro = IcqGetInstanceByHContact(wParam);
+ CIcqProto* ppro = CMPlugin::getInstance(wParam);
return (ppro) ? ppro->ShowXStatusDetails(wParam, lParam) : 0;
}
static INT_PTR IcqMenuHandleOpenProfile(WPARAM wParam, LPARAM lParam)
{
- CIcqProto* ppro = IcqGetInstanceByHContact(wParam);
+ CIcqProto* ppro = CMPlugin::getInstance(wParam);
return (ppro) ? ppro->OpenWebProfile(wParam, lParam) : 0;
}
@@ -74,7 +54,7 @@ static int IcqPrebuildContactMenu( WPARAM wParam, LPARAM lParam ) Menu_ShowItem(g_hContactMenuItems[ICMI_XSTATUS_DETAILS], FALSE);
Menu_ShowItem(g_hContactMenuItems[ICMI_OPEN_PROFILE], FALSE);
- CIcqProto* ppro = IcqGetInstanceByHContact(wParam);
+ CIcqProto* ppro = CMPlugin::getInstance(wParam);
return (ppro) ? ppro->OnPreBuildContactMenu(wParam, lParam) : 0;
}
diff --git a/protocols/IcqOscarJ/src/icq_proto.h b/protocols/IcqOscarJ/src/icq_proto.h index 004a7148ed..08fff03c9e 100644 --- a/protocols/IcqOscarJ/src/icq_proto.h +++ b/protocols/IcqOscarJ/src/icq_proto.h @@ -895,4 +895,11 @@ struct CIcqProto : public PROTO<CIcqProto> bool validateStatusMessageRequest(MCONTACT hContact, WORD byMessageType);
};
+struct CMPlugin : public ACCPROTOPLUGIN<CIcqProto>
+{
+ CMPlugin() :
+ ACCPROTOPLUGIN<CIcqProto>(ICQ_PROTOCOL_NAME)
+ {}
+};
+
#endif
diff --git a/protocols/IcqOscarJ/src/init.cpp b/protocols/IcqOscarJ/src/init.cpp index fb53d2312e..46e5b68c17 100644 --- a/protocols/IcqOscarJ/src/init.cpp +++ b/protocols/IcqOscarJ/src/init.cpp @@ -28,6 +28,7 @@ #include "m_extraicons.h"
#include "m_icolib.h"
+CMPlugin g_plugin;
HINSTANCE hInst;
int hLangpack;
CLIST_INTERFACE *pcli;
@@ -161,28 +162,3 @@ void CIcqProto::UpdateGlobalSettings() m_bMoodsEnabled = getByte("MoodsEnabled", DEFAULT_MOODS_ENABLED);
}
-/////////////////////////////////////////////////////////////////////////////////////////
-
-static PROTO_INTERFACE* icqProtoInit(const char* pszProtoName, const wchar_t* tszUserName)
-{
- CIcqProto *ppro = new CIcqProto(pszProtoName, tszUserName);
- g_Instances.insert(ppro);
- return ppro;
-}
-
-static int icqProtoUninit(PROTO_INTERFACE* ppro)
-{
- g_Instances.remove((CIcqProto*)ppro);
- delete (CIcqProto*)ppro;
- return 0;
-}
-
-struct CMPlugin : public CMPluginBase
-{
- CMPlugin() :
- CMPluginBase(ICQ_PROTOCOL_NAME)
- {
- RegisterProtocol(PROTOTYPE_PROTOCOL, icqProtoInit, icqProtoUninit);
- }
-}
- g_plugin;
diff --git a/protocols/IcqOscarJ/src/stdafx.h b/protocols/IcqOscarJ/src/stdafx.h index 61877a2a58..303c6f363e 100644 --- a/protocols/IcqOscarJ/src/stdafx.h +++ b/protocols/IcqOscarJ/src/stdafx.h @@ -118,6 +118,5 @@ #include "icq_popups.h"
#include "icq_proto.h"
-extern LIST<CIcqProto> g_Instances;
extern bool g_bTerminated;
extern IconItem iconList[];
\ No newline at end of file |