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.

228 lines
7.2 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: StdQSpec.cxx
  7. //
  8. // Contents: ICommand for file-based queries
  9. //
  10. // Classes: CMetadataQuerySpec
  11. //
  12. // History: 30 Jun 1995 AlanW Created
  13. //
  14. //----------------------------------------------------------------------------
  15. #include <pch.cxx>
  16. #pragma hdrstop
  17. #include "metqspec.hxx"
  18. //+-------------------------------------------------------------------------
  19. //
  20. // Member: CMetadataQuerySpec::CMetadataQuerySpec, public
  21. //
  22. // Synopsis: Constructor of a CMetadataQuerySpec
  23. //
  24. // Arguments: [pOuterUnk] - Outer unknown
  25. // [ppMyUnk] - OUT: filled in with pointer to non-delegated
  26. // IUnknown on return
  27. // [eType] - Class of metadata to return
  28. // [pCat] - Content index catalog
  29. // [pMachine]
  30. //
  31. // History: 08-Feb-96 KyleP Added support for virtual paths
  32. //
  33. //--------------------------------------------------------------------------
  34. CMetadataQuerySpec::CMetadataQuerySpec (
  35. IUnknown * pOuterUnk,
  36. IUnknown ** ppMyUnk,
  37. CiMetaData eType,
  38. WCHAR const * pCat,
  39. WCHAR const * pMachine )
  40. : CRootQuerySpec(pOuterUnk, ppMyUnk),
  41. _eType( eType )
  42. {
  43. //
  44. // Make a copy of the catalog string for ICommand::Clone
  45. //
  46. unsigned len = wcslen( pCat ) + 1;
  47. _xCat.Set( new WCHAR[len] );
  48. RtlCopyMemory( _xCat.GetPointer(), pCat, len * sizeof(WCHAR) );
  49. //
  50. // Make a copy of the machine string for ICommand::Clone
  51. //
  52. if ( 0 != pMachine )
  53. {
  54. len = wcslen( pMachine ) + 1;
  55. _xMachine.Set( new WCHAR[len] );
  56. RtlCopyMemory( _xMachine.GetPointer(), pMachine, len * sizeof(WCHAR) );
  57. }
  58. }
  59. //+-------------------------------------------------------------------------
  60. //
  61. // Member: CMetadataQuerySpec::QueryInternalQuery, protected
  62. //
  63. // Synopsis: Instantiates internal query, using current parameters.
  64. //
  65. // Returns: Pointer to internal query object.
  66. //
  67. // History: 03-Mar-1997 KyleP Created
  68. //
  69. //--------------------------------------------------------------------------
  70. PIInternalQuery * CMetadataQuerySpec::QueryInternalQuery()
  71. {
  72. //
  73. // get a pointer to the IInternalQuery interface
  74. //
  75. PIInternalQuery * pQuery = 0;
  76. SCODE sc = EvalMetadataQuery( &pQuery,
  77. _eType,
  78. _xCat.GetPointer(),
  79. _xMachine.GetPointer() );
  80. if ( FAILED( sc ) )
  81. THROW( CException( sc ) );
  82. return pQuery;
  83. }
  84. //+---------------------------------------------------------------------------
  85. //
  86. // Member: MakeMetadataICommand
  87. //
  88. // Synopsis: Evaluate the metadata query
  89. //
  90. // Arguments: [ppQuery] -- Returns the IUnknown for the command
  91. // [eType] -- Type of metadata (vroot, proot, etc)
  92. // [wcsCat] -- Catalog
  93. // [wcsMachine] -- Machine name for meta query
  94. // [pOuterUnk] -- (optional) outer unknown pointer
  95. //
  96. // Returns SCODE result
  97. //
  98. // History: 15-Apr-96 SitaramR Created header
  99. // 29-May-97 EmilyB Added aggregation support, so now
  100. // returns IUnknown ptr and caller
  101. // must now call QI to get ICommand ptr
  102. //
  103. //----------------------------------------------------------------------------
  104. SCODE MakeMetadataICommand(
  105. IUnknown ** ppQuery,
  106. CiMetaData eType,
  107. WCHAR const * wcsCat,
  108. WCHAR const * wcsMachine,
  109. IUnknown * pOuterUnk )
  110. {
  111. //
  112. // Check for invalid parameters
  113. //
  114. if ( 0 == wcsCat ||
  115. 0 == ppQuery ||
  116. ( eType != CiVirtualRoots &&
  117. eType != CiPhysicalRoots &&
  118. eType != CiProperties ) )
  119. {
  120. return E_INVALIDARG;
  121. }
  122. *ppQuery = 0;
  123. CMetadataQuerySpec * pQuery = 0;
  124. SCODE sc = S_OK;
  125. TRANSLATE_EXCEPTIONS;
  126. TRY
  127. {
  128. pQuery = new CMetadataQuerySpec( pOuterUnk,
  129. ppQuery,
  130. eType,
  131. wcsCat,
  132. wcsMachine );
  133. }
  134. CATCH( CException, e )
  135. {
  136. Win4Assert(0 == pQuery);
  137. sc = e.GetErrorCode();
  138. }
  139. END_CATCH
  140. UNTRANSLATE_EXCEPTIONS;
  141. return sc;
  142. } //MakeMetadataICommand
  143. //+---------------------------------------------------------------------------
  144. //
  145. // Method: CMetadataQuerySpec::GetProperties, public
  146. //
  147. // Synopsis: Get rowset properties
  148. //
  149. // Arguments: [cPropertySetIDs] - number of desired property set IDs or 0
  150. // [rgPropertySetIDs] - array of desired property set IDs or NULL
  151. // [pcPropertySets] - number of property sets returned
  152. // [prgPropertySets] - array of returned property sets
  153. //
  154. // Returns: SCODE - result code indicating error return status. One of
  155. // S_OK, DB_S_ERRORSOCCURRED or DB_E_ERRORSOCCURRED. Any
  156. // other errors are thrown.
  157. //
  158. // History: 12-Mayr-97 dlee Created
  159. //
  160. //----------------------------------------------------------------------------
  161. SCODE STDMETHODCALLTYPE CMetadataQuerySpec::GetProperties(
  162. ULONG const cPropertySetIDs,
  163. DBPROPIDSET const rgPropertySetIDs[],
  164. ULONG * pcPropertySets,
  165. DBPROPSET ** prgPropertySets)
  166. {
  167. _DBErrorObj.ClearErrorInfo();
  168. SCODE scParent = CRootQuerySpec::GetProperties( cPropertySetIDs,
  169. rgPropertySetIDs,
  170. pcPropertySets,
  171. prgPropertySets );
  172. if ( S_OK != scParent )
  173. _DBErrorObj.PostHResult( scParent, IID_ICommandProperties );
  174. return scParent;
  175. } //GetProperties
  176. //+---------------------------------------------------------------------------
  177. //
  178. // Method: CMetadataQuerySpec::SetProperties, public
  179. //
  180. // Synopsis: Set rowset scope properties
  181. //
  182. // Arguments: [cPropertySets] - number of property sets
  183. // [rgPropertySets] - array of property sets
  184. //
  185. // Returns: SCODE - result code indicating error return status. One of
  186. // S_OK, DB_S_ERRORSOCCURRED or DB_E_ERRORSOCCURRED. Any
  187. // other errors are thrown.
  188. //
  189. // History: 12-Mayr-97 dlee Created
  190. //
  191. //----------------------------------------------------------------------------
  192. SCODE STDMETHODCALLTYPE CMetadataQuerySpec::SetProperties(
  193. ULONG cPropertySets,
  194. DBPROPSET rgPropertySets[] )
  195. {
  196. _DBErrorObj.ClearErrorInfo();
  197. SCODE scParent = CRootQuerySpec::SetProperties( cPropertySets,
  198. rgPropertySets );
  199. if ( S_OK != scParent )
  200. _DBErrorObj.PostHResult( scParent, IID_ICommandProperties );
  201. return scParent;
  202. } //SetProperties