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.

458 lines
12 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  4. //
  5. // File: metapenm.cxx
  6. //
  7. // Contents: Meta property enumerator
  8. //
  9. // History: 12-Dec-96 SitaramR Created
  10. //
  11. //--------------------------------------------------------------------------
  12. #include <pch.cxx>
  13. #pragma hdrstop
  14. #include <metapenm.hxx>
  15. #include <catalog.hxx>
  16. //+-------------------------------------------------------------------------
  17. //
  18. // Member: CMetaPropEnum::CMetaPropEnum, public
  19. //
  20. // Synopsis: Constructor
  21. //
  22. // Arguments: [cat] -- Catalog
  23. // [pQueryPropMapper] -- Pid Remapper associated with the query
  24. // [secCache] -- Cache of AccessCheck() results
  25. // [fUsePathAlias] -- TRUE if client is going through rdr/svr
  26. //
  27. // History: 19-Aug-93 KyleP Created
  28. //
  29. //--------------------------------------------------------------------------
  30. CMetaPropEnum::CMetaPropEnum( PCatalog & cat,
  31. ICiQueryPropertyMapper *pQueryPropMapper,
  32. CSecurityCache & secCache,
  33. BOOL fUsePathAlias )
  34. : CGenericPropRetriever( cat,
  35. pQueryPropMapper,
  36. secCache,
  37. 0 ), // Never fixup 'path'
  38. _iBmk( 0 )
  39. {
  40. _Path.Buffer = _awcGuid;
  41. _Path.Length = ccStringizedGuid * sizeof(WCHAR);
  42. }
  43. //+-------------------------------------------------------------------------
  44. //
  45. // Member: CMetaPropEnum::~CMetaPropEnum, public
  46. //
  47. // Synopsis: Destructor
  48. //
  49. // History: 19-Aug-93 KyleP Created
  50. //
  51. //--------------------------------------------------------------------------
  52. CMetaPropEnum::~CMetaPropEnum()
  53. {
  54. }
  55. //+-------------------------------------------------------------------------
  56. //
  57. // Member: CMetaPropEnum::NextObject, public
  58. //
  59. // Synopsis: Move to next object
  60. //
  61. // Returns: Work id of next valid object, or widInvalid if end of
  62. // iteration.
  63. //
  64. // History: 19-Aug-93 KyleP Created
  65. //
  66. //--------------------------------------------------------------------------
  67. WORKID CMetaPropEnum::NextObject()
  68. {
  69. if ( !_cat.EnumerateProperty( _psCurrent, _cbCurrent, _typeCurrent,
  70. _storeLevelCurrent, _fModifiableCurrent,
  71. _iBmk ) )
  72. return widInvalid;
  73. //
  74. // String-ify the guid
  75. //
  76. swprintf( _awcGuid,
  77. L"%08lX-%04X-%04X-%02X%02X%02X%02X%02X%02X%02X%02X",
  78. _psCurrent.GetPropSet().Data1,
  79. _psCurrent.GetPropSet().Data2,
  80. _psCurrent.GetPropSet().Data3,
  81. _psCurrent.GetPropSet().Data4[0], _psCurrent.GetPropSet().Data4[1],
  82. _psCurrent.GetPropSet().Data4[2], _psCurrent.GetPropSet().Data4[3],
  83. _psCurrent.GetPropSet().Data4[4], _psCurrent.GetPropSet().Data4[5],
  84. _psCurrent.GetPropSet().Data4[6], _psCurrent.GetPropSet().Data4[7] );
  85. //
  86. // String-ify the PropId, if appropriate.
  87. //
  88. if ( _psCurrent.IsPropertyPropid() )
  89. {
  90. _Name.Length = (USHORT)(sizeof(WCHAR) * swprintf( _awcPropId, L"%u", _psCurrent.GetPropertyPropid() ));
  91. _Name.Buffer = _awcPropId;
  92. }
  93. else
  94. {
  95. _Name.Buffer = (WCHAR *)_psCurrent.GetPropertyName();
  96. _Name.Length = sizeof(WCHAR) * wcslen( _Name.Buffer );
  97. }
  98. return _iBmk;
  99. }
  100. //+-------------------------------------------------------------------------
  101. //
  102. // Member: CMetaPropEnum::GetPropGuid
  103. //
  104. // Synopsis: Returns guid property
  105. //
  106. // History: 12-Dec-96 SitaramR Added header
  107. //
  108. //--------------------------------------------------------------------------
  109. BOOL CMetaPropEnum::GetPropGuid( GUID & guid )
  110. {
  111. RtlCopyMemory( &guid, &(_psCurrent.GetPropSet()), sizeof(guid) );
  112. return TRUE;
  113. }
  114. //+-------------------------------------------------------------------------
  115. //
  116. // Member: CMetaPropEnum::GetPropPid
  117. //
  118. // Synopsis: Returns propid property
  119. //
  120. // History: 12-Dec-96 SitaramR Added header
  121. //
  122. //--------------------------------------------------------------------------
  123. PROPID CMetaPropEnum::GetPropPropid()
  124. {
  125. if ( _psCurrent.IsPropertyPropid() )
  126. return _psCurrent.GetPropertyPropid();
  127. else
  128. return pidInvalid;
  129. }
  130. //+-------------------------------------------------------------------------
  131. //
  132. // Member: CMetaPropEnum::GetPropName
  133. //
  134. // Synopsis: Returns propname property
  135. //
  136. // History: 12-Dec-96 SitaramR Added header
  137. //
  138. //--------------------------------------------------------------------------
  139. UNICODE_STRING const * CMetaPropEnum::GetPropName()
  140. {
  141. if ( _psCurrent.IsPropertyName() )
  142. return &_Name;
  143. else
  144. return 0;
  145. }
  146. //+-------------------------------------------------------------------------
  147. //
  148. // Member: CMetaPropEnum::BeginPropertyRetrieval
  149. //
  150. // Synopsis: Prime wid for property retrieval
  151. //
  152. // Arguments: [wid] -- Wid to prime
  153. //
  154. // History: 12-Dec-96 SitaramR Created
  155. //
  156. //--------------------------------------------------------------------------
  157. SCODE STDMETHODCALLTYPE CMetaPropEnum::BeginPropertyRetrieval( WORKID wid )
  158. {
  159. //
  160. // Check that we are retrieving the property for the wid on
  161. // which we are currently positioned
  162. //
  163. Win4Assert( wid == _widCurrent );
  164. Win4Assert( _widPrimedForPropRetrieval == widInvalid );
  165. if ( wid == _widCurrent )
  166. {
  167. _widPrimedForPropRetrieval = _widCurrent;
  168. return S_OK;
  169. }
  170. else
  171. return E_FAIL;
  172. }
  173. //+-------------------------------------------------------------------------
  174. //
  175. // Member: CMetaPropEnum::IsInScope
  176. //
  177. // Synopsis: Checks if current wid is in scope
  178. //
  179. // Arguments: [pfInScope] -- Scope check result returned here
  180. //
  181. // History: 12-Dec-96 SitaramR Created
  182. //
  183. //--------------------------------------------------------------------------
  184. SCODE STDMETHODCALLTYPE CMetaPropEnum::IsInScope( BOOL *pfInScope )
  185. {
  186. if ( widInvalid == _widPrimedForPropRetrieval )
  187. return CI_E_WORKID_NOTVALID;
  188. *pfInScope = TRUE;
  189. return S_OK;
  190. }
  191. //+-------------------------------------------------------------------------
  192. //
  193. // Member: CMetaPropEnum::CheckSecurity
  194. //
  195. // Synopsis: Test wid for security access
  196. //
  197. // Arguments: [am] -- Access Mask
  198. // [pfGranted] -- Result of security check returned here
  199. //
  200. // History: 12-Dec-96 SitaramR Created
  201. //
  202. //--------------------------------------------------------------------------
  203. SCODE STDMETHODCALLTYPE CMetaPropEnum::CheckSecurity( ACCESS_MASK am,
  204. BOOL *pfGranted)
  205. {
  206. if ( _widPrimedForPropRetrieval == widInvalid )
  207. return CI_E_WORKID_NOTVALID;
  208. *pfGranted = TRUE;
  209. return S_OK;
  210. }
  211. //+-------------------------------------------------------------------------
  212. //
  213. // Member: CMetaPropEnum::Begin
  214. //
  215. // Synopsis: Begins an enumeration
  216. //
  217. // History: 12-Dec-96 SitaramR Created
  218. //
  219. //--------------------------------------------------------------------------
  220. SCODE STDMETHODCALLTYPE CMetaPropEnum::Begin()
  221. {
  222. SCODE sc = S_OK;
  223. TRY
  224. {
  225. _iBmk = 0;
  226. _widCurrent = NextObject();
  227. }
  228. CATCH( CException, e )
  229. {
  230. sc = e.GetErrorCode();
  231. vqDebugOut(( DEB_ERROR,
  232. "CMetaPropEnum::Begin - Exception caught 0x%x\n",
  233. sc ));
  234. }
  235. END_CATCH;
  236. return sc;
  237. }
  238. //+-------------------------------------------------------------------------
  239. //
  240. // Member: CMetaPropEnum::CurrentDocument
  241. //
  242. // Synopsis: Returns current document
  243. //
  244. // Arguments: [pWorkId] -- Wid of current doc returned here
  245. //
  246. // History: 12-Dec-96 SitaramR Created
  247. //
  248. //--------------------------------------------------------------------------
  249. SCODE STDMETHODCALLTYPE CMetaPropEnum::CurrentDocument( WORKID *pWorkId )
  250. {
  251. *pWorkId = _widCurrent;
  252. if ( _widCurrent == widInvalid )
  253. return CI_S_END_OF_ENUMERATION;
  254. else
  255. return S_OK;
  256. }
  257. //+-------------------------------------------------------------------------
  258. //
  259. // Member: CMetaPropEnum::NextDocument
  260. //
  261. // Synopsis: Returns next document
  262. //
  263. // Arguments: [pWorkId] -- Wid of next doc returned here
  264. //
  265. // History: 12-Dec-96 SitaramR Created
  266. //
  267. //--------------------------------------------------------------------------
  268. SCODE STDMETHODCALLTYPE CMetaPropEnum::NextDocument( WORKID *pWorkId )
  269. {
  270. SCODE sc = S_OK;
  271. TRY
  272. {
  273. _widCurrent = NextObject();
  274. sc = CurrentDocument( pWorkId );
  275. }
  276. CATCH( CException, e )
  277. {
  278. sc = e.GetErrorCode();
  279. vqDebugOut(( DEB_ERROR,
  280. "CMetaPropEnum::NextDocument - Exception caught 0x%x\n",
  281. sc ));
  282. }
  283. END_CATCH;
  284. return sc;
  285. }
  286. //+-------------------------------------------------------------------------
  287. //
  288. // Member: CMetaPropEnum::End
  289. //
  290. // Synopsis: Ends an enumeration
  291. //
  292. // History: 12-Dec-96 SitaramR Created
  293. //
  294. //--------------------------------------------------------------------------
  295. SCODE STDMETHODCALLTYPE CMetaPropEnum::End()
  296. {
  297. _widCurrent = widInvalid;
  298. return S_OK;
  299. }
  300. //+-------------------------------------------------------------------------
  301. //
  302. // Method: CMetaPropEnum::AddRef
  303. //
  304. // Synopsis: Increments refcount
  305. //
  306. // History: 12-Dec-1996 SitaramR Created
  307. //
  308. //--------------------------------------------------------------------------
  309. ULONG STDMETHODCALLTYPE CMetaPropEnum::AddRef()
  310. {
  311. return CGenericPropRetriever::AddRef();
  312. }
  313. //+-------------------------------------------------------------------------
  314. //
  315. // Method: CMetaPropEnum::Release
  316. //
  317. // Synopsis: Decrement refcount. Delete if necessary.
  318. //
  319. // History: 12-Dec-1996 SitaramR Created
  320. //
  321. //--------------------------------------------------------------------------
  322. ULONG STDMETHODCALLTYPE CMetaPropEnum::Release()
  323. {
  324. return CGenericPropRetriever::Release();
  325. }
  326. //+-------------------------------------------------------------------------
  327. //
  328. // Method: CMetaPropEnum::QueryInterface
  329. //
  330. // Synopsis: Rebind to other interface
  331. //
  332. // Arguments: [riid] -- IID of new interface
  333. // [ppvObject] -- New interface * returned here
  334. //
  335. // Returns: S_OK if bind succeeded, E_NOINTERFACE if bind failed
  336. //
  337. // History: 12-Dec-1996 SitaramR Created
  338. //
  339. //--------------------------------------------------------------------------
  340. SCODE STDMETHODCALLTYPE CMetaPropEnum::QueryInterface(
  341. REFIID riid,
  342. void ** ppvObject)
  343. {
  344. if ( IID_ICiCScopeEnumerator == riid )
  345. *ppvObject = (ICiCScopeEnumerator *)this;
  346. else if ( IID_ICiCPropRetriever == riid )
  347. *ppvObject = (ICiCPropRetriever *)this;
  348. else if ( IID_IUnknown == riid )
  349. *ppvObject = (IUnknown *)(ICiCScopeEnumerator *) this;
  350. else
  351. {
  352. *ppvObject = 0;
  353. return E_NOINTERFACE;
  354. }
  355. AddRef();
  356. return S_OK;
  357. }
  358. //+---------------------------------------------------------------------------
  359. //
  360. // Member: CMetaPropEnum::RatioFinished, public
  361. //
  362. // Synopsis: Returns query progress estimate
  363. //
  364. // Arguments: [denom] -- Denominator returned here
  365. // [num] -- Numerator returned here
  366. //
  367. // History: 12-Dec-96 SitaramR Created
  368. //
  369. //----------------------------------------------------------------------------
  370. SCODE STDMETHODCALLTYPE CMetaPropEnum::RatioFinished (ULONG *pDenom, ULONG *pNum)
  371. {
  372. *pNum = 50;
  373. *pDenom = 100;
  374. return S_OK;
  375. }