7#include <QtCore/qloggingcategory.h>
8#include <QtCore/qdebug.h>
19 const BluetoothDeviceAddress &iobtAddress = iobluetooth_address(address);
20 ObjCStrongReference<IOBluetoothDevice> res([IOBluetoothDevice deviceWithAddress:&iobtAddress], RetainPolicy::doInitialRetain);
30@implementation DarwinBTClassicPairing
32 QT_PREPEND_NAMESPACE(QBluetoothAddress) m_targetAddress;
35 IOBluetoothDevicePair *m_pairing;
36 QT_PREPEND_NAMESPACE(DarwinBluetooth)::PairingDelegate *m_object;
39- (
id)initWithTarget:(
const QBluetoothAddress &)address
40 delegate:(DarwinBluetooth::PairingDelegate *)object
42 if (self = [super init]) {
43 Q_ASSERT_X(!address.isNull(), Q_FUNC_INFO,
"invalid target address");
44 Q_ASSERT_X(object, Q_FUNC_INFO,
"invalid delegate (null)");
46 m_targetAddress = address;
66 Q_ASSERT_X(!m_targetAddress.isNull(), Q_FUNC_INFO,
"invalid target address");
70 const BluetoothDeviceAddress &iobtAddress = DarwinBluetooth::iobluetooth_address(m_targetAddress);
72 IOBluetoothDevice *
const device = [IOBluetoothDevice deviceWithAddress:&iobtAddress];
74 qCCritical(QT_BT_DARWIN) <<
"failed to create a device to pair with";
75 return kIOReturnError;
78 m_pairing = [[IOBluetoothDevicePair pairWithDevice:device] retain];
80 qCCritical(QT_BT_DARWIN) <<
"failed to create a device pair";
81 return kIOReturnError;
84 [m_pairing setDelegate:self];
85 const IOReturn result = [m_pairing start];
86 if (result != kIOReturnSuccess) {
108- (
const QBluetoothAddress &)targetAddress
110 return m_targetAddress;
113- (IOBluetoothDevicePair *)pairingRequest
115 return [[m_pairing retain] autorelease];
118- (IOBluetoothDevice *)targetDevice
120 return [m_pairing device];
125- (
void)devicePairingStarted:(id)sender
130- (
void)devicePairingConnecting:(id)sender
135- (
void)deviceParingPINCodeRequest:(id)sender
140- (
void)devicePairingUserConfirmationRequest:(id)sender
141 numericValue:(BluetoothNumericValue)numericValue
143 if (sender != m_pairing)
146 Q_ASSERT_X(m_object, Q_FUNC_INFO,
"invalid delegate (null)");
148 m_object->requestUserConfirmation(self, numericValue);
151- (
void)devicePairingUserPasskeyNotification:(id)sender
152 passkey:(BluetoothPasskey)passkey
158- (
void)devicePairingFinished:(id)sender error:(IOReturn)error
160 Q_ASSERT_X(m_object, Q_FUNC_INFO,
"invalid delegate (null)");
162 if (sender != m_pairing)
166 if (error != kIOReturnSuccess)
167 m_object->error(self, error);
169 m_object->pairingFinished(self);
172- (
void)deviceSimplePairingComplete:(id)sender
173 status:(BluetoothHCIEventStatus)status
#define QT_BT_MAC_AUTORELEASEPOOL
ObjCStrongReference< IOBluetoothDevice > device_with_address(const QBluetoothAddress &address)