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.

250 lines
7.4 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 2000.
  5. //
  6. // File: FDAEMON.HXX
  7. //
  8. // Contents: Filter Daemon
  9. //
  10. // Classes: CFilterDaemon
  11. //
  12. // History: 26-Mar-93 AmyA Created
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #include <pfilter.hxx> // STATUS
  17. #include <perfobj.hxx>
  18. #include <time.h>
  19. #include <imprsnat.hxx>
  20. #include <ciintf.h>
  21. #include <lang.hxx>
  22. #include <pidmap.hxx>
  23. class CFullPropSpec;
  24. class CStorageVariant;
  25. class CCI;
  26. class PCatalog;
  27. //+---------------------------------------------------------------------------
  28. //
  29. // Class: CNonStoredProps
  30. //
  31. // Purpose: Tracks properties that shouldn't be stored in the property cache
  32. //
  33. // History: 9-Feb-97 dlee Created.
  34. //
  35. //----------------------------------------------------------------------------
  36. class CNonStoredProps
  37. {
  38. public:
  39. enum { maxCachedSpecs = 20 };
  40. CNonStoredProps() : _cSpecs( 0 ), _cMetaSpecs( 0 )
  41. {
  42. RtlZeroMemory( _afStgPropNonStored, sizeof _afStgPropNonStored );
  43. }
  44. void Add( CFullPropSpec const & ps );
  45. BOOL IsNonStored( CFullPropSpec const & ps );
  46. private:
  47. BOOL _afStgPropNonStored[ CSTORAGEPROPERTY ];
  48. int _cMetaSpecs;
  49. CFullPropSpec _aMetaSpecs[ maxCachedSpecs ];
  50. int _cSpecs;
  51. CFullPropSpec _aSpecs[ maxCachedSpecs ];
  52. };
  53. //+-------------------------------------------------------------------------
  54. //
  55. // Class: CiProxy
  56. //
  57. // Purpose: Channel between filter daemon and content index
  58. //
  59. // History: 01-Aug-93 KyleP Modified
  60. //
  61. //--------------------------------------------------------------------------
  62. class CiProxy : public PPidConverter
  63. {
  64. public:
  65. virtual ~CiProxy() {}
  66. virtual SCODE FilterReady( BYTE * docBuffer,
  67. ULONG & cb,
  68. ULONG cMaxDocs ) = 0;
  69. virtual SCODE FilterDataReady ( BYTE const * pEntryBuf,
  70. ULONG cb ) = 0;
  71. virtual SCODE FilterMore( STATUS const * aStatus, ULONG cStatus ) = 0;
  72. virtual SCODE FilterDone( STATUS const * aStatus, ULONG cStatus ) = 0;
  73. virtual SCODE FilterStoreValue( WORKID widFake,
  74. CFullPropSpec const & ps,
  75. CStorageVariant const & var,
  76. BOOL & fCanStore ) = 0;
  77. virtual SCODE FilterStoreSecurity( WORKID widFake,
  78. PSECURITY_DESCRIPTOR pSD,
  79. ULONG cbSD,
  80. BOOL & fCanStore ) = 0;
  81. };
  82. class CCiFrameworkParams;
  83. //+---------------------------------------------------------------------------
  84. //
  85. // Class: CFilterDaemon
  86. //
  87. // Purpose: Contains the filter driver and a reference to CCI.
  88. //
  89. // History: 26-Mar-93 AmyA Created.
  90. //
  91. // Notes:
  92. //
  93. //----------------------------------------------------------------------------
  94. class CFilterDaemon
  95. {
  96. friend class CFilterDocument;
  97. public:
  98. CFilterDaemon ( CiProxy & proxy,
  99. CCiFrameworkParams & params,
  100. CLangList & LangList,
  101. BYTE * buf,
  102. ULONG cbMax,
  103. ICiCFilterClient *pICiCFilterClient );
  104. ~CFilterDaemon();
  105. SCODE FilterDataReady ( const BYTE * pEntryBuf, ULONG cb );
  106. SCODE FilterStoreValue( WORKID widFake,
  107. CFullPropSpec const & ps,
  108. CStorageVariant const & var,
  109. BOOL & fCanStore );
  110. SCODE FilterStoreSecurity( WORKID widFake,
  111. PSECURITY_DESCRIPTOR pSD,
  112. ULONG cbSD,
  113. BOOL & fCanStore );
  114. SCODE DoUpdates();
  115. const ULONG GetFilteredDocuments() const { return _cFilteredDocuments; }
  116. const ULONG GetFilteredBlocks() const { return _cFilteredBlocks; }
  117. VOID StopFiltering();
  118. BOOL IsFilteringStopped() const { return _fStopFilter; }
  119. BOOL IsWaitingForDocument();
  120. private:
  121. void FilterDocs();
  122. BYTE * _docBuffer;
  123. ULONG _cbTotal;
  124. ULONG _cbHdr;
  125. ULONG _cbDocBuffer;
  126. CiProxy & _proxy;
  127. XInterface<ICiCAdviseStatus> _xAdviseStatus;
  128. XInterface<ICiCFilterClient> _xFilterClient;
  129. XInterface<ICiCFilterStatus> _xFilterStatus;
  130. CCiFrameworkParams & _params;
  131. CI_CLIENT_FILTER_CONFIG_INFO _configInfo;
  132. CPidMapper _pidmap; // Must be after _proxy
  133. CLangList & _LangList;
  134. ULONG _cFilteredDocuments;
  135. ULONG _cFilteredBlocks;
  136. BYTE const * _pbCurrentDocument;
  137. ULONG _cbCurrentDocument;
  138. BOOL _fStopFilter;
  139. BOOL _fWaitingForDocument;
  140. CMutexSem _mutex;
  141. BOOL _fOwned; // Set to TRUE if the buffer is owned
  142. BYTE * _entryBuffer; // buffer for CEntryBuffer
  143. ULONG _cbMax; // Number of bytes in the buffer
  144. CNonStoredProps _NonStoredProps;
  145. };
  146. //+---------------------------------------------------------------------------
  147. //
  148. // Member: CFilterDaemon::FilterStoreValue
  149. //
  150. // Synopsis: Store a property value.
  151. //
  152. // Arguments: [widFake] -- Fake workid (1 - MAX_DOCS_IN_WORDLIST)
  153. // [ps] -- Property descriptor
  154. // [var] -- Value
  155. // [fCanStore] -- on return, TRUE if store succeeded
  156. //
  157. // History: 21-Dec-95 KyleP Created
  158. //
  159. //----------------------------------------------------------------------------
  160. inline SCODE CFilterDaemon::FilterStoreValue( WORKID widFake,
  161. CFullPropSpec const & ps,
  162. CStorageVariant const & var,
  163. BOOL & fCanStore )
  164. {
  165. return _proxy.FilterStoreValue( widFake, ps, var, fCanStore );
  166. }
  167. //+---------------------------------------------------------------------------
  168. //
  169. // Member: CFilterDaemon::FilterStoreSecurity
  170. //
  171. // Synopsis: Store a file's security descriptor, and map to SDID
  172. //
  173. // Arguments: [widFake] -- Fake workid (1 - MAX_DOCS_IN_WORDLIST)
  174. // [pSD] -- pointer to security descriptor
  175. // [cbSD] -- size in bytes of security descriptor
  176. // [fCanStore] -- on return, TRUE if store succeeded
  177. //
  178. // History: 07 Feb 96 AlanW Created
  179. //
  180. //----------------------------------------------------------------------------
  181. inline SCODE CFilterDaemon::FilterStoreSecurity( WORKID widFake,
  182. PSECURITY_DESCRIPTOR pSD,
  183. ULONG cbSD,
  184. BOOL & fCanStore )
  185. {
  186. return _proxy.FilterStoreSecurity( widFake, pSD, cbSD, fCanStore );
  187. }
  188. // Default implementation of CiProxy::FilterStoreSecurity; only used for
  189. // downlevel index.
  190. inline SCODE CiProxy::FilterStoreSecurity( WORKID widFake,
  191. PSECURITY_DESCRIPTOR pSD,
  192. ULONG cbSD,
  193. BOOL & fCanStore )
  194. {
  195. fCanStore = FALSE;
  196. return S_OK;
  197. }