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.

137 lines
4.0 KiB

  1. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Microsoft Windows
  3. Copyright (C) Microsoft Corporation, 1995 - 1999.
  4. File: ExtendedProperties.h
  5. Content: Declaration of CExtendedProperties.
  6. History: 06-15-2001 dsie created
  7. ------------------------------------------------------------------------------*/
  8. #ifndef __EXTENDEDPROPERTIES_H_
  9. #define __EXTENDEDPROPERTIES_H_
  10. #include "Resource.h"
  11. #include "Lock.h"
  12. #include "Debug.h"
  13. #include "Error.h"
  14. #include "CopyItem.h"
  15. #include "ExtendedProperty.h"
  16. //
  17. // typdefs to make life easier.
  18. //
  19. typedef std::map<CComBSTR, CComPtr<IExtendedProperty> > ExtendedPropertyMap;
  20. typedef CComEnumOnSTL<IEnumVARIANT, &IID_IEnumVARIANT, VARIANT, _CopyMapItem<IExtendedProperty>, ExtendedPropertyMap> ExtendedPropertyEnum;
  21. typedef ICollectionOnSTLImpl<IExtendedProperties, ExtendedPropertyMap, VARIANT, _CopyMapItem<IExtendedProperty>, ExtendedPropertyEnum> IExtendedPropertiesCollection;
  22. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  23. Function : CreateExtendedPropertiesObject
  24. Synopsis : Create and initialize an IExtendedProperties collection object.
  25. Parameter: PCCERT_CONTEXT pCertContext - Pointer to CERT_CONTEXT.
  26. BOOL bReadOnly - TRUE if read only instance, else FALSE.
  27. IExtendedProperties ** ppIExtendedProperties - Pointer to pointer
  28. to IExtendedProperties
  29. to receive the
  30. interface pointer.
  31. Remark :
  32. ------------------------------------------------------------------------------*/
  33. HRESULT CreateExtendedPropertiesObject (PCCERT_CONTEXT pCertContext,
  34. BOOL bReadOnly,
  35. IExtendedProperties ** ppIExtendedProperties);
  36. ////////////////////////////////////////////////////////////////////////////////
  37. //
  38. // CExtendedProperties
  39. //
  40. class ATL_NO_VTABLE CExtendedProperties :
  41. public CComObjectRootEx<CComMultiThreadModel>,
  42. public CComCoClass<CExtendedProperties, &CLSID_ExtendedProperties>,
  43. public ICAPICOMError<CExtendedProperties, &IID_IExtendedProperties>,
  44. public IDispatchImpl<IExtendedPropertiesCollection, &IID_IExtendedProperties, &LIBID_CAPICOM,
  45. CAPICOM_MAJOR_VERSION, CAPICOM_MINOR_VERSION>
  46. {
  47. public:
  48. CExtendedProperties()
  49. {
  50. }
  51. DECLARE_NO_REGISTRY()
  52. DECLARE_PROTECT_FINAL_CONSTRUCT()
  53. BEGIN_COM_MAP(CExtendedProperties)
  54. COM_INTERFACE_ENTRY(IExtendedProperties)
  55. COM_INTERFACE_ENTRY(IDispatch)
  56. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  57. END_COM_MAP()
  58. HRESULT FinalConstruct()
  59. {
  60. HRESULT hr;
  61. if (FAILED(hr = m_Lock.Initialized()))
  62. {
  63. DebugTrace("Error [%#x]: Critical section could not be created for ExtendedProperties object.\n", hr);
  64. return hr;
  65. }
  66. m_pCertContext = NULL;
  67. m_bReadOnly = FALSE;
  68. return S_OK;
  69. }
  70. void FinalRelease()
  71. {
  72. if (m_pCertContext)
  73. {
  74. ::CertFreeCertificateContext(m_pCertContext);
  75. }
  76. }
  77. //
  78. // IExtendedProperties
  79. //
  80. public:
  81. //
  82. // These are the only ones that we need to implemented, others will be
  83. // handled by ATL ICollectionOnSTLImpl.
  84. #if (0)
  85. STDMETHOD(get_Item)
  86. (/*[in]*/ long Index,
  87. /*[out, retval]*/ VARIANT * pVal);
  88. #endif
  89. STDMETHOD(Add)
  90. (/*[in]*/ IExtendedProperty * pVal);
  91. STDMETHOD(Remove)
  92. (/*[in]*/ CAPICOM_PROPID PropId);
  93. //
  94. // None COM functions.
  95. //
  96. STDMETHOD(Init)
  97. (PCCERT_CONTEXT pCertContext,
  98. BOOL bReadOnly);
  99. private:
  100. CLock m_Lock;
  101. PCCERT_CONTEXT m_pCertContext;
  102. BOOL m_bReadOnly;
  103. };
  104. #endif //__EXTENDEDPROPERTIES_H_