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.

118 lines
3.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2000.
  5. //
  6. // File: P R O V I D E R M A N A G E R . C P P
  7. //
  8. // Contents: Registrar helper object for managing providers.
  9. //
  10. // Notes:
  11. //
  12. // Author: mbend 14 Sep 2000
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include "uhbase.h"
  18. #include "ProviderManager.h"
  19. CProviderManager::CProviderManager()
  20. {
  21. }
  22. CProviderManager::~CProviderManager()
  23. {
  24. }
  25. HRESULT CProviderManager::HrShutdown()
  26. {
  27. TraceTag(ttidRegistrar, "CProviderManager::HrShutdown");
  28. HRESULT hr = S_OK;
  29. m_providerTable.Clear();
  30. TraceHr(ttidRegistrar, FAL, hr, FALSE, "CProviderManager::HrShutdown");
  31. return hr;
  32. }
  33. HRESULT CProviderManager::HrRegisterProvider(
  34. const wchar_t * szProviderName,
  35. const wchar_t * szProgIDProviderClass,
  36. const wchar_t * szInitString,
  37. const wchar_t * szContainerId)
  38. {
  39. CHECK_POINTER(szProviderName);
  40. CHECK_POINTER(szProgIDProviderClass);
  41. CHECK_POINTER(szInitString);
  42. CHECK_POINTER(szContainerId);
  43. TraceTag(ttidRegistrar, "CProviderManager::HrRegisterProvider");
  44. HRESULT hr = S_OK;
  45. CLSID clsid;
  46. // Ensure we have a valid ProgID
  47. hr = CLSIDFromProgID(szProgIDProviderClass, &clsid);
  48. if (SUCCEEDED(hr))
  49. {
  50. CUString strProviderName;
  51. hr = strProviderName.HrAssign(szProviderName);
  52. if(SUCCEEDED(hr))
  53. {
  54. CProvider * pProvider;
  55. // First check if the provider has already been registered and
  56. // continue only if we get back an error indicating it is not yet in
  57. // the table
  58. //
  59. hr = m_providerTable.HrLookup(strProviderName, &pProvider);
  60. if (FAILED(hr))
  61. {
  62. CProvider provider;
  63. hr = provider.HrInitialize(szProgIDProviderClass, szInitString,
  64. szContainerId);
  65. if(SUCCEEDED(hr))
  66. {
  67. hr = m_providerTable.HrInsertTransfer(strProviderName,
  68. provider);
  69. }
  70. }
  71. else
  72. {
  73. hr = UPNP_E_DUPLICATE_NOT_ALLOWED;
  74. }
  75. }
  76. }
  77. else
  78. {
  79. hr = E_INVALIDARG;
  80. }
  81. TraceHr(ttidRegistrar, FAL, hr, FALSE, "CProviderManager::HrRegisterProvider");
  82. return hr;
  83. }
  84. HRESULT CProviderManager::UnegisterProvider(
  85. const wchar_t * szProviderName)
  86. {
  87. CHECK_POINTER(szProviderName);
  88. TraceTag(ttidRegistrar, "CProviderManager::UnegisterDeviceProvider");
  89. HRESULT hr = S_OK;
  90. CUString strProviderName;
  91. hr = strProviderName.HrAssign(szProviderName);
  92. if(SUCCEEDED(hr))
  93. {
  94. hr = m_providerTable.HrErase(strProviderName);
  95. }
  96. TraceHr(ttidRegistrar, FAL, hr, FALSE, "CProviderManager::UnegisterDeviceProvider");
  97. return hr;
  98. }