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.

141 lines
4.2 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2000.
  5. //
  6. // File: N O T I F Y . H
  7. //
  8. // Contents: SSDP client notification support
  9. //
  10. // Notes:
  11. //
  12. // Author: mbend 12 Nov 2000
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #include "ulist.h"
  17. #include "upsync.h"
  18. #include "ustring.h"
  19. #include "timer.h"
  20. #include "ssdptypes.h"
  21. class CSsdpPendingNotification
  22. {
  23. public:
  24. CSsdpPendingNotification();
  25. ~CSsdpPendingNotification();
  26. HRESULT HrInitialize(const SSDP_REQUEST * pRequest);
  27. HRESULT HrGetRequest(SSDP_REQUEST * pRequest);
  28. private:
  29. CSsdpPendingNotification(const CSsdpPendingNotification &);
  30. CSsdpPendingNotification & operator=(const CSsdpPendingNotification &);
  31. SSDP_REQUEST m_ssdpRequest;
  32. };
  33. class CSsdpNotifyRequest
  34. {
  35. public:
  36. CSsdpNotifyRequest();
  37. ~CSsdpNotifyRequest();
  38. // RPC rundown support
  39. static void OnRundown(CSsdpNotifyRequest * pNotify);
  40. // Timer callback methods
  41. void TimerFired();
  42. BOOL TimerTryToLock();
  43. void TimerUnlock();
  44. HRESULT HrRestartClientResubscribeTimer(
  45. DWORD dwSecTimeout);
  46. HRESULT HrInitializeAlive(
  47. const char * szNT,
  48. HANDLE hNotifySemaphore);
  49. HRESULT HrInitializePropChange(
  50. const char * szUrl,
  51. HANDLE hNotifySemaphore);
  52. HRESULT HrSendPropChangeSubscription(SSDP_REGISTER_INFO ** ppRegisterInfo);
  53. HRESULT HrShutdown();
  54. BOOL FIsMatchBySemaphore(HANDLE hNotifySemaphore);
  55. BOOL FIsMatchingEvent(const SSDP_REQUEST * pRequest);
  56. BOOL FIsMatchingAliveOrByebye(const SSDP_REQUEST * pRequest);
  57. HRESULT HrQueuePendingNotification(const SSDP_REQUEST * pRequest);
  58. BOOL FIsPendingNotification();
  59. HRESULT HrRetreivePendingNotification(MessageList ** ppSvcList);
  60. private:
  61. CSsdpNotifyRequest(const CSsdpNotifyRequest &);
  62. CSsdpNotifyRequest & operator=(const CSsdpNotifyRequest &);
  63. typedef CUList<CSsdpPendingNotification> PendingNotificationList;
  64. NOTIFY_TYPE m_nt;
  65. CUCriticalSection m_critSec;
  66. CUString m_strNT;
  67. CUString m_strUrl;
  68. DWORD m_dwSecTimeout;
  69. CUString m_strSid;
  70. CTimer<CSsdpNotifyRequest> m_timer;
  71. HANDLE m_hNotifySemaphore;
  72. PendingNotificationList m_pendingNotificationList;
  73. };
  74. class CSsdpNotifyRequestManager
  75. {
  76. public:
  77. ~CSsdpNotifyRequestManager();
  78. static CSsdpNotifyRequestManager & Instance();
  79. void OnRundown(CSsdpNotifyRequest * pNotify);
  80. HRESULT HrCreateAliveNotifyRequest(
  81. PCONTEXT_HANDLE_TYPE * ppContextHandle,
  82. const char * szNT,
  83. HANDLE hNotifySemaphore);
  84. HRESULT HrCreatePropChangeNotifyRequest(
  85. PCONTEXT_HANDLE_TYPE * ppContextHandle,
  86. const char * szUrl,
  87. HANDLE hNotifySemaphore,
  88. SSDP_REGISTER_INFO ** ppRegisterInfo);
  89. HRESULT HrRemoveNotifyRequest(
  90. HANDLE hNotifySemaphore);
  91. HRESULT HrRemoveNotifyRequestByPointer(
  92. CSsdpNotifyRequest * pRequest);
  93. HRESULT HrCheckListNotifyForEvent(const SSDP_REQUEST * pRequest);
  94. HRESULT HrCheckListNotifyForAliveOrByebye(const SSDP_REQUEST * pRequest);
  95. BOOL FIsAliveOrByebyeInListNotify(const SSDP_REQUEST * pRequest);
  96. HRESULT HrRetreivePendingNotification(
  97. HANDLE hNotifySemaphore,
  98. MessageList ** ppSvcList);
  99. HRESULT HrRestartClientResubscribeTimer(
  100. CSsdpNotifyRequest * pRequest,
  101. DWORD dwSecTimeout);
  102. private:
  103. CSsdpNotifyRequestManager();
  104. CSsdpNotifyRequestManager(const CSsdpNotifyRequestManager &);
  105. CSsdpNotifyRequestManager & operator=(const CSsdpNotifyRequestManager &);
  106. HRESULT HrRemoveInternal(BOOL bRundown, HANDLE hNotifySemaphore, CSsdpNotifyRequest * pRequest);
  107. static CSsdpNotifyRequestManager s_instance;
  108. typedef CUList<CSsdpNotifyRequest> NotifyRequestList;
  109. typedef CUList<__int64> TimestampList;
  110. CUCriticalSection m_critSecAliveList;
  111. NotifyRequestList m_aliveList;
  112. CUCriticalSection m_critSecPropChangeList;
  113. NotifyRequestList m_propChangeList;
  114. CUCriticalSection m_critSecTimestampList;
  115. TimestampList m_timestampList;
  116. __int64 m_unTimestamp;
  117. HANDLE m_hEventTimestamp;
  118. };