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.

392 lines
10 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1994.
  5. //
  6. // File: spropmap.cxx
  7. //
  8. // Contents: Standard Property + Volatile Property mapper
  9. //
  10. // Classes: CStandardPropMapper
  11. //
  12. // History: 1-03-97 srikants Created (Moved code from qcat.cxx)
  13. //
  14. //----------------------------------------------------------------------------
  15. #include <pch.cxx>
  16. #pragma hdrstop
  17. #include <propspec.hxx>
  18. #include <spropmap.hxx>
  19. IMPL_DYNARRAY( CPropSpecArray, CPropSpecPidMap );
  20. static const GUID guidDbBookmark = DBBMKGUID;
  21. static const GUID guidDbSelf = DBSELFGUID;
  22. static const GUID guidDbColumn = DBCIDGUID;
  23. //+---------------------------------------------------------------------------
  24. //
  25. // Member: Constructor of the Standard property mapper.
  26. //
  27. // History: 1-03-97 srikants Created
  28. //
  29. //----------------------------------------------------------------------------
  30. CStandardPropMapper::CStandardPropMapper()
  31. : _pidNextAvailable( INIT_DOWNLEVEL_PID ),
  32. _cps( 0 ),
  33. _cRefs( 1 )
  34. {
  35. }
  36. //+-------------------------------------------------------------------------
  37. //
  38. // Method: CStandardPropMapper::StandardPropertyToPropId, protected
  39. //
  40. // Synopsis: Locate pid for standard properties
  41. //
  42. // Arguments: [ps] -- Property specification (name)
  43. //
  44. // Returns: The pid of [ps] if ps is one of the standard properties.
  45. //
  46. // History: 10 Jan 1996 Alanw Created
  47. // 3 Jan 1997 Srikants Moved from CQCat
  48. //
  49. //--------------------------------------------------------------------------
  50. PROPID CStandardPropMapper::StandardPropertyToPropId(
  51. CFullPropSpec const & ps )
  52. {
  53. if ( ps.IsPropertyName() )
  54. return pidInvalid; // no name-based standard properties
  55. PROPID pid = pidInvalid;
  56. if ( ps.GetPropSet() == guidStorage )
  57. {
  58. if ( ps.IsPropertyPropid() )
  59. {
  60. pid = ps.GetPropertyPropid();
  61. if (pid > PID_DICTIONARY && pid <= PID_STG_MAX)
  62. {
  63. pid = MK_CISTGPROPID(pid);
  64. }
  65. else if (pid == PID_SECURITY) // Note: overload PID_DICTIONARY
  66. {
  67. pid = pidSecurity;
  68. }
  69. }
  70. }
  71. else if ( ps.GetPropSet() == guidQuery )
  72. {
  73. if ( ps.IsPropertyPropid() )
  74. {
  75. switch( ps.GetPropertyPropid() )
  76. {
  77. case DISPID_QUERY_RANK:
  78. pid = pidRank;
  79. break;
  80. case DISPID_QUERY_RANKVECTOR:
  81. pid = pidRankVector;
  82. break;
  83. case DISPID_QUERY_HITCOUNT:
  84. pid = pidHitCount;
  85. break;
  86. case DISPID_QUERY_WORKID:
  87. pid = pidWorkId;
  88. break;
  89. case DISPID_QUERY_ALL:
  90. pid = pidAll;
  91. break;
  92. case DISPID_QUERY_UNFILTERED:
  93. pid = pidUnfiltered;
  94. break;
  95. case DISPID_QUERY_REVNAME:
  96. pid = pidRevName;
  97. break;
  98. case DISPID_QUERY_VIRTUALPATH:
  99. pid = pidVirtualPath;
  100. break;
  101. case DISPID_QUERY_LASTSEENTIME:
  102. pid = pidLastSeenTime;
  103. break;
  104. default:
  105. pid = pidInvalid;
  106. }
  107. }
  108. }
  109. else if ( ps.GetPropSet() == guidQueryMetadata )
  110. {
  111. if ( ps.IsPropertyPropid() )
  112. {
  113. switch( ps.GetPropertyPropid() )
  114. {
  115. case DISPID_QUERY_METADATA_VROOTUSED:
  116. pid = pidVRootUsed;
  117. break;
  118. case DISPID_QUERY_METADATA_VROOTAUTOMATIC:
  119. pid = pidVRootAutomatic;
  120. break;
  121. case DISPID_QUERY_METADATA_VROOTMANUAL:
  122. pid = pidVRootManual;
  123. break;
  124. case DISPID_QUERY_METADATA_PROPGUID:
  125. pid = pidPropertyGuid;
  126. break;
  127. case DISPID_QUERY_METADATA_PROPDISPID:
  128. pid = pidPropertyDispId;
  129. break;
  130. case DISPID_QUERY_METADATA_PROPNAME:
  131. pid = pidPropertyName;
  132. break;
  133. case DISPID_QUERY_METADATA_STORELEVEL:
  134. pid = pidPropertyStoreLevel;
  135. break;
  136. case DISPID_QUERY_METADATA_PROPMODIFIABLE:
  137. pid = pidPropDataModifiable;
  138. break;
  139. default:
  140. pid = pidInvalid;
  141. }
  142. }
  143. }
  144. else if ( ps.GetPropSet() == guidDbColumn )
  145. {
  146. if (ps.GetPropertyPropid() < CDBCOLDISPIDS)
  147. {
  148. pid = MK_CIDBCOLPROPID( ps.GetPropertyPropid() );
  149. }
  150. }
  151. else if ( ps.GetPropSet() == guidDbBookmark )
  152. {
  153. if (ps.GetPropertyPropid() < CDBBMKDISPIDS)
  154. {
  155. pid = MK_CIDBBMKPROPID( ps.GetPropertyPropid() );
  156. }
  157. }
  158. else if ( ps.GetPropSet() == guidDbSelf )
  159. {
  160. if (ps.GetPropertyPropid() == PROPID_DBSELF_SELF)
  161. {
  162. pid = pidSelf;
  163. }
  164. }
  165. return( pid );
  166. }
  167. //+-------------------------------------------------------------------------
  168. //
  169. // Method: CStandardPropMapper::PropertyToPropId, public
  170. //
  171. // Synopsis: Locate pid for property
  172. //
  173. // Arguments: [ps] -- Property specification (name)
  174. // [fCreate] -- TRUE if non-existent mapping should be created
  175. //
  176. // Returns: The pid of [ps].
  177. //
  178. // History: 28-Feb-1994 KyleP Created
  179. // 30-Jun-1994 KyleP Added downlevel property support
  180. // 03-Jan-1997 SrikantS Moved from CQCat
  181. //
  182. //--------------------------------------------------------------------------
  183. PROPID CStandardPropMapper::PropertyToPropId(
  184. CFullPropSpec const & ps,
  185. BOOL fCreate )
  186. {
  187. PROPID pid = StandardPropertyToPropId( ps );
  188. if (pidInvalid == pid)
  189. {
  190. //
  191. // Create pid good only for life of catalog.
  192. //
  193. //
  194. // Have we seen this property before? Use linear search since
  195. // we shouldn't have too many of these.
  196. //
  197. for ( unsigned i = 0; i < _cps; i++ )
  198. {
  199. if ( ps == _aps.Get(i)->PS() )
  200. break;
  201. }
  202. if ( i < _cps )
  203. {
  204. pid = _aps.Get(i)->Pid();
  205. }
  206. else
  207. {
  208. pid = _pidNextAvailable++;
  209. CPropSpecPidMap * ppm = new CPropSpecPidMap( ps, pid );
  210. _aps.Add( ppm, _cps );
  211. _cps++;
  212. }
  213. }
  214. return pid;
  215. }
  216. //+-------------------------------------------------------------------------
  217. //
  218. // Method: CStandardPropMapper::AddRef
  219. //
  220. // Synopsis: Increments refcount
  221. //
  222. // History: 31-Jan-1997 SitaramR Created
  223. //
  224. //--------------------------------------------------------------------------
  225. ULONG STDMETHODCALLTYPE CStandardPropMapper::AddRef()
  226. {
  227. return InterlockedIncrement( (long *) &_cRefs );
  228. }
  229. //+-------------------------------------------------------------------------
  230. //
  231. // Method: CStandardPropMapper::Release
  232. //
  233. // Synopsis: Decrement refcount. Delete if necessary.
  234. //
  235. // History: 31-Jan-1997 SitaramR Created
  236. //
  237. //--------------------------------------------------------------------------
  238. ULONG STDMETHODCALLTYPE CStandardPropMapper::Release()
  239. {
  240. Win4Assert( _cRefs > 0 );
  241. ULONG uTmp = InterlockedDecrement( (long *) &_cRefs );
  242. if ( 0 == uTmp )
  243. delete this;
  244. return uTmp;
  245. }
  246. //+-------------------------------------------------------------------------
  247. //
  248. // Method: CStandardPropMapper::QueryInterface
  249. //
  250. // Synopsis: Rebind to other interface
  251. //
  252. // Arguments: [riid] -- IID of new interface
  253. // [ppvObject] -- New interface * returned here
  254. //
  255. // Returns: S_OK if bind succeeded, E_NOINTERFACE if bind failed
  256. //
  257. // History: 31-Jan-1997 SitaramR Created
  258. //
  259. //--------------------------------------------------------------------------
  260. SCODE STDMETHODCALLTYPE CStandardPropMapper::QueryInterface(
  261. REFIID riid,
  262. void ** ppvObject)
  263. {
  264. if ( 0 == ppvObject )
  265. return E_INVALIDARG;
  266. *ppvObject = 0;
  267. if ( IID_IPropertyMapper == riid )
  268. *ppvObject = (IUnknown *)(IPropertyMapper *) this;
  269. else if ( IID_IUnknown == riid )
  270. *ppvObject = (IUnknown *) this;
  271. else
  272. return E_NOINTERFACE;
  273. AddRef();
  274. return S_OK;
  275. }
  276. //+-------------------------------------------------------------------------
  277. //
  278. // Method: CStandardPropMapper::PropertyToPropid
  279. //
  280. // Synopsis: Convert propspec to pid
  281. //
  282. // Arguments: [pFullPropSpec] -- propspec to convert
  283. // [fCreate] -- Create property if not found ?
  284. // [pPropId] -- pid returned here
  285. //
  286. // History: 31-Jan-1997 SitaramR Created
  287. //
  288. //--------------------------------------------------------------------------
  289. SCODE STDMETHODCALLTYPE CStandardPropMapper::PropertyToPropid( const FULLPROPSPEC *pFullPropSpec,
  290. BOOL fCreate,
  291. PROPID *pPropId)
  292. {
  293. SCODE sc = S_OK;
  294. TRY
  295. {
  296. CFullPropSpec const * pProperty = (CFullPropSpec const *) pFullPropSpec;
  297. *pPropId = PropertyToPropId( *pProperty, fCreate );
  298. }
  299. CATCH( CException, e )
  300. {
  301. sc = e.GetErrorCode();
  302. vqDebugOut(( DEB_ERROR,
  303. "CStandardPropMapper:PropertyToPropid - Exception caught 0x%x\n",
  304. sc ));
  305. }
  306. END_CATCH;
  307. return sc;
  308. }
  309. //+-------------------------------------------------------------------------
  310. //
  311. // Method: CStandardPropMapper::PropidToProperty
  312. //
  313. // Synopsis: Convert pid to propspec
  314. //
  315. // Arguments: [pPropId] -- pid to convert
  316. // [pFullPropSpec] -- propspec returned here
  317. //
  318. // History: 31-Jan-1997 SitaramR Created
  319. //
  320. //--------------------------------------------------------------------------
  321. SCODE STDMETHODCALLTYPE CStandardPropMapper::PropidToProperty( PROPID propId,
  322. FULLPROPSPEC **ppFullPropSpec )
  323. {
  324. Win4Assert( !"Not yet implemented" );
  325. return E_NOTIMPL;
  326. }