summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-08-03 18:51:25 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-08-03 18:51:25 +0000
commit31582b9e959b65cb9e29c4197a42e1a7e9ca804e (patch)
tree23ed81355fc68a8b9812be0c30f20467b4c52cf4
parentc8a4c6574f3e0894d97c67cdd45e311a42eda59f (diff)
tray icons code standardization
git-svn-id: http://svn.miranda-ng.org/main/trunk@5569 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--include/m_clistint.h1
-rw-r--r--plugins/Clist_modern/src/hdr/modern_commonprototypes.h2
-rw-r--r--plugins/Clist_modern/src/init.cpp2
-rw-r--r--plugins/Clist_modern/src/modern_clisttray.cpp76
-rw-r--r--plugins/Clist_modern/src/modern_clui.cpp4
-rw-r--r--plugins/Clist_modern/src/modern_cluiservices.cpp2
-rw-r--r--plugins/Clist_mw/src/clisttray.cpp125
-rw-r--r--plugins/Clist_mw/src/contact.cpp8
-rw-r--r--plugins/Clist_nicer/src/clistmod.cpp1
-rw-r--r--plugins/Clist_nicer/src/clisttray.cpp26
-rw-r--r--plugins/Clist_nicer/src/init.cpp6
-rw-r--r--src/modules/clist/clc.h1
-rw-r--r--src/modules/clist/clistcore.cpp1
-rw-r--r--src/modules/clist/clisttray.cpp121
14 files changed, 163 insertions, 213 deletions
diff --git a/include/m_clistint.h b/include/m_clistint.h
index 7b3681d72c..df80cea43d 100644
--- a/include/m_clistint.h
+++ b/include/m_clistint.h
@@ -475,6 +475,7 @@ typedef struct
* Miranda NG additions
*************************************************************************************/
int (*pfnGetContactIcon)(HANDLE hContact);
+ int (*pfnTrayCalcChanged)(const char *szChangedProto, int averageMode, int iProtoCount);
}
CLIST_INTERFACE;
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)
diff --git a/plugins/Clist_mw/src/clisttray.cpp b/plugins/Clist_mw/src/clisttray.cpp
index af0f210e14..2aeb9e70d4 100644
--- a/plugins/Clist_mw/src/clisttray.cpp
+++ b/plugins/Clist_mw/src/clisttray.cpp
@@ -36,12 +36,13 @@ INT_PTR TrayIconProcessMessage(WPARAM wParam,LPARAM lParam)
case WM_DRAWITEM:
return CallService(MS_CLIST_MENUDRAWITEM,msg->wParam,msg->lParam);
break;
+
case WM_MEASUREITEM:
return CallService(MS_CLIST_MENUMEASUREITEM,msg->wParam,msg->lParam);
break;
+
case TIM_CALLBACK:
- if (msg->lParam == WM_RBUTTONUP)
- {
+ if (msg->lParam == WM_RBUTTONUP) {
POINT pt;
HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDTRAY,0,0);
@@ -49,7 +50,7 @@ INT_PTR TrayIconProcessMessage(WPARAM wParam,LPARAM lParam)
SetFocus(msg->hwnd);
GetCursorPos(&pt);
TrackPopupMenu(hMenu, TPM_TOPALIGN | TPM_LEFTALIGN, pt.x, pt.y, 0, msg->hwnd, NULL);
- DestroyTrayMenu(hMenu);
+ DestroyTrayMenu(hMenu);
}
else break;
@@ -69,10 +70,12 @@ HANDLE hTrayStatusMenuItemProxy;
HANDLE hPreBuildTrayMenuEvent;
//traymenu exec param(ownerdata)
-typedef struct{
-char *szServiceName;
-INT_PTR Param1;
-}TrayMenuExecParam,*lpTrayMenuExecParam;
+typedef struct
+{
+ char *szServiceName;
+ INT_PTR Param1;
+}
+ TrayMenuExecParam,*lpTrayMenuExecParam;
/*
wparam = handle to the menu item returned by MS_CLIST_ADDCONTACTMENUITEM
@@ -159,7 +162,8 @@ INT_PTR TrayMenuonAddService(WPARAM wParam,LPARAM lParam)
//called with:
//wparam - ownerdata
//lparam - lparam from winproc
-INT_PTR TrayMenuExecService(WPARAM wParam,LPARAM lParam) {
+INT_PTR TrayMenuExecService(WPARAM wParam,LPARAM lParam)
+{
if (wParam != 0)
{
lpTrayMenuExecParam mmep = (lpTrayMenuExecParam)wParam;
@@ -223,56 +227,55 @@ void InitTrayMenus(void)
op.Value = (INT_PTR)"CLISTMENUSTRAY/TrayMenuonAddService";
CallService(MO_SETOPTIONSMENUOBJECT,0,(LPARAM)&op);
- {
- //add exit command to menu
- CLISTMENUITEM mi = { sizeof(mi) };
- mi.position = 900000;
- mi.pszService = "CloseAction";
- mi.pszName = LPGEN("E&xit");
- AddTrayMenuItem(0,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.position = 100000;
- mi.pszService = MS_CLIST_SHOWHIDE;
- mi.pszName = LPGEN("&Hide/Show");
- hHideShowMainMenuItem = (HANDLE)AddTrayMenuItem(0,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.position = 200000;
- mi.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_FINDUSER));
- mi.pszService = "FindAdd/FindAddCommand";
- mi.pszName = LPGEN("&Find/Add Contacts...");
- AddTrayMenuItem(0,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.position = 300000;
- mi.pszService = "";
- mi.pszName = LPGEN("&Main Menu");
- hTrayMainMenuItemProxy = (HANDLE)AddTrayMenuItem(0,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.position = 300100;
- mi.pszService = "";
- mi.pszName = LPGEN("&Status");
- hTrayStatusMenuItemProxy = (HANDLE)AddTrayMenuItem(0,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.position = 400000;
- mi.hIcon = LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_OPTIONS));
- mi.pszService = "Options/OptionsCommand";
- mi.pszName = LPGEN("&Options...");
- AddTrayMenuItem(0,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.position = 500000;
- mi.hIcon = LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_CLIENTMIRANDA));
- mi.pszService = "Help/AboutCommand";
- mi.pszName = LPGEN("&About");
- AddTrayMenuItem(0,(LPARAM)&mi);
-} }
+ //add exit command to menu
+ CLISTMENUITEM mi = { sizeof(mi) };
+ mi.position = 900000;
+ mi.pszService = "CloseAction";
+ mi.pszName = LPGEN("E&xit");
+ AddTrayMenuItem(0,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 100000;
+ mi.pszService = MS_CLIST_SHOWHIDE;
+ mi.pszName = LPGEN("&Hide/Show");
+ hHideShowMainMenuItem = (HANDLE)AddTrayMenuItem(0,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 200000;
+ mi.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_FINDUSER));
+ mi.pszService = "FindAdd/FindAddCommand";
+ mi.pszName = LPGEN("&Find/Add Contacts...");
+ AddTrayMenuItem(0,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 300000;
+ mi.pszService = "";
+ mi.pszName = LPGEN("&Main Menu");
+ hTrayMainMenuItemProxy = (HANDLE)AddTrayMenuItem(0,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 300100;
+ mi.pszService = "";
+ mi.pszName = LPGEN("&Status");
+ hTrayStatusMenuItemProxy = (HANDLE)AddTrayMenuItem(0,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 400000;
+ mi.hIcon = LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_OPTIONS));
+ mi.pszService = "Options/OptionsCommand";
+ mi.pszName = LPGEN("&Options...");
+ AddTrayMenuItem(0,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 500000;
+ mi.hIcon = LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_CLIENTMIRANDA));
+ mi.pszService = "Help/AboutCommand";
+ mi.pszName = LPGEN("&About");
+ AddTrayMenuItem(0,(LPARAM)&mi);
+}
diff --git a/plugins/Clist_mw/src/contact.cpp b/plugins/Clist_mw/src/contact.cpp
index 12a82ba2d5..9a818226e1 100644
--- a/plugins/Clist_mw/src/contact.cpp
+++ b/plugins/Clist_mw/src/contact.cpp
@@ -77,9 +77,11 @@ void LoadContactTree(void)
{
int tick = GetTickCount();
CallService(MS_CLUI_LISTBEGINREBUILD,0,0);
- for (int i=1;; i++)
- if ((char*)CallService(MS_CLIST_GROUPGETNAME2, i, 0) != NULL)
- CallService(MS_CLUI_GROUPADDED, i, 0);
+ for (int i=1;; i++) {
+ if ((char*)CallService(MS_CLIST_GROUPGETNAME2, i, 0) == NULL)
+ break;
+ CallService(MS_CLUI_GROUPADDED, i, 0);
+ }
int hideOffline = db_get_b(NULL,"CList","HideOffline",SETTING_HIDEOFFLINE_DEFAULT);
diff --git a/plugins/Clist_nicer/src/clistmod.cpp b/plugins/Clist_nicer/src/clistmod.cpp
index ae022a4a7f..bfb01329b5 100644
--- a/plugins/Clist_nicer/src/clistmod.cpp
+++ b/plugins/Clist_nicer/src/clistmod.cpp
@@ -40,7 +40,6 @@ extern int RemoveEvent(WPARAM wParam, LPARAM lParam);
int InitCustomMenus(void);
void UninitCustomMenus(void);
INT_PTR GetContactStatusMessage(WPARAM wParam, LPARAM lParam);
-void TrayIconUpdateBase(const char *szChangedProto);
int EventsProcessContactDoubleClick(HANDLE hContact);
int SetHideOffline(WPARAM wParam, LPARAM lParam);
diff --git a/plugins/Clist_nicer/src/clisttray.cpp b/plugins/Clist_nicer/src/clisttray.cpp
index 9430ed1f56..bad9535193 100644
--- a/plugins/Clist_nicer/src/clisttray.cpp
+++ b/plugins/Clist_nicer/src/clisttray.cpp
@@ -35,29 +35,11 @@ extern HIMAGELIST hCListImages;
#define NIF_STATE 0x00000008
#define NIF_INFO 0x00000010
-void TrayIconUpdateBase(const char *szChangedProto)
+int TrayCalcChanged(const char *szChangedProto, int averageMode, int netProtoCount)
{
- int i,count,netProtoCount,changed = -1;
- PROTOACCOUNT **accs;
- int averageMode = 0;
+ int changed = -1;
HWND hwnd = pcli->hwndContactList;
- 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 ))
- 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 (averageMode > 0) {
if (cfg::getByte("CList", "TrayIcon", SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_MULTI) {
@@ -150,8 +132,8 @@ void TrayIconUpdateBase(const char *szChangedProto)
else
changed = pcli->pfnTrayIconSetBaseInfo(ImageList_GetIcon(hCListImages, iIcon, ILD_NORMAL), NULL);
}
- if (changed != -1 && pcli->trayIcon[changed].isBase)
- pcli->pfnTrayIconUpdate( pcli->trayIcon[changed].hBaseIcon, NULL, pcli->trayIcon[changed].szProto, 1);
+
+ return changed;
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/Clist_nicer/src/init.cpp b/plugins/Clist_nicer/src/init.cpp
index 7b8b31de25..f7ac4a02ba 100644
--- a/plugins/Clist_nicer/src/init.cpp
+++ b/plugins/Clist_nicer/src/init.cpp
@@ -51,9 +51,9 @@ TIME_API tmi;
HMENU BuildGroupPopupMenu( ClcGroup* group );
ClcContact* CreateClcContact( void );
-struct CListEvent* fnCreateEvent( void );
+CListEvent* fnCreateEvent( void );
void ReloadThemedOptions();
-void TrayIconUpdateBase(const char *szChangedProto);
+int TrayCalcChanged(const char *szChangedProto, int averageMode, int iProtoCount);
void RegisterCLUIFrameClasses();
void LoadButtonModule();
@@ -299,7 +299,7 @@ extern "C" int __declspec(dllexport) CListInitialise()
pcli->pfnRebuildEntireList = RebuildEntireList;
pcli->pfnRowHitTest = RowHeight::hitTest;
pcli->pfnScrollTo = ScrollTo;
- pcli->pfnTrayIconUpdateBase = TrayIconUpdateBase;
+ pcli->pfnTrayCalcChanged = TrayCalcChanged;
pcli->pfnSetHideOffline = SetHideOffline;
pcli->pfnShowHide = ShowHide;
diff --git a/src/modules/clist/clc.h b/src/modules/clist/clc.h
index 215e0eaec7..6e4a3c4c28 100644
--- a/src/modules/clist/clc.h
+++ b/src/modules/clist/clc.h
@@ -172,6 +172,7 @@ void fnTrayIconSetToBase (char *szPreferredProto);
void fnTrayIconTaskbarCreated(HWND hwnd);
int fnTrayIconUpdate(HICON hNewIcon, const TCHAR *szNewTip, const char *szPreferredProto, int isBase);
void fnTrayIconUpdateBase (const char *szChangedProto);
+int fnTrayCalcChanged(const char *szChangedProto, int averageMode, int netProtoCount);
void fnTrayIconUpdateWithImageList (int iImage, const TCHAR *szNewTip, char *szPreferredProto);
VOID CALLBACK fnTrayCycleTimerProc(HWND hwnd, UINT message, UINT_PTR idEvent, DWORD dwTime);
diff --git a/src/modules/clist/clistcore.cpp b/src/modules/clist/clistcore.cpp
index 31d7ab129b..63e65bb90a 100644
--- a/src/modules/clist/clistcore.cpp
+++ b/src/modules/clist/clistcore.cpp
@@ -169,6 +169,7 @@ static INT_PTR srvRetrieveInterface(WPARAM, LPARAM)
cli.pfnTrayIconTaskbarCreated = fnTrayIconTaskbarCreated;
cli.pfnTrayIconUpdate = fnTrayIconUpdate;
cli.pfnTrayIconUpdateBase = fnTrayIconUpdateBase;
+ cli.pfnTrayCalcChanged = fnTrayCalcChanged;
cli.pfnTrayIconUpdateWithImageList = fnTrayIconUpdateWithImageList;
cli.pfnCListTrayNotify = fnCListTrayNotify;
diff --git a/src/modules/clist/clisttray.cpp b/src/modules/clist/clisttray.cpp
index 564c21cfa1..4bd8d68c34 100644
--- a/src/modules/clist/clisttray.cpp
+++ b/src/modules/clist/clisttray.cpp
@@ -34,8 +34,6 @@ int GetAverageMode(int* pNetProtoCount = NULL);
static UINT WM_TASKBARCREATED;
static UINT WM_TASKBARBUTTONCREATED;
static BOOL mToolTipTrayTips = FALSE;
-static UINT_PTR cycleTimerId = 0;
-static int cycleStep = 0;
static UINT_PTR RefreshTimerId = 0; /////by FYR
static CRITICAL_SECTION trayLockCS;
@@ -461,15 +459,15 @@ VOID CALLBACK fnTrayCycleTimerProc(HWND, UINT, UINT_PTR, DWORD)
int i;
for (i = accounts.getCount() + 1; --i;) {
- cycleStep = (cycleStep + 1) % accounts.getCount();
- if (cli.pfnGetProtocolVisibility(accounts[cycleStep]->szModuleName))
+ cli.cycleStep = (cli.cycleStep + 1) % accounts.getCount();
+ if (cli.pfnGetProtocolVisibility(accounts[cli.cycleStep]->szModuleName))
break;
}
if (i) {
DestroyIcon(cli.trayIcon[0].hBaseIcon);
- cli.trayIcon[0].hBaseIcon = cli.pfnGetIconFromStatusMode(NULL, accounts[cycleStep]->szModuleName,
- CallProtoServiceInt(NULL,accounts[cycleStep]->szModuleName, PS_GETSTATUS, 0, 0));
+ cli.trayIcon[0].hBaseIcon = cli.pfnGetIconFromStatusMode(NULL, accounts[cli.cycleStep]->szModuleName,
+ CallProtoServiceInt(NULL, accounts[cli.cycleStep]->szModuleName, PS_GETSTATUS, 0, 0));
if (cli.trayIcon[0].isBase)
cli.pfnTrayIconUpdate(cli.trayIcon[0].hBaseIcon, NULL, NULL, 1);
}
@@ -477,11 +475,11 @@ VOID CALLBACK fnTrayCycleTimerProc(HWND, UINT, UINT_PTR, DWORD)
void fnTrayIconUpdateBase(const char *szChangedProto)
{
+ initcheck;
+ if (szChangedProto == NULL) return;
if ( !cli.pfnGetProtocolVisibility(szChangedProto)) return;
- int i, netProtoCount, changed = -1;
- HWND hwnd = cli.hwndContactList;
- initcheck;
+ int netProtoCount;
mir_cslock lck(trayLockCS);
int averageMode = GetAverageMode(&netProtoCount);
@@ -490,72 +488,65 @@ void fnTrayIconUpdateBase(const char *szChangedProto)
cli.cycleTimerId = 0;
}
- for (i=0; i < accounts.getCount(); i++)
+ for (int i=0; i < accounts.getCount(); i++)
if ( !lstrcmpA(szChangedProto, accounts[i]->szModuleName))
- cycleStep = i - 1;
+ cli.cycleStep = i;
- if (netProtoCount > 0) {
- int trayIconSetting = db_get_b(NULL, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT);
+ int changed = cli.pfnTrayCalcChanged(szChangedProto, averageMode, netProtoCount);
+ if (changed != -1 && cli.trayIcon[changed].isBase)
+ cli.pfnTrayIconUpdate(cli.trayIcon[changed].hBaseIcon, NULL, cli.trayIcon[changed].szProto, 1);
+}
- if (averageMode > 0) {
- if (trayIconSetting == SETTING_TRAYICON_MULTI) {
- if (db_get_b(NULL, "CList", "AlwaysMulti", SETTING_ALWAYSMULTI_DEFAULT))
- //changed = cli.pfnTrayIconSetBaseInfo(cli.pfnGetIconFromStatusMode((char*)szChangedProto, NULL, averageMode), (char*)szChangedProto);
- changed = cli.pfnTrayIconSetBaseInfo(cli.pfnGetIconFromStatusMode(NULL, szChangedProto, CallProtoServiceInt(NULL,szChangedProto, PS_GETSTATUS, 0, 0)), (char*)szChangedProto);
- else if (cli.trayIcon && cli.trayIcon[0].szProto != NULL) {
- cli.pfnTrayIconDestroy(hwnd);
- cli.pfnTrayIconInit(hwnd);
- }
- else
- changed = cli.pfnTrayIconSetBaseInfo(cli.pfnGetIconFromStatusMode(NULL, NULL, averageMode), NULL);
- }
- else
- changed = cli.pfnTrayIconSetBaseInfo(cli.pfnGetIconFromStatusMode(NULL, NULL, averageMode), NULL);
- }
- else {
- switch (trayIconSetting) {
- case SETTING_TRAYICON_SINGLE:
- {
- DBVARIANT dbv = { DBVT_DELETED };
- char *szProto;
- if (db_get_s(NULL, "CList", "PrimaryStatus", &dbv))
- szProto = NULL;
- else
- szProto = dbv.pszVal;
- changed = cli.pfnTrayIconSetBaseInfo(cli.pfnGetIconFromStatusMode(NULL, szProto, szProto ?
- CallProtoServiceInt(NULL,szProto, PS_GETSTATUS, 0, 0) :
- CallService(MS_CLIST_GETSTATUSMODE, 0, 0)), szProto);
- db_free(&dbv);
- }
- break;
+int fnTrayCalcChanged(const char *szChangedProto, int averageMode, int netProtoCount)
+{
+ if (netProtoCount == 0)
+ return cli.pfnTrayIconSetBaseInfo(ImageList_GetIcon(hCListImages, cli.pfnIconFromStatusMode(NULL, averageMode, NULL), ILD_NORMAL), NULL);
- case SETTING_TRAYICON_CYCLE:
- cli.cycleTimerId = SetTimer(NULL, 0, db_get_w(NULL, "CList", "CycleTime", SETTING_CYCLETIME_DEFAULT) * 1000, cli.pfnTrayCycleTimerProc);
- changed =
- cli.pfnTrayIconSetBaseInfo(ImageList_GetIcon
- (hCListImages, cli.pfnIconFromStatusMode(szChangedProto, CallProtoServiceInt(NULL,szChangedProto, PS_GETSTATUS, 0, 0), NULL),
- ILD_NORMAL), NULL);
- break;
+ int trayIconSetting = db_get_b(NULL, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT);
- case SETTING_TRAYICON_MULTI:
- if ( !cli.trayIcon)
- cli.pfnTrayIconRemove(NULL, NULL);
- else if ((cli.trayIconCount > 1 || netProtoCount == 1) || db_get_b(NULL, "CList", "AlwaysMulti", SETTING_ALWAYSMULTI_DEFAULT))
- changed = cli.pfnTrayIconSetBaseInfo(cli.pfnGetIconFromStatusMode(NULL, szChangedProto, CallProtoServiceInt(NULL,szChangedProto, PS_GETSTATUS, 0, 0)), (char*)szChangedProto);
- else {
- cli.pfnTrayIconDestroy(hwnd);
- cli.pfnTrayIconInit(hwnd);
- }
- break;
+ if (averageMode > 0) {
+ if (trayIconSetting != SETTING_TRAYICON_MULTI)
+ return cli.pfnTrayIconSetBaseInfo(cli.pfnGetIconFromStatusMode(NULL, NULL, averageMode), NULL);
+
+ if (db_get_b(NULL, "CList", "AlwaysMulti", SETTING_ALWAYSMULTI_DEFAULT))
+ return cli.pfnTrayIconSetBaseInfo(cli.pfnGetIconFromStatusMode(NULL, szChangedProto, CallProtoServiceInt(NULL,szChangedProto, PS_GETSTATUS, 0, 0)), (char*)szChangedProto);
+
+ if (cli.trayIcon == NULL || cli.trayIcon[0].szProto == NULL)
+ return cli.pfnTrayIconSetBaseInfo(cli.pfnGetIconFromStatusMode(NULL, NULL, averageMode), NULL);
+
+ cli.pfnTrayIconDestroy(cli.hwndContactList);
+ cli.pfnTrayIconInit(cli.hwndContactList);
+ }
+ else {
+ switch (trayIconSetting) {
+ case SETTING_TRAYICON_CYCLE:
+ cli.cycleTimerId = SetTimer(NULL, 0, db_get_w(NULL, "CList", "CycleTime", SETTING_CYCLETIME_DEFAULT) * 1000, cli.pfnTrayCycleTimerProc);
+ return cli.pfnTrayIconSetBaseInfo(ImageList_GetIcon
+ (hCListImages, cli.pfnIconFromStatusMode(szChangedProto, CallProtoServiceInt(NULL,szChangedProto, PS_GETSTATUS, 0, 0), NULL),
+ ILD_NORMAL), NULL);
+
+ case SETTING_TRAYICON_MULTI:
+ if ( !cli.trayIcon)
+ cli.pfnTrayIconRemove(NULL, NULL);
+ else if ((cli.trayIconCount > 1 || netProtoCount == 1) || db_get_b(NULL, "CList", "AlwaysMulti", SETTING_ALWAYSMULTI_DEFAULT))
+ return cli.pfnTrayIconSetBaseInfo(cli.pfnGetIconFromStatusMode(NULL, szChangedProto, CallProtoServiceInt(NULL,szChangedProto, PS_GETSTATUS, 0, 0)), (char*)szChangedProto);
+ else {
+ cli.pfnTrayIconDestroy(cli.hwndContactList);
+ cli.pfnTrayIconInit(cli.hwndContactList);
}
+ break;
+
+ case SETTING_TRAYICON_SINGLE:
+ ptrA szProto( db_get_sa(NULL, "CList", "PrimaryStatus"));
+ return cli.pfnTrayIconSetBaseInfo(cli.pfnGetIconFromStatusMode(NULL, szProto, szProto ?
+ CallProtoServiceInt(NULL,szProto, PS_GETSTATUS, 0, 0) :
+ CallService(MS_CLIST_GETSTATUSMODE, 0, 0)), szProto);
}
}
- else changed = cli.pfnTrayIconSetBaseInfo(ImageList_GetIcon(hCListImages, cli.pfnIconFromStatusMode(NULL, averageMode, NULL), ILD_NORMAL), NULL);
- if (changed != -1 && cli.trayIcon[changed].isBase)
- cli.pfnTrayIconUpdate(cli.trayIcon[changed].hBaseIcon, NULL, cli.trayIcon[changed].szProto, 1);
+ return -1;
}
-
+
void fnTrayIconSetToBase(char *szPreferredProto)
{
int i;