Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
btsocketlistener.mm
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5#include "btdelegates_p.h"
6#include "btutility_p.h"
7
8#include <QtCore/qdebug.h>
9
11
13{
14 IOBluetoothUserNotification *connectionNotification;
15 QT_PREPEND_NAMESPACE(DarwinBluetooth::SocketListener) *delegate;
17}
18
19- (id)initWithListener:(DarwinBluetooth::SocketListener *)aDelegate
20{
21 Q_ASSERT_X(aDelegate, Q_FUNC_INFO, "invalid delegate (null)");
22 if (self = [super init]) {
23 connectionNotification = nil;
24 delegate = aDelegate;
25 port = 0;
26 }
27
28 return self;
29}
30
31- (void)dealloc
32{
33 [connectionNotification unregister];
34 [connectionNotification release];
35
36 [super dealloc];
37}
38
39- (bool)listenRFCOMMConnectionsWithChannelID:(BluetoothRFCOMMChannelID)channelID
40{
41 Q_ASSERT_X(!connectionNotification, Q_FUNC_INFO, "already listening");
42
43 connectionNotification = [IOBluetoothRFCOMMChannel registerForChannelOpenNotifications:self
44 selector:@selector(rfcommOpenNotification:channel:)
45 withChannelID:channelID
46 direction:kIOBluetoothUserNotificationChannelDirectionIncoming];
47 connectionNotification = [connectionNotification retain];
48 if (connectionNotification)
49 port = channelID;
50
51 return connectionNotification;
52}
53
54- (bool)listenL2CAPConnectionsWithPSM:(BluetoothL2CAPPSM)psm
55{
56 Q_ASSERT_X(!connectionNotification, Q_FUNC_INFO, "already listening");
57
58 connectionNotification = [IOBluetoothL2CAPChannel registerForChannelOpenNotifications:self
59 selector:@selector(l2capOpenNotification:channel:)
60 withPSM:psm
61 direction:kIOBluetoothUserNotificationChannelDirectionIncoming];
62 connectionNotification = [connectionNotification retain];
63 if (connectionNotification)
64 port = psm;
65
66 return connectionNotification;
67}
68
69- (void)rfcommOpenNotification:(IOBluetoothUserNotification *)notification
70 channel:(IOBluetoothRFCOMMChannel *)newChannel
71{
72 Q_UNUSED(notification);
73
74 Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
75 delegate->openNotifyRFCOMM(newChannel);
76}
77
78- (void)l2capOpenNotification:(IOBluetoothUserNotification *)notification
79 channel:(IOBluetoothL2CAPChannel *)newChannel
80{
81 Q_UNUSED(notification);
82
83 Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
84 delegate->openNotifyL2CAP(newChannel);
85}
86
88{
89 return port;
90}
91
92@end
quint16 port
QString self
Definition language.cpp:58
#define Q_FUNC_INFO
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
EGLOutputPortEXT port
GLenum GLuint id
[7]
#define Q_ASSERT_X(cond, x, msg)
Definition qrandom.cpp:48
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
#define Q_UNUSED(x)
unsigned short quint16
Definition qtypes.h:48