[f1e2cf]: PasskeySetup.cpp  Maximize  Restore  History

Download this file

148 lines (122 with data), 3.9 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/// \file PasskeySetup.cpp
//-----------------------------------------------------------------------------
#include "stdafx.h"
#include "PasswordSafe.h"
#include "corelib/PWCharPool.h" // for CheckPassword()
#include "ThisMfcApp.h"
#include "corelib/PwsPlatform.h"
#if defined(POCKET_PC)
#include "pocketpc/resource.h"
#include "pocketpc/PocketPC.h"
#else
#include "resource.h"
#endif
#include "corelib/util.h"
#include "PasskeySetup.h"
#include "PwFont.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//-----------------------------------------------------------------------------
CPasskeySetup::CPasskeySetup(CWnd* pParent)
: super(CPasskeySetup::IDD, pParent)
{
m_passkey = _T("");
m_verify = _T("");
}
BOOL CPasskeySetup::OnInitDialog()
{
CDialog::OnInitDialog();
SetPasswordFont(GetDlgItem(IDC_PASSKEY));
SetPasswordFont(GetDlgItem(IDC_VERIFY));
return TRUE;
}
void CPasskeySetup::DoDataExchange(CDataExchange* pDX)
{
super::DoDataExchange(pDX);
DDX_Text(pDX, IDC_PASSKEY, (CString &)m_passkey);
DDX_Text(pDX, IDC_VERIFY, (CString &)m_verify);
}
BEGIN_MESSAGE_MAP(CPasskeySetup, super)
ON_BN_CLICKED(ID_HELP, OnHelp)
#if defined(POCKET_PC)
ON_EN_SETFOCUS(IDC_PASSKEY, OnPasskeySetfocus)
ON_EN_SETFOCUS(IDC_VERIFY, OnPasskeySetfocus)
ON_EN_KILLFOCUS(IDC_PASSKEY, OnPasskeyKillfocus)
ON_EN_KILLFOCUS(IDC_VERIFY, OnPasskeyKillfocus)
#endif
END_MESSAGE_MAP()
void CPasskeySetup::OnCancel()
{
super::OnCancel();
}
void CPasskeySetup::OnOK()
{
UpdateData(TRUE);
if (m_passkey != m_verify)
{
AfxMessageBox(_T("The two entries do not match."));
((CEdit*)GetDlgItem(IDC_VERIFY))->SetFocus();
return;
}
if (m_passkey.IsEmpty())
{
AfxMessageBox(_T("Please enter a key and verify it."));
((CEdit*)GetDlgItem(IDC_PASSKEY))->SetFocus();
return;
}
// Accept weak passwords in debug build, to make it easier to test
// Reject weak passwords in Release (prior to 3.02, we allowed the
// user to accept a weak password if she insisted).
// DK - I think this is wrong, so I have put it back in a different form.
#ifndef _DEBUG
CMyString errmess;
if (!CPasswordCharPool::CheckPassword(m_passkey, errmess)) {
CString msg(_T("Weak passphrase:\n\n"));
msg += CString(errmess);
if (m_bAllowWeakPassphrases) {
msg += _T("\n\nAccept it anyway?");
int rc = AfxMessageBox(msg, MB_YESNO | MB_ICONSTOP);
if (rc == IDNO)
return;
} else {
AfxMessageBox(msg, MB_ICONSTOP);
return;
}
}
#endif
super::OnOK();
}
void CPasskeySetup::OnHelp()
{
#if defined(POCKET_PC)
CreateProcess( _T("PegHelp.exe"), _T("pws_ce_help.html#newdatabase"), NULL, NULL, FALSE, 0, NULL, NULL, NULL, NULL );
#else
//WinHelp(0x20084, HELP_CONTEXT);
::HtmlHelp(NULL,
"pwsafe.chm::/html/create_new_db.html",
HH_DISPLAY_TOPIC, 0);
#endif
}
#if defined(POCKET_PC)
/************************************************************************/
/* Restore the state of word completion when the password field loses */
/* focus. */
/************************************************************************/
void CPasskeySetup::OnPasskeyKillfocus()
{
EnableWordCompletion( m_hWnd );
}
/************************************************************************/
/* When the password field is activated, pull up the SIP and disable */
/* word completion. */
/************************************************************************/
void CPasskeySetup::OnPasskeySetfocus()
{
DisableWordCompletion( m_hWnd );
}
#endif
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------