diff options
author | George Hazan <george.hazan@gmail.com> | 2023-07-18 12:49:26 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-07-18 12:49:26 +0300 |
commit | b94cdc1e20807eade7fd414b9a7caef2722f2a9a (patch) | |
tree | d6d4de83da00335e7cf4854807be96acf1062eba | |
parent | 728d102e547378a2d2baec15c473ab0ddc9ea0dc (diff) |
rest of offline file options
-rw-r--r-- | src/mir_app/res/resource.rc | 2 | ||||
-rw-r--r-- | src/mir_app/src/file.cpp | 9 | ||||
-rw-r--r-- | src/mir_app/src/file.h | 3 | ||||
-rw-r--r-- | src/mir_app/src/fileopts.cpp | 17 | ||||
-rw-r--r-- | src/mir_app/src/filerecvdlg.cpp | 24 | ||||
-rw-r--r-- | src/mir_app/src/filexferdlg.cpp | 2 |
6 files changed, 37 insertions, 20 deletions
diff --git a/src/mir_app/res/resource.rc b/src/mir_app/res/resource.rc index 00ae85f211..5f998c9cb1 100644 --- a/src/mir_app/res/resource.rc +++ b/src/mir_app/res/resource.rc @@ -1149,8 +1149,8 @@ BEGIN "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,148,288,10
RTEXT "Only if their size is less than",IDC_STATIC,12,162,153,8
EDITTEXT IDC_OFFLINE_AUTOSIZE,169,160,40,12,ES_AUTOHSCROLL
+ CONTROL "",IDC_OFFLINE_AUTOSIZE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,198,159,11,14
LTEXT "KBytes (0 - always)",IDC_STATIC,212,162,91,8
- CONTROL "",IDC_OFFLINE_AUTOSIZE_SPIN,"msctls_updown32",UDS_ARROWKEYS,198,159,11,14
END
IDD_OPT_FILESECURITY DIALOGEX 0, 0, 313, 243
diff --git a/src/mir_app/src/file.cpp b/src/mir_app/src/file.cpp index b72149de8e..5d55c3e9d0 100644 --- a/src/mir_app/src/file.cpp +++ b/src/mir_app/src/file.cpp @@ -35,15 +35,18 @@ CMOption<bool> File::bAutoMin(SRFILEMODULE, "AutoMin", false); CMOption<bool> File::bAutoClear(SRFILEMODULE, "AutoClear", true); CMOption<bool> File::bAutoClose(SRFILEMODULE, "AutoClose", false); CMOption<bool> File::bAutoAccept(SRFILEMODULE, "AutoAccept", false); +CMOption<bool> File::bOfflineAuto(SRFILEMODULE, "OfflineAuto", true); CMOption<bool> File::bReverseOrder(SRFILEMODULE, "ReverseOrder", false); CMOption<bool> File::bWarnBeforeOpening(SRFILEMODULE, "WarnBeforeOpening", true); -CMOption<uint8_t> File::iUseScanner(SRFILEMODULE, "UseScanner", VIRUSSCAN_DISABLE); -CMOption<uint8_t> File::iIfExists(SRFILEMODULE, "IfExists", FILERESUME_ASK); - CMOption<wchar_t*> File::wszSaveDir(SRFILEMODULE, "RecvFilesDirAdv", L""); CMOption<wchar_t*> File::wszScanCmdLine(SRFILEMODULE, "ScanCmdLine", L""); +CMOption<uint8_t> File::iIfExists(SRFILEMODULE, "IfExists", FILERESUME_ASK); +CMOption<uint8_t> File::iUseScanner(SRFILEMODULE, "UseScanner", VIRUSSCAN_DISABLE); + +CMOption<uint32_t> File::iOfflineSize(SRFILEMODULE, "OfflineSize", 2000); + static HGENMENU hSRFileMenuItem; static INT_PTR SendFileCommand(WPARAM hContact, LPARAM) diff --git a/src/mir_app/src/file.h b/src/mir_app/src/file.h index b807c4bc5b..ee248814ff 100644 --- a/src/mir_app/src/file.h +++ b/src/mir_app/src/file.h @@ -137,7 +137,8 @@ extern MWindowList g_hFileWindows; namespace File { extern CMOption<bool> bAutoMin, bAutoClear, bAutoClose, bAutoAccept, bReverseOrder; - extern CMOption<bool> bWarnBeforeOpening; + extern CMOption<bool> bWarnBeforeOpening, bOfflineAuto; extern CMOption<uint8_t> iIfExists, iUseScanner; + extern CMOption<uint32_t> iOfflineSize; extern CMOption<wchar_t*> wszSaveDir, wszScanCmdLine; }; diff --git a/src/mir_app/src/fileopts.cpp b/src/mir_app/src/fileopts.cpp index c8bca065e2..07a5ff0952 100644 --- a/src/mir_app/src/fileopts.cpp +++ b/src/mir_app/src/fileopts.cpp @@ -30,9 +30,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. class CFileGeneralOptsDlg : public CDlgBase { - CCtrlButton btnFileDir; - CCtrlCheck chkAutoMin, chkAutoClear, chkAutoClose, chkAutoAccept, chkReverseOrder; + CCtrlSpin spinSize; + CCtrlCheck chkAutoMin, chkAutoClear, chkAutoClose, chkAutoAccept, chkReverseOrder, chkOfflineAuto; CCtrlCombo cmbFileExists; + CCtrlButton btnFileDir; public: CFileGeneralOptsDlg() : @@ -42,18 +43,23 @@ public: chkAutoClear(this, IDC_AUTOCLEAR), chkAutoClose(this, IDC_AUTOCLOSE), chkAutoAccept(this, IDC_AUTOACCEPT), + chkOfflineAuto(this, IDC_OFFLINE_AUTO), cmbFileExists(this, IDC_FILEEXISTS), - chkReverseOrder(this, IDC_REVERSE_ORDER) + chkReverseOrder(this, IDC_REVERSE_ORDER), + spinSize(this, IDC_OFFLINE_AUTOSIZE_SPIN, 10000) { + CreateLink(spinSize, File::iOfflineSize); CreateLink(chkAutoMin, File::bAutoMin); CreateLink(chkAutoClear, File::bAutoClear); CreateLink(chkAutoClose, File::bAutoClose); CreateLink(chkAutoAccept, File::bAutoAccept); + CreateLink(chkOfflineAuto, File::bOfflineAuto); CreateLink(chkReverseOrder, File::bReverseOrder); btnFileDir.OnClick = Callback(this, &CFileGeneralOptsDlg::onClick_FileDir); chkAutoAccept.OnChange = Callback(this, &CFileGeneralOptsDlg::onChange_AutoAccept); + chkOfflineAuto.OnChange = Callback(this, &CFileGeneralOptsDlg::onChange_OfflineAuto); } bool OnInitDialog() override @@ -88,6 +94,11 @@ public: chkAutoMin.Enable(chkAutoAccept.GetState()); } + void onChange_OfflineAuto(CCtrlCheck *) + { + EnableWindow(GetDlgItem(m_hwnd, IDC_OFFLINE_AUTOSIZE), chkOfflineAuto.IsChecked()); + } + void onClick_FileDir(CCtrlButton*) { wchar_t str[MAX_PATH]; diff --git a/src/mir_app/src/filerecvdlg.cpp b/src/mir_app/src/filerecvdlg.cpp index e069b55b77..58ef04afa6 100644 --- a/src/mir_app/src/filerecvdlg.cpp +++ b/src/mir_app/src/filerecvdlg.cpp @@ -231,11 +231,11 @@ public: char idstr[32]; mir_snprintf(idstr, "MruDir%d", i); - DBVARIANT dbv; - if (g_plugin.getWString(idstr, &dbv)) + ptrW wszValue(db_get_wsa(0, SRFILEMODULE, idstr)); + if (wszValue) + SendDlgItemMessage(m_hwnd, IDC_FILEDIR, CB_ADDSTRING, 0, wszValue); + else break; - SendDlgItemMessage(m_hwnd, IDC_FILEDIR, CB_ADDSTRING, 0, (LPARAM)dbv.pwszVal); - db_free(&dbv); } db_event_markRead(dat->hContact, dat->hDbEvent); @@ -283,16 +283,18 @@ public: GetContactReceivedFilesDir(NULL, szDefaultRecvDir, _countof(szDefaultRecvDir), TRUE); if (wcsnicmp(szRecvDir, szDefaultRecvDir, mir_wstrlen(szDefaultRecvDir))) { char idstr[32]; - int i; - DBVARIANT dbv; - for (i = MAX_MRU_DIRS - 2; i >= 0; i--) { + ptrW wszValue; + + for (int i = MAX_MRU_DIRS - 2; i >= 0; i--) { mir_snprintf(idstr, "MruDir%d", i); - if (g_plugin.getWString(idstr, &dbv)) continue; + wszValue = db_get_wsa(0, SRFILEMODULE, idstr); + if (!wszValue) + continue; + mir_snprintf(idstr, "MruDir%d", i + 1); - g_plugin.setWString(idstr, dbv.pwszVal); - db_free(&dbv); + db_set_ws(0, SRFILEMODULE, idstr, wszValue); } - g_plugin.setWString(idstr, szRecvDir); + db_set_ws(0, SRFILEMODULE, idstr, szRecvDir); } EnableWindow(GetDlgItem(m_hwnd, IDC_FILENAMES), FALSE); diff --git a/src/mir_app/src/filexferdlg.cpp b/src/mir_app/src/filexferdlg.cpp index 957afd243d..e7fc5e6d4c 100644 --- a/src/mir_app/src/filexferdlg.cpp +++ b/src/mir_app/src/filexferdlg.cpp @@ -31,7 +31,7 @@ static int CheckVirusScanned(HWND hwnd, FileDlgData *dat, int i) if (dat->send) return 1; if (dat->fileVirusScanned == nullptr) return 0; if (dat->fileVirusScanned[i]) return 1; - if (g_plugin.getByte("WarnBeforeOpening", 1) == 0) return 1; + if (!File::bWarnBeforeOpening) return 1; return IDYES == MessageBox(hwnd, TranslateT("This file has not yet been scanned for viruses. Are you certain you want to open it?"), |