1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-14 10:24:19 +01:00

Some more Mac MTP work.

Reminder: Ship libusb-compat, not legacy libusb as it is fucked.
This commit is contained in:
John Maguire 2010-09-02 22:35:00 +00:00
parent 75a576a5c2
commit 902e4906e2
2 changed files with 7 additions and 5 deletions

View File

@ -230,7 +230,7 @@ QString GetSerialForDevice(io_object_t device) {
QString GetSerialForMTPDevice(io_object_t device) { QString GetSerialForMTPDevice(io_object_t device) {
return QString( return QString(
"MTP/" + GetUSBRegistryEntryString(device, CFSTR(kUSBSerialNumberString))); QString("MTP/") + [(NSString*)GetPropertyForDevice(device, CFSTR(kUSBSerialNumberString)) UTF8String]);
} }
QString FindDeviceProperty(const QString& bsd_name, CFStringRef property) { 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)); NSString* product = (NSString*)GetPropertyForDevice(object, CFSTR(kUSBProductString));
NSNumber* vendor_id = (NSNumber*)GetPropertyForDevice(object, CFSTR(kUSBVendorID)); NSNumber* vendor_id = (NSNumber*)GetPropertyForDevice(object, CFSTR(kUSBVendorID));
NSNumber* product_id = (NSNumber*)GetPropertyForDevice(object, CFSTR(kUSBProductID)); NSNumber* product_id = (NSNumber*)GetPropertyForDevice(object, CFSTR(kUSBProductID));
QString serial = GetSerialForMTPDevice(object);
MTPDevice device; MTPDevice device;
device.vendor = QString::fromUtf8([vendor UTF8String]); device.vendor = QString::fromUtf8([vendor UTF8String]);
@ -375,7 +376,8 @@ void MacDeviceLister::USBDeviceAddedCallback(void* refcon, io_iterator_t it) {
qDebug() << device.vendor qDebug() << device.vendor
<< device.vendor_id << device.vendor_id
<< device.product << device.product
<< device.product_id; << device.product_id
<< serial;
NSNumber* addr = (NSNumber*)GetPropertyForDevice(object, CFSTR("USB Address")); NSNumber* addr = (NSNumber*)GetPropertyForDevice(object, CFSTR("USB Address"));
int bus = GetBusNumber(object); int bus = GetBusNumber(object);
@ -477,7 +479,7 @@ void MacDeviceLister::USBDeviceAddedCallback(void* refcon, io_iterator_t it) {
continue; continue;
} }
// Hurray! We made it! // Hurray! We made it!
me->FoundMTPDevice(device, GetSerialForMTPDevice(object)); me->FoundMTPDevice(device, serial);
} }
} }
} }

View File

@ -71,7 +71,7 @@ bool MtpDevice::StartCopy(QList<Song::FileType>* supported_types) {
db_busy_.lock(); db_busy_.lock();
// Connect to the device // Connect to the device
connection_.reset(new MtpConnection(url_.host())); connection_.reset(new MtpConnection(url_));
// Did the caller want a list of supported types? // Did the caller want a list of supported types?
if (supported_types) { if (supported_types) {
@ -174,7 +174,7 @@ void MtpDevice::FinishDelete(bool success) {
bool MtpDevice::GetSupportedFiletypes(QList<Song::FileType>* ret) { bool MtpDevice::GetSupportedFiletypes(QList<Song::FileType>* ret) {
QMutexLocker l(&db_busy_); QMutexLocker l(&db_busy_);
MtpConnection connection(url_.host()); MtpConnection connection(url_);
if (!connection.is_valid()) { if (!connection.is_valid()) {
qWarning() << "Error connecting to MTP device, couldn't get list of supported filetypes"; qWarning() << "Error connecting to MTP device, couldn't get list of supported filetypes";
return false; return false;