void PasswordSafeFrame::OnPreferencesClick( wxCommandEvent& /* evt */ ) { PWSprefs* prefs = PWSprefs::GetInstance(); const StringX sxOldDBPrefsString(prefs->Store()); COptions *window = new COptions(this); if (window->ShowModal() == wxID_OK) { StringX sxNewDBPrefsString(prefs->Store(true)); // Update system tray icon if visible so changes show up immediately if (m_sysTray && prefs->GetPref(PWSprefs::UseSystemTray)) m_sysTray->ShowIcon(); if (!m_core.GetCurFile().empty() && !m_core.IsReadOnly() && m_core.GetReadFileVersion() == PWSfile::VCURRENT) { if (sxOldDBPrefsString != sxNewDBPrefsString) { Command *pcmd = DBPrefsCommand::Create(&m_core, sxNewDBPrefsString); if (pcmd) { //I don't know why notifications should ever be suspended, but that's how //things were before I messed with them, so I want to limit the damage by //enabling notifications only as long as required and no more m_core.ResumeOnDBNotification(); Execute(pcmd); //deleted automatically m_core.SuspendOnDBNotification(); } } } } window->Destroy(); }
void CManagePasswordPolicies::OnOkClick( wxCommandEvent& ) { /* * User may have changed default policy, named policy, none or both. * If anything has changed, we treat the change as atomic, creating a multicommand * s.t. Undo/Redo will work as expected. */ PWPolicy olddefpol(PWSprefs::GetInstance()->GetDefaultPolicy()); bool defChanged = (olddefpol != m_st_default_pp); bool namedChanged = (m_MapPSWDPLC != m_core.GetPasswordPolicies()); if (defChanged || namedChanged) { MultiCommands *pmulticmds = MultiCommands::Create(&m_core); if (defChanged) { // User has changed database default policy - need to update preferences // Update the copy only! PWSprefs::GetInstance()->SetupCopyPrefs(); PWSprefs::GetInstance()->SetDefaultPolicy(m_st_default_pp, true); // Now get new DB preferences String value StringX sxNewDBPrefsString(PWSprefs::GetInstance()->Store(true)); // Set up Command to update string in database if (m_core.GetReadFileVersion() == PWSfile::VCURRENT) pmulticmds->Add(DBPrefsCommand::Create(&m_core, sxNewDBPrefsString)); } // defChanged if (namedChanged) { pmulticmds->Add(DBPolicyNamesCommand::Create(&m_core, m_MapPSWDPLC, DBPolicyNamesCommand::NP_REPLACEALL)); } m_core.Execute(pmulticmds); } // defChanged || namedChanged EndModal(wxID_OK); }