summaryrefslogtreecommitdiff
path: root/plugins/Clist_modern
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-02-17 20:25:21 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-02-17 20:25:21 +0000
commitd92361fbcc16534d127d62f731d26579d1569d6d (patch)
tree49daa11f28310398b2f1488ee9079614ff4b8376 /plugins/Clist_modern
parent104ac4660fbd90f36dd76f6082122ab42983224d (diff)
crash fix for clist modern's options
git-svn-id: http://svn.miranda-ng.org/main/trunk@12170 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Clist_modern')
-rw-r--r--plugins/Clist_modern/src/modern_clcopts.cpp4
-rw-r--r--plugins/Clist_modern/src/modern_clisttray.cpp49
2 files changed, 27 insertions, 26 deletions
diff --git a/plugins/Clist_modern/src/modern_clcopts.cpp b/plugins/Clist_modern/src/modern_clcopts.cpp
index ac6821ac25..b7d0142d1b 100644
--- a/plugins/Clist_modern/src/modern_clcopts.cpp
+++ b/plugins/Clist_modern/src/modern_clcopts.cpp
@@ -629,13 +629,13 @@ static INT_PTR CALLBACK DlgProcTrayOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_S, CB_ADDSTRING, 0, (LPARAM)acc[i]->tszAccountName);
SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_S, CB_SETITEMDATA, item, (LPARAM)acc[i]);
- if (!strcmp(acc[i]->szModuleName, db_get_sa(NULL, "CList", "tiAccS")))
+ if (!mir_strcmp(acc[i]->szModuleName, db_get_sa(NULL, "CList", "tiAccS")))
siS = item;
item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_V, CB_ADDSTRING, 0, (LPARAM)acc[i]->tszAccountName);
SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_V, CB_SETITEMDATA, item, (LPARAM)acc[i]);
- if (!strcmp(acc[i]->szModuleName, db_get_sa(NULL, "CList", "tiAccV")))
+ if (!mir_strcmp(acc[i]->szModuleName, db_get_sa(NULL, "CList", "tiAccV")))
siV = item;
}
diff --git a/plugins/Clist_modern/src/modern_clisttray.cpp b/plugins/Clist_modern/src/modern_clisttray.cpp
index 268873b2ca..a6c0126ec2 100644
--- a/plugins/Clist_modern/src/modern_clisttray.cpp
+++ b/plugins/Clist_modern/src/modern_clisttray.cpp
@@ -534,6 +534,9 @@ int cliTrayIconInit(HWND hwnd)
case TRAY_ICON_MODE_ACC:
{
ptrA szProto(db_get_sa(NULL, "CList", (!bDiffers) ? "tiAccS" : "tiAccV"));
+ if (!szProto)
+ break;
+
PROTOACCOUNT *pa = ProtoGetAccount(szProto);
if (!pa || !pa->ppro)
pcli->pfnTrayIconAdd(hwnd, NULL, NULL, CListTray_GetGlobalStatus(0, 0));
@@ -565,7 +568,7 @@ int cliTrayIconInit(HWND hwnd)
return 0;
}
-int cliTrayCalcChanged(const char *szChangedProto, int averageMode, int netProtoCount)
+int cliTrayCalcChanged(const char *szChangedProto, int, int)
{
if (!szChangedProto)
return -1;
@@ -587,7 +590,8 @@ int cliTrayCalcChanged(const char *szChangedProto, int averageMode, int netProto
}
HICON hIcon = NULL;
- int i = 0;
+ int i = 0, iStatus;
+ char *szProto;
switch (Mode) {
case TRAY_ICON_MODE_GLOBAL:
@@ -596,27 +600,26 @@ int cliTrayCalcChanged(const char *szChangedProto, int averageMode, int netProto
break;
case TRAY_ICON_MODE_ACC:
- char *szProto;
// В этом режиме показывается иконка совершенно определённого аккаунта, и не всегда это szChangedProto.
szProto = db_get_sa(NULL, "CList", bDiffers ? "tiAccV" : "tiAccS");
-
- if ( g_StatusBarData.bConnectingIcon
- && (ProtoCallService(szProto, PS_GETSTATUS, 0, 0) >= ID_STATUS_CONNECTING)
- && (ProtoCallService(szProto, PS_GETSTATUS, 0, 0) <= (ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES)) )
+ if (szProto == NULL)
+ break;
+
+ iStatus = ProtoCallService(szProto, PS_GETSTATUS, 0, 0);
+ if (g_StatusBarData.bConnectingIcon && (iStatus >= ID_STATUS_CONNECTING) && (iStatus <= (ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES)))
hIcon = (HICON)CLUI_GetConnectingIconService((WPARAM)szProto, 0);
else
hIcon = pcli->pfnGetIconFromStatusMode(NULL, szProto, ProtoCallService(szProto, PS_GETSTATUS, 0, 0));
+
pcli->pfnTrayIconMakeTooltip(NULL, szProto);
break;
case TRAY_ICON_MODE_CYCLE:
- if ( g_StatusBarData.bConnectingIcon
- && (ProtoCallService(szChangedProto, PS_GETSTATUS, 0, 0) >= ID_STATUS_CONNECTING)
- && (ProtoCallService(szChangedProto, PS_GETSTATUS, 0, 0) <= (ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES)) )
+ iStatus = ProtoCallService(szChangedProto, PS_GETSTATUS, 0, 0);
+ if (g_StatusBarData.bConnectingIcon && (iStatus >= ID_STATUS_CONNECTING) && (iStatus <= (ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES)))
hIcon = (HICON)CLUI_GetConnectingIconService((WPARAM)szChangedProto, 0);
- else
- if (!bConn)
- hIcon = pcli->pfnGetIconFromStatusMode(NULL, szChangedProto, ProtoCallService(szChangedProto, PS_GETSTATUS, 0, 0));
+ else if (!bConn)
+ hIcon = pcli->pfnGetIconFromStatusMode(NULL, szChangedProto, ProtoCallService(szChangedProto, PS_GETSTATUS, 0, 0));
pcli->pfnTrayIconMakeTooltip(NULL, NULL);
break;
@@ -625,32 +628,30 @@ int cliTrayCalcChanged(const char *szChangedProto, int averageMode, int netProto
for (; i < pcli->trayIconCount; i++)
if (!strcmp(pcli->trayIcon[i].szProto, szChangedProto))
break;
-
- if ( g_StatusBarData.bConnectingIcon
- && (ProtoCallService(szChangedProto, PS_GETSTATUS, 0, 0) >= ID_STATUS_CONNECTING)
- && (ProtoCallService(szChangedProto, PS_GETSTATUS, 0, 0) <= (ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES)) )
+
+ iStatus = ProtoCallService(szChangedProto, PS_GETSTATUS, 0, 0);
+ if (g_StatusBarData.bConnectingIcon && (iStatus >= ID_STATUS_CONNECTING) && (iStatus <= (ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES)))
hIcon = (HICON)CLUI_GetConnectingIconService((WPARAM)szChangedProto, 0);
else
hIcon = pcli->pfnGetIconFromStatusMode(NULL, szChangedProto, ProtoCallService(szChangedProto, PS_GETSTATUS, 0, 0));
pcli->pfnTrayIconMakeTooltip(NULL, pcli->trayIcon[i].szProto);
break;
}
-
+
DestroyIcon(pcli->trayIcon[i].hBaseIcon);
pcli->trayIcon[i].hBaseIcon = hIcon;
pcli->trayIcon[i].ptszToolTip = mir_tstrdup(pcli->szTip);
-
+
NOTIFYICONDATA nid = { sizeof(NOTIFYICONDATA) };
nid.hWnd = pcli->hwndContactList;
nid.uID = pcli->trayIcon[i].id;
nid.hIcon = pcli->trayIcon[i].hBaseIcon;
- nid.uFlags = NIF_ICON | NIF_TIP;
-
+ nid.uFlags = NIF_ICON | NIF_TIP;
+
// if Tipper is missing or turned off for tray, use system tooltips
- if (!ServiceExists("mToolTip/ShowTip") || !db_get_b(NULL, "Tipper", "TrayTip", 1)) {
+ if (!ServiceExists("mToolTip/ShowTip") || !db_get_b(NULL, "Tipper", "TrayTip", 1))
lstrcpyn(nid.szTip, pcli->szTip, SIZEOF(nid.szTip));
- }
-
+
Shell_NotifyIcon(NIM_MODIFY, &nid);
return -1;