From 978b44865b77eb0029e6033dcbfc0876954cef2e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 7 Apr 2017 15:32:08 +0300 Subject: SRMM events are now created inside the core to avoid problems with dynamic plugin unload --- src/core/stdmsg/src/cmdlist.cpp | 2 +- src/core/stdmsg/src/msgdialog.cpp | 4 ++-- src/core/stdmsg/src/msgs.cpp | 7 ------- src/core/stdmsg/src/stdafx.h | 1 - src/mir_app/src/chat.h | 1 + src/mir_app/src/chat_svc.cpp | 7 +++++-- src/mir_app/src/chat_tools.cpp | 4 ++-- 7 files changed, 11 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/core/stdmsg/src/cmdlist.cpp b/src/core/stdmsg/src/cmdlist.cpp index 28d06b9517..a63430bf1c 100644 --- a/src/core/stdmsg/src/cmdlist.cpp +++ b/src/core/stdmsg/src/cmdlist.cpp @@ -101,7 +101,7 @@ void msgQueue_processack(MCONTACT hContact, int id, BOOL success, const char *sz dbei.pBlob = (PBYTE)p->szMsg; MessageWindowEvent evt = { id, hContact, &dbei }; - NotifyEventHooks(hHookWinWrite, 0, (LPARAM)&evt); + NotifyEventHooks(pci->hevPreCreate, 0, (LPARAM)&evt); p->szMsg = (char*)dbei.pBlob; diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index ac2b92bf73..4ad170a8bf 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -771,7 +771,7 @@ LRESULT CSrmmWindow::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) } // First notification - NotifyEventHooks(hHookWinPopup, 0, (LPARAM)&mwpd); + NotifyEventHooks(pci->hevWinPopup, 0, (LPARAM)&mwpd); // Someone added items? if (GetMenuItemCount(mwpd.hMenu) > 0) { @@ -781,7 +781,7 @@ LRESULT CSrmmWindow::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) // Second notification mwpd.uType = MSG_WINDOWPOPUP_SELECTED; - NotifyEventHooks(hHookWinPopup, 0, (LPARAM)&mwpd); + NotifyEventHooks(pci->hevWinPopup, 0, (LPARAM)&mwpd); switch (mwpd.selection) { case IDM_UNDO: diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index bd0301088b..36675d350b 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -30,7 +30,6 @@ const CLSID IID_IRichEditOleCallback = { 0x00020D03, 0x00, 0x00, { 0xC0, 0x00, 0 int OnCheckPlugins(WPARAM, LPARAM); -HANDLE hHookWinPopup, hHookWinWrite; HGENMENU hMsgMenuItem; HMODULE hMsftEdit; @@ -522,9 +521,6 @@ int LoadSendRecvMessageModule(void) CreateServiceFunction(MS_MSG_SETSTATUSTEXT, SetStatusText); CreateServiceFunction("SRMsg/ReadMessage", ReadMessageCommand); - hHookWinPopup = CreateHookableEvent(ME_MSG_WINDOWPOPUP); - hHookWinWrite = CreateHookableEvent(ME_MSG_PRECREATEEVENT); - SkinAddNewSoundEx("RecvMsgActive", LPGEN("Instant messages"), LPGEN("Incoming (focused window)")); SkinAddNewSoundEx("RecvMsgInactive", LPGEN("Instant messages"), LPGEN("Incoming (unfocused window)")); SkinAddNewSoundEx("AlertMsg", LPGEN("Instant messages"), LPGEN("Incoming (new session)")); @@ -539,9 +535,6 @@ int LoadSendRecvMessageModule(void) void SplitmsgShutdown(void) { - DestroyHookableEvent(hHookWinPopup); - DestroyHookableEvent(hHookWinWrite); - FreeMsgLogIcons(); FreeLibrary(hMsftEdit); msgQueue_destroy(); diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h index dc0b0dbe05..b8248a870d 100644 --- a/src/core/stdmsg/src/stdafx.h +++ b/src/core/stdmsg/src/stdafx.h @@ -81,7 +81,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define GC_SWITCHTAB (WM_USER+0x106) extern HINSTANCE g_hInst; -extern HANDLE hHookWinPopup, hHookWinWrite; ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/mir_app/src/chat.h b/src/mir_app/src/chat.h index fca1458400..cfc262e3eb 100644 --- a/src/mir_app/src/chat.h +++ b/src/mir_app/src/chat.h @@ -43,6 +43,7 @@ extern HCURSOR g_hCurHyperlinkHand; extern char* pLogIconBmpBits[14]; extern LIST g_arSessions; extern MWindowList g_hWindowList; +extern HANDLE hevSendEvent, hevBuildMenuEvent; // log.c void LoadMsgLogBitmaps(void); diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index da3deabc4a..99ab00f793 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -781,9 +781,12 @@ int LoadChatModule(void) HookEvent(ME_SKIN_ICONSCHANGED, IconsChanged); g_hWindowList = WindowList_Create(); - chatApi.hSendEvent = CreateHookableEvent(ME_GC_EVENT); - chatApi.hBuildMenuEvent = CreateHookableEvent(ME_GC_BUILDMENU); hHookEvent = CreateHookableEvent(ME_GC_HOOK_EVENT); + hevSendEvent = CreateHookableEvent(ME_GC_EVENT); + hevBuildMenuEvent = CreateHookableEvent(ME_GC_BUILDMENU); + + chatApi.hevPreCreate = CreateHookableEvent(ME_MSG_PRECREATEEVENT); + chatApi.hevWinPopup = CreateHookableEvent(ME_MSG_WINDOWPOPUP); HookEvent(ME_FONT_RELOAD, FontsChanged); HookEvent(ME_SKIN2_ICONSCHANGED, IconsChanged); diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp index 2e03698412..2b0ccdde6b 100644 --- a/src/mir_app/src/chat_tools.cpp +++ b/src/mir_app/src/chat_tools.cpp @@ -622,7 +622,7 @@ MIR_APP_DLL(BOOL) Chat_DoEventHook(SESSION_INFO *si, int iType, const USERINFO * gch.ptszText = (LPTSTR)pszText; gch.dwData = dwItem; gch.pDest = &gcd; - NotifyEventHooks(chatApi.hSendEvent, 0, (WPARAM)&gch); + NotifyEventHooks(hevSendEvent, 0, (WPARAM)&gch); return TRUE; } @@ -821,7 +821,7 @@ MIR_APP_DLL(UINT) Chat_CreateGCMenu(HWND hwnd, HMENU hMenu, POINT pt, SESSION_IN gcmi.Type = MENU_ON_NICKLIST; } - NotifyEventHooks(chatApi.hBuildMenuEvent, 0, (WPARAM)&gcmi); + NotifyEventHooks(hevBuildMenuEvent, 0, (WPARAM)&gcmi); return TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, nullptr); } -- cgit v1.2.3