Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

757 lines
18 KiB

  1. // ChooseFileNamePage.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "CertWiz.h"
  5. #include "ChooseFileName.h"
  6. #include "Certificat.h"
  7. #include "Shlwapi.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CChooseFileNamePage property page
  15. IMPLEMENT_DYNCREATE(CChooseFileNamePage, CIISWizardPage)
  16. CChooseFileNamePage::CChooseFileNamePage(UINT id,
  17. UINT defaultID,
  18. UINT extID,
  19. UINT filterID,
  20. CString * pOutFileName)
  21. : CIISWizardPage(id, IDS_CERTWIZ, TRUE),
  22. m_id(id),
  23. m_defaultID(defaultID),
  24. m_DoReplaceFile(FALSE),
  25. m_pOutFileName(pOutFileName)
  26. {
  27. //{{AFX_DATA_INIT(CChooseFileNamePage)
  28. m_FileName = _T("");
  29. //}}AFX_DATA_INIT
  30. if (extID != 0)
  31. ext.LoadString(extID);
  32. if (filterID != 0)
  33. filter.LoadString(filterID);
  34. // replace '!'s in this string to null chars
  35. for (int i = 0; i < filter.GetLength(); i++)
  36. {
  37. if (filter[i] == L'!')
  38. filter.SetAt(i, L'\0');
  39. }
  40. }
  41. CChooseFileNamePage::~CChooseFileNamePage()
  42. {
  43. }
  44. void CChooseFileNamePage::DoDataExchange(CDataExchange* pDX)
  45. {
  46. CIISWizardPage::DoDataExchange(pDX);
  47. //{{AFX_DATA_MAP(CChooseFileNamePage)
  48. DDX_Text(pDX, IDC_FILE_NAME, m_FileName);
  49. //}}AFX_DATA_MAP
  50. }
  51. LRESULT
  52. CChooseFileNamePage::OnWizardBack()
  53. {
  54. ASSERT(FALSE);
  55. return 1;
  56. }
  57. static BOOL
  58. AnswerIsYes(UINT id, CString& file)
  59. {
  60. CString strMessage;
  61. AfxFormatString1(strMessage, id, file);
  62. return (IDYES == AfxMessageBox(strMessage, MB_ICONEXCLAMATION | MB_YESNO));
  63. }
  64. #if 0
  65. #define SHOW_MESSAGE_BOX(id,str)\
  66. do {\
  67. CString strMessage;\
  68. AfxFormatString1(strMessage, (id), (str));\
  69. if (IDNO == AfxMessageBox(strMessage, MB_ICONEXCLAMATION | MB_YESNO))\
  70. {\
  71. CEdit * pEdit = (CEdit *)CWnd::FromHandle(GetDlgItem(IDC_FILE_NAME)->m_hWnd);\
  72. pEdit->SetSel(0, -1);\
  73. pEdit->SetFocus();\
  74. return 1;\
  75. }\
  76. } while(FALSE)
  77. #endif
  78. LRESULT CChooseFileNamePage::DoWizardNext(LRESULT id)
  79. {
  80. if (id != 1)
  81. {
  82. ASSERT(m_pOutFileName != NULL);
  83. *m_pOutFileName = m_FileName;
  84. }
  85. else
  86. {
  87. UpdateData(FALSE);
  88. SetWizardButtons(PSWIZB_BACK);
  89. GetDlgItem(IDC_FILE_NAME)->SendMessage(EM_SETSEL, 0, -1);
  90. GetDlgItem(IDC_FILE_NAME)->SetFocus();
  91. MessageBeep(MB_ICONQUESTION);
  92. }
  93. return id;
  94. }
  95. BOOL CChooseFileNamePage::OnSetActive()
  96. {
  97. SetWizardButtons(m_FileName.IsEmpty() ?
  98. PSWIZB_BACK : PSWIZB_BACK | PSWIZB_NEXT);
  99. return CIISWizardPage::OnSetActive();
  100. }
  101. BEGIN_MESSAGE_MAP(CChooseFileNamePage, CIISWizardPage)
  102. //{{AFX_MSG_MAP(CChooseCAPage)
  103. ON_BN_CLICKED(IDC_BROWSE_BTN, OnBrowseBtn)
  104. ON_EN_CHANGE(IDC_FILE_NAME, OnChangeFileName)
  105. //}}AFX_MSG_MAP
  106. END_MESSAGE_MAP()
  107. /////////////////////////////////////////////////////////////////////////////
  108. // CChooseCAPage message handlers
  109. void CChooseFileNamePage::OnBrowseBtn()
  110. {
  111. ASSERT(FALSE);
  112. }
  113. void CChooseFileNamePage::Browse(CString& strPath, CString& strFile)
  114. {
  115. if (strPath.IsEmpty())
  116. {
  117. ::GetCurrentDirectory(MAX_PATH, strPath.GetBuffer(MAX_PATH + 1));
  118. strPath.ReleaseBuffer();
  119. }
  120. CFileDialog fileName(IsReadFileDlg());
  121. fileName.m_ofn.Flags |= OFN_NOCHANGEDIR | OFN_OVERWRITEPROMPT;
  122. if (IsReadFileDlg())
  123. fileName.m_ofn.Flags |= OFN_PATHMUSTEXIST;
  124. else
  125. fileName.m_ofn.Flags |= OFN_NOREADONLYRETURN;
  126. // We need to disable hook to show new style of File Dialog
  127. fileName.m_ofn.Flags &= ~(OFN_ENABLEHOOK);
  128. CString strExt = _T("*");
  129. strExt += ext;
  130. fileName.m_ofn.lpstrDefExt = strExt;
  131. fileName.m_ofn.lpstrFile = strFile.GetBuffer(MAX_PATH+1);
  132. fileName.m_ofn.nMaxFile = MAX_PATH;
  133. fileName.m_ofn.lpstrInitialDir = strPath.IsEmpty() ? NULL : (LPCTSTR)strPath;
  134. fileName.m_ofn.lpstrFilter = filter;
  135. fileName.m_ofn.nFilterIndex = 0;
  136. if (IDOK == fileName.DoModal())
  137. {
  138. ASSERT(NULL != GetDlgItem(IDC_FILE_NAME));
  139. CString strPrev;
  140. GetDlgItemText(IDC_FILE_NAME, strPrev);
  141. if (strPrev.CompareNoCase(strFile) != 0)
  142. {
  143. SetDlgItemText(IDC_FILE_NAME, strFile);
  144. m_DoReplaceFile = TRUE;
  145. FileNameChanged();
  146. }
  147. }
  148. strFile.ReleaseBuffer();
  149. }
  150. BOOL CChooseFileNamePage::OnInitDialog()
  151. {
  152. CIISWizardPage::OnInitDialog();
  153. SHAutoComplete(GetDlgItem(IDC_FILE_NAME)->m_hWnd, SHACF_FILESYSTEM);
  154. GetDlgItem(IDC_FILE_NAME)->SetFocus();
  155. SetWizardButtons(m_FileName.IsEmpty() ?
  156. PSWIZB_BACK : PSWIZB_BACK | PSWIZB_NEXT);
  157. return FALSE;
  158. }
  159. void CChooseFileNamePage::OnChangeFileName()
  160. {
  161. UpdateData(TRUE);
  162. //
  163. // Our replacement flag is not valid now:
  164. // It may be set to TRUE only when name was entered through
  165. // FileOpen dialog box which asks user about replacing itself
  166. //
  167. m_DoReplaceFile = FALSE;
  168. SetWizardButtons(m_FileName.IsEmpty() ?
  169. PSWIZB_BACK : PSWIZB_BACK | PSWIZB_NEXT);
  170. // call virtual handler to notify inherited classes
  171. FileNameChanged();
  172. }
  173. void
  174. CChooseFileNamePage::GetDefaultFileName(CString& str)
  175. {
  176. if (m_defaultID != 0)
  177. str.LoadString(m_defaultID);
  178. // set system disk letter to the string
  179. TCHAR sz[MAX_PATH];
  180. if (MAX_PATH >= GetSystemDirectory(sz, MAX_PATH))
  181. {
  182. str.SetAt(0, sz[0]);
  183. str.MakeLower();
  184. }
  185. }
  186. /////////////////////////////////////////////////////////////////////////////
  187. // CChooseReadFileName property page
  188. IMPLEMENT_DYNCREATE(CChooseReadFileName, CChooseFileNamePage)
  189. CChooseReadFileName::CChooseReadFileName(UINT id,
  190. UINT defaultID,
  191. UINT extID,
  192. UINT filterID,
  193. CString * pOutFileName
  194. )
  195. : CChooseFileNamePage(id, defaultID, extID, filterID, pOutFileName)
  196. {
  197. }
  198. BEGIN_MESSAGE_MAP(CChooseReadFileName, CChooseFileNamePage)
  199. //{{AFX_MSG_MAP(CChooseReadFileName)
  200. ON_BN_CLICKED(IDC_BROWSE_BTN, OnBrowseBtn)
  201. //}}AFX_MSG_MAP
  202. END_MESSAGE_MAP()
  203. BOOL
  204. CChooseReadFileName::OnInitDialog()
  205. {
  206. GetDefaultFileName(m_FileName);
  207. // check if this default file exists
  208. if (!PathFileExists(m_FileName))
  209. {
  210. // try to find first file with this extension
  211. CString find_str = m_FileName;
  212. WIN32_FIND_DATA find_data;
  213. PathRemoveFileSpec(find_str.GetBuffer(MAX_PATH));
  214. find_str.ReleaseBuffer();
  215. find_str += _T("*");
  216. find_str += ext;
  217. HANDLE hFind = FindFirstFile(find_str, &find_data);
  218. if ( hFind != INVALID_HANDLE_VALUE
  219. && (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0
  220. )
  221. {
  222. PathRemoveFileSpec(m_FileName.GetBuffer(MAX_PATH));
  223. m_FileName.ReleaseBuffer();
  224. m_FileName += find_data.cFileName;
  225. FindClose(hFind);
  226. }
  227. else
  228. {
  229. // if nothing found, just attach *.exe to the path
  230. // it will prevent user from just clicking Next
  231. m_FileName = find_str;
  232. }
  233. }
  234. return CChooseFileNamePage::OnInitDialog();
  235. }
  236. LRESULT
  237. CChooseReadFileName::OnWizardNext()
  238. {
  239. LRESULT id = 0;
  240. CString buf;
  241. UpdateData();
  242. // check if this file exists
  243. if ( !PathFileExists(m_FileName)
  244. && !PathIsDirectory(m_FileName)
  245. )
  246. {
  247. // try with default extension if it is just filename
  248. CString str = m_FileName;
  249. LPTSTR p = PathFindExtension(str);
  250. if (p != NULL && *p == 0)
  251. {
  252. str += ext;
  253. if (PathFileExists(str))
  254. {
  255. m_FileName = str;
  256. goto DoNext;
  257. }
  258. }
  259. AfxFormatString1(buf, IDS_FILE_DOES_NOT_EXIST, m_FileName);
  260. AfxMessageBox(buf, MB_OK);
  261. id = 1;
  262. }
  263. else if (PathIsDirectory(m_FileName))
  264. {
  265. AfxFormatString1(buf, IDS_FILE_IS_DIRECTORY, m_FileName);
  266. AfxMessageBox(buf, MB_OK);
  267. if (m_FileName.Right(1) != L'\\')
  268. m_FileName += _T("\\");
  269. id = 1;
  270. }
  271. DoNext:
  272. return DoWizardNext(id);
  273. }
  274. void CChooseReadFileName::OnBrowseBtn()
  275. {
  276. CString strFile, strPath;
  277. GetDlgItemText(IDC_FILE_NAME, m_FileName);
  278. if (!PathFileExists(m_FileName))
  279. {
  280. int n = m_FileName.ReverseFind(_T('\\'));
  281. if (n != -1)
  282. {
  283. strPath = m_FileName.Left(n);
  284. if (!PathFileExists(strPath))
  285. {
  286. strPath.Empty();
  287. strFile = m_FileName.Right(m_FileName.GetLength() - n - 1);
  288. }
  289. else if (PathIsDirectory(strPath))
  290. {
  291. strFile = m_FileName.Right(m_FileName.GetLength() - n - 1);
  292. }
  293. }
  294. else
  295. strFile = m_FileName;
  296. }
  297. else if (PathIsDirectory(m_FileName))
  298. {
  299. strPath = m_FileName;
  300. }
  301. else
  302. {
  303. // split filename and path
  304. strPath = m_FileName;
  305. PathRemoveFileSpec(strPath.GetBuffer(0));
  306. strPath.ReleaseBuffer();
  307. strFile = PathFindFileName(m_FileName);
  308. }
  309. CChooseFileNamePage::Browse(strPath, strFile);
  310. }
  311. /////////////////////////////////////////////////////////////////////////////
  312. // CChooseWriteFileName
  313. IMPLEMENT_DYNCREATE(CChooseWriteFileName, CChooseFileNamePage)
  314. CChooseWriteFileName::CChooseWriteFileName(UINT id,
  315. UINT defaultID,
  316. UINT extID,
  317. UINT filterID,
  318. CString * pOutFileName
  319. )
  320. : CChooseFileNamePage(id, defaultID, extID, filterID, pOutFileName)
  321. {
  322. }
  323. BEGIN_MESSAGE_MAP(CChooseWriteFileName, CChooseFileNamePage)
  324. //{{AFX_MSG_MAP(CChooseWriteFileName)
  325. ON_BN_CLICKED(IDC_BROWSE_BTN, OnBrowseBtn)
  326. //}}AFX_MSG_MAP
  327. END_MESSAGE_MAP()
  328. BOOL
  329. CChooseWriteFileName::OnInitDialog()
  330. {
  331. GetDefaultFileName(m_FileName);
  332. return CChooseFileNamePage::OnInitDialog();
  333. }
  334. LRESULT
  335. CChooseWriteFileName::OnWizardNext()
  336. {
  337. LRESULT id = 0;
  338. UpdateData();
  339. CString fileName = m_FileName, strPathOnly;
  340. if (PathIsURL(fileName))
  341. {
  342. // we cannot use URLs
  343. id = 1;
  344. goto ExitPoint;
  345. }
  346. if (PathIsUNC(fileName))
  347. {
  348. if (PathIsUNCServer(fileName))
  349. {
  350. // path is incomplete
  351. id = 1;
  352. goto ExitPoint;
  353. }
  354. if (PathIsUNCServerShare(fileName))
  355. {
  356. // path is incomplete
  357. id = 1;
  358. goto ExitPoint;
  359. }
  360. }
  361. // If it is not an UNC, then make sure we have absolute path
  362. else if (PathIsRelative(fileName))
  363. {
  364. // We will make path from default drive root,
  365. // not from current directory
  366. CString path;
  367. if (0 != GetCurrentDirectory(MAX_PATH, path.GetBuffer(MAX_PATH)))
  368. {
  369. TCHAR szRoot[5];
  370. fileName = PathBuildRoot(szRoot, PathGetDriveNumber(path));
  371. PathAppend(fileName.GetBuffer(MAX_PATH), m_FileName);
  372. fileName.ReleaseBuffer();
  373. }
  374. else
  375. ASSERT(FALSE);
  376. }
  377. // Check if we already have file with this name
  378. if (PathFileExists(fileName))
  379. {
  380. // if it is directory, do nothing, file spec is incomplete
  381. if (PathIsDirectory(fileName))
  382. id = 1;
  383. else
  384. {
  385. if (!m_DoReplaceFile)
  386. id = AnswerIsYes(IDS_REPLACE_FILE, fileName) ? 0 : 1;
  387. }
  388. goto ExitPoint;
  389. }
  390. // File does not exists
  391. //
  392. // we should check, if target directory exists
  393. strPathOnly = fileName;
  394. if (strPathOnly.Right(1) != _T('\\'))
  395. {
  396. if (PathRemoveFileSpec(strPathOnly.GetBuffer(MAX_PATH)))
  397. {
  398. if (PathIsUNCServerShare(strPathOnly))
  399. {
  400. // check if we have write access to this
  401. if (GetFileAttributes(strPathOnly) & FILE_ATTRIBUTE_READONLY)
  402. {
  403. id = 1;
  404. goto ExitPoint;
  405. }
  406. }
  407. if (!PathIsDirectory(strPathOnly))
  408. {
  409. id = AnswerIsYes(IDS_ASK_CREATE_DIR, strPathOnly) ? 0 : 1;
  410. goto ExitPoint;
  411. }
  412. }
  413. strPathOnly.ReleaseBuffer();
  414. // If user entered filename with dot only (qqqq.) it means
  415. // that no extension should be used
  416. if (fileName.Right(1) == _T("."))
  417. {
  418. // remove this dot and check if this file exists
  419. fileName.ReleaseBuffer(fileName.GetLength() - 1);
  420. if (PathIsDirectory(fileName))
  421. {
  422. id = 1;
  423. }
  424. else if (PathFileExists(fileName))
  425. {
  426. id = AnswerIsYes(IDS_REPLACE_FILE, fileName) ? 0 : 1;
  427. }
  428. goto ExitPoint;
  429. }
  430. }
  431. else
  432. {
  433. // not clear, what to do with this
  434. id = 1;
  435. goto ExitPoint;
  436. }
  437. // It could be just a file name, without extension, try
  438. // with default extension now
  439. if (PathFindExtension(fileName) == NULL)
  440. {
  441. fileName += ext;
  442. if (PathIsDirectory(fileName))
  443. {
  444. id = 1;
  445. }
  446. else if (PathFileExists(fileName))
  447. {
  448. id = AnswerIsYes(IDS_REPLACE_FILE, fileName) ? 0 : 1;
  449. }
  450. goto ExitPoint;
  451. }
  452. ExitPoint:
  453. fileName.MakeLower();
  454. m_FileName = fileName;
  455. // prepare to go to the next page
  456. return DoWizardNext(id);
  457. }
  458. // I try to start FileOpen dialog in some reasonable directory
  459. //
  460. void CChooseWriteFileName::OnBrowseBtn()
  461. {
  462. CString strPath, strFile;
  463. UpdateData();
  464. strPath = m_FileName;
  465. if (!PathIsDirectory(strPath))
  466. {
  467. LPTSTR pPath = strPath.GetBuffer(strPath.GetLength());
  468. if (PathRemoveFileSpec(pPath))
  469. {
  470. // check if path part of filename exists
  471. if (PathIsDirectory(pPath))
  472. {
  473. // we will use non-path part of spec as a filename
  474. strFile = PathFindFileName(m_FileName);
  475. }
  476. else
  477. {
  478. // it is wrong path, use default one
  479. // TODO: actually I need to take from filespec all existent
  480. // chunks of path and filename, for example c:\aa\bb\cc\dd.txt,
  481. // if c:\aa\bb exists, then strPath should be set to c:\aa\bb,
  482. // and strFile to dd.txt
  483. strPath.Empty();
  484. }
  485. }
  486. else
  487. {
  488. // it is filename only
  489. strFile = m_FileName;
  490. strPath.Empty();
  491. }
  492. strPath.ReleaseBuffer();
  493. }
  494. CChooseFileNamePage::Browse(strPath, strFile);
  495. }
  496. /////////////////////////////////////////////////////////////////////////////
  497. // CChooseRespFile property page
  498. IMPLEMENT_DYNCREATE(CChooseRespFile, CChooseFileNamePage)
  499. CChooseRespFile::CChooseRespFile(CCertificate * pCert)
  500. : CChooseReadFileName(CChooseRespFile::IDD,
  501. IDS_RESP_FILE_DEFAULT,
  502. IDS_RESP_FILE_EXT,
  503. IDS_RESP_FILE_FILTER,
  504. &pCert->m_RespFileName),
  505. m_pCert(pCert)
  506. {
  507. //{{AFX_DATA_INIT(CChooseRespFile)
  508. // NOTE: the ClassWizard will add member initialization here
  509. //}}AFX_DATA_INIT
  510. }
  511. CChooseRespFile::~CChooseRespFile()
  512. {
  513. }
  514. void CChooseRespFile::FileNameChanged()
  515. {
  516. // we should remove any error messages now
  517. SetDlgItemText(IDC_ERROR_MSG, _T(""));
  518. GetDlgItem(IDC_ERROR_MSG)->InvalidateRect(NULL, TRUE);
  519. GetDlgItem(IDC_ERROR_MSG)->UpdateWindow();
  520. }
  521. void CChooseRespFile::DoDataExchange(CDataExchange* pDX)
  522. {
  523. CChooseReadFileName::DoDataExchange(pDX);
  524. //{{AFX_DATA_MAP(CChooseRespFile)
  525. //}}AFX_DATA_MAP
  526. }
  527. BEGIN_MESSAGE_MAP(CChooseRespFile, CChooseReadFileName)
  528. //{{AFX_MSG_MAP(CChooseRespFile)
  529. ON_WM_CTLCOLOR()
  530. //}}AFX_MSG_MAP
  531. END_MESSAGE_MAP()
  532. /////////////////////////////////////////////////////////////////////////////
  533. // CChooseRespFile message handlers
  534. HBRUSH
  535. CChooseRespFile::OnCtlColor(
  536. IN CDC * pDC,
  537. IN CWnd * pWnd,
  538. IN UINT nCtlColor
  539. )
  540. {
  541. if (pWnd->GetDlgCtrlID() == IDC_ERROR_MSG)
  542. {
  543. //
  544. // Default processing...
  545. //
  546. return CPropertyPage::OnCtlColor(pDC, pWnd, nCtlColor);
  547. }
  548. else
  549. return CIISWizardPage::OnCtlColor(pDC, pWnd, nCtlColor);
  550. }
  551. LRESULT CChooseRespFile::OnWizardNext()
  552. {
  553. LRESULT id = 1;
  554. // Parent class will check all about files
  555. if (1 != CChooseReadFileName::OnWizardNext())
  556. {
  557. m_pCert->m_RespFileName = m_FileName;
  558. if (m_pCert->GetResponseCert() == NULL)
  559. {
  560. CString strInstanceName;
  561. CString str;
  562. // it is possible, that this is wrong response file
  563. // we will try to inform user, for which site this response
  564. // file was created
  565. if (m_pCert->FindInstanceNameForResponse(strInstanceName))
  566. {
  567. AfxFormatString1(str, IDS_CERTKEY_MISMATCH_ERROR1, strInstanceName);
  568. }
  569. // it is possible that this certificate response file already have been processed
  570. // in this case it should be in MY store
  571. else if (m_pCert->IsResponseInstalled(strInstanceName))
  572. {
  573. if (!strInstanceName.IsEmpty())
  574. AfxFormatString1(str,
  575. IDS_CERTKEY_ALREADY_INSTALLED_WHERE, strInstanceName);
  576. else
  577. str.LoadString(IDS_CERTKEY_ALREADY_INSTALLED);
  578. }
  579. else
  580. {
  581. // request probably was canceled
  582. str.LoadString(IDS_CERTKEY_MISMATCH_ERROR2);
  583. }
  584. SetDlgItemText(IDC_ERROR_MSG, str);
  585. SetWizardButtons(PSWIZB_BACK);
  586. }
  587. else
  588. id = IDD_PAGE_NEXT;
  589. }
  590. return id;
  591. }
  592. LRESULT
  593. CChooseRespFile::OnWizardBack()
  594. {
  595. return IDD_PAGE_PREV;
  596. }
  597. /////////////////////////////////////////////////////////////////////////////
  598. // CChooseReqFile property page
  599. IMPLEMENT_DYNCREATE(CChooseReqFile, CChooseWriteFileName)
  600. CChooseReqFile::CChooseReqFile(CCertificate * pCert)
  601. : CChooseWriteFileName(CChooseReqFile::IDD,
  602. IDS_REQ_FILE_DEFAULT,
  603. IDS_REQ_FILE_EXT,
  604. IDS_REQ_FILE_FILTER,
  605. &pCert->m_ReqFileName),
  606. m_pCert(pCert)
  607. {
  608. //{{AFX_DATA_INIT(CChooseRespFile)
  609. //}}AFX_DATA_INIT
  610. }
  611. CChooseReqFile::~CChooseReqFile()
  612. {
  613. }
  614. void CChooseReqFile::DoDataExchange(CDataExchange* pDX)
  615. {
  616. CChooseWriteFileName::DoDataExchange(pDX);
  617. //{{AFX_DATA_MAP(CChooseRespFile)
  618. //}}AFX_DATA_MAP
  619. }
  620. LRESULT
  621. CChooseReqFile::OnWizardBack()
  622. {
  623. return IDD_PAGE_PREV;
  624. }
  625. LRESULT
  626. CChooseReqFile::OnWizardNext()
  627. {
  628. if (CChooseWriteFileName::OnWizardNext() != 1)
  629. return IDD_PAGE_NEXT;
  630. return 1;
  631. }
  632. BEGIN_MESSAGE_MAP(CChooseReqFile, CChooseWriteFileName)
  633. //{{AFX_MSG_MAP(CChooseReqFile)
  634. //}}AFX_MSG_MAP
  635. END_MESSAGE_MAP()
  636. /////////////////////////////////////////////////////////////////////////////
  637. // CChooseReqFile message handlers
  638. /////////////////////////////////////////////////////////////////////////////
  639. // CChooseKeyFile property page
  640. IMPLEMENT_DYNCREATE(CChooseKeyFile, CChooseReadFileName)
  641. CChooseKeyFile::CChooseKeyFile(CCertificate * pCert)
  642. : CChooseReadFileName(CChooseKeyFile::IDD,
  643. IDS_KEY_FILE_DEFAULT,
  644. IDS_KEY_FILE_EXT,
  645. IDS_KEY_FILE_FILTER,
  646. &pCert->m_KeyFileName),
  647. m_pCert(pCert)
  648. {
  649. }
  650. CChooseKeyFile::~CChooseKeyFile()
  651. {
  652. }
  653. void CChooseKeyFile::DoDataExchange(CDataExchange* pDX)
  654. {
  655. CChooseReadFileName::DoDataExchange(pDX);
  656. //{{AFX_DATA_MAP(CChooseRespFile)
  657. //}}AFX_DATA_MAP
  658. }
  659. LRESULT
  660. CChooseKeyFile::OnWizardBack()
  661. {
  662. return IDD_PAGE_PREV;
  663. }
  664. LRESULT
  665. CChooseKeyFile::OnWizardNext()
  666. {
  667. CString strFileName = m_pCert->m_KeyFileName;
  668. if (CChooseReadFileName::OnWizardNext() != 1)
  669. {
  670. // if file name was changed then probably password is wrong now
  671. // and if cert context was imported before -- it is also invalid
  672. //
  673. if (m_pCert->m_KeyFileName.CompareNoCase(strFileName))
  674. {
  675. m_pCert->m_KeyPassword.Empty();
  676. m_pCert->DeleteKeyRingCert();
  677. }
  678. return IDD_PAGE_NEXT;
  679. }
  680. return 1;
  681. }
  682. BEGIN_MESSAGE_MAP(CChooseKeyFile, CChooseReadFileName)
  683. //{{AFX_MSG_MAP(CChooseKeyFile)
  684. //}}AFX_MSG_MAP
  685. END_MESSAGE_MAP()
  686. /////////////////////////////////////////////////////////////////////////////
  687. // CChooseKeyFile message handlers