48 #include <nsStringGlue.h>
69 PRBool* aImplementsClass)
72 NS_ENSURE_ARG_POINTER(aImplementsClass);
75 PRBool implementsClass = PR_FALSE;
78 for (PRUint32
i = 0;
i < aDescriptorList.Length();
i++) {
86 PRBool hasClass = PR_TRUE;
112 if (usbClass == aUSBClass)
114 implementsClass = PR_TRUE;
120 *aImplementsClass = implementsClass;
141 PRUint8 aDescriptorType,
142 PRUint8 aDescriptorIndex,
143 PRUint16 aDescriptorIndex2,
147 NS_ENSURE_ARG_POINTER(aDeviceRef);
148 NS_ENSURE_ARG_POINTER(aDescriptor);
151 PRUint16 descriptorLength = 0;
155 switch (aDescriptorType) {
169 if (!descriptorLength) {
171 nsRefPtr<sbUSBDescriptor> sbDescriptorHeader;
177 getter_AddRefs(sbDescriptorHeader));
178 NS_ENSURE_SUCCESS(rv, rv);
182 descriptorLength = descriptorHeader->
bLength;
186 nsRefPtr<sbUSBDescriptor> descriptor;
192 getter_AddRefs(descriptor));
193 NS_ENSURE_SUCCESS(rv, rv);
199 descriptor->GetConfiguration();
200 PRUint16 totalLength = configurationDescriptor->
wTotalLength;
208 getter_AddRefs(descriptor));
209 NS_ENSURE_SUCCESS(rv, rv);
213 descriptor.forget(aDescriptor);
233 PRUint8 aDescriptorIndex,
234 PRUint16 aDescriptorIndex2,
238 NS_ENSURE_ARG_POINTER(aDeviceRef);
244 nsRefPtr<sbUSBDescriptor> sbStringDescriptor;
249 getter_AddRefs(sbStringDescriptor));
250 NS_ENSURE_SUCCESS(rv, rv);
254 PRUint32 length = (stringDescriptor->
bLength -
257 aString.Assign(stringDescriptor->
bString, length);
273 nsTArray<PRUint16>& aLanguageList)
276 NS_ENSURE_ARG_POINTER(aDeviceRef);
282 nsRefPtr<sbUSBDescriptor> sbLanguageDescriptor;
287 getter_AddRefs(sbLanguageDescriptor));
288 NS_ENSURE_SUCCESS(rv, rv);
292 PRUint32 languageCount = (languageDescriptor->
bLength -
295 aLanguageList.Clear();
296 for (PRUint32
i = 0;
i < languageCount;
i++) {
297 aLanguageList.AppendElement
298 (static_cast<PRUint16>(languageDescriptor->
bString[
i]));
317 PRUint8 aConfigurationIndex,
321 NS_ENSURE_ARG_POINTER(aDeviceRef);
327 nsRefPtr<sbUSBDescriptor> sbConfigurationDescriptor;
332 getter_AddRefs(sbConfigurationDescriptor));
333 NS_ENSURE_SUCCESS(rv, rv);
337 sbConfigurationDescriptor->GetHeader();
339 sbConfigurationDescriptor->GetConfiguration();
340 PRUint16 bytesRemaining = configurationDescriptor->
wTotalLength;
342 (bytesRemaining > descriptorHeader->
bLength)) {
344 nsRefPtr<sbUSBDescriptor> descriptor =
346 NS_ENSURE_TRUE(descriptor, NS_ERROR_OUT_OF_MEMORY);
347 NS_ENSURE_TRUE(descriptor->Get(), NS_ERROR_OUT_OF_MEMORY);
350 NS_ENSURE_TRUE(aDescriptorList.AppendElement(descriptor),
351 NS_ERROR_OUT_OF_MEMORY);
354 bytesRemaining -= descriptorHeader->
bLength;
356 (((
reinterpret_cast<PRUint8*
>(descriptorHeader)) +
372 #if 0 // Must be implemented by system dependent sources.
391 PRUint8 aDescriptorType,
392 PRUint8 aDescriptorIndex,
393 PRUint16 aDescriptorIndex2,
394 PRUint16 aDescriptorLength,
nsTArray< nsRefPtr< sbUSBDescriptor > > sbUSBDescriptorList
#define SB_USB_DESCRIPTOR_TYPE_INTERFACE
nsresult sbUSBDeviceGetLanguageList(sbUSBDeviceRef *aDeviceRef, nsTArray< PRUint16 > &aLanguageList)
#define SB_USB_DESCRIPTOR_TYPE_DEVICE
nsresult sbUSBDeviceGetDescriptor(sbUSBDeviceRef *aDeviceRef, PRUint8 aDescriptorType, PRUint8 aDescriptorIndex, PRUint16 aDescriptorIndex2, sbUSBDescriptor **aDescriptor)
sbUSBDescriptorHeader * GetHeader()
nsresult sbUSBDeviceImplementsClass(sbUSBDescriptorList &aDescriptorList, PRUint8 aUSBClass, PRBool *aImplementsClass)
#define SB_USB_DESCRIPTOR_TYPE_STRING
nsresult sbUSBDeviceAddConfigurationDescriptors(sbUSBDeviceRef *aDeviceRef, PRUint8 aConfigurationIndex, sbUSBDescriptorList &aDescriptorList)
nsresult sbUSBDeviceGetStringDescriptor(sbUSBDeviceRef *aDeviceRef, PRUint8 aDescriptorIndex, PRUint16 aDescriptorIndex2, nsAString &aString)
Songbird USB Device Utilities Definitions.
#define SB_USB_DESCRIPTOR_TYPE_CONFIGURATION
_getSelectedPageStyle s i