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.

328 lines
7.3 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. HRESULT hr = S_OK;
  82. wcscpy((LPWSTR)_wcName, pszName);
  83. _lMetaId = (long) dwMetaId;
  84. _lUserType = (long) dwUserType;
  85. _lAllAttributes = (long) dwAttribute;
  86. _bInherit = dwAttribute & METADATA_INHERIT;
  87. _bPartialPath = dwAttribute & METADATA_PARTIAL_PATH;
  88. _bSecure = dwAttribute & METADATA_SECURE;
  89. _bReference = dwAttribute & METADATA_REFERENCE;
  90. _bVolatile = dwAttribute & METADATA_VOLATILE;
  91. _bIsinherit = dwAttribute & METADATA_ISINHERITED;
  92. _bInsertPath = dwAttribute & METADATA_INSERT_PATH;
  93. hr = VariantCopy(&_vDefault, pvVal);
  94. return hr;
  95. }
  96. HRESULT
  97. CPropertyAttribute::AllocatePropertyAttributeObject(
  98. CPropertyAttribute ** ppPropertyAttribute
  99. )
  100. {
  101. CPropertyAttribute FAR * pPropertyAttribute = NULL;
  102. CAggregatorDispMgr FAR * pDispMgr = NULL;
  103. HRESULT hr = S_OK;
  104. pPropertyAttribute = new CPropertyAttribute();
  105. if (pPropertyAttribute == NULL) {
  106. hr = E_OUTOFMEMORY;
  107. }
  108. BAIL_ON_FAILURE(hr);
  109. pDispMgr = new CAggregatorDispMgr;
  110. if (pDispMgr == NULL) {
  111. hr = E_OUTOFMEMORY;
  112. }
  113. BAIL_ON_FAILURE(hr);
  114. hr = pDispMgr->LoadTypeInfoEntry(
  115. LIBID_IISOle,
  116. IID_IISPropertyAttribute,
  117. (IISPropertyAttribute *)pPropertyAttribute,
  118. DISPID_REGULAR
  119. );
  120. BAIL_ON_FAILURE(hr);
  121. pPropertyAttribute->_pDispMgr = pDispMgr;
  122. *ppPropertyAttribute = pPropertyAttribute;
  123. RRETURN(hr);
  124. error:
  125. if (pDispMgr)
  126. {
  127. delete pDispMgr;
  128. }
  129. if (pPropertyAttribute)
  130. {
  131. delete pPropertyAttribute;
  132. }
  133. RRETURN(hr);
  134. }
  135. STDMETHODIMP
  136. CPropertyAttribute::get_PropName(THIS_ BSTR FAR * retval)
  137. {
  138. HRESULT hr = S_OK;
  139. hr = ADsAllocString((LPWSTR)_wcName, retval);
  140. RRETURN(hr);
  141. }
  142. STDMETHODIMP
  143. CPropertyAttribute::get_MetaId(THIS_ LONG FAR * retval)
  144. {
  145. *retval = _lMetaId;
  146. RRETURN(S_OK);
  147. }
  148. STDMETHODIMP
  149. CPropertyAttribute::put_MetaId(THIS_ LONG lMetaId)
  150. {
  151. RRETURN(E_ADS_PROPERTY_NOT_SET);
  152. }
  153. STDMETHODIMP
  154. CPropertyAttribute::get_UserType(THIS_ LONG FAR * retval)
  155. {
  156. *retval = _lUserType;
  157. RRETURN(S_OK);
  158. }
  159. STDMETHODIMP
  160. CPropertyAttribute::put_UserType(THIS_ LONG lUserType)
  161. {
  162. _lUserType = lUserType;
  163. RRETURN(S_OK);
  164. }
  165. STDMETHODIMP
  166. CPropertyAttribute::get_AllAttributes(THIS_ LONG FAR * retval)
  167. {
  168. *retval = _lAllAttributes;
  169. RRETURN(S_OK);
  170. }
  171. STDMETHODIMP
  172. CPropertyAttribute::get_Inherit(THIS_ VARIANT_BOOL FAR * retval)
  173. {
  174. *retval = _bInherit ? VARIANT_TRUE : VARIANT_FALSE;
  175. RRETURN(S_OK);
  176. }
  177. STDMETHODIMP
  178. CPropertyAttribute::put_Inherit(THIS_ VARIANT_BOOL bInherit)
  179. {
  180. _bInherit = bInherit ? TRUE : FALSE;
  181. _lAllAttributes |= (_bInherit ? METADATA_INHERIT : 0);
  182. RRETURN(S_OK);
  183. }
  184. STDMETHODIMP
  185. CPropertyAttribute::get_PartialPath(THIS_ VARIANT_BOOL FAR * retval)
  186. {
  187. *retval = _bPartialPath ? VARIANT_TRUE : VARIANT_FALSE;
  188. RRETURN(S_OK);
  189. }
  190. STDMETHODIMP
  191. CPropertyAttribute::put_PartialPath(THIS_ VARIANT_BOOL bPartialPath)
  192. {
  193. _bPartialPath = bPartialPath ? TRUE : FALSE;
  194. _lAllAttributes |= (_bPartialPath ? METADATA_PARTIAL_PATH : 0);
  195. RRETURN(S_OK);
  196. }
  197. STDMETHODIMP
  198. CPropertyAttribute::get_Reference(THIS_ VARIANT_BOOL FAR * retval)
  199. {
  200. *retval = _bReference ? VARIANT_TRUE : VARIANT_FALSE;
  201. RRETURN(S_OK);
  202. }
  203. STDMETHODIMP
  204. CPropertyAttribute::put_Reference(THIS_ VARIANT_BOOL bReference)
  205. {
  206. _bReference = bReference ? TRUE : FALSE;
  207. _lAllAttributes |= (_bReference ? METADATA_REFERENCE : 0);
  208. RRETURN(S_OK);
  209. }
  210. STDMETHODIMP
  211. CPropertyAttribute::get_Secure(THIS_ VARIANT_BOOL FAR * retval)
  212. {
  213. *retval = _bSecure ? VARIANT_TRUE : VARIANT_FALSE;
  214. RRETURN(S_OK);
  215. }
  216. STDMETHODIMP
  217. CPropertyAttribute::put_Secure(THIS_ VARIANT_BOOL bSecure)
  218. {
  219. _bSecure = bSecure ? TRUE : FALSE;
  220. _lAllAttributes |= (_bSecure ? METADATA_SECURE : 0);
  221. RRETURN(S_OK);
  222. }
  223. STDMETHODIMP
  224. CPropertyAttribute::get_Volatile(THIS_ VARIANT_BOOL FAR * retval)
  225. {
  226. *retval = _bVolatile ? VARIANT_TRUE : VARIANT_FALSE;
  227. RRETURN(S_OK);
  228. }
  229. STDMETHODIMP
  230. CPropertyAttribute::put_Volatile(THIS_ VARIANT_BOOL bVolatile)
  231. {
  232. _bVolatile = bVolatile ? TRUE : FALSE;
  233. _lAllAttributes |= (_bVolatile ? METADATA_VOLATILE : 0);
  234. RRETURN(S_OK);
  235. }
  236. STDMETHODIMP
  237. CPropertyAttribute::get_Isinherit(THIS_ VARIANT_BOOL FAR * retval)
  238. {
  239. *retval = _bIsinherit ? VARIANT_TRUE : VARIANT_FALSE;
  240. RRETURN(S_OK);
  241. }
  242. STDMETHODIMP
  243. CPropertyAttribute::put_Isinherit(THIS_ VARIANT_BOOL bIsinherit)
  244. {
  245. _bIsinherit = bIsinherit ? TRUE : FALSE;
  246. _lAllAttributes |= (_bIsinherit ? METADATA_ISINHERITED : 0);
  247. RRETURN(S_OK);
  248. }
  249. STDMETHODIMP
  250. CPropertyAttribute::get_InsertPath(THIS_ VARIANT_BOOL FAR * retval)
  251. {
  252. *retval = _bInsertPath ? VARIANT_TRUE : VARIANT_FALSE;
  253. RRETURN(S_OK);
  254. }
  255. STDMETHODIMP
  256. CPropertyAttribute::put_InsertPath(THIS_ VARIANT_BOOL bInsertPath)
  257. {
  258. _bInsertPath = bInsertPath ? TRUE : FALSE;
  259. _lAllAttributes |= (_bInsertPath ? METADATA_INSERT_PATH : 0);
  260. RRETURN(S_OK);
  261. }
  262. STDMETHODIMP
  263. CPropertyAttribute::get_Default(THIS_ VARIANT FAR * retval)
  264. {
  265. VariantInit(retval);
  266. RRETURN(VariantCopy(retval, &_vDefault));
  267. }
  268. STDMETHODIMP
  269. CPropertyAttribute::put_Default(THIS_ VARIANT vVarDefault)
  270. {
  271. VariantClear(&_vDefault);
  272. RRETURN(VariantCopy(&_vDefault, &vVarDefault));
  273. }