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.

158 lines
4.2 KiB

  1. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Microsoft Windows
  3. Copyright (C) Microsoft Corporation, 1995 - 1999.
  4. File: Attribute.h
  5. Content: Declaration of CAttribute.
  6. History: 11-15-99 dsie created
  7. ------------------------------------------------------------------------------*/
  8. #ifndef __ATTRIBUTE_H_
  9. #define __ATTRIBUTE_H_
  10. #include "Resource.h"
  11. #include "Lock.h"
  12. #include "Error.h"
  13. #include "Debug.h"
  14. ////////////////////////////////////////////////////////////////////////////////
  15. //
  16. // Exported functions.
  17. //
  18. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  19. Function : CreateAttributebject
  20. Synopsis : Create an IAttribute object and initialize the object with data
  21. from the specified attribute.
  22. Parameter: CRYPT_ATTRIBUTE * pAttribute - Pointer to CRYPT_ATTRIBUTE.
  23. IAttribute ** ppIAttribute - Pointer to pointer IAttribute object.
  24. Remark :
  25. ------------------------------------------------------------------------------*/
  26. HRESULT CreateAttributeObject (CRYPT_ATTRIBUTE * pAttribute,
  27. IAttribute ** ppIAttribute);
  28. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  29. Function : AttributeIsValid
  30. Synopsis : Check to see if an attribute is valid.
  31. Parameter: IAttribute * pVal - Attribute to be checked.
  32. Remark :
  33. ------------------------------------------------------------------------------*/
  34. HRESULT AttributeIsValid (IAttribute * pAttribute);
  35. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  36. Function : AttributeIsSupported
  37. Synopsis : Check to see if an attribute is supported.
  38. Parameter: LPSTR pszObjID - Pointer to attribute OID.
  39. Remark :
  40. ------------------------------------------------------------------------------*/
  41. BOOL AttributeIsSupported (LPSTR pszObjId);
  42. ///////////////////////////////////////////////////////////////////////////////
  43. //
  44. // CAttribute
  45. //
  46. class ATL_NO_VTABLE CAttribute :
  47. public CComObjectRootEx<CComMultiThreadModel>,
  48. public CComCoClass<CAttribute, &CLSID_Attribute>,
  49. public ICAPICOMError<CAttribute, &IID_IAttribute>,
  50. public IDispatchImpl<IAttribute, &IID_IAttribute, &LIBID_CAPICOM,
  51. CAPICOM_MAJOR_VERSION, CAPICOM_MINOR_VERSION>,
  52. public IObjectSafetyImpl<CAttribute, INTERFACESAFE_FOR_UNTRUSTED_CALLER |
  53. INTERFACESAFE_FOR_UNTRUSTED_DATA>
  54. {
  55. public:
  56. CAttribute()
  57. {
  58. }
  59. DECLARE_REGISTRY_RESOURCEID(IDR_ATTRIBUTE)
  60. DECLARE_GET_CONTROLLING_UNKNOWN()
  61. DECLARE_PROTECT_FINAL_CONSTRUCT()
  62. BEGIN_COM_MAP(CAttribute)
  63. COM_INTERFACE_ENTRY(IAttribute)
  64. COM_INTERFACE_ENTRY(IDispatch)
  65. COM_INTERFACE_ENTRY(IObjectSafety)
  66. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  67. END_COM_MAP()
  68. BEGIN_CATEGORY_MAP(CAttribute)
  69. IMPLEMENTED_CATEGORY(CATID_SafeForScripting)
  70. IMPLEMENTED_CATEGORY(CATID_SafeForInitializing)
  71. END_CATEGORY_MAP()
  72. HRESULT FinalConstruct()
  73. {
  74. HRESULT hr;
  75. if (FAILED(hr = m_Lock.Initialized()))
  76. {
  77. DebugTrace("Error [%#x]: Critical section could not be created for Attribute object.\n", hr);
  78. return hr;
  79. }
  80. m_bInitialized = FALSE;
  81. return S_OK;
  82. }
  83. //
  84. // IAttribute
  85. //
  86. public:
  87. STDMETHOD(get_Value)
  88. (/*[out, retval]*/ VARIANT *pVal);
  89. STDMETHOD(put_Value)
  90. (/*[in]*/ VARIANT newVal);
  91. STDMETHOD(get_Name)
  92. (/*[out, retval]*/ CAPICOM_ATTRIBUTE *pVal);
  93. STDMETHOD(put_Name)
  94. (/*[in]*/ CAPICOM_ATTRIBUTE newVal);
  95. //
  96. // C++ member function needed to initialize the object.
  97. //
  98. STDMETHOD(Init)
  99. (CAPICOM_ATTRIBUTE AttributeName,
  100. LPSTR lpszOID,
  101. VARIANT varValue);
  102. private:
  103. CLock m_Lock;
  104. BOOL m_bInitialized;
  105. CAPICOM_ATTRIBUTE m_AttrName;
  106. CComBSTR m_bstrOID;
  107. CComVariant m_varValue;
  108. };
  109. #endif //__ATTRIBUTE_H_