summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-04-19 18:17:25 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-04-19 18:17:25 +0300
commit2dd3e220e4c783a5454d763b01d56e71042644f2 (patch)
tree3bc72825fdc8a981e0cf5af155fea98c305b6ab0
parent198fa4f35166d05fa513658c30f4a0bc6ab5a733 (diff)
CallObjectEventHook: new function to call the event hook of the specified object
-rw-r--r--include/m_core.h1
-rw-r--r--libs/win32/mir_core.libbin321512 -> 321758 bytes
-rw-r--r--libs/win64/mir_core.libbin322540 -> 322762 bytes
-rw-r--r--src/mir_core/src/mir_core.def1
-rw-r--r--src/mir_core/src/mir_core64.def1
-rw-r--r--src/mir_core/src/modules.cpp28
6 files changed, 31 insertions, 0 deletions
diff --git a/include/m_core.h b/include/m_core.h
index f39e711750..00ac529c3d 100644
--- a/include/m_core.h
+++ b/include/m_core.h
@@ -101,6 +101,7 @@ MIR_CORE_DLL(HANDLE) CreateHookableEvent(const char *name);
MIR_CORE_DLL(int) DestroyHookableEvent(HANDLE hEvent);
MIR_CORE_DLL(int) SetHookDefaultForHookableEvent(HANDLE hEvent, MIRANDAHOOK pfnHook);
MIR_CORE_DLL(int) CallPluginEventHook(HINSTANCE hInst, HANDLE hEvent, WPARAM wParam = 0, LPARAM lParam = 0);
+MIR_CORE_DLL(int) CallObjectEventHook(void *pObject, HANDLE hEvent, WPARAM wParam = 0, LPARAM lParam = 0);
MIR_CORE_DLL(int) NotifyEventHooks(HANDLE hEvent, WPARAM wParam = 0, LPARAM lParam = 0);
MIR_CORE_DLL(int) NotifyFastHook(HANDLE hEvent, WPARAM wParam = 0, LPARAM lParam = 0);
diff --git a/libs/win32/mir_core.lib b/libs/win32/mir_core.lib
index 732885b31d..f0a817b50e 100644
--- a/libs/win32/mir_core.lib
+++ b/libs/win32/mir_core.lib
Binary files differ
diff --git a/libs/win64/mir_core.lib b/libs/win64/mir_core.lib
index 707908ed12..cba2f307f8 100644
--- a/libs/win64/mir_core.lib
+++ b/libs/win64/mir_core.lib
Binary files differ
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def
index 6e7bf951ce..2d117035ea 100644
--- a/src/mir_core/src/mir_core.def
+++ b/src/mir_core/src/mir_core.def
@@ -1066,3 +1066,4 @@ IsTerminalDisconnected @1245
??0CCtrlLabel@@QAE@PAVCDlgBase@@H@Z @1256 NONAME
??1CCtrlLabel@@UAE@XZ @1257 NONAME
??_7CCtrlLabel@@6B@ @1258 NONAME
+CallObjectEventHook @1259
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def
index 748925cc79..98e8fb7ca2 100644
--- a/src/mir_core/src/mir_core64.def
+++ b/src/mir_core/src/mir_core64.def
@@ -1066,3 +1066,4 @@ IsTerminalDisconnected @1245
??0CCtrlLabel@@QEAA@PEAVCDlgBase@@H@Z @1256 NONAME
??1CCtrlLabel@@UEAA@XZ @1257 NONAME
??_7CCtrlLabel@@6B@ @1258 NONAME
+CallObjectEventHook @1259
diff --git a/src/mir_core/src/modules.cpp b/src/mir_core/src/modules.cpp
index a57f0d19ea..707cf91523 100644
--- a/src/mir_core/src/modules.cpp
+++ b/src/mir_core/src/modules.cpp
@@ -191,6 +191,34 @@ MIR_CORE_DLL(int) CallPluginEventHook(HINSTANCE hInst, HANDLE hEvent, WPARAM wPa
return 0;
}
+MIR_CORE_DLL(int) CallObjectEventHook(void *pObject, HANDLE hEvent, WPARAM wParam, LPARAM lParam)
+{
+ THook *p = (THook*)hEvent;
+ if (p == nullptr || pObject == nullptr)
+ return -1;
+
+ mir_cslock lck(p->csHook);
+ for (int i = 0; i < p->subscriberCount; i++) {
+ THookSubscriber* s = &p->subscriber[i];
+ if (s->object != pObject)
+ continue;
+
+ int returnVal;
+ switch (s->type) {
+ case 3: returnVal = s->pfnHookObj(s->object, wParam, lParam); break;
+ case 4: returnVal = s->pfnHookObjParam(s->object, wParam, lParam, s->lParam); break;
+ default: continue;
+ }
+ if (returnVal)
+ return returnVal;
+ }
+
+ if (p->subscriberCount == 0 && p->pfnHook != nullptr)
+ return p->pfnHook(wParam, lParam);
+
+ return 0;
+}
+
static int CallHookSubscribers(THook *p, WPARAM wParam, LPARAM lParam)
{
if (p == nullptr)