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.

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