| 1 | // Copyright (C) 2016 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 | |
| 4 | #ifndef QBLUETOOTHSERVICEINFO_P_H |
| 5 | #define QBLUETOOTHSERVICEINFO_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include "qbluetoothuuid.h" |
| 19 | #include "qbluetoothaddress.h" |
| 20 | #include "qbluetoothdeviceinfo.h" |
| 21 | #include "qbluetoothserviceinfo.h" |
| 22 | |
| 23 | #include <QMap> |
| 24 | #include <QVariant> |
| 25 | |
| 26 | #ifdef Q_OS_MACOS |
| 27 | #include "darwin/btraii_p.h" |
| 28 | #endif |
| 29 | |
| 30 | namespace QtBluetoothPrivate { |
| 31 | |
| 32 | class OrgBluezServiceInterface; |
| 33 | class OrgBluezProfileManager1Interface; |
| 34 | |
| 35 | } // namespace QtBluetoothPrivate |
| 36 | |
| 37 | #ifdef QT_WINRT_BLUETOOTH |
| 38 | #include <wrl.h> |
| 39 | |
| 40 | namespace ABI { |
| 41 | namespace Windows { |
| 42 | namespace Devices { |
| 43 | namespace Bluetooth { |
| 44 | namespace Rfcomm { |
| 45 | struct IRfcommServiceProvider; |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | #endif |
| 52 | |
| 53 | QT_BEGIN_NAMESPACE |
| 54 | |
| 55 | class QBluetoothServiceInfo; |
| 56 | |
| 57 | |
| 58 | class QBluetoothServiceInfoPrivate |
| 59 | : public QObject |
| 60 | { |
| 61 | Q_OBJECT |
| 62 | public: |
| 63 | QBluetoothServiceInfoPrivate(); |
| 64 | ~QBluetoothServiceInfoPrivate(); |
| 65 | |
| 66 | bool registerService(const QBluetoothAddress &localAdapter = QBluetoothAddress()); |
| 67 | |
| 68 | bool isRegistered() const; |
| 69 | |
| 70 | bool unregisterService(); |
| 71 | |
| 72 | QBluetoothDeviceInfo deviceInfo; |
| 73 | QMap<quint16, QVariant> attributes; |
| 74 | |
| 75 | QBluetoothServiceInfo::Sequence protocolDescriptor(QBluetoothUuid::ProtocolUuid protocol) const; |
| 76 | int serverChannel() const; |
| 77 | private: |
| 78 | #if QT_CONFIG(bluez) |
| 79 | QtBluetoothPrivate::OrgBluezProfileManager1Interface *service = nullptr; |
| 80 | quint32 serviceRecord; |
| 81 | QBluetoothAddress currentLocalAdapter; |
| 82 | QString profilePath; |
| 83 | #endif |
| 84 | |
| 85 | #ifdef QT_WINRT_BLUETOOTH |
| 86 | Microsoft::WRL::ComPtr<ABI::Windows::Devices::Bluetooth::Rfcomm::IRfcommServiceProvider> serviceProvider; |
| 87 | |
| 88 | bool writeSdpAttributes(); |
| 89 | #endif |
| 90 | |
| 91 | #if QT_OSX_BLUETOOTH |
| 92 | public: |
| 93 | bool registerService(const QBluetoothServiceInfo &info); |
| 94 | |
| 95 | private: |
| 96 | |
| 97 | using SDPRecord = DarwinBluetooth::ScopedPointer; |
| 98 | SDPRecord serviceRecord; |
| 99 | quint32 serviceRecordHandle = 0; |
| 100 | #endif // QT_OSX_BLUETOOTH |
| 101 | |
| 102 | mutable bool registered = false; |
| 103 | }; |
| 104 | |
| 105 | QT_END_NAMESPACE |
| 106 | |
| 107 | #endif // QBLUETOOTHSERVICEINFO_P_H |
| 108 | |