diff options
author | George Hazan <george.hazan@gmail.com> | 2016-02-02 08:48:56 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2016-02-02 08:48:56 +0000 |
commit | 2c8efde364e6dc3e3ad2da9e99b667c1b56c1585 (patch) | |
tree | fad3ba812c31d855126c1ec68389da890f41f8a8 | |
parent | 8b76921724a22eda440f9a8d1fb52b9fa8cc0df0 (diff) |
another perversion (called EventList) died
git-svn-id: http://svn.miranda-ng.org/main/trunk@16210 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | include/delphi/m_clistint.inc | 2 | ||||
-rw-r--r-- | include/m_clistint.h | 18 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_clistevents.cpp | 29 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/clistevents.cpp | 31 | ||||
-rw-r--r-- | plugins/helpers/gen_helpers.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/clistevents.cpp | 174 | ||||
-rw-r--r-- | src/mir_app/src/miranda.h | 2 |
7 files changed, 119 insertions, 139 deletions
diff --git a/include/delphi/m_clistint.inc b/include/delphi/m_clistint.inc index 5b92b8f8ad..dd9526d786 100644 --- a/include/delphi/m_clistint.inc +++ b/include/delphi/m_clistint.inc @@ -452,7 +452,7 @@ type * version 2 - events processing
*************************************************************************************)
- events : TEventList;
+ events : PEventList;
pfnAddEvent : function (_para1:PCLISTEVENT):PCListEvent; cdecl;
pfnGetEvent : function (hContact:TMCONTACT; idx:int):PCLISTEVENT; cdecl;
diff --git a/include/m_clistint.h b/include/m_clistint.h index 04109666ba..a78ff48c6e 100644 --- a/include/m_clistint.h +++ b/include/m_clistint.h @@ -31,6 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_clist.h>
#endif
+#include <m_system_cpp.h>
#include <m_protocols.h>
#include <m_clc.h>
@@ -80,13 +81,6 @@ struct ContactList void* sortFunc;
};
-struct EventList
-{
- struct CListEvent** items;
- int count, limit, increment;
- void* sortFunc;
-};
-
struct ClcGroup
{
ContactList cl;
@@ -165,8 +159,14 @@ struct ClcDataBase int filterSearch;
};
-struct CListEvent : public CLISTEVENT
+struct CListEvent : public CLISTEVENT, public MZeroedObject
{
+ ~CListEvent()
+ {
+ mir_free(pszService);
+ mir_free(pszTooltip);
+ }
+
int imlIconIndex;
int flashesDone;
@@ -410,7 +410,7 @@ struct CLIST_INTERFACE * version 2 - events processing
*************************************************************************************/
- EventList events;
+ OBJLIST<CListEvent> *events;
struct CListEvent* (*pfnAddEvent)(CLISTEVENT*);
CLISTEVENT* (*pfnGetEvent)(MCONTACT hContact, int idx);
diff --git a/plugins/Clist_modern/src/modern_clistevents.cpp b/plugins/Clist_modern/src/modern_clistevents.cpp index 038f6449e7..78bd96b475 100644 --- a/plugins/Clist_modern/src/modern_clistevents.cpp +++ b/plugins/Clist_modern/src/modern_clistevents.cpp @@ -74,10 +74,10 @@ struct NotifyMenuItemExData { static CLISTEVENT* MyGetEvent(int iSelection)
{
- for (int i = 0; i < pcli->events.count; i++) {
- CListEvent *p = pcli->events.items[i];
- if (p->menuId == iSelection)
- return p;
+ for (int i = 0; i < pcli->events->getCount(); i++) {
+ CListEvent &p = (*pcli->events)[i];
+ if (p.menuId == iSelection)
+ return &p;
}
return NULL;
}
@@ -141,7 +141,7 @@ CListEvent* cli_AddEvent(CLISTEVENT *cle) g_CluiData.hUpdateContact = p->hContact;
}
- if (pcli->events.count > 0) {
+ if (pcli->events->getCount() > 0) {
g_CluiData.bEventAreaEnabled = TRUE;
if (g_CluiData.bNotifyActive == FALSE) {
g_CluiData.bNotifyActive = TRUE;
@@ -158,31 +158,34 @@ int cli_RemoveEvent(MCONTACT hContact, MEVENT hDbEvent) {
// Find the event that should be removed
int i;
- for (i = 0; i < pcli->events.count; i++)
- if ((pcli->events.items[i]->hContact == hContact) && (pcli->events.items[i]->hDbEvent == hDbEvent))
+ for (i = 0; i < pcli->events->getCount(); i++) {
+ CListEvent &e = (*pcli->events)[i];
+ if (e.hContact == hContact && e.hDbEvent == hDbEvent)
break;
+ }
// Event was not found
- if (i == pcli->events.count)
+ if (i == pcli->events->getCount())
return 1;
// remove event from the notify menu
- if (pcli->events.items[i]->menuId > 0) {
+ int iMenuId = (*pcli->events)[i].menuId;
+ if (iMenuId > 0) {
MENUITEMINFO mii = { 0 };
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_DATA;
- if (GetMenuItemInfo(g_CluiData.hMenuNotify, pcli->events.items[i]->menuId, FALSE, &mii) != 0) {
+ if (GetMenuItemInfo(g_CluiData.hMenuNotify, iMenuId, FALSE, &mii) != 0) {
struct NotifyMenuItemExData *nmi = (struct NotifyMenuItemExData *) mii.dwItemData;
if (nmi && nmi->hContact == hContact && nmi->hDbEvent == hDbEvent) {
free(nmi);
- DeleteMenu(g_CluiData.hMenuNotify, pcli->events.items[i]->menuId, MF_BYCOMMAND);
+ DeleteMenu(g_CluiData.hMenuNotify, iMenuId, MF_BYCOMMAND);
}
}
}
int res = corecli.pfnRemoveEvent(hContact, hDbEvent);
- if (pcli->events.count == 0) {
+ if (pcli->events->getCount() == 0) {
g_CluiData.bNotifyActive = FALSE;
EventArea_HideShowNotifyFrame();
}
@@ -263,7 +266,7 @@ static int ehhEventAreaBackgroundSettingsChanged(WPARAM, LPARAM) void EventArea_ConfigureEventArea()
{
- int iCount = pcli->events.count;
+ int iCount = pcli->events->getCount();
g_CluiData.dwFlags &= ~(CLUI_FRAME_AUTOHIDENOTIFY | CLUI_FRAME_SHOWALWAYS);
if (db_get_b(NULL, "CLUI", "EventArea", SETTING_EVENTAREAMODE_DEFAULT) == 1) g_CluiData.dwFlags |= CLUI_FRAME_AUTOHIDENOTIFY;
diff --git a/plugins/Clist_nicer/src/clistevents.cpp b/plugins/Clist_nicer/src/clistevents.cpp index 5db5463e11..39afbc541a 100644 --- a/plugins/Clist_nicer/src/clistevents.cpp +++ b/plugins/Clist_nicer/src/clistevents.cpp @@ -67,10 +67,10 @@ void HideShowNotifyFrame() static CLISTEVENT* MyGetEvent(int iSelection)
{
- for (int i = 0; i < pcli->events.count; i++) {
- CListEvent* p = pcli->events.items[i];
- if (p->menuId == iSelection)
- return p;
+ for (int i = 0; i < pcli->events->getCount(); i++) {
+ CListEvent &p = (*pcli->events)[i];
+ if (p.menuId == iSelection)
+ return &p;
}
return NULL;
}
@@ -298,7 +298,7 @@ CListEvent* AddEvent(CLISTEVENT *cle) }
}
- if (pcli->events.count > 0) {
+ if (pcli->events->getCount() > 0) {
cfg::dat.bEventAreaEnabled = TRUE;
if (cfg::dat.notifyActive == 0) {
cfg::dat.notifyActive = 1;
@@ -318,31 +318,34 @@ int RemoveEvent(MCONTACT hContact, MEVENT hDbEvent) {
// Find the event that should be removed
int i;
- for (i = 0; i < pcli->events.count; i++)
- if ((pcli->events.items[i]->hContact == hContact) && (pcli->events.items[i]->hDbEvent == hDbEvent))
+ for (i = 0; i < pcli->events->getCount(); i++) {
+ CListEvent &e = (*pcli->events)[i];
+ if (e.hContact == hContact && e.hDbEvent == hDbEvent)
break;
+ }
// Event was not found
- if (i == pcli->events.count)
+ if (i == pcli->events->getCount())
return 1;
// remove event from the notify menu
- if (pcli->events.items[i]->menuId > 0) {
+ int iMenuId = (*pcli->events)[i].menuId;
+ if (iMenuId > 0) {
MENUITEMINFO mii = { 0 };
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_DATA;
- if (GetMenuItemInfo(cfg::dat.hMenuNotify, pcli->events.items[i]->menuId, FALSE, &mii) != 0) {
+ if (GetMenuItemInfo(cfg::dat.hMenuNotify, iMenuId, FALSE, &mii) != 0) {
struct NotifyMenuItemExData *nmi = (struct NotifyMenuItemExData *) mii.dwItemData;
if (nmi && nmi->hContact == hContact && nmi->hDbEvent == hDbEvent) {
free(nmi);
- DeleteMenu(cfg::dat.hMenuNotify, pcli->events.items[i]->menuId, MF_BYCOMMAND);
+ DeleteMenu(cfg::dat.hMenuNotify, iMenuId, MF_BYCOMMAND);
}
}
}
- coreCli.pfnRemoveEvent(hContact, hDbEvent);
+ int res = coreCli.pfnRemoveEvent(hContact, hDbEvent);
- if (pcli->events.count == 0) {
+ if (pcli->events->getCount() == 0) {
cfg::dat.bEventAreaEnabled = FALSE;
if (cfg::dat.dwFlags & CLUI_FRAME_AUTOHIDENOTIFY) {
cfg::dat.notifyActive = 0;
@@ -363,5 +366,5 @@ int RemoveEvent(MCONTACT hContact, MEVENT hDbEvent) if (cfg::dat.notifyActive)
InvalidateRect(hwndEventFrame, NULL, FALSE);
- return 0;
+ return res;
}
diff --git a/plugins/helpers/gen_helpers.cpp b/plugins/helpers/gen_helpers.cpp index e79c66a7c4..aba815a2fd 100644 --- a/plugins/helpers/gen_helpers.cpp +++ b/plugins/helpers/gen_helpers.cpp @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
+*/
#include "commonheaders.h"
#include "gen_helpers.h"
diff --git a/src/mir_app/src/clistevents.cpp b/src/mir_app/src/clistevents.cpp index 7ed8ef4485..65985d8ed1 100644 --- a/src/mir_app/src/clistevents.cpp +++ b/src/mir_app/src/clistevents.cpp @@ -40,6 +40,8 @@ static int iconsOn; static int disableTrayFlash;
static int disableIconFlash;
+OBJLIST<CListEvent> g_cliEvents(10);
+
int fnGetImlIconIndex(HICON hIcon)
{
int i;
@@ -56,26 +58,26 @@ int fnGetImlIconIndex(HICON hIcon) static char* GetEventProtocol(int idx)
{
- if (!cli.events.count || idx < 0 && idx >= cli.events.count)
+ if (!g_cliEvents.getCount() || idx < 0 && idx >= g_cliEvents.getCount())
return NULL;
- CListEvent *ev = cli.events.items[idx];
- if (ev->hContact != NULL)
- return GetContactProto(ev->hContact);
+ CListEvent &ev = g_cliEvents[idx];
+ if (ev.hContact != NULL)
+ return GetContactProto(ev.hContact);
- return (ev->flags & CLEF_PROTOCOLGLOBAL) ? ev->lpszProtocol : NULL;
+ return (ev.flags & CLEF_PROTOCOLGLOBAL) ? ev.lpszProtocol : NULL;
}
static void ShowOneEventInTray(int idx)
{
- cli.pfnTrayIconUpdateWithImageList((iconsOn || disableTrayFlash) ? cli.events.items[idx]->imlIconIndex : 0, cli.events.items[idx]->ptszTooltip, GetEventProtocol(idx));
+ cli.pfnTrayIconUpdateWithImageList((iconsOn || disableTrayFlash) ? g_cliEvents[idx].imlIconIndex : 0, g_cliEvents[idx].ptszTooltip, GetEventProtocol(idx));
}
static void ShowEventsInTray()
{
int nTrayCnt = cli.trayIconCount;
- if (!cli.events.count || !nTrayCnt) return;
- if (cli.events.count == 1 || nTrayCnt == 1) {
+ if (!g_cliEvents.getCount() || !nTrayCnt) return;
+ if (g_cliEvents.getCount() == 1 || nTrayCnt == 1) {
ShowOneEventInTray(0); //for only one icon in tray show topmost event
return;
}
@@ -89,7 +91,7 @@ static void ShowEventsInTray() if (cli.trayIcon[i].id != 0 && cli.trayIcon[i].szProto)
pTrayProtos[nTrayProtoCnt++] = cli.trayIcon[i].szProto;
- for (int i = 0; i < cli.events.count; i++) {
+ for (int i = 0; i < g_cliEvents.getCount(); i++) {
char *iEventProto = GetEventProtocol(i);
int j;
@@ -108,21 +110,21 @@ static VOID CALLBACK IconFlashTimer(HWND, UINT, UINT_PTR idEvent, DWORD) {
ShowEventsInTray();
- for (int i=0; i < cli.events.count; i++) {
+ for (int i=0; i < g_cliEvents.getCount(); i++) {
int j;
for (j = 0; j < i; j++)
- if (cli.events.items[j]->hContact == cli.events.items[i]->hContact)
+ if (g_cliEvents[j].hContact == g_cliEvents[i].hContact)
break;
if (j >= i)
- cli.pfnChangeContactIcon(cli.events.items[i]->hContact, iconsOn || disableIconFlash ? cli.events.items[i]->imlIconIndex : 0, 0);
+ cli.pfnChangeContactIcon(g_cliEvents[i].hContact, iconsOn || disableIconFlash ? g_cliEvents[i].imlIconIndex : 0, 0);
// decrease eflashes in any case - no need to collect all events
- if (cli.events.items[i]->flags & CLEF_ONLYAFEW)
- if (0 >= --cli.events.items[i]->flashesDone)
- cli.pfnRemoveEvent(cli.events.items[i]->hContact, cli.events.items[i]->hDbEvent);
+ if (g_cliEvents[i].flags & CLEF_ONLYAFEW)
+ if (0 >= --g_cliEvents[i].flashesDone)
+ cli.pfnRemoveEvent(g_cliEvents[i].hContact, g_cliEvents[i].hDbEvent);
}
- if (cli.events.count == 0) {
+ if (g_cliEvents.getCount() == 0) {
KillTimer(NULL, idEvent);
cli.pfnTrayIconSetToBase(NULL);
}
@@ -137,26 +139,23 @@ CListEvent* fnAddEvent(CLISTEVENT *cle) int i;
if (cle->flags & CLEF_URGENT) {
- for (i=0; i < cli.events.count; i++)
- if (!(cli.events.items[i]->flags & CLEF_URGENT))
+ for (i=0; i < g_cliEvents.getCount(); i++)
+ if (!(g_cliEvents[i].flags & CLEF_URGENT))
break;
}
- else i = cli.events.count;
-
- CListEvent *p = (CListEvent*)mir_calloc(sizeof(CListEvent));
- if (p == NULL)
- return NULL;
+ else i = g_cliEvents.getCount();
- List_Insert((SortedList*)&cli.events, p, i);
+ CListEvent *p = new CListEvent();
+ g_cliEvents.insert(p, i);
memcpy(p, cle, sizeof(*cle));
- p->imlIconIndex = fnGetImlIconIndex(cli.events.items[i]->hIcon);
+ p->imlIconIndex = fnGetImlIconIndex(g_cliEvents[i].hIcon);
p->flashesDone = 12;
- p->pszService = mir_strdup(cli.events.items[i]->pszService);
+ p->pszService = mir_strdup(g_cliEvents[i].pszService);
if (p->flags & CLEF_UNICODE)
p->ptszTooltip = mir_tstrdup(p->ptszTooltip);
else
p->ptszTooltip = mir_a2u(p->pszTooltip); //if no flag defined it handled as unicode
- if (cli.events.count == 1) {
+ if (g_cliEvents.getCount() == 1) {
char *szProto;
if (cle->hContact == NULL) {
if (cle->flags & CLEF_PROTOCOLGLOBAL)
@@ -174,63 +173,55 @@ CListEvent* fnAddEvent(CLISTEVENT *cle) return p;
}
-static void fnFreeEvent(CListEvent *p)
-{
- mir_free(p->pszService);
- mir_free(p->pszTooltip);
- mir_free(p);
-}
-
// 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
int i;
- for (i = 0; i < cli.events.count; i++) {
- CListEvent *e = cli.events.items[i];
- if (e->hContact == hContact && e->hDbEvent == dbEvent)
+ for (i = 0; i < g_cliEvents.getCount(); i++) {
+ CListEvent &e = g_cliEvents[i];
+ if (e.hContact == hContact && e.hDbEvent == dbEvent)
break;
}
// Event was not found
- if (i == cli.events.count)
+ if (i == g_cliEvents.getCount())
return 1;
// Update contact's icon
char *szProto = GetContactProto(hContact);
- cli.pfnChangeContactIcon(cli.events.items[i]->hContact,
- CallService(MS_CLIST_GETCONTACTICON, (WPARAM)cli.events.items[i]->hContact, 1), 0);
+ cli.pfnChangeContactIcon(g_cliEvents[i].hContact,
+ CallService(MS_CLIST_GETCONTACTICON, (WPARAM)g_cliEvents[i].hContact, 1), 0);
// Free any memory allocated to the event
- fnFreeEvent(cli.events.items[i]);
- List_Remove((SortedList*)&cli.events, i);
+ g_cliEvents.remove(i);
// count same protocoled events
int nSameProto = 0;
char *szEventProto;
- for (i = 0; i < cli.events.count; i++) {
- if (cli.events.items[i]->hContact)
- szEventProto = GetContactProto((cli.events.items[i]->hContact));
- else if (cli.events.items[i]->flags & CLEF_PROTOCOLGLOBAL)
- szEventProto = (char*)cli.events.items[i]->lpszProtocol;
+ for (i = 0; i < g_cliEvents.getCount(); i++) {
+ if (g_cliEvents[i].hContact)
+ szEventProto = GetContactProto((g_cliEvents[i].hContact));
+ else if (g_cliEvents[i].flags & CLEF_PROTOCOLGLOBAL)
+ szEventProto = (char*)g_cliEvents[i].lpszProtocol;
else
szEventProto = NULL;
if (szEventProto && szProto && !mir_strcmp(szEventProto, szProto))
nSameProto++;
}
- if (cli.events.count == 0 || nSameProto == 0) {
- if (cli.events.count == 0)
+ if (g_cliEvents.getCount() == 0 || nSameProto == 0) {
+ if (g_cliEvents.getCount() == 0)
KillTimer(NULL, flashTimerId);
cli.pfnTrayIconSetToBase(hContact == NULL ? NULL : szProto);
}
else {
- if (cli.events.items[0]->hContact == NULL)
+ if (g_cliEvents[0].hContact == NULL)
szProto = NULL;
else
- szProto = GetContactProto(cli.events.items[0]->hContact);
- cli.pfnTrayIconUpdateWithImageList(iconsOn ? cli.events.items[0]->imlIconIndex : 0, cli.events.items[0]->ptszTooltip, szProto);
+ szProto = GetContactProto(g_cliEvents[0].hContact);
+ cli.pfnTrayIconUpdateWithImageList(iconsOn ? g_cliEvents[0].imlIconIndex : 0, g_cliEvents[0].ptszTooltip, szProto);
}
return 0;
@@ -239,24 +230,24 @@ int fnRemoveEvent(MCONTACT hContact, MEVENT dbEvent) CLISTEVENT* fnGetEvent(MCONTACT hContact, int idx)
{
if (hContact == INVALID_CONTACT_ID) {
- if (idx >= cli.events.count)
+ if (idx >= g_cliEvents.getCount())
return NULL;
- return cli.events.items[idx];
+ return &g_cliEvents[idx];
}
- for (int i=0; i < cli.events.count; i++)
- if (cli.events.items[i]->hContact == hContact)
+ for (int i=0; i < g_cliEvents.getCount(); i++)
+ if (g_cliEvents[i].hContact == hContact)
if (idx-- == 0)
- return cli.events.items[i];
+ return &g_cliEvents[i];
return NULL;
}
int fnEventsProcessContactDoubleClick(MCONTACT hContact)
{
- for (int i = 0; i < cli.events.count; i++) {
- if (cli.events.items[i]->hContact == hContact) {
- MEVENT hDbEvent = cli.events.items[i]->hDbEvent;
- CallService(cli.events.items[i]->pszService, NULL, (LPARAM)cli.events.items[i]);
+ for (int i = 0; i < g_cliEvents.getCount(); i++) {
+ if (g_cliEvents[i].hContact == hContact) {
+ MEVENT hDbEvent = g_cliEvents[i].hDbEvent;
+ CallService(g_cliEvents[i].pszService, NULL, (LPARAM)&g_cliEvents[i]);
cli.pfnRemoveEvent(hContact, hDbEvent);
return 0;
}
@@ -268,7 +259,7 @@ int fnEventsProcessContactDoubleClick(MCONTACT hContact) int fnEventsProcessTrayDoubleClick(int index)
{
BOOL click_in_first_icon = FALSE;
- if (cli.events.count == 0)
+ if (g_cliEvents.getCount() == 0)
return 1;
int eventIndex = 0;
@@ -286,12 +277,12 @@ int fnEventsProcessTrayDoubleClick(int index) }
}
if (szProto) {
- for (i = 0; i < cli.events.count; i++) {
+ for (i = 0; i < g_cliEvents.getCount(); i++) {
char *eventProto = NULL;
- if (cli.events.items[i]->hContact)
- eventProto = GetContactProto(cli.events.items[i]->hContact);
+ if (g_cliEvents[i].hContact)
+ eventProto = GetContactProto(g_cliEvents[i].hContact);
if (!eventProto)
- eventProto = cli.events.items[i]->lpszProtocol;
+ eventProto = g_cliEvents[i].lpszProtocol;
if (!eventProto || !_strcmpi(eventProto, szProto)) {
eventIndex = i;
@@ -300,14 +291,14 @@ int fnEventsProcessTrayDoubleClick(int index) }
// let's process backward try to find first event without desired proto in tray
- if (i == cli.events.count) {
+ if (i == g_cliEvents.getCount()) {
if (click_in_first_icon) {
- for (i = 0; i < cli.events.count; i++) {
+ for (i = 0; i < g_cliEvents.getCount(); i++) {
char *eventProto = NULL;
- if (cli.events.items[i]->hContact)
- eventProto = GetContactProto(cli.events.items[i]->hContact);
+ if (g_cliEvents[i].hContact)
+ eventProto = GetContactProto(g_cliEvents[i].hContact);
if (!eventProto)
- eventProto = cli.events.items[i]->lpszProtocol;
+ eventProto = g_cliEvents[i].lpszProtocol;
if (!eventProto)
continue;
@@ -322,41 +313,27 @@ int fnEventsProcessTrayDoubleClick(int index) }
}
}
- if (i == cli.events.count) //not found
+ if (i == g_cliEvents.getCount()) //not found
return 1; //continue processing to show contact list
}
}
}
lck.unlock();
- MCONTACT hContact = cli.events.items[eventIndex]->hContact;
- MEVENT hDbEvent = cli.events.items[eventIndex]->hDbEvent;
+ MCONTACT hContact = g_cliEvents[eventIndex].hContact;
+ MEVENT hDbEvent = g_cliEvents[eventIndex].hDbEvent;
// ; may be better to show send msg?
- CallService(cli.events.items[eventIndex]->pszService, 0, (LPARAM)cli.events.items[eventIndex]);
+ CallService(g_cliEvents[eventIndex].pszService, 0, (LPARAM)&g_cliEvents[eventIndex]);
cli.pfnRemoveEvent(hContact, hDbEvent);
return 0;
}
static int RemoveEventsForContact(WPARAM wParam, LPARAM)
{
- int j, hit;
-
- /*
- the for (;;) loop is used here since the cli.events.count can not be relied upon to take us
- thru the cli.events.items[] array without suffering from shortsightedness about how many unseen
- events remain, e.g. three events, we remove the first, we're left with 2, the event
- loop exits at 2 and we never see the real new 2.
- */
-
- for (; cli.events.count > 0;) {
- for (hit = 0, j = 0; j < cli.events.count; j++) {
- if (cli.events.items[j]->hContact == wParam) {
- cli.pfnRemoveEvent(wParam, cli.events.items[j]->hDbEvent);
- hit = 1;
- }
- }
- if (j == cli.events.count && hit == 0)
- return 0; /* got to the end of the array and didnt remove anything */
+ for (int i = g_cliEvents.getCount()-1; i >= 0; i--) {
+ CListEvent &e = g_cliEvents[i];
+ if (e.hContact == wParam)
+ cli.pfnRemoveEvent(wParam, e.hDbEvent);
}
return 0;
@@ -378,8 +355,7 @@ static int CListEventSettingsChanged(WPARAM hContact, LPARAM lParam) int InitCListEvents(void)
{
- memset(&cli.events, 0, sizeof(cli.events));
- cli.events.increment = 10;
+ cli.events = &g_cliEvents;
disableTrayFlash = db_get_b(NULL, "CList", "DisableTrayFlash", 0);
disableIconFlash = db_get_b(NULL, "CList", "NoIconBlink", 0);
@@ -390,13 +366,9 @@ int InitCListEvents(void) void UninitCListEvents(void)
{
- if (cli.events.count)
+ if (g_cliEvents.getCount())
KillTimer(NULL, flashTimerId);
-
- for (int i = 0; i < cli.events.count; i++)
- fnFreeEvent(cli.events.items[i]);
-
- List_Destroy((SortedList*)&cli.events);
+ g_cliEvents.destroy();
if (imlIcon != NULL)
mir_free(imlIcon);
diff --git a/src/mir_app/src/miranda.h b/src/mir_app/src/miranda.h index 6de6a6c6f7..0a46080262 100644 --- a/src/mir_app/src/miranda.h +++ b/src/mir_app/src/miranda.h @@ -121,6 +121,8 @@ extern const int statusModeList[ MAX_STATUS_COUNT ]; extern const int skinIconStatusList[ MAX_STATUS_COUNT ];
extern const int skinIconStatusFlags[ MAX_STATUS_COUNT ];
+extern OBJLIST<CListEvent> g_cliEvents;
+
int TryProcessDoubleClick(MCONTACT hContact);
/**** protocols.cpp *********************************************************************/
|