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.

138 lines
3.4 KiB

  1. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Microsoft Windows
  3. Copyright (C) Microsoft Corporation, 1995 - 1999.
  4. File: Template.h.
  5. Content: Declaration of the CTemplate.
  6. History: 10-02-2001 dsie created
  7. ------------------------------------------------------------------------------*/
  8. #ifndef __TEMPLATE_H_
  9. #define __TEMPLATE_H_
  10. #include "Resource.h"
  11. #include "Error.h"
  12. #include "Lock.h"
  13. #include "Debug.h"
  14. ////////////////////////////////////////////////////////////////////////////////
  15. //
  16. // Exported functions.
  17. //
  18. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  19. Function : CreateTemplateObject
  20. Synopsis : Create a ITemplate object and populate the porperties with
  21. data from the key usage extension of the specified certificate.
  22. Parameter: PCCERT_CONTEXT pCertContext - Pointer to CERT_CONTEXT.
  23. ITemplate ** ppITemplate - Pointer to pointer to ITemplate object.
  24. Remark :
  25. ------------------------------------------------------------------------------*/
  26. HRESULT CreateTemplateObject (PCCERT_CONTEXT pCertContext,
  27. ITemplate ** ppITemplate);
  28. ////////////////////////////////////////////////////////////////////////////////
  29. //
  30. // CTemplate
  31. //
  32. class ATL_NO_VTABLE CTemplate :
  33. public CComObjectRootEx<CComMultiThreadModel>,
  34. public CComCoClass<CTemplate, &CLSID_Template>,
  35. public ICAPICOMError<CTemplate, &IID_ITemplate>,
  36. public IDispatchImpl<ITemplate, &IID_ITemplate, &LIBID_CAPICOM,
  37. CAPICOM_MAJOR_VERSION, CAPICOM_MINOR_VERSION>
  38. {
  39. public:
  40. CTemplate()
  41. {
  42. }
  43. DECLARE_NO_REGISTRY()
  44. DECLARE_PROTECT_FINAL_CONSTRUCT()
  45. BEGIN_COM_MAP(CTemplate)
  46. COM_INTERFACE_ENTRY(ITemplate)
  47. COM_INTERFACE_ENTRY(IDispatch)
  48. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  49. END_COM_MAP()
  50. BEGIN_CATEGORY_MAP(CTemplate)
  51. END_CATEGORY_MAP()
  52. HRESULT FinalConstruct()
  53. {
  54. HRESULT hr;
  55. if (FAILED(hr = m_Lock.Initialized()))
  56. {
  57. DebugTrace("Error [%#x]: Critical section could not be created for Template object.\n", hr);
  58. return hr;
  59. }
  60. m_bIsPresent = VARIANT_FALSE;
  61. m_bIsCritical = VARIANT_FALSE;
  62. m_pIOID = NULL;
  63. m_dwMajorVersion = 0;
  64. m_dwMinorVersion = 0;
  65. return S_OK;
  66. }
  67. void FinalRelease()
  68. {
  69. m_pIOID.Release();
  70. }
  71. //
  72. // Template
  73. //
  74. public:
  75. STDMETHOD(get_IsPresent)
  76. (/*[out, retval]*/ VARIANT_BOOL * pVal);
  77. STDMETHOD(get_IsCritical)
  78. (/*[out, retval]*/ VARIANT_BOOL * pVal);
  79. STDMETHOD(get_Name)
  80. (/*[out, retval]*/ BSTR * pVal);
  81. STDMETHOD(get_OID)
  82. (/*[out, retval]*/ IOID ** pVal);
  83. STDMETHOD(get_MajorVersion)
  84. (/*[out, retval]*/ long * pVal);
  85. STDMETHOD(get_MinorVersion)
  86. (/*[out, retval]*/ long * pVal);
  87. //
  88. // Non COM functions.
  89. //
  90. STDMETHOD(Init)
  91. (PCCERT_CONTEXT pCertContext);
  92. private:
  93. CLock m_Lock;
  94. VARIANT_BOOL m_bIsPresent;
  95. VARIANT_BOOL m_bIsCritical;
  96. CComBSTR m_bstrName;
  97. CComPtr<IOID> m_pIOID;
  98. DWORD m_dwMajorVersion;
  99. DWORD m_dwMinorVersion;
  100. };
  101. #endif //__TEMPLATE_H_