summaryrefslogtreecommitdiff
path: root/src/core/stdfile
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-12-14 17:57:25 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-12-14 17:57:25 +0300
commit422eedb14b84b4cd9e5cb3d43971cd47bc787e52 (patch)
tree19095dbd3a2f1d244fe8e7e7889a6674596fd7da /src/core/stdfile
parent7ea25880794e76dc40790826c1198d4048b156eb (diff)
fixes #2650 (Option for reverse sorting in StdFile filetransfer window) + massive options rework
Diffstat (limited to 'src/core/stdfile')
-rw-r--r--src/core/stdfile/res/resource.rc89
-rw-r--r--src/core/stdfile/src/file.cpp2
-rw-r--r--src/core/stdfile/src/fileopts.cpp331
-rw-r--r--src/core/stdfile/src/filerecvdlg.cpp4
-rw-r--r--src/core/stdfile/src/filexferdlg.cpp46
-rw-r--r--src/core/stdfile/src/ftmanager.cpp228
-rw-r--r--src/core/stdfile/src/main.cpp10
-rw-r--r--src/core/stdfile/src/stdafx.h2
-rw-r--r--src/core/stdfile/stdfile.vcxproj1
-rw-r--r--src/core/stdfile/stdfile.vcxproj.filters3
10 files changed, 370 insertions, 346 deletions
diff --git a/src/core/stdfile/res/resource.rc b/src/core/stdfile/res/resource.rc
index 419246897c..ea8c40fd57 100644
--- a/src/core/stdfile/res/resource.rc
+++ b/src/core/stdfile/res/resource.rc
@@ -139,7 +139,7 @@ STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPT
CAPTION "File transfers"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
- CONTROL "",IDC_TABS,"SysTabControl32", WS_TABSTOP,7,7,262,224
+ CONTROL "",IDC_TABS,"SysTabControl32",WS_TABSTOP,7,7,262,224
PUSHBUTTON "Clear completed",IDC_CLEAR,7,234,100,14
PUSHBUTTON "Close",IDCANCEL,219,234,50,14
END
@@ -151,45 +151,46 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
END
-IDD_OPT_FILETRANSFER DIALOGEX 0, 0, 313, 232
+IDD_OPT_FILETRANSFER DIALOGEX 0, 0, 313, 243
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- GROUPBOX "Receiving files",IDC_STATIC,0,0,313,90
+ GROUPBOX "Receiving files",IDC_STATIC,0,0,313,99
LTEXT "Received files folder:",IDC_STATIC,8,15,82,8
EDITTEXT IDC_FILEDIR,92,13,190,12,ES_AUTOHSCROLL
- PUSHBUTTON "...",IDC_FILEDIRBROWSE,287,14,15,11
- LTEXT "Variables allowed: %userid%, %nick%, %proto%, %miranda_path%, %userprofile%",IDC_STATIC,8,27,294,11,WS_DISABLED
+ PUSHBUTTON "...",IDC_FILEDIRBROWSE,287,12,15,13
+ LTEXT "Variables allowed: %userid%, %nick%, %proto%, %miranda_path%, %userprofile%",IDC_STATIC,8,26,294,11,WS_DISABLED
CONTROL "Auto-accept incoming files from people on my contact list",IDC_AUTOACCEPT,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,39,294,10
- CONTROL "Minimize the file transfer window",IDC_AUTOMIN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,52,285,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,36,294,10
+ CONTROL "Minimize the file transfer window",IDC_AUTOMIN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,48,285,10
CONTROL "Close window when transfer completes",IDC_AUTOCLOSE,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,65,294,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,60,294,10
CONTROL "Clear completed transfers on window closing",IDC_AUTOCLEAR,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,76,294,10
- GROUPBOX "Virus scanner",IDC_VIRUSSCANNERGROUP,0,90,313,93
- LTEXT "Scan files:",IDC_STATIC,8,102,43,9,SS_CENTERIMAGE
- CONTROL "Never, do not use virus scanning",IDC_NOSCANNER,"Button",BS_AUTORADIOBUTTON,52,102,250,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,72,294,10
+ CONTROL "Sort file transfers in the reverse order",IDC_REVERSE_ORDER,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,84,286,10
+ GROUPBOX "Virus scanner",IDC_VIRUSSCANNERGROUP,0,100,313,93
+ LTEXT "Scan files:",IDC_STATIC,8,112,43,9,SS_CENTERIMAGE
+ CONTROL "Never, do not use virus scanning",IDC_NOSCANNER,"Button",BS_AUTORADIOBUTTON,52,112,250,10
CONTROL "When all files have been downloaded",IDC_SCANAFTERDL,
- "Button",BS_AUTORADIOBUTTON,52,114,250,10
+ "Button",BS_AUTORADIOBUTTON,52,124,250,10
CONTROL "As each file finishes downloading",IDC_SCANDURINGDL,
- "Button",BS_AUTORADIOBUTTON,52,126,250,10
- LTEXT "Command line:",IDC_ST_CMDLINE,7,142,62,8
- COMBOBOX IDC_SCANCMDLINE,70,141,213,71,CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP
- PUSHBUTTON "...",IDC_SCANCMDLINEBROWSE,287,142,15,11
- LTEXT "%f will be replaced by the file or folder name to be scanned",IDC_ST_CMDLINEHELP,70,155,232,8
+ "Button",BS_AUTORADIOBUTTON,52,136,250,10
+ LTEXT "Command line:",IDC_ST_CMDLINE,7,161,62,8
+ COMBOBOX IDC_SCANCMDLINE,70,151,213,71,CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP
+ PUSHBUTTON "...",IDC_SCANCMDLINEBROWSE,287,151,15,13
+ LTEXT "%f will be replaced by the file or folder name to be scanned",IDC_ST_CMDLINEHELP,70,165,232,8
CONTROL "Warn me before opening a file that has not been scanned",IDC_WARNBEFOREOPENING,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,168,294,10
- GROUPBOX "If incoming files already exist",IDC_STATIC,0,187,313,41
- CONTROL "Ask me",IDC_ASK,"Button",BS_AUTORADIOBUTTON,8,200,73,10
- CONTROL "Resume",IDC_RESUME,"Button",BS_AUTORADIOBUTTON,82,200,125,10
- CONTROL "Overwrite",IDC_OVERWRITE,"Button",BS_AUTORADIOBUTTON,8,212,73,10
- CONTROL "Rename (append "" (1)"", etc.)",IDC_RENAME,"Button",BS_AUTORADIOBUTTON,82,212,125,10
- LTEXT "You will always be asked about files from people not on your contact list",IDC_STATIC,212,198,90,24
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,178,294,10
+ GROUPBOX "If incoming files already exist",IDC_STATIC,0,197,313,41
+ CONTROL "Ask me",IDC_ASK,"Button",BS_AUTORADIOBUTTON,8,210,73,10
+ CONTROL "Resume",IDC_RESUME,"Button",BS_AUTORADIOBUTTON,82,210,125,10
+ CONTROL "Overwrite",IDC_OVERWRITE,"Button",BS_AUTORADIOBUTTON,8,222,73,10
+ CONTROL "Rename (append "" (1)"", etc.)",IDC_RENAME,"Button",BS_AUTORADIOBUTTON,82,222,125,10
+ LTEXT "You will always be asked about files from people not on your contact list",IDC_STATIC,212,208,90,24
END
-#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
@@ -260,28 +261,56 @@ BEGIN
END
#endif // APSTUDIO_INVOKED
+
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
-1 TEXTINCLUDE
+1 TEXTINCLUDE
BEGIN
- "..\..\mir_app\src\resource.h\0"
+ "..\\..\\mir_app\\src\\resource.h\0"
END
-2 TEXTINCLUDE
+2 TEXTINCLUDE
BEGIN
"#include <windows.h>\r\n"
"#include <winres.h>\r\n"
"\0"
END
-3 TEXTINCLUDE
+3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// AFX_DIALOG_LAYOUT
+//
+
+IDD_OPT_FILETRANSFER AFX_DIALOG_LAYOUT
+BEGIN
+ 0
+END
+
+#endif // English (United States) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/src/core/stdfile/src/file.cpp b/src/core/stdfile/src/file.cpp
index 3f4c528a84..67b62ab6e0 100644
--- a/src/core/stdfile/src/file.cpp
+++ b/src/core/stdfile/src/file.cpp
@@ -101,7 +101,7 @@ void PushFileEvent(MCONTACT hContact, MEVENT hdbe, LPARAM lParam)
cle.hContact = hContact;
cle.hDbEvent = hdbe;
cle.lParam = lParam;
- if (g_plugin.getByte("AutoAccept", 0) && Contact_OnList(hContact)) {
+ if (g_plugin.bAutoAccept && Contact_OnList(hContact)) {
CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_FILERECV), NULL, DlgProcRecvFile, (LPARAM)&cle);
}
else {
diff --git a/src/core/stdfile/src/fileopts.cpp b/src/core/stdfile/src/fileopts.cpp
index 3911361721..970899a4a0 100644
--- a/src/core/stdfile/src/fileopts.cpp
+++ b/src/core/stdfile/src/fileopts.cpp
@@ -29,12 +29,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define VSCAN_NORTON 3
#define VSCAN_CA 4
-struct virusscannerinfo {
+struct {
const wchar_t *szProductName;
const wchar_t *szExeRegPath;
const wchar_t *szExeRegValue;
const wchar_t *szCommandLine;
-} virusScanners[] = {
+}
+static virusScanners[] =
+{
{L"Network Associates/McAfee VirusScan", L"SOFTWARE\\McAfee\\VirusScan", L"Scan32EXE", L"\"%s\" %%f /nosplash /comp /autoscan /autoexit /noboot"},
{L"Dr Solomon's VirusScan (Network Associates)", L"SOFTWARE\\Network Associates\\TVD\\VirusScan\\AVConsol\\General", L"szScannerExe", L"\"%s\" %%f /uinone /noboot /comp /prompt /autoexit"},
{L"Norton AntiVirus", L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Navw32.exe", nullptr, L"\"%s\" %%f /b- /m- /s+ /noresults"},
@@ -47,189 +49,192 @@ struct virusscannerinfo {
{L"ESET NOD32 Antivirus", L"SOFTWARE\\ESET\\ESET Security\\CurrentVersion\\Info", L"InstallDir", L"\"%secls.exe\" /log-all /aind /no-boots /adware /sfx /unsafe /unwanted /heur /adv-heur /action = clean \"%%f\""},
};
-#define M_UPDATEENABLING (WM_USER+100)
-#define M_SCANCMDLINESELCHANGE (WM_USER+101)
-
#ifndef SHACF_FILESYS_DIRS
#define SHACF_FILESYS_DIRS 0x00000020
#endif
-static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+class CFileOptsDlg : public CDlgBase
{
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- {
- SHAutoComplete(GetDlgItem(hwndDlg, IDC_FILEDIR), SHACF_FILESYS_DIRS);
-
- wchar_t str[MAX_PATH];
- GetContactReceivedFilesDir(NULL, str, _countof(str), FALSE);
- SetDlgItemText(hwndDlg, IDC_FILEDIR, str);
-
- CheckDlgButton(hwndDlg, IDC_AUTOACCEPT, g_plugin.getByte("AutoAccept", 0) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_AUTOMIN, g_plugin.getByte("AutoMin", 0) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_AUTOCLOSE, g_plugin.getByte("AutoClose", 0) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_AUTOCLEAR, g_plugin.getByte("AutoClear", 1) ? BST_CHECKED : BST_UNCHECKED);
- switch (g_plugin.getByte("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, g_plugin.getByte("WarnBeforeOpening", 1) ? BST_CHECKED : BST_UNCHECKED);
-
- for (int i = 0; i < _countof(virusScanners); i++) {
- wchar_t szScanExe[MAX_PATH];
- if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE, virusScanners[i].szExeRegPath, virusScanners[i].szExeRegValue, szScanExe, _countof(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)L"");
- SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_SETITEMDATA, iItem, (LPARAM)-1);
- }
+ CCtrlButton btnFileDir, btnScanCmdLine;
+ CCtrlCheck chkAutoMin, chkAutoClear, chkAutoClose, chkAutoAccept, chkReverseOrder, chkNoScanner;
+ CCtrlCombo cmbScanCmdLine;
+
+public:
+ CFileOptsDlg() :
+ CDlgBase(g_plugin, IDD_OPT_FILETRANSFER),
+ btnFileDir(this, IDC_FILEDIRBROWSE),
+ btnScanCmdLine(this, IDC_SCANCMDLINEBROWSE),
+ chkAutoMin(this, IDC_AUTOMIN),
+ chkAutoClear(this, IDC_AUTOCLEAR),
+ chkAutoClose(this, IDC_AUTOCLOSE),
+ chkNoScanner(this, IDC_NOSCANNER),
+ chkAutoAccept(this, IDC_AUTOACCEPT),
+ chkReverseOrder(this, IDC_REVERSE_ORDER),
+ cmbScanCmdLine(this, IDC_SCANCMDLINE)
+ {
+ CreateLink(chkAutoMin, g_plugin.bAutoMin);
+ CreateLink(chkAutoClear, g_plugin.bAutoClear);
+ CreateLink(chkAutoClose, g_plugin.bAutoClose);
+ CreateLink(chkAutoAccept, g_plugin.bAutoAccept);
+ CreateLink(chkReverseOrder, g_plugin.bReverseOrder);
+
+ btnFileDir.OnClick = Callback(this, &CFileOptsDlg::onClick_FileDir);
+ btnScanCmdLine.OnClick = Callback(this, &CFileOptsDlg::onClick_ScanCmdLine);
+
+ chkNoScanner.OnChange = Callback(this, &CFileOptsDlg::onChange_NoScanner);
+ chkAutoAccept.OnChange = Callback(this, &CFileOptsDlg::onChange_AutoAccept);
+ cmbScanCmdLine.OnSelChanged = Callback(this, &CFileOptsDlg::onSelChanged_Combo);
+ }
- DBVARIANT dbv;
- if (g_plugin.getWString("ScanCmdLine", &dbv) == 0) {
- SetDlgItemText(hwndDlg, IDC_SCANCMDLINE, dbv.pwszVal);
- 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);
- }
+ bool OnInitDialog() override
+ {
+ SHAutoComplete(GetDlgItem(m_hwnd, IDC_FILEDIR), SHACF_FILESYS_DIRS);
+
+ wchar_t str[MAX_PATH];
+ GetContactReceivedFilesDir(NULL, str, _countof(str), FALSE);
+ SetDlgItemText(m_hwnd, IDC_FILEDIR, str);
- switch (g_plugin.getByte("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;
+ switch (g_plugin.getByte("UseScanner", VIRUSSCAN_DISABLE)) {
+ case VIRUSSCAN_AFTERDL: CheckDlgButton(m_hwnd, IDC_SCANAFTERDL, BST_CHECKED); break;
+ case VIRUSSCAN_DURINGDL: CheckDlgButton(m_hwnd, IDC_SCANDURINGDL, BST_CHECKED); break;
+ default: CheckDlgButton(m_hwnd, IDC_NOSCANNER, BST_CHECKED); break;
+ }
+ CheckDlgButton(m_hwnd, IDC_WARNBEFOREOPENING, g_plugin.getByte("WarnBeforeOpening", 1) ? BST_CHECKED : BST_UNCHECKED);
+
+ for (int i = 0; i < _countof(virusScanners); i++) {
+ wchar_t szScanExe[MAX_PATH];
+ if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE, virusScanners[i].szExeRegPath, virusScanners[i].szExeRegValue, szScanExe, _countof(szScanExe))) {
+ int iItem = SendDlgItemMessage(m_hwnd, IDC_SCANCMDLINE, CB_ADDSTRING, 0, (LPARAM)virusScanners[i].szProductName);
+ SendDlgItemMessage(m_hwnd, IDC_SCANCMDLINE, CB_SETITEMDATA, iItem, i);
}
- SendMessage(hwndDlg, M_UPDATEENABLING, 0, 0);
}
- return TRUE;
+ if (SendDlgItemMessageA(m_hwnd, IDC_SCANCMDLINE, CB_GETCOUNT, 0, 0) == 0) {
+ int iItem = SendDlgItemMessage(m_hwnd, IDC_SCANCMDLINE, CB_ADDSTRING, 0, (LPARAM)L"");
+ SendDlgItemMessage(m_hwnd, IDC_SCANCMDLINE, CB_SETITEMDATA, iItem, (LPARAM)-1);
+ }
- case M_UPDATEENABLING:
- {
- int on = BST_UNCHECKED == 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));
+ DBVARIANT dbv;
+ if (g_plugin.getWString("ScanCmdLine", &dbv) == 0) {
+ SetDlgItemText(m_hwnd, IDC_SCANCMDLINE, dbv.pwszVal);
+ db_free(&dbv);
}
- break;
- case M_SCANCMDLINESELCHANGE:
- {
- wchar_t str[512];
- wchar_t szScanExe[MAX_PATH];
- int iScanner = SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETCURSEL, 0, 0), 0);
- if (iScanner >= _countof(virusScanners) || iScanner < 0) break;
- str[0] = '\0';
- if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE, virusScanners[iScanner].szExeRegPath, virusScanners[iScanner].szExeRegValue, szScanExe, _countof(szScanExe)))
- mir_snwprintf(str, virusScanners[iScanner].szCommandLine, szScanExe);
- SetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str);
+ else if (SendDlgItemMessage(m_hwnd, IDC_SCANCMDLINE, CB_GETCOUNT, 0, 0)) {
+ SendDlgItemMessage(m_hwnd, IDC_SCANCMDLINE, CB_SETCURSEL, 0, 0);
+ onSelChanged_Combo(0);
}
- break;
-
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDC_FILEDIR:
- if ((HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0;
- break;
-
- case IDC_FILEDIRBROWSE:
- {
- wchar_t str[MAX_PATH];
- GetDlgItemText(hwndDlg, IDC_FILEDIR, str, _countof(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:
- wchar_t str[MAX_PATH + 2];
- GetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str, _countof(str));
-
- CMStringW tszFilter;
- tszFilter.AppendFormat(L"%s (*.exe)%c*.exe%c", TranslateT("Executable files"), 0, 0);
- tszFilter.AppendFormat(L"%s (*)%c*%c", TranslateT("All files"), 0, 0);
-
- OPENFILENAME ofn = { 0 };
- ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
- ofn.hwndOwner = hwndDlg;
- ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_DONTADDTORECENT;
- ofn.lpstrFilter = tszFilter;
- ofn.lpstrFile = str;
- ofn.nMaxFile = _countof(str) - 2;
- if (str[0] == '"') {
- wchar_t *pszQuote = wcschr(str + 1, '"');
- if (pszQuote)
- *pszQuote = 0;
- memmove(str, str + 1, (mir_wstrlen(str) * sizeof(wchar_t)));
- }
- else {
- wchar_t *pszSpace = wcschr(str, ' ');
- if (pszSpace) *pszSpace = 0;
- }
- ofn.nMaxFileTitle = MAX_PATH;
- if (!GetOpenFileName(&ofn)) break;
- if (wcschr(str, ' ') != nullptr) {
- memmove(str + 1, str, ((_countof(str) - 2) * sizeof(wchar_t)));
- str[0] = '"';
- mir_wstrcat(str, L"\"");
- }
- SetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str);
- break;
+
+ switch (g_plugin.getByte("IfExists", FILERESUME_ASK)) {
+ case FILERESUME_RESUMEALL: CheckDlgButton(m_hwnd, IDC_RESUME, BST_CHECKED); break;
+ case FILERESUME_OVERWRITEALL: CheckDlgButton(m_hwnd, IDC_OVERWRITE, BST_CHECKED); break;
+ case FILERESUME_RENAMEALL: CheckDlgButton(m_hwnd, IDC_RENAME, BST_CHECKED); break;
+ default: CheckDlgButton(m_hwnd, IDC_ASK, BST_CHECKED); break;
}
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
-
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->code) {
- case PSN_APPLY:
- wchar_t str[512];
- GetDlgItemText(hwndDlg, IDC_FILEDIR, str, _countof(str));
- RemoveInvalidPathChars(str);
- g_plugin.setWString("RecvFilesDirAdv", str);
- g_plugin.setByte("AutoAccept", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOACCEPT));
- g_plugin.setByte("AutoMin", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOMIN));
- g_plugin.setByte("AutoClose", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOCLOSE));
- g_plugin.setByte("AutoClear", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOCLEAR));
- g_plugin.setByte("UseScanner", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_SCANAFTERDL) ? VIRUSSCAN_AFTERDL : (IsDlgButtonChecked(hwndDlg, IDC_SCANDURINGDL) ? VIRUSSCAN_DURINGDL : VIRUSSCAN_DISABLE)));
- GetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str, _countof(str));
- g_plugin.setWString("ScanCmdLine", str);
- g_plugin.setByte("WarnBeforeOpening", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_WARNBEFOREOPENING));
- g_plugin.setByte("IfExists", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_ASK) ? FILERESUME_ASK : (IsDlgButtonChecked(hwndDlg, IDC_RESUME) ? FILERESUME_RESUMEALL : (IsDlgButtonChecked(hwndDlg, IDC_OVERWRITE) ? FILERESUME_OVERWRITEALL : FILERESUME_RENAMEALL))));
- return TRUE;
+
+ onChange_NoScanner(0);
+ onChange_AutoAccept(0);
+ return true;
+ }
+
+ bool OnApply() override
+ {
+ wchar_t str[512];
+ GetDlgItemText(m_hwnd, IDC_FILEDIR, str, _countof(str));
+ RemoveInvalidPathChars(str);
+ g_plugin.setWString("RecvFilesDirAdv", str);
+
+ GetDlgItemText(m_hwnd, IDC_SCANCMDLINE, str, _countof(str));
+ g_plugin.setWString("ScanCmdLine", str);
+
+ g_plugin.setByte("UseScanner", (BYTE)(IsDlgButtonChecked(m_hwnd, IDC_SCANAFTERDL) ? VIRUSSCAN_AFTERDL : (IsDlgButtonChecked(m_hwnd, IDC_SCANDURINGDL) ? VIRUSSCAN_DURINGDL : VIRUSSCAN_DISABLE)));
+ g_plugin.setByte("WarnBeforeOpening", (BYTE)IsDlgButtonChecked(m_hwnd, IDC_WARNBEFOREOPENING));
+ g_plugin.setByte("IfExists", (BYTE)(IsDlgButtonChecked(m_hwnd, IDC_ASK) ? FILERESUME_ASK :
+ (IsDlgButtonChecked(m_hwnd, IDC_RESUME) ? FILERESUME_RESUMEALL :
+ (IsDlgButtonChecked(m_hwnd, IDC_OVERWRITE) ? FILERESUME_OVERWRITEALL : FILERESUME_RENAMEALL))));
+ return TRUE;
+ }
+
+ void onChange_AutoAccept(CCtrlCheck *)
+ {
+ chkAutoMin.Enable(chkAutoAccept.GetState());
+ }
+
+ void onChange_NoScanner(CCtrlCheck *)
+ {
+ bool bEnabled = chkNoScanner.GetState();
+ btnScanCmdLine.Enable(bEnabled);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_ST_CMDLINE), bEnabled);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_SCANCMDLINE), bEnabled);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_ST_CMDLINEHELP), bEnabled);
+ }
+
+ void onSelChanged_Combo(CCtrlCombo*)
+ {
+ int iScanner = SendDlgItemMessage(m_hwnd, IDC_SCANCMDLINE, CB_GETITEMDATA, SendDlgItemMessage(m_hwnd, IDC_SCANCMDLINE, CB_GETCURSEL, 0, 0), 0);
+ if (iScanner >= _countof(virusScanners) || iScanner < 0)
+ return;
+
+ wchar_t szScanExe[MAX_PATH], str[512];
+ if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE, virusScanners[iScanner].szExeRegPath, virusScanners[iScanner].szExeRegValue, szScanExe, _countof(szScanExe)))
+ mir_snwprintf(str, virusScanners[iScanner].szCommandLine, szScanExe);
+ else
+ str[0] = 0;
+ SetDlgItemText(m_hwnd, IDC_SCANCMDLINE, str);
+ }
+
+ void onClick_FileDir(CCtrlButton*)
+ {
+ wchar_t str[MAX_PATH];
+ GetDlgItemText(m_hwnd, IDC_FILEDIR, str, _countof(str));
+ if (BrowseForFolder(m_hwnd, str))
+ SetDlgItemText(m_hwnd, IDC_FILEDIR, str);
+ }
+
+ void onClick_ScanCmdLine(CCtrlButton*)
+ {
+ wchar_t str[MAX_PATH + 2];
+ GetDlgItemText(m_hwnd, IDC_SCANCMDLINE, str, _countof(str));
+
+ CMStringW tszFilter;
+ tszFilter.AppendFormat(L"%s (*.exe)%c*.exe%c", TranslateT("Executable files"), 0, 0);
+ tszFilter.AppendFormat(L"%s (*)%c*%c", TranslateT("All files"), 0, 0);
+
+ OPENFILENAME ofn = { 0 };
+ ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
+ ofn.hwndOwner = m_hwnd;
+ ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_DONTADDTORECENT;
+ ofn.lpstrFilter = tszFilter;
+ ofn.lpstrFile = str;
+ ofn.nMaxFile = _countof(str) - 2;
+ if (str[0] == '"') {
+ wchar_t *pszQuote = wcschr(str + 1, '"');
+ if (pszQuote)
+ *pszQuote = 0;
+ memmove(str, str + 1, (mir_wstrlen(str) * sizeof(wchar_t)));
}
- break;
+ else {
+ wchar_t *pszSpace = wcschr(str, ' ');
+ if (pszSpace) *pszSpace = 0;
+ }
+ ofn.nMaxFileTitle = MAX_PATH;
+ if (!GetOpenFileName(&ofn))
+ return;
+
+ if (wcschr(str, ' ') != nullptr) {
+ memmove(str + 1, str, ((_countof(str) - 2) * sizeof(wchar_t)));
+ str[0] = '"';
+ mir_wstrcat(str, L"\"");
+ }
+ SetDlgItemText(m_hwnd, IDC_SCANCMDLINE, str);
}
- return FALSE;
-}
+};
int FileOptInitialise(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = {};
odp.position = 900000000;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_FILETRANSFER);
odp.szTitle.a = LPGEN("File transfers");
odp.szGroup.a = LPGEN("Events");
- odp.pfnDlgProc = DlgProcFileOpts;
+ odp.pDialog = new CFileOptsDlg();
odp.flags = ODPF_BOLDGROUPS;
g_plugin.addOptions(wParam, &odp);
return 0;
diff --git a/src/core/stdfile/src/filerecvdlg.cpp b/src/core/stdfile/src/filerecvdlg.cpp
index d2327aaa4a..622ca6525c 100644
--- a/src/core/stdfile/src/filerecvdlg.cpp
+++ b/src/core/stdfile/src/filerecvdlg.cpp
@@ -257,7 +257,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
GetWindowRect(GetDlgItem(hwndDlg, IDC_DATE), &rcDateCtrl);
SetWindowPos(GetDlgItem(hwndDlg, IDC_DATE), 0, 0, 0, rcDateCtrl.right - rcDateCtrl.left - (rcBtn2.left - rcBtn1.left), rcDateCtrl.bottom - rcDateCtrl.top, SWP_NOZORDER | SWP_NOMOVE);
}
- else if (g_plugin.getByte("AutoAccept", 0)) {
+ else if (g_plugin.bAutoAccept) {
//don't check auto-min here to fix BUG#647620
PostMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDOK, BN_CLICKED), (LPARAM)GetDlgItem(hwndDlg, IDOK));
}
@@ -332,7 +332,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
dat->hwndTransfer = FtMgr_AddTransfer(dat);
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
//check for auto-minimize here to fix BUG#647620
- if (g_plugin.getByte("AutoAccept", 0) && g_plugin.getByte("AutoMin", 0)) {
+ if (g_plugin.bAutoAccept && g_plugin.bAutoMin) {
ShowWindow(hwndDlg, SW_HIDE);
ShowWindow(hwndDlg, SW_SHOWMINNOACTIVE);
}
diff --git a/src/core/stdfile/src/filexferdlg.cpp b/src/core/stdfile/src/filexferdlg.cpp
index c652c6b480..25848bbc7b 100644
--- a/src/core/stdfile/src/filexferdlg.cpp
+++ b/src/core/stdfile/src/filexferdlg.cpp
@@ -309,31 +309,29 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
if (dat->bytesRecvedHistorySize < _countof(dat->bytesRecvedHistory))
dat->bytesRecvedHistorySize++;
- {
- wchar_t szSpeed[32], szTime[32], szDisplay[96];
- SYSTEMTIME st;
- ULARGE_INTEGER li;
- FILETIME ft;
-
- GetSensiblyFormattedSize((dat->bytesRecvedHistory[0] - dat->bytesRecvedHistory[dat->bytesRecvedHistorySize - 1]) / dat->bytesRecvedHistorySize, szSpeed, _countof(szSpeed), 0, 1, NULL);
- if (dat->bytesRecvedHistory[0] == dat->bytesRecvedHistory[dat->bytesRecvedHistorySize - 1])
- mir_wstrcpy(szTime, L"??:??:??");
- else {
- li.QuadPart = BIGI(10000000)*(dat->transferStatus.currentFileSize - dat->transferStatus.currentFileProgress)*dat->bytesRecvedHistorySize / (dat->bytesRecvedHistory[0] - dat->bytesRecvedHistory[dat->bytesRecvedHistorySize - 1]);
- ft.dwHighDateTime = li.HighPart; ft.dwLowDateTime = li.LowPart;
- FileTimeToSystemTime(&ft, &st);
- GetTimeFormat(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER, &st, NULL, szTime, _countof(szTime));
- }
- if (dat->bytesRecvedHistory[0] != dat->bytesRecvedHistory[dat->bytesRecvedHistorySize - 1]) {
- li.QuadPart = BIGI(10000000)*(dat->transferStatus.totalBytes - dat->transferStatus.totalProgress)*dat->bytesRecvedHistorySize / (dat->bytesRecvedHistory[0] - dat->bytesRecvedHistory[dat->bytesRecvedHistorySize - 1]);
- ft.dwHighDateTime = li.HighPart; ft.dwLowDateTime = li.LowPart;
- FileTimeToSystemTime(&ft, &st);
- GetTimeFormat(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER, &st, NULL, szTime, _countof(szTime));
- }
-
- mir_snwprintf(szDisplay, L"%s/%s (%s %s)", szSpeed, TranslateT("sec"), szTime, TranslateT("remaining"));
- SetDlgItemText(hwndDlg, IDC_ALLSPEED, szDisplay);
+ wchar_t szSpeed[32], szTime[32], szDisplay[96];
+ SYSTEMTIME st;
+ ULARGE_INTEGER li;
+ FILETIME ft;
+
+ GetSensiblyFormattedSize((dat->bytesRecvedHistory[0] - dat->bytesRecvedHistory[dat->bytesRecvedHistorySize - 1]) / dat->bytesRecvedHistorySize, szSpeed, _countof(szSpeed), 0, 1, NULL);
+ if (dat->bytesRecvedHistory[0] == dat->bytesRecvedHistory[dat->bytesRecvedHistorySize - 1])
+ mir_wstrcpy(szTime, L"??:??:??");
+ else {
+ li.QuadPart = BIGI(10000000)*(dat->transferStatus.currentFileSize - dat->transferStatus.currentFileProgress)*dat->bytesRecvedHistorySize / (dat->bytesRecvedHistory[0] - dat->bytesRecvedHistory[dat->bytesRecvedHistorySize - 1]);
+ ft.dwHighDateTime = li.HighPart; ft.dwLowDateTime = li.LowPart;
+ FileTimeToSystemTime(&ft, &st);
+ GetTimeFormat(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER, &st, NULL, szTime, _countof(szTime));
+ }
+ if (dat->bytesRecvedHistory[0] != dat->bytesRecvedHistory[dat->bytesRecvedHistorySize - 1]) {
+ li.QuadPart = BIGI(10000000)*(dat->transferStatus.totalBytes - dat->transferStatus.totalProgress)*dat->bytesRecvedHistorySize / (dat->bytesRecvedHistory[0] - dat->bytesRecvedHistory[dat->bytesRecvedHistorySize - 1]);
+ ft.dwHighDateTime = li.HighPart; ft.dwLowDateTime = li.LowPart;
+ FileTimeToSystemTime(&ft, &st);
+ GetTimeFormat(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER, &st, NULL, szTime, _countof(szTime));
}
+
+ mir_snwprintf(szDisplay, L"%s/%s (%s %s)", szSpeed, TranslateT("sec"), szTime, TranslateT("remaining"));
+ SetDlgItemText(hwndDlg, IDC_ALLSPEED, szDisplay);
break;
case WM_MEASUREITEM:
diff --git a/src/core/stdfile/src/ftmanager.cpp b/src/core/stdfile/src/ftmanager.cpp
index 83ed1dab5a..b8bfe6a64e 100644
--- a/src/core/stdfile/src/ftmanager.cpp
+++ b/src/core/stdfile/src/ftmanager.cpp
@@ -33,7 +33,7 @@ struct TFtMgrData
HWND hwndOutgoing;
HANDLE hhkPreshutdown;
- TBPFLAG errorState;
+ TBPFLAG errorState;
};
#define M_CALCPROGRESS (WM_USER + 200)
@@ -46,25 +46,28 @@ struct TFtProgressData
struct TLayoutWindowInfo
{
+ TLayoutWindowInfo(HWND _hwnd) :
+ hwnd(_hwnd)
+ {
+ ::GetWindowRect(_hwnd, &rc);
+ }
+
HWND hwnd;
RECT rc;
};
-struct TLayoutWindowList
-{
- struct TLayoutWindowInfo **items;
- int realCount, limit, increment;
- FSortFunc sortFunc;
-};
-
struct TFtPageData
{
- struct TLayoutWindowList *wnds;
- int runningCount;
- int height, dataHeight, scrollPos;
+ TFtPageData() :
+ arWindows(1)
+ {}
+
+ OBJLIST<TLayoutWindowInfo> arWindows;
+ int runningCount = 0;
+ int height = 0, dataHeight = 0, scrollPos = 0;
};
-static void LayoutTransfers(HWND hwnd, struct TFtPageData *dat)
+static void LayoutTransfers(HWND hwnd, TFtPageData *dat)
{
int top = 0;
RECT rc;
@@ -73,13 +76,13 @@ static void LayoutTransfers(HWND hwnd, struct TFtPageData *dat)
dat->scrollPos = GetScrollPos(hwnd, SB_VERT);
dat->height = rc.bottom - rc.top;
- if (dat->wnds->realCount) {
- HDWP hdwp = BeginDeferWindowPos(dat->wnds->realCount);
+ if (dat->arWindows.getCount()) {
+ HDWP hdwp = BeginDeferWindowPos(dat->arWindows.getCount());
top -= dat->scrollPos;
- for (int i = 0; i < dat->wnds->realCount; ++i) {
- int height = dat->wnds->items[i]->rc.bottom - dat->wnds->items[i]->rc.top;
- if (nullptr != dat->wnds->items[i]->hwnd) /* Wine fix. */
- hdwp = DeferWindowPos(hdwp, dat->wnds->items[i]->hwnd, nullptr, 0, top, rc.right, height, SWP_NOZORDER);
+ for (auto &it : dat->arWindows) {
+ int height = it->rc.bottom - it->rc.top;
+ if (nullptr != it->hwnd) /* Wine fix. */
+ hdwp = DeferWindowPos(hdwp, it->hwnd, nullptr, 0, top, rc.right, height, SWP_NOZORDER);
top += height;
}
top += dat->scrollPos;
@@ -99,32 +102,29 @@ static void LayoutTransfers(HWND hwnd, struct TFtPageData *dat)
static INT_PTR CALLBACK FtMgrPageDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- struct TFtPageData *dat = (struct TFtPageData *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- int i;
+ TFtPageData *dat = (TFtPageData *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
switch (msg) {
case WM_INITDIALOG:
{
// Force scrollbar visibility
- SCROLLINFO si = {0};
+ SCROLLINFO si = {};
si.cbSize = sizeof(si);
si.fMask = SIF_DISABLENOSCROLL;
SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
- dat = (struct TFtPageData *)mir_alloc(sizeof(struct TFtPageData));
- dat->wnds = (struct TLayoutWindowList *)List_Create(0, 1);
- dat->scrollPos = 0;
- dat->runningCount = 0;
+ dat = new TFtPageData();
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)dat);
}
break;
case WM_FT_ADD:
{
- TLayoutWindowInfo *wnd = (struct TLayoutWindowInfo *)mir_alloc(sizeof(struct TLayoutWindowInfo));
- wnd->hwnd = (HWND)lParam;
- GetWindowRect(wnd->hwnd, &wnd->rc);
- List_Insert((SortedList *)dat->wnds, wnd, dat->wnds->realCount);
+ TLayoutWindowInfo *wnd = new TLayoutWindowInfo((HWND)lParam);
+ if (g_plugin.bReverseOrder)
+ dat->arWindows.insert(wnd, 0);
+ else
+ dat->arWindows.insert(wnd);
LayoutTransfers(hwnd, dat);
dat->runningCount++;
PostMessage(GetParent(hwnd), WM_TIMER, 1, NULL);
@@ -132,19 +132,18 @@ static INT_PTR CALLBACK FtMgrPageDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPA
break;
case WM_FT_RESIZE:
- for (i=0; i < dat->wnds->realCount; ++i)
- if (dat->wnds->items[i]->hwnd == (HWND)lParam) {
- GetWindowRect(dat->wnds->items[i]->hwnd, &dat->wnds->items[i]->rc);
+ for (auto &it : dat->arWindows)
+ if (it->hwnd == (HWND)lParam) {
+ GetWindowRect(it->hwnd, &it->rc);
break;
}
LayoutTransfers(hwnd, dat);
break;
case WM_FT_REMOVE:
- for (i=0; i < dat->wnds->realCount; ++i)
- if (dat->wnds->items[i]->hwnd == (HWND)lParam) {
- mir_free(dat->wnds->items[i]);
- List_Remove((SortedList *)dat->wnds, i);
+ for (auto &it : dat->arWindows)
+ if (it->hwnd == (HWND)lParam) {
+ dat->arWindows.remove(dat->arWindows.indexOf(&it));
break;
}
LayoutTransfers(hwnd, dat);
@@ -153,23 +152,27 @@ static INT_PTR CALLBACK FtMgrPageDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPA
case WM_FT_COMPLETED:
//wParam: { ACKRESULT_SUCCESS | ACKRESULT_FAILED | ACKRESULT_DENIED }
dat->runningCount--;
- for (i=0; i < dat->wnds->realCount; i++) {
- // no error when canceling (WM_FT_REMOVE is send first, check if hwnd is still registered)
- if (dat->wnds->items[i]->hwnd == (HWND)lParam) {
- SendMessage(GetParent(hwnd), WM_TIMER, 1, (LPARAM)wParam);
- break;
- }
+ {
+ bool bFound = false;
+ for (auto &it : dat->arWindows)
+ // no error when canceling (WM_FT_REMOVE is send first, check if hwnd is still registered)
+ if (it->hwnd == (HWND)lParam) {
+ bFound = true;
+ SendMessage(GetParent(hwnd), WM_TIMER, 1, (LPARAM)wParam);
+ break;
+ }
+
+ if (!bFound)
+ PostMessage(GetParent(hwnd), WM_TIMER, 1, NULL);
}
- if (i == dat->wnds->realCount)
- PostMessage(GetParent(hwnd), WM_TIMER, 1, NULL);
- if(dat->runningCount == 0 && wParam == ACKRESULT_SUCCESS && g_plugin.getByte("AutoClose", 0))
+ if(dat->runningCount == 0 && wParam == ACKRESULT_SUCCESS && g_plugin.bAutoClose)
ShowWindow(hwndFtMgr, SW_HIDE);
break;
case WM_FT_CLEANUP:
- for (i=0; i < dat->wnds->realCount; ++i)
- SendMessage(dat->wnds->items[i]->hwnd, WM_FT_CLEANUP, wParam, lParam);
+ for (auto &it : dat->arWindows)
+ SendMessage(it->hwnd, WM_FT_CLEANUP, wParam, lParam);
break;
case WM_SIZE:
@@ -177,19 +180,16 @@ static INT_PTR CALLBACK FtMgrPageDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPA
break;
case WM_MOUSEWHEEL:
- {
- short zDelta = GET_WHEEL_DELTA_WPARAM(wParam);
- if (zDelta) {
- int nScrollLines = 0;
- SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, (void*)&nScrollLines, 0);
- for (i=0; i < (nScrollLines + 1) / 2; i++)
- SendMessage(hwnd, WM_VSCROLL, (zDelta < 0) ? SB_LINEDOWN : SB_LINEUP, 0);
- }
-
- SetWindowLongPtr(hwnd, DWLP_MSGRESULT, 0);
- return TRUE;
+ if (int zDelta = GET_WHEEL_DELTA_WPARAM(wParam)) {
+ int nScrollLines = 0;
+ SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &nScrollLines, 0);
+ for (int i=0; i < (nScrollLines + 1) / 2; i++)
+ SendMessage(hwnd, WM_VSCROLL, (zDelta < 0) ? SB_LINEDOWN : SB_LINEUP, 0);
}
+ SetWindowLongPtr(hwnd, DWLP_MSGRESULT, 0);
+ return TRUE;
+
case WM_VSCROLL:
{
int pos = dat->scrollPos;
@@ -211,27 +211,29 @@ static INT_PTR CALLBACK FtMgrPageDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPA
break;
}
- if (pos > dat->dataHeight - dat->height) pos = dat->dataHeight - dat->height;
- if (pos < 0) pos = 0;
+ if (pos > dat->dataHeight - dat->height)
+ pos = dat->dataHeight - dat->height;
+ if (pos < 0)
+ pos = 0;
if (dat->scrollPos != pos) {
ScrollWindow(hwnd, 0, dat->scrollPos - pos, nullptr, nullptr);
SetScrollPos(hwnd, SB_VERT, pos, TRUE);
dat->scrollPos = pos;
}
- break;
}
+ break;
case M_PRESHUTDOWN:
- for (i=0; i < dat->wnds->realCount; ++i)
- PostMessage(dat->wnds->items[i]->hwnd, WM_COMMAND, MAKEWPARAM(IDCANCEL, BN_CLICKED), 0);
+ for (auto &it : dat->arWindows)
+ PostMessage(it->hwnd, WM_COMMAND, MAKEWPARAM(IDCANCEL, BN_CLICKED), 0);
break;
case M_CALCPROGRESS:
{
TFtProgressData *prg = (TFtProgressData *)wParam;
- for (i=0; i < dat->wnds->realCount; ++i) {
- FileDlgData *trdat = (FileDlgData *)GetWindowLongPtr(dat->wnds->items[i]->hwnd, GWLP_USERDATA);
+ for (auto &it : dat->arWindows) {
+ FileDlgData *trdat = (FileDlgData *)GetWindowLongPtr(it->hwnd, GWLP_USERDATA);
if (trdat->transferStatus.totalBytes && trdat->fs && !trdat->send && (trdat->transferStatus.totalBytes == trdat->transferStatus.totalProgress))
prg->scan++;
else if (trdat->transferStatus.totalBytes && trdat->fs) { // in progress
@@ -246,11 +248,7 @@ static INT_PTR CALLBACK FtMgrPageDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPA
break;
case WM_DESTROY:
- for (i=0; i < dat->wnds->realCount; ++i)
- mir_free(dat->wnds->items[i]);
- List_Destroy((SortedList *)dat->wnds);
- mir_free(dat->wnds);
- mir_free(dat);
+ delete dat;
break;
}
@@ -260,13 +258,11 @@ static INT_PTR CALLBACK FtMgrPageDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPA
static INT_PTR CALLBACK FtMgrDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
struct TFtMgrData *dat = (struct TFtMgrData *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ HWND hwndTab = GetDlgItem(hwnd, IDC_TABS);
switch (msg) {
case WM_INITDIALOG:
{
- TCITEM tci = {0};
- HWND hwndTab = GetDlgItem(hwnd, IDC_TABS);
-
TranslateDialogDefault(hwnd);
Window_SetSkinIcon_IcoLib(hwnd, SKINICON_EVENT_FILE);
@@ -280,6 +276,7 @@ static INT_PTR CALLBACK FtMgrDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
dat->hwndOutgoing = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_FTPAGE), hwnd, FtMgrPageDlgProc);
ShowWindow(dat->hwndIncoming, SW_SHOW);
+ TCITEM tci = {};
tci.mask = TCIF_PARAM|TCIF_TEXT;
tci.pszText = TranslateT("Incoming");
tci.lParam = (LPARAM)dat->hwndIncoming;
@@ -290,20 +287,18 @@ static INT_PTR CALLBACK FtMgrDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
Utils_RestoreWindowPosition(hwnd, NULL, MODULENAME, "FtMgrDlg_", RWPF_NOACTIVATE);
// Fall through to setup initial placement
+ __fallthrough;
}
case WM_SIZE:
{
RECT rc, rcButton;
- HDWP hdwp;
- HWND hwndTab = GetDlgItem(hwnd, IDC_TABS);
-
GetWindowRect(GetDlgItem(hwnd, IDCANCEL), &rcButton);
OffsetRect(&rcButton, -rcButton.left, -rcButton.top);
GetClientRect(hwnd, &rc);
InflateRect(&rc, -6, -6);
- hdwp = BeginDeferWindowPos(3);
+ HDWP hdwp = BeginDeferWindowPos(3);
hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDC_CLEAR), NULL, rc.left, rc.bottom-rcButton.bottom, 0, 0, SWP_NOZORDER|SWP_NOSIZE);
hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDCANCEL), nullptr, rc.right-rcButton.right, rc.bottom-rcButton.bottom, 0, 0, SWP_NOZORDER|SWP_NOSIZE);
@@ -328,29 +323,24 @@ static INT_PTR CALLBACK FtMgrDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
hdwp = DeferWindowPos(hdwp, dat->hwndOutgoing, HWND_TOP, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, 0);
EndDeferWindowPos(hdwp);
-
- break;
}
+ break;
case WM_MOUSEWHEEL:
- if (IsWindowVisible(dat->hwndIncoming)) SendMessage(dat->hwndIncoming, msg, wParam, lParam);
- if (IsWindowVisible(dat->hwndOutgoing)) SendMessage(dat->hwndOutgoing, msg, wParam, lParam);
+ if (IsWindowVisible(dat->hwndIncoming))
+ SendMessage(dat->hwndIncoming, msg, wParam, lParam);
+ if (IsWindowVisible(dat->hwndOutgoing))
+ SendMessage(dat->hwndOutgoing, msg, wParam, lParam);
break;
case WM_FT_SELECTPAGE:
- {
- TCITEM tci = {0};
- HWND hwndTab = GetDlgItem(hwnd, IDC_TABS);
-
- if (TabCtrl_GetCurSel(hwndTab) == (int)wParam) break;
-
+ if (TabCtrl_GetCurSel(hwndTab) != (int)wParam) {
+ TCITEM tci = {};
tci.mask = TCIF_PARAM;
-
TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci);
- ShowWindow((HWND)tci.lParam, SW_HIDE);
+ ShowWindow((HWND)tci.lParam, SW_HIDE);
TabCtrl_SetCurSel(hwndTab, wParam);
-
TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci);
ShowWindow((HWND)tci.lParam, SW_SHOW);
}
@@ -361,13 +351,13 @@ static INT_PTR CALLBACK FtMgrDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam;
lpmmi->ptMinTrackSize.x = 300;
lpmmi->ptMinTrackSize.y = 400;
- return 0;
}
+ return 0;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDCANCEL:
- PostMessage(hwnd, WM_CLOSE , 0, 0);
+ PostMessage(hwnd, WM_CLOSE, 0, 0);
break;
case IDC_CLEAR:
@@ -380,29 +370,21 @@ static INT_PTR CALLBACK FtMgrDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
case WM_NOTIFY:
switch (((LPNMHDR)lParam)->idFrom) {
case IDC_TABS:
- {
- HWND hwndTab = GetDlgItem(hwnd, IDC_TABS);
- switch (((LPNMHDR)lParam)->code) {
- case TCN_SELCHANGING:
- {
- TCITEM tci = {0};
- tci.mask = TCIF_PARAM;
- TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci);
- ShowWindow((HWND)tci.lParam, SW_HIDE);
- break;
- }
-
- case TCN_SELCHANGE:
- {
- TCITEM tci = {0};
- tci.mask = TCIF_PARAM;
- TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci);
- ShowWindow((HWND)tci.lParam, SW_SHOW);
- break;
- }
- }
+ TCITEM tci = {};
+ switch (((LPNMHDR)lParam)->code) {
+ case TCN_SELCHANGING:
+ tci.mask = TCIF_PARAM;
+ TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci);
+ ShowWindow((HWND)tci.lParam, SW_HIDE);
+ break;
+
+ case TCN_SELCHANGE:
+ tci.mask = TCIF_PARAM;
+ TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci);
+ ShowWindow((HWND)tci.lParam, SW_SHOW);
break;
}
+ break;
}
break;
@@ -414,7 +396,7 @@ static INT_PTR CALLBACK FtMgrDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
case WM_CLOSE:
ShowWindow(hwnd, SW_HIDE);
- if (g_plugin.getByte("AutoClear", 1)) {
+ if (g_plugin.bAutoClear) {
PostMessage(dat->hwndIncoming, WM_FT_CLEANUP, 0, 0);
PostMessage(dat->hwndOutgoing, WM_FT_CLEANUP, 0, 0);
}
@@ -436,7 +418,7 @@ static INT_PTR CALLBACK FtMgrDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
break;
case WM_SHOWWINDOW:
- if ( !wParam) { // hiding
+ if (!wParam) { // hiding
KillTimer(hwnd, 1);
break;
}
@@ -448,12 +430,12 @@ static INT_PTR CALLBACK FtMgrDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
if ((lParam == ACKRESULT_FAILED) || (lParam == ACKRESULT_DENIED))
dat->errorState = TBPF_ERROR;
- TFtProgressData prg = {0};
+ TFtProgressData prg = { 0 };
SendMessage(dat->hwndIncoming, M_CALCPROGRESS, (WPARAM)&prg, 0);
SendMessage(dat->hwndOutgoing, M_CALCPROGRESS, (WPARAM)&prg, 0);
if (dat->errorState) {
pTaskbarInterface->SetProgressState(hwnd, dat->errorState);
- if ( !prg.run)
+ if (!prg.run)
pTaskbarInterface->SetProgressValue(hwnd, 1, 1);
}
else if (prg.run)
@@ -476,8 +458,6 @@ static INT_PTR CALLBACK FtMgrDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
HWND FtMgr_Show(bool bForceActivate, bool bFromMenu)
{
- bool bAutoMin = g_plugin.getByte("AutoMin", 0) != 0; /* lqbe */
-
bool bJustCreated = (hwndFtMgr == nullptr);
if (bJustCreated)
hwndFtMgr = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_FTMGR), NULL, FtMgrDlgProc);
@@ -488,7 +468,7 @@ HWND FtMgr_Show(bool bForceActivate, bool bFromMenu)
SetForegroundWindow(hwndFtMgr);
return hwndFtMgr;
}
- if (bAutoMin && bJustCreated) { /* lqbe */
+ if (g_plugin.bAutoMin && bJustCreated) { /* lqbe */
ShowWindow(hwndFtMgr, SW_HIDE);
ShowWindow(hwndFtMgr, SW_MINIMIZE);
return hwndFtMgr;
@@ -499,10 +479,10 @@ HWND FtMgr_Show(bool bForceActivate, bool bFromMenu)
SetForegroundWindow(hwndFtMgr);
return hwndFtMgr;
}
- if ( !bJustCreated && IsWindowVisible(hwndFtMgr))
+ if (!bJustCreated && IsWindowVisible(hwndFtMgr))
return hwndFtMgr;
- ShowWindow(hwndFtMgr, bAutoMin ? SW_SHOWMINNOACTIVE : SW_SHOWNOACTIVATE);
+ ShowWindow(hwndFtMgr, g_plugin.bAutoMin ? SW_SHOWMINNOACTIVE : SW_SHOWNOACTIVATE);
return hwndFtMgr;
}
@@ -520,8 +500,8 @@ void FtMgr_ShowPage(int page)
HWND FtMgr_AddTransfer(FileDlgData *fdd)
{
- bool bForceActivate = fdd->send || !g_plugin.getByte("AutoAccept", 0);
- TFtMgrData *dat = (TFtMgrData*)GetWindowLongPtr(FtMgr_Show(bForceActivate, false), GWLP_USERDATA);
+ bool bForceActivate = fdd->send || !g_plugin.bAutoAccept;
+ TFtMgrData *dat = (TFtMgrData *)GetWindowLongPtr(FtMgr_Show(bForceActivate, false), GWLP_USERDATA);
if (dat == nullptr)
return nullptr;
diff --git a/src/core/stdfile/src/main.cpp b/src/core/stdfile/src/main.cpp
index bbdc8a6be4..197ad45ba9 100644
--- a/src/core/stdfile/src/main.cpp
+++ b/src/core/stdfile/src/main.cpp
@@ -43,8 +43,14 @@ PLUGININFOEX pluginInfoEx = {
};
CMPlugin::CMPlugin() :
- PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
-{}
+ PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx),
+ bAutoMin(MODULENAME, "AutoMin", false),
+ bAutoClear(MODULENAME, "AutoClear", true),
+ bAutoClose(MODULENAME, "AutoClose", false),
+ bAutoAccept(MODULENAME, "AutoAccept", false),
+ bReverseOrder(MODULENAME, "ReverseOrder", false)
+{
+}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/stdfile/src/stdafx.h b/src/core/stdfile/src/stdafx.h
index 3c3c4f3a66..a80385828e 100644
--- a/src/core/stdfile/src/stdafx.h
+++ b/src/core/stdfile/src/stdafx.h
@@ -77,6 +77,8 @@ struct CMPlugin : public PLUGIN<CMPlugin>
{
CMPlugin();
+ CMOption<bool> bAutoMin, bAutoClear, bAutoClose, bAutoAccept, bReverseOrder;
+
int Load() override;
int Unload() override;
};
diff --git a/src/core/stdfile/stdfile.vcxproj b/src/core/stdfile/stdfile.vcxproj
index 583d46d164..598687702c 100644
--- a/src/core/stdfile/stdfile.vcxproj
+++ b/src/core/stdfile/stdfile.vcxproj
@@ -37,6 +37,7 @@
<ClCompile Include="src\stdafx.cxx">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
+ <ClInclude Include="..\mir_app\src\resource.h" />
<ClInclude Include="src\file.h" />
<ClInclude Include="src\stdafx.h" />
<ClInclude Include="src\version.h" />
diff --git a/src/core/stdfile/stdfile.vcxproj.filters b/src/core/stdfile/stdfile.vcxproj.filters
index c0669be005..2dd1daeea9 100644
--- a/src/core/stdfile/stdfile.vcxproj.filters
+++ b/src/core/stdfile/stdfile.vcxproj.filters
@@ -40,6 +40,9 @@
<ClInclude Include="src\version.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\mir_app\src\resource.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\resource.rc">