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.

139 lines
3.2 KiB

  1. // OrgInfoPage.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "CertWiz.h"
  5. #include "OrgInfoPage.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. void DDV_MaxCharsCombo(CDataExchange* pDX, UINT ControlID, CString const& value, int nChars)
  15. {
  16. ASSERT(nChars >= 1); // allow them something
  17. if (pDX->m_bSaveAndValidate && value.GetLength() > nChars)
  18. {
  19. DDV_MaxChars(pDX, value, nChars);
  20. }
  21. else
  22. {
  23. // limit the control max-chars automatically
  24. pDX->m_pDlgWnd->SendDlgItemMessage(ControlID, CB_LIMITTEXT, nChars, 0);
  25. }
  26. }
  27. /////////////////////////////////////////////////////////////////////////////
  28. // COrgInfoPage property page
  29. IMPLEMENT_DYNCREATE(COrgInfoPage, CIISWizardPage)
  30. COrgInfoPage::COrgInfoPage(CCertificate * pCert)
  31. : CIISWizardPage(COrgInfoPage::IDD, IDS_CERTWIZ, TRUE),
  32. m_pCert(pCert)
  33. {
  34. //{{AFX_DATA_INIT(COrgInfoPage)
  35. m_OrgName = _T("");
  36. m_OrgUnit = _T("");
  37. //}}AFX_DATA_INIT
  38. }
  39. COrgInfoPage::~COrgInfoPage()
  40. {
  41. }
  42. void COrgInfoPage::DoDataExchange(CDataExchange* pDX)
  43. {
  44. CIISWizardPage::DoDataExchange(pDX);
  45. //{{AFX_DATA_MAP(COrgInfoPage)
  46. DDX_Text(pDX, IDC_NEWKEY_ORG, m_OrgName);
  47. DDV_MaxCharsCombo(pDX, IDC_NEWKEY_ORG, m_OrgName, 64);
  48. DDX_Text(pDX, IDC_NEWKEY_ORGUNIT, m_OrgUnit);
  49. DDV_MaxCharsCombo(pDX, IDC_NEWKEY_ORGUNIT, m_OrgUnit, 64);
  50. //}}AFX_DATA_MAP
  51. }
  52. LRESULT
  53. COrgInfoPage::OnWizardBack()
  54. {
  55. return m_pCert->m_DefaultCSP ? IDD_PAGE_PREV : IDD_PREV_CSP;
  56. }
  57. LRESULT
  58. COrgInfoPage::OnWizardNext()
  59. {
  60. LRESULT lret = 1;
  61. UpdateData(TRUE);
  62. m_pCert->m_Organization = m_OrgName;
  63. m_pCert->m_OrganizationUnit = m_OrgUnit;
  64. CString buf;
  65. buf.LoadString(IDS_INVALID_X500_CHARACTERS);
  66. if (!IsValidX500Chars(m_OrgName))
  67. {
  68. GetDlgItem(IDC_NEWKEY_ORG)->SetFocus();
  69. AfxMessageBox(buf, MB_OK);
  70. }
  71. else if (!IsValidX500Chars(m_OrgUnit))
  72. {
  73. GetDlgItem(IDC_NEWKEY_ORGUNIT)->SetFocus();
  74. AfxMessageBox(buf, MB_OK);
  75. }
  76. else
  77. {
  78. lret = IDD_PAGE_NEXT;
  79. }
  80. return lret;
  81. }
  82. BOOL
  83. COrgInfoPage::OnSetActive()
  84. {
  85. SetButtons();
  86. return CIISWizardPage::OnSetActive();
  87. }
  88. void COrgInfoPage::SetButtons()
  89. {
  90. UpdateData(TRUE);
  91. SetWizardButtons(m_OrgName.IsEmpty() || m_OrgUnit.IsEmpty() ?
  92. PSWIZB_BACK : PSWIZB_BACK | PSWIZB_NEXT);
  93. }
  94. BEGIN_MESSAGE_MAP(COrgInfoPage, CIISWizardPage)
  95. //{{AFX_MSG_MAP(COrgInfoPage)
  96. ON_CBN_EDITCHANGE(IDC_NEWKEY_ORG, OnChangeName)
  97. ON_CBN_EDITCHANGE(IDC_NEWKEY_ORGUNIT, OnChangeName)
  98. //}}AFX_MSG_MAP
  99. END_MESSAGE_MAP()
  100. /////////////////////////////////////////////////////////////////////////////
  101. // COrgInfoPage message handlers
  102. BOOL COrgInfoPage::OnInitDialog()
  103. {
  104. ASSERT(m_pCert != NULL);
  105. m_OrgName = m_pCert->m_Organization;
  106. m_OrgUnit = m_pCert->m_OrganizationUnit;
  107. CIISWizardPage::OnInitDialog();
  108. // Load MRU names
  109. LoadMRUToCombo(this, IDC_NEWKEY_ORG, szOrganizationMRU, m_OrgName, MAX_MRU);
  110. LoadMRUToCombo(this, IDC_NEWKEY_ORGUNIT, szOrganizationUnitMRU, m_OrgUnit, MAX_MRU);
  111. GetDlgItem(IDC_NEWKEY_ORG)->SetFocus();
  112. return FALSE;
  113. }
  114. void COrgInfoPage::OnChangeName()
  115. {
  116. SetButtons();
  117. }