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.

147 lines
5.5 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997 - 1998
  5. //
  6. // File: CatAdm.hxx
  7. //
  8. // Contents: Declaration of the CCatAdm
  9. //
  10. // Classes: CCatAdm
  11. //
  12. // History: 12-10-97 mohamedn created
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. //
  17. // constants
  18. //
  19. const unsigned UpdateInterval = 5000; // 5 seconds.
  20. //
  21. // forward declarations
  22. //
  23. class CScopeAdm;
  24. class CMachineAdm;
  25. typedef CComObject<CScopeAdm> ScopeAdmObject;
  26. //
  27. // utility routines
  28. //
  29. WCHAR const * GetWCHARFromVariant( VARIANT & Var );
  30. //+---------------------------------------------------------------------------
  31. //
  32. // Class: CCatAdm
  33. //
  34. // Purpose: CI Catalog Administration Interface
  35. //
  36. // History: 12-10-97 mohamedn created
  37. //
  38. //----------------------------------------------------------------------------
  39. class ATL_NO_VTABLE CCatAdm :
  40. public CComObjectRootEx<CComMultiThreadModel>,
  41. public CComCoClass<CCatAdm, &CLSID_CatAdm>,
  42. public ISupportErrorInfo,
  43. public IDispatchImpl<ICatAdm, &IID_ICatAdm, &LIBID_CIODMLib>
  44. {
  45. public:
  46. CCatAdm();
  47. void SetParent( CComObject<CMachineAdm> * pIMacAdm ) { _pIMacAdm = pIMacAdm; }
  48. void Initialize( XPtr<CCatalogAdmin> & xCatAdmin );
  49. void SetInvalid() { _eCurrentState = CIODM_NOT_INITIALIZED; }
  50. BOOL ScopeExists(WCHAR const * pScopePath);
  51. ULONG InternalAddRef();
  52. ULONG InternalRelease();
  53. void IncObjectCount() { _cMinRefCountToDestroy++; _pIMacAdm->IncObjectCount();}
  54. void DecObjectCount() { _cMinRefCountToDestroy--; _pIMacAdm->DecObjectCount();}
  55. BOOL IsCurrentObjectValid() { return (CIODM_INITIALIZED == _eCurrentState); }
  56. void SetErrorInfo( HRESULT hRes );
  57. void GetScopeAutomationObject( XPtr<CScopeAdmin> & xScopeAdmin,
  58. XInterface<ScopeAdmObject> & xIScopeAdm );
  59. IDispatch * GetIDisp( unsigned i );
  60. CCatalogAdmin * GetCatalogAdmin() { return _xCatAdmin.GetPointer(); }
  61. DECLARE_REGISTRY_RESOURCEID(IDR_CATADM)
  62. BEGIN_COM_MAP(CCatAdm)
  63. COM_INTERFACE_ENTRY(ICatAdm)
  64. COM_INTERFACE_ENTRY(IDispatch)
  65. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  66. END_COM_MAP()
  67. // ISupportsErrorInfo
  68. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  69. // ICatAdm
  70. public:
  71. //
  72. // interface methods/properties
  73. //
  74. STDMETHOD(ForceMasterMerge) (void);
  75. STDMETHOD(AddScope) ( BSTR bstrScopeName, VARIANT_BOOL fExclude, VARIANT vtLogon, VARIANT vtPassword, IDispatch ** pIDisp);
  76. STDMETHOD(RemoveScope) ( BSTR bstrScopePath);
  77. STDMETHOD(GetScopeByPath) ( BSTR bstrPath, IDispatch ** pIDisp);
  78. STDMETHOD(GetScopeByAlias) ( BSTR bstrAlias, IDispatch ** pIDisp);
  79. STDMETHOD(FindFirstScope) ( VARIANT_BOOL * fFound);
  80. STDMETHOD(FindNextScope) ( VARIANT_BOOL * fFound);
  81. STDMETHOD(GetScope) ( IDispatch ** pIDisp);
  82. STDMETHOD( get_CatalogName ) ( BSTR *pVal );
  83. STDMETHOD( get_CatalogLocation ) ( BSTR *pVal );
  84. STDMETHOD( get_WordListCount ) ( LONG *pVal );
  85. STDMETHOD( get_PersistentIndexCount ) ( LONG *pVal );
  86. STDMETHOD( get_QueryCount ) ( LONG *pVal );
  87. STDMETHOD( get_DocumentsToFilter ) ( LONG *pVal );
  88. STDMETHOD( get_FreshTestCount ) ( LONG *pVal );
  89. STDMETHOD( get_PctMergeComplete ) ( LONG *pVal );
  90. STDMETHOD( get_FilteredDocumentCount ) ( LONG *pVal );
  91. STDMETHOD( get_TotalDocumentCount ) ( LONG *pVal );
  92. STDMETHOD( get_PendingScanCount ) ( LONG *pVal );
  93. STDMETHOD( get_IndexSize ) ( LONG *pVal );
  94. STDMETHOD( get_UniqueKeyCount ) ( LONG *pVal );
  95. STDMETHOD( get_StateInfo ) ( LONG *pVal );
  96. STDMETHOD( get_IsUpToDate ) ( VARIANT_BOOL *pVal );
  97. STDMETHOD( get_DelayedFilterCount ) ( LONG *pVal );
  98. STDMETHOD( StartCatalog ) ( CatalogStateType *pdwOldState );
  99. STDMETHOD( StopCatalog ) ( CatalogStateType *pdwOldState );
  100. STDMETHOD( PauseCatalog ) ( CatalogStateType *pdwOldState );
  101. STDMETHOD( ContinueCatalog ) ( CatalogStateType *pdwOldState );
  102. STDMETHOD( IsCatalogRunning ) ( VARIANT_BOOL *pfIsRunning );
  103. STDMETHOD( IsCatalogPaused ) ( VARIANT_BOOL *pfIsPaused );
  104. STDMETHOD( IsCatalogStopped ) ( VARIANT_BOOL *pfIsStopped );
  105. //
  106. // utility routines
  107. //
  108. void SafeForScripting(void) { _pIMacAdm->SafeForScripting(); }
  109. private:
  110. CMutexSem _mtx;
  111. DWORD _dwTickCount;
  112. DWORD _cEnumIndex;
  113. XPtr<CCatalogAdmin> _xCatAdmin;
  114. CComObject<CMachineAdm> * _pIMacAdm;
  115. CCountedIDynArray<ScopeAdmObject> _aIScopeAdmin;
  116. //
  117. // to control when objects are deleted.
  118. //
  119. enum eCiOdmState { CIODM_NOT_INITIALIZED, CIODM_INITIALIZED, CIODM_DESTROY };
  120. eCiOdmState _eCurrentState;
  121. LONG _cMinRefCountToDestroy;
  122. };