From cef86ad96279cd536e576883c37e4b522e9441b4 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Tue, 23 Apr 2013 08:45:16 +0000 Subject: small cleanup git-svn-id: http://svn.miranda-ng.org/main/trunk@4513 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/SimpleAR/src/Common.h | 1 + plugins/SimpleAR/src/Main.cpp | 53 +++++++++++++++++----------------------- plugins/SimpleAR/src/Options.cpp | 2 +- 3 files changed, 25 insertions(+), 31 deletions(-) (limited to 'plugins') diff --git a/plugins/SimpleAR/src/Common.h b/plugins/SimpleAR/src/Common.h index 7eb0b069d7..ac898491a7 100644 --- a/plugins/SimpleAR/src/Common.h +++ b/plugins/SimpleAR/src/Common.h @@ -26,5 +26,6 @@ extern HINSTANCE hinstance; extern INT interval; extern TCHAR *ptszDefaultMsg[6]; extern HGENMENU hEnableMenu; +extern IconItemT iconList[]; extern INT OptInit(WPARAM wParam, LPARAM lParam); diff --git a/plugins/SimpleAR/src/Main.cpp b/plugins/SimpleAR/src/Main.cpp index c92b2aeabb..fa52e56501 100644 --- a/plugins/SimpleAR/src/Main.cpp +++ b/plugins/SimpleAR/src/Main.cpp @@ -18,7 +18,6 @@ Copyright (C) 2000-2 Richard Hughes, Roland Rabien & Tristan Van de Vreede HINSTANCE hinstance; -HANDLE hPreBuildHook = NULL, hAddEventHook = NULL, hOptHook = NULL, hCheckDefHook = NULL, hOnPreShutdown = NULL, hToggleEnable = NULL, hToggleAutoanswer = NULL; HGENMENU hToggle, hEnableMenu; BOOL gbVarsServiceExist = FALSE; INT interval; @@ -44,7 +43,7 @@ PLUGININFOEX pluginInfoEx = { __AUTHORWEB, UNICODE_AWARE, // {46BF191F-8DFB-4656-88B2-4C20BE4CFA44} - {0x46bf191f, 0x8dfb, 0x4656, { 0x88, 0xb2, 0x4c, 0x20, 0xbe, 0x4c, 0xfa, 0x44}} + {0x46bf191f, 0x8dfb, 0x4656, {0x88, 0xb2, 0x4c, 0x20, 0xbe, 0x4c, 0xfa, 0x44}} }; extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) @@ -52,21 +51,21 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda return &pluginInfoEx; } -BOOL WINAPI DllMain(HINSTANCE hinst,DWORD fdwReason,LPVOID lpvReserved) +BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID lpvReserved) { - hinstance=hinst; + hinstance = hinst; return TRUE; } INT_PTR ToggleEnable(WPARAM wParam, LPARAM lParam) { - BOOL fEnabled = db_get_b(NULL, protocolname, KEY_ENABLED, 1); - db_set_b(NULL, protocolname, KEY_ENABLED, !fEnabled); + BOOL fEnabled = !db_get_b(NULL, protocolname, KEY_ENABLED, 1); + db_set_b(NULL, protocolname, KEY_ENABLED, fEnabled); CLISTMENUITEM mi = { sizeof(mi) }; mi.flags = CMIM_NAME | CMIM_ICON | CMIF_TCHAR; - mi.ptszName = !fEnabled ? LPGENT("Disable Auto&reply") : LPGENT("Enable Auto&reply"); - mi.hIcon = !fEnabled ? LoadIcon(hinstance, MAKEINTRESOURCE(IDI_OFF)) : LoadIcon(hinstance, MAKEINTRESOURCE(IDI_ON)); + mi.ptszName = fEnabled ? LPGENT("Disable Auto&reply") : LPGENT("Enable Auto&reply"); + mi.icolibItem = fEnabled ? iconList[0].hIcolib : iconList[1].hIcolib; Menu_ModifyItem(hEnableMenu, &mi); return 0; } @@ -81,7 +80,7 @@ INT_PTR Toggle(WPARAM w, LPARAM l) CLISTMENUITEM mi = { sizeof(mi) }; mi.flags = CMIM_NAME | CMIM_ICON | CMIF_TCHAR; mi.ptszName = on ? LPGENT("Turn off Autoanswer") : LPGENT("Turn on Autoanswer"); - mi.hIcon = on ? LoadIcon(hinstance, MAKEINTRESOURCE(IDI_OFF)) : LoadIcon(hinstance, MAKEINTRESOURCE(IDI_ON)); + mi.icolibItem = on ? iconList[0].hIcolib : iconList[1].hIcolib; Menu_ModifyItem(hToggle, &mi); return 0; } @@ -94,7 +93,7 @@ INT OnPreBuildContactMenu(WPARAM w, LPARAM l) mi.flags = CMIM_NAME | CMIM_ICON | CMIF_TCHAR; BOOL on = !db_get_b(hContact, protocolname, "TurnedOn", 0); mi.ptszName = on ? LPGENT("Turn off Autoanswer") : LPGENT("Turn on Autoanswer"); - mi.hIcon = on ? LoadIcon(hinstance, MAKEINTRESOURCE(IDI_OFF)) : LoadIcon(hinstance, MAKEINTRESOURCE(IDI_ON)); + mi.icolibItem = on ? iconList[0].hIcolib : iconList[1].hIcolib; Menu_ModifyItem(hToggle, &mi); return 0; } @@ -102,11 +101,9 @@ INT OnPreBuildContactMenu(WPARAM w, LPARAM l) INT CheckDefaults(WPARAM, LPARAM) { DBVARIANT dbv; - TCHAR* ptszDefault; + TCHAR *ptszDefault; char szStatus[6]={0}; - UnhookEvent(hCheckDefHook); - interval=db_get_w(NULL,protocolname,KEY_REPEATINTERVAL,300); if (db_get_ts(NULL,protocolname,KEY_HEADING,&dbv)) @@ -136,7 +133,7 @@ INT CheckDefaults(WPARAM, LPARAM) db_free(&dbv); } } - hPreBuildHook = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, OnPreBuildContactMenu); + HookEvent(ME_CLIST_PREBUILDCONTACTMENU, OnPreBuildContactMenu); if (ServiceExists(MS_VARS_FORMATSTRING)) gbVarsServiceExist = TRUE; @@ -144,7 +141,7 @@ INT CheckDefaults(WPARAM, LPARAM) CLISTMENUITEM mi = { sizeof(mi) }; mi.flags = CMIM_NAME | CMIM_ICON | CMIF_TCHAR; mi.ptszName = fEnabled ? LPGENT("Disable Auto&reply") : LPGENT("Enable Auto&reply"); - mi.hIcon = fEnabled ? LoadIcon(hinstance, MAKEINTRESOURCE(IDI_OFF)) : LoadIcon(hinstance, MAKEINTRESOURCE(IDI_ON)); + mi.icolibItem = fEnabled ? iconList[0].hIcolib : iconList[1].hIcolib; Menu_ModifyItem(hEnableMenu, &mi); return 0; @@ -300,21 +297,18 @@ INT addEvent(WPARAM wParam, LPARAM lParam) return 0; } -INT OnPreShutdown(WPARAM wParam, LPARAM lParam) +IconItemT iconList[] = { - UnhookEvent(hAddEventHook); - UnhookEvent(hPreBuildHook); - UnhookEvent(hOptHook); - UnhookEvent(hOnPreShutdown); - return 0; -} + { LPGENT("Disable Auto&reply"), "Disable Auto&reply", IDI_OFF }, + { LPGENT("Enable Auto&reply"), "Enable Auto&reply", IDI_ON } +}; extern "C" int __declspec(dllexport)Load(void) { mir_getLP(&pluginInfoEx); - hToggleEnable = CreateServiceFunction(protocolname"/ToggleEnable", ToggleEnable); - hToggleAutoanswer = CreateServiceFunction(protocolname"/ToggleAutoanswer",Toggle); + CreateServiceFunction(protocolname"/ToggleEnable", ToggleEnable); + CreateServiceFunction(protocolname"/ToggleAutoanswer",Toggle); CLISTMENUITEM mi = { sizeof(mi) }; mi.position = 500090000; @@ -328,17 +322,16 @@ extern "C" int __declspec(dllexport)Load(void) hToggle = Menu_AddContactMenuItem(&mi); //add hook - hOptHook = HookEvent(ME_OPT_INITIALISE, OptInit); - hAddEventHook = HookEvent(ME_DB_EVENT_ADDED, addEvent); - hCheckDefHook = HookEvent(ME_SYSTEM_MODULESLOADED, CheckDefaults); - hOnPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreShutdown); + HookEvent(ME_OPT_INITIALISE, OptInit); + HookEvent(ME_DB_EVENT_ADDED, addEvent); + HookEvent(ME_SYSTEM_MODULESLOADED, CheckDefaults); + + Icon_RegisterT(hinstance, _T("Simple Auto Replier"), iconList, SIZEOF(iconList)); return 0; } extern "C" __declspec(dllexport)int Unload(void) { - DestroyServiceFunction(hToggleEnable); - DestroyServiceFunction(hToggleAutoanswer); return 0; } \ No newline at end of file diff --git a/plugins/SimpleAR/src/Options.cpp b/plugins/SimpleAR/src/Options.cpp index 59aa4587df..aa4c3101ec 100644 --- a/plugins/SimpleAR/src/Options.cpp +++ b/plugins/SimpleAR/src/Options.cpp @@ -95,7 +95,7 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara CLISTMENUITEM mi = { sizeof(mi) }; mi.flags = CMIM_NAME | CMIM_ICON | CMIF_TCHAR; mi.ptszName = fEnabled ? LPGENT("Disable Auto&reply") : LPGENT("Enable Auto&reply"); - mi.hIcon = fEnabled ? LoadIcon(hinstance, MAKEINTRESOURCE(IDI_ON)) : LoadIcon(hinstance, MAKEINTRESOURCE(IDI_OFF)); + mi.icolibItem = fEnabled ? iconList[0].hIcolib : iconList[1].hIcolib; Menu_ModifyItem(hEnableMenu, &mi); GetDlgItemText(hwndDlg, IDC_HEADING, ptszText, SIZEOF(ptszText)); -- cgit v1.2.3