summaryrefslogtreecommitdiff
path: root/plugins/NewEventNotify
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-06-05 17:50:34 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-06-05 17:50:34 +0300
commitd7c9eb34f80f207efd47d2fc65e31aedf166c323 (patch)
tree338b9b905674dc31b1efab739dfcedeed3d8d7b3 /plugins/NewEventNotify
parentffc5a3d7550528281976745279e77ac9faba551b (diff)
major code cleaning in regard to db_event_getBlobSize & event memory allocation
Diffstat (limited to 'plugins/NewEventNotify')
-rw-r--r--plugins/NewEventNotify/src/popup.cpp26
1 files changed, 8 insertions, 18 deletions
diff --git a/plugins/NewEventNotify/src/popup.cpp b/plugins/NewEventNotify/src/popup.cpp
index 07a074042e..b2bd6190f0 100644
--- a/plugins/NewEventNotify/src/popup.cpp
+++ b/plugins/NewEventNotify/src/popup.cpp
@@ -358,12 +358,10 @@ int PopupShow(MCONTACT hContact, MEVENT hEvent, UINT eventType)
}
// get DBEVENTINFO with pBlob if preview is needed (when is test then is off)
- DBEVENTINFO dbe = {};
+ DB::EventInfo dbe;
if (hEvent) {
- if ((g_plugin.bPreview || eventType == EVENTTYPE_ADDED || eventType == EVENTTYPE_AUTHREQUEST)) {
- dbe.cbBlob = db_event_getBlobSize(hEvent);
- dbe.pBlob = (PBYTE)mir_alloc(dbe.cbBlob);
- }
+ if ((g_plugin.bPreview || eventType == EVENTTYPE_ADDED || eventType == EVENTTYPE_AUTHREQUEST))
+ dbe.cbBlob = -1;
db_event_get(hEvent, &dbe);
}
@@ -412,8 +410,6 @@ int PopupShow(MCONTACT hContact, MEVENT hEvent, UINT eventType)
mir_free(pdata);
}
- if (dbe.pBlob)
- mir_free(dbe.pBlob);
return 0;
}
@@ -458,16 +454,12 @@ int PopupUpdate(MCONTACT hContact, MEVENT hEvent)
iEvent++;
// get DBEVENTINFO with pBlob if preview is needed (when is test then is off)
- DBEVENTINFO dbe = {};
- dbe.pBlob = nullptr;
- dbe.cbBlob = 0;
- if (g_plugin.bPreview && eventData->hEvent) {
- dbe.cbBlob = db_event_getBlobSize(eventData->hEvent);
- dbe.pBlob = (PBYTE)mir_alloc(dbe.cbBlob);
- }
-
- if (eventData->hEvent)
+ DB::EventInfo dbe;
+ if (eventData->hEvent) {
+ if (g_plugin.bPreview)
+ dbe.cbBlob = -1;
db_event_get(eventData->hEvent, &dbe);
+ }
if (g_plugin.bShowDate || g_plugin.bShowTime) {
wchar_t timestamp[MAX_DATASIZE];
@@ -486,8 +478,6 @@ int PopupUpdate(MCONTACT hContact, MEVENT hEvent)
mir_snwprintf(lpzText, L"%s%s", lpzText, szEventPreview);
mir_free(szEventPreview);
- if (dbe.pBlob)
- mir_free(dbe.pBlob);
if (doReverse) {
if ((iEvent >= g_plugin.iNumberMsg && g_plugin.iNumberMsg) || !eventData->next)
break;