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.

1045 lines
27 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000-2001 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // TaskGatherNodeInfo.cpp
  7. //
  8. // Description:
  9. // CTaskGatherNodeInfo implementation.
  10. //
  11. // Maintained By:
  12. // Galen Barbee (GalenB) 02-FEB-2000
  13. //
  14. //////////////////////////////////////////////////////////////////////////////
  15. #include "Pch.h"
  16. #include "TaskGatherNodeInfo.h"
  17. #include <Lm.h>
  18. #include <LmJoin.h>
  19. DEFINE_THISCLASS("CTaskGatherNodeInfo")
  20. //
  21. // Failure code.
  22. //
  23. #define SSR_FAILURE( _minor, _hr ) THR( SendStatusReport( m_bstrName, TASKID_Major_Client_And_Server_Log, _minor, 0, 1, 1, _hr, NULL, NULL, NULL ) );
  24. // ************************************************************************
  25. //
  26. // Constructor / Destructor
  27. //
  28. // ************************************************************************
  29. //////////////////////////////////////////////////////////////////////////////
  30. //
  31. // HRESULT
  32. // CTaskGatherNodeInfo::S_HrCreateInstance(
  33. // IUnknown ** ppunkOut
  34. // )
  35. //
  36. //////////////////////////////////////////////////////////////////////////////
  37. HRESULT
  38. CTaskGatherNodeInfo::S_HrCreateInstance(
  39. IUnknown ** ppunkOut
  40. )
  41. {
  42. TraceFunc( "" );
  43. HRESULT hr = S_OK;
  44. CTaskGatherNodeInfo * ptgni = NULL;
  45. Assert( ppunkOut != NULL );
  46. if ( ppunkOut == NULL )
  47. {
  48. hr = THR( E_POINTER );
  49. goto Cleanup;
  50. }
  51. ptgni = new CTaskGatherNodeInfo;
  52. if ( ptgni == NULL )
  53. {
  54. hr = THR( E_OUTOFMEMORY );
  55. goto Cleanup;
  56. }
  57. hr = THR( ptgni->HrInit() );
  58. if ( FAILED( hr ) )
  59. {
  60. goto Cleanup;
  61. }
  62. hr = THR( ptgni->TypeSafeQI( IUnknown, ppunkOut ) );
  63. if ( FAILED( hr ) )
  64. {
  65. goto Cleanup;
  66. }
  67. // This gets passed to other threads.
  68. TraceMoveToMemoryList( ptgni, g_GlobalMemoryList );
  69. Cleanup:
  70. if ( ptgni != NULL )
  71. {
  72. ptgni->Release();
  73. }
  74. HRETURN( hr );
  75. } //*** CTaskGatherNodeInfo::S_HrCreateInstance
  76. //////////////////////////////////////////////////////////////////////////////
  77. //
  78. // CTaskGatherNodeInfo::CTaskGatherNodeInfo
  79. //
  80. //////////////////////////////////////////////////////////////////////////////
  81. CTaskGatherNodeInfo::CTaskGatherNodeInfo( void )
  82. : m_cRef( 1 )
  83. {
  84. TraceFunc( "" );
  85. InterlockedIncrement( &g_cObjects );
  86. TraceFuncExit();
  87. } //*** CTaskGatherNodeInfo::CTaskGatherNodeInfo
  88. //////////////////////////////////////////////////////////////////////////////
  89. //
  90. // STDMETHODIMP
  91. // CTaskGatherNodeInfo::HrInit
  92. //
  93. //////////////////////////////////////////////////////////////////////////////
  94. STDMETHODIMP
  95. CTaskGatherNodeInfo::HrInit( void )
  96. {
  97. TraceFunc( "" );
  98. HRESULT hr = S_OK;
  99. // IUnknown stuff
  100. Assert( m_cRef == 1 );
  101. // IDoTask / ITaskGatherNodeInfo
  102. Assert( m_cookie == NULL );
  103. Assert( m_cookieCompletion == NULL );
  104. Assert( m_bstrName == NULL );
  105. // IClusCfgCallback
  106. Assert( m_pcccb == NULL );
  107. HRETURN( hr );
  108. } //*** CTaskGatherNodeInfo::HrInit
  109. //////////////////////////////////////////////////////////////////////////////
  110. //
  111. // CTaskGatherNodeInfo::~CTaskGatherNodeInfo
  112. //
  113. //////////////////////////////////////////////////////////////////////////////
  114. CTaskGatherNodeInfo::~CTaskGatherNodeInfo( void )
  115. {
  116. TraceFunc( "" );
  117. if ( m_pcccb != NULL )
  118. {
  119. m_pcccb->Release();
  120. }
  121. TraceSysFreeString( m_bstrName );
  122. //
  123. // This keeps the per thread memory tracking from screaming.
  124. //
  125. TraceMoveFromMemoryList( this, g_GlobalMemoryList );
  126. InterlockedDecrement( &g_cObjects );
  127. TraceFuncExit();
  128. } //*** CTaskGatherNodeInfo::~CTaskGatherNodeInfo
  129. // ************************************************************************
  130. //
  131. // IUnknown
  132. //
  133. // ************************************************************************
  134. //////////////////////////////////////////////////////////////////////////////
  135. //++
  136. //
  137. // CTaskGatherNodeInfo::QueryInterface
  138. //
  139. // Description:
  140. // Query this object for the passed in interface.
  141. //
  142. // Arguments:
  143. // riidIn
  144. // Id of interface requested.
  145. //
  146. // ppvOut
  147. // Pointer to the requested interface.
  148. //
  149. // Return Value:
  150. // S_OK
  151. // If the interface is available on this object.
  152. //
  153. // E_NOINTERFACE
  154. // If the interface is not available.
  155. //
  156. // E_POINTER
  157. // ppvOut was NULL.
  158. //
  159. // Remarks:
  160. // None.
  161. //
  162. //--
  163. //////////////////////////////////////////////////////////////////////////////
  164. STDMETHODIMP
  165. CTaskGatherNodeInfo::QueryInterface(
  166. REFIID riidIn
  167. , LPVOID * ppvOut
  168. )
  169. {
  170. TraceQIFunc( riidIn, ppvOut );
  171. HRESULT hr = S_OK;
  172. //
  173. // Validate arguments.
  174. //
  175. Assert( ppvOut != NULL );
  176. if ( ppvOut == NULL )
  177. {
  178. hr = THR( E_POINTER );
  179. goto Cleanup;
  180. }
  181. //
  182. // Handle known interfaces.
  183. //
  184. if ( IsEqualIID( riidIn, IID_IUnknown ) )
  185. {
  186. *ppvOut = static_cast< ITaskGatherNodeInfo * >( this );
  187. } // if: IUnknown
  188. else if ( IsEqualIID( riidIn, IID_IDoTask ) )
  189. {
  190. *ppvOut = TraceInterface( __THISCLASS__, IDoTask, this, 0 );
  191. } // else if: IDoTask
  192. else if ( IsEqualIID( riidIn, IID_ITaskGatherNodeInfo ) )
  193. {
  194. *ppvOut = TraceInterface( __THISCLASS__, ITaskGatherNodeInfo, this, 0 );
  195. } // else if: ITaskGatherNodeInfo
  196. else
  197. {
  198. *ppvOut = NULL;
  199. hr = E_NOINTERFACE;
  200. }
  201. //
  202. // Add a reference to the interface if successful.
  203. //
  204. if ( SUCCEEDED( hr ) )
  205. {
  206. ((IUnknown *) *ppvOut)->AddRef();
  207. } // if: success
  208. Cleanup:
  209. QIRETURN_IGNORESTDMARSHALLING( hr, riidIn );
  210. } //*** CTaskGatherNodeInfo::QueryInterface
  211. //////////////////////////////////////////////////////////////////////////////
  212. //
  213. // STDMETHODIMP_(ULONG)
  214. // CTaskGatherNodeInfo::AddRef
  215. //
  216. //////////////////////////////////////////////////////////////////////////////
  217. STDMETHODIMP_( ULONG )
  218. CTaskGatherNodeInfo::AddRef( void )
  219. {
  220. TraceFunc( "[IUnknown]" );
  221. InterlockedIncrement( &m_cRef );
  222. CRETURN( m_cRef );
  223. } //*** CTaskGatherNodeInfo::AddRef
  224. //////////////////////////////////////////////////////////////////////////////
  225. //
  226. // STDMETHODIMP_(ULONG)
  227. // CTaskGatherNodeInfo::Release
  228. //
  229. //////////////////////////////////////////////////////////////////////////////
  230. STDMETHODIMP_( ULONG )
  231. CTaskGatherNodeInfo::Release( void )
  232. {
  233. TraceFunc( "[IUnknown]" );
  234. LONG cRef;
  235. cRef = InterlockedDecrement( &m_cRef );
  236. if ( cRef == 0 )
  237. {
  238. TraceDo( delete this );
  239. }
  240. CRETURN( cRef );
  241. } //*** CTaskGatherNodeInfo::Release
  242. // ************************************************************************
  243. //
  244. // IDoTask / ITaskGatherNodeInfo
  245. //
  246. // ************************************************************************
  247. //////////////////////////////////////////////////////////////////////////////
  248. //
  249. // STDMETHODIMP
  250. // CTaskGatherNodeInfo::BeginTask( void );
  251. //
  252. //////////////////////////////////////////////////////////////////////////////
  253. STDMETHODIMP
  254. CTaskGatherNodeInfo::BeginTask( void )
  255. {
  256. TraceFunc( "[IDoTask]" );
  257. HRESULT hr;
  258. OBJECTCOOKIE cookieParent;
  259. BSTR bstrNotification = NULL;
  260. BSTR bstrDisplayName = NULL;
  261. IServiceProvider * psp = NULL;
  262. IUnknown * punk = NULL;
  263. IObjectManager * pom = NULL;
  264. IConnectionManager * pcm = NULL;
  265. IConnectionPointContainer * pcpc = NULL;
  266. IConnectionPoint * pcp = NULL;
  267. INotifyUI * pnui = NULL;
  268. IClusCfgNodeInfo * pccni = NULL;
  269. IClusCfgServer * pccs = NULL;
  270. IGatherData * pgd = NULL;
  271. IStandardInfo * psi = NULL;
  272. TraceInitializeThread( L"TaskGatherNodeInfo" );
  273. //
  274. // Collect the manager we need to complete this task.
  275. //
  276. hr = THR( CoCreateInstance( CLSID_ServiceManager,
  277. NULL,
  278. CLSCTX_INPROC_SERVER,
  279. TypeSafeParams( IServiceProvider, &psp )
  280. ) );
  281. if ( FAILED( hr ) )
  282. {
  283. SSR_FAILURE( TASKID_Minor_GatherNodeInfo_CoCreate_ServiceManager, hr );
  284. goto Cleanup;
  285. }
  286. hr = THR( psp->TypeSafeQS( CLSID_ObjectManager, IObjectManager, &pom ) );
  287. if ( FAILED( hr ) )
  288. {
  289. SSR_FAILURE( TASKID_Minor_GatherNodeInfo_QS_ObjectManager, hr );
  290. goto Cleanup;
  291. }
  292. hr = THR( psp->TypeSafeQS( CLSID_ClusterConnectionManager, IConnectionManager, &pcm ) );
  293. if ( FAILED( hr ) )
  294. {
  295. SSR_FAILURE( TASKID_Minor_BeginTask_QS_ConnectionManager, hr );
  296. goto Cleanup;
  297. }
  298. hr = THR( psp->TypeSafeQS( CLSID_NotificationManager, IConnectionPointContainer, &pcpc ) );
  299. if ( FAILED( hr ) )
  300. {
  301. SSR_FAILURE( TASKID_Minor_GatherNodeInfo_QS_NotificationManager, hr );
  302. goto Cleanup;
  303. }
  304. hr = THR( pcpc->FindConnectionPoint( IID_INotifyUI, &pcp ) );
  305. if ( FAILED( hr ) )
  306. {
  307. SSR_FAILURE( TASKID_Minor_GatherNodeInfo_FindConnectionPoint, hr );
  308. goto Cleanup;
  309. }
  310. pcp = TraceInterface( L"CTaskGatherNodeInfo!IConnectionPoint", IConnectionPoint, pcp, 1 );
  311. hr = THR( pcp->TypeSafeQI( INotifyUI, &pnui ) );
  312. if ( FAILED( hr ) )
  313. {
  314. SSR_FAILURE( TASKID_Minor_GatherNodeInfo_FindConnectionPoint_QI, hr );
  315. goto Cleanup;
  316. }
  317. pnui = TraceInterface( L"CTaskGatherNodeInfo!INotifyUI", INotifyUI, pnui, 1 );
  318. // release promptly
  319. psp->Release();
  320. psp = NULL;
  321. if ( m_fStop == TRUE )
  322. {
  323. goto Cleanup;
  324. } // if:
  325. //
  326. // Retrieve the node's standard info.
  327. //
  328. hr = THR( pom->GetObject( DFGUID_StandardInfo, m_cookie, &punk ) );
  329. if ( FAILED( hr ) )
  330. {
  331. SSR_FAILURE( TASKID_Minor_GatherNodeInfo_GetObject_StandardInfo, hr );
  332. goto Cleanup;
  333. }
  334. hr = THR( punk->TypeSafeQI( IStandardInfo, &psi ) );
  335. if ( FAILED( hr ) )
  336. {
  337. SSR_FAILURE( TASKID_Minor_GatherNodeInfo_GetObject_StandardInfo_QI_psi, hr );
  338. goto Cleanup;
  339. }
  340. punk->Release();
  341. punk = NULL;
  342. psi = TraceInterface( L"TaskGatherNodeInfo!IStandardInfo", IStandardInfo, psi, 1 );
  343. //
  344. // Get the node's name to display a status message.
  345. //
  346. hr = THR( psi->GetName( &m_bstrName ) );
  347. if ( FAILED( hr ) )
  348. {
  349. SSR_FAILURE( TASKID_Minor_GatherNodeInfo_GetName, hr );
  350. goto Cleanup;
  351. }
  352. TraceMemoryAddBSTR( m_bstrName );
  353. hr = STHR( HrGetFQNDisplayName( m_bstrName, &bstrDisplayName ) );
  354. if ( FAILED( hr ) )
  355. {
  356. SSR_FAILURE( TASKID_Minor_GatherNodeInfo_GetName, hr );
  357. goto Cleanup;
  358. } // if:
  359. //
  360. // Create a progress message.
  361. //
  362. // Tell the UI layer what's going on.
  363. //
  364. hr = THR( HrSendStatusReport(
  365. m_bstrName
  366. , TASKID_Major_Establish_Connection
  367. , TASKID_Minor_Connecting
  368. , 0
  369. , 1
  370. , 0
  371. , S_OK
  372. , IDS_TASKID_MINOR_CONNECTING_TO_NODES
  373. ) );
  374. if ( FAILED( hr ) )
  375. goto Cleanup;
  376. if ( m_fStop == TRUE )
  377. {
  378. goto Cleanup;
  379. } // if:
  380. //
  381. // Ask the Connection Manager for a connection to the object.
  382. //
  383. hr = pcm->GetConnectionToObject( m_cookie, &punk );
  384. if ( hr == HR_S_RPC_S_CLUSTER_NODE_DOWN )
  385. {
  386. goto Cleanup;
  387. }
  388. if ( ( hr == HR_S_RPC_S_SERVER_UNAVAILABLE ) || FAILED( hr ) )
  389. {
  390. LPWSTR pszNameBuffer = NULL;
  391. NETSETUP_JOIN_STATUS JoinType;
  392. NET_API_STATUS naps = NERR_Success;
  393. //
  394. // test domain membership
  395. //
  396. naps = NetGetJoinInformation( bstrDisplayName, &pszNameBuffer, &JoinType );
  397. //
  398. // We are using bstrDisplayName instead of a full DNS name in the code above,
  399. // since machine that is a workgroup member might have only NETBIOS name only
  400. //
  401. LogMsg( L"%ws: Test domain membership, %d.", bstrDisplayName, naps );
  402. if ( naps == NERR_Success )
  403. {
  404. if ( JoinType == NetSetupDomainName )
  405. {
  406. LogMsg( L"%ws is a member of a domain.", m_bstrName );
  407. }
  408. else
  409. {
  410. // not a member of the domain
  411. naps = ERROR_ACCESS_DENIED;
  412. }
  413. NetApiBufferFree( pszNameBuffer );
  414. } // if: NetGetJoinInformation failed
  415. if ( naps == ERROR_ACCESS_DENIED )
  416. {
  417. LogMsg( L"%ws is not a member of a domain.", m_bstrName );
  418. //
  419. // verify that the node is a member of the domain
  420. //
  421. HRESULT reportHr = THR( HRESULT_FROM_WIN32( ERROR_NO_SUCH_DOMAIN ) );
  422. THR( HrSendStatusReport( m_bstrName,
  423. TASKID_Major_Establish_Connection,
  424. TASKID_Minor_Check_Domain_Membership,
  425. 0,
  426. 1,
  427. 1,
  428. reportHr,
  429. IDS_TASKID_MINOR_CHECK_DOMAIN_MEMBERSHIP,
  430. IDS_TASKID_MINOR_CHECK_DOMAIN_MEMBERSHIP_ERROR_REF
  431. ) );
  432. } // if: failed with ACCESS_DENIED
  433. }// if: GetConnectionToObject failed
  434. if ( FAILED( hr ) )
  435. {
  436. THR( hr );
  437. SSR_FAILURE( TASKID_Minor_BeginTask_GetConnectionToObject, hr );
  438. goto Cleanup;
  439. }
  440. //
  441. // If this comes up from a Node, this is bad so change the error code
  442. // back and bail.
  443. //
  444. if ( hr == HR_S_RPC_S_SERVER_UNAVAILABLE )
  445. {
  446. //
  447. // Commented out as a fix for bug #543135 [GorN 4/11/2002]
  448. //
  449. if ( m_fUserAddedNode )
  450. {
  451. //
  452. // If it is user entered node the error is fatal.
  453. //
  454. hr = THR( HRESULT_FROM_WIN32( RPC_S_SERVER_UNAVAILABLE ) );
  455. }
  456. goto Cleanup;
  457. }
  458. hr = THR( punk->TypeSafeQI( IClusCfgServer, &pccs ) );
  459. if ( FAILED( hr ) )
  460. {
  461. SSR_FAILURE( TASKID_Minor_BeginTask_GetConnectionToObject_QI_pccs, hr );
  462. goto Cleanup;
  463. }
  464. punk->Release();
  465. punk = NULL;
  466. if ( m_fStop == TRUE )
  467. {
  468. goto Cleanup;
  469. } // if:
  470. hr = THR( pccs->GetClusterNodeInfo( &pccni ) );
  471. if ( FAILED( hr ) )
  472. {
  473. SSR_FAILURE( TASKID_Minor_BeginTask_GetClusterNodeInfo, hr );
  474. goto Cleanup;
  475. }
  476. //
  477. // Ask the Object Manager to retrieve the data format to store the information.
  478. //
  479. hr = THR( pom->GetObject( DFGUID_NodeInformation, m_cookie, &punk ) );
  480. if ( FAILED( hr ) )
  481. {
  482. SSR_FAILURE( TASKID_Minor_BeginTask_GetObject_NodeInformation, hr );
  483. goto Cleanup;
  484. }
  485. hr = THR( punk->TypeSafeQI( IGatherData, &pgd ) );
  486. if ( FAILED( hr ) )
  487. {
  488. SSR_FAILURE( TASKID_Minor_BeginTask_GetObject_NodeInformation_QI_pgd, hr );
  489. goto Cleanup;
  490. }
  491. punk->Release();
  492. punk = NULL;
  493. if ( m_fStop == TRUE )
  494. {
  495. goto Cleanup;
  496. } // if:
  497. //
  498. // Find out our parent.
  499. //
  500. hr = THR( psi->GetParent( &cookieParent ) );
  501. if ( FAILED( hr ) )
  502. {
  503. SSR_FAILURE( TASKID_Minor_BeginTask_GetParent, hr );
  504. goto Cleanup;
  505. }
  506. if ( m_fStop == TRUE )
  507. {
  508. goto Cleanup;
  509. } // if:
  510. //
  511. // Start sucking.
  512. //
  513. hr = THR( pgd->Gather( cookieParent, pccni ) );
  514. if ( FAILED( hr ) )
  515. {
  516. SSR_FAILURE( TASKID_Minor_BeginTask_Gather, hr );
  517. //
  518. // Don't goto cleanup - we need to single that the information possibly changed.
  519. //
  520. }
  521. //
  522. // At this point, we don't care if the "Gather" succeeded or failed. We
  523. // need to single that the object potentially changed.
  524. //
  525. THR( pnui->ObjectChanged( m_cookie ) );
  526. Cleanup:
  527. // Tell the UI layer we are done and the results of what was done.
  528. THR( SendStatusReport( m_bstrName,
  529. TASKID_Major_Establish_Connection,
  530. TASKID_Minor_Connecting,
  531. 0,
  532. 1,
  533. 1,
  534. hr,
  535. NULL,
  536. NULL,
  537. NULL
  538. ) );
  539. // don't care about errors from SSR at this point
  540. if ( psp != NULL )
  541. {
  542. psp->Release();
  543. }
  544. if ( pcm != NULL )
  545. {
  546. pcm->Release();
  547. }
  548. if ( pccs != NULL )
  549. {
  550. pccs->Release();
  551. }
  552. if ( pccni != NULL )
  553. {
  554. pccni->Release();
  555. }
  556. if ( punk != NULL )
  557. {
  558. punk->Release();
  559. }
  560. if ( pom != NULL )
  561. {
  562. //
  563. // Update the cookie's status indicating the result of our task.
  564. //
  565. IUnknown * punkTemp = NULL;
  566. HRESULT hr2;
  567. hr2 = THR( pom->GetObject( DFGUID_StandardInfo, m_cookie, &punkTemp ) );
  568. if ( SUCCEEDED( hr2 ) )
  569. {
  570. IStandardInfo * psiTemp = NULL;
  571. hr2 = THR( punkTemp->TypeSafeQI( IStandardInfo, &psiTemp ) );
  572. punkTemp->Release();
  573. punkTemp = NULL;
  574. if ( SUCCEEDED( hr2 ) )
  575. {
  576. // if ( hr == HR_S_RPC_S_CLUSTER_NODE_DOWN )
  577. // {
  578. // hr = HRESULT_FROM_WIN32( ERROR_CLUSTER_NODE_DOWN );
  579. // }
  580. hr2 = THR( psiTemp->SetStatus( hr ) );
  581. psiTemp->Release();
  582. psiTemp = NULL;
  583. }
  584. }
  585. hr2 = THR( pom->GetObject( DFGUID_StandardInfo, m_cookieCompletion, &punkTemp ) );
  586. if ( SUCCEEDED( hr2 ) )
  587. {
  588. IStandardInfo * psiTemp = NULL;
  589. hr2 = THR( punkTemp->TypeSafeQI( IStandardInfo, &psiTemp ) );
  590. punkTemp->Release();
  591. punkTemp = NULL;
  592. if ( SUCCEEDED( hr2 ) )
  593. {
  594. hr2 = THR( psiTemp->SetStatus( hr ) );
  595. psiTemp->Release();
  596. psiTemp = NULL;
  597. }
  598. }
  599. pom->Release();
  600. } // if: ( pom != NULL )
  601. if ( pcpc != NULL )
  602. {
  603. pcpc->Release();
  604. }
  605. if ( pcp != NULL )
  606. {
  607. pcp->Release();
  608. }
  609. if ( pnui != NULL )
  610. {
  611. if ( m_cookieCompletion != 0 )
  612. {
  613. //
  614. // Signal the cookie to indicate that we are done.
  615. //
  616. hr = THR( pnui->ObjectChanged( m_cookieCompletion ) );
  617. }
  618. pnui->Release();
  619. }
  620. if ( pgd != NULL )
  621. {
  622. pgd->Release();
  623. }
  624. if ( psi != NULL )
  625. {
  626. psi->Release();
  627. }
  628. TraceSysFreeString( bstrDisplayName );
  629. TraceSysFreeString( bstrNotification );
  630. LogMsg( L"[MT] [CTaskGatherNodeInfo] exiting task. The task was%ws cancelled.", m_fStop == FALSE ? L" not" : L"" );
  631. HRETURN( hr );
  632. } //*** CTaskGatherNodeInfo::BeginTask
  633. //////////////////////////////////////////////////////////////////////////////
  634. //
  635. // STDMETHODIMP
  636. // CTaskGatherNodeInfo::StopTask( void )
  637. //
  638. //////////////////////////////////////////////////////////////////////////////
  639. STDMETHODIMP
  640. CTaskGatherNodeInfo::StopTask( void )
  641. {
  642. TraceFunc( "[IDoTask]" );
  643. HRESULT hr = S_OK;
  644. m_fStop = TRUE;
  645. LogMsg( L"[MT] [CTaskGatherNodeInfo] is being stopped." );
  646. HRETURN( hr );
  647. } //*** StopTask
  648. //////////////////////////////////////////////////////////////////////////////
  649. //
  650. // STDMETHODIMP
  651. // CTaskGatherNodeInfo::SetCookie(
  652. // OBJECTCOOKIE cookieIn
  653. // )
  654. //
  655. //////////////////////////////////////////////////////////////////////////////
  656. STDMETHODIMP
  657. CTaskGatherNodeInfo::SetCookie(
  658. OBJECTCOOKIE cookieIn
  659. )
  660. {
  661. TraceFunc( "[ITaskGatherNodeInfo]" );
  662. HRESULT hr = S_OK;
  663. m_cookie = cookieIn;
  664. HRETURN( hr );
  665. } //*** SetCookie
  666. //////////////////////////////////////////////////////////////////////////////
  667. //
  668. // STDMETHODIMP
  669. // CTaskGatherNodeInfo::SetCompletionCookie(
  670. // OBJECTCOOKIE cookieIn
  671. // )
  672. //
  673. //////////////////////////////////////////////////////////////////////////////
  674. STDMETHODIMP
  675. CTaskGatherNodeInfo::SetCompletionCookie(
  676. OBJECTCOOKIE cookieIn
  677. )
  678. {
  679. TraceFunc( "..." );
  680. HRESULT hr = S_OK;
  681. m_cookieCompletion = cookieIn;
  682. HRETURN( hr );
  683. } //*** CTaskGatherNodeInfo::SetGatherPunk
  684. //////////////////////////////////////////////////////////////////////////////
  685. //
  686. // STDMETHODIMP
  687. // CTaskGatherNodeInfo::SetUserAddedNodeFlag(
  688. // BOOL fUserAddedNodeIn
  689. // )
  690. //
  691. //////////////////////////////////////////////////////////////////////////////
  692. STDMETHODIMP
  693. CTaskGatherNodeInfo::SetUserAddedNodeFlag(
  694. BOOL fUserAddedNodeIn
  695. )
  696. {
  697. TraceFunc( "[ITaskGatherNodeInfo]" );
  698. HRESULT hr = S_OK;
  699. m_fUserAddedNode = fUserAddedNodeIn;
  700. HRETURN( hr );
  701. } //*** SetUserAddedNodeFlag
  702. //****************************************************************************
  703. //
  704. // IClusCfgCallback
  705. //
  706. //****************************************************************************
  707. //////////////////////////////////////////////////////////////////////////////
  708. //
  709. // STDMETHODIMP
  710. // CTaskGatherNodeInfo::SendStatusReport(
  711. // LPCWSTR pcszNodeNameIn
  712. // , CLSID clsidTaskMajorIn
  713. // , CLSID clsidTaskMinorIn
  714. // , ULONG ulMinIn
  715. // , ULONG ulMaxIn
  716. // , ULONG ulCurrentIn
  717. // , HRESULT hrStatusIn
  718. // , LPCWSTR pcszDescriptionIn
  719. // , FILETIME * pftTimeIn
  720. // , LPCWSTR pcszReferenceIn
  721. // )
  722. //
  723. //////////////////////////////////////////////////////////////////////////////
  724. STDMETHODIMP
  725. CTaskGatherNodeInfo::SendStatusReport(
  726. LPCWSTR pcszNodeNameIn
  727. , CLSID clsidTaskMajorIn
  728. , CLSID clsidTaskMinorIn
  729. , ULONG ulMinIn
  730. , ULONG ulMaxIn
  731. , ULONG ulCurrentIn
  732. , HRESULT hrStatusIn
  733. , LPCWSTR pcszDescriptionIn
  734. , FILETIME * pftTimeIn
  735. , LPCWSTR pcszReferenceIn
  736. )
  737. {
  738. TraceFunc( "[IClusCfgCallback]" );
  739. Assert( pcszNodeNameIn != NULL );
  740. HRESULT hr = S_OK;
  741. IServiceProvider * psp = NULL;
  742. IConnectionPointContainer * pcpc = NULL;
  743. IConnectionPoint * pcp = NULL;
  744. FILETIME ft;
  745. if ( m_pcccb == NULL )
  746. {
  747. //
  748. // Collect the manager we need to complete this task.
  749. //
  750. hr = THR( CoCreateInstance( CLSID_ServiceManager, NULL, CLSCTX_INPROC_SERVER, TypeSafeParams( IServiceProvider, &psp ) ) );
  751. if ( FAILED( hr ) )
  752. goto Cleanup;
  753. hr = THR( psp->TypeSafeQS( CLSID_NotificationManager, IConnectionPointContainer, &pcpc ) );
  754. if ( FAILED( hr ) )
  755. goto Cleanup;
  756. hr = THR( pcpc->FindConnectionPoint( IID_IClusCfgCallback, &pcp ) );
  757. if ( FAILED( hr ) )
  758. goto Cleanup;
  759. pcp = TraceInterface( L"CConfigurationConnection!IConnectionPoint", IConnectionPoint, pcp, 1 );
  760. hr = THR( pcp->TypeSafeQI( IClusCfgCallback, &m_pcccb ) );
  761. if ( FAILED( hr ) )
  762. goto Cleanup;
  763. m_pcccb = TraceInterface( L"CConfigurationConnection!IClusCfgCallback", IClusCfgCallback, m_pcccb, 1 );
  764. psp->Release();
  765. psp = NULL;
  766. }
  767. if ( pftTimeIn == NULL )
  768. {
  769. GetSystemTimeAsFileTime( &ft );
  770. pftTimeIn = &ft;
  771. } // if:
  772. //
  773. // Send the message!
  774. //
  775. hr = THR( m_pcccb->SendStatusReport(
  776. pcszNodeNameIn != NULL ? pcszNodeNameIn : m_bstrName
  777. , clsidTaskMajorIn
  778. , clsidTaskMinorIn
  779. , ulMinIn
  780. , ulMaxIn
  781. , ulCurrentIn
  782. , hrStatusIn
  783. , pcszDescriptionIn
  784. , pftTimeIn
  785. , pcszReferenceIn
  786. ) );
  787. Cleanup:
  788. if ( psp != NULL )
  789. {
  790. psp->Release();
  791. }
  792. if ( pcpc != NULL )
  793. {
  794. pcpc->Release();
  795. }
  796. if ( pcp != NULL )
  797. {
  798. pcp->Release();
  799. }
  800. HRETURN( hr );
  801. } //*** CTaskGatherNodeInfo::SendStatusReport
  802. //////////////////////////////////////////////////////////////////////////////
  803. //
  804. // HRESULT
  805. // CTaskGatherNodeInfo::HrSendStatusReport(
  806. // LPCWSTR pcsNodeNameIn
  807. // , CLSID clsidMajorIn
  808. // , CLSID clsidMinorIn
  809. // , ULONG ulMinIn
  810. // , ULONG ulMaxIn
  811. // , ULONG ulCurrentIn
  812. // , HRESULT hrIn
  813. // , int nDescriptionIdIn
  814. // )
  815. //
  816. //////////////////////////////////////////////////////////////////////////////
  817. HRESULT
  818. CTaskGatherNodeInfo::HrSendStatusReport(
  819. LPCWSTR pcszNodeNameIn
  820. , CLSID clsidMajorIn
  821. , CLSID clsidMinorIn
  822. , ULONG ulMinIn
  823. , ULONG ulMaxIn
  824. , ULONG ulCurrentIn
  825. , HRESULT hrIn
  826. , int nDescriptionIdIn
  827. , int nReferenceIdIn // = 0
  828. )
  829. {
  830. TraceFunc( "" );
  831. HRESULT hr = S_OK;
  832. BSTR bstr = NULL;
  833. BSTR bReference = NULL;
  834. hr = THR( HrLoadStringIntoBSTR( g_hInstance, nDescriptionIdIn, &bstr ) );
  835. if ( FAILED( hr ) )
  836. {
  837. goto Cleanup;
  838. } // if:
  839. if ( nReferenceIdIn != 0 )
  840. {
  841. //
  842. // Even though we failed to load the reference, we still would like the user to learn
  843. // about whatever report we were going to send...
  844. //
  845. THR( HrLoadStringIntoBSTR( g_hInstance, nReferenceIdIn, &bReference ) );
  846. } // if:
  847. hr = THR( SendStatusReport( pcszNodeNameIn, clsidMajorIn, clsidMinorIn, ulMinIn, ulMaxIn, ulCurrentIn, hrIn, bstr, NULL, bReference ) );
  848. Cleanup:
  849. TraceSysFreeString( bReference );
  850. TraceSysFreeString( bstr );
  851. HRETURN( hr );
  852. } //*** CTaskGatherNodeInfo::HrSendStatusReport