diff options
author | George Hazan <george.hazan@gmail.com> | 2014-06-24 21:10:28 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-06-24 21:10:28 +0000 |
commit | ee445e9c96823f95a9a8fc47cb8a1bb40c706bec (patch) | |
tree | ca26808239050b4ec9935991127b9fbad9b602bb /src/core/stdfile/fileopts.cpp | |
parent | 0eae5d3fe73c4db870912328fe2c41af89dcd01d (diff) |
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@9572 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/core/stdfile/fileopts.cpp')
-rw-r--r-- | src/core/stdfile/fileopts.cpp | 240 |
1 files changed, 120 insertions, 120 deletions
diff --git a/src/core/stdfile/fileopts.cpp b/src/core/stdfile/fileopts.cpp index 95a73b4455..cc36766a66 100644 --- a/src/core/stdfile/fileopts.cpp +++ b/src/core/stdfile/fileopts.cpp @@ -58,173 +58,173 @@ static const struct virusscannerinfo virusScanners[] = { static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg) {
- case WM_INITDIALOG:
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
{
- TranslateDialogDefault(hwndDlg);
-
SHAutoComplete(GetDlgItem(hwndDlg, IDC_FILEDIR), SHACF_FILESYS_DIRS);
- {
- TCHAR str[MAX_PATH];
- GetContactReceivedFilesDir(NULL, str, SIZEOF(str), FALSE);
- SetDlgItemText(hwndDlg, IDC_FILEDIR, str);
- }
+ TCHAR str[MAX_PATH];
+ GetContactReceivedFilesDir(NULL, str, SIZEOF(str), FALSE);
+ SetDlgItemText(hwndDlg, IDC_FILEDIR, str);
CheckDlgButton(hwndDlg, IDC_AUTOACCEPT, db_get_b(NULL, "SRFile", "AutoAccept", 0) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_AUTOMIN, db_get_b(NULL, "SRFile", "AutoMin", 0) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_AUTOCLOSE, db_get_b(NULL, "SRFile", "AutoClose", 0) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_AUTOCLEAR, db_get_b(NULL, "SRFile", "AutoClear", 1) ? BST_CHECKED : BST_UNCHECKED);
- switch(db_get_b(NULL, "SRFile", "UseScanner", VIRUSSCAN_DISABLE)) {
+ switch (db_get_b(NULL, "SRFile", "UseScanner", VIRUSSCAN_DISABLE)) {
case VIRUSSCAN_AFTERDL: CheckDlgButton(hwndDlg, IDC_SCANAFTERDL, BST_CHECKED); break;
case VIRUSSCAN_DURINGDL: CheckDlgButton(hwndDlg, IDC_SCANDURINGDL, BST_CHECKED); break;
default: CheckDlgButton(hwndDlg, IDC_NOSCANNER, BST_CHECKED); break;
}
CheckDlgButton(hwndDlg, IDC_WARNBEFOREOPENING, db_get_b(NULL, "SRFile", "WarnBeforeOpening", 1) ? BST_CHECKED : BST_UNCHECKED);
- { TCHAR szScanExe[MAX_PATH];
- int i, iItem;
- for (i=0; i < SIZEOF(virusScanners); i++) {
- if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE, virusScanners[i].szExeRegPath, virusScanners[i].szExeRegValue, szScanExe, SIZEOF(szScanExe))) {
- iItem = SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_ADDSTRING, 0, (LPARAM)virusScanners[i].szProductName);
- SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_SETITEMDATA, iItem, i);
- }
- }
- if (SendDlgItemMessageA(hwndDlg, IDC_SCANCMDLINE, CB_GETCOUNT, 0, 0) == 0)
- {
- iItem = SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_ADDSTRING, 0, (LPARAM)_T(""));
- SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_SETITEMDATA, iItem, (LPARAM)-1);
+ for (int i = 0; i < SIZEOF(virusScanners); i++) {
+ TCHAR szScanExe[MAX_PATH];
+ if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE, virusScanners[i].szExeRegPath, virusScanners[i].szExeRegValue, szScanExe, SIZEOF(szScanExe))) {
+ int iItem = SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_ADDSTRING, 0, (LPARAM)virusScanners[i].szProductName);
+ SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_SETITEMDATA, iItem, i);
}
}
+ if (SendDlgItemMessageA(hwndDlg, IDC_SCANCMDLINE, CB_GETCOUNT, 0, 0) == 0) {
+ int iItem = SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_ADDSTRING, 0, (LPARAM)_T(""));
+ SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_SETITEMDATA, iItem, (LPARAM)-1);
+ }
DBVARIANT dbv;
if (db_get_ts(NULL, "SRFile", "ScanCmdLine", &dbv) == 0) {
SetDlgItemText(hwndDlg, IDC_SCANCMDLINE, dbv.ptszVal);
db_free(&dbv);
}
- else {
- if (SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETCOUNT, 0, 0)) {
- SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_SETCURSEL, 0, 0);
- PostMessage(hwndDlg, M_SCANCMDLINESELCHANGE, 0, 0);
- }
+ else if (SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETCOUNT, 0, 0)) {
+ SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_SETCURSEL, 0, 0);
+ PostMessage(hwndDlg, M_SCANCMDLINESELCHANGE, 0, 0);
}
- switch(db_get_b(NULL, "SRFile", "IfExists", FILERESUME_ASK)) {
+
+ switch (db_get_b(NULL, "SRFile", "IfExists", FILERESUME_ASK)) {
case FILERESUME_RESUMEALL: CheckDlgButton(hwndDlg, IDC_RESUME, BST_CHECKED); break;
case FILERESUME_OVERWRITEALL: CheckDlgButton(hwndDlg, IDC_OVERWRITE, BST_CHECKED); break;
case FILERESUME_RENAMEALL: CheckDlgButton(hwndDlg, IDC_RENAME, BST_CHECKED); break;
default: CheckDlgButton(hwndDlg, IDC_ASK, BST_CHECKED); break;
}
SendMessage(hwndDlg, M_UPDATEENABLING, 0, 0);
- return TRUE;
}
- case M_UPDATEENABLING:
- { int on = !IsDlgButtonChecked(hwndDlg, IDC_NOSCANNER);
+ return TRUE;
+
+ case M_UPDATEENABLING:
+ {
+ int on = !IsDlgButtonChecked(hwndDlg, IDC_NOSCANNER);
EnableWindow(GetDlgItem(hwndDlg, IDC_ST_CMDLINE), on);
EnableWindow(GetDlgItem(hwndDlg, IDC_SCANCMDLINE), on);
EnableWindow(GetDlgItem(hwndDlg, IDC_SCANCMDLINEBROWSE), on);
EnableWindow(GetDlgItem(hwndDlg, IDC_ST_CMDLINEHELP), on);
EnableWindow(GetDlgItem(hwndDlg, IDC_AUTOMIN), IsDlgButtonChecked(hwndDlg, IDC_AUTOACCEPT));
- break;
}
- case M_SCANCMDLINESELCHANGE:
- { TCHAR str[512];
+ break;
+ case M_SCANCMDLINESELCHANGE:
+ {
+ TCHAR str[512];
TCHAR szScanExe[MAX_PATH];
int iScanner = SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETCURSEL, 0, 0), 0);
- if (iScanner >= SIZEOF(virusScanners) || iScanner<0) break;
+ if (iScanner >= SIZEOF(virusScanners) || iScanner < 0) break;
str[0] = '\0';
if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE, virusScanners[iScanner].szExeRegPath, virusScanners[iScanner].szExeRegValue, szScanExe, SIZEOF(szScanExe)))
mir_sntprintf(str, SIZEOF(str), virusScanners[iScanner].szCommandLine, szScanExe);
SetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str);
- break;
}
- case WM_COMMAND:
- switch(LOWORD(wParam)) {
- case IDC_FILEDIR:
- if ((HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0;
- break;
- case IDC_FILEDIRBROWSE:
- { TCHAR str[MAX_PATH];
- GetDlgItemText(hwndDlg, IDC_FILEDIR, str, SIZEOF(str));
- if (BrowseForFolder(hwndDlg, str))
- SetDlgItemText(hwndDlg, IDC_FILEDIR, str);
- break;
- }
- case IDC_AUTOACCEPT:
- case IDC_NOSCANNER:
- case IDC_SCANAFTERDL:
- case IDC_SCANDURINGDL:
- SendMessage(hwndDlg, M_UPDATEENABLING, 0, 0);
- break;
- case IDC_SCANCMDLINE:
- if (HIWORD(wParam) == CBN_SELCHANGE) PostMessage(hwndDlg, M_SCANCMDLINESELCHANGE, 0, 0);
- else if (HIWORD(wParam) != CBN_EDITCHANGE) return 0;
- break;
- case IDC_SCANCMDLINEBROWSE:
- { TCHAR str[MAX_PATH+2];
- OPENFILENAME ofn = {0};
- TCHAR filter[512], *pfilter;
-
- GetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str, SIZEOF(str));
- ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
- ofn.hwndOwner = hwndDlg;
- ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_DONTADDTORECENT;
- _tcscpy(filter, TranslateT("Executable files"));
- _tcscat(filter, _T(" (*.exe)"));
- pfilter = filter + _tcslen(filter) + 1;
- _tcscpy(pfilter, _T("*.exe"));
- pfilter = pfilter + _tcslen(pfilter)+1;
- _tcscpy(pfilter, TranslateT("All files"));
- _tcscat(pfilter, _T(" (*)"));
- pfilter = pfilter + _tcslen(pfilter) + 1;
- _tcscpy(pfilter, _T("*"));
- pfilter = pfilter + _tcslen(pfilter) + 1;
- *pfilter = 0;
- ofn.lpstrFilter = filter;
- ofn.lpstrFile = str;
- ofn.nMaxFile = SIZEOF(str)-2;
- if (str[0] == '"') {
- TCHAR *pszQuote = _tcschr(str + 1, '"');
- if (pszQuote) *pszQuote = 0;
- MoveMemory(str, str + 1, _tcslen(str) * sizeof(TCHAR));
- }
- else {
- TCHAR *pszSpace = _tcschr(str, ' ');
- if (pszSpace) *pszSpace = 0;
- }
- ofn.nMaxFileTitle = MAX_PATH;
- if ( !GetOpenFileName(&ofn)) break;
- if (_tcschr(str, ' ') != NULL) {
- MoveMemory(str+1, str, SIZEOF(str) - 2 * sizeof(TCHAR));
- str[0] = '"';
- _tcscat(str, _T("\""));
- }
- SetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str);
- break;
- }
- }
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_FILEDIR:
+ if ((HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0;
break;
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->code)
+
+ case IDC_FILEDIRBROWSE:
{
- case PSN_APPLY:
- { TCHAR str[512];
- GetDlgItemText(hwndDlg, IDC_FILEDIR, str, SIZEOF(str));
- RemoveInvalidPathChars(str);
- db_set_ts(NULL, "SRFile", "RecvFilesDirAdv", str);
- db_set_b(NULL, "SRFile", "AutoAccept", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOACCEPT));
- db_set_b(NULL, "SRFile", "AutoMin", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOMIN));
- db_set_b(NULL, "SRFile", "AutoClose", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOCLOSE));
- db_set_b(NULL, "SRFile", "AutoClear", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOCLEAR));
- db_set_b(NULL, "SRFile", "UseScanner", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_SCANAFTERDL)?VIRUSSCAN_AFTERDL:(IsDlgButtonChecked(hwndDlg, IDC_SCANDURINGDL)?VIRUSSCAN_DURINGDL:VIRUSSCAN_DISABLE)));
- GetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str, SIZEOF(str));
- db_set_ts(NULL, "SRFile", "ScanCmdLine", str);
- db_set_b(NULL, "SRFile", "WarnBeforeOpening", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_WARNBEFOREOPENING));
- db_set_b(NULL, "SRFile", "IfExists", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_ASK)?FILERESUME_ASK:(IsDlgButtonChecked(hwndDlg, IDC_RESUME)?FILERESUME_RESUMEALL:(IsDlgButtonChecked(hwndDlg, IDC_OVERWRITE)?FILERESUME_OVERWRITEALL:FILERESUME_RENAMEALL))));
- return TRUE;
- }
+ TCHAR str[MAX_PATH];
+ GetDlgItemText(hwndDlg, IDC_FILEDIR, str, SIZEOF(str));
+ if (BrowseForFolder(hwndDlg, str))
+ SetDlgItemText(hwndDlg, IDC_FILEDIR, str);
+ }
+ break;
+
+ case IDC_AUTOACCEPT:
+ case IDC_NOSCANNER:
+ case IDC_SCANAFTERDL:
+ case IDC_SCANDURINGDL:
+ SendMessage(hwndDlg, M_UPDATEENABLING, 0, 0);
+ break;
+
+ case IDC_SCANCMDLINE:
+ if (HIWORD(wParam) == CBN_SELCHANGE) PostMessage(hwndDlg, M_SCANCMDLINESELCHANGE, 0, 0);
+ else if (HIWORD(wParam) != CBN_EDITCHANGE) return 0;
+ break;
+
+ case IDC_SCANCMDLINEBROWSE:
+ TCHAR str[MAX_PATH + 2];
+ OPENFILENAME ofn = { 0 };
+ TCHAR filter[512], *pfilter;
+
+ GetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str, SIZEOF(str));
+ ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
+ ofn.hwndOwner = hwndDlg;
+ ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_DONTADDTORECENT;
+ _tcscpy(filter, TranslateT("Executable files"));
+ _tcscat(filter, _T(" (*.exe)"));
+ pfilter = filter + _tcslen(filter) + 1;
+ _tcscpy(pfilter, _T("*.exe"));
+ pfilter = pfilter + _tcslen(pfilter) + 1;
+ _tcscpy(pfilter, TranslateT("All files"));
+ _tcscat(pfilter, _T(" (*)"));
+ pfilter = pfilter + _tcslen(pfilter) + 1;
+ _tcscpy(pfilter, _T("*"));
+ pfilter = pfilter + _tcslen(pfilter) + 1;
+ *pfilter = 0;
+ ofn.lpstrFilter = filter;
+ ofn.lpstrFile = str;
+ ofn.nMaxFile = SIZEOF(str) - 2;
+ if (str[0] == '"') {
+ TCHAR *pszQuote = _tcschr(str + 1, '"');
+ if (pszQuote) *pszQuote = 0;
+ MoveMemory(str, str + 1, _tcslen(str) * sizeof(TCHAR));
+ }
+ else {
+ TCHAR *pszSpace = _tcschr(str, ' ');
+ if (pszSpace) *pszSpace = 0;
+ }
+ ofn.nMaxFileTitle = MAX_PATH;
+ if (!GetOpenFileName(&ofn)) break;
+ if (_tcschr(str, ' ') != NULL) {
+ MoveMemory(str + 1, str, SIZEOF(str) - 2 * sizeof(TCHAR));
+ str[0] = '"';
+ _tcscat(str, _T("\""));
}
+ SetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str);
break;
+ }
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case WM_NOTIFY:
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_APPLY:
+ TCHAR str[512];
+ GetDlgItemText(hwndDlg, IDC_FILEDIR, str, SIZEOF(str));
+ RemoveInvalidPathChars(str);
+ db_set_ts(NULL, "SRFile", "RecvFilesDirAdv", str);
+ db_set_b(NULL, "SRFile", "AutoAccept", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOACCEPT));
+ db_set_b(NULL, "SRFile", "AutoMin", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOMIN));
+ db_set_b(NULL, "SRFile", "AutoClose", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOCLOSE));
+ db_set_b(NULL, "SRFile", "AutoClear", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOCLEAR));
+ db_set_b(NULL, "SRFile", "UseScanner", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_SCANAFTERDL) ? VIRUSSCAN_AFTERDL : (IsDlgButtonChecked(hwndDlg, IDC_SCANDURINGDL) ? VIRUSSCAN_DURINGDL : VIRUSSCAN_DISABLE)));
+ GetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str, SIZEOF(str));
+ db_set_ts(NULL, "SRFile", "ScanCmdLine", str);
+ db_set_b(NULL, "SRFile", "WarnBeforeOpening", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_WARNBEFOREOPENING));
+ db_set_b(NULL, "SRFile", "IfExists", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_ASK) ? FILERESUME_ASK : (IsDlgButtonChecked(hwndDlg, IDC_RESUME) ? FILERESUME_RESUMEALL : (IsDlgButtonChecked(hwndDlg, IDC_OVERWRITE) ? FILERESUME_OVERWRITEALL : FILERESUME_RENAMEALL))));
+ return TRUE;
+ }
+ break;
}
return FALSE;
}
|