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.

98 lines
2.1 KiB

  1. //=================================================================
  2. //
  3. // Win32_ControllerHasHub.cpp -- Controller to usb hub assoc
  4. //
  5. // Copyright (c) 2000-2001 Microsoft Corporation, All Rights Reserved
  6. //
  7. //=================================================================
  8. #include "precomp.h"
  9. #include <Binding.h>
  10. #include <ConfgMgr.h>
  11. #include "Win32_ControllerHasHub.h"
  12. CContHasHub::CContHasHub(
  13. LPCWSTR pwszClassName,
  14. LPCWSTR pwszNamespaceName,
  15. LPCWSTR pwszLeftClassName,
  16. LPCWSTR pwszRightClassName,
  17. LPCWSTR pwszLeftPropertyName,
  18. LPCWSTR pwszRightPropertyName,
  19. LPCWSTR pwszLeftBindingPropertyName,
  20. LPCWSTR pwszRightBindingPropertyName
  21. ) : CBinding (
  22. pwszClassName,
  23. pwszNamespaceName,
  24. pwszLeftClassName,
  25. pwszRightClassName,
  26. pwszLeftPropertyName,
  27. pwszRightPropertyName,
  28. pwszLeftBindingPropertyName,
  29. pwszRightBindingPropertyName
  30. )
  31. {
  32. }
  33. CContHasHub UserToDomain(
  34. L"Win32_ControllerHasHub",
  35. IDS_CimWin32Namespace,
  36. L"Win32_USBController",
  37. L"Win32_USBHub",
  38. IDS_Antecedent,
  39. IDS_Dependent,
  40. IDS_DeviceID,
  41. IDS_DeviceID
  42. );
  43. bool CContHasHub::AreRelated(
  44. const CInstance *pLeft,
  45. const CInstance *pRight
  46. )
  47. {
  48. // Ok, at this point, we know pLeft is a usb controller and pRight
  49. // is a usb hub. The only question left is whether the usb controller
  50. // is controlling this specific hub.
  51. bool bRet = false;
  52. CHString sHub;
  53. pRight->GetCHString(IDS_DeviceID, sHub);
  54. CConfigManager cfgmgr;
  55. CConfigMgrDevicePtr pDevice, pParentDevice;
  56. if ( cfgmgr.LocateDevice ( sHub , pDevice ) )
  57. {
  58. CHString sController, sDeviceID;
  59. pLeft->GetCHString(IDS_DeviceID, sController);
  60. while (pDevice->GetParent(pParentDevice))
  61. {
  62. pParentDevice->GetDeviceID(sDeviceID);
  63. if (sDeviceID.CompareNoCase(sController) == 0)
  64. {
  65. bRet = true;
  66. break;
  67. }
  68. else
  69. {
  70. pDevice = pParentDevice;
  71. }
  72. }
  73. }
  74. return bRet;
  75. }