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.

997 lines
23 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000-2002 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // ClusDomainPage.cpp
  7. //
  8. // Maintained By:
  9. // David Potter (DavidP) 31-JAN-2001
  10. // Geoffrey Pease (GPease) 12-MAY-2000
  11. //
  12. //////////////////////////////////////////////////////////////////////////////
  13. #include "Pch.h"
  14. #include "ClusDomainPage.h"
  15. #include "WizardUtils.h"
  16. DEFINE_THISCLASS("CClusDomainPage");
  17. //////////////////////////////////////////////////////////////////////////////
  18. //++
  19. //
  20. // CClusDomainPage::CClusDomainPage
  21. //
  22. // Description:
  23. // Constructor.
  24. //
  25. // Arguments:
  26. // pccwIn - CClusCfgWizard
  27. // ecamCreateAddModeIn - Creating cluster or adding nodes to cluster
  28. // idsDescIn - Resource ID for the domain description string.
  29. //
  30. // Return Values:
  31. // None.
  32. //
  33. // Remarks:
  34. //
  35. //--
  36. //////////////////////////////////////////////////////////////////////////////
  37. CClusDomainPage::CClusDomainPage(
  38. CClusCfgWizard * pccwIn,
  39. ECreateAddMode ecamCreateAddModeIn,
  40. UINT idsDescIn
  41. )
  42. : m_pccw( pccwIn )
  43. {
  44. TraceFunc( "" );
  45. Assert( pccwIn != NULL );
  46. Assert( idsDescIn != 0 );
  47. // m_hwnd
  48. m_pccw->AddRef();
  49. m_ecamCreateAddMode = ecamCreateAddModeIn;
  50. m_idsDesc = idsDescIn;
  51. if ( ( ecamCreateAddModeIn == camADDING )
  52. && ( m_pccw->FHasClusterName() )
  53. && ( !m_pccw->FDefaultedClusterDomain() ) )
  54. {
  55. //
  56. // Don't show the cluster name/domain page if we are joining
  57. // and the cluster name has been filled in by the caller.
  58. //
  59. m_fDisplayPage = FALSE;
  60. }
  61. else
  62. {
  63. m_fDisplayPage = TRUE;
  64. }
  65. m_cRef = 0;
  66. m_ptgd = NULL;
  67. TraceFuncExit();
  68. } //*** CClusDomainPage::CClusDomainPage
  69. //////////////////////////////////////////////////////////////////////////////
  70. //++
  71. //
  72. // CClusDomainPage::~CClusDomainPage
  73. //
  74. // Description:
  75. // Destructor.
  76. //
  77. // Arguments:
  78. // None.
  79. //
  80. // Return Values:
  81. // None.
  82. //
  83. // Remarks:
  84. //
  85. //--
  86. //////////////////////////////////////////////////////////////////////////////
  87. CClusDomainPage::~CClusDomainPage( void )
  88. {
  89. TraceFunc( "" );
  90. if ( m_pccw != NULL )
  91. {
  92. m_pccw->Release();
  93. }
  94. if ( m_ptgd != NULL )
  95. {
  96. // Make sure we don't get called anymore.
  97. THR( m_ptgd->SetCallback( NULL ) );
  98. m_ptgd->Release();
  99. }
  100. Assert( m_cRef == 0 );
  101. TraceFuncExit();
  102. } //*** CClusDomainPage::~CClusDomainPage
  103. //////////////////////////////////////////////////////////////////////////////
  104. //++
  105. //
  106. // CClusDomainPage::OnInitDialog
  107. //
  108. // Description:
  109. // Handle the WM_INITDIALOG window message.
  110. //
  111. // Arguments:
  112. // None.
  113. //
  114. // Return Values:
  115. // FALSE - Didn't set the focus.
  116. //
  117. // Remarks:
  118. //
  119. //--
  120. //////////////////////////////////////////////////////////////////////////////
  121. LRESULT
  122. CClusDomainPage::OnInitDialog( void )
  123. {
  124. TraceFunc( "" );
  125. HRESULT hr;
  126. LRESULT lr = FALSE; // didn't set focus
  127. BSTR bstrClusterName = NULL;
  128. BSTR bstrClusterLabel = NULL;
  129. BSTR bstrDomain = NULL;
  130. BSTR bstrDomainDesc = NULL;
  131. PCWSTR pwcszLabelToUse = NULL;
  132. BSTR bstrNodeName = NULL;
  133. IUnknown * punkTask = NULL;
  134. //
  135. // (jfranco, bugs #373331 and #480246) Limit cluster name length to max( MAX_CLUSTERNAME_LENGTH, INET_ADDRSTRLEN - 1 )
  136. // Use INET_ADDRSTRLEN - 1 because INET_ADDRSTRLEN seems to include terminating null.
  137. // According to MSDN, EM_(SET)LIMITTEXT does not return a value, so ignore what SendDlgItemMessage returns.
  138. //
  139. SendDlgItemMessage( m_hwnd, IDC_CLUSDOMAIN_E_CLUSTERNAME, EM_SETLIMITTEXT, max( MAX_CLUSTERNAME_LENGTH, INET_ADDRSTRLEN - 1 ), 0 );
  140. //
  141. // (jfranco, bug #462673) Limit cluster domain length to ADJUSTED_DNS_MAX_NAME_LENGTH
  142. // According to MSDN, the return value of CB_LIMITTEXT is always true, so ignore what SendDlgItemMessage returns
  143. //
  144. SendDlgItemMessage( m_hwnd, IDC_CLUSDOMAIN_CB_DOMAIN, CB_LIMITTEXT, ADJUSTED_DNS_MAX_NAME_LENGTH, 0 );
  145. //
  146. // Kick off the GetDomains task.
  147. //
  148. hr = THR( m_pccw->HrCreateTask( TASK_GetDomains, &punkTask ) );
  149. if ( FAILED( hr ) )
  150. {
  151. goto Cleanup;
  152. }
  153. //TraceMoveFromMemoryList( punkTask, g_GlobalMemoryList );
  154. hr = THR( punkTask->TypeSafeQI( ITaskGetDomains, &m_ptgd ) );
  155. if ( FAILED( hr ) )
  156. {
  157. goto Cleanup;
  158. }
  159. hr = THR( m_ptgd->SetCallback( static_cast< ITaskGetDomainsCallback * >( this ) ) );
  160. if ( FAILED( hr ) )
  161. {
  162. goto Cleanup;
  163. }
  164. hr = THR( m_pccw->HrSubmitTask( m_ptgd ) );
  165. if ( FAILED( hr ) )
  166. {
  167. goto Cleanup;
  168. }
  169. //
  170. // If a cluster name has already been specified, set it to the page.
  171. //
  172. hr = STHR( m_pccw->get_ClusterName( &bstrClusterName ) );
  173. if ( FAILED( hr ) )
  174. {
  175. goto Cleanup;
  176. }
  177. else if ( bstrClusterName != NULL )
  178. {
  179. TraceMemoryAddBSTR( bstrClusterName );
  180. hr = STHR( HrIsValidFQN( bstrClusterName, true ) );
  181. if ( FAILED( hr ) )
  182. {
  183. goto Cleanup;
  184. }
  185. else if ( hr == S_OK )
  186. {
  187. hr = THR( HrExtractPrefixFromFQN( bstrClusterName, &bstrClusterLabel ) );
  188. if ( FAILED( hr ) )
  189. {
  190. goto Cleanup;
  191. }
  192. pwcszLabelToUse = bstrClusterLabel;
  193. }
  194. else
  195. {
  196. pwcszLabelToUse = bstrClusterName;
  197. }
  198. SetDlgItemText( m_hwnd, IDC_CLUSDOMAIN_E_CLUSTERNAME, pwcszLabelToUse );
  199. if ( !m_pccw->FDefaultedClusterDomain() )
  200. {
  201. hr = STHR( m_pccw->HrGetClusterDomain( &bstrDomain ) );
  202. if ( FAILED( hr ) )
  203. {
  204. goto Cleanup;
  205. }
  206. }
  207. } // if: cluster name specified already
  208. else
  209. {
  210. size_t cNodes = 0;
  211. hr = THR( m_pccw->HrGetNodeCount( &cNodes ) );
  212. if ( FAILED( hr ) )
  213. {
  214. goto Cleanup;
  215. }
  216. // If a node FQN has been specified, use its domain.
  217. if ( cNodes > 0 )
  218. {
  219. hr = THR( m_pccw->HrGetNodeName( 0, &bstrNodeName ) );
  220. if ( FAILED( hr ) )
  221. {
  222. goto Cleanup;
  223. }
  224. hr = STHR( HrIsValidFQN( bstrNodeName, true ) );
  225. if ( FAILED( hr ) )
  226. {
  227. goto Cleanup;
  228. }
  229. else if ( hr == S_OK )
  230. {
  231. size_t idxDomain = 0;
  232. hr = THR( HrFindDomainInFQN( bstrNodeName, &idxDomain ) );
  233. if ( FAILED( hr ) )
  234. {
  235. goto Cleanup;
  236. }
  237. bstrDomain = TraceSysAllocString( ( bstrNodeName + idxDomain ) );
  238. if ( bstrDomain == NULL )
  239. {
  240. hr = THR( E_OUTOFMEMORY );
  241. goto Cleanup;
  242. }
  243. }
  244. } // if the wizard already has some nodes.
  245. if ( bstrDomain == NULL )
  246. {
  247. //
  248. // Get the domain of the local computer.
  249. //
  250. hr = THR( HrGetComputerName(
  251. ComputerNameDnsDomain
  252. , &bstrDomain
  253. , FALSE // fBestEffortIn
  254. ) );
  255. if ( FAILED( hr ) )
  256. {
  257. goto Cleanup;
  258. }
  259. } // cNodes == 0 or node name is not fully qualified
  260. } // else: don't have a cluster name
  261. SetDlgItemText( m_hwnd, IDC_CLUSDOMAIN_CB_DOMAIN, ( bstrDomain == NULL? L"": bstrDomain ) );
  262. //
  263. // Set the text of the domain description control.
  264. //
  265. hr = HrLoadStringIntoBSTR( g_hInstance, m_idsDesc, &bstrDomainDesc );
  266. if ( FAILED( hr ) )
  267. {
  268. goto Cleanup;
  269. }
  270. SetDlgItemText( m_hwnd, IDC_CLUSDOMAIN_S_DOMAIN_DESC, bstrDomainDesc );
  271. Cleanup:
  272. TraceSysFreeString( bstrClusterLabel );
  273. TraceSysFreeString( bstrClusterName );
  274. TraceSysFreeString( bstrDomainDesc );
  275. TraceSysFreeString( bstrDomain );
  276. TraceSysFreeString( bstrNodeName );
  277. if ( punkTask != NULL )
  278. {
  279. punkTask->Release();
  280. }
  281. RETURN( lr );
  282. } //*** CClusDomainPage::OnInitDialog
  283. //////////////////////////////////////////////////////////////////////////////
  284. //++
  285. //
  286. // CClusDomainPage::OnNotifySetActive
  287. //
  288. // Description:
  289. //
  290. // Arguments:
  291. // None.
  292. //
  293. // Return Values:
  294. // TRUE
  295. //
  296. // Remarks:
  297. //
  298. //--
  299. //////////////////////////////////////////////////////////////////////////////
  300. LRESULT
  301. CClusDomainPage::OnNotifySetActive( void )
  302. {
  303. TraceFunc( "" );
  304. LRESULT lr = TRUE;
  305. if ( m_fDisplayPage )
  306. {
  307. lr = OnUpdateWizardButtons();
  308. }
  309. else
  310. {
  311. SetWindowLongPtr( m_hwnd, DWLP_MSGRESULT, -1 );
  312. }
  313. RETURN( lr );
  314. } //*** CClusDomainPage::OnNotifySetActive
  315. //////////////////////////////////////////////////////////////////////////////
  316. //++
  317. //
  318. // CClusDomainPage::OnNotifyWizNext
  319. //
  320. // Description:
  321. //
  322. // Arguments:
  323. // None.
  324. //
  325. // Return Values:
  326. // TRUE
  327. //
  328. // Remarks:
  329. //
  330. //--
  331. //////////////////////////////////////////////////////////////////////////////
  332. LRESULT
  333. CClusDomainPage::OnNotifyWizNext( void )
  334. {
  335. TraceFunc( "" );
  336. HRESULT hr = S_OK;
  337. LRESULT lr = TRUE;
  338. BSTR bstrDomainName = NULL;
  339. BSTR bstrClusterNameLabel = NULL;
  340. BSTR bstrClusterFQN = NULL;
  341. int idcFocus = 0;
  342. PFN_LABEL_VALIDATOR pfnLabelValidator = ( m_ecamCreateAddMode == camCREATING? HrValidateClusterNameLabel: HrValidateFQNPrefix );
  343. EFQNErrorOrigin efeo = feoSYSTEM;
  344. // Get the cluster domain.
  345. hr = THR( HrGetTrimmedText( GetDlgItem( m_hwnd, IDC_CLUSDOMAIN_CB_DOMAIN ), &bstrDomainName ) );
  346. if ( hr != S_OK )
  347. {
  348. // Next is supposed to be disabled when control is empty.
  349. goto Error;
  350. }
  351. // Get the cluster hostname label.
  352. hr = THR( HrGetTrimmedText( GetDlgItem( m_hwnd, IDC_CLUSDOMAIN_E_CLUSTERNAME ), &bstrClusterNameLabel ) );
  353. if ( hr != S_OK )
  354. {
  355. // Next is supposed to be disabled when control is empty.
  356. goto Error;
  357. }
  358. // Weed out IP addresses when creating.
  359. if ( m_ecamCreateAddMode == camCREATING )
  360. {
  361. hr = STHR( HrIsValidIPAddress( bstrClusterNameLabel ) );
  362. if ( hr == S_OK )
  363. {
  364. MessageBoxFromStrings(
  365. m_hwnd
  366. , IDS_ERR_VALIDATING_NAME_TITLE
  367. , IDS_ERR_CLUSTER_CREATE_IP_TEXT
  368. , MB_OK | MB_ICONSTOP
  369. );
  370. goto Error;
  371. }
  372. else if ( FAILED( hr ) )
  373. {
  374. goto Error;
  375. }
  376. }
  377. // Make the cluster FQN.
  378. hr = THR( HrCreateFQN( m_hwnd, bstrClusterNameLabel, bstrDomainName, pfnLabelValidator, &bstrClusterFQN, &efeo ) );
  379. if ( FAILED( hr ) )
  380. {
  381. if ( efeo == feoLABEL )
  382. {
  383. idcFocus = IDC_CLUSDOMAIN_E_CLUSTERNAME;
  384. }
  385. else if ( efeo == feoDOMAIN )
  386. {
  387. idcFocus = IDC_CLUSDOMAIN_CB_DOMAIN;
  388. }
  389. goto Error;
  390. }
  391. hr = STHR( m_pccw->HrSetClusterName( bstrClusterFQN, true ) );
  392. if ( FAILED( hr ) )
  393. {
  394. THR( HrMessageBoxWithStatus(
  395. m_hwnd
  396. , IDS_ERR_CLUSTER_RENAME_TITLE
  397. , IDS_ERR_CLUSTER_RENAME_TEXT
  398. , hr
  399. , 0
  400. , MB_OK | MB_ICONSTOP
  401. , NULL
  402. ) );
  403. goto Error;
  404. }
  405. Cleanup:
  406. TraceSysFreeString( bstrClusterFQN );
  407. TraceSysFreeString( bstrDomainName );
  408. TraceSysFreeString( bstrClusterNameLabel );
  409. RETURN( lr );
  410. Error:
  411. if ( idcFocus != 0 )
  412. {
  413. SetFocus( GetDlgItem( m_hwnd, idcFocus ) );
  414. }
  415. // Don't go to the next page.
  416. SetWindowLongPtr( m_hwnd, DWLP_MSGRESULT, -1 );
  417. goto Cleanup;
  418. } //*** CClusDomainPage::OnNotifyWizNext
  419. //////////////////////////////////////////////////////////////////////////////
  420. //++
  421. //
  422. // CClusDomainPage::OnNotifyQueryCancel
  423. //
  424. // Description:
  425. //
  426. // Arguments:
  427. // None.
  428. //
  429. // Return Values:
  430. // TRUE
  431. //
  432. // Remarks:
  433. //
  434. //--
  435. //////////////////////////////////////////////////////////////////////////////
  436. LRESULT
  437. CClusDomainPage::OnNotifyQueryCancel( void )
  438. {
  439. TraceFunc( "" );
  440. LRESULT lr = TRUE;
  441. int iRet;
  442. iRet = MessageBoxFromStrings( m_hwnd,
  443. IDS_QUERY_CANCEL_TITLE,
  444. IDS_QUERY_CANCEL_TEXT,
  445. MB_YESNO
  446. );
  447. if ( iRet == IDNO )
  448. {
  449. SetWindowLongPtr( m_hwnd, DWLP_MSGRESULT, -1 );
  450. }
  451. RETURN( lr );
  452. } //*** OnNotifyQueryCancel
  453. //////////////////////////////////////////////////////////////////////////////
  454. //++
  455. //
  456. // CClusDomainPage::OnNotify
  457. //
  458. // Description:
  459. //
  460. // Arguments:
  461. // idCtrlIn
  462. // pnmhdrIn
  463. //
  464. // Return Values:
  465. // TRUE
  466. // Other LRESULT values.
  467. //
  468. // Remarks:
  469. //
  470. //--
  471. //////////////////////////////////////////////////////////////////////////////
  472. LRESULT
  473. CClusDomainPage::OnNotify(
  474. WPARAM idCtrlIn,
  475. LPNMHDR pnmhdrIn
  476. )
  477. {
  478. TraceFunc( "" );
  479. LRESULT lr = TRUE;
  480. SetWindowLongPtr( m_hwnd, DWLP_MSGRESULT, 0 );
  481. switch ( pnmhdrIn->code )
  482. {
  483. case PSN_SETACTIVE:
  484. lr = OnNotifySetActive();
  485. break;
  486. case PSN_WIZNEXT:
  487. lr = OnNotifyWizNext();
  488. break;
  489. case PSN_WIZBACK:
  490. //
  491. // Disable the wizard buttons.
  492. //
  493. PropSheet_SetWizButtons( GetParent( m_hwnd ), 0 );
  494. break;
  495. case PSN_QUERYCANCEL:
  496. lr = OnNotifyQueryCancel();
  497. break;
  498. } // switch: notification code
  499. RETURN( lr );
  500. } //*** CClusDomainPage::OnNotify
  501. //////////////////////////////////////////////////////////////////////////////
  502. //++
  503. //
  504. // CClusDomainPage::OnCommand
  505. //
  506. // Description:
  507. //
  508. // Arguments:
  509. // idNotificationIn
  510. // idControlIn
  511. // hwndSenderIn
  512. //
  513. // Return Values:
  514. // TRUE
  515. // FALSE
  516. //
  517. // Remarks:
  518. //
  519. //--
  520. //////////////////////////////////////////////////////////////////////////////
  521. LRESULT
  522. CClusDomainPage::OnCommand(
  523. UINT idNotificationIn,
  524. UINT idControlIn,
  525. HWND hwndSenderIn
  526. )
  527. {
  528. TraceFunc( "" );
  529. LRESULT lr = FALSE;
  530. switch ( idControlIn )
  531. {
  532. case IDC_CLUSDOMAIN_E_CLUSTERNAME:
  533. if ( idNotificationIn == EN_CHANGE )
  534. {
  535. lr = OnUpdateWizardButtons();
  536. }
  537. break;
  538. case IDC_CLUSDOMAIN_CB_DOMAIN:
  539. if ( ( idNotificationIn == CBN_EDITCHANGE ) || ( idNotificationIn == CBN_SELENDOK ) )
  540. {
  541. // KB: jfranco 24-oct-2001 bug 481636
  542. // Need to update wizard buttons, but only after combo box has a chance to update itself.
  543. if ( PostMessage( m_hwnd, WM_CCW_UPDATEBUTTONS, 0, 0 ) == 0 )
  544. {
  545. TW32( GetLastError() );
  546. }
  547. lr = TRUE;
  548. }
  549. break;
  550. } // switch: control ID
  551. RETURN( lr );
  552. } //*** CClusDomainPage::OnCommand
  553. //////////////////////////////////////////////////////////////////////////////
  554. //++
  555. //
  556. // CClusDomainPage::OnUpdateWizardButtons
  557. //
  558. // Description:
  559. //
  560. // Arguments:
  561. // None.
  562. //
  563. // Return Values:
  564. // TRUE
  565. //
  566. // Remarks:
  567. //
  568. //--
  569. //////////////////////////////////////////////////////////////////////////////
  570. LRESULT
  571. CClusDomainPage::OnUpdateWizardButtons( void )
  572. {
  573. TraceFunc( "" );
  574. LRESULT lr = TRUE;
  575. HRESULT hrName = S_OK;
  576. HRESULT hrDomain = S_OK;
  577. BSTR bstrName = NULL;
  578. BSTR bstrDomain = NULL;
  579. DWORD mEnabledButtons = PSWIZB_BACK;
  580. hrName = STHR( HrGetTrimmedText( GetDlgItem( m_hwnd, IDC_CLUSDOMAIN_E_CLUSTERNAME ), &bstrName ) );
  581. hrDomain = STHR( HrGetTrimmedText( GetDlgItem( m_hwnd, IDC_CLUSDOMAIN_CB_DOMAIN ), &bstrDomain ) );
  582. if ( ( hrName == S_OK ) && ( hrDomain == S_OK ) )
  583. {
  584. mEnabledButtons |= PSWIZB_NEXT;
  585. }
  586. PropSheet_SetWizButtons( GetParent( m_hwnd ), mEnabledButtons );
  587. TraceSysFreeString( bstrName );
  588. TraceSysFreeString( bstrDomain );
  589. RETURN( lr );
  590. } //*** CClusDomainPage::OnUpdateWizardButtons
  591. //////////////////////////////////////////////////////////////////////////////
  592. //++
  593. //
  594. // static
  595. // CALLBACK
  596. // CClusDomainPage::S_DlgProc
  597. //
  598. // Description:
  599. // Dialog proc for this page.
  600. //
  601. // Arguments:
  602. // hDlgIn
  603. // MsgIn
  604. // wParam
  605. // lParam
  606. //
  607. // Return Values:
  608. // FALSE
  609. // Other LRESULT values.
  610. //
  611. // Remarks:
  612. //
  613. //--
  614. //////////////////////////////////////////////////////////////////////////////
  615. INT_PTR
  616. CALLBACK
  617. CClusDomainPage::S_DlgProc(
  618. HWND hDlgIn,
  619. UINT MsgIn,
  620. WPARAM wParam,
  621. LPARAM lParam
  622. )
  623. {
  624. // Don't do TraceFunc because every mouse movement
  625. // will cause this function to be called.
  626. WndMsg( hDlgIn, MsgIn, wParam, lParam );
  627. LRESULT lr = FALSE;
  628. CClusDomainPage * pPage = reinterpret_cast< CClusDomainPage *> ( GetWindowLongPtr( hDlgIn, GWLP_USERDATA ) );
  629. if ( MsgIn == WM_INITDIALOG )
  630. {
  631. PROPSHEETPAGE * ppage = reinterpret_cast< PROPSHEETPAGE * >( lParam );
  632. SetWindowLongPtr( hDlgIn, GWLP_USERDATA, (LPARAM) ppage->lParam );
  633. pPage = reinterpret_cast< CClusDomainPage * >( ppage->lParam );
  634. pPage->m_hwnd = hDlgIn;
  635. }
  636. if ( pPage != NULL )
  637. {
  638. Assert( hDlgIn == pPage->m_hwnd );
  639. switch( MsgIn )
  640. {
  641. case WM_INITDIALOG:
  642. lr = pPage->OnInitDialog();
  643. break;
  644. case WM_NOTIFY:
  645. lr = pPage->OnNotify( wParam, reinterpret_cast< LPNMHDR >( lParam ) );
  646. break;
  647. case WM_COMMAND:
  648. lr= pPage->OnCommand( HIWORD( wParam ), LOWORD( wParam ), (HWND) lParam );
  649. break;
  650. case WM_CCW_UPDATEBUTTONS:
  651. lr = pPage->OnUpdateWizardButtons();
  652. break;
  653. // no default clause needed
  654. } // switch: message
  655. } // if: there is a page associated with the window
  656. return lr;
  657. } //*** CClusDomainPage::S_DlgProc
  658. // ************************************************************************
  659. //
  660. // IUnknown
  661. //
  662. // ************************************************************************
  663. //////////////////////////////////////////////////////////////////////////////
  664. //++
  665. //
  666. // CClusDomainPage::QueryInterface
  667. //
  668. // Description:
  669. // Query this object for the passed in interface.
  670. //
  671. // Arguments:
  672. // riidIn
  673. // Id of interface requested.
  674. //
  675. // ppvOut
  676. // Pointer to the requested interface.
  677. //
  678. // Return Value:
  679. // S_OK
  680. // If the interface is available on this object.
  681. //
  682. // E_NOINTERFACE
  683. // If the interface is not available.
  684. //
  685. // E_POINTER
  686. // ppvOut was NULL.
  687. //
  688. // Remarks:
  689. // This QI implementation does not use the interface tracing macros due
  690. // to problems with CITracker's marshalling support.
  691. //
  692. //--
  693. //////////////////////////////////////////////////////////////////////////////
  694. STDMETHODIMP
  695. CClusDomainPage::QueryInterface(
  696. REFIID riidIn
  697. , LPVOID * ppvOut
  698. )
  699. {
  700. TraceFunc( "" );
  701. HRESULT hr = S_OK;
  702. //
  703. // Validate arguments.
  704. //
  705. Assert( ppvOut != NULL );
  706. if ( ppvOut == NULL )
  707. {
  708. hr = THR( E_POINTER );
  709. goto Cleanup;
  710. }
  711. //
  712. // Handle known interfaces.
  713. //
  714. if ( IsEqualIID( riidIn, IID_IUnknown ) )
  715. {
  716. *ppvOut = static_cast< IUnknown * >( this );
  717. } // if: IUnknown
  718. else if ( IsEqualIID( riidIn, IID_ITaskGetDomainsCallback ) )
  719. {
  720. *ppvOut = static_cast< ITaskGetDomainsCallback * >( this );
  721. } // else if: ITaskGetDomainsCallback
  722. else
  723. {
  724. *ppvOut = NULL;
  725. hr = E_NOINTERFACE;
  726. } // else
  727. //
  728. // Add a reference to the interface if successful.
  729. //
  730. if ( SUCCEEDED( hr ) )
  731. {
  732. ((IUnknown *) *ppvOut)->AddRef();
  733. } // if: success
  734. Cleanup:
  735. HRETURN( hr );
  736. } //*** CClusDomainPage::QueryInterface
  737. //////////////////////////////////////////////////////////////////////////////
  738. //++
  739. //
  740. // CClusDomainPage::AddRef
  741. //
  742. // Description:
  743. //
  744. // Arguments:
  745. // None.
  746. //
  747. // Return Values:
  748. // New reference count.
  749. //
  750. // Remarks:
  751. //
  752. //--
  753. //////////////////////////////////////////////////////////////////////////////
  754. STDMETHODIMP_( ULONG )
  755. CClusDomainPage::AddRef( void )
  756. {
  757. TraceFunc( "[IUnknown]" );
  758. InterlockedIncrement( &m_cRef );
  759. CRETURN( m_cRef );
  760. } //*** CClusDomainPage::AddRef
  761. //////////////////////////////////////////////////////////////////////////////
  762. //++
  763. //
  764. // CClusDomainPage::Release
  765. //
  766. // Description:
  767. //
  768. // Arguments:
  769. // None.
  770. //
  771. // Return Values:
  772. // New reference count.
  773. //
  774. // Remarks:
  775. //
  776. //--
  777. //////////////////////////////////////////////////////////////////////////////
  778. STDMETHODIMP_( ULONG )
  779. CClusDomainPage::Release( void )
  780. {
  781. TraceFunc( "[IUnknown]" );
  782. LONG cRef;
  783. cRef = InterlockedDecrement( &m_cRef );
  784. if ( cRef == 0 )
  785. {
  786. // do nothing -- COM interface does not control object lifetime
  787. }
  788. CRETURN( cRef );
  789. } //*** CClusDomainPage::Release
  790. //****************************************************************************
  791. //
  792. // ITaskGetDomainsCallback
  793. //
  794. //****************************************************************************
  795. //////////////////////////////////////////////////////////////////////////////
  796. //++
  797. //
  798. // [ITaskGetDomainsCallback]
  799. // CClusDomainPage::ReceiveDomainResult
  800. //
  801. // Description:
  802. //
  803. // Arguments:
  804. // hrIn
  805. //
  806. // Return Values:
  807. // S_OK
  808. // Other HRESULT values.
  809. //
  810. // Remarks:
  811. //
  812. //--
  813. //////////////////////////////////////////////////////////////////////////////
  814. STDMETHODIMP
  815. CClusDomainPage::ReceiveDomainResult(
  816. HRESULT hrIn
  817. )
  818. {
  819. TraceFunc( "[ITaskGetDomainsCallback]" );
  820. HRESULT hr;
  821. hr = THR( m_ptgd->SetCallback( NULL ) );
  822. HRETURN( hr );
  823. } //*** CClusDomainPage::ReceiveResult
  824. //////////////////////////////////////////////////////////////////////////////
  825. //++
  826. //
  827. // [ITaskGetDomainsCallback]
  828. // CClusDomainPage::ReceiveDomainName
  829. //
  830. // Description:
  831. //
  832. // Arguments:
  833. // bstrDomainIn
  834. //
  835. // Remarks:
  836. //
  837. //--
  838. //////////////////////////////////////////////////////////////////////////////
  839. STDMETHODIMP
  840. CClusDomainPage::ReceiveDomainName(
  841. LPCWSTR pcszDomainIn
  842. )
  843. {
  844. TraceFunc( "[ITaskGetDomainsCallback]" );
  845. HRESULT hr = S_OK;
  846. ComboBox_AddString( GetDlgItem( m_hwnd, IDC_CLUSDOMAIN_CB_DOMAIN ), pcszDomainIn );
  847. HRETURN( hr );
  848. } //*** CClusDomainPage::ReceiveName