summaryrefslogtreecommitdiff
path: root/plugins/Dbx_sqlite/src/dbevents.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2023-01-07 21:13:52 +0300
committerGeorge Hazan <ghazan@miranda.im>2023-01-07 21:13:52 +0300
commit6635344981d9bfb245ada6c685b3a179cfd6ef45 (patch)
treeae31aee90b002d803be85a03caeca687145d8248 /plugins/Dbx_sqlite/src/dbevents.cpp
parent21331cf681e7f1fb0729109de251d0cc61be6098 (diff)
Telegram: simple version of marking messages read
Diffstat (limited to 'plugins/Dbx_sqlite/src/dbevents.cpp')
-rw-r--r--plugins/Dbx_sqlite/src/dbevents.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/plugins/Dbx_sqlite/src/dbevents.cpp b/plugins/Dbx_sqlite/src/dbevents.cpp
index fa3691a47e..bf8959c977 100644
--- a/plugins/Dbx_sqlite/src/dbevents.cpp
+++ b/plugins/Dbx_sqlite/src/dbevents.cpp
@@ -268,6 +268,8 @@ int CDbxSQLite::GetBlobSize(MEVENT hDbEvent)
return res;
}
+static char g_szId[100];
+
BOOL CDbxSQLite::GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbei)
{
if (hDbEvent == 0)
@@ -282,7 +284,7 @@ BOOL CDbxSQLite::GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbei)
}
mir_cslock lock(m_csDbAccess);
- sqlite3_stmt *stmt = InitQuery("SELECT module, timestamp, type, flags, length(data), data FROM events WHERE id = ? LIMIT 1;", qEvGet);
+ sqlite3_stmt *stmt = InitQuery("SELECT module, timestamp, type, flags, server_id, length(data), data FROM events WHERE id = ? LIMIT 1;", qEvGet);
sqlite3_bind_int64(stmt, 1, hDbEvent);
int rc = sqlite3_step(stmt);
logError(rc, __FILE__, __LINE__);
@@ -299,8 +301,15 @@ BOOL CDbxSQLite::GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbei)
dbei->timestamp = sqlite3_column_int64(stmt, 1);
dbei->eventType = sqlite3_column_int(stmt, 2);
dbei->flags = sqlite3_column_int64(stmt, 3);
+
+ char *pszId = (char *)sqlite3_column_text(stmt, 4);
+ if (mir_strlen(pszId)) {
+ mir_strncpy(g_szId, pszId, sizeof(g_szId));
+ dbei->szId = g_szId;
+ }
+ else dbei->szId = nullptr;
- int32_t cbBlob = sqlite3_column_int64(stmt, 4);
+ int32_t cbBlob = sqlite3_column_int64(stmt, 5);
size_t bytesToCopy = cbBlob;
if (dbei->cbBlob == -1)
dbei->pBlob = (uint8_t*)mir_calloc(cbBlob + 2);
@@ -309,7 +318,7 @@ BOOL CDbxSQLite::GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbei)
dbei->cbBlob = cbBlob;
if (bytesToCopy && dbei->pBlob) {
- uint8_t *data = (uint8_t *)sqlite3_column_blob(stmt, 5);
+ uint8_t *data = (uint8_t *)sqlite3_column_blob(stmt, 6);
if (dbei->flags & DBEF_ENCRYPTED) {
dbei->flags &= ~DBEF_ENCRYPTED;