From 31582b9e959b65cb9e29c4197a42e1a7e9ca804e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 3 Aug 2013 18:51:25 +0000 Subject: tray icons code standardization git-svn-id: http://svn.miranda-ng.org/main/trunk@5569 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- .../Clist_modern/src/hdr/modern_commonprototypes.h | 2 +- plugins/Clist_modern/src/init.cpp | 2 +- plugins/Clist_modern/src/modern_clisttray.cpp | 76 +++++++--------------- plugins/Clist_modern/src/modern_clui.cpp | 4 +- plugins/Clist_modern/src/modern_cluiservices.cpp | 2 +- 5 files changed, 28 insertions(+), 58 deletions(-) (limited to 'plugins/Clist_modern/src') diff --git a/plugins/Clist_modern/src/hdr/modern_commonprototypes.h b/plugins/Clist_modern/src/hdr/modern_commonprototypes.h index 844638c10b..26ef062251 100644 --- a/plugins/Clist_modern/src/hdr/modern_commonprototypes.h +++ b/plugins/Clist_modern/src/hdr/modern_commonprototypes.h @@ -300,7 +300,7 @@ int cliShowHide(WPARAM wParam,LPARAM lParam); BOOL CLUI__cliInvalidateRect(HWND hWnd, CONST RECT* lpRect,BOOL bErase ); int cliCompareContacts(const ClcContact *contact1,const ClcContact *contact2); int cliFindItem(HWND hwnd,ClcData *dat,HANDLE hItem,ClcContact **contact,ClcGroup **subgroup,int *isVisible); -void cliTrayIconUpdateBase(const char *szChangedProto); +int cliTrayCalcChanged(const char *szChangedProto, int averageMode, int netProtoCount); int cliTrayIconPauseAutoHide(WPARAM wParam,LPARAM lParam); void cliCluiProtocolStatusChanged(int status,const char * proto); HMENU cliBuildGroupPopupMenu(ClcGroup *group); diff --git a/plugins/Clist_modern/src/init.cpp b/plugins/Clist_modern/src/init.cpp index da3e5d1b0f..876a3b3464 100644 --- a/plugins/Clist_modern/src/init.cpp +++ b/plugins/Clist_modern/src/init.cpp @@ -158,7 +158,7 @@ static HRESULT SubclassClistInterface() pcli->pfnInvalidateDisplayNameCacheEntry = cliInvalidateDisplayNameCacheEntry; pcli->pfnTrayIconPauseAutoHide = cliTrayIconPauseAutoHide; - pcli->pfnTrayIconUpdateBase = cliTrayIconUpdateBase; + pcli->pfnTrayCalcChanged = cliTrayCalcChanged; pcli->pfnCluiProtocolStatusChanged = cliCluiProtocolStatusChanged; pcli->pfnBeginRenameSelection = cliBeginRenameSelection; diff --git a/plugins/Clist_modern/src/modern_clisttray.cpp b/plugins/Clist_modern/src/modern_clisttray.cpp index 19a6b8c605..f50a5c3c34 100644 --- a/plugins/Clist_modern/src/modern_clisttray.cpp +++ b/plugins/Clist_modern/src/modern_clisttray.cpp @@ -155,33 +155,14 @@ static VOID CALLBACK RefreshTimerProc(HWND hwnd,UINT message,UINT idEvent,DWORD } //////// End by FYR ///////// -void cliTrayIconUpdateBase(const char *szChangedProto) +int cliTrayCalcChanged(const char *szChangedProto, int averageMode, int netProtoCount) { - if ( !szChangedProto) return; - if ( !pcli->pfnGetProtocolVisibility(szChangedProto)) return; - - int i,count,netProtoCount,changed = -1; - PROTOACCOUNT **accs; - int averageMode = 0; + int changed = -1; HWND hwnd = pcli->hwndContactList; DBVARIANT dbv; char *szProto = NULL; - pcli->pfnLockTray(); - if ( pcli->cycleTimerId ) { - KillTimer( NULL, pcli->cycleTimerId); - pcli->cycleTimerId = 0; - } - ProtoEnumAccounts( &count, &accs ); - for (i=0, netProtoCount = 0;i < count;i++) { - if ( pcli->pfnGetProtocolVisibility(accs[i]->szModuleName) == 0 ) continue; - netProtoCount++; - if ( !lstrcmpA(szChangedProto,accs[i]->szModuleName)) pcli->cycleStep = i; - if (averageMode == 0) averageMode = CallProtoService(accs[i]->szModuleName,PS_GETSTATUS, 0, 0); - else if (averageMode != CallProtoService(accs[i]->szModuleName,PS_GETSTATUS, 0, 0)) {averageMode = -1; break;} - } - - if (netProtoCount>1) { + if (netProtoCount > 1) { if (averageMode >= ID_STATUS_OFFLINE) { if ( db_get_b(NULL,"CList","TrayIcon",SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_MULTI) { if ( db_get_b(NULL,"CList","AlwaysMulti",SETTING_ALWAYSMULTI_DEFAULT)) @@ -222,7 +203,7 @@ void cliTrayIconUpdateBase(const char *szChangedProto) CListTray_GetGlobalStatus(0, 0); if (g_bMultiConnectionMode) { if (_strcmpi(szChangedProto, g_szConnectingProto)) - { pcli->pfnUnlockTray(); return; } + return -1; else hIcon = (HICON)CLUI_GetConnectingIconService(NULL, 1); } @@ -252,23 +233,20 @@ void cliTrayIconUpdateBase(const char *szChangedProto) { HICON hIcon; // 1 check if multi connecting icon - if (g_bMultiConnectionMode) + if (g_bMultiConnectionMode) { if (_strcmpi(szChangedProto,g_szConnectingProto)) - { pcli->pfnUnlockTray(); return; } - else - hIcon = (HICON)CLUI_GetConnectingIconService((WPARAM)"",1); - else - hIcon = (HICON)CLUI_GetConnectingIconService((WPARAM)szChangedProto,0); + return -1; + hIcon = (HICON)CLUI_GetConnectingIconService((WPARAM)"",1); + } + else hIcon = (HICON)CLUI_GetConnectingIconService((WPARAM)szChangedProto,0); if (hIcon) changed = pcli->pfnTrayIconSetBaseInfo(hIcon,NULL); } } - else - { + else { pcli->cycleTimerId = CLUI_SafeSetTimer(NULL, 0, db_get_w(NULL,"CList","CycleTime",SETTING_CYCLETIME_DEFAULT)*1000, pcli->pfnTrayCycleTimerProc); changed = pcli->pfnTrayIconSetBaseInfo(cliGetIconFromStatusMode(NULL,szChangedProto,status),NULL); } - } break; @@ -278,19 +256,13 @@ void cliTrayIconUpdateBase(const char *szChangedProto) else if ( db_get_b(NULL,"CList","AlwaysMulti",SETTING_ALWAYSMULTI_DEFAULT )) { if (pcli->pfnGetProtocolVisibility(szChangedProto)) { - - int status; - status = CallProtoService(szChangedProto,PS_GETSTATUS, 0, 0); - if ((g_StatusBarData.connectingIcon == 1) && status >= ID_STATUS_CONNECTING && status <= ID_STATUS_CONNECTING+MAX_CONNECT_RETRIES) - { - // - HICON hIcon; - hIcon = (HICON)CLUI_GetConnectingIconService((WPARAM)szChangedProto,0);; + int status = CallProtoService(szChangedProto,PS_GETSTATUS, 0, 0); + if ((g_StatusBarData.connectingIcon == 1) && status >= ID_STATUS_CONNECTING && status <= ID_STATUS_CONNECTING+MAX_CONNECT_RETRIES) { + HICON hIcon = (HICON)CLUI_GetConnectingIconService((WPARAM)szChangedProto,0); if (hIcon) changed = pcli->pfnTrayIconSetBaseInfo(hIcon,szChangedProto); } - else - changed = pcli->pfnTrayIconSetBaseInfo(cliGetIconFromStatusMode(NULL,szChangedProto,CallProtoService(szChangedProto,PS_GETSTATUS, 0, 0)),szChangedProto); + else changed = pcli->pfnTrayIconSetBaseInfo(cliGetIconFromStatusMode(NULL,szChangedProto,CallProtoService(szChangedProto,PS_GETSTATUS, 0, 0)),szChangedProto); } } else if (pcli->pfnGetProtocolVisibility(szChangedProto)) { @@ -303,18 +275,18 @@ void cliTrayIconUpdateBase(const char *szChangedProto) pcli->pfnTrayIconInit(hwnd); } else { - int status; changed = i; - status = CallProtoService(szChangedProto,PS_GETSTATUS, 0, 0); + int status = CallProtoService(szChangedProto,PS_GETSTATUS, 0, 0); if ((g_StatusBarData.connectingIcon == 1) && status >= ID_STATUS_CONNECTING && status <= ID_STATUS_CONNECTING+MAX_CONNECT_RETRIES) { - // - HICON hIcon; - hIcon = (HICON)CLUI_GetConnectingIconService((WPARAM)szChangedProto,0);; - if (hIcon) { + HICON hIcon = (HICON)CLUI_GetConnectingIconService((WPARAM)szChangedProto,0);; + if (hIcon) changed = pcli->pfnTrayIconSetBaseInfo(hIcon,szChangedProto); - } } } } + } + } + } break; - } } + } + } } else if ( pcli->pfnGetProtocolVisibility( szChangedProto )) { @@ -339,9 +311,7 @@ void cliTrayIconUpdateBase(const char *szChangedProto) } } - if (changed != -1) // && pcli->trayIcon[changed].isBase) - pcli->pfnTrayIconUpdate(pcli->trayIcon[changed].hBaseIcon,NULL,szChangedProto,1); // by FYR (No suitable protocol) - { pcli->pfnUnlockTray(); return; } + return changed; } static UINT_PTR autoHideTimerId; diff --git a/plugins/Clist_modern/src/modern_clui.cpp b/plugins/Clist_modern/src/modern_clui.cpp index 7376a2a363..d8ad4dda50 100644 --- a/plugins/Clist_modern/src/modern_clui.cpp +++ b/plugins/Clist_modern/src/modern_clui.cpp @@ -2168,9 +2168,9 @@ LRESULT CLUI::OnStatusBarUpdateTimer(UINT msg, WPARAM wParam, LPARAM lParam) if (IsWindowVisible(pcli->hwndStatus)) pcli->pfnInvalidateRect(pcli->hwndStatus,NULL,0); if (pt->bGlobal) - cliTrayIconUpdateBase(g_szConnectingProto); + pcli->pfnTrayIconUpdateBase(g_szConnectingProto); else - cliTrayIconUpdateBase(pt->szProto); + pcli->pfnTrayIconUpdateBase(pt->szProto); pcli->pfnInvalidateRect(pcli->hwndStatus,NULL,TRUE); return DefCluiWndProc( msg, wParam, lParam); diff --git a/plugins/Clist_modern/src/modern_cluiservices.cpp b/plugins/Clist_modern/src/modern_cluiservices.cpp index c5813f1439..2203f713e7 100644 --- a/plugins/Clist_modern/src/modern_cluiservices.cpp +++ b/plugins/Clist_modern/src/modern_cluiservices.cpp @@ -35,7 +35,7 @@ void cliCluiProtocolStatusChanged(int status,const char * proto) { CallService(MS_SKINENG_INVALIDATEFRAMEIMAGE,(WPARAM)pcli->hwndStatus,0); if (proto) - cliTrayIconUpdateBase(proto); + pcli->pfnTrayIconUpdateBase(proto); } static INT_PTR MetaSupportCheck(WPARAM wParam,LPARAM lParam) -- cgit v1.2.3