/* dru_getlongdevicedescription Fills a character buffer with a device's long description: VENDOR PRODUCT (FIRMWARE) via BUS. The incoming buffer is returned as a convenience. */ char * druGetDeviceLongDescription(DRDeviceRef device, char *buffer, size_t bufSize) { CFDictionaryRef deviceInfo = DRDeviceCopyInfo(device); CFStringRef bus = CFDictionaryGetValue(deviceInfo,kDRDevicePhysicalInterconnectKey); CFStringRef desc; CFIndex len = 0; #if 1 /* for now, until the bus starts getting returned in ASCII */ if (CFEqual(bus,kDRDevicePhysicalInterconnectFireWire)) bus = CFSTR("FireWire"); else if (CFEqual(bus,kDRDevicePhysicalInterconnectUSB)) bus = CFSTR("USB"); else if (CFEqual(bus,kDRDevicePhysicalInterconnectATAPI)) bus = CFSTR("ATAPI"); else if (CFEqual(bus,kDRDevicePhysicalInterconnectSCSI)) bus = CFSTR("SCSI"); else bus = CFSTR("unknown interface"); #endif desc = CFStringCreateWithFormat(NULL,NULL,CFSTR("%@ %@ (%@) via %@"), CFDictionaryGetValue(deviceInfo,kDRDeviceVendorNameKey), CFDictionaryGetValue(deviceInfo,kDRDeviceProductNameKey), CFDictionaryGetValue(deviceInfo,kDRDeviceFirmwareRevisionKey), bus); CFStringGetBytes(desc, CFRangeMake(0,CFStringGetLength(desc)), kCFStringEncodingASCII, '.', false, (UInt8*)buffer, bufSize-1, &len); buffer[len] = 0; CFRelease(deviceInfo); CFRelease(desc); return buffer; }
static void MyBurnSessionDeviceSelectionNotificationCallBack(DRBurnSessionRef burnSession, DRDeviceRef device) { #pragma unused(burnSession) CFDictionaryRef deviceDict; CFStringRef vendorName; CFStringRef productName; char vendor[256]; char product[256]; /* DRDeviceCopyInfo will return information that identifies the device and describes its capabilities. The information includes the vendor's name, the product identifier, whether the device can burn CDs or DVDs, and so on. */ deviceDict = DRDeviceCopyInfo(device); if (deviceDict != NULL) // 'deviceDict' will be NULL if the user clicks 'Cancel' in the Burn dialog. { vendorName = CFDictionaryGetValue(deviceDict, kDRDeviceVendorNameKey); assert((vendorName != NULL) && (CFGetTypeID(vendorName) == CFStringGetTypeID())); productName = CFDictionaryGetValue(deviceDict, kDRDeviceProductNameKey); assert((productName != NULL) && (CFGetTypeID(productName) == CFStringGetTypeID())); if (CFStringGetCString(vendorName, vendor, sizeof(vendor), kCFStringEncodingASCII)) { if (CFStringGetCString(productName, product, sizeof(product), kCFStringEncodingASCII)) { fprintf(stderr, "%s ", vendor); fprintf(stderr, "%s Selected.\n", product); } } CFRelease(deviceDict); } return; }
int druFilter_DVDBurners(DRDeviceRef device) { CFDictionaryRef info = DRDeviceCopyInfo(device); CFDictionaryRef capabilities = CFDictionaryGetValue(info,kDRDeviceWriteCapabilitiesKey); int result = ((CFDictionaryGetValue(capabilities,kDRDeviceCanWriteDVDRKey) == kCFBooleanTrue) || (CFDictionaryGetValue(capabilities,kDRDeviceCanWriteDVDRWKey) == kCFBooleanTrue)); CFRelease(info); return result; }
/* druGetDeviceShortDescription Fills a character buffer with a device's short description: VENDOR PRODUCT. The incoming buffer is returned as a convenience. */ char * druGetDeviceShortDescription(DRDeviceRef device, char *buffer, size_t bufSize) { CFDictionaryRef deviceInfo = DRDeviceCopyInfo(device); CFStringRef desc = CFStringCreateWithFormat(NULL,NULL,CFSTR("%@ %@"), CFDictionaryGetValue(deviceInfo,kDRDeviceVendorNameKey), CFDictionaryGetValue(deviceInfo,kDRDeviceProductNameKey)); CFIndex len = 0; CFStringGetBytes(desc, CFRangeMake(0,CFStringGetLength(desc)), kCFStringEncodingASCII, '.', false, (UInt8*)buffer, bufSize-1, &len); buffer[len] = 0; CFRelease(deviceInfo); CFRelease(desc); return buffer; }
static Boolean MyBurnSessionDeviceCheckCallBack(DRBurnSessionRef burnSession, DRDeviceRef device) { #pragma unused(burnSession) CFDictionaryRef deviceDict; CFDictionaryRef writeCapDict; CFBooleanRef canWriteDVDRAM; CFStringRef vendorName; CFStringRef productName; char vendor[256]; char product[256]; Boolean showDeviceInList; /* DRDeviceCopyInfo will return information that identifies the device and describes its capabilities. The information includes the vendor's name, the product identifier, whether the device can burn CDs or DVDs, and so on. */ deviceDict = DRDeviceCopyInfo(device); assert(deviceDict != NULL); vendorName = CFDictionaryGetValue(deviceDict, kDRDeviceVendorNameKey); assert((vendorName != NULL) && (CFGetTypeID(vendorName) == CFStringGetTypeID())); productName = CFDictionaryGetValue(deviceDict, kDRDeviceProductNameKey); assert((productName != NULL) && (CFGetTypeID(productName) == CFStringGetTypeID())); if (CFStringGetCString(vendorName, vendor, sizeof(vendor), kCFStringEncodingASCII)) { if (CFStringGetCString(productName, product, sizeof(product), kCFStringEncodingASCII)) { fprintf(stderr, "%s ", vendor); fprintf(stderr, "%s Checked.\n", product); } } writeCapDict = CFDictionaryGetValue(deviceDict, kDRDeviceWriteCapabilitiesKey); assert((writeCapDict != NULL) && (CFGetTypeID(writeCapDict) == CFDictionaryGetTypeID())); canWriteDVDRAM = CFDictionaryGetValue(writeCapDict, kDRDeviceCanWriteDVDRAMKey); assert((canWriteDVDRAM != NULL) && (CFGetTypeID(canWriteDVDRAM) == CFBooleanGetTypeID())); // Don't show DVD-RAM drives in the list. showDeviceInList = !CFBooleanGetValue(canWriteDVDRAM); CFRelease(deviceDict); return showDeviceInList; }
/* Get the name of the device with a given index. Only valid after a call to GetNumDevices. */ char *PortBurn_GetDeviceName(void *handle, int index) { PBHandle *h = (PBHandle *)handle; CFDictionaryRef deviceInfo; CFStringRef bus, vendor, product; CFStringRef cfname; char *result; if (!h) return NULL; if (!h->deviceList) return NULL; DRDeviceRef device; device = (DRDeviceRef)CFArrayGetValueAtIndex(h->deviceList, index); deviceInfo = DRDeviceCopyInfo(device); bus = (CFStringRef)CFDictionaryGetValue(deviceInfo, kDRDevicePhysicalInterconnectKey); if (CFEqual(bus, kDRDevicePhysicalInterconnectFireWire)) bus = CFSTR("FireWire: "); else if (CFEqual(bus, kDRDevicePhysicalInterconnectUSB)) bus = CFSTR("USB: "); else if (CFEqual(bus, kDRDevicePhysicalInterconnectATAPI)) bus = CFSTR("ATAPI: "); else if (CFEqual(bus, kDRDevicePhysicalInterconnectSCSI)) bus = CFSTR("SCSI: "); else bus = CFSTR(""); vendor = CFDictionaryGetValue(deviceInfo, kDRDeviceVendorNameKey); product = CFDictionaryGetValue(deviceInfo, kDRDeviceProductNameKey); cfname = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@%@ %@"), bus, vendor, product); result = PortBurn_CStringFromCFString(cfname); CFRelease(cfname); CFRelease(deviceInfo); return result; }