summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothserver_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/bluetooth/qbluetoothserver_p.h')
-rw-r--r--src/bluetooth/qbluetoothserver_p.h62
1 files changed, 58 insertions, 4 deletions
diff --git a/src/bluetooth/qbluetoothserver_p.h b/src/bluetooth/qbluetoothserver_p.h
index 5ace7f75..d14dc7b4 100644
--- a/src/bluetooth/qbluetoothserver_p.h
+++ b/src/bluetooth/qbluetoothserver_p.h
@@ -77,15 +77,25 @@ class ServerAcceptanceThread;
#include <windows.networking.sockets.h>
#endif
+#ifdef QT_OSX_BLUETOOTH
+
+#include "osx/btdelegates_p.h"
+#include "osx/btraii_p.h"
+
+#include <QtCore/qvector.h>
+
+#endif // QT_OSX_BLUETOOTH
+
QT_BEGIN_NAMESPACE
class QBluetoothAddress;
class QBluetoothSocket;
class QBluetoothServer;
-#ifndef QT_OSX_BLUETOOTH
-
class QBluetoothServerPrivate
+#ifdef QT_OSX_BLUETOOTH
+ : public DarwinBluetooth::SocketListener
+#endif
{
Q_DECLARE_PUBLIC(QBluetoothServer)
@@ -142,9 +152,53 @@ public:
bool initiateActiveListening(const QString &serviceName);
bool deactivateActiveListening();
#endif
-};
-#endif //QT_OSX_BLUETOOTH
+#ifdef QT_OSX_BLUETOOTH
+
+public:
+
+ friend class QBluetoothServer;
+ friend class QBluetoothServiceInfoPrivate;
+
+private:
+ bool startListener(quint16 realPort);
+ void stopListener();
+ bool isListening() const;
+
+ // SocketListener (delegate):
+ void openNotifyRFCOMM(void *channel) override;
+ void openNotifyL2CAP(void *channel) override;
+
+ // Either a "temporary" channelID/PSM assigned by QBluetoothServer::listen,
+ // or a real channelID/PSM returned by IOBluetooth after we've registered
+ // a service.
+ quint16 port;
+
+ DarwinBluetooth::StrongReference listener;
+
+ // These static functions below
+ // deal with differences between bluetooth sockets
+ // (bluez and QtBluetooth's API) and IOBluetooth, where it's not possible
+ // to have a real PSM/channelID _before_ a service is registered,
+ // the solution - "fake" ports.
+ // These functions require external locking - using channelMapMutex.
+ static QMutex &channelMapMutex();
+
+ static bool channelIsBusy(quint16 channelID);
+ static quint16 findFreeChannel();
+
+ static bool psmIsBusy(quint16 psm);
+ static quint16 findFreePSM();
+
+ static void registerServer(QBluetoothServerPrivate *server, quint16 port);
+ static QBluetoothServerPrivate *registeredServer(quint16 port, QBluetoothServiceInfo::Protocol protocol);
+ static void unregisterServer(QBluetoothServerPrivate *server);
+
+ using PendingConnection = DarwinBluetooth::StrongReference;
+ QVector<PendingConnection> pendingConnections;
+
+#endif // QT_OSX_BLUETOOTH
+};
QT_END_NAMESPACE