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.

354 lines
12 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000-2002 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // CBCAInterface.h
  7. //
  8. // Implementation Files:
  9. // CBCAInterface.cpp
  10. //
  11. // Description:
  12. // This file contains the declaration of the CBCAInterface
  13. // class. This class implements the IClusCfgBaseCluster interface.
  14. //
  15. // Maintained By:
  16. // David Potter (DavidP) 19-JUN-2001
  17. // Vij Vasu (VVasu) 07-MAR-2000
  18. //
  19. //////////////////////////////////////////////////////////////////////////////
  20. // Make sure that this file is included only once per compile path.
  21. #pragma once
  22. //////////////////////////////////////////////////////////////////////////////
  23. // Include Files
  24. //////////////////////////////////////////////////////////////////////////////
  25. // For IUnknown
  26. #include <unknwn.h>
  27. // For IClusCfgBaseCluster
  28. // For IClusCfgInitialize
  29. // For IClusCfgCallback
  30. #include "ClusCfgServer.h"
  31. #include "ClusCfgPrivate.h"
  32. // For CSmartIfacePtr
  33. #include "SmartClasses.h"
  34. // For the a few common types and definitions
  35. #include "CommonDefs.h"
  36. // For the CStr class
  37. #include "CStr.h"
  38. // For the CList class
  39. #include "CList.h"
  40. //////////////////////////////////////////////////////////////////////////
  41. // Forward declarations.
  42. //////////////////////////////////////////////////////////////////////////
  43. class CBaseClusterAction;
  44. class CException;
  45. class CExceptionWithString;
  46. class CAssert;
  47. //////////////////////////////////////////////////////////////////////////////
  48. //++
  49. //
  50. // class CBCAInterface
  51. //
  52. // Description:
  53. // This class implements the IClusCfgBaseCluster interface.
  54. //
  55. //--
  56. //////////////////////////////////////////////////////////////////////////////
  57. class CBCAInterface
  58. : public IClusCfgBaseCluster
  59. , public IClusCfgInitialize
  60. {
  61. public:
  62. //////////////////////////////////////////////////////////////////////////
  63. // IUnknown methods
  64. //////////////////////////////////////////////////////////////////////////
  65. STDMETHOD( QueryInterface )( REFIID riidIn, void ** ppvOut );
  66. STDMETHOD_( ULONG, AddRef )( void );
  67. STDMETHOD_( ULONG, Release )( void );
  68. //////////////////////////////////////////////////////////////////////////
  69. // IClusCfgBaseCluster methods
  70. //////////////////////////////////////////////////////////////////////////
  71. // Indicate that a cluster is to be created.
  72. STDMETHOD( SetCreate )(
  73. const WCHAR * pcszClusterNameIn
  74. , const WCHAR * pcszClusterBindingStringIn
  75. , IClusCfgCredentials * pcccServiceAccountIn
  76. , const DWORD dwClusterIPAddressIn
  77. , const DWORD dwClusterIPSubnetMaskIn
  78. , const WCHAR * pcszClusterIPNetworkIn
  79. );
  80. // Indicate that this node should be added to a cluster.
  81. STDMETHOD( SetAdd )(
  82. const WCHAR * pcszClusterNameIn
  83. , const WCHAR * pcszClusterBindingStringIn
  84. , IClusCfgCredentials * pcccServiceAccountIn
  85. );
  86. // Indicate that this node needs to be cleaned up.
  87. STDMETHOD( SetCleanup )( void );
  88. // Commit the action desired.
  89. STDMETHOD( Commit )( void );
  90. // Rollback the committed action.
  91. STDMETHOD( Rollback )( void );
  92. //////////////////////////////////////////////////////////////////////////
  93. // IClusCfgInitialize methods
  94. //////////////////////////////////////////////////////////////////////////
  95. // Initialize this object.
  96. STDMETHOD( Initialize )(
  97. IUnknown * punkCallbackIn
  98. , LCID lcidIn
  99. );
  100. //////////////////////////////////////////////////////////////////////////
  101. // Other public methods
  102. //////////////////////////////////////////////////////////////////////////
  103. // Create an instance of this class.
  104. static HRESULT S_HrCreateInstance( IUnknown ** ppunkOut );
  105. // Send progress notification [ string id overload ]
  106. void
  107. SendStatusReport(
  108. const CLSID & clsidTaskMajorIn
  109. , const CLSID & clsidTaskMinorIn
  110. , ULONG ulMinIn
  111. , ULONG ulMaxIn
  112. , ULONG ulCurrentIn
  113. , HRESULT hrStatusIn
  114. , UINT uiDescriptionStringIdIn
  115. , bool fIsAbortAllowedIn = true
  116. );
  117. // Send progress notification [ string id & REF string id overload ]
  118. void
  119. SendStatusReport(
  120. const CLSID & clsidTaskMajorIn
  121. , const CLSID & clsidTaskMinorIn
  122. , ULONG ulMinIn
  123. , ULONG ulMaxIn
  124. , ULONG ulCurrentIn
  125. , HRESULT hrStatusIn
  126. , UINT uiDescriptionStringIdIn
  127. , UINT uiReferenceStringIdIn
  128. , bool fIsAbortAllowedIn = true
  129. );
  130. // Send progress notification [ string overload ]
  131. void
  132. SendStatusReport(
  133. const CLSID & clsidTaskMajorIn
  134. , const CLSID & clsidTaskMinorIn
  135. , ULONG ulMinIn
  136. , ULONG ulMaxIn
  137. , ULONG ulCurrentIn
  138. , HRESULT hrStatusIn
  139. , const WCHAR * pcszDescriptionStringIn
  140. , bool fIsAbortAllowedIn = true
  141. );
  142. // Send progress notification [ string & REF string overload ]
  143. void
  144. SendStatusReport(
  145. const CLSID & clsidTaskMajorIn
  146. , const CLSID & clsidTaskMinorIn
  147. , ULONG ulMinIn
  148. , ULONG ulMaxIn
  149. , ULONG ulCurrentIn
  150. , HRESULT hrStatusIn
  151. , const WCHAR * pcszDescriptionStringIn
  152. , const WCHAR * pcszReferenceStringIn
  153. , bool fIsAbortAllowedIn = true
  154. );
  155. // Queue a status report to be sent when an exception is caught.
  156. void
  157. QueueStatusReportCompletion(
  158. const CLSID & clsidTaskMajorIn
  159. , const CLSID & clsidTaskMinorIn
  160. , ULONG ulMinIn
  161. , ULONG ulMaxIn
  162. , UINT uiDescriptionStringIdIn
  163. , UINT uiReferenceStringIdIn
  164. );
  165. // Process an exception that should be shown to the user.
  166. HRESULT
  167. HrProcessException( CExceptionWithString & resExceptionObjectInOut ) throw();
  168. // Process an assert exception.
  169. HRESULT
  170. HrProcessException( const CAssert & rcaExceptionObjectIn ) throw();
  171. // Process a general exception.
  172. HRESULT
  173. HrProcessException( const CException & rceExceptionObjectIn ) throw();
  174. // Process an unknown exception.
  175. HRESULT
  176. HrProcessException( void ) throw();
  177. //////////////////////////////////////////////////////////////////////////
  178. // Public accessor methods
  179. //////////////////////////////////////////////////////////////////////////
  180. // Has this action been successfully committed?
  181. bool
  182. FIsCommitComplete() const throw() { return m_fCommitComplete; }
  183. // Can this action be rolled back?
  184. bool
  185. FIsRollbackPossible() const throw() { return m_fRollbackPossible; }
  186. // Are callbacks supported?
  187. bool
  188. FIsCallbackSupported() const throw() { return m_fCallbackSupported; }
  189. private:
  190. //////////////////////////////////////////////////////////////////////////
  191. // Private types
  192. //////////////////////////////////////////////////////////////////////////
  193. // Smart pointer to a base cluster action.
  194. typedef CSmartGenericPtr< CPtrTrait< CBaseClusterAction > > SmartBCAPointer;
  195. // Structure that holds the data required to send pending status reports.
  196. struct SPendingStatusReport
  197. {
  198. CLSID m_clsidTaskMajor;
  199. CLSID m_clsidTaskMinor;
  200. ULONG m_ulMin;
  201. ULONG m_ulMax;
  202. UINT m_uiDescriptionStringId;
  203. UINT m_uiReferenceStringId;
  204. // Constructor
  205. SPendingStatusReport(
  206. const CLSID & rclsidTaskMajorIn
  207. , const CLSID & rclsidTaskMinorIn
  208. , ULONG ulMinIn
  209. , ULONG ulMaxIn
  210. , UINT uiDescriptionStringIdIn
  211. , UINT uiReferenceStringIdIn
  212. )
  213. : m_clsidTaskMajor( rclsidTaskMajorIn )
  214. , m_clsidTaskMinor( rclsidTaskMinorIn )
  215. , m_ulMin( ulMinIn )
  216. , m_ulMax( ulMaxIn )
  217. , m_uiDescriptionStringId( uiDescriptionStringIdIn )
  218. , m_uiReferenceStringId( uiReferenceStringIdIn )
  219. {
  220. } //*** SPendingStatusReport
  221. }; // struct SPendingStatusReport
  222. // List of pending status reports
  223. typedef CList< SPendingStatusReport > PendingReportList;
  224. //////////////////////////////////////////////////////////////////////////
  225. // Private member functions
  226. //////////////////////////////////////////////////////////////////////////
  227. //
  228. // Private constructors, destructor and assignment operator.
  229. // All of these methods are private for two reasons:
  230. // 1. Lifetimes of objects of this class are controlled by S_HrCreateInstance and Release.
  231. // 2. Copying of an object of this class is prohibited.
  232. //
  233. // Default constructor.
  234. CBCAInterface( void );
  235. // Destructor.
  236. ~CBCAInterface( void );
  237. // Copy constructor.
  238. CBCAInterface( const CBCAInterface & );
  239. // Assignment operator.
  240. CBCAInterface & operator =( const CBCAInterface & );
  241. //////////////////////////////////////////////////////////////////////////
  242. // Private accessor methods
  243. //////////////////////////////////////////////////////////////////////////
  244. // Set the commit status.
  245. void
  246. SetCommitCompleted( bool fComplete = true ) throw() { m_fCommitComplete = fComplete; }
  247. // Indicate if rollback is possible
  248. void
  249. SetRollbackPossible( bool fPossible = true ) throw() { m_fRollbackPossible = fPossible; }
  250. // Indicate if callbacks are supported or not.
  251. void
  252. SetCallbackSupported( bool fSupported = true ) throw() { m_fCallbackSupported = fSupported; }
  253. //////////////////////////////////////////////////////////////////////////
  254. // Other private methods
  255. //////////////////////////////////////////////////////////////////////////
  256. // Send all those status reports that were supposed to be sent
  257. void
  258. CompletePendingStatusReports( HRESULT hrStatusIn ) throw();
  259. //////////////////////////////////////////////////////////////////////////
  260. // Private data
  261. //////////////////////////////////////////////////////////////////////////
  262. // Indicates if this action has been successfully committed or not.
  263. bool m_fCommitComplete;
  264. // Indicates if this action can be rolled back or not.
  265. bool m_fRollbackPossible;
  266. // Indicates if callbacks are supported or not.
  267. bool m_fCallbackSupported;
  268. // Reference count for this object.
  269. LONG m_cRef;
  270. // The locale id.
  271. LCID m_lcid;
  272. // Pointer to the action to be performed during Commit()
  273. SmartBCAPointer m_spbcaCurrentAction;
  274. // Pointer to the synchronous callback interface.
  275. CSmartIfacePtr< IClusCfgCallback > m_spcbCallback;
  276. // List of status reports that need to be send when an exception is caught.
  277. PendingReportList m_prlPendingReportList;
  278. }; //*** class CBCAInterface