summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bluetooth/bluetooth.pro5
-rw-r--r--src/bluetooth/doc/src/bluetooth-index.qdoc1
-rw-r--r--src/bluetooth/doc/src/examples.qdoc5
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent.cpp29
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent.h1
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp16
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_p.cpp2
-rw-r--r--src/bluetooth/qbluetoothdeviceinfo.h2
-rw-r--r--src/bluetooth/qbluetoothlocaldevice.cpp21
-rw-r--r--src/bluetooth/qbluetoothlocaldevice.h5
-rw-r--r--src/bluetooth/qbluetoothlocaldevice_bluez.cpp122
-rw-r--r--src/bluetooth/qbluetoothlocaldevice_p.cpp5
-rw-r--r--src/bluetooth/qbluetoothlocaldevice_p.h18
-rw-r--r--src/bluetooth/qbluetoothlocaldevice_qnx.cpp63
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent.cpp45
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent.h1
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp2
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_p.cpp1
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_p.h5
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp123
-rw-r--r--src/bluetooth/qbluetoothsocket.h2
-rw-r--r--src/bluetooth/qbluetoothsocket_bluez.cpp8
-rw-r--r--src/bluetooth/qbluetoothtransfermanager.h2
-rw-r--r--src/bluetooth/qbluetoothtransferreply_bluez.cpp2
-rw-r--r--src/bluetooth/qbluetoothtransferrequest.h2
-rw-r--r--src/imports/bluetooth/plugin.cpp4
-rw-r--r--src/imports/bluetooth/plugins.qmltypes7
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp5
-rw-r--r--src/imports/nfc/plugin.cpp5
-rw-r--r--src/imports/nfc/plugins.qmltypes10
-rw-r--r--src/nfc/qllcpserver_p.cpp2
-rw-r--r--src/nfc/qllcpsocket.cpp2
-rw-r--r--src/nfc/qllcpsocket_p.cpp2
33 files changed, 486 insertions, 39 deletions
diff --git a/src/bluetooth/bluetooth.pro b/src/bluetooth/bluetooth.pro
index c1553936..d7214f2c 100644
--- a/src/bluetooth/bluetooth.pro
+++ b/src/bluetooth/bluetooth.pro
@@ -77,6 +77,11 @@ config_bluez:qtHaveModule(dbus) {
include(qnx/qnx.pri)
+ config_btapi10_2_1 {
+ DEFINES += QT_QNX_BT_BLUETOOTH
+ LIBS += -lbtapi
+ }
+
PRIVATE_HEADERS += \
qbluetoothtransferreply_qnx_p.h
diff --git a/src/bluetooth/doc/src/bluetooth-index.qdoc b/src/bluetooth/doc/src/bluetooth-index.qdoc
index ff1651d0..77575994 100644
--- a/src/bluetooth/doc/src/bluetooth-index.qdoc
+++ b/src/bluetooth/doc/src/bluetooth-index.qdoc
@@ -68,6 +68,7 @@ import statement in your \c .qml file:
\li QML
\list
\li \l {scanner}{QML Bluetooth Scanner}
+ \li \l {picturetransfer}{QML Bluetooth Picture Push}
\endlist
\li C++
\list
diff --git a/src/bluetooth/doc/src/examples.qdoc b/src/bluetooth/doc/src/examples.qdoc
index 441b303d..a4329b3a 100644
--- a/src/bluetooth/doc/src/examples.qdoc
+++ b/src/bluetooth/doc/src/examples.qdoc
@@ -66,8 +66,11 @@
\li The tennis game using a QML interface to the Bluetooth API. It
must connect to an instance of the C++ \l{bttennis}{Bluetooth Tennis} game to play.
\row
- \li \l{btscanner}{QML Bluetooth Scanner}
+ \li \l{scanner}{QML Bluetooth Scanner}
\li A QML implementation of the Bluetooth device scanner.
+ \row
+ \li \l{picturetransfer}{QML Picture Push Example}
+ \li A QML application that transfers pictures between Bluetooth devices.
\endtable
*/
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent.cpp
index 57136a65..eeac8f11 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent.cpp
@@ -38,6 +38,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+#include "qbluetoothhostinfo.h"
#include "qbluetoothdevicediscoveryagent.h"
#include "qbluetoothdevicediscoveryagent_p.h"
@@ -71,6 +72,8 @@ QT_BEGIN_NAMESPACE
\value NoError No error has occurred.
\value PoweredOffError The Bluetooth adaptor is powered off, power it on before doing discovery.
\value InputOutputError Writing or reading from the device resulted in an error.
+ \value InvalidBluetoothAdapterError The passed local adapter address does not match the physical
+ adapter address of any local Bluetooth device.
\value UnknownError An unknown error has occurred.
*/
@@ -102,12 +105,14 @@ QT_BEGIN_NAMESPACE
\fn void QBluetoothDeviceDiscoveryAgent::finished()
This signal is emitted when Bluetooth device discovery completes.
+ The signal is not going to be emitted if the device discovery finishes with an error.
*/
/*!
\fn void QBluetoothDeviceDiscoveryAgent::error(QBluetoothDeviceDiscoveryAgent::Error error)
This signal is emitted when an \a error occurs during Bluetooth device discovery.
+ The \a error parameter describes the error that occurred.
\sa error(), errorString()
*/
@@ -134,14 +139,30 @@ QBluetoothDeviceDiscoveryAgent::QBluetoothDeviceDiscoveryAgent(QObject *parent)
}
/*!
- Constructs a new Bluetooth device discovery agent with parent \a parent and uses the adapter \a deviceAdapter
- for the device search. If \a deviceAdapter is default constructed the resulting
+ Constructs a new Bluetooth device discovery agent with \a parent.
+
+ It uses \a deviceAdapter for the device search. If \a deviceAdapter is default constructed the resulting
QBluetoothDeviceDiscoveryAgent object will use the local default Bluetooth adapter.
+
+ If a \a deviceAdapter is specified that is not a local adapter \l error() will be set to
+ \l InvalidBluetoothAdapterError. Therefore it is recommended to test the error flag immediately after
+ using this constructor.
+
+ \sa error()
*/
QBluetoothDeviceDiscoveryAgent::QBluetoothDeviceDiscoveryAgent(const QBluetoothAddress &deviceAdapter, QObject *parent)
: QObject(parent), d_ptr(new QBluetoothDeviceDiscoveryAgentPrivate(deviceAdapter))
{
d_ptr->q_ptr = this;
+ if (!deviceAdapter.isNull()) {
+ const QList<QBluetoothHostInfo> localDevices = QBluetoothLocalDevice::allDevices();
+ foreach (const QBluetoothHostInfo &hostInfo, localDevices) {
+ if (hostInfo.address() == deviceAdapter)
+ return;
+ }
+ d_ptr->lastError = InvalidBluetoothAdapterError;
+ d_ptr->errorString = tr("Invalid Bluetooth adapter address");
+ }
}
/*!
@@ -194,7 +215,7 @@ QList<QBluetoothDeviceInfo> QBluetoothDeviceDiscoveryAgent::discoveredDevices()
void QBluetoothDeviceDiscoveryAgent::start()
{
Q_D(QBluetoothDeviceDiscoveryAgent);
- if (!isActive())
+ if (!isActive() && d->lastError != InvalidBluetoothAdapterError)
d->start();
}
@@ -207,7 +228,7 @@ void QBluetoothDeviceDiscoveryAgent::start()
void QBluetoothDeviceDiscoveryAgent::stop()
{
Q_D(QBluetoothDeviceDiscoveryAgent);
- if (isActive())
+ if (isActive() && d->lastError != InvalidBluetoothAdapterError)
d->stop();
}
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent.h b/src/bluetooth/qbluetoothdevicediscoveryagent.h
index a311d14f..4ac1685e 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent.h
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent.h
@@ -66,6 +66,7 @@ public:
NoError,
InputOutputError,
PoweredOffError,
+ InvalidBluetoothAdapterError,
UnknownError = 100 //New errors must be added before Unknown error
};
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp
index 48c8b983..69f09130 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp
@@ -121,6 +121,18 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start()
qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO << "ERROR: " << errorString;
lastError = QBluetoothDeviceDiscoveryAgent::InputOutputError;
Q_Q(QBluetoothDeviceDiscoveryAgent);
+ delete adapter;
+ adapter = 0;
+ emit q->error(lastError);
+ return;
+ }
+
+ if (!propertiesReply.value().value(QStringLiteral("Powered")).toBool()) {
+ qCDebug(QT_BT_BLUEZ) << "Aborting device discovery due to offline Bluetooth Adapter";
+ lastError = QBluetoothDeviceDiscoveryAgent::PoweredOffError;
+ errorString = QBluetoothDeviceDiscoveryAgent::tr("Device is powered off.");
+ delete adapter;
+ adapter = 0;
emit q->error(lastError);
return;
}
@@ -154,7 +166,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::_q_deviceFound(const QString &addres
{
const QBluetoothAddress btAddress(address);
const QString btName = dict.value(QLatin1String("Name")).toString();
- quint32 btClass = dict.value(QLatin1String("Class")).toUInt();
+ quint32 btClass = dict.value(QLatin1String("Class")).toUInt();
qCDebug(QT_BT_BLUEZ) << "Discovered: " << address << btName
<< "Num UUIDs" << dict.value(QLatin1String("UUIDs")).toStringList().count()
@@ -193,7 +205,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::_q_deviceFound(const QString &addres
void QBluetoothDeviceDiscoveryAgentPrivate::_q_propertyChanged(const QString &name,
const QDBusVariant &value)
-{
+{
qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO << name << value.variant();
if (name == QLatin1String("Discovering") && !value.variant().toBool()) {
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_p.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_p.cpp
index 2c667607..72a3e853 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_p.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_p.cpp
@@ -85,7 +85,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::_q_deviceFound(const QString &addres
void QBluetoothDeviceDiscoveryAgentPrivate::_q_propertyChanged(const QString &name,
const QDBusVariant &value)
-{
+{
Q_UNUSED(name);
Q_UNUSED(value);
}
diff --git a/src/bluetooth/qbluetoothdeviceinfo.h b/src/bluetooth/qbluetoothdeviceinfo.h
index ee8be191..be605f8d 100644
--- a/src/bluetooth/qbluetoothdeviceinfo.h
+++ b/src/bluetooth/qbluetoothdeviceinfo.h
@@ -142,7 +142,7 @@ public:
enum MinorImagingClass {
UncategorizedImagingDevice = 0,
ImageDisplay = 0x04,
- ImageCamera = 0x08,
+ ImageCamera = 0x08,
ImageScanner = 0x10,
ImagePrinter = 0x20
};
diff --git a/src/bluetooth/qbluetoothlocaldevice.cpp b/src/bluetooth/qbluetoothlocaldevice.cpp
index 2981f3e0..fe13a2de 100644
--- a/src/bluetooth/qbluetoothlocaldevice.cpp
+++ b/src/bluetooth/qbluetoothlocaldevice.cpp
@@ -187,6 +187,27 @@ bool QBluetoothLocalDevice::isValid() const
*/
/*!
+ \fn QBluetoothLocalDevice::deviceConnected(const QBluetoothAddress &address)
+ \since 5.3
+
+ A device with \a address is connected with this device.
+*/
+
+/*!
+ \fn QBluetoothLocalDevice::deviceDisconnected(const QBluetoothAddress &address)
+ \since 5.3
+
+ A device with \a address is disconnected from this device.
+*/
+
+/*!
+ \fn QList<QBluetoothAddress> QBluetoothLocalDevice::connectedDevices() const
+ \since 5.3
+
+ Returns the list of connected devices.
+*/
+
+/*!
\fn QBluetoothLocalDevice::pairingStatus(const QBluetoothAddress &address) const
Returns the current bluetooth pairing status of \a address, if it's unpaired, paired, or paired and authorized.
diff --git a/src/bluetooth/qbluetoothlocaldevice.h b/src/bluetooth/qbluetoothlocaldevice.h
index 713b5037..597496b7 100644
--- a/src/bluetooth/qbluetoothlocaldevice.h
+++ b/src/bluetooth/qbluetoothlocaldevice.h
@@ -68,7 +68,7 @@ public:
AuthorizedPaired
};
- enum HostMode {
+ enum HostMode {
HostPoweredOff,
HostConnectable,
HostDiscoverable,
@@ -91,6 +91,7 @@ public:
void setHostMode(QBluetoothLocalDevice::HostMode mode);
HostMode hostMode() const;
+ QList<QBluetoothAddress> connectedDevices() const;
void powerOn();
@@ -104,6 +105,8 @@ public Q_SLOTS:
Q_SIGNALS:
void hostModeStateChanged(QBluetoothLocalDevice::HostMode state);
+ void deviceConnected(const QBluetoothAddress &address);
+ void deviceDisconnected(const QBluetoothAddress &address);
void pairingFinished(const QBluetoothAddress &address, QBluetoothLocalDevice::Pairing pairing);
void pairingDisplayPinCode(const QBluetoothAddress &address, QString pin);
diff --git a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp
index c4601947..310be91b 100644
--- a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp
+++ b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp
@@ -57,6 +57,11 @@ Q_DECLARE_LOGGING_CATEGORY(QT_BT_BLUEZ)
static const QLatin1String agentPath("/qt/agent");
+inline uint qHash(const QBluetoothAddress &address)
+{
+ return ::qHash(address.toUInt64());
+}
+
QBluetoothLocalDevice::QBluetoothLocalDevice(QObject *parent) :
QObject(parent), d_ptr(new QBluetoothLocalDevicePrivate(this))
{
@@ -68,7 +73,7 @@ QBluetoothLocalDevice::QBluetoothLocalDevice(const QBluetoothAddress &address, Q
}
QString QBluetoothLocalDevice::name() const
-{
+{
if (!d_ptr || !d_ptr->adapter)
return QString();
@@ -157,6 +162,11 @@ QBluetoothLocalDevice::HostMode QBluetoothLocalDevice::hostMode() const
return HostPoweredOff;
}
+QList<QBluetoothAddress> QBluetoothLocalDevice::connectedDevices() const
+{
+ return d_ptr->connectedDevices();
+}
+
QList<QBluetoothHostInfo> QBluetoothLocalDevice::allDevices()
{
QList<QBluetoothHostInfo> localDevices;
@@ -337,9 +347,19 @@ QBluetoothLocalDevice::Pairing QBluetoothLocalDevice::pairingStatus(const QBluet
}
QBluetoothLocalDevicePrivate::QBluetoothLocalDevicePrivate(QBluetoothLocalDevice *q, QBluetoothAddress address)
- : adapter(0), agent(0), localAddress(address), pendingHostModeChange(-1), msgConnection(0), q_ptr(q)
+ : adapter(0), agent(0), localAddress(address), pendingHostModeChange(-1), msgConnection(0), q_ptr(q), connectedCached(false)
{
initializeAdapter();
+ connectDeviceChanges();
+}
+
+void QBluetoothLocalDevicePrivate::connectDeviceChanges()
+{
+ if (adapter) { //invalid QBluetoothLocalDevice due to wrong local adapter address
+ connect(adapter, SIGNAL(PropertyChanged(QString,QDBusVariant)), SLOT(PropertyChanged(QString,QDBusVariant)));
+ connect(adapter, SIGNAL(DeviceCreated(QDBusObjectPath)), SLOT(_q_deviceCreated(QDBusObjectPath)));
+ connect(adapter, SIGNAL(DeviceRemoved(QDBusObjectPath)), SLOT(_q_deviceRemoved(QDBusObjectPath)));
+ }
}
QBluetoothLocalDevicePrivate::~QBluetoothLocalDevicePrivate()
@@ -347,6 +367,7 @@ QBluetoothLocalDevicePrivate::~QBluetoothLocalDevicePrivate()
delete msgConnection;
delete adapter;
delete agent;
+ qDeleteAll(devices);
}
void QBluetoothLocalDevicePrivate::initializeAdapter()
@@ -414,6 +435,103 @@ void QBluetoothLocalDevicePrivate::RequestConfirmation(const QDBusObjectPath &in
return;
}
+void QBluetoothLocalDevicePrivate::_q_deviceCreated(const QDBusObjectPath &device)
+{
+ OrgBluezDeviceInterface *deviceInterface =
+ new OrgBluezDeviceInterface(QLatin1String("org.bluez"), device.path(), QDBusConnection::systemBus());
+ connect(deviceInterface, SIGNAL(PropertyChanged(QString,QDBusVariant)), SLOT(_q_devicePropertyChanged(QString,QDBusVariant)));
+ devices << deviceInterface;
+ QDBusPendingReply<QVariantMap> properties = deviceInterface->asyncCall(QLatin1String("GetProperties"));
+
+ properties.waitForFinished();
+ if (!properties.isValid()) {
+ qCritical() << "Unable to get device properties from: " << device.path();
+ return;
+ }
+ const QBluetoothAddress address = QBluetoothAddress(properties.value().value(QLatin1String("Address")).toString());
+ const bool connected = properties.value().value(QLatin1String("Connected")).toBool();
+
+ if (connectedCached) {
+ if (connected)
+ connectedDevicesSet.insert(address);
+ else
+ connectedDevicesSet.remove(address);
+ }
+ if (connected)
+ emit q_ptr->deviceConnected(address);
+ else
+ emit q_ptr->deviceDisconnected(address);
+}
+
+void QBluetoothLocalDevicePrivate::_q_deviceRemoved(const QDBusObjectPath &device)
+{
+ foreach (OrgBluezDeviceInterface *deviceInterface, devices) {
+ if (deviceInterface->path() == device.path()) {
+ devices.remove(deviceInterface);
+ delete deviceInterface; //deviceDisconnected is already emitted by _q_devicePropertyChanged
+ break;
+ }
+ }
+}
+
+void QBluetoothLocalDevicePrivate::_q_devicePropertyChanged(const QString &property, const QDBusVariant &value)
+{
+ OrgBluezDeviceInterface *deviceInterface = qobject_cast<OrgBluezDeviceInterface*>(sender());
+ if (deviceInterface && property == QLatin1String("Connected")) {
+ QDBusPendingReply<QVariantMap> propertiesReply = deviceInterface->GetProperties();
+ propertiesReply.waitForFinished();
+ if (propertiesReply.isError()) {
+ qCWarning(QT_BT_BLUEZ) << propertiesReply.error().message();
+ return;
+ }
+ const QVariantMap properties = propertiesReply.value();
+ const QBluetoothAddress address = QBluetoothAddress(properties.value(QLatin1String("Address")).toString());
+ const bool connected = value.variant().toBool();
+
+ if (connectedCached) {
+ if (connected)
+ connectedDevicesSet.insert(address);
+ else
+ connectedDevicesSet.remove(address);
+ }
+ if (connected)
+ emit q_ptr->deviceConnected(address);
+ else
+ emit q_ptr->deviceDisconnected(address);
+ }
+}
+
+void QBluetoothLocalDevicePrivate::createCache()
+{
+ QDBusPendingReply<QList<QDBusObjectPath> > reply = adapter->ListDevices();
+ reply.waitForFinished();
+ if (reply.isError()) {
+ qCWarning(QT_BT_BLUEZ) << reply.error().message();
+ return;
+ }
+ foreach (const QDBusObjectPath &device, reply.value()) {
+ OrgBluezDeviceInterface deviceInterface(QLatin1String("org.bluez"), device.path(), QDBusConnection::systemBus());
+
+ QDBusPendingReply<QVariantMap> properties = deviceInterface.asyncCall(QLatin1String("GetProperties"));
+ properties.waitForFinished();
+ if (!properties.isValid()) {
+ qCWarning(QT_BT_BLUEZ) << "Unable to get properties for device " << device.path();
+ return;
+ }
+
+ if (properties.value().value(QLatin1String("Connected")).toBool())
+ connectedDevicesSet.insert(QBluetoothAddress(properties.value().value(QLatin1String("Address")).toString()));
+ }
+ connectedCached = true;
+}
+
+QList<QBluetoothAddress> QBluetoothLocalDevicePrivate::connectedDevices() const
+{
+ if (!connectedCached)
+ const_cast<QBluetoothLocalDevicePrivate *>(this)->createCache();
+ return connectedDevicesSet.toList();
+}
+
void QBluetoothLocalDevice::pairingConfirmation(bool confirmation)
{
if(!d_ptr ||
diff --git a/src/bluetooth/qbluetoothlocaldevice_p.cpp b/src/bluetooth/qbluetoothlocaldevice_p.cpp
index 411863cb..d40e6473 100644
--- a/src/bluetooth/qbluetoothlocaldevice_p.cpp
+++ b/src/bluetooth/qbluetoothlocaldevice_p.cpp
@@ -79,6 +79,11 @@ QBluetoothLocalDevice::HostMode QBluetoothLocalDevice::hostMode() const
return HostPoweredOff;
}
+QList<QBluetoothAddress> QBluetoothLocalDevice::connectedDevices() const
+{
+ return QList<QBluetoothAddress>();
+}
+
QList<QBluetoothHostInfo> QBluetoothLocalDevice::allDevices()
{
QList<QBluetoothHostInfo> localDevices;
diff --git a/src/bluetooth/qbluetoothlocaldevice_p.h b/src/bluetooth/qbluetoothlocaldevice_p.h
index 0f2aaca8..76a7e460 100644
--- a/src/bluetooth/qbluetoothlocaldevice_p.h
+++ b/src/bluetooth/qbluetoothlocaldevice_p.h
@@ -51,9 +51,11 @@
#include <QDBusContext>
#include <QDBusObjectPath>
#include <QDBusMessage>
+#include <QSet>
class OrgBluezAdapterInterface;
class OrgBluezAgentAdaptor;
+class OrgBluezDeviceInterface;
QT_BEGIN_NAMESPACE
class QDBusPendingCallWatcher;
@@ -78,8 +80,13 @@ public:
QBluetoothLocalDevicePrivate(QBluetoothLocalDevice *q, QBluetoothAddress localAddress = QBluetoothAddress());
~QBluetoothLocalDevicePrivate();
+ QSet<OrgBluezDeviceInterface *> devices;
+ QSet<QBluetoothAddress> connectedDevicesSet;
OrgBluezAdapterInterface *adapter;
OrgBluezAgentAdaptor *agent;
+
+ QList<QBluetoothAddress> connectedDevices() const;
+
QString agent_path;
QBluetoothAddress localAddress;
QBluetoothAddress address;
@@ -101,14 +108,22 @@ public Q_SLOTS: // METHODS
void pairingCompleted(QDBusPendingCallWatcher*);
void PropertyChanged(QString,QDBusVariant);
+ void _q_deviceCreated(const QDBusObjectPath &device);
+ void _q_deviceRemoved(const QDBusObjectPath &device);
+ void _q_devicePropertyChanged(const QString &property, const QDBusVariant &value);
bool isValid() const;
private:
+ void createCache();
+ void connectDeviceChanges();
+
QDBusMessage msgConfirmation;
QDBusConnection *msgConnection;
QBluetoothLocalDevice *q_ptr;
+ bool connectedCached;
+
void initializeAdapter();
};
@@ -134,6 +149,8 @@ public:
void requestPairing(const QBluetoothAddress &address, QBluetoothLocalDevice::Pairing pairing);
void setAccess(int);
+ // This method will be used for emitting signals.
+ void connectedDevices();
Q_INVOKABLE void controlReply(ppsResult res);
Q_INVOKABLE void controlEvent(ppsResult res);
@@ -143,6 +160,7 @@ public:
private:
QBluetoothLocalDevice *q_ptr;
bool isValidDevice;
+ QList<QBluetoothAddress> connectedDevicesSet;
};
#else
class QBluetoothLocalDevicePrivate : public QObject
diff --git a/src/bluetooth/qbluetoothlocaldevice_qnx.cpp b/src/bluetooth/qbluetoothlocaldevice_qnx.cpp
index bba92199..d0236b6a 100644
--- a/src/bluetooth/qbluetoothlocaldevice_qnx.cpp
+++ b/src/bluetooth/qbluetoothlocaldevice_qnx.cpp
@@ -42,7 +42,10 @@
#include "qbluetoothlocaldevice.h"
#include "qbluetoothaddress.h"
#include "qbluetoothlocaldevice_p.h"
+#include <sys/pps.h>
#include "qnx/ppshelpers_p.h"
+#include <QDir>
+#include <QtCore/private/qcore_unix_p.h>
QT_BEGIN_NAMESPACE
@@ -93,6 +96,46 @@ QBluetoothLocalDevice::HostMode QBluetoothLocalDevice::hostMode() const
return this->d_ptr->hostMode();
}
+QList<QBluetoothAddress> QBluetoothLocalDevice::connectedDevices() const
+{
+ QList<QBluetoothAddress> devices;
+ QDir bluetoothDevices(QStringLiteral("/pps/services/bluetooth/remote_devices/"));
+ QStringList allFiles = bluetoothDevices.entryList(QDir::NoDotAndDotDot| QDir::Files);
+ for (int i = 0; i < allFiles.size(); i++) {
+ qCDebug(QT_BT_QNX) << allFiles.at(i);
+ int fileId;
+ const char *filePath = QByteArray("/pps/services/bluetooth/remote_devices/").append(allFiles.at(i).toUtf8().constData()).constData();
+ if ((fileId = qt_safe_open(filePath, O_RDONLY)) == -1)
+ qCWarning(QT_BT_QNX) << "Failed to open remote device file";
+ else {
+ pps_decoder_t ppsDecoder;
+ pps_decoder_initialize(&ppsDecoder, 0);
+
+ QBluetoothAddress deviceAddr;
+ QString deviceName;
+
+ if (!ppsReadRemoteDevice(fileId, &ppsDecoder, &deviceAddr, &deviceName)) {
+ pps_decoder_cleanup(&ppsDecoder);
+ qDebug() << "Failed to open remote device file";
+ }
+
+ bool connectedDevice = false;
+ int a = pps_decoder_get_bool(&ppsDecoder, "acl_connected", &connectedDevice);
+ if (a == PPS_DECODER_OK) {
+ if (connectedDevice)
+ devices.append(deviceAddr);
+ }
+ else if ( a == PPS_DECODER_BAD_TYPE)
+ qCDebug(QT_BT_QNX) << "Type missmatch";
+ else
+ qCDebug(QT_BT_QNX) << "An unknown error occurred while checking connected status.";
+ pps_decoder_cleanup(&ppsDecoder);
+ }
+ }
+
+ return devices;
+}
+
QList<QBluetoothHostInfo> QBluetoothLocalDevice::allDevices()
{
//We only have one device
@@ -256,6 +299,25 @@ void QBluetoothLocalDevicePrivate::setAccess(int access)
}
}
+void QBluetoothLocalDevicePrivate::connectedDevices()
+{
+ QList<QBluetoothAddress> devices = q_ptr->connectedDevices();
+ for (int i = 0; i < devices.size(); i ++) {
+ if (!connectedDevicesSet.contains(devices.at(i))) {
+ QBluetoothAddress addr = devices.at(i);
+ connectedDevicesSet.append(addr);
+ emit q_ptr->deviceConnected(devices.at(i));
+ }
+ }
+ for (int i = 0; i < connectedDevicesSet.size(); i ++) {
+ if (!devices.contains(connectedDevicesSet.at(i))) {
+ QBluetoothAddress addr = connectedDevicesSet.at(i);
+ emit q_ptr->deviceDisconnected(addr);
+ connectedDevicesSet.removeOne(addr);
+ }
+ }
+}
+
void QBluetoothLocalDevicePrivate::controlReply(ppsResult result)
{
qCDebug(QT_BT_QNX) << Q_FUNC_INFO << result.msg << result.dat;
@@ -276,6 +338,7 @@ void QBluetoothLocalDevicePrivate::controlEvent(ppsResult result)
result.dat.first() == QStringLiteral("level")) {
QBluetoothLocalDevice::HostMode newHostMode = hostMode();
qCDebug(QT_BT_QNX) << "New Host mode" << newHostMode;
+ connectedDevices();
Q_EMIT q_ptr->hostModeStateChanged(newHostMode);
}
} else if (result.msg == QStringLiteral("pairing_complete")) {
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent.cpp b/src/bluetooth/qbluetoothservicediscoveryagent.cpp
index beaa3503..4df6a4ea 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent.cpp
@@ -39,6 +39,8 @@
**
****************************************************************************/
+#include "qbluetoothhostinfo.h"
+#include "qbluetoothlocaldevice.h"
#include "qbluetoothservicediscoveryagent.h"
#include "qbluetoothservicediscoveryagent_p.h"
@@ -67,6 +69,10 @@ QT_BEGIN_NAMESPACE
use cases this is adequate as QBluetoothSocket::connectToService() will perform additional
discovery if required. If full service information is required, pass \l FullDiscovery as the
discoveryMode parameter to start().
+
+ This class may internally utilize \l QBluetoothDeviceDiscoveryAgent to find unknown devices.
+
+ \sa QBluetoothDeviceDiscoveryAgent
*/
/*!
@@ -77,6 +83,8 @@ QT_BEGIN_NAMESPACE
\value NoError No error has occurred.
\value PoweredOffError The Bluetooth adaptor is powered off, power it on before doing discovery.
\value InputOutputError Writing or reading from the device resulted in an error.
+ \value InvalidBluetoothAdapterError The passed local adapter address does not match the physical
+ adapter address of any local Bluetooth device.
\value UnknownError An unknown error has occurred.
*/
@@ -99,20 +107,24 @@ QT_BEGIN_NAMESPACE
/*!
\fn QBluetoothServiceDiscoveryAgent::finished()
- This signal is emitted when the Bluetooth service discovery completes. This signal will even
- be emitted when an error occurred during the service discovery.
+ This signal is emitted when the Bluetooth service discovery completes.
+
+ Unlike the \l QBluetoothDeviceDiscoveryAgent::finished() signal this
+ signal will even be emitted when an error occurred during the service discovery. Therefore
+ it is recommended to check the \l error() signal to evaluate the success of the
+ service discovery discovery.
*/
/*!
\fn void QBluetoothServiceDiscoveryAgent::error(QBluetoothServiceDiscoveryAgent::Error error)
- This signal is emitted when an error occurs. The \a error parameter describes the error that
+ This signal is emitted when an \a error occurs. The \a error parameter describes the error that
occurred.
*/
/*!
- Constructs a new QBluetoothServiceDiscoveryAgent with \a parent. Services will be discovered on all
- contactable devices.
+ Constructs a new QBluetoothServiceDiscoveryAgent with \a parent. The search is performed via the
+ local default Bluetooth adapter.
*/
QBluetoothServiceDiscoveryAgent::QBluetoothServiceDiscoveryAgent(QObject *parent)
: QObject(parent), d_ptr(new QBluetoothServiceDiscoveryAgentPrivate(QBluetoothAddress()))
@@ -123,12 +135,28 @@ QBluetoothServiceDiscoveryAgent::QBluetoothServiceDiscoveryAgent(QObject *parent
/*!
Constructs a new QBluetoothServiceDiscoveryAgent for \a deviceAdapter and with \a parent.
- If \a deviceAdapter is default constructed, the local default adapter will be used.
+ It uses \a deviceAdapter for the service search. If \a deviceAdapter is default constructed
+ the resulting QBluetoothServiceDiscoveryAgent object will use the local default Bluetooth adapter.
+
+ If a \a deviceAdapter is specified that is not a local adapter \l error() will be set to
+ \l InvalidBluetoothAdapterError. Therefore it is recommended to test the error flag immediately after
+ using this constructor.
+
+ \sa error()
*/
QBluetoothServiceDiscoveryAgent::QBluetoothServiceDiscoveryAgent(const QBluetoothAddress &deviceAdapter, QObject *parent)
: QObject(parent), d_ptr(new QBluetoothServiceDiscoveryAgentPrivate(deviceAdapter))
{
d_ptr->q_ptr = this;
+ if (!deviceAdapter.isNull()) {
+ const QList<QBluetoothHostInfo> localDevices = QBluetoothLocalDevice::allDevices();
+ foreach (const QBluetoothHostInfo &hostInfo, localDevices) {
+ if (hostInfo.address() == deviceAdapter)
+ return;
+ }
+ d_ptr->error = InvalidBluetoothAdapterError;
+ d_ptr->errorString = tr("Invalid Bluetooth adapter address");
+ }
}
/*!
@@ -247,7 +275,8 @@ void QBluetoothServiceDiscoveryAgent::start(DiscoveryMode mode)
{
Q_D(QBluetoothServiceDiscoveryAgent);
- if (d->discoveryState() == QBluetoothServiceDiscoveryAgentPrivate::Inactive) {
+ if (d->discoveryState() == QBluetoothServiceDiscoveryAgentPrivate::Inactive
+ && d->error != InvalidBluetoothAdapterError) {
d->setDiscoveryMode(mode);
if (d->deviceAddress.isNull()) {
d->startDeviceDiscovery();
@@ -266,7 +295,7 @@ void QBluetoothServiceDiscoveryAgent::stop()
{
Q_D(QBluetoothServiceDiscoveryAgent);
- if (!isActive())
+ if (d->error == InvalidBluetoothAdapterError || !isActive())
return;
switch (d->discoveryState()) {
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent.h b/src/bluetooth/qbluetoothservicediscoveryagent.h
index f923c2d0..cad89d0d 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent.h
+++ b/src/bluetooth/qbluetoothservicediscoveryagent.h
@@ -65,6 +65,7 @@ public:
NoError = QBluetoothDeviceDiscoveryAgent::NoError,
InputOutputError = QBluetoothDeviceDiscoveryAgent::InputOutputError,
PoweredOffError = QBluetoothDeviceDiscoveryAgent::PoweredOffError,
+ InvalidBluetoothAdapterError = QBluetoothDeviceDiscoveryAgent::InvalidBluetoothAdapterError,
UnknownError = QBluetoothDeviceDiscoveryAgent::UnknownError //=100
//New Errors must be added after Unknown Error the space before UnknownError is reserved
//for future device discovery errors
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
index 2795a855..7cb53253 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
@@ -74,7 +74,7 @@ QBluetoothServiceDiscoveryAgentPrivate::~QBluetoothServiceDiscoveryAgentPrivate(
void QBluetoothServiceDiscoveryAgentPrivate::start(const QBluetoothAddress &address)
{
- Q_Q(QBluetoothServiceDiscoveryAgent);
+ Q_Q(QBluetoothServiceDiscoveryAgent);
qCDebug(QT_BT_BLUEZ) << "Full discovery on: " << address.toString();
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_p.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_p.cpp
index 47467463..513d7ea7 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_p.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_p.cpp
@@ -45,6 +45,7 @@
QT_BEGIN_NAMESPACE
QBluetoothServiceDiscoveryAgentPrivate::QBluetoothServiceDiscoveryAgentPrivate(const QBluetoothAddress &deviceAdapter)
+ : error(QBluetoothServiceDiscoveryAgent::NoError), state(Inactive)
{
Q_UNUSED(deviceAdapter);
}
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_p.h b/src/bluetooth/qbluetoothservicediscoveryagent_p.h
index 517f6a98..0691b490 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_p.h
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_p.h
@@ -64,6 +64,7 @@ QT_END_NAMESPACE
#include <fcntl.h>
#include <unistd.h>
#include <QTimer>
+#include <btapi/btdevice.h>
#endif
QT_BEGIN_NAMESPACE
@@ -125,11 +126,15 @@ private Q_SLOTS:
void controlReply(ppsResult result);
void controlEvent(ppsResult result);
void queryTimeout();
+#ifdef QT_QNX_BT_BLUETOOTH
+ static void deviceServicesDiscoveryCallback(bt_sdp_list_t *, void *, uint8_t);
+#endif
private:
int m_rdfd;
QSocketNotifier *rdNotifier;
QTimer m_queryTimer;
+ bool m_btInitialized;
#endif
public:
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp
index f88e7b70..7af2590a 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp
@@ -49,6 +49,10 @@
#include "qbluetoothuuid.h"
#include <sys/pps.h>
+#ifdef QT_QNX_BT_BLUETOOTH
+#include <errno.h>
+#include <QPointer>
+#endif
#include <QFile>
@@ -56,13 +60,85 @@
QT_BEGIN_NAMESPACE
+#ifdef QT_QNX_BT_BLUETOOTH
+void QBluetoothServiceDiscoveryAgentPrivate::deviceServicesDiscoveryCallback(bt_sdp_list_t *result, void *user_data, uint8_t error)
+{
+ if (error != 0)
+ qCWarning(QT_BT_QNX) << "Error received in callback: " << errno << strerror(errno);
+ QPointer<QBluetoothServiceDiscoveryAgentPrivate> *classPointer = static_cast<QPointer<QBluetoothServiceDiscoveryAgentPrivate> *>(user_data);
+ if (classPointer->isNull()) {
+ qCDebug(QT_BT_QNX) << "Pointer received in callback is null";
+ return;
+ }
+ QBluetoothServiceDiscoveryAgentPrivate *p = classPointer->data();
+ if ( result == 0) {
+ qCDebug(QT_BT_QNX) << "Result received in callback is null.";
+ p->errorString = QBluetoothServiceDiscoveryAgent::tr("Result received in callback is null.");
+ p->error = QBluetoothServiceDiscoveryAgent::InputOutputError;
+ p->q_ptr->error(p->error);
+ p->_q_serviceDiscoveryFinished();
+ return;
+ }
+
+ for (int i = 0; i < result->num_records; i++) {
+ bt_sdp_record_t rec = result->record[i];
+ QBluetoothServiceInfo serviceInfo;
+ serviceInfo.setDevice(p->discoveredDevices.at(0));
+ serviceInfo.setServiceName(rec.name);
+ serviceInfo.setServiceDescription(rec.description);
+ //serviceInfo.setServiceAvailability(rec.availability);
+ serviceInfo.setServiceProvider(QString(rec.provider));
+ QBluetoothServiceInfo::Sequence protocolDescriptorList;
+ for ( int j = 0; j < rec.num_protocol; j++) {
+ bt_sdp_prot_t protoc = rec.protocol[j];
+ QString protocolUuid(protoc.uuid);
+ protocolUuid = QStringLiteral("0x") + protocolUuid;
+ QBluetoothUuid pUuid(protocolUuid.toUShort(0,0));
+ protocolDescriptorList << QVariant::fromValue(pUuid);
+ for ( int k = 0; k < 2; k++)
+ protocolDescriptorList << QVariant::fromValue(QString::fromLatin1(protoc.parm[k]));
+ }
+ serviceInfo.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList, protocolDescriptorList);
+ qCDebug(QT_BT_QNX) << "Service name " << rec.name << " Description: " << rec.description << "uuid " << rec.serviceId << "provider: " << rec.provider;
+ qCDebug(QT_BT_QNX) << "num protocol " << rec.num_protocol << "record handle " << rec.record_handle << "class id" << rec.num_classId << "availability " << rec.availability << rec.num_language;
+
+ QList<QBluetoothUuid> serviceClassId;
+
+ for (int j = 0; j < rec.num_classId; j++) {
+ bt_sdp_class_t uuid = rec.classId[j];
+ qCDebug(QT_BT_QNX) << "uuid: " << uuid.uuid;
+ QString protocolUuid(uuid.uuid);
+ protocolUuid = QStringLiteral("0x") + protocolUuid;
+ QBluetoothUuid Uuid(protocolUuid.toUShort(0,0));
+ if (j == 0) {
+ serviceInfo.setServiceUuid(Uuid);
+ //Check if the UUID is in the uuidFilter
+ if (!p->uuidFilter.isEmpty() && !p->uuidFilter.contains(Uuid))
+ continue;
+ }
+ serviceClassId << Uuid;
+ }
+ serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceClassIds, QVariant::fromValue(serviceClassId));
+ serviceInfo.setAttribute(QBluetoothServiceInfo::BrowseGroupList,
+ QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
+ p->q_ptr->serviceDiscovered(serviceInfo);
+ }
+ p->_q_serviceDiscoveryFinished();
+ //delete p;
+ //delete classPointer;
+}
+#endif
+
QBluetoothServiceDiscoveryAgentPrivate::QBluetoothServiceDiscoveryAgentPrivate(const QBluetoothAddress &deviceAdapter)
- : m_rdfd(-1), rdNotifier(0), error(QBluetoothServiceDiscoveryAgent::NoError), deviceAddress(deviceAdapter), state(Inactive),
+ : m_rdfd(-1), rdNotifier(0), m_btInitialized(false), error(QBluetoothServiceDiscoveryAgent::NoError), deviceAddress(deviceAdapter), state(Inactive),
deviceDiscoveryAgent(0), mode(QBluetoothServiceDiscoveryAgent::MinimalDiscovery)
{
ppsRegisterControl();
connect(&m_queryTimer, SIGNAL(timeout()), this, SLOT(queryTimeout()));
ppsRegisterForEvent(QStringLiteral("service_updated"), this);
+ //Needed for connecting signals and slots from static function
+ qRegisterMetaType<QBluetoothServiceInfo>("QBluetoothServiceInfo");
+ qRegisterMetaType<QBluetoothServiceDiscoveryAgent::Error>("QBluetoothServiceDiscoveryAgent::Error");
}
QBluetoothServiceDiscoveryAgentPrivate::~QBluetoothServiceDiscoveryAgentPrivate()
@@ -74,6 +150,50 @@ QBluetoothServiceDiscoveryAgentPrivate::~QBluetoothServiceDiscoveryAgentPrivate(
void QBluetoothServiceDiscoveryAgentPrivate::start(const QBluetoothAddress &address)
{
Q_Q(QBluetoothServiceDiscoveryAgent);
+#ifdef QT_QNX_BT_BLUETOOTH
+ errno = 0;
+ if (!m_btInitialized) {
+ if (bt_device_init( 0 ) < 0) {
+ qCWarning(QT_BT_QNX) << "Failed to initialize bluetooth stack.";
+ error = QBluetoothServiceDiscoveryAgent::InputOutputError;
+ errorString = QBluetoothServiceDiscoveryAgent::tr("Failed to open to initialize bluetooth stack");
+ q->error(error);
+ _q_serviceDiscoveryFinished();
+ return;
+ }
+ }
+ m_btInitialized = true;
+ errno = 0;
+ bt_remote_device_t *remoteDevice = bt_rdev_get_device(address.toString().toLocal8Bit().constData());
+ int deviceType = bt_rdev_get_type(remoteDevice);
+ if (deviceType == -1) {
+ qCWarning(QT_BT_QNX) << "Could not retrieve remote device (address is 00:00:00:00:00:00).";
+ error = QBluetoothServiceDiscoveryAgent::InputOutputError;
+ errorString = QBluetoothServiceDiscoveryAgent::tr("Could not retrieve remote device (address is 00:00:00:00:00:00).");
+ q->error(error);
+ _q_serviceDiscoveryFinished();
+ return;
+ }
+ /*
+ * In case remote device is LE device, calling bt_rdev_sdp_search_async will cause memory fault.
+ */
+
+ if ( deviceType >1) {
+ errno = 0;
+ QPointer<QBluetoothServiceDiscoveryAgentPrivate> *classPointer = new QPointer<QBluetoothServiceDiscoveryAgentPrivate>(this);
+ int b = bt_rdev_sdp_search_async(remoteDevice, 0, &(this->deviceServicesDiscoveryCallback), classPointer);
+ if ( b != 0 ) {
+ qCWarning(QT_BT_QNX) << "Failed to run search on device: " << address.toString();
+ error = QBluetoothServiceDiscoveryAgent::InputOutputError;
+ errorString = QBluetoothServiceDiscoveryAgent::tr(strerror(errno));
+ q->error(error);
+ _q_serviceDiscoveryFinished();
+ return;
+ }
+ }
+ else
+ _q_serviceDiscoveryFinished();
+#else
qCDebug(QT_BT_QNX) << "Starting Service discovery for" << address.toString();
const QString filePath = QStringLiteral("/pps/services/bluetooth/remote_devices/").append(address.toString());
if ((m_rdfd = qt_safe_open(filePath.toLocal8Bit().constData(), O_RDONLY)) == -1) {
@@ -105,6 +225,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::start(const QBluetoothAddress &addr
}
m_queryTimer.start(10000);
ppsSendControlMessage("service_query", QStringLiteral("{\"addr\":\"%1\"}").arg(address.toString()), this);
+#endif
}
void QBluetoothServiceDiscoveryAgentPrivate::stop()
diff --git a/src/bluetooth/qbluetoothsocket.h b/src/bluetooth/qbluetoothsocket.h
index cc580d0b..5a21d551 100644
--- a/src/bluetooth/qbluetoothsocket.h
+++ b/src/bluetooth/qbluetoothsocket.h
@@ -58,7 +58,7 @@ class QBluetoothServiceInfo;
class Q_BLUETOOTH_EXPORT QBluetoothSocket : public QIODevice
{
- Q_OBJECT
+ Q_OBJECT
Q_DECLARE_PRIVATE(QBluetoothSocket)
friend class QBluetoothServer;
diff --git a/src/bluetooth/qbluetoothsocket_bluez.cpp b/src/bluetooth/qbluetoothsocket_bluez.cpp
index 24879d11..7b1046c4 100644
--- a/src/bluetooth/qbluetoothsocket_bluez.cpp
+++ b/src/bluetooth/qbluetoothsocket_bluez.cpp
@@ -118,7 +118,7 @@ bool QBluetoothSocketPrivate::ensureNativeSocket(QBluetoothServiceInfo::Protocol
Q_Q(QBluetoothSocket);
readNotifier = new QSocketNotifier(socket, QSocketNotifier::Read);
QObject::connect(readNotifier, SIGNAL(activated(int)), q, SLOT(_q_readNotify()));
- connectWriteNotifier = new QSocketNotifier(socket, QSocketNotifier::Write, q);
+ connectWriteNotifier = new QSocketNotifier(socket, QSocketNotifier::Write, q);
QObject::connect(connectWriteNotifier, SIGNAL(activated(int)), q, SLOT(_q_writeNotify()));
connectWriteNotifier->setEnabled(false);
@@ -215,7 +215,7 @@ void QBluetoothSocketPrivate::_q_writeNotify()
connectWriteNotifier->setEnabled(false);
this->close();
}
- }
+ }
}
// TODO: move to private backend?
@@ -238,7 +238,7 @@ void QBluetoothSocketPrivate::_q_readNotify()
q->setSocketError(QBluetoothSocket::UnknownSocketError);
q->disconnectFromService();
- q->setSocketState(QBluetoothSocket::UnconnectedState);
+ q->setSocketState(QBluetoothSocket::UnconnectedState);
}
else {
buffer.chop(QPRIVATELINEARBUFFER_BUFFERSIZE - (readFromDevice < 0 ? 0 : readFromDevice));
@@ -458,7 +458,7 @@ qint64 QBluetoothSocketPrivate::writeData(const char *data, qint64 maxSize)
return 0;
if(txBuffer.size() == 0) {
- connectWriteNotifier->setEnabled(true);
+ connectWriteNotifier->setEnabled(true);
QMetaObject::invokeMethod(q, "_q_writeNotify", Qt::QueuedConnection);
}
diff --git a/src/bluetooth/qbluetoothtransfermanager.h b/src/bluetooth/qbluetoothtransfermanager.h
index 520e0d73..501a40a0 100644
--- a/src/bluetooth/qbluetoothtransfermanager.h
+++ b/src/bluetooth/qbluetoothtransfermanager.h
@@ -63,7 +63,7 @@ public:
explicit QBluetoothTransferManager(QObject *parent = 0);
~QBluetoothTransferManager();
- QBluetoothTransferReply *put(const QBluetoothTransferRequest &request, QIODevice *data);
+ QBluetoothTransferReply *put(const QBluetoothTransferRequest &request, QIODevice *data);
Q_SIGNALS:
void finished(QBluetoothTransferReply *reply);
diff --git a/src/bluetooth/qbluetoothtransferreply_bluez.cpp b/src/bluetooth/qbluetoothtransferreply_bluez.cpp
index 19be6d48..891fb012 100644
--- a/src/bluetooth/qbluetoothtransferreply_bluez.cpp
+++ b/src/bluetooth/qbluetoothtransferreply_bluez.cpp
@@ -128,7 +128,7 @@ bool QBluetoothTransferReplyBluez::start()
QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection, Q_ARG(QBluetoothTransferReply*, this));
return false;
}
- m_size = file->size();
+ m_size = file->size();
startOPP(file->fileName());
}
return true;
diff --git a/src/bluetooth/qbluetoothtransferrequest.h b/src/bluetooth/qbluetoothtransferrequest.h
index 072d330f..b91429a0 100644
--- a/src/bluetooth/qbluetoothtransferrequest.h
+++ b/src/bluetooth/qbluetoothtransferrequest.h
@@ -72,7 +72,7 @@ public:
void setAttribute(Attribute code, const QVariant &value);
QBluetoothAddress address() const;
-
+
bool operator!=(const QBluetoothTransferRequest &other) const;
QBluetoothTransferRequest &operator=(const QBluetoothTransferRequest &other);
bool operator==(const QBluetoothTransferRequest &other) const;
diff --git a/src/imports/bluetooth/plugin.cpp b/src/imports/bluetooth/plugin.cpp
index 6b509c43..bcf59794 100644
--- a/src/imports/bluetooth/plugin.cpp
+++ b/src/imports/bluetooth/plugin.cpp
@@ -75,6 +75,10 @@ public:
qmlRegisterType<QDeclarativeBluetoothService >(uri, major, minor, "BluetoothService");
qmlRegisterType<QDeclarativeBluetoothSocket >(uri, major, minor, "BluetoothSocket");
+ // Register the 5.3 types
+ // introduces 5.3 version, other existing 5.2 exports automatically become availabe under 5.3 as well
+ minor = 3;
+ qmlRegisterType<QDeclarativeBluetoothDiscoveryModel >(uri, major, minor, "BluetoothDiscoveryModel");
}
};
diff --git a/src/imports/bluetooth/plugins.qmltypes b/src/imports/bluetooth/plugins.qmltypes
index 20d57574..18647c2c 100644
--- a/src/imports/bluetooth/plugins.qmltypes
+++ b/src/imports/bluetooth/plugins.qmltypes
@@ -4,7 +4,7 @@ import QtQuick.tooling 1.1
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -notrelocatable QtBluetooth 5.2'
+// 'qmlplugindump -notrelocatable QtBluetooth 5.3'
Module {
Component {
@@ -12,9 +12,10 @@ Module {
prototype: "QAbstractListModel"
exports: [
"QtBluetooth/BluetoothDiscoveryModel 5.0",
- "QtBluetooth/BluetoothDiscoveryModel 5.2"
+ "QtBluetooth/BluetoothDiscoveryModel 5.2",
+ "QtBluetooth/BluetoothDiscoveryModel 5.3"
]
- exportMetaObjectRevisions: [0, 0]
+ exportMetaObjectRevisions: [0, 0, 0]
Enum {
name: "DiscoveryMode"
values: {
diff --git a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp
index b7534329..d0d6d7ee 100644
--- a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp
+++ b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp
@@ -167,6 +167,11 @@ void QDeclarativeBluetoothDiscoveryModel::errorDeviceDiscovery(QBluetoothDeviceD
{
d->m_error = static_cast<QDeclarativeBluetoothDiscoveryModel::Error>(error);
emit errorChanged();
+
+ //QBluetoothDeviceDiscoveryAgent::finished() signal is not emitted in case of an error
+ //Note that this behavior is different from QBluetoothServiceDiscoveryAgent.
+ //This reset the models running flag.
+ setRunning(false);
}
void QDeclarativeBluetoothDiscoveryModel::clearModel()
diff --git a/src/imports/nfc/plugin.cpp b/src/imports/nfc/plugin.cpp
index 0a423495..8694e185 100644
--- a/src/imports/nfc/plugin.cpp
+++ b/src/imports/nfc/plugin.cpp
@@ -84,6 +84,11 @@ public:
qmlRegisterType<QDeclarativeNdefTextRecord>(uri, major, minor, "NdefTextRecord");
qmlRegisterType<QDeclarativeNdefUriRecord>(uri, major, minor, "NdefUriRecord");
qmlRegisterType<QDeclarativeNdefMimeRecord>(uri, major, minor, "NdefMimeRecord");
+
+ // Register the 5.3 types
+ // introduces 5.3 version, other existing 5.2 exports automatically become availabe under 5.3 as well
+ minor = 3;
+ qmlRegisterType<QDeclarativeNearField>(uri, major, minor, "NearField");
}
};
diff --git a/src/imports/nfc/plugins.qmltypes b/src/imports/nfc/plugins.qmltypes
index 346c0bfa..fff2834f 100644
--- a/src/imports/nfc/plugins.qmltypes
+++ b/src/imports/nfc/plugins.qmltypes
@@ -4,7 +4,7 @@ import QtQuick.tooling 1.1
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -notrelocatable QtNfc 5.2'
+// 'qmlplugindump -notrelocatable QtNfc 5.3'
Module {
Component {
@@ -52,8 +52,12 @@ Module {
Component {
name: "QDeclarativeNearField"
prototype: "QObject"
- exports: ["QtNfc/NearField 5.0", "QtNfc/NearField 5.2"]
- exportMetaObjectRevisions: [0, 0]
+ exports: [
+ "QtNfc/NearField 5.0",
+ "QtNfc/NearField 5.2",
+ "QtNfc/NearField 5.3"
+ ]
+ exportMetaObjectRevisions: [0, 0, 0]
Property { name: "messageRecords"; type: "QQmlNdefRecord"; isList: true; isReadonly: true }
Property { name: "filter"; type: "QDeclarativeNdefFilter"; isList: true; isReadonly: true }
Property { name: "orderMatch"; type: "bool" }
diff --git a/src/nfc/qllcpserver_p.cpp b/src/nfc/qllcpserver_p.cpp
index 55d2a866..c22c868a 100644
--- a/src/nfc/qllcpserver_p.cpp
+++ b/src/nfc/qllcpserver_p.cpp
@@ -49,7 +49,7 @@ QLlcpServerPrivate::QLlcpServerPrivate(QLlcpServer *q)
}
QLlcpServerPrivate::~QLlcpServerPrivate()
-{
+{
}
bool QLlcpServerPrivate::listen(const QString &serviceUri)
diff --git a/src/nfc/qllcpsocket.cpp b/src/nfc/qllcpsocket.cpp
index 2bf3e2c3..79cb1284 100644
--- a/src/nfc/qllcpsocket.cpp
+++ b/src/nfc/qllcpsocket.cpp
@@ -231,7 +231,7 @@ qint64 QLlcpSocket::writeDatagram(const char *data, qint64 size)
*/
bool QLlcpSocket::isSequential() const
{
- return true;
+ return true;
}
/*!
diff --git a/src/nfc/qllcpsocket_p.cpp b/src/nfc/qllcpsocket_p.cpp
index 4d076b9c..b1af336f 100644
--- a/src/nfc/qllcpsocket_p.cpp
+++ b/src/nfc/qllcpsocket_p.cpp
@@ -50,7 +50,7 @@ QLlcpSocketPrivate::QLlcpSocketPrivate(QLlcpSocket *q)
QLlcpSocketPrivate::~QLlcpSocketPrivate()
{
-
+
}
void QLlcpSocketPrivate::connectToService(QNearFieldTarget *target, const QString &serviceUri)