diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Dbx_sqlite/src/dbevents.cpp | 25 | ||||
-rw-r--r-- | plugins/Dbx_sqlite/src/dbintf.h | 2 |
2 files changed, 17 insertions, 10 deletions
diff --git a/plugins/Dbx_sqlite/src/dbevents.cpp b/plugins/Dbx_sqlite/src/dbevents.cpp index 73baf8389c..1206b30b09 100644 --- a/plugins/Dbx_sqlite/src/dbevents.cpp +++ b/plugins/Dbx_sqlite/src/dbevents.cpp @@ -254,7 +254,7 @@ BOOL CDbxSQLite::EditEvent(MEVENT hDbEvent, const DBEVENTINFO *dbei) DBEVENTINFO tmp = *dbei;
mir_ptr<uint8_t> pCryptBlob;
- if (m_bEncrypted) {
+ if (m_bEncrypted && tmp.pBlob) {
size_t len;
uint8_t *pResult = m_crypto->encodeBuffer(tmp.pBlob, tmp.cbBlob, &len);
if (pResult != nullptr) {
@@ -265,14 +265,21 @@ BOOL CDbxSQLite::EditEvent(MEVENT hDbEvent, const DBEVENTINFO *dbei) }
mir_cslockfull lock(m_csDbAccess);
- sqlite3_stmt *stmt = InitQuery("UPDATE events SET module = ?, timestamp = ?, type = ?, flags = ?, data = ?, is_read = ? WHERE id = ?;", qEvEdit);
- sqlite3_bind_text(stmt, 1, tmp.szModule, (int)mir_strlen(tmp.szModule), nullptr);
- sqlite3_bind_int64(stmt, 2, tmp.timestamp);
- sqlite3_bind_int(stmt, 3, tmp.eventType);
- sqlite3_bind_int64(stmt, 4, tmp.flags);
- sqlite3_bind_blob(stmt, 5, tmp.pBlob, tmp.cbBlob, nullptr);
- sqlite3_bind_int(stmt, 6, tmp.markedRead());
- sqlite3_bind_int64(stmt, 7, hDbEvent);
+ sqlite3_stmt *stmt;
+ if (tmp.pBlob)
+ stmt = InitQuery("UPDATE events SET module = ?, timestamp = ?, type = ?, flags = ?, data = ?, is_read = ? WHERE id = ?;", qEvEdit1);
+ else
+ stmt = InitQuery("UPDATE events SET module = ?, timestamp = ?, type = ?, flags = ?, is_read = ? WHERE id = ?;", qEvEdit2);
+
+ int i = 1;
+ sqlite3_bind_text(stmt, i++, tmp.szModule, (int)mir_strlen(tmp.szModule), nullptr);
+ sqlite3_bind_int64(stmt, i++, tmp.timestamp);
+ sqlite3_bind_int(stmt, i++, tmp.eventType);
+ sqlite3_bind_int64(stmt, i++, tmp.flags);
+ if (tmp.pBlob)
+ sqlite3_bind_blob(stmt, i++, tmp.pBlob, tmp.cbBlob, nullptr);
+ sqlite3_bind_int(stmt, i++, tmp.markedRead());
+ sqlite3_bind_int64(stmt, i++, hDbEvent);
int rc = sqlite3_step(stmt);
logError(rc, __FILE__, __LINE__);
sqlite3_reset(stmt);
diff --git a/plugins/Dbx_sqlite/src/dbintf.h b/plugins/Dbx_sqlite/src/dbintf.h index 9e9716f153..7b1d82550b 100644 --- a/plugins/Dbx_sqlite/src/dbintf.h +++ b/plugins/Dbx_sqlite/src/dbintf.h @@ -79,7 +79,7 @@ class CDbxSQLite : public MDatabaseCommon, public MIDatabaseChecker, public MZer LIST<char> m_modules;
void InitEvents();
void UninitEvents();
- CQuery qEvAdd, qEvDel, qEvEdit, qEvBlobSize, qEvGet, qEvGetFlags, qEvSetFlags, qEvGetContact, qEvGetContact2;
+ CQuery qEvAdd, qEvDel, qEvEdit1, qEvEdit2, qEvBlobSize, qEvGet, qEvGetFlags, qEvSetFlags, qEvGetContact, qEvGetContact2;
CQuery qEvFindFirst, qEvFindNext, qEvFindLast, qEvFindPrev, qEvFindUnread, qEvAddSrt, qEvDelSrt, qEvMetaSplit, qEvMetaMerge;
CQuery qEvGetById, qEvUpdateId, qEvSetJson;
int DeleteEventMain(MEVENT);
|