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.

1209 lines
30 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000-2002 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // CommitPage.cpp
  7. //
  8. // Maintained By:
  9. // Galen Barbee (GalenB) 12-MAY-2000
  10. //
  11. //////////////////////////////////////////////////////////////////////////////
  12. #include "Pch.h"
  13. #include "TaskTreeView.h"
  14. #include "CommitPage.h"
  15. #include "WizardUtils.h"
  16. DEFINE_THISCLASS( "CCommitPage" );
  17. //
  18. // Special CLSID_Type for completion cookie.
  19. //
  20. #include <initguid.h>
  21. // {FC4D0128-7BAB-4c76-9C38-E3C042F15822}
  22. DEFINE_GUID( CLSID_CommitTaskCompletionCookieType,
  23. 0xfc4d0128, 0x7bab, 0x4c76, 0x9c, 0x38, 0xe3, 0xc0, 0x42, 0xf1, 0x58, 0x22);
  24. //////////////////////////////////////////////////////////////////////////////
  25. //++
  26. //
  27. // CCommitPage::CCommitPage(
  28. // CClusCfgWizard * pccwIn,
  29. // ECreateAddMode ecamCreateAddModeIn
  30. // )
  31. //
  32. //--
  33. //////////////////////////////////////////////////////////////////////////////
  34. CCommitPage::CCommitPage(
  35. CClusCfgWizard * pccwIn
  36. , ECreateAddMode ecamCreateAddModeIn
  37. )
  38. {
  39. TraceFunc( "" );
  40. Assert( pccwIn != NULL );
  41. m_hwnd = NULL;
  42. pccwIn->AddRef();
  43. m_pccw = pccwIn;
  44. m_fNext = FALSE;
  45. m_fDisableBack = FALSE;
  46. m_fAborted = FALSE;
  47. m_fPassedPointOfNoReturn = FALSE;
  48. m_ecamCreateAddMode = ecamCreateAddModeIn;
  49. m_htiReanalyze = NULL;
  50. m_rgfSubReanalyzeAdded[ 0 ] = FALSE;
  51. m_rgfSubReanalyzeAdded[ 1 ] = FALSE;
  52. m_rgfSubReanalyzeAdded[ 2 ] = FALSE;
  53. m_rgfSubReanalyzeAdded[ 3 ] = FALSE;
  54. m_rgfSubReanalyzeAdded[ 4 ] = FALSE;
  55. m_ptccc = NULL;
  56. m_cRef = 0;
  57. m_cookieCompletion = NULL;
  58. // m_fTaskDone
  59. // m_hrResult
  60. m_pttv = NULL;
  61. m_bstrLogMsg = NULL;
  62. m_dwCookieCallback = 0;
  63. m_dwCookieNotify = 0;
  64. TraceFuncExit();
  65. } //*** CCommitPage::CCommitPage
  66. //////////////////////////////////////////////////////////////////////////////
  67. //++
  68. //
  69. // CCommitPage::~CCommitPage( void )
  70. //
  71. //--
  72. //////////////////////////////////////////////////////////////////////////////
  73. CCommitPage::~CCommitPage( void )
  74. {
  75. TraceFunc( "" );
  76. THR( HrCleanupCommit() );
  77. if ( m_pccw != NULL )
  78. {
  79. m_pccw->Release();
  80. }
  81. //
  82. // Unregister UI notification (if needed)
  83. //
  84. THR( HrUnAdviseConnections() );
  85. if ( m_pttv != NULL )
  86. {
  87. delete m_pttv;
  88. } // if:
  89. TraceSysFreeString( m_bstrLogMsg );
  90. Assert( m_cRef == 0 );
  91. TraceFuncExit();
  92. } //*** CCommitPage::~CCommitPage
  93. //////////////////////////////////////////////////////////////////////////////
  94. //++
  95. //
  96. // LRESULT
  97. // CCommitPage::OnInitDialog( void )
  98. //
  99. //--
  100. //////////////////////////////////////////////////////////////////////////////
  101. LRESULT
  102. CCommitPage::OnInitDialog( void )
  103. {
  104. TraceFunc( "" );
  105. LRESULT lr = FALSE; // didn't set focus
  106. size_t cNodes = 0;
  107. size_t cInitialTickCount = 400;
  108. HRESULT hr = S_OK;
  109. //
  110. // Get the node count to get a rough approximation of the initial tick count
  111. // for the TaskTreeView.
  112. //
  113. hr = THR( m_pccw->HrGetNodeCount( &cNodes ) );
  114. if ( FAILED( hr ) )
  115. {
  116. cNodes = 1;
  117. }
  118. // Numbers based on bulk-add testing.
  119. cInitialTickCount = 120 + ( 280 * cNodes );
  120. //
  121. // Initialize the tree view
  122. //
  123. m_pttv = new CTaskTreeView( m_hwnd, IDC_COMMIT_TV_TASKS, IDC_COMMIT_PRG_STATUS, IDC_COMMIT_S_STATUS, cInitialTickCount );
  124. if ( m_pttv == NULL )
  125. {
  126. goto OutOfMemory;
  127. }
  128. THR( m_pttv->HrOnInitDialog() );
  129. Cleanup:
  130. RETURN( lr );
  131. OutOfMemory:
  132. goto Cleanup;
  133. } //*** CCommitPage::OnInitDialog
  134. //////////////////////////////////////////////////////////////////////////////
  135. //++
  136. //
  137. // LRESULT
  138. // CCommitPage::OnCommand(
  139. // UINT idNotificationIn,
  140. // UINT idControlIn,
  141. // HWND hwndSenderIn
  142. // )
  143. //
  144. //--
  145. //////////////////////////////////////////////////////////////////////////////
  146. LRESULT
  147. CCommitPage::OnCommand(
  148. UINT idNotificationIn,
  149. UINT idControlIn,
  150. HWND hwndSenderIn
  151. )
  152. {
  153. TraceFunc( "" );
  154. LRESULT lr = FALSE;
  155. switch ( idControlIn )
  156. {
  157. case IDC_COMMIT_PB_VIEW_LOG:
  158. if ( idNotificationIn == BN_CLICKED )
  159. {
  160. THR( HrViewLogFile( m_hwnd ) );
  161. lr = TRUE;
  162. } // if: button click
  163. break;
  164. case IDC_COMMIT_PB_DETAILS:
  165. if ( idNotificationIn == BN_CLICKED )
  166. {
  167. Assert( m_pttv != NULL );
  168. THR( m_pttv->HrDisplayDetails() );
  169. lr = TRUE;
  170. }
  171. break;
  172. case IDC_COMMIT_PB_RETRY:
  173. if ( idNotificationIn == BN_CLICKED )
  174. {
  175. THR( HrCleanupCommit() );
  176. OnNotifySetActive();
  177. lr = TRUE;
  178. }
  179. break;
  180. } // switch: idControlIn
  181. RETURN( lr );
  182. } //*** CCommitPage::OnCommand
  183. //////////////////////////////////////////////////////////////////////////////
  184. //++
  185. //
  186. // HRESULT
  187. // CCommitPage::HrUpdateWizardButtons( void )
  188. //
  189. //--
  190. //////////////////////////////////////////////////////////////////////////////
  191. HRESULT
  192. CCommitPage::HrUpdateWizardButtons( void )
  193. {
  194. TraceFunc( "" );
  195. HRESULT hr = S_OK;
  196. DWORD dwFlags = 0;
  197. BOOL fEnableRetry = FALSE;
  198. BOOL fEnableCancel = FALSE;
  199. if ( m_fDisableBack == FALSE )
  200. {
  201. dwFlags = PSWIZB_BACK;
  202. }
  203. if ( m_fTaskDone == TRUE )
  204. {
  205. //
  206. // The retry, cancel, and back buttons can only be enabled if we
  207. // haven't passed the point of no return.
  208. //
  209. if ( FAILED( m_hrResult )
  210. && ( m_fPassedPointOfNoReturn == FALSE )
  211. )
  212. {
  213. fEnableRetry = TRUE;
  214. fEnableCancel = TRUE;
  215. dwFlags |= PSWIZB_BACK;
  216. }
  217. else
  218. {
  219. dwFlags |= PSWIZB_NEXT;
  220. }
  221. } // if: commit task has completed
  222. else
  223. {
  224. //
  225. // Disable the back button if task is not completed yet
  226. //
  227. dwFlags &= ~PSWIZB_BACK;
  228. fEnableCancel = FALSE;
  229. } // else: commit task has not completed
  230. PropSheet_SetWizButtons( GetParent( m_hwnd ), dwFlags );
  231. EnableWindow( GetDlgItem( GetParent( m_hwnd ), IDCANCEL ), fEnableCancel );
  232. EnableWindow( GetDlgItem( m_hwnd, IDC_COMMIT_PB_RETRY ), fEnableRetry );
  233. HRETURN( hr );
  234. } //*** CCommitPage::HrUpdateWizardButtons
  235. //////////////////////////////////////////////////////////////////////////////
  236. //++
  237. //
  238. // LRESULT
  239. // CCommitPage::OnNotifyQueryCancel( void )
  240. //
  241. //--
  242. //////////////////////////////////////////////////////////////////////////////
  243. LRESULT
  244. CCommitPage::OnNotifyQueryCancel( void )
  245. {
  246. TraceFunc( "" );
  247. LONG_PTR lptrCancelState = FALSE; // allow cancel
  248. if ( m_fTaskDone == FALSE )
  249. {
  250. lptrCancelState = TRUE; // do not allow cancel
  251. } // if:
  252. else
  253. {
  254. int iRet;
  255. iRet = MessageBoxFromStrings( m_hwnd, IDS_QUERY_CANCEL_TITLE, IDS_QUERY_CANCEL_TEXT, MB_YESNO );
  256. if ( iRet == IDNO )
  257. {
  258. lptrCancelState = TRUE; // do not allow cancel
  259. }
  260. else
  261. {
  262. THR( m_pccw->HrLaunchCleanupTask() );
  263. m_fAborted = TRUE;
  264. } // else:
  265. } // else:
  266. SetWindowLongPtr( m_hwnd, DWLP_MSGRESULT, lptrCancelState );
  267. RETURN( TRUE ); // this must return TRUE!
  268. } //*** CCommitPage::OnNotifyQueryCancel
  269. //////////////////////////////////////////////////////////////////////////////
  270. //++
  271. //
  272. // LRESULT
  273. // CCommitPage::OnNotifySetActive( void )
  274. //
  275. //--
  276. //////////////////////////////////////////////////////////////////////////////
  277. LRESULT
  278. CCommitPage::OnNotifySetActive( void )
  279. {
  280. TraceFunc( "" );
  281. HRESULT hr = S_OK;
  282. OBJECTCOOKIE cookieCluster = 0;
  283. LRESULT lr = TRUE;
  284. IUnknown * punkTask = NULL;
  285. if ( m_fNext )
  286. {
  287. m_fNext = FALSE;
  288. hr = THR( HrUpdateWizardButtons() );
  289. goto Cleanup;
  290. }
  291. //
  292. // Make sure things were cleaned up from the last commit.
  293. //
  294. m_hrResult = S_OK;
  295. m_fAborted = FALSE;
  296. LogMsg( L"[WIZ] Setting commit page active. Setting aborted to FALSE." );
  297. Assert( m_dwCookieNotify == 0 );
  298. Assert( m_cookieCompletion == NULL );
  299. //
  300. // Reset the progress bar's color.
  301. //
  302. SendDlgItemMessage( m_hwnd, IDC_COMMIT_PRG_STATUS, PBM_SETBARCOLOR, 0, RGB( 0, 0, 0x80 ) );
  303. //
  304. // Clear the tree view and status line. Disable the retry button.
  305. //
  306. Assert( m_pttv != NULL );
  307. hr = THR( m_pttv->HrOnNotifySetActive() );
  308. if ( FAILED ( hr ) )
  309. {
  310. goto Cleanup;
  311. }
  312. //
  313. // Add the major root task nodes.
  314. // (Minor reanalyze tasks are added dynamically.)
  315. //
  316. hr = THR( m_pttv->HrAddTreeViewItem(
  317. &m_htiReanalyze
  318. , IDS_TASKID_MAJOR_REANALYZE
  319. , TASKID_Major_Reanalyze
  320. , IID_NULL
  321. , TVI_ROOT
  322. , TRUE // fParentToAllNodeTasksIn
  323. ) );
  324. if ( FAILED( hr ) )
  325. {
  326. goto Cleanup;
  327. }
  328. hr = THR( m_pttv->HrAddTreeViewRootItem(
  329. IDS_TASKID_MAJOR_CONFIGURE_CLUSTER_SERVICES
  330. , TASKID_Major_Configure_Cluster_Services
  331. ) );
  332. if ( FAILED( hr ) )
  333. {
  334. goto Cleanup;
  335. }
  336. hr = THR( m_pttv->HrAddTreeViewRootItem(
  337. IDS_TASKID_MAJOR_CONFIGURE_RESOURCE_TYPES
  338. , TASKID_Major_Configure_Resource_Types
  339. ) );
  340. if ( FAILED( hr ) )
  341. {
  342. goto Cleanup;
  343. }
  344. hr = THR( m_pttv->HrAddTreeViewRootItem(
  345. IDS_TASKID_MAJOR_CONFIGURE_RESOURCES
  346. , TASKID_Major_Configure_Resources
  347. ) );
  348. if ( FAILED( hr ) )
  349. {
  350. goto Cleanup;
  351. }
  352. //
  353. // Find the cluster cookie.
  354. //
  355. hr = THR( m_pccw->HrGetClusterCookie( &cookieCluster ) );
  356. if ( FAILED( hr ) )
  357. {
  358. goto Cleanup;
  359. }
  360. //
  361. // Create a completion cookie.
  362. //
  363. // Don't wrap - this can fail with E_PENDING
  364. hr = m_pccw->HrGetCompletionCookie( CLSID_CommitTaskCompletionCookieType, &m_cookieCompletion );
  365. if ( hr == E_PENDING )
  366. {
  367. // no-op.
  368. }
  369. else if ( FAILED( hr ) )
  370. {
  371. THR( hr );
  372. goto Cleanup;
  373. }
  374. //
  375. // Register to get UI notification (if needed)
  376. //
  377. if ( m_dwCookieNotify == 0 )
  378. {
  379. hr = THR( m_pccw->HrAdvise( IID_INotifyUI, static_cast< INotifyUI* >( this ), &m_dwCookieNotify ) );
  380. if ( FAILED( hr ) )
  381. {
  382. goto Cleanup;
  383. }
  384. }
  385. if ( m_dwCookieCallback == 0 )
  386. {
  387. hr = THR( m_pccw->HrAdvise( IID_IClusCfgCallback, static_cast< IClusCfgCallback* >( this ), &m_dwCookieCallback ) );
  388. if ( FAILED( hr ) )
  389. {
  390. goto Cleanup;
  391. }
  392. }
  393. //
  394. // Create a new analyze task.
  395. //
  396. hr = THR( m_pccw->HrCreateTask( TASK_CommitClusterChanges, &punkTask ) );
  397. if ( FAILED( hr ) )
  398. {
  399. goto Cleanup;
  400. }
  401. hr = THR( punkTask->TypeSafeQI( ITaskCommitClusterChanges, &m_ptccc ) );
  402. if ( FAILED( hr ) )
  403. {
  404. goto Cleanup;
  405. }
  406. hr = THR( m_ptccc->SetClusterCookie( cookieCluster ) );
  407. if ( FAILED( hr ) )
  408. {
  409. goto Cleanup;
  410. }
  411. hr = THR( m_ptccc->SetCookie( m_cookieCompletion ) );
  412. if ( FAILED( hr ) )
  413. {
  414. goto Cleanup;
  415. }
  416. m_fTaskDone = FALSE; // reset before commiting task
  417. hr = THR( m_pccw->HrSubmitTask( m_ptccc ) );
  418. if ( FAILED( hr ) )
  419. {
  420. goto Cleanup;
  421. }
  422. hr = THR( HrUpdateWizardButtons() );
  423. if ( FAILED( hr ) )
  424. {
  425. goto Cleanup;
  426. }
  427. Cleanup:
  428. if ( punkTask != NULL )
  429. {
  430. punkTask->Release();
  431. }
  432. RETURN( lr );
  433. } //*** CCommitPage::OnNotifySetActive
  434. //////////////////////////////////////////////////////////////////////////////
  435. //++
  436. //
  437. // LRESULT
  438. // CCommitPage::OnNotifyWizBack( void )
  439. //
  440. //--
  441. //////////////////////////////////////////////////////////////////////////////
  442. LRESULT
  443. CCommitPage::OnNotifyWizBack( void )
  444. {
  445. TraceFunc( "" );
  446. LRESULT lr = TRUE;
  447. m_fAborted = TRUE;
  448. LogMsg( L"[WIZ] Back button pressed on the commit page. Setting aborted to TRUE." );
  449. THR( HrCleanupCommit() );
  450. RETURN( lr );
  451. } //*** CCommitPage::OnNotifyWizBack
  452. //////////////////////////////////////////////////////////////////////////////
  453. //++
  454. //
  455. // LRESULT
  456. // CCommitPage::OnNotifyWizNext( void )
  457. //
  458. //--
  459. //////////////////////////////////////////////////////////////////////////////
  460. LRESULT
  461. CCommitPage::OnNotifyWizNext( void )
  462. {
  463. TraceFunc( "" );
  464. LRESULT lr = TRUE;
  465. RETURN( lr );
  466. } //*** CCommitPage::OnNotifyWizNext
  467. //////////////////////////////////////////////////////////////////////////////
  468. //++
  469. //
  470. // LRESULT
  471. // CCommitPage::OnNotify(
  472. // WPARAM idCtrlIn,
  473. // LPNMHDR pnmhdrIn
  474. // )
  475. //
  476. //--
  477. //////////////////////////////////////////////////////////////////////////////
  478. LRESULT
  479. CCommitPage::OnNotify(
  480. WPARAM idCtrlIn,
  481. LPNMHDR pnmhdrIn
  482. )
  483. {
  484. TraceFunc( "" );
  485. LRESULT lr = TRUE;
  486. SetWindowLongPtr( m_hwnd, DWLP_MSGRESULT, 0 );
  487. switch( pnmhdrIn->code )
  488. {
  489. case PSN_SETACTIVE:
  490. lr = OnNotifySetActive();
  491. break;
  492. case PSN_WIZNEXT:
  493. lr = OnNotifyWizNext();
  494. break;
  495. case PSN_WIZBACK:
  496. lr = OnNotifyWizBack();
  497. break;
  498. case PSN_QUERYCANCEL:
  499. lr = OnNotifyQueryCancel();
  500. break;
  501. default:
  502. if ( ( idCtrlIn == IDC_COMMIT_TV_TASKS )
  503. && ( m_pttv != NULL ) )
  504. {
  505. // Pass the notification on to the tree control.
  506. lr = m_pttv->OnNotify( pnmhdrIn );
  507. }
  508. break;
  509. } // switch: notify code
  510. RETURN( lr );
  511. } //*** CCommitPage::OnNotify
  512. //////////////////////////////////////////////////////////////////////////////
  513. //++
  514. //
  515. // INT_PTR
  516. // CALLBACK
  517. // CCommitPage::S_DlgProc(
  518. // HWND hwndDlgIn,
  519. // UINT nMsgIn,
  520. // WPARAM wParam,
  521. // LPARAM lParam
  522. // )
  523. //
  524. //--
  525. //////////////////////////////////////////////////////////////////////////////
  526. INT_PTR
  527. CALLBACK
  528. CCommitPage::S_DlgProc(
  529. HWND hwndDlgIn,
  530. UINT nMsgIn,
  531. WPARAM wParam,
  532. LPARAM lParam
  533. )
  534. {
  535. // Don't do TraceFunc because every mouse movement
  536. // will cause this function to be called.
  537. WndMsg( hwndDlgIn, nMsgIn, wParam, lParam );
  538. LRESULT lr = FALSE;
  539. CCommitPage * pPage = reinterpret_cast< CCommitPage * >( GetWindowLongPtr( hwndDlgIn, GWLP_USERDATA ) );
  540. if ( nMsgIn == WM_INITDIALOG )
  541. {
  542. PROPSHEETPAGE * ppage = reinterpret_cast< PROPSHEETPAGE * >( lParam );
  543. SetWindowLongPtr( hwndDlgIn, GWLP_USERDATA, (LPARAM) ppage->lParam );
  544. pPage = reinterpret_cast< CCommitPage * >( ppage->lParam );
  545. pPage->m_hwnd = hwndDlgIn;
  546. }
  547. if ( pPage != NULL )
  548. {
  549. Assert( hwndDlgIn == pPage->m_hwnd );
  550. switch( nMsgIn )
  551. {
  552. case WM_INITDIALOG:
  553. lr = pPage->OnInitDialog();
  554. break;
  555. case WM_NOTIFY:
  556. lr = pPage->OnNotify( wParam, reinterpret_cast< LPNMHDR >( lParam ) );
  557. break;
  558. case WM_COMMAND:
  559. lr = pPage->OnCommand( HIWORD( wParam ), LOWORD( wParam ), reinterpret_cast< HWND >( lParam ) );
  560. break;
  561. // No default clause needed
  562. } // switch: nMsgIn
  563. } // if: page is specified
  564. return lr;
  565. } //*** CCommitPage::S_DlgProc
  566. // ************************************************************************
  567. //
  568. // IUnknown
  569. //
  570. // ************************************************************************
  571. //////////////////////////////////////////////////////////////////////////////
  572. //++
  573. //
  574. // CCommitPage::QueryInterface
  575. //
  576. // Description:
  577. // Query this object for the passed in interface.
  578. //
  579. // Arguments:
  580. // riidIn
  581. // Id of interface requested.
  582. //
  583. // ppvOut
  584. // Pointer to the requested interface.
  585. //
  586. // Return Value:
  587. // S_OK
  588. // If the interface is available on this object.
  589. //
  590. // E_NOINTERFACE
  591. // If the interface is not available.
  592. //
  593. // E_POINTER
  594. // ppvOut was NULL.
  595. //
  596. // Remarks:
  597. // None.
  598. //
  599. //--
  600. //////////////////////////////////////////////////////////////////////////////
  601. STDMETHODIMP
  602. CCommitPage::QueryInterface(
  603. REFIID riidIn
  604. , LPVOID * ppvOut
  605. )
  606. {
  607. TraceQIFunc( riidIn, ppvOut );
  608. HRESULT hr = S_OK;
  609. //
  610. // Validate arguments.
  611. //
  612. Assert( ppvOut != NULL );
  613. if ( ppvOut == NULL )
  614. {
  615. hr = THR( E_POINTER );
  616. goto Cleanup;
  617. }
  618. //
  619. // Handle known interfaces.
  620. //
  621. if ( IsEqualIID( riidIn, IID_IUnknown ) )
  622. {
  623. *ppvOut = static_cast< INotifyUI * >( this );
  624. } // if: IUnknown
  625. else if ( IsEqualIID( riidIn, IID_INotifyUI ) )
  626. {
  627. *ppvOut = TraceInterface( __THISCLASS__, INotifyUI, this, 0 );
  628. } // else if: INotifyUI
  629. else if ( IsEqualIID( riidIn, IID_IClusCfgCallback ) )
  630. {
  631. *ppvOut = TraceInterface( __THISCLASS__, IClusCfgCallback, this, 0 );
  632. } // else if: IClusCfgCallback
  633. else
  634. {
  635. *ppvOut = NULL;
  636. hr = E_NOINTERFACE;
  637. } // else
  638. //
  639. // Add a reference to the interface if successful.
  640. //
  641. if ( SUCCEEDED( hr ) )
  642. {
  643. ((IUnknown *) *ppvOut)->AddRef();
  644. } // if: success
  645. Cleanup:
  646. QIRETURN_IGNORESTDMARSHALLING( hr, riidIn );
  647. } //*** CCommitPage::QueryInterface
  648. //////////////////////////////////////////////////////////////////////////////
  649. //++
  650. //
  651. // STDMETHODIMP_( ULONG )
  652. // CCommitPage::AddRef
  653. //
  654. //--
  655. //////////////////////////////////////////////////////////////////////////////
  656. STDMETHODIMP_( ULONG )
  657. CCommitPage::AddRef( void )
  658. {
  659. TraceFunc( "[IUnknown]" );
  660. InterlockedIncrement( &m_cRef );
  661. CRETURN( m_cRef );
  662. } //*** CCommitPage::AddRef
  663. //////////////////////////////////////////////////////////////////////////////
  664. //++
  665. //
  666. // STDMETHODIMP_( ULONG )
  667. // CCommitPage::Release
  668. //
  669. //--
  670. //////////////////////////////////////////////////////////////////////////////
  671. STDMETHODIMP_( ULONG )
  672. CCommitPage::Release( void )
  673. {
  674. TraceFunc( "[IUnknown]" );
  675. LONG cRef;
  676. cRef = InterlockedDecrement( &m_cRef );
  677. if ( cRef == 0 )
  678. {
  679. // Do nothing -- COM interface does not control object lifetime
  680. }
  681. CRETURN( cRef );
  682. } //*** CCommitPage::Release
  683. //****************************************************************************
  684. //
  685. // INotifyUI
  686. //
  687. //****************************************************************************
  688. //////////////////////////////////////////////////////////////////////////////
  689. //++
  690. //
  691. // STDMETHODIMP
  692. // CCommitPage::ObjectChanged(
  693. // OBJECTCOOKIE cookieIn
  694. // )
  695. //
  696. //--
  697. //////////////////////////////////////////////////////////////////////////////
  698. STDMETHODIMP
  699. CCommitPage::ObjectChanged(
  700. OBJECTCOOKIE cookieIn
  701. )
  702. {
  703. TraceFunc( "[INotifyUI]" );
  704. HRESULT hr = S_OK;
  705. BSTR bstrDescription = NULL;
  706. if ( cookieIn == m_cookieCompletion )
  707. {
  708. hr = THR( m_pccw->HrGetCompletionStatus( m_cookieCompletion, &m_hrResult ) );
  709. if ( FAILED( hr ) )
  710. {
  711. goto Cleanup;
  712. }
  713. hr = THR( m_pttv->HrShowStatusAsDone() );
  714. if ( FAILED( hr ) )
  715. {
  716. goto Cleanup;
  717. }
  718. // [GorN] added m_fPassedPointOfNoReturn as
  719. // a fix for bug#546011
  720. if ( SUCCEEDED( m_hrResult ) || m_fPassedPointOfNoReturn )
  721. {
  722. hr = THR( HrLoadStringIntoBSTR( g_hInstance,
  723. IDS_COMMIT_SUCCESSFUL_INSTRUCTIONS,
  724. &bstrDescription
  725. ) );
  726. SendDlgItemMessage( m_hwnd, IDC_COMMIT_PRG_STATUS, PBM_SETBARCOLOR, 0, RGB( 0, 0x80, 0 ) );
  727. }
  728. else
  729. {
  730. if ( !m_fDisableBack )
  731. {
  732. hr = THR( HrLoadStringIntoBSTR( g_hInstance,
  733. IDS_COMMIT_FAILED_INSTRUCTIONS_BACK_ENABLED,
  734. &bstrDescription
  735. ) );
  736. }
  737. else
  738. {
  739. hr = THR( HrLoadStringIntoBSTR( g_hInstance,
  740. IDS_COMMIT_FAILED_INSTRUCTIONS,
  741. &bstrDescription
  742. ) );
  743. }
  744. SendDlgItemMessage( m_hwnd, IDC_COMMIT_PRG_STATUS, PBM_SETBARCOLOR, 0, RGB( 0x80, 0, 0 ) );
  745. }
  746. SetDlgItemText( m_hwnd, IDC_COMMIT_S_RESULTS, bstrDescription );
  747. m_fTaskDone = TRUE;
  748. THR( m_pccw->HrReleaseCompletionObject( m_cookieCompletion ) );
  749. // Don't care if it fails.
  750. m_cookieCompletion = NULL;
  751. THR( HrUpdateWizardButtons() );
  752. hr = THR( m_pccw->HrUnadvise( IID_IClusCfgCallback, m_dwCookieCallback ) );
  753. if ( FAILED( hr ) )
  754. {
  755. goto Cleanup;
  756. }
  757. m_dwCookieCallback = 0;
  758. } // if: received the completion cookie
  759. Cleanup:
  760. TraceSysFreeString( bstrDescription );
  761. HRETURN( hr );
  762. } //*** CCommitPage::ObjectChanged
  763. //****************************************************************************
  764. //
  765. // IClusCfgCallback
  766. //
  767. //****************************************************************************
  768. //////////////////////////////////////////////////////////////////////////////
  769. //++
  770. //
  771. // STDMETHODIMP
  772. // CCommitPage::SendStatusReport(
  773. // LPCWSTR pcszNodeNameIn
  774. // , CLSID clsidTaskMajorIn
  775. // , CLSID clsidTaskMinorIn
  776. // , ULONG ulMinIn
  777. // , ULONG ulMaxIn
  778. // , ULONG ulCurrentIn
  779. // , HRESULT hrStatusIn
  780. // , LPCWSTR pcszDescriptionIn
  781. // , FILETIME * pftTimeIn
  782. // , LPCWSTR pcszReferenceIn
  783. // )
  784. //
  785. //--
  786. //////////////////////////////////////////////////////////////////////////////
  787. STDMETHODIMP
  788. CCommitPage::SendStatusReport(
  789. LPCWSTR pcszNodeNameIn
  790. , CLSID clsidTaskMajorIn
  791. , CLSID clsidTaskMinorIn
  792. , ULONG ulMinIn
  793. , ULONG ulMaxIn
  794. , ULONG ulCurrentIn
  795. , HRESULT hrStatusIn
  796. , LPCWSTR pcszDescriptionIn
  797. , FILETIME * pftTimeIn
  798. , LPCWSTR pcszReferenceIn
  799. )
  800. {
  801. TraceFunc( "[IClusCfgCallback]" );
  802. Assert( m_ptccc != NULL );
  803. Assert( m_pttv != NULL );
  804. HRESULT hr;
  805. ULONG idx;
  806. static const GUID * rgclsidAnalysis[] =
  807. {
  808. &TASKID_Major_Checking_For_Existing_Cluster
  809. , &TASKID_Major_Establish_Connection
  810. , &TASKID_Major_Check_Node_Feasibility
  811. , &TASKID_Major_Find_Devices
  812. , &TASKID_Major_Check_Cluster_Feasibility
  813. };
  814. static const UINT rgidsAnalysis[] =
  815. {
  816. IDS_TASKID_MAJOR_CHECKING_FOR_EXISTING_CLUSTER
  817. , IDS_TASKID_MAJOR_ESTABLISH_CONNECTION
  818. , IDS_TASKID_MAJOR_CHECK_NODE_FEASIBILITY
  819. , IDS_TASKID_MAJOR_FIND_DEVICES
  820. , IDS_TASKID_MAJOR_CHECK_CLUSTER_FEASIBILITY
  821. };
  822. //
  823. // If this is an analyze task, add it below the Reanalyze task item
  824. // if it hasn't been added yet.
  825. //
  826. for ( idx = 0 ; idx < ARRAYSIZE( rgclsidAnalysis ) ; idx ++ )
  827. {
  828. if ( clsidTaskMajorIn == *rgclsidAnalysis[ idx ] )
  829. {
  830. if ( m_rgfSubReanalyzeAdded[ idx ] == FALSE )
  831. {
  832. Assert( m_htiReanalyze != NULL );
  833. hr = THR( m_pttv->HrAddTreeViewItem(
  834. NULL // phtiOut
  835. , rgidsAnalysis[ idx ]
  836. , *rgclsidAnalysis[ idx ]
  837. , TASKID_Major_Reanalyze
  838. , m_htiReanalyze
  839. , TRUE // fParentToAllNodeTasksIn
  840. ) );
  841. if ( SUCCEEDED( hr ) )
  842. {
  843. m_rgfSubReanalyzeAdded[ idx ] = TRUE;
  844. }
  845. } // if: major ID not added yet
  846. break;
  847. } // if: found known major ID
  848. } // for: each known major task ID
  849. //
  850. // Remove the "back" button as an option if the tasks have made it past re-analyze.
  851. //
  852. if ( ( m_fDisableBack == FALSE )
  853. && ( clsidTaskMajorIn == TASKID_Major_Configure_Cluster_Services )
  854. )
  855. {
  856. BSTR bstrDescription = NULL;
  857. m_fDisableBack = TRUE;
  858. hr = THR( HrLoadStringIntoBSTR( g_hInstance, IDS_COMMIT_SUCCESSFUL_INSTRUCTIONS_BACK_DISABLED, &bstrDescription ) );
  859. if ( SUCCEEDED( hr ) )
  860. {
  861. SetDlgItemText( m_hwnd, IDC_COMMIT_S_RESULTS, bstrDescription );
  862. TraceSysFreeString( bstrDescription );
  863. }
  864. THR( HrUpdateWizardButtons() );
  865. } // if: finished re-analyze
  866. //
  867. // If we are at the point of no return.
  868. //
  869. if ( ( clsidTaskMajorIn == TASKID_Major_Configure_Cluster_Services )
  870. && ( clsidTaskMinorIn == TASKID_Minor_Errors_To_Warnings_Point )
  871. )
  872. {
  873. //
  874. // Tell the tree view to treat errors as warnings since we are now
  875. // past the point of no return.
  876. //
  877. m_pttv->SetDisplayErrorsAsWarnings( TRUE /* fDisplayErrorsAsWarningsIn */ );
  878. m_fPassedPointOfNoReturn = TRUE;
  879. }
  880. hr = THR( m_pttv->HrOnSendStatusReport( pcszNodeNameIn,
  881. clsidTaskMajorIn,
  882. clsidTaskMinorIn,
  883. ulMinIn,
  884. ulMaxIn,
  885. ulCurrentIn,
  886. hrStatusIn,
  887. pcszDescriptionIn,
  888. pftTimeIn,
  889. pcszReferenceIn
  890. ) );
  891. if ( m_fAborted )
  892. {
  893. LogMsg( L"[WIZ] Commit page -- replacing (hr = %#08x) with E_ABORT", hr );
  894. hr = E_ABORT;
  895. } // if:
  896. //
  897. // If the minor task ID is TASKID_Minor_Disconnecting_From_Server then we need to cancel the commit
  898. // task and set the cancel button, reanylze, and back are enbabled.
  899. //
  900. if ( IsEqualIID( clsidTaskMinorIn, TASKID_Minor_Disconnecting_From_Server ) )
  901. {
  902. THR( m_pttv->HrShowStatusAsDone() );
  903. SendDlgItemMessage( m_hwnd, IDC_COMMIT_PRG_STATUS, PBM_SETBARCOLOR, 0, RGB( 0x80, 0, 0 ) );
  904. LogMsg( L"[WIZ] Calling StopTask() on the commit changes task because we were disconnected from the server." );
  905. THR( m_ptccc->StopTask() );
  906. PropSheet_SetWizButtons( GetParent( m_hwnd ), PSWIZB_BACK );
  907. EnableWindow( GetDlgItem( m_hwnd, IDC_COMMIT_PB_RETRY ), TRUE );
  908. EnableWindow( GetDlgItem( GetParent( m_hwnd ), IDCANCEL ), TRUE );
  909. m_fTaskDone = TRUE; // reset so that the cancel button will actually cancel...
  910. } // if:
  911. HRETURN( hr );
  912. } //*** CCommitPage::SendStatusReport
  913. //////////////////////////////////////////////////////////////////////////////
  914. //
  915. // HRESULT
  916. // CCommitPage::HrCleanupCommit( void )
  917. //
  918. //////////////////////////////////////////////////////////////////////////////
  919. HRESULT
  920. CCommitPage::HrCleanupCommit( void )
  921. {
  922. TraceFunc( "" );
  923. HRESULT hr = S_OK;
  924. UINT idx;
  925. if ( m_ptccc != NULL )
  926. {
  927. LogMsg( L"[WIZ] Calling StopTask() on the commit changes task becasue we are cleaning up." );
  928. THR( m_ptccc->StopTask() );
  929. m_ptccc->Release();
  930. m_ptccc = NULL;
  931. } // if:
  932. //
  933. // Unregister UI notification (if needed)
  934. //
  935. THR( HrUnAdviseConnections() );
  936. //
  937. // Delete the completion cookie.
  938. //
  939. if ( m_cookieCompletion != NULL )
  940. {
  941. // Don't care if this fails.
  942. THR( m_pccw->HrReleaseCompletionObject( m_cookieCompletion ) );
  943. m_cookieCompletion = NULL;
  944. }
  945. //
  946. // Clear out the array that indicates whether reanalysis top-level task
  947. // IDs have been added yet.
  948. //
  949. for ( idx = 0 ; idx < ARRAYSIZE( m_rgfSubReanalyzeAdded ) ; idx++ )
  950. {
  951. m_rgfSubReanalyzeAdded[ idx ] = FALSE;
  952. } // for: each entry in the array
  953. HRETURN( hr );
  954. } //*** CCommitPage::HrCleanupCommit
  955. //////////////////////////////////////////////////////////////////////////////
  956. //++
  957. //
  958. // HRESULT
  959. // CAnalyzePage::HrUnAdviseConnections(
  960. // void
  961. // )
  962. //
  963. //--
  964. //////////////////////////////////////////////////////////////////////////////
  965. HRESULT
  966. CCommitPage::HrUnAdviseConnections(
  967. void
  968. )
  969. {
  970. TraceFunc( "" );
  971. HRESULT hr = S_OK;
  972. if ( m_dwCookieNotify != 0 )
  973. {
  974. hr = THR( m_pccw->HrUnadvise( IID_INotifyUI, m_dwCookieNotify ) );
  975. if ( FAILED( hr ) )
  976. {
  977. goto Cleanup;
  978. } //if:
  979. m_dwCookieNotify = 0;
  980. } //if:
  981. if ( m_dwCookieCallback != 0 )
  982. {
  983. hr = THR( m_pccw->HrUnadvise( IID_IClusCfgCallback, m_dwCookieCallback ) );
  984. if ( FAILED( hr ) )
  985. {
  986. goto Cleanup;
  987. } // if:
  988. m_dwCookieCallback = 0;
  989. } // if:
  990. Cleanup:
  991. HRETURN( hr );
  992. } //*** CAnalyzePage::HrUnAdviseConnections