diff options
author | George Hazan <george.hazan@gmail.com> | 2023-05-21 14:56:39 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-05-21 14:56:39 +0300 |
commit | f04b54e3fc162d475e8688784631a316f264f733 (patch) | |
tree | 5feed9526e1c2acac25942f39f68713b8ccb9d1d /src/mir_app | |
parent | ec8a7614a371f41937dc1dbc2d53289e45706e3a (diff) |
Clist_RemoveEvent became static, pfnRemoveEvent is replaced with pfnFreeEvent
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/src/chat_log.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/chat_manager.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/chat_svc.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/chat_tools.cpp | 4 | ||||
-rw-r--r-- | src/mir_app/src/clc.h | 2 | ||||
-rw-r--r-- | src/mir_app/src/clistcore.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/clistevents.cpp | 51 | ||||
-rw-r--r-- | src/mir_app/src/clistsettings.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 2 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 2 | ||||
-rw-r--r-- | src/mir_app/src/srmm_log_rtf.cpp | 2 |
11 files changed, 45 insertions, 28 deletions
diff --git a/src/mir_app/src/chat_log.cpp b/src/mir_app/src/chat_log.cpp index 425f80753e..91895d3046 100644 --- a/src/mir_app/src/chat_log.cpp +++ b/src/mir_app/src/chat_log.cpp @@ -321,7 +321,7 @@ void CRtfLogWindow::CreateChatRtfMessage(RtfChatLogStreamData *streamData, const if (!dbei.markedRead()) {
if (dbei.eventType == EVENTTYPE_MESSAGE || dbei.eventType == EVENTTYPE_FILE || dbei.isSrmm()) {
db_event_markRead(si->hContact, lin.hEvent);
- g_clistApi.pfnRemoveEvent(si->hContact, lin.hEvent);
+ Clist_RemoveEvent(si->hContact, lin.hEvent);
}
}
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index 394f0d16e7..b0c4999d89 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -114,7 +114,7 @@ static SESSION_INFO* SM_CreateSession(void) void SM_FreeSession(SESSION_INFO *si)
{
if (Clist_GetEvent(si->hContact, 0))
- g_clistApi.pfnRemoveEvent(si->hContact, GC_FAKE_EVENT);
+ Clist_RemoveEvent(si->hContact, GC_FAKE_EVENT);
si->wState &= ~STATE_TALK;
db_set_w(si->hContact, si->pszModule, "ApparentMode", 0);
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index fc6e001881..e03d826320 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -823,7 +823,7 @@ static int OnEventAdded(WPARAM hContact, LPARAM hDbEvent) Chat_EventToGC(si, hDbEvent);
}
else {
- g_clistApi.pfnRemoveEvent(hContact, 1);
+ Clist_RemoveEvent(hContact, 1);
DB::EventInfo dbei(hDbEvent, false);
if (dbei) {
diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp index cbe06d3d77..e2b4865e12 100644 --- a/src/mir_app/src/chat_tools.cpp +++ b/src/mir_app/src/chat_tools.cpp @@ -137,7 +137,7 @@ static void AddEvent(MCONTACT hContact, HICON hIcon, int type, const wchar_t *pw }
else {
if (Clist_GetEvent(hContact, 0))
- g_clistApi.pfnRemoveEvent(hContact, GC_FAKE_EVENT);
+ Clist_RemoveEvent(hContact, GC_FAKE_EVENT);
g_clistApi.pfnAddEvent(&cle);
}
}
@@ -229,7 +229,7 @@ static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPA SESSION_INFO *si = (SESSION_INFO*)PUGetPluginData(hWnd);
if (si->hContact)
if (Clist_GetEvent(si->hContact, 0))
- g_clistApi.pfnRemoveEvent(si->hContact, GC_FAKE_EVENT);
+ Clist_RemoveEvent(si->hContact, GC_FAKE_EVENT);
if (si->pDlg && si->pDlg->timerFlash.Stop())
FlashWindow(si->pDlg->GetHwnd(), FALSE);
diff --git a/src/mir_app/src/clc.h b/src/mir_app/src/clc.h index 6a38b78e9f..39425f98a6 100644 --- a/src/mir_app/src/clc.h +++ b/src/mir_app/src/clc.h @@ -121,7 +121,7 @@ void UnregisterFileDropping(HWND hwnd); struct CListEvent* fnAddEvent(CLISTEVENT *cle);
int fnGetImlIconIndex(HICON hIcon);
-int fnRemoveEvent(MCONTACT hContact, MEVENT dbEvent);
+int fnRemoveEvent(CListEvent *pEvent);
int EventsProcessContactDoubleClick(MCONTACT hContact);
diff --git a/src/mir_app/src/clistcore.cpp b/src/mir_app/src/clistcore.cpp index dcb1b64045..dfcc6e81e4 100644 --- a/src/mir_app/src/clistcore.cpp +++ b/src/mir_app/src/clistcore.cpp @@ -101,7 +101,7 @@ void InitClistCore() g_clistApi.pfnAddEvent = fnAddEvent;
g_clistApi.pfnGetImlIconIndex = fnGetImlIconIndex;
- g_clistApi.pfnRemoveEvent = fnRemoveEvent;
+ g_clistApi.pfnFreeEvent = fnRemoveEvent;
g_clistApi.pfnInvalidateDisplayNameCacheEntry = fnInvalidateDisplayNameCacheEntry;
g_clistApi.pfnCreateCacheItem = fnCreateCacheItem;
diff --git a/src/mir_app/src/clistevents.cpp b/src/mir_app/src/clistevents.cpp index 51185c681f..1bf064b467 100644 --- a/src/mir_app/src/clistevents.cpp +++ b/src/mir_app/src/clistevents.cpp @@ -146,7 +146,7 @@ static VOID CALLBACK IconFlashTimer(HWND, UINT, UINT_PTR idEvent, DWORD) // decrease eflashes in any case - no need to collect all events
if (e.flags & CLEF_ONLYAFEW)
if (0 >= --e.flashesDone)
- g_clistApi.pfnRemoveEvent(e.hContact, e.hDbEvent);
+ Clist_RemoveEvent(e.hContact, e.hDbEvent);
}
if (g_cliEvents.getCount() == 0) {
@@ -194,24 +194,14 @@ CListEvent* fnAddEvent(CLISTEVENT *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)
+int fnRemoveEvent(CListEvent *pEvent)
{
- // Find the event that should be removed
- CListEvent *pEvent = nullptr;
- for (auto &it : g_cliEvents) {
- if (it->hContact == hContact && it->hDbEvent == dbEvent) {
- pEvent = it;
- break;
- }
- }
-
- // Event was not found
- if (pEvent == nullptr)
- return 1;
+ // save hContact, because pEvent should be freed
+ auto hContact = pEvent->hContact;
// Update contact's icon
char *szProto = Proto_GetBaseAccountName(hContact);
- Clist_ChangeContactIcon(pEvent->hContact, Clist_GetContactIcon(pEvent->hContact));
+ Clist_ChangeContactIcon(hContact, Clist_GetContactIcon(hContact));
// Free any memory allocated to the event
g_cliEvents.remove(pEvent);
@@ -242,6 +232,30 @@ int fnRemoveEvent(MCONTACT hContact, MEVENT dbEvent) /////////////////////////////////////////////////////////////////////////////////////////
+MIR_APP_DLL(CListEvent *) Clist_FindEvent(MCONTACT hContact, MEVENT hDbEvent)
+{
+ for (auto &it : g_cliEvents) {
+ if ((hContact == it->hContact || hContact == -1) && it->hDbEvent == hDbEvent)
+ return it;
+ }
+
+ return nullptr;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+MIR_APP_DLL(int) Clist_RemoveEvent(MCONTACT hContact, MEVENT hDbEvent)
+{
+ if (auto *pEvent = Clist_FindEvent(hContact, hDbEvent)) {
+ g_clistApi.pfnFreeEvent(pEvent);
+ return 0;
+ }
+
+ return 1;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
MIR_APP_DLL(CListEvent *) Clist_GetEvent(MCONTACT hContact, int idx)
{
if (hContact == INVALID_CONTACT_ID) {
@@ -264,9 +278,8 @@ int EventsProcessContactDoubleClick(MCONTACT hContact) {
for (auto &it : g_cliEvents) {
if (it->hContact == hContact) {
- MEVENT hDbEvent = it->hDbEvent;
CallService(it->pszService, 0, (LPARAM)it);
- g_clistApi.pfnRemoveEvent(hContact, hDbEvent);
+ g_clistApi.pfnFreeEvent(it);
return 0;
}
}
@@ -338,7 +351,7 @@ MIR_APP_DLL(int) Clist_EventsProcessTrayDoubleClick(int index) MCONTACT hContact = pEvent->hContact;
MEVENT hDbEvent = pEvent->hDbEvent;
CallService(pEvent->pszService, 0, (LPARAM)pEvent);
- g_clistApi.pfnRemoveEvent(hContact, hDbEvent);
+ Clist_RemoveEvent(hContact, hDbEvent);
return 0;
}
@@ -347,7 +360,7 @@ MIR_APP_DLL(int) Clist_EventsProcessTrayDoubleClick(int index) static int CListEventMarkedRead(WPARAM hContact, LPARAM hDbEvent)
{
- g_clistApi.pfnRemoveEvent(hContact, hDbEvent);
+ Clist_RemoveEvent(hContact, hDbEvent);
return 0;
}
diff --git a/src/mir_app/src/clistsettings.cpp b/src/mir_app/src/clistsettings.cpp index 4d3e60b9d4..b19de6d6a9 100644 --- a/src/mir_app/src/clistsettings.cpp +++ b/src/mir_app/src/clistsettings.cpp @@ -161,7 +161,7 @@ int ContactDeleted(WPARAM hContact, LPARAM) // remove events for a contact
for (auto &it : g_cliEvents.rev_iter())
if (it->hContact == hContact)
- g_clistApi.pfnRemoveEvent(hContact, it->hDbEvent);
+ Clist_RemoveEvent(hContact, it->hDbEvent);
Chat_RemoveContact(hContact);
return 0;
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 4dba25cc4d..02620ec096 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -870,3 +870,5 @@ Chat_IsMuted @941 NONAME ?setSize@FILE_BLOB@DB@@QAEX_J@Z @985 NONAME
?setUrl@FILE_BLOB@DB@@QAEXPBD@Z @986 NONAME
?Clist_GetEvent@@YGPAUCListEvent@@IH@Z @987 NONAME
+?Clist_FindEvent@@YGPAUCListEvent@@II@Z @988 NONAME
+Clist_RemoveEvent @989
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 6c56bbbffa..f6b294699f 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -870,3 +870,5 @@ Chat_IsMuted @941 NONAME ?setSize@FILE_BLOB@DB@@QEAAX_J@Z @985 NONAME
?setUrl@FILE_BLOB@DB@@QEAAXPEBD@Z @986 NONAME
?Clist_GetEvent@@YAPEAUCListEvent@@IH@Z @987 NONAME
+?Clist_FindEvent@@YAPEAUCListEvent@@II@Z @988 NONAME
+Clist_RemoveEvent @989
diff --git a/src/mir_app/src/srmm_log_rtf.cpp b/src/mir_app/src/srmm_log_rtf.cpp index ccd1480ba3..7c40253003 100644 --- a/src/mir_app/src/srmm_log_rtf.cpp +++ b/src/mir_app/src/srmm_log_rtf.cpp @@ -296,7 +296,7 @@ static bool CreateRtfFromDbEvent(RtfLogStreamData *dat) if (!(dbei.flags & DBEF_SENT) && (dbei.eventType == EVENTTYPE_MESSAGE || dbei.isSrmm())) {
db_event_markRead(dat->hContact, dat->hDbEvent);
- g_clistApi.pfnRemoveEvent(dat->hContact, dat->hDbEvent);
+ Clist_RemoveEvent(dat->hContact, dat->hDbEvent);
}
else if (dbei.eventType == EVENTTYPE_JABBER_CHATSTATES || dbei.eventType == EVENTTYPE_JABBER_PRESENCE) {
db_event_markRead(dat->hContact, dat->hDbEvent);
|