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/Gadu-Gadu/src/gg.cpp | |
parent | c2bb7727483b9b5620e8cc0ce6adae35ee78d0a4 (diff) |
common protocol instance management code went into template
Diffstat (limited to 'protocols/Gadu-Gadu/src/gg.cpp')
-rw-r--r-- | protocols/Gadu-Gadu/src/gg.cpp | 47 |
1 files changed, 2 insertions, 45 deletions
diff --git a/protocols/Gadu-Gadu/src/gg.cpp b/protocols/Gadu-Gadu/src/gg.cpp index 31ba420df2..8aeffc1391 100644 --- a/protocols/Gadu-Gadu/src/gg.cpp +++ b/protocols/Gadu-Gadu/src/gg.cpp @@ -38,12 +38,12 @@ PLUGININFOEX pluginInfo = { };
// Other variables
+CMPlugin g_plugin;
HINSTANCE hInstance;
SSL_API sslApi;
CLIST_INTERFACE *pcli;
int hLangpack;
-LIST<GaduProto> g_Instances(1, PtrKeySortT);
static unsigned long crc_table[256];
@@ -214,27 +214,11 @@ static int gg_modulesloaded(WPARAM, LPARAM) }
//////////////////////////////////////////////////////////
-// Gets protocol instance associated with a contact
-//
-static GaduProto* gg_getprotoinstance(MCONTACT hContact)
-{
- char* szProto = GetContactProto(hContact);
- if (szProto == nullptr)
- return nullptr;
-
- for (auto &it : g_Instances)
- if (mir_strcmp(szProto, it->m_szModuleName) == 0)
- return it;
-
- return nullptr;
-}
-
-//////////////////////////////////////////////////////////
// Handles PrebuildContactMenu event
//
static int gg_prebuildcontactmenu(WPARAM hContact, LPARAM)
{
- GaduProto* gg = gg_getprotoinstance(hContact);
+ GaduProto* gg = CMPlugin::getInstance(hContact);
if (gg == nullptr)
return 0;
@@ -437,30 +421,3 @@ BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD, LPVOID) #endif
return TRUE;
}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-static PROTO_INTERFACE* gg_proto_init(const char *pszProtoName, const wchar_t *tszUserName)
-{
- GaduProto *gg = new GaduProto(pszProtoName, tszUserName);
- g_Instances.insert(gg);
- return gg;
-}
-
-static int gg_proto_uninit(PROTO_INTERFACE *proto)
-{
- GaduProto *gg = (GaduProto*)proto;
- g_Instances.remove(gg);
- delete gg;
- return 0;
-}
-
-struct CMPlugin : public CMPluginBase
-{
- CMPlugin() :
- CMPluginBase(GGDEF_PROTO)
- {
- RegisterProtocol(PROTOTYPE_PROTOCOL, gg_proto_init, gg_proto_uninit);
- }
-}
- g_plugin;
|