From 02d5017ff8c7e8d66adbb210433a93cff45d94d8 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 28 Jan 2016 10:19:17 +0000 Subject: tabSRMM: fix to restore the saved events order on startup git-svn-id: http://svn.miranda-ng.org/main/trunk@16176 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TabSRMM/src/globals.cpp | 40 +++++++++++++++++++++++++++---------- plugins/TabSRMM/src/mim.cpp | 10 ++++++---- plugins/TabSRMM/src/msgdlgutils.cpp | 5 +++-- 3 files changed, 38 insertions(+), 17 deletions(-) (limited to 'plugins/TabSRMM/src') diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp index ba2b5d4508..a3dbf0e364 100644 --- a/plugins/TabSRMM/src/globals.cpp +++ b/plugins/TabSRMM/src/globals.cpp @@ -527,12 +527,20 @@ int CGlobals::OkToExit(WPARAM, LPARAM) ///////////////////////////////////////////////////////////////////////////////////////// // used on startup to restore flashing tray icon if one or more messages are still "unread" +struct MSavedEvent +{ + MSavedEvent(MCONTACT _hContact, MEVENT _hEvent) : + hContact(_hContact), + hEvent(_hEvent) + {} + + MEVENT hEvent; + MCONTACT hContact; +}; + void CGlobals::RestoreUnreadMessageAlerts(void) { - CLISTEVENT cle = { sizeof(cle) }; - cle.hIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE); - cle.pszService = "SRMsg/ReadMessage"; - cle.flags = CLEF_TCHAR; + OBJLIST arEvents(10, NumericKeySortT); for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { if (db_get_dw(hContact, "SendLater", "count", 0)) @@ -545,16 +553,26 @@ void CGlobals::RestoreUnreadMessageAlerts(void) if (M.FindWindow(hContact) != NULL) continue; - cle.hContact = hContact; - cle.hDbEvent = hDbEvent; - - TCHAR toolTip[256]; - mir_sntprintf(toolTip, TranslateT("Message from %s"), pcli->pfnGetContactDisplayName(hContact, 0)); - cle.ptszTooltip = toolTip; - CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle); + arEvents.insert(new MSavedEvent(hContact, hDbEvent)); } } } + TCHAR toolTip[256]; + + CLISTEVENT cle = {}; + cle.cbSize = sizeof(cle); + cle.hIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE); + cle.pszService = "SRMsg/ReadMessage"; + cle.flags = CLEF_TCHAR; + cle.ptszTooltip = toolTip; + + for (int i = 0; i < arEvents.getCount(); i++) { + MSavedEvent &e = arEvents[i]; + mir_sntprintf(toolTip, TranslateT("Message from %s"), pcli->pfnGetContactDisplayName(e.hContact, 0)); + cle.hContact = e.hContact; + cle.hDbEvent = e.hEvent; + pcli->pfnAddEvent(&cle); + } } void CGlobals::logStatusChange(WPARAM wParam, const CContactCache *c) diff --git a/plugins/TabSRMM/src/mim.cpp b/plugins/TabSRMM/src/mim.cpp index 076f1d939e..c2bb842037 100644 --- a/plugins/TabSRMM/src/mim.cpp +++ b/plugins/TabSRMM/src/mim.cpp @@ -311,15 +311,17 @@ int CMimAPI::TypingMessage(WPARAM hContact, LPARAM mode) CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)&tn); } if (fShowOnClist) { - CLISTEVENT cle = { sizeof(cle) }; + pcli->pfnRemoveEvent(hContact, 1); + + CLISTEVENT cle = {}; + cle.cbSize = sizeof(cle); cle.hContact = hContact; cle.hDbEvent = 1; cle.flags = CLEF_ONLYAFEW | CLEF_TCHAR; cle.hIcon = PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING]; cle.pszService = "SRMsg/TypingMessage"; cle.ptszTooltip = szTip; - CallServiceSync(MS_CLIST_REMOVEEVENT, hContact, 1); - CallServiceSync(MS_CLIST_ADDEVENT, hContact, (LPARAM)&cle); + pcli->pfnAddEvent(&cle); } } return 0; @@ -552,7 +554,7 @@ nowindowcreate: contactName = pcli->pfnGetContactDisplayName(hContact, 0); mir_sntprintf(toolTip, TranslateT("Message from %s"), contactName); cle.ptszTooltip = toolTip; - CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle); + pcli->pfnAddEvent(&cle); } tabSRMM_ShowPopup(hContact, hDbEvent, dbei.eventType, 0, 0, 0, dbei.szModule); } diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp index c590dad1cd..f7b32970e7 100644 --- a/plugins/TabSRMM/src/msgdlgutils.cpp +++ b/plugins/TabSRMM/src/msgdlgutils.cpp @@ -772,13 +772,14 @@ void TSAPI FlashOnClist(HWND hwndDlg, TWindowData *dat, MEVENT hEvent, DBEVENTIN return; if ((GetForegroundWindow() != dat->pContainer->hwnd || dat->pContainer->hwndActive != hwndDlg) && !(dbei->flags & DBEF_SENT) && dbei->eventType == EVENTTYPE_MESSAGE && !(dat->dwFlagsEx & MWF_SHOW_FLASHCLIST)) { - CLISTEVENT cle = { 0 }; + CLISTEVENT cle = {}; cle.cbSize = sizeof(cle); cle.hContact = (MCONTACT)dat->hContact; cle.hDbEvent = hEvent; cle.hIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE); cle.pszService = "SRMsg/ReadMessage"; - CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle); + pcli->pfnAddEvent(&cle); + dat->dwFlagsEx |= MWF_SHOW_FLASHCLIST; dat->hFlashingEvent = hEvent; } -- cgit v1.2.3