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.

669 lines
16 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1999-2002 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // AddNodesWizard.cpp
  7. //
  8. // Description:
  9. // Implementation of CAddNodesWizard class.
  10. //
  11. // Maintained By:
  12. // John Franco (jfranco) 17-APR-2002
  13. //
  14. //////////////////////////////////////////////////////////////////////////////
  15. //////////////////////////////////////////////////////////////////////////////
  16. // Include Files
  17. //////////////////////////////////////////////////////////////////////////////
  18. #include "Pch.h"
  19. #include "AddNodesWizard.h"
  20. //****************************************************************************
  21. //
  22. // CAddNodesWizard
  23. //
  24. //****************************************************************************
  25. DEFINE_THISCLASS( "CAddNodesWizard" )
  26. //////////////////////////////////////////////////////////////////////////////
  27. //++
  28. //
  29. // CAddNodesWizard::S_HrCreateInstance
  30. //
  31. // Description:
  32. // Creates a CAddNodesWizard instance.
  33. //
  34. // Arguments:
  35. // ppunkOut - The IUnknown interface of the new object.
  36. //
  37. // Return Values:
  38. // S_OK - Success.
  39. // E_OUTOFMEMORY - Not enough memory to create the object.
  40. // Other HRESULTs.
  41. //
  42. //--
  43. //////////////////////////////////////////////////////////////////////////////
  44. HRESULT
  45. CAddNodesWizard::S_HrCreateInstance( IUnknown ** ppunkOut )
  46. {
  47. TraceFunc( "" );
  48. HRESULT hr = S_OK;
  49. CAddNodesWizard * panw = NULL;
  50. Assert( ppunkOut != NULL );
  51. if ( ppunkOut == NULL )
  52. {
  53. hr = THR( E_POINTER );
  54. goto Cleanup;
  55. }
  56. panw = new CAddNodesWizard();
  57. if ( panw == NULL )
  58. {
  59. hr = THR( E_OUTOFMEMORY );
  60. goto Cleanup;
  61. }
  62. hr = THR( panw->HrInit() );
  63. if ( FAILED( hr ) )
  64. {
  65. goto Cleanup;
  66. }
  67. hr = THR( panw->TypeSafeQI( IUnknown, ppunkOut ) );
  68. if ( FAILED ( hr ) )
  69. {
  70. goto Cleanup;
  71. }
  72. Cleanup:
  73. if ( panw != NULL )
  74. {
  75. panw->Release();
  76. }
  77. HRETURN( hr );
  78. } //*** CAddNodesWizard::S_HrCreateInstance
  79. //////////////////////////////////////////////////////////////////////////////
  80. //++
  81. //
  82. // CAddNodesWizard::CAddNodesWizard
  83. //
  84. // Description:
  85. // Default constructor.
  86. //
  87. // Arguments:
  88. // None.
  89. //
  90. // Return Values:
  91. // None.
  92. //
  93. //--
  94. //////////////////////////////////////////////////////////////////////////////
  95. CAddNodesWizard::CAddNodesWizard( void )
  96. : m_pccw( NULL )
  97. , m_cRef( 1 )
  98. {
  99. } //*** CAddNodesWizard::CAddNodesWizard
  100. //////////////////////////////////////////////////////////////////////////////
  101. //++
  102. //
  103. // CAddNodesWizard::~CAddNodesWizard
  104. //
  105. // Description:
  106. // Destructor.
  107. //
  108. // Arguments:
  109. // None.
  110. //
  111. // Return Values:
  112. // None.
  113. //
  114. //--
  115. //////////////////////////////////////////////////////////////////////////////
  116. CAddNodesWizard::~CAddNodesWizard( void )
  117. {
  118. TraceFunc( "" );
  119. if ( m_pccw != NULL )
  120. {
  121. m_pccw->Release();
  122. }
  123. TraceFuncExit();
  124. } //*** CAddNodesWizard::~CAddNodesWizard
  125. //////////////////////////////////////////////////////////////////////////////
  126. //++
  127. //
  128. // CAddNodesWizard::HrInit
  129. //
  130. // Description:
  131. // Initialize the object instance.
  132. //
  133. // Arguments:
  134. // None.
  135. //
  136. // Return Values:
  137. // S_OK - Operation completed successfully.
  138. // Other HRESULTs.
  139. //
  140. //--
  141. //////////////////////////////////////////////////////////////////////////////
  142. HRESULT
  143. CAddNodesWizard::HrInit( void )
  144. {
  145. TraceFunc( "" );
  146. HRESULT hr = S_OK;
  147. //
  148. // Initialize the IDispatch handler to support the scripting interface.
  149. //
  150. hr = THR( TDispatchHandler< IClusCfgAddNodesWizard >::HrInit( LIBID_ClusCfgWizard ) );
  151. if ( FAILED ( hr ) )
  152. {
  153. goto Cleanup;
  154. }
  155. //
  156. // Create the wizard object.
  157. //
  158. hr = THR( CClusCfgWizard::S_HrCreateInstance( &m_pccw ) );
  159. if ( FAILED ( hr ) )
  160. {
  161. goto Cleanup;
  162. }
  163. Cleanup:
  164. HRETURN( hr );
  165. } //*** HRESULT CAddNodesWizard::HrInit
  166. //****************************************************************************
  167. //
  168. // IUnknown
  169. //
  170. //****************************************************************************
  171. //////////////////////////////////////////////////////////////////////////////
  172. //++
  173. //
  174. // CAddNodesWizard::QueryInterface
  175. //
  176. // Description:
  177. // Query this object for the passed in interface.
  178. //
  179. // Arguments:
  180. // riidIn
  181. // Id of interface requested.
  182. //
  183. // ppvOut
  184. // Pointer to the requested interface.
  185. //
  186. // Return Value:
  187. // S_OK
  188. // If the interface is available on this object.
  189. //
  190. // E_NOINTERFACE
  191. // If the interface is not available.
  192. //
  193. // E_POINTER
  194. // ppvOut was NULL.
  195. //
  196. // Remarks:
  197. // None.
  198. //
  199. //--
  200. //////////////////////////////////////////////////////////////////////////////
  201. STDMETHODIMP
  202. CAddNodesWizard::QueryInterface(
  203. REFIID riidIn
  204. , PVOID * ppvOut
  205. )
  206. {
  207. TraceQIFunc( riidIn, ppvOut );
  208. HRESULT hr = S_OK;
  209. //
  210. // Validate arguments.
  211. //
  212. Assert( ppvOut != NULL );
  213. if ( ppvOut == NULL )
  214. {
  215. hr = THR( E_POINTER );
  216. goto Cleanup;
  217. }
  218. //
  219. // Handle known interfaces.
  220. //
  221. if ( IsEqualIID( riidIn, IID_IUnknown ) )
  222. {
  223. *ppvOut = static_cast< IUnknown * >( this );
  224. } // if: IUnknown
  225. else if ( IsEqualIID( riidIn, IID_IClusCfgAddNodesWizard ) )
  226. {
  227. *ppvOut = TraceInterface( __THISCLASS__, IClusCfgAddNodesWizard, this, 0 );
  228. } // else if: IClusCfgAddNodesWizard
  229. else if ( IsEqualIID( riidIn, IID_IDispatch ) )
  230. {
  231. *ppvOut = TraceInterface( __THISCLASS__, IDispatch, this, 0 );
  232. } // else if: IDispatch
  233. else
  234. {
  235. *ppvOut = NULL;
  236. hr = E_NOINTERFACE;
  237. } // else
  238. //
  239. // Add a reference to the interface if successful.
  240. //
  241. if ( SUCCEEDED( hr ) )
  242. {
  243. ((IUnknown *) *ppvOut)->AddRef();
  244. } // if: success
  245. Cleanup:
  246. QIRETURN_IGNORESTDMARSHALLING( hr, riidIn );
  247. } //*** CAddNodesWizard::QueryInterface
  248. //////////////////////////////////////////////////////////////////////////////
  249. //++
  250. //
  251. // CAddNodesWizard::AddRef
  252. //
  253. // Description:
  254. // Add a reference to this instance.
  255. //
  256. // Arguments:
  257. // None.
  258. //
  259. // Return Values:
  260. // New reference count.
  261. //
  262. //--
  263. //////////////////////////////////////////////////////////////////////////////
  264. ULONG
  265. CAddNodesWizard::AddRef( void )
  266. {
  267. TraceFunc( "[IUnknown]" );
  268. InterlockedIncrement( &m_cRef );
  269. CRETURN( m_cRef );
  270. } //*** CAddNodesWizard::AddRef
  271. //////////////////////////////////////////////////////////////////////////////
  272. //++
  273. //
  274. // CAddNodesWizard::Release
  275. //
  276. // Description:
  277. // Release a reference to this instance. If it is the last reference
  278. // the object instance will be deallocated.
  279. //
  280. // Arguments:
  281. // None.
  282. //
  283. // Return Values:
  284. // New reference count.
  285. //
  286. //--
  287. //////////////////////////////////////////////////////////////////////////////
  288. ULONG
  289. CAddNodesWizard::Release( void )
  290. {
  291. TraceFunc( "[IUnknown]" );
  292. LONG cRef;
  293. cRef = InterlockedDecrement( &m_cRef );
  294. if ( cRef == 0 )
  295. {
  296. delete this;
  297. }
  298. CRETURN( cRef );
  299. } //*** CAddNodesWizard::Release
  300. //****************************************************************************
  301. //
  302. // IClusCfgAddNodesWizard
  303. //
  304. //****************************************************************************
  305. //////////////////////////////////////////////////////////////////////////////
  306. //++
  307. //
  308. // CAddNodesWizard::put_ClusterName
  309. //
  310. // Description:
  311. // Set the cluster name to add nodes to. If this is not empty, the
  312. // page asking the user to enter the cluster name will not be displayed.
  313. //
  314. // Arguments:
  315. // bstrClusterNameIn - The name of the cluster.
  316. //
  317. // Return Values:
  318. // S_OK - Operation completed successfully.
  319. // Other HRESULTs.
  320. //
  321. //--
  322. //////////////////////////////////////////////////////////////////////////////
  323. STDMETHODIMP
  324. CAddNodesWizard::put_ClusterName( BSTR bstrClusterNameIn )
  325. {
  326. TraceFunc( "[IClusCfgAddNodesWizard]" );
  327. HRESULT hr = THR( m_pccw->put_ClusterName( bstrClusterNameIn ) );
  328. HRETURN( hr );
  329. } //*** CAddNodesWizard::put_ClusterName
  330. //////////////////////////////////////////////////////////////////////////////
  331. //++
  332. //
  333. // CAddNodesWizard::get_ClusterName
  334. //
  335. // Description:
  336. // Return the name of the cluster to add nodes to. This will be either
  337. // the cluster name specified in a call to put_ClusterName or one entered
  338. // by the user.
  339. //
  340. // Arguments:
  341. // pbstrClusterNameOut - Cluster name used by the wizard.
  342. //
  343. // Return Values:
  344. // S_OK - Operation completed successfully.
  345. // Other HRESULTs.
  346. //
  347. //--
  348. //////////////////////////////////////////////////////////////////////////////
  349. STDMETHODIMP
  350. CAddNodesWizard::get_ClusterName( BSTR * pbstrClusterNameOut )
  351. {
  352. TraceFunc( "[IClusCfgAddNodesWizard]" );
  353. HRESULT hr = THR( m_pccw->get_ClusterName( pbstrClusterNameOut ) );
  354. HRETURN( hr );
  355. } //*** CAddNodesWizard::get_ClusterName
  356. //////////////////////////////////////////////////////////////////////////////
  357. //++
  358. //
  359. // CAddNodesWizard::put_ServiceAccountPassword
  360. //
  361. // Description:
  362. // Set the cluster service account password.
  363. //
  364. // Arguments:
  365. // bstrPasswordIn - Cluster service account password.
  366. //
  367. // Return Values:
  368. // S_OK - Operation completed successfully.
  369. // Other HRESULTs.
  370. //
  371. //--
  372. //////////////////////////////////////////////////////////////////////////////
  373. STDMETHODIMP
  374. CAddNodesWizard::put_ServiceAccountPassword( BSTR bstrPasswordIn )
  375. {
  376. TraceFunc( "[IClusCfgAddNodesWizard]" );
  377. HRESULT hr = THR( m_pccw->put_ServiceAccountPassword( bstrPasswordIn ) );
  378. HRETURN( hr );
  379. } //*** CAddNodesWizard::put_ServiceAccountPassword
  380. //////////////////////////////////////////////////////////////////////////////
  381. //++
  382. //
  383. // CAddNodesWizard::put_MinimumConfiguration
  384. //
  385. // Description:
  386. // Specify whether the wizard should operate in full or minimum
  387. // configuration mode.
  388. //
  389. // Arguments:
  390. // fMinConfigIn
  391. // VARIANT_TRUE - Put wizard in Minimum Configuration mode.
  392. // VARIANT_FALSE - Put wizard in Full Configuration mode.
  393. //
  394. // Return Values:
  395. // S_OK - Operation completed successfully.
  396. // Other HRESULTs.
  397. //
  398. //--
  399. //////////////////////////////////////////////////////////////////////////////
  400. STDMETHODIMP
  401. CAddNodesWizard::put_MinimumConfiguration( VARIANT_BOOL fMinConfigIn )
  402. {
  403. TraceFunc( "[IClusCfgAddNodesWizard]" );
  404. HRESULT hr = S_OK;
  405. BOOL fMinConfig = ( fMinConfigIn == VARIANT_TRUE? TRUE: FALSE );
  406. hr = THR( m_pccw->put_MinimumConfiguration( fMinConfig ) );
  407. HRETURN( hr );
  408. } //*** CAddNodesWizard::put_MinimumConfiguration
  409. //////////////////////////////////////////////////////////////////////////////
  410. //++
  411. //
  412. // CAddNodesWizard::get_MinimumConfiguration
  413. //
  414. // Description:
  415. // Get the current configuration mode of the wizard.
  416. //
  417. // Arguments:
  418. // pfMinConfigOut
  419. // Configuration mode of the wizard:
  420. // VARIANT_TRUE - Minimum Configuration mode.
  421. // VARIANT_FALSE - Full Configuration mode.
  422. // This value could have been set either by a call to the
  423. // put_MinimumConfiguration method or by the user in the wizard.
  424. //
  425. // Return Values:
  426. // S_OK - Operation completed successfully.
  427. // Other HRESULTs.
  428. //
  429. //--
  430. //////////////////////////////////////////////////////////////////////////////
  431. STDMETHODIMP
  432. CAddNodesWizard::get_MinimumConfiguration( VARIANT_BOOL * pfMinConfigOut )
  433. {
  434. TraceFunc( "[IClusCfgAddNodesWizard]" );
  435. HRESULT hr = S_OK;
  436. BOOL fMinConfig = FALSE;
  437. if ( pfMinConfigOut == NULL )
  438. {
  439. hr = THR( E_POINTER );
  440. goto Cleanup;
  441. }
  442. hr = THR( m_pccw->get_MinimumConfiguration( &fMinConfig ) );
  443. if ( FAILED( hr ) )
  444. {
  445. goto Cleanup;
  446. }
  447. *pfMinConfigOut = ( fMinConfig? VARIANT_TRUE: VARIANT_FALSE );
  448. Cleanup:
  449. HRETURN( hr );
  450. } //*** CAddNodesWizard::put_MinimumConfiguration
  451. //////////////////////////////////////////////////////////////////////////////
  452. //++
  453. //
  454. // CAddNodesWizard::AddNodeToList
  455. //
  456. // Description:
  457. // Add a node to the list of nodes to be added to the cluster.
  458. //
  459. // Arguments:
  460. // bstrNodeNameIn - Node to be added to the cluster.
  461. //
  462. // Return Values:
  463. // S_OK - Operation completed successfully.
  464. // Other HRESULTs.
  465. //
  466. //--
  467. //////////////////////////////////////////////////////////////////////////////
  468. STDMETHODIMP
  469. CAddNodesWizard::AddNodeToList( BSTR bstrNodeNameIn )
  470. {
  471. TraceFunc( "[IClusCfgAddNodesWizard]" );
  472. HRESULT hr = THR( m_pccw->AddComputer( bstrNodeNameIn ) );
  473. HRETURN( hr );
  474. } //*** CAddNodesWizard::AddNodeToList
  475. //////////////////////////////////////////////////////////////////////////////
  476. //++
  477. //
  478. // CAddNodesWizard::RemoveNodeFromList
  479. //
  480. // Description:
  481. // Remove a node from the list of nodes to be added to the cluster.
  482. //
  483. // Arguments:
  484. // bstrNodeNameIn - Node to be removed from the list.
  485. //
  486. // Return Values:
  487. // S_OK - Operation completed successfully.
  488. // Other HRESULTs.
  489. //
  490. //--
  491. //////////////////////////////////////////////////////////////////////////////
  492. STDMETHODIMP
  493. CAddNodesWizard::RemoveNodeFromList( BSTR bstrNodeNameIn )
  494. {
  495. TraceFunc( "[IClusCfgAddNodesWizard]" );
  496. HRESULT hr = THR( m_pccw->RemoveComputer( bstrNodeNameIn ) );
  497. HRETURN( hr );
  498. } //*** CAddNodesWizard::RemoveNodeFromList
  499. //////////////////////////////////////////////////////////////////////////////
  500. //++
  501. //
  502. // CAddNodesWizard::ClearNodeList
  503. //
  504. // Description:
  505. // Remove all entries from the list of nodes to be added to the cluster.
  506. //
  507. // Arguments:
  508. // None.
  509. //
  510. // Return Values:
  511. // S_OK - Operation completed successfully.
  512. // Other HRESULTs.
  513. //
  514. //--
  515. //////////////////////////////////////////////////////////////////////////////
  516. STDMETHODIMP
  517. CAddNodesWizard::ClearNodeList( void )
  518. {
  519. TraceFunc( "[IClusCfgAddNodesWizard]" );
  520. HRESULT hr = THR( m_pccw->ClearComputerList() );
  521. HRETURN( hr );
  522. } //*** CAddNodesWizard::ClearNodeList
  523. //////////////////////////////////////////////////////////////////////////////
  524. //++
  525. //
  526. // CAddNodesWizard::ShowWizard
  527. //
  528. // Description:
  529. // Show the wizard.
  530. //
  531. // Arguments:
  532. // lParentWindowHandleIn
  533. // The parent window handle represented as a LONG value.
  534. //
  535. // pfCompletedOut
  536. // Return status of the wizard operation itself:
  537. // VARIANT_TRUE - Wizard was completed.
  538. // VARIANT_FALSE - Wizard was cancelled.
  539. //
  540. // Return Values:
  541. // S_OK - Operation completed successfully.
  542. // Other HRESULTs.
  543. //
  544. //--
  545. //////////////////////////////////////////////////////////////////////////////
  546. STDMETHODIMP
  547. CAddNodesWizard::ShowWizard(
  548. long lParentWindowHandleIn
  549. , VARIANT_BOOL * pfCompletedOut
  550. )
  551. {
  552. TraceFunc( "[IClusCfgAddNodesWizard]" );
  553. HRESULT hr = S_OK;
  554. BOOL fCompleted = FALSE;
  555. HWND hwndParent = reinterpret_cast< HWND >( LongToHandle( lParentWindowHandleIn ) );
  556. if ( ( hwndParent != NULL ) && ( IsWindow( hwndParent ) == FALSE ) )
  557. {
  558. hr = THR( E_INVALIDARG );
  559. goto Cleanup;
  560. }
  561. hr = THR( m_pccw->AddClusterNodes( hwndParent, &fCompleted ) );
  562. if ( FAILED( hr ) )
  563. {
  564. goto Cleanup;
  565. }
  566. if ( pfCompletedOut != NULL )
  567. {
  568. *pfCompletedOut = ( fCompleted? VARIANT_TRUE: VARIANT_FALSE );
  569. }
  570. Cleanup:
  571. HRETURN( hr );
  572. } //*** CAddNodesWizard::ShowWizard