From 32cd89f64ef0449eac0ceea2ba9bc1aa36c5759b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 4 Feb 2018 16:42:23 +0300 Subject: the error code of db_event_get() should be checked --- plugins/SMS/src/SMS_svc.cpp | 24 ------------------------ plugins/SMS/src/stdafx.h | 1 - plugins/Scriver/src/msgs.cpp | 3 ++- plugins/TabSRMM/src/globals.cpp | 4 +++- 4 files changed, 5 insertions(+), 27 deletions(-) (limited to 'plugins') diff --git a/plugins/SMS/src/SMS_svc.cpp b/plugins/SMS/src/SMS_svc.cpp index ee3b8dc53c..1f62781b2f 100644 --- a/plugins/SMS/src/SMS_svc.cpp +++ b/plugins/SMS/src/SMS_svc.cpp @@ -49,8 +49,6 @@ int LoadModules(void) Skin_AddSound("RecvSMSConfirmation", PROTOCOL_NAMEW, LPGENW("Incoming SMS Confirmation")); RefreshAccountList(NULL, NULL); - - RestoreUnreadMessageAlerts(); return 0; } @@ -130,25 +128,3 @@ int ReadAckSMS(WPARAM, LPARAM lParam) } return 1; } - -void RestoreUnreadMessageAlerts(void) -{ - DBEVENTINFO dbei = {}; - - for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) - for (MEVENT hDbEvent = db_event_firstUnread(hContact); hDbEvent; hDbEvent = db_event_next(hContact, hDbEvent)) { - dbei.cbBlob = 0; - if (db_event_get(hDbEvent, &dbei) == 0) - if ((dbei.flags & (DBEF_SENT | DBEF_READ)) == 0 && ((dbei.eventType == ICQEVENTTYPE_SMS) || (dbei.eventType == ICQEVENTTYPE_SMSCONFIRMATION))) - if (dbei.cbBlob > MIN_SMS_DBEVENT_LEN) - handleNewMessage(hContact, (LPARAM)hDbEvent); - } - - for (MEVENT hDbEvent = db_event_firstUnread(NULL); hDbEvent; hDbEvent = db_event_next(NULL, hDbEvent)) { - dbei.cbBlob = 0; - if (db_event_get(hDbEvent, &dbei) == 0) - if ((dbei.flags & (DBEF_SENT | DBEF_READ)) == 0 && ((dbei.eventType == ICQEVENTTYPE_SMS) || (dbei.eventType == ICQEVENTTYPE_SMSCONFIRMATION))) - if (dbei.cbBlob > MIN_SMS_DBEVENT_LEN) - handleNewMessage(NULL, (LPARAM)hDbEvent); - } -} diff --git a/plugins/SMS/src/stdafx.h b/plugins/SMS/src/stdafx.h index a13314daaf..a908077d6c 100644 --- a/plugins/SMS/src/stdafx.h +++ b/plugins/SMS/src/stdafx.h @@ -122,7 +122,6 @@ int LoadModules(); int handleAckSMS(WPARAM wParam,LPARAM lParam); int handleNewMessage(WPARAM wParam,LPARAM lParam); -void RestoreUnreadMessageAlerts(); // Declaration of Menu SMS send click function int SmsRebuildContactMenu(WPARAM wParam,LPARAM lParam); diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index d7c0f1ac32..e713c569cc 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -252,7 +252,8 @@ static void RestoreUnreadMessageAlerts(void) for (MEVENT hDbEvent = db_event_firstUnread(hContact); hDbEvent; hDbEvent = db_event_next(hContact, hDbEvent)) { DBEVENTINFO dbei = {}; dbei.cbBlob = 0; - db_event_get(hDbEvent, &dbei); + if (db_event_get(hDbEvent, &dbei)) + continue; if ((dbei.flags & (DBEF_SENT | DBEF_READ)) || !DbEventIsMessageOrCustom(&dbei)) continue; diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp index e52eb2a63e..69e3799fd9 100644 --- a/plugins/TabSRMM/src/globals.cpp +++ b/plugins/TabSRMM/src/globals.cpp @@ -507,7 +507,9 @@ void CGlobals::RestoreUnreadMessageAlerts(void) for (MEVENT hDbEvent = db_event_firstUnread(hContact); hDbEvent; hDbEvent = db_event_next(hContact, hDbEvent)) { DBEVENTINFO dbei = {}; - db_event_get(hDbEvent, &dbei); + if (db_event_get(hDbEvent, &dbei)) + continue; + if (!dbei.markedRead() && dbei.eventType == EVENTTYPE_MESSAGE) { if (Srmm_FindWindow(hContact) != nullptr) continue; -- cgit v1.2.3