Leaked source code of windows server 2003
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.

118 lines
2.4 KiB

  1. #include "pch.h"
  2. #pragma hdrstop
  3. #include "cmsabcon.h"
  4. CSharedAccessBeacon::CSharedAccessBeacon()
  5. {
  6. m_MediaType = NCM_NONE;
  7. ZeroMemory(&m_LocalAdapterGUID, sizeof(m_LocalAdapterGUID));
  8. ZeroMemory(&m_Services, sizeof(m_Services));
  9. m_UniqueDeviceName = NULL;
  10. }
  11. HRESULT CSharedAccessBeacon::FinalRelease()
  12. {
  13. for(int i = 0; i < SAHOST_SERVICE_MAX; i++)
  14. {
  15. if(NULL != m_Services[i])
  16. {
  17. ReleaseObj(m_Services[i]);
  18. }
  19. }
  20. SysFreeString(m_UniqueDeviceName);
  21. return S_OK;
  22. }
  23. HRESULT CSharedAccessBeacon::SetMediaType(NETCON_MEDIATYPE MediaType)
  24. {
  25. m_MediaType = MediaType;
  26. return S_OK;
  27. }
  28. HRESULT CSharedAccessBeacon::SetLocalAdapterGUID(GUID* pGuid)
  29. {
  30. CopyMemory(&m_LocalAdapterGUID, pGuid, sizeof(GUID));
  31. return S_OK;
  32. }
  33. HRESULT CSharedAccessBeacon::SetService(ULONG ulService, IUPnPService* pService)
  34. {
  35. HRESULT hr = S_OK;
  36. if(SAHOST_SERVICE_MAX > ulService && NULL == m_Services[ulService])
  37. {
  38. m_Services[ulService] = pService;
  39. pService->AddRef();
  40. }
  41. else
  42. {
  43. hr = E_INVALIDARG;
  44. }
  45. return hr;
  46. }
  47. HRESULT CSharedAccessBeacon::SetUniqueDeviceName(BSTR UniqueDeviceName)
  48. {
  49. HRESULT hr = S_OK;
  50. m_UniqueDeviceName = SysAllocString(UniqueDeviceName);
  51. if(NULL == m_UniqueDeviceName)
  52. {
  53. hr = E_OUTOFMEMORY;
  54. }
  55. return hr;
  56. }
  57. HRESULT CSharedAccessBeacon::GetMediaType(NETCON_MEDIATYPE* pMediaType)
  58. {
  59. *pMediaType = m_MediaType;
  60. return S_OK;
  61. }
  62. HRESULT CSharedAccessBeacon::GetLocalAdapterGUID(GUID* pGuid)
  63. {
  64. CopyMemory(pGuid, &m_LocalAdapterGUID, sizeof(GUID));
  65. return S_OK;
  66. }
  67. HRESULT CSharedAccessBeacon::GetService(SAHOST_SERVICES ulService, IUPnPService** ppService)
  68. {
  69. HRESULT hr = S_OK;
  70. *ppService = NULL;
  71. if(SAHOST_SERVICE_MAX > ulService)
  72. {
  73. *ppService = m_Services[ulService];
  74. if(NULL != *ppService)
  75. {
  76. (*ppService)->AddRef();
  77. }
  78. else
  79. {
  80. hr = E_FAIL;
  81. }
  82. }
  83. else
  84. {
  85. hr = E_INVALIDARG;
  86. }
  87. return hr;
  88. }
  89. HRESULT CSharedAccessBeacon::GetUniqueDeviceName(BSTR* pUniqueDeviceName)
  90. {
  91. HRESULT hr = S_OK;
  92. *pUniqueDeviceName = SysAllocString(m_UniqueDeviceName);
  93. if(NULL == *pUniqueDeviceName)
  94. {
  95. hr = E_OUTOFMEMORY;
  96. }
  97. return hr;
  98. }