Normalize QObject::connect() statements
Some cases use the Q_PRIVATE_SLOT logic which does not require QObject inheritance. Those cases were converted to lambda logic to avoid need for QObject inheritance. The Q_PRIVATE_SLOT macro was removed from qbluetoothdevicediscoveryagent.h. This is not a BC problem because the macro expands to nothing. Only moc recognizes the pattern. Change-Id: Ic7cb4cde397f9b230b6fd0b4046e59e504583e58 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
parent
77c3c1427d
commit
819bb06c2c
|
|
@ -120,16 +120,6 @@ Q_SIGNALS:
|
||||||
private:
|
private:
|
||||||
Q_DECLARE_PRIVATE(QBluetoothDeviceDiscoveryAgent)
|
Q_DECLARE_PRIVATE(QBluetoothDeviceDiscoveryAgent)
|
||||||
QBluetoothDeviceDiscoveryAgentPrivate *d_ptr;
|
QBluetoothDeviceDiscoveryAgentPrivate *d_ptr;
|
||||||
|
|
||||||
#if QT_CONFIG(bluez)
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_deviceFound(const QString &address, const QVariantMap &dict))
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_propertyChanged(const QString &name, const QDBusVariant &value))
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_InterfacesAdded(const QDBusObjectPath &path, InterfaceList interfaceList))
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_discoveryFinished())
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_discoveryInterrupted(const QString &path))
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_PropertiesChanged(const QString &interface, const QVariantMap &changed_properties, const QStringList &invalidated_properties))
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_extendedDeviceDiscoveryTimeout())
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(QBluetoothDeviceDiscoveryAgent::DiscoveryMethods)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(QBluetoothDeviceDiscoveryAgent::DiscoveryMethods)
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,6 @@ QBluetoothDeviceDiscoveryAgentPrivate::QBluetoothDeviceDiscoveryAgentPrivate(
|
||||||
lowEnergySearchTimeout(-1), // remains -1 on BlueZ 4 -> timeout not supported
|
lowEnergySearchTimeout(-1), // remains -1 on BlueZ 4 -> timeout not supported
|
||||||
q_ptr(parent)
|
q_ptr(parent)
|
||||||
{
|
{
|
||||||
Q_Q(QBluetoothDeviceDiscoveryAgent);
|
|
||||||
if (isBluez5()) {
|
if (isBluez5()) {
|
||||||
lowEnergySearchTimeout = 20000;
|
lowEnergySearchTimeout = 20000;
|
||||||
managerBluez5 = new OrgFreedesktopDBusObjectManagerInterface(
|
managerBluez5 = new OrgFreedesktopDBusObjectManagerInterface(
|
||||||
|
|
@ -75,8 +74,10 @@ QBluetoothDeviceDiscoveryAgentPrivate::QBluetoothDeviceDiscoveryAgentPrivate(
|
||||||
QStringLiteral("/"),
|
QStringLiteral("/"),
|
||||||
QDBusConnection::systemBus(), parent);
|
QDBusConnection::systemBus(), parent);
|
||||||
QObject::connect(managerBluez5,
|
QObject::connect(managerBluez5,
|
||||||
SIGNAL(InterfacesAdded(QDBusObjectPath,InterfaceList)),
|
&OrgFreedesktopDBusObjectManagerInterface::InterfacesAdded,
|
||||||
q, SLOT(_q_InterfacesAdded(QDBusObjectPath,InterfaceList)));
|
[this](const QDBusObjectPath &objectPath, InterfaceList interfacesAndProperties) {
|
||||||
|
this->_q_InterfacesAdded(objectPath, interfacesAndProperties);
|
||||||
|
});
|
||||||
|
|
||||||
// start private address monitoring
|
// start private address monitoring
|
||||||
BluetoothManagement::instance();
|
BluetoothManagement::instance();
|
||||||
|
|
@ -84,8 +85,9 @@ QBluetoothDeviceDiscoveryAgentPrivate::QBluetoothDeviceDiscoveryAgentPrivate(
|
||||||
manager = new OrgBluezManagerInterface(QStringLiteral("org.bluez"), QStringLiteral("/"),
|
manager = new OrgBluezManagerInterface(QStringLiteral("org.bluez"), QStringLiteral("/"),
|
||||||
QDBusConnection::systemBus(), parent);
|
QDBusConnection::systemBus(), parent);
|
||||||
QObject::connect(&extendedDiscoveryTimer,
|
QObject::connect(&extendedDiscoveryTimer,
|
||||||
SIGNAL(timeout()),
|
&QTimer::timeout, [this]() {
|
||||||
q, SLOT(_q_extendedDeviceDiscoveryTimeout()));
|
this->_q_extendedDeviceDiscoveryTimeout();
|
||||||
|
});
|
||||||
extendedDiscoveryTimer.setInterval(10000);
|
extendedDiscoveryTimer.setInterval(10000);
|
||||||
extendedDiscoveryTimer.setSingleShot(true);
|
extendedDiscoveryTimer.setSingleShot(true);
|
||||||
}
|
}
|
||||||
|
|
@ -159,10 +161,14 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start(QBluetoothDeviceDiscoveryAgent
|
||||||
QDBusConnection::systemBus());
|
QDBusConnection::systemBus());
|
||||||
|
|
||||||
Q_Q(QBluetoothDeviceDiscoveryAgent);
|
Q_Q(QBluetoothDeviceDiscoveryAgent);
|
||||||
QObject::connect(adapter, SIGNAL(DeviceFound(QString, QVariantMap)),
|
QObject::connect(adapter, &OrgBluezAdapterInterface::DeviceFound,
|
||||||
q, SLOT(_q_deviceFound(QString, QVariantMap)));
|
[this](const QString &address, const QVariantMap &dict) {
|
||||||
QObject::connect(adapter, SIGNAL(PropertyChanged(QString, QDBusVariant)),
|
this->_q_deviceFound(address, dict);
|
||||||
q, SLOT(_q_propertyChanged(QString, QDBusVariant)));
|
});
|
||||||
|
QObject::connect(adapter, &OrgBluezAdapterInterface::PropertyChanged,
|
||||||
|
[this](const QString &name, const QDBusVariant &value) {
|
||||||
|
this->_q_propertyChanged(name, value);
|
||||||
|
});
|
||||||
|
|
||||||
QDBusPendingReply<QVariantMap> propertiesReply = adapter->GetProperties();
|
QDBusPendingReply<QVariantMap> propertiesReply = adapter->GetProperties();
|
||||||
propertiesReply.waitForFinished();
|
propertiesReply.waitForFinished();
|
||||||
|
|
@ -280,8 +286,10 @@ void QBluetoothDeviceDiscoveryAgentPrivate::startBluez5(QBluetoothDeviceDiscover
|
||||||
}
|
}
|
||||||
|
|
||||||
QtBluezDiscoveryManager::instance()->registerDiscoveryInterest(adapterBluez5->path());
|
QtBluezDiscoveryManager::instance()->registerDiscoveryInterest(adapterBluez5->path());
|
||||||
QObject::connect(QtBluezDiscoveryManager::instance(), SIGNAL(discoveryInterrupted(QString)),
|
QObject::connect(QtBluezDiscoveryManager::instance(), &QtBluezDiscoveryManager::discoveryInterrupted,
|
||||||
q, SLOT(_q_discoveryInterrupted(QString)));
|
[this](const QString &path){
|
||||||
|
this->_q_discoveryInterrupted(path);
|
||||||
|
});
|
||||||
|
|
||||||
// collect initial set of information
|
// collect initial set of information
|
||||||
QDBusPendingReply<ManagedObjectList> reply = managerBluez5->GetManagedObjects();
|
QDBusPendingReply<ManagedObjectList> reply = managerBluez5->GetManagedObjects();
|
||||||
|
|
@ -312,8 +320,10 @@ void QBluetoothDeviceDiscoveryAgentPrivate::startBluez5(QBluetoothDeviceDiscover
|
||||||
if (!discoveryTimer) {
|
if (!discoveryTimer) {
|
||||||
discoveryTimer = new QTimer(q);
|
discoveryTimer = new QTimer(q);
|
||||||
discoveryTimer->setSingleShot(true);
|
discoveryTimer->setSingleShot(true);
|
||||||
QObject::connect(discoveryTimer, SIGNAL(timeout()),
|
QObject::connect(discoveryTimer, &QTimer::timeout,
|
||||||
q, SLOT(_q_discoveryFinished()));
|
[this]() {
|
||||||
|
this->_q_discoveryFinished();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lowEnergySearchTimeout > 0) { // otherwise no timeout and stop() required
|
if (lowEnergySearchTimeout > 0) { // otherwise no timeout and stop() required
|
||||||
|
|
@ -420,8 +430,12 @@ void QBluetoothDeviceDiscoveryAgentPrivate::deviceFoundBluez5(const QString& dev
|
||||||
|
|
||||||
OrgFreedesktopDBusPropertiesInterface *prop = new OrgFreedesktopDBusPropertiesInterface(
|
OrgFreedesktopDBusPropertiesInterface *prop = new OrgFreedesktopDBusPropertiesInterface(
|
||||||
QStringLiteral("org.bluez"), devicePath, QDBusConnection::systemBus(), q);
|
QStringLiteral("org.bluez"), devicePath, QDBusConnection::systemBus(), q);
|
||||||
QObject::connect(prop, SIGNAL(PropertiesChanged(QString,QVariantMap,QStringList)),
|
QObject::connect(prop, &OrgFreedesktopDBusPropertiesInterface::PropertiesChanged,
|
||||||
q, SLOT(_q_PropertiesChanged(QString,QVariantMap,QStringList)));
|
[this](const QString &interface, const QVariantMap &changedProperties,
|
||||||
|
const QStringList &invalidatedProperties) {
|
||||||
|
this->_q_PropertiesChanged(interface, changedProperties, invalidatedProperties);
|
||||||
|
});
|
||||||
|
|
||||||
// remember what we have to cleanup
|
// remember what we have to cleanup
|
||||||
propertyMonitors.append(prop);
|
propertyMonitors.append(prop);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -397,8 +397,8 @@ void QBluetoothLocalDevice::requestPairing(const QBluetoothAddress &address, Pai
|
||||||
QStringLiteral("NoInputNoOutput"));
|
QStringLiteral("NoInputNoOutput"));
|
||||||
|
|
||||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
|
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
|
||||||
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher *)), d_ptr,
|
connect(watcher, &QDBusPendingCallWatcher::finished,
|
||||||
SLOT(pairingCompleted(QDBusPendingCallWatcher *)));
|
d_ptr, &QBluetoothLocalDevicePrivate::pairingCompleted);
|
||||||
|
|
||||||
if (reply.isError())
|
if (reply.isError())
|
||||||
qCWarning(QT_BT_BLUEZ) << Q_FUNC_INFO << reply.error() << d_ptr->agent_path;
|
qCWarning(QT_BT_BLUEZ) << Q_FUNC_INFO << reply.error() << d_ptr->agent_path;
|
||||||
|
|
@ -492,8 +492,8 @@ void QBluetoothLocalDevicePrivate::requestPairingBluez5(const QBluetoothAddress
|
||||||
pairingDiscoveryTimer = new QTimer(this);
|
pairingDiscoveryTimer = new QTimer(this);
|
||||||
pairingDiscoveryTimer->setSingleShot(true);
|
pairingDiscoveryTimer->setSingleShot(true);
|
||||||
pairingDiscoveryTimer->setInterval(20000); //20s
|
pairingDiscoveryTimer->setInterval(20000); //20s
|
||||||
connect(pairingDiscoveryTimer, SIGNAL(timeout()),
|
connect(pairingDiscoveryTimer, &QTimer::timeout,
|
||||||
SLOT(pairingDiscoveryTimedOut()));
|
this, &QBluetoothLocalDevicePrivate::pairingDiscoveryTimedOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
qCDebug(QT_BT_BLUEZ) << "Initiating discovery for pairing on" << targetAddress.toString();
|
qCDebug(QT_BT_BLUEZ) << "Initiating discovery for pairing on" << targetAddress.toString();
|
||||||
|
|
@ -555,8 +555,8 @@ void QBluetoothLocalDevicePrivate::processPairingBluez5(const QString &objectPat
|
||||||
//initiate the pairing
|
//initiate the pairing
|
||||||
QDBusPendingReply<> pairReply = pairingTarget->Pair();
|
QDBusPendingReply<> pairReply = pairingTarget->Pair();
|
||||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pairReply, this);
|
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pairReply, this);
|
||||||
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
|
connect(watcher, &QDBusPendingCallWatcher::finished,
|
||||||
SLOT(pairingCompleted(QDBusPendingCallWatcher*)));
|
this, &QBluetoothLocalDevicePrivate::pairingCompleted);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -678,12 +678,12 @@ void QBluetoothLocalDevicePrivate::connectDeviceChanges()
|
||||||
{
|
{
|
||||||
if (adapter) { // invalid QBluetoothLocalDevice due to wrong local adapter address
|
if (adapter) { // invalid QBluetoothLocalDevice due to wrong local adapter address
|
||||||
createCache();
|
createCache();
|
||||||
connect(adapter, SIGNAL(PropertyChanged(QString, QDBusVariant)),
|
connect(adapter, &OrgBluezAdapterInterface::PropertyChanged,
|
||||||
SLOT(PropertyChanged(QString, QDBusVariant)));
|
this, &QBluetoothLocalDevicePrivate::PropertyChanged);
|
||||||
connect(adapter, SIGNAL(DeviceCreated(QDBusObjectPath)),
|
connect(adapter, &OrgBluezAdapterInterface::DeviceCreated,
|
||||||
SLOT(_q_deviceCreated(QDBusObjectPath)));
|
this, &QBluetoothLocalDevicePrivate::_q_deviceCreated);
|
||||||
connect(adapter, SIGNAL(DeviceRemoved(QDBusObjectPath)),
|
connect(adapter, &OrgBluezAdapterInterface::DeviceRemoved,
|
||||||
SLOT(_q_deviceRemoved(QDBusObjectPath)));
|
this, &QBluetoothLocalDevicePrivate::_q_deviceRemoved);
|
||||||
} else if (adapterBluez5 && managerBluez5) {
|
} else if (adapterBluez5 && managerBluez5) {
|
||||||
//setup property change notifications for all existing devices
|
//setup property change notifications for all existing devices
|
||||||
QDBusPendingReply<ManagedObjectList> reply = managerBluez5->GetManagedObjects();
|
QDBusPendingReply<ManagedObjectList> reply = managerBluez5->GetManagedObjects();
|
||||||
|
|
@ -710,8 +710,8 @@ void QBluetoothLocalDevicePrivate::connectDeviceChanges()
|
||||||
monitor = new OrgFreedesktopDBusPropertiesInterface(QStringLiteral("org.bluez"),
|
monitor = new OrgFreedesktopDBusPropertiesInterface(QStringLiteral("org.bluez"),
|
||||||
path.path(),
|
path.path(),
|
||||||
QDBusConnection::systemBus(), this);
|
QDBusConnection::systemBus(), this);
|
||||||
connect(monitor, SIGNAL(PropertiesChanged(QString,QVariantMap,QStringList)),
|
connect(monitor, &OrgFreedesktopDBusPropertiesInterface::PropertiesChanged,
|
||||||
SLOT(PropertiesChanged(QString,QVariantMap,QStringList)));
|
this, &QBluetoothLocalDevicePrivate::PropertiesChanged);
|
||||||
deviceChangeMonitors.insert(path.path(), monitor);
|
deviceChangeMonitors.insert(path.path(), monitor);
|
||||||
|
|
||||||
if (ifaceValues.value(QStringLiteral("Connected"), false).toBool()) {
|
if (ifaceValues.value(QStringLiteral("Connected"), false).toBool()) {
|
||||||
|
|
@ -788,13 +788,13 @@ void QBluetoothLocalDevicePrivate::initializeAdapter()
|
||||||
|
|
||||||
// monitor case when local adapter is removed
|
// monitor case when local adapter is removed
|
||||||
manager = man.take();
|
manager = man.take();
|
||||||
connect(manager, SIGNAL(AdapterRemoved(QDBusObjectPath)),
|
connect(manager, &OrgBluezManagerInterface::AdapterRemoved,
|
||||||
this, SLOT(adapterRemoved(QDBusObjectPath)));
|
this, &QBluetoothLocalDevicePrivate::adapterRemoved);
|
||||||
|
|
||||||
currentMode = static_cast<QBluetoothLocalDevice::HostMode>(-1);
|
currentMode = static_cast<QBluetoothLocalDevice::HostMode>(-1);
|
||||||
if (adapter) {
|
if (adapter) {
|
||||||
connect(adapter, SIGNAL(PropertyChanged(QString, QDBusVariant)),
|
connect(adapter, &OrgBluezAdapterInterface::PropertyChanged,
|
||||||
SLOT(PropertyChanged(QString, QDBusVariant)));
|
this, &QBluetoothLocalDevicePrivate::PropertyChanged);
|
||||||
|
|
||||||
agent_path = agentPath;
|
agent_path = agentPath;
|
||||||
agent_path.append(QString::fromLatin1("/%1").arg(QRandomGenerator::global()->generate()));
|
agent_path.append(QString::fromLatin1("/%1").arg(QRandomGenerator::global()->generate()));
|
||||||
|
|
@ -813,10 +813,10 @@ void QBluetoothLocalDevicePrivate::initializeAdapterBluez5()
|
||||||
QStringLiteral("/"),
|
QStringLiteral("/"),
|
||||||
QDBusConnection::systemBus(), this);
|
QDBusConnection::systemBus(), this);
|
||||||
|
|
||||||
connect(managerBluez5, SIGNAL(InterfacesAdded(QDBusObjectPath,InterfaceList)),
|
connect(managerBluez5, &OrgFreedesktopDBusObjectManagerInterface::InterfacesAdded,
|
||||||
SLOT(InterfacesAdded(QDBusObjectPath,InterfaceList)));
|
this, &QBluetoothLocalDevicePrivate::InterfacesAdded);
|
||||||
connect(managerBluez5, SIGNAL(InterfacesRemoved(QDBusObjectPath,QStringList)),
|
connect(managerBluez5, &OrgFreedesktopDBusObjectManagerInterface::InterfacesRemoved,
|
||||||
SLOT(InterfacesRemoved(QDBusObjectPath,QStringList)));
|
this, &QBluetoothLocalDevicePrivate::InterfacesRemoved);
|
||||||
|
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
const QString adapterPath = findAdapterForAddress(localAddress, &ok);
|
const QString adapterPath = findAdapterForAddress(localAddress, &ok);
|
||||||
|
|
@ -833,8 +833,8 @@ void QBluetoothLocalDevicePrivate::initializeAdapterBluez5()
|
||||||
adapterProperties = new OrgFreedesktopDBusPropertiesInterface(
|
adapterProperties = new OrgFreedesktopDBusPropertiesInterface(
|
||||||
QStringLiteral("org.bluez"), adapterBluez5->path(),
|
QStringLiteral("org.bluez"), adapterBluez5->path(),
|
||||||
QDBusConnection::systemBus(), this);
|
QDBusConnection::systemBus(), this);
|
||||||
connect(adapterProperties, SIGNAL(PropertiesChanged(QString,QVariantMap,QStringList)),
|
connect(adapterProperties, &OrgFreedesktopDBusPropertiesInterface::PropertiesChanged,
|
||||||
SLOT(PropertiesChanged(QString,QVariantMap,QStringList)));
|
this, &QBluetoothLocalDevicePrivate::PropertiesChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentMode = static_cast<QBluetoothLocalDevice::HostMode>(-1);
|
currentMode = static_cast<QBluetoothLocalDevice::HostMode>(-1);
|
||||||
|
|
@ -914,8 +914,8 @@ void QBluetoothLocalDevicePrivate::InterfacesAdded(const QDBusObjectPath &object
|
||||||
QStringLiteral("org.bluez"),
|
QStringLiteral("org.bluez"),
|
||||||
object_path.path(),
|
object_path.path(),
|
||||||
QDBusConnection::systemBus());
|
QDBusConnection::systemBus());
|
||||||
connect(monitor, SIGNAL(PropertiesChanged(QString,QVariantMap,QStringList)),
|
connect(monitor, &OrgFreedesktopDBusPropertiesInterface::PropertiesChanged,
|
||||||
SLOT(PropertiesChanged(QString,QVariantMap,QStringList)));
|
this, &QBluetoothLocalDevicePrivate::PropertiesChanged);
|
||||||
deviceChangeMonitors.insert(object_path.path(), monitor);
|
deviceChangeMonitors.insert(object_path.path(), monitor);
|
||||||
|
|
||||||
const QVariantMap ifaceValues = interfaces_and_properties.value(QStringLiteral("org.bluez.Device1"));
|
const QVariantMap ifaceValues = interfaces_and_properties.value(QStringLiteral("org.bluez.Device1"));
|
||||||
|
|
@ -1034,8 +1034,8 @@ void QBluetoothLocalDevicePrivate::_q_deviceCreated(const QDBusObjectPath &devic
|
||||||
= new OrgBluezDeviceInterface(QStringLiteral("org.bluez"),
|
= new OrgBluezDeviceInterface(QStringLiteral("org.bluez"),
|
||||||
device.path(),
|
device.path(),
|
||||||
QDBusConnection::systemBus(), this);
|
QDBusConnection::systemBus(), this);
|
||||||
connect(deviceInterface, SIGNAL(PropertyChanged(QString, QDBusVariant)),
|
connect(deviceInterface, &OrgBluezDeviceInterface::PropertyChanged,
|
||||||
SLOT(_q_devicePropertyChanged(QString, QDBusVariant)));
|
this, &QBluetoothLocalDevicePrivate::_q_devicePropertyChanged);
|
||||||
devices << deviceInterface;
|
devices << deviceInterface;
|
||||||
QDBusPendingReply<QVariantMap> properties
|
QDBusPendingReply<QVariantMap> properties
|
||||||
= deviceInterface->asyncCall(QStringLiteral("GetProperties"));
|
= deviceInterface->asyncCall(QStringLiteral("GetProperties"));
|
||||||
|
|
@ -1112,8 +1112,8 @@ void QBluetoothLocalDevicePrivate::createCache()
|
||||||
new OrgBluezDeviceInterface(QStringLiteral("org.bluez"),
|
new OrgBluezDeviceInterface(QStringLiteral("org.bluez"),
|
||||||
device.path(),
|
device.path(),
|
||||||
QDBusConnection::systemBus(), this);
|
QDBusConnection::systemBus(), this);
|
||||||
connect(deviceInterface, SIGNAL(PropertyChanged(QString,QDBusVariant)),
|
connect(deviceInterface, &OrgBluezDeviceInterface::PropertyChanged,
|
||||||
SLOT(_q_devicePropertyChanged(QString,QDBusVariant)));
|
this, &QBluetoothLocalDevicePrivate::_q_devicePropertyChanged);
|
||||||
devices << deviceInterface;
|
devices << deviceInterface;
|
||||||
|
|
||||||
QDBusPendingReply<QVariantMap> properties
|
QDBusPendingReply<QVariantMap> properties
|
||||||
|
|
|
||||||
|
|
@ -104,10 +104,6 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DECLARE_PRIVATE(QBluetoothServer)
|
Q_DECLARE_PRIVATE(QBluetoothServer)
|
||||||
|
|
||||||
#if QT_CONFIG(bluez)
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_newConnection())
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
|
||||||
|
|
@ -252,7 +252,10 @@ bool QBluetoothServer::listen(const QBluetoothAddress &address, quint16 port)
|
||||||
if (!d->socketNotifier) {
|
if (!d->socketNotifier) {
|
||||||
d->socketNotifier = new QSocketNotifier(d->socket->socketDescriptor(),
|
d->socketNotifier = new QSocketNotifier(d->socket->socketDescriptor(),
|
||||||
QSocketNotifier::Read);
|
QSocketNotifier::Read);
|
||||||
connect(d->socketNotifier, SIGNAL(activated(int)), this, SLOT(_q_newConnection()));
|
connect(d->socketNotifier, &QSocketNotifier::activated,
|
||||||
|
[d](){
|
||||||
|
d->_q_newConnection();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -434,13 +434,19 @@ void QBluetoothServiceDiscoveryAgentPrivate::startDeviceDiscovery()
|
||||||
#else
|
#else
|
||||||
deviceDiscoveryAgent = new QBluetoothDeviceDiscoveryAgent(q);
|
deviceDiscoveryAgent = new QBluetoothDeviceDiscoveryAgent(q);
|
||||||
#endif
|
#endif
|
||||||
QObject::connect(deviceDiscoveryAgent, SIGNAL(finished()),
|
QObject::connect(deviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::finished,
|
||||||
q, SLOT(_q_deviceDiscoveryFinished()));
|
[this](){
|
||||||
QObject::connect(deviceDiscoveryAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)),
|
this->_q_deviceDiscoveryFinished();
|
||||||
q, SLOT(_q_deviceDiscovered(QBluetoothDeviceInfo)));
|
});
|
||||||
QObject::connect(deviceDiscoveryAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)),
|
QObject::connect(deviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered,
|
||||||
q, SLOT(_q_deviceDiscoveryError(QBluetoothDeviceDiscoveryAgent::Error)));
|
[this](const QBluetoothDeviceInfo &info){
|
||||||
|
this->_q_deviceDiscovered(info);
|
||||||
|
});
|
||||||
|
QObject::connect(deviceDiscoveryAgent,
|
||||||
|
QOverload<QBluetoothDeviceDiscoveryAgent::Error>::of(&QBluetoothDeviceDiscoveryAgent::error),
|
||||||
|
[this](QBluetoothDeviceDiscoveryAgent::Error newError){
|
||||||
|
this->_q_deviceDiscoveryError(newError);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setDiscoveryState(DeviceDiscovery);
|
setDiscoveryState(DeviceDiscovery);
|
||||||
|
|
|
||||||
|
|
@ -110,25 +110,6 @@ Q_SIGNALS:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QBluetoothServiceDiscoveryAgentPrivate *d_ptr;
|
QBluetoothServiceDiscoveryAgentPrivate *d_ptr;
|
||||||
|
|
||||||
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_deviceDiscovered(const QBluetoothDeviceInfo &info))
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_deviceDiscoveryFinished())
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_deviceDiscoveryError(QBluetoothDeviceDiscoveryAgent::Error))
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_serviceDiscoveryFinished())
|
|
||||||
|
|
||||||
#if QT_CONFIG(bluez)
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_discoveredServices(QDBusPendingCallWatcher*))
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_createdDevice(QDBusPendingCallWatcher*))
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_foundDevice(QDBusPendingCallWatcher*))
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_sdpScannerDone(int,QProcess::ExitStatus))
|
|
||||||
#endif
|
|
||||||
#ifdef QT_ANDROID_BLUETOOTH
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_processFetchedUuids(const QBluetoothAddress &address,
|
|
||||||
const QList<QBluetoothUuid>&))
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_fetchUuidsTimeout())
|
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_hostModeStateChanged(QBluetoothLocalDevice::HostMode state))
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <QtCore/qcoreapplication.h>
|
||||||
#include <QtCore/QLoggingCategory>
|
#include <QtCore/QLoggingCategory>
|
||||||
#include <QtCore/QTimer>
|
#include <QtCore/QTimer>
|
||||||
#include <QtCore/private/qjnihelpers_p.h>
|
#include <QtCore/private/qjnihelpers_p.h>
|
||||||
|
|
@ -198,14 +199,18 @@ void QBluetoothServiceDiscoveryAgentPrivate::start(const QBluetoothAddress &addr
|
||||||
//Full discovery uses BluetoothDevice.fetchUuidsWithSdp()
|
//Full discovery uses BluetoothDevice.fetchUuidsWithSdp()
|
||||||
if (!receiver) {
|
if (!receiver) {
|
||||||
receiver = new ServiceDiscoveryBroadcastReceiver();
|
receiver = new ServiceDiscoveryBroadcastReceiver();
|
||||||
QObject::connect(receiver, SIGNAL(uuidFetchFinished(QBluetoothAddress,QList<QBluetoothUuid>)),
|
QObject::connect(receiver, &ServiceDiscoveryBroadcastReceiver::uuidFetchFinished,
|
||||||
q, SLOT(_q_processFetchedUuids(QBluetoothAddress,QList<QBluetoothUuid>)));
|
[this](const QBluetoothAddress &address, const QList<QBluetoothUuid>& uuids) {
|
||||||
|
this->_q_processFetchedUuids(address, uuids);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!localDeviceReceiver) {
|
if (!localDeviceReceiver) {
|
||||||
localDeviceReceiver = new LocalDeviceBroadcastReceiver();
|
localDeviceReceiver = new LocalDeviceBroadcastReceiver();
|
||||||
QObject::connect(localDeviceReceiver, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)),
|
QObject::connect(localDeviceReceiver, &LocalDeviceBroadcastReceiver::hostModeStateChanged,
|
||||||
q, SLOT(_q_hostModeStateChanged(QBluetoothLocalDevice::HostMode)));
|
[this](QBluetoothLocalDevice::HostMode state){
|
||||||
|
this->_q_hostModeStateChanged(state);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
jboolean result = remoteDevice.callMethod<jboolean>("fetchUuidsWithSdp");
|
jboolean result = remoteDevice.callMethod<jboolean>("fetchUuidsWithSdp");
|
||||||
|
|
@ -245,8 +250,9 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_processFetchedUuids(
|
||||||
//could not find any service for the current address/device -> go to next one
|
//could not find any service for the current address/device -> go to next one
|
||||||
if (address.isNull() || uuids.isEmpty()) {
|
if (address.isNull() || uuids.isEmpty()) {
|
||||||
if (discoveredDevices.count() == 1) {
|
if (discoveredDevices.count() == 1) {
|
||||||
Q_Q(QBluetoothServiceDiscoveryAgent);
|
QTimer::singleShot(4000, qApp, [this]() {
|
||||||
QTimer::singleShot(4000, q, SLOT(_q_fetchUuidsTimeout()));
|
this->_q_fetchUuidsTimeout();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
_q_serviceDiscoveryFinished();
|
_q_serviceDiscoveryFinished();
|
||||||
return;
|
return;
|
||||||
|
|
@ -295,8 +301,9 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_processFetchedUuids(
|
||||||
//the discovery on the last device cannot immediately finish
|
//the discovery on the last device cannot immediately finish
|
||||||
//we have to grant the 2 seconds timeout delay
|
//we have to grant the 2 seconds timeout delay
|
||||||
if (discoveredDevices.count() == 1) {
|
if (discoveredDevices.count() == 1) {
|
||||||
Q_Q(QBluetoothServiceDiscoveryAgent);
|
QTimer::singleShot(4000, qApp, [this]() {
|
||||||
QTimer::singleShot(4000, q, SLOT(_q_fetchUuidsTimeout()));
|
this->_q_fetchUuidsTimeout();
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -128,8 +128,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::start(const QBluetoothAddress &addr
|
||||||
|
|
||||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(deviceObjectPath, q);
|
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(deviceObjectPath, q);
|
||||||
watcher->setProperty("_q_BTaddress", QVariant::fromValue(address));
|
watcher->setProperty("_q_BTaddress", QVariant::fromValue(address));
|
||||||
QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
|
QObject::connect(watcher, &QDBusPendingCallWatcher::finished,
|
||||||
q, SLOT(_q_foundDevice(QDBusPendingCallWatcher*)));
|
[this](QDBusPendingCallWatcher *watcher){
|
||||||
|
this->_q_foundDevice(watcher);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bluez 5
|
// Bluez 5
|
||||||
|
|
@ -212,8 +214,11 @@ void QBluetoothServiceDiscoveryAgentPrivate::runExternalSdpScan(
|
||||||
if (QT_BT_BLUEZ().isDebugEnabled())
|
if (QT_BT_BLUEZ().isDebugEnabled())
|
||||||
sdpScannerProcess->setProcessChannelMode(QProcess::ForwardedErrorChannel);
|
sdpScannerProcess->setProcessChannelMode(QProcess::ForwardedErrorChannel);
|
||||||
sdpScannerProcess->setProgram(fileInfo.canonicalFilePath());
|
sdpScannerProcess->setProgram(fileInfo.canonicalFilePath());
|
||||||
q->connect(sdpScannerProcess, SIGNAL(finished(int,QProcess::ExitStatus)),
|
q->connect(sdpScannerProcess,
|
||||||
q, SLOT(_q_sdpScannerDone(int,QProcess::ExitStatus)));
|
QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
||||||
|
[this](int exitCode, QProcess::ExitStatus status){
|
||||||
|
this->_q_sdpScannerDone(exitCode, status);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
|
|
@ -326,7 +331,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::stop()
|
||||||
{
|
{
|
||||||
qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO << "Stop called";
|
qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO << "Stop called";
|
||||||
if (device) {
|
if (device) {
|
||||||
//we are waiting for _q_discoveredServices() slot to be called
|
//we are waiting for _q_discoveredServices() to be called
|
||||||
// adapter is already 0
|
// adapter is already 0
|
||||||
QDBusPendingReply<> reply = device->CancelDiscovery();
|
QDBusPendingReply<> reply = device->CancelDiscovery();
|
||||||
reply.waitForFinished();
|
reply.waitForFinished();
|
||||||
|
|
@ -335,7 +340,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::stop()
|
||||||
device = nullptr;
|
device = nullptr;
|
||||||
Q_ASSERT(!adapter);
|
Q_ASSERT(!adapter);
|
||||||
} else if (adapter) {
|
} else if (adapter) {
|
||||||
//we are waiting for _q_createdDevice() slot to be called
|
//we are waiting for _q_createdDevice() to be called
|
||||||
adapter->deleteLater();
|
adapter->deleteLater();
|
||||||
adapter = nullptr;
|
adapter = nullptr;
|
||||||
Q_ASSERT(!device);
|
Q_ASSERT(!device);
|
||||||
|
|
@ -390,8 +395,11 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_foundDevice(QDBusPendingCallWatc
|
||||||
deviceObjectPath = adapter->CreateDevice(address.toString());
|
deviceObjectPath = adapter->CreateDevice(address.toString());
|
||||||
watcher = new QDBusPendingCallWatcher(deviceObjectPath, q);
|
watcher = new QDBusPendingCallWatcher(deviceObjectPath, q);
|
||||||
watcher->setProperty("_q_BTaddress", QVariant::fromValue(address));
|
watcher->setProperty("_q_BTaddress", QVariant::fromValue(address));
|
||||||
QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
|
QObject::connect(watcher, &QDBusPendingCallWatcher::finished,
|
||||||
q, SLOT(_q_createdDevice(QDBusPendingCallWatcher*)));
|
[this](QDBusPendingCallWatcher *watcher){
|
||||||
|
this->_q_createdDevice(watcher);
|
||||||
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -528,8 +536,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::discoverServices(const QString &dev
|
||||||
|
|
||||||
QDBusPendingReply<ServiceMap> discoverReply = device->DiscoverServices(pattern);
|
QDBusPendingReply<ServiceMap> discoverReply = device->DiscoverServices(pattern);
|
||||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(discoverReply, q);
|
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(discoverReply, q);
|
||||||
QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
|
QObject::connect(watcher, &QDBusPendingCallWatcher::finished,
|
||||||
q, SLOT(_q_discoveredServices(QDBusPendingCallWatcher*)));
|
[this](QDBusPendingCallWatcher *watcher){
|
||||||
|
this->_q_discoveredServices(watcher);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue