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.

194 lines
5.4 KiB

  1. // EdtRulEl.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "certmap.h"
  5. #include "EdtRulEl.h"
  6. extern "C"
  7. {
  8. #include <wincrypt.h>
  9. #include <sslsp.h>
  10. }
  11. #include "Iismap.hxx"
  12. #include "Iiscmr.hxx"
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CEditRuleElement dialog
  20. //---------------------------------------------------------------------------
  21. CEditRuleElement::CEditRuleElement(CWnd* pParent /*=NULL*/)
  22. : CDialog(CEditRuleElement::IDD, pParent)
  23. {
  24. //{{AFX_DATA_INIT(CEditRuleElement)
  25. m_sz_criteria = _T("");
  26. m_int_field = -1;
  27. m_sz_subfield = _T("");
  28. m_bool_match_case = FALSE;
  29. //}}AFX_DATA_INIT
  30. }
  31. //---------------------------------------------------------------------------
  32. void CEditRuleElement::DoDataExchange(CDataExchange* pDX)
  33. {
  34. CDialog::DoDataExchange(pDX);
  35. //{{AFX_DATA_MAP(CEditRuleElement)
  36. DDX_Control(pDX, IDC_SUBFIELD, m_ccombobox_subfield);
  37. DDX_Control(pDX, IDC_FIELDS, m_ccombobox_field);
  38. DDX_Text(pDX, IDC_CRITERIA, m_sz_criteria);
  39. DDX_CBIndex(pDX, IDC_FIELDS, m_int_field);
  40. DDX_CBString(pDX, IDC_SUBFIELD, m_sz_subfield);
  41. DDX_Check(pDX, IDC_CHK_CAPITALIZATION, m_bool_match_case);
  42. //}}AFX_DATA_MAP
  43. }
  44. //---------------------------------------------------------------------------
  45. BEGIN_MESSAGE_MAP(CEditRuleElement, CDialog)
  46. //{{AFX_MSG_MAP(CEditRuleElement)
  47. ON_CBN_SELCHANGE(IDC_FIELDS, OnSelchangeFields)
  48. ON_EN_CHANGE(IDC_SUBFIELD, OnChangeSubfield)
  49. ON_BN_CLICKED(IDC_BTN_HELP, OnBtnHelp)
  50. //}}AFX_MSG_MAP
  51. ON_COMMAND(ID_HELP_FINDER, OnBtnHelp)
  52. ON_COMMAND(ID_HELP, OnBtnHelp)
  53. ON_COMMAND(ID_CONTEXT_HELP, OnBtnHelp)
  54. ON_COMMAND(ID_DEFAULT_HELP, OnBtnHelp)
  55. END_MESSAGE_MAP()
  56. /////////////////////////////////////////////////////////////////////////////
  57. // CEditRuleElement message handlers
  58. //---------------------------------------------------------------------------
  59. BOOL CEditRuleElement::OnInitDialog()
  60. {
  61. CString sz;
  62. // call the parental oninitdialog
  63. BOOL f = CDialog::OnInitDialog();
  64. // initialize the elements in the drop-list
  65. // loop the list of CERT_FIELD_IDs, adding each to the drop-list
  66. for ( UINT id = CERT_FIELD_ISSUER; id < CERT_FIELD_LAST; id++ )
  67. {
  68. // bug 154957 requests that we no longer support mapping on the
  69. // serial number. This makes sense anyway as mapping to the serial
  70. // numbers is better off done as 1::1 mapping. If the bug doesn't
  71. // make this conclusion clear enough upon reading, it is the
  72. // interpretation that MikeHow has handed down.
  73. if ( id == CERT_FIELD_SERIAL_NUMBER )
  74. continue;
  75. // get the string associated with the id
  76. sz = MapIdToField( (CERT_FIELD_ID)id );
  77. m_ccombobox_field.AddString( sz );
  78. }
  79. // initialize the list of known subfields
  80. id = 0;
  81. //
  82. // UNICODE conversion -- RonaldM
  83. //
  84. LPCSTR psz;
  85. while ( psz = EnumerateKnownSubFields(id) )
  86. {
  87. CString str(psz);
  88. // append it to the drop-list
  89. m_ccombobox_subfield.AddString( str );
  90. // increment id
  91. id++;
  92. }
  93. UpdateData( FALSE );
  94. // store the initial value of the sub-field
  95. m_szTempSubStorage = m_sz_subfield;
  96. // make sure to check the subfields
  97. OnSelchangeFields();
  98. // return the answer
  99. return f;
  100. }
  101. //---------------------------------------------------------------------------
  102. // make sure that, if there is a sub-field, that it is valid
  103. //
  104. void CEditRuleElement::OnOK()
  105. {
  106. UpdateData( TRUE );
  107. //
  108. // UNICODE/ANSI conversion - RonaldM
  109. //
  110. USES_CONVERSION;
  111. // test the sub-field flag for the newly selected field type
  112. DWORD flags = GetIdFlags( (CERT_FIELD_ID)m_int_field );
  113. BOOL fSubs = flags & CERT_FIELD_FLAG_CONTAINS_SUBFIELDS;
  114. // if there are sub-fields, test their validity
  115. if ( fSubs )
  116. {
  117. CString szTest(MapSubFieldToAsn1( T2A((LPTSTR)(LPCTSTR)m_sz_subfield) ));
  118. // if there is NO match, tell the user
  119. if ( szTest.IsEmpty() )
  120. {
  121. AfxMessageBox( IDS_INVALID_SUBFIELD );
  122. return;
  123. }
  124. }
  125. // it is valid
  126. CDialog::OnOK();
  127. }
  128. //---------------------------------------------------------------------------
  129. void CEditRuleElement::OnSelchangeFields()
  130. {
  131. UpdateData( TRUE );
  132. // test the sub-field flag for the newly selected field type
  133. DWORD flags = GetIdFlags( (CERT_FIELD_ID)m_int_field );
  134. BOOL fSubs = flags & CERT_FIELD_FLAG_CONTAINS_SUBFIELDS;
  135. // set the correct enable state
  136. BOOL fWasEnabled = m_ccombobox_subfield.EnableWindow( fSubs );
  137. // restore the value if necessary
  138. if ( fSubs )
  139. {
  140. m_sz_subfield = m_szTempSubStorage;
  141. UpdateData( FALSE );
  142. }
  143. else
  144. {
  145. m_szTempSubStorage = m_sz_subfield;
  146. m_sz_subfield.Empty();
  147. UpdateData( FALSE );
  148. }
  149. }
  150. //---------------------------------------------------------------------------
  151. void CEditRuleElement::OnChangeSubfield()
  152. {
  153. m_szTempSubStorage = m_sz_subfield;
  154. }
  155. //---------------------------------------------------------------------------
  156. void CEditRuleElement::OnBtnHelp()
  157. {
  158. WinHelp( HIDD_CERTMAP_RUL_ELEMENT );
  159. }