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/Twitter/src/theme.cpp | |
parent | c2bb7727483b9b5620e8cc0ce6adae35ee78d0a4 (diff) |
common protocol instance management code went into template
Diffstat (limited to 'protocols/Twitter/src/theme.cpp')
-rw-r--r-- | protocols/Twitter/src/theme.cpp | 26 |
1 files changed, 6 insertions, 20 deletions
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 <http://www.gnu.org/licenses/>. #include "theme.h"
#include "proto.h"
-extern OBJLIST<TwitterProto> 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(__cdecl TwitterProto::*Fcn)(WPARAM, LPARAM)>
-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()
|