summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2023-04-18 11:35:41 +0300
committerGeorge Hazan <ghazan@miranda.im>2023-04-18 11:35:41 +0300
commitcd5679ac850cd43c1b681de6485c8ec30a9e8e1d (patch)
treee8458a29ae632340ff4ad0fafae00ae995251d33 /src/mir_app
parent02e7a43880dd6e0b44f0b6776d7d0ce85d08df8a (diff)
Group chats with database to follow SRMM event filtering rules + code cleaning
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/clistevents.cpp16
-rw-r--r--src/mir_app/src/srmm_base.cpp39
2 files changed, 34 insertions, 21 deletions
diff --git a/src/mir_app/src/clistevents.cpp b/src/mir_app/src/clistevents.cpp
index 39b197f9e5..89928c9569 100644
--- a/src/mir_app/src/clistevents.cpp
+++ b/src/mir_app/src/clistevents.cpp
@@ -127,6 +127,9 @@ static void ShowEventsInTray()
}
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// Adds an event to the contact list's queue
+
static VOID CALLBACK IconFlashTimer(HWND, UINT, UINT_PTR idEvent, DWORD)
{
ShowEventsInTray();
@@ -187,8 +190,10 @@ CListEvent* fnAddEvent(CLISTEVENT *cle)
return (CListEvent*)CallFunctionSync(DoAddEvent, cle);
}
+/////////////////////////////////////////////////////////////////////////////////////////
// Removes an event from the contact list's queue
// Returns 0 if the event was successfully removed, or nonzero if the event was not found
+
int fnRemoveEvent(MCONTACT hContact, MEVENT dbEvent)
{
// Find the event that should be removed
@@ -235,6 +240,8 @@ int fnRemoveEvent(MCONTACT hContact, MEVENT dbEvent)
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
CLISTEVENT* fnGetEvent(MCONTACT hContact, int idx)
{
if (hContact == INVALID_CONTACT_ID) {
@@ -251,6 +258,8 @@ CLISTEVENT* fnGetEvent(MCONTACT hContact, int idx)
return nullptr;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
int EventsProcessContactDoubleClick(MCONTACT hContact)
{
for (auto &it : g_cliEvents) {
@@ -265,6 +274,8 @@ int EventsProcessContactDoubleClick(MCONTACT hContact)
return 1;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
MIR_APP_DLL(int) Clist_EventsProcessTrayDoubleClick(int index)
{
BOOL click_in_first_icon = FALSE;
@@ -331,6 +342,9 @@ MIR_APP_DLL(int) Clist_EventsProcessTrayDoubleClick(int index)
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// Module entry point
+
static int CListEventMarkedRead(WPARAM hContact, LPARAM hDbEvent)
{
g_clistApi.pfnRemoveEvent(hContact, hDbEvent);
@@ -349,8 +363,6 @@ static int CListEventSettingsChanged(WPARAM hContact, LPARAM lParam)
return 0;
}
-/***************************************************************************************/
-
int InitCListEvents(void)
{
g_clistApi.events = &g_cliEvents;
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp
index 8c7b9b69df..99ded72210 100644
--- a/src/mir_app/src/srmm_base.cpp
+++ b/src/mir_app/src/srmm_base.cpp
@@ -660,30 +660,31 @@ void CSrmmBaseDialog::UpdateChatLog()
if (!m_si->pMI->bDatabase || m_si->bHistoryInit)
return;
+ m_pLog->Clear();
GetFirstEvent();
auto *szProto = Proto_GetBaseAccountName(m_hContact);
for (MEVENT hDbEvent = m_hDbEventFirst; hDbEvent; hDbEvent = db_event_next(m_hContact, hDbEvent)) {
DB::EventInfo dbei(hDbEvent);
- if (dbei) {
- if (!mir_strcmp(szProto, dbei.szModule) && dbei.eventType == EVENTTYPE_MESSAGE && dbei.szUserId) {
- auto *pUser = g_chatApi.UM_FindUser(m_si, Utf2T(dbei.szUserId));
- if (pUser == nullptr)
- continue;
-
- Utf2T wszUserId(dbei.szUserId);
- CMStringW wszText(Utf2T((char*)dbei.pBlob));
- wszText.Replace(L"%", L"%%");
-
- GCEVENT gce = { m_si, GC_EVENT_MESSAGE };
- gce.dwFlags = GCEF_ADDTOLOG;
- gce.pszUserInfo.w = wszUserId;
- gce.pszText.w = wszText;
- gce.time = dbei.timestamp;
- if (USERINFO *ui = g_chatApi.UM_FindUser(m_si, wszUserId))
- gce.pszNick.w = ui->pszNick;
- SM_AddEvent(m_si, &gce, false);
- }
+ if (dbei && !mir_strcmp(szProto, dbei.szModule) && dbei.eventType == EVENTTYPE_MESSAGE && dbei.szUserId) {
+ auto *pUser = g_chatApi.UM_FindUser(m_si, Utf2T(dbei.szUserId));
+ if (pUser == nullptr)
+ continue;
+
+ Utf2T wszUserId(dbei.szUserId);
+ CMStringW wszText(Utf2T((char*)dbei.pBlob));
+ wszText.Replace(L"%", L"%%");
+
+ GCEVENT gce = { m_si, GC_EVENT_MESSAGE };
+ gce.dwFlags = GCEF_ADDTOLOG;
+ gce.pszUserInfo.w = wszUserId;
+ gce.pszText.w = wszText;
+ gce.time = dbei.timestamp;
+ gce.hEvent = hDbEvent;
+
+ if (USERINFO *ui = g_chatApi.UM_FindUser(m_si, wszUserId))
+ gce.pszNick.w = ui->pszNick;
+ SM_AddEvent(m_si, &gce, false);
}
}