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.

1168 lines
28 KiB

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