4#include <QtCore/QLoggingCategory>
5#include <QtCore/QJniEnvironment>
17 qRegisterMetaType<QBluetoothServer::Error>();
24 shutdownPendingConnections();
29 QBluetooth::SecurityFlags securityFlags)
33 m_serviceName = serviceName;
34 secFlags = securityFlags;
40 return !pendingSockets.
isEmpty();
61 maxPendingConnections = maximumCount;
69 qCWarning(QT_BT_ANDROID) <<
"Invalid Server Socket setup";
75 shutdownPendingConnections();
78 javaThread = QJniObject::construct<QtJniTypes::QtBtSocketServer>(
79 QNativeInterface::QAndroidApplication::context());
80 if (!javaThread.isValid())
83 javaThread.setField<jlong>(
"qtObject",
reinterpret_cast<long>(
this));
84 javaThread.setField<jboolean>(
"logEnabled", QT_BT_ANDROID().isDebugEnabled());
88 QJniObject uuidString = QJniObject::fromString(tempUuid);
89 QJniObject serviceNameString = QJniObject::fromString(m_serviceName);
91 javaThread.callMethod<
void>(
"setServiceDetails",
92 uuidString.object<jstring>(),
93 serviceNameString.object<jstring>(),
95 javaThread.callMethod<
void>(
"start");
100 if (javaThread.isValid()) {
101 qCDebug(QT_BT_ANDROID) <<
"Closing server socket";
102 javaThread.callMethod<
void>(
"close");
108 if (javaThread.isValid())
109 return javaThread.callMethod<jboolean>(
"isAlive");
117 qCDebug(QT_BT_ANDROID) <<
"JavaThread error:" << errorCode;
130 if (pendingSockets.
size() < maxPendingConnections) {
131 qCDebug(QT_BT_ANDROID) <<
"New incoming java socket detected";
135 qCWarning(QT_BT_ANDROID) <<
"Refusing connection due to limited pending socket queue";
136 socket.callMethod<
void>(
"close");
140bool ServerAcceptanceThread::validSetup()
const
145void ServerAcceptanceThread::shutdownPendingConnections()
147 while (!pendingSockets.
isEmpty()) {
149 socket.callMethod<
void>(
"close");
bool isValid() const
Returns true if the socket is valid and ready for use; otherwise returns false.
qsizetype size() const noexcept
bool isEmpty() const noexcept
void append(parameter_type t)
\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...
QJniObject nextPendingConnection()
void setServiceDetails(const QBluetoothUuid &uuid, const QString &serviceName, QBluetooth::SecurityFlags securityFlags)
void errorOccurred(QBluetoothServer::Error)
void javaNewSocket(jobject socket)
bool hasPendingConnections() const
void javaThreadErrorOccurred(int errorCode)
~ServerAcceptanceThread()
void setMaxPendingConnections(int maximumCount)
Combined button and popup list for selecting options.
#define qCWarning(category,...)
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent