summaryrefslogtreecommitdiffstats
path: root/src/imports
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-05-08 09:51:40 +0200
committerAlex Blasche <alexander.blasche@digia.com>2014-05-08 09:51:40 +0200
commit94445dd4b9a6754a63736a05b9bccaaffc0a4038 (patch)
treefedeb79f2a583da4935fcd8fc5f70298812c056d /src/imports
parent74449f1b0b2952dcbad9525c167b36fbf908696f (diff)
parentef7de5da3d4d2346ec7110413c8fb12db8c94013 (diff)
Merge branch 'stable' into dev
Conflicts: .qmake.conf src/bluetooth/qbluetoothlocaldevice_bluez.cpp src/bluetooth/qbluetoothserver_p.h src/bluetooth/qbluetoothsocket_qnx.cpp Change-Id: I08792f10155f9b4e6af30066b70e24b48985ddd6
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp1
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothservice.cpp63
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothservice_p.h1
-rw-r--r--src/imports/bluetooth/qmldir1
-rw-r--r--src/imports/nfc/qmldir1
5 files changed, 26 insertions, 41 deletions
diff --git a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp
index bb1d327c..d4974967 100644
--- a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp
+++ b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp
@@ -403,6 +403,7 @@ void QDeclarativeBluetoothDiscoveryModel::setRunning(bool running)
}
d->m_serviceAgent->setRemoteAddress(QBluetoothAddress(d->m_remoteAddress));
+ d->m_serviceAgent->clear();
if (!d->m_uuid.isEmpty())
d->m_serviceAgent->setUuidFilter(QBluetoothUuid(d->m_uuid));
diff --git a/src/imports/bluetooth/qdeclarativebluetoothservice.cpp b/src/imports/bluetooth/qdeclarativebluetoothservice.cpp
index adff13db..e246ca8d 100644
--- a/src/imports/bluetooth/qdeclarativebluetoothservice.cpp
+++ b/src/imports/bluetooth/qdeclarativebluetoothservice.cpp
@@ -102,8 +102,6 @@ public:
delete m_service;
}
- int listen();
-
bool m_componentComplete;
QBluetoothServiceInfo *m_service;
QDeclarativeBluetoothService::Protocol m_protocol;
@@ -271,28 +269,6 @@ bool QDeclarativeBluetoothService::isRegistered() const
return d->m_service->isRegistered();
}
-
-int QDeclarativeBluetoothServicePrivate::listen() {
-
- if (m_service->socketProtocol() == QBluetoothServiceInfo::UnknownProtocol) {
- qCWarning(QT_BT_QML) << "Unknown protocol, can't make service" << m_protocol;
- return -1;
- }
- QBluetoothServiceInfo::Protocol serverType = QBluetoothServiceInfo::UnknownProtocol;
- if (m_service->socketProtocol() == QBluetoothServiceInfo::L2capProtocol)
- serverType = QBluetoothServiceInfo::L2capProtocol;
- else if (m_service->socketProtocol() == QBluetoothServiceInfo::RfcommProtocol)
- serverType = QBluetoothServiceInfo::RfcommProtocol;
-
- QBluetoothServer *server = new QBluetoothServer(serverType);
- server->setMaxPendingConnections(1);
- server->listen(QBluetoothAddress());
- server->serverPort();
- m_server = server;
-
- return server->serverPort();
-}
-
void QDeclarativeBluetoothService::setRegistered(bool registered)
{
if (!d->m_componentComplete) {
@@ -308,9 +284,21 @@ void QDeclarativeBluetoothService::setRegistered(bool registered)
return;
}
- d->listen();
- connect(d->m_server, SIGNAL(newConnection()), this, SLOT(new_connection()));
+ if (d->m_protocol == UnknownProtocol) {
+ qCWarning(QT_BT_QML) << "Unknown protocol, can't make service" << d->m_protocol;
+ return;
+ }
+
+ QBluetoothServer *server
+ = new QBluetoothServer(static_cast<QBluetoothServiceInfo::Protocol>(d->m_protocol));
+ server->setMaxPendingConnections(1);
+ if (!server->listen()) {
+ qCWarning(QT_BT_QML) << "Could not start server. Error:" << server->error();
+ return;
+ }
+ d->m_server = server;
+ connect(d->m_server, SIGNAL(newConnection()), this, SLOT(new_connection()));
d->m_service->setAttribute(QBluetoothServiceInfo::ServiceRecordHandle, (uint)0x00010010);
@@ -321,7 +309,7 @@ void QDeclarativeBluetoothService::setRegistered(bool registered)
//qDebug() << "name/uuid" << d->m_name << d->m_uuid << d->m_port;
d->m_service->setAttribute(QBluetoothServiceInfo::BrowseGroupList,
- QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
+ QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
QBluetoothServiceInfo::Sequence protocolDescriptorList;
QBluetoothServiceInfo::Sequence protocol;
@@ -329,26 +317,19 @@ void QDeclarativeBluetoothService::setRegistered(bool registered)
if (d->m_protocol == L2CapProtocol) {
protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::L2cap))
<< QVariant::fromValue(quint16(d->m_server->serverPort()));
- protocolDescriptorList.append(QVariant::fromValue(protocol));
- }
- else if (d->m_protocol == RfcommProtocol) {
+ } else if (d->m_protocol == RfcommProtocol) {
protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm))
<< QVariant::fromValue(quint8(d->m_server->serverPort()));
- protocolDescriptorList.append(QVariant::fromValue(protocol));
- }
- else {
- qCWarning(QT_BT_QML) << "No protocol specified for bluetooth service";
}
+ protocolDescriptorList.append(QVariant::fromValue(protocol));
+
d->m_service->setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList,
- protocolDescriptorList);
+ protocolDescriptorList);
- if (d->m_service->registerService()) {
+ if (d->m_service->registerService())
emit registeredChanged();
- }
- else {
- qCWarning(QT_BT_QML) << "Register service failed";
- //TODO propaget this error to the user
- }
+ else
+ qCWarning(QT_BT_QML) << "Register service failed"; // TODO: propagate this error to the user
}
QBluetoothServiceInfo *QDeclarativeBluetoothService::serviceInfo() const
diff --git a/src/imports/bluetooth/qdeclarativebluetoothservice_p.h b/src/imports/bluetooth/qdeclarativebluetoothservice_p.h
index e7e861c7..644e8905 100644
--- a/src/imports/bluetooth/qdeclarativebluetoothservice_p.h
+++ b/src/imports/bluetooth/qdeclarativebluetoothservice_p.h
@@ -68,6 +68,7 @@ class QDeclarativeBluetoothService : public QObject, public QQmlParserStatus
Q_ENUMS(Protocol)
public:
+ /// TODO: Merge/Replace with QBluetoothServiceInfo::Protocol in Qt 6
enum Protocol {
RfcommProtocol = QBluetoothServiceInfo::RfcommProtocol,
L2CapProtocol = QBluetoothServiceInfo::L2capProtocol,
diff --git a/src/imports/bluetooth/qmldir b/src/imports/bluetooth/qmldir
index 159d2422..2f5b2fac 100644
--- a/src/imports/bluetooth/qmldir
+++ b/src/imports/bluetooth/qmldir
@@ -1,3 +1,4 @@
module QtBluetooth
plugin declarative_bluetooth
+classname QBluetoothQmlPlugin
typeinfo plugins.qmltypes
diff --git a/src/imports/nfc/qmldir b/src/imports/nfc/qmldir
index 3afa926d..0025f3e6 100644
--- a/src/imports/nfc/qmldir
+++ b/src/imports/nfc/qmldir
@@ -1,3 +1,4 @@
module QtNfc
plugin declarative_nfc
+classname QNfcQmlPlugin
typeinfo plugins.qmltypes