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.

1180 lines
28 KiB

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