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.

1024 lines
37 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 2000.
  5. //
  6. // File: proputl.cxx
  7. //
  8. // Contents: Utility object for sharing property information between
  9. // the commandobject and the rowset object
  10. //
  11. // Classes: CMRowsetProps : public CUtlProps
  12. // CMDSProps : public CUtlProps
  13. // CMSessProps : public CUtlProps
  14. // CMDSPropInfo : public CUtlPropInfo
  15. //
  16. // History: 10-28-97 danleg Created from monarch utlprop.cpp
  17. //
  18. //----------------------------------------------------------------------------
  19. #include <pch.cxx>
  20. #pragma hdrstop
  21. #include <propglob.hxx>
  22. #include <ntverp.h>
  23. #include <proputl.hxx>
  24. #include <proprst.hxx>
  25. #include "propinfr.h"
  26. #include "proptbl.hxx"
  27. //-----------------------------------------------------------------------------
  28. // Constants
  29. //-----------------------------------------------------------------------------
  30. #define __L(x) L ## x
  31. #define _L(x) __L(x) // Lx
  32. #define __Q(x) #x
  33. #define _Q(x) __Q(x) // "x"
  34. #define _LQ(x) _L(_Q(x)) // L"x"
  35. // Returns string of the form L"0"L"0"L"."L"0"L"0" L"." L"0000"
  36. // The version should be of the format ##.##.####.
  37. #define MakeProvVerString(x, y, z) _LQ(0)_LQ(x) L"." _LQ(y) L"." _LQ(z)
  38. static const LPWSTR pwszProviderOLEDBVer = L"02.00";
  39. static const LPWSTR pwszProviderVersion = MakeProvVerString(VER_PRODUCTMAJORVERSION, VER_PRODUCTMINORVERSION, VER_PRODUCTBUILD);
  40. //static const LPWSTR pwszProviderVersion = MakeProvVerString(VER_PRODUCTVERSION_STRING, VER_PRODUCTBUILD);
  41. static const LCID lcidNeutral = MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),SORT_DEFAULT);
  42. static const LPWSTR pwszNeutral = L"NEUTRAL";
  43. static const LCID InvalidLCID = 0xFFFFFFFF;
  44. static const LPWSTR s_wszCATALOG = L"catalog";
  45. static const LPWSTR s_wszIndexServer = L"Indexing Service";
  46. static const LPWSTR s_wszIndexServerVer = L"03.00.0000";
  47. static const LPWSTR s_wszProviderFileName = L"query.dll";
  48. //-----------------------------------------------------------------------------
  49. // Constants and structures for file read/write.
  50. //-----------------------------------------------------------------------------
  51. //
  52. // Note that this must match up with the enum CMDSProps::EID.
  53. // We don't support all the properties listed in the spec.
  54. //
  55. static const UPROPINFO s_rgdbPropInit[] =
  56. {
  57. //PM_(AUTH_CACHE_AUTHINFO), VT_BOOL, PF_(DBINIT) | PF_(READ) | PF_(WRITE),
  58. //PM_(AUTH_ENCRYPT_PASSWORD), VT_BOOL, PF_(DBINIT) | PF_(READ) | PF_(WRITE),
  59. PM_(AUTH_INTEGRATED), VT_BSTR, PF_(DBINIT) | PF_(READ) | PF_(WRITE),
  60. //PM_(AUTH_MASK_PASSWORD), VT_BOOL, PF_(DBINIT) | PF_(READ) | PF_(WRITE),
  61. //PM_(AUTH_PASSWORD), VT_BSTR, PF_(DBINIT) | PF_(READ) | PF_(WRITE),
  62. //PM_(AUTH_PERSIST_ENCRYPTED), VT_BOOL, PF_(DBINIT) | PF_(READ) | PF_(WRITE),
  63. //PM_(AUTH_PERSIST_SENSITIVE_AUTHINFO), VT_BOOL, PF_(DBINIT) | PF_(READ) | PF_(WRITE),
  64. //PM_(AUTH_USERID), VT_BSTR, PF_(DBINIT) | PF_(READ) | PF_(WRITE),
  65. //PM_(INIT_ASYNCH), VT_I4, PF_(DBINIT) | PF_(READ),
  66. //--PM_(INIT_CATALOG), VT_BSTR, PF_(DBINIT) | PF_(READ) | PF_(WRITE),
  67. PM_(INIT_DATASOURCE), VT_BSTR, PF_(DBINIT) | PF_(READ) | PF_(WRITE),
  68. PM_(INIT_HWND), VT_I4, PF_(DBINIT) | PF_(READ) | PF_(WRITE),
  69. //PM_(INIT_IMPERSONATION_LEVEL), VT_I4, PF_(DBINIT) | PF_(READ) | PF_(WRITE),
  70. PM_(INIT_LCID), VT_I4, PF_(DBINIT) | PF_(READ) | PF_(WRITE),
  71. PM_(INIT_LOCATION), VT_BSTR, PF_(DBINIT) | PF_(READ) | PF_(CHANGE),
  72. //PM_(INIT_MODE), VT_I4, PF_(DBINIT) | PF_(READ) | PF_(WRITE),
  73. PM_(INIT_OLEDBSERVICES), VT_I4, PF_(DBINIT) | PF_(READ) | PF_(WRITE),
  74. PM_(INIT_PROMPT), VT_I2, PF_(DBINIT) | PF_(READ) | PF_(WRITE),
  75. //PM_(INIT_PROTECTION_LEVEL), VT_I4, PF_(DBINIT) | PF_(READ) | PF_(WRITE),
  76. //PM_(INIT_PROVIDERSTRING), VT_BSTR, PF_(DBINIT) | PF_(READ) | PF_(WRITE),
  77. //PM_(INIT_TIMEOUT), VT_I4, PF_(DBINIT) | PF_(READ) | PF_(WRITE),
  78. };
  79. static const UPROPINFO s_rgdbPropDS[] =
  80. {
  81. PM_(CURRENTCATALOG), VT_BSTR, PF_(DATASOURCE) | PF_(READ) | PF_(WRITE),
  82. PM_(RESETDATASOURCE), VT_I4, PF_(DATASOURCE) | PF_(READ) | PF_(WRITE),
  83. };
  84. static const UPROPINFO s_rgdbPropSESS[] =
  85. {
  86. PM_(SESS_AUTOCOMMITISOLEVELS), VT_I4, PF_(SESSION) | PF_(READ),
  87. };
  88. //
  89. // DataSource. Must match with the enumerator in header of CMDSProps
  90. //
  91. static const UPROPINFO s_rgdbPropDSInfo[] =
  92. {
  93. PM_(ACTIVESESSIONS), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  94. //NEVER: PM_(ASYNCTXNABORT), VT_BOOL, PF_(DATASOURCEINFO) | PF_(READ),
  95. //NEVER: PM_(ASYNCTXNCOMMIT), VT_BOOL, PF_(DATASOURCEINFO) | PF_(READ),
  96. PM_(BYREFACCESSORS), VT_BOOL, PF_(DATASOURCEINFO) | PF_(READ),
  97. PM_(CATALOGLOCATION), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  98. PM_(CATALOGTERM), VT_BSTR, PF_(DATASOURCEINFO) | PF_(READ),
  99. PM_(CATALOGUSAGE), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  100. PM_(COLUMNDEFINITION), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  101. //NEVER: PM_(CONCATNULLBEHAVIOR), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  102. //NEVER: PM_(DATASOURCENAME), VT_BSTR, PF_(DATASOURCEINFO) | PF_(READ),
  103. PM_(DATASOURCEREADONLY), VT_BOOL, PF_(DATASOURCEINFO) | PF_(READ),
  104. PM_(DBMSNAME), VT_BSTR, PF_(DATASOURCEINFO) | PF_(READ),
  105. PM_(DBMSVER), VT_BSTR, PF_(DATASOURCEINFO) | PF_(READ),
  106. PM_(DSOTHREADMODEL), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  107. PM_(GROUPBY), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  108. PM_(HETEROGENEOUSTABLES), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  109. //NEVER: PM_(IDENTIFIERCASE), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  110. PM_(MAXOPENCHAPTERS), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  111. //NEVER: PM_(MAXINDEXSIZE), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  112. PM_(MAXROWSIZE), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  113. //NEVER: PM_(MAXROWSIZEINCLUDESBLOB),VT_BOOL, PF_(DATASOURCEINFO) | PF_(READ),
  114. PM_(MAXTABLESINSELECT), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  115. PM_(MULTIPLEPARAMSETS), VT_BOOL, PF_(DATASOURCEINFO) | PF_(READ),
  116. PM_(MULTIPLERESULTS), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  117. PM_(MULTIPLESTORAGEOBJECTS), VT_BOOL, PF_(DATASOURCEINFO) | PF_(READ),
  118. //NEVER: PM_(MULTITABLEUPDATE), VT_BOOL, PF_(DATASOURCEINFO) | PF_(READ),
  119. PM_(NULLCOLLATION), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  120. PM_(OLEOBJECTS), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  121. PM_(ORDERBYCOLUMNSINSELECT), VT_BOOL, PF_(DATASOURCEINFO) | PF_(READ),
  122. PM_(OUTPUTPARAMETERAVAILABILITY), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  123. PM_(PERSISTENTIDTYPE), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  124. //NEVER: PM_(PREPAREABORTBEHAVIOR), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  125. //NEVER: PM_(PREPARECOMMITBEHAVIOR),VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  126. //NEVER: PM_(PROCEDURETERM), VT_BSTR, PF_(DATASOURCEINFO) | PF_(READ),
  127. PM_(PROVIDERFRIENDLYNAME), VT_BSTR, PF_(DATASOURCEINFO) | PF_(READ),
  128. PM_(PROVIDERNAME), VT_BSTR, PF_(DATASOURCEINFO) | PF_(READ),
  129. PM_(PROVIDEROLEDBVER), VT_BSTR, PF_(DATASOURCEINFO) | PF_(READ),
  130. PM_(PROVIDERVER), VT_BSTR, PF_(DATASOURCEINFO) | PF_(READ),
  131. //NEVER: PM_(QUOTEDIDENTIFIERCASE), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  132. PM_(ROWSETCONVERSIONSONCOMMAND), VT_BOOL, PF_(DATASOURCEINFO) | PF_(READ),
  133. //NEVER: PM_(SCHEMATERM), VT_BSTR, PF_(DATASOURCEINFO) | PF_(READ),
  134. //NEVER: PM_(SCHEMAUSAGE), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  135. PM_(SQLSUPPORT), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  136. PM_(STRUCTUREDSTORAGE), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  137. PM_(SUBQUERIES), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  138. PM_(SUPPORTEDTXNDDL), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  139. PM_(SUPPORTEDTXNISOLEVELS), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  140. PM_(SUPPORTEDTXNISORETAIN), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  141. //NEVER: PM_(TABLETERM), VT_BSTR, PF_(DATASOURCEINFO) | PF_(READ),
  142. //NEVER: PM_(USERNAME), VT_BSTR, PF_(DATASOURCEINFO) | PF_(READ),
  143. //--PM_(CONNECTIONSTATUS), VT_I4, PF_(DATASOURCEINFO) | PF_(READ),
  144. //--PM_(SERVERNAME), VT_BSTR PF_(DATASOURCEINFO) | PF_(READ),
  145. };
  146. //
  147. // This is used by CMDSProps, CMDSPropInfo
  148. //
  149. static const UPROPSET s_rgIDXPropertySets[] =
  150. {
  151. &DBPROPSET_DBINIT, NUMELEM(s_rgdbPropInit), s_rgdbPropInit, 0,
  152. &DBPROPSET_DATASOURCEINFO, NUMELEM(s_rgdbPropDSInfo), s_rgdbPropDSInfo, 0,
  153. &DBPROPSET_DATASOURCE, NUMELEM(s_rgdbPropDS), s_rgdbPropDS, 0,
  154. &DBPROPSET_SESSION, NUMELEM(s_rgdbPropSESS), s_rgdbPropSESS, 0,
  155. &DBPROPSET_ROWSET, NUMELEM(s_rgdbPropRowset), s_rgdbPropRowset, 0,
  156. &DBPROPSET_MSIDXS_ROWSET_EXT, NUMELEM(s_rgdbPropMSIDXSExt), s_rgdbPropMSIDXSExt, 0,
  157. &DBPROPSET_QUERY_EXT, NUMELEM(s_rgdbPropQueryExt), s_rgdbPropQueryExt, 0,
  158. };
  159. //
  160. // Note: There is an enum for these offsets in utlprop.h (eid_DBPOPSET_xx).
  161. // This is used by CMDSProps.
  162. //
  163. static const UPROPSET s_rgDSPropSets[] =
  164. {
  165. &DBPROPSET_DBINIT, NUMELEM(s_rgdbPropInit), s_rgdbPropInit, 0,
  166. &DBPROPSET_DATASOURCEINFO, NUMELEM(s_rgdbPropDSInfo), s_rgdbPropDSInfo, 0,
  167. &DBPROPSET_DATASOURCE, NUMELEM(s_rgdbPropDS), s_rgdbPropDS, 0,
  168. };
  169. //
  170. //////////////////////////////////////////////////////////////////
  171. //
  172. // This is used by CMSessProps.
  173. //
  174. static const UPROPSET s_rgSessPropSets[] =
  175. {
  176. &DBPROPSET_SESSION, NUMELEM(s_rgdbPropSESS), s_rgdbPropSESS, 0,
  177. };
  178. // module handle for query.dll
  179. extern HANDLE g_hCurrentDll;
  180. //
  181. // CMDSProps methods
  182. //
  183. //+---------------------------------------------------------------------------
  184. //
  185. // Method: CMDSProps::CMDSProps, public
  186. //
  187. // Synopsis: Constructor
  188. //
  189. // History: 11-12-97 danleg Created from Monarch
  190. //
  191. //----------------------------------------------------------------------------
  192. CMDSProps::CMDSProps(CImpIParserVerify* pIPVerify)
  193. : CUtlProps(ARGCHK_PROPERTIESINERROR)
  194. {
  195. _xIPVerify.Set(pIPVerify);
  196. _xIPVerify->AddRef();
  197. FInit();
  198. }
  199. //+---------------------------------------------------------------------------
  200. //
  201. // Method: CMDSProps::ValidateCatalog, public
  202. //
  203. // Synopsis: Validate the catalog values
  204. //
  205. // Returns: S_OK - valid
  206. // S_FALSE - invalid
  207. //
  208. // History: 11-12-97 danleg Created from Monarch
  209. //
  210. //----------------------------------------------------------------------------
  211. SCODE CMDSProps::ValidateCatalog
  212. (
  213. VARIANT* pvValue
  214. )
  215. {
  216. SCODE sc = S_OK;
  217. if ( 0 != (V_VT(pvValue) == VT_BSTR) && (V_BSTR(pvValue)) )
  218. {
  219. _xIPVerify->VerifyCatalog( 0, V_BSTR(pvValue) );
  220. }
  221. else
  222. sc = S_FALSE;
  223. return sc;
  224. }
  225. //+---------------------------------------------------------------------------
  226. //
  227. // Method: CMDSProps::ValidateLocale, public
  228. //
  229. // Synopsis: Verifies the validity of the LCID given in *pVariant. Done by
  230. // checking a list of valid LCID's
  231. //
  232. // Returns: S_OK - valid LCID
  233. // S_FALSE - invalid LCID
  234. //
  235. // History: 11-12-97 danleg Created from Monarch
  236. // 01-06-99 danleg Use IsValidLocale to validate LCID
  237. //
  238. //----------------------------------------------------------------------------
  239. SCODE CMDSProps::ValidateLocale(VARIANT *pVariant)
  240. {
  241. BOOL fValidLCID = FALSE;
  242. if ( V_VT(pVariant) != VT_I4 )
  243. return S_FALSE;
  244. fValidLCID = IsValidLocale( V_I4(pVariant), LCID_SUPPORTED );
  245. return fValidLCID ? S_OK : S_FALSE;
  246. }
  247. //+---------------------------------------------------------------------------
  248. //
  249. // Method: CMDSProps::ExposeMinimalSets, public
  250. //
  251. // Synopsis: Minimize the number of propertysets exposed. Done in response
  252. // to IDBInitialize::Uninitialize
  253. //
  254. // History: 11-12-97 danleg Created from Monarch
  255. //
  256. //----------------------------------------------------------------------------
  257. void CMDSProps::ExposeMinimalSets()
  258. {
  259. // Temporarily trick ourselves into thinking we only have
  260. // the first propset.
  261. SetUPropSetCount(eid_DBPROPSET_DBINIT+1);
  262. }
  263. //+---------------------------------------------------------------------------
  264. //
  265. // Method: CMDSProps::ExposeMaximalSets, public
  266. //
  267. // Synopsis: Maximize the number of property sets we expose. New ones are
  268. // initialized. Done in response to IDBInitialize::Initialize
  269. //
  270. // History: 11-12-97 danleg Created from Monarch
  271. //
  272. //----------------------------------------------------------------------------
  273. SCODE CMDSProps::ExposeMaximalSets
  274. (
  275. )
  276. {
  277. ULONG iPropSet;
  278. SCODE sc = S_OK;
  279. // Expose the non-init propsets.
  280. // They might have values left over, so re-initialize.
  281. SetUPropSetCount(eid_DBPROPSET_NUM);
  282. for (iPropSet=eid_DBPROPSET_DBINIT+1; iPropSet < GetUPropSetCount(); iPropSet++)
  283. {
  284. sc = FillDefaultValues( iPropSet );
  285. if ( FAILED(sc) )
  286. return sc;
  287. }
  288. return S_OK;
  289. };
  290. //+---------------------------------------------------------------------------
  291. //
  292. // Method: CMDSProps::GetDefaultValue, private
  293. //
  294. // Synopsis: Retrieve the initial value for a propid.
  295. // DEVNOTE: Using the index from 0 to (GetCountofAvailPropSets-1)
  296. // and an index of 0 to (GetCountofAvailPropidsInPropset-1)
  297. // within that propertyset, return the correct information.
  298. // NOTE: pVar shoudl be initialized prior to this routine.
  299. //
  300. // History: 11-12-97 danleg Created from Monarch
  301. //
  302. //----------------------------------------------------------------------------
  303. SCODE CMDSProps::GetDefaultValue
  304. (
  305. ULONG iCurSet,
  306. DBPROPID dwPropId,
  307. DWORD* pdwOption,
  308. VARIANT* pvValue
  309. )
  310. {
  311. WCHAR* pwszValue;
  312. LPCWSTR pwszCatalog;
  313. Win4Assert( V_VT(pvValue) == VT_EMPTY );
  314. switch( iCurSet )
  315. {
  316. case eid_DBPROPSET_DATASOURCEINFO:
  317. *pdwOption = DBPROPOPTIONS_REQUIRED;
  318. switch( dwPropId )
  319. {
  320. case DBPROP_BYREFACCESSORS:
  321. case DBPROP_MULTIPLEPARAMSETS:
  322. case DBPROP_MULTIPLESTORAGEOBJECTS:
  323. case DBPROP_ORDERBYCOLUMNSINSELECT:
  324. V_VT(pvValue) = VT_BOOL;
  325. V_BOOL(pvValue) = VARIANT_FALSE;
  326. break;
  327. case DBPROP_DATASOURCEREADONLY:
  328. case DBPROP_ROWSETCONVERSIONSONCOMMAND:
  329. V_VT(pvValue) = VT_BOOL;
  330. V_BOOL(pvValue) = VARIANT_TRUE;
  331. break;
  332. case DBPROP_CATALOGLOCATION:
  333. V_VT(pvValue) = VT_I4;
  334. V_I4(pvValue) = DBPROPVAL_CL_START;
  335. break;
  336. case DBPROP_CATALOGUSAGE:
  337. V_VT(pvValue) = VT_I4;
  338. V_I4(pvValue) = DBPROPVAL_CU_DML_STATEMENTS;
  339. break;
  340. case DBPROP_NULLCOLLATION:
  341. V_VT(pvValue) = VT_I4;
  342. V_I4(pvValue) = DBPROPVAL_NC_LOW;
  343. break;
  344. case DBPROP_OUTPUTPARAMETERAVAILABILITY:
  345. V_VT(pvValue) = VT_I4;
  346. V_I4(pvValue) = DBPROPVAL_OA_NOTSUPPORTED;
  347. break;
  348. case DBPROP_MULTIPLERESULTS:
  349. V_VT(pvValue) = VT_I4;
  350. V_I4(pvValue) = DBPROPVAL_MR_NOTSUPPORTED;
  351. break;
  352. case DBPROP_DSOTHREADMODEL:
  353. V_VT(pvValue) = VT_I4;
  354. V_I4(pvValue) = DBPROPVAL_RT_FREETHREAD;
  355. break;
  356. case DBPROP_SQLSUPPORT:
  357. pvValue->vt = VT_I4;
  358. V_I4(pvValue) = DBPROPVAL_SQL_ODBC_MINIMUM;
  359. break;
  360. case DBPROP_MAXTABLESINSELECT:
  361. V_VT(pvValue) = VT_I4;
  362. V_I4(pvValue) = 1;
  363. break;
  364. case DBPROP_ACTIVESESSIONS:
  365. case DBPROP_COLUMNDEFINITION:
  366. case DBPROP_HETEROGENEOUSTABLES:
  367. case DBPROP_MAXROWSIZE:
  368. case DBPROP_OLEOBJECTS:
  369. case DBPROP_STRUCTUREDSTORAGE:
  370. case DBPROP_SUBQUERIES:
  371. case DBPROP_SUPPORTEDTXNISORETAIN:
  372. case DBPROP_GROUPBY:
  373. case DBPROP_MAXOPENCHAPTERS:
  374. V_VT(pvValue) = VT_I4;
  375. V_I4(pvValue) = 0;
  376. break;
  377. case DBPROP_SUPPORTEDTXNISOLEVELS:
  378. V_VT(pvValue) = VT_I4;
  379. V_I4(pvValue) = DBPROPVAL_TI_BROWSE;
  380. break;
  381. case DBPROP_SUPPORTEDTXNDDL:
  382. V_VT(pvValue) = VT_I4;
  383. V_I4(pvValue) = DBPROPVAL_TC_NONE;
  384. break;
  385. case DBPROP_PERSISTENTIDTYPE:
  386. V_VT(pvValue) = VT_I4;
  387. V_I4(pvValue) = DBPROPVAL_PT_GUID_PROPID;
  388. break;
  389. // The following are static value, so just allocate the bstr buffer
  390. // and return the value
  391. case DBPROP_DBMSNAME:
  392. case DBPROP_DBMSVER:
  393. case DBPROP_PROVIDEROLEDBVER:
  394. case DBPROP_PROVIDERFRIENDLYNAME:
  395. case DBPROP_PROVIDERNAME:
  396. case DBPROP_PROVIDERVER:
  397. case DBPROP_CATALOGTERM:
  398. switch( dwPropId )
  399. {
  400. case DBPROP_CATALOGTERM:
  401. pwszValue = s_wszCATALOG;
  402. break;
  403. case DBPROP_DBMSNAME:
  404. pwszValue = s_wszIndexServer;
  405. break;
  406. case DBPROP_DBMSVER:
  407. pwszValue = s_wszIndexServerVer;
  408. break;
  409. case DBPROP_PROVIDERNAME:
  410. pwszValue = s_wszProviderFileName; // query.dll
  411. break;
  412. case DBPROP_PROVIDERFRIENDLYNAME:
  413. pwszValue = g_wszProviderName; // Microsoft OLE DB Provider for Indexing Service
  414. break;
  415. case DBPROP_PROVIDERVER:
  416. pwszValue = (PWSTR)&(pwszProviderVersion[0]);
  417. break;
  418. case DBPROP_PROVIDEROLEDBVER:
  419. pwszValue = (PWSTR)&(pwszProviderOLEDBVer[0]);
  420. break;
  421. default:
  422. Win4Assert( !"Every inner case value match an outer case value" );
  423. break;
  424. }
  425. V_VT(pvValue) = VT_BSTR;
  426. V_BSTR(pvValue) = SysAllocString(pwszValue);
  427. if ( 0 == V_BSTR(pvValue) )
  428. {
  429. V_VT(pvValue) = VT_EMPTY;
  430. }
  431. break;
  432. default:
  433. //Indicate that value is unknown
  434. VariantClear(pvValue);
  435. break;
  436. }
  437. break;
  438. case eid_DBPROPSET_DATASOURCE:
  439. *pdwOption = DBPROPOPTIONS_OPTIONAL;
  440. switch( dwPropId)
  441. {
  442. case DBPROP_CURRENTCATALOG:
  443. pwszCatalog = GetValString(eid_DBPROPSET_DBINIT,eid_DBPROPVAL_INIT_DATASOURCE);
  444. V_VT(pvValue) = VT_BSTR;
  445. V_BSTR(pvValue) = SysAllocString(pwszCatalog);
  446. break;
  447. case DBPROP_RESETDATASOURCE:
  448. V_VT(pvValue) = VT_I4;
  449. V_I4(pvValue) = 0;
  450. break;
  451. default:
  452. Win4Assert(!"A property in DBPROPSET_DATASOURCE was requested that does not have a default");
  453. break;
  454. }
  455. break;
  456. case eid_DBPROPSET_DBINIT:
  457. *pdwOption = DBPROPOPTIONS_OPTIONAL;
  458. switch( dwPropId )
  459. {
  460. case DBPROP_AUTH_INTEGRATED:
  461. V_VT(pvValue) = VT_BSTR;
  462. V_BSTR(pvValue) = 0;
  463. break;
  464. case DBPROP_INIT_DATASOURCE:
  465. HandleCatalog( pvValue );
  466. break;
  467. case DBPROP_INIT_LOCATION:
  468. V_VT(pvValue) = VT_BSTR;
  469. V_BSTR(pvValue) = SysAllocString( DEFAULT_MACHINE );
  470. break;
  471. case DBPROP_INIT_LCID:
  472. V_VT(pvValue) = VT_I4;
  473. V_I4(pvValue) = GetUserDefaultLCID();
  474. break;
  475. case DBPROP_INIT_OLEDBSERVICES:
  476. V_VT(pvValue) = VT_I4;
  477. V_I4(pvValue) = DBPROPVAL_OS_ENABLEALL;
  478. break;
  479. /*
  480. case DBPROP_INIT_ASYNCH:
  481. V_VT(pvValue) = VT_I4;
  482. V_BSTR(pvValue) = 0;
  483. break;
  484. case DBPROP_INIT_PROVIDERSTRING:
  485. V_VT(pvValue) = VT_BSTR;
  486. if ( IsMonarch() )
  487. V_BSTR(pvValue) = SysAllocString(L"msidxs");
  488. else
  489. V_BSTR(pvValue) = SysAllocString(L"msidxsnl");
  490. break;
  491. */
  492. case DBPROP_INIT_PROMPT:
  493. // For this, we have a known value.
  494. // Note that NOPROMPT is safer for server usage.
  495. // (Otherwise a hidden window is presented, and we will appear to hang.)
  496. pvValue->vt = VT_I2;
  497. V_I2(pvValue) = DBPROMPT_NOPROMPT;
  498. break;
  499. case DBPROP_INIT_HWND:
  500. default:
  501. // For these, we don't have a value (empty).
  502. VariantClear(pvValue);
  503. break;
  504. }
  505. break;
  506. default:
  507. // Invalid Property Set
  508. Win4Assert( ! "Invalid property set in GetDefaultValue.");
  509. return E_FAIL;
  510. }
  511. return S_OK;
  512. }
  513. //+---------------------------------------------------------------------------
  514. //
  515. // Method: CMDSProps::IsValidValue, private
  516. //
  517. // Synopsis: Validate that the variant contains legal values for its
  518. // particular type and for the particular PROPID in this propset.
  519. // DEVNOTE: This routine has to apply to writable properties only.
  520. //
  521. // History: 11-12-97 danleg Created from Monarch
  522. //
  523. //----------------------------------------------------------------------------
  524. SCODE CMDSProps::IsValidValue
  525. (
  526. ULONG iCurSet,
  527. DBPROP* pDBProp
  528. )
  529. {
  530. // Check BOOLEAN values
  531. if ( (pDBProp->vValue.vt == VT_BOOL) &&
  532. !((V_BOOL(&(pDBProp->vValue)) == VARIANT_TRUE) ||
  533. (V_BOOL(&(pDBProp->vValue)) == VARIANT_FALSE)) )
  534. return S_FALSE;
  535. switch(iCurSet)
  536. {
  537. case eid_DBPROPSET_DATASOURCEINFO:
  538. default:
  539. return S_FALSE;
  540. case eid_DBPROPSET_DATASOURCE:
  541. switch( pDBProp->dwPropertyID )
  542. {
  543. case DBPROP_CURRENTCATALOG:
  544. return ValidateCatalog(&(pDBProp->vValue));
  545. break;
  546. case DBPROP_RESETDATASOURCE:
  547. if ( VT_I4 != V_VT(&(pDBProp->vValue)) ||
  548. !(DBPROPVAL_RD_RESETALL == V_I4(&(pDBProp->vValue)) ||
  549. 0 == V_I4(&(pDBProp->vValue))) )
  550. return S_FALSE;
  551. break;
  552. default:
  553. return S_FALSE;
  554. }
  555. break;
  556. case eid_DBPROPSET_DBINIT:
  557. switch( pDBProp->dwPropertyID )
  558. {
  559. case DBPROP_AUTH_INTEGRATED:
  560. // VariantCopy() translates a NULL BSTR ptr to
  561. // an empty BSTR. Check for both.
  562. if ( VT_BSTR != V_VT(&(pDBProp->vValue)) ||
  563. (0 != V_BSTR(&pDBProp->vValue) &&
  564. L'\0' != V_BSTR(&pDBProp->vValue)[0]) )
  565. return S_FALSE;
  566. break;
  567. case DBPROP_INIT_DATASOURCE:
  568. return ValidateCatalog(&(pDBProp->vValue));
  569. break;
  570. case DBPROP_INIT_PROMPT:
  571. // These are the only values we support (from spec).
  572. if ( pDBProp->vValue.vt != VT_I2
  573. || ! ( V_I2(&pDBProp->vValue) == DBPROMPT_PROMPT
  574. || V_I2(&pDBProp->vValue) == DBPROMPT_COMPLETE
  575. || V_I2(&pDBProp->vValue) == DBPROMPT_COMPLETEREQUIRED
  576. || V_I2(&pDBProp->vValue) == DBPROMPT_NOPROMPT))
  577. return S_FALSE;
  578. break;
  579. case DBPROP_INIT_LOCATION:
  580. case DBPROP_INIT_HWND:
  581. case DBPROP_INIT_PROVIDERSTRING:
  582. case DBPROP_INIT_OLEDBSERVICES:
  583. break;
  584. case DBPROP_INIT_LCID:
  585. return ValidateLocale(&(pDBProp->vValue));
  586. // We support these, with any value.
  587. break;
  588. default:
  589. // Anything else, we don't support.
  590. // Note that an alternative would be to allow setting
  591. // to EMPTY or to FALSE.
  592. return S_FALSE;
  593. break;
  594. }
  595. break;
  596. }
  597. return S_OK; // Is valid
  598. }
  599. //+---------------------------------------------------------------------------
  600. //
  601. // Method: CMDSProps::InitAvailUPropSets, private
  602. //
  603. // Synopsis: Provide property set information to the base class
  604. //
  605. // History: 11-12-97 danleg Created from Monarch
  606. //
  607. //----------------------------------------------------------------------------
  608. SCODE CMDSProps::InitAvailUPropSets
  609. (
  610. ULONG* pcUPropSet,
  611. UPROPSET** ppUPropSet,
  612. ULONG* pcElemPerSupported
  613. )
  614. {
  615. Win4Assert( pcUPropSet && ppUPropSet );
  616. Win4Assert( NUMELEM(s_rgdbPropInit) == eid_INIT_PROPS_NUM );
  617. Win4Assert( NUMELEM(s_rgdbPropDSInfo) == eid_DSINFO_PROPS_NUM );
  618. Win4Assert( NUMELEM(s_rgdbPropDS) == eid_DS_PROPS_NUM );
  619. *pcUPropSet = NUMELEM(s_rgDSPropSets);
  620. *ppUPropSet = (UPROPSET*)s_rgDSPropSets;
  621. *pcElemPerSupported = DWORDSNEEDEDPERSET;
  622. return S_OK;
  623. }
  624. //+---------------------------------------------------------------------------
  625. //
  626. // Method: CMDSProps::InitUPropSetsSupported, private
  627. //
  628. // Synopsis: Build the required supported property bitmask for the property
  629. // set supported by this class.
  630. //
  631. // History: 11-12-97 danleg Created from Monarch
  632. //
  633. //----------------------------------------------------------------------------
  634. SCODE CMDSProps::InitUPropSetsSupported
  635. (
  636. DWORD* rgdwSupported
  637. )
  638. {
  639. Win4Assert( rgdwSupported );
  640. // Initialize the bitmask to indicate all properties are supported
  641. RtlFillMemory( rgdwSupported,
  642. DWORDSNEEDEDPERSET * NUMELEM(s_rgDSPropSets) * sizeof(DWORD),
  643. 0xFF);
  644. // The following assert is to gaurentee that the PROPSET described
  645. // at index 1 is always DBPROPSET_DATASOURCEINFO.
  646. Win4Assert( *(s_rgIDXPropertySets[1].pPropSet) == DBPROPSET_DATASOURCEINFO );
  647. return S_OK;
  648. }
  649. //+---------------------------------------------------------------------------
  650. //
  651. // Method: CMDSProps::HandleCatalog, private
  652. //
  653. // Synopsis: Retrieve the initial value for the catalog values
  654. //
  655. // History: 11-12-97 danleg Created from Monarch
  656. //
  657. //----------------------------------------------------------------------------
  658. void CMDSProps::HandleCatalog
  659. (
  660. VARIANT *pvValue
  661. )
  662. {
  663. WCHAR wszCatalog[256] = L"";
  664. ULONG cOut;
  665. _xIPVerify->GetDefaultCatalog( wszCatalog, NUMELEM(wszCatalog), &cOut );
  666. V_VT(pvValue) = VT_BSTR;
  667. V_BSTR(pvValue) = SysAllocString(wszCatalog);
  668. }
  669. //
  670. // CMSessProps methods
  671. //
  672. //+---------------------------------------------------------------------------
  673. //
  674. // Method: CMSessProps::GetDefaultValue, private
  675. //
  676. // Synopsis: Retrieve the initial value for a propid.
  677. // DEVNOTE: Using the index from 0 to (GetCountofAvailPropSets-1)
  678. // and an index of 0 to (GetCountofAvailPropidsInPropset-1)
  679. // within that propertyset, return the correct information.
  680. // NOTE: pVar shoudl be initialized prior to this routine.
  681. //
  682. //
  683. // History: 11-12-97 danleg Created from Monarch
  684. //
  685. //----------------------------------------------------------------------------
  686. // ---------------------------------------------------------------------------
  687. // CMSessProps::GetDefaultValue
  688. // @mfunc Retrieve the initial value for the propids.
  689. //
  690. // @devnote Using the index from 0 to (GetCountofAvailPropSets - 1) and a index
  691. // of 0 to (GetCountofAvailPropidsInPropSet - 1) within that property set return
  692. // the correct information. NOTE: pVar should be initialized prior to this
  693. // routine
  694. //
  695. // @rdesc SCODE indicating status
  696. //
  697. SCODE CMSessProps::GetDefaultValue
  698. (
  699. ULONG iCurSet,
  700. DBPROPID dwPropId,
  701. DWORD* pdwOption,
  702. VARIANT* pvValue
  703. )
  704. {
  705. Win4Assert( V_VT(pvValue) == VT_EMPTY );
  706. switch( iCurSet )
  707. {
  708. case eid_DBPROPSET_SESSION:
  709. switch( dwPropId )
  710. {
  711. case DBPROP_SESS_AUTOCOMMITISOLEVELS:
  712. *pdwOption = DBPROPOPTIONS_REQUIRED;
  713. V_VT(pvValue) = VT_I4;
  714. V_I4(pvValue) = DBPROPVAL_TI_BROWSE;
  715. break;
  716. default:
  717. //Indicate that value is unknown
  718. VariantClear(pvValue);
  719. break;
  720. }
  721. break;
  722. default:
  723. // Invalid Property Set
  724. Win4Assert( ! "Invalid property set in GetDefaultValue.");
  725. return E_FAIL;
  726. }
  727. return S_OK;
  728. }
  729. //+---------------------------------------------------------------------------
  730. //
  731. // Method: CMSessProps::IsValidValue, private
  732. //
  733. // Synopsis: Validate that the variant contains legal values for its
  734. // particular type and for the particular PROPID in this propset
  735. //
  736. // History: 11-12-97 danleg Created from Monarch
  737. //
  738. //----------------------------------------------------------------------------
  739. SCODE CMSessProps::IsValidValue
  740. (
  741. ULONG iCurSet,
  742. DBPROP* pDBProp
  743. )
  744. {
  745. switch(iCurSet)
  746. {
  747. case eid_SESS_AUTOCOMMITISOLEVELS:
  748. switch( pDBProp->dwPropertyID )
  749. {
  750. case DBPROP_SESS_AUTOCOMMITISOLEVELS:
  751. break;
  752. default:
  753. return S_FALSE;
  754. }
  755. break;
  756. default:
  757. return S_FALSE;
  758. }
  759. return S_OK; // Is valid
  760. }
  761. //+---------------------------------------------------------------------------
  762. //
  763. // Method: CMSessProps::InitAvailUPropSets, private
  764. //
  765. // Synopsis: Provide property set information to the base class
  766. //
  767. // History: 11-12-97 danleg Created from Monarch
  768. //
  769. //----------------------------------------------------------------------------
  770. SCODE CMSessProps::InitAvailUPropSets
  771. (
  772. ULONG* pcUPropSet,
  773. UPROPSET** ppUPropSet,
  774. ULONG* pcElemPerSupported
  775. )
  776. {
  777. Win4Assert( pcUPropSet && ppUPropSet);
  778. Win4Assert( NUMELEM(s_rgdbPropSESS) == eid_SESS_PROPS_NUM );
  779. *pcUPropSet = NUMELEM(s_rgSessPropSets);
  780. *ppUPropSet = (UPROPSET*)s_rgSessPropSets;
  781. *pcElemPerSupported = DWORDSNEEDEDPERSET;
  782. return S_OK;
  783. }
  784. //+---------------------------------------------------------------------------
  785. //
  786. // Method: CMSessProps::InitUPropSetsSupported, private
  787. //
  788. // Synopsis: Build the required supported property bitmask for the property
  789. // set supported by this class
  790. //
  791. // History: 11-12-97 danleg Created from Monarch
  792. //
  793. //----------------------------------------------------------------------------
  794. SCODE CMSessProps::InitUPropSetsSupported
  795. (
  796. DWORD* rgdwSupported
  797. )
  798. {
  799. Win4Assert( rgdwSupported );
  800. // Initialize the bitmask to indicate all properties are supported
  801. RtlFillMemory ( rgdwSupported,
  802. DWORDSNEEDEDPERSET * NUMELEM(s_rgSessPropSets) * sizeof(DWORD),
  803. 0xFF);
  804. return S_OK;
  805. }
  806. //
  807. // CMDSPropInfo methods
  808. //
  809. //+---------------------------------------------------------------------------
  810. //
  811. // Method: CMDSPropInfo::InitAvailUPropSets, private
  812. //
  813. // Synopsis: Provide property set information to the base class
  814. //
  815. // History: 11-12-97 danleg Created from Monarch
  816. //
  817. //----------------------------------------------------------------------------
  818. SCODE CMDSPropInfo::InitAvailUPropSets
  819. (
  820. ULONG* pcUPropSet,
  821. UPROPSET** ppUPropSet,
  822. ULONG* pcElemPerSupported
  823. )
  824. {
  825. Win4Assert( pcUPropSet && ppUPropSet);
  826. // The datasource info properties array should always match the DBPROP enum.
  827. Win4Assert( NUMELEM(s_rgdbPropDSInfo) == eid_DSINFO_PROPS_NUM );
  828. *pcUPropSet = NUMELEM(s_rgIDXPropertySets);
  829. *ppUPropSet = (UPROPSET*)s_rgIDXPropertySets;
  830. *pcElemPerSupported = DWORDSNEEDEDPERSET;
  831. return S_OK;
  832. }
  833. //+---------------------------------------------------------------------------
  834. //
  835. // Method: CMDSPropInfo::InitUPropSetsSupported, private
  836. //
  837. // Synopsis: Build the required supported property bitmask for the property
  838. // set supported by this class
  839. //
  840. // History: 11-12-97 danleg Created from Monarch
  841. //
  842. //----------------------------------------------------------------------------
  843. SCODE CMDSPropInfo::InitUPropSetsSupported
  844. (
  845. DWORD* rgdwSupported
  846. )
  847. {
  848. Win4Assert( rgdwSupported );
  849. // Initialize the bitmask to indicate all properties are supported
  850. RtlFillMemory ( rgdwSupported,
  851. DWORDSNEEDEDPERSET * NUMELEM(s_rgIDXPropertySets) * sizeof(DWORD),
  852. 0xFF );
  853. return S_OK;
  854. }
  855. //+---------------------------------------------------------------------------
  856. //
  857. // Method: CMDSPropInfo::LoadDescription, private
  858. //
  859. // Synopsis: Load a property description string into a buffer.
  860. //
  861. // Returns: ULONG - Count of characters returned in the buffer
  862. //
  863. // Notes: Property descriptions are used in ADO programming. They
  864. // should not be localized strings.
  865. //
  866. // History: 11-12-97 danleg Created from Monarch
  867. //
  868. //----------------------------------------------------------------------------
  869. ULONG CMDSPropInfo::LoadDescription
  870. (
  871. LPCWSTR pwszDesc, //@parm IN | Description String
  872. PWSTR pwszBuff, //@parm OUT | Temporary buffer
  873. ULONG cchBuff //@parm IN | Count of characters buffer can hold
  874. )
  875. {
  876. Win4Assert( pwszDesc && pwszBuff && cchBuff );
  877. ULONG cchDesc = wcslen(pwszDesc);
  878. if (cchDesc < cchBuff)
  879. {
  880. wcscpy(pwszBuff, pwszDesc);
  881. }
  882. else
  883. {
  884. pwszBuff[0] = L'\0';
  885. cchDesc = 0;
  886. }
  887. return cchDesc;
  888. }