summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss@sss.chaoslab.ru>2019-06-10 08:45:44 +0300
committerGluzskiy Alexandr <sss@sss.chaoslab.ru>2019-06-10 08:47:55 +0300
commitfceec22e76927745f74b9853db9c4975d2680bf7 (patch)
treea2ed2492d69e50bad8497ebf0119acdb36dafe34 /plugins
parent9e9d67e4c600277cc073b706a8d7a158e71a2b2e (diff)
dbx_sqlite: dropped first/last event cache (broken by reimplementation)
Diffstat (limited to 'plugins')
-rwxr-xr-x[-rw-r--r--]plugins/Dbx_sqlite/src/dbcontacts.cpp32
-rwxr-xr-xplugins/Dbx_sqlite/src/dbevents.cpp38
-rwxr-xr-xplugins/Dbx_sqlite/src/dbintf.h6
3 files changed, 26 insertions, 50 deletions
diff --git a/plugins/Dbx_sqlite/src/dbcontacts.cpp b/plugins/Dbx_sqlite/src/dbcontacts.cpp
index e2bef8664a..0cf3a85d57 100644..100755
--- a/plugins/Dbx_sqlite/src/dbcontacts.cpp
+++ b/plugins/Dbx_sqlite/src/dbcontacts.cpp
@@ -153,30 +153,14 @@ void DBCachedContact::AddEvent(MEVENT hDbEvent, uint32_t timestamp, bool unread)
m_count = HasCount()
? m_count + 1
: 1;
- if (m_firstTimestamp > timestamp) {
- m_first = hDbEvent;
- m_firstTimestamp = timestamp;
- }
if (unread && m_unreadTimestamp > timestamp) {
m_unread = hDbEvent;
m_unreadTimestamp = timestamp;
}
- if (m_lastTimestamp <= timestamp) {
- m_last = hDbEvent;
- m_lastTimestamp = timestamp;
- }
}
void DBCachedContact::EditEvent(MEVENT hDbEvent, uint32_t timestamp, bool unread)
{
- if (m_first = hDbEvent && m_firstTimestamp != timestamp) {
- m_first = 0;
- m_firstTimestamp = 0;
- }
- else if (m_firstTimestamp > timestamp) {
- m_first = hDbEvent;
- m_firstTimestamp = timestamp;
- }
if (m_unread = hDbEvent && (!unread || m_unreadTimestamp != timestamp)) {
m_unread = 0;
m_unreadTimestamp = 0;
@@ -185,32 +169,16 @@ void DBCachedContact::EditEvent(MEVENT hDbEvent, uint32_t timestamp, bool unread
m_unread = hDbEvent;
m_unreadTimestamp = timestamp;
}
- if (m_last = hDbEvent && m_lastTimestamp != timestamp) {
- m_last = 0;
- m_lastTimestamp = 0;
- }
- else if (m_lastTimestamp <= timestamp) {
- m_last = hDbEvent;
- m_lastTimestamp = timestamp;
- }
}
void DBCachedContact::DeleteEvent(MEVENT hDbEvent)
{
if (m_count > 0)
m_count--;
- if (m_first == hDbEvent) {
- m_first = 0;
- m_firstTimestamp = 0;
- }
if (m_unread == hDbEvent) {
m_unread = 0;
m_unreadTimestamp = 0;
}
- if (m_last == hDbEvent) {
- m_last = 0;
- m_lastTimestamp = 0;
- }
}
void DBCachedContact::MarkRead(MEVENT hDbEvent)
diff --git a/plugins/Dbx_sqlite/src/dbevents.cpp b/plugins/Dbx_sqlite/src/dbevents.cpp
index e4492410cd..77aee3f4e4 100755
--- a/plugins/Dbx_sqlite/src/dbevents.cpp
+++ b/plugins/Dbx_sqlite/src/dbevents.cpp
@@ -32,9 +32,9 @@ static char *evt_stmts[SQL_EVT_STMT_NUM] = {
"select flags from events where id = ? limit 1;",
"update events set flags = ? where id = ?;",
"select contact_id from events where id = ? limit 1;",
- "select id, timestamp from events_srt where contact_id = ? order by timestamp;",
+ "select id from events_srt where contact_id = ? order by timestamp;",
"select id, timestamp from events where contact_id = ? and (flags & ?) = 0 order by timestamp, id limit 1;",
- "select id, timestamp from events_srt where contact_id = ? order by timestamp desc, id desc;",
+ "select id from events_srt where contact_id = ? order by timestamp desc, id desc;",
"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 (?, ?, ?);",
@@ -427,8 +427,6 @@ MEVENT CDbxSQLite::FindFirstEvent(MCONTACT hContact)
if (cc == nullptr)
return 0;
- if (cc->m_first)
- return cc->m_first;
evt_cnt_fwd = hContact;
@@ -441,16 +439,19 @@ MEVENT CDbxSQLite::FindFirstEvent(MCONTACT hContact)
evt_cur_fwd = evt_stmts_prep[SQL_EVT_STMT_FINDFIRST];
sqlite3_bind_int64(evt_cur_fwd, 1, hContact);
+
int rc = sqlite3_step(evt_cur_fwd);
assert(rc == SQLITE_ROW || rc == SQLITE_DONE);
if (rc != SQLITE_ROW) {
+ //empty response
+ //reset sql cursor
sqlite3_reset(evt_cur_fwd);
evt_cur_fwd = 0;
+ //reset current contact
+ evt_cnt_fwd = 0;
return 0;
}
- cc->m_first = sqlite3_column_int64(evt_cur_fwd, 0);
- cc->m_firstTimestamp = sqlite3_column_int64(evt_cur_fwd, 1);
- return cc->m_first;
+ return sqlite3_column_int64(evt_cur_fwd, 0);
}
MEVENT CDbxSQLite::FindFirstUnreadEvent(MCONTACT hContact)
@@ -516,9 +517,6 @@ MEVENT CDbxSQLite::FindLastEvent(MCONTACT hContact)
if (cc == nullptr)
return 0;
- if (cc->m_last)
- return cc->m_last;
-
evt_cnt_backwd = hContact;
mir_cslock lock(m_csDbAccess);
@@ -533,13 +531,15 @@ MEVENT CDbxSQLite::FindLastEvent(MCONTACT hContact)
int rc = sqlite3_step(evt_cur_backwd);
assert(rc == SQLITE_ROW || rc == SQLITE_DONE);
if (rc != SQLITE_ROW) {
+ //empty response
+ //reset sql cursor
sqlite3_reset(evt_cur_backwd);
evt_cur_backwd = 0;
+ //reset current contact
+ evt_cnt_backwd = 0;
return 0;
}
- cc->m_last = sqlite3_column_int64(evt_cur_backwd, 0);
- cc->m_lastTimestamp = sqlite3_column_int64(evt_cur_backwd, 1);
- return cc->m_last;
+ return sqlite3_column_int64(evt_cur_backwd, 0);
}
MEVENT CDbxSQLite::FindNextEvent(MCONTACT hContact, MEVENT hDbEvent)
@@ -566,8 +566,11 @@ MEVENT CDbxSQLite::FindNextEvent(MCONTACT hContact, MEVENT hDbEvent)
assert(rc == SQLITE_ROW || rc == SQLITE_DONE);
if (rc == SQLITE_DONE)
{
+ //reset sql cursor
sqlite3_reset(evt_cur_fwd);
evt_cur_fwd = 0;
+ //reset current contact
+ evt_cnt_fwd = 0;
return 0;
}
}
@@ -575,8 +578,11 @@ MEVENT CDbxSQLite::FindNextEvent(MCONTACT hContact, MEVENT hDbEvent)
int rc = sqlite3_step(evt_cur_fwd);
assert(rc == SQLITE_ROW || rc == SQLITE_DONE);
if (rc != SQLITE_ROW) {
+ //reset sql cursor
sqlite3_reset(evt_cur_fwd);
evt_cur_fwd = 0;
+ //reset current contact
+ evt_cnt_fwd = 0;
return 0;
}
hDbEvent = sqlite3_column_int64(evt_cur_fwd, 0);
@@ -608,8 +614,11 @@ MEVENT CDbxSQLite::FindPrevEvent(MCONTACT hContact, MEVENT hDbEvent)
assert(rc == SQLITE_ROW || rc == SQLITE_DONE);
if (rc == SQLITE_DONE)
{
+ //reset sql cursor
sqlite3_reset(evt_cur_backwd);
evt_cur_backwd = 0;
+ //reset current contact
+ evt_cnt_backwd = 0;
return 0;
}
}
@@ -617,8 +626,11 @@ MEVENT CDbxSQLite::FindPrevEvent(MCONTACT hContact, MEVENT hDbEvent)
int rc = sqlite3_step(evt_cur_backwd);
assert(rc == SQLITE_ROW || rc == SQLITE_DONE);
if (rc != SQLITE_ROW) {
+ //reset sql cursor
sqlite3_reset(evt_cur_backwd);
evt_cur_backwd = 0;
+ //reset current contact
+ evt_cnt_backwd = 0;
return 0;
}
hDbEvent = sqlite3_column_int64(evt_cur_backwd, 0);
diff --git a/plugins/Dbx_sqlite/src/dbintf.h b/plugins/Dbx_sqlite/src/dbintf.h
index e164be6cd8..fdab9d8b4c 100755
--- a/plugins/Dbx_sqlite/src/dbintf.h
+++ b/plugins/Dbx_sqlite/src/dbintf.h
@@ -7,15 +7,11 @@
struct DBCachedContact : public DBCachedContactBase
{
uint32_t m_count;
- MEVENT m_first;
- uint32_t m_firstTimestamp;
MEVENT m_unread;
uint32_t m_unreadTimestamp;
- MEVENT m_last;
- uint32_t m_lastTimestamp;
DBCachedContact()
- : m_count(-1), m_first(0), m_unread(0), m_last(0) { }
+ : m_count(-1), m_unread(0) { }
bool HasCount() const;