13#include <QCoreApplication>
14#include <QtCore/QLoggingCategory>
24 : serverType(sType), q_ptr(
parent)
27 thread->setMaxPendingConnections(maxPendingConnections);
38 thread->deleteLater();
42bool QBluetoothServerPrivate::initiateActiveListening(
45 qCDebug(QT_BT_ANDROID) <<
"Initiate active listening" << uuid.
toString() << serviceName;
51 if (uuid == m_uuid && serviceName == m_serviceName && thread->isRunning())
55 m_serviceName = serviceName;
56 thread->setServiceDetails(m_uuid, m_serviceName,
securityFlags);
59 if (!thread->isRunning())
65bool QBluetoothServerPrivate::deactivateActiveListening()
75bool QBluetoothServerPrivate::isListening()
const
85 if (
d->thread->isRunning()) {
87 d->thread->disconnect();
102 qCWarning(QT_BT_ANDROID) <<
"Bluetooth server listen() failed due to missing permissions";
110 qCWarning(QT_BT_ANDROID) <<
"Device does not support Bluetooth";
116 if (!localAdapter.isNull()) {
119 if (hostInfo.address() == localAdapter) {
126 qCWarning(QT_BT_ANDROID) << localAdapter.toString() <<
"is not a valid local Bt adapter";
131 if (
d->isListening())
137 if (!btAdapter.isValid()) {
138 qCWarning(QT_BT_ANDROID) <<
"Device does not support Bluetooth";
144 const int state = btAdapter.callMethod<jint>(
"getState");
148 qCWarning(QT_BT_ANDROID) <<
"Bluetooth device is powered off";
155 for (
int i=1; ;
i++){
166 qCDebug(QT_BT_ANDROID) <<
"Port" <<
port <<
"registered";
168 qCWarning(QT_BT_ANDROID) <<
"server with port" <<
port <<
"already registered or port invalid";
185 d->maxPendingConnections = numConnections;
186 d->thread->setMaxPendingConnections(numConnections);
198 return hosts.
at(0).address();
212 return d->thread->hasPendingConnections();
237 d->securityFlags = security;
243 return d->securityFlags;
QJniObject getDefaultBluetoothAdapter()
QT_BEGIN_NAMESPACE bool ensureAndroidPermission(QBluetoothPermission::CommunicationModes modes)
bool isValid() const
Returns true if the socket is valid and ready for use; otherwise returns false.
static QList< QBluetoothHostInfo > allDevices()
Returns a list of all available local Bluetooth devices.
QBluetooth::SecurityFlags securityFlags
~QBluetoothServerPrivate()
bool hasPendingConnections() const
Returns true if a connection is pending, otherwise false.
void setSecurityFlags(QBluetooth::SecurityFlags security)
Sets the Bluetooth security flags to security.
Error
This enum describes Bluetooth server error types.
@ MissingPermissionsError
@ UnsupportedProtocolError
@ ServiceAlreadyRegisteredError
QBluetoothSocket * nextPendingConnection()
Returns a pointer to the QBluetoothSocket for the next pending connection.
bool listen(const QBluetoothAddress &address=QBluetoothAddress(), quint16 port=0)
Start listening for incoming connections to address on port.
void close()
Closes and resets the listening socket.
void errorOccurred(QBluetoothServer::Error error)
This signal is emitted when an error occurs.
quint16 serverPort() const
Returns the server port number.
QBluetoothAddress serverAddress() const
Returns the server address.
QBluetooth::SecurityFlags securityFlags() const
Returns the Bluetooth security flags.
void newConnection()
This signal is emitted when a new connection is available.
void setMaxPendingConnections(int numConnections)
Sets the maximum number of pending connections to numConnections.
QBluetoothServiceInfo::Protocol serverType() const
Returns the type of the QBluetoothServer.
virtual bool setSocketDescriptor(int socketDescriptor, QBluetoothServiceInfo::Protocol socketType, QBluetoothSocket::SocketState socketState=QBluetoothSocket::SocketState::ConnectedState, QBluetoothSocket::OpenMode openMode=QBluetoothSocket::ReadWrite)=0
QBluetoothSocketBasePrivate * d_ptr
qsizetype size() const noexcept
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString toString(StringFormat mode=WithBraces) const
bool isNull() const noexcept
Returns true if this is the null UUID {00000000-0000-0000-0000-000000000000}; otherwise returns false...
Combined button and popup list for selecting options.
QT_BEGIN_NAMESPACE QHash< QBluetoothServerPrivate *, int > __fakeServerPorts
#define qCWarning(category,...)
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLdouble GLdouble GLdouble GLdouble q
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent