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.

1231 lines
28 KiB

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