summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-01-18 21:15:51 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-01-18 21:15:51 +0300
commit35780da54a30840b50313ebf6ca2a0b7367d6c49 (patch)
tree3eb66fe2e3a7654544a74499344eeb66a13d46b0 /plugins/TabSRMM/src
parent6436b0320228f42b696c8298ef30f92439af9872 (diff)
fixes #2700 (Scriver: при открытии окна через попап отображается лишь одно сообщение)
Diffstat (limited to 'plugins/TabSRMM/src')
-rw-r--r--plugins/TabSRMM/src/msgdialog.cpp3
-rw-r--r--plugins/TabSRMM/src/msgdlgother.cpp50
2 files changed, 23 insertions, 30 deletions
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp
index dfb50c91b7..8a09bd4c2f 100644
--- a/plugins/TabSRMM/src/msgdialog.cpp
+++ b/plugins/TabSRMM/src/msgdialog.cpp
@@ -586,7 +586,8 @@ bool CMsgDialog::OnInitDialog()
DM_OptionsApplied();
- for (MEVENT hdbEvent = db_event_last(m_hContact); hdbEvent; hdbEvent = db_event_prev(m_hContact, hdbEvent)) {
+ DB::ECPTR pCursor(DB::EventsRev(m_hContact));
+ while (MEVENT hdbEvent = pCursor.FetchNext()) {
DBEVENTINFO dbei = {};
db_event_get(hdbEvent, &dbei);
if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) {
diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp
index 0dec572846..01e98df270 100644
--- a/plugins/TabSRMM/src/msgdlgother.cpp
+++ b/plugins/TabSRMM/src/msgdlgother.cpp
@@ -463,49 +463,41 @@ void CMsgDialog::FindFirstEvent()
if (m_bActualHistory)
historyMode = LOADHISTORY_COUNT;
+ DBEVENTINFO dbei = {};
+ DB::ECPTR pCursor(DB::EventsRev(m_hContact, m_hDbEventFirst));
+
switch (historyMode) {
case LOADHISTORY_COUNT:
int i;
- MEVENT hPrevEvent;
- {
- DBEVENTINFO dbei = {};
- // ability to load only current session's history
- if (m_bActualHistory)
- i = m_cache->getSessionMsgCount();
- else
- i = g_plugin.getWord(SRMSGSET_LOADCOUNT, SRMSGDEFSET_LOADCOUNT);
- for (; i > 0; i--) {
- if (m_hDbEventFirst == 0)
- hPrevEvent = db_event_last(m_hContact);
- else
- hPrevEvent = db_event_prev(m_hContact, m_hDbEventFirst);
- if (hPrevEvent == 0)
- break;
- dbei.cbBlob = 0;
- m_hDbEventFirst = hPrevEvent;
- db_event_get(m_hDbEventFirst, &dbei);
- if (!DbEventIsShown(&dbei))
- i++;
- }
+ // ability to load only current session's history
+ if (m_bActualHistory)
+ i = m_cache->getSessionMsgCount();
+ else
+ i = g_plugin.getWord(SRMSGSET_LOADCOUNT, SRMSGDEFSET_LOADCOUNT);
+
+ for (; i > 0; i--) {
+ MEVENT hPrevEvent = pCursor.FetchNext();
+ if (hPrevEvent == 0)
+ break;
+
+ dbei.cbBlob = 0;
+ m_hDbEventFirst = hPrevEvent;
+ db_event_get(m_hDbEventFirst, &dbei);
+ if (!DbEventIsShown(&dbei))
+ i++;
}
break;
case LOADHISTORY_TIME:
- DBEVENTINFO dbei = {};
if (m_hDbEventFirst == 0)
dbei.timestamp = time(0);
else
db_event_get(m_hDbEventFirst, &dbei);
DWORD firstTime = dbei.timestamp - 60 * g_plugin.getWord(SRMSGSET_LOADTIME, SRMSGDEFSET_LOADTIME);
- for (;;) {
- if (m_hDbEventFirst == 0)
- hPrevEvent = db_event_last(m_hContact);
- else
- hPrevEvent = db_event_prev(m_hContact, m_hDbEventFirst);
- if (hPrevEvent == 0)
- break;
+
+ while (MEVENT hPrevEvent = pCursor.FetchNext()) {
dbei.cbBlob = 0;
db_event_get(hPrevEvent, &dbei);
if (dbei.timestamp < firstTime)