Annotation of truecrypt/main/forms/mountoptionsdialog.cpp, revision 1.1.1.1

1.1       root        1: /*
                      2:  Copyright (c) 2008 TrueCrypt Foundation. All rights reserved.
                      3: 
                      4:  Governed by the TrueCrypt License 2.4 the full text of which is contained
                      5:  in the file License.txt included in TrueCrypt binary and source code
                      6:  distribution packages.
                      7: */
                      8: 
                      9: #include "System.h"
                     10: #include "Main/Main.h"
                     11: #include "Main/GraphicUserInterface.h"
                     12: #include "MountOptionsDialog.h"
                     13: 
                     14: namespace TrueCrypt
                     15: {
                     16:        MountOptionsDialog::MountOptionsDialog (wxWindow *parent, MountOptions &options)
                     17:                : MountOptionsDialogBase (parent, wxID_ANY, wxString()
                     18: #ifdef __WXGTK__ // GTK apparently needs wxRESIZE_BORDER to support dynamic resizing
                     19:                , wxDefaultPosition, wxSize (-1,-1), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER
                     20: #endif
                     21:                ), Options (options)
                     22:        {
                     23:                if (options.Path && !options.Path->IsEmpty())
                     24:                        this->SetTitle (StringFormatter (LangString["ENTER_PASSWORD_FOR"], wstring (*options.Path)));
                     25:                else
                     26:                        this->SetTitle (LangString["ENTER_TC_VOL_PASSWORD"]);
                     27: 
                     28:                PasswordPanel = new VolumePasswordPanel (this, options.Password, options.Keyfiles, true);
                     29:                PasswordPanel->SetCacheCheckBoxValidator (wxGenericValidator (&Options.CachePassword));
                     30: 
                     31:                PasswordSizer->Add (PasswordPanel, 1, wxALL | wxEXPAND);
                     32: 
                     33: #ifdef __WXGTK__
                     34:                FilesystemOptionsSizer->Remove (FilesystemSpacer);
                     35:                OptionsPanel->Show (false);
                     36:                Fit();
                     37:                Layout();
                     38:                SetMinSize (GetSize());
                     39: #endif
                     40: 
                     41:                NoFilesystemCheckBox->SetValidator (wxGenericValidator (&Options.NoFilesystem));
                     42:                RemovableCheckBox->SetValidator (wxGenericValidator (&Options.Removable));
                     43: 
                     44:                TransferDataToWindow();
                     45: 
                     46:                if (Options.MountPoint && !Options.MountPoint->IsEmpty())
                     47:                         MountPointTextCtrl->SetValue (wstring (*Options.MountPoint));
                     48: 
                     49:                FilesystemOptionsTextCtrl->SetValue (Options.FilesystemOptions);
                     50: 
                     51:                ReadOnlyCheckBox->SetValue (Options.Protection == VolumeProtection::ReadOnly);
                     52:                ProtectionCheckBox->SetValue (Options.Protection == VolumeProtection::HiddenVolumeReadOnly);
                     53: 
                     54:                OptionsButtonLabel = OptionsButton->GetLabel();
                     55:                OptionsButton->SetLabel (OptionsButtonLabel + L" >");
                     56:                OptionsPanel->Show (false);
                     57: 
                     58:                ProtectionPasswordPanel = new VolumePasswordPanel (OptionsPanel, options.ProtectionPassword, options.ProtectionKeyfiles, false, true, true, false, false, _("P&assword to hidden volume:"));
                     59:                ProtectionPasswordSizer->Add (ProtectionPasswordPanel, 1, wxALL | wxEXPAND);
                     60: 
                     61:                UpdateDialog();
                     62:                Center();
                     63:        }
                     64: 
                     65:        void MountOptionsDialog::OnInitDialog (wxInitDialogEvent& event)
                     66:        {
                     67:                PasswordPanel->SetFocusToPasswordTextCtrl();
                     68:        }
                     69: 
                     70:        void MountOptionsDialog::OnMountPointButtonClick (wxCommandEvent& event)
                     71:        {
                     72:                DirectoryPath dir = Gui->SelectDirectory (this, wxEmptyString, false);
                     73:                if (!dir.IsEmpty())
                     74:                        MountPointTextCtrl->SetValue (wstring (dir));
                     75:        }
                     76: 
                     77:        void MountOptionsDialog::OnOKButtonClick (wxCommandEvent& event)
                     78:        {
                     79:                TransferDataFromWindow();
                     80: 
                     81:                Options.Password = PasswordPanel->GetPassword();
                     82:                Options.Keyfiles = PasswordPanel->GetKeyfiles();
                     83: 
                     84:                if (ReadOnlyCheckBox->IsChecked())
                     85:                {
                     86:                        Options.Protection = VolumeProtection::ReadOnly;
                     87:                }
                     88:                else if (ProtectionCheckBox->IsChecked())
                     89:                {
                     90:                        Options.Protection = VolumeProtection::HiddenVolumeReadOnly;
                     91:                        Options.ProtectionPassword = ProtectionPasswordPanel->GetPassword();
                     92:                        Options.ProtectionKeyfiles = ProtectionPasswordPanel->GetKeyfiles();
                     93:                }
                     94:                else
                     95:                {
                     96:                        Options.Protection = VolumeProtection::None;
                     97:                }
                     98: 
                     99:                wstring mountPoint (MountPointTextCtrl->GetValue());
                    100:                if (!mountPoint.empty())
                    101:                        Options.MountPoint = make_shared <DirectoryPath> (mountPoint);
                    102: 
                    103:                Options.FilesystemOptions = FilesystemOptionsTextCtrl->GetValue();
                    104: 
                    105:                try
                    106:                {
                    107:                        if (Options.Password)
                    108:                                Options.Password->CheckPortability();
                    109:                }
                    110:                catch (UnportablePassword &)
                    111:                {
                    112:                        Gui->ShowWarning (LangString ["UNSUPPORTED_CHARS_IN_PWD_RECOM"]);
                    113:                }
                    114: 
                    115:                EndModal (wxID_OK);
                    116:        }
                    117: 
                    118:        void MountOptionsDialog::OnOptionsButtonClick (wxCommandEvent& event)
                    119:        {
                    120:                FreezeScope freeze (this);
                    121:                OptionsPanel->Show (!OptionsPanel->IsShown());
                    122:                UpdateDialog();
                    123:                OptionsButton->SetLabel (OptionsButtonLabel + (OptionsPanel->IsShown() ? L" <" : L" >"));
                    124:        }
                    125: 
                    126:        void MountOptionsDialog::OnProtectionCheckBoxClick (wxCommandEvent& event)
                    127:        {
                    128:                FreezeScope freeze (this);
                    129:                ProtectionPasswordPanel->Show (event.IsChecked());
                    130:                Fit();
                    131:                Layout();
                    132:                ProtectionPasswordPanel->SetFocusToPasswordTextCtrl();
                    133:        }
                    134: 
                    135:        void MountOptionsDialog::OnProtectionHyperlinkClick (wxHyperlinkEvent& event)
                    136:        {
                    137:                Gui->OpenHomepageLink (this, L"hiddenvolprotection");
                    138:        }
                    139: 
                    140:        void MountOptionsDialog::UpdateDialog ()
                    141:        {
                    142:                FreezeScope freeze (this);
                    143: 
                    144: #ifdef TC_WINDOWS
                    145:                FilesystemSizer->Show (false);
                    146: #else
                    147:                FilesystemOptionsSizer->Show (!NoFilesystemCheckBox->IsChecked());
                    148: 
                    149: #      ifdef TC_MACOSX
                    150:                FilesystemOptionsStaticText->Show (false);
                    151:                FilesystemOptionsTextCtrl->Show (false);
                    152: #      endif
                    153: 
                    154:                if (!Options.Path || Options.Path->IsEmpty())
                    155:                {
                    156:                        MountPointTextCtrlStaticText->Show (false);
                    157:                        MountPointTextCtrl->Show (false);
                    158:                        MountPointButton->Show (false);
                    159:                }
                    160:                RemovableCheckBox->Show (false);
                    161: #endif
                    162:                ProtectionSizer->Show (!ReadOnlyCheckBox->IsChecked());
                    163:                ProtectionPasswordPanel->Show (!ReadOnlyCheckBox->IsChecked() && ProtectionCheckBox->IsChecked());
                    164: 
                    165:                Fit();
                    166:                Layout();
                    167:        }
                    168: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.