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.

162 lines
2.4 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. sink.cxx
  5. Abstract:
  6. Implements the ADMIN_SINK object.
  7. Author:
  8. Keith Moore (keithmo) 05-Feb-1997
  9. Revision History:
  10. --*/
  11. #include "precomp.hxx"
  12. #pragma hdrstop
  13. //
  14. // Private constants.
  15. //
  16. //
  17. // Private types.
  18. //
  19. //
  20. // Private globals.
  21. //
  22. //
  23. // Private prototypes.
  24. //
  25. //
  26. // Public functions.
  27. //
  28. ADMIN_SINK::ADMIN_SINK()
  29. {
  30. //
  31. // Put everything into a known state.
  32. //
  33. m_StateChangeEvent = NULL;
  34. } // ADMIN_SINK::ADMIN_SINK
  35. ADMIN_SINK::~ADMIN_SINK()
  36. {
  37. //
  38. // Zap the state change event.
  39. //
  40. if( m_StateChangeEvent != NULL ) {
  41. CloseHandle( m_StateChangeEvent );
  42. m_StateChangeEvent = NULL;
  43. }
  44. } // ADMIN_SINK::~ADMIN_SINK
  45. HRESULT
  46. ADMIN_SINK::Initialize(
  47. IN IUnknown * Object
  48. )
  49. {
  50. HRESULT result;
  51. result = BASE_ADMIN_SINK::Initialize( Object );
  52. if( SUCCEEDED(result) ) {
  53. m_StateChangeEvent = CreateEvent(
  54. NULL, // lpEventAttributes
  55. FALSE, // bManualReset
  56. FALSE, // bInitialState
  57. NULL // lpName
  58. );
  59. if( m_StateChangeEvent == NULL ) {
  60. DWORD err = GetLastError();
  61. result = HRESULT_FROM_WIN32( err );
  62. }
  63. }
  64. return result;
  65. } // ADMIN_SINK::Initialize
  66. HRESULT
  67. STDMETHODCALLTYPE
  68. ADMIN_SINK::SinkNotify(
  69. IN DWORD NumElements,
  70. IN MD_CHANGE_OBJECT ChangeList[]
  71. )
  72. {
  73. DWORD numIds;
  74. DWORD *idList;
  75. //
  76. // Scan the change list. If MD_SERVER_STATE has changed, set the
  77. // change event so the polling loop will exit.
  78. //
  79. for( ; NumElements > 0 ; NumElements--, ChangeList++ ) {
  80. numIds = ChangeList->dwMDNumDataIDs;
  81. idList = ChangeList->pdwMDDataIDs;
  82. for( ; numIds > 0 ; numIds--, idList++ ) {
  83. if( *idList == MD_SERVER_STATE ) {
  84. SetEvent( m_StateChangeEvent );
  85. break;
  86. }
  87. }
  88. }
  89. return NO_ERROR;
  90. } // ADMIN_SINK::SinkNotify
  91. DWORD
  92. ADMIN_SINK::WaitForStateChange(
  93. IN DWORD Timeout
  94. )
  95. {
  96. return WaitForSingleObject(
  97. m_StateChangeEvent,
  98. Timeout
  99. );
  100. } // ADMIN_SINK::WaitForStateChange
  101. //
  102. // Private functions.
  103. //