summaryrefslogtreecommitdiff
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
parent6436b0320228f42b696c8298ef30f92439af9872 (diff)
fixes #2700 (Scriver: при открытии окна через попап отображается лишь одно сообщение)
-rw-r--r--plugins/Scriver/src/msgdialog.cpp35
-rw-r--r--plugins/TabSRMM/src/msgdialog.cpp3
-rw-r--r--plugins/TabSRMM/src/msgdlgother.cpp50
-rw-r--r--protocols/NewsAggregator/Src/CheckFeed.cpp4
-rw-r--r--src/core/stdmsg/src/msgdialog.cpp96
5 files changed, 84 insertions, 104 deletions
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp
index 43fd82a142..f0d55d784c 100644
--- a/plugins/Scriver/src/msgdialog.cpp
+++ b/plugins/Scriver/src/msgdialog.cpp
@@ -256,17 +256,17 @@ bool CMsgDialog::OnInitDialog()
notifyUnread = true;
}
+ DB::ECPTR pCursor(DB::EventsRev(m_hContact, m_hDbEventFirst));
+
DBEVENTINFO dbei = {};
MEVENT hPrevEvent;
switch (historyMode) {
case LOADHISTORY_COUNT:
for (int i = g_plugin.iLoadCount; i > 0; i--) {
- if (m_hDbEventFirst == 0)
- hPrevEvent = db_event_last(m_hContact);
- else
- hPrevEvent = db_event_prev(m_hContact, m_hDbEventFirst);
+ hPrevEvent = pCursor.FetchNext();
if (hPrevEvent == 0)
break;
+
dbei.cbBlob = 0;
m_hDbEventFirst = hPrevEvent;
db_event_get(m_hDbEventFirst, &dbei);
@@ -276,26 +276,23 @@ bool CMsgDialog::OnInitDialog()
break;
case LOADHISTORY_TIME:
- if (m_hDbEventFirst == 0) {
+ if (m_hDbEventFirst == 0)
dbei.timestamp = time(0);
- hPrevEvent = db_event_last(m_hContact);
- }
- else {
+ else
db_event_get(m_hDbEventFirst, &dbei);
- hPrevEvent = db_event_prev(m_hContact, m_hDbEventFirst);
- }
DWORD firstTime = dbei.timestamp - 60 * g_plugin.iLoadTime;
for (;;) {
+ hPrevEvent = pCursor.FetchNext();
if (hPrevEvent == 0)
break;
+
dbei.cbBlob = 0;
db_event_get(hPrevEvent, &dbei);
if (dbei.timestamp < firstTime)
break;
if (DbEventIsShown(dbei))
m_hDbEventFirst = hPrevEvent;
- hPrevEvent = db_event_prev(m_hContact, hPrevEvent);
}
break;
}
@@ -303,16 +300,14 @@ bool CMsgDialog::OnInitDialog()
m_pParent->AddChild(this);
- MEVENT hdbEvent = db_event_last(m_hContact);
- if (hdbEvent) {
+ DB::ECPTR pCursor(DB::EventsRev(m_hContact));
+ while (MEVENT hdbEvent = pCursor.FetchNext()) {
DBEVENTINFO dbei = {};
- do {
- db_event_get(hdbEvent, &dbei);
- if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) {
- m_lastMessage = dbei.timestamp;
- break;
- }
- } while ((hdbEvent = db_event_prev(m_hContact, hdbEvent)));
+ db_event_get(hdbEvent, &dbei);
+ if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_SENT)) {
+ m_lastMessage = dbei.timestamp;
+ break;
+ }
}
SendMessage(m_hwnd, DM_OPTIONSAPPLIED, 0, 0);
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)
diff --git a/protocols/NewsAggregator/Src/CheckFeed.cpp b/protocols/NewsAggregator/Src/CheckFeed.cpp
index 87282451f4..eab3be7bb3 100644
--- a/protocols/NewsAggregator/Src/CheckFeed.cpp
+++ b/protocols/NewsAggregator/Src/CheckFeed.cpp
@@ -161,7 +161,9 @@ static void XmlToMsg(MCONTACT hContact, CMStringW &title, CMStringW &link, CMStr
T2Utf pszTemp(message);
DWORD cbMemoLen = 10000, cbOrigLen = (DWORD)mir_strlen(pszTemp);
BYTE *pbBuffer = (BYTE*)mir_alloc(cbMemoLen);
- for (MEVENT hDbEvent = db_event_last(hContact); hDbEvent; hDbEvent = db_event_prev(hContact, hDbEvent)) {
+
+ DB::ECPTR pCursor(DB::EventsRev(hContact));
+ while (MEVENT hDbEvent = pCursor.FetchNext()) {
olddbei.cbBlob = db_event_getBlobSize(hDbEvent);
if (olddbei.cbBlob > cbMemoLen)
pbBuffer = (PBYTE)mir_realloc(pbBuffer, (size_t)(cbMemoLen = olddbei.cbBlob));
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp
index a5185eb762..8bfbfb1d31 100644
--- a/src/core/stdmsg/src/msgdialog.cpp
+++ b/src/core/stdmsg/src/msgdialog.cpp
@@ -151,68 +151,58 @@ bool CMsgDialog::OnInitDialog()
// This finds the first message to display, it works like shit
m_hDbEventFirst = db_event_firstUnread(m_hContact);
- switch (g_dat.iLoadHistory) {
- case LOADHISTORY_COUNT:
- for (int i = g_dat.nLoadCount; i--;) {
- MEVENT hPrevEvent;
- if (m_hDbEventFirst == 0)
- hPrevEvent = db_event_last(m_hContact);
- else
- hPrevEvent = db_event_prev(m_hContact, m_hDbEventFirst);
- if (hPrevEvent == 0)
- break;
+ {
+ DB::ECPTR pCursor(DB::EventsRev(m_hContact, m_hDbEventFirst));
+
+ switch (g_dat.iLoadHistory) {
+ case LOADHISTORY_COUNT:
+ for (int i = g_dat.nLoadCount; i--;) {
+ MEVENT hPrevEvent = pCursor.FetchNext();
+ if (hPrevEvent == 0)
+ break;
+
+ DBEVENTINFO dbei = {};
+ m_hDbEventFirst = hPrevEvent;
+ db_event_get(hPrevEvent, &dbei);
+ if (!DbEventIsShown(&dbei))
+ i++;
+ }
+ break;
+ case LOADHISTORY_TIME:
DBEVENTINFO dbei = {};
- m_hDbEventFirst = hPrevEvent;
- db_event_get(hPrevEvent, &dbei);
- if (!DbEventIsShown(&dbei))
- i++;
- }
- break;
-
- case LOADHISTORY_TIME:
- DBEVENTINFO dbei = {};
- if (m_hDbEventFirst == 0)
- dbei.timestamp = (DWORD)time(0);
- else
- db_event_get(m_hDbEventFirst, &dbei);
-
- DWORD firstTime = dbei.timestamp - 60 * g_dat.nLoadTime;
- for (;;) {
- MEVENT hPrevEvent;
if (m_hDbEventFirst == 0)
- hPrevEvent = db_event_last(m_hContact);
+ dbei.timestamp = (DWORD)time(0);
else
- hPrevEvent = db_event_prev(m_hContact, m_hDbEventFirst);
- if (hPrevEvent == 0)
- break;
-
- dbei.cbBlob = 0;
- db_event_get(hPrevEvent, &dbei);
- if (dbei.timestamp < firstTime)
- break;
- m_hDbEventFirst = hPrevEvent;
+ db_event_get(m_hDbEventFirst, &dbei);
+
+ DWORD firstTime = dbei.timestamp - 60 * g_dat.nLoadTime;
+ while (MEVENT hPrevEvent = pCursor.FetchNext()) {
+ dbei.cbBlob = 0;
+ db_event_get(hPrevEvent, &dbei);
+ if (dbei.timestamp < firstTime)
+ break;
+ m_hDbEventFirst = hPrevEvent;
+ }
+ break;
}
- break;
}
- MEVENT hdbEvent = db_event_last(m_hContact);
- if (hdbEvent) {
- bool bUpdate = false;
- do {
- DBEVENTINFO dbei = {};
- db_event_get(hdbEvent, &dbei);
- if ((dbei.eventType == EVENTTYPE_MESSAGE) && !(dbei.flags & DBEF_SENT)) {
- m_lastMessage = dbei.timestamp;
- bUpdate = true;
- break;
- }
- } while (hdbEvent = db_event_prev(m_hContact, hdbEvent));
-
- if (bUpdate)
- UpdateLastMessage();
+ bool bUpdate = false;
+ 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)) {
+ m_lastMessage = dbei.timestamp;
+ bUpdate = true;
+ break;
+ }
}
+ if (bUpdate)
+ UpdateLastMessage();
+
OnOptionsApplied(false);
// restore saved msg if any...