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.

318 lines
6.9 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995
  5. //
  6. // File: cpobj.cxx
  7. //
  8. // Contents: Property Attribute object
  9. //
  10. // History: 21-1-98 SophiaC Created.
  11. //
  12. //----------------------------------------------------------------------------
  13. #include "iis.hxx"
  14. #pragma hdrstop
  15. // Class CPropertyAttribute
  16. DEFINE_Simple_IDispatch_Implementation(CPropertyAttribute)
  17. CPropertyAttribute::CPropertyAttribute():
  18. _pDispMgr(NULL)
  19. {
  20. VariantInit(&_vDefault);
  21. ENLIST_TRACKING(CPropertyAttribute);
  22. }
  23. HRESULT
  24. CPropertyAttribute::CreatePropertyAttribute(
  25. REFIID riid,
  26. void **ppvObj
  27. )
  28. {
  29. CPropertyAttribute FAR * pPropertyAttribute = NULL;
  30. HRESULT hr = S_OK;
  31. hr = AllocatePropertyAttributeObject(&pPropertyAttribute);
  32. BAIL_ON_FAILURE(hr);
  33. hr = pPropertyAttribute->QueryInterface(riid, ppvObj);
  34. BAIL_ON_FAILURE(hr);
  35. pPropertyAttribute->Release();
  36. RRETURN(hr);
  37. error:
  38. delete pPropertyAttribute;
  39. RRETURN(hr);
  40. }
  41. CPropertyAttribute::~CPropertyAttribute( )
  42. {
  43. VariantClear(&_vDefault);
  44. delete _pDispMgr;
  45. }
  46. STDMETHODIMP
  47. CPropertyAttribute::QueryInterface(
  48. REFIID iid,
  49. LPVOID FAR* ppv
  50. )
  51. {
  52. if (IsEqualIID(iid, IID_IUnknown))
  53. {
  54. *ppv = (IISPropertyAttribute FAR *) this;
  55. }
  56. else if (IsEqualIID(iid, IID_IISPropertyAttribute))
  57. {
  58. *ppv = (IISPropertyAttribute FAR *) this;
  59. }
  60. else if (IsEqualIID(iid, IID_IDispatch))
  61. {
  62. *ppv = (IISPropertyAttribute FAR *) this;
  63. }
  64. else
  65. {
  66. *ppv = NULL;
  67. return E_NOINTERFACE;
  68. }
  69. AddRef();
  70. return NOERROR;
  71. }
  72. HRESULT
  73. CPropertyAttribute::InitFromRawData(
  74. LPWSTR pszName,
  75. DWORD dwMetaId,
  76. DWORD dwUserType,
  77. DWORD dwAttribute,
  78. VARIANT *pvVal
  79. )
  80. {
  81. wcscpy((LPWSTR)_wcName, pszName);
  82. _lMetaId = (long) dwMetaId;
  83. _lUserType = (long) dwUserType;
  84. _lAllAttributes = (long) dwAttribute;
  85. _bInherit = dwAttribute & METADATA_INHERIT;
  86. _bPartialPath = dwAttribute & METADATA_PARTIAL_PATH;
  87. _bSecure = dwAttribute & METADATA_SECURE;
  88. _bReference = dwAttribute & METADATA_REFERENCE;
  89. _bVolatile = dwAttribute & METADATA_VOLATILE;
  90. _bIsinherit = dwAttribute & METADATA_ISINHERITED;
  91. _bInsertPath = dwAttribute & METADATA_INSERT_PATH;
  92. VariantCopy(&_vDefault, pvVal);
  93. return S_OK;
  94. }
  95. HRESULT
  96. CPropertyAttribute::AllocatePropertyAttributeObject(
  97. CPropertyAttribute ** ppPropertyAttribute
  98. )
  99. {
  100. CPropertyAttribute FAR * pPropertyAttribute = NULL;
  101. CAggregatorDispMgr FAR * pDispMgr = NULL;
  102. HRESULT hr = S_OK;
  103. pPropertyAttribute = new CPropertyAttribute();
  104. if (pPropertyAttribute == NULL) {
  105. hr = E_OUTOFMEMORY;
  106. }
  107. BAIL_ON_FAILURE(hr);
  108. pDispMgr = new CAggregatorDispMgr;
  109. if (pDispMgr == NULL) {
  110. hr = E_OUTOFMEMORY;
  111. }
  112. BAIL_ON_FAILURE(hr);
  113. hr = pDispMgr->LoadTypeInfoEntry(
  114. LIBID_IISOle,
  115. IID_IISPropertyAttribute,
  116. (IISPropertyAttribute *)pPropertyAttribute,
  117. DISPID_REGULAR
  118. );
  119. BAIL_ON_FAILURE(hr);
  120. pPropertyAttribute->_pDispMgr = pDispMgr;
  121. *ppPropertyAttribute = pPropertyAttribute;
  122. RRETURN(hr);
  123. error:
  124. delete pDispMgr;
  125. RRETURN(hr);
  126. }
  127. STDMETHODIMP
  128. CPropertyAttribute::get_PropName(THIS_ BSTR FAR * retval)
  129. {
  130. HRESULT hr = S_OK;
  131. hr = ADsAllocString((LPWSTR)_wcName, retval);
  132. RRETURN(hr);
  133. }
  134. STDMETHODIMP
  135. CPropertyAttribute::get_MetaId(THIS_ LONG FAR * retval)
  136. {
  137. *retval = _lMetaId;
  138. RRETURN(S_OK);
  139. }
  140. STDMETHODIMP
  141. CPropertyAttribute::put_MetaId(THIS_ LONG lMetaId)
  142. {
  143. RRETURN(E_ADS_PROPERTY_NOT_SET);
  144. }
  145. STDMETHODIMP
  146. CPropertyAttribute::get_UserType(THIS_ LONG FAR * retval)
  147. {
  148. *retval = _lUserType;
  149. RRETURN(S_OK);
  150. }
  151. STDMETHODIMP
  152. CPropertyAttribute::put_UserType(THIS_ LONG lUserType)
  153. {
  154. _lUserType = lUserType;
  155. RRETURN(S_OK);
  156. }
  157. STDMETHODIMP
  158. CPropertyAttribute::get_AllAttributes(THIS_ LONG FAR * retval)
  159. {
  160. *retval = _lAllAttributes;
  161. RRETURN(S_OK);
  162. }
  163. STDMETHODIMP
  164. CPropertyAttribute::get_Inherit(THIS_ VARIANT_BOOL FAR * retval)
  165. {
  166. *retval = _bInherit ? VARIANT_TRUE : VARIANT_FALSE;
  167. RRETURN(S_OK);
  168. }
  169. STDMETHODIMP
  170. CPropertyAttribute::put_Inherit(THIS_ VARIANT_BOOL bInherit)
  171. {
  172. _bInherit = bInherit ? TRUE : FALSE;
  173. _lAllAttributes |= (_bInherit ? METADATA_INHERIT : 0);
  174. RRETURN(S_OK);
  175. }
  176. STDMETHODIMP
  177. CPropertyAttribute::get_PartialPath(THIS_ VARIANT_BOOL FAR * retval)
  178. {
  179. *retval = _bPartialPath ? VARIANT_TRUE : VARIANT_FALSE;
  180. RRETURN(S_OK);
  181. }
  182. STDMETHODIMP
  183. CPropertyAttribute::put_PartialPath(THIS_ VARIANT_BOOL bPartialPath)
  184. {
  185. _bPartialPath = bPartialPath ? TRUE : FALSE;
  186. _lAllAttributes |= (_bPartialPath ? METADATA_PARTIAL_PATH : 0);
  187. RRETURN(S_OK);
  188. }
  189. STDMETHODIMP
  190. CPropertyAttribute::get_Reference(THIS_ VARIANT_BOOL FAR * retval)
  191. {
  192. *retval = _bReference ? VARIANT_TRUE : VARIANT_FALSE;
  193. RRETURN(S_OK);
  194. }
  195. STDMETHODIMP
  196. CPropertyAttribute::put_Reference(THIS_ VARIANT_BOOL bReference)
  197. {
  198. _bReference = bReference ? TRUE : FALSE;
  199. _lAllAttributes |= (_bReference ? METADATA_REFERENCE : 0);
  200. RRETURN(S_OK);
  201. }
  202. STDMETHODIMP
  203. CPropertyAttribute::get_Secure(THIS_ VARIANT_BOOL FAR * retval)
  204. {
  205. *retval = _bSecure ? VARIANT_TRUE : VARIANT_FALSE;
  206. RRETURN(S_OK);
  207. }
  208. STDMETHODIMP
  209. CPropertyAttribute::put_Secure(THIS_ VARIANT_BOOL bSecure)
  210. {
  211. _bSecure = bSecure ? TRUE : FALSE;
  212. _lAllAttributes |= (_bSecure ? METADATA_SECURE : 0);
  213. RRETURN(S_OK);
  214. }
  215. STDMETHODIMP
  216. CPropertyAttribute::get_Volatile(THIS_ VARIANT_BOOL FAR * retval)
  217. {
  218. *retval = _bVolatile ? VARIANT_TRUE : VARIANT_FALSE;
  219. RRETURN(S_OK);
  220. }
  221. STDMETHODIMP
  222. CPropertyAttribute::put_Volatile(THIS_ VARIANT_BOOL bVolatile)
  223. {
  224. _bVolatile = bVolatile ? TRUE : FALSE;
  225. _lAllAttributes |= (_bVolatile ? METADATA_VOLATILE : 0);
  226. RRETURN(S_OK);
  227. }
  228. STDMETHODIMP
  229. CPropertyAttribute::get_Isinherit(THIS_ VARIANT_BOOL FAR * retval)
  230. {
  231. *retval = _bIsinherit ? VARIANT_TRUE : VARIANT_FALSE;
  232. RRETURN(S_OK);
  233. }
  234. STDMETHODIMP
  235. CPropertyAttribute::put_Isinherit(THIS_ VARIANT_BOOL bIsinherit)
  236. {
  237. _bIsinherit = bIsinherit ? TRUE : FALSE;
  238. _lAllAttributes |= (_bIsinherit ? METADATA_ISINHERITED : 0);
  239. RRETURN(S_OK);
  240. }
  241. STDMETHODIMP
  242. CPropertyAttribute::get_InsertPath(THIS_ VARIANT_BOOL FAR * retval)
  243. {
  244. *retval = _bInsertPath ? VARIANT_TRUE : VARIANT_FALSE;
  245. RRETURN(S_OK);
  246. }
  247. STDMETHODIMP
  248. CPropertyAttribute::put_InsertPath(THIS_ VARIANT_BOOL bInsertPath)
  249. {
  250. _bInsertPath = bInsertPath ? TRUE : FALSE;
  251. _lAllAttributes |= (_bInsertPath ? METADATA_INSERT_PATH : 0);
  252. RRETURN(S_OK);
  253. }
  254. STDMETHODIMP
  255. CPropertyAttribute::get_Default(THIS_ VARIANT FAR * retval)
  256. {
  257. VariantInit(retval);
  258. RRETURN(VariantCopy(retval, &_vDefault));
  259. }
  260. STDMETHODIMP
  261. CPropertyAttribute::put_Default(THIS_ VARIANT vVarDefault)
  262. {
  263. VariantClear(&_vDefault);
  264. RRETURN(VariantCopy(&_vDefault, &vVarDefault));
  265. }