summaryrefslogtreecommitdiff
path: root/plugins/Clist_nicer/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-05-21 14:56:39 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-05-21 14:56:39 +0300
commitf04b54e3fc162d475e8688784631a316f264f733 (patch)
tree5feed9526e1c2acac25942f39f68713b8ccb9d1d /plugins/Clist_nicer/src
parentec8a7614a371f41937dc1dbc2d53289e45706e3a (diff)
Clist_RemoveEvent became static, pfnRemoveEvent is replaced with pfnFreeEvent
Diffstat (limited to 'plugins/Clist_nicer/src')
-rw-r--r--plugins/Clist_nicer/src/clistevents.cpp23
-rw-r--r--plugins/Clist_nicer/src/init.cpp4
2 files changed, 9 insertions, 18 deletions
diff --git a/plugins/Clist_nicer/src/clistevents.cpp b/plugins/Clist_nicer/src/clistevents.cpp
index 134738fcff..08a48dcede 100644
--- a/plugins/Clist_nicer/src/clistevents.cpp
+++ b/plugins/Clist_nicer/src/clistevents.cpp
@@ -161,7 +161,7 @@ LRESULT CALLBACK EventAreaWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa
// event we're interested in was removed by the service (nasty one...)
cle1 = MyGetEvent(iSelection);
if (cle1 != nullptr)
- g_clistApi.pfnRemoveEvent(cle->hContact, cle->hDbEvent);
+ Clist_RemoveEvent(cle->hContact, cle->hDbEvent);
}
}
}
@@ -312,20 +312,8 @@ CListEvent* AddEvent(CLISTEVENT *cle)
// wParam=(MCONTACT)hContact
// lParam=(LPARAM)(HANDLE)hDbEvent
// Returns 0 if the event was successfully removed, or nonzero if the event was not found
-int RemoveEvent(MCONTACT hContact, MEVENT hDbEvent)
+int RemoveEvent(CListEvent *e)
{
- // Find the event that should be removed
- CListEvent *e = nullptr;
- for (auto &it : *g_clistApi.events)
- if (it->hContact == hContact && it->hDbEvent == hDbEvent) {
- e = it;
- break;
- }
-
- // Event was not found
- if (e == nullptr)
- return 1;
-
// remove event from the notify menu
int iMenuId = e->menuId;
if (iMenuId > 0) {
@@ -334,14 +322,17 @@ int RemoveEvent(MCONTACT hContact, MEVENT hDbEvent)
mii.fMask = MIIM_DATA;
if (GetMenuItemInfo(cfg::dat.hMenuNotify, iMenuId, FALSE, &mii) != 0) {
struct NotifyMenuItemExData *nmi = (struct NotifyMenuItemExData *) mii.dwItemData;
- if (nmi && nmi->hContact == hContact && nmi->hDbEvent == hDbEvent) {
+ if (nmi && nmi->hContact == e->hContact && nmi->hDbEvent == e->hDbEvent) {
free(nmi);
DeleteMenu(cfg::dat.hMenuNotify, iMenuId, MF_BYCOMMAND);
}
}
}
- int res = coreCli.pfnRemoveEvent(hContact, hDbEvent);
+ // save variables, because core call frees the structure
+ auto hContact = e->hContact;
+ auto hDbEvent = e->hDbEvent;
+ int res = coreCli.pfnFreeEvent(e);
if (g_clistApi.events->getCount() == 0) {
cfg::dat.bEventAreaEnabled = FALSE;
diff --git a/plugins/Clist_nicer/src/init.cpp b/plugins/Clist_nicer/src/init.cpp
index a46350cb87..e9cf0b9f50 100644
--- a/plugins/Clist_nicer/src/init.cpp
+++ b/plugins/Clist_nicer/src/init.cpp
@@ -52,7 +52,7 @@ ClcGroup* AddGroup(HWND hwnd, struct ClcData *dat, const wchar_t *szName, uint
ClcContact* AddContactToGroup(struct ClcData *dat, ClcGroup *group, MCONTACT hContact);
ClcContact* AddInfoItemToGroup(ClcGroup *group, int flags, const wchar_t *pszText);
LRESULT ProcessExternalMessages(HWND hwnd, struct ClcData *dat, UINT msg, WPARAM wParam, LPARAM lParam);
-int RemoveEvent(MCONTACT hContact, MEVENT hDbEvent);
+int RemoveEvent(CListEvent *);
INT_PTR TrayIconProcessMessage(WPARAM wParam, LPARAM lParam);
void RecalcScrollBar(HWND hwnd, struct ClcData *dat);
@@ -196,7 +196,7 @@ int CMPlugin::Load()
g_clistApi.pfnAddContactToGroup = AddContactToGroup;
g_clistApi.pfnAddEvent = AddEvent;
- g_clistApi.pfnRemoveEvent = RemoveEvent;
+ g_clistApi.pfnFreeEvent = RemoveEvent;
g_clistApi.pfnAddGroup = AddGroup;
g_clistApi.pfnAddInfoItemToGroup = AddInfoItemToGroup;