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.

94 lines
2.5 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2000.
  5. //
  6. // File: D E V I C E I N F O . C P P
  7. //
  8. // Contents: Registrar representation of a device
  9. //
  10. // Notes:
  11. //
  12. // Author: mbend 12 Sep 2000
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include "uhbase.h"
  18. #include "DeviceInfo.h"
  19. CDeviceInfo::CDeviceInfo()
  20. {
  21. }
  22. CDeviceInfo::~CDeviceInfo()
  23. {
  24. Clear();
  25. }
  26. HRESULT CDeviceInfo::HrGetService(
  27. const PhysicalDeviceIdentifier & pdi,
  28. const wchar_t * szUDN,
  29. const wchar_t * szServiceId,
  30. const wchar_t * szContainerId,
  31. IUPnPDeviceControlPtr & pDeviceControl,
  32. CServiceInfo ** ppServiceInfo,
  33. BOOL bRunning)
  34. {
  35. CHECK_POINTER(szUDN);
  36. CHECK_POINTER(szServiceId);
  37. CHECK_POINTER(ppServiceInfo);
  38. CHECK_POINTER(pDeviceControl.GetRawPointer());
  39. TraceTag(ttidRegistrar, "CDeviceInfo::HrGetService(UDN=%S, ServiceId=%S)", szUDN, szServiceId);
  40. HRESULT hr = S_OK;
  41. // Look it up in the service table first
  42. CUString strSid;
  43. hr = strSid.HrAssign(szServiceId);
  44. if(SUCCEEDED(hr))
  45. {
  46. *ppServiceInfo = m_serviceTable.Lookup(strSid);
  47. if(!*ppServiceInfo)
  48. {
  49. // It doesn't exist so create it
  50. CServiceInfo serviceInfo;
  51. hr = serviceInfo.HrInitialize(pdi, szUDN, szServiceId, szContainerId, pDeviceControl, bRunning);
  52. if(SUCCEEDED(hr))
  53. {
  54. // Put it into the table - !!! This wipes out strSid
  55. hr = m_serviceTable.HrInsertTransfer(strSid, serviceInfo);
  56. if(SUCCEEDED(hr))
  57. {
  58. // Reinit strSid
  59. hr = strSid.HrAssign(szServiceId);
  60. if(SUCCEEDED(hr))
  61. {
  62. *ppServiceInfo = m_serviceTable.Lookup(strSid);
  63. }
  64. }
  65. }
  66. }
  67. }
  68. if(SUCCEEDED(hr) && !*ppServiceInfo)
  69. {
  70. hr = E_INVALIDARG;
  71. TraceTag(ttidRegistrar, "CDeviceInfo::HrGetService- could not find ServiceId='%S'",
  72. static_cast<const wchar_t *>(strSid));
  73. }
  74. TraceHr(ttidRegistrar, FAL, hr, FALSE, "CDeviceInfo::HrGetService");
  75. return hr;
  76. }
  77. void CDeviceInfo::Transfer(CDeviceInfo & ref)
  78. {
  79. m_serviceTable.Swap(ref.m_serviceTable);
  80. }
  81. void CDeviceInfo::Clear()
  82. {
  83. m_serviceTable.Clear();
  84. }