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.

1025 lines
25 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000-2001 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // CClusCfgCallback.cpp
  7. //
  8. // Description:
  9. // This file contains the definition of the CClusCfgCallback
  10. // class.
  11. //
  12. // The class CClusCfgCallback inplements the callback
  13. // interface between this server and its clients. It implements the
  14. // IClusCfgCallback interface.
  15. //
  16. // Documentation:
  17. //
  18. // Header File:
  19. // CClusCfgCallback.h
  20. //
  21. // Maintained By:
  22. // Galen Barbee (GalenB) 22-FEB-2000
  23. //
  24. //////////////////////////////////////////////////////////////////////////////
  25. //////////////////////////////////////////////////////////////////////////////
  26. // Include Files
  27. //////////////////////////////////////////////////////////////////////////////
  28. #include "pch.h"
  29. #include "CClusCfgCallback.h"
  30. //////////////////////////////////////////////////////////////////////////////
  31. // Constant Definitions
  32. //////////////////////////////////////////////////////////////////////////////
  33. DEFINE_THISCLASS( "CClusCfgCallback" );
  34. //*************************************************************************//
  35. /////////////////////////////////////////////////////////////////////////////
  36. // CClusCfgCallback class
  37. /////////////////////////////////////////////////////////////////////////////
  38. //////////////////////////////////////////////////////////////////////////////
  39. //++
  40. //
  41. // CClusCfgCallback::S_HrCreateInstance
  42. //
  43. // Description:
  44. // Create a CClusCfgCallback instance.
  45. //
  46. // Arguments:
  47. // ppunkOut
  48. // The IUnknown interface of the newly created object.
  49. //
  50. // Return Values:
  51. // S_OK
  52. // Success.
  53. //
  54. // E_OUTOFMEMORY
  55. // Out of memory.
  56. //
  57. // other HRESULTs
  58. // Object initialization failed.
  59. //
  60. //--
  61. //////////////////////////////////////////////////////////////////////////////
  62. HRESULT
  63. CClusCfgCallback::S_HrCreateInstance( IUnknown ** ppunkOut )
  64. {
  65. TraceFunc( "" );
  66. HRESULT hr;
  67. CClusCfgCallback * lpccs = NULL;
  68. if ( ppunkOut == NULL )
  69. {
  70. hr = THR( E_POINTER );
  71. goto Cleanup;
  72. } // if:
  73. lpccs = new CClusCfgCallback();
  74. if ( lpccs == NULL )
  75. {
  76. hr = THR( E_OUTOFMEMORY );
  77. goto Cleanup;
  78. } // if: error allocating object
  79. hr = THR( lpccs->HrInit() );
  80. if ( FAILED( hr ) )
  81. {
  82. goto Cleanup;
  83. } // if: HrInit() succeeded
  84. hr = THR( lpccs->TypeSafeQI( IUnknown, ppunkOut ) );
  85. Cleanup:
  86. if ( lpccs != NULL )
  87. {
  88. lpccs->Release();
  89. } // if:
  90. if ( FAILED( hr ) )
  91. {
  92. LogMsg( L"[SRV] CClusCfgCallback::S_HrCreateInstance() failed. (hr = %#08x)", hr );
  93. } // if:
  94. HRETURN( hr );
  95. } //*** CClusCfgCallback::S_HrCreateInstance
  96. //////////////////////////////////////////////////////////////////////////////
  97. //++
  98. //
  99. // CClusCfgCallback::CClusCfgCallback
  100. //
  101. // Description:
  102. // Constructor of the CClusCfgCallback class. This initializes
  103. // the m_cRef variable to 1 instead of 0 to account of possible
  104. // QueryInterface failure in DllGetClassObject.
  105. //
  106. // Arguments:
  107. // None.
  108. //
  109. // Return Value:
  110. // None.
  111. //
  112. // Remarks:
  113. // None.
  114. //
  115. //--
  116. //////////////////////////////////////////////////////////////////////////////
  117. CClusCfgCallback::CClusCfgCallback( void )
  118. : m_cRef( 1 )
  119. {
  120. TraceFunc( "" );
  121. // Increment the count of components in memory so the DLL hosting this
  122. // object cannot be unloaded.
  123. InterlockedIncrement( &g_cObjects );
  124. Assert( m_pccc == NULL );
  125. Assert( m_hEvent == NULL );
  126. Assert( m_pcszNodeName == NULL );
  127. Assert( m_pclsidTaskMajor == NULL );
  128. Assert( m_pclsidTaskMinor == NULL );
  129. Assert( m_pulMin == NULL );
  130. Assert( m_pulMax == NULL );
  131. Assert( m_pulCurrent == NULL );
  132. Assert( m_phrStatus == NULL );
  133. Assert( m_pcszDescription == NULL );
  134. Assert( m_pftTime == NULL );
  135. Assert( m_pcszReference == NULL );
  136. Assert( !m_fPollingMode );
  137. Assert( m_bstrNodeName == NULL );
  138. Assert( m_plLogger == NULL );
  139. TraceFuncExit();
  140. } //*** CClusCfgCallback::CClusCfgCallback
  141. //////////////////////////////////////////////////////////////////////////////
  142. //++
  143. //
  144. // CClusCfgCallback::~CClusCfgCallback
  145. //
  146. // Description:
  147. // Desstructor of the CClusCfgCallback class.
  148. //
  149. // Arguments:
  150. // None.
  151. //
  152. // Return Value:
  153. // None.
  154. //
  155. // Remarks:
  156. // None.
  157. //
  158. //--
  159. //////////////////////////////////////////////////////////////////////////////
  160. CClusCfgCallback::~CClusCfgCallback( void )
  161. {
  162. TraceFunc( "" );
  163. if ( m_hEvent != NULL )
  164. {
  165. if ( CloseHandle( m_hEvent ) == false )
  166. {
  167. TW32( GetLastError() );
  168. LogMsg( L"[SRV] Cannot close event handle. (sc = %#08x)", GetLastError() );
  169. }
  170. } // if:
  171. TraceSysFreeString( m_bstrNodeName );
  172. if ( m_pccc != NULL )
  173. {
  174. m_pccc->Release();
  175. } // if:
  176. if ( m_plLogger != NULL )
  177. {
  178. m_plLogger->Release();
  179. } // if:
  180. // There's going to be one less component in memory. Decrement component count.
  181. InterlockedDecrement( &g_cObjects );
  182. TraceFuncExit();
  183. } //*** CClusCfgCallback::~CClusCfgCallback
  184. //////////////////////////////////////////////////////////////////////////////
  185. //++
  186. //
  187. // CClusterConfigurationInfo::SendStatusReport
  188. //
  189. // Description:
  190. //
  191. // Arguments:
  192. //
  193. // Return Value:
  194. //
  195. // Remarks:
  196. // None.
  197. //
  198. //--
  199. //////////////////////////////////////////////////////////////////////////////
  200. STDMETHODIMP
  201. CClusCfgCallback::SendStatusReport(
  202. CLSID clsidTaskMajorIn,
  203. CLSID clsidTaskMinorIn,
  204. ULONG ulMinIn,
  205. ULONG ulMaxIn,
  206. ULONG ulCurrentIn,
  207. HRESULT hrStatusIn,
  208. const WCHAR * pcszDescriptionIn
  209. )
  210. {
  211. TraceFunc1( "pcszDescriptionIn = '%ls'", pcszDescriptionIn == NULL ? L"<null>" : pcszDescriptionIn );
  212. HRESULT hr = S_OK;
  213. BSTR bstrDescription = NULL;
  214. FILETIME ft;
  215. bstrDescription = TraceSysAllocString( pcszDescriptionIn );
  216. if ( bstrDescription == NULL )
  217. {
  218. hr = THR( E_OUTOFMEMORY );
  219. goto Cleanup;
  220. } // if:
  221. GetSystemTimeAsFileTime( &ft );
  222. hr = THR( SendStatusReport(
  223. NULL,
  224. clsidTaskMajorIn,
  225. clsidTaskMinorIn,
  226. ulMinIn,
  227. ulMaxIn,
  228. ulCurrentIn,
  229. hrStatusIn,
  230. bstrDescription,
  231. &ft,
  232. NULL
  233. ) );
  234. Cleanup:
  235. TraceSysFreeString( bstrDescription );
  236. HRETURN( hr );
  237. } //*** CClusCfgCallback::SendStatusReport
  238. //////////////////////////////////////////////////////////////////////////////
  239. //++
  240. //
  241. // CClusterConfigurationInfo::SendStatusReport
  242. //
  243. // Description:
  244. //
  245. // Arguments:
  246. //
  247. // Return Value:
  248. //
  249. // Remarks:
  250. // None.
  251. //
  252. //--
  253. //////////////////////////////////////////////////////////////////////////////
  254. STDMETHODIMP
  255. CClusCfgCallback::SendStatusReport(
  256. CLSID clsidTaskMajorIn,
  257. CLSID clsidTaskMinorIn,
  258. ULONG ulMinIn,
  259. ULONG ulMaxIn,
  260. ULONG ulCurrentIn,
  261. HRESULT hrStatusIn,
  262. DWORD dwDescriptionIn
  263. )
  264. {
  265. TraceFunc1( "dwDescriptionIn = %d", dwDescriptionIn );
  266. HRESULT hr = S_OK;
  267. BSTR bstrDescription = NULL;
  268. FILETIME ft;
  269. hr = THR( HrLoadStringIntoBSTR( g_hInstance, dwDescriptionIn, &bstrDescription ) );
  270. if ( FAILED( hr ) )
  271. {
  272. goto Cleanup;
  273. } // if:
  274. GetSystemTimeAsFileTime( &ft );
  275. hr = THR( SendStatusReport(
  276. NULL,
  277. clsidTaskMajorIn,
  278. clsidTaskMinorIn,
  279. ulMinIn,
  280. ulMaxIn,
  281. ulCurrentIn,
  282. hrStatusIn,
  283. bstrDescription,
  284. &ft,
  285. NULL
  286. ) );
  287. Cleanup:
  288. TraceSysFreeString( bstrDescription );
  289. HRETURN( hr );
  290. } //*** CClusCfgCallback::SendStatusReport
  291. //*************************************************************************//
  292. /////////////////////////////////////////////////////////////////////////////
  293. // CClusCfgCallback -- IUnknown interface.
  294. /////////////////////////////////////////////////////////////////////////////
  295. //////////////////////////////////////////////////////////////////////////////
  296. //++
  297. //
  298. // STDMETHODIMP_( ULONG )
  299. // CClusCfgCallback:: [IUNKNOWN] AddRef
  300. //
  301. // Description:
  302. // Increment the reference count of this object by one.
  303. //
  304. // Arguments:
  305. // None.
  306. //
  307. // Return Value:
  308. // The new reference count.
  309. //
  310. // Remarks:
  311. // None.
  312. //
  313. //--
  314. //////////////////////////////////////////////////////////////////////////////
  315. STDMETHODIMP_( ULONG )
  316. CClusCfgCallback::AddRef( void )
  317. {
  318. TraceFunc( "[IUnknown]" );
  319. InterlockedIncrement( & m_cRef );
  320. RETURN( m_cRef );
  321. } //*** CClusCfgCallback::AddRef
  322. //////////////////////////////////////////////////////////////////////////////
  323. //++
  324. //
  325. // STDMETHODIMP_( ULONG )
  326. // CClusCfgCallback:: [IUNKNOWN] Release
  327. //
  328. // Description:
  329. // Decrement the reference count of this object by one.
  330. //
  331. // Arguments:
  332. // None.
  333. //
  334. // Return Value:
  335. // The new reference count.
  336. //
  337. // Remarks:
  338. // None.
  339. //
  340. //--
  341. //////////////////////////////////////////////////////////////////////////////
  342. STDMETHODIMP_( ULONG )
  343. CClusCfgCallback::Release( void )
  344. {
  345. TraceFunc( "[IUnknown]" );
  346. InterlockedDecrement( &m_cRef );
  347. if ( m_cRef > 0 )
  348. {
  349. RETURN( m_cRef );
  350. } // if: reference count equal to zero
  351. TraceDo( delete this );
  352. RETURN( 0 );
  353. } //*** CClusCfgCallback::Release
  354. //////////////////////////////////////////////////////////////////////////////
  355. //++
  356. //
  357. // CClusCfgCallback:: [INKNOWN] QueryInterface
  358. //
  359. // Description:
  360. // Query this object for the passed in interface.
  361. //
  362. // Arguments:
  363. // IN REFIID riid,
  364. // Id of interface requested.
  365. //
  366. // OUT void ** ppv
  367. // Pointer to the requested interface.
  368. //
  369. // Return Value:
  370. // S_OK
  371. // If the interface is available on this object.
  372. //
  373. // E_NOINTERFACE
  374. // If the interface is not available.
  375. //
  376. // Remarks:
  377. // None.
  378. //
  379. //--
  380. //////////////////////////////////////////////////////////////////////////////
  381. STDMETHODIMP
  382. CClusCfgCallback::QueryInterface( REFIID riid, void ** ppv )
  383. {
  384. TraceQIFunc( riid, ppv );
  385. HRESULT hr = E_NOINTERFACE;
  386. if ( IsEqualIID( riid, IID_IUnknown ) )
  387. {
  388. *ppv = static_cast< IClusCfgCallback * >( this );
  389. hr = S_OK;
  390. } // if: IUnknown
  391. else if ( IsEqualIID( riid, IID_IClusCfgCallback ) )
  392. {
  393. *ppv = TraceInterface( __THISCLASS__, IClusCfgCallback, this, 0 );
  394. hr = S_OK;
  395. } // else if:
  396. else if ( IsEqualIID( riid, IID_IClusCfgInitialize ) )
  397. {
  398. *ppv = TraceInterface( __THISCLASS__, IClusCfgInitialize, this, 0 );
  399. hr = S_OK;
  400. } // else if:
  401. else if ( IsEqualIID( riid, IID_IClusCfgPollingCallback ) )
  402. {
  403. *ppv = TraceInterface( __THISCLASS__, IClusCfgPollingCallback, this, 0 );
  404. hr = S_OK;
  405. } // else if:
  406. else if ( IsEqualIID( riid, IID_IClusCfgSetPollingCallback ) )
  407. {
  408. *ppv = TraceInterface( __THISCLASS__, IClusCfgSetPollingCallback, this, 0 );
  409. hr = S_OK;
  410. } // else if:
  411. if ( SUCCEEDED( hr ) )
  412. {
  413. ((IUnknown *) *ppv)->AddRef( );
  414. } // if: success
  415. QIRETURN_IGNORESTDMARSHALLING( hr, riid );
  416. } //*** CClusCfgCallback::QueryInterface
  417. //*************************************************************************//
  418. /////////////////////////////////////////////////////////////////////////////
  419. // CClusCfgCallback -- IClusCfgCallback interface.
  420. /////////////////////////////////////////////////////////////////////////////
  421. //////////////////////////////////////////////////////////////////////////////
  422. //++
  423. //
  424. // CClusterConfigurationInfo::SendStatusReport
  425. //
  426. // Description:
  427. //
  428. // Arguments:
  429. //
  430. // Return Value:
  431. //
  432. // Remarks:
  433. // None.
  434. //
  435. //--
  436. //////////////////////////////////////////////////////////////////////////////
  437. STDMETHODIMP
  438. CClusCfgCallback::SendStatusReport(
  439. LPCWSTR pcszNodeNameIn,
  440. CLSID clsidTaskMajorIn,
  441. CLSID clsidTaskMinorIn,
  442. ULONG ulMinIn,
  443. ULONG ulMaxIn,
  444. ULONG ulCurrentIn,
  445. HRESULT hrStatusIn,
  446. LPCWSTR pcszDescriptionIn,
  447. FILETIME * pftTimeIn,
  448. LPCWSTR pcszReferenceIn
  449. )
  450. {
  451. TraceFunc1( "[IClusCfgCallback] pcszDescriptionIn = '%s'", pcszDescriptionIn == NULL ? TEXT("<null>") : pcszDescriptionIn );
  452. HRESULT hr = S_OK;
  453. if ( pcszNodeNameIn == NULL )
  454. {
  455. pcszNodeNameIn = m_bstrNodeName;
  456. } // if:
  457. TraceMsg( mtfFUNC, L"pcszNodeNameIn = %s", pcszNodeNameIn );
  458. TraceMsgGUID( mtfFUNC, "clsidTaskMajorIn ", clsidTaskMajorIn );
  459. TraceMsgGUID( mtfFUNC, "clsidTaskMinorIn ", clsidTaskMinorIn );
  460. TraceMsg( mtfFUNC, L"ulMinIn = %u", ulMinIn );
  461. TraceMsg( mtfFUNC, L"ulMaxIn = %u", ulMaxIn );
  462. TraceMsg( mtfFUNC, L"ulCurrentIn = %u", ulCurrentIn );
  463. TraceMsg( mtfFUNC, L"hrStatusIn = %#x", hrStatusIn );
  464. TraceMsg( mtfFUNC, L"pcszDescriptionIn = '%ws'", ( pcszDescriptionIn ? pcszDescriptionIn : L"<null>" ) );
  465. //
  466. // TODO: 21 NOV 2000 GalenB
  467. //
  468. // How do we log pftTimeIn?
  469. //
  470. TraceMsg( mtfFUNC, L"pcszReferenceIn = '%ws'", ( pcszReferenceIn ? pcszReferenceIn : L"<null>" ) );
  471. hr = THR( CClCfgSrvLogger::S_HrLogStatusReport(
  472. m_plLogger
  473. , pcszNodeNameIn
  474. , clsidTaskMajorIn
  475. , clsidTaskMinorIn
  476. , ulMinIn
  477. , ulMaxIn
  478. , ulCurrentIn
  479. , hrStatusIn
  480. , pcszDescriptionIn
  481. , pftTimeIn
  482. , pcszReferenceIn
  483. ) );
  484. // Local logging - don't send up
  485. if ( IsEqualIID( clsidTaskMajorIn, TASKID_Major_Server_Log ) )
  486. {
  487. goto Cleanup;
  488. } // if:
  489. if ( m_fPollingMode )
  490. {
  491. Assert( m_pccc == NULL );
  492. TraceMsg( mtfFUNC, L"[SRV] Sending the status message with polling." );
  493. hr = THR( HrQueueStatusReport(
  494. pcszNodeNameIn,
  495. clsidTaskMajorIn,
  496. clsidTaskMinorIn,
  497. ulMinIn,
  498. ulMaxIn,
  499. ulCurrentIn,
  500. hrStatusIn,
  501. pcszDescriptionIn,
  502. pftTimeIn,
  503. pcszReferenceIn
  504. ) );
  505. } // if:
  506. else if ( m_pccc != NULL )
  507. {
  508. TraceMsg( mtfFUNC, L"[SRV] Sending the status message without polling." );
  509. hr = THR( m_pccc->SendStatusReport(
  510. pcszNodeNameIn,
  511. clsidTaskMajorIn,
  512. clsidTaskMinorIn,
  513. ulMinIn,
  514. ulMaxIn,
  515. ulCurrentIn,
  516. hrStatusIn,
  517. pcszDescriptionIn,
  518. pftTimeIn,
  519. pcszReferenceIn
  520. ) );
  521. } // else if:
  522. else
  523. {
  524. LogMsg( L"[SRV] Neither a polling callback or a regular callback were found. No messages are being sent to anyone!" );
  525. } // else:
  526. Cleanup:
  527. HRETURN( hr );
  528. } //*** CClusCfgCallback::SendStatusReport
  529. //*************************************************************************//
  530. /////////////////////////////////////////////////////////////////////////////
  531. // CClusCfgCallback -- IClusCfgPollingCallback interface.
  532. /////////////////////////////////////////////////////////////////////////////
  533. //////////////////////////////////////////////////////////////////////////////
  534. //++
  535. //
  536. // CClusterConfigurationInfo::GetStatusReport
  537. //
  538. // Description:
  539. //
  540. // Arguments:
  541. //
  542. // Return Value:
  543. //
  544. // Remarks:
  545. // None.
  546. //
  547. //--
  548. //////////////////////////////////////////////////////////////////////////////
  549. STDMETHODIMP
  550. CClusCfgCallback::GetStatusReport(
  551. BSTR * pbstrNodeNameOut,
  552. CLSID * pclsidTaskMajorOut,
  553. CLSID * pclsidTaskMinorOut,
  554. ULONG * pulMinOut,
  555. ULONG * pulMaxOut,
  556. ULONG * pulCurrentOut,
  557. HRESULT * phrStatusOut,
  558. BSTR * pbstrDescriptionOut,
  559. FILETIME * pftTimeOut,
  560. BSTR * pbstrReferenceOut
  561. )
  562. {
  563. TraceFunc( "[IClusCfgPollingCallback]" );
  564. HRESULT hr;
  565. DWORD sc;
  566. sc = WaitForSingleObject( m_hEvent, 0 );
  567. if ( sc == WAIT_FAILED )
  568. {
  569. sc = TW32( GetLastError() );
  570. hr = HRESULT_FROM_WIN32( sc );
  571. goto Cleanup;
  572. } // if:
  573. if ( sc == WAIT_TIMEOUT )
  574. {
  575. Assert( *m_pcszNodeName != NULL );
  576. *pbstrNodeNameOut = SysAllocString( m_pcszNodeName );
  577. if ( *pbstrNodeNameOut == NULL )
  578. {
  579. goto OutOfMemory;
  580. } // if:
  581. *pclsidTaskMajorOut = *m_pclsidTaskMajor;
  582. *pclsidTaskMinorOut = *m_pclsidTaskMinor;
  583. *pulMinOut = *m_pulMin;
  584. *pulMaxOut = *m_pulMax;
  585. *pulCurrentOut = *m_pulCurrent;
  586. *phrStatusOut = *m_phrStatus;
  587. *pftTimeOut = *m_pftTime;
  588. if ( m_pcszDescription != NULL )
  589. {
  590. *pbstrDescriptionOut = SysAllocString( m_pcszDescription );
  591. if ( *pbstrDescriptionOut == NULL )
  592. {
  593. goto OutOfMemory;
  594. } // if:
  595. } // if:
  596. else
  597. {
  598. *pbstrDescriptionOut = NULL;
  599. } // else:
  600. if ( m_pcszReference != NULL )
  601. {
  602. *pbstrReferenceOut = SysAllocString( m_pcszReference );
  603. if ( *pbstrReferenceOut == NULL )
  604. {
  605. goto OutOfMemory;
  606. } // if:
  607. } // if:
  608. else
  609. {
  610. *pbstrReferenceOut = NULL;
  611. } // else:
  612. hr = S_OK;
  613. } // if: event was not signaled
  614. else
  615. {
  616. hr = S_FALSE;
  617. } // else: event was signaled
  618. goto Cleanup;
  619. OutOfMemory:
  620. hr = E_OUTOFMEMORY;
  621. Cleanup:
  622. HRETURN( hr );
  623. } //*** CClusCfgCallback::GetStatusReport
  624. //////////////////////////////////////////////////////////////////////////////
  625. //++
  626. //
  627. // CClusterConfigurationInfo::SetHResult
  628. //
  629. // Description:
  630. //
  631. // Arguments:
  632. //
  633. // Return Value:
  634. //
  635. // Remarks:
  636. // None.
  637. //
  638. //--
  639. //////////////////////////////////////////////////////////////////////////////
  640. STDMETHODIMP
  641. CClusCfgCallback::SetHResult( HRESULT hrIn )
  642. {
  643. TraceFunc( "[IClusCfgPollingCallback]" );
  644. HRESULT hr = S_OK;
  645. DWORD sc;
  646. m_hr = hrIn;
  647. if ( hrIn != S_OK )
  648. {
  649. LogMsg( L"[SRV] SetHResult(). (hrIn = %#08x)", hrIn );
  650. } // if:
  651. if ( !SetEvent( m_hEvent ) )
  652. {
  653. sc = TW32( GetLastError() );
  654. hr = HRESULT_FROM_WIN32( sc );
  655. LogMsg( L"[SRV] Could not signal event. (hr = %#08x)", hr );
  656. } // if:
  657. HRETURN( hr );
  658. } //*** CClusCfgCallback::SetHResult
  659. //*************************************************************************//
  660. /////////////////////////////////////////////////////////////////////////////
  661. // CClusCfgCallback -- IClusCfgInitialize interface.
  662. /////////////////////////////////////////////////////////////////////////////
  663. //////////////////////////////////////////////////////////////////////////////
  664. //++
  665. //
  666. // CClusterConfigurationInfo::Initialize
  667. //
  668. // Description:
  669. //
  670. // Arguments:
  671. //
  672. // Return Value:
  673. //
  674. // Remarks:
  675. // None.
  676. //
  677. //--
  678. //////////////////////////////////////////////////////////////////////////////
  679. STDMETHODIMP
  680. CClusCfgCallback::Initialize( IUnknown * punkCallbackIn, LCID lcidIn )
  681. {
  682. TraceFunc( "[IClusCfgInitialize]" );
  683. Assert( m_pccc == NULL );
  684. HRESULT hr = S_OK;
  685. m_lcid = lcidIn;
  686. //
  687. // KB: 13 DEC 2000 GalenB
  688. //
  689. // If the passed in callback object is NULL then we had better be doing a polling
  690. // callback!
  691. //
  692. if ( punkCallbackIn != NULL )
  693. {
  694. Assert( !m_fPollingMode );
  695. hr = THR( punkCallbackIn->TypeSafeQI( IClusCfgCallback, &m_pccc ) );
  696. } // if:
  697. else
  698. {
  699. Assert( m_fPollingMode );
  700. } // else:
  701. HRETURN( hr );
  702. } //*** CClusCfgCallback::Initialize
  703. //*************************************************************************//
  704. /////////////////////////////////////////////////////////////////////////////
  705. // CClusCfgCallback -- IClusCfgSetPollingCallback interface.
  706. /////////////////////////////////////////////////////////////////////////////
  707. //////////////////////////////////////////////////////////////////////////////
  708. //++
  709. //
  710. // CClusCfgCallback::SetPollingMode
  711. //
  712. // Description:
  713. //
  714. // Arguments:
  715. //
  716. // Return Value:
  717. //
  718. // Remarks:
  719. // None.
  720. //
  721. //--
  722. //////////////////////////////////////////////////////////////////////////////
  723. STDMETHODIMP
  724. CClusCfgCallback::SetPollingMode( BOOL fUsePollingModeIn )
  725. {
  726. TraceFunc( "[IClusCfgPollingCallback]" );
  727. HRESULT hr = S_OK;
  728. m_fPollingMode = fUsePollingModeIn;
  729. HRETURN( hr );
  730. } //*** CClusCfgCallback::SetPollingMode
  731. //*************************************************************************//
  732. /////////////////////////////////////////////////////////////////////////////
  733. // CClusCfgCallback class -- Private Methods.
  734. /////////////////////////////////////////////////////////////////////////////
  735. //////////////////////////////////////////////////////////////////////////////
  736. //++
  737. //
  738. // CClusCfgCallback::HrInit
  739. //
  740. // Description:
  741. // Initialize this component.
  742. //
  743. // Arguments:
  744. // None.
  745. //
  746. // Return Value:
  747. //
  748. //
  749. // Remarks:
  750. // None.
  751. //
  752. //--
  753. //////////////////////////////////////////////////////////////////////////////
  754. HRESULT
  755. CClusCfgCallback::HrInit( void )
  756. {
  757. TraceFunc( "" );
  758. HRESULT hr = S_OK;
  759. DWORD sc;
  760. //
  761. // Create the event in a signaled state. To prevent MT polling task from grabbing
  762. // bad/empty data.
  763. //
  764. m_hEvent = CreateEvent( NULL, TRUE, TRUE, NULL );
  765. if ( m_hEvent == NULL )
  766. {
  767. sc = TW32( GetLastError() );
  768. hr = HRESULT_FROM_WIN32( sc );
  769. LogMsg( L"[SRV] Could not create event. (hr = %#08x)", hr );
  770. goto Cleanup;
  771. } // if:
  772. //
  773. // Save off the local computer name.
  774. //
  775. hr = THR( HrGetComputerName( ComputerNameDnsFullyQualified, &m_bstrNodeName ) );
  776. if ( FAILED( hr ) )
  777. goto Cleanup;
  778. //
  779. // Get a ClCfgSrv ILogger instance.
  780. //
  781. hr = CClCfgSrvLogger::S_HrGetLogger( &m_plLogger );
  782. if ( FAILED( hr ) )
  783. goto Cleanup;
  784. Cleanup:
  785. HRETURN( hr );
  786. } //*** CClusCfgCallback::HrInit
  787. //////////////////////////////////////////////////////////////////////////////
  788. //++
  789. //
  790. // CClusterConfigurationInfo::HrQueueStatusReport
  791. //
  792. // Description:
  793. //
  794. // Arguments:
  795. //
  796. // Return Value:
  797. //
  798. // Remarks:
  799. // None.
  800. //
  801. //--
  802. //////////////////////////////////////////////////////////////////////////////
  803. HRESULT
  804. CClusCfgCallback::HrQueueStatusReport(
  805. LPCWSTR pcszNodeNameIn,
  806. CLSID clsidTaskMajorIn,
  807. CLSID clsidTaskMinorIn,
  808. ULONG ulMinIn,
  809. ULONG ulMaxIn,
  810. ULONG ulCurrentIn,
  811. HRESULT hrStatusIn,
  812. LPCWSTR pcszDescriptionIn,
  813. FILETIME * pftTimeIn,
  814. LPCWSTR pcszReferenceIn
  815. )
  816. {
  817. TraceFunc( "" );
  818. HRESULT hr = S_OK;
  819. DWORD sc;
  820. MSG msg;
  821. m_pcszNodeName = pcszNodeNameIn;
  822. m_pclsidTaskMajor = &clsidTaskMajorIn;
  823. m_pclsidTaskMinor = &clsidTaskMinorIn;
  824. m_pulMin = &ulMinIn;
  825. m_pulMax = &ulMaxIn;
  826. m_pulCurrent = &ulCurrentIn;
  827. m_phrStatus = &hrStatusIn;
  828. m_pcszDescription = pcszDescriptionIn;
  829. m_pftTime = pftTimeIn,
  830. m_pcszReference = pcszReferenceIn;
  831. if ( !ResetEvent( m_hEvent ) )
  832. {
  833. sc = TW32( GetLastError() );
  834. hr = HRESULT_FROM_WIN32( sc );
  835. LogMsg( L"[SRV] Could not reset event. (hr = %#08x)", hr );
  836. goto Cleanup;
  837. } // if:
  838. for ( sc = (DWORD) -1; sc != WAIT_OBJECT_0; )
  839. {
  840. while ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
  841. {
  842. TranslateMessage( &msg );
  843. DispatchMessage( &msg );
  844. } // while: PeekMessage
  845. sc = MsgWaitForMultipleObjects( 1, &m_hEvent, FALSE, INFINITE, QS_ALLEVENTS | QS_ALLINPUT | QS_ALLPOSTMESSAGE );
  846. if ( sc == -1 )
  847. {
  848. sc = TW32( GetLastError() );
  849. hr = HRESULT_FROM_WIN32( sc );
  850. LogMsg( L"[SRV] MsgWaitForMultipleObjects failed. (hr = %#08x)", hr );
  851. goto Cleanup;
  852. } // if:
  853. } // for:
  854. hr = m_hr;
  855. Cleanup:
  856. HRETURN( hr );
  857. } //*** CClusCfgCallback::HrQueueStatusReport