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/Twitter/src/theme.cpp | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'protocols/Twitter/src/theme.cpp') diff --git a/protocols/Twitter/src/theme.cpp b/protocols/Twitter/src/theme.cpp index ca6338edc7..75c5252f34 100644 --- a/protocols/Twitter/src/theme.cpp +++ b/protocols/Twitter/src/theme.cpp @@ -20,8 +20,6 @@ along with this program. If not, see . #include "theme.h" #include "proto.h" -extern OBJLIST g_Instances; - static IconItem icons[] = { { LPGEN("Twitter Icon"), "twitter", IDI_TWITTER }, @@ -57,32 +55,20 @@ HANDLE GetIconHandle(const char *name) static HGENMENU g_hMenuItems[2]; // Helper functions -static TwitterProto* GetInstanceByHContact(MCONTACT hContact) -{ - char *proto = GetContactProto(hContact); - if (!proto) - return nullptr; - - for (auto &it : g_Instances) - if (!mir_strcmp(proto, it->m_szModuleName)) - return it; - - return nullptr; -} template -INT_PTR GlobalService(WPARAM wParam, LPARAM lParam) +INT_PTR GlobalService(WPARAM hContact, LPARAM lParam) { - TwitterProto *proto = GetInstanceByHContact(MCONTACT(wParam)); - return proto ? (proto->*Fcn)(wParam, lParam) : 0; + TwitterProto *proto = CMPlugin::getInstance(MCONTACT(hContact)); + return proto ? (proto->*Fcn)(hContact, lParam) : 0; } -static int PrebuildContactMenu(WPARAM wParam, LPARAM lParam) +static int PrebuildContactMenu(WPARAM hContact, LPARAM lParam) { ShowContactMenus(false); - TwitterProto *proto = GetInstanceByHContact(MCONTACT(wParam)); - return proto ? proto->OnPrebuildContactMenu(wParam, lParam) : 0; + TwitterProto *proto = CMPlugin::getInstance(MCONTACT(hContact)); + return proto ? proto->OnPrebuildContactMenu(hContact, lParam) : 0; } void InitContactMenus() -- cgit v1.2.3