diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2013-12-10 12:53:20 +0100 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@digia.com> | 2013-12-10 12:53:20 +0100 |
commit | 9f831dde07cb2411808534e76669b28a1b76e21d (patch) | |
tree | ed6252d64c9a3ab27aa93786272cda1b6008f3c7 /src/plugins/ios/iosdevice.cpp | |
parent | cdac81f896ef4b052d76f96485a08e6ec13696b8 (diff) | |
parent | ea1a92484ac99057b06130a012164bf9788650e9 (diff) | |
download | qt-creator-wip/clang.tar.gz |
Merge remote-tracking branch 'origin/master' into wip/clangwip/clang
Change-Id: I8a2c8068a3f2b15034fb1bf6304c9a0f3f0e3c8f
Diffstat (limited to 'src/plugins/ios/iosdevice.cpp')
-rw-r--r-- | src/plugins/ios/iosdevice.cpp | 118 |
1 files changed, 69 insertions, 49 deletions
diff --git a/src/plugins/ios/iosdevice.cpp b/src/plugins/ios/iosdevice.cpp index b0d552345c..58cf894b96 100644 --- a/src/plugins/ios/iosdevice.cpp +++ b/src/plugins/ios/iosdevice.cpp @@ -46,6 +46,8 @@ #include <CoreFoundation/CoreFoundation.h> #endif +#include <exception> + using namespace ProjectExplorer; static bool debugDeviceDetection = false; @@ -85,7 +87,7 @@ IosDevice::IosDevice() Constants::IOS_DEVICE_ID) { setDisplayName(IosDevice::name()); - setDeviceState(DeviceStateUnknown); + setDeviceState(DeviceDisconnected); } IosDevice::IosDevice(const IosDevice &other) @@ -99,7 +101,7 @@ IosDevice::IosDevice(const QString &uid) Core::Id(Constants::IOS_DEVICE_ID).withSuffix(uid)) { setDisplayName(IosDevice::name()); - setDeviceState(DeviceStateUnknown); + setDeviceState(DeviceDisconnected); } @@ -364,62 +366,80 @@ io_iterator_t gRemovedIter; extern "C" { void deviceConnectedCallback(void *refCon, io_iterator_t iterator) { - kern_return_t kr; - io_service_t usbDevice; - (void) refCon; - - while ((usbDevice = IOIteratorNext(iterator))) { - io_name_t deviceName; - - // Get the USB device's name. - kr = IORegistryEntryGetName(usbDevice, deviceName); - QString name; - if (KERN_SUCCESS == kr) - name = QString::fromLocal8Bit(deviceName); - if (debugDeviceDetection) - qDebug() << "ios device " << name << " in deviceAddedCallback"; - - CFStringRef cfUid = static_cast<CFStringRef>(IORegistryEntryCreateCFProperty( - usbDevice, - CFSTR(kUSBSerialNumberString), - kCFAllocatorDefault, 0)); - QString uid = CFStringRef2QString(cfUid); - CFRelease(cfUid); - IosDeviceManager::instance()->deviceConnected(uid, name); - - // Done with this USB device; release the reference added by IOIteratorNext - kr = IOObjectRelease(usbDevice); - } -} - -void deviceDisconnectedCallback(void *refCon, io_iterator_t iterator) -{ - kern_return_t kr; - io_service_t usbDevice; - (void) refCon; - - while ((usbDevice = IOIteratorNext(iterator))) { - io_name_t deviceName; - - // Get the USB device's name. - kr = IORegistryEntryGetName(usbDevice, deviceName); - if (KERN_SUCCESS != kr) - deviceName[0] = '\0'; - if (debugDeviceDetection) - qDebug() << "ios device " << deviceName << " in deviceDisconnectedCallback"; + try { + kern_return_t kr; + io_service_t usbDevice; + (void) refCon; + + while ((usbDevice = IOIteratorNext(iterator))) { + io_name_t deviceName; + + // Get the USB device's name. + kr = IORegistryEntryGetName(usbDevice, deviceName); + QString name; + if (KERN_SUCCESS == kr) + name = QString::fromLocal8Bit(deviceName); + if (debugDeviceDetection) + qDebug() << "ios device " << name << " in deviceAddedCallback"; - { CFStringRef cfUid = static_cast<CFStringRef>(IORegistryEntryCreateCFProperty( usbDevice, CFSTR(kUSBSerialNumberString), kCFAllocatorDefault, 0)); QString uid = CFStringRef2QString(cfUid); CFRelease(cfUid); - IosDeviceManager::instance()->deviceDisconnected(uid); + IosDeviceManager::instance()->deviceConnected(uid, name); + + // Done with this USB device; release the reference added by IOIteratorNext + kr = IOObjectRelease(usbDevice); } + } + catch (std::exception &e) { + qDebug() << "Exception " << e.what() << " in iosdevice.cpp deviceConnectedCallback"; + } + catch (...) { + qDebug() << "Exception in iosdevice.cpp deviceConnectedCallback"; + throw; + } +} + +void deviceDisconnectedCallback(void *refCon, io_iterator_t iterator) +{ + try { + kern_return_t kr; + io_service_t usbDevice; + (void) refCon; + + while ((usbDevice = IOIteratorNext(iterator))) { + io_name_t deviceName; + + // Get the USB device's name. + kr = IORegistryEntryGetName(usbDevice, deviceName); + if (KERN_SUCCESS != kr) + deviceName[0] = '\0'; + if (debugDeviceDetection) + qDebug() << "ios device " << deviceName << " in deviceDisconnectedCallback"; + + { + CFStringRef cfUid = static_cast<CFStringRef>(IORegistryEntryCreateCFProperty( + usbDevice, + CFSTR(kUSBSerialNumberString), + kCFAllocatorDefault, 0)); + QString uid = CFStringRef2QString(cfUid); + CFRelease(cfUid); + IosDeviceManager::instance()->deviceDisconnected(uid); + } - // Done with this USB device; release the reference added by IOIteratorNext - kr = IOObjectRelease(usbDevice); + // Done with this USB device; release the reference added by IOIteratorNext + kr = IOObjectRelease(usbDevice); + } + } + catch (std::exception &e) { + qDebug() << "Exception " << e.what() << " in iosdevice.cpp deviceDisconnectedCallback"; + } + catch (...) { + qDebug() << "Exception in iosdevice.cpp deviceDisconnectedCallback"; + throw; } } |