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.

101 lines
2.7 KiB

  1. #include <windows.h>
  2. #include <iiscnfg.h>
  3. #include "Sink.h"
  4. #include "pwstray.h"
  5. extern HWND g_hwnd;
  6. BOOL FUpdateTrayIcon( DWORD dwMessage );
  7. //--------------------------------------------------------------------
  8. CImpIMSAdminBaseSink::CImpIMSAdminBaseSink()
  9. {
  10. m_dwRefCount=0;
  11. }
  12. //--------------------------------------------------------------------
  13. CImpIMSAdminBaseSink::~CImpIMSAdminBaseSink()
  14. {
  15. }
  16. //--------------------------------------------------------------------
  17. HRESULT
  18. CImpIMSAdminBaseSink::QueryInterface(REFIID riid, void **ppObject) {
  19. if (riid==IID_IUnknown || riid==IID_IMSAdminBaseSink) {
  20. *ppObject = (IMSAdminBaseSink*) this;
  21. }
  22. else {
  23. return E_NOINTERFACE;
  24. }
  25. AddRef();
  26. return NO_ERROR;
  27. }
  28. //--------------------------------------------------------------------
  29. ULONG
  30. CImpIMSAdminBaseSink::AddRef()
  31. {
  32. DWORD dwRefCount;
  33. dwRefCount = InterlockedIncrement((long *)&m_dwRefCount);
  34. return dwRefCount;
  35. }
  36. //--------------------------------------------------------------------
  37. ULONG
  38. CImpIMSAdminBaseSink::Release()
  39. {
  40. DWORD dwRefCount;
  41. dwRefCount = InterlockedDecrement((long *)&m_dwRefCount);
  42. if (dwRefCount == 0)
  43. {
  44. delete this;
  45. }
  46. return dwRefCount;
  47. }
  48. //--------------------------------------------------------------------
  49. HRESULT STDMETHODCALLTYPE
  50. CImpIMSAdminBaseSink::SinkNotify(
  51. /* [in] */ DWORD dwMDNumElements,
  52. /* [size_is][in] */ MD_CHANGE_OBJECT __RPC_FAR pcoChangeList[ ])
  53. {
  54. // we are not actually allowed to make any metadata calls here
  55. if ( pcoChangeList->dwMDChangeType & MD_CHANGE_TYPE_SET_DATA )
  56. {
  57. for ( DWORD iElement = 0; iElement < dwMDNumElements; iElement++ )
  58. {
  59. // each change has a list of IDs...
  60. for ( DWORD iID = 0; iID < pcoChangeList[iElement].dwMDNumDataIDs; iID++ )
  61. {
  62. // look for the ids that we are interested in
  63. switch( pcoChangeList[iElement].pdwMDDataIDs[iID] )
  64. {
  65. case MD_SERVER_STATE:
  66. if ( g_hwnd )
  67. PostMessage( g_hwnd, WM_PWS_TRAY_UPDATE_STATE, 0, 0 );
  68. return (0);
  69. default:
  70. // do nothing
  71. break;
  72. };
  73. }
  74. }
  75. }
  76. return (0);
  77. }
  78. //--------------------------------------------------------------------
  79. // if the service is going away, then we need to go away too
  80. HRESULT STDMETHODCALLTYPE
  81. CImpIMSAdminBaseSink::ShutdownNotify(void)
  82. {
  83. if ( g_hwnd )
  84. {
  85. // tell the app to do its thing
  86. PostMessage( g_hwnd, WM_PWS_TRAY_SHUTDOWN_NOTIFY, 0, 0 );
  87. }
  88. return (0);
  89. }