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.

126 lines
3.2 KiB

  1. // ManageCertPage.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "CertWiz.h"
  5. #include "ManageCertPage.h"
  6. #include "Certificat.h"
  7. #include "certutil.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CManageCertPage property page
  15. IMPLEMENT_DYNCREATE(CManageCertPage, CIISWizardPage)
  16. CManageCertPage::CManageCertPage(CCertificate * pCert)
  17. : CIISWizardPage(CManageCertPage::IDD, IDS_CERTWIZ, TRUE),
  18. m_pCert(pCert)
  19. {
  20. //{{AFX_DATA_INIT(CManageCertPage)
  21. m_Index = -1;
  22. //}}AFX_DATA_INIT
  23. }
  24. CManageCertPage::~CManageCertPage()
  25. {
  26. }
  27. void CManageCertPage::DoDataExchange(CDataExchange* pDX)
  28. {
  29. CIISWizardPage::DoDataExchange(pDX);
  30. //{{AFX_DATA_MAP(CManageCertPage)
  31. DDX_Radio(pDX, IDC_RENEW_CERT, m_Index);
  32. //}}AFX_DATA_MAP
  33. }
  34. BEGIN_MESSAGE_MAP(CManageCertPage, CIISWizardPage)
  35. //{{AFX_MSG_MAP(CManageCertPage)
  36. //}}AFX_MSG_MAP
  37. END_MESSAGE_MAP()
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CManageCertPage message handlers
  40. LRESULT CManageCertPage::OnWizardBack()
  41. {
  42. return IDD_PAGE_PREV;
  43. }
  44. LRESULT CManageCertPage::OnWizardNext()
  45. {
  46. LRESULT res = 1;
  47. UpdateData();
  48. switch (m_Index)
  49. {
  50. case CONTINUE_RENEW:
  51. m_pCert->SetStatusCode(CCertificate::REQUEST_RENEW_CERT);
  52. res = IDD_PAGE_NEXT_RENEW;
  53. break;
  54. case CONTINUE_REMOVE:
  55. res = IDD_PAGE_NEXT_REMOVE;
  56. break;
  57. case CONTINUE_REPLACE:
  58. m_pCert->SetStatusCode(CCertificate::REQUEST_REPLACE_CERT);
  59. res = IDD_PAGE_NEXT_REPLACE;
  60. break;
  61. case CONTINUE_EXPORT_PFX:
  62. m_pCert->SetStatusCode(CCertificate::REQUEST_EXPORT_CERT);
  63. res = IDD_PAGE_NEXT_EXPORT_PFX;
  64. break;
  65. case CONTINUE_COPY_MOVE_TO_REMOTE:
  66. m_pCert->SetStatusCode(CCertificate::REQUEST_COPY_MOVE_TO_REMOTE);
  67. res = IDD_PAGE_NEXT_COPY_MOVE_TO_REMOTE;
  68. break;
  69. }
  70. return res;
  71. }
  72. BOOL CManageCertPage::OnSetActive()
  73. {
  74. m_pCert->SetStatusCode(CCertificate::REQUEST_UNDEFINED);
  75. SetWizardButtons(PSWIZB_BACK | PSWIZB_NEXT);
  76. return CIISWizardPage::OnSetActive();
  77. }
  78. BOOL CManageCertPage::OnInitDialog()
  79. {
  80. m_Index = 0;
  81. CIISWizardPage::OnInitDialog();
  82. // we should make some checks and disable some buttons
  83. if (m_pCert->MyStoreCertCount() == 0)
  84. {
  85. ASSERT(NULL != GetDlgItem(IDC_REPLACE_CERT));
  86. GetDlgItem(IDC_REPLACE_CERT)->EnableWindow(FALSE);
  87. }
  88. // Enable or disable controls based on weather certobj is installed
  89. GetDlgItem(IDC_EXPORT_PFX_CERT)->EnableWindow(m_pCert->m_CertObjInstalled);
  90. GetDlgItem(IDC_EXPORT_PFX_CERT2)->EnableWindow(m_pCert->m_CertObjInstalled);
  91. if (m_pCert->m_CertObjInstalled)
  92. {
  93. BOOL fExportable = FALSE;
  94. GetDlgItem(IDC_EXPORT_PFX_CERT)->ShowWindow(SW_SHOW);
  95. GetDlgItem(IDC_EXPORT_PFX_CERT2)->ShowWindow(SW_SHOW);
  96. fExportable = IsCertExportable(m_pCert->GetInstalledCert());
  97. // if it is not exportable, then grey it out
  98. GetDlgItem(IDC_EXPORT_PFX_CERT)->EnableWindow(fExportable);
  99. GetDlgItem(IDC_EXPORT_PFX_CERT2)->EnableWindow(fExportable);
  100. }
  101. // Turn off for workstation.
  102. if (TRUE == IsWhistlerWorkstation())
  103. {
  104. GetDlgItem(IDC_EXPORT_PFX_CERT)->ShowWindow(SW_HIDE);
  105. GetDlgItem(IDC_EXPORT_PFX_CERT2)->ShowWindow(SW_HIDE);
  106. }
  107. return TRUE;
  108. }