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.

433 lines
10 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 2002.
  5. //
  6. // File: docstore.hxx
  7. //
  8. // Contents: Deals with the client side document store implementation.
  9. //
  10. // Classes: CClientDocStore
  11. //
  12. // History: 12-03-96 srikants Created
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #include <docname.hxx>
  17. #include <perfobj.hxx>
  18. #include <perfci.hxx>
  19. #include <frmutils.hxx>
  20. #include <workman.hxx>
  21. #include <langres.hxx>
  22. #include <fsciclnt.h>
  23. #include <notifary.hxx>
  24. #if CIDBG==1
  25. #include <cisavtst.hxx>
  26. #endif // CIDBG==1
  27. //
  28. // ClassId of the client component in the cidaemon.
  29. //
  30. //
  31. // The Daemon uses Ole to create an instance of the CFilterObject to perform
  32. // filtering. The classid of the appropriate class is passed as a
  33. // start up parameter.
  34. //
  35. extern "C" const GUID clsidStorageFilterObject;
  36. const LONGLONG eSigClientDocStore = 0x45524F5453434F44i64; // "DOCSTORE"
  37. //+---------------------------------------------------------------------------
  38. //
  39. // Class: CClientDocStore
  40. //
  41. // Purpose: An object implementing the ICiCDocStoreEx,
  42. // ICiCDocNameToWorkidTranslatorEx, ICiCPropertyStorage,
  43. // ICiCAdviseStatus, IFsCiAdmin, and ICiCLangRes
  44. // interfaces. Represents the CiCDocStore object.
  45. //
  46. // History: 12-03-96 srikants Created
  47. // 01-Nov-98 KLam Changed CDiskFreeStatus member to XPtr
  48. //
  49. // Notes:
  50. //
  51. //----------------------------------------------------------------------------
  52. class CClientDocStore : public ICiCDocStoreEx,
  53. public ICiCDocNameToWorkidTranslatorEx,
  54. public ICiCPropertyStorage,
  55. public ICiCAdviseStatus,
  56. public IFsCiAdmin,
  57. public ICiCLangRes,
  58. public ICiCResourceMonitor
  59. {
  60. friend class CiCat;
  61. friend class CiNullCat;
  62. friend class CStartFilterDaemon;
  63. public:
  64. CClientDocStore();
  65. CClientDocStore( WCHAR const * pwszPath,
  66. BOOL fOpenForReadOnly,
  67. CDrvNotifArray & DrvNotifArray,
  68. WCHAR const * pwszName = 0);
  69. virtual ~CClientDocStore();
  70. //
  71. // IUnknown methods.
  72. //
  73. STDMETHOD(QueryInterface) (THIS_ REFIID riid,LPVOID *ppiuk );
  74. STDMETHOD_(ULONG, AddRef) (THIS);
  75. STDMETHOD_(ULONG, Release) (THIS);
  76. //
  77. // ICiCPropertyStorage methods.
  78. //
  79. STDMETHOD(IsPropertyCached)(
  80. const FULLPROPSPEC *pPropSpec,
  81. BOOL *pfValue);
  82. STDMETHOD(StoreProperty) (
  83. WORKID workId,
  84. const FULLPROPSPEC *pPropSpec,
  85. const PROPVARIANT *pPropVariant);
  86. STDMETHOD(FetchValueByPid) (
  87. WORKID workId,
  88. PROPID pid,
  89. PROPVARIANT *pbData,
  90. ULONG *pcb)
  91. {
  92. Win4Assert( !"Not Yet Implemented" );
  93. return E_NOTIMPL;
  94. }
  95. STDMETHOD(FetchValueByPropSpec) (
  96. WORKID workId,
  97. const FULLPROPSPEC *pPropSpec,
  98. PROPVARIANT *pbData,
  99. ULONG *pcb)
  100. {
  101. Win4Assert( !"Not Yet Implemented" );
  102. return E_NOTIMPL;
  103. }
  104. STDMETHOD(FetchVariantByPid) (
  105. WORKID workId,
  106. PROPID pid,
  107. PROPVARIANT ** ppVariant)
  108. {
  109. Win4Assert( !"Not Yet Implemented" );
  110. return E_NOTIMPL;
  111. }
  112. STDMETHOD(FetchVariantByByPropSpec) (
  113. WORKID workId,
  114. const FULLPROPSPEC *pPropSpec,
  115. PROPVARIANT ** ppVariant)
  116. {
  117. Win4Assert( !"Not Yet Implemented" );
  118. return E_NOTIMPL;
  119. }
  120. STDMETHOD(ClearNonStoragePropertiesForWid)( WORKID wid );
  121. //
  122. // ICiCDocStore methods.
  123. //
  124. STDMETHOD(FlushPropertyStore) (void);
  125. STDMETHOD(GetClientStatus) (
  126. CI_CLIENT_STATUS * pStatus);
  127. STDMETHOD(GetContentIndex) (
  128. ICiManager **ppICiManager);
  129. STDMETHOD(EnableUpdates) (void);
  130. STDMETHOD(DisableUpdates) (
  131. BOOL fIncremental,
  132. CI_DISABLE_UPDATE_REASON dwReason);
  133. STDMETHOD(ProcessCiDaemonTermination) (
  134. DWORD dwStatus);
  135. STDMETHOD(CheckPointChangesFlushed) (
  136. FILETIME ftFlushed,
  137. ULONG cEntries,
  138. const USN_FLUSH_INFO * const *ppUsnEntries);
  139. STDMETHOD(GetQuerySession) (
  140. ICiCQuerySession **ppICiCQuerySession);
  141. STDMETHOD(MarkDocUnReachable) (
  142. WORKID wid);
  143. STDMETHOD(GetPropertyMapper) (
  144. IPropertyMapper **ppIPropertyMapper);
  145. STDMETHOD(StoreSecurity) (
  146. WORKID wid,
  147. BYTE const * pbData,
  148. ULONG cbData );
  149. //
  150. // ICiCDocStoreEx methods
  151. //
  152. STDMETHOD(IsNoQuery) (
  153. BOOL * fNoQuery );
  154. //
  155. // ICiCDocNameToWorkidTranslatorEx methods
  156. //
  157. STDMETHOD(QueryDocName) (
  158. ICiCDocName **ppICiCDocName);
  159. STDMETHOD(WorkIdToDocName) (
  160. WORKID workId,
  161. ICiCDocName *pICiCDocName);
  162. STDMETHOD(DocNameToWorkId) (
  163. const ICiCDocName *pICiCDocName,
  164. WORKID *pWorkId);
  165. STDMETHOD(WorkIdToAccurateDocName) (
  166. WORKID workId,
  167. ICiCDocName *pICiCDocName);
  168. //
  169. // ICiCAdviseStatus methods.
  170. //
  171. STDMETHOD(SetPerfCounterValue) (
  172. CI_PERF_COUNTER_NAME name,
  173. long value );
  174. STDMETHOD(IncrementPerfCounterValue) (
  175. CI_PERF_COUNTER_NAME name );
  176. STDMETHOD(DecrementPerfCounterValue) (
  177. CI_PERF_COUNTER_NAME name );
  178. STDMETHOD(GetPerfCounterValue) (
  179. CI_PERF_COUNTER_NAME name,
  180. long * pValue );
  181. STDMETHOD(NotifyEvent) ( WORD fType,
  182. DWORD eventId,
  183. ULONG nParams,
  184. const PROPVARIANT *aParams,
  185. ULONG cbData = 0 ,
  186. void* data = 0 );
  187. STDMETHOD(NotifyStatus) ( CI_NOTIFY_STATUS_VALUE status,
  188. ULONG nParams,
  189. const PROPVARIANT *aParams );
  190. //
  191. // IFsCiAdmin methods.
  192. //
  193. STDMETHOD(ForceMerge) (
  194. PARTITIONID partId );
  195. STDMETHOD( AbortMerge) (
  196. PARTITIONID partId ) ;
  197. STDMETHOD( CiState ) (
  198. CI_STATE * pCiState) ;
  199. STDMETHOD( UpdateDocuments ) (
  200. const WCHAR *rootPath,
  201. ULONG flag) ;
  202. STDMETHOD( AddScopeToCI ) (
  203. const WCHAR *rootPath) ;
  204. STDMETHOD( RemoveScopeFromCI ) (
  205. const WCHAR *rootPath) ;
  206. STDMETHOD( BeginCacheTransaction ) ( ULONG_PTR * pulToken ) ;
  207. STDMETHOD( SetupCache ) (
  208. const FULLPROPSPEC *ps,
  209. ULONG vt,
  210. ULONG cbMaxLen,
  211. ULONG_PTR ulToken,
  212. BOOL fCanBeModified,
  213. DWORD dwStoreLevel) ;
  214. STDMETHOD( EndCacheTransaction ) (
  215. ULONG_PTR ulToken,
  216. BOOL fCommit) ;
  217. //
  218. // ICiCLangRes methods
  219. //
  220. STDMETHOD(GetWordBreaker) ( LCID locale, PROPID pid, IWordBreaker ** ppWordBreaker )
  221. {
  222. return _langRes.GetWordBreaker(locale, pid, ppWordBreaker );
  223. }
  224. STDMETHOD(GetStemmer) ( LCID locale, PROPID pid, IStemmer ** ppStemmer )
  225. {
  226. return _langRes.GetStemmer(locale, pid, ppStemmer);
  227. }
  228. STDMETHOD(GetNoiseWordList) ( LCID locale, PROPID pid, IStream ** ppIStrmNoiseFile )
  229. {
  230. return _langRes.GetNoiseWordList( locale, pid, ppIStrmNoiseFile );
  231. }
  232. //
  233. // ICiCResourceMonitor methods
  234. //
  235. STDMETHOD(IsMemoryLow) ()
  236. {
  237. return E_NOTIMPL;
  238. }
  239. STDMETHOD(IsBatteryLow) ()
  240. {
  241. return E_NOTIMPL;
  242. }
  243. STDMETHOD(IsOnBatteryPower) ()
  244. {
  245. return E_NOTIMPL;
  246. }
  247. STDMETHOD(IsIoHigh) ( BOOL * pfAbort );
  248. STDMETHOD(IsUserActive) ( BOOL fCheckLongTermActivity )
  249. {
  250. return E_NOTIMPL;
  251. }
  252. STDMETHOD(SampleUserActivity) ()
  253. {
  254. return E_NOTIMPL;
  255. }
  256. //
  257. // Non-Interface methods.
  258. //
  259. void Shutdown();
  260. WCHAR const * GetName();
  261. CiCat * GetCiCat() { return _pCiCat; }
  262. CiNullCat * GetCiNullCat() { return _pCiNullCat; }
  263. BOOL IsLowOnDiskSpace() const;
  264. BOOL VerifyIfLowOnDiskSpace();
  265. void SetNoQuery()
  266. {
  267. _fNoQuery = TRUE;
  268. }
  269. void UnSetNoQuery()
  270. {
  271. _fNoQuery = FALSE;
  272. }
  273. private:
  274. void _CreateCiManager();
  275. BOOL _GetPerfIndex( CI_PERF_COUNTER_NAME name, ULONG & index );
  276. void _SetCiCatRecovered();
  277. void _StartFiltering();
  278. BOOL _IsShutdown() const { return eShutdown == _state; }
  279. BOOL _AreUpdatesEnabled() const { return eUpdatesEnabled == _state; }
  280. BOOL _AreUpdatesDisabled() const { return eUpdatesDisabled == _state; }
  281. PROPID _PropertyToPropid( FULLPROPSPEC const * fps, BOOL fCreate )
  282. {
  283. PROPID pid = pidInvalid;
  284. SCODE sc = _xPropMapper->PropertyToPropid( fps, fCreate, &pid );
  285. if ( S_OK != sc )
  286. pid = pidInvalid;
  287. return pid;
  288. }
  289. void _LokDisableUpdates()
  290. {
  291. if ( eUpdatesEnabled == _state )
  292. _state = eUpdatesDisabled;
  293. }
  294. void _LokMarkShutdown()
  295. {
  296. _state = eShutdown;
  297. }
  298. void _ReportFilteringFailure( WORKID wid );
  299. SCODE InternalWorkIdToDocName( WORKID workid,
  300. ICiCDocName * pICiCDocName,
  301. BOOL fAccurate );
  302. enum EState
  303. {
  304. eUpdatesDisabled, // Updates are disabled
  305. eEnablingUpdates, // Trying to enable updates
  306. eUpdatesEnabled, // Updates are enabled
  307. eShutdown // We are in the process of shutting down
  308. };
  309. LONGLONG _sigClientDocStore;
  310. BOOL _fNoQuery;
  311. long _refCount;
  312. EState _state; // State of docstore
  313. CMutexSem _mutex; // Mutex guard
  314. CWorkManager _workMan; // Asynchronous work item manager for client
  315. CLangRes _langRes;
  316. CiCat * _pCiCat;
  317. CiNullCat * _pCiNullCat;
  318. CDrvNotifArray * _pDrvNotifArray;
  319. XPtr<CPerfMon> _xPerfMon;
  320. XInterface<ICiManager> _xCiManager;
  321. XInterface<IPropertyMapper> _xPropMapper;
  322. XPtr<CDiskFreeStatus> _xDiskStatus; // Client Storage Disk Status
  323. #if CIDBG==1
  324. XPtr<CCiSaveTest> _xSaveTest;
  325. #endif // CIDBG==1
  326. };