summaryrefslogtreecommitdiff
path: root/plugins/Spamotron
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-06-15 18:35:21 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-06-15 18:35:28 +0300
commit436e303e24e5046d6cc52ac3da51a0b51adbef36 (patch)
tree4f7d3b27ad24e710dae845558e2d719b54d1d88a /plugins/Spamotron
parentf0d86d413859d402331b49b98db7d61fef801489 (diff)
simpler way of applying server ids to messages
Diffstat (limited to 'plugins/Spamotron')
-rw-r--r--plugins/Spamotron/src/spamotron.cpp32
-rw-r--r--plugins/Spamotron/src/utils.cpp23
2 files changed, 26 insertions, 29 deletions
diff --git a/plugins/Spamotron/src/spamotron.cpp b/plugins/Spamotron/src/spamotron.cpp
index 445261ee14..f61f1c43f5 100644
--- a/plugins/Spamotron/src/spamotron.cpp
+++ b/plugins/Spamotron/src/spamotron.cpp
@@ -227,23 +227,21 @@ int OnDBEventFilterAdd(WPARAM wParam, LPARAM lParam)
wchar_t AuthEventModule[100];
char* szAuthEventModule;
if (db_get(hContact, MODULENAME, "AuthEvent", &_dbv) == 0) {
- DBEVENTINFO *_dbei = (DBEVENTINFO *)malloc(sizeof(DBEVENTINFO));
- if (_dbei != nullptr) {
- memcpy(&_dbei->cbBlob, _dbv.pbVal, sizeof(DWORD));
- _dbei->eventType = EVENTTYPE_AUTHREQUEST;
- _getCOptS(AuthEventModule, 100, hContact, "AuthEventModule", L"ICQ");
- szAuthEventModule = mir_u2a(AuthEventModule);
- _dbei->szModule = szAuthEventModule;
- _dbei->timestamp = dbei->timestamp;
- _dbei->flags = 0;
- _dbei->pBlob = _dbv.pbVal + sizeof(DWORD);
- db_event_add(hContact,_dbei);
- g_plugin.delSetting(hContact, "AuthEvent");
- g_plugin.delSetting(hContact, "AuthEventPending");
- g_plugin.delSetting(hContact, "AuthEventModule");
- mir_free(szAuthEventModule);
- free(_dbei);
- }
+ DBEVENTINFO dbei2 = {};
+ dbei2.cbBlob = *(DWORD *)_dbv.pbVal;
+ dbei2.eventType = EVENTTYPE_AUTHREQUEST;
+ _getCOptS(AuthEventModule, 100, hContact, "AuthEventModule", L"ICQ");
+ szAuthEventModule = mir_u2a(AuthEventModule);
+ dbei2.szModule = szAuthEventModule;
+ dbei2.timestamp = dbei->timestamp;
+ dbei2.pBlob = _dbv.pbVal + sizeof(DWORD);
+ db_event_add(hContact, &dbei2);
+
+ g_plugin.delSetting(hContact, "AuthEvent");
+ g_plugin.delSetting(hContact, "AuthEventPending");
+ g_plugin.delSetting(hContact, "AuthEventModule");
+ mir_free(szAuthEventModule);
+
db_free(&_dbv);
}
}
diff --git a/plugins/Spamotron/src/utils.cpp b/plugins/Spamotron/src/utils.cpp
index bdbbdacd09..52ba7ef5c4 100644
--- a/plugins/Spamotron/src/utils.cpp
+++ b/plugins/Spamotron/src/utils.cpp
@@ -488,21 +488,20 @@ void MarkUnread(MCONTACT hContact)
if (db_get(hContact, MODULENAME, "LastMsgEvents", &_dbv) == 0) {
pos = _dbv.pbVal;
while (pos - _dbv.pbVal < _dbv.cpbVal) {
- DBEVENTINFO _dbei = {};
- memcpy(&_dbei.eventType, pos, sizeof(WORD)); pos += sizeof(WORD);
- memcpy(&_dbei.flags, pos, sizeof(DWORD)); pos += sizeof(DWORD);
- memcpy(&_dbei.timestamp, pos, sizeof(DWORD)); pos += sizeof(DWORD);
+ DBEVENTINFO dbei = {};
+ memcpy(&dbei.eventType, pos, sizeof(WORD)); pos += sizeof(WORD);
+ memcpy(&dbei.flags, pos, sizeof(DWORD)); pos += sizeof(DWORD);
+ memcpy(&dbei.timestamp, pos, sizeof(DWORD)); pos += sizeof(DWORD);
- _dbei.szModule = (char*)malloc(mir_strlen((const char*)pos)+1);
- mir_strcpy(_dbei.szModule, (const char*)pos);
+ dbei.szModule = (char*)malloc(mir_strlen((const char*)pos)+1);
+ mir_strcpy((char*)dbei.szModule, (const char*)pos);
pos += mir_strlen((const char*)pos)+1;
- memcpy(&_dbei.cbBlob, pos, sizeof(DWORD)); pos += sizeof(DWORD);
- _dbei.pBlob = (PBYTE)malloc(_dbei.cbBlob);
- memcpy(_dbei.pBlob, pos, _dbei.cbBlob);
- pos += _dbei.cbBlob;
-
- db_event_add(hContact,&_dbei);
+ memcpy(&dbei.cbBlob, pos, sizeof(DWORD)); pos += sizeof(DWORD);
+ dbei.pBlob = (PBYTE)malloc(dbei.cbBlob);
+ memcpy(dbei.pBlob, pos, dbei.cbBlob);
+ pos += dbei.cbBlob;
+ db_event_add(hContact,&dbei);
}
db_free(&_dbv);
g_plugin.delSetting(hContact, "LastMsgEvents");