diff options
author | George Hazan <george.hazan@gmail.com> | 2013-08-03 19:16:06 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-08-03 19:16:06 +0000 |
commit | a6f3759cfee25d42bd6bbfd53c5b2ac140707bc0 (patch) | |
tree | 23cee653b38cb1c1ac8cc99975cb7875a8af6646 /plugins/Clist_nicer/src | |
parent | 31582b9e959b65cb9e29c4197a42e1a7e9ca804e (diff) |
rest of pfnTrayCalcChanged optimization
git-svn-id: http://svn.miranda-ng.org/main/trunk@5570 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Clist_nicer/src')
-rw-r--r-- | plugins/Clist_nicer/src/clistmod.cpp | 6 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/clisttray.cpp | 114 |
2 files changed, 44 insertions, 76 deletions
diff --git a/plugins/Clist_nicer/src/clistmod.cpp b/plugins/Clist_nicer/src/clistmod.cpp index bfb01329b5..fced8ea43a 100644 --- a/plugins/Clist_nicer/src/clistmod.cpp +++ b/plugins/Clist_nicer/src/clistmod.cpp @@ -58,6 +58,9 @@ extern int ( *saveIconFromStatusMode )( const char *szProto, int status, HANDLE int IconFromStatusMode(const char *szProto, int status, HANDLE hContact, HICON *phIcon)
{
+ if (phIcon != NULL)
+ *phIcon = NULL;
+
char *szFinalProto;
int finalStatus;
@@ -65,7 +68,8 @@ int IconFromStatusMode(const char *szProto, int status, HANDLE hContact, HICON * HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM) hContact, 0);
szFinalProto = GetContactProto(hSubContact);
finalStatus = (status == 0) ? (WORD) cfg::getWord(hSubContact, szFinalProto, "Status", ID_STATUS_OFFLINE) : status;
- } else {
+ }
+ else {
szFinalProto = (char*) szProto;
finalStatus = status;
}
diff --git a/plugins/Clist_nicer/src/clisttray.cpp b/plugins/Clist_nicer/src/clisttray.cpp index bad9535193..a11daa1ad0 100644 --- a/plugins/Clist_nicer/src/clisttray.cpp +++ b/plugins/Clist_nicer/src/clisttray.cpp @@ -37,103 +37,67 @@ extern HIMAGELIST hCListImages; int TrayCalcChanged(const char *szChangedProto, int averageMode, int netProtoCount)
{
- int changed = -1;
+ HICON hIcon;
+ int iIcon;
HWND hwnd = pcli->hwndContactList;
if (netProtoCount > 1) {
if (averageMode > 0) {
if (cfg::getByte("CList", "TrayIcon", SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_MULTI) {
if (cfg::getByte("CList", "AlwaysMulti", SETTING_ALWAYSMULTI_DEFAULT)) {
- HICON hIcon = 0;
- int iIcon = IconFromStatusMode(szChangedProto, averageMode, 0, &hIcon);
- if (hIcon)
- changed = pcli->pfnTrayIconSetBaseInfo(CopyIcon(hIcon), szChangedProto);
- else
- changed = pcli->pfnTrayIconSetBaseInfo(ImageList_GetIcon(hCListImages, iIcon, ILD_NORMAL), szChangedProto);
+ iIcon = IconFromStatusMode(szChangedProto, averageMode, 0, &hIcon);
+ hIcon = (hIcon) ? CopyIcon(hIcon) : ImageList_GetIcon(hCListImages, iIcon, ILD_NORMAL);
+ return pcli->pfnTrayIconSetBaseInfo(hIcon, szChangedProto);
}
- else if (pcli->trayIcon && pcli->trayIcon[0].szProto != NULL) {
- pcli->pfnTrayIconDestroy(hwnd);
- pcli->pfnTrayIconInit(hwnd);
+ if (pcli->trayIcon == NULL || pcli->trayIcon[0].szProto == NULL) {
+ iIcon = IconFromStatusMode(NULL, averageMode, 0, &hIcon);
+ hIcon = (hIcon) ? CopyIcon(hIcon) : ImageList_GetIcon(hCListImages, iIcon, ILD_NORMAL);
+ return pcli->pfnTrayIconSetBaseInfo(hIcon, NULL);
}
- else {
- HICON hIcon = 0;
- int iIcon = IconFromStatusMode(NULL, averageMode, 0, &hIcon);
-
- if (hIcon)
- changed = pcli->pfnTrayIconSetBaseInfo(CopyIcon(hIcon), NULL);
- else
- changed = pcli->pfnTrayIconSetBaseInfo(ImageList_GetIcon(hCListImages, iIcon, ILD_NORMAL), NULL);
- }
- } else {
- HICON hIcon = 0;
- int iIcon = IconFromStatusMode(NULL, averageMode, 0, &hIcon);
-
- if (hIcon)
- changed = pcli->pfnTrayIconSetBaseInfo(CopyIcon(hIcon), NULL);
- else
- changed = pcli->pfnTrayIconSetBaseInfo(ImageList_GetIcon(hCListImages, iIcon, ILD_NORMAL), NULL);
+ pcli->pfnTrayIconDestroy(hwnd);
+ pcli->pfnTrayIconInit(hwnd);
+ }
+ else {
+ iIcon = IconFromStatusMode(NULL, averageMode, 0, &hIcon);
+ hIcon = (hIcon) ? CopyIcon(hIcon) : ImageList_GetIcon(hCListImages, iIcon, ILD_NORMAL);
+ return pcli->pfnTrayIconSetBaseInfo(hIcon, NULL);
}
- } else {
+ }
+ else {
switch (cfg::getByte("CList", "TrayIcon", SETTING_TRAYICON_DEFAULT)) {
- case SETTING_TRAYICON_SINGLE:
- {
- DBVARIANT dbv = {DBVT_DELETED};
- int iIcon = 0;
- HICON hIcon = 0;
- char *szProto;
- if (cfg::getString(NULL, "CList", "PrimaryStatus", &dbv))
- szProto = NULL;
- else
- szProto = dbv.pszVal;
- iIcon = IconFromStatusMode(szProto, szProto ? CallProtoService(szProto, PS_GETSTATUS, 0, 0) : CallService(MS_CLIST_GETSTATUSMODE, 0, 0), 0, &hIcon);
- if (hIcon)
- changed = pcli->pfnTrayIconSetBaseInfo(CopyIcon(hIcon), NULL);
- else
- changed = pcli->pfnTrayIconSetBaseInfo(ImageList_GetIcon(hCListImages, iIcon, ILD_NORMAL), NULL);
- db_free(&dbv);
- break;
- }
case SETTING_TRAYICON_CYCLE:
- {
- HICON hIcon = 0;
- int iIcon = IconFromStatusMode(szChangedProto, CallProtoService(szChangedProto, PS_GETSTATUS, 0, 0), 0, &hIcon);
-
- pcli->cycleTimerId = SetTimer(NULL, 0, cfg::getWord("CList", "CycleTime", SETTING_CYCLETIME_DEFAULT) * 1000, pcli->pfnTrayCycleTimerProc);
- if (hIcon)
- changed = pcli->pfnTrayIconSetBaseInfo(CopyIcon(hIcon), NULL);
- else
- changed = pcli->pfnTrayIconSetBaseInfo(ImageList_GetIcon(hCListImages, iIcon, ILD_NORMAL), NULL);
- break;
- }
+ iIcon = IconFromStatusMode(szChangedProto, CallProtoService(szChangedProto, PS_GETSTATUS, 0, 0), 0, &hIcon);
+ pcli->cycleTimerId = SetTimer(NULL, 0, cfg::getWord("CList", "CycleTime", SETTING_CYCLETIME_DEFAULT) * 1000, pcli->pfnTrayCycleTimerProc);
+ hIcon = (hIcon) ? CopyIcon(hIcon) : ImageList_GetIcon(hCListImages, iIcon, ILD_NORMAL);
+ return pcli->pfnTrayIconSetBaseInfo(hIcon, NULL);
+
case SETTING_TRAYICON_MULTI:
if ( !pcli->trayIcon )
pcli->pfnTrayIconRemove(NULL, NULL);
else if (cfg::getByte("CList", "AlwaysMulti", SETTING_ALWAYSMULTI_DEFAULT)) {
- HICON hIcon = 0;
- int iIcon = IconFromStatusMode(szChangedProto, CallProtoService(szChangedProto, PS_GETSTATUS, 0, 0), 0, &hIcon);
-
- if (hIcon)
- changed = pcli->pfnTrayIconSetBaseInfo(CopyIcon(hIcon), szChangedProto);
- else
- changed = pcli->pfnTrayIconSetBaseInfo(ImageList_GetIcon(hCListImages, iIcon, ILD_NORMAL), szChangedProto);
- }
- else {
- pcli->pfnTrayIconDestroy(hwnd);
- pcli->pfnTrayIconInit(hwnd);
+ iIcon = IconFromStatusMode(szChangedProto, CallProtoService(szChangedProto, PS_GETSTATUS, 0, 0), 0, &hIcon);
+ hIcon = (hIcon) ? CopyIcon(hIcon) : ImageList_GetIcon(hCListImages, iIcon, ILD_NORMAL);
+ return pcli->pfnTrayIconSetBaseInfo(hIcon, szChangedProto);
}
+ pcli->pfnTrayIconDestroy(hwnd);
+ pcli->pfnTrayIconInit(hwnd);
break;
+
+ case SETTING_TRAYICON_SINGLE:
+ ptrA szProto( db_get_sa(NULL,"CList","PrimaryStatus"));
+ int iIcon = IconFromStatusMode(szProto, szProto ? CallProtoService(szProto, PS_GETSTATUS, 0, 0) : CallService(MS_CLIST_GETSTATUSMODE, 0, 0), 0, &hIcon);
+ hIcon = (hIcon) ? CopyIcon(hIcon) : ImageList_GetIcon(hCListImages, iIcon, ILD_NORMAL);
+ return pcli->pfnTrayIconSetBaseInfo(hIcon, NULL);
}
}
- } else {
- HICON hIcon = 0;
+ }
+ else {
int iIcon = IconFromStatusMode(NULL, averageMode, 0, &hIcon);
- if ( hIcon )
- changed = pcli->pfnTrayIconSetBaseInfo(CopyIcon(hIcon), NULL);
- else
- changed = pcli->pfnTrayIconSetBaseInfo(ImageList_GetIcon(hCListImages, iIcon, ILD_NORMAL), NULL);
+ hIcon = (hIcon) ? CopyIcon(hIcon) : ImageList_GetIcon(hCListImages, iIcon, ILD_NORMAL);
+ return pcli->pfnTrayIconSetBaseInfo(hIcon, NULL);
}
- return changed;
+ return -1;
}
/////////////////////////////////////////////////////////////////////////////////////////
|