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.

469 lines
14 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Copyright (C) Microsoft Corporation, 1996 - 2002.
  4. //
  5. // File: ixsso.hxx
  6. //
  7. // Contents: Query SSO class
  8. //
  9. // History: 29 Oct 1996 Alanw Created
  10. //
  11. //----------------------------------------------------------------------------
  12. #pragma once
  13. //-----------------------------------------------------------------------------
  14. // Include Files
  15. //-----------------------------------------------------------------------------
  16. // Query object interface declarations
  17. #include "ixssoifc.h"
  18. #include "ixserror.hxx"
  19. #include <ciintf.h>
  20. #include <tgrow.hxx>
  21. enum EOptimizeFor {
  22. eOptNone = 0,
  23. eOptPerformance = 1,
  24. eOptRecall = 2,
  25. eOptHitCount = 4,
  26. // eOptPrecision,
  27. };
  28. extern const WCHAR * pwcDefaultDialect;
  29. //
  30. // Private interface definition for use by CixssoUtil.
  31. //
  32. const IID IID_IixssoQueryPrivate = {0x9357bd10,0x2b6f,0x11d0,{0xbf,0xbc,0x00,0x20,0xf8,0x00,0x80,0x24}};
  33. interface DECLSPEC_UUID("9357bd10-2b6f-11d0-bfbc-0020f8008024")
  34. IixssoQueryPrivate : public IixssoQueryEx
  35. {
  36. public:
  37. virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE AddScopeToQuery(
  38. /* [in] */ BSTR pwszScope,
  39. /* [optional][in] */ BSTR pwszDepth) = 0;
  40. };
  41. class CIXSSOPropertyList : public IColumnMapper
  42. {
  43. public:
  44. CIXSSOPropertyList(ULONG ulCodePage = CP_ACP);
  45. void SetDefaultList(IColumnMapper *pDefaultList);
  46. //
  47. // IUnknown methods.
  48. //
  49. STDMETHOD(QueryInterface) (THIS_ REFIID riid, void ** ppvObj);
  50. STDMETHOD_(ULONG, AddRef) (THIS);
  51. STDMETHOD_(ULONG, Release) (THIS);
  52. //
  53. // IColumnMapper methods
  54. //
  55. STDMETHOD(GetPropInfoFromName) (
  56. const WCHAR *wcsPropName,
  57. DBID * *ppPropId,
  58. DBTYPE *pPropType,
  59. unsigned int *puiWidth);
  60. STDMETHOD(GetPropInfoFromId) (
  61. const DBID *pPropId,
  62. WCHAR * *pwcsName,
  63. DBTYPE *pPropType,
  64. unsigned int *puiWidth);
  65. STDMETHOD(EnumPropInfo) (
  66. ULONG iEntry,
  67. const WCHAR * *pwcsName,
  68. DBID * *ppPropId,
  69. DBTYPE *pPropType,
  70. unsigned int *puiWidth);
  71. STDMETHOD(IsMapUpToDate)();
  72. // local methods
  73. SCODE AddEntry( XPtr<CPropEntry> & xPropEntry, int iLine );
  74. private:
  75. XInterface<IColumnMapper> _xDefaultList;
  76. XInterface<CPropertyList> _xOverrideList;
  77. LONG _cRefs; // ref counting
  78. CMutexSem _mtxAdd; // serialize access to AddEntry
  79. ULONG _ulCodePage; // codepage
  80. };
  81. //-----------------------------------------------------------------------------
  82. // CixssoQuery Declaration
  83. //-----------------------------------------------------------------------------
  84. class CixssoQuery : public IixssoQueryPrivate,
  85. public ISupportErrorInfo,
  86. public IObjectWithSite
  87. #if 0
  88. ,public IObjectSafety
  89. #endif
  90. {
  91. friend class CIxssoQueryCF;
  92. friend class CNLssoQueryCF;
  93. public:
  94. // IUnknown methods
  95. STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj);
  96. STDMETHOD_(ULONG, AddRef)(THIS);
  97. STDMETHOD_(ULONG, Release)(THIS);
  98. // IDispatch methods
  99. STDMETHOD(GetTypeInfoCount)(THIS_ UINT * pctinfo);
  100. STDMETHOD(GetTypeInfo)( THIS_
  101. UINT itinfo,
  102. LCID lcid,
  103. ITypeInfo * * pptinfo);
  104. STDMETHOD(GetIDsOfNames)( THIS_
  105. REFIID riid,
  106. OLECHAR * * rgszNames,
  107. UINT cNames,
  108. LCID lcid,
  109. DISPID * rgdispid);
  110. STDMETHOD(Invoke)( THIS_
  111. DISPID dispidMember,
  112. REFIID riid,
  113. LCID lcid,
  114. WORD wFlags,
  115. DISPPARAMS * pdispparams,
  116. VARIANT * pvarResult,
  117. EXCEPINFO * pexcepinfo,
  118. UINT * puArgErr);
  119. // ISupportErrorInfo method
  120. STDMETHOD(InterfaceSupportsErrorInfo)( THIS_
  121. REFIID riid);
  122. //
  123. // IixssoQuery property get/put methods
  124. //
  125. HRESULT STDMETHODCALLTYPE get_Query(
  126. /* [retval][out] */ BSTR *val);
  127. HRESULT STDMETHODCALLTYPE put_Query(
  128. /* [in] */ BSTR val);
  129. HRESULT STDMETHODCALLTYPE get_CiScope(
  130. /* [retval][out] */ BSTR *val);
  131. HRESULT STDMETHODCALLTYPE put_CiScope(
  132. /* [in] */ BSTR val);
  133. HRESULT STDMETHODCALLTYPE get_SortBy(
  134. /* [retval][out] */ BSTR *val);
  135. HRESULT STDMETHODCALLTYPE put_SortBy(
  136. /* [in] */ BSTR val);
  137. HRESULT STDMETHODCALLTYPE get_GroupBy(
  138. /* [retval][out] */ BSTR *val);
  139. HRESULT STDMETHODCALLTYPE put_GroupBy(
  140. /* [in] */ BSTR val);
  141. HRESULT STDMETHODCALLTYPE get_CiFlags(
  142. /* [retval][out] */ BSTR *val);
  143. HRESULT STDMETHODCALLTYPE put_CiFlags(
  144. /* [in] */ BSTR val);
  145. HRESULT STDMETHODCALLTYPE get_Columns(
  146. /* [retval][out] */ BSTR *val);
  147. HRESULT STDMETHODCALLTYPE put_Columns(
  148. /* [in] */ BSTR val);
  149. HRESULT STDMETHODCALLTYPE get_LocaleID(
  150. /* [retval][out] */ LONG *val);
  151. HRESULT STDMETHODCALLTYPE put_LocaleID(
  152. /* [in] */ LONG val);
  153. HRESULT STDMETHODCALLTYPE get_CodePage(
  154. /* [retval][out] */ LONG *val);
  155. HRESULT STDMETHODCALLTYPE put_CodePage(
  156. /* [in] */ LONG val);
  157. HRESULT STDMETHODCALLTYPE get_Catalog(
  158. /* [retval][out] */ BSTR *val);
  159. HRESULT STDMETHODCALLTYPE put_Catalog(
  160. /* [in] */ BSTR val);
  161. HRESULT STDMETHODCALLTYPE get_Dialect(
  162. /* [retval][out] */ BSTR *val);
  163. HRESULT STDMETHODCALLTYPE put_Dialect(
  164. /* [in] */ BSTR val);
  165. HRESULT STDMETHODCALLTYPE get_OptimizeFor(
  166. /* [retval][out] */ BSTR *val);
  167. HRESULT STDMETHODCALLTYPE put_OptimizeFor(
  168. /* [in] */ BSTR val);
  169. HRESULT STDMETHODCALLTYPE get_AllowEnumeration(
  170. /* [retval][out] */ VARIANT_BOOL *val);
  171. HRESULT STDMETHODCALLTYPE put_AllowEnumeration(
  172. /* [in] */ VARIANT_BOOL val);
  173. HRESULT STDMETHODCALLTYPE get_MaxRecords(
  174. /* [retval][out] */ LONG *val);
  175. HRESULT STDMETHODCALLTYPE put_MaxRecords(
  176. /* [in] */ LONG val);
  177. HRESULT STDMETHODCALLTYPE get_StartHit(
  178. /* [retval][out] */ VARIANT * pvar);
  179. HRESULT STDMETHODCALLTYPE put_StartHit(
  180. /* [in] */ VARIANT * pvar);
  181. HRESULT STDMETHODCALLTYPE get_ResourceUseFactor(
  182. /* [retval][out] */ LONG *val);
  183. HRESULT STDMETHODCALLTYPE put_ResourceUseFactor(
  184. /* [in] */ LONG val);
  185. HRESULT STDMETHODCALLTYPE get_QueryTimedOut(
  186. /* [retval][out] */ VARIANT_BOOL *val);
  187. HRESULT STDMETHODCALLTYPE get_QueryIncomplete(
  188. /* [retval][out] */ VARIANT_BOOL *val);
  189. HRESULT STDMETHODCALLTYPE get_OutOfDate(
  190. /* [retval][out] */ VARIANT_BOOL *val);
  191. //
  192. // IixssoQueryEx methods
  193. //
  194. HRESULT STDMETHODCALLTYPE get_FirstRows(
  195. /* [retval][out] */ LONG *val);
  196. HRESULT STDMETHODCALLTYPE put_FirstRows(
  197. /* [in] */ LONG val);
  198. //
  199. // IixssoQuery methods
  200. //
  201. HRESULT STDMETHODCALLTYPE SetQueryFromURL(
  202. /* [in] */ BSTR pwszQuery);
  203. HRESULT STDMETHODCALLTYPE QueryToURL(
  204. /* [retval][out] */ BSTR * ppwszQuery);
  205. HRESULT STDMETHODCALLTYPE AddScopeToQuery(
  206. /* [in] */ BSTR pwszScope,
  207. /* [in] */ BSTR pwszDepth);
  208. HRESULT STDMETHODCALLTYPE DefineColumn(
  209. /* [in] */ BSTR pwszColDefinition);
  210. HRESULT STDMETHODCALLTYPE CreateRecordset(
  211. /* [in] */ BSTR pwszSequential,
  212. /* [retval][out] */ IDispatch **ppDisp);
  213. HRESULT STDMETHODCALLTYPE Reset( void );
  214. //
  215. // ASP standard methods
  216. //
  217. HRESULT STDMETHODCALLTYPE OnStartPage( IUnknown * pUnk );
  218. HRESULT STDMETHODCALLTYPE OnEndPage( void );
  219. #if 0
  220. //
  221. // IObjectSafety methods
  222. //
  223. HRESULT STDMETHODCALLTYPE GetInterfaceSafetyOptions(
  224. REFIID riid,
  225. DWORD * pdwSupportedOptions,
  226. DWORD * pdwEnabledOptions );
  227. HRESULT STDMETHODCALLTYPE SetInterfaceSafetyOptions(
  228. REFIID riid,
  229. DWORD dwOptionSetMask,
  230. DWORD dwEnabledOptions );
  231. #endif
  232. //
  233. // IObjectWithSite methods
  234. //
  235. HRESULT STDMETHODCALLTYPE SetSite( IUnknown * pSite );
  236. HRESULT STDMETHODCALLTYPE GetSite( REFIID riid, void ** ppvSite );
  237. private:
  238. CixssoQuery( ITypeLib * pitlb,
  239. IClassFactory * pIAdoRecordsetCF,
  240. BOOL fAdoV1_5,
  241. const CLSID & ssoClsid );
  242. ~CixssoQuery();
  243. // Local methods
  244. void SetError( SCODE sc,
  245. const WCHAR * loc = 0,
  246. unsigned eErrClass = 0
  247. )
  248. {
  249. _err.SetError( sc, 0, 0, loc, eErrClass, _lcid );
  250. }
  251. void SetError( SCODE sc,
  252. const WCHAR * pwszLoc,
  253. const WCHAR * pwszDescription
  254. )
  255. {
  256. _err.SetError( sc, pwszLoc, pwszDescription );
  257. }
  258. void ExecuteQuery( void );
  259. void IsSafeForScripting();
  260. void GetDefaultCatalog( void );
  261. LCID GetLCID() const { return _lcid; }
  262. IColumnMapper * GetColumnMapper( )
  263. { return &_PropertyList; }
  264. DWORD GetQueryStatus( );
  265. BOOL IsAVirtualPath( WCHAR * wcsPath );
  266. BOOL IsSequential( void )
  267. { return _fSequential; }
  268. BOOL IsQueryActive( void )
  269. { return _pIRowset != 0; }
  270. SCODE ParseOptimizeFor( WCHAR const * wcsOptString,
  271. DWORD & eChoice );
  272. ULONG ParseCiDepthFlag( BSTR bstrFlags );
  273. ULONG GetDialect();
  274. SCODE SetLocaleString(BSTR str);
  275. // Property get/put helpers
  276. SCODE CopyWstrToBstr( BSTR * pbstr, WCHAR const * pwstr );
  277. SCODE CopyBstrToWstr( BSTR bstr, LPWSTR & pwstr );
  278. SCODE CopyBstrToWstrArray( BSTR bstr,
  279. CDynArray<WCHAR> &apstr,
  280. unsigned i );
  281. SCODE GetBoolProperty( VARIANT_BOOL * pfVal, BOOL fMemberVal );
  282. SCODE PutBoolProperty( VARIANT_BOOL fInputVal, BOOL & fMemberVal );
  283. SCODE CheckQueryStatusBit( VARIANT_BOOL * pfVal, DWORD dwBit );
  284. ULONG _cRef;
  285. CixssoError _err;
  286. IClassFactory * _pIAdoRecordsetCF;
  287. BOOL _fAdoV15;
  288. IRowset * _pIRowset;
  289. IRowsetQueryStatus * _pIRowsetQueryStatus;
  290. BOOL _fSequential; // TRUE if query is sequential
  291. // Settable parameters
  292. LCID _lcid; // Locale ID used for this query
  293. ULONG _ulCodepage; // Codepage used for this query
  294. XInterface<IUnknown> _xSite; // site loading the object
  295. WCHAR * _pwszRestriction; // Query
  296. WCHAR * _pwszSort; // SortBy
  297. WCHAR * _pwszGroup; // GroupBy
  298. WCHAR * _pwszColumns; // Columns
  299. WCHAR * _pwszCatalog; // Catalog
  300. WCHAR * _pwszDialect; // Query Dialect
  301. // Scope related parameters
  302. unsigned _cScopes; // number of active scopes
  303. CDynArray<WCHAR> _apwszScope; // CiScope
  304. CDynArrayInPlace<ULONG> _aulDepth; // CiFlags, DEEP/SHALLOW
  305. BOOL _fAllowEnumeration;
  306. DWORD _dwOptimizeFlags;
  307. LONG _maxResults; // total number of results
  308. LONG _cFirstRows;
  309. LONG _iResourceFactor; // resource use factor
  310. XSafeArray _StartHit; // starting hit(s) in results
  311. ITypeInfo * _ptinfo; // Type info from type lib
  312. // Command creator for this instance
  313. XInterface<ISimpleCommandCreator> _xCmdCreator; // points to cmd creator
  314. CIXSSOPropertyList _PropertyList; // Property list
  315. };
  316. // Global variables.
  317. class CTheGlobalIXSSOVariables;
  318. extern CTheGlobalIXSSOVariables * g_pTheGlobalIXSSOVariables;
  319. class CTheGlobalIXSSOVariables
  320. {
  321. public:
  322. CTheGlobalIXSSOVariables();
  323. ~CTheGlobalIXSSOVariables()
  324. {
  325. VariantClear(&_vtAcceptLanguageHeader);
  326. }
  327. VARIANT _vtAcceptLanguageHeader;
  328. XInterface<ISimpleCommandCreator> xCmdCreator;
  329. XInterface<IColumnMapperCreator> xColumnMapperCreator;
  330. };
  331. #define TheGlobalIXSSOVariables (*g_pTheGlobalIXSSOVariables)
  332. #define g_vtAcceptLanguageHeader TheGlobalIXSSOVariables._vtAcceptLanguageHeader
  333. void ParseNumberVectorString( WCHAR * pwszValue, CDynArrayInPlace<LONG> & aNum );
  334. void FormatLongVector( SAFEARRAY * psa, XGrowable<WCHAR> & awchBuf );