Leaked source code of windows server 2003
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.

222 lines
5.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 2002.
  5. //
  6. // File: ciframe.hxx
  7. //
  8. // Contents: Classes for the ciframe work that are used globally.
  9. //
  10. // History: 11-22-96 srikants Created
  11. //
  12. //----------------------------------------------------------------------------
  13. #pragma once
  14. #include <ciintf.h>
  15. #include <cifrmcom.hxx>
  16. class CLangList;
  17. struct CI_ADMIN_PARAMS_RANGE
  18. {
  19. DWORD _dwMin;
  20. DWORD _dwMax;
  21. DWORD _dwDefault;
  22. };
  23. //+---------------------------------------------------------------------------
  24. //
  25. // Class: CCiAdminParams
  26. //
  27. // Purpose: A class to get and set CI administrative parameters.
  28. //
  29. // History: 11-26-96 srikants Created
  30. //
  31. //----------------------------------------------------------------------------
  32. class CCiAdminParams : public ICiAdminParams,
  33. public ICiAdmin
  34. {
  35. public:
  36. //
  37. // Constructor and Destructor
  38. //
  39. CCiAdminParams( CLangList * pLangList = 0 );
  40. //
  41. // IUnknown methods.
  42. //
  43. STDMETHOD(QueryInterface) (THIS_ REFIID riid,LPVOID *ppiuk );
  44. STDMETHOD_(ULONG, AddRef) (THIS);
  45. STDMETHOD_(ULONG, Release) (THIS);
  46. //
  47. // ICiAdminParams methods
  48. //
  49. STDMETHOD(SetValue) ( CI_ADMIN_PARAMS param,
  50. DWORD dwValue );
  51. STDMETHOD(SetParamValue) ( CI_ADMIN_PARAMS param,
  52. const PROPVARIANT * pVarValue );
  53. STDMETHOD(SetValues) (ULONG nParams,
  54. const PROPVARIANT * aParamVals,
  55. const CI_ADMIN_PARAMS * aParamNames);
  56. STDMETHOD(GetValue) ( CI_ADMIN_PARAMS param,
  57. DWORD *pdwValue );
  58. STDMETHOD(GetInt64Value)( CI_ADMIN_PARAMS param,
  59. __int64 *pValue );
  60. STDMETHOD(GetParamValue) ( CI_ADMIN_PARAMS param,
  61. PROPVARIANT ** ppVarValue );
  62. STDMETHOD(IsSame) ( CI_ADMIN_PARAMS param,
  63. const PROPVARIANT * pVarValue,
  64. BOOL * pfSame);
  65. STDMETHOD(SetConfigType) ( CI_CONFIG_TYPE configType )
  66. {
  67. Win4Assert( !"Not Yet Implemented" );
  68. return E_NOTIMPL;
  69. }
  70. STDMETHOD(GetConfigType) ( CI_CONFIG_TYPE * pConfigType )
  71. {
  72. Win4Assert( !"Not Yet Implemented" );
  73. return E_NOTIMPL;
  74. }
  75. //
  76. // ICiAdmin methods.
  77. //
  78. STDMETHOD(InvalidateLangResources) ();
  79. //
  80. // Non-Interface methods.
  81. //
  82. BOOL IsValidParam( CI_ADMIN_PARAMS param ) const
  83. {
  84. return param < CI_AP_MAX_VAL && CI_AP_MAX_DWORD_VAL != param;
  85. }
  86. void SetLangList( CLangList * pLangList )
  87. {
  88. Win4Assert( 0 == _pLangList );
  89. _pLangList = pLangList;
  90. }
  91. protected:
  92. private:
  93. enum { eDelimVal = 0xFEFEFEFE };
  94. DWORD _GetValueInRange( CI_ADMIN_PARAMS param, DWORD dwVal )
  95. {
  96. Win4Assert( IsValidParam( param ) );
  97. return min( max( dwVal, _adwRangeParams[param]._dwMin ),
  98. _adwRangeParams[param]._dwMax );
  99. }
  100. long _refCount;
  101. CMutexSem _mutex; // Used to serialize access
  102. CLangList * _pLangList; // Optional language resources
  103. DWORD _adwParams[CI_AP_MAX_DWORD_VAL];
  104. // Array of values indexed by their enum
  105. // value
  106. __int64 _maxFilesizeFiltered; // Maximum filesize filtered
  107. static const CI_ADMIN_PARAMS_RANGE _adwRangeParams[CI_AP_MAX_DWORD_VAL];
  108. };
  109. //+---------------------------------------------------------------------------
  110. //
  111. // Class: CLocateDocStore
  112. //
  113. // Purpose: An object to give the docstore locator. Rather than doing
  114. // a CoCreateInstance once per query, we just do it once and
  115. // save it in this object.
  116. //
  117. // History: 1-17-97 srikants Created
  118. //
  119. //----------------------------------------------------------------------------
  120. class CLocateDocStore
  121. {
  122. public:
  123. CLocateDocStore()
  124. : _pDocStoreLocator(0),
  125. _fShutdown(FALSE)
  126. {
  127. }
  128. void Init()
  129. {
  130. _mutex.Init();
  131. }
  132. ~CLocateDocStore()
  133. {
  134. //Shutdown();
  135. //Win4Assert( 0 == _pDocStoreLocator );
  136. }
  137. void Shutdown();
  138. ICiCDocStoreLocator * Get( GUID const & guidDocStoreLocator );
  139. ICiCDocStoreLocator * Get();
  140. private:
  141. ICiCDocStoreLocator * _pDocStoreLocator;
  142. BOOL _fShutdown;
  143. CStaticMutexSem _mutex;
  144. };
  145. //+---------------------------------------------------------------------------
  146. //
  147. // Member: CLocateDocStore::Get
  148. //
  149. // Synopsis: Retrieves the DocStoreLocataor if one is avaialble.
  150. //
  151. // History: 1-17-97 srikants Created
  152. //
  153. //----------------------------------------------------------------------------
  154. inline ICiCDocStoreLocator * CLocateDocStore::Get()
  155. {
  156. if ( !_fShutdown )
  157. {
  158. CLock lock(_mutex);
  159. if ( 0 != _pDocStoreLocator )
  160. _pDocStoreLocator->AddRef();
  161. }
  162. return _pDocStoreLocator;
  163. }