Leaked source code of windows server 2003
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.

164 lines
3.8 KiB

  1. // GeoInfoPage.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "CertWiz.h"
  5. #include "GeoInfoPage.h"
  6. #include "Certificat.h"
  7. #include "mru.h"
  8. #include "strutil.h"
  9. #include "CertUtil.h"
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CGeoInfoPage property page
  17. IMPLEMENT_DYNCREATE(CGeoInfoPage, CIISWizardPage)
  18. CGeoInfoPage::CGeoInfoPage(CCertificate * pCert)
  19. : CIISWizardPage(CGeoInfoPage::IDD, IDS_CERTWIZ, TRUE),
  20. m_pCert(pCert)
  21. {
  22. //{{AFX_DATA_INIT(CGeoInfoPage)
  23. m_Locality = _T("");
  24. m_State = _T("");
  25. m_Country = _T("");
  26. //}}AFX_DATA_INIT
  27. }
  28. CGeoInfoPage::~CGeoInfoPage()
  29. {
  30. }
  31. void CGeoInfoPage::DoDataExchange(CDataExchange* pDX)
  32. {
  33. CIISWizardPage::DoDataExchange(pDX);
  34. //{{AFX_DATA_MAP(CGeoInfoPage)
  35. DDX_Text(pDX, IDC_NEWKEY_LOCALITY, m_Locality);
  36. DDV_MaxCharsCombo(pDX, IDC_NEWKEY_LOCALITY, m_Locality, 64);
  37. DDX_Text(pDX, IDC_NEWKEY_STATE, m_State);
  38. DDV_MaxCharsCombo(pDX, IDC_NEWKEY_STATE, m_State, 64);
  39. DDX_CBString(pDX, IDC_NEWKEY_COUNTRY, m_Country);
  40. //}}AFX_DATA_MAP
  41. }
  42. LRESULT
  43. CGeoInfoPage::OnWizardPrev()
  44. {
  45. return IDD_PAGE_PREV;
  46. // return m_pCert->m_CAType == CCertificate::CA_OFFLINE ?
  47. // IDD_PAGE_PREV_FILE : IDD_PAGE_PREV_ONLINE;
  48. }
  49. LRESULT
  50. CGeoInfoPage::OnWizardNext()
  51. {
  52. LRESULT lres = 1;
  53. ASSERT(m_pCert != NULL);
  54. UpdateData(TRUE);
  55. m_pCert->m_Locality = m_Locality;
  56. m_pCert->m_State = m_State;
  57. m_countryCombo.GetSelectedCountry(m_pCert->m_Country);
  58. CString buf;
  59. buf.LoadString(IDS_INVALID_X500_CHARACTERS);
  60. if (!IsValidX500Chars(m_pCert->m_Country))
  61. {
  62. GetDlgItem(IDC_NEWKEY_COUNTRY)->SetFocus();
  63. AfxMessageBox(buf, MB_OK);
  64. }
  65. else if (!IsValidX500Chars(m_State))
  66. {
  67. GetDlgItem(IDC_NEWKEY_STATE)->SetFocus();
  68. AfxMessageBox(buf, MB_OK);
  69. }
  70. else if (!IsValidX500Chars(m_Locality))
  71. {
  72. GetDlgItem(IDC_NEWKEY_LOCALITY)->SetFocus();
  73. AfxMessageBox(buf, MB_OK);
  74. }
  75. else
  76. {
  77. if (m_pCert->m_CAType == CCertificate::CA_OFFLINE)
  78. {
  79. lres = IDD_PAGE_NEXT_FILE;
  80. }
  81. else
  82. {
  83. lres = IDD_PAGE_NEXT_ONLINE;
  84. #ifdef ENABLE_W3SVC_SSL_PAGE
  85. if (IsWebServerType(m_pCert->m_WebSiteInstanceName))
  86. {
  87. lres = IDD_PAGE_NEXT_INSTALL_W3SVC_ONLY;
  88. }
  89. #endif
  90. }
  91. }
  92. return lres;
  93. }
  94. BOOL CGeoInfoPage::OnSetActive()
  95. {
  96. SetButtons();
  97. return CIISWizardPage::OnSetActive();
  98. }
  99. void CGeoInfoPage::SetButtons()
  100. {
  101. UpdateData(TRUE);
  102. SetWizardButtons(m_Country.IsEmpty() || m_Locality.IsEmpty() ?
  103. PSWIZB_BACK : PSWIZB_BACK | PSWIZB_NEXT);
  104. }
  105. BEGIN_MESSAGE_MAP(CGeoInfoPage, CIISWizardPage)
  106. //{{AFX_MSG_MAP(CGeoInfoPage)
  107. ON_CBN_EDITCHANGE(IDC_NEWKEY_LOCALITY, OnChangeNewkeyLocality)
  108. ON_CBN_EDITCHANGE(IDC_NEWKEY_STATE, OnChangeNewkeyState)
  109. ON_CBN_EDITCHANGE(IDC_NEWKEY_COUNTRY, OnEditchangeNewkeyCountry)
  110. //}}AFX_MSG_MAP
  111. END_MESSAGE_MAP()
  112. /////////////////////////////////////////////////////////////////////////////
  113. // CGeoInfoPage message handlers
  114. BOOL CGeoInfoPage::OnInitDialog()
  115. {
  116. ASSERT(m_pCert != NULL);
  117. m_Locality = m_pCert->m_Locality;
  118. m_State = m_pCert->m_State;
  119. m_countryCombo.SubclassDlgItem(IDC_NEWKEY_COUNTRY, this);
  120. CIISWizardPage::OnInitDialog();
  121. m_countryCombo.Init();
  122. m_countryCombo.SetSelectedCountry(m_pCert->m_Country);
  123. // Load MRU names
  124. LoadMRUToCombo(this, IDC_NEWKEY_STATE, szStateMRU, m_State, MAX_MRU);
  125. LoadMRUToCombo(this, IDC_NEWKEY_LOCALITY, szLocalityMRU, m_Locality, MAX_MRU);
  126. SetButtons();
  127. GetDlgItem(IDC_NEWKEY_COUNTRY)->SetFocus();
  128. return FALSE;
  129. }
  130. void CGeoInfoPage::OnChangeNewkeyLocality()
  131. {
  132. SetButtons();
  133. }
  134. void CGeoInfoPage::OnChangeNewkeyState()
  135. {
  136. SetButtons();
  137. }
  138. void CGeoInfoPage::OnEditchangeNewkeyCountry()
  139. {
  140. SetButtons();
  141. }