diff options
Diffstat (limited to 'plugins/AutoShutdown/src')
-rw-r--r-- | plugins/AutoShutdown/src/watcher.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/plugins/AutoShutdown/src/watcher.cpp b/plugins/AutoShutdown/src/watcher.cpp index e30ab9ad5f..b01cb95735 100644 --- a/plugins/AutoShutdown/src/watcher.cpp +++ b/plugins/AutoShutdown/src/watcher.cpp @@ -91,23 +91,21 @@ static wchar_t* GetMessageText(BYTE **ppBlob, DWORD *pcbBlob) static int MsgEventAdded(WPARAM, LPARAM hDbEvent)
{
if (currentWatcherType & SDWTF_MESSAGE) {
- DBEVENTINFO dbe = {};
- dbe.cbBlob = db_event_getBlobSize(hDbEvent);
- dbe.pBlob = (BYTE*)mir_alloc(dbe.cbBlob + 2); /* ensure term zero */
- if (dbe.pBlob == nullptr)
+ DB::EventInfo dbei;
+ dbei.cbBlob = -1;
+ if (db_event_get(hDbEvent, &dbei))
return 0;
- if (!db_event_get(hDbEvent, &dbe))
- if (dbe.eventType == EVENTTYPE_MESSAGE && !(dbe.flags & DBEF_SENT)) {
- DBVARIANT dbv;
- if (!g_plugin.getWString("Message", &dbv)) {
- TrimString(dbv.pwszVal);
- wchar_t *pszMsg = GetMessageText(&dbe.pBlob, &dbe.cbBlob);
- if (pszMsg != nullptr && wcsstr(pszMsg, dbv.pwszVal) != nullptr)
- ShutdownAndStopWatcher(); /* msg with specified text recvd */
- mir_free(dbv.pwszVal); /* does NULL check */
- }
+
+ if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) {
+ DBVARIANT dbv;
+ if (!g_plugin.getWString("Message", &dbv)) {
+ TrimString(dbv.pwszVal);
+ wchar_t *pszMsg = GetMessageText(&dbei.pBlob, &dbei.cbBlob);
+ if (pszMsg != nullptr && wcsstr(pszMsg, dbv.pwszVal) != nullptr)
+ ShutdownAndStopWatcher(); /* msg with specified text recvd */
+ mir_free(dbv.pwszVal); /* does NULL check */
}
- mir_free(dbe.pBlob);
+ }
}
return 0;
}
|