From 902e4906e206255bb80aa7d27ff42ae1c0c09f49 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Thu, 2 Sep 2010 22:35:00 +0000 Subject: [PATCH] Some more Mac MTP work. Reminder: Ship libusb-compat, not legacy libusb as it is fucked. --- src/devices/macdevicelister.mm | 8 +++++--- src/devices/mtpdevice.cpp | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/devices/macdevicelister.mm b/src/devices/macdevicelister.mm index ad7904b0d..7544e8872 100644 --- a/src/devices/macdevicelister.mm +++ b/src/devices/macdevicelister.mm @@ -230,7 +230,7 @@ QString GetSerialForDevice(io_object_t device) { QString GetSerialForMTPDevice(io_object_t device) { return QString( - "MTP/" + GetUSBRegistryEntryString(device, CFSTR(kUSBSerialNumberString))); + QString("MTP/") + [(NSString*)GetPropertyForDevice(device, CFSTR(kUSBSerialNumberString)) UTF8String]); } QString FindDeviceProperty(const QString& bsd_name, CFStringRef property) { @@ -356,6 +356,7 @@ void MacDeviceLister::USBDeviceAddedCallback(void* refcon, io_iterator_t it) { NSString* product = (NSString*)GetPropertyForDevice(object, CFSTR(kUSBProductString)); NSNumber* vendor_id = (NSNumber*)GetPropertyForDevice(object, CFSTR(kUSBVendorID)); NSNumber* product_id = (NSNumber*)GetPropertyForDevice(object, CFSTR(kUSBProductID)); + QString serial = GetSerialForMTPDevice(object); MTPDevice device; device.vendor = QString::fromUtf8([vendor UTF8String]); @@ -375,7 +376,8 @@ void MacDeviceLister::USBDeviceAddedCallback(void* refcon, io_iterator_t it) { qDebug() << device.vendor << device.vendor_id << device.product - << device.product_id; + << device.product_id + << serial; NSNumber* addr = (NSNumber*)GetPropertyForDevice(object, CFSTR("USB Address")); int bus = GetBusNumber(object); @@ -477,7 +479,7 @@ void MacDeviceLister::USBDeviceAddedCallback(void* refcon, io_iterator_t it) { continue; } // Hurray! We made it! - me->FoundMTPDevice(device, GetSerialForMTPDevice(object)); + me->FoundMTPDevice(device, serial); } } } diff --git a/src/devices/mtpdevice.cpp b/src/devices/mtpdevice.cpp index 37b0c4027..5e46a7d71 100644 --- a/src/devices/mtpdevice.cpp +++ b/src/devices/mtpdevice.cpp @@ -71,7 +71,7 @@ bool MtpDevice::StartCopy(QList* supported_types) { db_busy_.lock(); // Connect to the device - connection_.reset(new MtpConnection(url_.host())); + connection_.reset(new MtpConnection(url_)); // Did the caller want a list of supported types? if (supported_types) { @@ -174,7 +174,7 @@ void MtpDevice::FinishDelete(bool success) { bool MtpDevice::GetSupportedFiletypes(QList* ret) { QMutexLocker l(&db_busy_); - MtpConnection connection(url_.host()); + MtpConnection connection(url_); if (!connection.is_valid()) { qWarning() << "Error connecting to MTP device, couldn't get list of supported filetypes"; return false;