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.6 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2000.
  5. //
  6. // File: A N N O U N C E . H
  7. //
  8. // Contents: SSDP Announcement list
  9. //
  10. // Notes:
  11. //
  12. // Author: mbend 8 Nov 2000
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #include "ulist.h"
  17. #include "upsync.h"
  18. #include "timer.h"
  19. #include "rundown.h"
  20. #include "ssdptypes.h"
  21. #include "ustring.h"
  22. class CSsdpService
  23. {
  24. public:
  25. CSsdpService();
  26. ~CSsdpService();
  27. PCONTEXT_HANDLE_TYPE * GetContext();
  28. BOOL FIsUsn(const char * szUsn);
  29. // RPC rundown support
  30. static void OnRundown(CSsdpService * pService);
  31. // Timer callback methods
  32. void TimerFired();
  33. BOOL TimerTryToLock();
  34. void TimerUnlock();
  35. HRESULT HrInitialize(
  36. SSDP_MESSAGE * pssdpMsg,
  37. DWORD dwFlags,
  38. PCONTEXT_HANDLE_TYPE * ppContextHandle);
  39. HRESULT HrStartTimer();
  40. HRESULT HrAddSearchResponse(SSDP_REQUEST * pSsdpRequest,
  41. SOCKET * pSocket,
  42. SOCKADDR_IN * pRemoteSocket);
  43. HRESULT HrCleanup(BOOL bByebye);
  44. BOOL FIsPersistent();
  45. private:
  46. CSsdpService(const CSsdpService &);
  47. CSsdpService & operator=(const CSsdpService &);
  48. CTimer<CSsdpService> m_timer;
  49. long m_nRetryCount;
  50. long m_nLifetime;
  51. SSDP_REQUEST m_ssdpRequest;
  52. CUString m_strAlive;
  53. CUString m_strByebye;
  54. CUString m_strResponse;
  55. CUCriticalSection m_critSec;
  56. DWORD m_dwFlags;
  57. PCONTEXT_HANDLE_TYPE * m_ppContextHandle;
  58. };
  59. class CSsdpServiceManager
  60. {
  61. public:
  62. ~CSsdpServiceManager();
  63. static CSsdpServiceManager & Instance();
  64. HRESULT HrAddService(
  65. SSDP_MESSAGE * pssdpMsg,
  66. DWORD dwFlags,
  67. PCONTEXT_HANDLE_TYPE * ppContextHandle);
  68. CSsdpService * FindServiceByUsn(char * szUSN);
  69. HRESULT HrAddSearchResponse(SSDP_REQUEST * pSsdpRequest,
  70. SOCKET * pSocket,
  71. SOCKADDR_IN * pRemoteSocket);
  72. HRESULT HrRemoveService(CSsdpService * pService, BOOL bByebye);
  73. HRESULT HrServiceRundown(CSsdpService * pService);
  74. HRESULT HrCleanupAnouncements();
  75. private:
  76. CSsdpServiceManager();
  77. CSsdpServiceManager(const CSsdpServiceManager &);
  78. CSsdpServiceManager & operator=(const CSsdpServiceManager &);
  79. HRESULT HrRemoveServiceInternal(CSsdpService * pService, BOOL bByebye, BOOL bRundown);
  80. typedef CUList<CSsdpService> ServiceList;
  81. CUCriticalSection m_critSec;
  82. ServiceList m_serviceList;
  83. static CSsdpServiceManager s_instance;
  84. };