From 8bd59593912495db8b41f885c1c9c8c5687e4156 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 31 May 2018 12:24:51 +0300 Subject: fixes #1397 (StdMsg: dynamic loading breaks meta menu) --- include/m_message.h | 3 +++ libs/win32/mir_app.lib | Bin 169616 -> 169860 bytes libs/win64/mir_app.lib | Bin 164822 -> 165048 bytes plugins/Scriver/src/msgs.cpp | 1 - plugins/Scriver/src/statusicon.cpp | 12 +----------- plugins/Scriver/src/statusicon.h | 1 - plugins/TabSRMM/src/generic_msghandlers.cpp | 11 +---------- plugins/TabSRMM/src/globals.cpp | 1 - plugins/TabSRMM/src/msgs.h | 1 - src/core/stdmsg/src/msgs.cpp | 2 -- src/core/stdmsg/src/statusicon.cpp | 10 +--------- src/core/stdmsg/src/statusicon.h | 1 - src/mir_app/src/mir_app.def | 1 + src/mir_app/src/mir_app64.def | 1 + src/mir_app/src/srmm_statusicon.cpp | 14 ++++++++++++-- 15 files changed, 20 insertions(+), 39 deletions(-) diff --git a/include/m_message.h b/include/m_message.h index ad1685de27..2af205867b 100644 --- a/include/m_message.h +++ b/include/m_message.h @@ -200,6 +200,9 @@ struct StatusIconClickData // catch to be notified about the icon list's change. #define ME_MSG_ICONSCHANGED "MessageAPI/IconsChanged" +// emulates click on a status bar icon +EXTERN_C MIR_APP_DLL(void) Srmm_ClickStatusIcon(MCONTACT hContact, const StatusIconClickData *sid); + /////////////////////////////////////////////////////////////////////////////////////////////////////////////// // srmm toolbar icons' support diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib index afeead3c61..847b839939 100644 Binary files a/libs/win32/mir_app.lib and b/libs/win32/mir_app.lib differ diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib index ac37cf3bdd..41f80a52d2 100644 Binary files a/libs/win64/mir_app.lib and b/libs/win64/mir_app.lib differ diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index e5f4ca310e..cc1b078373 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -598,7 +598,6 @@ int OnSystemPreshutdown(WPARAM, LPARAM) { Srmm_Broadcast(WM_CLOSE, 0, 0); WindowList_Broadcast(g_dat.hParentWindowList, WM_CLOSE, 0, 0); - DeinitStatusIcons(); return 0; } diff --git a/plugins/Scriver/src/statusicon.cpp b/plugins/Scriver/src/statusicon.cpp index b11d49cd1a..ce5a3c2386 100644 --- a/plugins/Scriver/src/statusicon.cpp +++ b/plugins/Scriver/src/statusicon.cpp @@ -23,8 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" -HANDLE hHookIconPressedEvt; - void DrawStatusIcons(MCONTACT hContact, HDC hDC, const RECT &r, int gap) { int x = r.left; @@ -56,7 +54,7 @@ void CheckStatusIconClick(MCONTACT hContact, HWND hwndFrom, POINT pt, const RECT sicd.dwId = si->dwId; sicd.szModule = si->szModule; sicd.flags = click_flags; - NotifyEventHooks(hHookIconPressedEvt, hContact, (LPARAM)&sicd); + Srmm_ClickStatusIcon(hContact, &sicd); } static int OnSrmmIconChanged(WPARAM hContact, LPARAM) @@ -74,14 +72,6 @@ static int OnSrmmIconChanged(WPARAM hContact, LPARAM) int InitStatusIcons() { HookEvent(ME_MSG_ICONSCHANGED, OnSrmmIconChanged); - - hHookIconPressedEvt = CreateHookableEvent(ME_MSG_ICONPRESSED); - return 0; -} - -int DeinitStatusIcons() -{ - DestroyHookableEvent(hHookIconPressedEvt); return 0; } diff --git a/plugins/Scriver/src/statusicon.h b/plugins/Scriver/src/statusicon.h index 1788637637..d25f2b909c 100644 --- a/plugins/Scriver/src/statusicon.h +++ b/plugins/Scriver/src/statusicon.h @@ -24,7 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define _STATUS_ICON_INC int InitStatusIcons(); -int DeinitStatusIcons(); int GetStatusIconsCount(MCONTACT hContact); void DrawStatusIcons(MCONTACT hContact, HDC hdc, const RECT &r, int gap); diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index e2554acf5f..ca06a2a07c 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -1352,7 +1352,6 @@ void CTabBaseDlg::DM_HandleAutoSizeRequest(REQRESIZE* rr) // status icon stuff (by sje, used for indicating encryption status in the status bar // this is now part of the message window api -static HANDLE hHookIconPressedEvt; static int OnSrmmIconChanged(WPARAM hContact, LPARAM) { @@ -1459,7 +1458,7 @@ void CTabBaseDlg::CheckStatusIconClick(POINT pt, const RECT &rc, int gap, int co sicd.dwId = sid->dwId; sicd.szModule = sid->szModule; sicd.flags = (code == NM_RCLICK ? MBCF_RIGHTBUTTON : 0); - NotifyEventHooks(hHookIconPressedEvt, m_hContact, (LPARAM)&sicd); + Srmm_ClickStatusIcon(m_hContact, &sicd); InvalidateRect(m_pContainer->hwndStatus, nullptr, TRUE); } } @@ -1534,13 +1533,5 @@ int SI_InitStatusIcons() Srmm_AddIcon(&sid, g_plugin.m_hLang); HookEvent(ME_MSG_ICONSCHANGED, OnSrmmIconChanged); - - hHookIconPressedEvt = CreateHookableEvent(ME_MSG_ICONPRESSED); - return 0; -} - -int SI_DeinitStatusIcons() -{ - DestroyHookableEvent(hHookIconPressedEvt); return 0; } diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp index bdc5bdc3ec..544fc9cc98 100644 --- a/plugins/TabSRMM/src/globals.cpp +++ b/plugins/TabSRMM/src/globals.cpp @@ -454,7 +454,6 @@ int CGlobals::PreshutdownSendRecv(WPARAM, LPARAM) for (auto &hContact : Contacts()) db_set_dw(hContact, SRMSGMOD_T, "messagecount", 0); - ::SI_DeinitStatusIcons(); ::NEN_WriteOptions(&nen_options); ::DestroyWindow(PluginConfig.g_hwndHotkeyHandler); diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index 166247d4c1..1f75548e90 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -1100,7 +1100,6 @@ struct SIDEBARITEM { #define MSG_ICON_SOUND 2 int SI_InitStatusIcons(); -int SI_DeinitStatusIcons(); struct SKINDESC { diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index 869d679855..cdadeba179 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -479,8 +479,6 @@ static int SplitmsgModulesLoaded(WPARAM, LPARAM) int PreshutdownSendRecv(WPARAM, LPARAM) { Srmm_Broadcast(DM_CLOSETAB, 0, 0); - - DeinitStatusIcons(); return 0; } diff --git a/src/core/stdmsg/src/statusicon.cpp b/src/core/stdmsg/src/statusicon.cpp index 76509152cc..0246d2a762 100644 --- a/src/core/stdmsg/src/statusicon.cpp +++ b/src/core/stdmsg/src/statusicon.cpp @@ -67,20 +67,12 @@ void CheckStatusIconClick(MCONTACT hContact, HWND hwndFrom, POINT pt, const RECT sicd.dwId = sid->dwId; sicd.szModule = sid->szModule; sicd.flags = click_flags; - NotifyEventHooks(hHookIconPressedEvt, hContact, (LPARAM)&sicd); + Srmm_ClickStatusIcon(hContact, &sicd); } int InitStatusIcons() { HookEvent(ME_MSG_ICONSCHANGED, OnSrmmIconChanged); - - hHookIconPressedEvt = CreateHookableEvent(ME_MSG_ICONPRESSED); - return 0; -} - -int DeinitStatusIcons() -{ - DestroyHookableEvent(hHookIconPressedEvt); return 0; } diff --git a/src/core/stdmsg/src/statusicon.h b/src/core/stdmsg/src/statusicon.h index 8a267917dc..209e411671 100644 --- a/src/core/stdmsg/src/statusicon.h +++ b/src/core/stdmsg/src/statusicon.h @@ -5,7 +5,6 @@ extern HANDLE hHookIconPressedEvt; extern int status_icon_list_size; int InitStatusIcons(); -int DeinitStatusIcons(); int GetStatusIconsCount(MCONTACT hContact); void DrawStatusIcons(MCONTACT hContact, HDC hdc, const RECT &rc, int gap); diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 6920cdcb3d..33f5a59f10 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -617,3 +617,4 @@ UnregisterPlugin @633 ??_7CMPluginBase@@6B@ @646 NONAME ?Load@CMPluginBase@@UAEHXZ @647 NONAME ?Unload@CMPluginBase@@UAEHXZ @648 NONAME +Srmm_ClickStatusIcon @649 diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index d72137f7cc..67d1f4ee8b 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -617,3 +617,4 @@ UnregisterPlugin @633 ??_7CMPluginBase@@6B@ @646 NONAME ?Load@CMPluginBase@@UEAAHXZ @647 NONAME ?Unload@CMPluginBase@@UEAAHXZ @648 NONAME +Srmm_ClickStatusIcon @649 diff --git a/src/mir_app/src/srmm_statusicon.cpp b/src/mir_app/src/srmm_statusicon.cpp index 87a83542d9..34499a7f27 100644 --- a/src/mir_app/src/srmm_statusicon.cpp +++ b/src/mir_app/src/srmm_statusicon.cpp @@ -24,6 +24,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" HCURSOR g_hCurHyperlinkHand; +HANDLE hHookSrmmEvent; + +static HANDLE hHookIconsChanged, hHookIconPressedEvt; void LoadSrmmToolbarModule(); void UnloadSrmmToolbarModule(); @@ -79,8 +82,6 @@ static int CompareIcons(const StatusIconMain *p1, const StatusIconMain *p2) static OBJLIST arIcons(3, CompareIcons); -HANDLE hHookIconsChanged, hHookSrmmEvent; - ///////////////////////////////////////////////////////////////////////////////////////// MIR_APP_DLL(int) Srmm_AddIcon(StatusIconData *sid, int _hLangpack) @@ -195,6 +196,13 @@ MIR_APP_DLL(StatusIconData*) Srmm_GetNthIcon(MCONTACT hContact, int index) ///////////////////////////////////////////////////////////////////////////////////////// +MIR_APP_DLL(void) Srmm_ClickStatusIcon(MCONTACT hContact, const StatusIconData *sid) +{ + NotifyEventHooks(hHookIconPressedEvt, hContact, (LPARAM)sid); +} + +///////////////////////////////////////////////////////////////////////////////////////// + void KillModuleSrmmIcons(int _hLang) { auto T = arIcons.rev_iter(); @@ -211,6 +219,7 @@ int LoadSrmmModule() hHookSrmmEvent = CreateHookableEvent(ME_MSG_WINDOWEVENT); hHookIconsChanged = CreateHookableEvent(ME_MSG_ICONSCHANGED); + hHookIconPressedEvt = CreateHookableEvent(ME_MSG_ICONPRESSED); return 0; } @@ -220,6 +229,7 @@ void UnloadSrmmModule() DestroyHookableEvent(hHookIconsChanged); DestroyHookableEvent(hHookSrmmEvent); + DestroyHookableEvent(hHookIconPressedEvt); DestroyCursor(g_hCurHyperlinkHand); -- cgit v1.2.3