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.

313 lines
6.5 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995
  5. //
  6. // File: cgroups.cxx
  7. //
  8. // Contents: Group object
  9. //
  10. // History: Mar-18-965 t-ptam (PatrickT) Migrated.
  11. //
  12. //----------------------------------------------------------------------------
  13. #include "NWCOMPAT.hxx"
  14. #pragma hdrstop
  15. //
  16. // Class CNWCOMPATGroupCollection
  17. //
  18. DEFINE_IDispatch_Implementation(CNWCOMPATGroupCollection)
  19. //----------------------------------------------------------------------------
  20. //
  21. // Function:
  22. //
  23. // Synopsis:
  24. //
  25. //----------------------------------------------------------------------------
  26. CNWCOMPATGroupCollection::CNWCOMPATGroupCollection():
  27. _ParentType(0),
  28. _ServerName(NULL),
  29. _pDispMgr(NULL)
  30. {
  31. VariantInit(&_vFilter);
  32. ENLIST_TRACKING(CNWCOMPATGroupCollection);
  33. }
  34. //----------------------------------------------------------------------------
  35. //
  36. // Function:
  37. //
  38. // Synopsis:
  39. //
  40. //----------------------------------------------------------------------------
  41. CNWCOMPATGroupCollection::~CNWCOMPATGroupCollection( )
  42. {
  43. if (_ServerName)
  44. ADsFreeString(_ServerName);
  45. delete _pDispMgr;
  46. VariantClear(&_vFilter);
  47. }
  48. //----------------------------------------------------------------------------
  49. //
  50. // Function:
  51. //
  52. // Synopsis:
  53. //
  54. //----------------------------------------------------------------------------
  55. HRESULT
  56. CNWCOMPATGroupCollection::CreateGroupCollection(
  57. BSTR Parent,
  58. ULONG ParentType,
  59. BSTR ServerName,
  60. BSTR GroupName,
  61. REFIID riid,
  62. void **ppvObj
  63. )
  64. {
  65. CNWCOMPATGroupCollection FAR * pGroup = NULL;
  66. HRESULT hr = S_OK;
  67. hr = AllocateGroupCollectionObject(&pGroup);
  68. BAIL_ON_FAILURE(hr);
  69. hr = pGroup->InitializeCoreObject(
  70. Parent,
  71. GroupName,
  72. L"group",
  73. NO_SCHEMA,
  74. CLSID_NWCOMPATGroup,
  75. ADS_OBJECT_UNBOUND
  76. );
  77. BAIL_ON_FAILURE(hr);
  78. hr = ADsAllocString( ServerName , &pGroup->_ServerName);
  79. BAIL_ON_FAILURE(hr);
  80. pGroup->_ParentType = ParentType;
  81. hr = pGroup->QueryInterface(riid, ppvObj);
  82. BAIL_ON_FAILURE(hr);
  83. pGroup->Release();
  84. RRETURN(hr);
  85. error:
  86. delete pGroup;
  87. RRETURN_EXP_IF_ERR(hr);
  88. }
  89. //----------------------------------------------------------------------------
  90. //
  91. // Function:
  92. //
  93. // Synopsis:
  94. //
  95. //----------------------------------------------------------------------------
  96. STDMETHODIMP
  97. CNWCOMPATGroupCollection::QueryInterface(
  98. REFIID iid,
  99. LPVOID FAR* ppv
  100. )
  101. {
  102. if (ppv == NULL) {
  103. RRETURN(E_POINTER);
  104. }
  105. if (IsEqualIID(iid, IID_IUnknown))
  106. {
  107. *ppv = (IADsMembers FAR *) this;
  108. }
  109. else if (IsEqualIID(iid, IID_IADsMembers))
  110. {
  111. *ppv = (IADsMembers FAR *) this;
  112. }
  113. else if (IsEqualIID(iid, IID_IDispatch))
  114. {
  115. *ppv = (IADsMembers FAR *) this;
  116. }
  117. else if (IsEqualIID(iid, IID_ISupportErrorInfo))
  118. {
  119. *ppv = (ISupportErrorInfo FAR *) this;
  120. }
  121. else
  122. {
  123. *ppv = NULL;
  124. return E_NOINTERFACE;
  125. }
  126. AddRef();
  127. return NOERROR;
  128. }
  129. /* ISupportErrorInfo method */
  130. STDMETHODIMP
  131. CNWCOMPATGroupCollection::InterfaceSupportsErrorInfo(
  132. THIS_ REFIID riid
  133. )
  134. {
  135. if (IsEqualIID(riid, IID_IADsMembers)) {
  136. RRETURN(S_OK);
  137. } else {
  138. RRETURN(S_FALSE);
  139. }
  140. }
  141. //----------------------------------------------------------------------------
  142. //
  143. // Function:
  144. //
  145. // Synopsis:
  146. //
  147. //----------------------------------------------------------------------------
  148. STDMETHODIMP
  149. CNWCOMPATGroupCollection::get_Count(
  150. long FAR* retval
  151. )
  152. {
  153. RRETURN_EXP_IF_ERR(E_NOTIMPL);
  154. }
  155. //----------------------------------------------------------------------------
  156. //
  157. // Function:
  158. //
  159. // Synopsis:
  160. //
  161. //----------------------------------------------------------------------------
  162. STDMETHODIMP
  163. CNWCOMPATGroupCollection::get_Filter(
  164. THIS_ VARIANT FAR* pVar
  165. )
  166. {
  167. HRESULT hr;
  168. VariantInit(pVar);
  169. hr = VariantCopy(pVar, &_vFilter);
  170. RRETURN_EXP_IF_ERR(hr);
  171. }
  172. //----------------------------------------------------------------------------
  173. //
  174. // Function:
  175. //
  176. // Synopsis:
  177. //
  178. //----------------------------------------------------------------------------
  179. STDMETHODIMP
  180. CNWCOMPATGroupCollection::put_Filter(
  181. THIS_ VARIANT Var
  182. )
  183. {
  184. HRESULT hr;
  185. hr = VariantCopy(&_vFilter, &Var);
  186. RRETURN_EXP_IF_ERR(hr);
  187. }
  188. //----------------------------------------------------------------------------
  189. //
  190. // Function:
  191. //
  192. // Synopsis:
  193. //
  194. //----------------------------------------------------------------------------
  195. STDMETHODIMP
  196. CNWCOMPATGroupCollection::get__NewEnum(
  197. THIS_ IUnknown * FAR* retval
  198. )
  199. {
  200. HRESULT hr;
  201. IUnknown FAR* punkEnum=NULL;
  202. IEnumVARIANT * penum = NULL;
  203. *retval = NULL;
  204. hr = CNWCOMPATGroupCollectionEnum::Create(
  205. (CNWCOMPATGroupCollectionEnum **)&penum,
  206. _Parent,
  207. _ParentType,
  208. _ADsPath,
  209. _ServerName,
  210. _Name,
  211. _vFilter
  212. );
  213. BAIL_ON_FAILURE(hr);
  214. hr = penum->QueryInterface(
  215. IID_IUnknown,
  216. (VOID FAR* FAR*)retval
  217. );
  218. BAIL_ON_FAILURE(hr);
  219. if (penum) {
  220. penum->Release();
  221. }
  222. RRETURN(NOERROR);
  223. error:
  224. if (penum) {
  225. delete penum;
  226. }
  227. RRETURN_EXP_IF_ERR(hr);
  228. }
  229. //----------------------------------------------------------------------------
  230. //
  231. // Function:
  232. //
  233. // Synopsis:
  234. //
  235. //----------------------------------------------------------------------------
  236. HRESULT
  237. CNWCOMPATGroupCollection::AllocateGroupCollectionObject(
  238. CNWCOMPATGroupCollection ** ppGroup
  239. )
  240. {
  241. CNWCOMPATGroupCollection FAR * pGroup = NULL;
  242. CAggregatorDispMgr FAR * pDispMgr = NULL;
  243. HRESULT hr = S_OK;
  244. pGroup = new CNWCOMPATGroupCollection();
  245. if (pGroup == NULL) {
  246. hr = E_OUTOFMEMORY;
  247. }
  248. BAIL_ON_FAILURE(hr);
  249. pDispMgr = new CAggregatorDispMgr;
  250. if (pDispMgr == NULL) {
  251. hr = E_OUTOFMEMORY;
  252. }
  253. BAIL_ON_FAILURE(hr);
  254. hr = LoadTypeInfoEntry(
  255. pDispMgr,
  256. LIBID_ADs,
  257. IID_IADsMembers,
  258. (IADsMembers *)pGroup,
  259. DISPID_NEWENUM
  260. );
  261. BAIL_ON_FAILURE(hr);
  262. pGroup->_pDispMgr = pDispMgr;
  263. *ppGroup = pGroup;
  264. RRETURN(hr);
  265. error:
  266. if (pGroup) {
  267. delete pGroup;
  268. }
  269. if (pDispMgr) {
  270. delete pDispMgr;
  271. }
  272. RRETURN(hr);
  273. }