8#include <QtCore/qdebug.h>
12@implementation DarwinBTSocketListener
14 IOBluetoothUserNotification *connectionNotification;
15 QT_PREPEND_NAMESPACE(DarwinBluetooth::SocketListener) *delegate;
19- (
id)initWithListener:(DarwinBluetooth::SocketListener *)aDelegate
21 Q_ASSERT_X(aDelegate, Q_FUNC_INFO,
"invalid delegate (null)");
22 if (self = [super init]) {
23 connectionNotification = nil;
33 [connectionNotification unregister];
34 [connectionNotification release];
39- (
bool)listenRFCOMMConnectionsWithChannelID:(BluetoothRFCOMMChannelID)channelID
41 Q_ASSERT_X(!connectionNotification, Q_FUNC_INFO,
"already listening");
43 connectionNotification = [IOBluetoothRFCOMMChannel registerForChannelOpenNotifications:self
44 selector:@selector(rfcommOpenNotification:channel:)
45 withChannelID:channelID
46 direction:kIOBluetoothUserNotificationChannelDirectionIncoming];
47 connectionNotification = [connectionNotification retain];
48 if (connectionNotification)
51 return connectionNotification;
54- (
bool)listenL2CAPConnectionsWithPSM:(BluetoothL2CAPPSM)psm
56 Q_ASSERT_X(!connectionNotification, Q_FUNC_INFO,
"already listening");
58 connectionNotification = [IOBluetoothL2CAPChannel registerForChannelOpenNotifications:self
59 selector:@selector(l2capOpenNotification:channel:)
61 direction:kIOBluetoothUserNotificationChannelDirectionIncoming];
62 connectionNotification = [connectionNotification retain];
63 if (connectionNotification)
66 return connectionNotification;
69- (
void)rfcommOpenNotification:(IOBluetoothUserNotification *)notification
70 channel:(IOBluetoothRFCOMMChannel *)newChannel
72 Q_UNUSED(notification);
74 Q_ASSERT_X(delegate, Q_FUNC_INFO,
"invalid delegate (null)");
75 delegate->openNotifyRFCOMM(newChannel);
78- (
void)l2capOpenNotification:(IOBluetoothUserNotification *)notification
79 channel:(IOBluetoothL2CAPChannel *)newChannel
81 Q_UNUSED(notification);
83 Q_ASSERT_X(delegate, Q_FUNC_INFO,
"invalid delegate (null)");
84 delegate->openNotifyL2CAP(newChannel);