From d9fddc0cfa9066eb1b5ad3f4807b37426ae6ca88 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 5 Mar 2019 21:10:22 +0300 Subject: Popup: - wiping out checks for service presence; - code cleaning --- .../ClientChangeNotify/src/ClientChangeNotify.cpp | 43 ++++++++++------------ plugins/ClientChangeNotify/src/Misc.h | 22 ++++------- plugins/ClientChangeNotify/src/OptDlg.cpp | 18 ++++----- plugins/ClientChangeNotify/src/stdafx.h | 2 +- 4 files changed, 36 insertions(+), 49 deletions(-) (limited to 'plugins/ClientChangeNotify') diff --git a/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp b/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp index 3c9bd66d4f..e209a877ca 100644 --- a/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp +++ b/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp @@ -24,7 +24,7 @@ HGENMENU g_hTogglePopupsMenuItem; CMPlugin g_plugin; COptPage *g_PreviewOptPage; // we need to show popup even for the NULL contact if g_PreviewOptPage is not NULL (used for popup preview) -BOOL bPopupExists = FALSE, bFingerprintExists = FALSE, bVariablesExists = FALSE; +BOOL bFingerprintExists = FALSE, bVariablesExists = FALSE; ///////////////////////////////////////////////////////////////////////////////////////// @@ -268,12 +268,10 @@ static INT_PTR srvTogglePopups(WPARAM, LPARAM) static int PrebuildMainMenu(WPARAM, LPARAM) { // we have to use ME_CLIST_PREBUILDMAINMENU instead of updating menu items only on settings change, because "popup_enabled" and "popup_disabled" icons are not always available yet in ModulesLoaded - if (bPopupExists) { - if (g_PopupOptPage.GetDBValueCopy(IDC_POPUPOPTDLG_POPUPNOTIFY)) - Menu_ModifyItem(g_hTogglePopupsMenuItem, LPGENW("Disable c&lient change notification"), IcoLib_GetIcon("popup_enabled")); - else - Menu_ModifyItem(g_hTogglePopupsMenuItem, LPGENW("Enable c&lient change notification"), IcoLib_GetIcon("popup_disabled")); - } + if (g_PopupOptPage.GetDBValueCopy(IDC_POPUPOPTDLG_POPUPNOTIFY)) + Menu_ModifyItem(g_hTogglePopupsMenuItem, LPGENW("Disable c&lient change notification"), IcoLib_GetIcon("popup_enabled")); + else + Menu_ModifyItem(g_hTogglePopupsMenuItem, LPGENW("Enable c&lient change notification"), IcoLib_GetIcon("popup_disabled")); return 0; } @@ -301,7 +299,6 @@ INT_PTR CALLBACK CCNErrorDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM) static int ModuleLoad(WPARAM, LPARAM) { - bPopupExists = ServiceExists(MS_POPUP_ADDPOPUPW); bFingerprintExists = ServiceExists(MS_FP_SAMECLIENTST) && ServiceExists(MS_FP_GETCLIENTICONT); bVariablesExists = ServiceExists(MS_VARS_FORMATSTRING); return 0; @@ -316,22 +313,20 @@ static int MirandaLoaded(WPARAM, LPARAM) g_plugin.addSound(CLIENTCHANGED_SOUND, nullptr, LPGENW("ClientChangeNotify: Client changed")); - if (bPopupExists) { - CreateServiceFunction(MS_CCN_TOGGLEPOPUPS, srvTogglePopups); - HookEvent(ME_CLIST_PREBUILDMAINMENU, PrebuildMainMenu); - - CMenuItem mi(&g_plugin); - SET_UID(mi, 0xfabb9181, 0xdb92, 0x43f4, 0x86, 0x40, 0xca, 0xb6, 0x4c, 0x93, 0x34, 0x27); - mi.root = g_plugin.addRootMenu(MO_MAIN, LPGENW("Popups"), 0); - mi.flags = CMIF_UNICODE; - if (g_PopupOptPage.GetDBValueCopy(IDC_POPUPOPTDLG_POPUPNOTIFY)) - mi.name.w = LPGENW("Disable c&lient change notification"); - else - mi.name.w = LPGENW("Enable c&lient change notification"); - - mi.pszService = MS_CCN_TOGGLEPOPUPS; - g_hTogglePopupsMenuItem = Menu_AddMainMenuItem(&mi); - } + CreateServiceFunction(MS_CCN_TOGGLEPOPUPS, srvTogglePopups); + HookEvent(ME_CLIST_PREBUILDMAINMENU, PrebuildMainMenu); + + CMenuItem mi(&g_plugin); + SET_UID(mi, 0xfabb9181, 0xdb92, 0x43f4, 0x86, 0x40, 0xca, 0xb6, 0x4c, 0x93, 0x34, 0x27); + mi.root = g_plugin.addRootMenu(MO_MAIN, LPGENW("Popups"), 0); + mi.flags = CMIF_UNICODE; + if (g_PopupOptPage.GetDBValueCopy(IDC_POPUPOPTDLG_POPUPNOTIFY)) + mi.name.w = LPGENW("Disable c&lient change notification"); + else + mi.name.w = LPGENW("Enable c&lient change notification"); + + mi.pszService = MS_CCN_TOGGLEPOPUPS; + g_hTogglePopupsMenuItem = Menu_AddMainMenuItem(&mi); // seems that Fingerprint is not installed if (!bFingerprintExists && !g_plugin.getByte(DB_NO_FINGERPRINT_ERROR, 0)) diff --git a/plugins/ClientChangeNotify/src/Misc.h b/plugins/ClientChangeNotify/src/Misc.h index ccd6df194e..4b08bf9dab 100644 --- a/plugins/ClientChangeNotify/src/Misc.h +++ b/plugins/ClientChangeNotify/src/Misc.h @@ -20,23 +20,17 @@ #pragma once #include "stdafx.h" -extern BOOL bPopupExists; __inline void ShowMsg(wchar_t *FirstLine, wchar_t *SecondLine = L"", bool IsErrorMsg = false, int Timeout = 0) { - if (bPopupExists) { - POPUPDATAW ppd = { 0 }; - ppd.lchIcon = LoadIcon(NULL, IsErrorMsg ? IDI_EXCLAMATION : IDI_INFORMATION); - mir_wstrcpy(ppd.lpwzContactName, FirstLine); - mir_wstrcpy(ppd.lpwzText, SecondLine); - ppd.colorBack = IsErrorMsg ? 0x0202E3 : 0xE8F1FD; - ppd.colorText = IsErrorMsg ? 0xE8F1FD : 0x000000; - ppd.iSeconds = Timeout; - PUAddPopupW(&ppd); - } - else { - MessageBox(NULL, SecondLine, FirstLine, MB_OK | (IsErrorMsg ? MB_ICONEXCLAMATION : MB_ICONINFORMATION)); - } + POPUPDATAW ppd = { 0 }; + ppd.lchIcon = LoadIcon(NULL, IsErrorMsg ? IDI_EXCLAMATION : IDI_INFORMATION); + mir_wstrcpy(ppd.lpwzContactName, FirstLine); + mir_wstrcpy(ppd.lpwzText, SecondLine); + ppd.colorBack = IsErrorMsg ? 0x0202E3 : 0xE8F1FD; + ppd.colorText = IsErrorMsg ? 0xE8F1FD : 0x000000; + ppd.iSeconds = Timeout; + PUAddPopupW(&ppd); } __inline void ShowLog(TCString &LogFilePath) diff --git a/plugins/ClientChangeNotify/src/OptDlg.cpp b/plugins/ClientChangeNotify/src/OptDlg.cpp index 5c6dfc3e99..536334e4a4 100644 --- a/plugins/ClientChangeNotify/src/OptDlg.cpp +++ b/plugins/ClientChangeNotify/src/OptDlg.cpp @@ -160,16 +160,14 @@ INT_PTR CALLBACK PopupOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara int OptionsDlgInit(WPARAM wParam, LPARAM) { - if (bPopupExists) { - OPTIONSDIALOGPAGE optDi = {}; - optDi.position = 920000000; - optDi.szGroup.a = LPGEN("Popups"); - optDi.szTitle.a = LPGEN("ClientChangeNotify"); - optDi.pfnDlgProc = PopupOptDlg; - optDi.pszTemplate = MAKEINTRESOURCEA(IDD_POPUPOPTDLG); - optDi.flags = ODPF_BOLDGROUPS; - g_plugin.addOptions(wParam, &optDi); - } + OPTIONSDIALOGPAGE optDi = {}; + optDi.position = 920000000; + optDi.szGroup.a = LPGEN("Popups"); + optDi.szTitle.a = LPGEN("ClientChangeNotify"); + optDi.pfnDlgProc = PopupOptDlg; + optDi.pszTemplate = MAKEINTRESOURCEA(IDD_POPUPOPTDLG); + optDi.flags = ODPF_BOLDGROUPS; + g_plugin.addOptions(wParam, &optDi); return 0; } diff --git a/plugins/ClientChangeNotify/src/stdafx.h b/plugins/ClientChangeNotify/src/stdafx.h index 7a95b54140..676c1bbeaf 100644 --- a/plugins/ClientChangeNotify/src/stdafx.h +++ b/plugins/ClientChangeNotify/src/stdafx.h @@ -110,7 +110,7 @@ struct CMPlugin : public PLUGIN #define CLIENTCHANGED_SOUND "ClientChanged" -extern BOOL bPopupExists, bFingerprintExists; +extern BOOL bFingerprintExists; extern COptPage g_PopupOptPage; extern COptPage *g_PreviewOptPage; -- cgit v1.2.3