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.

122 lines
2.9 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2000.
  5. //
  6. // File: C D Y N A M I C C O N T E N T S O U R C E . C P P
  7. //
  8. // Contents:
  9. //
  10. // Notes:
  11. //
  12. // Author: mbend 17 Aug 2000
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include "uhbase.h"
  18. #include "hostp.h"
  19. #include "DynamicContentSource.h"
  20. #include "uhsync.h"
  21. #include "uhcommon.h"
  22. CDynamicContentSource::CDynamicContentSource()
  23. {
  24. }
  25. STDMETHODIMP CDynamicContentSource::GetContent(
  26. /*[in]*/ REFGUID guidContent,
  27. /*[out]*/ long * pnHeaderCount,
  28. /*[out, string, size_is(,*pnHeaderCount,)]*/ wchar_t *** parszHeaders,
  29. /*[out]*/ long * pnBytes,
  30. /*[out, size_is(,*pnBytes)]*/ byte ** parBytes)
  31. {
  32. CHECK_POINTER(pnHeaderCount);
  33. CHECK_POINTER(parszHeaders);
  34. CHECK_POINTER(pnBytes);
  35. CHECK_POINTER(parBytes);
  36. CALock lock(*this);
  37. HRESULT hr = E_INVALIDARG;
  38. hr = HrIsAllowedCOMCallLocality((CALL_LOCALITY) CALL_LOCALITY_INPROC);
  39. if (SUCCEEDED(hr))
  40. {
  41. long nCount = m_providerArray.GetCount();
  42. for(long n = 0; n < nCount; ++n)
  43. {
  44. hr = m_providerArray[n]->GetContent(
  45. guidContent,
  46. pnHeaderCount,
  47. parszHeaders,
  48. pnBytes,
  49. parBytes);
  50. if(FAILED(hr) || S_OK == hr)
  51. {
  52. break;
  53. }
  54. }
  55. if(S_FALSE == hr)
  56. {
  57. TraceTag(ttidError, "CDynamicContentSource::GetContent - cannot find content");
  58. // We didn't find anything so convert to an error
  59. hr = E_INVALIDARG;
  60. }
  61. }
  62. TraceHr(ttidError, FAL, hr, FALSE, "CDynamicContentSource::GetContent");
  63. return hr;
  64. }
  65. STDMETHODIMP CDynamicContentSource::RegisterProvider(
  66. /*[in]*/ IUPnPDynamicContentProvider * pProvider)
  67. {
  68. CHECK_POINTER(pProvider);
  69. CALock lock(*this);
  70. HRESULT hr = S_OK;
  71. IUPnPDynamicContentProviderPtr p;
  72. p = pProvider;
  73. hr = HrIsAllowedCOMCallLocality((CALL_LOCALITY) CALL_LOCALITY_INPROC);
  74. if (SUCCEEDED(hr))
  75. {
  76. hr = m_providerArray.HrPushBack(p);
  77. }
  78. TraceHr(ttidError, FAL, hr, FALSE, "CDynamicContentSource::RegisterProvider");
  79. return hr;
  80. }
  81. STDMETHODIMP CDynamicContentSource::UnregisterProvider(
  82. /*[in]*/ IUPnPDynamicContentProvider * pProvider)
  83. {
  84. CHECK_POINTER(pProvider);
  85. CALock lock(*this);
  86. HRESULT hr = S_OK;
  87. IUPnPDynamicContentProviderPtr p;
  88. p = pProvider;
  89. long nIndex = 0;
  90. hr = HrIsAllowedCOMCallLocality((CALL_LOCALITY) CALL_LOCALITY_INPROC);
  91. if (SUCCEEDED(hr))
  92. {
  93. hr = m_providerArray.HrFind(p, nIndex);
  94. }
  95. if(SUCCEEDED(hr))
  96. {
  97. hr = m_providerArray.HrErase(nIndex);
  98. }
  99. TraceHr(ttidError, FAL, hr, FALSE, "CDynamicContentSource::UnregisterProvider");
  100. return hr;
  101. }