diff options
author | George Hazan <george.hazan@gmail.com> | 2023-05-21 15:23:35 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-05-21 15:23:35 +0300 |
commit | d43eaaab830eb233f998f2bf5514b3943b6aeb30 (patch) | |
tree | ca9cfdd69f9019197b2ba8ce709518f1fa91a61a /plugins | |
parent | f04b54e3fc162d475e8688784631a316f264f733 (diff) |
link to events collection also removed from CLIST_INTERFACE + code cleaning
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Clist_modern/src/modern_clistevents.cpp | 23 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/clistevents.cpp | 19 |
2 files changed, 11 insertions, 31 deletions
diff --git a/plugins/Clist_modern/src/modern_clistevents.cpp b/plugins/Clist_modern/src/modern_clistevents.cpp index d0eb4753d2..a578a69a29 100644 --- a/plugins/Clist_modern/src/modern_clistevents.cpp +++ b/plugins/Clist_modern/src/modern_clistevents.cpp @@ -54,15 +54,6 @@ struct NotifyMenuItemExData MEVENT hDbEvent;
};
-static CLISTEVENT* MyGetEvent(int iSelection)
-{
- for (auto &it : *g_clistApi.events)
- if (it->menuId == iSelection)
- return it;
-
- return nullptr;
-}
-
static void EventArea_HideShowNotifyFrame()
{
int dwVisible = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, hNotifyFrame), 0) & F_VISIBLE;
@@ -142,7 +133,7 @@ CListEvent* cli_AddEvent(CLISTEVENT *cle) g_CluiData.hUpdateContact = p->hContact;
}
- if (g_clistApi.events->getCount() > 0) {
+ if (Clist_GetEventCount() > 0) {
g_CluiData.bEventAreaEnabled = true;
if (g_CluiData.bNotifyActive == false) {
g_CluiData.bNotifyActive = true;
@@ -178,7 +169,7 @@ int cli_RemoveEvent(CListEvent *pEvent) int res = corecli.pfnFreeEvent(pEvent);
- if (g_clistApi.events->getCount() == 0) {
+ if (Clist_GetEventCount() == 0) {
g_CluiData.bNotifyActive = false;
EventArea_HideShowNotifyFrame();
}
@@ -245,8 +236,6 @@ static int ehhEventAreaBackgroundSettingsChanged(WPARAM, LPARAM) void EventArea_ConfigureEventArea()
{
- int iCount = g_clistApi.events->getCount();
-
g_CluiData.dwFlags &= ~(CLUI_FRAME_AUTOHIDENOTIFY | CLUI_FRAME_SHOWALWAYS);
if (db_get_b(0, "CLUI", "EventArea", SETTING_EVENTAREAMODE_DEFAULT) == 1) g_CluiData.dwFlags |= CLUI_FRAME_AUTOHIDENOTIFY;
if (db_get_b(0, "CLUI", "EventArea", SETTING_EVENTAREAMODE_DEFAULT) == 2) g_CluiData.dwFlags |= CLUI_FRAME_SHOWALWAYS;
@@ -254,7 +243,7 @@ void EventArea_ConfigureEventArea() if (g_CluiData.dwFlags & CLUI_FRAME_SHOWALWAYS)
g_CluiData.bNotifyActive = true;
else if (g_CluiData.dwFlags & CLUI_FRAME_AUTOHIDENOTIFY)
- g_CluiData.bNotifyActive = iCount > 0;
+ g_CluiData.bNotifyActive = Clist_GetEventCount() > 0;
else
g_CluiData.bNotifyActive = false;
@@ -391,13 +380,13 @@ static LRESULT CALLBACK EventArea_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LP if (result != 0) {
NotifyMenuItemExData *nmi = (NotifyMenuItemExData*)mii.dwItemData;
if (nmi) {
- CLISTEVENT *cle = MyGetEvent(iSelection);
+ auto *cle = Clist_GetEventByMenu(iSelection);
if (cle) {
- CLISTEVENT *cle1 = nullptr;
CallService(cle->pszService, (WPARAM)nullptr, (LPARAM)cle);
+
// re-obtain the pointer, it may already be invalid/point to another event if the
// event we're interested in was removed by the service (nasty one...)
- cle1 = MyGetEvent(iSelection);
+ auto cle1 = Clist_GetEventByMenu(iSelection);
if (cle1 != nullptr)
Clist_RemoveEvent(cle->hContact, cle->hDbEvent);
}
diff --git a/plugins/Clist_nicer/src/clistevents.cpp b/plugins/Clist_nicer/src/clistevents.cpp index 08a48dcede..667fc07b3f 100644 --- a/plugins/Clist_nicer/src/clistevents.cpp +++ b/plugins/Clist_nicer/src/clistevents.cpp @@ -64,15 +64,6 @@ void HideShowNotifyFrame() }
}
-static CLISTEVENT* MyGetEvent(int iSelection)
-{
- for (auto &p : *g_clistApi.events)
- if (p->menuId == iSelection)
- return p;
-
- return nullptr;
-}
-
LRESULT CALLBACK EventAreaWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
@@ -153,13 +144,13 @@ LRESULT CALLBACK EventAreaWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa if (result != 0) {
nmi = (struct NotifyMenuItemExData *) mii.dwItemData;
if (nmi) {
- CLISTEVENT *cle = MyGetEvent(iSelection);
+ auto *cle = Clist_GetEventByMenu(iSelection);
if (cle) {
- CLISTEVENT *cle1 = nullptr;
CallService(cle->pszService, (WPARAM)NULL, (LPARAM)cle);
+
// re-obtain the pointer, it may already be invalid/point to another event if the
// event we're interested in was removed by the service (nasty one...)
- cle1 = MyGetEvent(iSelection);
+ auto *cle1 = Clist_GetEventByMenu(iSelection);
if (cle1 != nullptr)
Clist_RemoveEvent(cle->hContact, cle->hDbEvent);
}
@@ -296,7 +287,7 @@ CListEvent* AddEvent(CLISTEVENT *cle) }
}
- if (g_clistApi.events->getCount() > 0) {
+ if (Clist_GetEventCount() > 0) {
cfg::dat.bEventAreaEnabled = TRUE;
if (cfg::dat.notifyActive == 0) {
cfg::dat.notifyActive = 1;
@@ -334,7 +325,7 @@ int RemoveEvent(CListEvent *e) auto hDbEvent = e->hDbEvent;
int res = coreCli.pfnFreeEvent(e);
- if (g_clistApi.events->getCount() == 0) {
+ if (Clist_GetEventCount() == 0) {
cfg::dat.bEventAreaEnabled = FALSE;
if (cfg::dat.dwFlags & CLUI_FRAME_AUTOHIDENOTIFY) {
cfg::dat.notifyActive = 0;
|