本文整理汇总了C++中PWSprefs::SetPref方法的典型用法代码示例。如果您正苦于以下问题:C++ PWSprefs::SetPref方法的具体用法?C++ PWSprefs::SetPref怎么用?C++ PWSprefs::SetPref使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PWSprefs
的用法示例。
在下文中一共展示了PWSprefs::SetPref方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST_F(ItemDataTest, PasswordHistory)
{
size_t pwh_max, num_err;
PWHistList pwhl;
const StringX pw1(L"banana-0rchid");
const StringX pw2(L"banana-1rchid");
const StringX pw3(L"banana-2rchid");
const StringX pw4(L"banana-5rchid");
PWSprefs *prefs = PWSprefs::GetInstance();
prefs->SetPref(PWSprefs::SavePasswordHistory, true);
prefs->SetPref(PWSprefs::NumPWHistoryDefault, 3);
CItemData di;
di.SetCTime();
di.SetPassword(pw1); // first time must be Set, not Update!
di.UpdatePassword(pw2);
EXPECT_FALSE(di.GetPWHistory().empty());
EXPECT_TRUE(CreatePWHistoryList(di.GetPWHistory(), pwh_max, num_err,
pwhl, PWSUtil::TMC_ASC_UNKNOWN));
EXPECT_EQ(0, num_err);
EXPECT_EQ(3, pwh_max);
EXPECT_EQ(1, pwhl.size());
EXPECT_EQ(pw1, pwhl[0].password);
di.UpdatePassword(pw3);
EXPECT_TRUE(CreatePWHistoryList(di.GetPWHistory(), pwh_max, num_err,
pwhl, PWSUtil::TMC_ASC_UNKNOWN));
EXPECT_EQ(0, num_err);
EXPECT_EQ(3, pwh_max);
EXPECT_EQ(2, pwhl.size());
EXPECT_EQ(pw1, pwhl[0].password);
EXPECT_EQ(pw2, pwhl[1].password);
di.UpdatePassword(pw4);
EXPECT_TRUE(CreatePWHistoryList(di.GetPWHistory(), pwh_max, num_err,
pwhl, PWSUtil::TMC_ASC_UNKNOWN));
EXPECT_EQ(0, num_err);
EXPECT_EQ(3, pwh_max);
EXPECT_EQ(3, pwhl.size());
EXPECT_EQ(pw1, pwhl[0].password);
EXPECT_EQ(pw2, pwhl[1].password);
EXPECT_EQ(pw3, pwhl[2].password);
di.UpdatePassword(L"Last1");
EXPECT_TRUE(CreatePWHistoryList(di.GetPWHistory(), pwh_max, num_err,
pwhl, PWSUtil::TMC_ASC_UNKNOWN));
EXPECT_EQ(0, num_err);
EXPECT_EQ(3, pwh_max);
EXPECT_EQ(3, pwhl.size());
EXPECT_EQ(pw2, pwhl[0].password);
EXPECT_EQ(pw3, pwhl[1].password);
EXPECT_EQ(pw4, pwhl[2].password);
}
示例2: OnBackupSafe
//////////////////////////////////////////
// Backup and Restore
//
void PasswordSafeFrame::OnBackupSafe(wxCommandEvent& /*evt*/)
{
PWSprefs *prefs = PWSprefs::GetInstance();
const wxFileName currbackup(towxstring(prefs->GetPref(PWSprefs::CurrentBackup)));
const wxString title(_("Please Choose a Name for this Backup:"));
wxString dir;
if (m_core.GetCurFile().empty())
dir = towxstring(PWSdirs::GetSafeDir());
else {
wxFileName::SplitPath(towxstring(m_core.GetCurFile()), &dir, NULL, NULL);
wxCHECK_RET(!dir.IsEmpty(), _("Could not parse current file path"));
}
//returns empty string if user cancels
wxString wxbf = wxFileSelector(title,
dir,
currbackup.GetFullName(),
wxT("bak"),
_("Password Safe Backups (*.bak)|*.bak"),
wxFD_SAVE|wxFD_OVERWRITE_PROMPT,
this);
/*
The wxFileSelector code says it appends the default extension if user
doesn't type one, but it actually doesn't and I don't see the purported
code in 2.8.10. And doing it ourselves after the dialog has returned is
risky because we might silently overwrite an existing file
*/
//create a copy to avoid multiple conversions to StringX
const StringX backupfile(tostringx(wxbf));
#ifdef NOT_YET
if (m_inExit) {
// If U3ExitNow called while in CPWFileDialog,
// PostQuitMessage makes us return here instead
// of exiting the app. Try resignalling
PostQuitMessage(0);
return PWScore::USER_CANCEL;
}
#endif
if (!backupfile.empty()) { //i.e. if user didn't cancel
if (m_core.WriteFile(backupfile, m_core.GetReadFileVersion(),
false) == PWScore::CANT_OPEN_FILE) {
wxMessageBox( wxbf << wxT("\n\n") << _("Could not open file for writing!"),
_("Write Error"), wxOK|wxICON_ERROR, this);
}
prefs->SetPref(PWSprefs::CurrentBackup, backupfile);
}
}
示例3: OnExit
int PwsafeApp::OnExit()
{
m_idleTimer->Stop();
recentDatabases().Save();
PWSprefs *prefs = PWSprefs::GetInstance();
if (!m_core.GetCurFile().empty())
prefs->SetPref(PWSprefs::CurrentFile, m_core.GetCurFile());
// Save Application related preferences
prefs->SaveApplicationPreferences();
// Save shortcuts, if changed
PWSMenuShortcuts::GetShortcutsManager()->SaveUserShortcuts();
PWSMenuShortcuts::DestroyShortcutsManager();
////@begin PwsafeApp cleanup
return wxApp::OnExit();
////@end PwsafeApp cleanup
}
示例4: OnInit
//.........这里部分代码省略.........
if (filename.empty()) {
filename = prefs->GetPref(PWSprefs::CurrentFile).c_str();
} else {
recentDatabases().AddFileToHistory(filename);
}
m_core.SetCurFile(tostringx(filename));
m_core.SetApplicationNameAndVersion(tostdstring(progName),
MAKEWORD(MINORVERSION, MAJORVERSION));
static wxSingleInstanceChecker appInstance;
if (!prefs->GetPref(PWSprefs::MultipleInstances) &&
(appInstance.Create(wxT("pwsafe.lck"), towxstring(pws_os::getuserprefsdir())) &&
appInstance.IsAnotherRunning()))
{
wxMessageBox(_("Another instance of Password Safe is already running"), _("Password Safe"),
wxOK|wxICON_INFORMATION);
return false;
}
#if defined(__X__) || defined(__WXGTK__)
PWSclipboard::GetInstance()->UsePrimarySelection(prefs->GetPref(PWSprefs::UsePrimarySelectionForClipboard));
#endif
// here if we're the child
recentDatabases().Load();
if (cmd_closed || cmd_minimized) {
m_core.SetCurFile(L"");
}
if (cmd_silent) {
if ( wxTaskBarIcon::IsAvailable() ) {
// start silent implies use system tray.
// Note that if UseSystemTray is already true, then pwsafe will try to run silently anyway
PWSprefs::GetInstance()->SetPref(PWSprefs::UseSystemTray, true);
}
else {
// We don't want to bring up a UI if running silently
std::wcerr << L"There appears to be no system tray support in your current environment. pwsafe may not work as expected in silent mode." << std::endl;
}
}
m_appIcons.AddIcon(pwsafe16);
m_appIcons.AddIcon(pwsafe32);
m_appIcons.AddIcon(pwsafe48);
if (!m_helpController) { // helpController (re)created on language activation
std::wcerr << L"Could not initialize help subsystem." << std::endl;
if (!prefs->GetPref(PWSprefs::IgnoreHelpLoadError) && !cmd_silent) {
#if wxCHECK_VERSION(2,9,2)
wxRichMessageDialog dlg(NULL,
_("Could not initialize help subsystem. Help will not be available."),
_("Password Safe: Error initializing help"), wxCENTRE|wxOK|wxICON_EXCLAMATION);
dlg.ShowCheckBox(_("Don't show this warning again"));
dlg.ShowModal();
if (dlg.IsCheckBoxChecked()) {
prefs->SetPref(PWSprefs::IgnoreHelpLoadError, true);
prefs->SaveApplicationPreferences();
}
#else
wxMessageBox(_("Could not initialize help subsystem. Help will not be available."),
_("Password Safe: Error initializing help"), wxOK | wxICON_ERROR);
#endif
}
}
示例5: UpdateCopyPreferences
void COptions_PropertySheet::UpdateCopyPreferences()
{
PWSprefs *prefs = PWSprefs::GetInstance();
// Now update the Application preferences.
// In PropertyPage alphabetic order
// Note: Updating the copy values - especially important for DB preferences!!!
// Backup
prefs->SetPref(PWSprefs::BackupBeforeEverySave,
m_OPTMD.BackupBeforeSave == TRUE, true);
prefs->SetPref(PWSprefs::BackupPrefixValue,
LPCWSTR(m_OPTMD.UserBackupPrefix), true);
prefs->SetPref(PWSprefs::BackupSuffix,
(unsigned int)m_OPTMD.BackupSuffix, true);
prefs->SetPref(PWSprefs::BackupMaxIncremented,
m_OPTMD.MaxNumIncBackups, true);
if (!m_OPTMD.UserBackupOtherLocation.IsEmpty()) {
// Make sure it ends in a slash!
if (m_OPTMD.UserBackupOtherLocation.Right(1) != CSecString(L'\\'))
m_OPTMD.UserBackupOtherLocation += L'\\';
}
prefs->SetPref(PWSprefs::BackupDir,
LPCWSTR(m_OPTMD.UserBackupOtherLocation), true);
// Display
prefs->SetPref(PWSprefs::AlwaysOnTop,
m_OPTMD.AlwaysOnTop == TRUE, true);
prefs->SetPref(PWSprefs::ShowNotesAsTooltipsInViews,
m_OPTMD.ShowNotesAsTipsInViews == TRUE, true);
prefs->SetPref(PWSprefs::ExplorerTypeTree,
m_OPTMD.ExplorerTypeTree == TRUE, true);
prefs->SetPref(PWSprefs::ListViewGridLines,
m_OPTMD.EnableGrid == TRUE, true);
prefs->SetPref(PWSprefs::NotesWordWrap,
m_OPTMD.WordWrapNotes == TRUE, true);
prefs->SetPref(PWSprefs::PreExpiryWarn,
m_OPTMD.PreExpiryWarn == TRUE, true);
prefs->SetPref(PWSprefs::PreExpiryWarnDays,
m_OPTMD.PreExpiryWarnDays, true);
prefs->SetPref(PWSprefs::ClosedTrayIconColour,
m_OPTMD.TrayIconColour, true);
if (m_save_bHighlightChanges != m_OPTMD.HighlightChanges) {
prefs->SetPref(PWSprefs::HighlightChanges,
m_OPTMD.HighlightChanges == TRUE, true);
m_bRefreshViews = true;
}
// Misc
prefs->SetPref(PWSprefs::DeleteQuestion,
m_OPTMD.ConfirmDelete == FALSE, true);
prefs->SetPref(PWSprefs::EscExits,
m_OPTMD.EscExits == TRUE, true);
// by strange coincidence, the values of the enums match the indices
// of the radio buttons in the following :-)
prefs->SetPref(PWSprefs::DoubleClickAction,
(unsigned int)m_OPTMD.DoubleClickAction, true);
prefs->SetPref(PWSprefs::ShiftDoubleClickAction,
(unsigned int)m_OPTMD.ShiftDoubleClickAction, true);
prefs->SetPref(PWSprefs::QuerySetDef,
m_OPTMD.QuerySetDef == TRUE, true);
prefs->SetPref(PWSprefs::AltBrowser,
LPCWSTR(m_OPTMD.OtherBrowserLocation), true);
prefs->SetPref(PWSprefs::AltBrowserCmdLineParms,
LPCWSTR(m_OPTMD.BrowserCmdLineParms), true);
prefs->SetPref(PWSprefs::AltNotesEditor,
LPCWSTR(m_OPTMD.OtherEditorLocation), true);
prefs->SetPref(PWSprefs::MinimizeOnAutotype,
m_OPTMD.MinAuto == TRUE, true);
prefs->SetPref(PWSprefs::ClearClipboardOnMinimize,
m_OPTMD.ClearClipboardOnMinimize == TRUE, true);
prefs->SetPref(PWSprefs::ClearClipboardOnExit,
m_OPTMD.ClearClipboardOnExit == TRUE, true);
prefs->SetPref(PWSprefs::DatabaseClear,
m_OPTMD.LockOnMinimize == TRUE, true);
prefs->SetPref(PWSprefs::DontAskQuestion,
m_OPTMD.ConfirmCopy == FALSE, true);
prefs->SetPref(PWSprefs::LockOnWindowLock,
m_OPTMD.LockOnWindowLock == TRUE, true);
prefs->SetPref(PWSprefs::CopyPasswordWhenBrowseToURL,
m_OPTMD.CopyPswdBrowseURL == TRUE, true);
prefs->SetPref(PWSprefs::UseSystemTray,
m_OPTMD.UseSystemTray == TRUE, true);
prefs->SetPref(PWSprefs::HideSystemTray,
m_OPTMD.HideSystemTray == TRUE, true);
prefs->SetPref(PWSprefs::MaxREItems,
m_OPTMD.MaxREItems, true);
prefs->SetPref(PWSprefs::MaxMRUItems,
m_OPTMD.MaxMRUItems, true);
if (m_OPTMD.MaxMRUItems == 0) {
// Put them on File menu where they don't take up any room
prefs->SetPref(PWSprefs::MRUOnFileMenu, true, true);
} else {
prefs->SetPref(PWSprefs::MRUOnFileMenu,
m_OPTMD.MRUOnFileMenu == TRUE, true);
}
//.........这里部分代码省略.........