diff options
Diffstat (limited to 'protocols/Twitter/src')
-rw-r--r-- | protocols/Twitter/src/main.cpp | 36 | ||||
-rw-r--r-- | protocols/Twitter/src/proto.h | 7 | ||||
-rw-r--r-- | protocols/Twitter/src/theme.cpp | 26 |
3 files changed, 14 insertions, 55 deletions
diff --git a/protocols/Twitter/src/main.cpp b/protocols/Twitter/src/main.cpp index a4e714ba7e..14e91dc39e 100644 --- a/protocols/Twitter/src/main.cpp +++ b/protocols/Twitter/src/main.cpp @@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "proto.h"
#include "theme.h"
+CMPlugin g_plugin;
CLIST_INTERFACE* pcli;
HINSTANCE g_hInstance;
@@ -40,16 +41,6 @@ PLUGININFOEX pluginInfo = { { 0xbc09a71b, 0xb86e, 0x4d33, { 0xb1, 0x8d, 0x82, 0xd3, 0x4, 0x51, 0xdd, 0x3c } }
};
-/////////////////////////////////////////////////////////////////////////////
-// Protocol instances
-
-static int compare_protos(const TwitterProto *p1, const TwitterProto *p2)
-{
- return mir_wstrcmp(p1->m_tszUserName, p2->m_tszUserName);
-}
-
-OBJLIST<TwitterProto> g_Instances(1, compare_protos);
-
DWORD WINAPI DllMain(HINSTANCE hInstance, DWORD, LPVOID)
{
g_hInstance = hInstance;
@@ -87,28 +78,3 @@ extern "C" int __declspec(dllexport) Unload(void) {
return 0;
}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-static PROTO_INTERFACE* protoInit(const char *proto_name, const wchar_t *username)
-{
- TwitterProto *proto = new TwitterProto(proto_name, username);
- g_Instances.insert(proto);
- return proto;
-}
-
-static int protoUninit(PROTO_INTERFACE *proto)
-{
- g_Instances.remove(static_cast<TwitterProto*>(proto));
- return 0;
-}
-
-struct CMPlugin : public CMPluginBase
-{
- CMPlugin() :
- CMPluginBase("Twitter")
- {
- RegisterProtocol(PROTOTYPE_PROTOCOL, protoInit, protoUninit);
- }
-}
- g_plugin;
diff --git a/protocols/Twitter/src/proto.h b/protocols/Twitter/src/proto.h index 46facedcc2..a73b5caacc 100644 --- a/protocols/Twitter/src/proto.h +++ b/protocols/Twitter/src/proto.h @@ -129,6 +129,13 @@ private: wstring AuthorizeUrl;
};
+struct CMPlugin : public ACCPROTOPLUGIN<TwitterProto>
+{
+ CMPlugin() :
+ ACCPROTOPLUGIN<TwitterProto>("Twitter")
+ {}
+};
+
// TODO: remove this
inline std::string profile_base_url(const std::string &url)
{
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()
|