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.

385 lines
9.5 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 2002.
  5. //
  6. // File: cimanger.hxx
  7. //
  8. // Contents: The Content Index manager object implementing the
  9. // ICiManager interface.
  10. //
  11. // History: 12-03-96 srikants Created
  12. //
  13. //----------------------------------------------------------------------------
  14. #pragma once
  15. #include <frmutils.hxx>
  16. #include <cistore.hxx>
  17. #include <pidtable.hxx>
  18. #include <propmap.hxx>
  19. #include <workman.hxx>
  20. #include <lang.hxx>
  21. #include <psavtrak.hxx>
  22. #include "ciframe.hxx"
  23. #include "pdaemon.hxx"
  24. #include "idxnotif.hxx"
  25. class CCI;
  26. const LONGLONG sigCiManger = 0x5245474E414D4943i64; // "CIMANGER"
  27. class CCiManager : public ICiManager,
  28. public ICiStartup,
  29. public ICiAdmin,
  30. public ICiFrameworkQuery,
  31. public ICiPersistIncrFile,
  32. public ISimpleCommandCreator
  33. {
  34. friend class CDaemonSlave;
  35. public:
  36. CCiManager( ICiCDocStore * pICiCDocStore );
  37. virtual ~CCiManager();
  38. //
  39. // IUnknown methods.
  40. //
  41. STDMETHOD(QueryInterface) (THIS_ REFIID riid,LPVOID *ppiuk );
  42. STDMETHOD_(ULONG, AddRef) (THIS);
  43. STDMETHOD_(ULONG, Release) (THIS);
  44. //
  45. // ICiManager methods
  46. //
  47. STDMETHOD(GetStatus) ( CIF_STATE *pCiState);
  48. STDMETHOD(Empty) (void);
  49. STDMETHOD(Shutdown) (void);
  50. STDMETHOD(UpdateDocument) (
  51. const CI_DOCUMENT_UPDATE_INFO *pInfo);
  52. // We may not implement this unless it is found useful.
  53. STDMETHOD(UpdateDocuments) (
  54. ULONG cDocs,
  55. const CI_DOCUMENT_UPDATE_INFO *aInfo)
  56. {
  57. Win4Assert( !"Not Yet Implemented" );
  58. return E_NOTIMPL;
  59. }
  60. STDMETHOD(StartFiltering) (
  61. ULONG cbData,
  62. const BYTE *pbData);
  63. STDMETHOD(FlushUpdates) ( void);
  64. STDMETHOD(GetAdminParams) (
  65. ICiAdminParams **ppICiAdminParams)
  66. {
  67. Win4Assert( 0 != ppICiAdminParams );
  68. //
  69. // Admin Params are destroyed only in the destructor. So, it
  70. // is okay to get the pointer without a lock.
  71. //
  72. _xAdminParams->AddRef();
  73. *ppICiAdminParams = _xAdminParams.GetPointer();
  74. return S_OK;
  75. }
  76. STDMETHOD(ForceMerge)( CI_MERGE_TYPE mt );
  77. STDMETHOD(AbortMerge)( void );
  78. STDMETHOD(IsQuiesced) (BOOL *pfState);
  79. STDMETHOD(IsNullCatalog) (BOOL *pfNull)
  80. {
  81. *pfNull = _fNullContentIndex;
  82. return S_OK;
  83. }
  84. STDMETHOD(GetPropertyMapper) ( IPropertyMapper ** ppIPropertyMapper )
  85. {
  86. SCODE sc = S_OK;
  87. if ( !_xPropMapper.IsNull() )
  88. {
  89. *ppIPropertyMapper = _xPropMapper.GetPointer();
  90. _xPropMapper->AddRef();
  91. }
  92. else
  93. {
  94. sc = CI_E_SHUTDOWN;
  95. }
  96. return sc;
  97. }
  98. //
  99. // ICiFrameworkQuery methods
  100. //
  101. STDMETHOD(GetLangList) (void **ppLangList)
  102. {
  103. *ppLangList = _xLangList.GetPointer();
  104. if (_xLangList.IsNull())
  105. return E_FAIL; // should never be hit!
  106. else
  107. return S_OK;
  108. }
  109. STDMETHOD(GetCCI) (
  110. void ** ppCCI )
  111. {
  112. Win4Assert( 0 != ppCCI );
  113. *ppCCI = (void *) _pcci;
  114. return S_OK;
  115. }
  116. STDMETHOD(ProcessError) ( long lErrorCode );
  117. //
  118. // ICiAdmin methods
  119. //
  120. STDMETHOD(InvalidateLangResources) ()
  121. {
  122. SCODE sc = S_OK;
  123. if (_xLangList.IsNull())
  124. {
  125. sc = E_FAIL;
  126. }
  127. else
  128. {
  129. _xLangList->InvalidateLangResources();
  130. }
  131. return sc;
  132. }
  133. //
  134. // ICiPersistIncrFile methods.
  135. //
  136. STDMETHOD(Load) (
  137. BOOL fFull,
  138. BOOL fCallerOwnsFiles,
  139. IEnumString *pIFileList,
  140. IProgressNotify *pIProgressNotify,
  141. BOOL * pfAbort)
  142. {
  143. Win4Assert( !"Must Not be called" );
  144. return E_NOTIMPL;
  145. }
  146. STDMETHOD(Save) (
  147. const WCHAR *pwszSaveDirectory,
  148. BOOL fFull,
  149. IProgressNotify *pIProgressNotify,
  150. BOOL *pfAbort,
  151. ICiEnumWorkids ** ppWorkidList,
  152. IEnumString ** ppFileList,
  153. BOOL * pfFull,
  154. BOOL * pfCallerOwnsFiles);
  155. STDMETHOD(SaveCompleted) (void)
  156. {
  157. Win4Assert( !"Must Not be called" );
  158. return CI_E_INVALID_STATE;
  159. }
  160. //
  161. // Methods that are not needed for first version.
  162. //
  163. STDMETHOD(QueryRcovStorage) (
  164. IUnknown **ppIUnknown)
  165. {
  166. Win4Assert( !"Not Yet Implemented" );
  167. return E_NOTIMPL;
  168. }
  169. //
  170. // ICiStartup methods
  171. //
  172. STDMETHOD(StartupNullContentIndex) (
  173. CI_STARTUP_INFO * pStartupInfo,
  174. IProgressNotify *pIProgressNotify,
  175. BOOL * pfAbort
  176. );
  177. STDMETHOD(StartupContentIndex) (
  178. const WCHAR *pwszCiDirectory,
  179. CI_STARTUP_INFO * pStartupInfo,
  180. IProgressNotify *pIProgressNotify,
  181. BOOL * pfAbort
  182. );
  183. //
  184. // ISimpleCommandCreator methods
  185. //
  186. STDMETHOD(CreateICommand) (
  187. IUnknown ** ppIUnknown,
  188. IUnknown * pOuterUnk
  189. );
  190. STDMETHOD(VerifyCatalog) ( WCHAR const * pwszMachine,
  191. WCHAR const * pwszCatalogName );
  192. STDMETHOD(GetDefaultCatalog) ( WCHAR * pwszCatalogName,
  193. ULONG cwcIn,
  194. ULONG * pcwcOut );
  195. //
  196. // Non-Interface methods.
  197. //
  198. void ProcessCiDaemonTermination( SCODE status );
  199. SCODE UpdDocumentNoThrow( const CI_DOCUMENT_UPDATE_INFO * pInfo );
  200. private:
  201. SCODE StartupContentIndex(
  202. BOOL fNullContentIndex,
  203. const WCHAR * pwszCiDirectory,
  204. CI_STARTUP_INFO * pStartupInfo,
  205. IProgressNotify *pIProgressNotify,
  206. BOOL * pfAbort );
  207. void _HandleFilterReadyStatus( SCODE status )
  208. {
  209. //
  210. // In the framework model, we are no overloading the FilterReady
  211. // return status code to notify about failure and catastrophic events.
  212. // So, we don't have to do anything here.
  213. //
  214. }
  215. CCiFrameworkParams & _GetFrameworkParams()
  216. {
  217. return _xFrameParams.GetReference();
  218. }
  219. BOOL _CompareIncrDataSequence( WCHAR const * pwszNewDir );
  220. BOOL _IsValidSaveDirectory( WCHAR const * pwszDir );
  221. //
  222. // Various states the CCiManager object can be in.
  223. //
  224. enum EState
  225. {
  226. STARTING, // Starting up
  227. READY_TO_FILTER, // Ready to filtering, waiting for client to
  228. // call StartFiltering.
  229. FILTERING_ENABLED, // Filtering of documents enabled
  230. FILTERING_DISABLED, // Filtering of documents disabled
  231. SHUTDOWN // Shutdown - no new activity can begin
  232. };
  233. //
  234. // Reasons for disabling filtering.
  235. //
  236. enum EDisableReason
  237. {
  238. INVALID_REASON, // Not a valid value
  239. DISABLED_ON_STARTUP, // CI configured for query only
  240. DISABLED_FOR_DISK_FULL // CI disabled because disk is full
  241. };
  242. BOOL IsShutdown() const { return SHUTDOWN == _state; }
  243. SCODE _LokGetStartFilteringError() const;
  244. IPropertyMapper * _LokCreatePropertyMapper();
  245. void _UpdateQueryWorkerQueueParams();
  246. BOOL _IsInProcFiltering() const
  247. {
  248. return _startupFlags & CI_CONFIG_INPROCESS_FILTERING;
  249. }
  250. BOOL _IsIncrIndexingEnabled() const
  251. {
  252. return (_startupFlags & CI_CONFIG_ENABLE_INDEX_MIGRATION) &&
  253. (_startupFlags & CI_CONFIG_ENABLE_INDEXING);
  254. }
  255. BOOL _IsFilteringEnabled() const
  256. {
  257. return _startupFlags & CI_CONFIG_ENABLE_INDEXING;
  258. }
  259. void _CreateBackupOfPidTable( CiStorage & storage,
  260. PSaveProgressTracker & tracker );
  261. LONGLONG _sigCiManger; // Signature
  262. long _refCount; // Ref-counting
  263. CMutexSem _mutex; // Serialization
  264. EState _state; // Current state of the object.
  265. EDisableReason _reason; // reason for disabling filtering.
  266. XPtr<CiStorage> _xStorage; // Storage for Content Index
  267. XInterface<ICiCDocStore> _xDocStore;
  268. XInterface<ICiCAdviseStatus> _xAdviseStatus;
  269. XInterface<CCiAdminParams> _xAdminParams;
  270. XPtr<CCiFrameworkParams> _xFrameParams;
  271. XArray<WCHAR> _xCiDir; // "Directory" of Content Index.
  272. //
  273. // If the docstore does not provide a property mapper, CiManager provides
  274. // one.
  275. //
  276. CPidLookupTable * _pPidLookupTable; // Non zero if cretaed by CI
  277. //
  278. // Property mapper interface.
  279. //
  280. XInterface<IPropertyMapper> _xPropMapper;
  281. XInterface<CIndexNotificationTable> _xIndexNotifTable; // Buffer of notifications in push filtering
  282. CCI * _pcci; // Main Content Index
  283. XPtr<CLangList> _xLangList; // langList per ciManager/Docstore instance.
  284. GUID _clsidDmnClientMgr; // classId of the client component in
  285. // cidaemon.
  286. ULONG _startupFlags; // Flags specified during startup
  287. BOOL _fInProc; // InProcess filtering.
  288. PFilterDaemonControl * _pFilterDaemon;
  289. CProgressTracker _saveTracker; // Tracks a save operation
  290. BOOL _fNullContentIndex; // Null catalog?
  291. };