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.

434 lines
12 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996-1999.
  5. //
  6. // File: Catalog.hxx
  7. //
  8. // Contents: Used to manage catalog(s) state
  9. //
  10. // History: 27-Nov-1996 KyleP Created
  11. //
  12. //--------------------------------------------------------------------------
  13. #pragma once
  14. #include <vquery.hxx>
  15. #include <dynarray.hxx>
  16. #include <thrd32.hxx>
  17. #include "header.hxx"
  18. #include "dataobj.hxx"
  19. #include "scope.hxx"
  20. #include "prop.hxx"
  21. class CCatalog;
  22. class CCatalogs;
  23. //+-------------------------------------------------------------------------
  24. //
  25. // Class: CCatalog
  26. //
  27. // Purpose: Individual catalog state
  28. //
  29. // History: 27-Nov-1996 KyleP Created
  30. //
  31. //--------------------------------------------------------------------------
  32. class CCatalog : INHERIT_VIRTUAL_UNWIND, public PCIObjectType
  33. {
  34. public:
  35. CCatalog( CCatalogs & parent, WCHAR const * pwcsCat );
  36. ~CCatalog();
  37. void SetResultHandle( HRESULTITEM id ) { _idResult = id; }
  38. void SetScopeHandle( HRESULTITEM id ) { _idScope = id; }
  39. BOOL IsAddedToResult() const { return (0 != _idResult); }
  40. BOOL IsAddedToScope() const { return (0 != _idScope); }
  41. BOOL Update();
  42. BOOL UpdateProps();
  43. void ClearProperties(IResultData * pResultPane);
  44. void ClearScopes(IResultData * pResultPane);
  45. void InitScopeHeader( CListViewHeader & Header );
  46. void InitPropertyHeader( CListViewHeader & Header );
  47. void DisplayIntermediate( IConsoleNameSpace * pScopePane );
  48. void DisplayScopes( BOOL fFirstTime, IResultData * pResultPane );
  49. void DisplayProperties( BOOL fFirstTime, IResultData * pResultPane );
  50. void FillGroup1Settings();
  51. void FillGroup2Settings();
  52. void DeleteGroup1Settings();
  53. void DeleteGroup2Settings();
  54. BOOL DoGroup1SettingsExist();
  55. BOOL DoGroup2SettingsExist();
  56. //
  57. // Access methods
  58. //
  59. inline void GetDisplayInfo( RESULTDATAITEM * item );
  60. HRESULTITEM ResultHandle() const { return _idResult; }
  61. HSCOPEITEM ScopeHandle() const { return _idScope; }
  62. WCHAR const * GetDrive( BOOL fForceFetch ) const { return fForceFetch ? _pwcsDrive : 0; }
  63. WCHAR const * GetCat( BOOL fForceFetch ) const { return fForceFetch ? _pwcsCat : 0; }
  64. WCHAR const * GetSize( BOOL fForceFetch ) const { return (fForceFetch | _fSizeChanged ) ? _awcSize : 0; }
  65. WCHAR const * GetPropCacheSize( BOOL fForceFetch ) const { return (fForceFetch | _fPropCacheSizeChanged ) ? _awcPropCacheSize : 0; }
  66. WCHAR const * GetDocs( BOOL fForceFetch ) const { return (fForceFetch | _fDocsChanged ) ? _awcDocs : 0; }
  67. WCHAR const * GetDocsToFilter( BOOL fForceFetch ) const { return (fForceFetch | _fDocsToFilterChanged ) ? _awcDocsToFilter : 0; }
  68. WCHAR const * GetWordlists( BOOL fForceFetch ) const { return (fForceFetch | _fWordlistsChanged ) ? _awcWordlists : 0; }
  69. WCHAR const * GetPersIndex( BOOL fForceFetch ) const { return (fForceFetch | _fPersIndexChanged ) ? _awcPersIndex : 0; }
  70. WCHAR const * GetStatus( BOOL fForceFetch ) const { return (fForceFetch | _fStatusChanged ) ? _awcStatus : 0; }
  71. WCHAR const * GetSecQDocuments( BOOL fForceFetch ) const { return (fForceFetch | _fSecQDocumentsChanged ) ? _awcSecQDocuments : 0; }
  72. inline WCHAR const * GetMachine() const;
  73. inline BOOL IsLocalMachine() const;
  74. inline CCatalogs& GetParent() const;
  75. //
  76. // Direct access to state
  77. //
  78. void GetGeneration( BOOL & fFilterUnknown,
  79. BOOL & fGenerateCharacterization,
  80. ULONG & ccCharacterization );
  81. void SetGeneration( BOOL fFilterUnknown,
  82. BOOL fGenerateCharacterization,
  83. ULONG ccCharacterization );
  84. void GetWeb( BOOL & fVirtualRoots,
  85. BOOL & fNNTPRoots,
  86. ULONG & iVirtualServer,
  87. ULONG & iNNTPServer );
  88. void SetWeb( BOOL fVirtualRoots,
  89. BOOL fNNTPRoots,
  90. ULONG iVirtualServer,
  91. ULONG iNNTPServer );
  92. void GetTracking( BOOL & fAutoAlias );
  93. void SetTracking( BOOL fAutoAlias );
  94. //
  95. // Typing
  96. //
  97. PCIObjectType::OType Type() const { return PCIObjectType::Catalog; }
  98. //
  99. // Manipulation
  100. //
  101. void RemoveScope( CScope * pScope );
  102. SCODE AddScope( WCHAR const * pwszScope,
  103. WCHAR const * pwszAlias,
  104. BOOL fExclude,
  105. WCHAR const * pwszLogon,
  106. WCHAR const * pwszPassword );
  107. SCODE ModifyScope( CScope & rScope,
  108. WCHAR const * pwszScope,
  109. WCHAR const * pwszAlias,
  110. BOOL fExclude,
  111. WCHAR const * pwszLogon,
  112. WCHAR const * pwszPassword );
  113. void RescanScope( WCHAR const * pwszScope, BOOL fFull );
  114. void Merge();
  115. BOOL ChangesPending() { return ( _fSizeChanged | _fDocsChanged | _fDocsToFilterChanged | _fWordlistsChanged | _fPersIndexChanged | _fStatusChanged ); }
  116. void UpdateCachedProperty(CCachedProperty *pProperty);
  117. //
  118. // Parent reference
  119. //
  120. CIntermediate * GetIntermediateScopeNode() { return &_interScopes; }
  121. CIntermediate * GetIntermediatePropNode() { return &_interProperties; }
  122. CIntermediate * GetIntermediateUnfilteredNode() { return &_interUnfiltered; }
  123. //
  124. // Misc.
  125. //
  126. void Zombify() { _fZombie = TRUE; }
  127. BOOL IsZombie() { return _fZombie; }
  128. BOOL IsInactive() { return _fInactive; }
  129. void SetInactive(BOOL fInactive) { _fInactive = fInactive; }
  130. private:
  131. void Set( WCHAR const * pwcsSrc, WCHAR * & pwcsDst );
  132. static void Stringize( DWORD dwValue, WCHAR * pwcsDst, unsigned ccDst );
  133. static void Null( WCHAR * pwcsDst )
  134. {
  135. wcscpy( pwcsDst, L" " );
  136. }
  137. void FormatStatus( CI_STATE & state );
  138. unsigned AppendToStatus( unsigned ccLeft,
  139. CI_STATE & state,
  140. DWORD dwFlag,
  141. StringResource & srFlag,
  142. unsigned ccFlag );
  143. void PopulateScopes();
  144. HRESULTITEM _idResult;
  145. HSCOPEITEM _idScope;
  146. //
  147. // Back-pointer(s)
  148. //
  149. CIntermediate _interScopes;
  150. CIntermediate _interProperties;
  151. CIntermediate _interUnfiltered;
  152. //
  153. // Per-catalog state
  154. //
  155. WCHAR * _pwcsDrive;
  156. WCHAR * _pwcsCat;
  157. BOOL _fZombie;
  158. CI_STATE _state;
  159. //
  160. // Buffers to string-ize output. Size * 2 for safe formatting + 1 for null
  161. //
  162. WCHAR _awcSize[9]; // Max # is 4,096,
  163. WCHAR _awcPropCacheSize[9]; // Can't be too large. The size is in MBs
  164. WCHAR _awcDocs[19]; // Max supported for display: 999,999,999
  165. WCHAR _awcDocsToFilter[19]; // Max supported for display: 999,999,999
  166. WCHAR _awcWordlists[7]; // Max # is 999
  167. WCHAR _awcPersIndex[7]; // Max # is 999
  168. WCHAR _awcStatus[100]; // Artificial size cap.
  169. WCHAR _awcSecQDocuments[19]; // Max supported for display: 999,999,999
  170. BOOL _fSizeChanged;
  171. BOOL _fPropCacheSizeChanged;
  172. BOOL _fDocsChanged;
  173. BOOL _fDocsToFilterChanged;
  174. BOOL _fWordlistsChanged;
  175. BOOL _fPersIndexChanged;
  176. BOOL _fStatusChanged;
  177. BOOL _fInactive;
  178. BOOL _fSecQDocumentsChanged;
  179. CCountedDynArray<CScope> _aScope;
  180. CCountedDynArray<CCachedProperty> _aProperty;
  181. CCatalogs & _parent;
  182. };
  183. //+-------------------------------------------------------------------------
  184. //
  185. // Class: CCatalogs
  186. //
  187. // Purpose: Catalog state
  188. //
  189. // History: 27-Nov-1996 KyleP Created
  190. //
  191. //--------------------------------------------------------------------------
  192. class CCatalogs
  193. {
  194. public:
  195. CCatalogs();
  196. ~CCatalogs();
  197. void SetMachine( WCHAR const * pwcsMachine );
  198. void Init( IConsoleNameSpace * pScopePane );
  199. SCODE ReInit();
  200. void InitHeader( CListViewHeader & Header );
  201. void DisplayScope( HSCOPEITEM hScopeItem );
  202. void Display( BOOL fFirstTime = TRUE );
  203. void Quiesce();
  204. WCHAR const * GetMachine() const { return _xwcsMachine.Get(); }
  205. BOOL IsLocalMachine() const { return (_xwcsMachine[0] == L'.' && _xwcsMachine[1] == 0); }
  206. // Direct access to an individual catalog
  207. // i is a 0 based index
  208. CCatalog * GetCatalog( UINT i)
  209. {
  210. if (i >= _aCatalog.Count())
  211. return 0;
  212. return _aCatalog[i];
  213. }
  214. //
  215. // Direct access to state
  216. //
  217. void GetGeneration( BOOL & fFilterUnknown,
  218. BOOL & fGenerateCharacterization,
  219. ULONG & ccCharacterization );
  220. void SetGeneration( BOOL fFilterUnknown,
  221. BOOL fGenerateCharacterization,
  222. ULONG ccCharacterization );
  223. void GetTracking( BOOL & fAutoAlias );
  224. void SetTracking( BOOL fAutoAlias );
  225. //
  226. // Manipulation
  227. //
  228. SCODE AddCatalog( WCHAR const * pwcsCatName, WCHAR const * pwcsLocation );
  229. SCODE RemoveCatalog( CCatalog * pCat );
  230. void UpdateActiveState();
  231. //
  232. // Manipulation of catalog entry in scope pane
  233. //
  234. void AddCatalogToScope(CCatalog *pCat);
  235. void RemoveCatalogFromScope(CCatalog *pCat);
  236. // Set snapindata
  237. void SetSnapinData( CCISnapinData *pSnapinData )
  238. {
  239. _pSnapinData = pSnapinData;
  240. }
  241. // Get toolbar
  242. CCISnapinData * SnapinData() { return _pSnapinData; }
  243. // Get/Set service usage info
  244. void SetServiceUsage(DWORD dwUsage) { _dwUsage = dwUsage; }
  245. DWORD GetServiceUsage() const { return _dwUsage; }
  246. SCODE GetSavedServiceUsage(DWORD &dwUsage, DWORD &dwIdxPos, DWORD &dwQryPos);
  247. SCODE SaveServiceUsage(DWORD dwUsage, DWORD dwIdxPos, DWORD dwQryPos);
  248. // All parameters are within the wLowPos and wHighPos range.
  249. // For indexing and querying functionality, the values dictate the desired performance level.
  250. void SaveServicePerformanceSettings(WORD wIndexingPos, WORD wQueryingPos);
  251. void GetServicePerformanceSettings(WORD &wIndexingPos, WORD &wQueryingPos);
  252. SCODE TuneServicePerformance();
  253. SCODE DisableService();
  254. SCODE EnableService();
  255. void SetButtonState( int idCommand,
  256. MMC_BUTTON_STATE nState,
  257. BOOL bState );
  258. private:
  259. friend void CALLBACK DisplayTimerProc(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime);
  260. void Populate();
  261. void PickupNewCatalogs();
  262. CCountedDynArray<CCatalog> _aCatalog;
  263. IConsoleNameSpace * _pScopePane;
  264. HSCOPEITEM _hRootScopeItem; // Catalogs inserted under here.
  265. BOOL _fFirstScopeExpansion;
  266. BOOL _fAbort;
  267. static BOOL _fFirstTime; // Used for one-shot resource init.
  268. UINT _uiTimerIndex; // index into array of timer ids
  269. DWORD _dwUsage; // How will this service be used?
  270. WORD _wIndexingPos; // Indexing position
  271. WORD _wQueryingPos; // Querying position
  272. CCISnapinData * _pSnapinData;
  273. XGrowable<WCHAR,MAX_COMPUTERNAME_LENGTH> _xwcsMachine;
  274. };
  275. //
  276. // Catalog columns
  277. //
  278. struct SCatalogColumn
  279. {
  280. WCHAR const * (CCatalog::*pfGet)( BOOL fForceFetch ) const;
  281. StringResource srTitle;
  282. };
  283. extern SCatalogColumn coldefCatalog[];
  284. extern const unsigned cColDefCatalog;
  285. inline void CCatalog::GetDisplayInfo( RESULTDATAITEM * item )
  286. {
  287. // Win4Assert( item->itemID == ResultHandle() );
  288. if ( item->nCol >= (int)cColDefCatalog )
  289. {
  290. item->str = L"";
  291. return;
  292. }
  293. item->str = (WCHAR *)(this->*coldefCatalog[item->nCol].pfGet)( TRUE );
  294. item->nImage = ICON_CATALOG;
  295. }
  296. inline WCHAR const * CCatalog::GetMachine() const
  297. {
  298. return _parent.GetMachine();
  299. }
  300. inline BOOL CCatalog::IsLocalMachine() const
  301. {
  302. return _parent.IsLocalMachine();
  303. }
  304. inline CCatalogs& CCatalog::GetParent() const
  305. {
  306. return _parent;
  307. }
  308. // Refresh
  309. void CALLBACK DisplayTimerProc(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime);
  310. // Miscellaneous
  311. BOOL IsNTServer();