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.

153 lines
3.2 KiB

  1. // SiteNamePage.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "CertWiz.h"
  5. #include "SiteNamePage.h"
  6. #include "Certificat.h"
  7. #include "strutil.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CSiteNamePage property page
  15. IMPLEMENT_DYNCREATE(CSiteNamePage, CIISWizardPage)
  16. CSiteNamePage::CSiteNamePage(CCertificate * pCert)
  17. : CIISWizardPage(CSiteNamePage::IDD, IDS_CERTWIZ, TRUE),
  18. m_pCert(pCert)
  19. {
  20. //{{AFX_DATA_INIT(CSiteNamePage)
  21. m_CommonName = _T("");
  22. //}}AFX_DATA_INIT
  23. }
  24. CSiteNamePage::~CSiteNamePage()
  25. {
  26. }
  27. void CSiteNamePage::DoDataExchange(CDataExchange* pDX)
  28. {
  29. CIISWizardPage::DoDataExchange(pDX);
  30. //{{AFX_DATA_MAP(CSiteNamePage)
  31. DDX_Text(pDX, IDC_NEWKEY_COMMONNAME, m_CommonName);
  32. DDV_MaxChars(pDX, m_CommonName, 64);
  33. //}}AFX_DATA_MAP
  34. }
  35. LRESULT
  36. CSiteNamePage::OnWizardPrev()
  37. /*++
  38. Routine Description:
  39. Prev button handler
  40. Arguments:
  41. None
  42. Return Value:
  43. 0 to automatically advance to the prev page;
  44. 1 to prevent the page from changing.
  45. To jump to a page other than the prev one,
  46. return the identifier of the dialog to be displayed.
  47. --*/
  48. {
  49. return IDD_PAGE_PREV;
  50. }
  51. LRESULT
  52. CSiteNamePage::OnWizardNext()
  53. /*++
  54. Routine Description:
  55. Next button handler
  56. Arguments:
  57. None
  58. Return Value:
  59. 0 to automatically advance to the next page;
  60. 1 to prevent the page from changing.
  61. To jump to a page other than the next one,
  62. return the identifier of the dialog to be displayed.
  63. --*/
  64. {
  65. LRESULT lres = 1;
  66. UpdateData(TRUE);
  67. m_pCert->m_CommonName = m_CommonName;
  68. CString buf;
  69. buf.LoadString(IDS_INVALID_X500_CHARACTERS);
  70. if (!IsValidX500Chars(m_CommonName))
  71. {
  72. GetDlgItem(IDC_NEWKEY_COMMONNAME)->SetFocus();
  73. AfxMessageBox(buf, MB_OK);
  74. }
  75. else
  76. {
  77. lres = IDD_PAGE_NEXT;
  78. }
  79. return lres;
  80. }
  81. BOOL
  82. CSiteNamePage::OnSetActive()
  83. /*++
  84. Routine Description:
  85. Activation handler
  86. We could have empty name field on entrance, so we should
  87. disable Back button
  88. Arguments:
  89. None
  90. Return Value:
  91. TRUE for success, FALSE for failure
  92. --*/
  93. {
  94. ASSERT(m_pCert != NULL);
  95. m_CommonName = m_pCert->m_CommonName;
  96. UpdateData(FALSE);
  97. SetWizardButtons(m_CommonName.IsEmpty() ?
  98. PSWIZB_BACK : PSWIZB_BACK | PSWIZB_NEXT);
  99. return CIISWizardPage::OnSetActive();
  100. }
  101. BOOL
  102. CSiteNamePage::OnKillActive()
  103. /*++
  104. Routine Description:
  105. Activation handler
  106. We could leave this page only if we have good names
  107. entered or when Back button is clicked. In both cases
  108. we should enable both buttons
  109. Arguments:
  110. None
  111. Return Value:
  112. TRUE for success, FALSE for failure
  113. --*/
  114. {
  115. SetWizardButtons(PSWIZB_BACK | PSWIZB_NEXT);
  116. return CIISWizardPage::OnSetActive();
  117. }
  118. BEGIN_MESSAGE_MAP(CSiteNamePage, CIISWizardPage)
  119. //{{AFX_MSG_MAP(CSiteNamePage)
  120. ON_EN_CHANGE(IDC_NEWKEY_COMMONNAME, OnEditchangeNewkeyCommonname)
  121. //}}AFX_MSG_MAP
  122. END_MESSAGE_MAP()
  123. /////////////////////////////////////////////////////////////////////////////
  124. // CSiteNamePage message handlers
  125. void CSiteNamePage::OnEditchangeNewkeyCommonname()
  126. {
  127. UpdateData(TRUE);
  128. SetWizardButtons(m_CommonName.IsEmpty() ?
  129. PSWIZB_BACK : PSWIZB_BACK | PSWIZB_NEXT);
  130. }