51 #include <WMDRMCertificate.h>
54 #include <nsAutoPtr.h>
73 IWMDMDevice** aDevice)
76 NS_ENSURE_ARG_POINTER(aDevice);
83 nsRefPtr<IWMDeviceManager> deviceManager;
84 nsRefPtr<IWMDeviceManager2> deviceManager2;
86 NS_ENSURE_SUCCESS(rv, rv);
87 hr = deviceManager->QueryInterface(__uuidof(IWMDeviceManager2),
88 getter_AddRefs(deviceManager2));
89 NS_ENSURE_TRUE(SUCCEEDED(hr), NS_ERROR_FAILURE);
92 nsRefPtr<IWMDMEnumDevice> deviceEnum;
93 hr = deviceManager2->EnumDevices2(getter_AddRefs(deviceEnum));
94 NS_ENSURE_TRUE(SUCCEEDED(hr), NS_ERROR_FAILURE);
97 nsRefPtr<IWMDMDevice> matchingDevice;
100 nsRefPtr<IWMDMDevice> device;
102 hr = deviceEnum->Next(1, getter_AddRefs(device), &deviceCount);
103 NS_ENSURE_TRUE(SUCCEEDED(hr), NS_ERROR_FAILURE);
108 WCHAR canonicalName[MAX_PATH] = {0};
109 nsRefPtr<IWMDMDevice2> device2;
110 hr = device->QueryInterface(__uuidof(IWMDMDevice2),
111 getter_AddRefs(device2));
114 hr = device2->GetCanonicalName(canonicalName, ARRAYSIZE(canonicalName));
121 nsAutoString deviceInterfaceName(canonicalName);
122 PRInt32 index = deviceInterfaceName.RFindChar(
'$');
124 deviceInterfaceName.SetLength(index);
127 nsAutoString deviceInstanceID;
134 if (deviceInstanceID.Equals(aDeviceInstanceID)) {
135 matchingDevice = device;
140 return NS_ERROR_NOT_AVAILABLE;
143 matchingDevice.forget(aDevice);
158 NS_ENSURE_ARG_POINTER(aDeviceManager);
164 nsRefPtr<IComponentAuthenticate> wmdmDeviceManagerAuth;
165 hr = ::CoCreateInstance(__uuidof(::MediaDevMgr),
167 CLSCTX_INPROC_SERVER,
168 __uuidof(IComponentAuthenticate),
169 getter_AddRefs(wmdmDeviceManagerAuth));
170 NS_ENSURE_TRUE(SUCCEEDED(hr), NS_ERROR_FAILURE);
173 CSecureChannelClient* secureChannelClient = new ::CSecureChannelClient;
174 NS_ENSURE_TRUE(secureChannelClient, NS_ERROR_OUT_OF_MEMORY);
175 hr = secureChannelClient->SetCertificate(SAC_CERT_V1,
177 sizeof(wmDRMCertificate),
179 sizeof(wmDRMPrivateKey));
180 NS_ENSURE_TRUE(SUCCEEDED(hr), NS_ERROR_FAILURE);
183 secureChannelClient->SetInterface(wmdmDeviceManagerAuth);
184 hr = secureChannelClient->Authenticate(SAC_PROTOCOL_V1);
185 NS_ENSURE_TRUE(SUCCEEDED(hr), NS_ERROR_FAILURE);
188 nsRefPtr<IWMDeviceManager> deviceManager;
189 hr = wmdmDeviceManagerAuth->QueryInterface(__uuidof(IWMDeviceManager),
190 getter_AddRefs(deviceManager));
191 NS_ENSURE_TRUE(SUCCEEDED(hr), NS_ERROR_FAILURE);
194 deviceManager.forget(aDeviceManager);
Songbird Windows Device Utilities Definitions.
Songbird WMDM Utilities Definitions.
nsresult sbWinGetDeviceInstanceIDFromDeviceInterfaceName(nsAString &aDeviceInterfaceName, nsAString &aDeviceInstanceID)
nsresult sbWMDMGetDeviceFromDeviceInstanceID(nsAString &aDeviceInstanceID, IWMDMDevice **aDevice)
nsresult sbWMDMGetDeviceManager(IWMDeviceManager **aDeviceManager)