From ba56d9f794ef819de024b90f136ee35fd07cb4e8 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 14 Aug 2013 20:56:58 +0000 Subject: cleaning popup-related junk git-svn-id: http://svn.miranda-ng.org/main/trunk@5693 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TabSRMM/src/chat/tools.cpp | 2 +- plugins/TabSRMM/src/eventpopups.cpp | 77 +++++++++++++------------------------ plugins/TabSRMM/src/nen.h | 3 +- plugins/TabSRMM/src/utils.cpp | 2 +- 4 files changed, 30 insertions(+), 54 deletions(-) (limited to 'plugins/TabSRMM/src') diff --git a/plugins/TabSRMM/src/chat/tools.cpp b/plugins/TabSRMM/src/chat/tools.cpp index 393a92e111..71db16c4c9 100644 --- a/plugins/TabSRMM/src/chat/tools.cpp +++ b/plugins/TabSRMM/src/chat/tools.cpp @@ -158,7 +158,7 @@ static void TSAPI Chat_DismissPopup(const SESSION_INFO *si, HWND hwndPopup) static INT_PTR CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - SESSION_INFO *si = (SESSION_INFO*)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, 0);; + SESSION_INFO *si = (SESSION_INFO*)PUGetPluginData(hWnd); switch (message) { case WM_COMMAND: diff --git a/plugins/TabSRMM/src/eventpopups.cpp b/plugins/TabSRMM/src/eventpopups.cpp index 0aaaa2952a..44cb28d69a 100644 --- a/plugins/TabSRMM/src/eventpopups.cpp +++ b/plugins/TabSRMM/src/eventpopups.cpp @@ -40,22 +40,13 @@ #include "commonheaders.h" -typedef std::vector::iterator PopupListIterator; -static std::vector PopupList; +static LIST arPopupList(10, HandleKeySortT); -BOOL bWmNotify = TRUE; +BOOL bWmNotify = TRUE; -static const PLUGIN_DATAT* PU_GetByContact(const HANDLE hContact) +static PLUGIN_DATAT* PU_GetByContact(const HANDLE hContact) { - if (PopupList.size()) { - PopupListIterator it = PopupList.begin(); - while(it != PopupList.end()) { - if ((*it)->hContact == hContact) - return(*it); - it++; - } - } - return 0; + return arPopupList.find((PLUGIN_DATAT*)&hContact); } /** @@ -65,22 +56,12 @@ static const PLUGIN_DATAT* PU_GetByContact(const HANDLE hContact) */ static void PU_CleanUp() { - if (PopupList.size()) { - PopupListIterator it = PopupList.begin(); - while(it != PopupList.end()) { - if (PopupList.size() == 0) - break; - if ((*it)->hContact == 0) { - //_DebugTraceW(_T("found stale popup %s"), (*it)->eventData->szText); - if ((*it)->eventData) - mir_free((*it)->eventData); - mir_free(*it); - it = PopupList.erase(it); - continue; - } - it++; - } + for (int i=0; i < arPopupList.getCount(); i++) { + PLUGIN_DATAT *p = arPopupList[i]; + mir_free(p->eventData); + mir_free(p); } + arPopupList.destroy(); } static void CheckForRemoveMask() @@ -441,12 +422,9 @@ static int PopupAct(HWND hWnd, UINT mask, PLUGIN_DATAT* pdata) PUDeletePopup(hWnd); if (pdata->hContainer) { - FLASHWINFO fwi; - fwi.cbSize = sizeof(fwi); - fwi.uCount = 0; + FLASHWINFO fwi = { sizeof(fwi) }; fwi.dwFlags = FLASHW_STOP; fwi.hwnd = pdata->hContainer; - fwi.dwTimeout = 0; FlashWindowEx(&fwi); } } @@ -455,10 +433,9 @@ static int PopupAct(HWND hWnd, UINT mask, PLUGIN_DATAT* pdata) static BOOL CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - PLUGIN_DATAT* pdata = NULL; - - pdata = (PLUGIN_DATAT *)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, (LPARAM)pdata); - if (!pdata) return FALSE; + PLUGIN_DATAT *pdata = (PLUGIN_DATAT*)PUGetPluginData(hWnd); + if (pdata == NULL) + return FALSE; switch (message) { case WM_COMMAND: @@ -510,7 +487,7 @@ static BOOL CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM * @return */ -static TCHAR *ShortenPreview(DBEVENTINFO* dbe) +static TCHAR* ShortenPreview(DBEVENTINFO* dbe) { bool fAddEllipsis = false; int iPreviewLimit = nen_options.iLimitPreview; @@ -534,9 +511,9 @@ static TCHAR *ShortenPreview(DBEVENTINFO* dbe) return buf; } -static TCHAR *GetPreviewT(WORD eventType, DBEVENTINFO* dbe) +static TCHAR* GetPreviewT(WORD eventType, DBEVENTINFO* dbe) { - char *pBlob = (char *)dbe->pBlob; + char *pBlob = (char *)dbe->pBlob; switch (eventType) { case EVENTTYPE_MESSAGE: @@ -594,11 +571,11 @@ static int PopupUpdateT(HANDLE hContact, HANDLE hEvent) if (hEvent == NULL) return 0; - if (pdata->pluginOptions->bShowHeaders) { - mir_sntprintf(pdata->szHeader, SIZEOF(pdata->szHeader), _T("%s %d\n"), - TranslateT("New messages: "), pdata->nrMerged + 1); - pdata->szHeader[255] = 0; - } + TCHAR szHeader[256]; + if (pdata->pluginOptions->bShowHeaders) + mir_sntprintf(szHeader, SIZEOF(szHeader), _T("%s %d\n"), TranslateT("New messages: "), pdata->nrMerged + 1); + else + szHeader[0] = 0; DBEVENTINFO dbe = { sizeof(dbe) }; if (pdata->pluginOptions->bPreview && hContact) { @@ -625,11 +602,11 @@ static int PopupUpdateT(HANDLE hContact, HANDLE hEvent) * for which there is enough space in the popup text */ - TCHAR lpzText[MAX_SECONDLINE] = _T(""); + TCHAR lpzText[MAX_SECONDLINE]; int i, available = MAX_SECONDLINE - 1; if (pdata->pluginOptions->bShowHeaders) { - _tcsncpy(lpzText, pdata->szHeader, MAX_SECONDLINE); - available -= lstrlen(pdata->szHeader); + _tcsncpy(lpzText, szHeader, MAX_SECONDLINE); + available -= lstrlen(szHeader); } for (i = pdata->nrMerged; i >= 0; i--) { available -= lstrlen(pdata->eventData[i].szText); @@ -657,8 +634,8 @@ static int PopupUpdateT(HANDLE hContact, HANDLE hEvent) static int PopupShowT(NEN_OPTIONS *pluginOptions, HANDLE hContact, HANDLE hEvent, UINT eventType, HWND hContainer) { //there has to be a maximum number of popups shown at the same time - if (PopupList.size() >= MAX_POPUPS) - return(2); + if (arPopupList.getCount() >= MAX_POPUPS) + return 2; if (!PluginConfig.g_PopupAvail) return 0; @@ -734,7 +711,7 @@ static int PopupShowT(NEN_OPTIONS *pluginOptions, HANDLE hContact, HANDLE hEvent mir_free(pdata->eventData); mir_free(pdata); } - else PopupList.push_back(pdata); + else arPopupList.insert(pdata); if (dbe.pBlob) mir_free(dbe.pBlob); diff --git a/plugins/TabSRMM/src/nen.h b/plugins/TabSRMM/src/nen.h index dfe3402bfa..36cdf03ab2 100644 --- a/plugins/TabSRMM/src/nen.h +++ b/plugins/TabSRMM/src/nen.h @@ -143,13 +143,12 @@ struct EVENT_DATAT struct PLUGIN_DATAT { - UINT eventType; HANDLE hContact; + UINT eventType; NEN_OPTIONS *pluginOptions; POPUPDATAT *pud; HWND hWnd; long iSeconds; - TCHAR szHeader[256]; int nrMerged; EVENT_DATAT *eventData; int nrEventsAlloced; diff --git a/plugins/TabSRMM/src/utils.cpp b/plugins/TabSRMM/src/utils.cpp index bfce442532..d278132555 100644 --- a/plugins/TabSRMM/src/utils.cpp +++ b/plugins/TabSRMM/src/utils.cpp @@ -690,7 +690,7 @@ int Utils::RTFColorToIndex(int iCol) */ INT_PTR CALLBACK Utils::PopupDlgProcError(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - HANDLE hContact = (HANDLE)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, (LPARAM)&hContact); + HANDLE hContact = (HANDLE)PUGetPluginData(hWnd); switch (message) { case WM_COMMAND: -- cgit v1.2.3