summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/TabSRMM/src')
-rw-r--r--plugins/TabSRMM/src/globals.cpp6
-rw-r--r--plugins/TabSRMM/src/msgdlgother.cpp39
2 files changed, 21 insertions, 24 deletions
diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp
index f46d7b6fdd..a6ab43374d 100644
--- a/plugins/TabSRMM/src/globals.cpp
+++ b/plugins/TabSRMM/src/globals.cpp
@@ -442,7 +442,7 @@ struct MSavedEvent
void CGlobals::RestoreUnreadMessageAlerts(void)
{
- OBJLIST<MSavedEvent> arEvents(10, NumericKeySortT);
+ OBJLIST<MSavedEvent> events(10, NumericKeySortT);
for (auto &hContact : Contacts()) {
if (Proto_GetBaseAccountName(hContact) == nullptr)
@@ -459,12 +459,12 @@ void CGlobals::RestoreUnreadMessageAlerts(void)
if (!dbei.markedRead() && dbei.isAlertable())
if (!Srmm_FindWindow(hContact))
- arEvents.insert(new MSavedEvent(hContact, hDbEvent));
+ events.insert(new MSavedEvent(hContact, hDbEvent));
}
}
}
- for (auto &e : arEvents)
+ for (auto &e : events)
Srmm_AddEvent(e->hContact, e->hEvent);
}
diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp
index 1bf3dde416..56cdf162d7 100644
--- a/plugins/TabSRMM/src/msgdlgother.cpp
+++ b/plugins/TabSRMM/src/msgdlgother.cpp
@@ -401,35 +401,31 @@ void CMsgDialog::EventAdded(MEVENT hDbEvent, const DB::EventInfo &dbei)
bool CMsgDialog::GetFirstEvent()
{
int historyMode = g_plugin.getByte(m_hContact, "LoadHistory", Srmm::iHistoryMode);
-
- m_hDbEventFirst = db_event_firstUnread(m_hContact);
-
if (m_bActualHistory)
historyMode = LOADHISTORY_COUNT;
DB::EventInfo dbei;
- DB::ECPTR pCursor(DB::EventsRev(m_hContact, m_hDbEventFirst));
switch (historyMode) {
- case LOADHISTORY_COUNT:
- int 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);
+ case LOADHISTORY_UNREAD:
+ m_hDbEventFirst = db_event_firstUnread(m_hContact);
+ break;
- for (; i > 0; i--) {
- MEVENT hPrevEvent = pCursor.FetchNext();
- if (hPrevEvent == 0)
- break;
+ case LOADHISTORY_COUNT:
+ {
+ DB::ECPTR pCursor(DB::EventsRev(m_hContact));
+ int n = (m_bActualHistory) ? m_cache->getSessionMsgCount() : g_plugin.getWord(SRMSGSET_LOADCOUNT, SRMSGDEFSET_LOADCOUNT);
+ while (n > 0) {
+ MEVENT hPrevEvent = pCursor.FetchNext();
+ if (hPrevEvent == 0)
+ break;
- dbei.cbBlob = 0;
- m_hDbEventFirst = hPrevEvent;
- db_event_get(m_hDbEventFirst, &dbei);
- if (!DbEventIsShown(dbei))
- i++;
+ dbei.cbBlob = 0;
+ m_hDbEventFirst = hPrevEvent;
+ db_event_get(m_hDbEventFirst, &dbei);
+ if (DbEventIsShown(dbei))
+ n--;
+ }
}
break;
@@ -441,6 +437,7 @@ bool CMsgDialog::GetFirstEvent()
uint32_t firstTime = dbei.getUnixtime() - 60 * g_plugin.getWord(SRMSGSET_LOADTIME, SRMSGDEFSET_LOADTIME);
+ DB::ECPTR pCursor(DB::EventsRev(m_hContact));
while (MEVENT hPrevEvent = pCursor.FetchNext()) {
dbei.cbBlob = 0;
db_event_get(hPrevEvent, &dbei);