1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Copyright (C) 2016 BlackBerry Limited. All rights reserved.
5** Contact: https://www.qt.io/licensing/
6**
7** This file is part of the QtBluetooth module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial License Usage
11** Licensees holding valid commercial Qt licenses may use this file in
12** accordance with the commercial license agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and The Qt Company. For licensing terms
15** and conditions see https://www.qt.io/terms-conditions. For further
16** information use the contact form at https://www.qt.io/contact-us.
17**
18** GNU Lesser General Public License Usage
19** Alternatively, this file may be used under the terms of the GNU Lesser
20** General Public License version 3 as published by the Free Software
21** Foundation and appearing in the file LICENSE.LGPL3 included in the
22** packaging of this file. Please review the following information to
23** ensure the GNU Lesser General Public License version 3 requirements
24** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
25**
26** GNU General Public License Usage
27** Alternatively, this file may be used under the terms of the GNU
28** General Public License version 2.0 or (at your option) the GNU General
29** Public license version 3 or any later version approved by the KDE Free
30** Qt Foundation. The licenses are as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
32** included in the packaging of this file. Please review the following
33** information to ensure the GNU General Public License requirements will
34** be met: https://www.gnu.org/licenses/gpl-2.0.html and
35** https://www.gnu.org/licenses/gpl-3.0.html.
36**
37** $QT_END_LICENSE$
38**
39****************************************************************************/
40
41#ifndef QBLUETOOTHSERVER_H
42#define QBLUETOOTHSERVER_H
43
44#include <QtBluetooth/qtbluetoothglobal.h>
45
46#include <QtCore/QObject>
47
48#include <QtBluetooth/QBluetoothAddress>
49#include <QtBluetooth/qbluetooth.h>
50#include <QtBluetooth/QBluetoothSocket>
51#include <QtBluetooth/QBluetoothServiceInfo>
52
53QT_BEGIN_NAMESPACE
54
55class QBluetoothServerPrivate;
56class QBluetoothSocket;
57
58class Q_BLUETOOTH_EXPORT QBluetoothServer : public QObject
59{
60 Q_OBJECT
61
62public:
63 enum Error {
64 NoError,
65 UnknownError,
66 PoweredOffError,
67 InputOutputError,
68 ServiceAlreadyRegisteredError,
69 UnsupportedProtocolError
70 };
71 Q_ENUM(Error)
72
73 explicit QBluetoothServer(QBluetoothServiceInfo::Protocol serverType, QObject *parent = nullptr);
74 ~QBluetoothServer();
75
76 void close();
77
78 bool listen(const QBluetoothAddress &address = QBluetoothAddress(), quint16 port = 0);
79 QBluetoothServiceInfo listen(const QBluetoothUuid &uuid, const QString &serviceName = QString());
80 bool isListening() const;
81
82 void setMaxPendingConnections(int numConnections);
83 int maxPendingConnections() const;
84
85 bool hasPendingConnections() const;
86 QBluetoothSocket *nextPendingConnection();
87
88 QBluetoothAddress serverAddress() const;
89 quint16 serverPort() const;
90
91 void setSecurityFlags(QBluetooth::SecurityFlags security);
92 QBluetooth::SecurityFlags securityFlags() const;
93
94 QBluetoothServiceInfo::Protocol serverType() const;
95
96 Error error() const;
97
98Q_SIGNALS:
99 void newConnection();
100 void error(QBluetoothServer::Error error);
101
102protected:
103 QBluetoothServerPrivate *d_ptr;
104
105private:
106 Q_DECLARE_PRIVATE(QBluetoothServer)
107};
108
109QT_END_NAMESPACE
110
111#endif
112