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.

107 lines
3.2 KiB

  1. #include "stdafx.h"
  2. #include "pwsform.h"
  3. #include <pwsdata.hxx>
  4. #include "Title.h"
  5. #include "HotLink.h"
  6. #include "PWSChart.h"
  7. #include "EdDir.h"
  8. #include "FormMain.h"
  9. #include "FormAdv.h"
  10. extern CFormMain* g_FormMain;
  11. extern CFormAdvanced* g_FormAdv;
  12. //--------------------------------------------------------------------
  13. CImpIMSAdminBaseSink::CImpIMSAdminBaseSink()
  14. {
  15. m_dwRefCount=0;
  16. }
  17. //--------------------------------------------------------------------
  18. CImpIMSAdminBaseSink::~CImpIMSAdminBaseSink()
  19. {
  20. }
  21. //--------------------------------------------------------------------
  22. HRESULT
  23. CImpIMSAdminBaseSink::QueryInterface(REFIID riid, void **ppObject) {
  24. if (riid==IID_IUnknown || riid==IID_IMSAdminBaseSink) {
  25. *ppObject = (IMSAdminBaseSink*) this;
  26. }
  27. else {
  28. return E_NOINTERFACE;
  29. }
  30. AddRef();
  31. return NO_ERROR;
  32. }
  33. //--------------------------------------------------------------------
  34. ULONG
  35. CImpIMSAdminBaseSink::AddRef()
  36. {
  37. DWORD dwRefCount;
  38. dwRefCount = InterlockedIncrement((long *)&m_dwRefCount);
  39. return dwRefCount;
  40. }
  41. //--------------------------------------------------------------------
  42. ULONG
  43. CImpIMSAdminBaseSink::Release()
  44. {
  45. DWORD dwRefCount;
  46. dwRefCount = InterlockedDecrement((long *)&m_dwRefCount);
  47. if (dwRefCount == 0) {
  48. delete this;
  49. }
  50. return dwRefCount;
  51. }
  52. //--------------------------------------------------------------------
  53. HRESULT STDMETHODCALLTYPE
  54. CImpIMSAdminBaseSink::SinkNotify(
  55. /* [in] */ DWORD dwMDNumElements,
  56. /* [size_is][in] */ MD_CHANGE_OBJECT __RPC_FAR pcoChangeList[ ])
  57. {
  58. // we are not actually allowed to make any metadata calls here, so we need to notfy the
  59. // appropriate view that it has work to do the next time there is time.
  60. // however, we can let the views decide if they want this...
  61. if ( g_FormMain )
  62. g_FormMain->SinkNotify( dwMDNumElements, pcoChangeList );
  63. if ( g_FormAdv )
  64. g_FormAdv->SinkNotify( dwMDNumElements, pcoChangeList );
  65. // if it is a server state change, let the main app know about it
  66. if ( pcoChangeList->dwMDChangeType & MD_CHANGE_TYPE_SET_DATA )
  67. {
  68. // we are only concerned with changes in the state of the server here
  69. // thus, we can just look for the MD_SERVER_STATE id
  70. for ( DWORD iElement = 0; iElement < dwMDNumElements; iElement++ )
  71. {
  72. // each change has a list of IDs...
  73. for ( DWORD iID = 0; iID < pcoChangeList[iElement].dwMDNumDataIDs; iID++ )
  74. {
  75. // look for the ids that we are interested in
  76. switch( pcoChangeList[iElement].pdwMDDataIDs[iID] )
  77. {
  78. case MD_SERVER_STATE:
  79. PostMessage( AfxGetMainWnd()->m_hWnd, WM_UPDATE_SERVER_STATE, 0, 0 );;
  80. break;
  81. default:
  82. // do nothing
  83. break;
  84. };
  85. }
  86. }
  87. }
  88. return (0);
  89. }
  90. //--------------------------------------------------------------------
  91. HRESULT STDMETHODCALLTYPE
  92. CImpIMSAdminBaseSink::ShutdownNotify(void)
  93. {
  94. PostMessage( AfxGetMainWnd()->m_hWnd, WM_MAJOR_SERVER_SHUTDOWN_ALERT, 0, 0 );
  95. return (0);
  96. }