summaryrefslogtreecommitdiff
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
parentf0d86d413859d402331b49b98db7d61fef801489 (diff)
simpler way of applying server ids to messages
-rw-r--r--include/delphi/m_database.inc11
-rw-r--r--include/m_database.h34
-rw-r--r--include/m_db_int.h2
-rw-r--r--libs/win32/mir_app.libbin207490 -> 207154 bytes
-rw-r--r--libs/win32/mir_core.libbin467702 -> 467482 bytes
-rw-r--r--libs/win64/mir_app.libbin203122 -> 202776 bytes
-rw-r--r--libs/win64/mir_core.libbin472636 -> 472440 bytes
-rw-r--r--plugins/Actman/iac_inout.pas1
-rw-r--r--plugins/Boltun/src/actionQueue.cpp2
-rw-r--r--plugins/BuddyPounce/src/main.cpp3
-rw-r--r--plugins/CmdLine/src/mimcmd_handlers.cpp21
-rw-r--r--plugins/Db3x_mmap/src/dbevents.cpp5
-rw-r--r--plugins/Db3x_mmap/src/dbintf.h1
-rw-r--r--plugins/Dbx_mdbx/src/dbevents.cpp75
-rw-r--r--plugins/Dbx_mdbx/src/dbintf.h3
-rwxr-xr-xplugins/Dbx_sqlite/src/dbevents.cpp36
-rwxr-xr-xplugins/Dbx_sqlite/src/dbintf.h1
-rw-r--r--plugins/Import/src/dbrw/dbintf.cpp5
-rw-r--r--plugins/Import/src/dbrw/dbintf.h1
-rw-r--r--plugins/Import/src/textjson.cpp2
-rw-r--r--plugins/MirLua/src/Modules/m_database.cpp4
-rw-r--r--plugins/NewAwaySysMod/src/MsgEventAdded.cpp19
-rw-r--r--plugins/NewXstatusNotify/src/main.cpp6
-rw-r--r--plugins/NewXstatusNotify/src/xstatus.cpp2
-rw-r--r--plugins/Scriver/src/globals.cpp5
-rw-r--r--plugins/Spamotron/src/spamotron.cpp32
-rw-r--r--plugins/Spamotron/src/utils.cpp23
-rw-r--r--plugins/TabSRMM/src/sendqueue.cpp3
-rw-r--r--protocols/Discord/src/server.cpp5
-rw-r--r--protocols/ICQ-WIM/src/server.cpp7
-rwxr-xr-xprotocols/JabberG/src/jabber_proto.cpp2
-rw-r--r--protocols/SkypeWeb/src/skype_db.cpp25
-rw-r--r--protocols/SkypeWeb/src/skype_proto.cpp10
-rw-r--r--protocols/SkypeWeb/src/skype_proto.h1
-rw-r--r--src/core/stdmsg/src/cmdlist.cpp5
-rw-r--r--src/mir_app/src/MDatabaseReadonly.cpp5
-rw-r--r--src/mir_app/src/mir_app.def1
-rw-r--r--src/mir_app/src/mir_app64.def1
-rw-r--r--src/mir_app/src/proto_interface.cpp4
-rw-r--r--src/mir_core/src/db.cpp5
-rw-r--r--src/mir_core/src/mir_core.def1
-rw-r--r--src/mir_core/src/mir_core64.def1
42 files changed, 166 insertions, 204 deletions
diff --git a/include/delphi/m_database.inc b/include/delphi/m_database.inc
index 35bb5118c1..65c3ba5f31 100644
--- a/include/delphi/m_database.inc
+++ b/include/delphi/m_database.inc
@@ -40,11 +40,12 @@ type
PDBEVENTINFO = ^TDBEVENTINFO;
TDBEVENTINFO = record
szModule : PAnsiChar; // module that 'owns' this event and controls the data format
- timestamp: dword; // timestamp in UNIX time
- flags : dword; // the DBEF_* flags above
- eventType: word; // event type, such as message, can be module defined
- cbBlob : dword; // size in bytes of pBlob^
- pBlob : PByte; // pointer to buffer containing the module defined event data
+ timestamp: dword; // timestamp in UNIX time
+ flags : dword; // the DBEF_* flags above
+ eventType: word; // event type, such as message, can be module defined
+ cbBlob : dword; // size in bytes of pBlob^
+ pBlob : PByte; // pointer to buffer containing the module defined event data
+ szId : PAnsiChar; // unique server id
end;
(******************************************************************************
diff --git a/include/m_database.h b/include/m_database.h
index c3d030ccb9..c0df1392e7 100644
--- a/include/m_database.h
+++ b/include/m_database.h
@@ -160,23 +160,25 @@ struct DBVARIANT
};
};
-#define DBEF_TEMPORARY 1 // disable notifications about temporary database events
-#define DBEF_SENT 2 // this event was sent by the user. If not set this event was received.
-#define DBEF_READ 4 // event has been read by the user. It does not need to be processed any more except for history.
-#define DBEF_RTL 8 // event contains the right-to-left aligned text
-#define DBEF_UTF 16 // event contains a text in utf-8
-#define DBEF_ENCRYPTED 32 // event is encrypted (never reported outside a driver)
+#define DBEF_TEMPORARY 0x0001 // disable notifications about temporary database events
+#define DBEF_SENT 0x0002 // this event was sent by the user. If not set this event was received.
+#define DBEF_READ 0x0004 // event has been read by the user. It does not need to be processed any more except for history.
+#define DBEF_RTL 0x0008 // event contains the right-to-left aligned text
+#define DBEF_UTF 0x0010 // event contains a text in utf-8
+#define DBEF_ENCRYPTED 0x0020 // event is encrypted (never reported outside a driver)
+#define DBEF_HAS_ID 0x0040 // event has unique server id
struct DBEVENTINFO
{
- char *szModule; // pointer to name of the module that 'owns' this event
- DWORD timestamp; // seconds since 00:00, 01/01/1970. Gives us times until 2106
- // unless you use the standard C library which is
- // signed and can only do until 2038. In GMT.
- DWORD flags; // combination of DBEF_* flags
- WORD eventType; // module-defined event type field
- DWORD cbBlob; // size of pBlob in bytes
- PBYTE pBlob; // pointer to buffer containing module-defined event data
+ const char *szModule; // pointer to name of the module that 'owns' this event
+ DWORD timestamp; // seconds since 00:00, 01/01/1970. Gives us times until 2106
+ // unless you use the standard C library which is
+ // signed and can only do until 2038. In GMT.
+ DWORD flags; // combination of DBEF_* flags
+ WORD eventType; // module-defined event type field
+ DWORD cbBlob; // size of pBlob in bytes
+ PBYTE pBlob; // pointer to buffer containing module-defined event data
+ const char *szId; // server id
bool __forceinline markedRead() const {
return (flags & (DBEF_SENT | DBEF_READ)) != 0;
@@ -357,10 +359,6 @@ EXTERN_C MIR_CORE_DLL(MEVENT) db_event_prev(MCONTACT hContact, MEVENT hDbEvent);
EXTERN_C MIR_CORE_DLL(MEVENT) db_event_getById(const char *szModule, const char *szId);
-// Sets an identifier for an event identified by its module and handle
-
-EXTERN_C MIR_CORE_DLL(MEVENT) db_event_setId(const char *szModule, MEVENT hDbEvent, const char *szId);
-
/////////////////////////////////////////////////////////////////////////////////////////
// Database settings
diff --git a/include/m_db_int.h b/include/m_db_int.h
index d6ca63d206..775c066b5a 100644
--- a/include/m_db_int.h
+++ b/include/m_db_int.h
@@ -132,7 +132,6 @@ interface MIR_APP_EXPORT MIDatabase
STDMETHOD_(BOOL, Backup)(LPCWSTR) PURE;
STDMETHOD_(MEVENT, GetEventById)(LPCSTR szModule, LPCSTR szId) PURE;
- STDMETHOD_(BOOL, SetEventId)(LPCSTR szModule, MEVENT, LPCSTR szId) PURE;
STDMETHOD_(DB::EventCursor*, EventCursor)(MCONTACT hContact, MEVENT hDbEvent) PURE;
STDMETHOD_(DB::EventCursor*, EventCursorRev)(MCONTACT hContact, MEVENT hDbEvent) PURE;
@@ -236,7 +235,6 @@ public:
////////////////////////////////////////////////////////////////////////////////////////
STDMETHODIMP_(MEVENT) GetEventById(LPCSTR szModule, LPCSTR szId) override;
- STDMETHODIMP_(BOOL) SetEventId(LPCSTR szModule, MEVENT, LPCSTR szId) override;
};
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index 89e16b8e60..d8e7e576ca 100644
--- a/libs/win32/mir_app.lib
+++ b/libs/win32/mir_app.lib
Binary files differ
diff --git a/libs/win32/mir_core.lib b/libs/win32/mir_core.lib
index dab014d3d9..1f08418c13 100644
--- a/libs/win32/mir_core.lib
+++ b/libs/win32/mir_core.lib
Binary files differ
diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib
index 95053c8104..e2a276057e 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
diff --git a/libs/win64/mir_core.lib b/libs/win64/mir_core.lib
index e6e9573b12..0d0126fb43 100644
--- a/libs/win64/mir_core.lib
+++ b/libs/win64/mir_core.lib
Binary files differ
diff --git a/plugins/Actman/iac_inout.pas b/plugins/Actman/iac_inout.pas
index d6abe6085b..713ff00bcb 100644
--- a/plugins/Actman/iac_inout.pas
+++ b/plugins/Actman/iac_inout.pas
@@ -266,6 +266,7 @@ begin
if DBReadByte(hContact,p,'ChatRoom',0)<>1 then
begin
WidetoUTF8(last,blob);
+ FillChar(dbei,SizeOf(dbeo),0);
ccs.hContact := hContact;
ccs.szProtoService := PSS_MESSAGE;
diff --git a/plugins/Boltun/src/actionQueue.cpp b/plugins/Boltun/src/actionQueue.cpp
index f31d1c6f75..52873c80ac 100644
--- a/plugins/Boltun/src/actionQueue.cpp
+++ b/plugins/Boltun/src/actionQueue.cpp
@@ -93,8 +93,8 @@ static void TimerAnswer(MCONTACT hContact, const TalkBot::MessageInfo* info)
dbei.flags = DBEF_SENT | DBEF_UTF;
dbei.szModule = BOLTUN_NAME;
dbei.timestamp = (DWORD)time(0);
-
db_event_add(hContact, &dbei);
+
bot->AnswerGiven(hContact, *info);
delete info;
diff --git a/plugins/BuddyPounce/src/main.cpp b/plugins/BuddyPounce/src/main.cpp
index bf7de24bb2..6cb099bfc7 100644
--- a/plugins/BuddyPounce/src/main.cpp
+++ b/plugins/BuddyPounce/src/main.cpp
@@ -36,11 +36,12 @@ int MsgAck(WPARAM, LPARAM lParam)
CreateMessageAcknowlegedWindow(ack->hContact, ack->result == ACKRESULT_SUCCESS);
if (ack->result == ACKRESULT_SUCCESS) {
// wrtie it to the DB
- DBEVENTINFO dbei = {};
DBVARIANT dbv;
int reuse = g_plugin.getByte(ack->hContact, "Reuse");
if (!g_plugin.getWString(ack->hContact, "PounceMsg", &dbv) && (dbv.pwszVal[0] != '\0')) {
T2Utf pszUtf(dbv.pwszVal);
+
+ DBEVENTINFO dbei = {};
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.flags = DBEF_UTF | DBEF_SENT;
dbei.szModule = (char*)ack->szModule;
diff --git a/plugins/CmdLine/src/mimcmd_handlers.cpp b/plugins/CmdLine/src/mimcmd_handlers.cpp
index 7427dc3257..d4393eae43 100644
--- a/plugins/CmdLine/src/mimcmd_handlers.cpp
+++ b/plugins/CmdLine/src/mimcmd_handlers.cpp
@@ -702,19 +702,14 @@ void HandleMessageCommand(PCommand command, TArgument *argv, int argc, PReply re
if (ack->szModule) {
szReply.AppendFormat(TranslateT("Message sent to '%s'."), contact);
- DBEVENTINFO e = {};
- char module[128];
- e.eventType = EVENTTYPE_MESSAGE;
- e.flags = DBEF_SENT | DBEF_UTF;
-
- e.pBlob = (PBYTE)szMessage.get();
- e.cbBlob = (DWORD)mir_strlen(szMessage) + 1;
-
- strncpy_s(module, ack->szModule, _countof(module));
- e.szModule = module;
- e.timestamp = (DWORD)time(0);
-
- db_event_add(ack->hContact, &e);
+ DBEVENTINFO dbei = {};
+ dbei.eventType = EVENTTYPE_MESSAGE;
+ dbei.flags = DBEF_SENT | DBEF_UTF;
+ dbei.pBlob = (PBYTE)szMessage.get();
+ dbei.cbBlob = (DWORD)mir_strlen(szMessage) + 1;
+ dbei.szModule = ack->szModule;
+ dbei.timestamp = (DWORD)time(0);
+ db_event_add(ack->hContact, &dbei);
}
else szReply.AppendFormat(TranslateT("Message to '%s' was marked as sent but the account seems to be offline"), contact);
}
diff --git a/plugins/Db3x_mmap/src/dbevents.cpp b/plugins/Db3x_mmap/src/dbevents.cpp
index a49e9ebbfb..e2e37f15a8 100644
--- a/plugins/Db3x_mmap/src/dbevents.cpp
+++ b/plugins/Db3x_mmap/src/dbevents.cpp
@@ -542,8 +542,3 @@ MEVENT CDb3Mmap::GetEventById(LPCSTR, LPCSTR)
{
return 0;
}
-
-BOOL CDb3Mmap::SetEventId(LPCSTR, MEVENT, LPCSTR)
-{
- return FALSE;
-}
diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h
index 97c262f8ce..17f634e051 100644
--- a/plugins/Db3x_mmap/src/dbintf.h
+++ b/plugins/Db3x_mmap/src/dbintf.h
@@ -242,7 +242,6 @@ public:
STDMETHODIMP_(BOOL) MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) override;
STDMETHODIMP_(MEVENT) GetEventById(LPCSTR szModule, LPCSTR szId) override;
- STDMETHODIMP_(BOOL) SetEventId(LPCSTR szModule, MEVENT, LPCSTR szId) override;
protected:
DWORD GetSettingsGroupOfsByModuleNameOfs(DBContact *dbc, DWORD ofsModuleName);
diff --git a/plugins/Dbx_mdbx/src/dbevents.cpp b/plugins/Dbx_mdbx/src/dbevents.cpp
index f065989221..724c5e4542 100644
--- a/plugins/Dbx_mdbx/src/dbevents.cpp
+++ b/plugins/Dbx_mdbx/src/dbevents.cpp
@@ -52,6 +52,7 @@ BOOL CDbxMDBX::DeleteEvent(MEVENT hDbEvent)
{
DBCachedContact *cc, *cc2;
DBEvent dbe;
+ char *szId = nullptr;
{
txn_ptr_ro txn(m_txn_ro);
MDBX_val key = { &hDbEvent, sizeof(MEVENT) }, data;
@@ -59,6 +60,11 @@ BOOL CDbxMDBX::DeleteEvent(MEVENT hDbEvent)
return 1;
dbe = *(DBEvent*)data.iov_base;
+ if (dbe.flags & DBEF_HAS_ID) {
+ char *src = (char *)data.iov_base + sizeof(dbe) + dbe.cbBlob + 1;
+ szId = NEWSTR_ALLOCA(src);
+ }
+
cc = (dbe.dwContactID != 0) ? m_cache->GetCachedContact(dbe.dwContactID) : &m_ccDummy;
if (cc == nullptr || cc->dbc.dwEventCount == 0)
return 1;
@@ -111,6 +117,15 @@ BOOL CDbxMDBX::DeleteEvent(MEVENT hDbEvent)
return 1;
}
+ if (szId) {
+ DBEventIdKey keyId;
+ keyId.iModuleId = dbe.iModuleId;
+ strncpy_s(keyId.szEventId, szId, _TRUNCATE);
+
+ MDBX_val keyid = { &keyId, sizeof(MEVENT) + strlen(keyId.szEventId) + 1 };
+ mdbx_del(trnlck, m_dbEventIds, &keyid, nullptr);
+ }
+
// remove an event
key.iov_len = sizeof(MEVENT); key.iov_base = &hDbEvent;
if (mdbx_del(trnlck, m_dbEvents, &key, nullptr) != MDBX_SUCCESS)
@@ -194,14 +209,25 @@ bool CDbxMDBX::EditEvent(MCONTACT contactID, MEVENT hDbEvent, const DBEVENTINFO
}
}
- {
- BYTE *recBuf = (BYTE*)_alloca(sizeof(DBEvent) + dbe.cbBlob);
- DBEvent *pNewEvent = (DBEvent*)recBuf;
- *pNewEvent = dbe;
- memcpy(pNewEvent + 1, pBlob, dbe.cbBlob);
+ size_t cbSrvId = mir_strlen(dbei->szId);
+ if (cbSrvId > 0) {
+ cbSrvId++;
+ dbe.flags |= DBEF_HAS_ID;
+ }
+ BYTE *recBuf = (BYTE*)_alloca(sizeof(DBEvent) + dbe.cbBlob + cbSrvId + 1), *p = recBuf;
+ memcpy(p, &dbe, sizeof(dbe)); p += sizeof(dbe);
+ memcpy(p, pBlob, dbe.cbBlob); p += dbe.cbBlob;
+ if (*p != 0)
+ *p++ = 0;
+ if (cbSrvId) {
+ memcpy(p, dbei->szId, cbSrvId);
+ p += cbSrvId;
+ }
+
+ {
txn_ptr trnlck(StartTran());
- MDBX_val key = { &hDbEvent, sizeof(MEVENT) }, data = { recBuf, sizeof(DBEvent) + dbe.cbBlob };
+ MDBX_val key = { &hDbEvent, sizeof(MEVENT) }, data = { recBuf, int(p - recBuf) };
if (mdbx_put(trnlck, m_dbEvents, &key, &data, 0) != MDBX_SUCCESS)
return false;
@@ -238,6 +264,16 @@ bool CDbxMDBX::EditEvent(MCONTACT contactID, MEVENT hDbEvent, const DBEVENTINFO
return false;
}
+ if (dbei->szId) {
+ DBEventIdKey keyId;
+ keyId.iModuleId = dbe.iModuleId;
+ strncpy_s(keyId.szEventId, dbei->szId, _TRUNCATE);
+
+ MDBX_val keyid = { &keyId, sizeof(MEVENT) + strlen(keyId.szEventId) + 1 }, dataid = { &hDbEvent, sizeof(hDbEvent) };
+ if (mdbx_put(trnlck, m_dbEventIds, &keyid, &dataid, 0) != MDBX_SUCCESS)
+ return false;
+ }
+
if (trnlck.commit() != MDBX_SUCCESS)
return false;
}
@@ -273,6 +309,7 @@ BOOL CDbxMDBX::GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbei)
return 1;
}
+ size_t cbBlob;
const DBEvent *dbe;
{
txn_ptr_ro txn(m_txn_ro);
@@ -282,13 +319,14 @@ BOOL CDbxMDBX::GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbei)
return 1;
dbe = (const DBEvent*)data.iov_base;
+ cbBlob = data.iov_len - sizeof(DBEvent);
}
dbei->szModule = GetModuleName(dbe->iModuleId);
dbei->timestamp = dbe->timestamp;
dbei->flags = dbe->flags;
dbei->eventType = dbe->wEventType;
- size_t bytesToCopy = min(dbei->cbBlob, dbe->cbBlob);
+ size_t bytesToCopy = min(dbei->cbBlob, cbBlob);
dbei->cbBlob = dbe->cbBlob;
if (bytesToCopy && dbei->pBlob) {
BYTE *pSrc = (BYTE*)dbe + sizeof(DBEvent);
@@ -302,9 +340,13 @@ BOOL CDbxMDBX::GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbei)
memcpy(dbei->pBlob, pBlob, bytesToCopy);
if (bytesToCopy > len)
memset(dbei->pBlob + len, 0, bytesToCopy - len);
+
mir_free(pBlob);
}
else memcpy(dbei->pBlob, pSrc, bytesToCopy);
+
+ if (dbei->flags & DBEF_HAS_ID)
+ dbei->szId = (char *)pSrc + dbei->cbBlob + 1;
}
return 0;
}
@@ -439,25 +481,6 @@ MEVENT CDbxMDBX::GetEventById(LPCSTR szModule, LPCSTR szId)
return hDbEvent;
}
-BOOL CDbxMDBX::SetEventId(LPCSTR szModule, MEVENT hDbEvent, LPCSTR szId)
-{
- if (szModule == nullptr || szId == nullptr || !hDbEvent)
- return 1;
-
- DBEventIdKey keyId;
- keyId.iModuleId = GetModuleID(szModule);
- strncpy_s(keyId.szEventId, szId, _TRUNCATE);
-
- txn_ptr trnlck(StartTran());
- MDBX_val key = { &keyId, sizeof(MEVENT) + strlen(keyId.szEventId) + 1 }, data = { &hDbEvent, sizeof(hDbEvent) };
- if (mdbx_put(trnlck, m_dbEventIds, &key, &data, 0) != MDBX_SUCCESS)
- return 1;
- if (trnlck.commit() != MDBX_SUCCESS)
- return 1;
-
- return 0;
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
MCONTACT CDbxMDBX::GetEventContact(MEVENT hDbEvent)
diff --git a/plugins/Dbx_mdbx/src/dbintf.h b/plugins/Dbx_mdbx/src/dbintf.h
index 06602c8632..0a29c30a78 100644
--- a/plugins/Dbx_mdbx/src/dbintf.h
+++ b/plugins/Dbx_mdbx/src/dbintf.h
@@ -296,8 +296,7 @@ public:
STDMETHODIMP_(BOOL) Backup(const wchar_t*);
STDMETHODIMP_(MEVENT) GetEventById(LPCSTR szModule, LPCSTR szId) override;
- STDMETHODIMP_(BOOL) SetEventId(LPCSTR szModule, MEVENT, LPCSTR szId) override;
-
+
STDMETHODIMP_(DB::EventCursor *) EventCursor(MCONTACT hContact, MEVENT hDbEvent) override;
STDMETHODIMP_(DB::EventCursor *) EventCursorRev(MCONTACT hContact, MEVENT hDbEvent) override;
diff --git a/plugins/Dbx_sqlite/src/dbevents.cpp b/plugins/Dbx_sqlite/src/dbevents.cpp
index 9c24ddb3f0..4b5c3e80de 100755
--- a/plugins/Dbx_sqlite/src/dbevents.cpp
+++ b/plugins/Dbx_sqlite/src/dbevents.cpp
@@ -14,7 +14,6 @@ enum {
SQL_EVT_STMT_FINDFIRSTUNREAD,
SQL_EVT_STMT_FINDLAST,
SQL_EVT_STMT_GETIDBYSRVID,
- SQL_EVT_STMT_SETSRVID,
SQL_EVT_STMT_ADDEVENT_SRT,
SQL_EVT_STMT_DELETE_SRT,
SQL_EVT_STMT_META_SPLIT,
@@ -37,7 +36,7 @@ static const char* reverse_order_pos_query =
static const char *evt_stmts[SQL_EVT_STMT_NUM] = {
"select count(1) from events where contact_id = ? limit 1;",
- "insert into events(contact_id, module, timestamp, type, flags, data) values (?, ?, ?, ?, ?, ?);",
+ "insert into events(contact_id, module, timestamp, type, flags, data, server_id) values (?, ?, ?, ?, ?, ?, ?);",
"delete from events where id = ?;",
"update events set module = ?, timestamp = ?, type = ?, flags = ?, blob = ? where id = ?;",
"select length(data) from events where id = ? limit 1;",
@@ -49,7 +48,6 @@ static const char *evt_stmts[SQL_EVT_STMT_NUM] = {
"select id, timestamp from events where contact_id = ? and (flags & ?) = 0 order by timestamp, id limit 1;",
reverse_order_query,
"select id, timestamp from events where module = ? and server_id = ? limit 1;",
- "update events set server_id = ? where id = ?;",
"insert into events_srt(id, contact_id, timestamp) values (?, ?, ?);",
"delete from events_srt where id = ?;",
"delete from events_srt where contact_id = ?;",
@@ -173,14 +171,23 @@ MEVENT CDbxSQLite::AddEvent(MCONTACT hContact, const DBEVENTINFO *dbei)
MEVENT hDbEvent = 0;
{
+ const char *szEventId;
+ DWORD dwFlags = dbei->flags;
+ if (dbei->szId != nullptr) {
+ dwFlags |= DBEF_HAS_ID;
+ szEventId = dbei->szId;
+ }
+ else szEventId = "";
+
mir_cslock lock(m_csDbAccess);
sqlite3_stmt *stmt = evt_stmts_prep[SQL_EVT_STMT_ADDEVENT];
sqlite3_bind_int64(stmt, 1, hContact);
sqlite3_bind_text(stmt, 2, dbei->szModule, (int)mir_strlen(dbei->szModule), nullptr);
sqlite3_bind_int64(stmt, 3, dbei->timestamp);
sqlite3_bind_int(stmt, 4, dbei->eventType);
- sqlite3_bind_int64(stmt, 5, dbei->flags);
+ sqlite3_bind_int64(stmt, 5, dwFlags);
sqlite3_bind_blob(stmt, 6, dbei->pBlob, dbei->cbBlob, nullptr);
+ sqlite3_bind_text(stmt, 7, szEventId, (int)mir_strlen(szEventId), nullptr);
int rc = sqlite3_step(stmt);
assert(rc == SQLITE_DONE);
sqlite3_reset(stmt);
@@ -209,7 +216,7 @@ MEVENT CDbxSQLite::AddEvent(MCONTACT hContact, const DBEVENTINFO *dbei)
ccSub->AddEvent(hDbEvent, dbei->timestamp, !dbei->markedRead());
}
- char *module = m_modules.find(dbei->szModule);
+ char *module = m_modules.find((char*)dbei->szModule);
if (module == nullptr)
m_modules.insert(mir_strdup(dbei->szModule));
}
@@ -289,7 +296,7 @@ BOOL CDbxSQLite::EditEvent(MCONTACT hContact, MEVENT hDbEvent, const DBEVENTINFO
if (cc->IsSub() && (cc = m_cache->GetCachedContact(cc->parentID)))
cc->EditEvent(hDbEvent, dbei->timestamp, !dbei->markedRead());
- char *module = m_modules.find(dbei->szModule);
+ char *module = m_modules.find((char*)dbei->szModule);
if (module == nullptr)
m_modules.insert(mir_strdup(dbei->szModule));
}
@@ -619,7 +626,7 @@ MEVENT CDbxSQLite::FindPrevEvent(MCONTACT hContact, MEVENT hDbEvent)
return 0;
}
- while (hDbEvent != sqlite3_column_int64(evt_cur_backwd, 0))
+ while (hDbEvent != sqlite3_column_int64(evt_cur_backwd, 0))
{
int rc = sqlite3_step(evt_cur_backwd);
assert(rc == SQLITE_ROW || rc == SQLITE_DONE);
@@ -669,21 +676,6 @@ MEVENT CDbxSQLite::GetEventById(LPCSTR szModule, LPCSTR szId)
return hDbEvent;
}
-BOOL CDbxSQLite::SetEventId(LPCSTR, MEVENT hDbEvent, LPCSTR szId)
-{
- if (hDbEvent == 0 || szId == nullptr)
- return 1;
-
- mir_cslock lock(m_csDbAccess);
- sqlite3_stmt *stmt = evt_stmts_prep[SQL_EVT_STMT_SETSRVID];
- sqlite3_bind_text(stmt, 1, szId, (int)mir_strlen(szId), nullptr);
- sqlite3_bind_int64(stmt, 2, hDbEvent);
- int rc = sqlite3_step(stmt);
- assert(rc == SQLITE_ROW || rc == SQLITE_DONE);
- sqlite3_reset(stmt);
- return (rc != SQLITE_DONE);
-}
-
BOOL CDbxSQLite::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub)
{
//TODO: test this
diff --git a/plugins/Dbx_sqlite/src/dbintf.h b/plugins/Dbx_sqlite/src/dbintf.h
index 70d021f202..62582a21c1 100755
--- a/plugins/Dbx_sqlite/src/dbintf.h
+++ b/plugins/Dbx_sqlite/src/dbintf.h
@@ -87,7 +87,6 @@ public:
STDMETHODIMP_(MEVENT) FindPrevEvent(MCONTACT contactID, MEVENT hDbEvent) override;
STDMETHODIMP_(MEVENT) GetEventById(LPCSTR szModule, LPCSTR szId) override;
- STDMETHODIMP_(BOOL) SetEventId(LPCSTR szModule, MEVENT, LPCSTR szId) override;
STDMETHODIMP_(BOOL) EnumModuleNames(DBMODULEENUMPROC pFunc, void *pParam) override;
diff --git a/plugins/Import/src/dbrw/dbintf.cpp b/plugins/Import/src/dbrw/dbintf.cpp
index aae77e66ab..4369c03eea 100644
--- a/plugins/Import/src/dbrw/dbintf.cpp
+++ b/plugins/Import/src/dbrw/dbintf.cpp
@@ -85,8 +85,3 @@ STDMETHODIMP_(MEVENT) CDbxSQLite::GetEventById(LPCSTR, LPCSTR)
{
return 0;
}
-
-STDMETHODIMP_(BOOL) CDbxSQLite::SetEventId(LPCSTR, MEVENT, LPCSTR)
-{
- return FALSE;
-}
diff --git a/plugins/Import/src/dbrw/dbintf.h b/plugins/Import/src/dbrw/dbintf.h
index 09d7514f2f..e6a171f87d 100644
--- a/plugins/Import/src/dbrw/dbintf.h
+++ b/plugins/Import/src/dbrw/dbintf.h
@@ -156,5 +156,4 @@ public:
STDMETHODIMP_(BOOL) MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) override;
STDMETHODIMP_(MEVENT) GetEventById(LPCSTR szModule, LPCSTR szId) override;
- STDMETHODIMP_(BOOL) SetEventId(LPCSTR szModule, MEVENT, LPCSTR szId) override;
};
diff --git a/plugins/Import/src/textjson.cpp b/plugins/Import/src/textjson.cpp
index 242574cc3a..b2fc92dae1 100644
--- a/plugins/Import/src/textjson.cpp
+++ b/plugins/Import/src/textjson.cpp
@@ -151,7 +151,7 @@ public:
dbei->szModule = m_modules.find((char*)szModule.c_str());
if (dbei->szModule == nullptr) {
dbei->szModule = mir_strdup(szModule.c_str());
- m_modules.insert(dbei->szModule);
+ m_modules.insert((char*)dbei->szModule);
}
}
diff --git a/plugins/MirLua/src/Modules/m_database.cpp b/plugins/MirLua/src/Modules/m_database.cpp
index d4f5a051be..f00887a7da 100644
--- a/plugins/MirLua/src/Modules/m_database.cpp
+++ b/plugins/MirLua/src/Modules/m_database.cpp
@@ -327,10 +327,10 @@ static int db_AddEvent(lua_State *L)
{
MCONTACT hContact = luaL_optinteger(L, 1, 0);
- DBEVENTINFO dbei;
+ DBEVENTINFO dbei = {};
MakeDbEvent(L, dbei);
- MEVENT hDbEvent = db_event_add(hContact, &dbei);
+ MEVENT hDbEvent = db_event_add(hContact, &dbei);
if (hDbEvent)
lua_pushnumber(L, hDbEvent);
else
diff --git a/plugins/NewAwaySysMod/src/MsgEventAdded.cpp b/plugins/NewAwaySysMod/src/MsgEventAdded.cpp
index ff4d1c35d4..56749a1d7f 100644
--- a/plugins/NewAwaySysMod/src/MsgEventAdded.cpp
+++ b/plugins/NewAwaySysMod/src/MsgEventAdded.cpp
@@ -64,17 +64,16 @@ void __cdecl AutoreplyDelayThread(CAutoreplyData *ad)
ProtoChainSend(ad->hContact, PSS_MESSAGE, 0, (LPARAM)pszReply);
if (g_AutoreplyOptPage.GetDBValueCopy(IDC_REPLYDLG_LOGREPLY)) { // store in the history
- DBEVENTINFO dbeo = {};
- dbeo.eventType = EVENTTYPE_MESSAGE;
- dbeo.flags = DBEF_SENT | DBEF_UTF;
- dbeo.szModule = szProto;
- dbeo.timestamp = time(0);
-
- dbeo.cbBlob = ReplyLen;
- dbeo.pBlob = (PBYTE)(char*)pszReply;
-
SleepEx(1000, true); // delay before sending the reply, as we need it to be later than the message we're replying to (without this delay, srmm puts the messages in a wrong order)
- db_event_add(ad->hContact, &dbeo);
+
+ DBEVENTINFO dbei = {};
+ dbei.eventType = EVENTTYPE_MESSAGE;
+ dbei.flags = DBEF_SENT | DBEF_UTF;
+ dbei.szModule = szProto;
+ dbei.timestamp = time(0);
+ dbei.cbBlob = ReplyLen;
+ dbei.pBlob = (PBYTE)(char*)pszReply;
+ db_event_add(ad->hContact, &dbei);
}
delete ad;
diff --git a/plugins/NewXstatusNotify/src/main.cpp b/plugins/NewXstatusNotify/src/main.cpp
index 0da90707e8..2992e620d2 100644
--- a/plugins/NewXstatusNotify/src/main.cpp
+++ b/plugins/NewXstatusNotify/src/main.cpp
@@ -275,11 +275,10 @@ void LogSMsgToDB(STATUSMSGINFO *smi, const wchar_t *tmplt)
dbei.pBlob = (PBYTE)blob;
dbei.eventType = EVENTTYPE_STATUSCHANGE;
dbei.flags = DBEF_READ | DBEF_UTF;
-
dbei.timestamp = (DWORD)time(0);
dbei.szModule = MODULENAME;
- MEVENT hDBEvent = db_event_add(smi->hContact, &dbei);
+ MEVENT hDBEvent = db_event_add(smi->hContact, &dbei);
if (opt.SMsgLogToDB_WinOpen && opt.SMsgLogToDB_Remove) {
DBEVENT *dbevent = (DBEVENT *)mir_alloc(sizeof(DBEVENT));
dbevent->hContact = smi->hContact;
@@ -360,11 +359,10 @@ int ContactStatusChanged(MCONTACT hContact, WORD oldStatus, WORD newStatus)
dbei.pBlob = (PBYTE)blob;
dbei.eventType = EVENTTYPE_STATUSCHANGE;
dbei.flags = DBEF_READ | DBEF_UTF;
-
dbei.timestamp = (DWORD)time(0);
dbei.szModule = MODULENAME;
- MEVENT hDBEvent = db_event_add(hContact, &dbei);
+ MEVENT hDBEvent = db_event_add(hContact, &dbei);
if (opt.LogToDB_WinOpen && opt.LogToDB_Remove) {
DBEVENT *dbevent = (DBEVENT *)mir_alloc(sizeof(DBEVENT));
dbevent->hContact = hContact;
diff --git a/plugins/NewXstatusNotify/src/xstatus.cpp b/plugins/NewXstatusNotify/src/xstatus.cpp
index b703204fd5..3e72eed316 100644
--- a/plugins/NewXstatusNotify/src/xstatus.cpp
+++ b/plugins/NewXstatusNotify/src/xstatus.cpp
@@ -294,8 +294,8 @@ void LogChangeToDB(XSTATUSCHANGE *xsc)
dbei.flags = DBEF_READ | DBEF_UTF;
dbei.timestamp = (DWORD)time(0);
dbei.szModule = MODULENAME;
- MEVENT hDBEvent = db_event_add(xsc->hContact, &dbei);
+ MEVENT hDBEvent = db_event_add(xsc->hContact, &dbei);
if (opt.XLogToDB_WinOpen && opt.XLogToDB_Remove) {
DBEVENT *dbevent = (DBEVENT *)mir_alloc(sizeof(DBEVENT));
dbevent->hContact = xsc->hContact;
diff --git a/plugins/Scriver/src/globals.cpp b/plugins/Scriver/src/globals.cpp
index ac1d9be163..6c017b7266 100644
--- a/plugins/Scriver/src/globals.cpp
+++ b/plugins/Scriver/src/globals.cpp
@@ -149,14 +149,13 @@ static int ackevent(WPARAM, LPARAM lParam)
dbei.timestamp = time(0);
dbei.cbBlob = (int)mir_strlen(item->sendBuffer) + 1;
dbei.pBlob = (PBYTE)item->sendBuffer;
+ dbei.szId = (char *)pAck->lParam;
MessageWindowEvent evt = { item->hSendId, hContact, &dbei };
NotifyEventHooks(g_chatApi.hevPreCreate, 0, (LPARAM)&evt);
item->sendBuffer = (char *)dbei.pBlob;
- MEVENT hNewEvent = db_event_add(hContact, &dbei);
- if (hNewEvent && pAck->lParam)
- db_event_setId(dbei.szModule, hNewEvent, (char *)pAck->lParam);
+ db_event_add(hContact, &dbei);
if (item->hwndErrorDlg != nullptr)
DestroyWindow(item->hwndErrorDlg);
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");
diff --git a/plugins/TabSRMM/src/sendqueue.cpp b/plugins/TabSRMM/src/sendqueue.cpp
index a31bbac0fd..bf444489fd 100644
--- a/plugins/TabSRMM/src/sendqueue.cpp
+++ b/plugins/TabSRMM/src/sendqueue.cpp
@@ -472,14 +472,13 @@ int SendQueue::ackMessage(CMsgDialog *dat, WPARAM wParam, LPARAM lParam)
if (job.dwFlags & PREF_RTL)
dbei.flags |= DBEF_RTL;
dbei.pBlob = (PBYTE)job.szSendBuffer;
+ dbei.szId = (char *)ack->lParam;
MessageWindowEvent evt = { job.iSendId, job.hContact, &dbei };
NotifyEventHooks(g_chatApi.hevPreCreate, 0, (LPARAM)&evt);
job.szSendBuffer = (char*)dbei.pBlob;
MEVENT hNewEvent = db_event_add(job.hContact, &dbei);
- if (hNewEvent && ack->lParam)
- db_event_setId(dbei.szModule, hNewEvent, (char*)ack->lParam);
if (m_pContainer)
if (!nen_options.iNoSounds && !m_pContainer->m_flags.m_bNoSound)
diff --git a/protocols/Discord/src/server.cpp b/protocols/Discord/src/server.cpp
index f1e3135aa4..735d2193b8 100644
--- a/protocols/Discord/src/server.cpp
+++ b/protocols/Discord/src/server.cpp
@@ -111,9 +111,8 @@ void CDiscordProto::OnReceiveHistory(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest
bSucceeded = 0 == db_event_edit(pUser->hContact, hDbEvent, &dbei);
if (!bSucceeded) {
- MEVENT hNew = db_event_add(pUser->hContact, &dbei);
- if (hNew != 0)
- db_event_setId(m_szModuleName, hNew, szMsgId);
+ dbei.szId = szMsgId;
+ db_event_add(pUser->hContact, &dbei);
}
}
else {
diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp
index 465cb052be..0794624c4a 100644
--- a/protocols/ICQ-WIM/src/server.cpp
+++ b/protocols/ICQ-WIM/src/server.cpp
@@ -75,11 +75,6 @@ MCONTACT CIcqProto::CheckOwnMessage(const CMStringA &reqId, const CMStringA &msg
MCONTACT ret = pOwn->m_hContact;
if (bRemove) {
- // here we filter service messages for SecureIM, OTR etc, i.e. messages that
- // weren't initialized by SRMM (we identify it by missing server id)
- if (db_event_getById(m_szModuleName, msgId) == 0)
- db_event_setId(m_szModuleName, 1, msgId);
-
mir_cslock lck(m_csOwnIds);
m_arOwnIds.remove(pOwn);
}
@@ -453,8 +448,6 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo
pReq << CHAR_PARAM("aimsid", m_aimsid) << CHAR_PARAM("previews", "600");
Push(pReq);
- db_event_setId(m_szModuleName, 1, szMsgId);
-
MarkAsRead(hContact);
return;
}
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp
index 5c496b1e6f..dfcea18fb0 100755
--- a/protocols/JabberG/src/jabber_proto.cpp
+++ b/protocols/JabberG/src/jabber_proto.cpp
@@ -602,6 +602,8 @@ INT_PTR CJabberProto::GetCaps(int type, MCONTACT hContact)
dwFlags = PF4_FORCEAUTH | PF4_NOCUSTOMAUTH | PF4_NOAUTHDENYREASON | PF4_SUPPORTTYPING | PF4_AVATARS | PF4_READNOTIFY;
if (m_bUseHttpUpload || m_bInlinePictures)
dwFlags |= PF4_OFFLINEFILES;
+ if (m_ThreadInfo && (m_ThreadInfo->jabberServerCaps & JABBER_CAPS_MAM))
+ dwFlags |= PF4_SERVERMSGID;
return dwFlags;
case PFLAG_UNIQUEIDTEXT:
diff --git a/protocols/SkypeWeb/src/skype_db.cpp b/protocols/SkypeWeb/src/skype_db.cpp
index c5b3aa348c..8a0869ab04 100644
--- a/protocols/SkypeWeb/src/skype_db.cpp
+++ b/protocols/SkypeWeb/src/skype_db.cpp
@@ -43,10 +43,15 @@ MEVENT CSkypeProto::AddDbEvent(WORD type, MCONTACT hContact, DWORD timestamp, DW
if (MEVENT hDbEvent = GetMessageFromDb(uid))
return hDbEvent;
- MEVENT ret = AddEventToDb(hContact, type, timestamp, flags, (DWORD)mir_strlen(content)+1, (BYTE*)content);
- if (uid && ret)
- db_event_setId(m_szModuleName, ret, uid);
- return ret;
+ DBEVENTINFO dbei = {};
+ dbei.szModule = m_szModuleName;
+ dbei.timestamp = timestamp;
+ dbei.eventType = type;
+ dbei.cbBlob = (DWORD)mir_strlen(content) + 1;
+ dbei.pBlob = (BYTE *)content;
+ dbei.flags = flags;
+ dbei.szId = uid;
+ return db_event_add(hContact, &dbei);
}
void CSkypeProto::EditEvent(MCONTACT hContact, MEVENT hEvent, const char *szContent, time_t edit_time)
@@ -92,18 +97,6 @@ void CSkypeProto::EditEvent(MCONTACT hContact, MEVENT hEvent, const char *szCont
db_event_edit(hContact, hEvent, &dbei);
}
-MEVENT CSkypeProto::AddEventToDb(MCONTACT hContact, WORD type, DWORD timestamp, DWORD flags, DWORD cbBlob, PBYTE pBlob)
-{
- DBEVENTINFO dbei = {};
- dbei.szModule = m_szModuleName;
- dbei.timestamp = timestamp;
- dbei.eventType = type;
- dbei.cbBlob = cbBlob;
- dbei.pBlob = pBlob;
- dbei.flags = flags;
- return db_event_add(hContact, &dbei);
-}
-
void CSkypeProto::InitDBEvents()
{
db_set_resident(m_szModuleName, "LastAuthRequestTime");
diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp
index 7a0bb990b5..e590729a4e 100644
--- a/protocols/SkypeWeb/src/skype_proto.cpp
+++ b/protocols/SkypeWeb/src/skype_proto.cpp
@@ -317,9 +317,15 @@ int CSkypeProto::RecvContacts(MCONTACT hContact, PROTORECVEVENT* pre)
// memcpy(pCurBlob + 1, szMessageId, mir_strlen(szMessageId));
- AddEventToDb(hContact, EVENTTYPE_CONTACTS, pre->timestamp, (pre->flags & PREF_CREATEREAD) ? DBEF_READ : 0, cbBlob, pBlob);
+ DBEVENTINFO dbei = {};
+ dbei.szModule = m_szModuleName;
+ dbei.timestamp = pre->timestamp;
+ dbei.eventType = EVENTTYPE_CONTACTS;
+ dbei.cbBlob = cbBlob;
+ dbei.pBlob = pBlob;
+ dbei.flags = (pre->flags & PREF_CREATEREAD) ? DBEF_READ : 0;
+ db_event_add(hContact, &dbei);
mir_free(pBlob);
-
return 0;
}
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h
index 8a9a243afe..52a8e04cc9 100644
--- a/protocols/SkypeWeb/src/skype_proto.h
+++ b/protocols/SkypeWeb/src/skype_proto.h
@@ -320,7 +320,6 @@ private:
{ return (!mir_strcmpi(str, m_szMyname) || !mir_strcmp(str, ptrA(getStringA("SelfEndpointName"))));
}
- MEVENT AddEventToDb(MCONTACT hContact, WORD type, DWORD timestamp, DWORD flags, DWORD cbBlob, PBYTE pBlob);
static time_t IsoToUnixTime(const char *stamp);
static CMStringA GetStringChunk(const char *haystack, const char *start, const char *end);
diff --git a/src/core/stdmsg/src/cmdlist.cpp b/src/core/stdmsg/src/cmdlist.cpp
index 35fbcac30a..dc399a27e2 100644
--- a/src/core/stdmsg/src/cmdlist.cpp
+++ b/src/core/stdmsg/src/cmdlist.cpp
@@ -95,15 +95,14 @@ void msgQueue_processack(MCONTACT hContact, int id, BOOL success, LPARAM lParam)
dbei.timestamp = time(0);
dbei.cbBlob = (DWORD)(mir_strlen(p->szMsg) + 1);
dbei.pBlob = (PBYTE)p->szMsg;
+ dbei.szId = (char *)lParam;
MessageWindowEvent evt = { id, hContact, &dbei };
NotifyEventHooks(g_chatApi.hevPreCreate, 0, (LPARAM)&evt);
p->szMsg = (char*)dbei.pBlob;
- MEVENT hNewEvent = db_event_add(hContact, &dbei);
- if (hNewEvent && lParam)
- db_event_setId(dbei.szModule, hNewEvent, (char*)lParam);
+ db_event_add(hContact, &dbei);
mir_free(p->szMsg);
mir_free(p);
diff --git a/src/mir_app/src/MDatabaseReadonly.cpp b/src/mir_app/src/MDatabaseReadonly.cpp
index c5ab94fed6..1de92de019 100644
--- a/src/mir_app/src/MDatabaseReadonly.cpp
+++ b/src/mir_app/src/MDatabaseReadonly.cpp
@@ -146,8 +146,3 @@ MEVENT MDatabaseReadonly::GetEventById(LPCSTR, LPCSTR)
{
return 0;
}
-
-BOOL MDatabaseReadonly::SetEventId(LPCSTR, MEVENT, LPCSTR)
-{
- return FALSE;
-}
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index c096e56e47..73c6f0edf6 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -597,7 +597,6 @@ Miranda_WaitOnHandleEx @663
??0MDatabaseReadonly@@QAE@XZ @684 NONAME
??_7MDatabaseReadonly@@6B@ @685 NONAME
?GetEventById@MDatabaseReadonly@@UAGIPBD0@Z @686 NONAME
-?SetEventId@MDatabaseReadonly@@UAGHPBDI0@Z @687 NONAME
?EditEvent@MDatabaseReadonly@@UAGHIIPBUDBEVENTINFO@@@Z @688 NONAME
g_hevContactAdded @689 NONAME
g_hevContactDeleted @690 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 3cba4b2b3b..9dcb0e0cab 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -597,7 +597,6 @@ Miranda_WaitOnHandleEx @663
??0MDatabaseReadonly@@QEAA@XZ @684 NONAME
??_7MDatabaseReadonly@@6B@ @685 NONAME
?GetEventById@MDatabaseReadonly@@UEAAIPEBD0@Z @686 NONAME
-?SetEventId@MDatabaseReadonly@@UEAAHPEBDI0@Z @687 NONAME
?EditEvent@MDatabaseReadonly@@UEAAHIIPEBUDBEVENTINFO@@@Z @688 NONAME
g_hevContactAdded @689 NONAME
g_hevContactDeleted @690 NONAME
diff --git a/src/mir_app/src/proto_interface.cpp b/src/mir_app/src/proto_interface.cpp
index 8eb3f862fc..c4b978a13f 100644
--- a/src/mir_app/src/proto_interface.cpp
+++ b/src/mir_app/src/proto_interface.cpp
@@ -199,11 +199,9 @@ MEVENT PROTO_INTERFACE::RecvMsg(MCONTACT hContact, PROTORECVEVENT *pre)
if ((GetCaps(PFLAGNUM_4) & PF4_SERVERMSGID) && pre->szMsgId != nullptr) {
MEVENT hDbEvent = db_event_getById(m_szModuleName, pre->szMsgId);
if (hDbEvent == 0 || db_event_edit(hContact, hDbEvent, &dbei)) {
+ dbei.szId = pre->szMsgId;
hDbEvent = db_event_add(hContact, &dbei);
- if (hDbEvent)
- db_event_setId(m_szModuleName, hDbEvent, pre->szMsgId);
}
-
return hDbEvent;
}
diff --git a/src/mir_core/src/db.cpp b/src/mir_core/src/db.cpp
index 62fd662b35..322402e22e 100644
--- a/src/mir_core/src/db.cpp
+++ b/src/mir_core/src/db.cpp
@@ -431,11 +431,6 @@ MIR_CORE_DLL(MEVENT) db_event_getById(const char *szModule, const char *szId)
return (currDb == nullptr) ? 0 : currDb->GetEventById(szModule, szId);
}
-MIR_CORE_DLL(MEVENT) db_event_setId(const char *szModule, MEVENT hDbEvent, const char *szId)
-{
- return (currDb == nullptr) ? 0 : currDb->SetEventId(szModule, hDbEvent, szId);
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
// event cursors
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def
index 6ccd0c16b5..829aeb94c4 100644
--- a/src/mir_core/src/mir_core.def
+++ b/src/mir_core/src/mir_core.def
@@ -1042,7 +1042,6 @@ CallObjectEventHook @1259
?CheckRowCount@CCtrlPages@@AAEXXZ @1264 NONAME
?VerifyControls@CDlgBase@@AAE_NP8CCtrlBase@@AE_NXZ@Z @1265 NONAME
db_event_getById @1266
-db_event_setId @1267
db_event_edit @1268
??0StrPair@tinyxml2@@QAE@XZ @1269 NONAME
??0XMLAttribute@tinyxml2@@AAE@XZ @1270 NONAME
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def
index 9779067440..41bebe9ac7 100644
--- a/src/mir_core/src/mir_core64.def
+++ b/src/mir_core/src/mir_core64.def
@@ -1042,7 +1042,6 @@ CallObjectEventHook @1259
?CheckRowCount@CCtrlPages@@AEAAXXZ @1264 NONAME
?VerifyControls@CDlgBase@@AEAA_NP8CCtrlBase@@EAA_NXZ@Z @1265 NONAME
db_event_getById @1266
-db_event_setId @1267
db_event_edit @1268
??0StrPair@tinyxml2@@QEAA@XZ @1269 NONAME
??0XMLAttribute@tinyxml2@@AEAA@XZ @1270 NONAME