summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-07-27 15:28:30 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-07-27 15:28:38 +0300
commitfc03dc9109a6a38dee7c526d757246ef942e9e32 (patch)
tree9049f48ca669070693ad824ea42eb8f42a0245e8
parent41b76c95667b7f6b27e53486e0df722d51c0a3ec (diff)
Clist_Modern:
- fixes #1518 (clist_modern account panel filter logic); - code cleaning
-rw-r--r--plugins/Clist_modern/src/modern_cachefuncs.cpp9
-rw-r--r--plugins/Clist_modern/src/modern_clc.cpp26
-rw-r--r--plugins/Clist_modern/src/modern_clcopts.cpp2
-rw-r--r--plugins/Clist_modern/src/modern_clcutils.cpp4
-rw-r--r--plugins/Clist_modern/src/modern_clisttray.cpp2
-rw-r--r--plugins/Clist_modern/src/modern_clui.cpp6
-rw-r--r--plugins/Clist_modern/src/modern_rowtemplateopt.cpp222
-rw-r--r--plugins/Clist_modern/src/modern_skinengine.cpp2
-rw-r--r--plugins/Clist_modern/src/modern_skinselector.cpp2
-rw-r--r--plugins/Clist_modern/src/modern_statusbar.cpp38
-rw-r--r--plugins/Clist_modern/src/modern_viewmodebar.cpp9
11 files changed, 157 insertions, 165 deletions
diff --git a/plugins/Clist_modern/src/modern_cachefuncs.cpp b/plugins/Clist_modern/src/modern_cachefuncs.cpp
index c25717b344..c25d62efb5 100644
--- a/plugins/Clist_modern/src/modern_cachefuncs.cpp
+++ b/plugins/Clist_modern/src/modern_cachefuncs.cpp
@@ -283,7 +283,6 @@ int GetStatusName(wchar_t *text, int text_size, ClcCacheEntry *pdnce, BOOL xstat
if (!noAwayMsg && !noXstatus && xstatus_has_priority && pdnce->hContact && pdnce->szProto) {
DBVARIANT dbv = { 0 };
if (!db_get_ws(pdnce->hContact, pdnce->szProto, "XStatusName", &dbv)) {
- //mir_wstrncpy(text, dbv.pszVal, text_size);
CopySkipUnprintableChars(text, dbv.pwszVal, text_size - 1);
db_free(&dbv);
@@ -479,18 +478,18 @@ void Cache_GetFirstLineText(ClcData *dat, ClcContact *contact)
DBVARIANT dbv = { 0 };
if (!db_get_ws(pdnce->hContact, pdnce->szProto, "Nick", &dbv)) {
wchar_t nick[_countof(contact->szText)];
- mir_wstrncpy(nick, dbv.pwszVal, _countof(contact->szText));
+ wcsncpy_s(nick, dbv.pwszVal, _TRUNCATE);
db_free(&dbv);
// They are the same -> use the name to keep the case
if (mir_wstrcmpi(name, nick) == 0)
- mir_wstrncpy(contact->szText, name, _countof(contact->szText));
+ wcsncpy_s(contact->szText, name, _TRUNCATE);
else // Append then
mir_snwprintf(contact->szText, L"%s - %s", name, nick);
}
- else mir_wstrncpy(contact->szText, name, _countof(contact->szText));
+ else wcsncpy_s(contact->szText, name, _TRUNCATE);
}
- else mir_wstrncpy(contact->szText, name, _countof(contact->szText));
+ else wcsncpy_s(contact->szText, name, _TRUNCATE);
if (!dat->bForceInDialog)
contact->ssText.ReplaceSmileys(dat, pdnce, contact->szText, dat->first_line_draw_smileys);
diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp
index 5aa6926c45..8e46ef4971 100644
--- a/plugins/Clist_modern/src/modern_clc.cpp
+++ b/plugins/Clist_modern/src/modern_clc.cpp
@@ -262,20 +262,26 @@ static int clcSearchNextContact(HWND hwnd, ClcData *dat, int index, const wchar_
return -1;
}
-static BOOL clcItemNotHiddenOffline(ClcGroup *group, ClcContact *contact)
+static bool clcItemNotHiddenOffline(ClcGroup *group, ClcContact *contact)
{
- if (g_CluiData.bFilterEffective) return FALSE;
+ if (g_CluiData.bFilterEffective)
+ return false;
- if (!contact) return FALSE;
+ if (!contact)
+ return false;
- if (contact->pce->m_bNoHiddenOffline) return TRUE;
+ if (contact->pce->m_bNoHiddenOffline)
+ return true;
- if (!group) return FALSE;
- if (group->hideOffline) return FALSE;
+ if (!group)
+ return false;
+ if (group->hideOffline)
+ return false;
- if (CLCItems_IsShowOfflineGroup(group)) return TRUE;
+ if (CLCItems_IsShowOfflineGroup(group))
+ return true;
- return FALSE;
+ return false;
}
static LRESULT clcOnCreate(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -1222,7 +1228,7 @@ static LRESULT clcOnLButtonUp(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam,
if (sourceGrName)
mir_snwprintf(newName, L"%s\\%s", sourceGrName, shortGroup);
else
- mir_wstrncpy(newName, shortGroup, _countof(newName));
+ wcsncpy_s(newName, shortGroup, _TRUNCATE);
}
mir_free(groupName);
mir_free(sourceGrName);
@@ -1339,7 +1345,7 @@ static LRESULT clcOnIntmIconChanged(ClcData *dat, HWND hwnd, UINT, WPARAM wParam
DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE);
bool isVisiblebyFilter = (((style & CLS_SHOWHIDDEN) && nHiddenStatus != -1) || !nHiddenStatus);
bool ifVisibleByClui = !Clist_IsHiddenMode(dat, status);
- bool isVisible = (g_CluiData.bFilterEffective & CLVM_FILTER_STATUS) ? TRUE : ifVisibleByClui;
+ bool isVisible = (g_CluiData.bFilterEffective & CLVM_FILTER_STATUS) ? true : ifVisibleByClui;
bool isIconChanged = Clist_GetContactIcon(wParam) != LOWORD(lParam);
int shouldShow = isVisiblebyFilter && (isVisible || isIconChanged);
diff --git a/plugins/Clist_modern/src/modern_clcopts.cpp b/plugins/Clist_modern/src/modern_clcopts.cpp
index 586fbbb5fe..ea9f4a5fa8 100644
--- a/plugins/Clist_modern/src/modern_clcopts.cpp
+++ b/plugins/Clist_modern/src/modern_clcopts.cpp
@@ -1266,7 +1266,7 @@ static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
if (!db_get_s(0, module, "BkBitmap", &dbv)) {
int retval = PathToAbsolute(dbv.pszVal, dat->item[indx].filename);
if (!retval || retval == CALLSERVICE_NOTFOUND)
- mir_strncpy(dat->item[indx].filename, dbv.pszVal, _countof(dat->item[indx].filename));
+ strncpy_s(dat->item[indx].filename, dbv.pszVal, _TRUNCATE);
mir_free(dbv.pszVal);
}
else *dat->item[indx].filename = 0;
diff --git a/plugins/Clist_modern/src/modern_clcutils.cpp b/plugins/Clist_modern/src/modern_clcutils.cpp
index aeb2aca4bf..2aaabf8900 100644
--- a/plugins/Clist_modern/src/modern_clcutils.cpp
+++ b/plugins/Clist_modern/src/modern_clcutils.cpp
@@ -564,7 +564,7 @@ void cli_LoadCLCOptions(HWND hwnd, ClcData *dat, BOOL bFirst)
ptrW tszLineText(db_get_wsa(0, "CList", "SecondLineText"));
if (tszLineText)
- mir_wstrncpy(dat->secondLine.text, tszLineText, _countof(dat->secondLine.text));
+ wcsncpy_s(dat->secondLine.text, tszLineText, _TRUNCATE);
else
dat->secondLine.text[0] = '\0';
@@ -584,7 +584,7 @@ void cli_LoadCLCOptions(HWND hwnd, ClcData *dat, BOOL bFirst)
ptrW tszLineText(db_get_wsa(0, "CList", "ThirdLineText"));
if (tszLineText)
- mir_wstrncpy(dat->thirdLine.text, tszLineText, _countof(dat->thirdLine.text));
+ wcsncpy_s(dat->thirdLine.text, tszLineText, _TRUNCATE);
else
dat->thirdLine.text[0] = '\0';
diff --git a/plugins/Clist_modern/src/modern_clisttray.cpp b/plugins/Clist_modern/src/modern_clisttray.cpp
index 3e4a04ba0d..e236e53743 100644
--- a/plugins/Clist_modern/src/modern_clisttray.cpp
+++ b/plugins/Clist_modern/src/modern_clisttray.cpp
@@ -453,7 +453,7 @@ int cliTrayCalcChanged(const char *szChangedProto, int, int)
// if Tipper is missing or turned off for tray, use system tooltips
if (!ServiceExists("mToolTip/ShowTip") || !db_get_b(0, "Tipper", "TrayTip", 1))
- mir_wstrncpy(nid.szTip, g_clistApi.szTip, _countof(nid.szTip));
+ wcsncpy_s(nid.szTip, g_clistApi.szTip, _TRUNCATE);
Shell_NotifyIcon(NIM_MODIFY, &nid);
diff --git a/plugins/Clist_modern/src/modern_clui.cpp b/plugins/Clist_modern/src/modern_clui.cpp
index e820f45321..714370a6ed 100644
--- a/plugins/Clist_modern/src/modern_clui.cpp
+++ b/plugins/Clist_modern/src/modern_clui.cpp
@@ -641,9 +641,9 @@ void CLUI_ChangeWindowMode()
wchar_t titleText[255] = { 0 };
DBVARIANT dbv;
if (db_get_ws(0, "CList", "TitleText", &dbv))
- mir_wstrncpy(titleText, _A2W(MIRANDANAME), _countof(titleText));
+ wcsncpy_s(titleText, _A2W(MIRANDANAME), _TRUNCATE);
else {
- mir_wstrncpy(titleText, dbv.pwszVal, _countof(titleText));
+ wcsncpy(titleText, dbv.pwszVal, _TRUNCATE);
db_free(&dbv);
}
SetWindowText(g_clistApi.hwndContactList, titleText);
@@ -925,7 +925,7 @@ static HICON CLUI_GetConnectingIconForProto(char *szAccoName, int idx)
}
// third try global
- mir_wstrncpy(szFullPath, L"proto_conn.dll", _countof(szFullPath));
+ wcsncpy_s(szFullPath, L"proto_conn.dll", _TRUNCATE);
if (hIcon = CLUI_LoadIconFromExternalFile(szFullPath, idx))
return hIcon;
diff --git a/plugins/Clist_modern/src/modern_rowtemplateopt.cpp b/plugins/Clist_modern/src/modern_rowtemplateopt.cpp
index 1ac420b9bf..f28e596aae 100644
--- a/plugins/Clist_modern/src/modern_rowtemplateopt.cpp
+++ b/plugins/Clist_modern/src/modern_rowtemplateopt.cpp
@@ -58,7 +58,7 @@ void rowOptShowSettings(HWND hwnd)
TreeView_GetItem(GetDlgItem(hwnd, IDC_ROWTREE), &tvi);
cell = (pROWCELL)tvi.lParam;
- if (!tvi.hItem) {
+ if (!tvi.hItem) {
EnableWindow(GetDlgItem(hwnd, IDC_CONTTYPE), 0);
EnableWindow(GetDlgItem(hwnd, IDC_VALIGN), 0);
EnableWindow(GetDlgItem(hwnd, IDC_HALIGN), 0);
@@ -241,23 +241,19 @@ void rowOptDelContainer(HWND htree, HTREEITEM hti)
tvpi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
- if (prev)
- {
+ if (prev) {
tvpi.hItem = prev;
TreeView_GetItem(htree, &tvpi);
((pROWCELL)tvpi.lParam)->next = ((pROWCELL)tvi.lParam)->next;
}
- else
- {
- if (prnt)
- {
+ else {
+ if (prnt) {
tvpi.hItem = prnt;
TreeView_GetItem(htree, &tvpi);
((pROWCELL)tvpi.lParam)->child = ((pROWCELL)tvi.lParam)->next;
prev = prnt;
}
- else
- {
+ else {
tvpi.lParam = 0;
rowOptTmplRoot = (pROWCELL)tvpi.lParam;
@@ -280,13 +276,11 @@ void rowOptDelContainer(HWND htree, HTREEITEM hti)
// Change icon at parent item
if (!prnt || (prnt != prev)) return;
- if (TreeView_GetChild(htree, prnt))
- {
+ if (TreeView_GetChild(htree, prnt)) {
tvpi.iImage = 1;
tvpi.iSelectedImage = 0;
}
- else
- {
+ else {
tvpi.iImage = 2;
tvpi.iSelectedImage = 2;
}
@@ -297,27 +291,23 @@ void rowOptDelContainer(HWND htree, HTREEITEM hti)
void RefreshTree(HWND hwndDlg, HTREEITEM hti)
{
HWND htree = GetDlgItem(hwndDlg, IDC_ROWTREE);
- pROWCELL cell;
- TVITEM tvi = { 0 };
+ pROWCELL cell;
+ TVITEM tvi = { 0 };
if (hti == nullptr) hti = TreeView_GetRoot(htree);
- while (hti)
- {
+ while (hti) {
tvi.hItem = hti;
- tvi.mask = TVIF_HANDLE;//|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_TEXT;
+ tvi.mask = TVIF_HANDLE;
TreeView_GetItem(htree, &tvi);
cell = (pROWCELL)tvi.lParam;
- if (cell)
- {
+ if (cell) {
wchar_t buf[200] = { 0 };
- if (!cell->child)
- {
+ if (!cell->child) {
if (cell->type == 0)
mir_snwprintf(buf, TranslateT("Empty %s cell"), cell->cont == TC_COL ? TranslateT("column") : TranslateT("line"));
else
mir_wstrncpy(buf, TranslateW(types[cell->type]), _countof(buf));
}
- else
- {
+ else {
if (cell->type == 0)
mir_wstrncpy(buf, (cell->cont != TC_COL ? TranslateT("columns") : TranslateT("lines")), _countof(buf));
else
@@ -340,13 +330,12 @@ void RefreshTree(HWND hwndDlg, HTREEITEM hti)
INT_PTR CALLBACK DlgTmplEditorOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
+ HWND htree = GetDlgItem(hwndDlg, IDC_ROWTREE);
+
switch (msg) {
case WM_INITDIALOG:
- {
- int hbuf = 0, seq = 0;
- HWND htree = GetDlgItem(hwndDlg, IDC_ROWTREE);
-
TranslateDialogDefault(hwndDlg);
+
rowOptTmplStr = db_get_sa(0, "ModernData", "RowTemplate");
if (!rowOptTmplStr)
rowOptTmplStr = mir_strdup("<TR />");
@@ -359,110 +348,103 @@ INT_PTR CALLBACK DlgTmplEditorOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
SendDlgItemMessage(hwndDlg, IDC_CONTTYPE, CB_SETITEMDATA, item, 0);
}
SendDlgItemMessage(hwndDlg, IDC_CONTTYPE, CB_SETCURSEL, 0, 0);
+ {
+ wchar_t *h_alignment[] = { L"left", L"hCenter", L"right" };
+ for (auto &it : h_alignment) {
+ int item = SendDlgItemMessage(hwndDlg, IDC_HALIGN, CB_ADDSTRING, 0, (LPARAM)TranslateW(it));
+ SendDlgItemMessage(hwndDlg, IDC_HALIGN, CB_SETITEMDATA, item, 0);
+ }
+ SendDlgItemMessage(hwndDlg, IDC_HALIGN, CB_SETCURSEL, 0, 0);
- wchar_t *h_alignment[] = { L"left", L"hCenter", L"right" };
- for (auto &it : h_alignment) {
- int item = SendDlgItemMessage(hwndDlg, IDC_HALIGN, CB_ADDSTRING, 0, (LPARAM)TranslateW(it));
- SendDlgItemMessage(hwndDlg, IDC_HALIGN, CB_SETITEMDATA, item, 0);
- }
- SendDlgItemMessage(hwndDlg, IDC_HALIGN, CB_SETCURSEL, 0, 0);
+ wchar_t *v_alignment[] = { L"top", L"vCenter", L"bottom" };
+ for (auto &it : v_alignment) {
+ int item = SendDlgItemMessage(hwndDlg, IDC_VALIGN, CB_ADDSTRING, 0, (LPARAM)TranslateW(it));
+ SendDlgItemMessage(hwndDlg, IDC_VALIGN, CB_SETITEMDATA, item, 0);
+ }
+ SendDlgItemMessage(hwndDlg, IDC_VALIGN, CB_SETCURSEL, 0, 0);
- wchar_t *v_alignment[] = { L"top", L"vCenter", L"bottom" };
- for (auto &it : v_alignment) {
- int item = SendDlgItemMessage(hwndDlg, IDC_VALIGN, CB_ADDSTRING, 0, (LPARAM)TranslateW(it));
- SendDlgItemMessage(hwndDlg, IDC_VALIGN, CB_SETITEMDATA, item, 0);
- }
- SendDlgItemMessage(hwndDlg, IDC_VALIGN, CB_SETCURSEL, 0, 0);
+ rowDeleteTree(rowOptTmplRoot);
+ rowOptTmplRoot = nullptr;
- rowDeleteTree(rowOptTmplRoot);
- rowOptTmplRoot = nullptr;
- rowParse(rowOptTmplRoot, rowOptTmplRoot, rowOptTmplStr, hbuf, seq, rowOptTA);
- seq = 0;
- memset(rowOptTA, 0, sizeof(rowOptTA));
- rowOptBuildTA(rowOptTmplRoot, (pROWCELL*)&rowOptTA, &seq);
+ int hbuf = 0, seq = 0;
+ rowParse(rowOptTmplRoot, rowOptTmplRoot, rowOptTmplStr, hbuf, seq, rowOptTA);
+ seq = 0;
+ memset(rowOptTA, 0, sizeof(rowOptTA));
+ rowOptBuildTA(rowOptTmplRoot, (pROWCELL*)&rowOptTA, &seq);
- rowOptFillRowTree(htree);
- RefreshTree(hwndDlg, nullptr);
- TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_ROWTREE), TreeView_GetRoot(GetDlgItem(hwndDlg, IDC_ROWTREE)));
- rowOptShowSettings(hwndDlg);
- }
- return TRUE;
+ rowOptFillRowTree(htree);
+ RefreshTree(hwndDlg, nullptr);
+ TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_ROWTREE), TreeView_GetRoot(GetDlgItem(hwndDlg, IDC_ROWTREE)));
+ rowOptShowSettings(hwndDlg);
+ }
+ return TRUE;
case WM_COMMAND:
- {
- HWND htree = GetDlgItem(hwndDlg, IDC_ROWTREE);
- pROWCELL cell;
- TVITEM tvi = { 0 };
- HTREEITEM hti = TreeView_GetSelection(htree);
-
-
- tvi.hItem = hti;
- tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
- TreeView_GetItem(htree, &tvi);
- cell = (pROWCELL)tvi.lParam;
-
- switch (LOWORD(wParam)) {
- case IDC_CONTTYPE:
- if (HIWORD(wParam) == CBN_SELENDOK) {
- int index = SendDlgItemMessage(hwndDlg, IDC_CONTTYPE, CB_GETCURSEL, 0, 0);
- cell->type = index;
- RefreshTree(hwndDlg, nullptr);
- }
+ {
+ HTREEITEM hti = TreeView_GetSelection(htree);
+
+ TVITEM tvi = { 0 };
+ tvi.hItem = hti;
+ tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
+ TreeView_GetItem(htree, &tvi);
+ pROWCELL cell = (pROWCELL)tvi.lParam;
+
+ switch (LOWORD(wParam)) {
+ case IDC_CONTTYPE:
+ if (HIWORD(wParam) == CBN_SELENDOK) {
+ int index = SendDlgItemMessage(hwndDlg, IDC_CONTTYPE, CB_GETCURSEL, 0, 0);
+ cell->type = index;
+ RefreshTree(hwndDlg, nullptr);
+ }
- case IDC_VALIGN:
- if (HIWORD(wParam) == CBN_SELENDOK) {
- switch (SendDlgItemMessage(hwndDlg, IDC_VALIGN, CB_GETCURSEL, 0, 0)) {
- case 0:
- cell->valign = TC_TOP;
- break;
- case 1:
- cell->valign = TC_VCENTER;
- break;
- case 2:
- cell->valign = TC_BOTTOM;
- break;
+ case IDC_VALIGN:
+ if (HIWORD(wParam) == CBN_SELENDOK) {
+ switch (SendDlgItemMessage(hwndDlg, IDC_VALIGN, CB_GETCURSEL, 0, 0)) {
+ case 0:
+ cell->valign = TC_TOP;
+ break;
+ case 1:
+ cell->valign = TC_VCENTER;
+ break;
+ case 2:
+ cell->valign = TC_BOTTOM;
+ break;
+ }
+ RefreshTree(hwndDlg, nullptr);
}
- RefreshTree(hwndDlg, nullptr);
- }
- case IDC_HALIGN:
- if (HIWORD(wParam) == CBN_SELENDOK) {
- switch (SendDlgItemMessage(hwndDlg, IDC_HALIGN, CB_GETCURSEL, 0, 0)) {
- case 0:
- cell->halign = TC_LEFT;
- break;
- case 1:
- cell->halign = TC_HCENTER;
- break;
- case 2:
- cell->halign = TC_RIGHT;
- break;
+ case IDC_HALIGN:
+ if (HIWORD(wParam) == CBN_SELENDOK) {
+ switch (SendDlgItemMessage(hwndDlg, IDC_HALIGN, CB_GETCURSEL, 0, 0)) {
+ case 0:
+ cell->halign = TC_LEFT;
+ break;
+ case 1:
+ cell->halign = TC_HCENTER;
+ break;
+ case 2:
+ cell->halign = TC_RIGHT;
+ break;
+ }
+ RefreshTree(hwndDlg, nullptr);
}
- RefreshTree(hwndDlg, nullptr);
}
- }
- if (HIWORD(wParam) == BN_CLICKED) {
- if (lParam == (LPARAM)GetDlgItem(hwndDlg, IDC_ADDCONTAINER))
- // Adding new container
- {
- rowOptAddContainer(htree, hti);
- }
- else if (lParam == (LPARAM)GetDlgItem(hwndDlg, IDC_DELCONTAINER))
- // Deleting container
- {
- rowOptDelContainer(htree, hti);
- }
- else if (lParam == (LPARAM)GetDlgItem(hwndDlg, IDC_CONTUP))
- // Moving container to up
- {
- RedrawWindow(htree, &da, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN);
+ if (HIWORD(wParam) == BN_CLICKED) {
+ if (lParam == (LPARAM)GetDlgItem(hwndDlg, IDC_ADDCONTAINER)) // Adding new container
+ rowOptAddContainer(htree, hti);
+
+ else if (lParam == (LPARAM)GetDlgItem(hwndDlg, IDC_DELCONTAINER)) // Deleting container
+ rowOptDelContainer(htree, hti);
+
+ else if (lParam == (LPARAM)GetDlgItem(hwndDlg, IDC_CONTUP)) // Moving container to up
+ RedrawWindow(htree, &da, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN);
+
+ RefreshTree(hwndDlg, nullptr);
+ RedrawWindow(GetParent(hwndDlg), nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN);
}
- RefreshTree(hwndDlg, nullptr);
- RedrawWindow(GetParent(hwndDlg), nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN);
+ return TRUE;
}
- return TRUE;
- }
case WM_NOTIFY:
switch (((LPNMHDR)lParam)->idFrom) {
@@ -475,14 +457,11 @@ INT_PTR CALLBACK DlgTmplEditorOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
case 0: // Apply or Ok button is pressed
return FALSE; // Temporary
- break;
}
return TRUE;
case WM_PAINT:
if (rowOptTmplRoot) {
- int i = 0;
-
// Drawning row template at properties page
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwndDlg, &ps);
@@ -492,6 +471,7 @@ INT_PTR CALLBACK DlgTmplEditorOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
curItem.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
TreeView_GetItem(GetDlgItem(hwndDlg, IDC_ROWTREE), &curItem);
+ int i = 0;
while (rowOptTA[i]) {
switch (rowOptTA[i]->type) {
case TC_AVATAR:
diff --git a/plugins/Clist_modern/src/modern_skinengine.cpp b/plugins/Clist_modern/src/modern_skinengine.cpp
index f9d925d662..dfb73cd100 100644
--- a/plugins/Clist_modern/src/modern_skinengine.cpp
+++ b/plugins/Clist_modern/src/modern_skinengine.cpp
@@ -3422,7 +3422,7 @@ static void ske_AddParseSkinFont(char * szFontID, char * szDefineString)
logfont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
char buf[255];
- mir_strncpy(logfont.lfFaceName, GetParamN(szDefineString, buf, sizeof(buf), 0, ',', TRUE), _countof(logfont.lfFaceName));
+ strncpy_s(logfont.lfFaceName, GetParamN(szDefineString, buf, sizeof(buf), 0, ',', TRUE), _TRUNCATE);
logfont.lfHeight = atoi(GetParamN(szDefineString, buf, sizeof(buf), 1, ',', TRUE));
if (logfont.lfHeight < 0) {
HDC hdc = CreateCompatibleDC(nullptr);
diff --git a/plugins/Clist_modern/src/modern_skinselector.cpp b/plugins/Clist_modern/src/modern_skinselector.cpp
index 3c167fd430..03f0a1c030 100644
--- a/plugins/Clist_modern/src/modern_skinselector.cpp
+++ b/plugins/Clist_modern/src/modern_skinselector.cpp
@@ -560,6 +560,6 @@ int SkinDrawGlyphMask(HDC hdc, RECT *rcSize, RECT *rcClip, MODERNMASK *ModernMas
rq.hDC = hdc;
rq.rcDestRect = *rcSize;
rq.rcClipRect = *rcClip;
- mir_strncpy(rq.szObjectID, "Masked draw", _countof(rq.szObjectID));
+ strncpy_s(rq.szObjectID, "Masked draw", _TRUNCATE);
return ske_Service_DrawGlyph((WPARAM)&rq, (LPARAM)ModernMask);
}
diff --git a/plugins/Clist_modern/src/modern_statusbar.cpp b/plugins/Clist_modern/src/modern_statusbar.cpp
index a261c96ae2..81148ef30c 100644
--- a/plugins/Clist_modern/src/modern_statusbar.cpp
+++ b/plugins/Clist_modern/src/modern_statusbar.cpp
@@ -346,7 +346,7 @@ int ModernDrawStatusBarWorker(HWND hWnd, HDC hDC)
p.tszProtoXStatus = mir_wstrdup(str);
}
- if ((p.xStatusMode & 3)) {
+ if (p.xStatusMode & 3) {
if (p.iProtoStatus > ID_STATUS_OFFLINE) {
if (ProtoServiceExists(p.szAccountName, PS_GETCUSTOMSTATUSICON))
p.extraIcon = (HICON)CallProtoService(p.szAccountName, PS_GETCUSTOMSTATUSICON, 0, 0);
@@ -758,15 +758,24 @@ LRESULT CALLBACK ModernStatusProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa
BOOL bCtrl = (GetKeyState(VK_CONTROL) & 0x8000);
if (msg == WM_LBUTTONDOWN && bCtrl) {
+ char protoF[_countof(g_CluiData.protoFilter)];
+ mir_snprintf(protoF, "%s|", p->szAccountName);
+
if (g_CluiData.bFilterEffective != CLVM_FILTER_PROTOS || !bShift) {
ApplyViewMode("");
- mir_snprintf(g_CluiData.protoFilter, "%s|", p->szAccountName);
- g_CluiData.bFilterEffective = CLVM_FILTER_PROTOS;
+
+ // if a user clicks on the same proto again, disable filter
+ if (!mir_strcmp(protoF, g_CluiData.protoFilter)) {
+ g_CluiData.protoFilter[0] = 0;
+ g_CluiData.bFilterEffective = 0;
+ }
+ else {
+ mir_snprintf(g_CluiData.protoFilter, "%s|", p->szAccountName);
+ g_CluiData.bFilterEffective = CLVM_FILTER_PROTOS;
+ }
}
else {
- char protoF[sizeof(g_CluiData.protoFilter)];
- mir_snprintf(protoF, "%s|", p->szAccountName);
- char *pos = strstri(g_CluiData.protoFilter, p->szAccountName);
+ char *pos = strstri(g_CluiData.protoFilter, protoF);
if (pos) {
// remove filter
size_t len = mir_strlen(protoF);
@@ -778,15 +787,15 @@ LRESULT CALLBACK ModernStatusProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa
g_CluiData.bFilterEffective = CLVM_FILTER_PROTOS;
}
else {
- //add filter
- mir_snprintf(g_CluiData.protoFilter, "%s%s", g_CluiData.protoFilter, protoF);
+ // add filter
+ strncat_s(g_CluiData.protoFilter, protoF, _TRUNCATE);
g_CluiData.bFilterEffective = CLVM_FILTER_PROTOS;
}
}
if (g_CluiData.bFilterEffective == CLVM_FILTER_PROTOS) {
- char filterName[sizeof(g_CluiData.protoFilter)] = { 0 };
- filterName[0] = (char)13;
+ CMStringA szFilterName;
+ szFilterName.AppendChar(13);
int protoCount;
PROTOACCOUNT **accs;
@@ -802,15 +811,14 @@ LRESULT CALLBACK ModernStatusProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa
mir_snprintf(protoF, "%s|", accs[k]->szModuleName);
if (strstri(g_CluiData.protoFilter, protoF)) {
if (!first)
- mir_strncat(filterName, "; ", _countof(filterName) - mir_strlen(filterName));
- mir_strncat(filterName, T2Utf(accs[k]->tszAccountName), _countof(filterName) - mir_strlen(filterName));
+ szFilterName.Append("; ");
+ szFilterName.Append(T2Utf(accs[k]->tszAccountName));
first = false;
}
}
- SaveViewMode(filterName, L"", g_CluiData.protoFilter, 0, -1, 0, 0, 0, 0);
-
- ApplyViewMode(filterName);
+ SaveViewMode(szFilterName, L"", g_CluiData.protoFilter, 0, -1, 0, 0, 0, 0);
+ ApplyViewMode(szFilterName);
}
Clist_Broadcast(CLM_AUTOREBUILD, 0, 0);
cliInvalidateRect(hwnd, nullptr, FALSE);
diff --git a/plugins/Clist_modern/src/modern_viewmodebar.cpp b/plugins/Clist_modern/src/modern_viewmodebar.cpp
index a654d615c1..67136c7d3c 100644
--- a/plugins/Clist_modern/src/modern_viewmodebar.cpp
+++ b/plugins/Clist_modern/src/modern_viewmodebar.cpp
@@ -1254,7 +1254,7 @@ void ApplyViewMode(const char *Name, bool onlySelector)
mir_snprintf(szSetting, "%c%s_PF", 246, Name);
if (!db_get_s(0, CLVM_MODULE, szSetting, &dbv)) {
if (mir_strlen(dbv.pszVal) >= 2) {
- mir_strncpy(g_CluiData.protoFilter, dbv.pszVal, _countof(g_CluiData.protoFilter));
+ strncpy_s(g_CluiData.protoFilter, dbv.pszVal, _TRUNCATE);
g_CluiData.protoFilter[_countof(g_CluiData.protoFilter) - 1] = 0;
g_CluiData.bFilterEffective |= CLVM_FILTER_PROTOS;
}
@@ -1263,8 +1263,7 @@ void ApplyViewMode(const char *Name, bool onlySelector)
mir_snprintf(szSetting, "%c%s_GF", 246, Name);
if (!db_get_ws(0, CLVM_MODULE, szSetting, &dbv)) {
if (mir_wstrlen(dbv.pwszVal) >= 2) {
- mir_wstrncpy(g_CluiData.groupFilter, dbv.pwszVal, _countof(g_CluiData.groupFilter));
- g_CluiData.groupFilter[_countof(g_CluiData.groupFilter) - 1] = 0;
+ wcsncpy_s(g_CluiData.groupFilter, dbv.pwszVal, _TRUNCATE);
g_CluiData.bFilterEffective |= CLVM_FILTER_GROUPS;
}
mir_free(dbv.pwszVal);
@@ -1286,7 +1285,7 @@ void ApplyViewMode(const char *Name, bool onlySelector)
if (g_CluiData.filterFlags & CLVM_AUTOCLEAR) {
mir_snprintf(szSetting, "%c%s_OPT", 246, Name);
DWORD timerexpire = LOWORD(db_get_dw(0, CLVM_MODULE, szSetting, 0));
- mir_strncpy(g_CluiData.old_viewmode, g_CluiData.current_viewmode, _countof(g_CluiData.old_viewmode));
+ strncpy_s(g_CluiData.old_viewmode, g_CluiData.current_viewmode, _TRUNCATE);
g_CluiData.old_viewmode[255] = 0;
CLUI_SafeSetTimer(g_hwndViewModeFrame, TIMERID_VIEWMODEEXPIRE, timerexpire * 1000, nullptr);
}
@@ -1294,7 +1293,7 @@ void ApplyViewMode(const char *Name, bool onlySelector)
mir_snprintf(szSetting, "%c_LastMode", 246);
db_set_s(0, CLVM_MODULE, szSetting, Name);
}
- mir_strncpy(g_CluiData.current_viewmode, Name, _countof(g_CluiData.current_viewmode));
+ strncpy_s(g_CluiData.current_viewmode, Name, _TRUNCATE);
g_CluiData.current_viewmode[255] = 0;
if (g_CluiData.filterFlags & CLVM_USELASTMSG) {