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.

284 lines
5.2 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995
  5. //
  6. // File: cPropertyEntry.cxx
  7. //
  8. // Contents: PropertyEntry object
  9. //
  10. // History: 11-1-95 krishnag Created.
  11. //
  12. //----------------------------------------------------------------------------
  13. #include "oleds.hxx"
  14. #pragma hdrstop
  15. // Class CPropertyEntry
  16. DEFINE_IDispatch_Implementation(CPropertyEntry)
  17. CPropertyEntry::CPropertyEntry():
  18. _pDispMgr(NULL),
  19. _lpName(NULL),
  20. _dwValueCount(0),
  21. _dwADsType(0),
  22. _dwControlCode(0)
  23. {
  24. ENLIST_TRACKING(CPropertyEntry);
  25. }
  26. HRESULT
  27. CPropertyEntry::CreatePropertyEntry(
  28. REFIID riid,
  29. void **ppvObj
  30. )
  31. {
  32. CPropertyEntry FAR * pPropertyEntry = NULL;
  33. HRESULT hr = S_OK;
  34. hr = AllocatePropertyEntryObject(&pPropertyEntry);
  35. BAIL_ON_FAILURE(hr);
  36. hr = pPropertyEntry->QueryInterface(riid, ppvObj);
  37. BAIL_ON_FAILURE(hr);
  38. pPropertyEntry->Release();
  39. RRETURN(hr);
  40. error:
  41. delete pPropertyEntry;
  42. RRETURN_EXP_IF_ERR(hr);
  43. }
  44. CPropertyEntry::~CPropertyEntry( )
  45. {
  46. VariantClear(&_propVar);
  47. if (_lpName) {
  48. FreeADsStr(_lpName);
  49. }
  50. delete _pDispMgr;
  51. }
  52. STDMETHODIMP
  53. CPropertyEntry::QueryInterface(
  54. REFIID iid,
  55. LPVOID FAR* ppv
  56. )
  57. {
  58. if (IsEqualIID(iid, IID_IUnknown))
  59. {
  60. *ppv = (IADsPropertyEntry FAR *) this;
  61. }
  62. else if (IsEqualIID(iid, IID_IADsPropertyEntry))
  63. {
  64. *ppv = (IADsPropertyEntry FAR *) this;
  65. }
  66. else if (IsEqualIID(iid, IID_IDispatch))
  67. {
  68. *ppv = (IADsPropertyEntry FAR *) this;
  69. }
  70. else if (IsEqualIID(iid, IID_ISupportErrorInfo))
  71. {
  72. *ppv = (ISupportErrorInfo FAR *) this;
  73. }
  74. else
  75. {
  76. *ppv = NULL;
  77. return E_NOINTERFACE;
  78. }
  79. AddRef();
  80. return NOERROR;
  81. }
  82. HRESULT
  83. CPropertyEntry::AllocatePropertyEntryObject(
  84. CPropertyEntry ** ppPropertyEntry
  85. )
  86. {
  87. CPropertyEntry FAR * pPropertyEntry = NULL;
  88. CDispatchMgr FAR * pDispMgr = NULL;
  89. HRESULT hr = S_OK;
  90. pPropertyEntry = new CPropertyEntry();
  91. if (pPropertyEntry == NULL) {
  92. hr = E_OUTOFMEMORY;
  93. }
  94. BAIL_ON_FAILURE(hr);
  95. pDispMgr = new CDispatchMgr;
  96. if (pDispMgr == NULL) {
  97. hr = E_OUTOFMEMORY;
  98. }
  99. BAIL_ON_FAILURE(hr);
  100. hr = LoadTypeInfoEntry(
  101. pDispMgr,
  102. LIBID_ADs,
  103. IID_IADsPropertyEntry,
  104. (IADsPropertyEntry *)pPropertyEntry,
  105. DISPID_REGULAR
  106. );
  107. BAIL_ON_FAILURE(hr);
  108. pPropertyEntry->_pDispMgr = pDispMgr;
  109. *ppPropertyEntry = pPropertyEntry;
  110. RRETURN(hr);
  111. error:
  112. delete pPropertyEntry;
  113. delete pDispMgr;
  114. RRETURN_EXP_IF_ERR(hr);
  115. }
  116. //
  117. // ISupportErrorInfo method
  118. //
  119. STDMETHODIMP
  120. CPropertyEntry::InterfaceSupportsErrorInfo(THIS_ REFIID riid)
  121. {
  122. if (IsEqualIID(riid, IID_IADsPropertyEntry)) {
  123. return S_OK;
  124. } else {
  125. return S_FALSE;
  126. }
  127. }
  128. STDMETHODIMP
  129. CPropertyEntry::get_Values(THIS_ VARIANT FAR * retval)
  130. {
  131. HRESULT hr;
  132. VariantInit(retval);
  133. hr = VariantCopy(retval, &_propVar);
  134. RRETURN_EXP_IF_ERR(hr);
  135. }
  136. STDMETHODIMP
  137. CPropertyEntry::put_Values(THIS_ VARIANT vValues)
  138. {
  139. HRESULT hr;
  140. // set the values only if it is valid
  141. if ( (V_VT(&vValues) == (VT_ARRAY | VT_VARIANT))
  142. || (V_VT(&vValues) == (VT_EMPTY))) {
  143. hr = VariantCopy(&_propVar, &vValues);
  144. RRETURN_EXP_IF_ERR(hr);
  145. } else {
  146. RRETURN(hr=E_ADS_BAD_PARAMETER);
  147. }
  148. }
  149. STDMETHODIMP
  150. CPropertyEntry::get_ValueCount(THIS_ long FAR * retval)
  151. {
  152. *retval = _dwValueCount;
  153. RRETURN(S_OK);
  154. }
  155. STDMETHODIMP
  156. CPropertyEntry::put_ValueCount(THIS_ long lnValueCount)
  157. {
  158. _dwValueCount = lnValueCount;
  159. RRETURN(S_OK);
  160. }
  161. STDMETHODIMP
  162. CPropertyEntry::get_ADsType(THIS_ long FAR * retval)
  163. {
  164. *retval = _dwADsType;
  165. RRETURN(S_OK);
  166. }
  167. STDMETHODIMP
  168. CPropertyEntry::put_ADsType(THIS_ long lnADsType)
  169. {
  170. _dwADsType = lnADsType;
  171. RRETURN(S_OK);
  172. }
  173. STDMETHODIMP
  174. CPropertyEntry::get_ControlCode(THIS_ long FAR * retval)
  175. {
  176. *retval = _dwControlCode;
  177. RRETURN(S_OK);
  178. }
  179. STDMETHODIMP
  180. CPropertyEntry::put_ControlCode(THIS_ long lnControlCode)
  181. {
  182. _dwControlCode = lnControlCode;
  183. RRETURN(S_OK);
  184. }
  185. STDMETHODIMP
  186. CPropertyEntry::get_Name(THIS_ BSTR FAR * retval)
  187. {
  188. HRESULT hr = S_OK;
  189. hr = ADsAllocString(_lpName, retval);
  190. RRETURN_EXP_IF_ERR(hr);
  191. }
  192. STDMETHODIMP
  193. CPropertyEntry::put_Name(THIS_ BSTR bstrName)
  194. {
  195. if (!bstrName) {
  196. RRETURN_EXP_IF_ERR(E_ADS_BAD_PARAMETER);
  197. }
  198. if (_lpName) {
  199. FreeADsStr(_lpName);
  200. }
  201. _lpName = AllocADsStr(bstrName);
  202. if (!_lpName) {
  203. RRETURN_EXP_IF_ERR(E_OUTOFMEMORY);
  204. }
  205. RRETURN(S_OK);
  206. }
  207. STDMETHODIMP
  208. CPropertyEntry::Clear(THIS_ )
  209. {
  210. _dwADsType = 0;
  211. _dwControlCode = 0;
  212. _dwValueCount = 0;
  213. VariantClear(&_propVar);
  214. if (_lpName) {
  215. FreeADsStr(_lpName);
  216. _lpName = NULL;
  217. }
  218. RRETURN(S_OK);
  219. }
  220.