@@ -33,7 +33,7 @@ THE SOFTWARE.
3333#include " cppcryptfs.h"
3434#include " SettingsPropertyPage.h"
3535#include " afxdialogex.h"
36- #include " cppcryptfs .h"
36+ #include " util/util .h"
3737#include " context/cryptcontext.h"
3838#include " ui/cryptdefaults.h"
3939#include " util/savedpasswords.h"
@@ -48,6 +48,7 @@ CSettingsPropertyPage::CSettingsPropertyPage()
4848 m_bCaseInsensitive = false ;
4949 m_bMountManager = false ;
5050 m_bEnableSavingPasswords = false ;
51+ m_bNeverSaveHistory = false ;
5152}
5253
5354CSettingsPropertyPage::~CSettingsPropertyPage ()
@@ -70,6 +71,7 @@ BEGIN_MESSAGE_MAP(CSettingsPropertyPage, CPropertyPage)
7071 ON_BN_CLICKED(IDC_MOUNTMANAGER, &CSettingsPropertyPage::OnClickedMountmanager)
7172 ON_BN_CLICKED(IDC_RESETWARNINGS, &CSettingsPropertyPage::OnClickedResetwarnings)
7273 ON_BN_CLICKED(IDC_ENABLE_SAVING_PASSWORDS, &CSettingsPropertyPage::OnClickedEnableSavingPasswords)
74+ ON_BN_CLICKED(IDC_NEVER_SAVE_HISTORY, &CSettingsPropertyPage::OnClickedNeverSaveHistory)
7375END_MESSAGE_MAP()
7476
7577
@@ -79,7 +81,10 @@ static int buffer_sizes[] = { 4, 8, 16, 32, 64, 128, 256, 512, 1024 };
7981
8082static int ttls[] = { 0 , 1 , 2 , 5 , 10 , 15 , 30 , 45 , 60 , 90 , 120 , 300 , 600 , 900 , 1800 , 3600 };
8183
82- static const WCHAR* ttl_strings[] = { L" infinite" , L" 1 second" , L" 2 seconds" , L" 5 seconds" , L" 10 seconds" , L" 15 seconds" , L" 30 seconds" , L" 45 seconds" , L" 60 seconds" , L" 90 seconds" , L" 2 minutes" , L" 5 minutes" , L" 10 minutes" , L" 15 minutes" , L" 30 minutes" , L" 1 hour" };
84+ static const WCHAR* ttl_strings[] = { L" infinite" , L" 1 second" , L" 2 seconds" , L" 5 seconds" ,
85+ L" 10 seconds" , L" 15 seconds" , L" 30 seconds" , L" 45 seconds" ,
86+ L" 60 seconds" , L" 90 seconds" , L" 2 minutes" , L" 5 minutes" ,
87+ L" 10 minutes" , L" 15 minutes" , L" 30 minutes" , L" 1 hour" };
8388
8489BOOL CSettingsPropertyPage::OnInitDialog ()
8590{
@@ -97,17 +102,23 @@ BOOL CSettingsPropertyPage::OnInitDialog()
97102
98103 bool bMountManager = theApp.GetProfileInt (L" Settings" , L" MountManager" , MOUNTMANAGER_DEFAULT) != 0 ;
99104
100- bool bEnableSavingPasswords = theApp.GetProfileInt (L" Settings" , L" EnableSavingPasswords" , ENABLE_SAVING_PASSWORDS_DEFAULT) != 0 ;
105+ bool bEnableSavingPasswords = theApp.GetProfileInt (L" Settings" , L" EnableSavingPasswords" ,
106+ ENABLE_SAVING_PASSWORDS_DEFAULT) != 0 ;
107+
108+ bool bNeverSaveHistory = NeverSaveHistory ();
101109
102- return SetControls (nThreads, bufferblocks, cachettl, bCaseInsensitive, bMountManager, bEnableSavingPasswords);
110+ return SetControls (nThreads, bufferblocks, cachettl, bCaseInsensitive, bMountManager,
111+ bEnableSavingPasswords, bNeverSaveHistory);
103112}
104113
105- BOOL CSettingsPropertyPage::SetControls (int nThreads, int bufferblocks, int cachettl, bool bCaseInsensitive, bool bMountManager, bool bEnableSavingPasswords)
114+ BOOL CSettingsPropertyPage::SetControls (int nThreads, int bufferblocks, int cachettl,
115+ bool bCaseInsensitive, bool bMountManager, bool bEnableSavingPasswords, bool bNeverSaveHistory)
106116{
107117
108118 m_bCaseInsensitive = bCaseInsensitive;
109119 m_bMountManager = bMountManager;
110120 m_bEnableSavingPasswords = bEnableSavingPasswords;
121+ m_bNeverSaveHistory = bNeverSaveHistory;
111122
112123 int i;
113124
@@ -166,7 +177,8 @@ BOOL CSettingsPropertyPage::SetControls(int nThreads, int bufferblocks, int cach
166177
167178 pBox->ResetContent ();
168179
169- static_assert (sizeof (ttls) / sizeof (ttls[0 ]) == sizeof (ttl_strings) / sizeof (ttl_strings[0 ]), " mismatch in sizes of ttls/ttl_strings" );
180+ static_assert (sizeof (ttls) / sizeof (ttls[0 ]) == sizeof (ttl_strings) / sizeof (ttl_strings[0 ]),
181+ " mismatch in sizes of ttls/ttl_strings" );
170182
171183 int selitem = 0 ;
172184
@@ -185,6 +197,8 @@ BOOL CSettingsPropertyPage::SetControls(int nThreads, int bufferblocks, int cach
185197
186198 CheckDlgButton (IDC_ENABLE_SAVING_PASSWORDS, m_bEnableSavingPasswords ? 1 : 0 );
187199
200+ CheckDlgButton (IDC_NEVER_SAVE_HISTORY, m_bNeverSaveHistory ? 1 : 0 );
201+
188202 return TRUE ; // return TRUE unless you set the focus to a control
189203 // EXCEPTION: OCX Property Pages should return FALSE
190204}
@@ -259,17 +273,21 @@ void CSettingsPropertyPage::SaveSettings()
259273 m_bCaseInsensitive = !m_bCaseInsensitive; // OnBnClickedCaseinsensitive() flips it
260274 m_bMountManager = !m_bMountManager; // ditto
261275 m_bEnableSavingPasswords = !m_bEnableSavingPasswords; // ditto
276+ m_bNeverSaveHistory = !m_bNeverSaveHistory; // ditto
262277
263278 OnBnClickedCaseinsensitive ();
264279 OnClickedMountmanager ();
265280 OnClickedEnableSavingPasswords ();
281+ OnClickedNeverSaveHistory ();
266282}
267283
268284void CSettingsPropertyPage::OnBnClickedDefaults ()
269285{
270286 // TODO: Add your control notification handler code here
271287
272- SetControls (PER_FILESYSTEM_THREADS_DEFAULT, BUFFERBLOCKS_DEFAULT, CACHETTL_DEFAULT, CASEINSENSITIVE_DEFAULT, MOUNTMANAGER_DEFAULT, ENABLE_SAVING_PASSWORDS_DEFAULT);
288+ SetControls (PER_FILESYSTEM_THREADS_DEFAULT, BUFFERBLOCKS_DEFAULT, CACHETTL_DEFAULT,
289+ CASEINSENSITIVE_DEFAULT, MOUNTMANAGER_DEFAULT, ENABLE_SAVING_PASSWORDS_DEFAULT,
290+ NEVER_SAVE_HISTORY_DEFAULT);
273291
274292 SaveSettings ();
275293}
@@ -279,7 +297,9 @@ void CSettingsPropertyPage::OnBnClickedRecommended()
279297{
280298 // TODO: Add your control notification handler code here
281299
282- SetControls (PER_FILESYSTEM_THREADS_RECOMMENDED, BUFFERBLOCKS_RECOMMENDED, CACHETTL_RECOMMENDED, CASEINSENSITIVE_RECOMMENDED, MOUNTMANAGER_RECOMMENDED, ENABLE_SAVING_PASSWORDS_RECOMMENDED);
300+ SetControls (PER_FILESYSTEM_THREADS_RECOMMENDED, BUFFERBLOCKS_RECOMMENDED, CACHETTL_RECOMMENDED,
301+ CASEINSENSITIVE_RECOMMENDED, MOUNTMANAGER_RECOMMENDED, ENABLE_SAVING_PASSWORDS_RECOMMENDED,
302+ NEVER_SAVE_HISTORY_RECOMMENDED);
283303
284304 SaveSettings ();
285305}
@@ -315,6 +335,11 @@ void CSettingsPropertyPage::OnClickedEnableSavingPasswords()
315335 CheckDlgButton (IDC_ENABLE_SAVING_PASSWORDS, m_bEnableSavingPasswords ? 1 : 0 );
316336
317337 if (m_bEnableSavingPasswords) {
338+
339+ if (m_bNeverSaveHistory) {
340+ MessageBox (L" Passwords will not be saved if \" Never save history\" is turned on." ,
341+ L" cppcryptfs" , MB_OK | MB_ICONINFORMATION);
342+ }
318343 theApp.WriteProfileInt (L" Settings" , L" EnableSavingPasswords" , TRUE );
319344 } else {
320345 theApp.WriteProfileInt (L" Settings" , L" EnableSavingPasswords" , FALSE );
@@ -331,3 +356,48 @@ void CSettingsPropertyPage::OnClickedEnableSavingPasswords()
331356 }
332357 }
333358}
359+
360+
361+ void CSettingsPropertyPage::OnClickedNeverSaveHistory ()
362+ {
363+ // TODO: Add your control notification handler code here
364+
365+ m_bNeverSaveHistory = !m_bNeverSaveHistory;
366+
367+ CheckDlgButton (IDC_NEVER_SAVE_HISTORY, !!m_bNeverSaveHistory);
368+
369+ theApp.WriteProfileInt (L" Settings" , L" NeverSaveHistory" , !!m_bNeverSaveHistory);
370+
371+ if (m_bNeverSaveHistory) {
372+
373+ if (m_bEnableSavingPasswords) {
374+ MessageBox (L" If you turn on \" Never save history\" , saved passwords will not be deleted, but new passwords will not "
375+ L" be saved. To delete any saved passwords, uncheck \" Enable saved passwords\" ." ,
376+ L" cppcryptfs" , MB_OK | MB_ICONINFORMATION);
377+ }
378+
379+ wstring mes;
380+ wstring error;
381+
382+ // DeleteAllRegistryValues() returns false if there is nothing to delete and
383+ // with an empty error message. So use the message to accumulate real errors
384+ DeleteAllRegisteryValues (CPPCRYPTFS_REG_PATH CPPCRYPTFS_FOLDERS_SECTION, mes);
385+ error += mes;
386+ DeleteAllRegisteryValues (CPPCRYPTFS_REG_PATH CPPCRYPTFS_CONFIGPATHS_SECTION, mes);
387+ error += mes;
388+ DeleteAllRegisteryValues (CPPCRYPTFS_REG_PATH CPPCRYPTFS_MOUNTPOINTS_SECTION, mes);
389+ error += mes;
390+ DeleteAllRegisteryValues (CPPCRYPTFS_REG_PATH L" MountPoint" , mes);
391+ error += mes;
392+ DeleteAllRegisteryValues (CPPCRYPTFS_REG_PATH L" MountFlags" , mes);
393+ error += mes;
394+ DeleteAllRegisteryValues (CPPCRYPTFS_REG_PATH L" MountOptions" , mes);
395+ error += mes;
396+ DeleteAllRegisteryValues (CPPCRYPTFS_REG_PATH L" CreateOptions" , mes);
397+ error += mes;
398+ if (!error.empty ()) {
399+ MessageBox (L" unable to delete history from registry" , L" cppcryptfs" ,
400+ MB_OK | MB_ICONEXCLAMATION);
401+ }
402+ }
403+ }
0 commit comments