void WPassGen::OnChoicePreset(wxCommandEvent& WXUNUSED(event)) { int ni = choicePreset->GetSelection(); if (ni < 0 || (unsigned int)ni >= presetlist.size()) return; const Preset& preset = presetlist[ni]; choiceType->SetSelection(preset.type); checkboxSkipSimilarChar->SetValue(preset.skip_similar); checkboxSkipSwappedChar->SetValue(preset.skip_swapped); textctrlExtraChar->ChangeValue(preset.extrachar); spinctrlLength->SetValue(preset.length); UpdateCheckboxes(); UpdateKeyStrength(); }
void WPassGen::LoadDefaultSettings() { choicePreset->SetSelection(PT_ALPHANUMERIC); choiceType->SetSelection(0); checkboxSkipSimilarChar->SetValue(false); checkboxSkipSwappedChar->SetValue(false); textctrlExtraChar->SetValue(_T("")); spinctrlLength->SetValue(12); spinctrlNumber->SetValue(10); checkboxEnumerate->SetValue(false); presetlist = GetDefaultPresets(); // update dialog logic ResetPresetChoice(); UpdateCheckboxes(); UpdateKeyStrength(); GenerateList(); buttonOK->Disable(); }
//------------------------------------------------------------------------- INT_PTR CALLBACK ResetPermissionDialog::MainDialogProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: { hDlg = hWnd; // Set the initial states/configuration bRecurse = true; bResetPerm = true; bRmHidSys = false; bTakeOwn = false; bDontFollowLinks = true; UpdateCheckboxes(false); HICON hIcon = LoadIcon( hInstance, MAKEINTRESOURCE(IDI_SMALL)); SendMessage( hDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon); LPCTSTR Arg = GetArg(1); #ifdef _DEBUG if (Arg == NULL) Arg = _TEXT("C:\\Temp\\perm"); // Enable editing for the folder text editbox in debug mode SendDlgItemMessage(hDlg, IDTXT_FOLDER, EM_SETREADONLY, FALSE, 0); #endif if (Arg != NULL) { SetFolderText(Arg); UpdateCommandText(); } return TRUE; } case WM_MENUCOMMAND: break; case WM_COMMAND: { UINT wmId = LOWORD(wParam); UINT wmEvent = HIWORD(wParam); #ifdef _DEBUG TCHAR b[1024]; _sntprintf_s( b, _countof(b), _TEXT("WM_COMMAND: wmParam=%08X lParam=%08X | ID=%04X Event=%04X\n"), wParam, lParam, wmId, wmEvent); OutputDebugString(b); // Reflect the folder text changes when the control is editable if (wmId == IDTXT_FOLDER && wmEvent == EN_CHANGE) UpdateCommandText(); #endif switch (wmId) { // // Handle checkboxes // case IDCHK_RECURSE: case IDCHK_DONTFOLLOWLINKS: case IDCHK_TAKEOWN: case IDCHK_RESETPERM: case IDCHK_RM_HS: { // Reforumulate the command text on each option change if (wmEvent == BN_CLICKED) { UpdateCommandText(); return TRUE; } break; } // // Handle context menu // case IDM_ADDTOEXPLORERFOLDERCONTEXTMENU: case IDM_REMOVEFROMEXPLORERFOLDERCONTEXTMENU: AddToExplorerContextMenu(wmId == IDM_ADDTOEXPLORERFOLDERCONTEXTMENU); break; case IDM_BACKUPPERMSCONTEXTMENU: case IDM_RESTOREPERMSCONTEXTMENU: BackRestorePermissions(wmId == IDM_BACKUPPERMSCONTEXTMENU); break; // // About box // case IDBTN_ABOUT: { DialogBox( hInstance, MAKEINTRESOURCE(IDD_ABOUTBOX), hDlg, AboutDlgProc); return TRUE; } // // Choose folder // case IDBTN_CHOOSE_FOLDER: { stringT Folder; if (BrowseFolder(hDlg, STR_SELECT_FOLDER, Folder)) { SetFolderText(Folder.c_str()); UpdateCommandText(); } return TRUE; } // // Trigger the "Advanced" menu // case IDBTN_ADVANCED: { ShowPopupMenu(IDR_ADVANCED_MENU, IDBTN_ADVANCED); return TRUE; } // // GO button // case IDOK: { // Validate the input folder and execute the command ExecuteWindowCommand(true); return TRUE; } // HELP button case IDBTN_HELP: { ShellExecute( hDlg, _TEXT("open"), STR_HELP_URL, nullptr, nullptr, SW_SHOW); return TRUE; } } // switch(wmId) break; } // case WM_COMMAND // Close dialog case WM_CLOSE: EndDialog(hDlg, IDOK); return TRUE; } return FALSE; }
//------------------------------------------------------------------------- // Update the command text void ResetPermissionDialog::UpdateCommandText() { UpdateCheckboxes(true); stringT folder; if (GetFolderText(folder, false, true, true) == 0) return; stringT cmd; InitCommand(cmd); // Form takeown.exe command if (bTakeOwn) { // Update the command prompt's title cmd += _TEXT("TITLE taking ownership of folder: ") + folder + STR_NEWLINE; cmd += STR_CMD_TAKEOWN; if (bRecurse) cmd += _TEXT(" /r "); if (bDontFollowLinks) cmd += _TEXT(" /SKIPSL "); cmd += _TEXT(" /f ") + folder + STR_NEWLINE2; } // // Form icacls.exe command // if (bResetPerm) { // Update the command prompt's title cmd += _TEXT("TITLE Taking ownership of folder: ") + folder + STR_NEWLINE; cmd += STR_CMD_ICACLS + folder; if (bRecurse) cmd += _TEXT(" /T "); if (bDontFollowLinks) cmd += _TEXT(" /L "); cmd += _TEXT(" /Q /C /RESET") + STR_NEWLINE2; } // Form attribute.exe command if (bRmHidSys) { // Update the command prompt's title cmd += _TEXT("TITLE Changing files attributes in folder: ") + folder + STR_NEWLINE; cmd += STR_CMD_ATTRIB; if (bRecurse) cmd += _TEXT(" /s "); cmd += _TEXT(" -h -s ") + folder + STR_NEWLINE2; } // Always add a pause and a new line cmd += STR_CMD_PAUSE; cmd += STR_NEWLINE; // Update the SetCommandWindowText(cmd.c_str()); }
void WPassGen::OnChoiceType(wxCommandEvent& WXUNUSED(event)) { ResetPresetChoice(); UpdateCheckboxes(); UpdateKeyStrength(); }
WPassGen::WPassGen(wxWindow* parent, bool _standalone, int id, const wxString& title, const wxPoint& pos, const wxSize& size, long WXUNUSED(style)) : wxDialog(parent, id, title, pos, size, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxTHICK_FRAME), standalone(_standalone) { { #include "art/pwgen-16.h" #include "art/pwgen-22.h" #include "art/pwgen-32.h" #include "art/pwgen-48.h" wxIconBundle progicon; progicon.AddIcon(wxIconFromMemory(pwgen_16_png)); progicon.AddIcon(wxIconFromMemory(pwgen_22_png)); progicon.AddIcon(wxIconFromMemory(pwgen_32_png)); progicon.AddIcon(wxIconFromMemory(pwgen_48_png)); SetIcons(progicon); } // begin wxGlade: WPassGen::WPassGen sizer2_staticbox = new wxStaticBox(this, -1, _("Generator Options")); const wxString* choicePreset_choices = NULL; choicePreset = new wxChoice(this, myID_PRESET, wxDefaultPosition, wxDefaultSize, 0, choicePreset_choices, 0); buttonPresetAdd = new wxBitmapButton(this, myID_PRESET_ADD, wxNullBitmap); buttonPresetRemove = new wxBitmapButton(this, myID_PRESET_REMOVE, wxNullBitmap); const wxString* choiceType_choices = NULL; choiceType = new wxChoice(this, myID_TYPE, wxDefaultPosition, wxDefaultSize, 0, choiceType_choices, 0); checkboxSkipSimilarChar = new wxCheckBox(this, myID_SKIPSIMILARCHAR, _("Don't use 0/O and 1/l.")); checkboxSkipSwappedChar = new wxCheckBox(this, myID_SKIPSWAPPEDCHAR, _("Don't use z/y.")); textctrlExtraChar = new wxTextCtrl(this, myID_TEXT_EXTRACHAR, wxEmptyString); spinctrlLength = new wxSpinCtrl(this, myID_LENGTH, wxT("12"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 6, 100); textctrlStrength = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY); spinctrlNumber = new wxSpinCtrl(this, myID_NUMBER, wxT("10"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 1000); checkboxEnumerate = new wxCheckBox(this, myID_ENUMERATE, _("Enumerate")); buttonGenerate = new wxButton(this, myID_GENERATE, _("&Generate")); listctrlPasslist = new wxListCtrl(this, myID_PASSLIST, wxDefaultPosition, wxDefaultSize, wxLC_LIST | wxSUNKEN_BORDER); textctrlPasslist = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY); buttonOK = new wxButton(this, wxID_OK, wxEmptyString); buttonCancel = new wxButton(this, wxID_CANCEL, wxEmptyString); buttonAbout = new wxButton(this, wxID_ABOUT, _("&About")); buttonClose = new wxButton(this, wxID_CLOSE, wxEmptyString); set_properties(); do_layout(); // end wxGlade // set bitmap from compiled-in PNGs { #include "art/gnome/list-add.h" #include "art/gnome/list-remove.h" buttonPresetAdd->SetBitmapLabel(wxBitmapFromMemory(gnome_list_add_png)); buttonPresetRemove->SetBitmapLabel(wxBitmapFromMemory(gnome_list_remove_png)); } // insert password type names for (unsigned int pt = 0; pt <= PT_LAST; ++pt) { choiceType->Append(GetTypeName((pass_type)pt)); } // update dialog logic ResetPresetChoice(); UpdateCheckboxes(); UpdateKeyStrength(); GenerateList(); buttonOK->Disable(); }
void WPassGen::LoadSettings(class wxConfigBase* cfg) { // load settings from wxConfig cfg->SetPath(_T("/pwgen")); int preset, type, length, number; bool skip_similar, skip_swapped, enumerate; wxString extrachar; cfg->Read(_T("preset"), &preset, PT_ALPHANUMERIC); cfg->Read(_T("type"), &type, 0); cfg->Read(_T("skip_similar"), &skip_similar, false); cfg->Read(_T("skip_swapped"), &skip_swapped, false); cfg->Read(_T("extrachar"), &extrachar); cfg->Read(_T("length"), &length, 12); cfg->Read(_T("number"), &number, 10); cfg->Read(_T("enumerate"), &enumerate, false); choicePreset->SetSelection(preset); choiceType->SetSelection(type); checkboxSkipSimilarChar->SetValue(skip_similar); checkboxSkipSwappedChar->SetValue(skip_swapped); textctrlExtraChar->SetValue(extrachar); spinctrlLength->SetValue(length); spinctrlNumber->SetValue(number); checkboxEnumerate->SetValue(enumerate); if (cfg->Exists(_T("/pwgen/presets"))) { presetlist.clear(); cfg->SetPath(_T("/pwgen/presets")); for (unsigned int pi = 0; cfg->HasGroup(wxString::Format(_T("%d"), pi)); ++pi) { cfg->SetPath(wxString::Format(_T("%d"), pi)); Preset preset; cfg->Read(_T("name"), &preset.name, _("<unknown>")); cfg->Read(_T("type"), (int*)&preset.type, 0); cfg->Read(_T("skip_similar"), &preset.skip_similar, false); cfg->Read(_T("skip_swapped"), &preset.skip_swapped, false); cfg->Read(_T("extrachar"), &preset.extrachar); cfg->Read(_T("length"), &preset.length, 12); presetlist.push_back(preset); cfg->SetPath(_T("..")); } } else { // Load a list of default presets if none are defined in the config // storage. presetlist = GetDefaultPresets(); } // update dialog logic ResetPresetChoice(); UpdateCheckboxes(); UpdateKeyStrength(); GenerateList(); buttonOK->Disable(); }