summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.qmake.conf2
-rw-r--r--LGPL_EXCEPTION.txt2
-rw-r--r--LICENSE.GPLv24
-rw-r--r--LICENSE.LGPLv214
-rw-r--r--LICENSE.LGPLv34
-rw-r--r--config.tests/bluez/main.cpp14
-rw-r--r--config.tests/bluez_le/main.cpp14
-rw-r--r--config.tests/btapi10_2_1/main.cpp14
-rw-r--r--config.tests/libbb2/main.cpp12
-rw-r--r--examples/bluetooth/btchat/chat.cpp8
-rw-r--r--examples/bluetooth/btchat/chat.h8
-rw-r--r--examples/bluetooth/btchat/chatclient.cpp8
-rw-r--r--examples/bluetooth/btchat/chatclient.h8
-rw-r--r--examples/bluetooth/btchat/chatserver.cpp8
-rw-r--r--examples/bluetooth/btchat/chatserver.h8
-rw-r--r--examples/bluetooth/btchat/doc/src/btchat.qdoc12
-rw-r--r--examples/bluetooth/btchat/main.cpp8
-rw-r--r--examples/bluetooth/btchat/remoteselector.cpp8
-rw-r--r--examples/bluetooth/btchat/remoteselector.h8
-rw-r--r--examples/bluetooth/btfiletransfer/doc/src/btfiletransfer.qdoc12
-rw-r--r--examples/bluetooth/btfiletransfer/main.cpp8
-rw-r--r--examples/bluetooth/btfiletransfer/pindisplay.cpp8
-rw-r--r--examples/bluetooth/btfiletransfer/pindisplay.h8
-rw-r--r--examples/bluetooth/btfiletransfer/progress.cpp8
-rw-r--r--examples/bluetooth/btfiletransfer/progress.h8
-rw-r--r--examples/bluetooth/btfiletransfer/remoteselector.cpp8
-rw-r--r--examples/bluetooth/btfiletransfer/remoteselector.h8
-rw-r--r--examples/bluetooth/btscanner/device.cpp8
-rw-r--r--examples/bluetooth/btscanner/device.h8
-rw-r--r--examples/bluetooth/btscanner/doc/src/btscanner.qdoc12
-rw-r--r--examples/bluetooth/btscanner/main.cpp8
-rw-r--r--examples/bluetooth/btscanner/service.cpp8
-rw-r--r--examples/bluetooth/btscanner/service.h8
-rw-r--r--examples/bluetooth/chat/Button.qml8
-rw-r--r--examples/bluetooth/chat/InputBox.qml8
-rw-r--r--examples/bluetooth/chat/Search.qml8
-rw-r--r--examples/bluetooth/chat/chat.qml8
-rw-r--r--examples/bluetooth/chat/doc/src/chat.qdoc12
-rw-r--r--examples/bluetooth/chat/qmlchat.cpp8
-rw-r--r--examples/bluetooth/heartlistener/assets/Button.qml6
-rw-r--r--examples/bluetooth/heartlistener/assets/Point.qml6
-rw-r--r--examples/bluetooth/heartlistener/assets/dialog.qml6
-rw-r--r--examples/bluetooth/heartlistener/assets/draw.js6
-rw-r--r--examples/bluetooth/heartlistener/assets/home.qml6
-rw-r--r--examples/bluetooth/heartlistener/assets/main.qml6
-rw-r--r--examples/bluetooth/heartlistener/assets/monitor.qml6
-rw-r--r--examples/bluetooth/heartlistener/assets/results.qml8
-rw-r--r--examples/bluetooth/heartlistener/deviceinfo.cpp20
-rw-r--r--examples/bluetooth/heartlistener/deviceinfo.h10
-rw-r--r--examples/bluetooth/heartlistener/doc/src/heartlistener.qdoc12
-rw-r--r--examples/bluetooth/heartlistener/heartrate.cpp11
-rw-r--r--examples/bluetooth/heartlistener/heartrate.h8
-rw-r--r--examples/bluetooth/heartlistener/main.cpp8
-rw-r--r--examples/bluetooth/lowenergyscanner/assets/Characteristics.qml8
-rw-r--r--examples/bluetooth/lowenergyscanner/assets/Dialog.qml8
-rw-r--r--examples/bluetooth/lowenergyscanner/assets/Header.qml8
-rw-r--r--examples/bluetooth/lowenergyscanner/assets/Label.qml8
-rw-r--r--examples/bluetooth/lowenergyscanner/assets/Menu.qml8
-rw-r--r--examples/bluetooth/lowenergyscanner/assets/Services.qml12
-rw-r--r--examples/bluetooth/lowenergyscanner/assets/main.qml8
-rw-r--r--examples/bluetooth/lowenergyscanner/characteristicinfo.cpp8
-rw-r--r--examples/bluetooth/lowenergyscanner/characteristicinfo.h8
-rw-r--r--examples/bluetooth/lowenergyscanner/device.cpp28
-rw-r--r--examples/bluetooth/lowenergyscanner/device.h9
-rw-r--r--examples/bluetooth/lowenergyscanner/deviceinfo.cpp16
-rw-r--r--examples/bluetooth/lowenergyscanner/deviceinfo.h8
-rw-r--r--examples/bluetooth/lowenergyscanner/doc/src/lowenergyscanner.qdoc12
-rw-r--r--examples/bluetooth/lowenergyscanner/main.cpp8
-rw-r--r--examples/bluetooth/lowenergyscanner/serviceinfo.cpp8
-rw-r--r--examples/bluetooth/lowenergyscanner/serviceinfo.h8
-rw-r--r--examples/bluetooth/picturetransfer/Button.qml6
-rw-r--r--examples/bluetooth/picturetransfer/DeviceDiscovery.qml8
-rw-r--r--examples/bluetooth/picturetransfer/FileSending.qml6
-rw-r--r--examples/bluetooth/picturetransfer/PictureSelector.qml8
-rw-r--r--examples/bluetooth/picturetransfer/bttransfer.qml8
-rw-r--r--examples/bluetooth/picturetransfer/doc/src/picturetransfer.qdoc12
-rw-r--r--examples/bluetooth/picturetransfer/filetransfer.cpp6
-rw-r--r--examples/bluetooth/picturetransfer/filetransfer.h6
-rw-r--r--examples/bluetooth/picturetransfer/main.cpp6
-rw-r--r--examples/bluetooth/pingpong/assets/Board.qml6
-rw-r--r--examples/bluetooth/pingpong/assets/Dialog.qml6
-rw-r--r--examples/bluetooth/pingpong/assets/Menu.qml6
-rw-r--r--examples/bluetooth/pingpong/assets/main.qml6
-rw-r--r--examples/bluetooth/pingpong/doc/src/pingpong.qdoc12
-rw-r--r--examples/bluetooth/pingpong/main.cpp6
-rw-r--r--examples/bluetooth/pingpong/pingpong.cpp6
-rw-r--r--examples/bluetooth/pingpong/pingpong.h6
-rw-r--r--examples/bluetooth/scanner/Button.qml6
-rw-r--r--examples/bluetooth/scanner/doc/src/scanner.qdoc12
-rw-r--r--examples/bluetooth/scanner/qmlscanner.cpp8
-rw-r--r--examples/bluetooth/scanner/scanner.qml8
-rw-r--r--examples/nfc/annotatedurl/annotatedurl.cpp56
-rw-r--r--examples/nfc/annotatedurl/annotatedurl.h21
-rw-r--r--examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc12
-rw-r--r--examples/nfc/annotatedurl/main.cpp18
-rw-r--r--examples/nfc/annotatedurl/mainwindow.cpp8
-rw-r--r--examples/nfc/annotatedurl/mainwindow.h8
-rw-r--r--examples/nfc/corkboard/Mode.qml157
-rw-r--r--examples/nfc/corkboard/corkboards.qml49
-rw-r--r--examples/nfc/corkboard/doc/src/corkboard.qdoc12
-rw-r--r--examples/nfc/corkboard/main.cpp8
-rw-r--r--examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc12
-rw-r--r--examples/nfc/ndefeditor/main.cpp8
-rw-r--r--examples/nfc/ndefeditor/mainwindow.cpp12
-rw-r--r--examples/nfc/ndefeditor/mainwindow.h8
-rw-r--r--examples/nfc/ndefeditor/mimeimagerecordeditor.cpp9
-rw-r--r--examples/nfc/ndefeditor/mimeimagerecordeditor.h8
-rw-r--r--examples/nfc/ndefeditor/textrecordeditor.cpp8
-rw-r--r--examples/nfc/ndefeditor/textrecordeditor.h8
-rw-r--r--examples/nfc/ndefeditor/urirecordeditor.cpp8
-rw-r--r--examples/nfc/ndefeditor/urirecordeditor.h8
-rw-r--r--examples/nfc/poster/doc/src/poster.qdoc12
-rw-r--r--examples/nfc/poster/poster.qml74
-rw-r--r--examples/nfc/poster/qmlposter.cpp8
-rw-r--r--src/android/bluetooth/bluetooth.pri5
-rw-r--r--src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothBroadcastReceiver.java26
-rw-r--r--src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothInputStreamThread.java19
-rw-r--r--src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java1126
-rw-r--r--src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothSocketServer.java25
-rw-r--r--src/bluetooth/android/android.pri6
-rw-r--r--src/bluetooth/android/androidbroadcastreceiver.cpp14
-rw-r--r--src/bluetooth/android/androidbroadcastreceiver_p.h16
-rw-r--r--src/bluetooth/android/devicediscoverybroadcastreceiver.cpp165
-rw-r--r--src/bluetooth/android/devicediscoverybroadcastreceiver_p.h21
-rw-r--r--src/bluetooth/android/inputstreamthread.cpp14
-rw-r--r--src/bluetooth/android/inputstreamthread_p.h14
-rw-r--r--src/bluetooth/android/jni_android.cpp52
-rw-r--r--src/bluetooth/android/jni_android_p.h14
-rw-r--r--src/bluetooth/android/localdevicebroadcastreceiver.cpp14
-rw-r--r--src/bluetooth/android/localdevicebroadcastreceiver_p.h15
-rw-r--r--src/bluetooth/android/lowenergynotificationhub.cpp299
-rw-r--r--src/bluetooth/android/lowenergynotificationhub_p.h117
-rw-r--r--src/bluetooth/android/serveracceptancethread.cpp18
-rw-r--r--src/bluetooth/android/serveracceptancethread_p.h14
-rw-r--r--src/bluetooth/android/servicediscoverybroadcastreceiver.cpp14
-rw-r--r--src/bluetooth/android/servicediscoverybroadcastreceiver_p.h15
-rw-r--r--src/bluetooth/bluetooth.pro61
-rw-r--r--src/bluetooth/bluez/adapter.cpp2
-rw-r--r--src/bluetooth/bluez/adapter1_bluez5.cpp2
-rw-r--r--src/bluetooth/bluez/adapter1_bluez5_p.h2
-rw-r--r--src/bluetooth/bluez/adapter_p.h2
-rw-r--r--src/bluetooth/bluez/agent.cpp2
-rw-r--r--src/bluetooth/bluez/agent_p.h2
-rw-r--r--src/bluetooth/bluez/bluez5_helper.cpp34
-rw-r--r--src/bluetooth/bluez/bluez5_helper_p.h14
-rw-r--r--src/bluetooth/bluez/bluez_data_p.h14
-rw-r--r--src/bluetooth/bluez/device.cpp2
-rw-r--r--src/bluetooth/bluez/device1_bluez5.cpp2
-rw-r--r--src/bluetooth/bluez/device1_bluez5_p.h2
-rw-r--r--src/bluetooth/bluez/device_p.h2
-rw-r--r--src/bluetooth/bluez/hcimanager.cpp14
-rw-r--r--src/bluetooth/bluez/hcimanager_p.h14
-rw-r--r--src/bluetooth/bluez/manager.cpp2
-rw-r--r--src/bluetooth/bluez/manager_p.h2
-rw-r--r--src/bluetooth/bluez/obex_agent.cpp2
-rw-r--r--src/bluetooth/bluez/obex_agent_p.h2
-rw-r--r--src/bluetooth/bluez/obex_client.cpp2
-rw-r--r--src/bluetooth/bluez/obex_client1_bluez5.cpp2
-rw-r--r--src/bluetooth/bluez/obex_client1_bluez5_p.h2
-rw-r--r--src/bluetooth/bluez/obex_client_p.h2
-rw-r--r--src/bluetooth/bluez/obex_manager.cpp2
-rw-r--r--src/bluetooth/bluez/obex_manager_p.h2
-rw-r--r--src/bluetooth/bluez/obex_objectpush1_bluez5.cpp2
-rw-r--r--src/bluetooth/bluez/obex_objectpush1_bluez5_p.h2
-rw-r--r--src/bluetooth/bluez/obex_transfer.cpp2
-rw-r--r--src/bluetooth/bluez/obex_transfer1_bluez5.cpp2
-rw-r--r--src/bluetooth/bluez/obex_transfer1_bluez5_p.h2
-rw-r--r--src/bluetooth/bluez/obex_transfer_p.h2
-rw-r--r--src/bluetooth/bluez/objectmanager.cpp2
-rw-r--r--src/bluetooth/bluez/objectmanager_p.h2
-rw-r--r--src/bluetooth/bluez/profile1.cpp2
-rw-r--r--src/bluetooth/bluez/profile1_p.h2
-rw-r--r--src/bluetooth/bluez/properties.cpp2
-rw-r--r--src/bluetooth/bluez/properties_p.h2
-rw-r--r--src/bluetooth/bluez/service.cpp2
-rw-r--r--src/bluetooth/bluez/service_p.h2
-rw-r--r--src/bluetooth/bluez/servicemap.cpp14
-rw-r--r--src/bluetooth/bluez/servicemap_p.h14
-rw-r--r--src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp12
-rw-r--r--src/bluetooth/doc/snippets/doc_src_qtbluetooth.qml8
-rw-r--r--src/bluetooth/doc/src/bluetooth-cpp.qdoc12
-rw-r--r--src/bluetooth/doc/src/bluetooth-index.qdoc26
-rw-r--r--src/bluetooth/doc/src/bluetooth-le-overview.qdoc30
-rw-r--r--src/bluetooth/doc/src/bluetooth-overview.qdoc12
-rw-r--r--src/bluetooth/doc/src/bluetooth-qml.qdoc12
-rw-r--r--src/bluetooth/doc/src/examples.qdoc12
-rw-r--r--src/bluetooth/osx/corebluetoothwrapper_p.h70
-rw-r--r--src/bluetooth/osx/osxbt.pri42
-rw-r--r--src/bluetooth/osx/osxbtcentralmanager.mm1591
-rw-r--r--src/bluetooth/osx/osxbtcentralmanager_p.h217
-rw-r--r--src/bluetooth/osx/osxbtchanneldelegate.mm46
-rw-r--r--src/bluetooth/osx/osxbtchanneldelegate_p.h62
-rw-r--r--src/bluetooth/osx/osxbtconnectionmonitor.mm133
-rw-r--r--src/bluetooth/osx/osxbtconnectionmonitor_p.h78
-rw-r--r--src/bluetooth/osx/osxbtdeviceinquiry.mm176
-rw-r--r--src/bluetooth/osx/osxbtdeviceinquiry_p.h91
-rw-r--r--src/bluetooth/osx/osxbtdevicepair.mm222
-rw-r--r--src/bluetooth/osx/osxbtdevicepair_p.h120
-rw-r--r--src/bluetooth/osx/osxbtl2capchannel.mm248
-rw-r--r--src/bluetooth/osx/osxbtl2capchannel_p.h109
-rw-r--r--src/bluetooth/osx/osxbtledeviceinquiry.mm336
-rw-r--r--src/bluetooth/osx/osxbtledeviceinquiry_p.h111
-rw-r--r--src/bluetooth/osx/osxbtobexsession.mm822
-rw-r--r--src/bluetooth/osx/osxbtobexsession_p.h138
-rw-r--r--src/bluetooth/osx/osxbtrfcommchannel.mm251
-rw-r--r--src/bluetooth/osx/osxbtrfcommchannel_p.h100
-rw-r--r--src/bluetooth/osx/osxbtsdpinquiry.mm258
-rw-r--r--src/bluetooth/osx/osxbtsdpinquiry_p.h95
-rw-r--r--src/bluetooth/osx/osxbtservicerecord.mm452
-rw-r--r--src/bluetooth/osx/osxbtservicerecord_p.h55
-rw-r--r--src/bluetooth/osx/osxbtsocketlistener.mm134
-rw-r--r--src/bluetooth/osx/osxbtsocketlistener_p.h92
-rw-r--r--src/bluetooth/osx/osxbtutility.mm310
-rw-r--r--src/bluetooth/osx/osxbtutility_p.h305
-rw-r--r--src/bluetooth/osx/uistrings.cpp82
-rw-r--r--src/bluetooth/osx/uistrings_p.h91
-rw-r--r--src/bluetooth/qbluetooth.cpp14
-rw-r--r--src/bluetooth/qbluetooth.h14
-rw-r--r--src/bluetooth/qbluetoothaddress.cpp16
-rw-r--r--src/bluetooth/qbluetoothaddress.h14
-rw-r--r--src/bluetooth/qbluetoothaddress_p.h14
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent.cpp26
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent.h15
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_android.cpp163
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp14
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_ios.mm374
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_osx.mm623
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_p.cpp27
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_p.h27
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_qnx.cpp12
-rw-r--r--src/bluetooth/qbluetoothdevicediscoverytimer_osx_p.h68
-rw-r--r--src/bluetooth/qbluetoothdeviceinfo.cpp78
-rw-r--r--src/bluetooth/qbluetoothdeviceinfo.h24
-rw-r--r--src/bluetooth/qbluetoothdeviceinfo_p.h16
-rw-r--r--src/bluetooth/qbluetoothglobal.h14
-rw-r--r--src/bluetooth/qbluetoothhostinfo.cpp14
-rw-r--r--src/bluetooth/qbluetoothhostinfo.h14
-rw-r--r--src/bluetooth/qbluetoothhostinfo_p.h14
-rw-r--r--src/bluetooth/qbluetoothlocaldevice.cpp44
-rw-r--r--src/bluetooth/qbluetoothlocaldevice.h14
-rw-r--r--src/bluetooth/qbluetoothlocaldevice_android.cpp14
-rw-r--r--src/bluetooth/qbluetoothlocaldevice_bluez.cpp14
-rw-r--r--src/bluetooth/qbluetoothlocaldevice_osx.mm481
-rw-r--r--src/bluetooth/qbluetoothlocaldevice_p.cpp14
-rw-r--r--src/bluetooth/qbluetoothlocaldevice_p.h16
-rw-r--r--src/bluetooth/qbluetoothlocaldevice_qnx.cpp12
-rw-r--r--src/bluetooth/qbluetoothserver.cpp14
-rw-r--r--src/bluetooth/qbluetoothserver.h14
-rw-r--r--src/bluetooth/qbluetoothserver_android.cpp14
-rw-r--r--src/bluetooth/qbluetoothserver_bluez.cpp14
-rw-r--r--src/bluetooth/qbluetoothserver_osx.mm493
-rw-r--r--src/bluetooth/qbluetoothserver_osx_p.h110
-rw-r--r--src/bluetooth/qbluetoothserver_p.cpp14
-rw-r--r--src/bluetooth/qbluetoothserver_p.h18
-rw-r--r--src/bluetooth/qbluetoothserver_qnx.cpp12
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent.cpp14
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent.h18
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_android.cpp16
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp18
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_osx.mm583
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_p.cpp14
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_p.h14
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp16
-rw-r--r--src/bluetooth/qbluetoothserviceinfo.cpp14
-rw-r--r--src/bluetooth/qbluetoothserviceinfo.h14
-rw-r--r--src/bluetooth/qbluetoothserviceinfo_android.cpp14
-rw-r--r--src/bluetooth/qbluetoothserviceinfo_bluez.cpp14
-rw-r--r--src/bluetooth/qbluetoothserviceinfo_osx.mm514
-rw-r--r--src/bluetooth/qbluetoothserviceinfo_p.cpp14
-rw-r--r--src/bluetooth/qbluetoothserviceinfo_p.h18
-rw-r--r--src/bluetooth/qbluetoothserviceinfo_qnx.cpp12
-rw-r--r--src/bluetooth/qbluetoothsocket.cpp16
-rw-r--r--src/bluetooth/qbluetoothsocket.h18
-rw-r--r--src/bluetooth/qbluetoothsocket_android.cpp21
-rw-r--r--src/bluetooth/qbluetoothsocket_bluez.cpp14
-rw-r--r--src/bluetooth/qbluetoothsocket_osx.mm772
-rw-r--r--src/bluetooth/qbluetoothsocket_osx_p.h139
-rw-r--r--src/bluetooth/qbluetoothsocket_p.cpp14
-rw-r--r--src/bluetooth/qbluetoothsocket_p.h31
-rw-r--r--src/bluetooth/qbluetoothsocket_qnx.cpp12
-rw-r--r--src/bluetooth/qbluetoothtransfermanager.cpp23
-rw-r--r--src/bluetooth/qbluetoothtransfermanager.h14
-rw-r--r--src/bluetooth/qbluetoothtransferreply.cpp16
-rw-r--r--src/bluetooth/qbluetoothtransferreply.h14
-rw-r--r--src/bluetooth/qbluetoothtransferreply_bluez.cpp18
-rw-r--r--src/bluetooth/qbluetoothtransferreply_bluez_p.h14
-rw-r--r--src/bluetooth/qbluetoothtransferreply_osx.mm470
-rw-r--r--src/bluetooth/qbluetoothtransferreply_osx_p.h84
-rw-r--r--src/bluetooth/qbluetoothtransferreply_p.h14
-rw-r--r--src/bluetooth/qbluetoothtransferreply_qnx.cpp18
-rw-r--r--src/bluetooth/qbluetoothtransferreply_qnx_p.h12
-rw-r--r--src/bluetooth/qbluetoothtransferrequest.cpp14
-rw-r--r--src/bluetooth/qbluetoothtransferrequest.h14
-rw-r--r--src/bluetooth/qbluetoothtransferrequest_p.h14
-rw-r--r--src/bluetooth/qbluetoothuuid.cpp263
-rw-r--r--src/bluetooth/qbluetoothuuid.h112
-rw-r--r--src/bluetooth/qlowenergycharacteristic.cpp35
-rw-r--r--src/bluetooth/qlowenergycharacteristic.h15
-rw-r--r--src/bluetooth/qlowenergycontroller.cpp91
-rw-r--r--src/bluetooth/qlowenergycontroller.h29
-rw-r--r--src/bluetooth/qlowenergycontroller_android.cpp581
-rw-r--r--src/bluetooth/qlowenergycontroller_bluez.cpp173
-rw-r--r--src/bluetooth/qlowenergycontroller_osx.mm975
-rw-r--r--src/bluetooth/qlowenergycontroller_osx_p.h162
-rw-r--r--src/bluetooth/qlowenergycontroller_p.cpp35
-rw-r--r--src/bluetooth/qlowenergycontroller_p.h68
-rw-r--r--src/bluetooth/qlowenergydescriptor.cpp24
-rw-r--r--src/bluetooth/qlowenergydescriptor.h15
-rw-r--r--src/bluetooth/qlowenergyservice.cpp236
-rw-r--r--src/bluetooth/qlowenergyservice.h30
-rw-r--r--src/bluetooth/qlowenergyservice_osx.mm270
-rw-r--r--src/bluetooth/qlowenergyserviceprivate.cpp19
-rw-r--r--src/bluetooth/qlowenergyserviceprivate_p.h18
-rw-r--r--src/bluetooth/qnx/ppshelpers.cpp12
-rw-r--r--src/bluetooth/qnx/ppshelpers_p.h12
-rw-r--r--src/bluetooth/qprivatelinearbuffer_p.h14
-rw-r--r--src/imports/bluetooth/plugin.cpp20
-rw-r--r--src/imports/bluetooth/plugins.qmltypes4
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp14
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel_p.h14
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothservice.cpp14
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothservice_p.h14
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothsocket.cpp14
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothsocket_p.h14
-rw-r--r--src/imports/nfc/plugin.cpp18
-rw-r--r--src/imports/nfc/plugins.qmltypes11
-rw-r--r--src/imports/nfc/qdeclarativendeffilter.cpp14
-rw-r--r--src/imports/nfc/qdeclarativendeffilter_p.h14
-rw-r--r--src/imports/nfc/qdeclarativendefmimerecord.cpp14
-rw-r--r--src/imports/nfc/qdeclarativendefmimerecord_p.h14
-rw-r--r--src/imports/nfc/qdeclarativendeftextrecord.cpp14
-rw-r--r--src/imports/nfc/qdeclarativendeftextrecord_p.h14
-rw-r--r--src/imports/nfc/qdeclarativendefurirecord.cpp14
-rw-r--r--src/imports/nfc/qdeclarativendefurirecord_p.h14
-rw-r--r--src/imports/nfc/qdeclarativenearfield.cpp117
-rw-r--r--src/imports/nfc/qdeclarativenearfield_p.h25
-rw-r--r--src/imports/nfc/qdeclarativenearfieldsocket.cpp14
-rw-r--r--src/imports/nfc/qdeclarativenearfieldsocket_p.h14
-rw-r--r--src/nfc/doc/snippets/doc_src_qtnfc.cpp6
-rw-r--r--src/nfc/doc/snippets/doc_src_qtnfc.qml8
-rw-r--r--src/nfc/doc/snippets/foorecord.cpp8
-rw-r--r--src/nfc/doc/snippets/foorecord.h8
-rw-r--r--src/nfc/doc/snippets/main.cpp8
-rw-r--r--src/nfc/doc/snippets/nfc.cpp8
-rw-r--r--src/nfc/doc/src/examples.qdoc10
-rw-r--r--src/nfc/doc/src/nfc-cpp.qdoc10
-rw-r--r--src/nfc/doc/src/nfc-index.qdoc14
-rw-r--r--src/nfc/doc/src/nfc-overview.qdoc14
-rw-r--r--src/nfc/doc/src/nfc-qml.qdoc10
-rw-r--r--src/nfc/neard/adapter.cpp25
-rw-r--r--src/nfc/neard/adapter_p.h60
-rw-r--r--src/nfc/neard/agent.cpp38
-rw-r--r--src/nfc/neard/agent_p.h100
-rw-r--r--src/nfc/neard/dbusobjectmanager.cpp26
-rw-r--r--src/nfc/neard/dbusobjectmanager_p.h58
-rw-r--r--src/nfc/neard/dbusproperties.cpp26
-rw-r--r--src/nfc/neard/dbusproperties_p.h71
-rw-r--r--src/nfc/neard/manager.cpp25
-rw-r--r--src/nfc/neard/manager_p.h91
-rw-r--r--src/nfc/neard/neard.pri22
-rw-r--r--src/nfc/neard/neard_helper.cpp100
-rw-r--r--src/nfc/neard/neard_helper_p.h76
-rw-r--r--src/nfc/neard/org.freedesktop.dbus.objectmanager.xml19
-rw-r--r--src/nfc/neard/org.freedesktop.dbus.properties.xml27
-rw-r--r--src/nfc/neard/org.neard.Adapter.xml11
-rw-r--r--src/nfc/neard/org.neard.Agent.xml26
-rw-r--r--src/nfc/neard/org.neard.Manager.xml38
-rw-r--r--src/nfc/neard/org.neard.Tag.xml13
-rw-r--r--src/nfc/neard/tag.cpp25
-rw-r--r--src/nfc/neard/tag_p.h60
-rw-r--r--src/nfc/nfc.pro28
-rw-r--r--src/nfc/qllcpserver.cpp14
-rw-r--r--src/nfc/qllcpserver_p.cpp14
-rw-r--r--src/nfc/qllcpserver_p.h14
-rw-r--r--src/nfc/qllcpserver_p_p.h14
-rw-r--r--src/nfc/qllcpserver_qnx_p.cpp12
-rw-r--r--src/nfc/qllcpserver_qnx_p.h12
-rw-r--r--src/nfc/qllcpserver_simulator_p.cpp14
-rw-r--r--src/nfc/qllcpserver_simulator_p.h14
-rw-r--r--src/nfc/qllcpsocket.cpp14
-rw-r--r--src/nfc/qllcpsocket_p.cpp14
-rw-r--r--src/nfc/qllcpsocket_p.h14
-rw-r--r--src/nfc/qllcpsocket_p_p.h14
-rw-r--r--src/nfc/qllcpsocket_qnx_p.cpp12
-rw-r--r--src/nfc/qllcpsocket_qnx_p.h12
-rw-r--r--src/nfc/qllcpsocket_simulator_p.cpp14
-rw-r--r--src/nfc/qllcpsocket_simulator_p.h14
-rw-r--r--src/nfc/qndeffilter.cpp14
-rw-r--r--src/nfc/qndeffilter.h14
-rw-r--r--src/nfc/qndefmessage.cpp14
-rw-r--r--src/nfc/qndefmessage.h14
-rw-r--r--src/nfc/qndefnfcsmartposterrecord.cpp54
-rw-r--r--src/nfc/qndefnfcsmartposterrecord.h14
-rw-r--r--src/nfc/qndefnfcsmartposterrecord_p.h12
-rw-r--r--src/nfc/qndefnfctextrecord.cpp14
-rw-r--r--src/nfc/qndefnfctextrecord.h14
-rw-r--r--src/nfc/qndefnfcurirecord.cpp14
-rw-r--r--src/nfc/qndefnfcurirecord.h14
-rw-r--r--src/nfc/qndefrecord.cpp14
-rw-r--r--src/nfc/qndefrecord.h14
-rw-r--r--src/nfc/qndefrecord_p.h14
-rw-r--r--src/nfc/qnearfieldmanager.cpp28
-rw-r--r--src/nfc/qnearfieldmanager.h14
-rw-r--r--src/nfc/qnearfieldmanager_emulator.cpp14
-rw-r--r--src/nfc/qnearfieldmanager_emulator_p.h14
-rw-r--r--src/nfc/qnearfieldmanager_neard.cpp267
-rw-r--r--src/nfc/qnearfieldmanager_neard_p.h89
-rw-r--r--src/nfc/qnearfieldmanager_p.h14
-rw-r--r--src/nfc/qnearfieldmanager_qnx.cpp12
-rw-r--r--src/nfc/qnearfieldmanager_qnx_p.h12
-rw-r--r--src/nfc/qnearfieldmanager_simulator.cpp14
-rw-r--r--src/nfc/qnearfieldmanager_simulator_p.h14
-rw-r--r--src/nfc/qnearfieldmanagerimpl_p.cpp14
-rw-r--r--src/nfc/qnearfieldmanagerimpl_p.h14
-rw-r--r--src/nfc/qnearfieldmanagervirtualbase.cpp14
-rw-r--r--src/nfc/qnearfieldmanagervirtualbase_p.h14
-rw-r--r--src/nfc/qnearfieldsharemanager.cpp12
-rw-r--r--src/nfc/qnearfieldsharemanager.h12
-rw-r--r--src/nfc/qnearfieldsharemanager_p.h12
-rw-r--r--src/nfc/qnearfieldsharemanager_qnx_p.cpp12
-rw-r--r--src/nfc/qnearfieldsharemanager_qnx_p.h12
-rw-r--r--src/nfc/qnearfieldsharemanagerimpl_p.cpp12
-rw-r--r--src/nfc/qnearfieldsharemanagerimpl_p.h12
-rw-r--r--src/nfc/qnearfieldsharetarget.cpp12
-rw-r--r--src/nfc/qnearfieldsharetarget.h12
-rw-r--r--src/nfc/qnearfieldsharetarget_p.h12
-rw-r--r--src/nfc/qnearfieldsharetarget_qnx_p.cpp12
-rw-r--r--src/nfc/qnearfieldsharetarget_qnx_p.h12
-rw-r--r--src/nfc/qnearfieldsharetargetimpl_p.cpp12
-rw-r--r--src/nfc/qnearfieldsharetargetimpl_p.h12
-rw-r--r--src/nfc/qnearfieldtagtype1.cpp14
-rw-r--r--src/nfc/qnearfieldtagtype1_p.h14
-rw-r--r--src/nfc/qnearfieldtagtype2.cpp14
-rw-r--r--src/nfc/qnearfieldtagtype2_p.h14
-rw-r--r--src/nfc/qnearfieldtagtype3.cpp14
-rw-r--r--src/nfc/qnearfieldtagtype3_p.h14
-rw-r--r--src/nfc/qnearfieldtagtype4.cpp14
-rw-r--r--src/nfc/qnearfieldtagtype4_p.h14
-rw-r--r--src/nfc/qnearfieldtarget.cpp19
-rw-r--r--src/nfc/qnearfieldtarget.h16
-rw-r--r--src/nfc/qnearfieldtarget_emulator.cpp16
-rw-r--r--src/nfc/qnearfieldtarget_emulator_p.h14
-rw-r--r--src/nfc/qnearfieldtarget_neard_p.h404
-rw-r--r--src/nfc/qnearfieldtarget_p.h14
-rw-r--r--src/nfc/qnearfieldtarget_qnx_p.h12
-rw-r--r--src/nfc/qnfc.cpp41
-rw-r--r--src/nfc/qnfcglobal.h14
-rw-r--r--src/nfc/qnx/qnxnfceventfilter.cpp12
-rw-r--r--src/nfc/qnx/qnxnfceventfilter_p.h12
-rw-r--r--src/nfc/qnx/qnxnfcmanager.cpp12
-rw-r--r--src/nfc/qnx/qnxnfcmanager_p.h12
-rw-r--r--src/nfc/qnx/qnxnfcsharemanager_p.cpp12
-rw-r--r--src/nfc/qnx/qnxnfcsharemanager_p.h12
-rw-r--r--src/nfc/qqmlndefrecord.cpp14
-rw-r--r--src/nfc/qqmlndefrecord.h14
-rw-r--r--src/nfc/qtlv.cpp14
-rw-r--r--src/nfc/qtlv_p.h14
-rw-r--r--src/nfc/targetemulator.cpp14
-rw-r--r--src/nfc/targetemulator_p.h14
-rw-r--r--src/tools/sdpscanner/main.cpp14
-rw-r--r--tests/auto/qbluetoothaddress/tst_qbluetoothaddress.cpp14
-rw-r--r--tests/auto/qbluetoothdevicediscoveryagent/qbluetoothdevicediscoveryagent.pro2
-rw-r--r--tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp37
-rw-r--r--tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp141
-rw-r--r--tests/auto/qbluetoothhostinfo/tst_qbluetoothhostinfo.cpp14
-rw-r--r--tests/auto/qbluetoothlocaldevice/qbluetoothlocaldevice.pro2
-rw-r--r--tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp34
-rw-r--r--tests/auto/qbluetoothserver/qbluetoothserver.pro2
-rw-r--r--tests/auto/qbluetoothserver/tst_qbluetoothserver.cpp34
-rw-r--r--tests/auto/qbluetoothservicediscoveryagent/qbluetoothservicediscoveryagent.pro1
-rw-r--r--tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp45
-rw-r--r--tests/auto/qbluetoothserviceinfo/qbluetoothserviceinfo.pro2
-rw-r--r--tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp20
-rw-r--r--tests/auto/qbluetoothsocket/qbluetoothsocket.pro1
-rw-r--r--tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp20
-rw-r--r--tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp15
-rw-r--r--tests/auto/qbluetoothtransferrequest/tst_qbluetoothtransferrequest.cpp14
-rw-r--r--tests/auto/qbluetoothuuid/tst_qbluetoothuuid.cpp16
-rw-r--r--tests/auto/qlowenergycharacteristic/qlowenergycharacteristic.pro3
-rw-r--r--tests/auto/qlowenergycharacteristic/tst_qlowenergycharacteristic.cpp47
-rw-r--r--tests/auto/qlowenergycontroller/qlowenergycontroller.pro8
-rw-r--r--tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp892
-rw-r--r--tests/auto/qlowenergydescriptor/qlowenergydescriptor.pro3
-rw-r--r--tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp30
-rw-r--r--tests/auto/qndefmessage/tst_qndefmessage.cpp14
-rw-r--r--tests/auto/qndefnfcsmartposterrecord/tst_qndefnfcsmartposterrecord.cpp12
-rw-r--r--tests/auto/qndefrecord/tst_qndefrecord.cpp14
-rw-r--r--tests/auto/qnearfieldmanager/tst_qnearfieldmanager.cpp18
-rw-r--r--tests/auto/qnearfieldtagtype1/tst_qnearfieldtagtype1.cpp18
-rw-r--r--tests/auto/qnearfieldtagtype2/tst_qnearfieldtagtype2.cpp18
-rw-r--r--tests/bttestui/Button.qml14
-rw-r--r--tests/bttestui/btlocaldevice.cpp14
-rw-r--r--tests/bttestui/btlocaldevice.h14
-rw-r--r--tests/bttestui/main.cpp14
-rw-r--r--tests/bttestui/main.qml14
495 files changed, 21942 insertions, 2819 deletions
diff --git a/.qmake.conf b/.qmake.conf
index 60b46503..068da422 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -1,4 +1,4 @@
load(qt_build_config)
CONFIG += qt_example_installs
-MODULE_VERSION = 5.4.3
+MODULE_VERSION = 5.5.0
diff --git a/LGPL_EXCEPTION.txt b/LGPL_EXCEPTION.txt
index 7e2e30ff..5cdacb9a 100644
--- a/LGPL_EXCEPTION.txt
+++ b/LGPL_EXCEPTION.txt
@@ -1,4 +1,4 @@
-Digia Qt LGPL Exception version 1.1
+The Qt Company Qt LGPL Exception version 1.1
As an additional permission to the GNU Lesser General Public License version
2.1, the object code form of a "work that uses the Library" may incorporate
diff --git a/LICENSE.GPLv2 b/LICENSE.GPLv2
index 194c39cb..6dbb032f 100644
--- a/LICENSE.GPLv2
+++ b/LICENSE.GPLv2
@@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE
- The Qt Toolkit is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
- Contact: http://www.qt-project.org/legal
+ The Qt Toolkit is Copyright (C) 2015 The Qt Company Ltd.
+ Contact: http://www.qt.io/licensing/
You may use, distribute and copy the Qt GUI Toolkit under the terms of
GNU General Public License version 2, which is displayed below.
diff --git a/LICENSE.LGPLv21 b/LICENSE.LGPLv21
index 341aa9ee..6e184611 100644
--- a/LICENSE.LGPLv21
+++ b/LICENSE.LGPLv21
@@ -1,7 +1,7 @@
GNU LESSER GENERAL PUBLIC LICENSE
- The Qt Toolkit is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
- Contact: http://www.qt-project.org/legal
+ The Qt Toolkit is Copyright (C) 2015 The Qt Company Ltd.
+ Contact: http://www.qt.io/licensing/
You may use, distribute and copy the Qt GUI Toolkit under the terms of
GNU Lesser General Public License version 2.1, which is displayed below.
diff --git a/LICENSE.LGPLv3 b/LICENSE.LGPLv3
index aed671a0..8fbb7439 100644
--- a/LICENSE.LGPLv3
+++ b/LICENSE.LGPLv3
@@ -1,7 +1,7 @@
GNU LESSER GENERAL PUBLIC LICENSE
- The Qt Toolkit is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
- Contact: http://www.qt-project.org/legal
+ The Qt Toolkit is Copyright (C) 2015 The Qt Company Ltd.
+ Contact: http://www.qt.io/licensing/
You may use, distribute and copy the Qt GUI Toolkit under the terms of
GNU Lesser General Public License version 3, which is displayed below.
diff --git a/config.tests/bluez/main.cpp b/config.tests/bluez/main.cpp
index c7867cdc..f0be7d3e 100644
--- a/config.tests/bluez/main.cpp
+++ b/config.tests/bluez/main.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtConnectivity module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/config.tests/bluez_le/main.cpp b/config.tests/bluez_le/main.cpp
index 11218b8e..3a601748 100644
--- a/config.tests/bluez_le/main.cpp
+++ b/config.tests/bluez_le/main.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtConnectivity module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/config.tests/btapi10_2_1/main.cpp b/config.tests/btapi10_2_1/main.cpp
index e7d5812e..e34585d1 100644
--- a/config.tests/btapi10_2_1/main.cpp
+++ b/config.tests/btapi10_2_1/main.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtConnectivity module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/config.tests/libbb2/main.cpp b/config.tests/libbb2/main.cpp
index baa509b3..f606744b 100644
--- a/config.tests/libbb2/main.cpp
+++ b/config.tests/libbb2/main.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtConnectivity module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/examples/bluetooth/btchat/chat.cpp b/examples/bluetooth/btchat/chat.cpp
index 61943ac0..51a2d4ed 100644
--- a/examples/bluetooth/btchat/chat.cpp
+++ b/examples/bluetooth/btchat/chat.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/btchat/chat.h b/examples/bluetooth/btchat/chat.h
index 75d7669f..564b7867 100644
--- a/examples/bluetooth/btchat/chat.h
+++ b/examples/bluetooth/btchat/chat.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/btchat/chatclient.cpp b/examples/bluetooth/btchat/chatclient.cpp
index 06930145..09a2f138 100644
--- a/examples/bluetooth/btchat/chatclient.cpp
+++ b/examples/bluetooth/btchat/chatclient.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/btchat/chatclient.h b/examples/bluetooth/btchat/chatclient.h
index 07f23164..73b1bc91 100644
--- a/examples/bluetooth/btchat/chatclient.h
+++ b/examples/bluetooth/btchat/chatclient.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/btchat/chatserver.cpp b/examples/bluetooth/btchat/chatserver.cpp
index 6848e2d7..6b21a507 100644
--- a/examples/bluetooth/btchat/chatserver.cpp
+++ b/examples/bluetooth/btchat/chatserver.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/btchat/chatserver.h b/examples/bluetooth/btchat/chatserver.h
index 8af21f55..c40daf52 100644
--- a/examples/bluetooth/btchat/chatserver.h
+++ b/examples/bluetooth/btchat/chatserver.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/btchat/doc/src/btchat.qdoc b/examples/bluetooth/btchat/doc/src/btchat.qdoc
index a78b9ede..213db715 100644
--- a/examples/bluetooth/btchat/doc/src/btchat.qdoc
+++ b/examples/bluetooth/btchat/doc/src/btchat.qdoc
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt local connectivty modules.
**
@@ -10,15 +10,15 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
+** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
diff --git a/examples/bluetooth/btchat/main.cpp b/examples/bluetooth/btchat/main.cpp
index ed362d23..bb862798 100644
--- a/examples/bluetooth/btchat/main.cpp
+++ b/examples/bluetooth/btchat/main.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/btchat/remoteselector.cpp b/examples/bluetooth/btchat/remoteselector.cpp
index 913988a2..5a417c5c 100644
--- a/examples/bluetooth/btchat/remoteselector.cpp
+++ b/examples/bluetooth/btchat/remoteselector.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/btchat/remoteselector.h b/examples/bluetooth/btchat/remoteselector.h
index 5b123127..2165cdd9 100644
--- a/examples/bluetooth/btchat/remoteselector.h
+++ b/examples/bluetooth/btchat/remoteselector.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/btfiletransfer/doc/src/btfiletransfer.qdoc b/examples/bluetooth/btfiletransfer/doc/src/btfiletransfer.qdoc
index 53832725..5f07e088 100644
--- a/examples/bluetooth/btfiletransfer/doc/src/btfiletransfer.qdoc
+++ b/examples/bluetooth/btfiletransfer/doc/src/btfiletransfer.qdoc
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt local connectivty modules.
**
@@ -10,15 +10,15 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
+** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
diff --git a/examples/bluetooth/btfiletransfer/main.cpp b/examples/bluetooth/btfiletransfer/main.cpp
index 44288caa..2e96ce45 100644
--- a/examples/bluetooth/btfiletransfer/main.cpp
+++ b/examples/bluetooth/btfiletransfer/main.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/btfiletransfer/pindisplay.cpp b/examples/bluetooth/btfiletransfer/pindisplay.cpp
index 6577d54e..1aabb719 100644
--- a/examples/bluetooth/btfiletransfer/pindisplay.cpp
+++ b/examples/bluetooth/btfiletransfer/pindisplay.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/btfiletransfer/pindisplay.h b/examples/bluetooth/btfiletransfer/pindisplay.h
index 52d14f43..f8d89352 100644
--- a/examples/bluetooth/btfiletransfer/pindisplay.h
+++ b/examples/bluetooth/btfiletransfer/pindisplay.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/btfiletransfer/progress.cpp b/examples/bluetooth/btfiletransfer/progress.cpp
index c9913c44..7b7c6bac 100644
--- a/examples/bluetooth/btfiletransfer/progress.cpp
+++ b/examples/bluetooth/btfiletransfer/progress.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/btfiletransfer/progress.h b/examples/bluetooth/btfiletransfer/progress.h
index eab84746..b71009b7 100644
--- a/examples/bluetooth/btfiletransfer/progress.h
+++ b/examples/bluetooth/btfiletransfer/progress.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/btfiletransfer/remoteselector.cpp b/examples/bluetooth/btfiletransfer/remoteselector.cpp
index 08072d14..4a1f96c0 100644
--- a/examples/bluetooth/btfiletransfer/remoteselector.cpp
+++ b/examples/bluetooth/btfiletransfer/remoteselector.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/btfiletransfer/remoteselector.h b/examples/bluetooth/btfiletransfer/remoteselector.h
index ec2e4fd5..1d2c3de2 100644
--- a/examples/bluetooth/btfiletransfer/remoteselector.h
+++ b/examples/bluetooth/btfiletransfer/remoteselector.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/btscanner/device.cpp b/examples/bluetooth/btscanner/device.cpp
index 016d1107..910791fb 100644
--- a/examples/bluetooth/btscanner/device.cpp
+++ b/examples/bluetooth/btscanner/device.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/btscanner/device.h b/examples/bluetooth/btscanner/device.h
index 6dbfb870..9e5c59f6 100644
--- a/examples/bluetooth/btscanner/device.h
+++ b/examples/bluetooth/btscanner/device.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/btscanner/doc/src/btscanner.qdoc b/examples/bluetooth/btscanner/doc/src/btscanner.qdoc
index e4d28ee2..600cfe39 100644
--- a/examples/bluetooth/btscanner/doc/src/btscanner.qdoc
+++ b/examples/bluetooth/btscanner/doc/src/btscanner.qdoc
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt local connectivty modules.
**
@@ -10,15 +10,15 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
+** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
diff --git a/examples/bluetooth/btscanner/main.cpp b/examples/bluetooth/btscanner/main.cpp
index 74094e8d..8ec92769 100644
--- a/examples/bluetooth/btscanner/main.cpp
+++ b/examples/bluetooth/btscanner/main.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/btscanner/service.cpp b/examples/bluetooth/btscanner/service.cpp
index c886c901..bd4b7207 100644
--- a/examples/bluetooth/btscanner/service.cpp
+++ b/examples/bluetooth/btscanner/service.cpp
@@ -1,8 +1,8 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/btscanner/service.h b/examples/bluetooth/btscanner/service.h
index 293bc7a9..5b47d11a 100644
--- a/examples/bluetooth/btscanner/service.h
+++ b/examples/bluetooth/btscanner/service.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/chat/Button.qml b/examples/bluetooth/chat/Button.qml
index 6259c097..d1136730 100644
--- a/examples/bluetooth/chat/Button.qml
+++ b/examples/bluetooth/chat/Button.qml
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/chat/InputBox.qml b/examples/bluetooth/chat/InputBox.qml
index 5cd5a768..8a10a5d1 100644
--- a/examples/bluetooth/chat/InputBox.qml
+++ b/examples/bluetooth/chat/InputBox.qml
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/chat/Search.qml b/examples/bluetooth/chat/Search.qml
index 47fbb6ab..f1f8f6ac 100644
--- a/examples/bluetooth/chat/Search.qml
+++ b/examples/bluetooth/chat/Search.qml
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/chat/chat.qml b/examples/bluetooth/chat/chat.qml
index 6a2830ad..ecac39fc 100644
--- a/examples/bluetooth/chat/chat.qml
+++ b/examples/bluetooth/chat/chat.qml
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/chat/doc/src/chat.qdoc b/examples/bluetooth/chat/doc/src/chat.qdoc
index 5f61fd74..4b5e8778 100644
--- a/examples/bluetooth/chat/doc/src/chat.qdoc
+++ b/examples/bluetooth/chat/doc/src/chat.qdoc
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt local connectivty modules.
**
@@ -10,15 +10,15 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
+** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
diff --git a/examples/bluetooth/chat/qmlchat.cpp b/examples/bluetooth/chat/qmlchat.cpp
index 6e23fe13..8cd90bda 100644
--- a/examples/bluetooth/chat/qmlchat.cpp
+++ b/examples/bluetooth/chat/qmlchat.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/heartlistener/assets/Button.qml b/examples/bluetooth/heartlistener/assets/Button.qml
index 40e98875..51c377b1 100644
--- a/examples/bluetooth/heartlistener/assets/Button.qml
+++ b/examples/bluetooth/heartlistener/assets/Button.qml
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/heartlistener/assets/Point.qml b/examples/bluetooth/heartlistener/assets/Point.qml
index 2ed94a4d..0341d11a 100644
--- a/examples/bluetooth/heartlistener/assets/Point.qml
+++ b/examples/bluetooth/heartlistener/assets/Point.qml
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/heartlistener/assets/dialog.qml b/examples/bluetooth/heartlistener/assets/dialog.qml
index 45b64cf3..bcaf299f 100644
--- a/examples/bluetooth/heartlistener/assets/dialog.qml
+++ b/examples/bluetooth/heartlistener/assets/dialog.qml
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/heartlistener/assets/draw.js b/examples/bluetooth/heartlistener/assets/draw.js
index a5de5474..f884d472 100644
--- a/examples/bluetooth/heartlistener/assets/draw.js
+++ b/examples/bluetooth/heartlistener/assets/draw.js
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/heartlistener/assets/home.qml b/examples/bluetooth/heartlistener/assets/home.qml
index 2c5e9485..e77081ae 100644
--- a/examples/bluetooth/heartlistener/assets/home.qml
+++ b/examples/bluetooth/heartlistener/assets/home.qml
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/heartlistener/assets/main.qml b/examples/bluetooth/heartlistener/assets/main.qml
index e892eb47..89d9f600 100644
--- a/examples/bluetooth/heartlistener/assets/main.qml
+++ b/examples/bluetooth/heartlistener/assets/main.qml
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/heartlistener/assets/monitor.qml b/examples/bluetooth/heartlistener/assets/monitor.qml
index 2fcbef3d..1d74ad84 100644
--- a/examples/bluetooth/heartlistener/assets/monitor.qml
+++ b/examples/bluetooth/heartlistener/assets/monitor.qml
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/heartlistener/assets/results.qml b/examples/bluetooth/heartlistener/assets/results.qml
index bdc7147d..301762c3 100644
--- a/examples/bluetooth/heartlistener/assets/results.qml
+++ b/examples/bluetooth/heartlistener/assets/results.qml
@@ -1,8 +1,8 @@
/***************************************************************************
**
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/heartlistener/deviceinfo.cpp b/examples/bluetooth/heartlistener/deviceinfo.cpp
index 5be9fcfe..cfddf56d 100644
--- a/examples/bluetooth/heartlistener/deviceinfo.cpp
+++ b/examples/bluetooth/heartlistener/deviceinfo.cpp
@@ -1,8 +1,8 @@
/***************************************************************************
**
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
@@ -39,6 +39,8 @@
**
****************************************************************************/
+#include <qbluetoothuuid.h>
+
#include "deviceinfo.h"
DeviceInfo::DeviceInfo(const QBluetoothDeviceInfo &info):
@@ -51,6 +53,16 @@ QBluetoothDeviceInfo DeviceInfo::getDevice() const
return m_device;
}
+QString DeviceInfo::getAddress() const
+{
+#ifdef Q_OS_MAC
+ // workaround for Core Bluetooth:
+ return m_device.deviceUuid().toString();
+#else
+ return m_device.address().toString();
+#endif
+}
+
void DeviceInfo::setDevice(const QBluetoothDeviceInfo &device)
{
m_device = device;
diff --git a/examples/bluetooth/heartlistener/deviceinfo.h b/examples/bluetooth/heartlistener/deviceinfo.h
index a80f723b..636f7905 100644
--- a/examples/bluetooth/heartlistener/deviceinfo.h
+++ b/examples/bluetooth/heartlistener/deviceinfo.h
@@ -1,8 +1,8 @@
/***************************************************************************
**
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
@@ -56,7 +56,7 @@ public:
DeviceInfo(const QBluetoothDeviceInfo &device);
void setDevice(const QBluetoothDeviceInfo &device);
QString getName() const { return m_device.name(); }
- QString getAddress() const { return m_device.address().toString(); }
+ QString getAddress() const;
QBluetoothDeviceInfo getDevice() const;
signals:
diff --git a/examples/bluetooth/heartlistener/doc/src/heartlistener.qdoc b/examples/bluetooth/heartlistener/doc/src/heartlistener.qdoc
index c73c13f7..e7e1176f 100644
--- a/examples/bluetooth/heartlistener/doc/src/heartlistener.qdoc
+++ b/examples/bluetooth/heartlistener/doc/src/heartlistener.qdoc
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
@@ -10,15 +10,15 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
+** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
diff --git a/examples/bluetooth/heartlistener/heartrate.cpp b/examples/bluetooth/heartlistener/heartrate.cpp
index 91fe41c1..fe53a740 100644
--- a/examples/bluetooth/heartlistener/heartrate.cpp
+++ b/examples/bluetooth/heartlistener/heartrate.cpp
@@ -1,8 +1,8 @@
/***************************************************************************
**
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
@@ -152,8 +152,7 @@ void HeartRate::connectToService(const QString &address)
}
//! [Connect signals]
- m_control = new QLowEnergyController(m_currentDevice.getDevice().address(),
- this);
+ m_control = new QLowEnergyController(m_currentDevice.getDevice(), this);
connect(m_control, SIGNAL(serviceDiscovered(QBluetoothUuid)),
this, SLOT(serviceDiscovered(QBluetoothUuid)));
connect(m_control, SIGNAL(discoveryFinished()),
diff --git a/examples/bluetooth/heartlistener/heartrate.h b/examples/bluetooth/heartlistener/heartrate.h
index 8f5ee061..1766ce3a 100644
--- a/examples/bluetooth/heartlistener/heartrate.h
+++ b/examples/bluetooth/heartlistener/heartrate.h
@@ -1,8 +1,8 @@
/***************************************************************************
**
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/heartlistener/main.cpp b/examples/bluetooth/heartlistener/main.cpp
index e50b87f1..7aa17080 100644
--- a/examples/bluetooth/heartlistener/main.cpp
+++ b/examples/bluetooth/heartlistener/main.cpp
@@ -1,8 +1,8 @@
/***************************************************************************
**
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/lowenergyscanner/assets/Characteristics.qml b/examples/bluetooth/lowenergyscanner/assets/Characteristics.qml
index 8e6e2868..957eee70 100644
--- a/examples/bluetooth/lowenergyscanner/assets/Characteristics.qml
+++ b/examples/bluetooth/lowenergyscanner/assets/Characteristics.qml
@@ -1,8 +1,8 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/lowenergyscanner/assets/Dialog.qml b/examples/bluetooth/lowenergyscanner/assets/Dialog.qml
index 2b8580f3..8195b842 100644
--- a/examples/bluetooth/lowenergyscanner/assets/Dialog.qml
+++ b/examples/bluetooth/lowenergyscanner/assets/Dialog.qml
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
@@ -42,7 +42,7 @@ import QtQuick 2.0
Rectangle {
width: parent.width/3*2
- height: 62
+ height: dialogTextId.height + background.height + 20
z: 50
property string dialogText: ""
property bool busyImage: true
diff --git a/examples/bluetooth/lowenergyscanner/assets/Header.qml b/examples/bluetooth/lowenergyscanner/assets/Header.qml
index 654fda34..721dc05c 100644
--- a/examples/bluetooth/lowenergyscanner/assets/Header.qml
+++ b/examples/bluetooth/lowenergyscanner/assets/Header.qml
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
@@ -54,7 +54,7 @@ Rectangle {
anchors.fill: parent
text: headerText
font.bold: true
- font.pixelSize: 30
+ font.pointSize: 20
elide: Text.ElideMiddle
color: "#363636"
}
diff --git a/examples/bluetooth/lowenergyscanner/assets/Label.qml b/examples/bluetooth/lowenergyscanner/assets/Label.qml
index 1dced831..aafda900 100644
--- a/examples/bluetooth/lowenergyscanner/assets/Label.qml
+++ b/examples/bluetooth/lowenergyscanner/assets/Label.qml
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
@@ -42,7 +42,7 @@ import QtQuick 2.0
Text {
property string textContent: ""
- font.pixelSize: 30
+ font.pointSize: 20
anchors.horizontalCenter: parent.horizontalCenter
color: "#363636"
horizontalAlignment: Text.AlignHCenter
diff --git a/examples/bluetooth/lowenergyscanner/assets/Menu.qml b/examples/bluetooth/lowenergyscanner/assets/Menu.qml
index 3669223a..e0a7b710 100644
--- a/examples/bluetooth/lowenergyscanner/assets/Menu.qml
+++ b/examples/bluetooth/lowenergyscanner/assets/Menu.qml
@@ -1,8 +1,8 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/lowenergyscanner/assets/Services.qml b/examples/bluetooth/lowenergyscanner/assets/Services.qml
index e3e05cac..d593c7d5 100644
--- a/examples/bluetooth/lowenergyscanner/assets/Services.qml
+++ b/examples/bluetooth/lowenergyscanner/assets/Services.qml
@@ -1,8 +1,8 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
@@ -76,6 +76,10 @@ Rectangle {
else
info.visible = false;
}
+
+ onDisconnected: {
+ pageLoader.source = "main.qml"
+ }
}
ListView {
diff --git a/examples/bluetooth/lowenergyscanner/assets/main.qml b/examples/bluetooth/lowenergyscanner/assets/main.qml
index 7f03d4fa..085c3e4f 100644
--- a/examples/bluetooth/lowenergyscanner/assets/main.qml
+++ b/examples/bluetooth/lowenergyscanner/assets/main.qml
@@ -1,8 +1,8 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp b/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp
index f5290459..91bbfbc8 100644
--- a/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp
+++ b/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp
@@ -1,8 +1,8 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/lowenergyscanner/characteristicinfo.h b/examples/bluetooth/lowenergyscanner/characteristicinfo.h
index d06c962e..c0566ba7 100644
--- a/examples/bluetooth/lowenergyscanner/characteristicinfo.h
+++ b/examples/bluetooth/lowenergyscanner/characteristicinfo.h
@@ -1,8 +1,8 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/lowenergyscanner/device.cpp b/examples/bluetooth/lowenergyscanner/device.cpp
index 9175095c..5ef2cf76 100644
--- a/examples/bluetooth/lowenergyscanner/device.cpp
+++ b/examples/bluetooth/lowenergyscanner/device.cpp
@@ -1,8 +1,8 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
@@ -138,6 +138,7 @@ QString Device::getUpdate()
void Device::scanServices(const QString &address)
{
// We need the current device for service discovery.
+
for (int i = 0; i < devices.size(); i++) {
if (((DeviceInfo*)devices.at(i))->getAddress() == address )
currentDevice.setDevice(((DeviceInfo*)devices.at(i))->getDevice());
@@ -157,7 +158,7 @@ void Device::scanServices(const QString &address)
setUpdate("Back\n(Connecting to device...)");
- if (controller && controller->remoteAddress() != currentDevice.getDevice().address()) {
+ if (controller && m_previousAddress != currentDevice.getAddress()) {
controller->disconnectFromDevice();
delete controller;
controller = 0;
@@ -166,7 +167,7 @@ void Device::scanServices(const QString &address)
//! [les-controller-1]
if (!controller) {
// Connecting signals and slots for connecting to LE services.
- controller = new QLowEnergyController(currentDevice.getDevice().address());
+ controller = new QLowEnergyController(currentDevice.getDevice());
connect(controller, SIGNAL(connected()),
this, SLOT(deviceConnected()));
connect(controller, SIGNAL(error(QLowEnergyController::Error)),
@@ -185,6 +186,8 @@ void Device::scanServices(const QString &address)
controller->setRemoteAddressType(QLowEnergyController::PublicAddress);
controller->connectToDevice();
//! [les-controller-1]
+
+ m_previousAddress = currentDevice.getAddress();
}
void Device::addLowEnergyService(const QBluetoothUuid &serviceUuid)
@@ -291,13 +294,24 @@ void Device::deviceDisconnected()
void Device::serviceDetailsDiscovered(QLowEnergyService::ServiceState newState)
{
- if (newState != QLowEnergyService::ServiceDiscovered)
+ if (newState != QLowEnergyService::ServiceDiscovered) {
+ // do not hang in "Scanning for characteristics" mode forever
+ // in case the service discovery failed
+ // We have to queue the signal up to give UI time to even enter
+ // the above mode
+ if (newState != QLowEnergyService::DiscoveringServices) {
+ QMetaObject::invokeMethod(this, "characteristicsUpdated",
+ Qt::QueuedConnection);
+ }
return;
+ }
QLowEnergyService *service = qobject_cast<QLowEnergyService *>(sender());
if (!service)
return;
+
+
//! [les-chars]
const QList<QLowEnergyCharacteristic> chars = service->characteristics();
foreach (const QLowEnergyCharacteristic &ch, chars) {
diff --git a/examples/bluetooth/lowenergyscanner/device.h b/examples/bluetooth/lowenergyscanner/device.h
index a12f9e0e..331d4458 100644
--- a/examples/bluetooth/lowenergyscanner/device.h
+++ b/examples/bluetooth/lowenergyscanner/device.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the demonstration applications of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
@@ -119,6 +119,7 @@ private:
QList<QObject*> devices;
QList<QObject*> m_services;
QList<QObject*> m_characteristics;
+ QString m_previousAddress;
QString m_message;
bool connected;
QLowEnergyController *controller;
diff --git a/examples/bluetooth/lowenergyscanner/deviceinfo.cpp b/examples/bluetooth/lowenergyscanner/deviceinfo.cpp
index d6b7a734..89371a76 100644
--- a/examples/bluetooth/lowenergyscanner/deviceinfo.cpp
+++ b/examples/bluetooth/lowenergyscanner/deviceinfo.cpp
@@ -1,8 +1,8 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
@@ -39,6 +39,8 @@
**
****************************************************************************/
+#include <qbluetoothuuid.h>
+
#include "deviceinfo.h"
DeviceInfo::DeviceInfo()
@@ -52,7 +54,13 @@ DeviceInfo::DeviceInfo(const QBluetoothDeviceInfo &d)
QString DeviceInfo::getAddress() const
{
+#ifdef Q_OS_MAC
+ // On OS X and iOS we do not have addresses,
+ // only unique UUIDs generated by Core Bluetooth.
+ return device.deviceUuid().toString();
+#else
return device.address().toString();
+#endif
}
QString DeviceInfo::getName() const
diff --git a/examples/bluetooth/lowenergyscanner/deviceinfo.h b/examples/bluetooth/lowenergyscanner/deviceinfo.h
index 48f11cfe..0c9ad673 100644
--- a/examples/bluetooth/lowenergyscanner/deviceinfo.h
+++ b/examples/bluetooth/lowenergyscanner/deviceinfo.h
@@ -1,8 +1,8 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/lowenergyscanner/doc/src/lowenergyscanner.qdoc b/examples/bluetooth/lowenergyscanner/doc/src/lowenergyscanner.qdoc
index 0dc38efa..b4ad9fa2 100644
--- a/examples/bluetooth/lowenergyscanner/doc/src/lowenergyscanner.qdoc
+++ b/examples/bluetooth/lowenergyscanner/doc/src/lowenergyscanner.qdoc
@@ -1,8 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited all rights reserved
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
@@ -11,15 +11,15 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
+** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
diff --git a/examples/bluetooth/lowenergyscanner/main.cpp b/examples/bluetooth/lowenergyscanner/main.cpp
index ce359545..27076f14 100644
--- a/examples/bluetooth/lowenergyscanner/main.cpp
+++ b/examples/bluetooth/lowenergyscanner/main.cpp
@@ -1,8 +1,8 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/lowenergyscanner/serviceinfo.cpp b/examples/bluetooth/lowenergyscanner/serviceinfo.cpp
index c05422ca..c424b046 100644
--- a/examples/bluetooth/lowenergyscanner/serviceinfo.cpp
+++ b/examples/bluetooth/lowenergyscanner/serviceinfo.cpp
@@ -1,8 +1,8 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/lowenergyscanner/serviceinfo.h b/examples/bluetooth/lowenergyscanner/serviceinfo.h
index 1d35b1b7..af040554 100644
--- a/examples/bluetooth/lowenergyscanner/serviceinfo.h
+++ b/examples/bluetooth/lowenergyscanner/serviceinfo.h
@@ -1,8 +1,8 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/picturetransfer/Button.qml b/examples/bluetooth/picturetransfer/Button.qml
index eed6a4e9..2c5afb0b 100644
--- a/examples/bluetooth/picturetransfer/Button.qml
+++ b/examples/bluetooth/picturetransfer/Button.qml
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/picturetransfer/DeviceDiscovery.qml b/examples/bluetooth/picturetransfer/DeviceDiscovery.qml
index 77391ec2..16d9972e 100644
--- a/examples/bluetooth/picturetransfer/DeviceDiscovery.qml
+++ b/examples/bluetooth/picturetransfer/DeviceDiscovery.qml
@@ -1,8 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/picturetransfer/FileSending.qml b/examples/bluetooth/picturetransfer/FileSending.qml
index 3a4a282f..bdd4167e 100644
--- a/examples/bluetooth/picturetransfer/FileSending.qml
+++ b/examples/bluetooth/picturetransfer/FileSending.qml
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/picturetransfer/PictureSelector.qml b/examples/bluetooth/picturetransfer/PictureSelector.qml
index ca81ae44..5626cf64 100644
--- a/examples/bluetooth/picturetransfer/PictureSelector.qml
+++ b/examples/bluetooth/picturetransfer/PictureSelector.qml
@@ -1,8 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/picturetransfer/bttransfer.qml b/examples/bluetooth/picturetransfer/bttransfer.qml
index bdfb47f0..87dd70fb 100644
--- a/examples/bluetooth/picturetransfer/bttransfer.qml
+++ b/examples/bluetooth/picturetransfer/bttransfer.qml
@@ -1,8 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/picturetransfer/doc/src/picturetransfer.qdoc b/examples/bluetooth/picturetransfer/doc/src/picturetransfer.qdoc
index 3b0218d4..f597819d 100644
--- a/examples/bluetooth/picturetransfer/doc/src/picturetransfer.qdoc
+++ b/examples/bluetooth/picturetransfer/doc/src/picturetransfer.qdoc
@@ -1,7 +1,7 @@
a/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the QtBluetooth module.
**
@@ -10,15 +10,15 @@ a/****************************************************************************
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
+** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
diff --git a/examples/bluetooth/picturetransfer/filetransfer.cpp b/examples/bluetooth/picturetransfer/filetransfer.cpp
index 6f0a25b2..2051f69c 100644
--- a/examples/bluetooth/picturetransfer/filetransfer.cpp
+++ b/examples/bluetooth/picturetransfer/filetransfer.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/picturetransfer/filetransfer.h b/examples/bluetooth/picturetransfer/filetransfer.h
index 1bc9c78d..5fb65bd4 100644
--- a/examples/bluetooth/picturetransfer/filetransfer.h
+++ b/examples/bluetooth/picturetransfer/filetransfer.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/picturetransfer/main.cpp b/examples/bluetooth/picturetransfer/main.cpp
index cad9c66c..1ce3112e 100644
--- a/examples/bluetooth/picturetransfer/main.cpp
+++ b/examples/bluetooth/picturetransfer/main.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/pingpong/assets/Board.qml b/examples/bluetooth/pingpong/assets/Board.qml
index 65e06e66..0adf6508 100644
--- a/examples/bluetooth/pingpong/assets/Board.qml
+++ b/examples/bluetooth/pingpong/assets/Board.qml
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/pingpong/assets/Dialog.qml b/examples/bluetooth/pingpong/assets/Dialog.qml
index da7f09d2..2a332715 100644
--- a/examples/bluetooth/pingpong/assets/Dialog.qml
+++ b/examples/bluetooth/pingpong/assets/Dialog.qml
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/pingpong/assets/Menu.qml b/examples/bluetooth/pingpong/assets/Menu.qml
index b14c7b2d..b7516262 100644
--- a/examples/bluetooth/pingpong/assets/Menu.qml
+++ b/examples/bluetooth/pingpong/assets/Menu.qml
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/pingpong/assets/main.qml b/examples/bluetooth/pingpong/assets/main.qml
index 2a155662..7b62f0bd 100644
--- a/examples/bluetooth/pingpong/assets/main.qml
+++ b/examples/bluetooth/pingpong/assets/main.qml
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/pingpong/doc/src/pingpong.qdoc b/examples/bluetooth/pingpong/doc/src/pingpong.qdoc
index 0e82a71a..1fabdf5c 100644
--- a/examples/bluetooth/pingpong/doc/src/pingpong.qdoc
+++ b/examples/bluetooth/pingpong/doc/src/pingpong.qdoc
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
@@ -10,15 +10,15 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
+** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
diff --git a/examples/bluetooth/pingpong/main.cpp b/examples/bluetooth/pingpong/main.cpp
index 86cbb8bf..d2a84440 100644
--- a/examples/bluetooth/pingpong/main.cpp
+++ b/examples/bluetooth/pingpong/main.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/pingpong/pingpong.cpp b/examples/bluetooth/pingpong/pingpong.cpp
index 423eced4..ab6ba8c7 100644
--- a/examples/bluetooth/pingpong/pingpong.cpp
+++ b/examples/bluetooth/pingpong/pingpong.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/pingpong/pingpong.h b/examples/bluetooth/pingpong/pingpong.h
index 17fe176b..650cd597 100644
--- a/examples/bluetooth/pingpong/pingpong.h
+++ b/examples/bluetooth/pingpong/pingpong.h
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/scanner/Button.qml b/examples/bluetooth/scanner/Button.qml
index 17fb38b5..566f539f 100644
--- a/examples/bluetooth/scanner/Button.qml
+++ b/examples/bluetooth/scanner/Button.qml
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/scanner/doc/src/scanner.qdoc b/examples/bluetooth/scanner/doc/src/scanner.qdoc
index f4e292a8..da5e55da 100644
--- a/examples/bluetooth/scanner/doc/src/scanner.qdoc
+++ b/examples/bluetooth/scanner/doc/src/scanner.qdoc
@@ -1,8 +1,8 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2013 Aaron McCarthy <mccarthy.aaron@gmail.com>
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt local connectivty modules.
**
@@ -11,15 +11,15 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
+** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
diff --git a/examples/bluetooth/scanner/qmlscanner.cpp b/examples/bluetooth/scanner/qmlscanner.cpp
index 5c09c8f3..fe961511 100644
--- a/examples/bluetooth/scanner/qmlscanner.cpp
+++ b/examples/bluetooth/scanner/qmlscanner.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/bluetooth/scanner/scanner.qml b/examples/bluetooth/scanner/scanner.qml
index 543e19de..10eeb83a 100644
--- a/examples/bluetooth/scanner/scanner.qml
+++ b/examples/bluetooth/scanner/scanner.qml
@@ -1,8 +1,8 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtBluetooth module.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/nfc/annotatedurl/annotatedurl.cpp b/examples/nfc/annotatedurl/annotatedurl.cpp
index f29045b6..cd35c4ef 100644
--- a/examples/nfc/annotatedurl/annotatedurl.cpp
+++ b/examples/nfc/annotatedurl/annotatedurl.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
@@ -40,6 +40,7 @@
#include "annotatedurl.h"
+#include <qnearfieldmanager.h>
#include <qnearfieldtarget.h>
#include <qndefmessage.h>
#include <qndefrecord.h>
@@ -53,14 +54,61 @@
#include <QLabel>
#include <QMouseEvent>
#include <QDesktopServices>
+#include <QDebug>
AnnotatedUrl::AnnotatedUrl(QObject *parent)
: QObject(parent)
{
+ //! [QNearFieldManager register handler]
+ manager = new QNearFieldManager(this);
+ if (!manager->isAvailable()) {
+ qWarning() << "NFC not available";
+ return;
+ }
+
+ QNdefFilter filter;
+ filter.setOrderMatch(false);
+ filter.appendRecord<QNdefNfcTextRecord>(1, UINT_MAX);
+ filter.appendRecord<QNdefNfcUriRecord>();
+ int result = manager->registerNdefMessageHandler(filter, this,
+ SLOT(handleMessage(QNdefMessage,QNearFieldTarget*)));
+ //! [QNearFieldManager register handler]
+
+ if (result != -1)
+ return;
+
+ manager->startTargetDetection();
+ connect(manager, SIGNAL(targetDetected(QNearFieldTarget*)),
+ this, SLOT(targetDetected(QNearFieldTarget*)));
+ connect(manager, SIGNAL(targetLost(QNearFieldTarget*)),
+ this, SLOT(targetLost(QNearFieldTarget*)));
}
AnnotatedUrl::~AnnotatedUrl()
{
+
+}
+
+void AnnotatedUrl::targetDetected(QNearFieldTarget *target)
+{
+ if (!target)
+ return;
+
+ connect(target, SIGNAL(ndefMessageRead(QNdefMessage)),
+ this, SLOT(handlePolledNdefMessage(QNdefMessage)));
+ target->readNdefMessages();
+}
+
+void AnnotatedUrl::targetLost(QNearFieldTarget *target)
+{
+ if (target)
+ target->deleteLater();
+}
+
+void AnnotatedUrl::handlePolledNdefMessage(QNdefMessage message)
+{
+ QNearFieldTarget *target = qobject_cast<QNearFieldTarget *>(sender());
+ handleMessage(message, target);
}
//! [handleMessage 1]
diff --git a/examples/nfc/annotatedurl/annotatedurl.h b/examples/nfc/annotatedurl/annotatedurl.h
index 863f0976..08e5b38e 100644
--- a/examples/nfc/annotatedurl/annotatedurl.h
+++ b/examples/nfc/annotatedurl/annotatedurl.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
@@ -42,16 +42,14 @@
#define ANNOTATEDURL_H
#include <qnfcglobal.h>
+#include <QNdefMessage>
#include <QtCore/QObject>
QT_FORWARD_DECLARE_CLASS(QUrl)
QT_FORWARD_DECLARE_CLASS(QPixmap)
-
-QT_BEGIN_NAMESPACE
-class QNearFieldTarget;
-class QNdefMessage;
-QT_END_NAMESPACE
+QT_FORWARD_DECLARE_CLASS(QNearFieldManager)
+QT_FORWARD_DECLARE_CLASS(QNearFieldTarget)
QT_USE_NAMESPACE
@@ -67,7 +65,12 @@ signals:
void annotatedUrl(const QUrl &url, const QString &title, const QPixmap &pixmap);
public slots:
+ void targetDetected(QNearFieldTarget *target);
+ void targetLost(QNearFieldTarget *target);
void handleMessage(const QNdefMessage &message, QNearFieldTarget *target);
+ void handlePolledNdefMessage(QNdefMessage message);
+private:
+ QNearFieldManager *manager;
};
#endif // ANNOTATEDURL_H
diff --git a/examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc b/examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc
index 08001fdf..a6ed6b34 100644
--- a/examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc
+++ b/examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt local connectivty modules.
**
@@ -10,15 +10,15 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
+** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
diff --git a/examples/nfc/annotatedurl/main.cpp b/examples/nfc/annotatedurl/main.cpp
index 351f33bf..f46d303e 100644
--- a/examples/nfc/annotatedurl/main.cpp
+++ b/examples/nfc/annotatedurl/main.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
@@ -57,18 +57,8 @@ int main(int argc, char *argv[])
QApplication a(argc, argv);
MainWindow mainWindow;
- //! [QNearFieldManager register handler]
- QNearFieldManager manager;
AnnotatedUrl annotatedUrl;
- QNdefFilter filter;
- filter.setOrderMatch(false);
- filter.appendRecord<QNdefNfcTextRecord>(1, UINT_MAX);
- filter.appendRecord<QNdefNfcUriRecord>();
- manager.registerNdefMessageHandler(filter, &annotatedUrl,
- SLOT(handleMessage(QNdefMessage,QNearFieldTarget*)));
- //! [QNearFieldManager register handler]
-
QObject::connect(&annotatedUrl, SIGNAL(annotatedUrl(QUrl,QString,QPixmap)),
&mainWindow, SLOT(displayAnnotatedUrl(QUrl,QString,QPixmap)));
diff --git a/examples/nfc/annotatedurl/mainwindow.cpp b/examples/nfc/annotatedurl/mainwindow.cpp
index 6ec256db..b0c7fc18 100644
--- a/examples/nfc/annotatedurl/mainwindow.cpp
+++ b/examples/nfc/annotatedurl/mainwindow.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/nfc/annotatedurl/mainwindow.h b/examples/nfc/annotatedurl/mainwindow.h
index b038be4a..0d367171 100644
--- a/examples/nfc/annotatedurl/mainwindow.h
+++ b/examples/nfc/annotatedurl/mainwindow.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/nfc/corkboard/Mode.qml b/examples/nfc/corkboard/Mode.qml
index a3df4448..81c42682 100644
--- a/examples/nfc/corkboard/Mode.qml
+++ b/examples/nfc/corkboard/Mode.qml
@@ -1,8 +1,8 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtNfc module.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
@@ -39,110 +39,101 @@
**
****************************************************************************/
-import QtQuick 2.1
+import QtQuick 2.4
Item {
id: page
width: ListView.view.width;
height: ListView.view.height
- Rectangle {
- id: frame
- anchors.fill: parent
- z: 1
- color: "transparent"
- border.color: "darkred"
- border.width: 10
- }
Image {
source: "qrc:/cork.jpg"
- width: listView.width
- height: listView.height
+ anchors.centerIn: parent
+ width: parent.width - 20
+ height: parent.height - 20
fillMode: Image.PreserveAspectCrop
- }
-
- Text {
- anchors { horizontalCenter: parent.horizontalCenter; top: parent.top; topMargin: 10}
- text: name;
- font.pixelSize: 30; font.bold: true; color: "white"
- style: Text.Outline; styleColor: "black"
- }
-
- Repeater {
- model: notes
- Item {
- id: stickyPage
- z: 2
-
- x: Math.random() * (listView.width-listView.width*0.30) + listView.width*0.10
- y: Math.random() * (listView.height-listView.height*0.30) + listView.height*0.10
- rotation: -listView.horizontalVelocity / 200;
- Behavior on rotation {
- SpringAnimation { spring: 2.0; damping: 0.15 }
- }
+ Text {
+ anchors { horizontalCenter: parent.horizontalCenter; top: parent.top; topMargin: 10}
+ text: name;
+ font.pixelSize: 30; font.bold: true; color: "white"
+ style: Text.Outline; styleColor: "black"
+ }
+ Repeater {
+ model: notes
Item {
- id: sticky
- scale: mouse.pressed ? 1 : 0.7
- rotation: mouse.pressed ? 8 : 0
- Behavior on rotation{
- NumberAnimation {duration: 200 }
- }
- Behavior on scale{
- NumberAnimation { duration: 200 }
- }
+ id: stickyPage
- Image {
- id: stickyImage
- x: 8 + -width * 0.6 / 2; y: -20
- source: "qrc:/note-yellow.png"
- scale: 0.6; transformOrigin: Item.TopLeft
- smooth: true
- }
+ x: Math.random() * (listView.width-listView.width*0.30) + listView.width*0.10
+ y: Math.random() * (listView.height-listView.height*0.30) + listView.height*0.10
- TextEdit {
- id: myText
- text: noteText
- x: -104; y: 36; width: 215; height: 200
- smooth: true
- font.pixelSize: 24
- readOnly: false
- rotation: -8
- wrapMode: TextEdit.Wrap
+ rotation: -listView.horizontalVelocity / 200;
+ Behavior on rotation {
+ SpringAnimation { spring: 2.0; damping: 0.15 }
}
Item {
- id: interactionItem
- x: stickyImage.x; y: -20
- width: stickyImage.width * stickyImage.scale
- height: stickyImage.height * stickyImage.scale
-
- MouseArea {
- id: mouse
- anchors.fill: parent
- drag.target: stickyPage
- drag.axis: Drag.XandYAxis
+ id: sticky
+ scale: mouse.pressed ? 1 : 0.7
+ rotation: mouse.pressed ? 8 : 0
+ Behavior on rotation{
+ NumberAnimation {duration: 200 }
}
+ Behavior on scale{
+ NumberAnimation { duration: 200 }
+ }
+
Image {
- id: writeButton
- source: "qrc:/NfcFlag.png"
- rotation: -8 // Note image itself is rotated
- anchors { bottom: parent.bottom; right:parent.right }
- scale: flagMouse.pressed ? 1.3 : 1
+ id: stickyImage
+ x: 8 + -width * 0.6 / 2; y: -20
+ source: "qrc:/note-yellow.png"
+ scale: 0.6; transformOrigin: Item.TopLeft
+ smooth: true
+ }
+
+ TextEdit {
+ id: myText
+ text: noteText
+ x: -104; y: 36; width: 215; height: 200
+ smooth: true
+ font.pixelSize: 24
+ readOnly: false
+ rotation: -8
+ wrapMode: TextEdit.Wrap
+ }
+
+ Item {
+ id: interactionItem
+ x: stickyImage.x; y: -20
+ width: stickyImage.width * stickyImage.scale
+ height: stickyImage.height * stickyImage.scale
+
MouseArea {
- id: flagMouse
+ id: mouse
anchors.fill: parent
- //onClicked: { }
+ drag.target: stickyPage
+ drag.axis: Drag.XandYAxis
+ }
+ Image {
+ id: writeButton
+ source: "qrc:/NfcFlag.png"
+ rotation: -8 // Note image itself is rotated
+ anchors { bottom: parent.bottom; right:parent.right }
+ scale: flagMouse.pressed ? 1.3 : 1
+ MouseArea {
+ id: flagMouse
+ anchors.fill: parent
+ }
}
}
}
- }
- Image {
- x: -width / 2; y: -height * 0.5 / 2
- source: "qrc:/tack.png"
- scale: 0.7; transformOrigin: Item.TopLeft
+ Image {
+ x: -width / 2; y: -height * 0.5 / 2
+ source: "qrc:/tack.png"
+ scale: 0.7; transformOrigin: Item.TopLeft
+ }
}
}
}
diff --git a/examples/nfc/corkboard/corkboards.qml b/examples/nfc/corkboard/corkboards.qml
index 55c83723..2f00bb5a 100644
--- a/examples/nfc/corkboard/corkboards.qml
+++ b/examples/nfc/corkboard/corkboards.qml
@@ -1,8 +1,8 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtNfc module.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
@@ -39,18 +39,50 @@
**
****************************************************************************/
-import QtQuick 2.1
-import QtNfc 5.2
+import QtQuick 2.3
+import QtNfc 5.5
Rectangle {
width: 800; height: 480
- color: "black"
+ color: "darkred"
NearField {
+ property bool requiresManualPolling: false
orderMatch: false
onMessageRecordsChanged: {
- list.get(listView.currentIndex).notes.append({"noteText":messageRecords[0].text})
+ var i;
+ for (i = 0; i < messageRecords.length; ++i) {
+ var data = "";
+ if (messageRecords[i].typeNameFormat === NdefRecord.NfcRtd) {
+ if (messageRecords[i].type === "T") {
+ data = messageRecords[i].text;
+ } else if (messageRecords[i].type === "U") {
+ data = messageRecords[i].uri;
+ }
+ }
+ if (!data)
+ data = "Unknown content";
+
+ list.get(listView.currentIndex).notes.append( {
+ "noteText":data
+ })
+ }
+ }
+
+ onPollingChanged: {
+ if (!polling && requiresManualPolling)
+ polling = true; //restart polling
+ }
+
+ Component.onCompleted: {
+ // Polling should be true if
+ // QNearFieldManager::registerNdefMessageHandler() was successful;
+ // otherwise the platform requires manual polling mode.
+ if (!polling) {
+ requiresManualPolling = true;
+ polling = true;
+ }
}
}
@@ -60,7 +92,6 @@ Rectangle {
ListElement {
name: "Personal"
notes: [
- ListElement { noteText: "https://developer.blackberry.com" },
ListElement { noteText: "Near Field Communication" },
ListElement { noteText: "Touch a tag and its contents will appear as a new note" }
]
diff --git a/examples/nfc/corkboard/doc/src/corkboard.qdoc b/examples/nfc/corkboard/doc/src/corkboard.qdoc
index db982d2e..46179107 100644
--- a/examples/nfc/corkboard/doc/src/corkboard.qdoc
+++ b/examples/nfc/corkboard/doc/src/corkboard.qdoc
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtNfc module.
**
@@ -10,15 +10,15 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
+** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
diff --git a/examples/nfc/corkboard/main.cpp b/examples/nfc/corkboard/main.cpp
index 044c083f..320412ff 100644
--- a/examples/nfc/corkboard/main.cpp
+++ b/examples/nfc/corkboard/main.cpp
@@ -1,8 +1,8 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the QtNfc module.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc b/examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc
index 3ebc5525..51801609 100644
--- a/examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc
+++ b/examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt local connectivty modules.
**
@@ -10,15 +10,15 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
+** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
diff --git a/examples/nfc/ndefeditor/main.cpp b/examples/nfc/ndefeditor/main.cpp
index 05bc2bb1..c60517dc 100644
--- a/examples/nfc/ndefeditor/main.cpp
+++ b/examples/nfc/ndefeditor/main.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/nfc/ndefeditor/mainwindow.cpp b/examples/nfc/ndefeditor/mainwindow.cpp
index 527ff6c7..28c2054a 100644
--- a/examples/nfc/ndefeditor/mainwindow.cpp
+++ b/examples/nfc/ndefeditor/mainwindow.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
@@ -235,6 +235,8 @@ void MainWindow::targetDetected(QNearFieldTarget *target)
this, SLOT(targetError(QNearFieldTarget::Error,QNearFieldTarget::RequestId)));
m_request = target->readNdefMessages();
+ if (!m_request.isValid()) // cannot read messages
+ targetError(QNearFieldTarget::NdefReadError, m_request);
break;
case WriteNdef:
connect(target, SIGNAL(ndefMessagesWritten()), this, SLOT(ndefMessageWritten()));
@@ -242,6 +244,8 @@ void MainWindow::targetDetected(QNearFieldTarget *target)
this, SLOT(targetError(QNearFieldTarget::Error,QNearFieldTarget::RequestId)));
m_request = target->writeNdefMessages(QList<QNdefMessage>() << ndefMessage());
+ if (!m_request.isValid()) // cannot write messages
+ targetError(QNearFieldTarget::NdefWriteError, m_request);
break;
}
}
diff --git a/examples/nfc/ndefeditor/mainwindow.h b/examples/nfc/ndefeditor/mainwindow.h
index 69e1e50f..374b2ee3 100644
--- a/examples/nfc/ndefeditor/mainwindow.h
+++ b/examples/nfc/ndefeditor/mainwindow.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/nfc/ndefeditor/mimeimagerecordeditor.cpp b/examples/nfc/ndefeditor/mimeimagerecordeditor.cpp
index 1b84ab4d..5ed733a4 100644
--- a/examples/nfc/ndefeditor/mimeimagerecordeditor.cpp
+++ b/examples/nfc/ndefeditor/mimeimagerecordeditor.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
@@ -134,6 +134,7 @@ void MimeImageRecordEditor::on_mimeImageOpen_clicked()
ui->mimeImageFile->setText(mimeDataFile);
ui->mimeImageImage->setPixmap(QPixmap::fromImage(image));
+ m_record.setTypeNameFormat(QNdefRecord::Mime);
m_record.setType(mimeType.toLatin1());
m_record.setPayload(imageData);
}
diff --git a/examples/nfc/ndefeditor/mimeimagerecordeditor.h b/examples/nfc/ndefeditor/mimeimagerecordeditor.h
index 150f11cd..996cabc3 100644
--- a/examples/nfc/ndefeditor/mimeimagerecordeditor.h
+++ b/examples/nfc/ndefeditor/mimeimagerecordeditor.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/nfc/ndefeditor/textrecordeditor.cpp b/examples/nfc/ndefeditor/textrecordeditor.cpp
index 9015aeee..77e8a085 100644
--- a/examples/nfc/ndefeditor/textrecordeditor.cpp
+++ b/examples/nfc/ndefeditor/textrecordeditor.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/nfc/ndefeditor/textrecordeditor.h b/examples/nfc/ndefeditor/textrecordeditor.h
index 0da016ee..2699cdb5 100644
--- a/examples/nfc/ndefeditor/textrecordeditor.h
+++ b/examples/nfc/ndefeditor/textrecordeditor.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/nfc/ndefeditor/urirecordeditor.cpp b/examples/nfc/ndefeditor/urirecordeditor.cpp
index fa4f9ca0..4ea12768 100644
--- a/examples/nfc/ndefeditor/urirecordeditor.cpp
+++ b/examples/nfc/ndefeditor/urirecordeditor.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/nfc/ndefeditor/urirecordeditor.h b/examples/nfc/ndefeditor/urirecordeditor.h
index aaf46b9a..156b5147 100644
--- a/examples/nfc/ndefeditor/urirecordeditor.h
+++ b/examples/nfc/ndefeditor/urirecordeditor.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/examples/nfc/poster/doc/src/poster.qdoc b/examples/nfc/poster/doc/src/poster.qdoc
index 05cfd6d3..a569f47a 100644
--- a/examples/nfc/poster/doc/src/poster.qdoc
+++ b/examples/nfc/poster/doc/src/poster.qdoc
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt local connectivty modules.
**
@@ -10,15 +10,15 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
+** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
diff --git a/examples/nfc/poster/poster.qml b/examples/nfc/poster/poster.qml
index e2c67dd9..89e6af19 100644
--- a/examples/nfc/poster/poster.qml
+++ b/examples/nfc/poster/poster.qml
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
@@ -38,8 +38,8 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtNfc 5.2
+import QtQuick 2.3
+import QtNfc 5.5
Rectangle {
id: root
@@ -48,6 +48,19 @@ Rectangle {
NearField {
id: nearfield
+ property bool requiresManualPolling: false
+
+ onPollingChanged: {
+ if (!polling && requiresManualPolling)
+ polling = true; //restart polling
+ }
+
+ Component.onCompleted: {
+ if (!polling) {
+ requiresManualPolling = true;
+ polling = true;
+ }
+ }
filter: [
NdefFilter { type: "U"; typeNameFormat: NdefRecord.NfcRtd; minimum: 1; maximum: 1 },
@@ -61,17 +74,32 @@ Rectangle {
var currentLocaleMatch = NdefTextRecord.LocaleMatchedNone;
var i;
+ var found = false;
for (i = 0; i < messageRecords.length; ++i) {
- if (messageRecords[i].recordType == "urn:nfc:wkt:T") {
- if (messageRecords[i].localeMatch > currentLocaleMatch) {
- currentLocaleMatch = messageRecords[i].localeMatch;
- posterText.text = messageRecords[i].text;
+ switch (messageRecords[i].typeNameFormat) {
+ case NdefRecord.NfcRtd:
+ if (messageRecords[i].type === "T") {
+ if (messageRecords[i].localeMatch > currentLocaleMatch) {
+ currentLocaleMatch = messageRecords[i].localeMatch;
+ posterText.text = messageRecords[i].text;
+ found = true;
+ }
+
+ } else if (messageRecords[i].type === "U") {
+ posterUrl.text = messageRecords[i].uri;
+ found = true;
+ }
+ break;
+ case NdefRecord.Mime:
+ if (messageRecords[i].type.indexOf("image/") === 0 ) {
+ posterImage.source = messageRecords[i].uri;
+ found = true;
}
- } else if (messageRecords[i].recordType == "urn:nfc:wkt:U") {
- posterUrl.text = messageRecords[i].uri;
- } else if (messageRecords[i].recordType.substr(0, 19) == "urn:nfc:mime:image/") {
- posterImage.source = messageRecords[i].uri;
+ break;
}
+
+ if (!found)
+ console.warn("Unknown NFC tag detected. Cannot display content.")
}
root.state = "show";
@@ -87,15 +115,6 @@ Rectangle {
font.pointSize: 18
}
- Text {
- id: posterText
- anchors.horizontalCenter: parent.right
- anchors.horizontalCenterOffset: - parent.width / 4
- y: -height
- font.bold: true
- font.pointSize: 18
- }
-
Image {
id: posterImage
scale: Image.PreserveAspectFit
@@ -107,6 +126,15 @@ Rectangle {
}
Text {
+ id: posterText
+ anchors.horizontalCenter: parent.right
+ anchors.horizontalCenterOffset: - parent.width / 4
+ y: -height
+ font.bold: true
+ font.pointSize: 18
+ }
+
+ Text {
id: posterUrl
anchors.horizontalCenter: parent.right
anchors.horizontalCenterOffset: - parent.width / 4
diff --git a/examples/nfc/poster/qmlposter.cpp b/examples/nfc/poster/qmlposter.cpp
index f6f3bbc8..eb96e1c2 100644
--- a/examples/nfc/poster/qmlposter.cpp
+++ b/examples/nfc/poster/qmlposter.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/src/android/bluetooth/bluetooth.pri b/src/android/bluetooth/bluetooth.pri
index b2121ff3..16d3b612 100644
--- a/src/android/bluetooth/bluetooth.pri
+++ b/src/android/bluetooth/bluetooth.pri
@@ -1,5 +1,6 @@
CONFIG += java
DESTDIR = $$[QT_INSTALL_PREFIX/get]/jar
+API_VERSION = android-18
PATHPREFIX = $$PWD/src/org/qtproject/qt5/android/bluetooth
@@ -7,8 +8,8 @@ JAVACLASSPATH += $$PWD/src/
JAVASOURCES += \
$$PATHPREFIX/QtBluetoothBroadcastReceiver.java \
$$PATHPREFIX/QtBluetoothSocketServer.java \
- $$PATHPREFIX/QtBluetoothInputStreamThread.java
-
+ $$PATHPREFIX/QtBluetoothInputStreamThread.java \
+ $$PATHPREFIX/QtBluetoothLE.java
# install
target.path = $$[QT_INSTALL_PREFIX]/jar
diff --git a/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothBroadcastReceiver.java b/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothBroadcastReceiver.java
index f12e68fa..57d92c03 100644
--- a/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothBroadcastReceiver.java
+++ b/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothBroadcastReceiver.java
@@ -1,8 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2013 Lauri Laanmets (Proekspert AS) <lauri.laanmets@eesti.ee>
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -40,7 +40,7 @@ import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
-import android.content.IntentFilter;
+
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.HashSet;
@@ -49,7 +49,9 @@ import java.util.List;
public class QtBluetoothBroadcastReceiver extends BroadcastReceiver
{
/* Pointer to the Qt object that "owns" the Java object */
+ @SuppressWarnings("WeakerAccess")
long qtObject = 0;
+ @SuppressWarnings("WeakerAccess")
static Activity qtactivity = null;
private static final int TURN_BT_ON = 3330;
@@ -158,11 +160,11 @@ public class QtBluetoothBroadcastReceiver extends BroadcastReceiver
//process found remote connections but avoid duplications
HashSet<String> set = new HashSet<String>();
- for (int i = 0; i < gattConnections.size(); i++)
- set.add(gattConnections.get(i).toString());
+ for (Object gattConnection : gattConnections)
+ set.add(gattConnection.toString());
- for (int i = 0; i < gattServerConnections.size(); i++)
- set.add(gattServerConnections.get(i).toString());
+ for (Object gattServerConnection : gattServerConnections)
+ set.add(gattServerConnection.toString());
return set.toArray(new String[set.size()]);
} catch (Exception ex) {
diff --git a/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothInputStreamThread.java b/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothInputStreamThread.java
index 30ada8c9..90cacdb6 100644
--- a/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothInputStreamThread.java
+++ b/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothInputStreamThread.java
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -37,10 +37,13 @@ import java.io.InputStream;
import java.io.IOException;
import android.util.Log;
+@SuppressWarnings("WeakerAccess")
public class QtBluetoothInputStreamThread extends Thread
{
/* Pointer to the Qt object that "owns" the Java object */
+ @SuppressWarnings("CanBeFinal")
long qtObject = 0;
+ @SuppressWarnings("CanBeFinal")
public boolean logEnabled = false;
private static final String TAG = "QtBluetooth";
private InputStream m_inputStream = null;
@@ -68,7 +71,7 @@ public class QtBluetoothInputStreamThread extends Thread
}
byte[] buffer = new byte[1000];
- int bytesRead = 0;
+ int bytesRead;
try {
while (!isInterrupted()) {
diff --git a/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java b/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java
new file mode 100644
index 00000000..e5711426
--- /dev/null
+++ b/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java
@@ -0,0 +1,1126 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
+ **
+ ** This file is part of the QtBluetooth module of the Qt Toolkit.
+ **
+ ** $QT_BEGIN_LICENSE:LGPL21$
+ ** Commercial License Usage
+ ** Licensees holding valid commercial Qt licenses may use this file in
+ ** accordance with the commercial license agreement provided with the
+ ** Software or, alternatively, in accordance with the terms contained in
+ ** a written agreement between you and The Qt Company. For licensing terms
+ ** and conditions see http://www.qt.io/terms-conditions. For further
+ ** information use the contact form at http://www.qt.io/contact-us.
+ **
+ ** GNU Lesser General Public License Usage
+ ** Alternatively, this file may be used under the terms of the GNU Lesser
+ ** General Public License version 2.1 or version 3 as published by the Free
+ ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+ ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+ ** following information to ensure the GNU Lesser General Public License
+ ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+ ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+ **
+ ** As a special exception, The Qt Company gives you certain additional
+ ** rights. These rights are described in The Qt Company LGPL Exception
+ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+ **
+ ** $QT_END_LICENSE$
+ **
+ ****************************************************************************/
+
+package org.qtproject.qt5.android.bluetooth;
+
+import android.app.Activity;
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothGatt;
+import android.bluetooth.BluetoothGattCallback;
+import android.bluetooth.BluetoothGattCharacteristic;
+import android.bluetooth.BluetoothGattDescriptor;
+import android.bluetooth.BluetoothGattService;
+import android.bluetooth.BluetoothProfile;
+import android.util.Log;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.UUID;
+
+public class QtBluetoothLE {
+ private static final String TAG = "QtBluetoothGatt";
+ private final BluetoothAdapter mBluetoothAdapter;
+ private boolean mLeScanRunning = false;
+
+ private BluetoothGatt mBluetoothGatt = null;
+ private String mRemoteGattAddress;
+ private final UUID clientCharacteristicUuid = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb");
+
+
+ /* Pointer to the Qt object that "owns" the Java object */
+ @SuppressWarnings({"CanBeFinal", "WeakerAccess"})
+ long qtObject = 0;
+ @SuppressWarnings("WeakerAccess")
+ Activity qtactivity = null;
+
+ @SuppressWarnings("WeakerAccess")
+ public QtBluetoothLE() {
+ mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+ }
+
+ public QtBluetoothLE(final String remoteAddress, Activity activity) {
+ this();
+ qtactivity = activity;
+ mRemoteGattAddress = remoteAddress;
+ }
+
+
+ /*************************************************************/
+ /* Device scan */
+ /*************************************************************/
+
+ /*
+ Returns true, if request was successfully completed
+ */
+ public boolean scanForLeDevice(final boolean isEnabled) {
+ if (isEnabled == mLeScanRunning)
+ return true;
+
+ if (isEnabled) {
+ mLeScanRunning = mBluetoothAdapter.startLeScan(leScanCallback);
+ } else {
+ mBluetoothAdapter.stopLeScan(leScanCallback);
+ mLeScanRunning = false;
+ }
+
+ return (mLeScanRunning == isEnabled);
+ }
+
+ // Device scan callback
+ private final BluetoothAdapter.LeScanCallback leScanCallback =
+ new BluetoothAdapter.LeScanCallback() {
+
+ @Override
+ public void onLeScan(final BluetoothDevice device, int rssi, byte[] scanRecord) {
+ if (qtObject == 0)
+ return;
+
+ leScanResult(qtObject, device, rssi);
+ }
+ };
+
+ public native void leScanResult(long qtObject, BluetoothDevice device, int rssi);
+
+ /*************************************************************/
+ /* Service Discovery */
+ /*************************************************************/
+
+ private final BluetoothGattCallback gattCallback = new BluetoothGattCallback() {
+
+ public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
+ if (qtObject == 0)
+ return;
+
+ int qLowEnergyController_State = 0;
+ //This must be in sync with QLowEnergyController::ControllerState
+ switch (newState) {
+ case BluetoothProfile.STATE_DISCONNECTED:
+ qLowEnergyController_State = 0;
+ // we disconnected -> get rid of data from previous run
+ resetData();
+ // reset mBluetoothGatt, reusing same object is not very reliable
+ // sometimes it reconnects and sometimes it does not.
+ if (mBluetoothGatt != null)
+ mBluetoothGatt.close();
+ mBluetoothGatt = null;
+ break;
+ case BluetoothProfile.STATE_CONNECTED:
+ qLowEnergyController_State = 2;
+ }
+
+ //This must be in sync with QLowEnergyController::Error
+ int errorCode;
+ switch (status) {
+ case BluetoothGatt.GATT_SUCCESS:
+ errorCode = 0; break; //QLowEnergyController::NoError
+ default:
+ Log.w(TAG, "Unhandled error code on connectionStateChanged: " + status);
+ errorCode = status; break; //TODO deal with all errors
+ }
+ leConnectionStateChange(qtObject, errorCode, qLowEnergyController_State);
+ }
+
+ public void onServicesDiscovered(BluetoothGatt gatt, int status) {
+ //This must be in sync with QLowEnergyController::Error
+ int errorCode;
+ StringBuilder builder = new StringBuilder();
+ switch (status) {
+ case BluetoothGatt.GATT_SUCCESS:
+ errorCode = 0; //QLowEnergyController::NoError
+ final List<BluetoothGattService> services = mBluetoothGatt.getServices();
+ for (BluetoothGattService service: services) {
+ builder.append(service.getUuid().toString()).append(" "); //space is separator
+ }
+ break;
+ default:
+ Log.w(TAG, "Unhandled error code on onServicesDiscovered: " + status);
+ errorCode = status; break; //TODO deal with all errors
+ }
+ leServicesDiscovered(qtObject, errorCode, builder.toString());
+ }
+
+ public void onCharacteristicRead(android.bluetooth.BluetoothGatt gatt,
+ android.bluetooth.BluetoothGattCharacteristic characteristic,
+ int status)
+ {
+ //runningHandle is only used during serviceDetailsDiscovery
+ //If it is -1 we got an update outside of the details discovery process
+ final boolean isServiceDiscoveryRun = (runningHandle != -1);
+
+ if (status != BluetoothGatt.GATT_SUCCESS) {
+ Log.w(TAG, "onCharacteristicRead error: " + status);
+
+ // read errors during serviceDiscovery are ignored
+ if (isServiceDiscoveryRun)
+ return;
+ }
+
+ synchronized (this) {
+ if (uuidToEntry.isEmpty()) // ignore data if internal setup is not ready;
+ return;
+ }
+
+ // once we have a service discovery run we report regular changes
+ if (!isServiceDiscoveryRun) {
+
+ int foundHandle = -1;
+ synchronized (this) {
+ foundHandle = handleForCharacteristic(characteristic);
+ }
+
+ synchronized (readWriteQueue) {
+ ioJobPending = false;
+ }
+
+ if (foundHandle == -1) {
+ Log.w(TAG, "Out-of-detail-discovery: char update failed. " +
+ "Cannot find handle for characteristic");
+ } else {
+ if (status == BluetoothGatt.GATT_SUCCESS) {
+ leCharacteristicRead(qtObject, characteristic.getService().getUuid().toString(),
+ foundHandle + 1, characteristic.getUuid().toString(),
+ characteristic.getProperties(), characteristic.getValue());
+ } else {
+ // This must be in sync with QLowEnergyService::CharacteristicReadError
+ final int characteristicReadError = 5;
+ leServiceError(qtObject, foundHandle + 1, characteristicReadError);
+ }
+ }
+
+ performNextIO();
+ return;
+ }
+
+ GattEntry entry = entries.get(runningHandle);
+ entry.valueKnown = true;
+ entries.set(runningHandle, entry);
+
+ // Qt manages handles starting at 1, in Java we use a system starting with 0
+ //TODO avoid sending service uuid -> service handle should be sufficient
+ leCharacteristicRead(qtObject, characteristic.getService().getUuid().toString(),
+ runningHandle + 1, characteristic.getUuid().toString(),
+ characteristic.getProperties(), characteristic.getValue());
+ performServiceDetailDiscoveryForHandle(runningHandle + 1, false);
+ }
+
+ public void onCharacteristicWrite(android.bluetooth.BluetoothGatt gatt,
+ android.bluetooth.BluetoothGattCharacteristic characteristic,
+ int status)
+ {
+ if (status != BluetoothGatt.GATT_SUCCESS)
+ Log.w(TAG, "onCharacteristicWrite: error " + status);
+
+ int handle = handleForCharacteristic(characteristic);
+ if (handle == -1) {
+ Log.w(TAG,"onCharacteristicWrite: cannot find handle");
+ return;
+ }
+
+ int errorCode;
+ //This must be in sync with QLowEnergyService::ServiceError
+ switch (status) {
+ case BluetoothGatt.GATT_SUCCESS:
+ errorCode = 0; break; // NoError
+ default:
+ errorCode = 2; break; // CharacteristicWriteError
+ }
+
+ synchronized (readWriteQueue) {
+ ioJobPending = false;
+ }
+ leCharacteristicWritten(qtObject, handle+1, characteristic.getValue(), errorCode);
+ performNextIO();
+ }
+
+ public void onCharacteristicChanged(android.bluetooth.BluetoothGatt gatt,
+ android.bluetooth.BluetoothGattCharacteristic characteristic)
+ {
+ int handle = handleForCharacteristic(characteristic);
+ if (handle == -1) {
+ Log.w(TAG,"onCharacteristicChanged: cannot find handle");
+ return;
+ }
+
+ leCharacteristicChanged(qtObject, handle+1, characteristic.getValue());
+ }
+
+ public void onDescriptorRead(android.bluetooth.BluetoothGatt gatt,
+ android.bluetooth.BluetoothGattDescriptor descriptor,
+ int status)
+ {
+ //runningHandle is only used during serviceDetailsDiscovery
+ //If it is -1 we got an update outside of the details discovery process
+ final boolean isServiceDiscoveryRun = (runningHandle != -1);
+
+ if (status != BluetoothGatt.GATT_SUCCESS) {
+ Log.w(TAG, "onDescriptorRead error: " + status);
+
+ // read errors during serviceDiscovery are ignored
+ if (isServiceDiscoveryRun)
+ return;
+ }
+
+ synchronized (this) {
+ if (uuidToEntry.isEmpty()) // ignore data if internal setup is not ready;
+ return;
+ }
+
+
+ if (!isServiceDiscoveryRun) {
+
+ int foundHandle = -1;
+ synchronized (this) {
+ foundHandle = handleForDescriptor(descriptor);
+ }
+
+ synchronized (readWriteQueue) {
+ ioJobPending = false;
+ }
+
+ if (foundHandle == -1) {
+ Log.w(TAG, "Out-of-detail-discovery: char update failed. " +
+ "Cannot find handle for descriptor.");
+ } else {
+ if (status == BluetoothGatt.GATT_SUCCESS) {
+ leDescriptorRead(qtObject, descriptor.getCharacteristic().getService().getUuid().toString(),
+ descriptor.getCharacteristic().getUuid().toString(), foundHandle + 1,
+ descriptor.getUuid().toString(), descriptor.getValue());
+ } else {
+ // This must be in sync with QLowEnergyService::DescriptorReadError
+ final int descriptorReadError = 6;
+ leServiceError(qtObject, foundHandle + 1, descriptorReadError);
+ }
+ }
+
+ performNextIO();
+ return;
+ }
+
+
+ GattEntry entry = entries.get(runningHandle);
+ entry.valueKnown = true;
+ entries.set(runningHandle, entry);
+ //TODO avoid sending service and characteristic uuid -> handles should be sufficient
+ leDescriptorRead(qtObject, descriptor.getCharacteristic().getService().getUuid().toString(),
+ descriptor.getCharacteristic().getUuid().toString(), runningHandle+1,
+ descriptor.getUuid().toString(), descriptor.getValue());
+
+ /* Some devices preset ClientCharacteristicConfiguration descriptors
+ * to enable notifications out of the box. However the additional
+ * BluetoothGatt.setCharacteristicNotification call prevents
+ * automatic notifications from coming through. Hence we manually set them
+ * up here.
+ */
+
+ if (descriptor.getUuid().compareTo(clientCharacteristicUuid) == 0) {
+ final int value = descriptor.getValue()[0];
+ // notification or indication bit set?
+ if ((value & 0x03) > 0) {
+ Log.d(TAG, "Found descriptor with automatic notifications.");
+ mBluetoothGatt.setCharacteristicNotification(
+ descriptor.getCharacteristic(), true);
+ }
+ }
+
+ performServiceDetailDiscoveryForHandle(runningHandle + 1, false);
+ }
+
+ public void onDescriptorWrite(android.bluetooth.BluetoothGatt gatt,
+ android.bluetooth.BluetoothGattDescriptor descriptor,
+ int status)
+ {
+ if (status != BluetoothGatt.GATT_SUCCESS)
+ Log.w(TAG, "onDescriptorWrite: error " + status);
+
+ int handle = handleForDescriptor(descriptor);
+
+ int errorCode;
+ //This must be in sync with QLowEnergyService::ServiceError
+ switch (status) {
+ case BluetoothGatt.GATT_SUCCESS:
+ errorCode = 0; break; // NoError
+ default:
+ errorCode = 3; break; // DescriptorWriteError
+ }
+
+ synchronized (readWriteQueue) {
+ ioJobPending = false;
+ }
+
+ leDescriptorWritten(qtObject, handle+1, descriptor.getValue(), errorCode);
+ performNextIO();
+ }
+ //TODO Requires Android API 21 which is not available on CI yet.
+// public void onReliableWriteCompleted(android.bluetooth.BluetoothGatt gatt,
+// int status) {
+// System.out.println("onReliableWriteCompleted");
+// }
+//
+// public void onReadRemoteRssi(android.bluetooth.BluetoothGatt gatt,
+// int rssi, int status) {
+// System.out.println("onReadRemoteRssi");
+// }
+
+ };
+
+
+ public boolean connect() {
+ BluetoothDevice mRemoteGattDevice;
+
+ try {
+ mRemoteGattDevice = mBluetoothAdapter.getRemoteDevice(mRemoteGattAddress);
+ } catch (IllegalArgumentException ex) {
+ Log.w(TAG, "Remote address is not valid: " + mRemoteGattAddress);
+ return false;
+ }
+
+ mBluetoothGatt = mRemoteGattDevice.connectGatt(qtactivity, false, gattCallback);
+ return mBluetoothGatt != null;
+ }
+
+ public void disconnect() {
+ if (mBluetoothGatt == null)
+ return;
+
+ mBluetoothGatt.disconnect();
+ }
+
+ public boolean discoverServices()
+ {
+ return mBluetoothGatt != null && mBluetoothGatt.discoverServices();
+ }
+
+ private enum GattEntryType
+ {
+ Service, Characteristic, CharacteristicValue, Descriptor
+ }
+ private class GattEntry
+ {
+ public GattEntryType type;
+ public boolean valueKnown = false;
+ public BluetoothGattService service = null;
+ public BluetoothGattCharacteristic characteristic = null;
+ public BluetoothGattDescriptor descriptor = null;
+ public int endHandle;
+ }
+
+ private enum IoJobType
+ {
+ Read, Write
+ }
+
+ private class ReadWriteJob
+ {
+ public GattEntry entry;
+ public byte[] newValue;
+ public int requestedWriteType;
+ public IoJobType jobType;
+ }
+
+ private final Hashtable<UUID, List<Integer>> uuidToEntry = new Hashtable<UUID, List<Integer>>(100);
+ private final ArrayList<GattEntry> entries = new ArrayList<GattEntry>(100);
+ private final LinkedList<Integer> servicesToBeDiscovered = new LinkedList<Integer>();
+
+
+ private final LinkedList<ReadWriteJob> readWriteQueue = new LinkedList<ReadWriteJob>();
+ private boolean ioJobPending;
+
+ /*
+ Internal helper function
+ Returns the handle id for the given characteristic; otherwise returns -1.
+
+ Note that this is the Java handle. The Qt handle is the Java handle +1.
+ */
+ private int handleForCharacteristic(BluetoothGattCharacteristic characteristic)
+ {
+ if (characteristic == null)
+ return -1;
+
+ List<Integer> handles = uuidToEntry.get(characteristic.getService().getUuid());
+ if (handles == null || handles.isEmpty())
+ return -1;
+
+ //TODO for now we assume we always want the first service in case of uuid collision
+ int serviceHandle = handles.get(0);
+
+ try {
+ GattEntry entry;
+ for (int i = serviceHandle+1; i < entries.size(); i++) {
+ entry = entries.get(i);
+ if (entry == null)
+ continue;
+
+ switch (entry.type) {
+ case Descriptor:
+ case CharacteristicValue:
+ continue;
+ case Service:
+ break;
+ case Characteristic:
+ if (entry.characteristic == characteristic)
+ return i;
+ break;
+ }
+ }
+ } catch (IndexOutOfBoundsException ex) { /*nothing*/ }
+ return -1;
+ }
+
+ /*
+ Internal helper function
+ Returns the handle id for the given descriptor; otherwise returns -1.
+
+ Note that this is the Java handle. The Qt handle is the Java handle +1.
+ */
+ private int handleForDescriptor(BluetoothGattDescriptor descriptor)
+ {
+ if (descriptor == null)
+ return -1;
+
+ List<Integer> handles = uuidToEntry.get(descriptor.getCharacteristic().getService().getUuid());
+ if (handles == null || handles.isEmpty())
+ return -1;
+
+ //TODO for now we assume we always want the first service in case of uuid collision
+ int serviceHandle = handles.get(0);
+
+ try {
+ GattEntry entry;
+ for (int i = serviceHandle+1; i < entries.size(); i++) {
+ entry = entries.get(i);
+ if (entry == null)
+ continue;
+
+ switch (entry.type) {
+ case Characteristic:
+ case CharacteristicValue:
+ continue;
+ case Service:
+ break;
+ case Descriptor:
+ if (entry.descriptor == descriptor)
+ return i;
+ break;
+ }
+ }
+ } catch (IndexOutOfBoundsException ignored) { }
+ return -1;
+ }
+
+ private void populateHandles()
+ {
+ // We introduce the notion of artificial handles. While GATT handles
+ // are not exposed on Android they help to quickly identify GATT attributes
+ // on the C++ side. The Qt Api will not expose the handles
+ GattEntry entry = null;
+ List<BluetoothGattService> services = mBluetoothGatt.getServices();
+ for (BluetoothGattService service: services) {
+ GattEntry serviceEntry = new GattEntry();
+ serviceEntry.type = GattEntryType.Service;
+ serviceEntry.service = service;
+ entries.add(entry);
+
+ // remember handle for the service for later update
+ int serviceHandle = entries.size() - 1;
+
+ //some devices may have more than one service with the same uuid
+ List<Integer> old = uuidToEntry.get(service.getUuid());
+ if (old == null)
+ old = new ArrayList<Integer>();
+ old.add(entries.size()-1);
+ uuidToEntry.put(service.getUuid(), old);
+
+ // add all characteristics
+ List<BluetoothGattCharacteristic> charList = service.getCharacteristics();
+ for (BluetoothGattCharacteristic characteristic: charList) {
+ entry = new GattEntry();
+ entry.type = GattEntryType.Characteristic;
+ entry.characteristic = characteristic;
+ entries.add(entry);
+
+ // this emulates GATT value attributes
+ entry = new GattEntry();
+ entry.type = GattEntryType.CharacteristicValue;
+ entries.add(entry);
+
+ // add all descriptors
+ List<BluetoothGattDescriptor> descList = characteristic.getDescriptors();
+ for (BluetoothGattDescriptor desc: descList) {
+ entry = new GattEntry();
+ entry.type = GattEntryType.Descriptor;
+ entry.descriptor = desc;
+ entries.add(entry);
+ }
+ }
+
+ // update endHandle of current service
+ serviceEntry.endHandle = entries.size() - 1;
+ entries.set(serviceHandle, serviceEntry);
+ }
+
+ entries.trimToSize();
+ }
+
+ private int currentServiceInDiscovery = -1;
+ private int runningHandle = -1;
+
+ private void resetData()
+ {
+ synchronized (this) {
+ runningHandle = -1;
+ currentServiceInDiscovery = -1;
+ uuidToEntry.clear();
+ entries.clear();
+ servicesToBeDiscovered.clear();
+ }
+ synchronized (readWriteQueue) {
+ readWriteQueue.clear();
+ }
+ }
+
+ public synchronized boolean discoverServiceDetails(String serviceUuid)
+ {
+ try {
+ if (mBluetoothGatt == null)
+ return false;
+
+ if (entries.isEmpty())
+ populateHandles();
+
+ GattEntry entry;
+ int serviceHandle;
+ try {
+ UUID service = UUID.fromString(serviceUuid);
+ List<Integer> handles = uuidToEntry.get(service);
+ if (handles == null || handles.isEmpty()) {
+ Log.w(TAG, "Unknown service uuid for current device: " + service.toString());
+ return false;
+ }
+
+ //TODO for now we assume we always want the first service in case of uuid collision
+ serviceHandle = handles.get(0);
+ entry = entries.get(serviceHandle);
+ if (entry == null) {
+ Log.w(TAG, "Service with UUID " + service.toString() + " not found");
+ return false;
+ }
+ } catch (IllegalArgumentException ex) {
+ //invalid UUID string passed
+ Log.w(TAG, "Cannot parse given UUID");
+ return false;
+ }
+
+ if (entry.type != GattEntryType.Service) {
+ Log.w(TAG, "Given UUID is not a service UUID: " + serviceUuid);
+ return false;
+ }
+
+ // current service already under investigation
+ if (currentServiceInDiscovery == serviceHandle)
+ return true;
+
+ if (currentServiceInDiscovery != -1) {
+ // we are currently discovering another service
+ // we queue the new one up until we finish the previous one
+ if (!entry.valueKnown) {
+ servicesToBeDiscovered.add(serviceHandle);
+ Log.w(TAG, "Service discovery already running on another service, " +
+ "queueing request for " + serviceUuid);
+ } else {
+ Log.w(TAG, "Service already known");
+ }
+ return true;
+ }
+
+ if (!entry.valueKnown) {
+ performServiceDetailDiscoveryForHandle(serviceHandle, true);
+ } else {
+ Log.w(TAG, "Service already discovered");
+ }
+
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ return false;
+ }
+
+ return true;
+ }
+
+ /*
+ Returns the uuids of the services included by the given service. Otherwise returns null.
+ Directly called from Qt.
+ */
+ public String includedServices(String serviceUuid)
+ {
+ UUID uuid;
+ try {
+ uuid = UUID.fromString(serviceUuid);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ return null;
+ }
+
+ //TODO Breaks in case of two services with same uuid
+ BluetoothGattService service = mBluetoothGatt.getService(uuid);
+ if (service == null)
+ return null;
+
+ final List<BluetoothGattService> includes = service.getIncludedServices();
+ if (includes.isEmpty())
+ return null;
+
+ StringBuilder builder = new StringBuilder();
+ for (BluetoothGattService includedService: includes) {
+ builder.append(includedService.getUuid().toString()).append(" "); //space is separator
+ }
+
+ return builder.toString();
+ }
+
+ private void finishCurrentServiceDiscovery()
+ {
+ int currentEntry = currentServiceInDiscovery;
+ GattEntry discoveredService = entries.get(currentServiceInDiscovery);
+ discoveredService.valueKnown = true;
+ entries.set(currentServiceInDiscovery, discoveredService);
+
+ runningHandle = -1;
+ currentServiceInDiscovery = -1;
+
+ leServiceDetailDiscoveryFinished(qtObject, discoveredService.service.getUuid().toString(),
+ currentEntry + 1, discoveredService.endHandle + 1);
+
+ if (!servicesToBeDiscovered.isEmpty()) {
+ try {
+ int nextService = servicesToBeDiscovered.remove();
+ performServiceDetailDiscoveryForHandle(nextService, true);
+ } catch (IndexOutOfBoundsException ex) {
+ Log.w(TAG, "Expected queued service but didn't find any");
+ }
+ }
+ }
+
+ private synchronized void performServiceDetailDiscoveryForHandle(int nextHandle, boolean searchStarted)
+ {
+ try {
+ if (searchStarted) {
+ currentServiceInDiscovery = nextHandle;
+ runningHandle = ++nextHandle;
+ } else {
+ runningHandle = nextHandle;
+ }
+
+ GattEntry entry;
+ try {
+ entry = entries.get(nextHandle);
+ } catch (IndexOutOfBoundsException ex) {
+ //ex.printStackTrace();
+ Log.w(TAG, "Last entry of last service read");
+ finishCurrentServiceDiscovery();
+ return;
+ }
+
+ boolean result;
+ switch (entry.type) {
+ case Characteristic:
+ result = mBluetoothGatt.readCharacteristic(entry.characteristic);
+ try {
+ if (!result) {
+ // add characteristic now since we won't get a read update later one
+ // this is possible when the characteristic is not readable
+ Log.d(TAG, "Non-readable characteristic " + entry.characteristic.getUuid() +
+ " for service " + entry.characteristic.getService().getUuid());
+ leCharacteristicRead(qtObject, entry.characteristic.getService().getUuid().toString(),
+ nextHandle + 1, entry.characteristic.getUuid().toString(),
+ entry.characteristic.getProperties(), entry.characteristic.getValue());
+ performServiceDetailDiscoveryForHandle(runningHandle + 1, false);
+ }
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ break;
+ case CharacteristicValue:
+ // ignore -> nothing to do for this artificial type
+ performServiceDetailDiscoveryForHandle(runningHandle + 1, false);
+ break;
+ case Descriptor:
+ result = mBluetoothGatt.readDescriptor(entry.descriptor);
+ if (!result) {
+ // atm all descriptor types are readable
+ Log.d(TAG, "Non-readable descriptor " + entry.descriptor.getUuid() +
+ " for service/char" + entry.descriptor.getCharacteristic().getService().getUuid() +
+ "/" + entry.descriptor.getCharacteristic().getUuid());
+ leDescriptorRead(qtObject,
+ entry.descriptor.getCharacteristic().getService().getUuid().toString(),
+ entry.descriptor.getCharacteristic().getUuid().toString(),
+ nextHandle+1, entry.descriptor.getUuid().toString(),
+ entry.descriptor.getValue());
+ performServiceDetailDiscoveryForHandle(runningHandle + 1, false);
+ }
+ break;
+ case Service:
+ finishCurrentServiceDiscovery();
+ break;
+ default:
+ Log.w(TAG, "Invalid GATT attribute type");
+ break;
+ }
+
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ /*************************************************************/
+ /* Write Characteristics */
+ /*************************************************************/
+
+ public boolean writeCharacteristic(int charHandle, byte[] newValue,
+ int writeMode)
+ {
+ if (mBluetoothGatt == null)
+ return false;
+
+ GattEntry entry;
+ try {
+ entry = entries.get(charHandle-1); //Qt always uses handles+1
+ } catch (IndexOutOfBoundsException ex) {
+ ex.printStackTrace();
+ return false;
+ }
+
+ ReadWriteJob newJob = new ReadWriteJob();
+ newJob.newValue = newValue;
+ newJob.entry = entry;
+ newJob.jobType = IoJobType.Write;
+
+ // writeMode must be in sync with QLowEnergyService::WriteMode
+ // For now we ignore SignedWriteType as Qt doesn't support it yet.
+ switch (writeMode) {
+ case 1: //WriteWithoutResponse
+ newJob.requestedWriteType = BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE;
+ break;
+ default:
+ newJob.requestedWriteType = BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT;
+ break;
+ }
+
+ boolean result;
+ synchronized (readWriteQueue) {
+ result = readWriteQueue.add(newJob);
+ }
+
+ if (!result) {
+ Log.w(TAG, "Cannot add characteristic write request for " + charHandle + " to queue" );
+ return false;
+ }
+
+ performNextIO();
+ return true;
+ }
+
+ /*************************************************************/
+ /* Write Descriptors */
+ /*************************************************************/
+
+ public boolean writeDescriptor(int descHandle, byte[] newValue)
+ {
+ if (mBluetoothGatt == null)
+ return false;
+
+ GattEntry entry;
+ try {
+ entry = entries.get(descHandle-1); //Qt always uses handles+1
+ } catch (IndexOutOfBoundsException ex) {
+ ex.printStackTrace();
+ return false;
+ }
+
+ ReadWriteJob newJob = new ReadWriteJob();
+ newJob.newValue = newValue;
+ newJob.entry = entry;
+ newJob.requestedWriteType = BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT;
+ newJob.jobType = IoJobType.Write;
+
+ boolean result;
+ synchronized (readWriteQueue) {
+ result = readWriteQueue.add(newJob);
+ }
+
+ if (!result) {
+ Log.w(TAG, "Cannot add descriptor write request for " + descHandle + " to queue" );
+ return false;
+ }
+
+ performNextIO();
+ return true;
+ }
+
+ /*************************************************************/
+ /* Read Characteristics */
+ /*************************************************************/
+
+ public boolean readCharacteristic(int charHandle)
+ {
+ if (mBluetoothGatt == null)
+ return false;
+
+ GattEntry entry;
+ try {
+ entry = entries.get(charHandle-1); //Qt always uses handles+1
+ } catch (IndexOutOfBoundsException ex) {
+ ex.printStackTrace();
+ return false;
+ }
+
+ ReadWriteJob newJob = new ReadWriteJob();
+ newJob.entry = entry;
+ newJob.jobType = IoJobType.Read;
+
+ boolean result;
+ synchronized (readWriteQueue) {
+ result = readWriteQueue.add(newJob);
+ }
+
+ if (!result) {
+ Log.w(TAG, "Cannot add characteristic read request for " + charHandle + " to queue" );
+ return false;
+ }
+
+ performNextIO();
+ return true;
+ }
+
+ public boolean readDescriptor(int descHandle)
+ {
+ if (mBluetoothGatt == null)
+ return false;
+
+ GattEntry entry;
+ try {
+ entry = entries.get(descHandle-1); //Qt always uses handles+1
+ } catch (IndexOutOfBoundsException ex) {
+ ex.printStackTrace();
+ return false;
+ }
+
+ ReadWriteJob newJob = new ReadWriteJob();
+ newJob.entry = entry;
+ newJob.jobType = IoJobType.Read;
+
+ boolean result;
+ synchronized (readWriteQueue) {
+ result = readWriteQueue.add(newJob);
+ }
+
+ if (!result) {
+ Log.w(TAG, "Cannot add descriptor read request for " + descHandle + " to queue" );
+ return false;
+ }
+
+ performNextIO();
+ return true;
+ }
+
+ /*
+ The queuing is required because two writeCharacteristic/writeDescriptor calls
+ cannot execute at the same time. The second write must happen after the
+ previous write has finished with on(Characteristic|Descriptor)Write().
+ */
+ private void performNextIO()
+ {
+ if (mBluetoothGatt == null)
+ return;
+
+ boolean skip = false;
+ final ReadWriteJob nextJob;
+ synchronized (readWriteQueue) {
+ if (readWriteQueue.isEmpty() || ioJobPending)
+ return;
+
+ nextJob = readWriteQueue.remove();
+
+ Log.w(TAG, "Performing queued job " + nextJob.jobType);
+ if (nextJob.jobType == IoJobType.Read)
+ skip = executeReadJob(nextJob);
+ else
+ skip = executeWriteJob(nextJob);
+
+ if (!skip)
+ ioJobPending = true;
+ }
+
+ if (skip) {
+ Log.w(TAG, "Skipping: " + nextJob.entry.type);
+
+ /*
+ BluetoothGatt.[read|write][Characteristic|Descriptor]() immediately
+ return in cases where meta data doesn't match the intended action
+ (e.g. trying to write to read-only char). When this happens
+ we have to report an error back to Qt. This is not required during
+ the initial service discovery though.
+ */
+ final boolean isServiceDiscoveryRun = (runningHandle != -1);
+ if (!isServiceDiscoveryRun) {
+ int handle = -1;
+ if (nextJob.entry.type == GattEntryType.Characteristic)
+ handle = handleForCharacteristic(nextJob.entry.characteristic);
+ else
+ handle = handleForDescriptor(nextJob.entry.descriptor);
+
+ if (handle != -1) {
+ int errorCode = 0;
+
+ // The error codes below must be in sync with QLowEnergyService::ServiceError
+ if (nextJob.jobType == IoJobType.Read) {
+ errorCode = (nextJob.entry.type == GattEntryType.Characteristic) ?
+ 5 : 6; // CharacteristicReadError : DescriptorReadError
+ } else {
+ errorCode = (nextJob.entry.type == GattEntryType.Characteristic) ?
+ 2 : 3; // CharacteristicWriteError : DescriptorWriteError
+ }
+
+ leServiceError(qtObject, handle + 1, errorCode);
+ }
+ }
+
+ performNextIO();
+ }
+ }
+
+ // Runs inside the Mutex on readWriteQueue.
+ // Returns true if nextJob should be skipped.
+ private boolean executeWriteJob(ReadWriteJob nextJob)
+ {
+ boolean result;
+ switch (nextJob.entry.type) {
+ case Characteristic:
+ if (nextJob.entry.characteristic.getWriteType() != nextJob.requestedWriteType) {
+ nextJob.entry.characteristic.setWriteType(nextJob.requestedWriteType);
+ }
+ result = nextJob.entry.characteristic.setValue(nextJob.newValue);
+ if (!result || !mBluetoothGatt.writeCharacteristic(nextJob.entry.characteristic))
+ return true;
+ break;
+ case Descriptor:
+ if (nextJob.entry.descriptor.getUuid().compareTo(clientCharacteristicUuid) == 0) {
+ /*
+ For some reason, Android splits characteristic notifications
+ into two operations. BluetoothGatt.enableCharacteristicNotification
+ ensures the local Bluetooth stack forwards the notifications. In addition,
+ BluetoothGattDescriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE)
+ must be written to the peripheral.
+ */
+
+
+ /* There is no documentation on indication behavior. The assumption is
+ that when indication or notification are requested we call
+ BluetoothGatt.setCharacteristicNotification. Furthermore it is assumed
+ indications are send via onCharacteristicChanged too and Android itself
+ will do the confirmation required for an indication as per
+ Bluetooth spec Vol 3, Part G, 4.11 . If neither of the two bits are set
+ we disable the signals.
+ */
+ boolean enableNotifications = false;
+ int value = (nextJob.newValue[0] & 0xff);
+ // first or second bit must be set
+ if (((value & 0x1) == 1) || (((value >> 1) & 0x1) == 1)) {
+ enableNotifications = true;
+ }
+
+ result = mBluetoothGatt.setCharacteristicNotification(
+ nextJob.entry.descriptor.getCharacteristic(), enableNotifications);
+ if (!result) {
+ Log.w(TAG, "Cannot set characteristic notification");
+ //we continue anyway to ensure that we write the requested value
+ //to the device
+ }
+
+ Log.d(TAG, "Enable notifications: " + enableNotifications);
+ }
+
+ result = nextJob.entry.descriptor.setValue(nextJob.newValue);
+ if (!result || !mBluetoothGatt.writeDescriptor(nextJob.entry.descriptor))
+ return true;
+ break;
+ case Service:
+ case CharacteristicValue:
+ return true;
+ }
+ return false;
+ }
+
+ // Runs inside the Mutex on readWriteQueue.
+ // Returns true if nextJob should be skipped.
+ private boolean executeReadJob(ReadWriteJob nextJob)
+ {
+ boolean result;
+ switch (nextJob.entry.type) {
+ case Characteristic:
+ result = mBluetoothGatt.readCharacteristic(nextJob.entry.characteristic);
+ if (!result)
+ return true; // skip
+ break;
+ case Descriptor:
+ result = mBluetoothGatt.readDescriptor(nextJob.entry.descriptor);
+ if (!result)
+ return true; // skip
+ break;
+ case Service:
+ case CharacteristicValue:
+ return true;
+ }
+ return false;
+ }
+
+ public native void leConnectionStateChange(long qtObject, int wasErrorTransition, int newState);
+ public native void leServicesDiscovered(long qtObject, int errorCode, String uuidList);
+ public native void leServiceDetailDiscoveryFinished(long qtObject, final String serviceUuid,
+ int startHandle, int endHandle);
+ public native void leCharacteristicRead(long qtObject, String serviceUuid,
+ int charHandle, String charUuid,
+ int properties, byte[] data);
+ public native void leDescriptorRead(long qtObject, String serviceUuid, String charUuid,
+ int descHandle, String descUuid, byte[] data);
+ public native void leCharacteristicWritten(long qtObject, int charHandle, byte[] newData,
+ int errorCode);
+ public native void leDescriptorWritten(long qtObject, int charHandle, byte[] newData,
+ int errorCode);
+ public native void leCharacteristicChanged(long qtObject, int charHandle, byte[] newData);
+ public native void leServiceError(long qtObject, int attributeHandle, int errorCode);
+}
+
diff --git a/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothSocketServer.java b/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothSocketServer.java
index ae0a03a5..b2db2bac 100644
--- a/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothSocketServer.java
+++ b/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothSocketServer.java
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -40,11 +40,14 @@ import android.util.Log;
import java.io.IOException;
import java.util.UUID;
+@SuppressWarnings("WeakerAccess")
public class QtBluetoothSocketServer extends Thread
{
/* Pointer to the Qt object that "owns" the Java object */
+ @SuppressWarnings({"WeakerAccess", "CanBeFinal"})
long qtObject = 0;
+ @SuppressWarnings({"WeakerAccess", "CanBeFinal"})
public boolean logEnabled = false;
private static final String TAG = "QtBluetooth";
@@ -54,9 +57,9 @@ public class QtBluetoothSocketServer extends Thread
private BluetoothServerSocket m_serverSocket = null;
//error codes
- public static final int QT_NO_BLUETOOTH_SUPPORTED = 0;
- public static final int QT_LISTEN_FAILED = 1;
- public static final int QT_ACCEPT_FAILED = 2;
+ private static final int QT_NO_BLUETOOTH_SUPPORTED = 0;
+ private static final int QT_LISTEN_FAILED = 1;
+ private static final int QT_ACCEPT_FAILED = 2;
public QtBluetoothSocketServer()
{
@@ -97,7 +100,7 @@ public class QtBluetoothSocketServer extends Thread
return;
}
- BluetoothSocket s = null;
+ BluetoothSocket s;
if (m_serverSocket != null) {
try {
while (!isInterrupted()) {
diff --git a/src/bluetooth/android/android.pri b/src/bluetooth/android/android.pri
index 0507894f..c50a919a 100644
--- a/src/bluetooth/android/android.pri
+++ b/src/bluetooth/android/android.pri
@@ -5,7 +5,8 @@ PRIVATE_HEADERS += \
android/androidbroadcastreceiver_p.h \
android/localdevicebroadcastreceiver_p.h \
android/serveracceptancethread_p.h \
- android/jni_android_p.h
+ android/jni_android_p.h \
+ android/lowenergynotificationhub_p.h
SOURCES += \
@@ -15,4 +16,5 @@ SOURCES += \
android/jni_android.cpp \
android/androidbroadcastreceiver.cpp \
android/localdevicebroadcastreceiver.cpp \
- android/serveracceptancethread.cpp
+ android/serveracceptancethread.cpp \
+ android/lowenergynotificationhub.cpp
diff --git a/src/bluetooth/android/androidbroadcastreceiver.cpp b/src/bluetooth/android/androidbroadcastreceiver.cpp
index 2ddf56c5..cb47dcb7 100644
--- a/src/bluetooth/android/androidbroadcastreceiver.cpp
+++ b/src/bluetooth/android/androidbroadcastreceiver.cpp
@@ -1,8 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2013 Lauri Laanmets (Proekspert AS) <lauri.laanmets@eesti.ee>
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/android/androidbroadcastreceiver_p.h b/src/bluetooth/android/androidbroadcastreceiver_p.h
index 347cd968..1f84a146 100644
--- a/src/bluetooth/android/androidbroadcastreceiver_p.h
+++ b/src/bluetooth/android/androidbroadcastreceiver_p.h
@@ -1,8 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2013 Lauri Laanmets (Proekspert AS) <lauri.laanmets@eesti.ee>
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -69,6 +69,8 @@ public:
protected:
friend void QtBroadcastReceiver_jniOnReceive(JNIEnv *, jobject, jlong, jobject, jobject);
virtual void onReceive(JNIEnv *env, jobject context, jobject intent) = 0;
+ friend void QtBluetoothLE_leScanResult(JNIEnv *, jobject, jlong, jobject, jint);
+ virtual void onReceiveLeScan(JNIEnv *env, jobject jBluetoothDevice, jint rssi) = 0;
QAndroidJniObject activityObject;
diff --git a/src/bluetooth/android/devicediscoverybroadcastreceiver.cpp b/src/bluetooth/android/devicediscoverybroadcastreceiver.cpp
index ee594c5c..af68bc0d 100644
--- a/src/bluetooth/android/devicediscoverybroadcastreceiver.cpp
+++ b/src/bluetooth/android/devicediscoverybroadcastreceiver.cpp
@@ -1,8 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2013 Lauri Laanmets (Proekspert AS) <lauri.laanmets@eesti.ee>
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -37,11 +37,58 @@
#include <QtBluetooth/QBluetoothAddress>
#include <QtBluetooth/QBluetoothDeviceInfo>
#include "android/jni_android_p.h"
+#include <QtCore/private/qjnihelpers_p.h>
+#include <QtCore/QHash>
QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(QT_BT_ANDROID)
+typedef QHash<jint, QBluetoothDeviceInfo::CoreConfigurations> JCachedBtTypes;
+Q_GLOBAL_STATIC(JCachedBtTypes, cachedBtTypes)
+
+// class name
+static const char * const javaBluetoothDeviceClassName = "android/bluetooth/BluetoothDevice";
+static const char * const javaDeviceTypeClassic = "DEVICE_TYPE_CLASSIC";
+static const char * const javaDeviceTypeDual = "DEVICE_TYPE_DUAL";
+static const char * const javaDeviceTypeLE = "DEVICE_TYPE_LE";
+static const char * const javaDeviceTypeUnknown = "DEVICE_TYPE_UNKNOWN";
+
+QBluetoothDeviceInfo::CoreConfigurations qtBtTypeForJavaBtType(jint javaType)
+{
+ const JCachedBtTypes::iterator it = cachedBtTypes()->find(javaType);
+ if (it == cachedBtTypes()->end()) {
+ QAndroidJniEnvironment env;
+
+ if (javaType == QAndroidJniObject::getStaticField<jint>(
+ javaBluetoothDeviceClassName, javaDeviceTypeClassic)) {
+ cachedBtTypes()->insert(javaType,
+ QBluetoothDeviceInfo::BaseRateCoreConfiguration);
+ return QBluetoothDeviceInfo::BaseRateCoreConfiguration;
+ } else if (javaType == QAndroidJniObject::getStaticField<jint>(
+ javaBluetoothDeviceClassName, javaDeviceTypeLE)) {
+ cachedBtTypes()->insert(javaType,
+ QBluetoothDeviceInfo::LowEnergyCoreConfiguration);
+ return QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
+ } else if (javaType == QAndroidJniObject::getStaticField<jint>(
+ javaBluetoothDeviceClassName, javaDeviceTypeDual)) {
+ cachedBtTypes()->insert(javaType,
+ QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration);
+ return QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ } else if (javaType == QAndroidJniObject::getStaticField<jint>(
+ javaBluetoothDeviceClassName, javaDeviceTypeUnknown)) {
+ cachedBtTypes()->insert(javaType,
+ QBluetoothDeviceInfo::UnknownCoreConfiguration);
+ } else {
+ qCWarning(QT_BT_ANDROID) << "Unknown Bluetooth device type value";
+ }
+
+ return QBluetoothDeviceInfo::UnknownCoreConfiguration;
+ } else {
+ return it.value();
+ }
+}
+
DeviceDiscoveryBroadcastReceiver::DeviceDiscoveryBroadcastReceiver(QObject* parent): AndroidBroadcastReceiver(parent)
{
addAction(valueForStaticField(JavaNames::BluetoothDevice, JavaNames::ActionFound));
@@ -49,6 +96,7 @@ DeviceDiscoveryBroadcastReceiver::DeviceDiscoveryBroadcastReceiver(QObject* pare
addAction(valueForStaticField(JavaNames::BluetoothAdapter, JavaNames::ActionDiscoveryFinished));
}
+// Runs in Java thread
void DeviceDiscoveryBroadcastReceiver::onReceive(JNIEnv *env, jobject context, jobject intent)
{
Q_UNUSED(context);
@@ -78,51 +126,84 @@ void DeviceDiscoveryBroadcastReceiver::onReceive(JNIEnv *env, jobject context, j
if (!bluetoothDevice.isValid())
return;
- const QString deviceName = bluetoothDevice.callObjectMethod<jstring>("getName").toString();
- const QBluetoothAddress deviceAddress(bluetoothDevice.callObjectMethod<jstring>("getAddress").toString());
keyExtra = valueForStaticField(JavaNames::BluetoothDevice,
JavaNames::ExtraRssi);
-
int rssi = intentObject.callMethod<jshort>("getShortExtra",
"(Ljava/lang/String;S)S",
keyExtra.object<jstring>(),
0);
- const QAndroidJniObject bluetoothClass = bluetoothDevice.callObjectMethod("getBluetoothClass",
- "()Landroid/bluetooth/BluetoothClass;");
- if (!bluetoothClass.isValid())
- return;
- int classType = bluetoothClass.callMethod<jint>("getDeviceClass");
-
-
- static QList<qint32> services;
- if (services.count() == 0)
- services << QBluetoothDeviceInfo::PositioningService
- << QBluetoothDeviceInfo::NetworkingService
- << QBluetoothDeviceInfo::RenderingService
- << QBluetoothDeviceInfo::CapturingService
- << QBluetoothDeviceInfo::ObjectTransferService
- << QBluetoothDeviceInfo::AudioService
- << QBluetoothDeviceInfo::TelephonyService
- << QBluetoothDeviceInfo::InformationService;
-
- //Matching BluetoothClass.Service values
- qint32 result = 0;
- qint32 current = 0;
- for (int i = 0; i < services.count(); i++) {
- current = services.at(i);
- int id = (current << 16);
- if (bluetoothClass.callMethod<jboolean>("hasService", "(I)Z", id))
- result |= current;
- }
- result = result << 13;
- classType |= result;
+ const QBluetoothDeviceInfo info = retrieveDeviceInfo(env, bluetoothDevice, rssi);
+ if (info.isValid())
+ emit deviceDiscovered(info, false);
+ }
+}
- QBluetoothDeviceInfo info(deviceAddress, deviceName, classType);
- info.setRssi(rssi);
+// Runs in Java thread
+void DeviceDiscoveryBroadcastReceiver::onReceiveLeScan(
+ JNIEnv *env, jobject jBluetoothDevice, jint rssi)
+{
+ qCDebug(QT_BT_ANDROID) << "DeviceDiscoveryBroadcastReceiver::onReceiveLeScan()";
+ const QAndroidJniObject bluetoothDevice(jBluetoothDevice);
+ if (!bluetoothDevice.isValid())
+ return;
+
+ const QBluetoothDeviceInfo info = retrieveDeviceInfo(env, bluetoothDevice, rssi);
+ if (info.isValid())
+ emit deviceDiscovered(info, true);
+}
- emit deviceDiscovered(info);
+QBluetoothDeviceInfo DeviceDiscoveryBroadcastReceiver::retrieveDeviceInfo(JNIEnv *env, const QAndroidJniObject &bluetoothDevice, int rssi)
+{
+ const QString deviceName = bluetoothDevice.callObjectMethod<jstring>("getName").toString();
+ const QBluetoothAddress deviceAddress(bluetoothDevice.callObjectMethod<jstring>("getAddress").toString());
+
+ const QAndroidJniObject bluetoothClass = bluetoothDevice.callObjectMethod("getBluetoothClass",
+ "()Landroid/bluetooth/BluetoothClass;");
+ if (!bluetoothClass.isValid())
+ return QBluetoothDeviceInfo();
+ int classType = bluetoothClass.callMethod<jint>("getDeviceClass");
+
+
+ static QList<qint32> services;
+ if (services.count() == 0)
+ services << QBluetoothDeviceInfo::PositioningService
+ << QBluetoothDeviceInfo::NetworkingService
+ << QBluetoothDeviceInfo::RenderingService
+ << QBluetoothDeviceInfo::CapturingService
+ << QBluetoothDeviceInfo::ObjectTransferService
+ << QBluetoothDeviceInfo::AudioService
+ << QBluetoothDeviceInfo::TelephonyService
+ << QBluetoothDeviceInfo::InformationService;
+
+ //Matching BluetoothClass.Service values
+ qint32 result = 0;
+ qint32 current = 0;
+ for (int i = 0; i < services.count(); i++) {
+ current = services.at(i);
+ int id = (current << 16);
+ if (bluetoothClass.callMethod<jboolean>("hasService", "(I)Z", id))
+ result |= current;
}
+
+ result = result << 13;
+ classType |= result;
+
+ QBluetoothDeviceInfo info(deviceAddress, deviceName, classType);
+ info.setRssi(rssi);
+
+ if (QtAndroidPrivate::androidSdkVersion() >= 18) {
+ jint javaBtType = bluetoothDevice.callMethod<jint>("getType");
+
+ if (env->ExceptionCheck()) {
+ env->ExceptionDescribe();
+ env->ExceptionClear();
+ } else {
+ info.setCoreConfigurations(qtBtTypeForJavaBtType(javaBtType));
+ }
+ }
+
+ return info;
}
QT_END_NAMESPACE
diff --git a/src/bluetooth/android/devicediscoverybroadcastreceiver_p.h b/src/bluetooth/android/devicediscoverybroadcastreceiver_p.h
index 4ed7027d..1fd93baa 100644
--- a/src/bluetooth/android/devicediscoverybroadcastreceiver_p.h
+++ b/src/bluetooth/android/devicediscoverybroadcastreceiver_p.h
@@ -1,8 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2013 Lauri Laanmets (Proekspert AS) <lauri.laanmets@eesti.ee>
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -59,10 +59,15 @@ class DeviceDiscoveryBroadcastReceiver : public AndroidBroadcastReceiver
public:
DeviceDiscoveryBroadcastReceiver(QObject* parent = 0);
virtual void onReceive(JNIEnv *env, jobject context, jobject intent);
+ virtual void onReceiveLeScan(JNIEnv *env, jobject jBluetoothDevice, jint rssi);
signals:
- void deviceDiscovered(const QBluetoothDeviceInfo &info);
+ void deviceDiscovered(const QBluetoothDeviceInfo &info, bool isLeScanResult);
void finished();
+
+private:
+ QBluetoothDeviceInfo retrieveDeviceInfo(JNIEnv *env, const QAndroidJniObject& bluetoothDevice,
+ int rssi);
};
QT_END_NAMESPACE
diff --git a/src/bluetooth/android/inputstreamthread.cpp b/src/bluetooth/android/inputstreamthread.cpp
index 98c245a7..c0e410b3 100644
--- a/src/bluetooth/android/inputstreamthread.cpp
+++ b/src/bluetooth/android/inputstreamthread.cpp
@@ -1,8 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2013 Lauri Laanmets (Proekspert AS) <lauri.laanmets@eesti.ee>
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/android/inputstreamthread_p.h b/src/bluetooth/android/inputstreamthread_p.h
index e7f7597e..5897a524 100644
--- a/src/bluetooth/android/inputstreamthread_p.h
+++ b/src/bluetooth/android/inputstreamthread_p.h
@@ -1,8 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2013 Lauri Laanmets (Proekspert AS) <lauri.laanmets@eesti.ee>
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/android/jni_android.cpp b/src/bluetooth/android/jni_android.cpp
index faeb411a..b4209500 100644
--- a/src/bluetooth/android/jni_android.cpp
+++ b/src/bluetooth/android/jni_android.cpp
@@ -1,8 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2013 Lauri Laanmets (Proekspert AS) <lauri.laanmets@eesti.ee>
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -40,6 +40,7 @@
#include "android/androidbroadcastreceiver_p.h"
#include "android/serveracceptancethread_p.h"
#include "android/inputstreamthread_p.h"
+#include "android/lowenergynotificationhub_p.h"
Q_DECLARE_LOGGING_CATEGORY(QT_BT_ANDROID)
@@ -183,12 +184,41 @@ static void QtBluetoothInputStreamThread_readyData(JNIEnv */*env*/, jobject /*ja
reinterpret_cast<InputStreamThread*>(qtObject)->javaReadyRead(buffer, bufferLength);
}
+void QtBluetoothLE_leScanResult(JNIEnv *env, jobject, jlong qtObject, jobject bluetoothDevice, jint rssi)
+{
+ reinterpret_cast<AndroidBroadcastReceiver*>(qtObject)->onReceiveLeScan(
+ env, bluetoothDevice, rssi);
+}
+
static JNINativeMethod methods[] = {
{"jniOnReceive", "(JLandroid/content/Context;Landroid/content/Intent;)V",
(void *) QtBroadcastReceiver_jniOnReceive},
};
+static JNINativeMethod methods_le[] = {
+ {"leScanResult", "(JLandroid/bluetooth/BluetoothDevice;I)V",
+ (void *) QtBluetoothLE_leScanResult},
+ {"leConnectionStateChange", "(JII)V",
+ (void *) LowEnergyNotificationHub::lowEnergy_connectionChange},
+ {"leServicesDiscovered", "(JILjava/lang/String;)V",
+ (void *) LowEnergyNotificationHub::lowEnergy_servicesDiscovered},
+ {"leServiceDetailDiscoveryFinished", "(JLjava/lang/String;II)V",
+ (void *) LowEnergyNotificationHub::lowEnergy_serviceDetailsDiscovered},
+ {"leCharacteristicRead", "(JLjava/lang/String;ILjava/lang/String;I[B)V",
+ (void *) LowEnergyNotificationHub::lowEnergy_characteristicRead},
+ {"leDescriptorRead", "(JLjava/lang/String;Ljava/lang/String;ILjava/lang/String;[B)V",
+ (void *) LowEnergyNotificationHub::lowEnergy_descriptorRead},
+ {"leCharacteristicWritten", "(JI[BI)V",
+ (void *) LowEnergyNotificationHub::lowEnergy_characteristicWritten},
+ {"leDescriptorWritten", "(JI[BI)V",
+ (void *) LowEnergyNotificationHub::lowEnergy_descriptorWritten},
+ {"leCharacteristicChanged", "(JI[B)V",
+ (void *) LowEnergyNotificationHub::lowEnergy_characteristicChanged},
+ {"leServiceError", "(JII)V",
+ (void *) LowEnergyNotificationHub::lowEnergy_serviceError},
+};
+
static JNINativeMethod methods_server[] = {
{"errorOccurred", "(JI)V",
(void *) QtBluetoothSocketServer_errorOccurred},
@@ -218,12 +248,18 @@ static bool registerNatives(JNIEnv *env)
jclass clazz;
FIND_AND_CHECK_CLASS("org/qtproject/qt5/android/bluetooth/QtBluetoothBroadcastReceiver");
-
if (env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])) < 0) {
__android_log_print(ANDROID_LOG_FATAL, logTag, "RegisterNatives for BraodcastReceiver failed");
return false;
}
+ FIND_AND_CHECK_CLASS("org/qtproject/qt5/android/bluetooth/QtBluetoothLE");
+ if (env->RegisterNatives(clazz, methods_le, sizeof(methods_le) / sizeof(methods_le[0])) < 0) {
+ __android_log_print(ANDROID_LOG_FATAL, logTag, "RegisterNatives for QBLuetoothLE failed");
+ return false;
+ }
+
+
FIND_AND_CHECK_CLASS("org/qtproject/qt5/android/bluetooth/QtBluetoothSocketServer");
if (env->RegisterNatives(clazz, methods_server, sizeof(methods_server) / sizeof(methods_server[0])) < 0) {
__android_log_print(ANDROID_LOG_FATAL, logTag, "RegisterNatives for SocketServer failed");
diff --git a/src/bluetooth/android/jni_android_p.h b/src/bluetooth/android/jni_android_p.h
index 0a90cfea..b45e634c 100644
--- a/src/bluetooth/android/jni_android_p.h
+++ b/src/bluetooth/android/jni_android_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/android/localdevicebroadcastreceiver.cpp b/src/bluetooth/android/localdevicebroadcastreceiver.cpp
index a3b92252..0487e376 100644
--- a/src/bluetooth/android/localdevicebroadcastreceiver.cpp
+++ b/src/bluetooth/android/localdevicebroadcastreceiver.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/android/localdevicebroadcastreceiver_p.h b/src/bluetooth/android/localdevicebroadcastreceiver_p.h
index 190ae631..146b6671 100644
--- a/src/bluetooth/android/localdevicebroadcastreceiver_p.h
+++ b/src/bluetooth/android/localdevicebroadcastreceiver_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -58,6 +58,7 @@ public:
explicit LocalDeviceBroadcastReceiver(QObject *parent = 0);
virtual ~LocalDeviceBroadcastReceiver() {}
virtual void onReceive(JNIEnv *env, jobject context, jobject intent);
+ virtual void onReceiveLeScan(JNIEnv *, jobject, jint) {}
bool pairingConfirmation(bool accept);
signals:
diff --git a/src/bluetooth/android/lowenergynotificationhub.cpp b/src/bluetooth/android/lowenergynotificationhub.cpp
new file mode 100644
index 00000000..9e95ece6
--- /dev/null
+++ b/src/bluetooth/android/lowenergynotificationhub.cpp
@@ -0,0 +1,299 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "lowenergynotificationhub_p.h"
+
+#include <QtCore/QHash>
+#include <QtCore/QLoggingCategory>
+#include <QtCore/QTime>
+#include <QtAndroidExtras/QAndroidJniEnvironment>
+
+QT_BEGIN_NAMESPACE
+
+typedef QHash<long, LowEnergyNotificationHub*> HubMapType;
+Q_GLOBAL_STATIC(HubMapType, hubMap)
+
+QReadWriteLock LowEnergyNotificationHub::lock;
+
+Q_DECLARE_LOGGING_CATEGORY(QT_BT_ANDROID)
+
+LowEnergyNotificationHub::LowEnergyNotificationHub(
+ const QBluetoothAddress &remote, QObject *parent)
+ : QObject(parent), javaToCtoken(0)
+{
+ QAndroidJniEnvironment env;
+ const QAndroidJniObject address =
+ QAndroidJniObject::fromString(remote.toString());
+ jBluetoothLe = QAndroidJniObject("org/qtproject/qt5/android/bluetooth/QtBluetoothLE",
+ "(Ljava/lang/String;Landroid/app/Activity;)V",
+ address.object<jstring>(),
+ QtAndroidPrivate::activity());
+
+
+ if (env->ExceptionCheck() || !jBluetoothLe.isValid()) {
+ env->ExceptionDescribe();
+ env->ExceptionClear();
+ jBluetoothLe = QAndroidJniObject();
+ return;
+ }
+
+ // register C++ class pointer in Java
+ qsrand(QTime::currentTime().msec());
+ lock.lockForWrite();
+
+ while (true) {
+ javaToCtoken = qrand();
+ if (!hubMap()->contains(javaToCtoken))
+ break;
+ }
+
+ hubMap()->insert(javaToCtoken, this);
+ lock.unlock();
+
+ jBluetoothLe.setField<jlong>("qtObject", javaToCtoken);
+}
+
+LowEnergyNotificationHub::~LowEnergyNotificationHub()
+{
+ lock.lockForWrite();
+ hubMap()->remove(javaToCtoken);
+ lock.unlock();
+}
+
+// runs in Java thread
+void LowEnergyNotificationHub::lowEnergy_connectionChange(JNIEnv *, jobject, jlong qtObject, jint errorCode, jint newState)
+{
+ lock.lockForRead();
+ LowEnergyNotificationHub *hub = hubMap()->value(qtObject);
+ lock.unlock();
+ if (!hub)
+ return;
+
+ QMetaObject::invokeMethod(hub, "connectionUpdated", Qt::QueuedConnection,
+ Q_ARG(QLowEnergyController::ControllerState,
+ (QLowEnergyController::ControllerState)newState),
+ Q_ARG(QLowEnergyController::Error,
+ (QLowEnergyController::Error)errorCode));
+}
+
+void LowEnergyNotificationHub::lowEnergy_servicesDiscovered(
+ JNIEnv *, jobject, jlong qtObject, jint errorCode, jobject uuidList)
+{
+ lock.lockForRead();
+ LowEnergyNotificationHub *hub = hubMap()->value(qtObject);
+ lock.unlock();
+ if (!hub)
+ return;
+
+ const QString uuids = QAndroidJniObject(uuidList).toString();
+ QMetaObject::invokeMethod(hub, "servicesDiscovered", Qt::QueuedConnection,
+ Q_ARG(QLowEnergyController::Error,
+ (QLowEnergyController::Error)errorCode),
+ Q_ARG(QString, uuids));
+}
+
+void LowEnergyNotificationHub::lowEnergy_serviceDetailsDiscovered(
+ JNIEnv *, jobject, jlong qtObject, jobject uuid, jint startHandle,
+ jint endHandle)
+{
+ lock.lockForRead();
+ LowEnergyNotificationHub *hub = hubMap()->value(qtObject);
+ lock.unlock();
+ if (!hub)
+ return;
+
+ const QString serviceUuid = QAndroidJniObject(uuid).toString();
+ QMetaObject::invokeMethod(hub, "serviceDetailsDiscoveryFinished",
+ Qt::QueuedConnection,
+ Q_ARG(QString, serviceUuid),
+ Q_ARG(int, startHandle),
+ Q_ARG(int, endHandle));
+}
+
+void LowEnergyNotificationHub::lowEnergy_characteristicRead(
+ JNIEnv *env, jobject, jlong qtObject, jobject sUuid, jint handle,
+ jobject cUuid, jint properties, jbyteArray data)
+{
+ lock.lockForRead();
+ LowEnergyNotificationHub *hub = hubMap()->value(qtObject);
+ lock.unlock();
+ if (!hub)
+ return;
+
+ const QBluetoothUuid serviceUuid(QAndroidJniObject(sUuid).toString());
+ if (serviceUuid.isNull())
+ return;
+
+ const QBluetoothUuid charUuid(QAndroidJniObject(cUuid).toString());
+ if (charUuid.isNull())
+ return;
+
+ QByteArray payload;
+ if (data) { //empty Java byte array is 0x0
+ jsize length = env->GetArrayLength(data);
+ payload.resize(length);
+ env->GetByteArrayRegion(data, 0, length,
+ reinterpret_cast<signed char*>(payload.data()));
+ }
+
+ QMetaObject::invokeMethod(hub, "characteristicRead", Qt::QueuedConnection,
+ Q_ARG(QBluetoothUuid, serviceUuid),
+ Q_ARG(int, handle),
+ Q_ARG(QBluetoothUuid, charUuid),
+ Q_ARG(int, properties),
+ Q_ARG(QByteArray, payload));
+
+}
+
+void LowEnergyNotificationHub::lowEnergy_descriptorRead(
+ JNIEnv *env, jobject, jlong qtObject, jobject sUuid, jobject cUuid,
+ jint handle, jobject dUuid, jbyteArray data)
+{
+ lock.lockForRead();
+ LowEnergyNotificationHub *hub = hubMap()->value(qtObject);
+ lock.unlock();
+ if (!hub)
+ return;
+
+ const QBluetoothUuid serviceUuid(QAndroidJniObject(sUuid).toString());
+ if (serviceUuid.isNull())
+ return;
+
+ const QBluetoothUuid charUuid(QAndroidJniObject(cUuid).toString());
+ const QBluetoothUuid descUuid(QAndroidJniObject(dUuid).toString());
+ if (charUuid.isNull() || descUuid.isNull())
+ return;
+
+ QByteArray payload;
+ if (data) { //empty Java byte array is 0x0
+ jsize length = env->GetArrayLength(data);
+ payload.resize(length);
+ env->GetByteArrayRegion(data, 0, length,
+ reinterpret_cast<signed char*>(payload.data()));
+ }
+
+ QMetaObject::invokeMethod(hub, "descriptorRead", Qt::QueuedConnection,
+ Q_ARG(QBluetoothUuid, serviceUuid),
+ Q_ARG(QBluetoothUuid, charUuid),
+ Q_ARG(int, handle),
+ Q_ARG(QBluetoothUuid, descUuid),
+ Q_ARG(QByteArray, payload));
+}
+
+void LowEnergyNotificationHub::lowEnergy_characteristicWritten(
+ JNIEnv *env, jobject, jlong qtObject, jint charHandle,
+ jbyteArray data, jint errorCode)
+{
+ lock.lockForRead();
+ LowEnergyNotificationHub *hub = hubMap()->value(qtObject);
+ lock.unlock();
+ if (!hub)
+ return;
+
+ QByteArray payload;
+ if (data) { //empty Java byte array is 0x0
+ jsize length = env->GetArrayLength(data);
+ payload.resize(length);
+ env->GetByteArrayRegion(data, 0, length,
+ reinterpret_cast<signed char*>(payload.data()));
+ }
+
+ QMetaObject::invokeMethod(hub, "characteristicWritten", Qt::QueuedConnection,
+ Q_ARG(int, charHandle),
+ Q_ARG(QByteArray, payload),
+ Q_ARG(QLowEnergyService::ServiceError,
+ (QLowEnergyService::ServiceError)errorCode));
+}
+
+void LowEnergyNotificationHub::lowEnergy_descriptorWritten(
+ JNIEnv *env, jobject, jlong qtObject, jint descHandle,
+ jbyteArray data, jint errorCode)
+{
+ lock.lockForRead();
+ LowEnergyNotificationHub *hub = hubMap()->value(qtObject);
+ lock.unlock();
+ if (!hub)
+ return;
+
+ QByteArray payload;
+ if (data) { //empty Java byte array is 0x0
+ jsize length = env->GetArrayLength(data);
+ payload.resize(length);
+ env->GetByteArrayRegion(data, 0, length,
+ reinterpret_cast<signed char*>(payload.data()));
+ }
+
+ QMetaObject::invokeMethod(hub, "descriptorWritten", Qt::QueuedConnection,
+ Q_ARG(int, descHandle),
+ Q_ARG(QByteArray, payload),
+ Q_ARG(QLowEnergyService::ServiceError,
+ (QLowEnergyService::ServiceError)errorCode));
+}
+
+void LowEnergyNotificationHub::lowEnergy_characteristicChanged(
+ JNIEnv *env, jobject, jlong qtObject, jint charHandle, jbyteArray data)
+{
+ lock.lockForRead();
+ LowEnergyNotificationHub *hub = hubMap()->value(qtObject);
+ lock.unlock();
+ if (!hub)
+ return;
+
+ QByteArray payload;
+ if (data) { //empty Java byte array is 0x0
+ jsize length = env->GetArrayLength(data);
+ payload.resize(length);
+ env->GetByteArrayRegion(data, 0, length,
+ reinterpret_cast<signed char*>(payload.data()));
+ }
+
+ QMetaObject::invokeMethod(hub, "characteristicChanged", Qt::QueuedConnection,
+ Q_ARG(int, charHandle), Q_ARG(QByteArray, payload));
+}
+
+void LowEnergyNotificationHub::lowEnergy_serviceError(
+ JNIEnv *, jobject, jlong qtObject, jint attributeHandle, int errorCode)
+{
+ lock.lockForRead();
+ LowEnergyNotificationHub *hub = hubMap()->value(qtObject);
+ lock.unlock();
+ if (!hub)
+ return;
+
+ QMetaObject::invokeMethod(hub, "serviceError", Qt::QueuedConnection,
+ Q_ARG(int, attributeHandle),
+ Q_ARG(QLowEnergyService::ServiceError,
+ (QLowEnergyService::ServiceError)errorCode));
+}
+
+QT_END_NAMESPACE
diff --git a/src/bluetooth/android/lowenergynotificationhub_p.h b/src/bluetooth/android/lowenergynotificationhub_p.h
new file mode 100644
index 00000000..0395f9db
--- /dev/null
+++ b/src/bluetooth/android/lowenergynotificationhub_p.h
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef LOWENERGYNOTIFICATIONHUB_H
+#define LOWENERGYNOTIFICATIONHUB_H
+
+#include <QtCore/QObject>
+#include <QtCore/QReadWriteLock>
+#include <QtCore/private/qjnihelpers_p.h>
+#include <QtAndroidExtras/QAndroidJniObject>
+#include <QtBluetooth/QBluetoothAddress>
+#include <jni.h>
+
+#include <QtBluetooth/QLowEnergyCharacteristic>
+#include "qlowenergycontroller_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class LowEnergyNotificationHub : public QObject
+{
+ Q_OBJECT
+public:
+ explicit LowEnergyNotificationHub(const QBluetoothAddress &remote,
+ QObject *parent = 0);
+ ~LowEnergyNotificationHub();
+
+ static void lowEnergy_connectionChange(JNIEnv*, jobject, jlong qtObject,
+ jint errorCode, jint newState);
+ static void lowEnergy_servicesDiscovered(JNIEnv*, jobject, jlong qtObject,
+ jint errorCode, jobject uuidList);
+ static void lowEnergy_serviceDetailsDiscovered(JNIEnv *, jobject,
+ jlong qtObject, jobject uuid,
+ jint startHandle, jint endHandle);
+ static void lowEnergy_characteristicRead(JNIEnv*env, jobject, jlong qtObject,
+ jobject serviceUuid,
+ jint handle, jobject charUuid,
+ jint properties, jbyteArray data);
+ static void lowEnergy_descriptorRead(JNIEnv *env, jobject, jlong qtObject,
+ jobject sUuid, jobject cUuid,
+ jint handle, jobject dUuid, jbyteArray data);
+ static void lowEnergy_characteristicWritten(JNIEnv *, jobject, jlong qtObject,
+ jint charHandle, jbyteArray data,
+ jint errorCode);
+ static void lowEnergy_descriptorWritten(JNIEnv *, jobject, jlong qtObject,
+ jint descHandle, jbyteArray data,
+ jint errorCode);
+ static void lowEnergy_characteristicChanged(JNIEnv *, jobject, jlong qtObject,
+ jint charHandle, jbyteArray data);
+ static void lowEnergy_serviceError(JNIEnv *, jobject, jlong qtObject,
+ jint attributeHandle, int errorCode);
+
+ QAndroidJniObject javaObject()
+ {
+ return jBluetoothLe;
+ }
+
+signals:
+ void connectionUpdated(QLowEnergyController::ControllerState newState,
+ QLowEnergyController::Error errorCode);
+ void servicesDiscovered(QLowEnergyController::Error errorCode, const QString &uuids);
+ void serviceDetailsDiscoveryFinished(const QString& serviceUuid,
+ int startHandle, int endHandle);
+ void characteristicRead(const QBluetoothUuid &serviceUuid,
+ int handle, const QBluetoothUuid &charUuid,
+ int properties, const QByteArray &data);
+ void descriptorRead(const QBluetoothUuid &serviceUuid, const QBluetoothUuid &charUuid,
+ int handle, const QBluetoothUuid &descUuid, const QByteArray &data);
+ void characteristicWritten(int charHandle, const QByteArray &data,
+ QLowEnergyService::ServiceError errorCode);
+ void descriptorWritten(int descHandle, const QByteArray &data,
+ QLowEnergyService::ServiceError errorCode);
+ void characteristicChanged(int charHandle, const QByteArray &data);
+ void serviceError(int attributeHandle, QLowEnergyService::ServiceError errorCode);
+
+public slots:
+private:
+ static QReadWriteLock lock;
+
+ QAndroidJniObject jBluetoothLe;
+ long javaToCtoken;
+
+};
+
+QT_END_NAMESPACE
+
+#endif // LOWENERGYNOTIFICATIONHUB_H
+
diff --git a/src/bluetooth/android/serveracceptancethread.cpp b/src/bluetooth/android/serveracceptancethread.cpp
index cc639135..3a30cacb 100644
--- a/src/bluetooth/android/serveracceptancethread.cpp
+++ b/src/bluetooth/android/serveracceptancethread.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -38,10 +38,12 @@
Q_DECLARE_LOGGING_CATEGORY(QT_BT_ANDROID)
+Q_DECLARE_METATYPE(QBluetoothServer::Error)
+
ServerAcceptanceThread::ServerAcceptanceThread(QObject *parent) :
QObject(parent), maxPendingConnections(1)
{
- qRegisterMetaType<QBluetoothServer::Error>("QBluetoothServer::Error");
+ qRegisterMetaType<QBluetoothServer::Error>();
}
ServerAcceptanceThread::~ServerAcceptanceThread()
diff --git a/src/bluetooth/android/serveracceptancethread_p.h b/src/bluetooth/android/serveracceptancethread_p.h
index 1adda433..ed565eec 100644
--- a/src/bluetooth/android/serveracceptancethread_p.h
+++ b/src/bluetooth/android/serveracceptancethread_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/android/servicediscoverybroadcastreceiver.cpp b/src/bluetooth/android/servicediscoverybroadcastreceiver.cpp
index 5ca9d59b..d0f3c3de 100644
--- a/src/bluetooth/android/servicediscoverybroadcastreceiver.cpp
+++ b/src/bluetooth/android/servicediscoverybroadcastreceiver.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/android/servicediscoverybroadcastreceiver_p.h b/src/bluetooth/android/servicediscoverybroadcastreceiver_p.h
index 273af121..9e953ab9 100644
--- a/src/bluetooth/android/servicediscoverybroadcastreceiver_p.h
+++ b/src/bluetooth/android/servicediscoverybroadcastreceiver_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -60,6 +60,7 @@ class ServiceDiscoveryBroadcastReceiver : public AndroidBroadcastReceiver
public:
ServiceDiscoveryBroadcastReceiver(QObject* parent = 0);
virtual void onReceive(JNIEnv *env, jobject context, jobject intent);
+ virtual void onReceiveLeScan(JNIEnv *, jobject, jint) {}
static QList<QBluetoothUuid> convertParcelableArray(const QAndroidJniObject &obj);
diff --git a/src/bluetooth/bluetooth.pro b/src/bluetooth/bluetooth.pro
index af0d96f0..be953d04 100644
--- a/src/bluetooth/bluetooth.pro
+++ b/src/bluetooth/bluetooth.pro
@@ -140,8 +140,69 @@ config_bluez:qtHaveModule(dbus) {
qbluetoothservicediscoveryagent_android.cpp \
qbluetoothsocket_android.cpp \
qbluetoothserver_android.cpp \
+ qlowenergycontroller_android.cpp
+
+} else:osx {
+ DEFINES += QT_OSX_BLUETOOTH
+ LIBS += -framework Foundation -framework IOBluetooth
+
+ include(osx/osxbt.pri)
+ OBJECTIVE_SOURCES += \
+ qbluetoothlocaldevice_osx.mm \
+ qbluetoothdevicediscoveryagent_osx.mm \
+ qbluetoothserviceinfo_osx.mm \
+ qbluetoothservicediscoveryagent_osx.mm \
+ qbluetoothsocket_osx.mm \
+ qbluetoothserver_osx.mm \
+ qbluetoothtransferreply_osx.mm \
+ qlowenergycontroller_osx.mm \
+ qlowenergyservice_osx.mm
+
+ SOURCES += \
+ qlowenergycontroller_p.cpp
+
+ PRIVATE_HEADERS += qbluetoothsocket_osx_p.h \
+ qbluetoothserver_osx_p.h \
+ qbluetoothtransferreply_osx_p.h \
+ qbluetoothtransferreply_osx_p.h \
+ qbluetoothdevicediscoverytimer_osx_p.h \
+ qlowenergycontroller_osx_p.h
+
+ SOURCES -= qbluetoothdevicediscoveryagent.cpp
+ SOURCES -= qbluetoothserviceinfo.cpp
+ SOURCES -= qbluetoothservicediscoveryagent.cpp
+ SOURCES -= qbluetoothsocket.cpp
+ SOURCES -= qbluetoothserver.cpp
+ SOURCES -= qlowenergyservice_p.cpp
+ SOURCES -= qlowenergyservice.cpp
+ SOURCES -= qlowenergycontroller.cpp
+ SOURCES -= qlowenergycontroller_p.cpp
+} else:ios {
+ DEFINES += QT_IOS_BLUETOOTH
+ LIBS += -framework Foundation -framework CoreBluetooth
+
+ OBJECTIVE_SOURCES += \
+ qbluetoothdevicediscoveryagent_ios.mm \
+ qlowenergycontroller_osx.mm \
+ qlowenergyservice_osx.mm
+
+ PRIVATE_HEADERS += \
+ qlowenergycontroller_osx_p.h
+
+ include(osx/osxbt.pri)
+ SOURCES += \
+ qbluetoothdevicediscoveryagent_p.cpp \
+ qbluetoothlocaldevice_p.cpp \
+ qbluetoothserviceinfo_p.cpp \
+ qbluetoothservicediscoveryagent_p.cpp \
+ qbluetoothsocket_p.cpp \
+ qbluetoothserver_p.cpp \
qlowenergycontroller_p.cpp
+ SOURCES -= qbluetoothdevicediscoveryagent.cpp
+ SOURCES -= qlowenergycontroller_p.cpp
+ SOURCES -= qlowenergyservice.cpp
+ SOURCES -= qlowenergycontroller.cpp
} else {
message("Unsupported Bluetooth platform, will not build a working QtBluetooth library.")
message("Either no Qt D-Bus found or no BlueZ headers.")
diff --git a/src/bluetooth/bluez/adapter.cpp b/src/bluetooth/bluez/adapter.cpp
index e4b4f1ad..10b46f3b 100644
--- a/src/bluetooth/bluez/adapter.cpp
+++ b/src/bluetooth/bluez/adapter.cpp
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp -p adapter_p.h:adapter.cpp org.bluez.all.xml org.bluez.Adapter
*
- * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+ * Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
diff --git a/src/bluetooth/bluez/adapter1_bluez5.cpp b/src/bluetooth/bluez/adapter1_bluez5.cpp
index 8de63d32..0f1e0acd 100644
--- a/src/bluetooth/bluez/adapter1_bluez5.cpp
+++ b/src/bluetooth/bluez/adapter1_bluez5.cpp
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp -p adapter1 -v org.bluez.Adapter1.xml
*
- * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
diff --git a/src/bluetooth/bluez/adapter1_bluez5_p.h b/src/bluetooth/bluez/adapter1_bluez5_p.h
index 32a70b3d..5568da4c 100644
--- a/src/bluetooth/bluez/adapter1_bluez5_p.h
+++ b/src/bluetooth/bluez/adapter1_bluez5_p.h
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp -p adapter1 -v org.bluez.Adapter1.xml
*
- * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
diff --git a/src/bluetooth/bluez/adapter_p.h b/src/bluetooth/bluez/adapter_p.h
index 2c865df4..d9b6a0c7 100644
--- a/src/bluetooth/bluez/adapter_p.h
+++ b/src/bluetooth/bluez/adapter_p.h
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp -p adapter_p.h:adapter.cpp org.bluez.all.xml org.bluez.Adapter
*
- * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+ * Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
diff --git a/src/bluetooth/bluez/agent.cpp b/src/bluetooth/bluez/agent.cpp
index 453f6143..89840531 100644
--- a/src/bluetooth/bluez/agent.cpp
+++ b/src/bluetooth/bluez/agent.cpp
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp -c OrgBluezAgentAdaptor -a agent_p.h:agent.cpp org.bluez.Agent.xml org.bluez.Agent
*
- * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+ * Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
diff --git a/src/bluetooth/bluez/agent_p.h b/src/bluetooth/bluez/agent_p.h
index 2ccc487d..8329089f 100644
--- a/src/bluetooth/bluez/agent_p.h
+++ b/src/bluetooth/bluez/agent_p.h
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp -c OrgBluezAgentAdaptor -a agent_p.h:agent.cpp org.bluez.Agent.xml org.bluez.Agent
*
- * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+ * Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
diff --git a/src/bluetooth/bluez/bluez5_helper.cpp b/src/bluetooth/bluez/bluez5_helper.cpp
index 0e3c0063..28b5c12d 100644
--- a/src/bluetooth/bluez/bluez5_helper.cpp
+++ b/src/bluetooth/bluez/bluez5_helper.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -38,6 +38,7 @@
#include "objectmanager_p.h"
#include "properties_p.h"
#include "adapter1_bluez5_p.h"
+#include "manager_p.h"
QT_BEGIN_NAMESPACE
@@ -47,7 +48,8 @@ typedef enum Bluez5TestResultType
{
BluezVersionUnknown,
BluezVersion4,
- BluezVersion5
+ BluezVersion5,
+ BluezNotAvailable
} Bluez5TestResult;
Q_GLOBAL_STATIC_WITH_ARGS(Bluez5TestResult, bluezVersion, (BluezVersionUnknown));
@@ -65,8 +67,20 @@ bool isBluez5()
QDBusPendingReply<ManagedObjectList> reply = manager.GetManagedObjects();
reply.waitForFinished();
if (reply.isError()) {
- *bluezVersion() = BluezVersion4;
- qCDebug(QT_BT_BLUEZ) << "Bluez 4 detected.";
+ // not Bluez 5.x
+ OrgBluezManagerInterface manager_bluez4(QStringLiteral("org.bluez"),
+ QStringLiteral("/"),
+ QDBusConnection::systemBus());
+ QDBusPendingReply<QList<QDBusObjectPath> > reply
+ = manager_bluez4.ListAdapters();
+ reply.waitForFinished();
+ if (reply.isError()) {
+ *bluezVersion() = BluezNotAvailable;
+ qWarning() << "Cannot find a running Bluez. Please check the Bluez installation.";
+ } else {
+ *bluezVersion() = BluezVersion4;
+ qCDebug(QT_BT_BLUEZ) << "Bluez 4 detected.";
+ }
} else {
*bluezVersion() = BluezVersion5;
qCDebug(QT_BT_BLUEZ) << "Bluez 5 detected.";
diff --git a/src/bluetooth/bluez/bluez5_helper_p.h b/src/bluetooth/bluez/bluez5_helper_p.h
index 7935877c..e1fb90c5 100644
--- a/src/bluetooth/bluez/bluez5_helper_p.h
+++ b/src/bluetooth/bluez/bluez5_helper_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/bluez/bluez_data_p.h b/src/bluetooth/bluez/bluez_data_p.h
index 9d0d9d9c..dc12dda2 100644
--- a/src/bluetooth/bluez/bluez_data_p.h
+++ b/src/bluetooth/bluez/bluez_data_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/bluez/device.cpp b/src/bluetooth/bluez/device.cpp
index 5bffbd8b..5dc814dc 100644
--- a/src/bluetooth/bluez/device.cpp
+++ b/src/bluetooth/bluez/device.cpp
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp -i servicemap_p.h -p device_p.h:device.cpp org.bluez.Device.xml org.bluez.Device
*
- * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+ * Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
diff --git a/src/bluetooth/bluez/device1_bluez5.cpp b/src/bluetooth/bluez/device1_bluez5.cpp
index 50bef4cb..a4c01d3f 100644
--- a/src/bluetooth/bluez/device1_bluez5.cpp
+++ b/src/bluetooth/bluez/device1_bluez5.cpp
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp -p device1_bluez5 -v org.bluez.Device1.xml
*
- * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
diff --git a/src/bluetooth/bluez/device1_bluez5_p.h b/src/bluetooth/bluez/device1_bluez5_p.h
index 4caae28a..d6181b34 100644
--- a/src/bluetooth/bluez/device1_bluez5_p.h
+++ b/src/bluetooth/bluez/device1_bluez5_p.h
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp -p device1_bluez5 -v org.bluez.Device1.xml
*
- * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
diff --git a/src/bluetooth/bluez/device_p.h b/src/bluetooth/bluez/device_p.h
index d4ec45f9..417db3d9 100644
--- a/src/bluetooth/bluez/device_p.h
+++ b/src/bluetooth/bluez/device_p.h
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp -i servicemap_p.h -p device_p.h:device.cpp org.bluez.Device.xml org.bluez.Device
*
- * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+ * Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
diff --git a/src/bluetooth/bluez/hcimanager.cpp b/src/bluetooth/bluez/hcimanager.cpp
index 32450588..bf2754f5 100644
--- a/src/bluetooth/bluez/hcimanager.cpp
+++ b/src/bluetooth/bluez/hcimanager.cpp
@@ -1,8 +1,8 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2013 Javier S. Pedro <maemo@javispedro.com>
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/bluez/hcimanager_p.h b/src/bluetooth/bluez/hcimanager_p.h
index 3a923519..9dd2ceee 100644
--- a/src/bluetooth/bluez/hcimanager_p.h
+++ b/src/bluetooth/bluez/hcimanager_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/bluez/manager.cpp b/src/bluetooth/bluez/manager.cpp
index aa974625..b5d6590d 100644
--- a/src/bluetooth/bluez/manager.cpp
+++ b/src/bluetooth/bluez/manager.cpp
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp -p manager_p.h:manager.cpp org.bluez.Manager.xml org.bluez.Manager
*
- * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+ * Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
diff --git a/src/bluetooth/bluez/manager_p.h b/src/bluetooth/bluez/manager_p.h
index 1cd8975c..edb1c73b 100644
--- a/src/bluetooth/bluez/manager_p.h
+++ b/src/bluetooth/bluez/manager_p.h
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp -p manager_p.h:manager.cpp org.bluez.Manager.xml org.bluez.Manager
*
- * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+ * Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
diff --git a/src/bluetooth/bluez/obex_agent.cpp b/src/bluetooth/bluez/obex_agent.cpp
index b4b27d2e..c5252898 100644
--- a/src/bluetooth/bluez/obex_agent.cpp
+++ b/src/bluetooth/bluez/obex_agent.cpp
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp -a obex_agent_p.h:obex_agent.cpp org.openobex.agent.xml
*
- * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+ * Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
diff --git a/src/bluetooth/bluez/obex_agent_p.h b/src/bluetooth/bluez/obex_agent_p.h
index 4eebbc32..8af38d86 100644
--- a/src/bluetooth/bluez/obex_agent_p.h
+++ b/src/bluetooth/bluez/obex_agent_p.h
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp -a obex_agent_p.h:obex_agent.cpp org.openobex.agent.xml
*
- * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+ * Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
diff --git a/src/bluetooth/bluez/obex_client.cpp b/src/bluetooth/bluez/obex_client.cpp
index b90438f5..07730d42 100644
--- a/src/bluetooth/bluez/obex_client.cpp
+++ b/src/bluetooth/bluez/obex_client.cpp
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp -p obex_client_p.h:obex_client.cpp org.openobex.client.xml org.openobex.Client
*
- * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+ * Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
diff --git a/src/bluetooth/bluez/obex_client1_bluez5.cpp b/src/bluetooth/bluez/obex_client1_bluez5.cpp
index fe0fd1f3..fb66708a 100644
--- a/src/bluetooth/bluez/obex_client1_bluez5.cpp
+++ b/src/bluetooth/bluez/obex_client1_bluez5.cpp
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp org.bluez.Client1.xml -p asd
*
- * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
diff --git a/src/bluetooth/bluez/obex_client1_bluez5_p.h b/src/bluetooth/bluez/obex_client1_bluez5_p.h
index f8f0f89a..5133faea 100644
--- a/src/bluetooth/bluez/obex_client1_bluez5_p.h
+++ b/src/bluetooth/bluez/obex_client1_bluez5_p.h
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp org.bluez.Client1.xml -p asd
*
- * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
diff --git a/src/bluetooth/bluez/obex_client_p.h b/src/bluetooth/bluez/obex_client_p.h
index a7b32621..b2dd0f61 100644
--- a/src/bluetooth/bluez/obex_client_p.h
+++ b/src/bluetooth/bluez/obex_client_p.h
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp -p obex_client_p.h:obex_client.cpp org.openobex.client.xml org.openobex.Client
*
- * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+ * Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
diff --git a/src/bluetooth/bluez/obex_manager.cpp b/src/bluetooth/bluez/obex_manager.cpp
index d2a173d7..0eb5d1c8 100644
--- a/src/bluetooth/bluez/obex_manager.cpp
+++ b/src/bluetooth/bluez/obex_manager.cpp
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp -p obex_manager_p.h:obex_manager.cpp org.openobex.all.xml org.openobex.Manager
*
- * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+ * Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
diff --git a/src/bluetooth/bluez/obex_manager_p.h b/src/bluetooth/bluez/obex_manager_p.h
index 339d8a70..a6e4d189 100644
--- a/src/bluetooth/bluez/obex_manager_p.h
+++ b/src/bluetooth/bluez/obex_manager_p.h
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp -p obex_manager_p.h:obex_manager.cpp org.openobex.all.xml org.openobex.Manager
*
- * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+ * Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
diff --git a/src/bluetooth/bluez/obex_objectpush1_bluez5.cpp b/src/bluetooth/bluez/obex_objectpush1_bluez5.cpp
index 637a3a62..6edb27a8 100644
--- a/src/bluetooth/bluez/obex_objectpush1_bluez5.cpp
+++ b/src/bluetooth/bluez/obex_objectpush1_bluez5.cpp
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp org.bluez.obex.ObjectPush1.xml -p obex_objectpush1_bluez5
*
- * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
diff --git a/src/bluetooth/bluez/obex_objectpush1_bluez5_p.h b/src/bluetooth/bluez/obex_objectpush1_bluez5_p.h
index f8adcab4..ba5f090d 100644
--- a/src/bluetooth/bluez/obex_objectpush1_bluez5_p.h
+++ b/src/bluetooth/bluez/obex_objectpush1_bluez5_p.h
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp org.bluez.obex.ObjectPush1.xml -p obex_objectpush1_bluez5
*
- * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
diff --git a/src/bluetooth/bluez/obex_transfer.cpp b/src/bluetooth/bluez/obex_transfer.cpp
index c125a4e4..49e1f7c9 100644
--- a/src/bluetooth/bluez/obex_transfer.cpp
+++ b/src/bluetooth/bluez/obex_transfer.cpp
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp -p obex_transfer_p.h:obex_transfer.cpp org.openobex.transfer.xml org.openobex.Transfer
*
- * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+ * Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
diff --git a/src/bluetooth/bluez/obex_transfer1_bluez5.cpp b/src/bluetooth/bluez/obex_transfer1_bluez5.cpp
index 51f2a013..8cddd05e 100644
--- a/src/bluetooth/bluez/obex_transfer1_bluez5.cpp
+++ b/src/bluetooth/bluez/obex_transfer1_bluez5.cpp
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp org.bluez.obex.Transfer1.xml -p obex_transfer1_bluez5
*
- * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
diff --git a/src/bluetooth/bluez/obex_transfer1_bluez5_p.h b/src/bluetooth/bluez/obex_transfer1_bluez5_p.h
index 46b86248..2307f2ae 100644
--- a/src/bluetooth/bluez/obex_transfer1_bluez5_p.h
+++ b/src/bluetooth/bluez/obex_transfer1_bluez5_p.h
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp org.bluez.obex.Transfer1.xml -p obex_transfer1_bluez5
*
- * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
diff --git a/src/bluetooth/bluez/obex_transfer_p.h b/src/bluetooth/bluez/obex_transfer_p.h
index 6578969c..81b9eb22 100644
--- a/src/bluetooth/bluez/obex_transfer_p.h
+++ b/src/bluetooth/bluez/obex_transfer_p.h
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp -p obex_transfer_p.h:obex_transfer.cpp org.openobex.transfer.xml org.openobex.Transfer
*
- * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+ * Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
diff --git a/src/bluetooth/bluez/objectmanager.cpp b/src/bluetooth/bluez/objectmanager.cpp
index 521012f6..a8e8fdba 100644
--- a/src/bluetooth/bluez/objectmanager.cpp
+++ b/src/bluetooth/bluez/objectmanager.cpp
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp -p objectmanager -v -i bluez5_helper.h org.freedesktop.dbus.objectmanager.xml
*
- * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
diff --git a/src/bluetooth/bluez/objectmanager_p.h b/src/bluetooth/bluez/objectmanager_p.h
index 5ecde487..823badeb 100644
--- a/src/bluetooth/bluez/objectmanager_p.h
+++ b/src/bluetooth/bluez/objectmanager_p.h
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp -p objectmanager -v -i bluez5_helper.h org.freedesktop.dbus.objectmanager.xml
*
- * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
diff --git a/src/bluetooth/bluez/profile1.cpp b/src/bluetooth/bluez/profile1.cpp
index 2cf15d7e..c289c89b 100644
--- a/src/bluetooth/bluez/profile1.cpp
+++ b/src/bluetooth/bluez/profile1.cpp
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp -p profile1 org.bluez.ProfileManager1.xml
*
- * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
diff --git a/src/bluetooth/bluez/profile1_p.h b/src/bluetooth/bluez/profile1_p.h
index d94f1916..a08f10e0 100644
--- a/src/bluetooth/bluez/profile1_p.h
+++ b/src/bluetooth/bluez/profile1_p.h
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp -p profile1 org.bluez.ProfileManager1.xml
*
- * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
diff --git a/src/bluetooth/bluez/properties.cpp b/src/bluetooth/bluez/properties.cpp
index 53c9021c..4ddbc30c 100644
--- a/src/bluetooth/bluez/properties.cpp
+++ b/src/bluetooth/bluez/properties.cpp
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp -p properties -v org.freedesktop.dbus.properties.xml
*
- * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
diff --git a/src/bluetooth/bluez/properties_p.h b/src/bluetooth/bluez/properties_p.h
index 44a79664..daadfefc 100644
--- a/src/bluetooth/bluez/properties_p.h
+++ b/src/bluetooth/bluez/properties_p.h
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp -p properties -v org.freedesktop.dbus.properties.xml
*
- * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
diff --git a/src/bluetooth/bluez/service.cpp b/src/bluetooth/bluez/service.cpp
index fb9c2e9c..2004bea7 100644
--- a/src/bluetooth/bluez/service.cpp
+++ b/src/bluetooth/bluez/service.cpp
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp -p service_p.h:service.cpp org.bluez.all.xml org.bluez.Service
*
- * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+ * Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
diff --git a/src/bluetooth/bluez/service_p.h b/src/bluetooth/bluez/service_p.h
index 3e13e672..e8c5e1f4 100644
--- a/src/bluetooth/bluez/service_p.h
+++ b/src/bluetooth/bluez/service_p.h
@@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp -p service_p.h:service.cpp org.bluez.all.xml org.bluez.Service
*
- * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+ * Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
diff --git a/src/bluetooth/bluez/servicemap.cpp b/src/bluetooth/bluez/servicemap.cpp
index 411eb6d8..dcc8760a 100644
--- a/src/bluetooth/bluez/servicemap.cpp
+++ b/src/bluetooth/bluez/servicemap.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/bluez/servicemap_p.h b/src/bluetooth/bluez/servicemap_p.h
index 6ae3afb3..56f8d61e 100644
--- a/src/bluetooth/bluez/servicemap_p.h
+++ b/src/bluetooth/bluez/servicemap_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp b/src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp
index d8e5b23f..1eec9206 100644
--- a/src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp
+++ b/src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
@@ -190,7 +190,7 @@ void MyClass::characteristicChanged(const QLowEnergyCharacteristic &, const QByt
void MyClass::btleSharedData()
{
- QBluetoothAddress remoteDevice;
+ QBluetoothDeviceInfo remoteDevice;
//! [data_share_qlowenergyservice]
QLowEnergyService *first, *second;
@@ -213,7 +213,7 @@ void MyClass::btleSharedData()
void MyClass::enableCharNotifications()
{
- QBluetoothAddress remoteDevice;
+ QBluetoothDeviceInfo remoteDevice;
QLowEnergyService *service;
QLowEnergyController *control = new QLowEnergyController(remoteDevice, this);
control->connectToDevice();
diff --git a/src/bluetooth/doc/snippets/doc_src_qtbluetooth.qml b/src/bluetooth/doc/snippets/doc_src_qtbluetooth.qml
index eac7c144..fcafbd53 100644
--- a/src/bluetooth/doc/snippets/doc_src_qtbluetooth.qml
+++ b/src/bluetooth/doc/snippets/doc_src_qtbluetooth.qml
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/src/bluetooth/doc/src/bluetooth-cpp.qdoc b/src/bluetooth/doc/src/bluetooth-cpp.qdoc
index df18cc6a..ae39772f 100644
--- a/src/bluetooth/doc/src/bluetooth-cpp.qdoc
+++ b/src/bluetooth/doc/src/bluetooth-cpp.qdoc
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt local connectivty modules.
**
@@ -10,15 +10,15 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
+** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
diff --git a/src/bluetooth/doc/src/bluetooth-index.qdoc b/src/bluetooth/doc/src/bluetooth-index.qdoc
index 112444a8..df7306b4 100644
--- a/src/bluetooth/doc/src/bluetooth-index.qdoc
+++ b/src/bluetooth/doc/src/bluetooth-index.qdoc
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
@@ -10,15 +10,15 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
+** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
@@ -33,11 +33,9 @@
The Bluetooth API provides connectivity between Bluetooth enabled devices.
-Currently the API is supported on \l{Qt for Android}{Android},
-\l{Qt for BlackBerry}{BlackBerry 10} and
-\l{Qt for Linux/X11}{Linux} (\l{http://www.bluez.org}{BlueZ 4.x/5.x}).
-
-
+Currently, the API is supported on the following platforms: \l{Qt for Android}{Android},
+\l{Qt for BlackBerry}{BlackBerry 10}, \l{Qt for iOS}{iOS}, \l{Qt for Linux/X11}{Linux}
+(\l{http://www.bluez.org}{BlueZ 4.x/5.x}) and \l{Qt for OS X}{OS X}.
\section1 Overview
@@ -47,11 +45,9 @@ for transferring data between devices. Bluetooth connectivity is based on
basic device management, such as scanning for devices, gathering information
about them, and exchanging data between them.
-This Qt release contains a Technology Preview of the new Qt Bluetooth
+Qt 5.5 contains the first full release of the new Qt Bluetooth
Low Energy API. Further details can be found in the
\l {Bluetooth Low Energy Overview}{Bluetooth Low Energy Overview} section.
-The Tech Preview supports BlueZ 4 & 5 based Linux systems. Support for
-further platforms is being planned.
\section1 Getting Started
@@ -70,7 +66,7 @@ import statement in your \c .qml file:
\section2 Guides
\list
\li \l {Qt Bluetooth Overview}{Classic Bluetooth Overview}
- \li \l {Bluetooth Low Energy Overview} (Tech Preview)
+ \li \l {Bluetooth Low Energy Overview}
\endlist
\section2 Reference
diff --git a/src/bluetooth/doc/src/bluetooth-le-overview.qdoc b/src/bluetooth/doc/src/bluetooth-le-overview.qdoc
index 029171f4..909beae2 100644
--- a/src/bluetooth/doc/src/bluetooth-le-overview.qdoc
+++ b/src/bluetooth/doc/src/bluetooth-le-overview.qdoc
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt local connectivty modules.
**
@@ -10,15 +10,15 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
+** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
@@ -34,17 +34,10 @@ Low Energy devices.
\tableofcontents
- \section1 Technology Preview
-
- The Qt Bluetooth Low Energy API has been introduced in Qt 5.4.
- The API is considered to be a preview of the technology and currently only works
- on BlueZ 4 & 5 based Linux systems. Support for further platforms, for example Android,
- is currently being worked on and will be added by later Qt releases. In addition,
- Qt only supports the central role. For more details on this limitation see below.
-
- While the API is not yet frozen it is close to its final stage.
- We would like to encourage you to send us feedback and bug reports related to
- this new feature.
+ The Qt Bluetooth Low Energy API was introduced by Qt 5.4. Since Qt 5.5 the API
+ is frozen and a compatibility guarantee is given for future releases.
+ At the moment, Qt supports the Bluetooth Low Energy central role.
+ For more details on this limitation see below.
\section1 What Is Bluetooth Low Energy
@@ -171,9 +164,6 @@ Low Energy devices.
and writing data stored on the device. The example code below is taken from the
\l {heartlistener}{Heart Listener} example.
- \note As of Qt 5.4 the Qt Bluetooth Low Energy API is in tech preview mode and supports Linux
- with BlueZ 4.101 & 5.x. The minimal Linux kernel version is 3.5.
-
\section2 Establishing a Connection
To be able to read and write the characteristics of the Bluetooth Low Energy peripheral device,
diff --git a/src/bluetooth/doc/src/bluetooth-overview.qdoc b/src/bluetooth/doc/src/bluetooth-overview.qdoc
index 1aa0d28d..1b712f23 100644
--- a/src/bluetooth/doc/src/bluetooth-overview.qdoc
+++ b/src/bluetooth/doc/src/bluetooth-overview.qdoc
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt local connectivty modules.
**
@@ -10,15 +10,15 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
+** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
diff --git a/src/bluetooth/doc/src/bluetooth-qml.qdoc b/src/bluetooth/doc/src/bluetooth-qml.qdoc
index 9c9fe0aa..2fb64f45 100644
--- a/src/bluetooth/doc/src/bluetooth-qml.qdoc
+++ b/src/bluetooth/doc/src/bluetooth-qml.qdoc
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt local connectivty modules.
**
@@ -10,15 +10,15 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
+** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
diff --git a/src/bluetooth/doc/src/examples.qdoc b/src/bluetooth/doc/src/examples.qdoc
index 7eb26cab..d21c7932 100644
--- a/src/bluetooth/doc/src/examples.qdoc
+++ b/src/bluetooth/doc/src/examples.qdoc
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
@@ -10,15 +10,15 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
+** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
diff --git a/src/bluetooth/osx/corebluetoothwrapper_p.h b/src/bluetooth/osx/corebluetoothwrapper_p.h
new file mode 100644
index 00000000..d0b6f23c
--- /dev/null
+++ b/src/bluetooth/osx/corebluetoothwrapper_p.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef COREBLUETOOTHWRAPPER_P_H
+#define COREBLUETOOTHWRAPPER_P_H
+
+#ifndef QT_OSX_BLUETOOTH
+
+#import <CoreBluetooth/CoreBluetooth.h>
+
+#else
+
+#include <QtCore/qglobal.h>
+
+// CoreBluetooth with SDK 10.9 seems to be broken: the class CBPeripheralManager is enabled on OS X 10.9,
+// but some of its declarations are using a disabled enum CBPeripheralAuthorizationStatus
+// (disabled using __attribute__ syntax and NS_ENUM_AVAILABLE macro).
+// This + -std=c++11 ends with a compilation error. For the SDK 10.9 we can:
+// either undefine NS_ENUM_AVAILABLE macro (it works somehow) and redefine it as an empty sequence of pp-tokens or
+// define __attribute__ as an empty sequence. Both solutions look quite ugly.
+
+#if QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9) && !QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_10)
+#define CB_ERROR_WORKAROUND_REQUIRED
+#endif
+
+#ifdef CB_ERROR_WORKAROUND_REQUIRED
+#undef NS_ENUM_AVAILABLE
+#define NS_ENUM_AVAILABLE(_mac, _ios)
+#endif
+
+#import <IOBluetooth/IOBluetooth.h>
+
+#ifdef CB_ERROR_WORKAROUND_REQUIRED
+#undef __attribute__
+#undef CB_ERROR_WORKAROUND_REQUIRED
+#endif
+
+#endif // QT_OSX_BLUETOOTH
+
+#endif // COREBLUETOOTHWRAPPER_P_H
diff --git a/src/bluetooth/osx/osxbt.pri b/src/bluetooth/osx/osxbt.pri
new file mode 100644
index 00000000..06389fcc
--- /dev/null
+++ b/src/bluetooth/osx/osxbt.pri
@@ -0,0 +1,42 @@
+SOURCES += osx/uistrings.cpp
+PRIVATE_HEADERS += osx/uistrings_p.h
+
+CONFIG(osx) {
+ PRIVATE_HEADERS += osx/osxbtutility_p.h \
+ osx/osxbtdevicepair_p.h \
+ osx/osxbtdeviceinquiry_p.h \
+ osx/osxbtconnectionmonitor_p.h \
+ osx/osxbtsdpinquiry_p.h \
+ osx/osxbtrfcommchannel_p.h \
+ osx/osxbtl2capchannel_p.h \
+ osx/osxbtchanneldelegate_p.h \
+ osx/osxbtservicerecord_p.h \
+ osx/osxbtsocketlistener_p.h \
+ osx/osxbtobexsession_p.h \
+ osx/osxbtledeviceinquiry_p.h \
+ osx/corebluetoothwrapper_p.h \
+ osx/osxbtcentralmanager_p.h
+
+ OBJECTIVE_SOURCES += osx/osxbtutility.mm \
+ osx/osxbtdevicepair.mm \
+ osx/osxbtdeviceinquiry.mm \
+ osx/osxbtconnectionmonitor.mm \
+ osx/osxbtsdpinquiry.mm \
+ osx/osxbtrfcommchannel.mm \
+ osx/osxbtl2capchannel.mm \
+ osx/osxbtchanneldelegate.mm \
+ osx/osxbtservicerecord.mm \
+ osx/osxbtsocketlistener.mm \
+ osx/osxbtobexsession.mm \
+ osx/osxbtledeviceinquiry.mm \
+ osx/osxbtcentralmanager.mm
+} else {
+ PRIVATE_HEADERS += osx/osxbtutility_p.h \
+ osx/osxbtledeviceinquiry_p.h \
+ osx/corebluetoothwrapper_p.h \
+ osx/osxbtcentralmanager_p.h
+
+ OBJECTIVE_SOURCES += osx/osxbtutility.mm \
+ osx/osxbtledeviceinquiry.mm \
+ osx/osxbtcentralmanager.mm
+}
diff --git a/src/bluetooth/osx/osxbtcentralmanager.mm b/src/bluetooth/osx/osxbtcentralmanager.mm
new file mode 100644
index 00000000..08905da8
--- /dev/null
+++ b/src/bluetooth/osx/osxbtcentralmanager.mm
@@ -0,0 +1,1591 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlowenergyserviceprivate_p.h"
+#include "qlowenergycharacteristic.h"
+#include "osxbtcentralmanager_p.h"
+
+
+#include <QtCore/qloggingcategory.h>
+#include <QtCore/qsysinfo.h>
+#include <QtCore/qdebug.h>
+
+#include <algorithm>
+#include <limits>
+
+QT_BEGIN_NAMESPACE
+
+namespace OSXBluetooth {
+
+CentralManagerDelegate::~CentralManagerDelegate()
+{
+}
+
+NSUInteger qt_countGATTEntries(CBService *service)
+{
+ // Identify, how many characteristics/descriptors we have on a given service,
+ // +1 for the service itself.
+ // No checks if NSUInteger is big enough :)
+ // Let's assume such number of entries is not possible :)
+
+ Q_ASSERT_X(service, Q_FUNC_INFO, "invalid service (nil)");
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ NSArray *const cs = service.characteristics;
+ if (!cs || !cs.count)
+ return 1;
+
+ NSUInteger n = 1 + cs.count;
+ for (CBCharacteristic *c in cs) {
+ NSArray *const ds = c.descriptors;
+ if (ds)
+ n += ds.count;
+ }
+
+ return n;
+}
+
+}
+
+QT_END_NAMESPACE
+
+
+#ifdef QT_NAMESPACE
+using namespace QT_NAMESPACE;
+#endif
+
+@interface QT_MANGLE_NAMESPACE(OSXBTCentralManager) (PrivateAPI)
+
+- (QLowEnergyController::Error)connectToDevice; // "Device" is in Qt's world ...
+- (void)connectToPeripheral; // "Peripheral" is in Core Bluetooth.
+- (void)discoverIncludedServices;
+- (void)readCharacteristics:(CBService *)service;
+- (void)serviceDetailsDiscoveryFinished:(CBService *)service;
+- (void)performNextRequest;
+- (void)performNextReadRequest;
+- (void)performNextWriteRequest;
+
+// Aux. functions.
+- (CBService *)serviceForUUID:(const QBluetoothUuid &)qtUuid;
+- (CBCharacteristic *)nextCharacteristicForService:(CBService*)service
+ startingFrom:(CBCharacteristic *)from;
+- (CBCharacteristic *)nextCharacteristicForService:(CBService*)service
+ startingFrom:(CBCharacteristic *)from
+ withProperties:(CBCharacteristicProperties)properties;
+- (CBDescriptor *)nextDescriptorForCharacteristic:(CBCharacteristic *)characteristic
+ startingFrom:(CBDescriptor *)descriptor;
+- (CBDescriptor *)descriptor:(const QBluetoothUuid &)dUuid
+ forCharacteristic:(CBCharacteristic *)ch;
+- (bool)cacheWriteValue:(const QByteArray &)value for:(NSObject *)obj;
+- (void)reset;
+
+@end
+
+@implementation QT_MANGLE_NAMESPACE(OSXBTCentralManager)
+
+- (id)initWithDelegate:(QT_PREPEND_NAMESPACE(OSXBluetooth)::CentralManagerDelegate *)aDelegate
+{
+ Q_ASSERT_X(aDelegate, Q_FUNC_INFO, "invalid delegate (null)");
+
+ if (self = [super init]) {
+ manager = nil;
+ managerState = OSXBluetooth::CentralManagerIdle;
+ disconnectPending = false;
+ peripheral = nil;
+ delegate = aDelegate;
+ currentService = 0;
+ lastValidHandle = 0;
+ requestPending = false;
+ currentReadHandle = 0;
+ }
+
+ return self;
+}
+
+- (void)dealloc
+{
+ // In the past I had a 'transient delegate': I've seen some crashes
+ // while deleting a manager _before_ its state updated.
+ // Strangely enough, I can not reproduce this anymore, so this
+ // part is simplified now. To be investigated though.
+
+ visitedServices.reset(nil);
+ servicesToVisit.reset(nil);
+ servicesToVisitNext.reset(nil);
+
+ [manager setDelegate:nil];
+ [manager release];
+
+ [peripheral setDelegate:nil];
+ [peripheral release];
+
+ [super dealloc];
+}
+
+- (QLowEnergyController::Error)connectToDevice:(const QBluetoothUuid &)aDeviceUuid
+{
+ Q_ASSERT_X(managerState == OSXBluetooth::CentralManagerIdle,
+ Q_FUNC_INFO, "invalid state");
+
+ deviceUuid = aDeviceUuid;
+
+ if (!manager) {
+ managerState = OSXBluetooth::CentralManagerUpdating; // We'll have to wait for updated state.
+ manager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
+ if (!manager) {
+ managerState = OSXBluetooth::CentralManagerIdle;
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to allocate a "
+ "central manager";
+ return QLowEnergyController::ConnectionError;
+ }
+ return QLowEnergyController::NoError;
+ } else {
+ return [self connectToDevice];
+ }
+}
+
+- (QLowEnergyController::Error)connectToDevice
+{
+ Q_ASSERT_X(manager, Q_FUNC_INFO, "invalid central manager (nil)");
+ Q_ASSERT_X(managerState == OSXBluetooth::CentralManagerIdle,
+ Q_FUNC_INFO, "invalid state");
+
+ if ([self isConnected]) {
+ qCDebug(QT_BT_OSX) << Q_FUNC_INFO << "already connected";
+ delegate->connectSuccess();
+ return QLowEnergyController::NoError;
+ } else if (peripheral) {
+ // Was retrieved already, but not connected
+ // or disconnected.
+ [self connectToPeripheral];
+ return QLowEnergyController::NoError;
+ }
+
+ using namespace OSXBluetooth;
+
+ // Retrieve a peripheral first ...
+ ObjCScopedPointer<NSMutableArray> uuids([[NSMutableArray alloc] init]);
+ if (!uuids) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to allocate identifiers";
+ return QLowEnergyController::ConnectionError;
+ }
+
+#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9, __IPHONE_6_0)
+ if (QSysInfo::MacintoshVersion >= qt_OS_limit(QSysInfo::MV_10_9, QSysInfo::MV_IOS_6_0)) {
+ const quint128 qtUuidData(deviceUuid.toUInt128());
+ // STATIC_ASSERT on sizes would be handy!
+ uuid_t uuidData = {};
+ std::copy(qtUuidData.data, qtUuidData.data + 16, uuidData);
+ const ObjCScopedPointer<NSUUID> nsUuid([[NSUUID alloc] initWithUUIDBytes:uuidData]);
+ if (!nsUuid) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to allocate NSUUID identifier";
+ return QLowEnergyController::ConnectionError;
+ }
+
+ [uuids addObject:nsUuid];
+
+ // With the latest CoreBluetooth, we can synchronously retrive peripherals:
+ QT_BT_MAC_AUTORELEASEPOOL;
+ NSArray *const peripherals = [manager retrievePeripheralsWithIdentifiers:uuids];
+ if (!peripherals || peripherals.count != 1) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to retrive a peripheral";
+ return QLowEnergyController::UnknownRemoteDeviceError;
+ }
+
+ peripheral = [static_cast<CBPeripheral *>([peripherals objectAtIndex:0]) retain];
+ [self connectToPeripheral];
+
+ return QLowEnergyController::NoError;
+ }
+#endif
+ OSXBluetooth::CFStrongReference<CFUUIDRef> cfUuid(OSXBluetooth::cf_uuid(deviceUuid));
+ if (!cfUuid) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to create CFUUID object";
+ return QLowEnergyController::ConnectionError;
+ }
+ // TODO: With ARC this cast will be illegal:
+ [uuids addObject:(id)cfUuid.data()];
+ // Unfortunately, with old Core Bluetooth this call is asynchronous ...
+ managerState = OSXBluetooth::CentralManagerConnecting;
+ [manager retrievePeripherals:uuids];
+
+ return QLowEnergyController::NoError;
+}
+
+- (void)connectToPeripheral
+{
+ Q_ASSERT_X(manager, Q_FUNC_INFO, "invalid central manager (nil)");
+ Q_ASSERT_X(peripheral, Q_FUNC_INFO, "invalid peripheral (nil)");
+ Q_ASSERT_X(managerState == OSXBluetooth::CentralManagerIdle,
+ Q_FUNC_INFO, "invalid state");
+
+ // The state is still the same - connecting.
+ if ([self isConnected]) {
+ qCDebug(QT_BT_OSX) << Q_FUNC_INFO << "already connected";
+ delegate->connectSuccess();
+ } else {
+ qCDebug(QT_BT_OSX) << Q_FUNC_INFO << "trying to connect";
+ managerState = OSXBluetooth::CentralManagerConnecting;
+ [manager connectPeripheral:peripheral options:nil];
+ }
+}
+
+- (bool)isConnected
+{
+ if (!peripheral)
+ return false;
+
+#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9, __IPHONE_7_0)
+ using OSXBluetooth::qt_OS_limit;
+
+ if (QSysInfo::MacintoshVersion >= qt_OS_limit(QSysInfo::MV_10_9, QSysInfo::MV_IOS_7_0))
+ return peripheral.state == CBPeripheralStateConnected;
+#endif
+ return peripheral.isConnected;
+}
+
+- (void)disconnectFromDevice
+{
+ [self reset];
+
+ if (managerState == OSXBluetooth::CentralManagerUpdating) {
+ disconnectPending = true;
+ } else {
+ disconnectPending = false;
+
+ if ([self isConnected])
+ managerState = OSXBluetooth::CentralManagerDisconnecting;
+ else
+ managerState = OSXBluetooth::CentralManagerIdle;
+
+ // We have to call -cancelPeripheralConnection: even
+ // if not connected (to cancel a pending connect attempt).
+ // Unfortunately, didDisconnect callback is not always called
+ // (despite of Apple's docs saying it _must_).
+ [manager cancelPeripheralConnection:peripheral];
+ }
+}
+
+- (void)discoverServices
+{
+ Q_ASSERT_X(peripheral, Q_FUNC_INFO, "invalid peripheral (nil)");
+ Q_ASSERT_X(managerState == OSXBluetooth::CentralManagerIdle,
+ Q_FUNC_INFO, "invalid state");
+
+ // From Apple's docs:
+ //
+ //"If the servicesUUIDs parameter is nil, all the available
+ //services of the peripheral are returned; setting the
+ //parameter to nil is considerably slower and is not recommended."
+ //
+ // ... but we'd like to have them all:
+
+ [peripheral setDelegate:self];
+ managerState = OSXBluetooth::CentralManagerDiscovering;
+ [peripheral discoverServices:nil];
+}
+
+- (void)discoverIncludedServices
+{
+ using namespace OSXBluetooth;
+
+ Q_ASSERT_X(managerState == CentralManagerIdle, Q_FUNC_INFO,
+ "invalid state");
+ Q_ASSERT_X(manager, Q_FUNC_INFO, "invalid manager (nil)");
+ Q_ASSERT_X(peripheral, Q_FUNC_INFO, "invalid peripheral (nil)");
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ NSArray *const services = peripheral.services;
+ if (!services || !services.count) { // Actually, !services.count works in both cases, but ...
+ // A peripheral without any services at all.
+ Q_ASSERT_X(delegate, Q_FUNC_INFO,
+ "invalid delegate (null)");
+ delegate->serviceDiscoveryFinished(ObjCStrongReference<NSArray>());
+ } else {
+ // 'reset' also calls retain on a parameter.
+ servicesToVisitNext.reset(nil);
+ servicesToVisit.reset([NSMutableArray arrayWithArray:services]);
+ currentService = 0;
+ visitedServices.reset([NSMutableSet setWithCapacity:peripheral.services.count]);
+
+ CBService *const s = [services objectAtIndex:currentService];
+ [visitedServices addObject:s];
+ managerState = CentralManagerDiscovering;
+ [peripheral discoverIncludedServices:nil forService:s];
+ }
+}
+
+- (bool)discoverServiceDetails:(const QBluetoothUuid &)serviceUuid
+{
+ // This function does not change 'managerState', since it
+ // can be called concurrently (not waiting for the previous
+ // discovery to finish).
+
+ using namespace OSXBluetooth;
+
+ Q_ASSERT_X(managerState != CentralManagerUpdating, Q_FUNC_INFO, "invalid state");
+ Q_ASSERT_X(!serviceUuid.isNull(), Q_FUNC_INFO, "invalid service UUID");
+ Q_ASSERT_X(peripheral, Q_FUNC_INFO, "invalid peripheral (nil)");
+
+ if (servicesToDiscoverDetails.contains(serviceUuid)) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO <<"already discovering for "
+ << serviceUuid;
+ return true;
+ }
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ if (CBService *const service = [self serviceForUUID:serviceUuid]) {
+ servicesToDiscoverDetails.append(serviceUuid);
+ [peripheral discoverCharacteristics:nil forService:service];
+ return true;
+ }
+
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "unknown service uuid "
+ << serviceUuid;
+
+ return false;
+}
+
+- (void)readCharacteristics:(CBService *)service
+{
+ // This method does not change 'managerState', we can
+ // have several 'detail discoveries' active.
+ Q_ASSERT_X(service, Q_FUNC_INFO, "invalid service (nil)");
+
+ using namespace OSXBluetooth;
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ Q_ASSERT_X(managerState != CentralManagerUpdating, Q_FUNC_INFO,
+ "invalid state");
+ Q_ASSERT_X(manager, Q_FUNC_INFO, "invalid manager (nil)");
+ Q_ASSERT_X(peripheral, Q_FUNC_INFO, "invalid peripheral (nil)");
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+
+ if (!service.characteristics || !service.characteristics.count)
+ return [self serviceDetailsDiscoveryFinished:service];
+
+ NSArray *const cs = service.characteristics;
+ for (CBCharacteristic *c in cs) {
+ if (c.properties & CBCharacteristicPropertyRead)
+ return [peripheral readValueForCharacteristic:c];
+ }
+
+ // No readable properties? Discover descriptors then:
+ [self discoverDescriptors:service];
+}
+
+- (void)discoverDescriptors:(CBService *)service
+{
+ // This method does not change 'managerState', we can have
+ // several discoveries active.
+ Q_ASSERT_X(service, Q_FUNC_INFO, "invalid service (nil)");
+
+ using namespace OSXBluetooth;
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ Q_ASSERT_X(managerState != CentralManagerUpdating,
+ Q_FUNC_INFO, "invalid state");
+ Q_ASSERT_X(manager, Q_FUNC_INFO, "invalid manager (nil)");
+ Q_ASSERT_X(peripheral, Q_FUNC_INFO, "invalid peripheral (nil)");
+
+ if (!service.characteristics || !service.characteristics.count) {
+ [self serviceDetailsDiscoveryFinished:service];
+ } else {
+ // Start from 0 and continue in the callback.
+ [peripheral discoverDescriptorsForCharacteristic:[service.characteristics objectAtIndex:0]];
+ }
+}
+
+- (void)readDescriptors:(CBService *)service
+{
+ Q_ASSERT_X(service, "-readDescriptors:",
+ "invalid service (nil)");
+ Q_ASSERT_X(managerState != OSXBluetooth::CentralManagerUpdating,
+ "-readDescriptors:",
+ "invalid state");
+ Q_ASSERT_X(peripheral, "-readDescriptors:",
+ "invalid peripheral (nil)");
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ NSArray *const cs = service.characteristics;
+ // We can never be here if we have no characteristics.
+ Q_ASSERT_X(cs && cs.count, "-readDescriptors:",
+ "invalid service");
+ for (CBCharacteristic *c in cs) {
+ if (c.descriptors && c.descriptors.count)
+ return [peripheral readValueForDescriptor:[c.descriptors objectAtIndex:0]];
+ }
+
+ // No descriptors to read, done.
+ [self serviceDetailsDiscoveryFinished:service];
+}
+
+- (void)serviceDetailsDiscoveryFinished:(CBService *)service
+{
+ //
+ Q_ASSERT_X(service, Q_FUNC_INFO, "invalid service (nil)");
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+
+ using namespace OSXBluetooth;
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ const QBluetoothUuid serviceUuid(qt_uuid(service.UUID));
+ servicesToDiscoverDetails.removeAll(serviceUuid);
+
+ const NSUInteger nHandles = qt_countGATTEntries(service);
+ Q_ASSERT_X(nHandles, Q_FUNC_INFO, "unexpected number of GATT entires");
+
+ const QLowEnergyHandle maxHandle = std::numeric_limits<QLowEnergyHandle>::max();
+ if (nHandles >= maxHandle || lastValidHandle > maxHandle - nHandles) {
+ // Well, that's unlikely :) But we must be sure.
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "can not allocate more handles";
+ delegate->error(serviceUuid, QLowEnergyService::OperationError);
+ return;
+ }
+
+ // A temporary service object to pass the details.
+ // Set only uuid, characteristics and descriptors (and probably values),
+ // nothing else is needed.
+ QSharedPointer<QLowEnergyServicePrivate> qtService(new QLowEnergyServicePrivate);
+ qtService->uuid = serviceUuid;
+ // We 'register' handles/'CBentities' even if qlowenergycontroller (delegate)
+ // later fails to do this with some error. Otherwise, if we try to implement
+ // rollback/transaction logic interface is getting too ugly/complicated.
+ ++lastValidHandle;
+ serviceMap[lastValidHandle] = service;
+ qtService->startHandle = lastValidHandle;
+
+ NSArray *const cs = service.characteristics;
+ // Now map chars/descriptors and handles.
+ if (cs && cs.count) {
+ QHash<QLowEnergyHandle, QLowEnergyServicePrivate::CharData> charList;
+
+ for (CBCharacteristic *c in cs) {
+ ++lastValidHandle;
+ // Register this characteristic:
+ charMap[lastValidHandle] = c;
+ // Create a Qt's internal characteristic:
+ QLowEnergyServicePrivate::CharData newChar = {};
+ newChar.uuid = qt_uuid(c.UUID);
+ const int cbProps = c.properties & 0xff;
+ newChar.properties = static_cast<QLowEnergyCharacteristic::PropertyTypes>(cbProps);
+ newChar.value = qt_bytearray(c.value);
+ newChar.valueHandle = lastValidHandle;
+
+ NSArray *const ds = c.descriptors;
+ if (ds && ds.count) {
+ QHash<QLowEnergyHandle, QLowEnergyServicePrivate::DescData> descList;
+ for (CBDescriptor *d in ds) {
+ // Register this descriptor:
+ ++lastValidHandle;
+ descMap[lastValidHandle] = d;
+ // Create a Qt's internal descriptor:
+ QLowEnergyServicePrivate::DescData newDesc = {};
+ newDesc.uuid = qt_uuid(d.UUID);
+ newDesc.value = qt_bytearray(static_cast<NSObject *>(d.value));
+ descList[lastValidHandle] = newDesc;
+ // Check, if it's client characteristic configuration descriptor:
+ if (newDesc.uuid == QBluetoothUuid::ClientCharacteristicConfiguration) {
+ if (newDesc.value.size() && (newDesc.value[0] & 3))
+ [peripheral setNotifyValue:YES forCharacteristic:c];
+ }
+ }
+
+ newChar.descriptorList = descList;
+ }
+
+ charList[newChar.valueHandle] = newChar;
+ }
+
+ qtService->characteristicList = charList;
+ }
+
+ qtService->endHandle = lastValidHandle;
+
+ ObjCStrongReference<CBService> leService(service, true);
+ delegate->serviceDetailsDiscoveryFinished(qtService);
+}
+
+- (void)performNextRequest
+{
+ using namespace OSXBluetooth;
+
+ if (requestPending || !requests.size())
+ return;
+
+ switch (requests.head().type) {
+ case LERequest::CharRead:
+ case LERequest::DescRead:
+ return [self performNextReadRequest];
+ case LERequest::CharWrite:
+ case LERequest::DescWrite:
+ case LERequest::ClientConfiguration:
+ return [self performNextWriteRequest];
+ default:
+ // Should never happen.
+ Q_ASSERT(0);
+ }
+}
+
+- (void)performNextReadRequest
+{
+ using namespace OSXBluetooth;
+
+ Q_ASSERT_X(peripheral, Q_FUNC_INFO, "invalid peripheral (nil)");
+ Q_ASSERT_X(!requestPending, Q_FUNC_INFO, "processing another request");
+ Q_ASSERT_X(requests.size(), Q_FUNC_INFO, "no requests to handle");
+ Q_ASSERT_X(requests.head().type == LERequest::CharRead
+ || requests.head().type == LERequest::DescRead,
+ Q_FUNC_INFO, "not a read request");
+
+ const LERequest request(requests.dequeue());
+ if (request.type == LERequest::CharRead) {
+ if (!charMap.contains(request.handle)) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "characteristic with handle"
+ << request.handle << "not found";
+ return [self performNextRequest];
+ }
+
+ requestPending = true;
+ currentReadHandle = request.handle;
+ [peripheral readValueForCharacteristic:charMap[request.handle]];
+ } else {
+ if (!descMap.contains(request.handle)) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "descriptor with handle"
+ << request.handle << "not found";
+ return [self performNextRequest];
+ }
+
+ requestPending = true;
+ currentReadHandle = request.handle;
+ [peripheral readValueForDescriptor:descMap[request.handle]];
+ }
+}
+
+- (void)performNextWriteRequest
+{
+ using namespace OSXBluetooth;
+
+ Q_ASSERT_X(peripheral, Q_FUNC_INFO, "invalid peripheral (nil)");
+ Q_ASSERT_X(!requestPending, Q_FUNC_INFO, "processing another request");
+ Q_ASSERT_X(requests.size(), Q_FUNC_INFO, "no requests to handle");
+ Q_ASSERT_X(requests.head().type == LERequest::CharWrite
+ || requests.head().type == LERequest::DescWrite
+ || requests.head().type == LERequest::ClientConfiguration,
+ Q_FUNC_INFO, "not a write request");
+
+ const LERequest request(requests.dequeue());
+
+ if (request.type == LERequest::DescWrite) {
+ if (!descMap.contains(request.handle)) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "handle: "
+ << request.handle << " not found";
+ return [self performNextRequest];
+ }
+
+ CBDescriptor *const descriptor = descMap[request.handle];
+ ObjCStrongReference<NSData> data(data_from_bytearray(request.value));
+ if (!data) {
+ // Even if qtData.size() == 0, we still need NSData object.
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed "
+ "to allocate an NSData object";
+ return [self performNextRequest];
+ }
+
+ if (![self cacheWriteValue:request.value for:descriptor])
+ return [self performNextRequest];
+
+ requestPending = true;
+ return [peripheral writeValue:data.data() forDescriptor:descriptor];
+ } else {
+ if (!charMap.contains(request.handle)) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "characteristic with "
+ "handle: " << request.handle << " not found";
+ return [self performNextRequest];
+ }
+
+ CBCharacteristic *const characteristic = charMap[request.handle];
+
+ if (request.type == LERequest::ClientConfiguration) {
+ const QBluetoothUuid qtUuid(QBluetoothUuid::ClientCharacteristicConfiguration);
+ CBDescriptor *const descriptor = [self descriptor:qtUuid forCharacteristic:characteristic];
+ Q_ASSERT_X(descriptor, Q_FUNC_INFO, "no client characteristic "
+ "configuration descriptor found");
+
+ if (![self cacheWriteValue:request.value for:descriptor])
+ return [self performNextRequest];
+
+ bool enable = false;
+ if (request.value.size())
+ enable = request.value[0] & 3;
+
+ requestPending = true;
+ [peripheral setNotifyValue:enable forCharacteristic:characteristic];
+ } else {
+ ObjCStrongReference<NSData> data(data_from_bytearray(request.value));
+ if (!data) {
+ // Even if qtData.size() == 0, we still need NSData object.
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to allocate NSData object";
+ return [self performNextRequest];
+ }
+
+ // TODO: check what happens if I'm using NSData with length 0.
+ if (request.withResponse) {
+ if (![self cacheWriteValue:request.value for:characteristic])
+ return [self performNextRequest];
+
+ requestPending = true;
+ [peripheral writeValue:data.data() forCharacteristic:characteristic
+ type:CBCharacteristicWriteWithResponse];
+ } else {
+ [peripheral writeValue:data.data() forCharacteristic:characteristic
+ type:CBCharacteristicWriteWithoutResponse];
+ [self performNextRequest];
+ }
+ }
+ }
+}
+
+- (bool)setNotifyValue:(const QByteArray &)value
+ forCharacteristic:(QT_PREPEND_NAMESPACE(QLowEnergyHandle))charHandle
+{
+ using namespace OSXBluetooth;
+
+ Q_ASSERT_X(charHandle, Q_FUNC_INFO, "invalid characteristic handle (0)");
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+
+ if (!charMap.contains(charHandle)) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO
+ << "unknown characteristic handle " << charHandle;
+ return false;
+ }
+
+ // At the moment we call setNotifyValue _only_ from 'writeDescriptor';
+ // from Qt's API POV it's a descriptor write oprtation and we must report
+ // it back, so check _now_ that we really have this descriptor.
+ const QBluetoothUuid qtUuid(QBluetoothUuid::ClientCharacteristicConfiguration);
+ if (![self descriptor:qtUuid forCharacteristic:charMap[charHandle]]) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO
+ << "no client characteristic configuration found";
+ return false;
+ }
+
+ LERequest request;
+ request.type = LERequest::ClientConfiguration;
+ request.handle = charHandle;
+ request.value = value;
+
+ requests.enqueue(request);
+ [self performNextRequest];
+
+ return true;
+}
+
+- (bool)readCharacteristic:(QT_PREPEND_NAMESPACE(QLowEnergyHandle))charHandle
+{
+ using namespace OSXBluetooth;
+
+ Q_ASSERT_X(charHandle, Q_FUNC_INFO, "invalid characteristic handle (0)");
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ if (!charMap.contains(charHandle)) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "characteristic: " << charHandle << " not found";
+ return false;
+ }
+
+ LERequest request;
+ request.type = LERequest::CharRead;
+ request.handle = charHandle;
+
+ requests.enqueue(request);
+ [self performNextRequest];
+
+ return true;
+}
+
+- (bool)write:(const QT_PREPEND_NAMESPACE(QByteArray) &)value
+ charHandle:(QT_PREPEND_NAMESPACE(QLowEnergyHandle))charHandle
+ withResponse:(bool)withResponse
+{
+ using namespace OSXBluetooth;
+
+ Q_ASSERT_X(charHandle, Q_FUNC_INFO, "invalid characteristic handle (0)");
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ if (!charMap.contains(charHandle)) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "characteristic: " << charHandle << " not found";
+ return false;
+ }
+
+ LERequest request;
+ request.type = LERequest::CharWrite;
+ request.withResponse = withResponse;
+ request.handle = charHandle;
+ request.value = value;
+
+ requests.enqueue(request);
+ [self performNextRequest];
+
+ return true;
+}
+
+- (bool)readDescriptor:(QT_PREPEND_NAMESPACE(QLowEnergyHandle))descHandle
+{
+ using namespace OSXBluetooth;
+
+ Q_ASSERT_X(descHandle, Q_FUNC_INFO, "invalid descriptor handle (0)");
+
+ if (!descMap.contains(descHandle)) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "handle:"
+ << descHandle << "not found";
+ return false;
+ }
+
+ LERequest request;
+ request.type = LERequest::DescRead;
+ request.handle = descHandle;
+
+ requests.enqueue(request);
+ [self performNextRequest];
+
+ return true;
+}
+
+- (bool)write:(const QByteArray &)value descHandle:(QLowEnergyHandle)descHandle
+{
+ using namespace OSXBluetooth;
+
+ Q_ASSERT_X(descHandle, Q_FUNC_INFO, "invalid descriptor handle (0)");
+
+ if (!descMap.contains(descHandle)) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "handle: "
+ << descHandle << " not found";
+ return false;
+ }
+
+ LERequest request;
+ request.type = LERequest::DescWrite;
+ request.handle = descHandle;
+ request.value = value;
+
+ requests.enqueue(request);
+ [self performNextRequest];
+
+ return true;
+}
+
+// Aux. methods:
+
+- (CBService *)serviceForUUID:(const QBluetoothUuid &)qtUuid
+{
+ using namespace OSXBluetooth;
+
+ Q_ASSERT_X(!qtUuid.isNull(), Q_FUNC_INFO, "invalid uuid");
+ Q_ASSERT_X(peripheral, Q_FUNC_INFO, "invalid peripheral (nil)");
+
+ ObjCStrongReference<NSMutableArray> toVisit([NSMutableArray arrayWithArray:peripheral.services], true);
+ ObjCStrongReference<NSMutableArray> toVisitNext([[NSMutableArray alloc] init], false);
+ ObjCStrongReference<NSMutableSet> visitedNodes([[NSMutableSet alloc] init], false);
+
+ while (true) {
+ for (NSUInteger i = 0, e = [toVisit count]; i < e; ++i) {
+ CBService *const s = [toVisit objectAtIndex:i];
+ if (equal_uuids(s.UUID, qtUuid))
+ return s;
+ if ([visitedNodes containsObject:s] && s.includedServices && s.includedServices.count) {
+ [visitedNodes addObject:s];
+ [toVisitNext addObjectsFromArray:s.includedServices];
+ }
+ }
+
+ if (![toVisitNext count])
+ return nil;
+
+ toVisit.resetWithoutRetain(toVisitNext.take());
+ toVisitNext.resetWithoutRetain([[NSMutableArray alloc] init]);
+ }
+
+ return nil;
+}
+
+- (CBCharacteristic *)nextCharacteristicForService:(CBService*)service
+ startingFrom:(CBCharacteristic *)characteristic
+{
+ Q_ASSERT_X(service, Q_FUNC_INFO, "invalid service (nil)");
+ Q_ASSERT_X(characteristic, Q_FUNC_INFO, "invalid characteristic (nil)");
+ Q_ASSERT_X(service.characteristics, Q_FUNC_INFO, "invalid service");
+ Q_ASSERT_X(service.characteristics.count, Q_FUNC_INFO, "invalid service");
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ // TODO: test that we NEVER have the same characteristic twice in array!
+ // At the moment I just protect against this by iterating in a reverse
+ // order (at least avoiding a potential inifite loop with '-indexOfObject:').
+ NSArray *const cs = service.characteristics;
+ if (cs.count == 1)
+ return nil;
+
+ for (NSUInteger index = cs.count - 1; index != 0; --index) {
+ if ([cs objectAtIndex:index] == characteristic) {
+ if (index + 1 == cs.count)
+ return nil;
+ else
+ return [cs objectAtIndex:index + 1];
+ }
+ }
+
+ Q_ASSERT_X([cs objectAtIndex:0] == characteristic, Q_FUNC_INFO,
+ "characteristic was not found in service.characteristics");
+
+ return [cs objectAtIndex:1];
+}
+
+- (CBCharacteristic *)nextCharacteristicForService:(CBService*)service
+ startingFrom:(CBCharacteristic *)characteristic
+ properties:(CBCharacteristicProperties)properties
+{
+ Q_ASSERT_X(service, Q_FUNC_INFO, "invalid service (nil)");
+ Q_ASSERT_X(characteristic, Q_FUNC_INFO, "invalid characteristic (nil)");
+ Q_ASSERT_X(service.characteristics, Q_FUNC_INFO, "invalid service");
+ Q_ASSERT_X(service.characteristics.count, Q_FUNC_INFO, "invalid service");
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ // TODO: test that we NEVER have the same characteristic twice in array!
+ // At the moment I just protect against this by iterating in a reverse
+ // order (at least avoiding a potential inifite loop with '-indexOfObject:').
+ NSArray *const cs = service.characteristics;
+ if (cs.count == 1)
+ return nil;
+
+ NSUInteger index = cs.count - 1;
+ for (; index != 0; --index) {
+ if ([cs objectAtIndex:index] == characteristic) {
+ if (index + 1 == cs.count) {
+ return nil;
+ } else {
+ index += 1;
+ break;
+ }
+ }
+ }
+
+ if (!index) {
+ Q_ASSERT_X([cs objectAtIndex:0] == characteristic, Q_FUNC_INFO,
+ "characteristic not found in service.characteristics");
+ index = 1;
+ }
+
+ for (const NSUInteger e = cs.count; index < e; ++index) {
+ CBCharacteristic *const c = [cs objectAtIndex:index];
+ if (c.properties & properties)
+ return c;
+ }
+
+ return nil;
+}
+
+- (CBDescriptor *)nextDescriptorForCharacteristic:(CBCharacteristic *)characteristic
+ startingFrom:(CBDescriptor *)descriptor
+{
+ Q_ASSERT_X(characteristic, Q_FUNC_INFO, "invalid characteristic (nil)");
+ Q_ASSERT_X(descriptor, Q_FUNC_INFO, "invalid descriptor (nil)");
+ Q_ASSERT_X(characteristic.descriptors, Q_FUNC_INFO, "invalid characteristic");
+ Q_ASSERT_X(characteristic.descriptors.count, Q_FUNC_INFO, "invalid characteristic");
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ NSArray *const ds = characteristic.descriptors;
+ if (ds.count == 1)
+ return nil;
+
+ for (NSUInteger index = ds.count - 1; index != 0; --index) {
+ if ([ds objectAtIndex:index] == descriptor) {
+ if (index + 1 == ds.count)
+ return nil;
+ else
+ return [ds objectAtIndex:index + 1];
+ }
+ }
+
+ Q_ASSERT_X([ds objectAtIndex:0] == descriptor, Q_FUNC_INFO,
+ "descriptor was not found in characteristic.descriptors");
+
+ return [ds objectAtIndex:1];
+}
+
+- (CBDescriptor *)descriptor:(const QBluetoothUuid &)qtUuid
+ forCharacteristic:(CBCharacteristic *)ch
+{
+ if (qtUuid.isNull() || !ch)
+ return nil;
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ CBDescriptor *descriptor = nil;
+ NSArray *const ds = ch.descriptors;
+ if (ds && ds.count) {
+ for (CBDescriptor *d in ds) {
+ if (OSXBluetooth::equal_uuids(d.UUID, qtUuid)) {
+ descriptor = d;
+ break;
+ }
+ }
+ }
+
+ return descriptor;
+}
+
+- (bool)cacheWriteValue:(const QByteArray &)value for:(NSObject *)obj
+{
+ Q_ASSERT_X(obj, Q_FUNC_INFO, "invalid object (nil)");
+
+ if ([obj isKindOfClass:[CBCharacteristic class]]) {
+ CBCharacteristic *const ch = static_cast<CBCharacteristic *>(obj);
+ if (!charMap.key(ch)) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "unexpected "
+ "characteristic, no handle found";
+ return false;
+ }
+ } else if ([obj isKindOfClass:[CBDescriptor class]]) {
+ CBDescriptor *const d = static_cast<CBDescriptor *>(obj);
+ if (!descMap.key(d)) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "unexpected "
+ "descriptor, no handle found";
+ return false;
+ }
+ } else {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid object, "
+ "characteristic or descriptor required";
+ return false;
+ }
+
+ if (valuesToWrite.contains(obj)) {
+ // It can be a result of some previous errors - for example,
+ // we never got a callback from a previous write.
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "already has a cached value for this "
+ "object, the value will be replaced";
+ }
+
+ valuesToWrite[obj] = value;
+ return true;
+}
+
+- (void)reset
+{
+ requestPending = false;
+ valuesToWrite.clear();
+ requests.clear();
+ servicesToDiscoverDetails.clear();
+ lastValidHandle = 0;
+ serviceMap.clear();
+ charMap.clear();
+ descMap.clear();
+ currentReadHandle = 0;
+ // TODO: also serviceToVisit/VisitNext and visitedServices ?
+}
+
+// CBCentralManagerDelegate (the real one).
+
+- (void)centralManagerDidUpdateState:(CBCentralManager *)central
+{
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+
+ using namespace OSXBluetooth;
+
+ const CBCentralManagerState state = central.state;
+
+ if (state == CBCentralManagerStateUnknown
+ || state == CBCentralManagerStateResetting) {
+ // We still have to wait, docs say:
+ // "The current state of the central manager is unknown;
+ // an update is imminent." or
+ // "The connection with the system service was momentarily
+ // lost; an update is imminent."
+ return;
+ }
+
+ if (disconnectPending) {
+ disconnectPending = false;
+ managerState = OSXBluetooth::CentralManagerIdle;
+ return [self disconnectFromDevice];
+ }
+
+ // Let's check some states we do not like first:
+ if (state == CBCentralManagerStateUnsupported || state == CBCentralManagerStateUnauthorized) {
+ if (managerState == CentralManagerUpdating) {
+ // We tried to connect just to realize, LE is not supported. Report this.
+ managerState = CentralManagerIdle;
+ delegate->LEnotSupported();
+ } else {
+ // TODO: if we are here, LE _was_ supported and we first managed to update
+ // and reset managerState from CentralManagerUpdating.
+ managerState = CentralManagerIdle;
+ delegate->error(QLowEnergyController::InvalidBluetoothAdapterError);
+ }
+ return;
+ }
+
+ if (state == CBCentralManagerStatePoweredOff) {
+ if (managerState == CentralManagerUpdating) {
+ // I've seen this instead of Unsopported on OS X.
+ managerState = CentralManagerIdle;
+ delegate->LEnotSupported();
+ } else {
+ managerState = CentralManagerIdle;
+ // TODO: we need a better error +
+ // what will happen if later the state changes to PoweredOn???
+ delegate->error(QLowEnergyController::InvalidBluetoothAdapterError);
+ }
+ return;
+ }
+
+ if (state == CBCentralManagerStatePoweredOn) {
+ if (managerState == CentralManagerUpdating) {
+ managerState = CentralManagerIdle;
+ const QLowEnergyController::Error status = [self connectToDevice];
+ if (status != QLowEnergyController::NoError)// An allocation problem?
+ delegate->error(status);
+ }
+ } else {
+ // We actually handled all known states, but .. Core Bluetooth can change?
+ Q_ASSERT_X(0, Q_FUNC_INFO, "invalid centra's state");
+ }
+}
+
+- (void)centralManager:(CBCentralManager *)central didRetrievePeripherals:(NSArray *)peripherals
+{
+ Q_UNUSED(central)
+
+ // This method is required for iOS before 7.0 and OS X below 10.9.
+ Q_ASSERT_X(manager, Q_FUNC_INFO, "invalid central manager (nil)");
+
+ if (managerState != OSXBluetooth::CentralManagerConnecting) {
+ // Canceled by calling -disconnectFromDevice method.
+ return;
+ }
+
+ managerState = OSXBluetooth::CentralManagerIdle;
+
+ if (!peripherals || peripherals.count != 1) {
+ Q_ASSERT_X(delegate, Q_FUNC_INFO,
+ "invalid delegate (null)");
+
+ qCDebug(QT_BT_OSX) << Q_FUNC_INFO <<"unexpected number of peripherals (!= 1)";
+
+ delegate->error(QLowEnergyController::UnknownRemoteDeviceError);
+ } else {
+ peripheral = [static_cast<CBPeripheral *>([peripherals objectAtIndex:0]) retain];
+ [self connectToPeripheral];
+ }
+}
+
+- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)aPeripheral
+{
+ Q_UNUSED(central)
+ Q_UNUSED(aPeripheral)
+
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+
+ if (managerState != OSXBluetooth::CentralManagerConnecting) {
+ // We called cancel but before disconnected, managed to connect?
+ return;
+ }
+
+ managerState = OSXBluetooth::CentralManagerIdle;
+ delegate->connectSuccess();
+}
+
+- (void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)aPeripheral
+ error:(NSError *)error
+{
+ Q_UNUSED(central)
+ Q_UNUSED(aPeripheral)
+ Q_UNUSED(error)
+
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+
+ if (managerState != OSXBluetooth::CentralManagerConnecting) {
+ // Canceled already.
+ return;
+ }
+
+ managerState = OSXBluetooth::CentralManagerIdle;
+ // TODO: better error mapping is required.
+ delegate->error(QLowEnergyController::UnknownRemoteDeviceError);
+}
+
+- (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)aPeripheral
+ error:(NSError *)error
+{
+ Q_UNUSED(central)
+ Q_UNUSED(aPeripheral)
+
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+
+ // Clear internal caches/data.
+ [self reset];
+
+ if (error && managerState == OSXBluetooth::CentralManagerDisconnecting) {
+ managerState = OSXBluetooth::CentralManagerIdle;
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to disconnect";
+ // TODO: instead of 'unknown' - .. ?
+ delegate->error(QLowEnergyController::UnknownRemoteDeviceError);
+ } else {
+ managerState = OSXBluetooth::CentralManagerIdle;
+ delegate->disconnected();
+ }
+}
+
+// CBPeripheralDelegate.
+
+- (void)peripheral:(CBPeripheral *)aPeripheral didDiscoverServices:(NSError *)error
+{
+ Q_UNUSED(aPeripheral)
+
+ if (managerState != OSXBluetooth::CentralManagerDiscovering) {
+ // Canceled by -disconnectFromDevice.
+ return;
+ }
+
+ managerState = OSXBluetooth::CentralManagerIdle;
+
+ if (error) {
+ // NSLog, not qCDebug/Warning - to print the error.
+ NSLog(@"%s failed with error %@", Q_FUNC_INFO, error);
+ // TODO: better error mapping required.
+ delegate->error(QLowEnergyController::UnknownError);
+ } else {
+ [self discoverIncludedServices];
+ }
+}
+
+
+- (void)peripheral:(CBPeripheral *)aPeripheral didDiscoverIncludedServicesForService:(CBService *)service
+ error:(NSError *)error
+{
+ Q_UNUSED(aPeripheral)
+
+ using namespace OSXBluetooth;
+
+ if (managerState != CentralManagerDiscovering) {
+ // Canceled by disconnectFromDevice or -peripheralDidDisconnect...
+ return;
+ }
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+ Q_ASSERT_X(peripheral, Q_FUNC_INFO, "invalid peripheral (nil)");
+ // TODO: asserts on other "pointers" ...
+
+ managerState = CentralManagerIdle;
+
+ if (error) {
+ // NSLog, not qCWarning/Critical - to log the actual NSError and service UUID.
+ NSLog(@"%s: finished with error %@ for service %@",
+ Q_FUNC_INFO, error, service.UUID);
+ } else if (service.includedServices && service.includedServices.count) {
+ // Now we have even more services to do included services discovery ...
+ if (!servicesToVisitNext)
+ servicesToVisitNext.reset([NSMutableArray arrayWithArray:service.includedServices]);
+ else
+ [servicesToVisitNext addObjectsFromArray:service.includedServices];
+ }
+
+ // Do we have something else to discover on this 'level'?
+ ++currentService;
+
+ for (const NSUInteger e = [servicesToVisit count]; currentService < e; ++currentService) {
+ CBService *const s = [servicesToVisit objectAtIndex:currentService];
+ if (![visitedServices containsObject:s]) {
+ // Continue with discovery ...
+ [visitedServices addObject:s];
+ managerState = CentralManagerDiscovering;
+ return [peripheral discoverIncludedServices:nil forService:s];
+ }
+ }
+
+ // No services to visit more on this 'level'.
+
+ if (servicesToVisitNext && [servicesToVisitNext count]) {
+ servicesToVisit.resetWithoutRetain(servicesToVisitNext.take());
+
+ currentService = 0;
+ for (const NSUInteger e = [servicesToVisit count]; currentService < e; ++currentService) {
+ CBService *const s = [servicesToVisit objectAtIndex:currentService];
+ if (![visitedServices containsObject:s]) {
+ [visitedServices addObject:s];
+ managerState = CentralManagerDiscovering;
+ return [peripheral discoverIncludedServices:nil forService:s];
+ }
+ }
+ }
+
+ // Finally, if we're here, the service discovery is done!
+
+ // Release all these things now, no need to prolong their lifetime.
+ visitedServices.reset(nil);
+ servicesToVisit.reset(nil);
+ servicesToVisitNext.reset(nil);
+
+ const ObjCStrongReference<NSArray> services(peripheral.services, true); // true == retain.
+ delegate->serviceDiscoveryFinished(services);
+}
+
+- (void)peripheral:(CBPeripheral *)aPeripheral didDiscoverCharacteristicsForService:(CBService *)service
+ error:(NSError *)error
+{
+ // This method does not change 'managerState', we can have several
+ // discoveries active.
+ Q_UNUSED(aPeripheral)
+
+ // TODO: check that this can never be called after cancelPeripheralConnection was executed.
+
+ using namespace OSXBluetooth;
+
+ Q_ASSERT_X(managerState != CentralManagerUpdating,
+ Q_FUNC_INFO, "invalid state");
+ Q_ASSERT_X(delegate, Q_FUNC_INFO,
+ "invalid delegate (null)");
+
+ if (error) {
+ // NSLog to show the actual NSError (can contain something interesting).
+ NSLog(@"%s failed with error: %@", Q_FUNC_INFO, error);
+ // We did not discover any characteristics and can not discover descriptors,
+ // inform our delegate (it will set a service state also).
+ delegate->error(qt_uuid(service.UUID), QLowEnergyController::UnknownError);
+ } else {
+ [self readCharacteristics:service];
+ }
+}
+
+- (void)peripheral:(CBPeripheral *)aPeripheral
+ didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic
+ error:(NSError *)error
+{
+ Q_UNUSED(aPeripheral)
+
+ using namespace OSXBluetooth;
+
+ Q_ASSERT_X(managerState != CentralManagerUpdating, Q_FUNC_INFO, "invalid state");
+ Q_ASSERT_X(peripheral, Q_FUNC_INFO, "invalid peripheral (nil)");
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+ // First, let's check if we're discovering a service details now.
+ CBService *const service = characteristic.service;
+ const QBluetoothUuid qtUuid(qt_uuid(service.UUID));
+ const bool isDetailsDiscovery = servicesToDiscoverDetails.contains(qtUuid);
+ const QLowEnergyHandle chHandle = charMap.key(characteristic);
+
+ if (error) {
+ // Use NSLog, not qCDebug/qCWarning to log the actual error.
+ NSLog(@"%s failed with error %@", Q_FUNC_INFO, error);
+ if (!isDetailsDiscovery) {
+ if (chHandle && chHandle == currentReadHandle) {
+ currentReadHandle = 0;
+ requestPending = false;
+ delegate->error(qtUuid, QLowEnergyService::CharacteristicReadError);
+ [self performNextRequest];
+ }
+ return;
+ }
+ }
+
+ if (isDetailsDiscovery) {
+ // Test if we have any other characteristic to read yet.
+ CBCharacteristic *const next = [self nextCharacteristicForService:characteristic.service
+ startingFrom:characteristic properties:CBCharacteristicPropertyRead];
+ if (next)
+ [peripheral readValueForCharacteristic:next];
+ else
+ [self discoverDescriptors:characteristic.service];
+ } else {
+ // This is (probably) the result of update notification.
+ // It's very possible we can have an invalid handle here (0) -
+ // if something esle is wrong (we subscribed for a notification),
+ // disconnected (but other application is connected) and still receiveing
+ // updated values ...
+ // TODO: this must be properly tested.
+ if (!chHandle) {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "unexpected update notification, "
+ "no characteristic handle found";
+ return;
+ }
+
+ if (currentReadHandle == chHandle) {
+ // Even if it was not a reply to our read request (no way to test it)
+ // report it.
+ requestPending = false;
+ currentReadHandle = 0;
+ //
+ delegate->characteristicReadNotification(chHandle, qt_bytearray(characteristic.value));
+ [self performNextRequest];
+ } else {
+ delegate->characteristicUpdateNotification(chHandle, qt_bytearray(characteristic.value));
+ }
+ }
+}
+
+- (void)peripheral:(CBPeripheral *)aPeripheral
+ didDiscoverDescriptorsForCharacteristic:(CBCharacteristic *)characteristic
+ error:(NSError *)error
+{
+ // This method does not change 'managerState', we can
+ // have several discoveries active at the same time.
+ Q_UNUSED(aPeripheral)
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ using namespace OSXBluetooth;
+
+ if (error) {
+ // Log the error using NSLog:
+ NSLog(@"%s failed with error %@", Q_FUNC_INFO, error);
+ // We can continue though ...
+ }
+
+ // Do we have more characteristics on this service to discover descriptors?
+ CBCharacteristic *const next = [self nextCharacteristicForService:characteristic.service
+ startingFrom:characteristic];
+ if (next)
+ [peripheral discoverDescriptorsForCharacteristic:next];
+ else
+ [self readDescriptors:characteristic.service];
+}
+
+- (void)peripheral:(CBPeripheral *)aPeripheral
+ didUpdateValueForDescriptor:(CBDescriptor *)descriptor
+ error:(NSError *)error
+{
+ Q_UNUSED(aPeripheral)
+
+ Q_ASSERT_X(peripheral, Q_FUNC_INFO, "invalid peripheral (nil)");
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ using namespace OSXBluetooth;
+
+ CBService *const service = descriptor.characteristic.service;
+ const QBluetoothUuid qtUuid(qt_uuid(service.UUID));
+ const bool isDetailsDiscovery = servicesToDiscoverDetails.contains(qtUuid);
+ const QLowEnergyHandle dHandle = descMap.key(descriptor);
+
+ if (error) {
+ // NSLog to log the actual error ...
+ NSLog(@"%s failed with error %@", Q_FUNC_INFO, error);
+
+ if (!isDetailsDiscovery) {
+ if (dHandle && dHandle == currentReadHandle) {
+ currentReadHandle = 0;
+ requestPending = false;
+ delegate->error(qtUuid, QLowEnergyService::DescriptorReadError);
+ [self performNextRequest];
+ }
+ return;
+ }
+ }
+
+ if (isDetailsDiscovery) {
+ // Test if we have any other characteristic to read yet.
+ CBDescriptor *const next = [self nextDescriptorForCharacteristic:descriptor.characteristic
+ startingFrom:descriptor];
+ if (next) {
+ [peripheral readValueForDescriptor:next];
+ } else {
+ // We either have to read a value for a next descriptor
+ // on a given characteristic, or continue with the
+ // next characteristic in a given service (if any).
+ CBCharacteristic *const ch = descriptor.characteristic;
+ CBCharacteristic *nextCh = [self nextCharacteristicForService:ch.service
+ startingFrom:ch];
+ while (nextCh) {
+ if (nextCh.descriptors && nextCh.descriptors.count)
+ return [peripheral readValueForDescriptor:[nextCh.descriptors objectAtIndex:0]];
+
+ nextCh = [self nextCharacteristicForService:ch.service
+ startingFrom:nextCh];
+ }
+
+ [self serviceDetailsDiscoveryFinished:service];
+ }
+ } else {
+ if (!dHandle) {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "unexpected value update notification, "
+ "no descriptor handle found";
+ return;
+ }
+
+ if (dHandle == currentReadHandle) {
+ currentReadHandle = 0;
+ requestPending = false;
+ delegate->descriptorReadNotification(dHandle, qt_bytearray(static_cast<NSObject *>(descriptor.value)));
+ [self performNextRequest];
+ }
+ }
+}
+
+- (void)peripheral:(CBPeripheral *)aPeripheral
+ didWriteValueForCharacteristic:(CBCharacteristic *)characteristic
+ error:(NSError *)error
+{
+ Q_UNUSED(aPeripheral)
+ Q_UNUSED(characteristic)
+
+ // From docs:
+ //
+ // "This method is invoked only when your app calls the writeValue:forCharacteristic:type:
+ // method with the CBCharacteristicWriteWithResponse constant specified as the write type.
+ // If successful, the error parameter is nil. If unsuccessful,
+ // the error parameter returns the cause of the failure."
+
+ using namespace OSXBluetooth;
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ requestPending = false;
+
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+
+
+ // Error or not, but the cached value has to be deleted ...
+ const QByteArray valueToReport(valuesToWrite.value(characteristic, QByteArray()));
+ if (!valuesToWrite.remove(characteristic)) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "no updated value found"
+ " for characteristic";
+ }
+
+ if (error) {
+ // Use NSLog to log the actual error:
+ NSLog(@"%s failed with error %@", Q_FUNC_INFO, error);
+ delegate->error(qt_uuid(characteristic.service.UUID),
+ QLowEnergyService::CharacteristicWriteError);
+ } else {
+ // Keys are unique.
+ const QLowEnergyHandle cHandle = charMap.key(characteristic);
+ Q_ASSERT_X(cHandle, Q_FUNC_INFO, "invalid handle, not found in the characteristics map");
+ delegate->characteristicWriteNotification(cHandle, valueToReport);
+ }
+
+ [self performNextRequest];
+}
+
+- (void)peripheral:(CBPeripheral *)aPeripheral
+ didWriteValueForDescriptor:(CBDescriptor *)descriptor
+ error:(NSError *)error
+{
+ Q_UNUSED(aPeripheral)
+
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+
+ using namespace OSXBluetooth;
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ requestPending = false;
+
+ using namespace OSXBluetooth;
+
+ // Error or not, a value (if any) must be removed.
+ const QByteArray valueToReport(valuesToWrite.value(descriptor, QByteArray()));
+ if (!valuesToWrite.remove(descriptor))
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "no updated value found";
+
+ if (error) {
+ // NSLog to log the actual NSError:
+ NSLog(@"%s failed with error %@", Q_FUNC_INFO, error);
+ delegate->error(qt_uuid(descriptor.characteristic.service.UUID),
+ QLowEnergyService::DescriptorWriteError);
+ } else {
+ const QLowEnergyHandle dHandle = descMap.key(descriptor);
+ Q_ASSERT_X(dHandle, Q_FUNC_INFO,
+ "descriptor not found in the descriptors map");
+ delegate->descriptorWriteNotification(dHandle, valueToReport);
+ }
+
+ [self performNextRequest];
+}
+
+- (void)peripheral:(CBPeripheral *)aPeripheral
+ didUpdateNotificationStateForCharacteristic:(CBCharacteristic *)characteristic
+ error:(NSError *)error
+{
+ Q_UNUSED(aPeripheral)
+
+ using namespace OSXBluetooth;
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ requestPending = false;
+
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (nil)");
+
+ const QBluetoothUuid qtUuid(QBluetoothUuid::ClientCharacteristicConfiguration);
+ CBDescriptor *const descriptor = [self descriptor:qtUuid forCharacteristic:characteristic];
+ const QByteArray valueToReport(valuesToWrite.value(descriptor, QByteArray()));
+ const int nRemoved = valuesToWrite.remove(descriptor);
+
+ if (error) {
+ // NSLog to log the actual NSError:
+ NSLog(@"%s failed with error %@", Q_FUNC_INFO, error);
+ delegate->error(qt_uuid(characteristic.service.UUID),
+ // In Qt's API it's a descriptor write actually.
+ QLowEnergyService::DescriptorWriteError);
+ } else {
+ if (nRemoved) {
+ const QLowEnergyHandle dHandle = descMap.key(descriptor);
+ delegate->descriptorWriteNotification(dHandle, valueToReport);
+ } else {
+ /*
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << ": notification value set to "
+ << int(characteristic.isNotifying)
+ << " but no client characteristic configuration descriptor found"
+ " or no previous writeDescriptor request found";
+ */
+ }
+ }
+
+ [self performNextRequest];
+}
+
+@end
diff --git a/src/bluetooth/osx/osxbtcentralmanager_p.h b/src/bluetooth/osx/osxbtcentralmanager_p.h
new file mode 100644
index 00000000..e8d7d234
--- /dev/null
+++ b/src/bluetooth/osx/osxbtcentralmanager_p.h
@@ -0,0 +1,217 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OSXBTCENTRALMANAGER_P_H
+#define OSXBTCENTRALMANAGER_P_H
+
+#include "qlowenergycontroller.h"
+#include "qlowenergyservice.h"
+#include "qbluetoothuuid.h"
+#include "osxbtutility_p.h"
+
+#include <QtCore/qbytearray.h>
+#include <QtCore/qglobal.h>
+#include <QtCore/qqueue.h>
+#include <QtCore/qhash.h>
+
+// Foundation.h must be included before corebluetoothwrapper_p.h -
+// a workaround for a broken 10.9 SDK.
+#include <Foundation/Foundation.h>
+
+#include "corebluetoothwrapper_p.h"
+
+@class QT_MANGLE_NAMESPACE(OSXBTCentralManager);
+
+QT_BEGIN_NAMESPACE
+
+class QLowEnergyServicePrivate;
+
+namespace OSXBluetooth {
+
+class CentralManagerDelegate
+{
+public:
+ typedef QT_MANGLE_NAMESPACE(OSXBTCentralManager) ObjCCentralManager;
+ typedef ObjCStrongReference<NSArray> LEServices;
+ typedef QSharedPointer<QLowEnergyServicePrivate> LEService;
+ typedef ObjCStrongReference<CBCharacteristic> LECharacteristic;
+
+ virtual ~CentralManagerDelegate();
+
+ virtual void LEnotSupported() = 0;
+ virtual void connectSuccess() = 0;
+ virtual void serviceDiscoveryFinished(LEServices services) = 0;
+ virtual void serviceDetailsDiscoveryFinished(LEService service) = 0;
+ virtual void characteristicReadNotification(QLowEnergyHandle charHandle,
+ const QByteArray &value) = 0;
+ virtual void characteristicWriteNotification(QLowEnergyHandle charHandle,
+ const QByteArray &value) = 0;
+ virtual void characteristicUpdateNotification(QLowEnergyHandle charHandle,
+ const QByteArray &value) = 0;
+ virtual void descriptorReadNotification(QLowEnergyHandle descHandle,
+ const QByteArray &value) = 0;
+ virtual void descriptorWriteNotification(QLowEnergyHandle descHandle,
+ const QByteArray &value) = 0;
+ virtual void disconnected() = 0;
+
+ // General errors.
+ virtual void error(QLowEnergyController::Error error) = 0;
+ // Service related errors.
+ virtual void error(const QBluetoothUuid &serviceUuid,
+ QLowEnergyController::Error error) = 0;
+ // Characteristics/descriptors related errors.
+ virtual void error(const QBluetoothUuid &serviceUuid,
+ QLowEnergyService::ServiceError error) = 0;
+};
+
+enum CentralManagerState
+{
+ // QLowEnergyController already has some of these states,
+ // but it's not enough and we need more special states here.
+ CentralManagerIdle,
+ // Required by CBCentralManager to avoid problems with dangled pointers.
+ CentralManagerUpdating,
+ CentralManagerConnecting,
+ CentralManagerDiscovering,
+ CentralManagerDisconnecting
+};
+
+// In Qt we work with handles and UUIDs. Core Bluetooth
+// has NSArrays (and nested NSArrays inside servces/characteristics).
+// To simplify a navigation, I need a simple way to map from a handle
+// to a Core Bluetooth object. These are weak pointers,
+// will probably require '__weak' with ARC.
+typedef QHash<QLowEnergyHandle, CBService *> ServiceHash;
+typedef QHash<QLowEnergyHandle, CBCharacteristic *> CharHash;
+typedef QHash<QLowEnergyHandle, CBDescriptor *> DescHash;
+
+// Descriptor/charactesirsti read/write requests
+// - we have to serialize 'concurrent' write requests.
+struct LERequest {
+ enum RequestType {
+ CharRead,
+ CharWrite,
+ DescRead,
+ DescWrite,
+ ClientConfiguration,
+ Invalid
+ };
+
+ LERequest() : type(Invalid),
+ withResponse(false),
+ handle(0)
+ {}
+
+ RequestType type;
+ bool withResponse;
+ QLowEnergyHandle handle;
+ QByteArray value;
+};
+
+typedef QQueue<LERequest> RequestQueue;
+
+// Core Bluetooth's write confirmation does not provide
+// the updated value (characteristic or descriptor).
+// But the Qt's Bluetooth API ('write with response')
+// expects this updated value as a response, so we have
+// to cache this write value and report it back.
+// 'NSObject *' will require '__weak' with ARC.
+typedef QHash<NSObject *, QByteArray> ValueHash;
+
+}
+
+QT_END_NAMESPACE
+
+@interface QT_MANGLE_NAMESPACE(OSXBTCentralManager) : NSObject<CBCentralManagerDelegate, CBPeripheralDelegate>
+{
+ CBCentralManager *manager;
+ QT_PREPEND_NAMESPACE(OSXBluetooth)::CentralManagerState managerState;
+ bool disconnectPending;
+
+ QT_PREPEND_NAMESPACE(QBluetoothUuid) deviceUuid;
+ CBPeripheral *peripheral;
+
+ QT_PREPEND_NAMESPACE(OSXBluetooth)::CentralManagerDelegate *delegate;
+
+ // Quite a verbose service discovery machinery
+ // (a "graph traversal").
+ QT_PREPEND_NAMESPACE(OSXBluetooth)::ObjCStrongReference<NSMutableArray> servicesToVisit;
+ // The service we're discovering now (included services discovery):
+ NSUInteger currentService;
+ // Included services, we'll iterate through at the end of 'servicesToVisit':
+ QT_PREPEND_NAMESPACE(OSXBluetooth)::ObjCStrongReference<NSMutableArray> servicesToVisitNext;
+ // We'd like to avoid loops in a services' topology:
+ QT_PREPEND_NAMESPACE(OSXBluetooth)::ObjCStrongReference<NSMutableSet> visitedServices;
+
+ QT_PREPEND_NAMESPACE(QList)<QT_PREPEND_NAMESPACE(QBluetoothUuid)> servicesToDiscoverDetails;
+
+ QT_PREPEND_NAMESPACE(OSXBluetooth)::ServiceHash serviceMap;
+ QT_PREPEND_NAMESPACE(OSXBluetooth)::CharHash charMap;
+ QT_PREPEND_NAMESPACE(OSXBluetooth)::DescHash descMap;
+
+ QT_PREPEND_NAMESPACE(QLowEnergyHandle) lastValidHandle;
+
+ bool requestPending;
+ QT_PREPEND_NAMESPACE(OSXBluetooth)::RequestQueue requests;
+ QT_PREPEND_NAMESPACE(QLowEnergyHandle) currentReadHandle;
+
+ QT_PREPEND_NAMESPACE(OSXBluetooth)::ValueHash valuesToWrite;
+}
+
+- (id)initWithDelegate:(QT_PREPEND_NAMESPACE(OSXBluetooth)::CentralManagerDelegate *)aDelegate;
+- (void)dealloc;
+
+- (QT_PREPEND_NAMESPACE(QLowEnergyController)::Error)
+ connectToDevice:(const QT_PREPEND_NAMESPACE(QBluetoothUuid) &)aDeviceUuid;
+
+- (void)disconnectFromDevice;
+
+- (void)discoverServices;
+- (bool)discoverServiceDetails:(const QT_PREPEND_NAMESPACE(QBluetoothUuid) &)serviceUuid;
+
+- (bool)setNotifyValue:(const QT_PREPEND_NAMESPACE(QByteArray) &)value
+ forCharacteristic:(QT_PREPEND_NAMESPACE(QLowEnergyHandle))charHandle;
+
+- (bool)readCharacteristic:(QT_PREPEND_NAMESPACE(QLowEnergyHandle))charHandle;
+
+- (bool)write:(const QT_PREPEND_NAMESPACE(QByteArray) &)value
+ charHandle:(QT_PREPEND_NAMESPACE(QLowEnergyHandle))charHandle
+ withResponse:(bool)writeWithResponse;
+
+- (bool)readDescriptor:(QT_PREPEND_NAMESPACE(QLowEnergyHandle))descHandle;
+
+- (bool)write:(const QT_PREPEND_NAMESPACE(QByteArray) &)value
+ descHandle:(QT_PREPEND_NAMESPACE(QLowEnergyHandle))descHandle;
+@end
+
+#endif
diff --git a/src/bluetooth/osx/osxbtchanneldelegate.mm b/src/bluetooth/osx/osxbtchanneldelegate.mm
new file mode 100644
index 00000000..2214168b
--- /dev/null
+++ b/src/bluetooth/osx/osxbtchanneldelegate.mm
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "osxbtchanneldelegate_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace OSXBluetooth {
+
+ChannelDelegate::~ChannelDelegate()
+{
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/bluetooth/osx/osxbtchanneldelegate_p.h b/src/bluetooth/osx/osxbtchanneldelegate_p.h
new file mode 100644
index 00000000..edcf6950
--- /dev/null
+++ b/src/bluetooth/osx/osxbtchanneldelegate_p.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OSXBTCHANNELDELEGATE_P_H
+#define OSXBTCHANNELDELEGATE_P_H
+
+#include <QtCore/qglobal.h>
+
+#include <IOKit/IOReturn.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace OSXBluetooth {
+
+class ChannelDelegate
+{
+public:
+ virtual ~ChannelDelegate();
+
+ virtual void setChannelError(IOReturn errorCode) = 0;
+ virtual void channelOpenComplete() = 0;
+ virtual void channelClosed() = 0;
+
+ virtual void readChannelData(void *data, std::size_t size) = 0;
+ virtual void writeComplete() = 0;
+};
+
+}
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/bluetooth/osx/osxbtconnectionmonitor.mm b/src/bluetooth/osx/osxbtconnectionmonitor.mm
new file mode 100644
index 00000000..8228d135
--- /dev/null
+++ b/src/bluetooth/osx/osxbtconnectionmonitor.mm
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "osxbtconnectionmonitor_p.h"
+#include "osxbtutility_p.h"
+
+#include <QtCore/qdebug.h>
+
+// Import, since these headers are not protected from the multiple inclusion.
+#import <IOBluetooth/objc/IOBluetoothUserNotification.h>
+#import <IOBluetooth/objc/IOBluetoothDevice.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace OSXBluetooth {
+
+ConnectionMonitor::~ConnectionMonitor()
+{
+}
+
+}
+
+QT_END_NAMESPACE
+
+#ifdef QT_NAMESPACE
+using namespace QT_NAMESPACE;
+#endif
+
+@implementation QT_MANGLE_NAMESPACE(OSXBTConnectionMonitor)
+
+- (id)initWithMonitor:(OSXBluetooth::ConnectionMonitor *)aMonitor
+{
+ Q_ASSERT_X(aMonitor, "-initWithMonitor:", "invalid monitor (null)");
+
+ if (self = [super init]) {
+ monitor = aMonitor;
+ discoveryNotification = [[IOBluetoothDevice registerForConnectNotifications:self
+ selector:@selector(connectionNotification:withDevice:)] retain];
+ foundConnections = [[NSMutableArray alloc] init];
+ }
+
+ return self;
+}
+
+- (void)dealloc
+{
+ [discoveryNotification unregister];
+ [discoveryNotification release];
+
+ for (IOBluetoothUserNotification *n in foundConnections)
+ [n unregister];
+
+ [foundConnections release];
+
+ [super dealloc];
+}
+
+- (void)connectionNotification:(IOBluetoothUserNotification *)aNotification
+ withDevice:(IOBluetoothDevice *)device
+{
+ Q_UNUSED(aNotification)
+
+ typedef IOBluetoothUserNotification Notification;
+
+ if (!device)
+ return;
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ // All Obj-C objects are autoreleased.
+
+ const QBluetoothAddress deviceAddress(OSXBluetooth::qt_address([device getAddress]));
+ if (deviceAddress.isNull())
+ return;
+
+ if (foundConnections) {
+ Notification *const notification = [device registerForDisconnectNotification:self
+ selector: @selector(connectionClosedNotification:withDevice:)];
+ if (notification)
+ [foundConnections addObject:notification];
+ }
+
+ Q_ASSERT_X(monitor, "-connectionNotification:withDevice:", "invalid monitor (null)");
+ monitor->deviceConnected(deviceAddress);
+}
+
+- (void)connectionClosedNotification:(IOBluetoothUserNotification *)notification
+ withDevice:(IOBluetoothDevice *)device
+{
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ [notification unregister];//?
+ [foundConnections removeObject:notification];
+
+ const QBluetoothAddress deviceAddress(OSXBluetooth::qt_address([device getAddress]));
+ if (deviceAddress.isNull())
+ return;
+
+ Q_ASSERT_X(monitor, "-connectionClosedNotification:withDevice:", "invalid monitor (null)");
+ monitor->deviceDisconnected(deviceAddress);
+}
+
+@end
diff --git a/src/bluetooth/osx/osxbtconnectionmonitor_p.h b/src/bluetooth/osx/osxbtconnectionmonitor_p.h
new file mode 100644
index 00000000..4ad28885
--- /dev/null
+++ b/src/bluetooth/osx/osxbtconnectionmonitor_p.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OSXBTCONNECTIONMONITOR_P_H
+#define OSXBTCONNECTIONMONITOR_P_H
+
+#include "qbluetoothaddress.h"
+
+#include <QtCore/qglobal.h>
+
+#include <Foundation/Foundation.h>
+
+@class QT_MANGLE_NAMESPACE(OSXBTConnectionMonitor);
+@class IOBluetoothUserNotification;
+@class IOBluetoothDevice;
+
+QT_BEGIN_NAMESPACE
+
+namespace OSXBluetooth {
+
+class ConnectionMonitor {
+public:
+ typedef QT_MANGLE_NAMESPACE(OSXBTConnectionMonitor) ObjCConnectionMonitor;
+
+ virtual ~ConnectionMonitor();
+
+ virtual void deviceConnected(const QBluetoothAddress &address) = 0;
+ virtual void deviceDisconnected(const QBluetoothAddress &address) = 0;
+};
+
+}
+
+QT_END_NAMESPACE
+
+@interface QT_MANGLE_NAMESPACE(OSXBTConnectionMonitor) : NSObject
+{
+ QT_PREPEND_NAMESPACE(OSXBluetooth::ConnectionMonitor) *monitor;
+ IOBluetoothUserNotification *discoveryNotification;
+ NSMutableArray *foundConnections;
+}
+
+- (id)initWithMonitor:(QT_PREPEND_NAMESPACE(OSXBluetooth::ConnectionMonitor) *)monitor;
+- (void)connectionNotification:(id)notification withDevice:(IOBluetoothDevice *)device;
+- (void)connectionClosedNotification:(id)notification withDevice:(IOBluetoothDevice *)device;
+
+@end
+
+#endif
diff --git a/src/bluetooth/osx/osxbtdeviceinquiry.mm b/src/bluetooth/osx/osxbtdeviceinquiry.mm
new file mode 100644
index 00000000..6fb89e20
--- /dev/null
+++ b/src/bluetooth/osx/osxbtdeviceinquiry.mm
@@ -0,0 +1,176 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "osxbtdeviceinquiry_p.h"
+#include "osxbtutility_p.h"
+
+#include <QtCore/qloggingcategory.h>
+#include <QtCore/qdebug.h>
+
+
+QT_BEGIN_NAMESPACE
+
+namespace OSXBluetooth {
+
+DeviceInquiryDelegate::~DeviceInquiryDelegate()
+{
+}
+
+}
+
+
+QT_END_NAMESPACE
+
+
+#ifdef QT_NAMESPACE
+// We do not want to litter a code with QT_PREPEND_NAMESPACE, right?
+using namespace QT_NAMESPACE;
+#endif
+
+
+@implementation QT_MANGLE_NAMESPACE(OSXBTDeviceInquiry)
+
+- (id)initWithDelegate:(OSXBluetooth::DeviceInquiryDelegate *)delegate
+{
+ if (self = [super init]) {
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid device inquiry delegate (null)");
+
+ m_inquiry = [[IOBluetoothDeviceInquiry inquiryWithDelegate:self] retain];
+
+ if (m_inquiry) {
+ [m_inquiry setInquiryLength:15];
+ [m_inquiry setUpdateNewDeviceNames:NO];//Useless, disable!
+ m_delegate = delegate;
+ } else {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to create "
+ "a device inquiry";
+ }
+
+ m_active = false;
+ }
+
+ return self;
+}
+
+- (void)dealloc
+{
+ // Noop if m_inquiry is nil.
+ [m_inquiry setDelegate:nil];
+ if (m_active)
+ [m_inquiry stop];
+ [m_inquiry release];
+
+ [super dealloc];
+}
+
+- (bool)isActive
+{
+ return m_active;
+}
+
+- (IOReturn)start
+{
+ if (!m_inquiry)
+ return kIOReturnNoPower;
+
+ if (m_active)
+ return kIOReturnBusy;
+
+ m_active = true;
+ [m_inquiry clearFoundDevices];
+ const IOReturn result = [m_inquiry start];
+ if (result != kIOReturnSuccess) {
+ // QtBluetooth will probably convert an error into UnknownError,
+ // loosing the actual information.
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO <<"failed with "
+ "IOKit error code: " << result;
+ m_active = false;
+ }
+
+ return result;
+}
+
+- (IOReturn)stop
+{
+ if (m_active) {
+ Q_ASSERT_X(m_inquiry, Q_FUNC_INFO, "active but nil inquiry");
+
+ m_active = false;
+ const IOReturn res = [m_inquiry stop];
+ if (res != kIOReturnSuccess)
+ m_active = true;
+
+ return res;
+ }
+
+ return kIOReturnSuccess;
+}
+
+- (void)deviceInquiryComplete:(IOBluetoothDeviceInquiry *)sender
+ error:(IOReturn)error aborted:(BOOL)aborted
+{
+ Q_UNUSED(aborted)
+
+ if (sender != m_inquiry) // Can never happen in the current version.
+ return;
+
+ m_active = false;
+
+ Q_ASSERT_X(m_delegate, Q_FUNC_INFO, "invalid device inquiry delegate (null)");
+
+ if (error != kIOReturnSuccess) {
+ // QtBluetooth has not too many error codes, 'UnknownError' is not really
+ // useful, report the actual error code here:
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "IOKit error code: " << error;
+ m_delegate->error(sender, error);
+ } else {
+ m_delegate->inquiryFinished(sender);
+ }
+}
+
+- (void)deviceInquiryDeviceFound:(IOBluetoothDeviceInquiry *)sender
+ device:(IOBluetoothDevice *)device
+{
+ if (sender != m_inquiry) // Can never happen in the current version.
+ return;
+
+ Q_ASSERT_X(m_delegate, Q_FUNC_INFO, "invalid device inquiry delegate (null)");
+ m_delegate->deviceFound(sender, device);
+}
+
+- (void)deviceInquiryStarted:(IOBluetoothDeviceInquiry *)sender
+{
+ Q_UNUSED(sender)
+}
+
+@end
diff --git a/src/bluetooth/osx/osxbtdeviceinquiry_p.h b/src/bluetooth/osx/osxbtdeviceinquiry_p.h
new file mode 100644
index 00000000..4397b45d
--- /dev/null
+++ b/src/bluetooth/osx/osxbtdeviceinquiry_p.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OSXBTDEVICEINQUIRY_P_H
+#define OSXBTDEVICEINQUIRY_P_H
+
+#include <QtCore/qglobal.h>
+
+// We have to import objc code (it does not have inclusion guards).
+#import <IOBluetooth/objc/IOBluetoothDeviceInquiry.h>
+
+#include <Foundation/Foundation.h>
+#include <IOKit/IOReturn.h>
+
+@class QT_MANGLE_NAMESPACE(OSXBTDeviceInquiry);
+
+QT_BEGIN_NAMESPACE
+
+namespace OSXBluetooth {
+
+class DeviceInquiryDelegate {
+public:
+ typedef QT_MANGLE_NAMESPACE(OSXBTDeviceInquiry) DeviceInquiryObjC;
+
+ virtual ~DeviceInquiryDelegate();
+
+ virtual void inquiryFinished(IOBluetoothDeviceInquiry *inq) = 0;
+ virtual void error(IOBluetoothDeviceInquiry *inq, IOReturn error) = 0;
+ virtual void deviceFound(IOBluetoothDeviceInquiry *inq, IOBluetoothDevice *device) = 0;
+};
+
+}
+
+QT_END_NAMESPACE
+
+@interface QT_MANGLE_NAMESPACE(OSXBTDeviceInquiry) : NSObject<IOBluetoothDeviceInquiryDelegate>
+{
+ IOBluetoothDeviceInquiry *m_inquiry;
+ bool m_active;
+ QT_PREPEND_NAMESPACE(OSXBluetooth::DeviceInquiryDelegate) *m_delegate;//C++ "delegate"
+}
+
+- (id)initWithDelegate:(QT_PREPEND_NAMESPACE(OSXBluetooth::DeviceInquiryDelegate) *)delegate;
+- (void)dealloc;
+
+- (bool)isActive;
+- (IOReturn)start;
+- (IOReturn)stop;
+
+//Obj-C delegate:
+- (void)deviceInquiryComplete:(IOBluetoothDeviceInquiry *)sender
+ error:(IOReturn)error aborted:(BOOL)aborted;
+
+- (void)deviceInquiryDeviceFound:(IOBluetoothDeviceInquiry *)sender
+ device:(IOBluetoothDevice *)device;
+
+- (void)deviceInquiryStarted:(IOBluetoothDeviceInquiry *)sender;
+
+@end
+
+#endif
diff --git a/src/bluetooth/osx/osxbtdevicepair.mm b/src/bluetooth/osx/osxbtdevicepair.mm
new file mode 100644
index 00000000..41c20b8b
--- /dev/null
+++ b/src/bluetooth/osx/osxbtdevicepair.mm
@@ -0,0 +1,222 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "osxbtdevicepair_p.h"
+#include "osxbtutility_p.h"
+
+#include <QtCore/qloggingcategory.h>
+#include <QtCore/qsysinfo.h>
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace OSXBluetooth {
+
+ObjCStrongReference<IOBluetoothDevice> device_with_address(const QBluetoothAddress &address)
+{
+ if (address.isNull())
+ return ObjCStrongReference<IOBluetoothDevice>(nil, false);
+
+ const BluetoothDeviceAddress &iobtAddress = iobluetooth_address(address);
+ ObjCStrongReference<IOBluetoothDevice> res([[IOBluetoothDevice deviceWithAddress:&iobtAddress] retain], false);
+ return res;
+}
+
+PairingDelegate::~PairingDelegate()
+{
+}
+
+}
+
+
+QT_END_NAMESPACE
+
+
+#ifdef QT_NAMESPACE
+using namespace QT_NAMESPACE;
+#endif
+
+@implementation QT_MANGLE_NAMESPACE(OSXBTPairing)
+
+- (id)initWithTarget:(const QBluetoothAddress &)address
+ delegate:(OSXBluetooth::PairingDelegate *)object
+{
+ if (self = [super init]) {
+ Q_ASSERT_X(!address.isNull(), Q_FUNC_INFO, "invalid target address");
+ Q_ASSERT_X(object, Q_FUNC_INFO, "invalid delegate (null)");
+
+ m_targetAddress = address;
+ m_object = object;
+ m_active = false;
+ }
+
+ return self;
+}
+
+- (void)dealloc
+{
+#if QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9)
+ // Stop also sets a delegate to nil (Apple's docs).
+ // 10.9 only.
+ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_9)
+ [m_pairing stop];
+ else
+ [m_pairing setDelegate:nil];
+#else
+ [m_pairing setDelegate:nil];
+#endif
+ [m_pairing release];
+
+ [super dealloc];
+}
+
+- (IOReturn) start
+{
+ if (m_active)
+ return kIOReturnBusy;
+
+ Q_ASSERT_X(!m_targetAddress.isNull(), Q_FUNC_INFO, "invalid target address");
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ const BluetoothDeviceAddress &iobtAddress = OSXBluetooth::iobluetooth_address(m_targetAddress);
+ // Device is autoreleased.
+ IOBluetoothDevice *const device = [IOBluetoothDevice deviceWithAddress:&iobtAddress];
+ if (!device) {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to create a device "
+ "to pair with";
+ return kIOReturnError;
+ }
+
+ m_pairing = [[IOBluetoothDevicePair pairWithDevice:device] retain];
+ if (!m_pairing) {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to create pair";
+ return kIOReturnError;
+ }
+
+ [m_pairing setDelegate:self];
+ const IOReturn result = [m_pairing start];
+ if (result != kIOReturnSuccess) {
+ [m_pairing release];
+ m_pairing = nil;
+ } else
+ m_active = true;
+
+ return result;
+}
+
+- (bool)isActive
+{
+ return m_active;
+}
+
+- (void)stop
+{
+ // stop: stops pairing, removes the delegate
+ // and disconnects if device was connected.
+ if (m_pairing)
+ [m_pairing stop];
+}
+
+- (const QBluetoothAddress &)targetAddress
+{
+ return m_targetAddress;
+}
+
+- (IOBluetoothDevicePair *)pairingRequest
+{
+ return [[m_pairing retain] autorelease];
+}
+
+- (IOBluetoothDevice *)targetDevice
+{
+ return [m_pairing device];//It's retained/autoreleased by pair.
+}
+
+// IOBluetoothDevicePairDelegate:
+
+- (void)devicePairingStarted:(id)sender
+{
+ Q_UNUSED(sender)
+}
+
+- (void)devicePairingConnecting:(id)sender
+{
+ Q_UNUSED(sender)
+}
+
+- (void)deviceParingPINCodeRequest:(id)sender
+{
+ Q_UNUSED(sender)
+}
+
+- (void)devicePairingUserConfirmationRequest:(id)sender
+ numericValue:(BluetoothNumericValue)numericValue
+{
+ if (sender != m_pairing) // Can never happen.
+ return;
+
+ Q_ASSERT_X(m_object, Q_FUNC_INFO, "invalid delegate (null)");
+
+ m_object->requestUserConfirmation(self, numericValue);
+}
+
+- (void)devicePairingUserPasskeyNotification:(id)sender
+ passkey:(BluetoothPasskey)passkey
+{
+ Q_UNUSED(sender)
+ Q_UNUSED(passkey)
+}
+
+- (void)devicePairingFinished:(id)sender error:(IOReturn)error
+{
+ Q_ASSERT_X(m_object, Q_FUNC_INFO, "invalid delegate (null)");
+
+ if (sender != m_pairing) // Can never happen though.
+ return;
+
+ m_active = false;
+ if (error != kIOReturnSuccess)
+ m_object->error(self, error);
+ else
+ m_object->pairingFinished(self);
+}
+
+- (void)deviceSimplePairingComplete:(id)sender
+ status:(BluetoothHCIEventStatus)status
+{
+ Q_UNUSED(sender)
+ Q_UNUSED(status)
+}
+
+@end
diff --git a/src/bluetooth/osx/osxbtdevicepair_p.h b/src/bluetooth/osx/osxbtdevicepair_p.h
new file mode 100644
index 00000000..a2aa2de0
--- /dev/null
+++ b/src/bluetooth/osx/osxbtdevicepair_p.h
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OSXBTDEVICEPAIR_P_H
+#define OSXBTDEVICEPAIR_P_H
+
+#include "qbluetoothaddress.h"
+#include "osxbtutility_p.h"
+
+#include <QtCore/qglobal.h>
+
+#include <Foundation/Foundation.h>
+// Only after Foundation.h:
+#include "corebluetoothwrapper_p.h"
+
+@class QT_MANGLE_NAMESPACE(OSXBTPairing);
+@class IOBluetoothDevice;
+
+QT_BEGIN_NAMESPACE
+
+namespace OSXBluetooth {
+
+// C++ delegate.
+class PairingDelegate
+{
+public:
+ typedef QT_MANGLE_NAMESPACE(OSXBTPairing) ObjCPairingRequest;
+
+ virtual ~PairingDelegate();
+
+ virtual void connecting(ObjCPairingRequest *pair) = 0;
+ virtual void requestPIN(ObjCPairingRequest *pair) = 0;
+ virtual void requestUserConfirmation(ObjCPairingRequest *pair,
+ BluetoothNumericValue) = 0;
+ virtual void passkeyNotification(ObjCPairingRequest *pair,
+ BluetoothPasskey passkey) = 0;
+ virtual void error(ObjCPairingRequest *pair, IOReturn errorCode) = 0;
+ virtual void pairingFinished(ObjCPairingRequest *pair) = 0;
+};
+
+ObjCStrongReference<IOBluetoothDevice> device_with_address(const QBluetoothAddress &address);
+
+} // Namespace OSXBluetooth.
+
+QT_END_NAMESPACE
+
+@interface QT_MANGLE_NAMESPACE(OSXBTPairing) : NSObject<IOBluetoothDevicePairDelegate>
+{
+ QT_PREPEND_NAMESPACE(QBluetoothAddress) m_targetAddress;
+
+ bool m_active;
+ IOBluetoothDevicePair *m_pairing; // The real pairing request
+ QT_PREPEND_NAMESPACE(OSXBluetooth)::PairingDelegate *m_object;
+}
+
+- (id)initWithTarget:(const QBluetoothAddress &)address
+ delegate:(QT_PREPEND_NAMESPACE(OSXBluetooth::PairingDelegate) *)object;
+
+- (void)dealloc;
+
+- (IOReturn)start;
+- (bool)isActive;
+- (void)stop;
+
+- (const QBluetoothAddress &)targetAddress;
+- (IOBluetoothDevicePair *)pairingRequest;
+- (IOBluetoothDevice *)targetDevice;
+
+// IOBluetoothDevicePairDelegate:
+
+- (void)devicePairingStarted:(id)sender;
+- (void)devicePairingConnecting:(id)sender;
+- (void)deviceParingPINCodeRequest:(id)sender;
+
+- (void)devicePairingUserConfirmationRequest:(id)sender
+ numericValue:(BluetoothNumericValue)numericValue;
+
+- (void)devicePairingUserPasskeyNotification:(id)sender
+ passkey:(BluetoothPasskey)passkey;
+
+- (void)devicePairingFinished:(id)sender
+ error:(IOReturn)error;
+
+- (void)deviceSimplePairingComplete:(id)sender
+ status:(BluetoothHCIEventStatus)status;
+
+@end
+
+
+#endif
diff --git a/src/bluetooth/osx/osxbtl2capchannel.mm b/src/bluetooth/osx/osxbtl2capchannel.mm
new file mode 100644
index 00000000..93e15012
--- /dev/null
+++ b/src/bluetooth/osx/osxbtl2capchannel.mm
@@ -0,0 +1,248 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "osxbtchanneldelegate_p.h"
+#include "osxbtl2capchannel_p.h"
+#include "qbluetoothaddress.h"
+#include "osxbtutility_p.h"
+
+#include <QtCore/qloggingcategory.h>
+#include <QtCore/qdebug.h>
+
+#ifdef QT_NAMESPACE
+using namespace QT_NAMESPACE;
+#endif
+
+@implementation QT_MANGLE_NAMESPACE(OSXBTL2CAPChannel)
+
+- (id)initWithDelegate:(OSXBluetooth::ChannelDelegate *)aDelegate
+{
+ Q_ASSERT_X(aDelegate, Q_FUNC_INFO, "invalid delegate (null)");
+
+ if (self = [super init]) {
+ delegate = aDelegate;
+ device = nil;
+ channel = nil;
+ connected = false;
+ }
+
+ return self;
+}
+
+- (id)initWithDelegate:(QT_PREPEND_NAMESPACE(OSXBluetooth::ChannelDelegate) *)aDelegate
+ channel:(IOBluetoothL2CAPChannel *)aChannel
+{
+ // This type of channel does not require connect, it's created with
+ // already open channel.
+ Q_ASSERT_X(aDelegate, Q_FUNC_INFO, "invalid delegate (null)");
+ Q_ASSERT_X(channel, Q_FUNC_INFO, "invalid channel (nil)");
+
+ if (self = [super init]) {
+ delegate = aDelegate;
+ channel = [aChannel retain];
+ [channel setDelegate:self];
+ device = [channel.device retain];
+ connected = true;
+ }
+
+ return self;
+}
+
+- (void)dealloc
+{
+ // TODO: test if this implementation works at all!
+ if (channel) {
+ [channel setDelegate:nil];
+ // From Apple's docs:
+ // "This method may only be called by the client that opened the channel
+ // in the first place. In the future asynchronous and synchronous versions
+ // will be provided that let the client know when the close process has been finished."
+ [channel closeChannel];
+ [channel release];
+ }
+
+ [device release];
+
+ [super dealloc];
+}
+
+- (IOReturn)connectAsyncToDevice:(const QBluetoothAddress &)address
+ withPSM:(BluetoothL2CAPChannelID)psm
+{
+ if (address.isNull()) {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "invalid peer address";
+ return kIOReturnNoDevice;
+ }
+
+ // Can never be called twice.
+ if (connected || device || channel) {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "connection is already active";
+ return kIOReturnStillOpen;
+ }
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ const BluetoothDeviceAddress iobtAddress = OSXBluetooth::iobluetooth_address(address);
+ device = [IOBluetoothDevice deviceWithAddress:&iobtAddress];
+ if (!device) {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to create a device";
+ return kIOReturnNoDevice;
+ }
+
+ const IOReturn status = [device openL2CAPChannelAsync:&channel withPSM:psm delegate:self];
+ if (status != kIOReturnSuccess) {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to open L2CAP channel";
+ // device is still autoreleased.
+ device = nil;
+ return status;
+ }
+
+ [channel retain];// What if we're closed already?
+ [device retain];
+
+ return kIOReturnSuccess;
+}
+
+// IOBluetoothL2CAPChannelDelegate:
+
+- (void)l2capChannelData:(IOBluetoothL2CAPChannel*)l2capChannel
+ data:(void *)dataPointer length:(size_t)dataLength
+{
+ Q_UNUSED(l2capChannel)
+
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+
+ if (dataPointer && dataLength)
+ delegate->readChannelData(dataPointer, dataLength);
+}
+
+- (void)l2capChannelOpenComplete:(IOBluetoothL2CAPChannel*)
+ l2capChannel status:(IOReturn)error
+{
+ Q_UNUSED(l2capChannel)
+
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+
+ if (error != kIOReturnSuccess) {
+ delegate->setChannelError(error);
+ } else {
+ connected = true;
+ delegate->channelOpenComplete();
+ }
+}
+
+- (void)l2capChannelClosed:(IOBluetoothL2CAPChannel*)l2capChannel
+{
+ Q_UNUSED(l2capChannel)
+
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+ delegate->channelClosed();
+ connected = false;
+}
+
+- (void)l2capChannelReconfigured:(IOBluetoothL2CAPChannel*)l2capChannel
+{
+ Q_UNUSED(l2capChannel)
+}
+
+- (void)l2capChannelWriteComplete:(IOBluetoothL2CAPChannel*)l2capChannel
+ refcon:(void*)refcon status:(IOReturn)error
+{
+ Q_UNUSED(l2capChannel)
+ Q_UNUSED(refcon)
+
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+
+ if (error != kIOReturnSuccess)
+ delegate->setChannelError(error);
+ else
+ delegate->writeComplete();
+}
+
+- (void)l2capChannelQueueSpaceAvailable:(IOBluetoothL2CAPChannel*)l2capChannel
+{
+ Q_UNUSED(l2capChannel)
+}
+
+// Aux. methods.
+- (BluetoothL2CAPPSM)getPSM
+{
+ if (channel)
+ return channel.PSM;
+
+ return 0;
+}
+
+- (BluetoothDeviceAddress)peerAddress
+{
+ const BluetoothDeviceAddress *const addr = device ? [device getAddress]
+ : Q_NULLPTR;
+ if (addr)
+ return *addr;
+
+ return BluetoothDeviceAddress();
+}
+
+- (NSString *)peerName
+{
+ if (device)
+ return device.name;
+
+ return nil;
+}
+
+- (bool)isConnected
+{
+ return connected;
+}
+
+- (IOReturn) writeSync:(void*)data length:(UInt16)length
+{
+ Q_ASSERT_X(data, Q_FUNC_INFO, "invalid data (null)");
+ Q_ASSERT_X(length, Q_FUNC_INFO, "invalid data size");
+ Q_ASSERT_X(connected && channel, Q_FUNC_INFO, "invalid L2CAP channel");
+
+ return [channel writeSync:data length:length];
+}
+
+- (IOReturn) writeAsync:(void*)data length:(UInt16)length
+{
+ Q_ASSERT_X(data, Q_FUNC_INFO, "invalid data (null)");
+ Q_ASSERT_X(length, Q_FUNC_INFO, "invalid data size");
+ Q_ASSERT_X(connected && channel, Q_FUNC_INFO, "invalid L2CAP channel");
+
+ return [channel writeAsync:data length:length refcon:Q_NULLPTR];
+}
+
+
+@end
diff --git a/src/bluetooth/osx/osxbtl2capchannel_p.h b/src/bluetooth/osx/osxbtl2capchannel_p.h
new file mode 100644
index 00000000..9736bd1d
--- /dev/null
+++ b/src/bluetooth/osx/osxbtl2capchannel_p.h
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OSXBTL2CAPCHANNEL_P_H
+#define OSXBTL2CAPCHANNEL_P_H
+
+#include <QtCore/qglobal.h>
+
+#include <Foundation/Foundation.h>
+// Only after Foundation.h:
+#include "corebluetoothwrapper_p.h"
+
+#include <cstddef>
+
+QT_BEGIN_NAMESPACE
+
+class QBluetoothAddress;
+
+namespace OSXBluetooth {
+
+class ChannelDelegate;
+
+}
+
+QT_END_NAMESPACE
+
+@class IOBluetoothDevice;
+
+@interface QT_MANGLE_NAMESPACE(OSXBTL2CAPChannel) : NSObject<IOBluetoothL2CAPChannelDelegate>
+{
+ QT_PREPEND_NAMESPACE(OSXBluetooth)::ChannelDelegate *delegate;
+ IOBluetoothDevice *device;
+ IOBluetoothL2CAPChannel *channel;
+ bool connected;
+}
+
+- (id)initWithDelegate:(QT_PREPEND_NAMESPACE(OSXBluetooth)::ChannelDelegate *)aDelegate;
+- (id)initWithDelegate:(QT_PREPEND_NAMESPACE(OSXBluetooth)::ChannelDelegate *)aDelegate
+ channel:(IOBluetoothL2CAPChannel *)aChannel;
+
+- (void)dealloc;
+
+// Async. connection (connect can be called only once).
+- (IOReturn)connectAsyncToDevice:(const QT_PREPEND_NAMESPACE(QBluetoothAddress) &)address
+ withPSM:(BluetoothL2CAPChannelID)psm;
+
+// IOBluetoothL2CAPChannelDelegate:
+- (void)l2capChannelData:(IOBluetoothL2CAPChannel*)l2capChannel
+ data:(void *)dataPointer length:(size_t)dataLength;
+- (void)l2capChannelOpenComplete:(IOBluetoothL2CAPChannel*)
+ l2capChannel status:(IOReturn)error;
+- (void)l2capChannelClosed:(IOBluetoothL2CAPChannel*)l2capChannel;
+- (void)l2capChannelReconfigured:(IOBluetoothL2CAPChannel*)l2capChannel;
+- (void)l2capChannelWriteComplete:(IOBluetoothL2CAPChannel*)l2capChannel
+ refcon:(void*)refcon status:(IOReturn)error;
+- (void)l2capChannelQueueSpaceAvailable:(IOBluetoothL2CAPChannel*)l2capChannel;
+
+//
+- (BluetoothL2CAPPSM)getPSM;
+- (BluetoothDeviceAddress)peerAddress;
+- (NSString *)peerName;
+- (bool)isConnected;
+
+// Writes the given data synchronously over the target L2CAP channel to the remote
+// device.
+// The length of the data may not exceed the L2CAP channel's outgoing MTU.
+// This method will block until the data has been successfully sent to the
+// hardware for transmission (or an error occurs).
+- (IOReturn) writeSync:(void*)data length:(UInt16)length;
+
+// The length of the data may not exceed the L2CAP channel's outgoing MTU.
+// When the data has been successfully passed to the hardware to be transmitted,
+// the delegate method -l2capChannelWriteComplete:refcon:status: will be called.
+// Returns kIOReturnSuccess if the data was buffered successfully.
+- (IOReturn) writeAsync:(void*)data length:(UInt16)length;
+
+@end
+
+#endif
diff --git a/src/bluetooth/osx/osxbtledeviceinquiry.mm b/src/bluetooth/osx/osxbtledeviceinquiry.mm
new file mode 100644
index 00000000..af304d8d
--- /dev/null
+++ b/src/bluetooth/osx/osxbtledeviceinquiry.mm
@@ -0,0 +1,336 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "osxbtledeviceinquiry_p.h"
+#include "qbluetoothdeviceinfo.h"
+#include "qbluetoothuuid.h"
+#include "osxbtutility_p.h"
+
+#include <QtCore/qloggingcategory.h>
+#include <QtCore/qsysinfo.h>
+#include <QtCore/qdebug.h>
+
+#include "corebluetoothwrapper_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace OSXBluetooth {
+
+LEDeviceInquiryDelegate::~LEDeviceInquiryDelegate()
+{
+}
+
+#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9, __IPHONE_6_0)
+
+QBluetoothUuid qt_uuid(NSUUID *nsUuid)
+{
+ if (!nsUuid)
+ return QBluetoothUuid();
+
+ uuid_t uuidData = {};
+ [nsUuid getUUIDBytes:uuidData];
+ quint128 qtUuidData = {};
+ std::copy(uuidData, uuidData + 16, qtUuidData.data);
+ return QBluetoothUuid(qtUuidData);
+}
+
+#endif
+
+QBluetoothUuid qt_uuid(CFUUIDRef uuid)
+{
+ if (!uuid)
+ return QBluetoothUuid();
+
+ const CFUUIDBytes data = CFUUIDGetUUIDBytes(uuid);
+ quint128 qtUuidData = {{data.byte0, data.byte1, data.byte2, data.byte3,
+ data.byte4, data.byte5, data.byte6, data.byte7,
+ data.byte8, data.byte9, data.byte10, data.byte11,
+ data.byte12, data.byte13, data.byte14, data.byte15}};
+
+ return QBluetoothUuid(qtUuidData);
+}
+
+typedef ObjCStrongReference<NSString> StringStrongReference;
+
+StringStrongReference uuid_as_nsstring(CFUUIDRef uuid)
+{
+ // We use the UUDI's string representation as a key in a dictionary.
+ if (!uuid)
+ return StringStrongReference();
+
+ CFStringRef cfStr = CFUUIDCreateString(kCFAllocatorDefault, uuid);
+ if (!cfStr)
+ return StringStrongReference();
+
+ // Imporant: with ARC this will require a different cast/ownership!
+ return StringStrongReference((NSString *)cfStr, false);
+}
+
+}
+
+
+QT_END_NAMESPACE
+
+#ifdef QT_NAMESPACE
+
+using namespace QT_NAMESPACE;
+
+#endif
+
+@interface QT_MANGLE_NAMESPACE(OSXBTLEDeviceInquiry) (PrivateAPI) <CBCentralManagerDelegate, CBPeripheralDelegate>
+// "Timeout" callback to stop a scan.
+- (void)stopScan;
+@end
+
+@implementation QT_MANGLE_NAMESPACE(OSXBTLEDeviceInquiry)
+
++ (int)inquiryLength
+{
+ // There is no default timeout,
+ // scan does not stop if not asked.
+ // Return in milliseconds
+ return 10 * 1000;
+}
+
+- (id)initWithDelegate:(OSXBluetooth::LEDeviceInquiryDelegate *)aDelegate
+{
+ Q_ASSERT_X(aDelegate, Q_FUNC_INFO, "invalid delegate (null)");
+
+ if (self = [super init]) {
+ delegate = aDelegate;
+ peripherals = [[NSMutableDictionary alloc] init];
+ manager = nil;
+ pendingStart = false;
+ cancelled = false;
+ isActive = false;
+ }
+
+ return self;
+}
+
+- (void)dealloc
+{
+ [NSObject cancelPreviousPerformRequestsWithTarget:self];
+
+ if (manager) {
+ [manager setDelegate:nil];
+ if (isActive)
+ [manager stopScan];
+ [manager release];
+ }
+
+ [peripherals release];
+ [super dealloc];
+}
+
+- (void)stopScan
+{
+ // Scan's timeout.
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+ Q_ASSERT_X(manager, Q_FUNC_INFO, "invalid central (nil)");
+ Q_ASSERT_X(!pendingStart, Q_FUNC_INFO, "invalid state");
+ Q_ASSERT_X(!cancelled, Q_FUNC_INFO, "invalid state");
+ Q_ASSERT_X(isActive, Q_FUNC_INFO, "invalid state");
+
+ [manager setDelegate:nil];
+ [manager stopScan];
+ isActive = false;
+
+ delegate->LEdeviceInquiryFinished();
+}
+
+- (bool)start
+{
+ Q_ASSERT_X(![self isActive], Q_FUNC_INFO, "LE device scan is already active");
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+
+ if (!peripherals) {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "internal error";
+ return false;
+ }
+
+ cancelled = false;
+ [peripherals removeAllObjects];
+
+ if (manager) {
+ // We can never be here, if status was not updated yet.
+ [manager setDelegate:nil];
+ [manager release];
+ }
+
+ startTime = QTime();
+ pendingStart = true;
+ manager = [CBCentralManager alloc];
+ manager = [manager initWithDelegate:self queue:nil];
+ if (!manager) {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to create a central manager";
+ return false;
+ }
+
+ return true;
+}
+
+- (void)centralManagerDidUpdateState:(CBCentralManager *)central
+{
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+
+ if (cancelled) {
+ Q_ASSERT_X(!isActive, Q_FUNC_INFO, "isActive is true");
+ pendingStart = false;
+ delegate->LEdeviceInquiryFinished();
+ return;
+ }
+
+ const CBCentralManagerState state = central.state;
+ if (state == CBCentralManagerStatePoweredOn) {
+ if (pendingStart) {
+ pendingStart = false;
+ isActive = true;
+#ifndef Q_OS_OSX
+ const NSTimeInterval timeout([QT_MANGLE_NAMESPACE(OSXBTLEDeviceInquiry) inquiryLength] / 1000);
+ Q_ASSERT_X(timeout > 0., Q_FUNC_INFO, "invalid scan timeout");
+ [self performSelector:@selector(stopScan) withObject:nil afterDelay:timeout];
+#endif
+ startTime = QTime::currentTime();
+ [manager scanForPeripheralsWithServices:nil options:nil];
+ } // Else we ignore.
+ } else if (state == CBCentralManagerStateUnsupported || state == CBCentralManagerStateUnauthorized) {
+ if (pendingStart) {
+ pendingStart = false;
+ delegate->LEnotSupported();
+ } else if (isActive) {
+ // It's not clear if this thing can happen at all.
+ // We had LE supported and now .. not anymore?
+ // Report as an error.
+ [NSObject cancelPreviousPerformRequestsWithTarget:self];
+ isActive = false;
+ [manager stopScan];
+ delegate->LEdeviceInquiryError(QBluetoothDeviceDiscoveryAgent::PoweredOffError);
+ }
+ } else if (state == CBCentralManagerStatePoweredOff) {
+ if (pendingStart) {
+ pendingStart = false;
+ delegate->LEnotSupported();
+ } else if (isActive) {
+ // We were able to start (isActive == true), so we had
+ // powered ON and now the adapter is OFF.
+ [NSObject cancelPreviousPerformRequestsWithTarget:self];
+ isActive = false;
+ [manager stopScan];
+ delegate->LEdeviceInquiryError(QBluetoothDeviceDiscoveryAgent::PoweredOffError);
+ } // Else we ignore.
+ } else {
+ // The following two states we ignore (from Apple's docs):
+ //"
+ // -CBCentralManagerStateUnknown
+ // The current state of the central manager is unknown;
+ // an update is imminent.
+ //
+ // -CBCentralManagerStateResetting
+ // The connection with the system service was momentarily
+ // lost; an update is imminent. "
+ //
+ // TODO: check if "is imminent" means UpdateState will
+ // be called again with something more reasonable.
+ }
+}
+
+- (void)stop
+{
+ [NSObject cancelPreviousPerformRequestsWithTarget:self];
+
+ if (pendingStart || cancelled) {
+ // We have to wait for a status update.
+ cancelled = true;
+ return;
+ }
+
+ if (isActive) {
+ [manager stopScan];
+ isActive = false;
+ delegate->LEdeviceInquiryFinished();
+ }
+}
+
+- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral
+ advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
+{
+ Q_UNUSED(central)
+ Q_UNUSED(advertisementData)
+
+ using namespace OSXBluetooth;
+
+ if (!isActive)
+ return;
+
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+
+#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9, __IPHONE_6_0)
+ if (QSysInfo::MacintoshVersion >= qt_OS_limit(QSysInfo::MV_10_9, QSysInfo::MV_IOS_6_0)) {
+ if (!peripheral.identifier) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "peripheral without NSUUID";
+ return;
+ }
+
+ if (![peripherals objectForKey:peripheral.identifier]) {
+ [peripherals setObject:peripheral forKey:peripheral.identifier];
+ const QBluetoothUuid deviceUuid(OSXBluetooth::qt_uuid(peripheral.identifier));
+ delegate->LEdeviceFound(peripheral, deviceUuid, advertisementData, RSSI);
+ }
+ return;
+ }
+#endif
+ if (!peripheral.UUID) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "peripheral without UUID";
+ return;
+ }
+
+ StringStrongReference key(uuid_as_nsstring(peripheral.UUID));
+ if (![peripherals objectForKey:key.data()]) {
+ [peripherals setObject:peripheral forKey:key.data()];
+ const QBluetoothUuid deviceUuid(OSXBluetooth::qt_uuid(peripheral.UUID));
+ delegate->LEdeviceFound(peripheral, deviceUuid, advertisementData, RSSI);
+ }
+}
+
+- (bool)isActive
+{
+ return pendingStart || isActive;
+}
+
+- (const QTime&)startTime
+{
+ return startTime;
+}
+
+@end
diff --git a/src/bluetooth/osx/osxbtledeviceinquiry_p.h b/src/bluetooth/osx/osxbtledeviceinquiry_p.h
new file mode 100644
index 00000000..7e6d0c8f
--- /dev/null
+++ b/src/bluetooth/osx/osxbtledeviceinquiry_p.h
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OSXBTLEDEVICEINQUIRY_P_H
+#define OSXBTLEDEVICEINQUIRY_P_H
+
+#include "qbluetoothdevicediscoveryagent.h"
+
+#include <QtCore/qdatetime.h>
+#include <QtCore/qglobal.h>
+#include <QtCore/qlist.h>
+
+#include <Foundation/Foundation.h>
+
+@class QT_MANGLE_NAMESPACE(OSXBTLEDeviceInquiry);
+
+@class CBCentralManager;
+@class CBPeripheral;
+
+QT_BEGIN_NAMESPACE
+
+class QBluetoothDeviceInfo;
+class QBluetoothUuid;
+
+namespace OSXBluetooth {
+
+class LEDeviceInquiryDelegate
+{
+public:
+ typedef QT_MANGLE_NAMESPACE(OSXBTLEDeviceInquiry) LEDeviceInquiryObjC;
+
+ virtual ~LEDeviceInquiryDelegate();
+
+ // At the moment the only error we're reporting is PoweredOffError!
+ virtual void LEdeviceInquiryError(QBluetoothDeviceDiscoveryAgent::Error error) = 0;
+
+ virtual void LEnotSupported() = 0;
+ virtual void LEdeviceFound(CBPeripheral *peripheral, const QBluetoothUuid &uuid,
+ NSDictionary *advertisementData, NSNumber *RSSI) = 0;
+ virtual void LEdeviceInquiryFinished() = 0;
+};
+
+}
+
+QT_END_NAMESPACE
+
+// Bluetooth Low Energy scan for iOS and OS X.
+
+@interface QT_MANGLE_NAMESPACE(OSXBTLEDeviceInquiry) : NSObject
+{// Protocols are adopted in the mm file.
+ QT_PREPEND_NAMESPACE(OSXBluetooth)::LEDeviceInquiryDelegate *delegate;
+
+ // TODO: scoped pointers/shared pointers?
+ NSMutableDictionary *peripherals; // Found devices.
+ CBCentralManager *manager;
+
+ // pending - waiting for a status update first.
+ bool pendingStart;
+ bool cancelled;
+ // scan actually started.
+ bool isActive;
+ QTime startTime;
+}
+
+// Inquiry length in milliseconds.
++ (int)inquiryLength;
+
+- (id)initWithDelegate:(QT_PREPEND_NAMESPACE(OSXBluetooth)::LEDeviceInquiryDelegate *)aDelegate;
+- (void)dealloc;
+
+// Actual scan can be delayed - we have to wait for a status update first.
+- (bool)start;
+// Stop can be delayed - if we're waiting for a status update.
+- (void)stop;
+
+- (bool)isActive;
+- (const QTime &)startTime;
+
+@end
+
+#endif
diff --git a/src/bluetooth/osx/osxbtobexsession.mm b/src/bluetooth/osx/osxbtobexsession.mm
new file mode 100644
index 00000000..f48da22d
--- /dev/null
+++ b/src/bluetooth/osx/osxbtobexsession.mm
@@ -0,0 +1,822 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "osxbtobexsession_p.h"
+#include "qbluetoothaddress.h"
+#include "osxbtutility_p.h"
+
+#include <QtCore/qloggingcategory.h>
+#include <QtCore/qvector.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qlist.h>
+
+#include <algorithm>
+#include <cstddef>
+#include <limits>
+
+QT_BEGIN_NAMESPACE
+
+namespace OSXBluetooth
+{
+
+OBEXSessionDelegate::~OBEXSessionDelegate()
+{
+}
+
+namespace {
+
+struct OBEXHeader
+{
+ OBEXHeader() : headerID(0)
+ {
+ }
+
+ quint8 headerID;
+ QVariant value;
+};
+
+enum {
+ // Bits 7 and 8 == header's format.
+ OBEXHeaderFormatMask = 0xc0,
+ //
+ OBEXHeaderFormatUnicode = 0, // 87
+ OBEXHeaderFormatByteSequence = 0x40, // 0100 0000
+ OBEXHeaderFormat1Byte = 0x80, // 1000 0000
+ OBEXHeaderFormat4Byte = 0xc0, // 1100 0000
+
+};
+
+quint32 extract_uint32(const uint8_t *bytes)
+{
+ // Four byte value, high byte first.
+ Q_ASSERT_X(bytes, Q_FUNC_INFO, "invalid input data (null)");
+
+ uint32_t value = uint32_t();
+ std::copy(bytes, bytes + sizeof value, reinterpret_cast<uint8_t *>(&value));
+
+ return NSSwapBigIntToHost(value);
+}
+
+quint16 extract_uint16(const uint8_t *bytes)
+{
+ // Two byte value, high byte first.
+ Q_ASSERT_X(bytes, Q_FUNC_INFO, "invalid input data (null)");
+
+ uint16_t value = uint16_t();
+ std::copy(bytes, bytes + sizeof value, reinterpret_cast<uint8_t *>(&value));
+
+ return NSSwapBigShortToHost(value);
+}
+
+QString extract_qstring(const uint8_t *bytes, quint16 stringLength)
+{
+ if (bytes && stringLength) {
+ NSString * const nsString = [[NSString alloc] initWithBytes:bytes
+ length:stringLength
+ encoding:NSUnicodeStringEncoding];
+ if (nsString)
+ return QString::fromNSString(nsString);
+ }
+
+ // Empty string is an error, "valid" empty strings are
+ // handled separately.
+ return QString();
+}
+
+QList<OBEXHeader> qt_bluetooth_headers(const uint8_t *data, std::size_t length)
+{
+ // Convert a data from IOBluetooth into something, Qt understands.
+ // Possible formats (bits 7 and 8):
+ // 1. 00 Two bytes of length folowed by a null-terminated
+ // Unicode text string (length is unsigned integer;
+ // it covers the header ID and the whole of the header
+ // value, including the length bytes and the two bytes
+ // of null terminator.
+ // 2. 01 Two bytes of length followed by a byte sequence (length
+ // is an unsigned integer sent high byte first; it covers
+ // the header ID and the whole of the header value).
+ // 3. 10 A single byte value.
+ // 4. 11 A four byte value, sent high byte first.
+
+ Q_ASSERT_X(data, Q_FUNC_INFO, "invalid data (null)");
+ Q_ASSERT_X(length >= 2, Q_FUNC_INFO, "invalid data length");
+
+ Q_UNUSED(data)
+ Q_UNUSED(length)
+
+ QList<OBEXHeader> empty;
+ QList<OBEXHeader> qtHeaders;
+
+ for (std::size_t i = 0; i < length;) {
+ std::size_t headerLength = 0;
+ OBEXHeader header;
+ header.headerID = data[i];
+
+ switch (data[i] & OBEXHeaderFormatMask) {
+ case OBEXHeaderFormatUnicode:
+ {
+ if (i + 3 > length)
+ return empty;
+ headerLength = extract_uint16(data + i + 1);
+ // Invalid length or input data:
+ if (headerLength < 3 || i + headerLength > length)
+ return empty;
+ if (headerLength == 3 || headerLength == 5) { // Can 5 ever happen?
+ header.value.fromValue<QString>(QString());
+ } else if (headerLength > 5) {// TODO: We do not check now, that the string actually valid.
+ const QString value(extract_qstring(data + i + 3, headerLength - 5));
+ if (!value.length()) // Some error?
+ return empty;
+ header.value.setValue<QString>(value);
+ } else // Still something weird.
+ return empty;
+ break;
+ }
+ case OBEXHeaderFormatByteSequence:
+ {
+ if (i + 3 > length)
+ return empty;
+ headerLength = extract_uint16(data + i + 1);
+ // Something is wrong:
+ if (headerLength < 3 || i + headerLength > length)
+ return empty;
+ QVector<unsigned char> value;
+ if (headerLength > 3) {
+ value.resize(headerLength - 3);
+ std::copy(data, data + headerLength, value.begin());
+ }
+ header.value.setValue<QVector<unsigned char> >(value);
+ break;
+ }
+ case OBEXHeaderFormat1Byte:
+ {
+ // 1 byte integer + 1 byte headerID == 2
+ if (i + 2 > length)
+ return empty;
+ headerLength = 2;
+ header.value.setValue<quint8>(data[i + 1]);
+ break;
+ }
+ case OBEXHeaderFormat4Byte:
+ {
+ // 4 byte integer + 1 byte headerID == 5
+ if (i + 5 > length)
+ return empty;
+ headerLength = 5;
+ header.value.setValue<quint32>(extract_uint32(data + i + 1));
+ break;
+ }
+ default:
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid header format";
+ return empty;
+ }
+
+ i += headerLength;
+ qtHeaders.push_back(header);
+ }
+
+ return qtHeaders;
+}
+
+bool append_uint16(ObjCStrongReference<NSMutableData> headers, uint16_t value)
+{
+ if (!headers)
+ return false;
+
+ const NSUInteger length = [headers length];
+ const uint16_t valueSwapped = NSSwapHostShortToBig(value);
+ [headers appendBytes:&valueSwapped length:sizeof valueSwapped];
+
+ return [headers length] - length == 2;
+}
+
+
+bool append_four_byte_header(ObjCStrongReference<NSMutableData> headers, uint8_t headerID,
+ uint32_t headerValue)
+{
+ if (!headers)
+ return false;
+
+ const NSUInteger length = [headers length];
+ // Header ID (1 byte)
+ [headers appendBytes:&headerID length:1];
+ // Header value (4 bytes)
+ const uint32_t valueSwapped(NSSwapHostIntToBig(headerValue));
+ [headers appendBytes:&valueSwapped length:sizeof valueSwapped];
+
+ return [headers length] - length == 5;
+}
+
+bool append_unicode_header(ObjCStrongReference<NSMutableData> headers, uint8_t headerID,
+ const QString &string)
+{
+ // Two bytes of length followed by a null-terminated
+ // Unicode text string. Length is unsigned integer,
+ // it covers the header ID and the whole of the header
+ // value, including the length bytes and the two bytes
+ // of null terminator.
+ // All Obj-C objects are autoreleased.
+
+ if (!headers)
+ return false;
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ const NSUInteger initialLength = [headers length];
+ [headers appendBytes:&headerID length:1];
+
+ if (!string.length()) {
+ // Empty string. The length is 3
+ // (header ID + length value itself).
+ return append_uint16(headers, 3);
+ }
+
+ NSString *const nsString = string.toNSString();
+ if (!nsString)
+ return false;
+
+ // TODO: check if the encodings is right. It was NSUnicodeStringEncoding but
+ // byte order was wrong. Also, I do not need BOM check anymore?
+ NSData *const data = [nsString dataUsingEncoding:NSUTF16BigEndianStringEncoding];
+ if (!data)
+ return false;
+
+ // This data can include byte-order marker (BOM) and does not include
+ // a null terminator. Anyway, the length must be >= 2.
+ NSUInteger length = [data length];
+ if (length < 2)
+ return false;
+
+ const uint8_t *dataPtr = static_cast<const uint8_t *>([data bytes]);
+ if ((dataPtr[0] == 0xff && dataPtr[1] == 0xfe)
+ || (dataPtr[0] == 0xfe && dataPtr[1] == 0xff)) {
+ if (length == 2) //Something weird?
+ return false;
+ // Skip a BOM.
+ dataPtr += 2;
+ length -= 2;
+ }
+
+ // headerID + length == 3, string's length + 2
+ // bytes for a null terminator.
+ if (!append_uint16(headers, length + 3 + 2))
+ return false;
+
+ [headers appendBytes:dataPtr length:length];
+ const uint8_t nullTerminator[2] = {};
+ [headers appendBytes:nullTerminator length:2];
+
+ return [headers length] - initialLength == length + 3 + 2;
+}
+
+ObjCStrongReference<NSMutableData> next_data_chunk(QIODevice &inputStream, IOBluetoothOBEXSession *session,
+ NSUInteger headersLength, bool &isLast)
+{
+ // Work only for OBEX put (we request a specific payload length).
+ Q_ASSERT_X(session, Q_FUNC_INFO, "invalid OBEX session (nil)");
+
+ const OBEXMaxPacketLength packetSize = [session getAvailableCommandPayloadLength:kOBEXOpCodePut];
+ if (!packetSize || headersLength >= packetSize)
+ return ObjCStrongReference<NSMutableData>();
+
+ const OBEXMaxPacketLength maxBodySize = packetSize - headersLength;
+
+ QVector<char> block(maxBodySize);
+ const int realSize = inputStream.read(block.data(), block.size());
+ if (realSize <= 0) {
+ // Well, either the last or an error.
+ isLast = true;
+ return ObjCStrongReference<NSMutableData>();
+ }
+
+ ObjCStrongReference<NSMutableData> chunk([NSMutableData dataWithBytes:block.data()
+ length:realSize], true);
+ if (chunk && [chunk length]) {
+ // If it actually was the last chunk
+ // of a length == maxBodySize, we'll
+ // send one more packet (empty though)?
+ isLast = [chunk length] < maxBodySize;
+ }
+
+ return chunk;
+}
+
+bool check_connect_event(const OBEXSessionEvent *e, OBEXError &error, OBEXOpCode &response)
+{
+ Q_ASSERT_X(e, Q_FUNC_INFO, "invalid event (null)");
+
+ // This function tries to extract either an error code or a
+ // server response code. "Good" event has type connect command respond
+ // and reponse code 0XA0. Everything else is a "bad" event and
+ // means connect failed.
+
+ // If it's an error event - return the error.
+ // If it's connect response - extract the response code.
+ // If it's something else (is it possible?) - set general error.
+
+ if (e->type == kOBEXSessionEventTypeError) {
+ error = e->u.errorData.error;
+ return false;
+ } if (e->type == kOBEXSessionEventTypeConnectCommandResponseReceived) {
+ // We can read response code only for such an event.
+ response = e->u.connectCommandResponseData.serverResponseOpCode;
+ return response == kOBEXResponseCodeSuccessWithFinalBit;
+ } else {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "unexpected event type";
+ error = kOBEXGeneralError;
+ return false;
+ }
+}
+
+bool check_put_event(const OBEXSessionEvent *e, OBEXError &error, OBEXOpCode &response)
+{
+ Q_ASSERT_X(e, Q_FUNC_INFO, "invalid event (null)");
+
+ // See the comments above.
+
+ if (e->type == kOBEXSessionEventTypeError) {
+ error = e->u.errorData.error;
+ return false;
+ } else if (e->type == kOBEXSessionEventTypePutCommandResponseReceived) {
+ response = e->u.putCommandResponseData.serverResponseOpCode;
+ return response == kOBEXResponseCodeContinueWithFinalBit ||
+ response == kOBEXResponseCodeSuccessWithFinalBit;
+ } else {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "unexpected event type";
+ error = kOBEXGeneralError;
+ return false;
+ }
+}
+
+bool check_abort_event(const OBEXSessionEvent *e, OBEXError &error, OBEXOpCode &response)
+{
+ Q_ASSERT_X(e, Q_FUNC_INFO, "invalid event (null)");
+
+ if (e->type == kOBEXSessionEventTypeError) {
+ error = e->u.errorData.error;
+ return false;
+ } else if (e->type == kOBEXSessionEventTypeAbortCommandResponseReceived) {
+ response = e->u.abortCommandResponseData.serverResponseOpCode;
+ return response == kOBEXResponseCodeSuccessWithFinalBit;
+ } else {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "unexpected event type";
+ return false;
+ }
+}
+
+} // Unnamed namespace.
+} // OSXBluetooth.
+
+QT_END_NAMESPACE
+
+#ifdef QT_NAMESPACE
+
+using namespace QT_NAMESPACE;
+
+#endif
+
+@interface QT_MANGLE_NAMESPACE(OSXBTOBEXSession) (PrivateAPI)
+
+// OBEXDisconnect returns void - it's considered to be always
+// successful. These methods are "private API" - no need to expose them,
+// for internal use only.
+- (void)OBEXDisconnect;
+- (void)OBEXDisconnectHandler:(const OBEXSessionEvent*)event;
+
+@end
+
+@implementation QT_MANGLE_NAMESPACE(OSXBTOBEXSession)
+
++ (OBEXMaxPacketLength) maxPacketLength
+{
+ // Some arbitrary number, we'll adjust it as soon as
+ // we connected, asking a session about packet size for
+ // a particular command.
+ return 0x1000;
+}
+
+- (id)initWithDelegate:(QT_PREPEND_NAMESPACE(OSXBluetooth::OBEXSessionDelegate) *)aDelegate
+ remoteDevice:(const QBluetoothAddress &)deviceAddress channelID:(quint16)port
+{
+ Q_ASSERT_X(aDelegate, Q_FUNC_INFO, "invalid delegate (null)");
+ Q_ASSERT_X(!deviceAddress.isNull(), Q_FUNC_INFO, "invalid remote device address");
+ Q_ASSERT_X(port, Q_FUNC_INFO, "invalid port (0)");
+
+ if (self = [super init]) {
+ connected = false;
+ currentRequest = OSXBluetooth::OBEXNoop;
+ connectionID = 0;
+ connectionIDFound = false;
+
+ const BluetoothDeviceAddress addr(OSXBluetooth::iobluetooth_address(deviceAddress));
+ device = [[IOBluetoothDevice deviceWithAddress:&addr] retain];
+ if (!device) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to create an IOBluetoothDevice";
+ return self;
+ }
+
+ session = [[IOBluetoothOBEXSession alloc] initWithDevice:device channelID:port];
+ if (!session) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to create an OBEX session";
+ return self;
+ }
+
+ delegate = aDelegate;
+ channelID = port;
+ }
+
+ return self;
+}
+
+- (void)dealloc
+{
+ [device release];
+ [session release];
+
+ [headersData release];
+ [bodyData release];
+
+ [super dealloc];
+}
+
+- (OBEXError)OBEXConnect
+{
+ if (!session) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid session (nil)";
+ return kOBEXGeneralError;
+ }
+
+ // That's a "single-shot" operation:
+ Q_ASSERT_X(currentRequest == OSXBluetooth::OBEXNoop, Q_FUNC_INFO,
+ "can not connect in this state (another request is active)");
+
+ connected = false;
+ connectionIDFound = false;
+ connectionID = 0;
+ currentRequest = OSXBluetooth::OBEXConnect;
+
+ const OBEXError status = [session OBEXConnect:kOBEXConnectFlagNone
+ maxPacketLength:[QT_MANGLE_NAMESPACE(OSXBTOBEXSession) maxPacketLength]
+ optionalHeaders:Q_NULLPTR
+ optionalHeadersLength:0
+ eventSelector:@selector(OBEXConnectHandler:)
+ selectorTarget:self
+ refCon:Q_NULLPTR];
+
+ if (status != kOBEXSuccess) {
+ currentRequest = OSXBluetooth::OBEXNoop;
+ // Already connected is still ok for us?
+ connected = status == kOBEXSessionAlreadyConnectedError;
+ }
+
+ return status;
+}
+
+- (void)OBEXConnectHandler:(const OBEXSessionEvent*)event
+{
+ using namespace OSXBluetooth;
+
+ Q_ASSERT_X(session, Q_FUNC_INFO, "invalid session (nil)");
+
+ if (pendingAbort) {
+ currentRequest = OBEXNoop;
+ [self OBEXAbort];
+ return;
+ }
+
+ if (currentRequest != OBEXConnect) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "called while there is no "
+ "active connect request";
+ return;
+ }
+
+ currentRequest = OBEXNoop;
+
+ OBEXError errorCode = kOBEXSuccess;
+ OBEXOpCode responseCode = kOBEXResponseCodeSuccessWithFinalBit;
+
+ if (!check_connect_event(event, errorCode, responseCode)) {
+ // OBEX connect failed.
+ if (delegate)
+ delegate->OBEXConnectError(errorCode, responseCode);
+ return;
+ }
+
+ const OBEXConnectCommandResponseData *const response = &event->u.connectCommandResponseData;
+ if (response->headerDataPtr && response->headerDataLength >= 2) {
+ // 2 == 1 byte headerID + at least 1 byte headerValue ...
+ QList<OBEXHeader> headers(qt_bluetooth_headers(static_cast<const uint8_t *>(response->headerDataPtr),
+ response->headerDataLength));
+ // ConnectionID is used when multiplexing OBEX connections
+ // to identify which particular connection this object is
+ // being sent on. When used, this _must_ be the first
+ // header sent.
+
+ foreach (const OBEXHeader &header, headers) {
+ if (header.headerID == kOBEXHeaderIDConnectionID) {
+ connectionID = header.value.value<quint32>();
+ connectionIDFound = true;
+ break;
+ }
+ }
+ }
+
+ connected = true;
+
+ if (delegate)
+ delegate->OBEXConnectSuccess();
+}
+
+- (OBEXError)OBEXAbort
+{
+ using namespace OSXBluetooth;
+
+ Q_ASSERT_X(session, Q_FUNC_INFO, "invalid OBEX session (nil)");
+
+ if (currentRequest == OBEXNoop) {
+ pendingAbort = false;
+
+ if (![self isConnected])
+ return kOBEXSessionNotConnectedError;
+
+ currentRequest = OBEXAbort;
+ const OBEXError status = [session OBEXAbort:Q_NULLPTR
+ optionalHeadersLength:0
+ eventSelector:@selector(OBEXAbortHandler:)
+ selectorTarget:self
+ refCon:Q_NULLPTR];
+ if (status != kOBEXSuccess)
+ currentRequest = OBEXNoop;
+
+ return status;
+ } else {
+ // We're in the middle of some request, wait
+ // for any handler to be called first.
+ pendingAbort = true;
+ return kOBEXSuccess;
+ }
+}
+
+- (void)OBEXAbortHandler:(const OBEXSessionEvent*)event
+{
+ using namespace OSXBluetooth;
+
+ Q_ASSERT_X(session, Q_FUNC_INFO, "invalid OBEX session (nil)");
+
+ if (currentRequest != OBEXAbort) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "called while there "
+ "is no ABORT request";
+ return;
+ }
+
+ pendingAbort = false;
+ currentRequest = OBEXNoop;
+
+ if (delegate) {
+ OBEXError error = kOBEXSuccess;
+ OBEXOpCode response = kOBEXResponseCodeSuccessWithFinalBit;
+ if (check_abort_event(event, error, response))
+ delegate->OBEXAbortSuccess();
+ }
+}
+
+- (OBEXError)OBEXPutFile:(QT_PREPEND_NAMESPACE(QIODevice) *)input withName:(const QString &)name
+{
+ using namespace OSXBluetooth;
+
+ if (!session || ![self isConnected])
+ return kOBEXSessionNotConnectedError;
+
+ Q_ASSERT_X(currentRequest == OBEXNoop, Q_FUNC_INFO,
+ "the current session has an active request already");
+ Q_ASSERT_X(input, Q_FUNC_INFO, "invalid input stream (null)");
+ Q_ASSERT_X(input->isReadable(), Q_FUNC_INFO, "invalid input stream (not readable)");
+
+ // We send a put request with a couple of headers (size/file name/may be connection ID) +
+ // a payload.
+ const qint64 fileSize = input->size();
+ if (fileSize <= 0 || fileSize >= std::numeric_limits<uint32_t>::max()) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid input file size";
+ return kOBEXBadArgumentError;
+ }
+
+ ObjCStrongReference<NSMutableData> headers([[NSMutableData alloc] init], false);
+ if (!headers) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to allocate headers";
+ return kOBEXNoResourcesError;
+ }
+
+ // Now we append headers with: Connection ID (if any),
+ // file name, file size, the first (and probably the only) chunk of data
+ // from the input stream and send a put request.
+
+ if (connectionIDFound) {
+ if (!append_four_byte_header(headers, kOBEXHeaderIDConnectionID, connectionID)) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to "
+ "append connection ID header";
+ return kOBEXNoResourcesError;
+ }
+ }
+
+ if (name.length()) {
+ if (!append_unicode_header(headers, kOBEXHeaderIDName, name)) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to append "
+ "a unicode string";
+ return kOBEXNoResourcesError;
+ }
+ }
+
+ if (fileSize && !input->isSequential())
+ append_four_byte_header(headers, kOBEXHeaderIDLength, uint32_t(fileSize));
+
+ bool lastChunk = false;
+ ObjCStrongReference<NSMutableData> chunk(next_data_chunk(*input, session, [headers length], lastChunk));
+ if (!chunk || ![chunk length]) {
+ // We do not support PUT-DELETE (?)
+ // At least the first chunk is expected to be non-empty.
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid input stream";
+ return kOBEXBadArgumentError;
+ }
+
+ currentRequest = OBEXPut;
+
+ const OBEXError status = [session OBEXPut:lastChunk
+ headersData:[headers mutableBytes]
+ headersDataLength:[headers length]
+ bodyData:[chunk mutableBytes]
+ bodyDataLength:[chunk length]
+ eventSelector:@selector(OBEXPutHandler:)
+ selectorTarget:self
+ refCon:Q_NULLPTR];
+
+ if (status == kOBEXSuccess) {
+ if (delegate && fileSize && !input->isSequential())
+ delegate->OBEXPutDataSent([chunk length], fileSize);
+
+ bytesSent = [chunk length];
+ headersData = headers.take();
+ bodyData = chunk.take();
+ inputStream = input;
+ } else {
+ // PUT request failed and we now
+ // want to close a connection/session.
+ currentRequest = OBEXNoop;
+ // Try to cleanup (disconnect).
+ [self OBEXDisconnect];
+ }
+
+ return status;
+}
+
+- (void)OBEXPutHandler:(const OBEXSessionEvent*)event
+{
+ using namespace OSXBluetooth;
+
+ Q_ASSERT_X(session, Q_FUNC_INFO, "invalid OBEX session (nil)");
+
+ if (pendingAbort) {
+ currentRequest = OBEXNoop;
+ [self OBEXAbort];
+ return;
+ }
+
+ if (currentRequest != OBEXPut) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "called while the current "
+ "request is not a put request";
+ return;
+ }
+
+ OBEXError error = kOBEXSuccess;
+ OBEXOpCode responseCode = kOBEXResponseCodeSuccessWithFinalBit;
+ if (!check_put_event(event, error, responseCode)) {
+ currentRequest = OBEXNoop;
+ if (delegate)
+ delegate->OBEXPutError(error, responseCode);
+ [self OBEXDisconnect];
+ return;
+ }
+
+ // Now try to send more data if we have any.
+ if (responseCode == kOBEXResponseCodeContinueWithFinalBit) {
+ // Send more data.
+ bool lastChunk = false;
+ // 0 for the headers length, no more headers.
+ ObjCStrongReference<NSMutableData> chunk(next_data_chunk(*inputStream, session, 0, lastChunk));
+ if (!chunk && !lastChunk) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to "
+ "allocate the next memory chunk";
+ return;
+ }
+
+ void *dataPtr = chunk ? [chunk mutableBytes] : Q_NULLPTR;
+ const NSUInteger dataSize = chunk ? [chunk length] : 0;
+ const OBEXError status = [session OBEXPut:lastChunk
+ headersData:Q_NULLPTR
+ headersDataLength:0
+ bodyData:dataPtr
+ bodyDataLength:dataSize
+ eventSelector:@selector(OBEXPutHandler:)
+ selectorTarget:self
+ refCon:Q_NULLPTR];
+
+ if (status != kOBEXSuccess) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to "
+ "send the next memory chunk";
+ currentRequest = OBEXNoop;
+ if (delegate) // Response code is not important here.
+ delegate->OBEXPutError(kOBEXNoResourcesError, 0);
+
+ [self OBEXDisconnect];
+ } else {
+ [bodyData release];
+ bytesSent += [chunk length];
+ bodyData = chunk.take();//retained already.
+
+ if (delegate && !inputStream->isSequential())
+ delegate->OBEXPutDataSent(bytesSent, inputStream->size());
+ }
+ } else if (responseCode == kOBEXResponseCodeSuccessWithFinalBit) {
+ currentRequest = OBEXNoop;
+ if (delegate)
+ delegate->OBEXPutSuccess();
+
+ [self OBEXDisconnect];
+ }
+}
+
+- (void)OBEXDisconnect
+{
+ Q_ASSERT_X(session, Q_FUNC_INFO, "invalid session (nil)");
+
+ currentRequest = OSXBluetooth::OBEXDisconnect;
+
+ [session OBEXDisconnect:Q_NULLPTR
+ optionalHeadersLength:0
+ eventSelector:@selector(OBEXDisconnectHandler:)
+ selectorTarget:self
+ refCon:Q_NULLPTR];
+}
+
+- (void)OBEXDisconnectHandler:(const OBEXSessionEvent*)event
+{
+ Q_UNUSED(event)
+
+ Q_ASSERT_X(session, Q_FUNC_INFO, "invalid session (nil)");
+
+ // Event can have an error type, but there's nothing
+ // we can do - even "cleanup" failed.
+ connected = false;
+}
+
+- (bool)isConnected
+{
+ return device && session && connected;
+}
+
+- (void)closeSession
+{
+ // Clear the delegate and reset the request,
+ // do not try any of OBEX commands - the session will be deleted
+ // immediately.
+ delegate = Q_NULLPTR;
+ // This will stop any handler (callback) preventing
+ // any read/write to potentially deleted objects.
+ currentRequest = OSXBluetooth::OBEXNoop;
+}
+
+- (bool)hasActiveRequest
+{
+ return currentRequest != OSXBluetooth::OBEXNoop && !pendingAbort;
+}
+
+@end
diff --git a/src/bluetooth/osx/osxbtobexsession_p.h b/src/bluetooth/osx/osxbtobexsession_p.h
new file mode 100644
index 00000000..ac2699cf
--- /dev/null
+++ b/src/bluetooth/osx/osxbtobexsession_p.h
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/qvariant.h>
+#include <QtCore/qglobal.h>
+
+#include <Foundation/Foundation.h>
+// Only after Foundation.h:
+#include "corebluetoothwrapper_p.h"
+
+@class IOBluetoothOBEXSession;
+@class IOBluetoothDevice;
+
+@class QT_MANGLE_NAMESPACE(OSXBTOBEXSession);
+
+QT_BEGIN_NAMESPACE
+
+class QBluetoothAddress;
+class QIODevice;
+class QString;
+
+namespace OSXBluetooth
+{
+
+class OBEXSessionDelegate
+{
+public:
+ typedef QT_MANGLE_NAMESPACE(OSXBTOBEXSession) ObjCOBEXSession;
+
+ virtual ~OBEXSessionDelegate();
+
+ virtual void OBEXConnectError(OBEXError error, OBEXOpCode responseCode) = 0;
+ virtual void OBEXConnectSuccess() = 0;
+
+ virtual void OBEXAbortSuccess() = 0;
+
+ virtual void OBEXPutDataSent(quint32 current, quint32 total) = 0;
+ virtual void OBEXPutSuccess() = 0;
+ virtual void OBEXPutError(OBEXError error, OBEXOpCode responseCode) = 0;
+};
+
+enum OBEXRequest {
+ OBEXNoop,
+ OBEXConnect,
+ OBEXDisconnect,
+ OBEXPut,
+ OBEXGet,
+ OBEXSetPath,
+ OBEXAbort
+};
+
+}
+
+QT_END_NAMESPACE
+
+// OBEX Session, it's a "single-shot" operation as our QBluetoothTransferReply is
+// (it does not have an interface to re-send data or re-use the same transfer reply).
+// It either succeeds or fails and tries to cleanup in any case.
+@interface QT_MANGLE_NAMESPACE(OSXBTOBEXSession) : NSObject
+{
+ QT_PREPEND_NAMESPACE(OSXBluetooth)::OBEXSessionDelegate *delegate;
+ IOBluetoothDevice *device;
+ quint16 channelID;
+ IOBluetoothOBEXSession *session;
+
+ QT_PREPEND_NAMESPACE(OSXBluetooth)::OBEXRequest currentRequest;
+
+ bool connected;
+ bool connectionIDFound;
+ quint32 connectionID;
+
+ QT_PREPEND_NAMESPACE(QIODevice) *inputStream;
+
+ // TODO: switch to scoped pointers or strong reference objects instead.
+ NSMutableData *headersData;
+ NSMutableData *bodyData;
+
+ quint32 bytesSent;
+ bool pendingAbort;
+}
+
+- (id)initWithDelegate:(QT_PREPEND_NAMESPACE(OSXBluetooth::OBEXSessionDelegate) *)aDelegate
+ remoteDevice:(const QBluetoothAddress &)deviceAddress channelID:(quint16)port;
+
+- (void)dealloc;
+
+// Below I have pairs: OBEX operation and its callback method.
+- (OBEXError)OBEXConnect;
+- (void)OBEXConnectHandler:(const OBEXSessionEvent*)event;
+
+- (OBEXError)OBEXAbort;
+- (void)OBEXAbortHandler:(const OBEXSessionEvent*)event;
+
+- (OBEXError)OBEXPutFile:(QT_PREPEND_NAMESPACE(QIODevice) *)inputStream withName:(const QString &)name;
+- (void)OBEXPutHandler:(const OBEXSessionEvent*)event;
+
+// Aux. methods.
+- (bool)isConnected;
+
+// To be called from C++ destructors. OBEXSession is not
+// valid anymore after this call (no more OBEX operations
+// can be executed). It's an ABORT/DISCONNECT sequence.
+// It also resets a delegate to null.
+- (void)closeSession;
+//
+- (bool)hasActiveRequest;
+
+@end
diff --git a/src/bluetooth/osx/osxbtrfcommchannel.mm b/src/bluetooth/osx/osxbtrfcommchannel.mm
new file mode 100644
index 00000000..a91f62dc
--- /dev/null
+++ b/src/bluetooth/osx/osxbtrfcommchannel.mm
@@ -0,0 +1,251 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "osxbtchanneldelegate_p.h"
+#include "osxbtrfcommchannel_p.h"
+#include "qbluetoothaddress.h"
+#include "osxbtutility_p.h"
+
+#ifdef QT_NAMESPACE
+using namespace QT_NAMESPACE;
+#endif
+
+@implementation QT_MANGLE_NAMESPACE(OSXBTRFCOMMChannel)
+
+- (id)initWithDelegate:(OSXBluetooth::ChannelDelegate *)aDelegate
+{
+ Q_ASSERT_X(aDelegate, Q_FUNC_INFO, "invalid delegate (null)");
+
+ if (self = [super init]) {
+ delegate = aDelegate;
+ device = nil;
+ channel = nil;
+ connected = false;
+ }
+
+ return self;
+}
+
+- (id)initWithDelegate:(QT_PREPEND_NAMESPACE(OSXBluetooth::ChannelDelegate) *)aDelegate
+ channel:(IOBluetoothRFCOMMChannel *)aChannel
+{
+ // This type of channel does not require connect, it's created with
+ // already open channel.
+ Q_ASSERT_X(aDelegate, Q_FUNC_INFO, "invalid delegate (null)");
+ Q_ASSERT_X(aChannel, Q_FUNC_INFO, "invalid channel (nil)");
+
+ if (self = [super init]) {
+ delegate = aDelegate;
+ channel = [aChannel retain];
+ [channel setDelegate:self];
+ device = [[channel getDevice] retain];
+ connected = true;
+ }
+
+ return self;
+}
+
+- (void)dealloc
+{
+ if (channel) {
+ [channel setDelegate:nil];
+ [channel closeChannel];
+ [channel release];
+ }
+
+ [device release];
+
+ [super dealloc];
+}
+
+// A single async connection (you can not reuse this object).
+- (IOReturn)connectAsyncToDevice:(const QBluetoothAddress &)address
+ withChannelID:(BluetoothRFCOMMChannelID)channelID
+{
+ if (address.isNull()) {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "invalid peer address";
+ return kIOReturnNoDevice;
+ }
+
+ // Can never be called twice.
+ if (connected || device || channel) {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "connection is already active";
+ return kIOReturnStillOpen;
+ }
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ const BluetoothDeviceAddress iobtAddress = OSXBluetooth::iobluetooth_address(address);
+ device = [IOBluetoothDevice deviceWithAddress:&iobtAddress];
+ if (!device) { // TODO: do I always check this BTW??? Apple's docs say nothing about nil.
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to create a device";
+ return kIOReturnNoDevice;
+ }
+
+ const IOReturn status = [device openRFCOMMChannelAsync:&channel
+ withChannelID:channelID delegate:self];
+ if (status != kIOReturnSuccess) {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to open L2CAP channel";
+ // device is still autoreleased.
+ device = nil;
+ return status;
+ }
+
+ [channel retain];// What if we're closed already?
+ [device retain];
+
+ return kIOReturnSuccess;
+}
+
+- (void)rfcommChannelData:(IOBluetoothRFCOMMChannel*)rfcommChannel
+ data:(void *)dataPointer length:(size_t)dataLength
+{
+ Q_UNUSED(rfcommChannel)
+
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+
+ // Not sure if it can ever happen and if
+ // assert is better.
+ if (!dataPointer || !dataLength)
+ return;
+
+ delegate->readChannelData(dataPointer, dataLength);
+}
+
+- (void)rfcommChannelOpenComplete:(IOBluetoothRFCOMMChannel*)rfcommChannel
+ status:(IOReturn)error
+{
+ Q_UNUSED(rfcommChannel)
+
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+
+ if (error != kIOReturnSuccess) {
+ delegate->setChannelError(error);
+ } else {
+ connected = true;
+ delegate->channelOpenComplete();
+ }
+}
+
+- (void)rfcommChannelClosed:(IOBluetoothRFCOMMChannel*)rfcommChannel
+{
+ Q_UNUSED(rfcommChannel)
+
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+ delegate->channelClosed();
+ connected = false;
+}
+
+- (void)rfcommChannelControlSignalsChanged:(IOBluetoothRFCOMMChannel*)rfcommChannel
+{
+ Q_UNUSED(rfcommChannel)
+}
+
+- (void)rfcommChannelFlowControlChanged:(IOBluetoothRFCOMMChannel*)rfcommChannel
+{
+ Q_UNUSED(rfcommChannel)
+}
+
+- (void)rfcommChannelWriteComplete:(IOBluetoothRFCOMMChannel*)rfcommChannel
+ refcon:(void*)refcon status:(IOReturn)error
+{
+ Q_UNUSED(rfcommChannel)
+ Q_UNUSED(refcon)
+
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+
+ if (error != kIOReturnSuccess)
+ delegate->setChannelError(error);
+ else
+ delegate->writeComplete();
+}
+
+- (void)rfcommChannelQueueSpaceAvailable:(IOBluetoothRFCOMMChannel*)rfcommChannel
+{
+ Q_UNUSED(rfcommChannel)
+}
+
+- (BluetoothRFCOMMChannelID)getChannelID
+{
+ if (channel)
+ return [channel getChannelID];
+
+ return 0;
+}
+
+- (BluetoothDeviceAddress)peerAddress
+{
+ const BluetoothDeviceAddress *const addr = device ? [device getAddress]
+ : Q_NULLPTR;
+ if (addr)
+ return *addr;
+
+ return BluetoothDeviceAddress();
+}
+
+- (NSString *)peerName
+{
+ if (device)
+ return device.name;
+
+ return nil;
+}
+
+- (BluetoothRFCOMMMTU)getMTU
+{
+ if (channel)
+ return [channel getMTU];
+
+ return 0;
+}
+
+- (IOReturn) writeSync:(void*)data length:(UInt16)length
+{
+ Q_ASSERT_X(data, Q_FUNC_INFO, "invalid data (null)");
+ Q_ASSERT_X(length, Q_FUNC_INFO, "invalid data size");
+ Q_ASSERT_X(connected && channel, Q_FUNC_INFO, "invalid RFCOMM channel");
+
+ return [channel writeSync:data length:length];
+}
+
+- (IOReturn) writeAsync:(void*)data length:(UInt16)length
+{
+ Q_ASSERT_X(data, Q_FUNC_INFO, "invalid data (null)");
+ Q_ASSERT_X(length, Q_FUNC_INFO, "invalid data size");
+ Q_ASSERT_X(connected && channel, Q_FUNC_INFO, "invalid RFCOMM channel");
+
+ return [channel writeAsync:data length:length refcon:Q_NULLPTR];
+}
+
+
+@end
diff --git a/src/bluetooth/osx/osxbtrfcommchannel_p.h b/src/bluetooth/osx/osxbtrfcommchannel_p.h
new file mode 100644
index 00000000..80758ab0
--- /dev/null
+++ b/src/bluetooth/osx/osxbtrfcommchannel_p.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OSXBTRFCOMMCHANNEL_P_H
+#define OSXBTRFCOMMCHANNEL_P_H
+
+#include <QtCore/qglobal.h>
+
+#include <Foundation/Foundation.h>
+// Only after Foundation.h:
+#include "corebluetoothwrapper_p.h"
+
+@class QT_MANGLE_NAMESPACE(OSXBTRFCOMMChannel);
+@class IOBluetoothDevice;
+
+QT_BEGIN_NAMESPACE
+
+class QBluetoothAddress;
+
+namespace OSXBluetooth {
+
+class ChannelDelegate;
+
+}
+
+QT_END_NAMESPACE
+
+@interface QT_MANGLE_NAMESPACE(OSXBTRFCOMMChannel) : NSObject<IOBluetoothRFCOMMChannelDelegate>
+{
+ QT_PREPEND_NAMESPACE(OSXBluetooth)::ChannelDelegate *delegate;
+ IOBluetoothDevice *device;
+ IOBluetoothRFCOMMChannel *channel;
+ bool connected;
+}
+
+- (id)initWithDelegate:(QT_PREPEND_NAMESPACE(OSXBluetooth)::ChannelDelegate *)aDelegate;
+- (id)initWithDelegate:(QT_PREPEND_NAMESPACE(OSXBluetooth)::ChannelDelegate *)aDelegate
+ channel:(IOBluetoothRFCOMMChannel *)aChannel;
+
+- (void)dealloc;
+
+// A single async connection (can connect only once).
+- (IOReturn)connectAsyncToDevice:(const QT_PREPEND_NAMESPACE(QBluetoothAddress) &)address
+ withChannelID:(BluetoothRFCOMMChannelID)channelID;
+
+- (void)rfcommChannelData:(IOBluetoothRFCOMMChannel*)rfcommChannel
+ data:(void *)dataPointer length:(size_t)dataLength;
+- (void)rfcommChannelOpenComplete:(IOBluetoothRFCOMMChannel*)rfcommChannel
+ status:(IOReturn)error;
+- (void)rfcommChannelClosed:(IOBluetoothRFCOMMChannel*)rfcommChannel;
+- (void)rfcommChannelControlSignalsChanged:(IOBluetoothRFCOMMChannel*)rfcommChannel;
+- (void)rfcommChannelFlowControlChanged:(IOBluetoothRFCOMMChannel*)rfcommChannel;
+- (void)rfcommChannelWriteComplete:(IOBluetoothRFCOMMChannel*)rfcommChannel
+ refcon:(void*)refcon status:(IOReturn)error;
+- (void)rfcommChannelQueueSpaceAvailable:(IOBluetoothRFCOMMChannel*)rfcommChannel;
+
+//
+- (BluetoothRFCOMMChannelID)getChannelID;
+- (BluetoothDeviceAddress)peerAddress;
+- (NSString *)peerName;
+
+- (BluetoothRFCOMMMTU)getMTU;
+
+- (IOReturn) writeSync:(void*)data length:(UInt16)length;
+- (IOReturn) writeAsync:(void*)data length:(UInt16)length;
+
+
+@end
+
+#endif
diff --git a/src/bluetooth/osx/osxbtsdpinquiry.mm b/src/bluetooth/osx/osxbtsdpinquiry.mm
new file mode 100644
index 00000000..004d9e61
--- /dev/null
+++ b/src/bluetooth/osx/osxbtsdpinquiry.mm
@@ -0,0 +1,258 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbluetoothserviceinfo.h"
+#include "osxbtsdpinquiry_p.h"
+#include "qbluetoothuuid.h"
+#include "osxbtutility_p.h"
+
+
+#include <QtCore/qvariant.h>
+#include <QtCore/qstring.h>
+
+#include "corebluetoothwrapper_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace OSXBluetooth {
+
+SDPInquiryDelegate::~SDPInquiryDelegate()
+{
+}
+
+QVariant extract_attribute_value(IOBluetoothSDPDataElement *dataElement)
+{
+ Q_ASSERT_X(dataElement, Q_FUNC_INFO, "invalid data element (nil)");
+
+ // TODO: error handling and diagnostic messages.
+
+ // All "temporary" obj-c objects are autoreleased.
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ const BluetoothSDPDataElementTypeDescriptor typeDescriptor = [dataElement getTypeDescriptor];
+
+ switch (typeDescriptor) {
+ case kBluetoothSDPDataElementTypeNil:
+ break;
+ case kBluetoothSDPDataElementTypeUnsignedInt:
+ return [[dataElement getNumberValue] unsignedIntValue];
+ case kBluetoothSDPDataElementTypeSignedInt:
+ return [[dataElement getNumberValue] intValue];
+ case kBluetoothSDPDataElementTypeUUID:
+ return QVariant::fromValue(qt_uuid([[dataElement getUUIDValue] getUUIDWithLength:16]));
+ case kBluetoothSDPDataElementTypeString:
+ case kBluetoothSDPDataElementTypeURL:
+ return QString::fromNSString([dataElement getStringValue]);
+ case kBluetoothSDPDataElementTypeBoolean:
+ return [[dataElement getNumberValue] boolValue];
+ case kBluetoothSDPDataElementTypeDataElementSequence:
+ case kBluetoothSDPDataElementTypeDataElementAlternative: // TODO: check this!
+ {
+ QBluetoothServiceInfo::Sequence sequence;
+ NSArray *const arr = [dataElement getArrayValue];
+ for (IOBluetoothSDPDataElement *element in arr)
+ sequence.append(extract_attribute_value(element));
+
+ return QVariant::fromValue(sequence);
+ }
+ break;// Coding style.
+ default:;
+ }
+
+ return QVariant();
+}
+
+void extract_service_record(IOBluetoothSDPServiceRecord *record, QBluetoothServiceInfo &serviceInfo)
+{
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ if (!record)
+ return;
+
+ NSDictionary *const attributes = record.attributes;
+ NSEnumerator *const keys = attributes.keyEnumerator;
+ for (NSNumber *key in keys) {
+ const quint16 attributeID = [key unsignedShortValue];
+ IOBluetoothSDPDataElement *const element = [attributes objectForKey:key];
+ const QVariant attributeValue = OSXBluetooth::extract_attribute_value(element);
+ serviceInfo.setAttribute(attributeID, attributeValue);
+ }
+}
+
+QList<QBluetoothUuid> extract_services_uuids(IOBluetoothDevice *device)
+{
+ QList<QBluetoothUuid> uuids;
+
+ // All "temporary" obj-c objects are autoreleased.
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ if (!device || !device.services)
+ return uuids;
+
+ NSArray * const records = device.services;
+ for (IOBluetoothSDPServiceRecord *record in records) {
+ IOBluetoothSDPDataElement *const element =
+ [record getAttributeDataElement:kBluetoothSDPAttributeIdentifierServiceClassIDList];
+
+ if (element && [element getTypeDescriptor] == kBluetoothSDPDataElementTypeUUID)
+ uuids.append(qt_uuid([[element getUUIDValue] getUUIDWithLength:16]));
+ }
+
+ return uuids;
+}
+
+}
+
+QT_END_NAMESPACE
+
+
+#ifdef QT_NAMESPACE
+using namespace QT_NAMESPACE;
+#endif
+
+using namespace OSXBluetooth;
+
+@implementation QT_MANGLE_NAMESPACE(OSXBTSDPInquiry)
+
+- (id)initWithDelegate:(SDPInquiryDelegate *)aDelegate
+{
+ Q_ASSERT_X(aDelegate, Q_FUNC_INFO, "invalid delegate (null)");
+
+ if (self = [super init]) {
+ delegate = aDelegate;
+ isActive = false;
+ }
+
+ return self;
+}
+
+- (void)dealloc
+{
+ //[device closeConnection]; //??? - synchronous, "In the future this API will be changed to allow asynchronous operation."
+ [device release];
+ [super dealloc];
+}
+
+- (IOReturn)performSDPQueryWithDevice:(const QBluetoothAddress &)address
+{
+ Q_ASSERT_X(!isActive, Q_FUNC_INFO, "SDP query in progress");
+
+ QList<QBluetoothUuid> emptyFilter;
+ return [self performSDPQueryWithDevice:address filters:emptyFilter];
+}
+
+- (IOReturn)performSDPQueryWithDevice:(const QBluetoothAddress &)address
+ filters:(const QList<QBluetoothUuid> &)qtFilters
+{
+ Q_ASSERT_X(!isActive, Q_FUNC_INFO, "SDP query in progress");
+ Q_ASSERT_X(!address.isNull(), Q_FUNC_INFO, "invalid target device address");
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ // We first try to allocate "filters":
+ ObjCScopedPointer<NSMutableArray> array;
+ if (qtFilters.size()) {
+ array.reset([[NSMutableArray alloc] init]);
+ if (!array) {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to allocate an uuid filter";
+ return kIOReturnError;
+ }
+
+ foreach (const QBluetoothUuid &qUuid, qtFilters) {
+ ObjCStrongReference<IOBluetoothSDPUUID> uuid(iobluetooth_uuid(qUuid));
+ if (uuid)
+ [array addObject:uuid];
+ }
+
+ if (int([array count]) != qtFilters.size()) {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to create an uuid filter";
+ return kIOReturnError;
+ }
+ }
+
+ const BluetoothDeviceAddress iobtAddress(iobluetooth_address(address));
+ ObjCScopedPointer<IOBluetoothDevice> newDevice([[IOBluetoothDevice deviceWithAddress:&iobtAddress] retain]);
+ if (!newDevice) {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to create an IOBluetoothDevice object";
+ return kIOReturnError;
+ }
+
+ ObjCScopedPointer<IOBluetoothDevice> oldDevice(device);
+ device = newDevice.data();
+
+ IOReturn result = kIOReturnSuccess;
+ if (qtFilters.size())
+ result = [device performSDPQuery:self uuids:array];
+ else
+ result = [device performSDPQuery:self];
+
+ if (result != kIOReturnSuccess) {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to start an SDP query";
+ device = oldDevice.take();
+ } else {
+ isActive = true;
+ newDevice.take();
+ }
+
+ return result;
+}
+
+- (void)stopSDPQuery
+{
+ // There is no API to stop it,
+ // but there is a 'stop' member-function in Qt and
+ // after it's called sdpQueryComplete must be somehow ignored.
+
+ [device release];
+ device = nil;
+}
+
+- (void)sdpQueryComplete:(IOBluetoothDevice *)aDevice status:(IOReturn)status
+{
+ // Can happen - there is no legal way to cancel an SDP query,
+ // after the 'reset' device can never be
+ // the same as the cancelled one.
+ if (device != aDevice)
+ return;
+
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+
+ isActive = false;
+
+ if (status != kIOReturnSuccess)
+ delegate->SDPInquiryError(aDevice, status);
+ else
+ delegate->SDPInquiryFinished(aDevice);
+}
+
+@end
diff --git a/src/bluetooth/osx/osxbtsdpinquiry_p.h b/src/bluetooth/osx/osxbtsdpinquiry_p.h
new file mode 100644
index 00000000..20b6c66c
--- /dev/null
+++ b/src/bluetooth/osx/osxbtsdpinquiry_p.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OSXBTSDPINQUIRY_H
+#define OSXBTSDPINQUIRY_H
+
+#include "qbluetoothaddress.h"
+#include "qbluetoothuuid.h"
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qlist.h>
+
+#include <Foundation/Foundation.h>
+
+@class QT_MANGLE_NAMESPACE(OSXBTSDPInquiry);
+@class IOBluetoothSDPServiceRecord;
+@class IOBluetoothSDPDataElement;
+@class IOBluetoothDevice;
+
+QT_BEGIN_NAMESPACE
+
+class QBluetoothServiceInfo;
+class QVariant;
+
+namespace OSXBluetooth {
+
+class SDPInquiryDelegate {
+public:
+ typedef QT_MANGLE_NAMESPACE(OSXBTSDPInquiry) ObjCServiceInquiry;
+
+ virtual ~SDPInquiryDelegate();
+
+ virtual void SDPInquiryFinished(IOBluetoothDevice *device) = 0;
+ virtual void SDPInquiryError(IOBluetoothDevice *device, IOReturn errorCode) = 0;
+};
+
+void extract_service_record(IOBluetoothSDPServiceRecord *record, QBluetoothServiceInfo &serviceInfo);
+QVariant extract_attribute_value(IOBluetoothSDPDataElement *dataElement);
+QList<QBluetoothUuid> extract_services_uuids(IOBluetoothDevice *device);
+
+}
+
+QT_END_NAMESPACE
+
+@interface QT_MANGLE_NAMESPACE(OSXBTSDPInquiry) : NSObject
+{
+ QT_PREPEND_NAMESPACE(OSXBluetooth::SDPInquiryDelegate) *delegate;
+ IOBluetoothDevice *device;
+ bool isActive;
+}
+
+- (id)initWithDelegate:(QT_PREPEND_NAMESPACE(OSXBluetooth::SDPInquiryDelegate) *)aDelegate;
+- (void)dealloc;
+
+- (IOReturn)performSDPQueryWithDevice:(const QBluetoothAddress &)address;
+- (IOReturn)performSDPQueryWithDevice:(const QBluetoothAddress &)address
+ filters:(const QList<QBluetoothUuid> &)filters;
+
+- (void)stopSDPQuery;
+
+- (void)sdpQueryComplete:(IOBluetoothDevice *)aDevice status:(IOReturn)status;
+
+@end
+
+#endif
diff --git a/src/bluetooth/osx/osxbtservicerecord.mm b/src/bluetooth/osx/osxbtservicerecord.mm
new file mode 100644
index 00000000..cd80ee63
--- /dev/null
+++ b/src/bluetooth/osx/osxbtservicerecord.mm
@@ -0,0 +1,452 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbluetoothserviceinfo.h"
+#include "osxbtservicerecord_p.h"
+
+#include <QtCore/qvariant.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qmap.h>
+#include <QtCore/qurl.h>
+
+#include "corebluetoothwrapper_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace OSXBluetooth {
+
+//
+// Returns a dictionary containing the Bluetooth RFCOMM service definition
+// corresponding to the provided |uuid| and |options|.
+namespace {
+
+typedef ObjCStrongReference<NSMutableDictionary> Dictionary;
+typedef ObjCStrongReference<IOBluetoothSDPUUID> SDPUUid;
+typedef ObjCStrongReference<NSNumber> Number;
+typedef QBluetoothServiceInfo QSInfo;
+typedef QSInfo::Sequence Sequence;
+typedef QSInfo::AttributeId AttributeId;
+
+}
+
+#if 0
+QBluetoothUuid profile_uuid(const QBluetoothServiceInfo &serviceInfo)
+{
+ // Strategy to pick service uuid:
+ // 1.) use serviceUuid()
+ // 2.) use first custom uuid if available
+ // 3.) use first service class uuid
+ QBluetoothUuid serviceUuid(serviceInfo.serviceUuid());
+
+ if (serviceUuid.isNull()) {
+ const QVariant var(serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds));
+ if (var.isValid()) {
+ const Sequence seq(var.value<Sequence>());
+
+ for (int i = 0; i < seq.count(); ++i) {
+ QBluetoothUuid uuid(seq.at(i).value<QBluetoothUuid>());
+ if (uuid.isNull())
+ continue;
+
+ const int size = uuid.minimumSize();
+ if (size == 2 || size == 4) { // Base UUID derived
+ if (serviceUuid.isNull())
+ serviceUuid = uuid;
+ } else {
+ return uuid;
+ }
+ }
+ }
+ }
+
+ return serviceUuid;
+}
+#endif
+
+template<class IntType>
+Number variant_to_nsnumber(const QVariant &);
+
+template<>
+Number variant_to_nsnumber<unsigned char>(const QVariant &var)
+{
+ return Number([NSNumber numberWithUnsignedChar:var.value<unsigned char>()], true);
+}
+
+template<>
+Number variant_to_nsnumber<unsigned short>(const QVariant &var)
+{
+ return Number([NSNumber numberWithUnsignedShort:var.value<unsigned short>()], true);
+}
+
+template<>
+Number variant_to_nsnumber<unsigned>(const QVariant &var)
+{
+ return Number([NSNumber numberWithUnsignedInt:var.value<unsigned>()], true);
+}
+
+template<>
+Number variant_to_nsnumber<char>(const QVariant &var)
+{
+ return Number([NSNumber numberWithChar:var.value<char>()], true);
+}
+
+template<>
+Number variant_to_nsnumber<short>(const QVariant &var)
+{
+ return Number([NSNumber numberWithShort:var.value<short>()], true);
+}
+
+template<>
+Number variant_to_nsnumber<int>(const QVariant &var)
+{
+ return Number([NSNumber numberWithInt:var.value<int>()], true);
+}
+
+template<class ValueType>
+void add_attribute(const QVariant &var, AttributeId key, Dictionary dict)
+{
+ Q_ASSERT_X(dict, Q_FUNC_INFO, "invalid dictionary (nil)");
+
+ if (!var.canConvert<ValueType>())
+ return;
+
+ const Number num(variant_to_nsnumber<ValueType>(var));
+ [dict setObject:num forKey:[NSString stringWithFormat:@"%d", int(key)]];
+}
+
+template<>
+void add_attribute<QString>(const QVariant &var, AttributeId key, Dictionary dict)
+{
+ Q_ASSERT_X(dict, Q_FUNC_INFO, "invalid dictionary (nil)");
+
+ if (!var.canConvert<QString>())
+ return;
+
+ const QString string(var.value<QString>());
+ if (string.length()) {
+ if (NSString *const nsString = string.toNSString())
+ [dict setObject:nsString forKey:[NSString stringWithFormat:@"%d", int(key)]];
+ }
+}
+
+template<>
+void add_attribute<QBluetoothUuid>(const QVariant &var, AttributeId key, Dictionary dict)
+{
+ Q_ASSERT_X(dict, Q_FUNC_INFO, "invalid dictionary (nil)");
+
+ if (!var.canConvert<QBluetoothUuid>())
+ return;
+
+ SDPUUid ioUUID(iobluetooth_uuid(var.value<QBluetoothUuid>()));
+ [dict setObject:ioUUID forKey:[NSString stringWithFormat:@"%d", int(key)]];
+}
+
+template<>
+void add_attribute<QUrl>(const QVariant &var, AttributeId key, Dictionary dict)
+{
+ Q_ASSERT_X(dict, Q_FUNC_INFO, "invalid dictionary (nil)");
+
+ if (!var.canConvert<QUrl>())
+ return;
+
+ Q_UNUSED(var)
+ Q_UNUSED(key)
+ Q_UNUSED(dict)
+
+ // TODO: not clear how should I pass an url in a dictionary, NSURL does not work.
+}
+
+template<class ValueType>
+void add_attribute(const QVariant &var, NSMutableArray *list);
+
+template<class ValueType>
+void add_attribute(const QVariant &var, NSMutableArray *list)
+{
+ Q_ASSERT_X(list, Q_FUNC_INFO, "invalid list (nil)");
+
+ if (!var.canConvert<ValueType>())
+ return;
+
+ const Number num(variant_to_nsnumber<ValueType>(var));
+ [list addObject:num];
+}
+
+template<>
+void add_attribute<QString>(const QVariant &var, NSMutableArray *list)
+{
+ Q_ASSERT_X(list, Q_FUNC_INFO, "invalid list (nil)");
+
+ if (!var.canConvert<QString>())
+ return;
+
+ const QString string(var.value<QString>());
+ if (string.length()) {
+ if (NSString *const nsString = string.toNSString())
+ [list addObject:nsString];
+ }
+}
+
+template<>
+void add_attribute<QBluetoothUuid>(const QVariant &var, NSMutableArray *list)
+{
+ Q_ASSERT_X(list, Q_FUNC_INFO, "invalid list (nil)");
+
+ if (!var.canConvert<QBluetoothUuid>())
+ return;
+
+ SDPUUid ioUUID(iobluetooth_uuid(var.value<QBluetoothUuid>()));
+ [list addObject:ioUUID];
+}
+
+template<>
+void add_attribute<QUrl>(const QVariant &var, NSMutableArray *list)
+{
+ Q_ASSERT_X(list, Q_FUNC_INFO, "invalid list (nil)");
+
+ if (!var.canConvert<QUrl>())
+ return;
+
+ Q_UNUSED(var)
+ Q_UNUSED(list)
+ // TODO: not clear how should I pass an url in a dictionary, NSURL does not work.
+}
+
+void add_rfcomm_protocol_descriptor_list(uint16 channelID, Dictionary dict)
+{
+ Q_ASSERT_X(dict, Q_FUNC_INFO, "invalid dictionary (nil)");
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ // Objective-C has literals (for arrays and dictionaries), but it will not compile
+ // on 10.7 or below, so quite a lot of code here.
+
+ NSMutableArray *const descriptorList = [NSMutableArray array];
+
+ IOBluetoothSDPUUID *const l2capUUID = [IOBluetoothSDPUUID uuid16:kBluetoothSDPUUID16L2CAP];
+ NSArray *const l2capList = [NSArray arrayWithObject:l2capUUID];
+
+ [descriptorList addObject:l2capList];
+ //
+ IOBluetoothSDPUUID *const rfcommUUID = [IOBluetoothSDPUUID uuid16:kBluetoothSDPUUID16RFCOMM];
+ NSMutableDictionary *const rfcommDict = [NSMutableDictionary dictionary];
+ [rfcommDict setObject:[NSNumber numberWithInt:1] forKey:@"DataElementType"];
+ [rfcommDict setObject:[NSNumber numberWithInt:1] forKey:@"DataElementSize"];
+ [rfcommDict setObject:[NSNumber numberWithInt:channelID] forKey:@"DataElementValue"];
+ //
+ NSMutableArray *const rfcommList = [NSMutableArray array];
+ [rfcommList addObject:rfcommUUID];
+ [rfcommList addObject:rfcommDict];
+
+ [descriptorList addObject:rfcommList];
+ [dict setObject:descriptorList forKey:[NSString stringWithFormat:@"%d",
+ kBluetoothSDPAttributeIdentifierProtocolDescriptorList]];
+}
+
+void add_l2cap_protocol_descriptor_list(uint16 psm, Dictionary dict)
+{
+ Q_ASSERT_X(dict, Q_FUNC_INFO, "invalid dictionary (nil)");
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ // Objective-C has literals (for arrays and dictionaries), but it will not compile
+ // on 10.7 or below, so quite a lot of code here.
+
+ NSMutableArray *const descriptorList = [NSMutableArray array];
+ NSMutableArray *const l2capList = [NSMutableArray array];
+
+ IOBluetoothSDPUUID *const l2capUUID = [IOBluetoothSDPUUID uuid16:kBluetoothSDPUUID16L2CAP];
+ [l2capList addObject:l2capUUID];
+
+ NSMutableDictionary *const l2capDict = [NSMutableDictionary dictionary];
+ [l2capDict setObject:[NSNumber numberWithInt:1] forKey:@"DataElementType"];
+ [l2capDict setObject:[NSNumber numberWithInt:2] forKey:@"DataElementSize"];
+ [l2capDict setObject:[NSNumber numberWithInt:psm] forKey:@"DataElementValue"];
+ [l2capList addObject:l2capDict];
+
+ [descriptorList addObject:l2capList];
+ [dict setObject:descriptorList forKey:[NSString stringWithFormat:@"%d",
+ kBluetoothSDPAttributeIdentifierProtocolDescriptorList]];
+}
+
+bool add_attribute(const QVariant &var, AttributeId key, NSMutableArray *list)
+{
+ Q_ASSERT_X(list, Q_FUNC_INFO, "invalid list (nil)");
+
+ if (var.canConvert<Sequence>())
+ return false;
+
+ if (var.canConvert<QString>()) {
+ //ServiceName, ServiceDescription, ServiceProvider.
+ add_attribute<QString>(var, list);
+ } else if (var.canConvert<QBluetoothUuid>()) {
+ add_attribute<QBluetoothUuid>(var, list);
+ } else {
+ // Here we need 'key' to understand the type.
+ // We can have different integer types actually, so I have to check
+ // the 'key' to be sure the conversion is reasonable.
+ switch (key) {
+ case QSInfo::ServiceRecordHandle:
+ case QSInfo::ServiceRecordState:
+ case QSInfo::ServiceInfoTimeToLive:
+ add_attribute<unsigned>(var, list);
+ break;
+ case QSInfo::ServiceAvailability:
+ add_attribute<unsigned char>(var, list);
+ break;
+ case QSInfo::IconUrl:
+ case QSInfo::DocumentationUrl:
+ case QSInfo::ClientExecutableUrl:
+ add_attribute<QUrl>(var, list);
+ break;
+ default:;
+ }
+ }
+
+ return true;
+}
+
+bool add_attribute(const QBluetoothServiceInfo &serviceInfo, AttributeId key, Dictionary dict)
+{
+ Q_ASSERT_X(dict, Q_FUNC_INFO, "invalid dict (nil)");
+
+ const QVariant var(serviceInfo.attribute(key));
+ if (var.canConvert<Sequence>())
+ return false;
+
+ if (var.canConvert<QString>()) {
+ //ServiceName, ServiceDescription, ServiceProvider.
+ add_attribute<QString>(var, key, dict);
+ } else if (var.canConvert<QBluetoothUuid>()) {
+ add_attribute<QBluetoothUuid>(serviceInfo.attribute(key), key, dict);
+ } else {
+ // We can have different integer types actually, so I have to check
+ // the 'key' to be sure the conversion is reasonable.
+ switch (key) {
+ case QSInfo::ServiceRecordHandle:
+ case QSInfo::ServiceRecordState:
+ case QSInfo::ServiceInfoTimeToLive:
+ add_attribute<unsigned>(serviceInfo.attribute(key), key, dict);
+ break;
+ case QSInfo::ServiceAvailability:
+ add_attribute<unsigned char>(serviceInfo.attribute(key), key, dict);
+ break;
+ case QSInfo::IconUrl:
+ case QSInfo::DocumentationUrl:
+ case QSInfo::ClientExecutableUrl:
+ add_attribute<QUrl>(serviceInfo.attribute(key), key, dict);
+ break;
+ default:;
+ }
+ }
+
+ return true;
+}
+
+bool add_sequence_attribute(const QVariant &var, AttributeId key, NSMutableArray *list)
+{
+ // Add a "nested" sequence.
+ Q_ASSERT_X(list, Q_FUNC_INFO, "invalid list (nil)");
+
+ if (var.isNull() || !var.canConvert<Sequence>())
+ return false;
+
+ const Sequence sequence(var.value<Sequence>());
+ foreach (const QVariant &var, sequence) {
+ if (var.canConvert<Sequence>()) {
+ NSMutableArray *const nested = [NSMutableArray array];
+ add_sequence_attribute(var, key, nested);
+ [list addObject:nested];
+ } else {
+ add_attribute(var, key, list);
+ }
+ }
+
+ return true;
+}
+
+bool add_sequence_attribute(const QBluetoothServiceInfo &serviceInfo, AttributeId key, Dictionary dict)
+{
+ Q_ASSERT_X(dict, Q_FUNC_INFO, "invalid dictionary (nil)");
+
+ const QVariant &var(serviceInfo.attribute(key));
+ if (var.isNull() || !var.canConvert<Sequence>())
+ return false;
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ NSMutableArray *const list = [NSMutableArray array];
+ const Sequence sequence(var.value<Sequence>());
+ foreach (const QVariant &element, sequence) {
+ if (!add_sequence_attribute(element, key, list))
+ add_attribute(element, key, list);
+ }
+ [dict setObject:list forKey:[NSString stringWithFormat:@"%d", int(key)]];
+
+ return true;
+}
+
+Dictionary iobluetooth_service_dictionary(const QBluetoothServiceInfo &serviceInfo)
+{
+ Dictionary dict;
+
+ if (serviceInfo.socketProtocol() == QBluetoothServiceInfo::UnknownProtocol)
+ return dict;
+
+ const QList<quint16> attributeIds(serviceInfo.attributes());
+ if (!attributeIds.size())
+ return dict;
+
+ dict.reset([[NSMutableDictionary alloc] init]);
+
+ foreach (quint16 key, attributeIds) {
+ if (key == QSInfo::ProtocolDescriptorList) // We handle it in a special way.
+ continue;
+ // TODO: check if non-sequence QVariant still must be
+ // converted into NSArray for some attribute ID.
+ if (!add_sequence_attribute(serviceInfo, AttributeId(key), dict))
+ add_attribute(serviceInfo, AttributeId(key), dict);
+ }
+
+ if (serviceInfo.socketProtocol() == QBluetoothServiceInfo::L2capProtocol) {
+ add_l2cap_protocol_descriptor_list(serviceInfo.protocolServiceMultiplexer(),
+ dict);
+ } else {
+ add_rfcomm_protocol_descriptor_list(serviceInfo.serverChannel(), dict);
+ }
+
+ return dict;
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/bluetooth/osx/osxbtservicerecord_p.h b/src/bluetooth/osx/osxbtservicerecord_p.h
new file mode 100644
index 00000000..fa84147b
--- /dev/null
+++ b/src/bluetooth/osx/osxbtservicerecord_p.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OSXBTSERVICERECORD_P_H
+#define OSXBTSERVICERECORD_P_H
+
+#include "osxbtutility_p.h"
+
+#include <QtCore/qglobal.h>
+
+#include <Foundation/Foundation.h>
+
+QT_BEGIN_NAMESPACE
+
+class QBluetoothServiceInfo;
+
+namespace OSXBluetooth {
+
+ObjCStrongReference<NSMutableDictionary> iobluetooth_service_dictionary(const QBluetoothServiceInfo &serviceInfo);
+
+}
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/bluetooth/osx/osxbtsocketlistener.mm b/src/bluetooth/osx/osxbtsocketlistener.mm
new file mode 100644
index 00000000..e3124dd1
--- /dev/null
+++ b/src/bluetooth/osx/osxbtsocketlistener.mm
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "osxbtsocketlistener_p.h"
+#include "osxbtutility_p.h"
+
+#include <QtCore/qdebug.h>
+
+#include "corebluetoothwrapper_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace OSXBluetooth {
+
+SocketListener::~SocketListener()
+{
+}
+
+}
+
+QT_END_NAMESPACE
+
+#ifdef QT_NAMESPACE
+
+using namespace QT_NAMESPACE;
+
+#endif
+
+@implementation QT_MANGLE_NAMESPACE(OSXBTSocketListener)
+
+- (id)initWithListener:(OSXBluetooth::SocketListener *)aDelegate
+{
+ Q_ASSERT_X(aDelegate, Q_FUNC_INFO, "invalid delegate (null)");
+ if (self = [super init]) {
+ connectionNotification = nil;
+ delegate = aDelegate;
+ port = 0;
+ }
+
+ return self;
+}
+
+- (void)dealloc
+{
+ [connectionNotification unregister];
+ [connectionNotification release];
+
+ [super dealloc];
+}
+
+- (bool)listenRFCOMMConnectionsWithChannelID:(BluetoothRFCOMMChannelID)channelID
+{
+ Q_ASSERT_X(!connectionNotification, Q_FUNC_INFO, "already listening");
+
+ connectionNotification = [IOBluetoothRFCOMMChannel registerForChannelOpenNotifications:self
+ selector:@selector(rfcommOpenNotification:channel:)
+ withChannelID:channelID
+ direction:kIOBluetoothUserNotificationChannelDirectionIncoming];
+ connectionNotification = [connectionNotification retain];
+ if (connectionNotification)
+ port = channelID;
+
+ return connectionNotification;
+}
+
+- (bool)listenL2CAPConnectionsWithPSM:(BluetoothL2CAPPSM)psm
+{
+ Q_ASSERT_X(!connectionNotification, Q_FUNC_INFO, "already listening");
+
+ connectionNotification = [IOBluetoothL2CAPChannel registerForChannelOpenNotifications:self
+ selector:@selector(l2capOpenNotification:channel:)
+ withPSM:psm
+ direction:kIOBluetoothUserNotificationChannelDirectionIncoming];
+ connectionNotification = [connectionNotification retain];
+ if (connectionNotification)
+ port = psm;
+
+ return connectionNotification;
+}
+
+- (void)rfcommOpenNotification:(IOBluetoothUserNotification *)notification
+ channel:(IOBluetoothRFCOMMChannel *)newChannel
+{
+ Q_UNUSED(notification)
+
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+ delegate->openNotify(newChannel);
+}
+
+- (void)l2capOpenNotification:(IOBluetoothUserNotification *)notification
+ channel:(IOBluetoothL2CAPChannel *)newChannel
+{
+ Q_UNUSED(notification)
+
+ Q_ASSERT_X(delegate, Q_FUNC_INFO, "invalid delegate (null)");
+ delegate->openNotify(newChannel);
+}
+
+- (quint16)port
+{
+ return port;
+}
+
+@end
diff --git a/src/bluetooth/osx/osxbtsocketlistener_p.h b/src/bluetooth/osx/osxbtsocketlistener_p.h
new file mode 100644
index 00000000..e4fd8882
--- /dev/null
+++ b/src/bluetooth/osx/osxbtsocketlistener_p.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OSXBTSOCKETLISTENER_P_H
+#define OSXBTSOCKETLISTENER_P_H
+
+#include <QtCore/qglobal.h>
+
+#include <Foundation/Foundation.h>
+#include <IOBluetooth/Bluetooth.h>
+
+@class IOBluetoothUserNotification;
+@class IOBluetoothRFCOMMChannel;
+@class IOBluetoothL2CAPChannel;
+@class QT_MANGLE_NAMESPACE(OSXBTSocketListener);
+
+QT_BEGIN_NAMESPACE
+
+namespace OSXBluetooth {
+
+class SocketListener
+{
+public:
+ typedef QT_MANGLE_NAMESPACE(OSXBTSocketListener) ObjCListener;
+
+ virtual ~SocketListener();
+
+ virtual void openNotify(IOBluetoothRFCOMMChannel *channel) = 0;
+ virtual void openNotify(IOBluetoothL2CAPChannel *channel) = 0;
+};
+
+}
+
+QT_END_NAMESPACE
+
+// A single OSXBTSocketListener can be started only once with
+// RFCOMM or L2CAP protocol. It must be deleted to stop listening.
+
+@interface QT_MANGLE_NAMESPACE(OSXBTSocketListener) : NSObject
+{
+ IOBluetoothUserNotification *connectionNotification;
+ QT_PREPEND_NAMESPACE(OSXBluetooth::SocketListener) *delegate;
+ quint16 port;
+}
+
+- (id)initWithListener:(QT_PREPEND_NAMESPACE(OSXBluetooth::SocketListener) *)aDelegate;
+- (void)dealloc;
+
+- (bool)listenRFCOMMConnectionsWithChannelID:(BluetoothRFCOMMChannelID)channelID;
+- (bool)listenL2CAPConnectionsWithPSM:(BluetoothL2CAPPSM)psm;
+
+- (void)rfcommOpenNotification:(IOBluetoothUserNotification *)notification
+ channel:(IOBluetoothRFCOMMChannel *)newChannel;
+
+- (void)l2capOpenNotification:(IOBluetoothUserNotification *)notification
+ channel:(IOBluetoothL2CAPChannel *)newChannel;
+
+- (quint16)port;
+
+@end
+
+#endif
diff --git a/src/bluetooth/osx/osxbtutility.mm b/src/bluetooth/osx/osxbtutility.mm
new file mode 100644
index 00000000..a5d3d936
--- /dev/null
+++ b/src/bluetooth/osx/osxbtutility.mm
@@ -0,0 +1,310 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbluetoothaddress.h"
+#include "osxbtutility_p.h"
+#include "qbluetoothuuid.h"
+
+#include <QtCore/qendian.h>
+#include <QtCore/qstring.h>
+
+#ifndef QT_IOS_BLUETOOTH
+
+#import <IOBluetooth/objc/IOBluetoothSDPUUID.h>
+
+#endif
+
+#include <algorithm>
+#include <limits>
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_IOS_BLUETOOTH
+
+Q_LOGGING_CATEGORY(QT_BT_OSX, "qt.bluetooth.osx")
+
+#else
+
+Q_LOGGING_CATEGORY(QT_BT_OSX, "qt.bluetooth.ios")
+
+#endif
+
+namespace OSXBluetooth {
+
+QString qt_address(NSString *address)
+{
+ if (address && address.length) {
+ NSString *const fixed = [address stringByReplacingOccurrencesOfString:@"-" withString:@":"];
+ return QString::fromNSString(fixed);
+ }
+
+ return QString();
+}
+
+#ifndef QT_IOS_BLUETOOTH
+
+
+QBluetoothAddress qt_address(const BluetoothDeviceAddress *a)
+{
+ if (a) {
+ // TODO: can a byte order be different in BluetoothDeviceAddress?
+ const quint64 qAddress = a->data[5] |
+ qint64(a->data[4]) << 8 |
+ qint64(a->data[3]) << 16 |
+ qint64(a->data[2]) << 24 |
+ qint64(a->data[1]) << 32 |
+ qint64(a->data[0]) << 40;
+ return QBluetoothAddress(qAddress);
+ }
+
+ return QBluetoothAddress();
+}
+
+BluetoothDeviceAddress iobluetooth_address(const QBluetoothAddress &qAddress)
+{
+ BluetoothDeviceAddress a = {};
+ if (!qAddress.isNull()) {
+ const quint64 val = qAddress.toUInt64();
+ a.data[0] = (val >> 40) & 0xff;
+ a.data[1] = (val >> 32) & 0xff;
+ a.data[2] = (val >> 24) & 0xff;
+ a.data[3] = (val >> 16) & 0xff;
+ a.data[4] = (val >> 8) & 0xff;
+ a.data[5] = val & 0xff;
+ }
+
+ return a;
+}
+
+ObjCStrongReference<IOBluetoothSDPUUID> iobluetooth_uuid(const QBluetoothUuid &uuid)
+{
+ const unsigned nBytes = 128 / std::numeric_limits<unsigned char>::digits;
+ const quint128 intVal(uuid.toUInt128());
+
+ const ObjCStrongReference<IOBluetoothSDPUUID> iobtUUID([IOBluetoothSDPUUID uuidWithBytes:intVal.data
+ length:nBytes], true);
+ return iobtUUID;
+}
+
+QBluetoothUuid qt_uuid(IOBluetoothSDPUUID *uuid)
+{
+ QBluetoothUuid qtUuid;
+ if (!uuid || [uuid length] != 16) // TODO: issue any diagnostic?
+ return qtUuid;
+
+ // TODO: ensure the correct byte-order!!!
+ quint128 uuidVal = {};
+ const quint8 *const source = static_cast<const quint8 *>([uuid bytes]);
+ std::copy(source, source + 16, uuidVal.data);
+ return QBluetoothUuid(uuidVal);
+}
+
+QString qt_error_string(IOReturn errorCode)
+{
+ switch (errorCode) {
+ case kIOReturnSuccess:
+ // NoError in many classes == an empty string description.
+ return QString();
+ case kIOReturnNoMemory:
+ return QString::fromLatin1("memory allocation failed");
+ case kIOReturnNoResources:
+ return QString::fromLatin1("failed to obtain a resource");
+ case kIOReturnBusy:
+ return QString::fromLatin1("device is busy");
+ case kIOReturnStillOpen:
+ return QString::fromLatin1("device(s) still open");
+ // Others later ...
+ case kIOReturnError: // "general error" (IOReturn.h)
+ default:
+ return QString::fromLatin1("unknown error");
+ }
+}
+
+#endif
+
+
+// Apple has: CBUUID, NSUUID, CFUUID, IOBluetoothSDPUUID
+// and it's handy to have several converters:
+
+QBluetoothUuid qt_uuid(CBUUID *uuid)
+{
+ // Apples' docs say "128 bit" and "16-bit UUIDs are implicitly
+ // pre-filled with the Bluetooth Base UUID."
+ // But Core Bluetooth can return CBUUID objects of length 2
+ // (16-bit, so they are not pre-filled?).
+
+ if (!uuid)
+ return QBluetoothUuid();
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ if (uuid.data.length == 2) {
+ // CBUUID's docs say nothing about byte-order.
+ // Seems to be in big-endian.
+ const uchar *const src = static_cast<const uchar *>(uuid.data.bytes);
+ return QBluetoothUuid(qFromBigEndian<quint16>(src));
+ } else if (uuid.data.length == 16) {
+ quint128 qtUuidData = {};
+ const quint8 *const source = static_cast<const quint8 *>(uuid.data.bytes);
+ std::copy(source, source + 16, qtUuidData.data);
+
+ return QBluetoothUuid(qtUuidData);
+ } else {
+ qCDebug(QT_BT_OSX) << "qt_uuid, invalid CBUUID, 2 or 16 bytes expected, but got "
+ << uuid.data.length << " bytes length";
+ return QBluetoothUuid();
+ }
+
+ if (uuid.data.length != 16) // TODO: warning?
+ return QBluetoothUuid();
+
+}
+
+CFStrongReference<CFUUIDRef> cf_uuid(const QBluetoothUuid &qtUuid)
+{
+ const quint128 qtUuidData = qtUuid.toUInt128();
+ const quint8 *const data = qtUuidData.data;
+
+ CFUUIDBytes bytes = {data[0], data[1], data[2], data[3],
+ data[4], data[5], data[6], data[7],
+ data[8], data[9], data[10], data[11],
+ data[12], data[13], data[14], data[15]};
+
+ CFUUIDRef cfUuid = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault, bytes);
+ return CFStrongReference<CFUUIDRef>(cfUuid, false);// false == already retained.
+}
+
+ObjCStrongReference<CBUUID> cb_uuid(const QBluetoothUuid &qtUuid)
+{
+ CFStrongReference<CFUUIDRef> cfUuid(cf_uuid(qtUuid));
+ if (!cfUuid)
+ return ObjCStrongReference<CBUUID>();
+
+ ObjCStrongReference<CBUUID> cbUuid([CBUUID UUIDWithCFUUID:cfUuid], true); //true == retain.
+ return cbUuid;
+}
+
+bool equal_uuids(const QBluetoothUuid &qtUuid, CBUUID *cbUuid)
+{
+ const QBluetoothUuid qtUuid2(qt_uuid(cbUuid));
+ return qtUuid == qtUuid2;
+}
+
+bool equal_uuids(CBUUID *cbUuid, const QBluetoothUuid &qtUuid)
+{
+ return equal_uuids(qtUuid, cbUuid);
+}
+
+QByteArray qt_bytearray(NSData *data)
+{
+ QByteArray value;
+ if (!data || !data.length)
+ return value;
+
+ value.resize(data.length);
+ const char *const src = static_cast<const char *>(data.bytes);
+ std::copy(src, src + data.length, value.data());
+
+ return value;
+}
+
+template<class Integer>
+QByteArray qt_bytearray(Integer n)
+{
+ QByteArray value;
+ value.resize(sizeof n);
+ const char *const src = reinterpret_cast<char *>(&n);
+ std::copy(src, src + sizeof n, value.data());
+
+ return value;
+}
+
+QByteArray qt_bytearray(NSString *string)
+{
+ if (!string)
+ return QByteArray();
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+ NSData *const utf8Data = [string dataUsingEncoding:NSUTF8StringEncoding];
+
+ return qt_bytearray(utf8Data);
+}
+
+QByteArray qt_bytearray(NSObject *obj)
+{
+ // descriptor.value has type 'id'.
+ // While the Apple's docs say this about descriptors:
+ //
+ // - CBUUIDCharacteristicExtendedPropertiesString
+ // The string representation of the UUID for the extended properties descriptor.
+ // The corresponding value for this descriptor is an NSNumber object.
+ //
+ // - CBUUIDCharacteristicUserDescriptionString
+ // The string representation of the UUID for the user description descriptor.
+ // The corresponding value for this descriptor is an NSString object.
+ //
+ // ... etc.
+ //
+ // This is not true. On OS X, they all seem to be NSData (or derived from NSData),
+ // and they can be something else on iOS (NSNumber, NSString, etc.)
+ if (!obj)
+ return QByteArray();
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ if ([obj isKindOfClass:[NSData class]]) {
+ return qt_bytearray(static_cast<NSData *>(obj));
+ } else if ([obj isKindOfClass:[NSString class]]) {
+ return qt_bytearray(static_cast<NSString *>(obj));
+ } else if ([obj isKindOfClass:[NSNumber class]]) {
+ NSNumber *const nsNumber = static_cast<NSNumber *>(obj);
+ return qt_bytearray([nsNumber unsignedShortValue]);
+ }
+ // TODO: Where can be more types, but Core Bluetooth does not support them,
+ // or at least it's not documented.
+
+ return QByteArray();
+}
+
+ObjCStrongReference<NSData> data_from_bytearray(const QByteArray & qtData)
+{
+ if (!qtData.size())
+ return ObjCStrongReference<NSData>([[NSData alloc] init], false);
+
+ ObjCStrongReference<NSData> result([NSData dataWithBytes:qtData.constData() length:qtData.size()], true);
+ return result;
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/bluetooth/osx/osxbtutility_p.h b/src/bluetooth/osx/osxbtutility_p.h
new file mode 100644
index 00000000..18d8732a
--- /dev/null
+++ b/src/bluetooth/osx/osxbtutility_p.h
@@ -0,0 +1,305 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OSXBTUTILITY_P_H
+#define OSXBTUTILITY_P_H
+
+#include <QtCore/qloggingcategory.h>
+#include <QtCore/qscopedpointer.h>
+#include <QtCore/qsysinfo.h>
+#include <QtCore/qglobal.h>
+
+#include <Foundation/Foundation.h>
+// Only after Foundation.h!
+#include "corebluetoothwrapper_p.h"
+
+@class CBUUID;
+
+QT_BEGIN_NAMESPACE
+
+class QBluetoothUuid;
+
+namespace OSXBluetooth {
+
+struct NSObjectDeleter {
+ static void cleanup(NSObject *obj)
+ {
+ [obj release];
+ }
+};
+
+template<class T>
+class ObjCScopedPointer : public QScopedPointer<NSObject, NSObjectDeleter>
+{
+public:
+ // TODO: remove default argument, add 'retain' parameter,
+ // add a default ctor??? This will make the semantics more
+ // transparent + will simplify the future transition to ARC
+ // (if it will ever happen).
+ explicit ObjCScopedPointer(T *ptr = Q_NULLPTR) : QScopedPointer(ptr){}
+ operator T*() const
+ {
+ return data();
+ }
+
+ T *data()const
+ {
+ return static_cast<T *>(QScopedPointer::data());
+ }
+
+ T *take()
+ {
+ return static_cast<T *>(QScopedPointer::take());
+ }
+};
+
+typedef ObjCScopedPointer<NSAutoreleasePool> AutoreleasePool;
+#define QT_BT_MAC_AUTORELEASEPOOL const OSXBluetooth::AutoreleasePool pool([[NSAutoreleasePool alloc] init])
+
+template<class T>
+class ObjCStrongReference {
+public:
+ ObjCStrongReference()
+ : m_ptr(nil)
+ {
+ }
+ ObjCStrongReference(T *obj, bool retain)
+ {
+ if (retain)
+ m_ptr = [obj retain];
+ else
+ m_ptr = obj; // For example, created with initWithXXXX.
+ }
+ ObjCStrongReference(const ObjCStrongReference &rhs)
+ {
+ m_ptr = [rhs.m_ptr retain];
+ }
+ ObjCStrongReference &operator = (const ObjCStrongReference &rhs)
+ {
+ // "Old-style" implementation:
+ if (this != &rhs && m_ptr != rhs.m_ptr) {
+ [m_ptr release];
+ m_ptr = [rhs.m_ptr retain];
+ }
+
+ return *this;
+ }
+
+#ifdef Q_COMPILER_RVALUE_REFS
+ ObjCStrongReference(ObjCStrongReference &&xval)
+ {
+ m_ptr = xval.m_ptr;
+ xval.m_ptr = nil;
+ }
+
+ ObjCStrongReference &operator = (ObjCStrongReference &&xval)
+ {
+ m_ptr = xval.m_ptr;
+ xval.m_ptr = nil;
+ return *this;
+ }
+#endif
+
+ ~ObjCStrongReference()
+ {
+ [m_ptr release];
+ }
+
+ void reset(T *newVal)
+ {
+ if (m_ptr != newVal) {
+ [m_ptr release];
+ m_ptr = [newVal retain];
+ }
+ }
+
+ void resetWithoutRetain(T *newVal)
+ {
+ if (m_ptr != newVal) {
+ [m_ptr release];
+ m_ptr = newVal;
+ }
+ }
+
+ operator T *() const
+ {
+ return m_ptr;
+ }
+
+ T *data() const
+ {
+ return m_ptr;
+ }
+
+ T *take()
+ {
+ T * p = m_ptr;
+ m_ptr = nil;
+ return p;
+ }
+private:
+ T *m_ptr;
+};
+
+// The type 'T' is some XXXRef from CoreFoundation and co.
+// In principle, we can do a trick removing a pointer from a type
+// when template is instantiated, but it's quite a lot of ugly pp-tokens
+// like OSXBluetooth::CFStrongReference<OSXBluetooth::remove_pointer<CFUUIDRref> > strongReference;
+// so instead we use 'T' everywhere, not 'T *' as can expected
+// from a smart pointer.
+template<class T>
+class CFStrongReference {
+public:
+ CFStrongReference()
+ : m_ptr(Q_NULLPTR)
+ {
+ }
+
+ CFStrongReference(T obj, bool retain)
+ : m_ptr(obj)
+ {
+ if (m_ptr && retain)
+ CFRetain(m_ptr);
+ }
+
+ CFStrongReference(const CFStrongReference &rhs)
+ {
+ if ((m_ptr = rhs.m_ptr))
+ CFRetain(m_ptr);
+ }
+
+ CFStrongReference &operator = (const CFStrongReference &rhs)
+ {
+ // "Old-style" implementation:
+ if (this != &rhs && m_ptr != rhs.m_ptr) {
+ if (m_ptr)
+ CFRelease(m_ptr);
+ if ((m_ptr = rhs.m_ptr))
+ CFRetain(m_ptr);
+ }
+
+ return *this;
+ }
+
+#ifdef Q_COMPILER_RVALUE_REFS
+ CFStrongReference(CFStrongReference &&xval)
+ {
+ m_ptr = xval.m_ptr;
+ xval.m_ptr = Q_NULLPTR;
+ }
+
+ CFStrongReference &operator = (CFStrongReference &&xval)
+ {
+ m_ptr = xval.m_ptr;
+ xval.m_ptr = Q_NULLPTR;
+ return *this;
+ }
+#endif
+
+ ~CFStrongReference()
+ {
+ if (m_ptr)
+ CFRelease(m_ptr);
+ }
+
+ void reset(T newVal)
+ {
+ if (m_ptr != newVal) {
+ if (m_ptr)
+ CFRelease(m_ptr);
+ if ((m_ptr = newVal))
+ CFRetain(m_ptr);
+ }
+ }
+
+ operator T() const
+ {
+ return m_ptr;
+ }
+
+ T data() const
+ {
+ return m_ptr;
+ }
+
+ T take()
+ {
+ T p = m_ptr;
+ m_ptr = Q_NULLPTR;
+ return p;
+ }
+private:
+ T m_ptr;
+};
+
+QString qt_address(NSString *address);
+
+#ifndef QT_IOS_BLUETOOTH
+
+class QBluetoothAddress qt_address(const BluetoothDeviceAddress *address);
+BluetoothDeviceAddress iobluetooth_address(const QBluetoothAddress &address);
+
+ObjCStrongReference<IOBluetoothSDPUUID> iobluetooth_uuid(const QBluetoothUuid &uuid);
+QBluetoothUuid qt_uuid(IOBluetoothSDPUUID *uuid);
+QString qt_error_string(IOReturn errorCode);
+
+#endif
+
+QBluetoothUuid qt_uuid(CBUUID *uuid);
+CFStrongReference<CFUUIDRef> cf_uuid(const QBluetoothUuid &qtUuid);
+ObjCStrongReference<CBUUID> cb_uuid(const QBluetoothUuid &qtUuid);
+bool equal_uuids(const QBluetoothUuid &qtUuid, CBUUID *cbUuid);
+bool equal_uuids(CBUUID *cbUuid, const QBluetoothUuid &qtUuid);
+QByteArray qt_bytearray(NSData *data);
+QByteArray qt_bytearray(NSObject *data);
+ObjCStrongReference<NSData> data_from_bytearray(const QByteArray & qtData);
+
+inline QSysInfo::MacVersion qt_OS_limit(QSysInfo::MacVersion osxVersion, QSysInfo::MacVersion iosVersion)
+{
+#ifdef Q_OS_OSX
+ Q_UNUSED(iosVersion)
+ return osxVersion;
+#else
+ Q_UNUSED(osxVersion)
+ return iosVersion;
+#endif
+}
+
+} // namespace OSXBluetooth
+
+// Logging category for both OS X and iOS.
+Q_DECLARE_LOGGING_CATEGORY(QT_BT_OSX)
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/bluetooth/osx/uistrings.cpp b/src/bluetooth/osx/uistrings.cpp
new file mode 100644
index 00000000..5684533e
--- /dev/null
+++ b/src/bluetooth/osx/uistrings.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "uistrings_p.h"
+
+// Translatable messages should go into this .cpp file for them to
+// be picked up by lupdate.
+
+QT_BEGIN_NAMESPACE
+
+const char DEV_DISCOVERY[] = "QBluetoothDeviceDiscoveryAgent";
+const char DD_POWERED_OFF[] = QT_TRANSLATE_NOOP("QBluetoothDeviceDiscoveryAgent", "Device is powered off");
+const char DD_INVALID_ADAPTER[] = QT_TRANSLATE_NOOP("QBluetoothDeviceDiscoveryAgent", "Cannot find valid Bluetooth adapter.");
+const char DD_IO[] = QT_TRANSLATE_NOOP("QBluetoothDeviceDiscoveryAgent", "Input Output Error");
+const char DD_NOTSUPPORTED[] = QT_TRANSLATE_NOOP("QBluetoothDeviceDiscoveryAgent", "Bluetooth LE is not supported");
+const char DD_UNKNOWN_ERROR[] = QT_TRANSLATE_NOOP("QBluetoothDeviceDiscoveryAgent", "Unknown error");
+const char DD_NOT_STARTED[] = QT_TRANSLATE_NOOP("QBluetoothDeviceDiscoveryAgent", "Cannot start device inquiry");
+const char DD_NOT_STARTED_LE[] = QT_TRANSLATE_NOOP("QBluetoothDeviceDiscoveryAgent", "Cannot start low energy device inquiry");
+const char DD_NOT_STOPPED[] = QT_TRANSLATE_NOOP("QBluetoothDeviceDiscoveryAgent", "Discovery cannot be stopped");
+
+const char SERVICE_DISCOVERY[] = "QBluetoothServiceDiscoveryAgent";
+const char SD_LOCAL_DEV_OFF[] = QT_TRANSLATE_NOOP("QBluetoothServiceDiscoveryAgent", "Local device is powered off");
+const char SD_MINIMAL_FAILED[] = QT_TRANSLATE_NOOP("QBluetoothServiceDiscoveryAgent", "Minimal service discovery failed");
+const char SD_INVALID_ADDRESS[] = QT_TRANSLATE_NOOP("QBluetoothServiceDiscoveryAgent", "Invalid Bluetooth adapter address");
+
+const char SOCKET[] = "QBluetoothSocket";
+const char SOC_NETWORK_ERROR[] = QT_TRANSLATE_NOOP("QBluetoothSocket", "Network Error");
+const char SOC_NOWRITE[] = QT_TRANSLATE_NOOP("QBluetoothSocket", "Cannot write while not connected");
+const char SOC_CONNECT_IN_PROGRESS[] = QT_TRANSLATE_NOOP("QBluetoothSocket", "Trying to connect while connection is in progress");
+const char SOC_SERVICE_NOT_FOUND[] = QT_TRANSLATE_NOOP("QBluetoothSocket", "Service cannot be found");
+const char SOC_INVAL_DATASIZE[] = QT_TRANSLATE_NOOP("QBluetoothSocket", "Invalid data/data size");
+const char SOC_NOREAD[] = QT_TRANSLATE_NOOP("QBluetoothSocket", "Cannot read while not connected");
+
+const char TRANSFER_REPLY[] = "QBluetoothTransferReply";
+const char TR_INVAL_TARGET[] = QT_TRANSLATE_NOOP("QBluetoothTransferReply", "Invalid target address");
+const char TR_SESSION_NO_START[] = QT_TRANSLATE_NOOP("QBluetoothTransferReply", "Push session cannot be started");
+const char TR_CONNECT_FAILED[] = QT_TRANSLATE_NOOP("QBluetoothTransferReply", "Push session cannot connect");
+const char TR_FILE_NOT_EXIST[] = QT_TRANSLATE_NOOP("QBluetoothTransferReply", "Source file does not exist");
+const char TR_NOT_READ_IODEVICE[] = QT_TRANSLATE_NOOP("QBluetoothTransferReply", "QIODevice cannot be read. Make sure it is open for reading.");
+const char TR_SESSION_FAILED[] = QT_TRANSLATE_NOOP("QBluetoothTransferReply", "Push session failed");
+const char TR_INVALID_DEVICE[] = QT_TRANSLATE_NOOP("QBluetoothTransferReply", "Invalid input device (null)");
+const char TR_OP_CANCEL[] = QT_TRANSLATE_NOOP("QBluetoothTransferReply", "Operation canceled");
+const char TR_IN_PROGRESS[] = QT_TRANSLATE_NOOP("QBluetoothTransferReply", "Transfer already started");
+const char TR_SERVICE_NO_FOUND[] = QT_TRANSLATE_NOOP("QBluetoothTransferReply", "Push service not found");
+
+const char LE_CONTROLLER[] = "QLowEnergyController";
+const char LEC_RDEV_NO_FOUND[] = QT_TRANSLATE_NOOP("QLowEnergyController", "Remote device cannot be found");
+const char LEC_NO_LOCAL_DEV[] = QT_TRANSLATE_NOOP("QLowEnergyController", "Cannot find local adapter");
+const char LEC_IO_ERROR[] = QT_TRANSLATE_NOOP("QLowEnergyController", "Error occurred during connection I/O");
+const char LEC_UNKNOWN_ERROR[] = QT_TRANSLATE_NOOP("QLowEnergyController", "Unknown Error");
+
+QT_END_NAMESPACE
diff --git a/src/bluetooth/osx/uistrings_p.h b/src/bluetooth/osx/uistrings_p.h
new file mode 100644
index 00000000..303bad89
--- /dev/null
+++ b/src/bluetooth/osx/uistrings_p.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TRANSLATIONS_H
+#define TRANSLATIONS_H
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QString>
+
+QT_BEGIN_NAMESPACE
+
+// QBluetoothDeviceDiscoveryAgent related strings
+extern const char DEV_DISCOVERY[];
+extern const char DD_POWERED_OFF[];
+extern const char DD_INVALID_ADAPTER[];
+extern const char DD_IO[];
+extern const char DD_NOTSUPPORTED[];
+extern const char DD_UNKNOWN_ERROR[];
+extern const char DD_NOT_STARTED[];
+extern const char DD_NOT_STARTED_LE[];
+extern const char DD_NOT_STOPPED[];
+
+// QBluetoothServiceDiscoveryAgent related strings
+extern const char SERVICE_DISCOVERY[];
+extern const char SD_LOCAL_DEV_OFF[];
+extern const char SD_MINIMAL_FAILED[];
+extern const char SD_INVALID_ADDRESS[];
+
+// QBluetoothSocket related strings
+extern const char SOCKET[];
+extern const char SOC_NETWORK_ERROR[];
+extern const char SOC_NOWRITE[];
+extern const char SOC_CONNECT_IN_PROGRESS[];
+extern const char SOC_SERVICE_NOT_FOUND[];
+extern const char SOC_INVAL_DATASIZE[];
+extern const char SOC_NOREAD[];
+
+// QBluetoothTransferReply related strings
+extern const char TRANSFER_REPLY[];
+extern const char TR_INVAL_TARGET[];
+extern const char TR_SESSION_NO_START[];
+extern const char TR_CONNECT_FAILED[];
+extern const char TR_FILE_NOT_EXIST[];
+extern const char TR_NOT_READ_IODEVICE[];
+extern const char TR_SESSION_FAILED[];
+extern const char TR_INVALID_DEVICE[];
+extern const char TR_OP_CANCEL[];
+extern const char TR_IN_PROGRESS[];
+extern const char TR_SERVICE_NO_FOUND[];
+
+// QLowEnergyController related strings
+extern const char LE_CONTROLLER[];
+extern const char LEC_RDEV_NO_FOUND[];
+extern const char LEC_NO_LOCAL_DEV[];
+extern const char LEC_IO_ERROR[];
+extern const char LEC_UNKNOWN_ERROR[];
+
+QT_END_NAMESPACE
+
+#endif // TRANSLATIONS_H
+
diff --git a/src/bluetooth/qbluetooth.cpp b/src/bluetooth/qbluetooth.cpp
index ea3900e1..cea63a34 100644
--- a/src/bluetooth/qbluetooth.cpp
+++ b/src/bluetooth/qbluetooth.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetooth.h b/src/bluetooth/qbluetooth.h
index ebe546f8..f448af02 100644
--- a/src/bluetooth/qbluetooth.h
+++ b/src/bluetooth/qbluetooth.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothaddress.cpp b/src/bluetooth/qbluetoothaddress.cpp
index 53ac7881..8e3c29c6 100644
--- a/src/bluetooth/qbluetoothaddress.cpp
+++ b/src/bluetooth/qbluetoothaddress.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -65,7 +65,7 @@ class BluetoothAddressRegisterMetaTypes
public:
BluetoothAddressRegisterMetaTypes()
{
- qRegisterMetaType<QBluetoothAddress>("QBluetoothAddress");
+ qRegisterMetaType<QBluetoothAddress>();
}
} _registerBluetoothAddressMetaTypes;
}
diff --git a/src/bluetooth/qbluetoothaddress.h b/src/bluetooth/qbluetoothaddress.h
index 3fa491a2..32356d3b 100644
--- a/src/bluetooth/qbluetoothaddress.h
+++ b/src/bluetooth/qbluetoothaddress.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothaddress_p.h b/src/bluetooth/qbluetoothaddress_p.h
index be641dca..7a2fbdcf 100644
--- a/src/bluetooth/qbluetoothaddress_p.h
+++ b/src/bluetooth/qbluetoothaddress_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent.cpp
index b92e9c72..073146bc 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -56,6 +56,14 @@ QT_BEGIN_NAMESPACE
To retrieve results asynchronously, connect to the deviceDiscovered() signal. To get a list of
all discovered devices, call discoveredDevices() after the finished() signal.
+
+ This class can be used to discover Classic and Low Energy Bluetooth devices.
+ The individual device type can be determined via the
+ \l QBluetoothDeviceInfo::coreConfigurations() attribute.
+ In most cases the list returned by \l discoveredDevices() contains both types
+ of devices. However not every platform can detect both types of devices.
+ On platforms with this limitation (for example iOS only suports Low Energy discovery),
+ the discovery process will limit the search to the type which is supported.
*/
/*!
@@ -68,6 +76,10 @@ QT_BEGIN_NAMESPACE
\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 UnsupportedPlatformError Device discovery is not possible or implemented on the current
+ platform. The error is set in response to a call to \l start().
+ An example for such cases are iOS versions below 5.0 which do not support
+ Bluetooth device search at all. This value was introduced by Qt 5.5.
\value UnknownError An unknown error has occurred.
*/
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent.h b/src/bluetooth/qbluetoothdevicediscoveryagent.h
index 7800f6f7..656604ac 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent.h
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -58,6 +58,7 @@ public:
InputOutputError,
PoweredOffError,
InvalidBluetoothAdapterError,
+ UnsupportedPlatformError,
UnknownError = 100 // New errors must be added before Unknown error
};
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_android.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_android.cpp
index 1bd3dac5..a6aaaf03 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_android.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_android.cpp
@@ -1,8 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2013 Lauri Laanmets (Proekspert AS) <lauri.laanmets@eesti.ee>
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -36,20 +36,28 @@
#include <QtCore/QLoggingCategory>
#include <QtBluetooth/QBluetoothAddress>
#include <QtBluetooth/QBluetoothDeviceInfo>
+#include <QtCore/private/qjnihelpers_p.h>
#include "android/devicediscoverybroadcastreceiver_p.h"
+#include <QtAndroidExtras/QAndroidJniEnvironment>
QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(QT_BT_ANDROID)
+enum {
+ NoScanActive = 0,
+ SDPScanActive = 1,
+ BtleScanActive = 2
+};
+
QBluetoothDeviceDiscoveryAgentPrivate::QBluetoothDeviceDiscoveryAgentPrivate(
const QBluetoothAddress &deviceAdapter, QBluetoothDeviceDiscoveryAgent *parent) :
inquiryType(QBluetoothDeviceDiscoveryAgent::GeneralUnlimitedInquiry),
lastError(QBluetoothDeviceDiscoveryAgent::NoError),
- errorString(QStringLiteral()),
receiver(0),
m_adapterAddress(deviceAdapter),
- m_active(false),
+ m_active(NoScanActive),
+ leScanTimeout(0),
pendingCancel(false),
pendingStart(false),
q_ptr(parent)
@@ -61,7 +69,7 @@ QBluetoothDeviceDiscoveryAgentPrivate::QBluetoothDeviceDiscoveryAgentPrivate(
QBluetoothDeviceDiscoveryAgentPrivate::~QBluetoothDeviceDiscoveryAgentPrivate()
{
- if (m_active)
+ if (m_active != NoScanActive)
stop();
if (receiver) {
@@ -76,7 +84,7 @@ bool QBluetoothDeviceDiscoveryAgentPrivate::isActive() const
return true;
if (pendingCancel)
return false;
- return m_active;
+ return m_active != NoScanActive;
}
void QBluetoothDeviceDiscoveryAgentPrivate::start()
@@ -116,11 +124,12 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start()
// install Java BroadcastReceiver
if (!receiver) {
+ // SDP based device discovery
receiver = new DeviceDiscoveryBroadcastReceiver();
- qRegisterMetaType<QBluetoothDeviceInfo>("QBluetoothDeviceInfo");
- QObject::connect(receiver, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)),
- this, SLOT(processDiscoveredDevices(QBluetoothDeviceInfo)));
- QObject::connect(receiver, SIGNAL(finished()), this, SLOT(processDiscoveryFinished()));
+ qRegisterMetaType<QBluetoothDeviceInfo>();
+ QObject::connect(receiver, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo,bool)),
+ this, SLOT(processDiscoveredDevices(QBluetoothDeviceInfo,bool)));
+ QObject::connect(receiver, SIGNAL(finished()), this, SLOT(processSdpDiscoveryFinished()));
}
discoveredDevices.clear();
@@ -133,7 +142,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start()
return;
}
- m_active = true;
+ m_active = SDPScanActive;
qCDebug(QT_BT_ANDROID)
<< "QBluetoothDeviceDiscoveryAgentPrivate::start() - successfully executed.";
@@ -143,35 +152,38 @@ void QBluetoothDeviceDiscoveryAgentPrivate::stop()
{
Q_Q(QBluetoothDeviceDiscoveryAgent);
- if (!m_active)
+ if (m_active == NoScanActive)
return;
- pendingCancel = true;
- pendingStart = false;
- bool success = adapter.callMethod<jboolean>("cancelDiscovery");
- if (!success) {
- lastError = QBluetoothDeviceDiscoveryAgent::InputOutputError;
- errorString = QBluetoothDeviceDiscoveryAgent::tr("Discovery cannot be stopped");
- emit q->error(lastError);
- return;
+ if (m_active == SDPScanActive) {
+ pendingCancel = true;
+ pendingStart = false;
+ bool success = adapter.callMethod<jboolean>("cancelDiscovery");
+ if (!success) {
+ lastError = QBluetoothDeviceDiscoveryAgent::InputOutputError;
+ errorString = QBluetoothDeviceDiscoveryAgent::tr("Discovery cannot be stopped");
+ emit q->error(lastError);
+ return;
+ }
+ } else if (m_active == BtleScanActive) {
+ stopLowEnergyScan();
}
}
-void QBluetoothDeviceDiscoveryAgentPrivate::processDiscoveryFinished()
+void QBluetoothDeviceDiscoveryAgentPrivate::processSdpDiscoveryFinished()
{
// We need to guard because Android sends two DISCOVERY_FINISHED when cancelling
// Also if we have two active agents both receive the same signal.
// If this one is not active ignore the device information
- if (!m_active)
+ if (m_active != SDPScanActive)
return;
- m_active = false;
-
Q_Q(QBluetoothDeviceDiscoveryAgent);
if (pendingCancel && !pendingStart) {
- emit q->canceled();
+ m_active = NoScanActive;
pendingCancel = false;
+ emit q->canceled();
} else if (pendingStart) {
pendingStart = pendingCancel = false;
start();
@@ -179,28 +191,111 @@ void QBluetoothDeviceDiscoveryAgentPrivate::processDiscoveryFinished()
// check that it didn't finish due to turned off Bluetooth Device
const int state = adapter.callMethod<jint>("getState");
if (state != 12) { // BluetoothAdapter.STATE_ON
+ m_active = NoScanActive;
lastError = QBluetoothDeviceDiscoveryAgent::PoweredOffError;
errorString = QBluetoothDeviceDiscoveryAgent::tr("Device is powered off");
emit q->error(lastError);
return;
}
- emit q->finished();
+
+ // start LE scan if supported
+ if (QtAndroidPrivate::androidSdkVersion() < 18) {
+ qCDebug(QT_BT_ANDROID) << "Skipping Bluetooth Low Energy device scan";
+ emit q->finished();
+ } else {
+ startLowEnergyScan();
+ }
}
}
void QBluetoothDeviceDiscoveryAgentPrivate::processDiscoveredDevices(
- const QBluetoothDeviceInfo &info)
+ const QBluetoothDeviceInfo &info, bool isLeResult)
{
// If we have two active agents both receive the same signal.
// If this one is not active ignore the device information
- if (!m_active)
+ if (m_active != SDPScanActive && !isLeResult)
+ return;
+ if (m_active != BtleScanActive && isLeResult)
return;
Q_Q(QBluetoothDeviceDiscoveryAgent);
+ for (int i = 0; i < discoveredDevices.size(); i++) {
+ if (discoveredDevices[i].address() == info.address()) {
+ if (discoveredDevices[i] == info) {
+ qCDebug(QT_BT_ANDROID) << "Duplicate: " << info.address()
+ << "isLeScanResult:" << isLeResult;
+ return;
+ }
+
+ // same device found -> avoid duplicates and update core configuration
+ discoveredDevices[i].setCoreConfigurations(discoveredDevices[i].coreConfigurations() | info.coreConfigurations());
+
+ emit q->deviceDiscovered(info);
+ return;
+ }
+ }
+
discoveredDevices.append(info);
- qCDebug(QT_BT_ANDROID) << "Device found: " << info.name() << info.address().toString();
+ qCDebug(QT_BT_ANDROID) << "Device found: " << info.name() << info.address().toString()
+ << "isLeScanResult:" << isLeResult;
emit q->deviceDiscovered(info);
}
+void QBluetoothDeviceDiscoveryAgentPrivate::startLowEnergyScan()
+{
+ Q_Q(QBluetoothDeviceDiscoveryAgent);
+
+ m_active = BtleScanActive;
+
+ QAndroidJniEnvironment env;
+ if (!leScanner.isValid()) {
+ leScanner = QAndroidJniObject("org/qtproject/qt5/android/bluetooth/QtBluetoothLE");
+ if (env->ExceptionCheck() || !leScanner.isValid()) {
+ qCWarning(QT_BT_ANDROID) << "Cannot load BTLE device scan class";
+ env->ExceptionDescribe();
+ env->ExceptionClear();
+ m_active = NoScanActive;
+ emit q->finished();
+ }
+
+ leScanner.setField<jlong>("qtObject", reinterpret_cast<long>(receiver));
+ }
+
+ jboolean result = leScanner.callMethod<jboolean>("scanForLeDevice", "(Z)Z", true);
+ if (!result) {
+ qCWarning(QT_BT_ANDROID) << "Cannot start BTLE device scanner";
+ m_active = NoScanActive;
+ emit q->finished();
+ }
+
+ if (!leScanTimeout) {
+ leScanTimeout = new QTimer(this);
+ leScanTimeout->setSingleShot(true);
+ leScanTimeout->setInterval(10000);
+ connect(leScanTimeout, &QTimer::timeout,
+ this, &QBluetoothDeviceDiscoveryAgentPrivate::stopLowEnergyScan);
+ }
+
+ leScanTimeout->start();
+}
+
+void QBluetoothDeviceDiscoveryAgentPrivate::stopLowEnergyScan()
+{
+ jboolean result = leScanner.callMethod<jboolean>("scanForLeDevice", "(Z)Z", false);
+ if (!result)
+ qCWarning(QT_BT_ANDROID) << "Cannot stop BTLE device scanner";
+
+ m_active = NoScanActive;
+
+ Q_Q(QBluetoothDeviceDiscoveryAgent);
+ if (leScanTimeout->isActive()) {
+ // still active if this function was called from stop()
+ leScanTimeout->stop();
+ emit q->canceled();
+ } else {
+ // timeout -> regular stop
+ emit q->finished();
+ }
+}
QT_END_NAMESPACE
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp
index 2f90fd30..4d296d20 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_ios.mm b/src/bluetooth/qbluetoothdevicediscoveryagent_ios.mm
new file mode 100644
index 00000000..1556c5f9
--- /dev/null
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_ios.mm
@@ -0,0 +1,374 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbluetoothdevicediscoveryagent.h"
+#include "osx/osxbtledeviceinquiry_p.h"
+#include "qbluetoothlocaldevice.h"
+#include "qbluetoothdeviceinfo.h"
+#include "osx/osxbtutility_p.h"
+#include "osx/uistrings_p.h"
+#include "qbluetoothuuid.h"
+
+#include <QtCore/qloggingcategory.h>
+#include <QtCore/qglobal.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qlist.h>
+
+#include <CoreBluetooth/CoreBluetooth.h>
+
+QT_BEGIN_NAMESPACE
+
+using OSXBluetooth::ObjCScopedPointer;
+
+class QBluetoothDeviceDiscoveryAgentPrivate : public OSXBluetooth::LEDeviceInquiryDelegate
+{
+ friend class QBluetoothDeviceDiscoveryAgent;
+public:
+ QBluetoothDeviceDiscoveryAgentPrivate(const QBluetoothAddress &address,
+ QBluetoothDeviceDiscoveryAgent *q);
+ virtual ~QBluetoothDeviceDiscoveryAgentPrivate();
+
+ bool isValid() const;
+ bool isActive() const;
+
+ void start();
+ void stop();
+
+private:
+ // LEDeviceInquiryDelegate:
+ void LEdeviceInquiryError(QBluetoothDeviceDiscoveryAgent::Error error) Q_DECL_OVERRIDE;
+ void LEnotSupported() Q_DECL_OVERRIDE;
+ void LEdeviceFound(CBPeripheral *peripheral, const QBluetoothUuid &deviceUuid,
+ NSDictionary *advertisementData, NSNumber *RSSI) Q_DECL_OVERRIDE;
+ void LEdeviceInquiryFinished() Q_DECL_OVERRIDE;
+
+ void setError(QBluetoothDeviceDiscoveryAgent::Error, const QString &text = QString());
+
+ QBluetoothDeviceDiscoveryAgent *q_ptr;
+
+ QBluetoothDeviceDiscoveryAgent::Error lastError;
+ QString errorString;
+
+ QBluetoothDeviceDiscoveryAgent::InquiryType inquiryType;
+
+ typedef ObjCScopedPointer<LEDeviceInquiryObjC> LEDeviceInquiry;
+ LEDeviceInquiry inquiryLE;
+
+ typedef QList<QBluetoothDeviceInfo> DevicesList;
+ DevicesList discoveredDevices;
+
+ bool startPending;
+ bool stopPending;
+};
+
+QBluetoothDeviceDiscoveryAgentPrivate::QBluetoothDeviceDiscoveryAgentPrivate(const QBluetoothAddress &adapter,
+ QBluetoothDeviceDiscoveryAgent *q) :
+ q_ptr(q),
+ lastError(QBluetoothDeviceDiscoveryAgent::NoError),
+ inquiryType(QBluetoothDeviceDiscoveryAgent::GeneralUnlimitedInquiry),
+ startPending(false),
+ stopPending(false)
+{
+ Q_UNUSED(adapter);
+
+ Q_ASSERT_X(q != Q_NULLPTR, Q_FUNC_INFO, "invalid q_ptr (null)");
+
+ // OSXBTLEDeviceInquiry can be constructed even if LE is not supported -
+ // at this stage it's only a memory allocation of the object itself,
+ // if it fails - we have some memory-related problems.
+ LEDeviceInquiry newInquiryLE([[LEDeviceInquiryObjC alloc] initWithDelegate:this]);
+ if (!newInquiryLE) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to initialize a device inquiry object";
+ return;
+ }
+
+ inquiryLE.reset(newInquiryLE.take());
+}
+
+QBluetoothDeviceDiscoveryAgentPrivate::~QBluetoothDeviceDiscoveryAgentPrivate()
+{
+}
+
+bool QBluetoothDeviceDiscoveryAgentPrivate::isValid() const
+{
+ // isValid() - Qt does not use exceptions, but the ctor
+ // can fail to initialize some important data-members
+ // - this is what meant here by valid/invalid.
+ return inquiryLE;
+}
+
+bool QBluetoothDeviceDiscoveryAgentPrivate::isActive() const
+{
+ if (startPending)
+ return true;
+ if (stopPending)
+ return false;
+
+ return [inquiryLE isActive];
+}
+
+void QBluetoothDeviceDiscoveryAgentPrivate::start()
+{
+ Q_ASSERT_X(isValid(), Q_FUNC_INFO, "called on invalid device discovery agent");
+ Q_ASSERT_X(!isActive(), Q_FUNC_INFO, "called on active device discovery agent");
+ Q_ASSERT_X(lastError != QBluetoothDeviceDiscoveryAgent::InvalidBluetoothAdapterError,
+ Q_FUNC_INFO, "called with an invalid Bluetooth adapter");
+
+ if (stopPending) {
+ startPending = true;
+ return;
+ }
+
+ discoveredDevices.clear();
+ setError(QBluetoothDeviceDiscoveryAgent::NoError);
+
+ if (![inquiryLE start]) {
+ // We can be here only if we have some kind of
+ // resource allocation error.
+ setError(QBluetoothDeviceDiscoveryAgent::UnknownError,
+ QCoreApplication::translate(DEV_DISCOVERY, DD_NOT_STARTED));
+ emit q_ptr->error(lastError);
+ }
+}
+
+void QBluetoothDeviceDiscoveryAgentPrivate::stop()
+{
+ Q_ASSERT_X(isValid(), Q_FUNC_INFO, "called on invalid device discovery agent");
+ Q_ASSERT_X(isActive(), Q_FUNC_INFO, "called whithout active inquiry");
+ Q_ASSERT_X(lastError != QBluetoothDeviceDiscoveryAgent::InvalidBluetoothAdapterError,
+ Q_FUNC_INFO, "called with invalid bluetooth adapter");
+
+ startPending = false;
+ stopPending = true;
+
+ setError(QBluetoothDeviceDiscoveryAgent::NoError);
+ // Can be asynchronous (depending on a status update of CBCentralManager).
+ // The call itself is always 'success'.
+ [inquiryLE stop];
+}
+
+void QBluetoothDeviceDiscoveryAgentPrivate::LEdeviceInquiryError(QBluetoothDeviceDiscoveryAgent::Error error)
+{
+ // At the moment the only error reported by osxbtledeviceinquiry
+ // can be 'powered off' error, it happens
+ // after the LE scan started (so we have LE support and this is
+ // a real PoweredOffError).
+ Q_ASSERT_X(error == QBluetoothDeviceDiscoveryAgent::PoweredOffError,
+ Q_FUNC_INFO, "unexpected error");
+
+ startPending = false;
+ stopPending = false;
+ setError(error);
+ emit q_ptr->error(lastError);
+}
+
+void QBluetoothDeviceDiscoveryAgentPrivate::LEnotSupported()
+{
+ startPending = false;
+ stopPending = false;
+ setError(QBluetoothDeviceDiscoveryAgent::UnsupportedPlatformError);
+ emit q_ptr->error(lastError);
+}
+
+void QBluetoothDeviceDiscoveryAgentPrivate::LEdeviceFound(CBPeripheral *peripheral, const QBluetoothUuid &deviceUuid,
+ NSDictionary *advertisementData,
+ NSNumber *RSSI)
+{
+ Q_ASSERT_X(peripheral, Q_FUNC_INFO, "invalid peripheral (nil)");
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ QString name;
+ if (peripheral.name && peripheral.name.length) {
+ name = QString::fromNSString(peripheral.name);
+ } else {
+ NSString *const localName = [advertisementData objectForKey:CBAdvertisementDataLocalNameKey];
+ if (localName && [localName length])
+ name = QString::fromNSString(localName);
+ }
+
+ // TODO: fix 'classOfDevice' (0 for now).
+ QBluetoothDeviceInfo newDeviceInfo(deviceUuid, name, 0);
+ if (RSSI)
+ newDeviceInfo.setRssi([RSSI shortValue]);
+ // CoreBluetooth scans only for LE devices.
+ newDeviceInfo.setCoreConfigurations(QBluetoothDeviceInfo::LowEnergyCoreConfiguration);
+
+ // Update, append or discard.
+ for (int i = 0, e = discoveredDevices.size(); i < e; ++i) {
+ if (discoveredDevices[i].deviceUuid() == newDeviceInfo.deviceUuid()) {
+ if (discoveredDevices[i] == newDeviceInfo)
+ return;
+
+ discoveredDevices.replace(i, newDeviceInfo);
+ emit q_ptr->deviceDiscovered(newDeviceInfo);
+ return;
+ }
+ }
+
+ discoveredDevices.append(newDeviceInfo);
+ emit q_ptr->deviceDiscovered(newDeviceInfo);
+}
+
+void QBluetoothDeviceDiscoveryAgentPrivate::LEdeviceInquiryFinished()
+{
+ Q_ASSERT_X(isValid(), Q_FUNC_INFO, "invalid device discovery agent");
+
+ if (stopPending && !startPending) {
+ stopPending = false;
+ emit q_ptr->canceled();
+ } else if (startPending) {
+ startPending = false;
+ stopPending = false;
+ start();
+ } else {
+ emit q_ptr->finished();
+ }
+}
+
+void QBluetoothDeviceDiscoveryAgentPrivate::setError(QBluetoothDeviceDiscoveryAgent::Error error,
+ const QString &text)
+{
+ lastError = error;
+
+ if (text.length() > 0) {
+ errorString = text;
+ } else {
+ switch (lastError) {
+ case QBluetoothDeviceDiscoveryAgent::NoError:
+ errorString = QString();
+ break;
+ case QBluetoothDeviceDiscoveryAgent::PoweredOffError:
+ errorString = QCoreApplication::translate(DEV_DISCOVERY, DD_POWERED_OFF);
+ break;
+ case QBluetoothDeviceDiscoveryAgent::InvalidBluetoothAdapterError:
+ errorString = QCoreApplication::translate(DEV_DISCOVERY, DD_INVALID_ADAPTER);
+ break;
+ case QBluetoothDeviceDiscoveryAgent::InputOutputError:
+ errorString = QCoreApplication::translate(DEV_DISCOVERY, DD_IO);
+ break;
+ case QBluetoothDeviceDiscoveryAgent::UnsupportedPlatformError:
+ errorString = QCoreApplication::translate(DEV_DISCOVERY, DD_NOTSUPPORTED);
+ break;
+ case QBluetoothDeviceDiscoveryAgent::UnknownError:
+ default:
+ errorString = QCoreApplication::translate(DEV_DISCOVERY, DD_UNKNOWN_ERROR);
+ }
+ }
+}
+
+QBluetoothDeviceDiscoveryAgent::QBluetoothDeviceDiscoveryAgent(QObject *parent) :
+ QObject(parent),
+ d_ptr(new QBluetoothDeviceDiscoveryAgentPrivate(QBluetoothAddress(), this))
+{
+}
+
+QBluetoothDeviceDiscoveryAgent::QBluetoothDeviceDiscoveryAgent(
+ const QBluetoothAddress &deviceAdapter, QObject *parent) :
+ QObject(parent),
+ d_ptr(new QBluetoothDeviceDiscoveryAgentPrivate(deviceAdapter, this))
+{
+ if (!deviceAdapter.isNull()) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "local device address is "
+ "not available, provided address is ignored";
+ d_ptr->setError(InvalidBluetoothAdapterError);
+ }
+}
+
+QBluetoothDeviceDiscoveryAgent::~QBluetoothDeviceDiscoveryAgent()
+{
+ delete d_ptr;
+}
+
+QBluetoothDeviceDiscoveryAgent::InquiryType QBluetoothDeviceDiscoveryAgent::inquiryType() const
+{
+ return d_ptr->inquiryType;
+}
+
+void QBluetoothDeviceDiscoveryAgent::setInquiryType(QBluetoothDeviceDiscoveryAgent::InquiryType type)
+{
+ d_ptr->inquiryType = type;
+}
+
+QList<QBluetoothDeviceInfo> QBluetoothDeviceDiscoveryAgent::discoveredDevices() const
+{
+ return d_ptr->discoveredDevices;
+}
+
+void QBluetoothDeviceDiscoveryAgent::start()
+{
+ if (d_ptr->lastError != InvalidBluetoothAdapterError) {
+ if (d_ptr->isValid()) {
+ if (!isActive())
+ d_ptr->start();
+ else
+ qCDebug(QT_BT_OSX) << Q_FUNC_INFO << "already started";
+ } else {
+ // We previously failed to initialize
+ // private object correctly.
+ d_ptr->setError(InvalidBluetoothAdapterError);
+ emit error(InvalidBluetoothAdapterError);
+ }
+ }
+}
+
+void QBluetoothDeviceDiscoveryAgent::stop()
+{
+ if (d_ptr->isValid()) {
+ if (isActive() && d_ptr->lastError != InvalidBluetoothAdapterError)
+ d_ptr->stop();
+ else
+ qCDebug(QT_BT_OSX) << Q_FUNC_INFO << "failed to stop";
+ }
+}
+
+bool QBluetoothDeviceDiscoveryAgent::isActive() const
+{
+ if (d_ptr->isValid())
+ return d_ptr->isActive();
+
+ return false;
+}
+
+QBluetoothDeviceDiscoveryAgent::Error QBluetoothDeviceDiscoveryAgent::error() const
+{
+ return d_ptr->lastError;
+}
+
+QString QBluetoothDeviceDiscoveryAgent::errorString() const
+{
+ return d_ptr->errorString;
+}
+
+QT_END_NAMESPACE
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_osx.mm b/src/bluetooth/qbluetoothdevicediscoveryagent_osx.mm
new file mode 100644
index 00000000..ebf9352d
--- /dev/null
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_osx.mm
@@ -0,0 +1,623 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbluetoothdevicediscoverytimer_osx_p.h"
+#include "qbluetoothdevicediscoveryagent.h"
+#include "osx/osxbtledeviceinquiry_p.h"
+#include "osx/osxbtdeviceinquiry_p.h"
+#include "qbluetoothlocaldevice.h"
+#include "osx/osxbtsdpinquiry_p.h"
+#include "qbluetoothdeviceinfo.h"
+#include "osx/osxbtutility_p.h"
+#include "osx/uistrings_p.h"
+#include "qbluetoothhostinfo.h"
+#include "qbluetoothuuid.h"
+
+#include <QtCore/qloggingcategory.h>
+#include <QtCore/qdatetime.h>
+#include <QtCore/qglobal.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qlist.h>
+
+#include <Foundation/Foundation.h>
+// Only after Foundation.h:
+#include "osx/corebluetoothwrapper_p.h"
+
+QT_BEGIN_NAMESPACE
+
+using OSXBluetooth::ObjCScopedPointer;
+
+class QBluetoothDeviceDiscoveryAgentPrivate : public OSXBluetooth::DeviceInquiryDelegate,
+ public OSXBluetooth::LEDeviceInquiryDelegate
+{
+ friend class QBluetoothDeviceDiscoveryAgent;
+ friend class OSXBluetooth::DDATimerHandler;
+public:
+ QBluetoothDeviceDiscoveryAgentPrivate(const QBluetoothAddress & address,
+ QBluetoothDeviceDiscoveryAgent *q);
+ virtual ~QBluetoothDeviceDiscoveryAgentPrivate(); // Just to make compiler happy.
+
+ bool isValid() const;
+ bool isActive() const;
+
+ void start();
+ void startLE();
+ void stop();
+
+private:
+ enum AgentState {
+ NonActive,
+ ClassicScan,
+ LEScan
+ };
+
+ // DeviceInquiryDelegate:
+ void inquiryFinished(IOBluetoothDeviceInquiry *inq) Q_DECL_OVERRIDE;
+ void error(IOBluetoothDeviceInquiry *inq, IOReturn error) Q_DECL_OVERRIDE;
+ void deviceFound(IOBluetoothDeviceInquiry *inq, IOBluetoothDevice *device) Q_DECL_OVERRIDE;
+ // LEDeviceInquiryDelegate:
+ void LEdeviceInquiryError(QBluetoothDeviceDiscoveryAgent::Error error) Q_DECL_OVERRIDE;
+ void LEnotSupported() Q_DECL_OVERRIDE;
+ void LEdeviceFound(CBPeripheral *peripheral, const QBluetoothUuid &deviceUuid,
+ NSDictionary *advertisementData, NSNumber *RSSI) Q_DECL_OVERRIDE;
+ void LEdeviceInquiryFinished() Q_DECL_OVERRIDE;
+
+ // Check if it's a really new device/updated info and emit
+ // q_ptr->deviceDiscovered.
+ void deviceFound(const QBluetoothDeviceInfo &newDeviceInfo);
+
+ void setError(IOReturn error, const QString &text = QString());
+ void setError(QBluetoothDeviceDiscoveryAgent::Error, const QString &text = QString());
+
+ void checkLETimeout();
+
+ QBluetoothDeviceDiscoveryAgent *q_ptr;
+ AgentState agentState;
+
+ QBluetoothAddress adapterAddress;
+
+ bool startPending;
+ bool stopPending;
+
+ QBluetoothDeviceDiscoveryAgent::Error lastError;
+ QString errorString;
+
+ QBluetoothDeviceDiscoveryAgent::InquiryType inquiryType;
+
+ typedef ObjCScopedPointer<DeviceInquiryObjC> DeviceInquiry;
+ DeviceInquiry inquiry;
+
+ typedef ObjCScopedPointer<LEDeviceInquiryObjC> LEDeviceInquiry;
+ LEDeviceInquiry inquiryLE;
+
+ typedef ObjCScopedPointer<IOBluetoothHostController> HostController;
+ HostController hostController;
+
+ typedef QList<QBluetoothDeviceInfo> DevicesList;
+ DevicesList discoveredDevices;
+
+ OSXBluetooth::DDATimerHandler timer;
+};
+
+namespace OSXBluetooth {
+
+DDATimerHandler::DDATimerHandler(QBluetoothDeviceDiscoveryAgentPrivate *d)
+ : owner(d)
+{
+ Q_ASSERT_X(owner, Q_FUNC_INFO, "invalid pointer");
+
+ timer.setSingleShot(true);
+ connect(&timer, &QTimer::timeout, this, &DDATimerHandler::onTimer);
+}
+
+void DDATimerHandler::start(int msec)
+{
+ Q_ASSERT_X(msec > 0, Q_FUNC_INFO, "invalid time interval");
+ if (timer.isActive()) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "timer is active";
+ return;
+ }
+
+ timer.start(msec);
+}
+
+void DDATimerHandler::stop()
+{
+ timer.stop();
+}
+
+void DDATimerHandler::onTimer()
+{
+ Q_ASSERT(owner);
+ owner->checkLETimeout();
+}
+
+}
+
+QBluetoothDeviceDiscoveryAgentPrivate::QBluetoothDeviceDiscoveryAgentPrivate(const QBluetoothAddress &adapter,
+ QBluetoothDeviceDiscoveryAgent *q) :
+ q_ptr(q),
+ agentState(NonActive),
+ adapterAddress(adapter),
+ startPending(false),
+ stopPending(false),
+ lastError(QBluetoothDeviceDiscoveryAgent::NoError),
+ inquiryType(QBluetoothDeviceDiscoveryAgent::GeneralUnlimitedInquiry),
+ timer(this)
+{
+ Q_ASSERT_X(q != Q_NULLPTR, Q_FUNC_INFO, "invalid q_ptr (null)");
+
+ HostController controller([[IOBluetoothHostController defaultController] retain]);
+ if (!controller || [controller powerState] != kBluetoothHCIPowerStateON) {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "no default host "
+ "controller or adapter is off";
+ return;
+ }
+
+ DeviceInquiry newInquiry([[DeviceInquiryObjC alloc]initWithDelegate:this]);
+ if (!newInquiry) { // Obj-C's way of "reporting errors":
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to "
+ "initialize an inquiry";
+ return;
+ }
+
+ // OSXBTLEDeviceInquiry can be constructed even if LE is not supported -
+ // at this stage it's only a memory allocation of the object itself,
+ // if it fails - we have some memory-related problem.
+ LEDeviceInquiry newInquiryLE([[LEDeviceInquiryObjC alloc] initWithDelegate:this]);
+ if (!newInquiryLE) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to "
+ "initialize a LE inquiry";
+ return;
+ }
+
+ hostController.reset(controller.take());
+ inquiry.reset(newInquiry.take());
+ inquiryLE.reset(newInquiryLE.take());
+}
+
+QBluetoothDeviceDiscoveryAgentPrivate::~QBluetoothDeviceDiscoveryAgentPrivate()
+{
+}
+
+bool QBluetoothDeviceDiscoveryAgentPrivate::isValid() const
+{
+ // isValid() - Qt does not use exceptions, but the ctor
+ // can fail to initialize some important data-members
+ // (and the error is probably not even related to Bluetooth at all)
+ // - say, allocation error - this is what meant here by valid/invalid.
+ return hostController && [hostController powerState] == kBluetoothHCIPowerStateON
+ && inquiry && inquiryLE;
+}
+
+bool QBluetoothDeviceDiscoveryAgentPrivate::isActive() const
+{
+ if (startPending)
+ return true;
+
+ if (stopPending)
+ return false;
+
+ return agentState != NonActive;
+}
+
+void QBluetoothDeviceDiscoveryAgentPrivate::start()
+{
+ Q_ASSERT_X(isValid(), Q_FUNC_INFO, "called on invalid device discovery agent");
+ Q_ASSERT_X(!isActive(), Q_FUNC_INFO, "called on active device discovery agent");
+ Q_ASSERT_X(lastError != QBluetoothDeviceDiscoveryAgent::InvalidBluetoothAdapterError,
+ Q_FUNC_INFO, "called with an invalid Bluetooth adapter");
+
+ if (stopPending) {
+ startPending = true;
+ return;
+ }
+
+ agentState = ClassicScan;
+
+ discoveredDevices.clear();
+ setError(QBluetoothDeviceDiscoveryAgent::NoError);
+
+ const IOReturn res = [inquiry start];
+ if (res != kIOReturnSuccess) {
+ setError(res, QCoreApplication::translate(DEV_DISCOVERY, DD_NOT_STARTED));
+ agentState = NonActive;
+ emit q_ptr->error(lastError);
+ }
+}
+
+void QBluetoothDeviceDiscoveryAgentPrivate::startLE()
+{
+ Q_ASSERT_X(isValid(), Q_FUNC_INFO, "called on invalid device discovery agent");
+ Q_ASSERT_X(lastError != QBluetoothDeviceDiscoveryAgent::InvalidBluetoothAdapterError,
+ Q_FUNC_INFO, "called with an invalid Bluetooth adapter");
+
+ agentState = LEScan;
+
+ // CoreBluetooth does not have a timeout. We start a timer here
+ // and check if scan really started and if yes if we have a timeout.
+ timer.start([LEDeviceInquiryObjC inquiryLength]);
+
+ if (![inquiryLE start]) {
+ // We can be here only if we have some kind of resource allocation error, so we
+ // do not emit finished, we emit error.
+ timer.stop();
+ setError(QBluetoothDeviceDiscoveryAgent::UnknownError,
+ QCoreApplication::translate(DEV_DISCOVERY, DD_NOT_STARTED_LE));
+ agentState = NonActive;
+ emit q_ptr->error(lastError);
+ }
+}
+
+void QBluetoothDeviceDiscoveryAgentPrivate::stop()
+{
+ Q_ASSERT_X(isValid(), Q_FUNC_INFO, "called on invalid device discovery agent");
+ Q_ASSERT_X(isActive(), Q_FUNC_INFO, "called whithout active inquiry");
+ Q_ASSERT_X(lastError != QBluetoothDeviceDiscoveryAgent::InvalidBluetoothAdapterError,
+ Q_FUNC_INFO, "called with invalid bluetooth adapter");
+
+ const bool prevStart = startPending;
+ startPending = false;
+ stopPending = true;
+
+ setError(QBluetoothDeviceDiscoveryAgent::NoError);
+
+ if (agentState == ClassicScan) {
+ const IOReturn res = [inquiry stop];
+ if (res != kIOReturnSuccess) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to stop";
+ startPending = prevStart;
+ stopPending = false;
+ setError(res, QCoreApplication::translate(DEV_DISCOVERY, DD_NOT_STOPPED));
+ emit q_ptr->error(lastError);
+ }
+ } else {
+ // Can be asynchronous (depending on a status update of CBCentralManager).
+ // The call itself is always 'success'.
+ [inquiryLE stop];
+ }
+}
+
+void QBluetoothDeviceDiscoveryAgentPrivate::inquiryFinished(IOBluetoothDeviceInquiry *inq)
+{
+ Q_UNUSED(inq)
+
+ Q_ASSERT_X(isValid(), Q_FUNC_INFO, "invalid device discovery agent"); //We can never be here.
+
+ // The subsequent start(LE) function (if any)
+ // will (re)set the correct state.
+ agentState = NonActive;
+
+ if (stopPending && !startPending) {
+ stopPending = false;
+ emit q_ptr->canceled();
+ } else if (startPending) {
+ startPending = false;
+ stopPending = false;
+ start();
+ } else {
+ // We can be here _only_ if a classic scan
+ // finished in a normal way (not cancelled).
+ // startLE() will take care of old devices
+ // not supporting Bluetooth 4.0.
+ startLE();
+ }
+}
+
+void QBluetoothDeviceDiscoveryAgentPrivate::error(IOBluetoothDeviceInquiry *inq, IOReturn error)
+{
+ Q_UNUSED(inq)
+
+ Q_ASSERT_X(isValid(), Q_FUNC_INFO, "invalid device discovery agent");
+
+ startPending = false;
+ stopPending = false;
+
+ setError(error);
+
+ emit q_ptr->error(lastError);
+}
+
+void QBluetoothDeviceDiscoveryAgentPrivate::deviceFound(IOBluetoothDeviceInquiry *inq, IOBluetoothDevice *device)
+{
+ Q_UNUSED(inq)
+
+ Q_ASSERT_X(isValid(), Q_FUNC_INFO, "invalid device discovery agent");
+ Q_ASSERT_X(device, Q_FUNC_INFO, "invalid IOBluetoothDevice (nil)");
+ Q_ASSERT_X(agentState == ClassicScan, Q_FUNC_INFO,
+ "invalid agent state (expected classic scan)");
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ // Let's collect some info about this device:
+ const QBluetoothAddress deviceAddress(OSXBluetooth::qt_address([device getAddress]));
+ if (deviceAddress.isNull()) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid Bluetooth address";
+ return;
+ }
+
+ QString deviceName;
+ if (device.name)
+ deviceName = QString::fromNSString(device.name);
+
+ const qint32 classOfDevice(device.classOfDevice);
+
+ QBluetoothDeviceInfo deviceInfo(deviceAddress, deviceName, classOfDevice);
+ deviceInfo.setCoreConfigurations(QBluetoothDeviceInfo::BaseRateCoreConfiguration);
+ deviceInfo.setRssi(device.RSSI);
+
+ const QList<QBluetoothUuid> uuids(OSXBluetooth::extract_services_uuids(device));
+ deviceInfo.setServiceUuids(uuids, QBluetoothDeviceInfo::DataIncomplete);
+
+ deviceFound(deviceInfo);
+}
+
+void QBluetoothDeviceDiscoveryAgentPrivate::setError(IOReturn error, const QString &text)
+{
+ if (error == kIOReturnSuccess)
+ setError(QBluetoothDeviceDiscoveryAgent::NoError, text);
+ else if (error == kIOReturnNoPower)
+ setError(QBluetoothDeviceDiscoveryAgent::PoweredOffError, text);
+ else
+ setError(QBluetoothDeviceDiscoveryAgent::UnknownError, text);
+}
+
+void QBluetoothDeviceDiscoveryAgentPrivate::setError(QBluetoothDeviceDiscoveryAgent::Error error,
+ const QString &text)
+{
+ lastError = error;
+
+ if (text.length() > 0) {
+ errorString = text;
+ } else {
+ switch (lastError) {
+ case QBluetoothDeviceDiscoveryAgent::NoError:
+ errorString = QString();
+ break;
+ case QBluetoothDeviceDiscoveryAgent::PoweredOffError:
+ errorString = QCoreApplication::translate(DEV_DISCOVERY, DD_POWERED_OFF);
+ break;
+ case QBluetoothDeviceDiscoveryAgent::InvalidBluetoothAdapterError:
+ errorString = QCoreApplication::translate(DEV_DISCOVERY, DD_INVALID_ADAPTER);
+ break;
+ case QBluetoothDeviceDiscoveryAgent::InputOutputError:
+ errorString = QCoreApplication::translate(DEV_DISCOVERY, DD_IO);
+ break;
+ case QBluetoothDeviceDiscoveryAgent::UnknownError:
+ default:
+ errorString = QCoreApplication::translate(DEV_DISCOVERY, DD_UNKNOWN_ERROR);
+ }
+ }
+
+ if (lastError != QBluetoothDeviceDiscoveryAgent::NoError)
+ qCDebug(QT_BT_OSX) << "error set: "<<errorString;
+}
+
+void QBluetoothDeviceDiscoveryAgentPrivate::checkLETimeout()
+{
+ Q_ASSERT_X(agentState == LEScan, Q_FUNC_INFO, "invalid agent state");
+ Q_ASSERT_X(inquiryLE, Q_FUNC_INFO, "LE device inquiry is nil");
+
+ const int timeout = [LEDeviceInquiryObjC inquiryLength];
+ Q_ASSERT(timeout > 0);
+ const QTime scanStartTime([inquiryLE startTime]);
+ if (scanStartTime.isValid()) {
+ const int elapsed = scanStartTime.msecsTo(QTime::currentTime());
+ Q_ASSERT(elapsed >= 0);
+ if (elapsed >= timeout)
+ [inquiryLE stop];
+ else
+ timer.start(timeout - elapsed);
+ } else {
+ // Scan not started yet. Wait 5 seconds more.
+ timer.start(timeout / 2);
+ }
+}
+
+void QBluetoothDeviceDiscoveryAgentPrivate::LEdeviceInquiryError(QBluetoothDeviceDiscoveryAgent::Error error)
+{
+ // At the moment the only error reported can be 'powered off' error, it happens
+ // after the LE scan started (so we have LE support and this is a real PoweredOffError).
+ Q_ASSERT_X(error == QBluetoothDeviceDiscoveryAgent::PoweredOffError,
+ Q_FUNC_INFO, "unexpected error code");
+
+ timer.stop();
+
+ agentState = NonActive;
+ setError(error);
+ emit q_ptr->error(lastError);
+}
+
+void QBluetoothDeviceDiscoveryAgentPrivate::LEnotSupported()
+{
+ // Not supported is not an error.
+ qCDebug(QT_BT_OSX) << "no Bluetooth LE support";
+ // After we call startLE and before receive NotSupported,
+ // the user can call stop (setting a pending stop).
+ // So the same rule apply:
+ timer.stop();
+
+ LEdeviceInquiryFinished();
+}
+
+void QBluetoothDeviceDiscoveryAgentPrivate::LEdeviceFound(CBPeripheral *peripheral, const QBluetoothUuid &deviceUuid,
+ NSDictionary *advertisementData,
+ NSNumber *RSSI)
+{
+ Q_ASSERT_X(peripheral, Q_FUNC_INFO, "invalid peripheral (nil)");
+ Q_ASSERT_X(agentState == LEScan, Q_FUNC_INFO,
+ "invalid agent state, expected LE scan");
+
+ Q_UNUSED(advertisementData)
+
+ QString name;
+ if (peripheral.name)
+ name = QString::fromNSString(peripheral.name);
+
+ // TODO: fix 'classOfDevice' (0 for now).
+ QBluetoothDeviceInfo newDeviceInfo(deviceUuid, name, 0);
+ if (RSSI)
+ newDeviceInfo.setRssi([RSSI shortValue]);
+ // CoreBluetooth scans only for LE devices.
+ newDeviceInfo.setCoreConfigurations(QBluetoothDeviceInfo::LowEnergyCoreConfiguration);
+
+ deviceFound(newDeviceInfo);
+}
+
+void QBluetoothDeviceDiscoveryAgentPrivate::LEdeviceInquiryFinished()
+{
+ // The same logic as in inquiryFinished, but does not start LE scan.
+ agentState = NonActive;
+
+ timer.stop();
+
+ if (stopPending && !startPending) {
+ stopPending = false;
+ emit q_ptr->canceled();
+ } else if (startPending) {
+ startPending = false;
+ stopPending = false;
+ start(); //Start from a classic scan again.
+ } else {
+ emit q_ptr->finished();
+ }
+}
+
+void QBluetoothDeviceDiscoveryAgentPrivate::deviceFound(const QBluetoothDeviceInfo &newDeviceInfo)
+{
+ // Core Bluetooth does not allow us to access addresses, we have to use uuid instead.
+ // This uuid has nothing to do with uuids in Bluetooth in general (it's generated by
+ // Apple's framework using some algorithm), but it's a 128-bit uuid after all.
+ const bool isLE = newDeviceInfo.coreConfigurations() == QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
+
+ for (int i = 0, e = discoveredDevices.size(); i < e; ++i) {
+ if (isLE ? discoveredDevices[i].deviceUuid() == newDeviceInfo.deviceUuid():
+ discoveredDevices[i].address() == newDeviceInfo.address()) {
+ if (discoveredDevices[i] == newDeviceInfo)
+ return;
+
+ discoveredDevices.replace(i, newDeviceInfo);
+ emit q_ptr->deviceDiscovered(newDeviceInfo);
+ return;
+ }
+ }
+
+ discoveredDevices.append(newDeviceInfo);
+ emit q_ptr->deviceDiscovered(newDeviceInfo);
+}
+
+QBluetoothDeviceDiscoveryAgent::QBluetoothDeviceDiscoveryAgent(QObject *parent) :
+ QObject(parent),
+ d_ptr(new QBluetoothDeviceDiscoveryAgentPrivate(QBluetoothAddress(), this))
+{
+}
+
+QBluetoothDeviceDiscoveryAgent::QBluetoothDeviceDiscoveryAgent(
+ const QBluetoothAddress &deviceAdapter, QObject *parent) :
+ QObject(parent),
+ d_ptr(new QBluetoothDeviceDiscoveryAgentPrivate(deviceAdapter, this))
+{
+ if (!deviceAdapter.isNull()) {
+ const QList<QBluetoothHostInfo> localDevices = QBluetoothLocalDevice::allDevices();
+ foreach (const QBluetoothHostInfo &hostInfo, localDevices) {
+ if (hostInfo.address() == deviceAdapter)
+ return;
+ }
+ d_ptr->setError(InvalidBluetoothAdapterError);
+ }
+}
+
+QBluetoothDeviceDiscoveryAgent::~QBluetoothDeviceDiscoveryAgent()
+{
+ delete d_ptr;
+}
+
+QBluetoothDeviceDiscoveryAgent::InquiryType QBluetoothDeviceDiscoveryAgent::inquiryType() const
+{
+ return d_ptr->inquiryType;
+}
+
+void QBluetoothDeviceDiscoveryAgent::setInquiryType(QBluetoothDeviceDiscoveryAgent::InquiryType type)
+{
+ d_ptr->inquiryType = type;
+}
+
+QList<QBluetoothDeviceInfo> QBluetoothDeviceDiscoveryAgent::discoveredDevices() const
+{
+ return d_ptr->discoveredDevices;
+}
+
+void QBluetoothDeviceDiscoveryAgent::start()
+{
+ if (d_ptr->lastError != InvalidBluetoothAdapterError) {
+ if (d_ptr->isValid()) {
+ if (!isActive())
+ d_ptr->start();
+ } else {
+ // We previously failed to initialize d_ptr correctly:
+ // either some memory allocation problem or
+ // no BT adapter found.
+ d_ptr->setError(InvalidBluetoothAdapterError);
+ emit error(InvalidBluetoothAdapterError);
+ }
+ }
+}
+
+void QBluetoothDeviceDiscoveryAgent::stop()
+{
+ if (d_ptr->isValid()) {
+ if (isActive() && d_ptr->lastError != InvalidBluetoothAdapterError)
+ d_ptr->stop();
+ }
+}
+
+bool QBluetoothDeviceDiscoveryAgent::isActive() const
+{
+ if (d_ptr->isValid())
+ return d_ptr->isActive();
+
+ return false;
+}
+
+QBluetoothDeviceDiscoveryAgent::Error QBluetoothDeviceDiscoveryAgent::error() const
+{
+ return d_ptr->lastError;
+}
+
+QString QBluetoothDeviceDiscoveryAgent::errorString() const
+{
+ return d_ptr->errorString;
+}
+
+QT_END_NAMESPACE
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_p.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_p.cpp
index c89c2d37..26052a52 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_p.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_p.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -43,11 +43,11 @@ QT_BEGIN_NAMESPACE
QBluetoothDeviceDiscoveryAgentPrivate::QBluetoothDeviceDiscoveryAgentPrivate(
const QBluetoothAddress &deviceAdapter,
QBluetoothDeviceDiscoveryAgent *parent)
- : q_ptr(parent)
+ : inquiryType(QBluetoothDeviceDiscoveryAgent::GeneralUnlimitedInquiry),
+ lastError(QBluetoothDeviceDiscoveryAgent::NoError),
+ q_ptr(parent)
{
Q_UNUSED(deviceAdapter);
- inquiryType = QBluetoothDeviceDiscoveryAgent::GeneralUnlimitedInquiry;
- lastError = QBluetoothDeviceDiscoveryAgent::NoError;
}
QBluetoothDeviceDiscoveryAgentPrivate::~QBluetoothDeviceDiscoveryAgentPrivate()
@@ -62,9 +62,10 @@ bool QBluetoothDeviceDiscoveryAgentPrivate::isActive() const
void QBluetoothDeviceDiscoveryAgentPrivate::start()
{
Q_Q(QBluetoothDeviceDiscoveryAgent);
- lastError = QBluetoothDeviceDiscoveryAgent::InputOutputError;
- errorString = QBluetoothDeviceDiscoveryAgent::tr("No Bluetooth device available");
- emit q->error(QBluetoothDeviceDiscoveryAgent::InputOutputError);
+ lastError = QBluetoothDeviceDiscoveryAgent::UnsupportedPlatformError;
+ errorString = QBluetoothDeviceDiscoveryAgent::tr("Device discovery not supported on this platform");
+
+ emit q->error(lastError);
}
void QBluetoothDeviceDiscoveryAgentPrivate::stop()
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_p.h b/src/bluetooth/qbluetoothdevicediscoveryagent_p.h
index f25496dc..5ef6772e 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_p.h
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -49,6 +49,7 @@
#ifdef QT_ANDROID_BLUETOOTH
#include <QtAndroidExtras/QAndroidJniObject>
#include "android/devicediscoverybroadcastreceiver_p.h"
+#include <QtCore/QTimer>
#endif
#include <QtCore/QVariantMap>
@@ -117,14 +118,20 @@ private:
#ifdef QT_ANDROID_BLUETOOTH
private slots:
- void processDiscoveryFinished();
- void processDiscoveredDevices(const QBluetoothDeviceInfo &info);
+ void processSdpDiscoveryFinished();
+ void processDiscoveredDevices(const QBluetoothDeviceInfo &info, bool isLeResult);
+ friend void QtBluetoothLE_leScanResult(JNIEnv *, jobject, jlong, jobject);
+ void stopLowEnergyScan();
private:
+ void startLowEnergyScan();
+
DeviceDiscoveryBroadcastReceiver *receiver;
QBluetoothAddress m_adapterAddress;
- bool m_active;
+ short m_active;
QAndroidJniObject adapter;
+ QAndroidJniObject leScanner;
+ QTimer *leScanTimeout;
bool pendingCancel, pendingStart;
#elif defined(QT_BLUEZ_BLUETOOTH)
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_qnx.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_qnx.cpp
index 2e4ad274..8996d71b 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_qnx.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_qnx.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2012 Research In Motion
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothdevicediscoverytimer_osx_p.h b/src/bluetooth/qbluetoothdevicediscoverytimer_osx_p.h
new file mode 100644
index 00000000..1537d82e
--- /dev/null
+++ b/src/bluetooth/qbluetoothdevicediscoverytimer_osx_p.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBLUETOOTHDEVICEDISCOVERYTIMER_OSX_P_H
+#define QBLUETOOTHDEVICEDISCOVERYTIMER_OSX_P_H
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qtimer.h>
+
+QT_BEGIN_NAMESPACE
+
+class QBluetoothDeviceDiscoveryAgentPrivate;
+
+namespace OSXBluetooth {
+
+class DDATimerHandler : public QObject
+{
+ Q_OBJECT
+
+public:
+ DDATimerHandler(QBluetoothDeviceDiscoveryAgentPrivate *d);
+
+ void start(int msec);
+ void stop();
+
+private slots:
+ void onTimer();
+
+private:
+ QTimer timer;
+ QBluetoothDeviceDiscoveryAgentPrivate *owner;
+};
+
+}
+
+QT_END_NAMESPACE
+
+#endif // QBLUETOOTHDEVICEDISCOVERYTIMER_OSX_P_H
diff --git a/src/bluetooth/qbluetoothdeviceinfo.cpp b/src/bluetooth/qbluetoothdeviceinfo.cpp
index c0562c45..37ba4e11 100644
--- a/src/bluetooth/qbluetoothdeviceinfo.cpp
+++ b/src/bluetooth/qbluetoothdeviceinfo.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -307,6 +307,37 @@ QBluetoothDeviceInfo::QBluetoothDeviceInfo(const QBluetoothAddress &address, con
}
/*!
+ Constructs a QBluetoothDeviceInfo object with unique \a uuid, device name
+ \a name and the encoded class of device \a classOfDevice.
+
+ This constructor is required for Low Energy devices on OS X and iOS. CoreBluetooth
+ API hides addresses and provides unique UUIDs to identify a device. This UUID is
+ not the same thing as a service UUID and is required to work later with CoreBluetooth API
+ and discovered devices.
+
+ \since 5.5
+*/
+QBluetoothDeviceInfo::QBluetoothDeviceInfo(const QBluetoothUuid &uuid, const QString &name,
+ quint32 classOfDevice) :
+ d_ptr(new QBluetoothDeviceInfoPrivate)
+{
+ Q_D(QBluetoothDeviceInfo);
+
+ d->name = name;
+ d->deviceUuid = uuid;
+
+ d->minorDeviceClass = static_cast<quint8>((classOfDevice >> 2) & 0x3f);
+ d->majorDeviceClass = static_cast<MajorDeviceClass>((classOfDevice >> 8) & 0x1f);
+ d->serviceClasses = static_cast<ServiceClasses>((classOfDevice >> 13) & 0x7ff);
+
+ d->serviceUuidsCompleteness = DataUnavailable;
+
+ d->valid = true;
+ d->cached = false;
+ d->rssi = 0;
+}
+
+/*!
Constructs a QBluetoothDeviceInfo that is a copy of \a other.
*/
QBluetoothDeviceInfo::QBluetoothDeviceInfo(const QBluetoothDeviceInfo &other) :
@@ -370,6 +401,7 @@ QBluetoothDeviceInfo &QBluetoothDeviceInfo::operator=(const QBluetoothDeviceInfo
d->serviceUuids = other.d_func()->serviceUuids;
d->rssi = other.d_func()->rssi;
d->deviceCoreConfiguration = other.d_func()->deviceCoreConfiguration;
+ d->deviceUuid = other.d_func()->deviceUuid;
return *this;
}
@@ -403,6 +435,8 @@ bool QBluetoothDeviceInfo::operator==(const QBluetoothDeviceInfo &other) const
return false;
if (d->deviceCoreConfiguration != other.d_func()->deviceCoreConfiguration)
return false;
+ if (d->deviceUuid != other.d_func()->deviceUuid)
+ return false;
return true;
}
@@ -560,4 +594,34 @@ void QBluetoothDeviceInfo::setCached(bool cached)
d->cached = cached;
}
+/*!
+ Sets the unique identifier \a uuid for Bluetooth devices, that do not have addresses.
+ This happens on OS X and iOS, where the CoreBluetooth API hides addresses, but provides
+ UUIDs to identify devices/peripherals.
+
+ This uuid is invalid on any other platform.
+
+ \sa deviceUuid()
+ \since 5.5
+ */
+void QBluetoothDeviceInfo::setDeviceUuid(const QBluetoothUuid &uuid)
+{
+ Q_D(QBluetoothDeviceInfo);
+
+ d->deviceUuid = uuid;
+}
+
+/*!
+ Returns a unique identifier for a Bluetooth device without an address.
+
+ \sa setDeviceUuid()
+ \since 5.5
+ */
+QBluetoothUuid QBluetoothDeviceInfo::deviceUuid() const
+{
+ Q_D(const QBluetoothDeviceInfo);
+
+ return d->deviceUuid;
+}
+
QT_END_NAMESPACE
diff --git a/src/bluetooth/qbluetoothdeviceinfo.h b/src/bluetooth/qbluetoothdeviceinfo.h
index 6e268dcf..b64a9727 100644
--- a/src/bluetooth/qbluetoothdeviceinfo.h
+++ b/src/bluetooth/qbluetoothdeviceinfo.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -36,7 +36,8 @@
#include <QtBluetooth/qbluetoothglobal.h>
-#include <QtCore/QString>
+#include <QtCore/qstring.h>
+#include <QtCore/qmetatype.h>
QT_BEGIN_NAMESPACE
@@ -199,6 +200,8 @@ public:
QBluetoothDeviceInfo();
QBluetoothDeviceInfo(const QBluetoothAddress &address, const QString &name,
quint32 classOfDevice);
+ QBluetoothDeviceInfo(const QBluetoothUuid &uuid, const QString &name,
+ quint32 classOfDevice);
QBluetoothDeviceInfo(const QBluetoothDeviceInfo &other);
~QBluetoothDeviceInfo();
@@ -228,6 +231,9 @@ public:
void setCoreConfigurations(QBluetoothDeviceInfo::CoreConfigurations coreConfigs);
QBluetoothDeviceInfo::CoreConfigurations coreConfigurations() const;
+ void setDeviceUuid(const QBluetoothUuid &uuid);
+ QBluetoothUuid deviceUuid() const;
+
protected:
QBluetoothDeviceInfoPrivate *d_ptr;
@@ -237,4 +243,6 @@ private:
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QBluetoothDeviceInfo)
+
#endif
diff --git a/src/bluetooth/qbluetoothdeviceinfo_p.h b/src/bluetooth/qbluetoothdeviceinfo_p.h
index 5b110993..99ff9bb4 100644
--- a/src/bluetooth/qbluetoothdeviceinfo_p.h
+++ b/src/bluetooth/qbluetoothdeviceinfo_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -73,6 +73,8 @@ public:
QBluetoothDeviceInfo::DataCompleteness serviceUuidsCompleteness;
QList<QBluetoothUuid> serviceUuids;
QBluetoothDeviceInfo::CoreConfigurations deviceCoreConfiguration;
+
+ QBluetoothUuid deviceUuid;
};
QT_END_NAMESPACE
diff --git a/src/bluetooth/qbluetoothglobal.h b/src/bluetooth/qbluetoothglobal.h
index 9c64e24e..830b23a5 100644
--- a/src/bluetooth/qbluetoothglobal.h
+++ b/src/bluetooth/qbluetoothglobal.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothhostinfo.cpp b/src/bluetooth/qbluetoothhostinfo.cpp
index cbabcb5e..1304f18a 100644
--- a/src/bluetooth/qbluetoothhostinfo.cpp
+++ b/src/bluetooth/qbluetoothhostinfo.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothhostinfo.h b/src/bluetooth/qbluetoothhostinfo.h
index abc70e7e..8b0085b0 100644
--- a/src/bluetooth/qbluetoothhostinfo.h
+++ b/src/bluetooth/qbluetoothhostinfo.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothhostinfo_p.h b/src/bluetooth/qbluetoothhostinfo_p.h
index 7eb46bd6..38f8df27 100644
--- a/src/bluetooth/qbluetoothhostinfo_p.h
+++ b/src/bluetooth/qbluetoothhostinfo_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothlocaldevice.cpp b/src/bluetooth/qbluetoothlocaldevice.cpp
index 4f80b439..0eb97647 100644
--- a/src/bluetooth/qbluetoothlocaldevice.cpp
+++ b/src/bluetooth/qbluetoothlocaldevice.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -93,6 +93,7 @@ QT_BEGIN_NAMESPACE
only made discoverable for a limited period of time. This can speed up discovery between gaming devices,
as service discovery can be skipped on devices not in LimitedInquiry mode. In this mode, the device will
be connectable and powered on, if required. This mode is is not supported on Android.
+ On OS X, it is not possible to set the \l hostMode() to HostConnectable or HostPoweredOff.
*/
@@ -102,13 +103,16 @@ class LocalDeviceRegisterMetaTypes
public:
LocalDeviceRegisterMetaTypes()
{
- qRegisterMetaType<QBluetoothLocalDevice::HostMode>("QBluetoothLocalDevice::HostMode");
- qRegisterMetaType<QBluetoothLocalDevice::Pairing>("QBluetoothLocalDevice::Pairing");
- qRegisterMetaType<QBluetoothLocalDevice::Error>("QBluetoothLocalDevice::Error");
+ qRegisterMetaType<QBluetoothLocalDevice::HostMode>();
+ qRegisterMetaType<QBluetoothLocalDevice::Pairing>();
+ qRegisterMetaType<QBluetoothLocalDevice::Error>();
}
} _registerLocalDeviceMetaTypes;
}
+
+#ifndef QT_OSX_BLUETOOTH
+
/*!
Destroys the QBluetoothLocalDevice.
*/
@@ -136,6 +140,8 @@ bool QBluetoothLocalDevice::isValid() const
return false;
}
+#endif
+
/*!
\fn void QBluetoothLocalDevice::setHostMode(QBluetoothLocalDevice::HostMode mode)
@@ -144,13 +150,16 @@ bool QBluetoothLocalDevice::isValid() const
\note Due to varying security policies on the supported platforms, this method may have
differing behaviors on the various platforms. For example the system may ask the user for
confirmation before turning Bluetooth on or off and not all host modes may be supported.
+ On OS X, it is not possbile to programmatically change the \l hostMode().
+ A user can only switch Bluetooth on/off in the System Preferences.
Please refer to the platform specific Bluetooth documentation for details.
*/
/*!
\fn QBluetoothLocalDevice::HostMode QBluetoothLocalDevice::hostMode() const
- Returns the current host mode of this local Bluetooth device.
+ Returns the current host mode of this local Bluetooth device. On OS X, it is either
+ HostPoweredOff or HostConnectable.
*/
/*!
@@ -168,7 +177,8 @@ bool QBluetoothLocalDevice::isValid() const
/*!
\fn QList<QBluetoothLocalDevice> QBluetoothLocalDevice::allDevices()
- Returns a list of all available local Bluetooth devices.
+ Returns a list of all available local Bluetooth devices. On OS X, there is
+ only the "default" local device.
*/
/*!
@@ -179,6 +189,7 @@ bool QBluetoothLocalDevice::isValid() const
\note Due to varying security policies on the supported platforms, this method may have
differing behaviors on the various platforms. For example
the system may ask the user for confirmation before turning Bluetooth on or off.
+ On OS X it is not possible to power on/off Bluetooth.
Please refer to the platform specific Bluetooth documentation for details.
*/
@@ -219,7 +230,7 @@ bool QBluetoothLocalDevice::isValid() const
Returns the list of connected devices. This list is different from the list of currently
paired devices.
- On Android it is not possible to retrieve a list of connected devices. It is only possible to
+ On Android and OS X, it is not possible to retrieve a list of connected devices. It is only possible to
listen to (dis)connect changes. For convenience, this class monitors all connect
and disconnect events since its instanciation and returns the current list when calling this function.
Therefore it is possible that this function returns an empty list shortly after creating an
@@ -242,6 +253,8 @@ bool QBluetoothLocalDevice::isValid() const
must be called to indicate if the user accepts or rejects the displayed pin.
This signal is only emitted for pairing requests issues by calling \l requestPairing().
+ On OS X, this method never gets called - there is a callback with a PIN (IOBluetooth),
+ but it expects immediate reply yes/no - and there is no time to show any dialog or compare PINs.
\sa pairingConfirmation()
*/
@@ -269,6 +282,11 @@ bool QBluetoothLocalDevice::isValid() const
Set the \a pairing status with \a address. The results are returned by the signal, pairingFinished().
On BlackBerry AuthorizedPaired is not possible and will have the same behavior as Paired.
+
+ On OS X, it is not possible to unpair a device. If Unpaired is requested, \l pairingFinished()
+ is immediately emitted although the device remains paired. It is possible to request the pairing
+ for a previously unpaired device. In addition \l AuthorizedPaired has the same behavior as \l Paired.
+
Caution: creating a pairing may take minutes, and may require the user to acknowledge.
*/
diff --git a/src/bluetooth/qbluetoothlocaldevice.h b/src/bluetooth/qbluetoothlocaldevice.h
index 4a70757f..bcb39bda 100644
--- a/src/bluetooth/qbluetoothlocaldevice.h
+++ b/src/bluetooth/qbluetoothlocaldevice.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothlocaldevice_android.cpp b/src/bluetooth/qbluetoothlocaldevice_android.cpp
index 8160a15d..20ac3d0a 100644
--- a/src/bluetooth/qbluetoothlocaldevice_android.cpp
+++ b/src/bluetooth/qbluetoothlocaldevice_android.cpp
@@ -1,8 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2013 Lauri Laanmets (Proekspert AS) <lauri.laanmets@eesti.ee>
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp
index 0df7cc5d..cae21e1b 100644
--- a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp
+++ b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothlocaldevice_osx.mm b/src/bluetooth/qbluetoothlocaldevice_osx.mm
new file mode 100644
index 00000000..71b7b81a
--- /dev/null
+++ b/src/bluetooth/qbluetoothlocaldevice_osx.mm
@@ -0,0 +1,481 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "osx/osxbtconnectionmonitor_p.h"
+#include "qbluetoothlocaldevice_p.h"
+#include "qbluetoothlocaldevice.h"
+#include "osx/osxbtdevicepair_p.h"
+#include "osx/osxbtutility_p.h"
+
+#include <QtCore/qloggingcategory.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qglobal.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qmap.h>
+
+
+#include <Foundation/Foundation.h>
+// Only after Foundation.h:
+#include "osx/corebluetoothwrapper_p.h"
+
+#include <algorithm>
+
+QT_BEGIN_NAMESPACE
+
+class QBluetoothLocalDevicePrivate : public OSXBluetooth::PairingDelegate,
+ public OSXBluetooth::ConnectionMonitor
+{
+ friend class QBluetoothLocalDevice;
+public:
+ typedef QBluetoothLocalDevice::Pairing Pairing;
+
+ QBluetoothLocalDevicePrivate(QBluetoothLocalDevice *, const QBluetoothAddress & =
+ QBluetoothAddress());
+
+ bool isValid() const;
+ void requestPairing(const QBluetoothAddress &address, Pairing pairing);
+ Pairing pairingStatus(const QBluetoothAddress &address) const;
+
+private:
+
+ // PairingDelegate:
+ void connecting(ObjCPairingRequest *pair) Q_DECL_OVERRIDE;
+ void requestPIN(ObjCPairingRequest *pair) Q_DECL_OVERRIDE;
+ void requestUserConfirmation(ObjCPairingRequest *pair,
+ BluetoothNumericValue) Q_DECL_OVERRIDE;
+ void passkeyNotification(ObjCPairingRequest *pair,
+ BluetoothPasskey passkey) Q_DECL_OVERRIDE;
+ void error(ObjCPairingRequest *pair, IOReturn errorCode) Q_DECL_OVERRIDE;
+ void pairingFinished(ObjCPairingRequest *pair) Q_DECL_OVERRIDE;
+
+ // ConnectionMonitor
+ void deviceConnected(const QBluetoothAddress &deviceAddress) Q_DECL_OVERRIDE;
+ void deviceDisconnected(const QBluetoothAddress &deviceAddress) Q_DECL_OVERRIDE;
+
+ void emitPairingFinished(const QBluetoothAddress &deviceAddress, Pairing pairing, bool queued);
+ void emitError(QBluetoothLocalDevice::Error error, bool queued);
+
+ void unpair(const QBluetoothAddress &deviceAddress);
+
+ QBluetoothLocalDevice *q_ptr;
+
+ typedef OSXBluetooth::ObjCScopedPointer<IOBluetoothHostController> HostController;
+ HostController hostController;
+
+ typedef OSXBluetooth::ObjCStrongReference<ObjCPairingRequest> PairingRequest;
+ typedef QMap<QBluetoothAddress, PairingRequest> RequestMap;
+
+ RequestMap pairingRequests;
+
+ OSXBluetooth::ObjCScopedPointer<ObjCConnectionMonitor> connectionMonitor;
+ QList<QBluetoothAddress> discoveredDevices;
+};
+
+QBluetoothLocalDevicePrivate::QBluetoothLocalDevicePrivate(QBluetoothLocalDevice *q,
+ const QBluetoothAddress &address) :
+ q_ptr(q)
+{
+ Q_ASSERT_X(q, Q_FUNC_INFO, "invalid q_ptr (null)");
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ HostController defaultController([[IOBluetoothHostController defaultController] retain]);
+ if (!defaultController) {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to "
+ "init a host controller object";
+ return;
+ }
+
+ if (!address.isNull()) {
+ NSString *const hciAddress = [defaultController addressAsString];
+ if (!hciAddress) {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to "
+ "obtain an address";
+ return;
+ }
+
+ BluetoothDeviceAddress iobtAddress = {};
+ if (IOBluetoothNSStringToDeviceAddress(hciAddress, &iobtAddress) != kIOReturnSuccess) {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "invalid "
+ "local device's address";
+ return;
+ }
+
+ if (address != OSXBluetooth::qt_address(&iobtAddress)) {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "invalid "
+ "local device's address";
+ return;
+ }
+ }
+
+ hostController.reset(defaultController.take());
+
+ // This one is optional, if it fails to initialize, we do not care at all.
+ connectionMonitor.reset([[ObjCConnectionMonitor alloc] initWithMonitor:this]);
+}
+
+bool QBluetoothLocalDevicePrivate::isValid() const
+{
+ return hostController;
+}
+
+void QBluetoothLocalDevicePrivate::requestPairing(const QBluetoothAddress &address, Pairing pairing)
+{
+ Q_ASSERT_X(isValid(), Q_FUNC_INFO, "invalid local device");
+ Q_ASSERT_X(!address.isNull(), Q_FUNC_INFO, "invalid device address");
+
+ using OSXBluetooth::device_with_address;
+ using OSXBluetooth::ObjCStrongReference;
+
+ // That's a really special case on OS X.
+ if (pairing == QBluetoothLocalDevice::Unpaired)
+ return unpair(address);
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ if (pairing == QBluetoothLocalDevice::AuthorizedPaired)
+ pairing = QBluetoothLocalDevice::Paired;
+
+ RequestMap::iterator pos = pairingRequests.find(address);
+ if (pos != pairingRequests.end()) {
+ if ([pos.value() isActive]) // Still trying to pair, continue.
+ return;
+
+ // 'device' is autoreleased:
+ IOBluetoothDevice *const device = [pos.value() targetDevice];
+ if ([device isPaired]) {
+ emitPairingFinished(address, pairing, true);
+ } else if ([pos.value() start] != kIOReturnSuccess) {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to "
+ "start a new pairing request";
+ emitError(QBluetoothLocalDevice::PairingError, true);
+ }
+ return;
+ }
+
+ // That's a totally new request ('Paired', since we are here).
+ // Even if this device is paired (not by our local device), I still create a pairing request,
+ // it'll just finish with success (skipping any intermediate steps).
+ PairingRequest newRequest([[ObjCPairingRequest alloc] initWithTarget:address delegate:this], false);
+ if (!newRequest) {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to "
+ "allocate a new pairing request";
+ emitError(QBluetoothLocalDevice::PairingError, true);
+ return;
+ }
+
+ pos = pairingRequests.insert(address, newRequest);
+ const IOReturn result = [newRequest start];
+ if (result != kIOReturnSuccess) {
+ pairingRequests.erase(pos);
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to "
+ "start a new pairing request";
+ emitError(QBluetoothLocalDevice::PairingError, true);
+ }
+}
+
+QBluetoothLocalDevice::Pairing QBluetoothLocalDevicePrivate::pairingStatus(const QBluetoothAddress &address)const
+{
+ Q_ASSERT_X(isValid(), Q_FUNC_INFO, "invalid local device");
+ Q_ASSERT_X(!address.isNull(), Q_FUNC_INFO, "invalid address");
+
+ using OSXBluetooth::device_with_address;
+ using OSXBluetooth::ObjCStrongReference;
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ RequestMap::const_iterator it = pairingRequests.find(address);
+ if (it != pairingRequests.end()) {
+ // All Obj-C objects are autoreleased.
+ IOBluetoothDevice *const device = [it.value() targetDevice];
+ if (device && [device isPaired])
+ return QBluetoothLocalDevice::Paired;
+ } else {
+ // Try even if device was not paired by this local device ...
+ const ObjCStrongReference<IOBluetoothDevice> device(device_with_address(address));
+ if (device && [device isPaired])
+ return QBluetoothLocalDevice::Paired;
+ }
+
+ return QBluetoothLocalDevice::Unpaired;
+}
+
+void QBluetoothLocalDevicePrivate::connecting(ObjCPairingRequest *pair)
+{
+ Q_UNUSED(pair)
+}
+
+void QBluetoothLocalDevicePrivate::requestPIN(ObjCPairingRequest *pair)
+{
+ Q_UNUSED(pair)
+}
+
+void QBluetoothLocalDevicePrivate::requestUserConfirmation(ObjCPairingRequest *pair, BluetoothNumericValue intPin)
+{
+ Q_UNUSED(pair)
+ Q_UNUSED(intPin)
+}
+
+void QBluetoothLocalDevicePrivate::passkeyNotification(ObjCPairingRequest *pair,
+ BluetoothPasskey passkey)
+{
+ Q_UNUSED(pair)
+ Q_UNUSED(passkey)
+}
+
+void QBluetoothLocalDevicePrivate::error(ObjCPairingRequest *pair, IOReturn errorCode)
+{
+ Q_UNUSED(pair)
+ Q_UNUSED(errorCode)
+
+ emitError(QBluetoothLocalDevice::PairingError, false);
+}
+
+void QBluetoothLocalDevicePrivate::pairingFinished(ObjCPairingRequest *pair)
+{
+ Q_ASSERT_X(pair, Q_FUNC_INFO, "invalid pairing request (nil)");
+
+ const QBluetoothAddress &deviceAddress = [pair targetAddress];
+ Q_ASSERT_X(!deviceAddress.isNull(), Q_FUNC_INFO,
+ "invalid target address");
+
+ emitPairingFinished(deviceAddress, QBluetoothLocalDevice::Paired, false);
+}
+
+void QBluetoothLocalDevicePrivate::deviceConnected(const QBluetoothAddress &deviceAddress)
+{
+ if (!discoveredDevices.contains(deviceAddress))
+ discoveredDevices.append(deviceAddress);
+
+ QMetaObject::invokeMethod(q_ptr, "deviceConnected", Qt::QueuedConnection,
+ Q_ARG(QBluetoothAddress, deviceAddress));
+}
+
+void QBluetoothLocalDevicePrivate::deviceDisconnected(const QBluetoothAddress &deviceAddress)
+{
+ QList<QBluetoothAddress>::iterator devicePos =std::find(discoveredDevices.begin(),
+ discoveredDevices.end(),
+ deviceAddress);
+
+ if (devicePos != discoveredDevices.end())
+ discoveredDevices.erase(devicePos);
+
+ QMetaObject::invokeMethod(q_ptr, "deviceDisconnected", Qt::QueuedConnection,
+ Q_ARG(QBluetoothAddress, deviceAddress));
+}
+
+void QBluetoothLocalDevicePrivate::emitError(QBluetoothLocalDevice::Error error, bool queued)
+{
+ if (queued) {
+ QMetaObject::invokeMethod(q_ptr, "error", Qt::QueuedConnection,
+ Q_ARG(QBluetoothLocalDevice::Error, error));
+ } else {
+ emit q_ptr->error(QBluetoothLocalDevice::PairingError);
+ }
+}
+
+void QBluetoothLocalDevicePrivate::emitPairingFinished(const QBluetoothAddress &deviceAddress,
+ Pairing pairing, bool queued)
+{
+ Q_ASSERT_X(!deviceAddress.isNull(), Q_FUNC_INFO, "invalid target device address");
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
+
+ if (queued) {
+ QMetaObject::invokeMethod(q_ptr, "pairingFinished", Qt::QueuedConnection,
+ Q_ARG(QBluetoothAddress, deviceAddress),
+ Q_ARG(QBluetoothLocalDevice::Pairing, pairing));
+ } else {
+ emit q_ptr->pairingFinished(deviceAddress, pairing);
+ }
+}
+
+void QBluetoothLocalDevicePrivate::unpair(const QBluetoothAddress &deviceAddress)
+{
+ Q_ASSERT_X(!deviceAddress.isNull(), Q_FUNC_INFO,
+ "invalid target address");
+
+ emitPairingFinished(deviceAddress, QBluetoothLocalDevice::Unpaired, true);
+}
+
+QBluetoothLocalDevice::QBluetoothLocalDevice(QObject *parent) :
+ QObject(parent),
+ d_ptr(new QBluetoothLocalDevicePrivate(this))
+{
+}
+
+QBluetoothLocalDevice::QBluetoothLocalDevice(const QBluetoothAddress &address, QObject *parent) :
+ QObject(parent),
+ d_ptr(new QBluetoothLocalDevicePrivate(this, address))
+{
+}
+
+QBluetoothLocalDevice::~QBluetoothLocalDevice()
+{
+ delete d_ptr;
+}
+
+bool QBluetoothLocalDevice::isValid() const
+{
+ return d_ptr->isValid();
+}
+
+
+QString QBluetoothLocalDevice::name() const
+{
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ if (isValid()) {
+ if (NSString *const nsn = [d_ptr->hostController nameAsString])
+ return QString::fromNSString(nsn);
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to obtain a name";
+ }
+
+ return QString();
+}
+
+QBluetoothAddress QBluetoothLocalDevice::address() const
+{
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ if (isValid()) {
+ if (NSString *const nsa = [d_ptr->hostController addressAsString])
+ return QBluetoothAddress(OSXBluetooth::qt_address(nsa));
+
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO << "failed to obtain an address";
+ } else {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid local device";
+ }
+
+ return QBluetoothAddress();
+}
+
+void QBluetoothLocalDevice::powerOn()
+{
+ if (!isValid())
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid local device";
+}
+
+void QBluetoothLocalDevice::setHostMode(QBluetoothLocalDevice::HostMode mode)
+{
+ Q_UNUSED(mode)
+
+ if (!isValid())
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid local device";
+}
+
+QBluetoothLocalDevice::HostMode QBluetoothLocalDevice::hostMode() const
+{
+ if (!isValid() || ![d_ptr->hostController powerState])
+ return HostPoweredOff;
+
+ return HostConnectable;
+}
+
+QList<QBluetoothAddress> QBluetoothLocalDevice::connectedDevices() const
+{
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ QList<QBluetoothAddress> connectedDevices;
+
+ // Take the devices known to IOBluetooth to be paired and connected first:
+ NSArray *const pairedDevices = [IOBluetoothDevice pairedDevices];
+ for (IOBluetoothDevice *device in pairedDevices) {
+ if ([device isConnected]) {
+ const QBluetoothAddress address(OSXBluetooth::qt_address([device getAddress]));
+ if (!address.isNull())
+ connectedDevices.append(address);
+ }
+ }
+
+ // Add devices, discovered by the connection monitor:
+ connectedDevices += d_ptr->discoveredDevices;
+ // Find something more elegant? :)
+ // But after all, addresses are integers.
+ std::sort(connectedDevices.begin(), connectedDevices.end());
+ connectedDevices.erase(std::unique(connectedDevices.begin(),
+ connectedDevices.end()),
+ connectedDevices.end());
+
+ return connectedDevices;
+}
+
+QList<QBluetoothHostInfo> QBluetoothLocalDevice::allDevices()
+{
+ QList<QBluetoothHostInfo> localDevices;
+
+ QBluetoothLocalDevice defaultAdapter;
+ if (!defaultAdapter.isValid() || defaultAdapter.address().isNull()) {
+ qCCritical(QT_BT_OSX) << Q_FUNC_INFO <<"no valid device found";
+ return localDevices;
+ }
+
+ QBluetoothHostInfo deviceInfo;
+ deviceInfo.setName(defaultAdapter.name());
+ deviceInfo.setAddress(defaultAdapter.address());
+
+ localDevices.append(deviceInfo);
+
+ return localDevices;
+}
+
+void QBluetoothLocalDevice::pairingConfirmation(bool confirmation)
+{
+ Q_UNUSED(confirmation)
+}
+
+
+void QBluetoothLocalDevice::requestPairing(const QBluetoothAddress &address, Pairing pairing)
+{
+ if (!isValid())
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid local device";
+
+ if (!isValid() || address.isNull()) {
+ d_ptr->emitError(PairingError, true);
+ return;
+ }
+
+ return d_ptr->requestPairing(address, pairing);
+}
+
+QBluetoothLocalDevice::Pairing QBluetoothLocalDevice::pairingStatus(const QBluetoothAddress &address) const
+{
+ if (!isValid())
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid local device";
+
+ if (!isValid() || address.isNull())
+ return Unpaired;
+
+ return d_ptr->pairingStatus(address);
+}
+
+QT_END_NAMESPACE
diff --git a/src/bluetooth/qbluetoothlocaldevice_p.cpp b/src/bluetooth/qbluetoothlocaldevice_p.cpp
index dbfb8724..2785e84c 100644
--- a/src/bluetooth/qbluetoothlocaldevice_p.cpp
+++ b/src/bluetooth/qbluetoothlocaldevice_p.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothlocaldevice_p.h b/src/bluetooth/qbluetoothlocaldevice_p.h
index 5d84af7e..c47ceb9e 100644
--- a/src/bluetooth/qbluetoothlocaldevice_p.h
+++ b/src/bluetooth/qbluetoothlocaldevice_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -237,7 +237,7 @@ private:
bool isValidDevice;
QList<QBluetoothAddress> connectedDevicesSet;
};
-#else
+#elif !defined(QT_OSX_BLUETOOTH)
class QBluetoothLocalDevicePrivate : public QObject
{
public:
diff --git a/src/bluetooth/qbluetoothlocaldevice_qnx.cpp b/src/bluetooth/qbluetoothlocaldevice_qnx.cpp
index c2a099f4..c36fb89a 100644
--- a/src/bluetooth/qbluetoothlocaldevice_qnx.cpp
+++ b/src/bluetooth/qbluetoothlocaldevice_qnx.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2012 Research In Motion
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothserver.cpp b/src/bluetooth/qbluetoothserver.cpp
index 1c4676e0..01f6fc37 100644
--- a/src/bluetooth/qbluetoothserver.cpp
+++ b/src/bluetooth/qbluetoothserver.cpp
@@ -1,8 +1,8 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothserver.h b/src/bluetooth/qbluetoothserver.h
index fde07784..951b47f4 100644
--- a/src/bluetooth/qbluetoothserver.h
+++ b/src/bluetooth/qbluetoothserver.h
@@ -1,8 +1,8 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothserver_android.cpp b/src/bluetooth/qbluetoothserver_android.cpp
index 3660cff8..8a23c4bf 100644
--- a/src/bluetooth/qbluetoothserver_android.cpp
+++ b/src/bluetooth/qbluetoothserver_android.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothserver_bluez.cpp b/src/bluetooth/qbluetoothserver_bluez.cpp
index c6ce77a3..d5cdb440 100644
--- a/src/bluetooth/qbluetoothserver_bluez.cpp
+++ b/src/bluetooth/qbluetoothserver_bluez.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothserver_osx.mm b/src/bluetooth/qbluetoothserver_osx.mm
new file mode 100644
index 00000000..6b82dd04
--- /dev/null
+++ b/src/bluetooth/qbluetoothserver_osx.mm
@@ -0,0 +1,493 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "osx/osxbtsocketlistener_p.h"
+#include "qbluetoothserver_osx_p.h"
+
+// The order is important: a workround for
+// a private header included by private header
+// (incorrectly handled dependencies).
+#include "qbluetoothsocket_p.h"
+#include "qbluetoothsocket_osx_p.h"
+
+#include "qbluetoothlocaldevice.h"
+#include "osx/osxbtutility_p.h"
+#include "qbluetoothserver.h"
+#include "qbluetoothsocket.h"
+
+#include <QtCore/qloggingcategory.h>
+#include <QtCore/qscopedpointer.h>
+#include <QtCore/qvariant.h>
+#include <QtCore/qglobal.h>
+#include <QtCore/qmutex.h>
+
+// Import, since Obj-C headers do not have inclusion guards.
+#include <Foundation/Foundation.h>
+// Only after Foundation.h
+#include "osx/corebluetoothwrapper_p.h"
+
+#include <limits>
+
+QT_BEGIN_NAMESPACE
+
+namespace {
+
+typedef QBluetoothServiceInfo QSInfo;
+
+QMap<quint16, QBluetoothServerPrivate *> &busyPSMs()
+{
+ static QMap<quint16, QBluetoothServerPrivate *> psms;
+ return psms;
+}
+
+QMap<quint16, QBluetoothServerPrivate *> &busyChannels()
+{
+ static QMap<quint16, QBluetoothServerPrivate *> channels;
+ return channels;
+}
+
+typedef QMap<quint16, QBluetoothServerPrivate *>::iterator ServerMapIterator;
+
+}
+
+
+QBluetoothServerPrivate::QBluetoothServerPrivate(QSInfo::Protocol type, QBluetoothServer *q)
+ : serverType(type),
+ q_ptr(q),
+ lastError(QBluetoothServer::NoError),
+ port(0),
+ maxPendingConnections(1)
+{
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
+ if (serverType == QSInfo::UnknownProtocol)
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "unknown protocol";
+}
+
+QBluetoothServerPrivate::~QBluetoothServerPrivate()
+{
+ // Actually, not good, but lock must be acquired.
+ // TODO: test this.
+ const QMutexLocker lock(&channelMapMutex());
+ unregisterServer(this);
+}
+
+void QBluetoothServerPrivate::_q_newConnection()
+{
+ // Noop, we have openNotify for this.
+}
+
+bool QBluetoothServerPrivate::startListener(quint16 realPort)
+{
+ Q_ASSERT_X(realPort, Q_FUNC_INFO, "invalid port");
+
+ if (serverType == QSInfo::UnknownProtocol) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid protocol";
+ return false;
+ }
+
+ if (!listener)
+ listener.reset([[ObjCListener alloc] initWithListener:this]);
+
+ bool result = false;
+ if (serverType == QSInfo::RfcommProtocol)
+ result = [listener listenRFCOMMConnectionsWithChannelID:realPort];
+ else
+ result = [listener listenL2CAPConnectionsWithPSM:realPort];
+
+ if (!result)
+ listener.reset(nil);
+
+ return result;
+}
+
+void QBluetoothServerPrivate::stopListener()
+{
+ listener.reset(nil);
+}
+
+void QBluetoothServerPrivate::openNotify(IOBluetoothRFCOMMChannel *channel)
+{
+ Q_ASSERT_X(listener, Q_FUNC_INFO, "invalid listener (nil)");
+ Q_ASSERT_X(channel, Q_FUNC_INFO, "invalid channel (nil)");
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
+
+ PendingConnection newConnection(channel, true);
+ pendingConnections.append(newConnection);
+
+ emit q_ptr->newConnection();
+}
+
+void QBluetoothServerPrivate::openNotify(IOBluetoothL2CAPChannel *channel)
+{
+ Q_ASSERT_X(listener, Q_FUNC_INFO, "invalid listener (nil)");
+ Q_ASSERT_X(channel, Q_FUNC_INFO, "invalid channel (nil)");
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
+
+ PendingConnection newConnection(channel, true);
+ pendingConnections.append(newConnection);
+
+ emit q_ptr->newConnection();
+}
+
+QMutex &QBluetoothServerPrivate::channelMapMutex()
+{
+ static QMutex mutex;
+ return mutex;
+}
+
+bool QBluetoothServerPrivate::channelIsBusy(quint16 channelID)
+{
+ // External lock is required.
+ return busyChannels().contains(channelID);
+}
+
+quint16 QBluetoothServerPrivate::findFreeChannel()
+{
+ // External lock is required.
+ for (quint16 i = 1; i <= 30; ++i) {
+ if (!busyChannels().contains(i))
+ return i;
+ }
+
+ return 0; //Invalid port.
+}
+
+bool QBluetoothServerPrivate::psmIsBusy(quint16 psm)
+{
+ // External lock is required.
+ return busyPSMs().contains(psm);
+}
+
+quint16 QBluetoothServerPrivate::findFreePSM()
+{
+ // External lock is required.
+ for (quint16 i = 1, e = std::numeric_limits<qint16>::max(); i < e; i += 2) {
+ if (!psmIsBusy(i))
+ return i;
+ }
+
+ return 0; // Invalid PSM.
+}
+
+void QBluetoothServerPrivate::registerServer(QBluetoothServerPrivate *server, quint16 port)
+{
+ // External lock is required + port must be free.
+ Q_ASSERT_X(server, Q_FUNC_INFO, "invalid server (null)");
+
+ const QSInfo::Protocol type = server->serverType;
+ if (type == QSInfo::RfcommProtocol) {
+ Q_ASSERT_X(!channelIsBusy(port), Q_FUNC_INFO, "port is busy");
+ busyChannels()[port] = server;
+ } else if (type == QSInfo::L2capProtocol) {
+ Q_ASSERT_X(!psmIsBusy(port), Q_FUNC_INFO, "port is busy");
+ busyPSMs()[port] = server;
+ } else {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "can not register a server "
+ "with unknown protocol type";
+ }
+}
+
+QBluetoothServerPrivate *QBluetoothServerPrivate::registeredServer(quint16 port, QBluetoothServiceInfo::Protocol protocol)
+{
+ // Eternal lock is required.
+ if (protocol == QSInfo::RfcommProtocol) {
+ ServerMapIterator it = busyChannels().find(port);
+ if (it != busyChannels().end())
+ return it.value();
+ } else if (protocol == QSInfo::L2capProtocol) {
+ ServerMapIterator it = busyPSMs().find(port);
+ if (it != busyPSMs().end())
+ return it.value();
+ } else {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid protocol";
+ }
+
+ return Q_NULLPTR;
+}
+
+void QBluetoothServerPrivate::unregisterServer(QBluetoothServerPrivate *server)
+{
+ // External lock is required.
+ const QSInfo::Protocol type = server->serverType;
+ const quint16 port = server->port;
+
+ if (type == QSInfo::RfcommProtocol) {
+ ServerMapIterator it = busyChannels().find(port);
+ if (it != busyChannels().end()) {
+ busyChannels().erase(it);
+ } else {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "server is not registered";
+ }
+ } else if (type == QSInfo::L2capProtocol) {
+ ServerMapIterator it = busyPSMs().find(port);
+ if (it != busyPSMs().end()) {
+ busyPSMs().erase(it);
+ } else {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "server is not registered";
+ }
+ } else {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid protocol";
+ }
+}
+
+
+QBluetoothServer::QBluetoothServer(QSInfo::Protocol serverType, QObject *parent)
+ : QObject(parent),
+ d_ptr(new QBluetoothServerPrivate(serverType, this))
+{
+}
+
+QBluetoothServer::~QBluetoothServer()
+{
+ delete d_ptr;
+}
+
+void QBluetoothServer::close()
+{
+ d_ptr->listener.reset(nil);
+
+ // Needs a lock :(
+ const QMutexLocker lock(&d_ptr->channelMapMutex());
+ d_ptr->unregisterServer(d_ptr);
+ d_ptr->port = 0;
+}
+
+bool QBluetoothServer::listen(const QBluetoothAddress &address, quint16 port)
+{
+ typedef QBluetoothServerPrivate::ObjCListener ObjCListener;
+
+ if (d_ptr->listener) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "already in listen mode, "
+ "close server first";
+ return false;
+ }
+
+ const QBluetoothLocalDevice device(address);
+ if (!device.isValid()) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "device does not support Bluetooth or "
+ << address.toString()
+ << " is not a valid local adapter";
+ d_ptr->lastError = UnknownError;
+ emit error(UnknownError);
+ return false;
+ }
+
+ const QBluetoothLocalDevice::HostMode hostMode = device.hostMode();
+ if (hostMode == QBluetoothLocalDevice::HostPoweredOff) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "Bluetooth device is powered off";
+ d_ptr->lastError = PoweredOffError;
+ emit error(PoweredOffError);
+ return false;
+ }
+
+ const QSInfo::Protocol type = d_ptr->serverType;
+
+ if (type == QSInfo::UnknownProtocol) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid protocol";
+ d_ptr->lastError = UnsupportedProtocolError;
+ emit error(d_ptr->lastError);
+ return false;
+ }
+
+ d_ptr->lastError = QBluetoothServer::NoError;
+
+ // Now we have to register a (fake) port, doing a proper (?) lock.
+ const QMutexLocker lock(&d_ptr->channelMapMutex());
+
+ if (port) {
+ if (type == QSInfo::RfcommProtocol) {
+ if (d_ptr->channelIsBusy(port)) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO <<"server port: "
+ << port << "already registered";
+ d_ptr->lastError = ServiceAlreadyRegisteredError;
+ }
+ } else {
+ if (d_ptr->psmIsBusy(port)) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "server port: "
+ << port << "already registered";
+ d_ptr->lastError = ServiceAlreadyRegisteredError;
+ }
+ }
+ } else {
+ type == QSInfo::RfcommProtocol ? port = d_ptr->findFreeChannel()
+ : port = d_ptr->findFreePSM();
+ }
+
+ if (d_ptr->lastError != QBluetoothServer::NoError) {
+ emit error(d_ptr->lastError);
+ return false;
+ }
+
+ if (!port) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "all ports are busy";
+ d_ptr->lastError = ServiceAlreadyRegisteredError;
+ emit error(d_ptr->lastError);
+ return false;
+ }
+
+ // It's a fake port, the real one will be different
+ // (provided after a service was registered).
+ d_ptr->port = port;
+ d_ptr->registerServer(d_ptr, port);
+ d_ptr->listener.reset([[ObjCListener alloc] initWithListener:d_ptr]);
+
+ return true;
+}
+
+QBluetoothServiceInfo QBluetoothServer::listen(const QBluetoothUuid &uuid, const QString &serviceName)
+{
+ if (!listen())
+ return QBluetoothServiceInfo();
+
+ QBluetoothServiceInfo serviceInfo;
+ serviceInfo.setAttribute(QSInfo::ServiceName, serviceName);
+ serviceInfo.setAttribute(QSInfo::BrowseGroupList,
+ QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
+
+ QSInfo::Sequence classId;
+ classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort));
+ serviceInfo.setAttribute(QSInfo::BluetoothProfileDescriptorList, classId);
+
+ classId.prepend(QVariant::fromValue(uuid));
+ serviceInfo.setAttribute(QSInfo::ServiceClassIds, classId);
+ serviceInfo.setServiceUuid(uuid);
+
+ QSInfo::Sequence protocolDescriptorList;
+ QSInfo::Sequence protocol;
+ protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::L2cap));
+ if (d_ptr->serverType == QSInfo::L2capProtocol)
+ protocol << QVariant::fromValue(serverPort());
+ protocolDescriptorList.append(QVariant::fromValue(protocol));
+ protocol.clear();
+
+ if (d_ptr->serverType == QBluetoothServiceInfo::RfcommProtocol) {
+ protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm))
+ << QVariant::fromValue(quint8(serverPort()));
+ protocolDescriptorList.append(QVariant::fromValue(protocol));
+ }
+
+ serviceInfo.setAttribute(QSInfo::ProtocolDescriptorList,
+ protocolDescriptorList);
+
+
+ // It's now up to a service info to acquire a real PSM/channel ID
+ // (provided by IOBluetooth) and start a listener.
+ if (!serviceInfo.registerService())
+ return QBluetoothServiceInfo();
+
+ return serviceInfo;
+}
+
+bool QBluetoothServer::isListening() const
+{
+ if (d_ptr->serverType == QSInfo::UnknownProtocol)
+ return false;
+
+ const QMutexLocker lock(&QBluetoothServerPrivate::channelMapMutex());
+ return QBluetoothServerPrivate::registeredServer(serverPort(), d_ptr->serverType);
+}
+
+void QBluetoothServer::setMaxPendingConnections(int numConnections)
+{
+ // That's a 'fake' limit, it affects nothing.
+ d_ptr->maxPendingConnections = numConnections;
+}
+
+int QBluetoothServer::maxPendingConnections() const
+{
+ // That's a 'fake' limit, it affects nothing.
+ return d_ptr->maxPendingConnections;
+}
+
+bool QBluetoothServer::hasPendingConnections() const
+{
+ return d_ptr->pendingConnections.size();
+}
+
+QBluetoothSocket *QBluetoothServer::nextPendingConnection()
+{
+ if (!d_ptr->pendingConnections.size())
+ return Q_NULLPTR;
+
+ QScopedPointer<QBluetoothSocket> newSocket(new QBluetoothSocket);
+ QBluetoothServerPrivate::PendingConnection channel(d_ptr->pendingConnections.front());
+
+ // Remove it even if we have some errors below.
+ d_ptr->pendingConnections.pop_front();
+
+ if (d_ptr->serverType == QSInfo::RfcommProtocol) {
+ if (!newSocket->d_ptr->setChannel(static_cast<IOBluetoothRFCOMMChannel *>(channel)))
+ return Q_NULLPTR;
+ } else {
+ if (!newSocket->d_ptr->setChannel(static_cast<IOBluetoothL2CAPChannel *>(channel)))
+ return Q_NULLPTR;
+ }
+
+ return newSocket.take();
+}
+
+QBluetoothAddress QBluetoothServer::serverAddress() const
+{
+ return QBluetoothLocalDevice().address();
+}
+
+quint16 QBluetoothServer::serverPort() const
+{
+ return d_ptr->port;
+}
+
+void QBluetoothServer::setSecurityFlags(QBluetooth::SecurityFlags security)
+{
+ Q_UNUSED(security)
+ // Not implemented (yet?)
+}
+
+QBluetooth::SecurityFlags QBluetoothServer::securityFlags() const
+{
+ // Not implemented (yet?)
+ return QBluetooth::NoSecurity;
+}
+
+QSInfo::Protocol QBluetoothServer::serverType() const
+{
+ return d_ptr->serverType;
+}
+
+QBluetoothServer::Error QBluetoothServer::error() const
+{
+ return d_ptr->lastError;
+}
+
+#include "moc_qbluetoothserver.cpp"
+
+QT_END_NAMESPACE
diff --git a/src/bluetooth/qbluetoothserver_osx_p.h b/src/bluetooth/qbluetoothserver_osx_p.h
new file mode 100644
index 00000000..6aed892c
--- /dev/null
+++ b/src/bluetooth/qbluetoothserver_osx_p.h
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBLUETOOTHSERVER_OSX_P_H
+#define QBLUETOOTHSERVER_OSX_P_H
+
+#ifdef QT_OSX_BLUETOOTH
+
+#include "osx/osxbtsocketlistener_p.h"
+#include "qbluetoothserviceinfo.h"
+#include "osx/osxbtutility_p.h"
+#include "qbluetoothserver.h"
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qlist.h>
+
+QT_BEGIN_NAMESPACE
+
+class QMutex;
+
+class QBluetoothServerPrivate : public OSXBluetooth::SocketListener
+{
+ friend class QBluetoothServer;
+ friend class QBluetoothServiceInfoPrivate;
+
+public:
+ QBluetoothServerPrivate(QBluetoothServiceInfo::Protocol type, QBluetoothServer *q);
+ ~QBluetoothServerPrivate();
+
+ void _q_newConnection();
+private:
+ bool startListener(quint16 realPort);
+ void stopListener();
+
+ // SocketListener (delegate):
+ void openNotify(IOBluetoothRFCOMMChannel *channel) Q_DECL_OVERRIDE;
+ void openNotify(IOBluetoothL2CAPChannel *channel) Q_DECL_OVERRIDE;
+
+ QBluetoothServiceInfo::Protocol serverType;
+ QBluetoothServer *q_ptr;
+ QBluetoothServer::Error lastError;
+
+ // Either a "temporary" channelID/PSM assigned by QBluetoothServer::listen,
+ // or a real channelID/PSM returned by IOBluetooth after we've registered
+ // a service.
+ quint16 port;
+
+ typedef OSXBluetooth::ObjCScopedPointer<ObjCListener> Listener;
+ Listener listener;
+
+ int maxPendingConnections;
+
+ // These static functions below
+ // deal with differences between bluetooth sockets
+ // (bluez and QtBluetooth's API) and IOBluetooth, where it's not possible
+ // to have a real PSM/channelID _before_ a service is registered,
+ // the solution - "fake" ports.
+ // These functions require external locking - using channelMapMutex.
+ static QMutex &channelMapMutex();
+
+ static bool channelIsBusy(quint16 channelID);
+ static quint16 findFreeChannel();
+
+ static bool psmIsBusy(quint16 psm);
+ static quint16 findFreePSM();
+
+ static void registerServer(QBluetoothServerPrivate *server, quint16 port);
+ static QBluetoothServerPrivate *registeredServer(quint16 port, QBluetoothServiceInfo::Protocol protocol);
+ static void unregisterServer(QBluetoothServerPrivate *server);
+
+ typedef OSXBluetooth::ObjCStrongReference<NSObject> PendingConnection;
+ QList<PendingConnection> pendingConnections;
+
+};
+
+QT_END_NAMESPACE
+
+#endif //QT_OSX_BLUETOOTH
+
+#endif
diff --git a/src/bluetooth/qbluetoothserver_p.cpp b/src/bluetooth/qbluetoothserver_p.cpp
index 310b6f68..86b520d6 100644
--- a/src/bluetooth/qbluetoothserver_p.cpp
+++ b/src/bluetooth/qbluetoothserver_p.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothserver_p.h b/src/bluetooth/qbluetoothserver_p.h
index 75f1bde6..090d8860 100644
--- a/src/bluetooth/qbluetoothserver_p.h
+++ b/src/bluetooth/qbluetoothserver_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -74,6 +74,8 @@ class QBluetoothSocket;
class QBluetoothServer;
+#ifndef QT_OSX_BLUETOOTH
+
class QBluetoothServerPrivate
#ifdef QT_QNX_BLUETOOTH
: public QObject
@@ -137,6 +139,8 @@ public:
#endif
};
+#endif //QT_OSX_BLUETOOTH
+
QT_END_NAMESPACE
#endif
diff --git a/src/bluetooth/qbluetoothserver_qnx.cpp b/src/bluetooth/qbluetoothserver_qnx.cpp
index bb2346cd..d23ea55a 100644
--- a/src/bluetooth/qbluetoothserver_qnx.cpp
+++ b/src/bluetooth/qbluetoothserver_qnx.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2012 - 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent.cpp b/src/bluetooth/qbluetoothservicediscoveryagent.cpp
index 7274780a..a285a557 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent.h b/src/bluetooth/qbluetoothservicediscoveryagent.h
index dddd67b2..d15a1d8d 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent.h
+++ b/src/bluetooth/qbluetoothservicediscoveryagent.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -103,10 +103,12 @@ Q_SIGNALS:
private:
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())
+
#ifdef QT_BLUEZ_BLUETOOTH
Q_PRIVATE_SLOT(d_func(), void _q_discoveredServices(QDBusPendingCallWatcher*))
Q_PRIVATE_SLOT(d_func(), void _q_createdDevice(QDBusPendingCallWatcher*))
@@ -122,4 +124,6 @@ private:
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QBluetoothServiceDiscoveryAgent::Error)
+
#endif
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp
index e10d2ffe..47f3bd0b 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -81,7 +81,7 @@ QBluetoothServiceDiscoveryAgentPrivate::QBluetoothServiceDiscoveryAgentPrivate(
if (!btAdapter.isValid())
qCWarning(QT_BT_ANDROID) << "Platform does not support Bluetooth";
- qRegisterMetaType<QList<QBluetoothUuid> >("QList<QBluetoothUuid>");
+ qRegisterMetaType<QList<QBluetoothUuid> >();
}
QBluetoothServiceDiscoveryAgentPrivate::~QBluetoothServiceDiscoveryAgentPrivate()
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
index 412fd916..f66603a9 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -71,9 +71,9 @@ QBluetoothServiceDiscoveryAgentPrivate::QBluetoothServiceDiscoveryAgentPrivate(c
managerBluez5 = new OrgFreedesktopDBusObjectManagerInterface(
QStringLiteral("org.bluez"), QStringLiteral("/"),
QDBusConnection::systemBus());
- qRegisterMetaType<QBluetoothServiceDiscoveryAgent::Error>("QBluetoothServiceDiscoveryAgent::Error");
+ qRegisterMetaType<QBluetoothServiceDiscoveryAgent::Error>();
} else {
- qRegisterMetaType<ServiceMap>("ServiceMap");
+ qRegisterMetaType<ServiceMap>();
qDBusRegisterMetaType<ServiceMap>();
manager = new OrgBluezManagerInterface(QStringLiteral("org.bluez"), QStringLiteral("/"),
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_osx.mm b/src/bluetooth/qbluetoothservicediscoveryagent_osx.mm
new file mode 100644
index 00000000..64723dd1
--- /dev/null
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_osx.mm
@@ -0,0 +1,583 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbluetoothservicediscoveryagent.h"
+#include "qbluetoothdevicediscoveryagent.h"
+#include "qbluetoothlocaldevice.h"
+#include "osx/osxbtsdpinquiry_p.h"
+#include "qbluetoothhostinfo.h"
+#include "osx/osxbtutility_p.h"
+#include "osx/uistrings_p.h"
+
+#include <QtCore/qloggingcategory.h>
+#include <QtCore/qscopedpointer.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qglobal.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qlist.h>
+
+#include <Foundation/Foundation.h>
+// Only after Foundation.h
+#include "osx/corebluetoothwrapper_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QBluetoothServiceDiscoveryAgentPrivate : public QObject, public OSXBluetooth::SDPInquiryDelegate
+{
+ friend class QBluetoothServiceDiscoveryAgent;
+public:
+ enum DiscoveryState {
+ Inactive,
+ DeviceDiscovery,
+ ServiceDiscovery,
+ };
+
+ QBluetoothServiceDiscoveryAgentPrivate(const QBluetoothAddress &localAddress);
+
+ void startDeviceDiscovery();
+ void stopDeviceDiscovery();
+
+ void startServiceDiscovery();
+ void stopServiceDiscovery();
+
+ DiscoveryState discoveryState();
+ void setDiscoveryMode(QBluetoothServiceDiscoveryAgent::DiscoveryMode m);
+ QBluetoothServiceDiscoveryAgent::DiscoveryMode DiscoveryMode();
+
+ void _q_deviceDiscovered(const QBluetoothDeviceInfo &info);
+ void _q_deviceDiscoveryError(QBluetoothDeviceDiscoveryAgent::Error);
+ void _q_deviceDiscoveryFinished();
+ void _q_serviceDiscoveryFinished();
+
+
+private:
+ // SDPInquiryDelegate:
+ void SDPInquiryFinished(IOBluetoothDevice *device) Q_DECL_OVERRIDE;
+ void SDPInquiryError(IOBluetoothDevice *device, IOReturn errorCode) Q_DECL_OVERRIDE;
+
+ void performMinimalServiceDiscovery(const QBluetoothAddress &deviceAddress);
+ void setupDeviceDiscoveryAgent();
+ bool isDuplicatedService(const QBluetoothServiceInfo &serviceInfo) const;
+ void serviceDiscoveryFinished();
+
+ QBluetoothServiceDiscoveryAgent *q_ptr;
+
+ QBluetoothServiceDiscoveryAgent::Error error;
+ QString errorString;
+
+ QList<QBluetoothDeviceInfo> discoveredDevices;
+ QList<QBluetoothServiceInfo> discoveredServices;
+ QList<QBluetoothUuid> uuidFilter;
+
+ bool singleDevice;
+ QBluetoothAddress deviceAddress;
+ QBluetoothAddress localAdapterAddress;
+
+ DiscoveryState state;
+ QBluetoothServiceDiscoveryAgent::DiscoveryMode discoveryMode;
+
+ QScopedPointer<QBluetoothDeviceDiscoveryAgent> deviceDiscoveryAgent;
+ OSXBluetooth::ObjCScopedPointer<ObjCServiceInquiry> serviceInquiry;
+};
+
+QBluetoothServiceDiscoveryAgentPrivate::QBluetoothServiceDiscoveryAgentPrivate(const QBluetoothAddress &localAddress) :
+ q_ptr(0),
+ error(QBluetoothServiceDiscoveryAgent::NoError),
+ singleDevice(false),
+ localAdapterAddress(localAddress),
+ state(Inactive),
+ discoveryMode(QBluetoothServiceDiscoveryAgent::MinimalDiscovery)
+{
+ serviceInquiry.reset([[ObjCServiceInquiry alloc] initWithDelegate:this]);
+}
+
+void QBluetoothServiceDiscoveryAgentPrivate::startDeviceDiscovery()
+{
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
+ Q_ASSERT_X(state == Inactive, Q_FUNC_INFO, "invalid state");
+ Q_ASSERT_X(error != QBluetoothServiceDiscoveryAgent::InvalidBluetoothAdapterError,
+ Q_FUNC_INFO, "invalid bluetooth adapter");
+
+ Q_ASSERT_X(deviceDiscoveryAgent.isNull(), "startDeviceDiscovery()",
+ "discovery agent already exists");
+
+ state = DeviceDiscovery;
+
+ setupDeviceDiscoveryAgent();
+ deviceDiscoveryAgent->start();
+}
+
+void QBluetoothServiceDiscoveryAgentPrivate::stopDeviceDiscovery()
+{
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
+ Q_ASSERT_X(!deviceDiscoveryAgent.isNull(), Q_FUNC_INFO,
+ "invalid device discovery agent (null)");
+ Q_ASSERT_X(state == DeviceDiscovery, Q_FUNC_INFO, "invalid state");
+
+ deviceDiscoveryAgent->stop();
+ deviceDiscoveryAgent.reset(Q_NULLPTR);
+ state = Inactive;
+
+ emit q_ptr->canceled();
+}
+
+void QBluetoothServiceDiscoveryAgentPrivate::startServiceDiscovery()
+{
+ // Any of 'Inactive'/'DeviceDiscovery'/'ServiceDiscovery' states
+ // are possible.
+
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
+ Q_ASSERT_X(error != QBluetoothServiceDiscoveryAgent::InvalidBluetoothAdapterError,
+ Q_FUNC_INFO, "invalid bluetooth adapter");
+
+ if (discoveredDevices.isEmpty()) {
+ state = Inactive;
+ emit q_ptr->finished();
+ return;
+ }
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ state = ServiceDiscovery;
+ const QBluetoothAddress &address(discoveredDevices.at(0).address());
+
+ if (address.isNull()) {
+ // This can happen: LE scan works with CoreBluetooth, but CBPeripherals
+ // do not expose hardware addresses.
+ // Pop the current QBluetoothDeviceInfo and decide what to do next.
+ return serviceDiscoveryFinished();
+ }
+
+ // Autoreleased object.
+ IOBluetoothHostController *const hc = [IOBluetoothHostController defaultController];
+ if (![hc powerState]) {
+ discoveredDevices.clear();
+ if (singleDevice) {
+ error = QBluetoothServiceDiscoveryAgent::PoweredOffError;
+ errorString = QCoreApplication::translate(SERVICE_DISCOVERY, SD_LOCAL_DEV_OFF);
+ emit q_ptr->error(error);
+ }
+
+ return serviceDiscoveryFinished();
+ }
+
+ if (DiscoveryMode() == QBluetoothServiceDiscoveryAgent::MinimalDiscovery) {
+ performMinimalServiceDiscovery(address);
+ } else {
+ IOReturn result = kIOReturnSuccess;
+ if (uuidFilter.size())
+ result = [serviceInquiry performSDPQueryWithDevice:address filters:uuidFilter];
+ else
+ result = [serviceInquiry performSDPQueryWithDevice:address];
+
+ if (result != kIOReturnSuccess) {
+ // Failed immediately to perform an SDP inquiry on IOBluetoothDevice:
+ SDPInquiryError(nil, result);
+ }
+ }
+}
+
+void QBluetoothServiceDiscoveryAgentPrivate::stopServiceDiscovery()
+{
+ Q_ASSERT_X(state != Inactive, Q_FUNC_INFO, "invalid state");
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
+
+ discoveredDevices.clear();
+ state = Inactive;
+
+ // "Stops" immediately.
+ [serviceInquiry stopSDPQuery];
+
+ emit q_ptr->canceled();
+}
+
+QBluetoothServiceDiscoveryAgentPrivate::DiscoveryState
+ QBluetoothServiceDiscoveryAgentPrivate::discoveryState()
+{
+ return state;
+}
+
+void QBluetoothServiceDiscoveryAgentPrivate::setDiscoveryMode(
+ QBluetoothServiceDiscoveryAgent::DiscoveryMode m)
+{
+ discoveryMode = m;
+
+}
+
+QBluetoothServiceDiscoveryAgent::DiscoveryMode
+ QBluetoothServiceDiscoveryAgentPrivate::DiscoveryMode()
+{
+ return discoveryMode;
+}
+
+void QBluetoothServiceDiscoveryAgentPrivate::_q_deviceDiscovered(const QBluetoothDeviceInfo &info)
+{
+ // Look for duplicates, and cached entries
+ for (int i = 0; i < discoveredDevices.count(); i++) {
+ if (discoveredDevices.at(i).address() == info.address()) {
+ discoveredDevices.removeAt(i);
+ break;
+ }
+ }
+
+ discoveredDevices.prepend(info);
+}
+
+void QBluetoothServiceDiscoveryAgentPrivate::_q_deviceDiscoveryError(QBluetoothDeviceDiscoveryAgent::Error)
+{
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
+
+ error = QBluetoothServiceDiscoveryAgent::UnknownError;
+ errorString = QCoreApplication::translate(DEV_DISCOVERY, DD_UNKNOWN_ERROR);
+
+ deviceDiscoveryAgent->stop();
+ deviceDiscoveryAgent.reset(Q_NULLPTR);
+
+ state = QBluetoothServiceDiscoveryAgentPrivate::Inactive;
+ emit q_ptr->error(error);
+ emit q_ptr->finished();
+}
+
+void QBluetoothServiceDiscoveryAgentPrivate::_q_deviceDiscoveryFinished()
+{
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
+
+ if (deviceDiscoveryAgent->error() != QBluetoothDeviceDiscoveryAgent::NoError) {
+ //Forward the device discovery error
+ error = static_cast<QBluetoothServiceDiscoveryAgent::Error>(deviceDiscoveryAgent->error());
+ errorString = deviceDiscoveryAgent->errorString();
+ deviceDiscoveryAgent.reset(Q_NULLPTR);
+ state = Inactive;
+ emit q_ptr->error(error);
+ emit q_ptr->finished();
+ } else {
+ deviceDiscoveryAgent.reset(Q_NULLPTR);
+ startServiceDiscovery();
+ }
+}
+
+void QBluetoothServiceDiscoveryAgentPrivate::_q_serviceDiscoveryFinished()
+{
+ // See SDPInquiryFinished.
+}
+
+void QBluetoothServiceDiscoveryAgentPrivate::SDPInquiryFinished(IOBluetoothDevice *device)
+{
+ Q_ASSERT_X(device, Q_FUNC_INFO, "invalid IOBluetoothDevice (nil)");
+
+ if (state == Inactive)
+ return;
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ NSArray *const records = device.services;
+ for (IOBluetoothSDPServiceRecord *record in records) {
+ QBluetoothServiceInfo serviceInfo;
+ Q_ASSERT_X(discoveredDevices.size() >= 1, Q_FUNC_INFO, "invalid number of devices");
+
+ serviceInfo.setDevice(discoveredDevices.at(0));
+ OSXBluetooth::extract_service_record(record, serviceInfo);
+
+ if (!serviceInfo.isValid())
+ continue;
+
+ if (!isDuplicatedService(serviceInfo)) {
+ discoveredServices.append(serviceInfo);
+ emit q_ptr->serviceDiscovered(serviceInfo);
+ // Here a user code can ... interrupt us by calling
+ // stop. Check this.
+ if (state == Inactive)
+ break;
+ }
+ }
+
+ serviceDiscoveryFinished();
+}
+
+void QBluetoothServiceDiscoveryAgentPrivate::SDPInquiryError(IOBluetoothDevice *device, IOReturn errorCode)
+{
+ Q_UNUSED(device)
+
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "inquiry failed with IOKit code: " << int(errorCode);
+
+ discoveredDevices.clear();
+ // TODO: find a better mapping from IOReturn to QBluetoothServiceDiscoveryAgent::Error.
+ if (singleDevice) {
+ error = QBluetoothServiceDiscoveryAgent::UnknownError;
+ errorString = QCoreApplication::translate(DEV_DISCOVERY, DD_UNKNOWN_ERROR);
+ emit q_ptr->error(error);
+ }
+
+ serviceDiscoveryFinished();
+}
+
+void QBluetoothServiceDiscoveryAgentPrivate::performMinimalServiceDiscovery(const QBluetoothAddress &deviceAddress)
+{
+ Q_ASSERT_X(!deviceAddress.isNull(), Q_FUNC_INFO, "invalid device address");
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ const BluetoothDeviceAddress iobtAddress = OSXBluetooth::iobluetooth_address(deviceAddress);
+ IOBluetoothDevice *const device = [IOBluetoothDevice deviceWithAddress:&iobtAddress];
+ if (!device || !device.services) {
+ if (singleDevice) {
+ error = QBluetoothServiceDiscoveryAgent::UnknownError;
+ errorString = QCoreApplication::translate(SERVICE_DISCOVERY, SD_MINIMAL_FAILED);
+ emit q_ptr->error(error);
+ }
+ } else {
+
+ NSArray *const records = device.services;
+ for (IOBluetoothSDPServiceRecord *record in records) {
+ QBluetoothServiceInfo serviceInfo;
+ Q_ASSERT_X(discoveredDevices.size() >= 1, Q_FUNC_INFO,
+ "invalid number of devices");
+
+ serviceInfo.setDevice(discoveredDevices.at(0));
+ OSXBluetooth::extract_service_record(record, serviceInfo);
+
+ if (!serviceInfo.isValid())
+ continue;
+
+ if (!uuidFilter.isEmpty() && !uuidFilter.contains(serviceInfo.serviceUuid()))
+ continue;
+
+ if (!isDuplicatedService(serviceInfo)) {
+ discoveredServices.append(serviceInfo);
+ emit q_ptr->serviceDiscovered(serviceInfo);
+ }
+ }
+ }
+
+ serviceDiscoveryFinished();
+}
+
+void QBluetoothServiceDiscoveryAgentPrivate::setupDeviceDiscoveryAgent()
+{
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
+ Q_ASSERT_X(deviceDiscoveryAgent.isNull() || !deviceDiscoveryAgent->isActive(),
+ Q_FUNC_INFO, "device discovery agent is active");
+
+ deviceDiscoveryAgent.reset(new QBluetoothDeviceDiscoveryAgent(localAdapterAddress, q_ptr));
+
+ QObject::connect(deviceDiscoveryAgent.data(), SIGNAL(deviceDiscovered(const QBluetoothDeviceInfo &)),
+ q_ptr, SLOT(_q_deviceDiscovered(const QBluetoothDeviceInfo &)));
+ QObject::connect(deviceDiscoveryAgent.data(), SIGNAL(finished()),
+ q_ptr, SLOT(_q_deviceDiscoveryFinished()));
+ QObject::connect(deviceDiscoveryAgent.data(), SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)),
+ q_ptr, SLOT(_q_deviceDiscoveryError(QBluetoothDeviceDiscoveryAgent::Error)));
+}
+
+bool QBluetoothServiceDiscoveryAgentPrivate::isDuplicatedService(const QBluetoothServiceInfo &serviceInfo) const
+{
+ //check the service is not already part of our known list
+ for (int j = 0; j < discoveredServices.count(); j++) {
+ const QBluetoothServiceInfo &info = discoveredServices.at(j);
+ if (info.device() == serviceInfo.device()
+ && info.serviceClassUuids() == serviceInfo.serviceClassUuids()
+ && info.serviceUuid() == serviceInfo.serviceUuid()) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void QBluetoothServiceDiscoveryAgentPrivate::serviceDiscoveryFinished()
+{
+ if (!discoveredDevices.isEmpty())
+ discoveredDevices.removeFirst();
+
+ if (state == ServiceDiscovery)
+ startServiceDiscovery();
+}
+
+QBluetoothServiceDiscoveryAgent::QBluetoothServiceDiscoveryAgent(QObject *parent)
+: QObject(parent), d_ptr(new QBluetoothServiceDiscoveryAgentPrivate(QBluetoothAddress()))
+{
+ d_ptr->q_ptr = this;
+}
+
+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 = QCoreApplication::translate(SERVICE_DISCOVERY, SD_INVALID_ADDRESS);
+ }
+}
+
+QBluetoothServiceDiscoveryAgent::~QBluetoothServiceDiscoveryAgent()
+{
+ delete d_ptr;
+}
+
+QList<QBluetoothServiceInfo> QBluetoothServiceDiscoveryAgent::discoveredServices() const
+{
+ return d_ptr->discoveredServices;
+}
+
+/*
+ Sets the UUID filter to \a uuids. Only services matching the UUIDs in \a uuids will be
+ returned.
+
+ An empty UUID list is equivalent to a list containing only QBluetoothUuid::PublicBrowseGroup.
+
+ \sa uuidFilter()
+*/
+void QBluetoothServiceDiscoveryAgent::setUuidFilter(const QList<QBluetoothUuid> &uuids)
+{
+ d_ptr->uuidFilter = uuids;
+}
+
+/*
+ This is an overloaded member function, provided for convenience.
+
+ Sets the UUID filter to a list containing the single element \a uuid.
+
+ \sa uuidFilter()
+*/
+void QBluetoothServiceDiscoveryAgent::setUuidFilter(const QBluetoothUuid &uuid)
+{
+ d_ptr->uuidFilter.clear();
+ d_ptr->uuidFilter.append(uuid);
+}
+
+/*
+ Returns the UUID filter.
+
+ \sa setUuidFilter()
+*/
+QList<QBluetoothUuid> QBluetoothServiceDiscoveryAgent::uuidFilter() const
+{
+ return d_ptr->uuidFilter;
+}
+
+/*
+ Sets the remote device address to \a address. If \a address is default constructed,
+ services will be discovered on all contactable Bluetooth devices. A new remote
+ address can only be set while there is no service discovery in progress; otherwise
+ this function returns false.
+
+ On some platforms such as Blackberry the service discovery might lead to pairing requests.
+ Therefore it is not recommended to do service discoveries on all devices.
+
+ \sa remoteAddress()
+*/
+bool QBluetoothServiceDiscoveryAgent::setRemoteAddress(const QBluetoothAddress &address)
+{
+ if (isActive())
+ return false;
+
+ if (!address.isNull())
+ d_ptr->singleDevice = true;
+
+ d_ptr->deviceAddress = address;
+ return true;
+}
+
+QBluetoothAddress QBluetoothServiceDiscoveryAgent::remoteAddress() const
+{
+ if (d_ptr->singleDevice)
+ return d_ptr->deviceAddress;
+
+ return QBluetoothAddress();
+}
+
+void QBluetoothServiceDiscoveryAgent::start(DiscoveryMode mode)
+{
+ if (d_ptr->discoveryState() == QBluetoothServiceDiscoveryAgentPrivate::Inactive
+ && d_ptr->error != InvalidBluetoothAdapterError)
+ {
+ d_ptr->setDiscoveryMode(mode);
+ if (d_ptr->deviceAddress.isNull()) {
+ d_ptr->startDeviceDiscovery();
+ } else {
+ d_ptr->discoveredDevices.append(QBluetoothDeviceInfo(d_ptr->deviceAddress, QString(), 0));
+ d_ptr->startServiceDiscovery();
+ }
+ }
+}
+
+void QBluetoothServiceDiscoveryAgent::stop()
+{
+ if (d_ptr->error == InvalidBluetoothAdapterError || !isActive())
+ return;
+
+ switch (d_ptr->discoveryState()) {
+ case QBluetoothServiceDiscoveryAgentPrivate::DeviceDiscovery:
+ d_ptr->stopDeviceDiscovery();
+ break;
+ case QBluetoothServiceDiscoveryAgentPrivate::ServiceDiscovery:
+ d_ptr->stopServiceDiscovery();
+ default:;
+ }
+
+ d_ptr->discoveredDevices.clear();
+}
+
+void QBluetoothServiceDiscoveryAgent::clear()
+{
+ // Don't clear the list while the search is ongoing
+ if (isActive())
+ return;
+
+ d_ptr->discoveredDevices.clear();
+ d_ptr->discoveredServices.clear();
+ d_ptr->uuidFilter.clear();
+}
+
+bool QBluetoothServiceDiscoveryAgent::isActive() const
+{
+ return d_ptr->state != QBluetoothServiceDiscoveryAgentPrivate::Inactive;
+}
+
+QBluetoothServiceDiscoveryAgent::Error QBluetoothServiceDiscoveryAgent::error() const
+{
+ return d_ptr->error;
+}
+
+QString QBluetoothServiceDiscoveryAgent::errorString() const
+{
+ return d_ptr->errorString;
+}
+
+#include "moc_qbluetoothservicediscoveryagent.cpp"
+
+QT_END_NAMESPACE
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_p.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_p.cpp
index 695912f1..738fe739 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_p.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_p.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_p.h b/src/bluetooth/qbluetoothservicediscoveryagent_p.h
index 3b9c0a42..9f2c501a 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_p.h
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp
index d8a03105..32d6d2c2 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2012 Research In Motion
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -132,8 +132,8 @@ QBluetoothServiceDiscoveryAgentPrivate::QBluetoothServiceDiscoveryAgentPrivate(c
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");
+ qRegisterMetaType<QBluetoothServiceInfo>();
+ qRegisterMetaType<QBluetoothServiceDiscoveryAgent::Error>();
}
QBluetoothServiceDiscoveryAgentPrivate::~QBluetoothServiceDiscoveryAgentPrivate()
diff --git a/src/bluetooth/qbluetoothserviceinfo.cpp b/src/bluetooth/qbluetoothserviceinfo.cpp
index 7b9460a1..445d64b4 100644
--- a/src/bluetooth/qbluetoothserviceinfo.cpp
+++ b/src/bluetooth/qbluetoothserviceinfo.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothserviceinfo.h b/src/bluetooth/qbluetoothserviceinfo.h
index 1ec1d7d9..b52eaf79 100644
--- a/src/bluetooth/qbluetoothserviceinfo.h
+++ b/src/bluetooth/qbluetoothserviceinfo.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothserviceinfo_android.cpp b/src/bluetooth/qbluetoothserviceinfo_android.cpp
index 64603235..714b671c 100644
--- a/src/bluetooth/qbluetoothserviceinfo_android.cpp
+++ b/src/bluetooth/qbluetoothserviceinfo_android.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothserviceinfo_bluez.cpp b/src/bluetooth/qbluetoothserviceinfo_bluez.cpp
index 59a9abca..e3fa81d1 100644
--- a/src/bluetooth/qbluetoothserviceinfo_bluez.cpp
+++ b/src/bluetooth/qbluetoothserviceinfo_bluez.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothserviceinfo_osx.mm b/src/bluetooth/qbluetoothserviceinfo_osx.mm
new file mode 100644
index 00000000..743fb377
--- /dev/null
+++ b/src/bluetooth/qbluetoothserviceinfo_osx.mm
@@ -0,0 +1,514 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "osx/osxbtservicerecord_p.h"
+#include "qbluetoothserver_osx_p.h"
+#include "qbluetoothserviceinfo.h"
+#include "qbluetoothdeviceinfo.h"
+#include "osx/osxbtutility_p.h"
+
+#include <QtCore/qloggingcategory.h>
+#include <QtCore/qvariant.h>
+#include <QtCore/qsysinfo.h>
+#include <QtCore/qglobal.h>
+#include <QtCore/qmutex.h>
+#include <QtCore/qmap.h>
+#include <QtCore/qurl.h>
+
+#include <Foundation/Foundation.h>
+// Only after Foundation.h:
+#include "osx/corebluetoothwrapper_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace {
+
+// This is not in osxbtutility_p, since it's not required
+// in general and just fixes the problem with SDK < 10.9,
+// where we have to care about about IOBluetoothSDPServiceRecordRef.
+class ServiceRecordRefGuard
+{
+public:
+ ServiceRecordRefGuard()
+ : recordRef(Q_NULLPTR)
+ {
+ }
+ explicit ServiceRecordRefGuard(IOBluetoothSDPServiceRecordRef r)
+ : recordRef(r)
+ {
+ }
+ ~ServiceRecordRefGuard()
+ {
+ if (recordRef) // Requires non-NULL pointers.
+ CFRelease(recordRef);
+ }
+
+ void reset(IOBluetoothSDPServiceRecordRef r)
+ {
+ if (recordRef)
+ CFRelease(recordRef);
+ // Take the ownership:
+ recordRef = r;
+ }
+
+private:
+ IOBluetoothSDPServiceRecordRef recordRef;
+
+ Q_DISABLE_COPY(ServiceRecordRefGuard)
+};
+
+}
+
+class QBluetoothServiceInfoPrivate
+{
+public:
+ typedef QBluetoothServiceInfo QSInfo;
+ QBluetoothServiceInfoPrivate(QBluetoothServiceInfo *q);
+
+ bool registerService(const QBluetoothAddress &localAdapter = QBluetoothAddress());
+
+ bool isRegistered() const;
+
+ bool unregisterService();
+
+ QBluetoothDeviceInfo deviceInfo;
+ QMap<quint16, QVariant> attributes;
+
+ QBluetoothServiceInfo::Sequence protocolDescriptor(QBluetoothUuid::ProtocolUuid protocol) const;
+ int serverChannel() const;
+
+private:
+ QBluetoothServiceInfo *q_ptr;
+ bool registered;
+
+ typedef OSXBluetooth::ObjCScopedPointer<IOBluetoothSDPServiceRecord> SDPRecord;
+ SDPRecord serviceRecord;
+ BluetoothSDPServiceRecordHandle serviceRecordHandle;
+};
+
+QBluetoothServiceInfoPrivate::QBluetoothServiceInfoPrivate(QBluetoothServiceInfo *q)
+ : q_ptr(q),
+ registered(false),
+ serviceRecordHandle(0)
+{
+ Q_ASSERT_X(q, Q_FUNC_INFO, "invalid q_ptr (null)");
+}
+
+bool QBluetoothServiceInfoPrivate::registerService(const QBluetoothAddress &localAdapter)
+{
+ Q_UNUSED(localAdapter)
+
+ if (registered)
+ return false;
+
+ Q_ASSERT_X(!serviceRecord, Q_FUNC_INFO, "not registered, but serviceRecord is not nil");
+
+ using namespace OSXBluetooth;
+
+ ObjCStrongReference<NSMutableDictionary>
+ serviceDict(iobluetooth_service_dictionary(*q_ptr));
+
+ if (!serviceDict) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to create a service dictionary";
+ return false;
+ }
+
+ ServiceRecordRefGuard refGuard;
+ SDPRecord newRecord;
+#if QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9)
+ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_9) {
+ newRecord.reset([[IOBluetoothSDPServiceRecord
+ publishedServiceRecordWithDictionary:serviceDict] retain]);
+ } else {
+#else
+ {
+#endif
+ IOBluetoothSDPServiceRecordRef recordRef = Q_NULLPTR;
+ // With ARC this will require a different cast?
+ const IOReturn status = IOBluetoothAddServiceDict((CFDictionaryRef)serviceDict.data(), &recordRef);
+ if (status != kIOReturnSuccess) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to register a service record";
+ return false;
+ }
+
+ refGuard.reset(recordRef);
+ newRecord.reset([[IOBluetoothSDPServiceRecord withSDPServiceRecordRef:recordRef] retain]);
+ // It's weird, but ... it's not possible to release a record ref yet.
+ }
+
+ if (!newRecord) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to register a service record";
+ // In case of SDK < 10.9 it's not possible to remove a service record ...
+ // no way to obtain record handle yet.
+ return false;
+ }
+
+ BluetoothSDPServiceRecordHandle newRecordHandle = 0;
+ if ([newRecord getServiceRecordHandle:&newRecordHandle] != kIOReturnSuccess) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to register a service record";
+#if QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9)
+ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_9)
+ [newRecord removeServiceRecord];
+#endif
+ // With SDK < 10.9 there is no way to unregister at this point ...
+ return false;
+ }
+
+ const QSInfo::Protocol type = q_ptr->socketProtocol();
+ quint16 realPort = 0;
+ QBluetoothServerPrivate *server = Q_NULLPTR;
+ bool configured = false;
+
+ if (type == QBluetoothServiceInfo::L2capProtocol) {
+ BluetoothL2CAPPSM psm = 0;
+ server = QBluetoothServerPrivate::registeredServer(q_ptr->protocolServiceMultiplexer(), type);
+ if ([newRecord getL2CAPPSM:&psm] == kIOReturnSuccess) {
+ configured = true;
+ realPort = psm;
+ }
+ } else if (type == QBluetoothServiceInfo::RfcommProtocol) {
+ BluetoothRFCOMMChannelID channelID = 0;
+ server = QBluetoothServerPrivate::registeredServer(q_ptr->serverChannel(), type);
+ if ([newRecord getRFCOMMChannelID:&channelID] == kIOReturnSuccess) {
+ configured = true;
+ realPort = channelID;
+ }
+ }
+
+ if (!configured) {
+#if QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9)
+ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_9) {
+ [newRecord removeServiceRecord];
+ } else {
+#else
+ {// Just to balance braces ...
+#endif
+ IOBluetoothRemoveServiceWithRecordHandle(newRecordHandle);
+ }
+
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to register a service record";
+ return false;
+ }
+
+ registered = true;
+ serviceRecord.reset(newRecord.take());
+ serviceRecordHandle = newRecordHandle;
+
+ if (server)
+ server->startListener(realPort);
+
+ return true;
+}
+
+bool QBluetoothServiceInfoPrivate::isRegistered() const
+{
+ return registered;
+}
+
+bool QBluetoothServiceInfoPrivate::unregisterService()
+{
+ if (!registered)
+ return false;
+
+ Q_ASSERT_X(serviceRecord, Q_FUNC_INFO, "service registered, but serviceRecord is nil");
+
+#if QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9)
+ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_9) {
+ [serviceRecord removeServiceRecord];
+ } else {
+#else
+ {
+#endif
+ // Assert on newRecordHandle? Is 0 a valid/invalid handle?
+ IOBluetoothRemoveServiceWithRecordHandle(serviceRecordHandle);
+ }
+
+ serviceRecord.reset(nil);
+
+ const QSInfo::Protocol type = q_ptr->socketProtocol();
+ QBluetoothServerPrivate *server = Q_NULLPTR;
+
+ const QMutexLocker lock(&QBluetoothServerPrivate::channelMapMutex());
+ if (type == QSInfo::RfcommProtocol)
+ server = QBluetoothServerPrivate::registeredServer(q_ptr->serverChannel(), type);
+ else if (type == QSInfo::L2capProtocol)
+ server = QBluetoothServerPrivate::registeredServer(q_ptr->protocolServiceMultiplexer(), type);
+
+ if (server)
+ server->stopListener();
+
+ registered = false;
+ serviceRecordHandle = 0;
+
+ return true;
+}
+
+bool QBluetoothServiceInfo::isRegistered() const
+{
+ return d_ptr->isRegistered();
+}
+
+bool QBluetoothServiceInfo::registerService(const QBluetoothAddress &localAdapter)
+{
+ return d_ptr->registerService(localAdapter);
+}
+
+bool QBluetoothServiceInfo::unregisterService()
+{
+ return d_ptr->unregisterService();
+}
+
+QBluetoothServiceInfo::QBluetoothServiceInfo()
+ : d_ptr(QSharedPointer<QBluetoothServiceInfoPrivate>(new QBluetoothServiceInfoPrivate(this)))
+{
+}
+
+QBluetoothServiceInfo::QBluetoothServiceInfo(const QBluetoothServiceInfo &other)
+ : d_ptr(other.d_ptr)
+{
+}
+
+QBluetoothServiceInfo::~QBluetoothServiceInfo()
+{
+}
+
+bool QBluetoothServiceInfo::isValid() const
+{
+ return !d_ptr->attributes.isEmpty();
+}
+
+bool QBluetoothServiceInfo::isComplete() const
+{
+ return d_ptr->attributes.keys().contains(ProtocolDescriptorList);
+}
+
+QBluetoothDeviceInfo QBluetoothServiceInfo::device() const
+{
+ return d_ptr->deviceInfo;
+}
+
+void QBluetoothServiceInfo::setDevice(const QBluetoothDeviceInfo &device)
+{
+ d_ptr->deviceInfo = device;
+}
+
+void QBluetoothServiceInfo::setAttribute(quint16 attributeId, const QVariant &value)
+{
+ d_ptr->attributes[attributeId] = value;
+}
+
+QVariant QBluetoothServiceInfo::attribute(quint16 attributeId) const
+{
+ return d_ptr->attributes.value(attributeId);
+}
+
+QList<quint16> QBluetoothServiceInfo::attributes() const
+{
+ return d_ptr->attributes.keys();
+}
+
+bool QBluetoothServiceInfo::contains(quint16 attributeId) const
+{
+ return d_ptr->attributes.contains(attributeId);
+}
+
+void QBluetoothServiceInfo::removeAttribute(quint16 attributeId)
+{
+ d_ptr->attributes.remove(attributeId);
+}
+
+QBluetoothServiceInfo::Protocol QBluetoothServiceInfo::socketProtocol() const
+{
+ QBluetoothServiceInfo::Sequence parameters = protocolDescriptor(QBluetoothUuid::Rfcomm);
+ if (!parameters.isEmpty())
+ return RfcommProtocol;
+
+ parameters = protocolDescriptor(QBluetoothUuid::L2cap);
+ if (!parameters.isEmpty())
+ return L2capProtocol;
+
+ return UnknownProtocol;
+}
+
+int QBluetoothServiceInfo::protocolServiceMultiplexer() const
+{
+ QBluetoothServiceInfo::Sequence parameters = protocolDescriptor(QBluetoothUuid::L2cap);
+
+ if (parameters.isEmpty())
+ return -1;
+ else if (parameters.count() == 1)
+ return 0;
+ else
+ return parameters.at(1).toUInt();
+}
+
+int QBluetoothServiceInfo::serverChannel() const
+{
+ return d_ptr->serverChannel();
+}
+
+QBluetoothServiceInfo::Sequence QBluetoothServiceInfo::protocolDescriptor(QBluetoothUuid::ProtocolUuid protocol) const
+{
+ return d_ptr->protocolDescriptor(protocol);
+}
+
+QList<QBluetoothUuid> QBluetoothServiceInfo::serviceClassUuids() const
+{
+ QList<QBluetoothUuid> results;
+
+ const QVariant var = attribute(QBluetoothServiceInfo::ServiceClassIds);
+ if (!var.isValid())
+ return results;
+
+ const QBluetoothServiceInfo::Sequence seq = var.value<QBluetoothServiceInfo::Sequence>();
+ for (int i = 0; i < seq.count(); i++)
+ results.append(seq.at(i).value<QBluetoothUuid>());
+
+ return results;
+}
+
+QBluetoothServiceInfo &QBluetoothServiceInfo::operator=(const QBluetoothServiceInfo &other)
+{
+ d_ptr = other.d_ptr;
+
+ return *this;
+}
+
+static void dumpAttributeVariant(const QVariant &var, const QString indent)
+{
+ switch (int(var.type())) {
+ case QMetaType::Void:
+ qDebug("%sEmpty", indent.toLocal8Bit().constData());
+ break;
+ case QMetaType::UChar:
+ qDebug("%suchar %u", indent.toLocal8Bit().constData(), var.toUInt());
+ break;
+ case QMetaType::UShort:
+ qDebug("%sushort %u", indent.toLocal8Bit().constData(), var.toUInt());
+ case QMetaType::UInt:
+ qDebug("%suint %u", indent.toLocal8Bit().constData(), var.toUInt());
+ break;
+ case QMetaType::Char:
+ qDebug("%schar %d", indent.toLocal8Bit().constData(), var.toInt());
+ break;
+ case QMetaType::Short:
+ qDebug("%sshort %d", indent.toLocal8Bit().constData(), var.toInt());
+ break;
+ case QMetaType::Int:
+ qDebug("%sint %d", indent.toLocal8Bit().constData(), var.toInt());
+ break;
+ case QMetaType::QString:
+ qDebug("%sstring %s", indent.toLocal8Bit().constData(), var.toString().toLocal8Bit().constData());
+ break;
+ case QMetaType::Bool:
+ qDebug("%sbool %d", indent.toLocal8Bit().constData(), var.toBool());
+ break;
+ case QMetaType::QUrl:
+ qDebug("%surl %s", indent.toLocal8Bit().constData(), var.toUrl().toString().toLocal8Bit().constData());
+ break;
+ case QVariant::UserType:
+ if (var.userType() == qMetaTypeId<QBluetoothUuid>()) {
+ QBluetoothUuid uuid = var.value<QBluetoothUuid>();
+ switch (uuid.minimumSize()) {
+ case 0:
+ qDebug("%suuid NULL", indent.toLocal8Bit().constData());
+ break;
+ case 2:
+ qDebug("%suuid %04x", indent.toLocal8Bit().constData(), uuid.toUInt16());
+ break;
+ case 4:
+ qDebug("%suuid %08x", indent.toLocal8Bit().constData(), uuid.toUInt32());
+ break;
+ case 16:
+ qDebug("%suuid %s", indent.toLocal8Bit().constData(), QByteArray(reinterpret_cast<const char *>(uuid.toUInt128().data), 16).toHex().constData());
+ break;
+ default:
+ qDebug("%suuid ???", indent.toLocal8Bit().constData());
+ ;
+ }
+ } else if (var.userType() == qMetaTypeId<QBluetoothServiceInfo::Sequence>()) {
+ qDebug("%sSequence", indent.toLocal8Bit().constData());
+ const QBluetoothServiceInfo::Sequence *sequence = static_cast<const QBluetoothServiceInfo::Sequence *>(var.data());
+ foreach (const QVariant &v, *sequence)
+ dumpAttributeVariant(v, indent + QLatin1Char('\t'));
+ } else if (var.userType() == qMetaTypeId<QBluetoothServiceInfo::Alternative>()) {
+ qDebug("%sAlternative", indent.toLocal8Bit().constData());
+ const QBluetoothServiceInfo::Alternative *alternative = static_cast<const QBluetoothServiceInfo::Alternative *>(var.data());
+ foreach (const QVariant &v, *alternative)
+ dumpAttributeVariant(v, indent + QLatin1Char('\t'));
+ }
+ break;
+ default:
+ qDebug("%sunknown variant type %d", indent.toLocal8Bit().constData(), var.userType());
+ }
+}
+
+QDebug operator << (QDebug dbg, const QBluetoothServiceInfo &info)
+{
+ foreach (quint16 id, info.attributes()) {
+ dumpAttributeVariant(info.attribute(id), QString::fromLatin1("(%1)\t").arg(id));
+ }
+ return dbg;
+}
+
+QBluetoothServiceInfo::Sequence QBluetoothServiceInfoPrivate::protocolDescriptor(QBluetoothUuid::ProtocolUuid protocol) const
+{
+ if (!attributes.contains(QBluetoothServiceInfo::ProtocolDescriptorList))
+ return QBluetoothServiceInfo::Sequence();
+
+ foreach (const QVariant &v, attributes.value(QBluetoothServiceInfo::ProtocolDescriptorList).value<QBluetoothServiceInfo::Sequence>()) {
+ QBluetoothServiceInfo::Sequence parameters = v.value<QBluetoothServiceInfo::Sequence>();
+ if (parameters.empty())
+ continue;
+ if (parameters.at(0).userType() == qMetaTypeId<QBluetoothUuid>()) {
+ if (parameters.at(0).value<QBluetoothUuid>() == protocol)
+ return parameters;
+ }
+ }
+
+ return QBluetoothServiceInfo::Sequence();
+}
+
+int QBluetoothServiceInfoPrivate::serverChannel() const
+{
+ QBluetoothServiceInfo::Sequence parameters = protocolDescriptor(QBluetoothUuid::Rfcomm);
+
+ if (parameters.isEmpty())
+ return -1;
+ else if (parameters.count() == 1)
+ return 0;
+ else
+ return parameters.at(1).toUInt();
+}
+
+QT_END_NAMESPACE
diff --git a/src/bluetooth/qbluetoothserviceinfo_p.cpp b/src/bluetooth/qbluetoothserviceinfo_p.cpp
index ba6a9526..8942149a 100644
--- a/src/bluetooth/qbluetoothserviceinfo_p.cpp
+++ b/src/bluetooth/qbluetoothserviceinfo_p.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothserviceinfo_p.h b/src/bluetooth/qbluetoothserviceinfo_p.h
index 7ff7132c..c109496a 100644
--- a/src/bluetooth/qbluetoothserviceinfo_p.h
+++ b/src/bluetooth/qbluetoothserviceinfo_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -60,6 +60,8 @@ QT_BEGIN_NAMESPACE
class QBluetoothServiceInfo;
+#ifndef QT_OSX_BLUETOOTH
+
class QBluetoothServiceInfoPrivate
: public QObject
{
@@ -93,6 +95,8 @@ private:
mutable bool registered;
};
+#endif
+
QT_END_NAMESPACE
#endif
diff --git a/src/bluetooth/qbluetoothserviceinfo_qnx.cpp b/src/bluetooth/qbluetoothserviceinfo_qnx.cpp
index 387f4751..6d5f678e 100644
--- a/src/bluetooth/qbluetoothserviceinfo_qnx.cpp
+++ b/src/bluetooth/qbluetoothserviceinfo_qnx.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2012 Research In Motion
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothsocket.cpp b/src/bluetooth/qbluetoothsocket.cpp
index f91057e1..56428544 100644
--- a/src/bluetooth/qbluetoothsocket.cpp
+++ b/src/bluetooth/qbluetoothsocket.cpp
@@ -1,8 +1,8 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -199,7 +199,7 @@ Q_DECLARE_LOGGING_CATEGORY(QT_BT_QNX)
Although some platforms may differ the socket must generally be connected to guarantee
the return of a valid port number.
- On BlackBerry and Android, this feature is not supported and returns 0.
+ On BlackBerry, Android and OS X, this feature is not supported and returns 0.
*/
/*!
diff --git a/src/bluetooth/qbluetoothsocket.h b/src/bluetooth/qbluetoothsocket.h
index 8252fa99..b073ada3 100644
--- a/src/bluetooth/qbluetoothsocket.h
+++ b/src/bluetooth/qbluetoothsocket.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -46,7 +46,6 @@
QT_BEGIN_NAMESPACE
class QBluetoothSocketPrivate;
-class QBluetoothServiceInfo;
class Q_BLUETOOTH_EXPORT QBluetoothSocket : public QIODevice
{
@@ -162,4 +161,7 @@ Q_BLUETOOTH_EXPORT QDebug operator<<(QDebug, QBluetoothSocket::SocketState);
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QBluetoothSocket::SocketError)
+Q_DECLARE_METATYPE(QBluetoothSocket::SocketState)
+
#endif
diff --git a/src/bluetooth/qbluetoothsocket_android.cpp b/src/bluetooth/qbluetoothsocket_android.cpp
index b4ebeb89..990ab378 100644
--- a/src/bluetooth/qbluetoothsocket_android.cpp
+++ b/src/bluetooth/qbluetoothsocket_android.cpp
@@ -1,8 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2013 Lauri Laanmets (Proekspert AS) <lauri.laanmets@eesti.ee>
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -41,7 +41,6 @@
#include <QtCore/private/qjni_p.h>
#include <QtAndroidExtras/QAndroidJniEnvironment>
-
QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(QT_BT_ANDROID)
@@ -179,8 +178,8 @@ QBluetoothSocketPrivate::QBluetoothSocketPrivate()
adapter = QAndroidJniObject::callStaticObjectMethod("android/bluetooth/BluetoothAdapter",
"getDefaultAdapter",
"()Landroid/bluetooth/BluetoothAdapter;");
- qRegisterMetaType<QBluetoothSocket::SocketError>("QBluetoothSocket::SocketError");
- qRegisterMetaType<QBluetoothSocket::SocketState>("QBluetoothSocket::SocketState");
+ qRegisterMetaType<QBluetoothSocket::SocketError>();
+ qRegisterMetaType<QBluetoothSocket::SocketState>();
}
QBluetoothSocketPrivate::~QBluetoothSocketPrivate()
@@ -210,7 +209,7 @@ bool QBluetoothSocketPrivate::fallBackConnect(QAndroidJniObject uuid, int channe
return false;
}
- QAndroidJniObject integerObject = QAndroidJniObject::getStaticObjectField<jobject>(
+ QAndroidJniObject integerObject = QAndroidJniObject::getStaticObjectField(
"java/lang/Integer", "TYPE", "Ljava/lang/Class;");
if (!integerObject.isValid()) {
qCWarning(QT_BT_ANDROID) << "Could not get Integer.TYPE";
diff --git a/src/bluetooth/qbluetoothsocket_bluez.cpp b/src/bluetooth/qbluetoothsocket_bluez.cpp
index 9f68386c..c18ce279 100644
--- a/src/bluetooth/qbluetoothsocket_bluez.cpp
+++ b/src/bluetooth/qbluetoothsocket_bluez.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothsocket_osx.mm b/src/bluetooth/qbluetoothsocket_osx.mm
new file mode 100644
index 00000000..490c1bed
--- /dev/null
+++ b/src/bluetooth/qbluetoothsocket_osx.mm
@@ -0,0 +1,772 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbluetoothservicediscoveryagent.h"
+// The order is important (the first header contains
+// the base class for a private socket) - workaround for
+// dependencies problem.
+#include "qbluetoothsocket_p.h"
+#include "qbluetoothsocket_osx_p.h"
+//
+#include "qbluetoothsocket_osx_p.h"
+#include "qbluetoothlocaldevice.h"
+#include "qbluetoothdeviceinfo.h"
+#include "osx/osxbtutility_p.h"
+#include "osx/uistrings_p.h"
+#include "qbluetoothsocket.h"
+
+#include <QtCore/qloggingcategory.h>
+#include <QtCore/qmetaobject.h>
+
+#include <algorithm>
+#include <limits>
+
+QT_BEGIN_NAMESPACE
+
+QBluetoothSocketPrivate::QBluetoothSocketPrivate()
+ : q_ptr(Q_NULLPTR),
+ writeChunk(std::numeric_limits<UInt16>::max()),
+ openMode(QIODevice::NotOpen), // That's what is set in public class' ctors.
+ state(QBluetoothSocket::UnconnectedState),
+ socketType(QBluetoothServiceInfo::UnknownProtocol),
+ socketError(QBluetoothSocket::NoSocketError),
+ isConnecting(false)
+{
+}
+
+QBluetoothSocketPrivate::~QBluetoothSocketPrivate()
+{
+ // "Empty" dtor to make a shared pointer happy (parametrized with
+ // incomplete type in the header file).
+}
+
+void QBluetoothSocketPrivate::connectToService(const QBluetoothAddress &address, quint16 port,
+ QIODevice::OpenMode mode)
+{
+ // We have readwrite channels with IOBluetooth's channels.
+ Q_UNUSED(openMode)
+
+ Q_ASSERT_X(state == QBluetoothSocket::ServiceLookupState
+ || state == QBluetoothSocket::UnconnectedState,
+ Q_FUNC_INFO, "invalid state");
+
+ socketError = QBluetoothSocket::NoSocketError;
+ errorString.clear();
+ buffer.clear();
+ txBuffer.clear();
+
+ IOReturn status = kIOReturnError;
+ // Set socket state on q_ptr will emit a signal,
+ // we'd like to avoid any signal until this function completes.
+ const QBluetoothSocket::SocketState oldState = state;
+ // To prevent other connectToService calls (from QBluetoothSocket):
+ // and also avoid signals in delegate callbacks.
+ state = QBluetoothSocket::ConnectingState;
+ // We're still inside this function:
+ isConnecting = true;
+
+ // We'll later (or now) have to set an open mode on QBluetoothSocket.
+ openMode = mode;
+
+ if (socketType == QBluetoothServiceInfo::RfcommProtocol) {
+ rfcommChannel.reset([[ObjCRFCOMMChannel alloc] initWithDelegate:this]);
+ if (rfcommChannel)
+ status = [rfcommChannel connectAsyncToDevice:address withChannelID:port];
+ else
+ status = kIOReturnNoMemory;
+ } else if (socketType == QBluetoothServiceInfo::L2capProtocol) {
+ l2capChannel.reset([[ObjCL2CAPChannel alloc] initWithDelegate:this]);
+ if (l2capChannel)
+ status = [l2capChannel connectAsyncToDevice:address withPSM:port];
+ else
+ status = kIOReturnNoMemory;
+ }
+
+ // We're probably still connecting, but at least are leaving this function:
+ isConnecting = false;
+
+ // QBluetoothSocket will change the state and also emit
+ // a signal later if required.
+ if (status == kIOReturnSuccess && socketError == QBluetoothSocket::NoSocketError) {
+ if (state == QBluetoothSocket::ConnectedState) {
+ // Callback 'channelOpenComplete' fired before
+ // connectToService finished:
+ state = oldState;
+ // Connected, setOpenMode on a QBluetoothSocket.
+ q_ptr->setOpenMode(openMode);
+ q_ptr->setSocketState(QBluetoothSocket::ConnectedState);
+ emit q_ptr->connected();
+ if (buffer.size()) // We also have some data already ...
+ emit q_ptr->readyRead();
+ } else if (state == QBluetoothSocket::UnconnectedState) {
+ // Even if we have some data, we can not read it if
+ // state != ConnectedState.
+ buffer.clear();
+ state = oldState;
+ q_ptr->setSocketError(QBluetoothSocket::UnknownSocketError);
+ } else {
+ // No error and we're connecting ...
+ state = oldState;
+ q_ptr->setSocketState(QBluetoothSocket::ConnectingState);
+ }
+ } else {
+ state = oldState;
+ if (status != kIOReturnSuccess)
+ errorString = OSXBluetooth::qt_error_string(status);
+ q_ptr->setSocketError(QBluetoothSocket::UnknownSocketError);
+ }
+}
+
+void QBluetoothSocketPrivate::close()
+{
+ // Can never be called while we're in connectToService:
+ Q_ASSERT_X(!isConnecting, Q_FUNC_INFO, "internal inconsistency - "
+ "still in connectToService()");
+
+ if (!txBuffer.size())
+ abort();
+}
+
+void QBluetoothSocketPrivate::abort()
+{
+ // Can never be called while we're in connectToService:
+ Q_ASSERT_X(!isConnecting, Q_FUNC_INFO, "internal inconsistency - "
+ "still in connectToService()");
+
+ if (socketType == QBluetoothServiceInfo::RfcommProtocol)
+ rfcommChannel.reset(nil);
+ else if (socketType == QBluetoothServiceInfo::L2capProtocol)
+ l2capChannel.reset(nil);
+}
+
+quint64 QBluetoothSocketPrivate::bytesAvailable() const
+{
+ return buffer.size();
+}
+
+QString QBluetoothSocketPrivate::peerName() const
+{
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ NSString *nsName = nil;
+ if (socketType == QBluetoothServiceInfo::RfcommProtocol) {
+ if (rfcommChannel)
+ nsName = [rfcommChannel peerName];
+ } else if (socketType == QBluetoothServiceInfo::L2capProtocol) {
+ if (l2capChannel)
+ nsName = [l2capChannel peerName];
+ }
+
+ if (nsName)
+ return QString::fromNSString(nsName);
+
+ return QString();
+}
+
+QBluetoothAddress QBluetoothSocketPrivate::peerAddress() const
+{
+ BluetoothDeviceAddress addr = {};
+ if (socketType == QBluetoothServiceInfo::RfcommProtocol) {
+ if (rfcommChannel)
+ addr = [rfcommChannel peerAddress];
+ } else if (socketType == QBluetoothServiceInfo::L2capProtocol) {
+ if (l2capChannel)
+ addr = [l2capChannel peerAddress];
+ }
+
+ return OSXBluetooth::qt_address(&addr);
+}
+
+quint16 QBluetoothSocketPrivate::peerPort() const
+{
+ if (socketType == QBluetoothServiceInfo::RfcommProtocol) {
+ if (rfcommChannel)
+ return [rfcommChannel getChannelID];
+ } else if (socketType == QBluetoothServiceInfo::L2capProtocol) {
+ if (l2capChannel)
+ return [l2capChannel getPSM];
+ }
+
+ return 0;
+}
+
+void QBluetoothSocketPrivate::_q_readNotify()
+{
+ // Noop.
+}
+
+void QBluetoothSocketPrivate::_q_writeNotify()
+{
+ Q_ASSERT_X(socketType == QBluetoothServiceInfo::L2capProtocol
+ || socketType == QBluetoothServiceInfo::RfcommProtocol,
+ Q_FUNC_INFO, "invalid socket type");
+ Q_ASSERT_X(l2capChannel || rfcommChannel, Q_FUNC_INFO,
+ "invalid socket (no open channel)");
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
+
+ if (txBuffer.size()) {
+ const bool isL2CAP = socketType == QBluetoothServiceInfo::L2capProtocol;
+ writeChunk.resize(isL2CAP ? std::numeric_limits<UInt16>::max() :
+ [rfcommChannel getMTU]);
+
+ const int size = txBuffer.read(writeChunk.data(), writeChunk.size());
+ IOReturn status = kIOReturnError;
+ if (!isL2CAP)
+ status = [rfcommChannel writeAsync:writeChunk.data() length:UInt16(size)];
+ else
+ status = [l2capChannel writeAsync:writeChunk.data() length:UInt16(size)];
+
+ if (status != kIOReturnSuccess) {
+ errorString = QCoreApplication::translate(SOCKET, SOC_NETWORK_ERROR);
+ q_ptr->setSocketError(QBluetoothSocket::NetworkError);
+ return;
+ } else {
+ emit q_ptr->bytesWritten(size);
+ }
+ }
+
+ if (!txBuffer.size() && state == QBluetoothSocket::ClosingState)
+ close();
+}
+
+bool QBluetoothSocketPrivate::setChannel(IOBluetoothRFCOMMChannel *channel)
+{
+ // A special case "constructor": on OS X we do not have a real listening socket,
+ // instead a bluetooth server "listens" for channel open notifications and
+ // creates (if asked by a user later) a "socket" object
+ // for this connection. This function initializes
+ // a "socket" from such an external channel (reported by a notification).
+
+ // It must be a newborn socket!
+ Q_ASSERT_X(socketError == QBluetoothSocket::NoSocketError
+ && state == QBluetoothSocket::UnconnectedState && !rfcommChannel && !l2capChannel,
+ Q_FUNC_INFO, "unexpected socket state");
+
+ openMode = QIODevice::ReadWrite;
+ rfcommChannel.reset([[ObjCRFCOMMChannel alloc] initWithDelegate:this channel:channel]);
+ if (rfcommChannel) {// We do not handle errors, up to an external user.
+ q_ptr->setOpenMode(QIODevice::ReadWrite);
+ state = QBluetoothSocket::ConnectedState;
+ socketType = QBluetoothServiceInfo::RfcommProtocol;
+ }
+
+ return rfcommChannel;
+}
+
+bool QBluetoothSocketPrivate::setChannel(IOBluetoothL2CAPChannel *channel)
+{
+ // A special case "constructor": on OS X we do not have a real listening socket,
+ // instead a bluetooth server "listens" for channel open notifications and
+ // creates (if asked by a user later) a "socket" object
+ // for this connection. This function initializes
+ // a "socket" from such an external channel (reported by a notification).
+
+ // It must be a newborn socket!
+ Q_ASSERT_X(socketError == QBluetoothSocket::NoSocketError
+ && state == QBluetoothSocket::UnconnectedState && !l2capChannel && !rfcommChannel,
+ Q_FUNC_INFO, "unexpected socket state");
+
+ openMode = QIODevice::ReadWrite;
+ l2capChannel.reset([[ObjCL2CAPChannel alloc] initWithDelegate:this channel:channel]);
+ if (l2capChannel) {// We do not handle errors, up to an external user.
+ q_ptr->setOpenMode(QIODevice::ReadWrite);
+ state = QBluetoothSocket::ConnectedState;
+ socketType = QBluetoothServiceInfo::L2capProtocol;
+ }
+
+ return l2capChannel;
+}
+
+
+void QBluetoothSocketPrivate::setChannelError(IOReturn errorCode)
+{
+ Q_UNUSED(errorCode)
+
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
+
+ if (isConnecting) {
+ // The delegate's method was called while we are still in
+ // connectToService ... will emit a moment later.
+ socketError = QBluetoothSocket::UnknownSocketError;
+ } else {
+ q_ptr->setSocketError(QBluetoothSocket::UnknownSocketError);
+ }
+}
+
+void QBluetoothSocketPrivate::channelOpenComplete()
+{
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
+
+ if (!isConnecting) {
+ q_ptr->setSocketState(QBluetoothSocket::ConnectedState);
+ q_ptr->setOpenMode(openMode);
+ emit q_ptr->connected();
+ } else {
+ state = QBluetoothSocket::ConnectedState;
+ // We are still in connectToService, it'll care
+ // about signals!
+ }
+}
+
+void QBluetoothSocketPrivate::channelClosed()
+{
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
+
+ // Channel was closed by IOBluetooth and we can not write any data
+ // (thus close/abort probably will not work).
+
+ if (!isConnecting) {
+ q_ptr->setSocketState(QBluetoothSocket::UnconnectedState);
+ q_ptr->setOpenMode(QIODevice::NotOpen);
+ emit q_ptr->disconnected();
+ } else {
+ state = QBluetoothSocket::UnconnectedState;
+ // We are still in connectToService and do not want
+ // to emit any signals yet.
+ }
+}
+
+void QBluetoothSocketPrivate::readChannelData(void *data, std::size_t size)
+{
+ Q_ASSERT_X(data, Q_FUNC_INFO, "invalid data (null)");
+ Q_ASSERT_X(size, Q_FUNC_INFO, "invalid data size (0)");
+ Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)");
+
+ const char *src = static_cast<char *>(data);
+ char *dst = buffer.reserve(size);
+ std::copy(src, src + size, dst);
+
+ if (!isConnecting) {
+ // If we're still in connectToService, do not emit.
+ emit q_ptr->readyRead();
+ } // else connectToService must check and emit readyRead!
+}
+
+void QBluetoothSocketPrivate::writeComplete()
+{
+ _q_writeNotify();
+}
+
+qint64 QBluetoothSocketPrivate::writeData(const char *data, qint64 maxSize)
+{
+ Q_ASSERT_X(data, Q_FUNC_INFO, "invalid data (null)");
+ Q_ASSERT_X(maxSize > 0, Q_FUNC_INFO, "invalid data size");
+
+ if (state != QBluetoothSocket::ConnectedState) {
+ errorString = QCoreApplication::translate(SOCKET, SOC_NOWRITE);
+ q_ptr->setSocketError(QBluetoothSocket::OperationError);
+ return -1;
+ }
+
+ // We do not have a real socket API under the hood,
+ // IOBluetoothL2CAPChannel buffered (writeAsync).
+
+ if (!txBuffer.size())
+ QMetaObject::invokeMethod(this, "_q_writeNotify", Qt::QueuedConnection);
+
+ char *dst = txBuffer.reserve(maxSize);
+ std::copy(data, data + maxSize, dst);
+
+ return maxSize;
+}
+
+QBluetoothSocket::QBluetoothSocket(QBluetoothServiceInfo::Protocol socketType, QObject *parent)
+ : QIODevice(parent),
+ d_ptr(new QBluetoothSocketPrivate)
+{
+ d_ptr->q_ptr = this;
+ d_ptr->socketType = socketType;
+
+ setOpenMode(NotOpen);
+}
+
+QBluetoothSocket::QBluetoothSocket(QObject *parent)
+ : QIODevice(parent),
+ d_ptr(new QBluetoothSocketPrivate)
+{
+ d_ptr->q_ptr = this;
+ setOpenMode(NotOpen);
+}
+
+QBluetoothSocket::~QBluetoothSocket()
+{
+ delete d_ptr;
+}
+
+bool QBluetoothSocket::isSequential() const
+{
+ return true;
+}
+
+qint64 QBluetoothSocket::bytesAvailable() const
+{
+ return QIODevice::bytesAvailable() + d_ptr->bytesAvailable();
+}
+
+qint64 QBluetoothSocket::bytesToWrite() const
+{
+ return d_ptr->txBuffer.size();
+}
+
+void QBluetoothSocket::connectToService(const QBluetoothServiceInfo &service, OpenMode openMode)
+{
+ if (state() != UnconnectedState && state() != ServiceLookupState) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "called on a busy socket";
+ d_ptr->errorString = QCoreApplication::translate(SOCKET, SOC_CONNECT_IN_PROGRESS);
+ setSocketError(OperationError);
+ return;
+ }
+
+ if (service.protocolServiceMultiplexer() > 0) {
+ d_ptr->connectToService(service.device().address(),
+ service.protocolServiceMultiplexer(),
+ openMode);
+ } else if (service.serverChannel() > 0) {
+ d_ptr->connectToService(service.device().address(),
+ service.serverChannel(), openMode);
+ } else {
+ // Try service discovery.
+ if (service.serviceUuid().isNull()) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "No port, "
+ "no PSM, and no UUID provided, unable to connect";
+ return;
+ }
+
+ doDeviceDiscovery(service, openMode);
+ }
+}
+
+void QBluetoothSocket::connectToService(const QBluetoothAddress &address, const QBluetoothUuid &uuid,
+ OpenMode openMode)
+{
+ if (state() != QBluetoothSocket::UnconnectedState) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "called on a busy socket";
+ d_ptr->errorString = QCoreApplication::translate(SOCKET, SOC_CONNECT_IN_PROGRESS);
+ setSocketError(QBluetoothSocket::OperationError);
+ return;
+ }
+
+ QBluetoothDeviceInfo device(address, QString(), QBluetoothDeviceInfo::MiscellaneousDevice);
+ QBluetoothServiceInfo service;
+ service.setDevice(device);
+ service.setServiceUuid(uuid);
+ doDeviceDiscovery(service, openMode);
+}
+
+void QBluetoothSocket::connectToService(const QBluetoothAddress &address, quint16 port,
+ OpenMode openMode)
+{
+ if (state() != QBluetoothSocket::UnconnectedState) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "called on a busy socket";
+ d_ptr->errorString = QCoreApplication::translate(SOCKET, SOC_CONNECT_IN_PROGRESS);
+ setSocketError(OperationError);
+ return;
+ }
+
+ setOpenMode(openMode);
+ d_ptr->connectToService(address, port, openMode);
+}
+
+QBluetoothServiceInfo::Protocol QBluetoothSocket::socketType() const
+{
+ return d_ptr->socketType;
+}
+
+QBluetoothSocket::SocketState QBluetoothSocket::state() const
+{
+ return d_ptr->state;
+}
+
+QBluetoothSocket::SocketError QBluetoothSocket::error() const
+{
+ return d_ptr->socketError;
+}
+
+QString QBluetoothSocket::errorString() const
+{
+ return d_ptr->errorString;
+}
+
+void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+{
+ const SocketState oldState = d_ptr->state;
+ d_ptr->state = state;
+ if (oldState != d_ptr->state)
+ emit stateChanged(state);
+
+ if (state == ListeningState) {
+ // We can register for L2CAP/RFCOMM open notifications,
+ // that's different from 'listen' and is implemented
+ // in QBluetoothServer.
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "listening sockets are not supported";
+ }
+}
+
+bool QBluetoothSocket::canReadLine() const
+{
+ return d_ptr->buffer.canReadLine() || QIODevice::canReadLine();
+}
+
+void QBluetoothSocket::setSocketError(QBluetoothSocket::SocketError socketError)
+{
+ d_ptr->socketError = socketError;
+ emit error(socketError);
+}
+
+void QBluetoothSocket::doDeviceDiscovery(const QBluetoothServiceInfo &service, OpenMode openMode)
+{
+ setSocketState(ServiceLookupState);
+
+ if (d_ptr->discoveryAgent)
+ d_ptr->discoveryAgent->stop();
+
+ d_ptr->discoveryAgent.reset(new QBluetoothServiceDiscoveryAgent(this));
+ d_ptr->discoveryAgent->setRemoteAddress(service.device().address());
+
+ connect(d_ptr->discoveryAgent.data(), SIGNAL(serviceDiscovered(QBluetoothServiceInfo)),
+ this, SLOT(serviceDiscovered(QBluetoothServiceInfo)));
+ connect(d_ptr->discoveryAgent.data(), SIGNAL(finished()),
+ this, SLOT(discoveryFinished()));
+
+ d_ptr->openMode = openMode;
+
+ if (!service.serviceUuid().isNull())
+ d_ptr->discoveryAgent->setUuidFilter(service.serviceUuid());
+
+ if (!service.serviceClassUuids().isEmpty())
+ d_ptr->discoveryAgent->setUuidFilter(service.serviceClassUuids());
+
+ Q_ASSERT_X(!d_ptr->discoveryAgent->uuidFilter().isEmpty(), Q_FUNC_INFO,
+ "invalid service info");
+
+ d_ptr->discoveryAgent->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+}
+
+void QBluetoothSocket::serviceDiscovered(const QBluetoothServiceInfo &service)
+{
+ if (service.protocolServiceMultiplexer() != 0 || service.serverChannel() != 0) {
+ d_ptr->discoveryAgent->stop();
+ connectToService(service, d_ptr->openMode);
+ }
+}
+
+void QBluetoothSocket::discoveryFinished()
+{
+ d_ptr->errorString = QCoreApplication::translate(SOCKET, SOC_SERVICE_NOT_FOUND);
+ setSocketState(UnconnectedState);
+ setSocketError(ServiceNotFoundError);
+}
+
+void QBluetoothSocket::abort()
+{
+ if (state() == UnconnectedState)
+ return;
+
+ setOpenMode(NotOpen);
+
+ if (state() == ServiceLookupState && d_ptr->discoveryAgent) {
+ d_ptr->discoveryAgent->disconnect();
+ d_ptr->discoveryAgent->stop();
+ d_ptr->discoveryAgent.reset();
+ }
+
+ setSocketState(QBluetoothSocket::ClosingState);
+ d_ptr->abort();
+
+ setSocketState(QBluetoothSocket::UnconnectedState);
+ emit disconnected();
+}
+
+void QBluetoothSocket::disconnectFromService()
+{
+ close();
+}
+
+QString QBluetoothSocket::localName() const
+{
+ const QBluetoothLocalDevice device;
+ return device.name();
+}
+
+QBluetoothAddress QBluetoothSocket::localAddress() const
+{
+ const QBluetoothLocalDevice device;
+ return device.address();
+}
+
+quint16 QBluetoothSocket::localPort() const
+{
+ return 0;
+}
+
+QString QBluetoothSocket::peerName() const
+{
+ return d_ptr->peerName();
+}
+
+QBluetoothAddress QBluetoothSocket::peerAddress() const
+{
+ return d_ptr->peerAddress();
+}
+
+quint16 QBluetoothSocket::peerPort() const
+{
+ return d_ptr->peerPort();
+}
+
+qint64 QBluetoothSocket::writeData(const char *data, qint64 maxSize)
+{
+ if (!data || maxSize <= 0) {
+ d_ptr->errorString = QCoreApplication::translate(SOCKET, SOC_INVAL_DATASIZE);
+ setSocketError(QBluetoothSocket::OperationError);
+ return -1;
+ }
+
+ return d_ptr->writeData(data, maxSize);
+}
+
+qint64 QBluetoothSocketPrivate::readData(char *data, qint64 maxSize)
+{
+ if (state != QBluetoothSocket::ConnectedState) {
+ errorString = QCoreApplication::translate(SOCKET, SOC_NOREAD);
+ q_ptr->setSocketError(QBluetoothSocket::OperationError);
+ return -1;
+ }
+
+ if (!buffer.isEmpty())
+ return buffer.read(data, maxSize);
+
+ return 0;
+}
+
+qint64 QBluetoothSocket::readData(char *data, qint64 maxSize)
+{
+ return d_ptr->readData(data, maxSize);
+}
+
+void QBluetoothSocket::close()
+{
+ if (state() == UnconnectedState)
+ return;
+
+ setOpenMode(NotOpen);
+
+ if (state() == ServiceLookupState && d_ptr->discoveryAgent) {
+ d_ptr->discoveryAgent->disconnect();
+ d_ptr->discoveryAgent->stop();
+ d_ptr->discoveryAgent.reset();
+ }
+
+ setSocketState(ClosingState);
+
+ d_ptr->close();
+
+ setSocketState(UnconnectedState);
+ emit disconnected();
+}
+
+bool QBluetoothSocket::setSocketDescriptor(int socketDescriptor, QBluetoothServiceInfo::Protocol socketType,
+ SocketState socketState, OpenMode openMode)
+{
+ Q_UNUSED(socketDescriptor)
+ Q_UNUSED(socketType)
+ Q_UNUSED(socketState)
+ Q_UNUSED(openMode)
+
+ // Noop on OS X.
+ return true;
+}
+
+int QBluetoothSocket::socketDescriptor() const
+{
+ return -1;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+
+QDebug operator<<(QDebug debug, QBluetoothSocket::SocketError error)
+{
+ switch (error) {
+ case QBluetoothSocket::UnknownSocketError:
+ debug << "QBluetoothSocket::UnknownSocketError";
+ break;
+ case QBluetoothSocket::HostNotFoundError:
+ debug << "QBluetoothSocket::HostNotFoundError";
+ break;
+ case QBluetoothSocket::ServiceNotFoundError:
+ debug << "QBluetoothSocket::ServiceNotFoundError";
+ break;
+ case QBluetoothSocket::NetworkError:
+ debug << "QBluetoothSocket::NetworkError";
+ break;
+ default:
+ debug << "QBluetoothSocket::SocketError(" << (int)error << ")";
+ }
+ return debug;
+}
+
+QDebug operator<<(QDebug debug, QBluetoothSocket::SocketState state)
+{
+ switch (state) {
+ case QBluetoothSocket::UnconnectedState:
+ debug << "QBluetoothSocket::UnconnectedState";
+ break;
+ case QBluetoothSocket::ConnectingState:
+ debug << "QBluetoothSocket::ConnectingState";
+ break;
+ case QBluetoothSocket::ConnectedState:
+ debug << "QBluetoothSocket::ConnectedState";
+ break;
+ case QBluetoothSocket::BoundState:
+ debug << "QBluetoothSocket::BoundState";
+ break;
+ case QBluetoothSocket::ClosingState:
+ debug << "QBluetoothSocket::ClosingState";
+ break;
+ case QBluetoothSocket::ListeningState:
+ debug << "QBluetoothSocket::ListeningState";
+ break;
+ case QBluetoothSocket::ServiceLookupState:
+ debug << "QBluetoothSocket::ServiceLookupState";
+ break;
+ default:
+ debug << "QBluetoothSocket::SocketState(" << (int)state << ")";
+ }
+ return debug;
+}
+
+#endif // QT_NO_DEBUG_STREAM
+
+#include "moc_qbluetoothsocket.cpp"
+
+QT_END_NAMESPACE
diff --git a/src/bluetooth/qbluetoothsocket_osx_p.h b/src/bluetooth/qbluetoothsocket_osx_p.h
new file mode 100644
index 00000000..8507620a
--- /dev/null
+++ b/src/bluetooth/qbluetoothsocket_osx_p.h
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBLUETOOTHSOCKET_OSX_P_H
+#define QBLUETOOTHSOCKET_OSX_P_H
+
+#ifdef QT_OSX_BLUETOOTH
+
+#include "osx/osxbtchanneldelegate_p.h"
+#include "osx/osxbtrfcommchannel_p.h"
+#include "osx/osxbtl2capchannel_p.h"
+#include "qbluetoothserviceinfo.h"
+#include "osx/osxbtutility_p.h"
+#include "qbluetoothsocket.h"
+
+#ifndef QPRIVATELINEARBUFFER_BUFFERSIZE
+#define QPRIVATELINEARBUFFER_BUFFERSIZE Q_INT64_C(16384)
+#endif
+// The order is important: bytearray before buffer:
+#include <QtCore/qbytearray.h>
+#include "qprivatelinearbuffer_p.h"
+
+#include <QtCore/qscopedpointer.h>
+#include <QtCore/qiodevice.h>
+#include <QtCore/qglobal.h>
+#include <QtCore/qobject.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qvector.h>
+
+@class IOBluetoothRFCOMMChannel;
+@class IOBluetoothL2CAPChannel;
+
+QT_BEGIN_NAMESPACE
+
+class QBluetoothServiceDiscoveryAgent;
+class QBluetoothAddress;
+
+class QBluetoothSocketPrivate : public QBluetoothSocketPrivateBase, public OSXBluetooth::ChannelDelegate
+{
+ friend class QBluetoothSocket;
+ friend class QBluetoothServer;
+
+public:
+ QBluetoothSocketPrivate();
+ ~QBluetoothSocketPrivate();
+
+ void connectToService(const QBluetoothAddress &address, quint16 port,
+ QIODevice::OpenMode openMode);
+
+ void close();
+ void abort();
+
+ quint64 bytesAvailable() const;
+
+ QString peerName() const;
+ QBluetoothAddress peerAddress() const;
+ quint16 peerPort() const;
+
+ void _q_readNotify();
+ void _q_writeNotify();
+
+private:
+ // Create a socket from an external source (without connectToService).
+ bool setChannel(IOBluetoothRFCOMMChannel *channel);
+ bool setChannel(IOBluetoothL2CAPChannel *channel);
+
+ // L2CAP and RFCOMM delegate
+ void setChannelError(IOReturn errorCode) Q_DECL_OVERRIDE;
+ void channelOpenComplete() Q_DECL_OVERRIDE;
+ void channelClosed() Q_DECL_OVERRIDE;
+ void readChannelData(void *data, std::size_t size) Q_DECL_OVERRIDE;
+ void writeComplete() Q_DECL_OVERRIDE;
+
+ qint64 writeData(const char *data, qint64 maxSize);
+ qint64 readData(char *data, qint64 maxSize);
+
+ QBluetoothSocket *q_ptr;
+
+ QScopedPointer<QBluetoothServiceDiscoveryAgent> discoveryAgent;
+
+ QPrivateLinearBuffer buffer;
+ QPrivateLinearBuffer txBuffer;
+ QVector<char> writeChunk;
+
+ // Probably, not needed.
+ QIODevice::OpenMode openMode;
+
+ QBluetoothSocket::SocketState state;
+ QBluetoothServiceInfo::Protocol socketType;
+
+ QBluetoothSocket::SocketError socketError;
+ QString errorString;
+
+ typedef QT_MANGLE_NAMESPACE(OSXBTL2CAPChannel) ObjCL2CAPChannel;
+ typedef OSXBluetooth::ObjCScopedPointer<ObjCL2CAPChannel> L2CAPChannel;
+ L2CAPChannel l2capChannel;
+
+ typedef QT_MANGLE_NAMESPACE(OSXBTRFCOMMChannel) ObjCRFCOMMChannel;
+ typedef OSXBluetooth::ObjCScopedPointer<ObjCRFCOMMChannel> RFCOMMChannel;
+ RFCOMMChannel rfcommChannel;
+ // A trick to deal with channel open too fast (synchronously).
+ bool isConnecting;
+};
+
+QT_END_NAMESPACE
+
+#endif
+
+#endif
diff --git a/src/bluetooth/qbluetoothsocket_p.cpp b/src/bluetooth/qbluetoothsocket_p.cpp
index 85b730dd..e18c985b 100644
--- a/src/bluetooth/qbluetoothsocket_p.cpp
+++ b/src/bluetooth/qbluetoothsocket_p.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothsocket_p.h b/src/bluetooth/qbluetoothsocket_p.h
index dc490f26..e5ddf798 100644
--- a/src/bluetooth/qbluetoothsocket_p.h
+++ b/src/bluetooth/qbluetoothsocket_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -83,6 +83,7 @@ public:
class QBluetoothSocket;
class QBluetoothServiceDiscoveryAgent;
+#ifndef QT_OSX_BLUETOOTH
class QBluetoothSocketPrivate : public QObject
{
Q_OBJECT
@@ -204,6 +205,21 @@ public:
#endif
};
+#else // QT_OSX_BLUETOOTH
+
+// QBluetoothSocketPrivate on OS X can not contain
+// Q_OBJECT (moc does not parse Objective-C syntax).
+// But QBluetoothSocket still requires QMetaObject::invokeMethod
+// to work. Here's the trick:
+class QBluetoothSocketPrivateBase : public QObject
+{
+// The most important part of it:
+ Q_OBJECT
+public slots:
+ virtual void _q_writeNotify() = 0;
+};
+
+#endif // QT_OSX_BLUETOOTH
static inline void convertAddress(quint64 from, quint8 (&to)[6])
{
@@ -227,4 +243,5 @@ static inline void convertAddress(quint8 (&from)[6], quint64 &to)
QT_END_NAMESPACE
+
#endif
diff --git a/src/bluetooth/qbluetoothsocket_qnx.cpp b/src/bluetooth/qbluetoothsocket_qnx.cpp
index 0d698ee5..125a5595 100644
--- a/src/bluetooth/qbluetoothsocket_qnx.cpp
+++ b/src/bluetooth/qbluetoothsocket_qnx.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2012 Research In Motion
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothtransfermanager.cpp b/src/bluetooth/qbluetoothtransfermanager.cpp
index 56e59f48..4c40fe72 100644
--- a/src/bluetooth/qbluetoothtransfermanager.cpp
+++ b/src/bluetooth/qbluetoothtransfermanager.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -38,7 +38,8 @@
#include "qbluetoothtransferreply_bluez_p.h"
#elif QT_QNX_BLUETOOTH
#include "qbluetoothtransferreply_qnx_p.h"
-#else
+#elif QT_OSX_BLUETOOTH
+#include "qbluetoothtransferreply_osx_p.h"
#endif
QT_BEGIN_NAMESPACE
@@ -89,6 +90,8 @@ QT_BEGIN_NAMESPACE
QBluetoothTransferManager::QBluetoothTransferManager(QObject *parent)
: QObject(parent)
{
+ qRegisterMetaType<QBluetoothTransferReply*>();
+ qRegisterMetaType<QBluetoothTransferReply::TransferError>();
}
/*!
@@ -109,6 +112,10 @@ QBluetoothTransferReply *QBluetoothTransferManager::put(const QBluetoothTransfer
QBluetoothTransferReplyQnx *reply = new QBluetoothTransferReplyQnx(data, request, this);
connect(reply, SIGNAL(finished(QBluetoothTransferReply*)), this, SIGNAL(finished(QBluetoothTransferReply*)));
return reply;
+#elif QT_OSX_BLUETOOTH
+ QBluetoothTransferReply *reply = new QBluetoothTransferReplyOSX(data, request, this);
+ connect(reply, SIGNAL(finished(QBluetoothTransferReply*)), this, SIGNAL(finished(QBluetoothTransferReply*)));
+ return reply;
#else
Q_UNUSED(request);
Q_UNUSED(data);
diff --git a/src/bluetooth/qbluetoothtransfermanager.h b/src/bluetooth/qbluetoothtransfermanager.h
index f252f975..6d6b0318 100644
--- a/src/bluetooth/qbluetoothtransfermanager.h
+++ b/src/bluetooth/qbluetoothtransfermanager.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothtransferreply.cpp b/src/bluetooth/qbluetoothtransferreply.cpp
index af1bf828..e0d30a60 100644
--- a/src/bluetooth/qbluetoothtransferreply.cpp
+++ b/src/bluetooth/qbluetoothtransferreply.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -118,8 +118,6 @@ void QBluetoothTransferReply::abort()
QBluetoothTransferReply::QBluetoothTransferReply(QObject *parent)
: QObject(parent), d_ptr(new QBluetoothTransferReplyPrivate())
{
- qRegisterMetaType<QBluetoothTransferReply*>();
- qRegisterMetaType<QBluetoothTransferReply::TransferError>();
}
/*!
diff --git a/src/bluetooth/qbluetoothtransferreply.h b/src/bluetooth/qbluetoothtransferreply.h
index 37ca8fe5..081b7002 100644
--- a/src/bluetooth/qbluetoothtransferreply.h
+++ b/src/bluetooth/qbluetoothtransferreply.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothtransferreply_bluez.cpp b/src/bluetooth/qbluetoothtransferreply_bluez.cpp
index 43a83d71..f7f72873 100644
--- a/src/bluetooth/qbluetoothtransferreply_bluez.cpp
+++ b/src/bluetooth/qbluetoothtransferreply_bluez.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -123,7 +123,7 @@ bool QBluetoothTransferReplyBluez::start()
m_tempfile->open();
qCDebug(QT_BT_BLUEZ) << "Not a QFile, making a copy" << m_tempfile->fileName();
if (!m_source->isReadable()) {
- m_errorStr = QBluetoothTransferReply::tr("QIODevice cannot be read."
+ m_errorStr = QBluetoothTransferReply::tr("QIODevice cannot be read. "
"Make sure it is open for reading.");
m_error = QBluetoothTransferReply::IODeviceNotReadableError;
m_finished = true;
@@ -385,7 +385,7 @@ void QBluetoothTransferReplyBluez::Error(const QDBusObjectPath &in0, const QStri
m_errorStr = tr("Could not open file for sending");
} else if (in1 == QStringLiteral("Operation canceled")) {
m_error = QBluetoothTransferReply::UserCanceledTransferError;
- m_errorStr = tr("Operation canceled");
+ m_errorStr = QBluetoothTransferReply::tr("Operation canceled");
} else {
m_error = QBluetoothTransferReply::UnknownError;
}
diff --git a/src/bluetooth/qbluetoothtransferreply_bluez_p.h b/src/bluetooth/qbluetoothtransferreply_bluez_p.h
index 0a9f9bca..2fd7633e 100644
--- a/src/bluetooth/qbluetoothtransferreply_bluez_p.h
+++ b/src/bluetooth/qbluetoothtransferreply_bluez_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothtransferreply_osx.mm b/src/bluetooth/qbluetoothtransferreply_osx.mm
new file mode 100644
index 00000000..1b84626b
--- /dev/null
+++ b/src/bluetooth/qbluetoothtransferreply_osx.mm
@@ -0,0 +1,470 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbluetoothservicediscoveryagent.h"
+#include "qbluetoothtransferreply_osx_p.h"
+#include "osx/osxbtobexsession_p.h"
+#include "qbluetoothserviceinfo.h"
+#include "osx/osxbtutility_p.h"
+#include "osx/uistrings_p.h"
+#include "qbluetoothuuid.h"
+
+
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qloggingcategory.h>
+#include <QtCore/qtemporaryfile.h>
+#include <QtCore/qmetaobject.h>
+#include <QtCore/qfileinfo.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qfile.h>
+#include <QtCore/qdir.h>
+
+QT_BEGIN_NAMESPACE
+
+class QBluetoothTransferReplyOSXPrivate : OSXBluetooth::OBEXSessionDelegate
+{
+ friend class QBluetoothTransferReplyOSX;
+public:
+ QBluetoothTransferReplyOSXPrivate(QBluetoothTransferReplyOSX *q, QIODevice *inputStream);
+
+ ~QBluetoothTransferReplyOSXPrivate();
+
+ bool isActive() const;
+ bool startOPP(const QBluetoothAddress &device);
+
+ //
+ void sendConnect(const QBluetoothAddress &device, quint16 channelID);
+ void sendPut();
+
+private:
+ // OBEX session delegate:
+ void OBEXConnectError(OBEXError errorCode, OBEXOpCode response) Q_DECL_OVERRIDE;
+ void OBEXConnectSuccess() Q_DECL_OVERRIDE;
+
+ void OBEXAbortSuccess() Q_DECL_OVERRIDE;
+
+ void OBEXPutDataSent(quint32 current, quint32 total) Q_DECL_OVERRIDE;
+ void OBEXPutSuccess() Q_DECL_OVERRIDE;
+ void OBEXPutError(OBEXError error, OBEXOpCode response) Q_DECL_OVERRIDE;
+
+ QBluetoothTransferReplyOSX *q_ptr;
+
+ QIODevice *inputStream;
+
+ QBluetoothTransferReply::TransferError error;
+ QString errorString;
+
+ // Set requestComplete, error, description, emit error, emit finished.
+ // Too many things in one, but not to repeat this code everywhere.
+ void setReplyError(QBluetoothTransferReply::TransferError errorCode,
+ const QString &errorMessage);
+
+ // With a given API, we have to discover a service first
+ // since we need a channel ID to work with OBEX session.
+ // Also, service discovery agent does not have an interface
+ // to test discovery mode, that's why we have this bool here.
+ bool minimalScan;
+ QScopedPointer<QBluetoothServiceDiscoveryAgent> agent;
+
+ // The next step is to create an OBEX session:
+ typedef OSXBluetooth::ObjCScopedPointer<ObjCOBEXSession> OBEXSession;
+ OBEXSession session;
+
+ // Both success and failure to send - transfer is complete.
+ bool requestComplete;
+
+ // We need a temporary file to generate an unique name
+ // in case inputStream is not a file. QTemporaryFile not
+ // only creates a random name, it also guarantees this name
+ // is unique. The amount of code to generate such a name
+ // is amaizingly huge (and will require global variables)
+ // - so a temporary file can help.
+ QScopedPointer<QTemporaryFile> temporaryFile;
+};
+
+QBluetoothTransferReplyOSXPrivate::QBluetoothTransferReplyOSXPrivate(QBluetoothTransferReplyOSX *q,
+ QIODevice *input)
+ : q_ptr(q),
+ inputStream(input),
+ error(QBluetoothTransferReply::NoError),
+ minimalScan(true),
+ requestComplete(false)
+{
+ Q_ASSERT_X(q, Q_FUNC_INFO, "invalid q_ptr (null)");
+}
+
+QBluetoothTransferReplyOSXPrivate::~QBluetoothTransferReplyOSXPrivate()
+{
+ // closeSession will set a delegate to null.
+ // The OBEX session will be closed then. If
+ // somehow IOBluetooth/OBEX still has a reference to our
+ // session, it will not call any of delegate's callbacks.
+ if (session)
+ [session closeSession];
+}
+
+bool QBluetoothTransferReplyOSXPrivate::isActive() const
+{
+ return agent || (session && [session hasActiveRequest]);
+}
+
+bool QBluetoothTransferReplyOSXPrivate::startOPP(const QBluetoothAddress &device)
+{
+ Q_ASSERT_X(!isActive(), Q_FUNC_INFO, "already started");
+ Q_ASSERT_X(!device.isNull(), Q_FUNC_INFO, "invalid device address");
+
+ errorString.clear();
+ error = QBluetoothTransferReply::NoError;
+
+ agent.reset(new QBluetoothServiceDiscoveryAgent);
+
+ agent->setRemoteAddress(device);
+ agent->setUuidFilter(QBluetoothUuid(QBluetoothUuid::ObexObjectPush));
+
+ QObject::connect(agent.data(), SIGNAL(finished()), q_ptr, SLOT(serviceDiscoveryFinished()));
+ QObject::connect(agent.data(), SIGNAL(error(QBluetoothServiceDiscoveryAgent::Error)),
+ q_ptr, SLOT(serviceDiscoveryError(QBluetoothServiceDiscoveryAgent::Error)));
+
+ minimalScan = true;
+ agent->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
+
+ // We probably failed already.
+ return error == QBluetoothTransferReply::NoError;
+}
+
+void QBluetoothTransferReplyOSXPrivate::sendConnect(const QBluetoothAddress &device, quint16 channelID)
+{
+ Q_ASSERT_X(!session, Q_FUNC_INFO, "session is already active");
+
+ error = QBluetoothTransferReply::NoError;
+ errorString.clear();
+
+ if (device.isNull() || !channelID) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid device address or port";
+ setReplyError(QBluetoothTransferReply::HostNotFoundError,
+ QCoreApplication::translate(TRANSFER_REPLY, TR_INVAL_TARGET));
+ return;
+ }
+
+ OBEXSession newSession([[ObjCOBEXSession alloc] initWithDelegate:this
+ remoteDevice:device channelID:channelID]);
+ if (!newSession) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "failed to allocate OSXBTOBEXSession object";
+
+ setReplyError(QBluetoothTransferReply::UnknownError,
+ QCoreApplication::translate(TRANSFER_REPLY, TR_SESSION_NO_START));
+ return;
+ }
+
+ const OBEXError status = [newSession OBEXConnect];
+
+ if ((status == kOBEXSuccess || status == kOBEXSessionAlreadyConnectedError)
+ && error == QBluetoothTransferReply::NoError) {
+ session.reset(newSession.take());
+ if ([session isConnected])
+ sendPut();// Connected, send a PUT request.
+ } else {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "OBEXConnect failed";
+
+ if (error == QBluetoothTransferReply::NoError) {
+ // The error is not set yet.
+ error = QBluetoothTransferReply::SessionError;
+ errorString = QCoreApplication::translate(TRANSFER_REPLY, TR_CONNECT_FAILED);
+ }
+
+ requestComplete = true;
+ emit q_ptr->error(error);
+ emit q_ptr->finished(q_ptr);
+ }
+}
+
+void QBluetoothTransferReplyOSXPrivate::sendPut()
+{
+ Q_ASSERT_X(inputStream, Q_FUNC_INFO, "invalid input stream (null)");
+ Q_ASSERT_X(session, Q_FUNC_INFO, "invalid OBEX session (nil)");
+ Q_ASSERT_X([session isConnected], Q_FUNC_INFO, "not connected");
+ Q_ASSERT_X(![session hasActiveRequest], Q_FUNC_INFO,
+ "session already has an active request");
+
+ QString fileName;
+ QFile *const file = qobject_cast<QFile *>(inputStream);
+ if (file) {
+ if (!file->exists()) {
+ setReplyError(QBluetoothTransferReply::FileNotFoundError,
+ QCoreApplication::translate(TRANSFER_REPLY, TR_FILE_NOT_EXIST));
+ return;
+ } else if (!file->isReadable()) {
+ file->open(QIODevice::ReadOnly);
+ if (!file->isReadable()) {
+ setReplyError(QBluetoothTransferReply::IODeviceNotReadableError,
+ QCoreApplication::translate(TRANSFER_REPLY, TR_NOT_READ_IODEVICE));
+ return;
+ }
+ }
+
+ fileName = file->fileName();
+ } else {
+ if (!inputStream->isReadable()) {
+ setReplyError(QBluetoothTransferReply::IODeviceNotReadableError,
+ QCoreApplication::translate(TRANSFER_REPLY, TR_NOT_READ_IODEVICE));
+ return;
+ }
+
+ temporaryFile.reset(new QTemporaryFile);
+ temporaryFile->open();
+ fileName = temporaryFile->fileName();
+ }
+
+ const QFileInfo fileInfo(fileName);
+ fileName = fileInfo.fileName();
+
+ if ([session OBEXPutFile:inputStream withName:fileName] != kOBEXSuccess) {
+ // TODO: convert OBEXError into something reasonable?
+ setReplyError(QBluetoothTransferReply::SessionError,
+ QCoreApplication::translate(TRANSFER_REPLY, TR_SESSION_FAILED));
+ }
+}
+
+
+void QBluetoothTransferReplyOSXPrivate::OBEXConnectError(OBEXError errorCode, OBEXOpCode response)
+{
+ Q_UNUSED(errorCode)
+ Q_UNUSED(response)
+
+ if (session) {
+ setReplyError(QBluetoothTransferReply::SessionError,
+ QCoreApplication::translate(TRANSFER_REPLY, TR_CONNECT_FAILED));
+ } else {
+ // Else we're still in OBEXConnect, in a call-back
+ // and do not want to emit yet (will be done a bit later).
+ error = QBluetoothTransferReply::SessionError;
+ errorString = QCoreApplication::translate(TRANSFER_REPLY, TR_CONNECT_FAILED);
+ requestComplete = true;
+ }
+}
+
+void QBluetoothTransferReplyOSXPrivate::OBEXConnectSuccess()
+{
+ // Now that OBEX connect succeeded, we can send an OBEX put request.
+ if (!session) {
+ // We're still in OBEXConnect(), it'll take care of next steps.
+ return;
+ }
+
+ sendPut();
+}
+
+void QBluetoothTransferReplyOSXPrivate::OBEXAbortSuccess()
+{
+ // TODO:
+}
+
+void QBluetoothTransferReplyOSXPrivate::OBEXPutDataSent(quint32 current, quint32 total)
+{
+ emit q_ptr->transferProgress(current, total);
+}
+
+void QBluetoothTransferReplyOSXPrivate::OBEXPutSuccess()
+{
+ requestComplete = true;
+ emit q_ptr->finished(q_ptr);
+}
+
+void QBluetoothTransferReplyOSXPrivate::OBEXPutError(OBEXError errorCode, OBEXOpCode responseCode)
+{
+ // Error can be reported by errorCode or responseCode
+ // (that's how errors are reported in OBEXSession events).
+ // errorCode and responseCode are "mutually exclusive".
+
+ Q_UNUSED(responseCode)
+
+ if (errorCode != kOBEXSuccess) {
+ // TODO: errorCode -> TransferError.
+ } else {
+ // TODO: a response code can give some interesting information,
+ // like "forbidden" etc. - convert this into more reasonable error.
+ }
+
+ setReplyError(QBluetoothTransferReply::SessionError,
+ QCoreApplication::translate(TRANSFER_REPLY, TR_SESSION_FAILED));
+}
+
+void QBluetoothTransferReplyOSXPrivate::setReplyError(QBluetoothTransferReply::TransferError errorCode,
+ const QString &description)
+{
+ // Not to be used to clear an error!
+
+ error = errorCode;
+ errorString = description;
+ requestComplete = true;
+ emit q_ptr->error(error);
+ emit q_ptr->finished(q_ptr);
+}
+
+
+QBluetoothTransferReplyOSX::QBluetoothTransferReplyOSX(QIODevice *input,
+ const QBluetoothTransferRequest &request,
+ QBluetoothTransferManager *manager)
+ : QBluetoothTransferReply(manager)
+
+{
+ Q_UNUSED(input)
+
+ setManager(manager);
+ setRequest(request);
+
+ osx_d_ptr.reset(new QBluetoothTransferReplyOSXPrivate(this, input));
+
+ if (input) {
+ QMetaObject::invokeMethod(this, "start", Qt::QueuedConnection);
+ } else {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid input stream (null)";
+ osx_d_ptr->requestComplete = true;
+ osx_d_ptr->errorString = QCoreApplication::translate(TRANSFER_REPLY, TR_INVALID_DEVICE);
+ osx_d_ptr->error = FileNotFoundError;
+ QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
+ Q_ARG(QBluetoothTransferReply::TransferError, FileNotFoundError));
+ }
+}
+
+QBluetoothTransferReplyOSX::~QBluetoothTransferReplyOSX()
+{
+ // A dtor to make a scoped pointer with incomplete type happy.
+}
+
+QBluetoothTransferReply::TransferError QBluetoothTransferReplyOSX::error() const
+{
+ return osx_d_ptr->error;
+}
+
+QString QBluetoothTransferReplyOSX::errorString() const
+{
+ return osx_d_ptr->errorString;
+}
+
+bool QBluetoothTransferReplyOSX::isFinished() const
+{
+ return osx_d_ptr->requestComplete;
+}
+
+bool QBluetoothTransferReplyOSX::isRunning() const
+{
+ return osx_d_ptr->isActive();
+}
+
+bool QBluetoothTransferReplyOSX::abort()
+{
+ // Reset a delegate.
+ [osx_d_ptr->session closeSession];
+ // Should never be called from an OBEX callback!
+ osx_d_ptr->session.reset(Q_NULLPTR);
+
+ // Not setReplyError, we emit finished only!
+ osx_d_ptr->requestComplete = true;
+ osx_d_ptr->errorString = QCoreApplication::translate(TRANSFER_REPLY, TR_OP_CANCEL);
+ osx_d_ptr->error = UserCanceledTransferError;
+
+ emit finished(this);
+
+ return true;
+}
+
+bool QBluetoothTransferReplyOSX::start()
+{
+ // OBEXSession requires a channel ID and we have to find it first,
+ // using QBluetoothServiceDiscoveryAgent (singleDevice, OBEX uuid filter, start
+ // from MinimalDiscovery mode and continue with FullDiscovery if
+ // MinimalDiscovery fails.
+
+ if (!osx_d_ptr->isActive()) {
+ // Step 0: find a channelID.
+ if (request().address().isNull()) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "invalid device address";
+ osx_d_ptr->setReplyError(HostNotFoundError,
+ QCoreApplication::translate(TRANSFER_REPLY, TR_INVAL_TARGET));
+ return false;
+ }
+
+ return osx_d_ptr->startOPP(request().address());
+ } else {
+ osx_d_ptr->setReplyError(UnknownError,
+ QCoreApplication::translate(TRANSFER_REPLY, TR_IN_PROGRESS));
+ return false;
+ }
+}
+
+void QBluetoothTransferReplyOSX::serviceDiscoveryFinished()
+{
+ Q_ASSERT_X(osx_d_ptr->agent.data(), Q_FUNC_INFO,
+ "invalid service discovery agent (null)");
+
+ const QList<QBluetoothServiceInfo> services = osx_d_ptr->agent->discoveredServices();
+ if (services.size()) {
+ // TODO: what if we have several?
+ const QBluetoothServiceInfo &foundOBEX = services.front();
+ osx_d_ptr->sendConnect(request().address(), foundOBEX.serverChannel());
+ } else {
+ if (osx_d_ptr->minimalScan) {
+ // Try full discovery now.
+ osx_d_ptr->minimalScan = false;
+ osx_d_ptr->agent->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ } else {
+ // No service record, no channel ID, no OBEX session.
+ osx_d_ptr->setReplyError(HostNotFoundError,
+ QCoreApplication::translate(TRANSFER_REPLY, TR_SERVICE_NO_FOUND));
+ }
+ }
+}
+
+void QBluetoothTransferReplyOSX::serviceDiscoveryError(QBluetoothServiceDiscoveryAgent::Error errorCode)
+{
+ Q_ASSERT_X(osx_d_ptr->agent.data(), Q_FUNC_INFO, "invalid service discovery agent (null)");
+
+ if (errorCode == QBluetoothServiceDiscoveryAgent::PoweredOffError) {
+ // There's nothing else we can do.
+ osx_d_ptr->setReplyError(UnknownError,
+ QCoreApplication::translate(DEV_DISCOVERY, DD_POWERED_OFF));
+ return;
+ }
+
+ if (osx_d_ptr->minimalScan) {// Try again, this time in FullDiscovery mode.
+ osx_d_ptr->minimalScan = false;
+ osx_d_ptr->agent->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ } else {
+ osx_d_ptr->setReplyError(HostNotFoundError,
+ QCoreApplication::translate(TRANSFER_REPLY, TR_INVAL_TARGET));
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/bluetooth/qbluetoothtransferreply_osx_p.h b/src/bluetooth/qbluetoothtransferreply_osx_p.h
new file mode 100644
index 00000000..74c1630e
--- /dev/null
+++ b/src/bluetooth/qbluetoothtransferreply_osx_p.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBLUETOOTHTRANSFERREPLY_OSX_P_H
+#define QBLUETOOTHTRANSFERREPLY_OSX_P_H
+
+#include "qbluetoothservicediscoveryagent.h"
+#include "qbluetoothtransferreply.h"
+
+#include <QtCore/qscopedpointer.h>
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+class QBluetoothTransferReplyOSXPrivate;
+class QBluetoothServiceInfo;
+class QBluetoothAddress;
+class QIODevice;
+
+class Q_BLUETOOTH_EXPORT QBluetoothTransferReplyOSX : public QBluetoothTransferReply
+{
+ Q_OBJECT
+
+public:
+ QBluetoothTransferReplyOSX(QIODevice *input, const QBluetoothTransferRequest &request,
+ QBluetoothTransferManager *parent);
+ ~QBluetoothTransferReplyOSX();
+
+ TransferError error() const Q_DECL_OVERRIDE;
+ QString errorString() const Q_DECL_OVERRIDE;
+
+ bool isFinished() const Q_DECL_OVERRIDE;
+ bool isRunning() const Q_DECL_OVERRIDE;
+
+Q_SIGNALS:
+ void error(QBluetoothTransferReply::TransferError lastError);
+
+public slots:
+ bool abort();
+
+private slots:
+ bool start();
+
+ void serviceDiscoveryFinished();
+ void serviceDiscoveryError(QBluetoothServiceDiscoveryAgent::Error error);
+
+private:
+ // OS X private data (not to be seen by moc).
+ QScopedPointer<QBluetoothTransferReplyOSXPrivate> osx_d_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/bluetooth/qbluetoothtransferreply_p.h b/src/bluetooth/qbluetoothtransferreply_p.h
index 8c6c4968..d3fbf4f1 100644
--- a/src/bluetooth/qbluetoothtransferreply_p.h
+++ b/src/bluetooth/qbluetoothtransferreply_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothtransferreply_qnx.cpp b/src/bluetooth/qbluetoothtransferreply_qnx.cpp
index d0e763cd..fa8992d2 100644
--- a/src/bluetooth/qbluetoothtransferreply_qnx.cpp
+++ b/src/bluetooth/qbluetoothtransferreply_qnx.cpp
@@ -1,8 +1,8 @@
/***************************************************************************
**
** Copyright (C) 2013 Research In Motion
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -112,7 +112,7 @@ bool QBluetoothTransferReplyQnx::start()
file.remove();
}
else if (directory.exists(appName) && busy) {
- m_errorStr = QBluetoothTransferReply::tr("Resurce busy.");
+ m_errorStr = QBluetoothTransferReply::tr("Resource busy.");
m_error = QBluetoothTransferReply::ResourceBusyError;
m_finished = true;
m_running = false;
@@ -121,7 +121,7 @@ bool QBluetoothTransferReplyQnx::start()
return false;
}
if (!source->isReadable()) {
- m_errorStr = QBluetoothTransferReply::tr("QIODevice cannot be read."
+ m_errorStr = QBluetoothTransferReply::tr("QIODevice cannot be read. "
"Make sure it is open for reading.");
m_error = QBluetoothTransferReply::IODeviceNotReadableError;
m_finished = true;
diff --git a/src/bluetooth/qbluetoothtransferreply_qnx_p.h b/src/bluetooth/qbluetoothtransferreply_qnx_p.h
index d6b4d64b..138672c5 100644
--- a/src/bluetooth/qbluetoothtransferreply_qnx_p.h
+++ b/src/bluetooth/qbluetoothtransferreply_qnx_p.h
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 Research In Motion
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothtransferrequest.cpp b/src/bluetooth/qbluetoothtransferrequest.cpp
index 6d750f25..999d81b5 100644
--- a/src/bluetooth/qbluetoothtransferrequest.cpp
+++ b/src/bluetooth/qbluetoothtransferrequest.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothtransferrequest.h b/src/bluetooth/qbluetoothtransferrequest.h
index 981e99a8..c68ae1c9 100644
--- a/src/bluetooth/qbluetoothtransferrequest.h
+++ b/src/bluetooth/qbluetoothtransferrequest.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothtransferrequest_p.h b/src/bluetooth/qbluetoothtransferrequest_p.h
index ff146ec7..3b68165e 100644
--- a/src/bluetooth/qbluetoothtransferrequest_p.h
+++ b/src/bluetooth/qbluetoothtransferrequest_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qbluetoothuuid.cpp b/src/bluetooth/qbluetoothuuid.cpp
index 1c8c0cf2..bbb9f652 100644
--- a/src/bluetooth/qbluetoothuuid.cpp
+++ b/src/bluetooth/qbluetoothuuid.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -211,6 +211,18 @@ Q_GLOBAL_STATIC_WITH_ARGS(QUuid, baseUuid, ("{00000000-0000-1000-8000-00805F9B34
sensor intended for sports and fitness applications.
\value LocationAndNavigation Location Navigation UUID (service). The service exposes location and navigation-related
data from a Location and Navigation sensor intended for outdoor activity applications.
+ \value EnvironmentalSensing Environmental sensor UUID (service). The service exposes data from an environmental sensor
+ for sports and fitness applications.
+ \value BodyComposition Body composition UUID (service). The service exposes data about the body composition intended
+ for consumer healthcare applications.
+ \value UserData User Data UUID (service). The User Data service provides user-related data such as name,
+ gender or weight in sports and fitness environments.
+ \value WeightScale Weight Scale UUID (service). The Weight Scale service exposes weight-related data from
+ a scale for consumer healthcare, sports and fitness applications.
+ \value BondManagement Bond Management UUID (service). The Bond Management service enables user to manage the
+ storage of bond information on Bluetooth devices.
+ \value ContinuousGlucoseMonitoring Continuous Glucose Monitoring UUID (service). The Continuous Glucose Monitoring service
+ exposes glucose data from a monitoring sensor for use in healthcare applications.
*/
/*!
@@ -218,8 +230,20 @@ Q_GLOBAL_STATIC_WITH_ARGS(QUuid, baseUuid, ("{00000000-0000-1000-8000-00805F9B34
\since 5.4
This enum is a convienience type for Bluetooth low energy service characteristics class UUIDs. Values of this type
- will be implicitly converted into a QBluetoothUuid when necessary.
-
+ will be implicitly converted into a QBluetoothUuid when necessary. The detailed type descriptions can be found
+ on \l{https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicsHome.aspx}{bluetooth.org}.
+
+ \value AerobicHeartRateLowerLimit The lower limit of the heart rate where the user improves his endurance while
+ exercising.
+ \value AerobicHeartRateUpperLimit The upper limit of the heart rate where the user improves his endurance while
+ exercising.
+ \value AerobicThreshold This characteristic states the first metabolic threshold.
+ \value Age This characteristic states the age of the user.
+ \value AnaerobicHeartRateLowerLimit The lower limit of the heart rate where the user enhances his anaerobic
+ tolerance while exercising.
+ \value AnaerobicHeartRateUpperLimit The upper limit of the heart rate where the user enhances his anaerobic
+ tolerance while exercising.
+ \value AnaerobicThreshold This characteristic states the second metabolic threshold.
\value AlertCategoryID Categories of alerts/messages.
\value AlertCategoryIDBitMask Categories of alerts/messages.
\value AlertLevel The level of an alert a device is to sound.
@@ -229,8 +253,14 @@ Q_GLOBAL_STATIC_WITH_ARGS(QUuid, baseUuid, ("{00000000-0000-1000-8000-00805F9B34
Client can write the command here to request the several
functions toward the server.
\value AlertStatus The Alert Status characteristic defines the Status of alert.
+ \value ApparentWindDirection The characteristic exposes the apparent wind direction. The apparent wind is
+ experienced by an observer in motion. This characteristic states the direction
+ of the wind with an angle measured clockwise relative to the observers heading.
+ \value ApparentWindSpeed The characteristic exposes the apparent wind speed in meters per second.
+ The apparent wind is experienced by an observer in motion.
\value Appearance The external appearance of this device. The values are composed
of a category (10-bits) and sub-categories (6-bits).
+ \value BarometricPressureTrend This characteristic exposes the trend the barometric pressure is taking.
\value BatteryLevel The current charge level of a battery. 100% represents fully charged
while 0% represents fully discharged.
\value BloodPressureFeature The Blood Pressure Feature characteristic is used to describe the supported
@@ -239,7 +269,12 @@ Q_GLOBAL_STATIC_WITH_ARGS(QUuid, baseUuid, ("{00000000-0000-1000-8000-00805F9B34
containing a Flags field, a Blood Pressure Measurement Compound Value field,
and contains additional fields such as Time Stamp, Pulse Rate and User ID
as determined by the contents of the Flags field.
- \value BodySensorLocation
+ \value BodyCompositionFeature This characteristic describes the available features in the \l BodyCompositionMeasurement
+ characteristic.
+ \value BodyCompositionMeasurement This characteristic describes the body composition such as muscle percentage
+ or the body water mass.
+ \value BodySensorLocation The Body Sensor Location characteristic describes the location of a sensor on
+ the body (e.g.: chest, finger or hand).
\value BootKeyboardInputReport The Boot Keyboard Input Report characteristic is used to transfer fixed format
and length Input Report data between a HID Host operating in Boot Protocol Mode
and a HID Service corresponding to a boot keyboard.
@@ -255,7 +290,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(QUuid, baseUuid, ("{00000000-0000-1000-8000-00805F9B34
is a variable length structure containing a Flags field and, based on the contents
of the Flags field, may contain one or more additional fields as shown in the tables
below.
- \value CurrentTime
+ \value CurrentTime The Current Time characteristic shows the same information as the \l ExactTime256
+ characteristic and information on timezone, DST and the method of update employed.
\value CyclingPowerControlPoint The Cycling Power Control Point characteristic is used to request a specific function
to be executed on the receiving device.
\value CyclingPowerFeature The CP Feature characteristic is used to report a list of features supported by
@@ -266,14 +302,28 @@ Q_GLOBAL_STATIC_WITH_ARGS(QUuid, baseUuid, ("{00000000-0000-1000-8000-00805F9B34
\value CyclingPowerVector The Cycling Power Vector characteristic is a variable length structure containing
a Flags fieldand based on the contents of the Flags field, may contain one or more
additional fields as shown in the table below.
+ \value DatabaseChangeIncrement
+ \value DateOfBirth This characteristic states the user's date of birth.
+ \value DateOfThresholdAssessment
\value DateTime The Date Time characteristic is used to represent time.
- \value DayDateTime
- \value DayOfWeek
- \value DeviceName
- \value DSTOffset
- \value ExactTime256
+ \value DayDateTime The Day Date Time characteristic presents the date, time and day of the week.
+ \value DayOfWeek The Day of Week characteristic describes the day of the week (Monday - Sunday).
+ \value DescriptorValueChanged This characteristic is related to the Environmental Sensing Service.
+ \value DeviceName The Device Name characteristic contains the name of the device.
+ \value DewPoint This characteristic states the dew point in degree Celsius.
+ \value DSTOffset The DST Offset characteristic describes the offset employed by the daylight saving time.
+ \value Elevation The Elevation characteristic states the elevation above/below sea level.
+ \value EmailAddress This characteristic states the email of the user.
+ \value ExactTime256 The Exact Time 256 characteristic describes the data, day and time
+ with an accuracy of 1/256th of a second.
+ \value FatBurnHeartRateLowerLimit The lower limit of the heart rate where the user maximizes the fat burn while exercising.
+ \value FatBurnHeartRateUpperLimit The upper limit of the heart rate where the user maximizes the fat burn while exercising.
\value FirmwareRevisionString The value of this characteristic is a UTF-8 string representing the firmware revision
for the firmware within the device.
+ \value FirstName This characteristic exposes the user's first name.
+ \value FiveZoneHeartRateLimits This characteristic contains the limits between the heart rate zones for the
+ 5-zone heart rate definition.
+ \value Gender This characteristic states the user's gender.
\value GlucoseFeature The Glucose Feature characteristic is used to describe the supported features
of the Server. When read, the Glucose Feature characteristic returns a value
that is used by a Client to determine the supported features of the Server.
@@ -282,20 +332,31 @@ Q_GLOBAL_STATIC_WITH_ARGS(QUuid, baseUuid, ("{00000000-0000-1000-8000-00805F9B34
of the Flags field, may contain a Time Offset field, Glucose Concentration field,
Type-Sample Location field and a Sensor Status Annunciation field.
\value GlucoseMeasurementContext
+ \value GustFactor The characteristic states a factor of wind speed increase between average wind speed in
+ maximum gust speed.
\value HardwareRevisionString The value of this characteristic is a UTF-8 string representing the hardware revision
for the hardware within the device.
+ \value MaximumRecommendedHeartRate This characteristic exposes the maximum recommended heart rate that limits exertion.
\value HeartRateControlPoint
+ \value HeartRateMax This characteristic states the maximum heart rate a user can reach in beats per minute.
\value HeartRateMeasurement
+ \value HeatIndex This characteristic provides a heat index in degree Celsius.
+ \value Height This characteristic states the user's height.
\value HIDControlPoint The HID Control Point characteristic is a control-point attribute that defines the
HID Commands when written.
\value HIDInformation The HID Information Characteristic returns the HID attributes when read.
+ \value HipCircumference This characteristic states the user's hip circumference in meters.
+ \value Humidity The characteristic states the humidity in percent.
\value IEEE1107320601RegulatoryCertificationDataList The value of the characteristic is an opaque structure listing
various regulatory and/or certification compliance items to which the device
claims adherence.
\value IntermediateCuffPressure This characteristic has the same format as the Blood Pressure Measurement
characteristic.
\value IntermediateTemperature The Intermediate Temperature characteristic has the same format as the
- Temperature Measurement characteristic
+ Temperature Measurement characteristic.
+ \value Irradiance This characteristic states the power of electromagnetic radiation in watt per square meter.
+ \value Language This characteristic contains the language definition based on ISO639-1.
+ \value LastName This characteristic states the user's last name.
\value LNControlPoint The LN Control Point characteristic is used to request a specific function
to be executed on the receiving device.
\value LNFeature The LN Feature characteristic is used to report a list of features supported
@@ -304,6 +365,11 @@ Q_GLOBAL_STATIC_WITH_ARGS(QUuid, baseUuid, ("{00000000-0000-1000-8000-00805F9B34
\value LocationAndSpeed The Location and Speed characteristic is a variable length structure containing
a Flags field and, based on the contents of the Flags field, may contain a combination
of data fields.
+ \value MagneticDeclination The characteristic contains the angle on the horizontal plane between the direction of
+ the (Geographic) True North and the Magnetic North, measured clockwise from True North
+ to Magnetic North.
+ \value MagneticFluxDensity2D This characteristic states the magnetic flux density on an x and y axis.
+ \value MagneticFluxDensity3D This characteristic states the magnetic flux density on an x, y and z axis.
\value ManufacturerNameString The value of this characteristic is a UTF-8 string representing the name of the
manufacturer of the device.
\value MeasurementInterval The Measurement Interval characteristic defines the time between measurements.
@@ -317,11 +383,14 @@ Q_GLOBAL_STATIC_WITH_ARGS(QUuid, baseUuid, ("{00000000-0000-1000-8000-00805F9B34
\value PeripheralPrivacyFlag
\value PnPID The PnP_ID characteristic returns its value when read using the GATT Characteristic
Value Read procedure.
+ \value PollenConcentration The characteristic exposes the pollen concentration count per cubic meter.
\value PositionQuality The Position Quality characteristic is a variable length structure containing a
- Flags field and at least one of the optional data
+ Flags field and at least one of the optional data.
+ \value Pressure The Pressure characteristic states the value of a pressure sensor.
\value ProtocolMode The Protocol Mode characteristic is used to expose the current protocol mode of
the HID Service with which it is associated, or to set the desired protocol
mode of the HID Service.
+ \value Rainfall This characteristic exposes the rainfall in meters.
\value ReconnectionAddress The Information included in this page is informative. The normative descriptions
are contained in the applicable specification.
\value RecordAccessControlPoint This control point is used with a service to provide basic management functionality
@@ -329,6 +398,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QUuid, baseUuid, ("{00000000-0000-1000-8000-00805F9B34
\value ReferenceTimeInformation
\value Report The Report characteristic is used to exchange data between a HID Device and a HID Host.
\value ReportMap Only a single instance of this characteristic exists as part of a HID Service.
+ \value RestingHeartRate This characteristic exposes the lowest heart rate a user can reach.
\value RingerControlPoint The Ringer Control Point characteristic defines the Control Point of Ringer.
\value RingerSetting The Ringer Setting characteristic defines the Setting of the Ringer.
\value RSCFeature The RSC (Running Speed and Cadence) Feature characteristic is used to describe the
@@ -347,26 +417,46 @@ Q_GLOBAL_STATIC_WITH_ARGS(QUuid, baseUuid, ("{00000000-0000-1000-8000-00805F9B34
\value ServiceChanged
\value SoftwareRevisionString The value of this characteristic is a UTF-8 string representing the software
revision for the software within the device.
+ \value SportTypeForAerobicAnaerobicThresholds This characteristic is used to preset the various Aerobic and Anaerobic
+ threshold characteristics based on the to-be-performed sport type.
\value SupportedNewAlertCategory Category that the server supports for new alert.
\value SupportedUnreadAlertCategory Category that the server supports for unread alert.
\value SystemID If the system ID is based of a Bluetooth Device Address with a Company Identifier
(OUI) is 0x123456 and the Company Assigned Identifier is 0x9ABCDE, then the System
Identifier is required to be 0x123456FFFE9ABCDE.
+ \value Temperature The value of this characteristic states the temperature in degree Celsius.
\value TemperatureMeasurement The Temperature Measurement characteristic is a variable length structure containing
a Flags field, a Temperature Measurement Value field and, based upon the contents of
the Flags field, optionally a Time Stamp field and/or a Temperature Type field.
\value TemperatureType The Temperature Type characteristic is an enumeration that indicates where the
temperature was measured.
+ \value ThreeZoneHeartRateLimits This characteristic contains the limits between the heart rate zones for the
+ 3-zone heart rate definition.
\value TimeAccuracy
\value TimeSource
\value TimeUpdateControlPoint
\value TimeUpdateState
\value TimeWithDST
\value TimeZone
+ \value TrueWindDirection The characteristic states the direction of the wind with an angle measured clockwise
+ relative to (Geographic) True North. A wind coming from the east is given as 90 degrees.
+ \value TrueWindSpeed The characteristic states the wind speed in meters per seconds.
+ \value TwoZoneHeartRateLimits This characteristic contains the limits between the heart rate zones for the
+ 2-zone heart rate definition.
\value TxPowerLevel The value of the characteristic is a signed 8 bit integer that has a fixed point
exponent of 0.
\value UnreadAlertStatus This characteristic shows how many numbers of unread alerts exist in the specific
category in the device.
+ \value UserControlPoint
+ \value UserIndex This characteristic states the index of the user.
+ \value UVIndex This characteristic exposes the UV index.
+ \value VO2Max This characteristic exposes the maximum Oxygen uptake of a user.
+ \value WaistCircumference This characteristic states the user's waist circumference in meters.
+ \value Weight This characteristic exposes the user's weight in kilograms.
+ \value WeightMeasurement This characteristic provides weight related data such as BMI or the user's weight.
+ \value WeightScaleFeature This characteristic describes the available data in the \l WeightMeasurement
+ characteristic.
+ \value WindChill This characteristic states the wind chill in degree Celsius
*/
/*!
@@ -376,7 +466,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(QUuid, baseUuid, ("{00000000-0000-1000-8000-00805F9B34
Descriptors are attributes that describe Bluetooth Low Energy characteristic values.
This enum is a convienience type for descriptor class UUIDs. Values of this type
- will be implicitly converted into a QBluetoothUuid when necessary.
+ will be implicitly converted into a QBluetoothUuid when necessary. The detailed type specifications
+ can be found on \l{https://developer.bluetooth.org/gatt/descriptors/Pages/DescriptorsHomePage.aspx}{bluetooth.org}.
\value CharacteristicExtendedProperties Descriptor defines additional Characteristic Properties.
The existence of this descriptor is indicated by the
@@ -395,9 +486,29 @@ Q_GLOBAL_STATIC_WITH_ARGS(QUuid, baseUuid, ("{00000000-0000-1000-8000-00805F9B34
\value ReportReference Mapping information in the form of a Report ID and Report Type which maps the
current parent characteristic to the Report ID(s) and Report Type (s) defined
within the Report Map characteristic.
+ \value EnvironmentalSensingConfiguration Descriptor defines how multiple trigger settings descriptors are combined. Therefore
+ this descriptor works together with the \l EnvironmentalSensingTriggerSetting descriptor
+ to define the conditions under which the associated characteristic value can be notified.
+ \value EnvironmentalSensingMeasurement Descriptor defines the additional information for the environmental sensing server
+ such as the intended application, sampling functions or measurement period and uncertainty.
+ \value EnvironmentalSensingTriggerSetting Descriptor defines under which conditions an environmental sensing server (ESS) should
+ trigger notifications. Examples of such conditions are certain thresholds being reached
+ or timers having expired. This implies that the ESS characteristic supports notifications.
\value UnknownDescriptorType The descriptor type is unknown.
*/
+namespace
+{
+ class BtUuidRegisterMetaTypes
+ {
+ public:
+ BtUuidRegisterMetaTypes()
+ {
+ qRegisterMetaType<QBluetoothUuid>();
+ }
+ } _registerBtUuidMetaTypes;
+}
+
/*!
Constructs a new null Bluetooth UUID.
*/
@@ -693,10 +804,17 @@ QString QBluetoothUuid::serviceClassToString(QBluetoothUuid::ServiceClassUuid uu
case QBluetoothUuid::AlertNotificationService: return QBluetoothServiceDiscoveryAgent::tr("Alert Notification Service");
case QBluetoothUuid::HumanInterfaceDevice: return QBluetoothServiceDiscoveryAgent::tr("Human Interface Device");
case QBluetoothUuid::ScanParameters: return QBluetoothServiceDiscoveryAgent::tr("Scan Parameters");
- case QBluetoothUuid::RunningSpeedAndCadence: return QBluetoothServiceDiscoveryAgent::tr("Running Speed and Cadance");
- case QBluetoothUuid::CyclingSpeedAndCadence: return QBluetoothServiceDiscoveryAgent::tr("Cycling Speed and Cadance");
+ case QBluetoothUuid::RunningSpeedAndCadence: return QBluetoothServiceDiscoveryAgent::tr("Running Speed and Cadence");
+ case QBluetoothUuid::CyclingSpeedAndCadence: return QBluetoothServiceDiscoveryAgent::tr("Cycling Speed and Cadence");
case QBluetoothUuid::CyclingPower: return QBluetoothServiceDiscoveryAgent::tr("Cycling Power");
case QBluetoothUuid::LocationAndNavigation: return QBluetoothServiceDiscoveryAgent::tr("Location and Navigation");
+ case QBluetoothUuid::EnvironmentalSensing: return QBluetoothServiceDiscoveryAgent::tr("Environmental Sensing");
+ case QBluetoothUuid::BodyComposition: return QBluetoothServiceDiscoveryAgent::tr("Body Composition");
+ case QBluetoothUuid::UserData: return QBluetoothServiceDiscoveryAgent::tr("User Data");
+ case QBluetoothUuid::WeightScale: return QBluetoothServiceDiscoveryAgent::tr("Weight Scale");
+ //: Connection management (Bluetooth)
+ case QBluetoothUuid::BondManagement: return QBluetoothServiceDiscoveryAgent::tr("Bond Management");
+ case QBluetoothUuid::ContinuousGlucoseMonitoring: return QBluetoothServiceDiscoveryAgent::tr("Continuous Glucose Monitoring");
default:
break;
}
@@ -738,7 +856,7 @@ QString QBluetoothUuid::protocolToString(QBluetoothUuid::ProtocolUuid uuid)
case QBluetoothUuid::Avdtp: return QBluetoothServiceDiscoveryAgent::tr("Audio/Video Distribution Transport Protocol");
case QBluetoothUuid::Cmtp: return QBluetoothServiceDiscoveryAgent::tr("Common ISDN Access Protocol");
case QBluetoothUuid::UdiCPlain: return QBluetoothServiceDiscoveryAgent::tr("UdiCPlain");
- case QBluetoothUuid::McapControlChannel: return QBluetoothServiceDiscoveryAgent::tr("Multi-Channel Adaptation Protocol -Conrol");
+ case QBluetoothUuid::McapControlChannel: return QBluetoothServiceDiscoveryAgent::tr("Multi-Channel Adaptation Protocol - Control");
case QBluetoothUuid::McapDataChannel: return QBluetoothServiceDiscoveryAgent::tr("Multi-Channel Adaptation Protocol - Data");
case QBluetoothUuid::L2cap: return QBluetoothServiceDiscoveryAgent::tr("Layer 2 Control Protocol");
default:
@@ -759,14 +877,19 @@ QString QBluetoothUuid::protocolToString(QBluetoothUuid::ProtocolUuid uuid)
QString QBluetoothUuid::characteristicToString(CharacteristicType uuid)
{
switch (uuid) {
+ //: GAP: Generic Access Profile (Bluetooth)
case QBluetoothUuid::DeviceName: return QBluetoothServiceDiscoveryAgent::tr("GAP Device Name");
+ //: GAP: Generic Access Profile (Bluetooth)
case QBluetoothUuid::Appearance: return QBluetoothServiceDiscoveryAgent::tr("GAP Appearance");
case QBluetoothUuid::PeripheralPrivacyFlag:
+ //: GAP: Generic Access Profile (Bluetooth)
return QBluetoothServiceDiscoveryAgent::tr("GAP Peripheral Privacy Flag");
case QBluetoothUuid::ReconnectionAddress:
+ //: GAP: Generic Access Profile (Bluetooth)
return QBluetoothServiceDiscoveryAgent::tr("GAP Reconnection Address");
case QBluetoothUuid::PeripheralPreferredConnectionParameters:
return QBluetoothServiceDiscoveryAgent::tr("GAP Peripheral Preferred Connection Parameters");
+ //: GATT: _G_eneric _Att_ribute Profile (Bluetooth)
case QBluetoothUuid::ServiceChanged: return QBluetoothServiceDiscoveryAgent::tr("GATT Service Changed");
case QBluetoothUuid::AlertLevel: return QBluetoothServiceDiscoveryAgent::tr("Alert Level");
case QBluetoothUuid::TxPowerLevel: return QBluetoothServiceDiscoveryAgent::tr("TX Power");
@@ -833,8 +956,10 @@ QString QBluetoothUuid::characteristicToString(CharacteristicType uuid)
case QBluetoothUuid::SupportedUnreadAlertCategory:
return QBluetoothServiceDiscoveryAgent::tr("Supported Unread Alert Category");
case QBluetoothUuid::BloodPressureFeature: return QBluetoothServiceDiscoveryAgent::tr("Blood Pressure Feature");
+ //: HID: Human Interface Device Profile (Bluetooth)
case QBluetoothUuid::HIDInformation: return QBluetoothServiceDiscoveryAgent::tr("HID Information");
case QBluetoothUuid::ReportMap: return QBluetoothServiceDiscoveryAgent::tr("Report Map");
+ //: HID: Human Interface Device Profile (Bluetooth)
case QBluetoothUuid::HIDControlPoint: return QBluetoothServiceDiscoveryAgent::tr("HID Control Point");
case QBluetoothUuid::Report: return QBluetoothServiceDiscoveryAgent::tr("Report");
case QBluetoothUuid::ProtocolMode: return QBluetoothServiceDiscoveryAgent::tr("Protocol Mode");
@@ -842,11 +967,16 @@ QString QBluetoothUuid::characteristicToString(CharacteristicType uuid)
case QBluetoothUuid::PnPID: return QBluetoothServiceDiscoveryAgent::tr("PnP ID");
case QBluetoothUuid::GlucoseFeature: return QBluetoothServiceDiscoveryAgent::tr("Glucose Feature");
case QBluetoothUuid::RecordAccessControlPoint:
+ //: Glucose Sensor patient record database.
return QBluetoothServiceDiscoveryAgent::tr("Record Access Control Point");
+ //: RSC: Running Speed and Cadence
case QBluetoothUuid::RSCMeasurement: return QBluetoothServiceDiscoveryAgent::tr("RSC Measurement");
+ //: RSC: Running Speed and Cadence
case QBluetoothUuid::RSCFeature: return QBluetoothServiceDiscoveryAgent::tr("RSC Feature");
case QBluetoothUuid::SCControlPoint: return QBluetoothServiceDiscoveryAgent::tr("SC Control Point");
+ //: CSC: Cycling Speed and Cadence
case QBluetoothUuid::CSCMeasurement: return QBluetoothServiceDiscoveryAgent::tr("CSC Measurement");
+ //: CSC: Cycling Speed and Cadence
case QBluetoothUuid::CSCFeature: return QBluetoothServiceDiscoveryAgent::tr("CSC Feature");
case QBluetoothUuid::SensorLocation: return QBluetoothServiceDiscoveryAgent::tr("Sensor Location");
case QBluetoothUuid::CyclingPowerMeasurement:
@@ -854,12 +984,89 @@ QString QBluetoothUuid::characteristicToString(CharacteristicType uuid)
case QBluetoothUuid::CyclingPowerVector: return QBluetoothServiceDiscoveryAgent::tr("Cycling Power Vector");
case QBluetoothUuid::CyclingPowerFeature: return QBluetoothServiceDiscoveryAgent::tr("Cycling Power Feature");
case QBluetoothUuid::CyclingPowerControlPoint:
- return QBluetoothServiceDiscoveryAgent::tr("Cycling Power COntrol Point");
+ return QBluetoothServiceDiscoveryAgent::tr("Cycling Power Control Point");
case QBluetoothUuid::LocationAndSpeed: return QBluetoothServiceDiscoveryAgent::tr("Location And Speed");
case QBluetoothUuid::Navigation: return QBluetoothServiceDiscoveryAgent::tr("Navigation");
case QBluetoothUuid::PositionQuality: return QBluetoothServiceDiscoveryAgent::tr("Position Quality");
case QBluetoothUuid::LNFeature: return QBluetoothServiceDiscoveryAgent::tr("LN Feature");
case QBluetoothUuid::LNControlPoint: return QBluetoothServiceDiscoveryAgent::tr("LN Control Point");
+ case QBluetoothUuid::MagneticDeclination:
+ //: Angle between geographic and magnetic north
+ return QBluetoothServiceDiscoveryAgent::tr("Magnetic Declination");
+ //: Above/below sea level
+ case QBluetoothUuid::Elevation: return QBluetoothServiceDiscoveryAgent::tr("Elevation");
+ case QBluetoothUuid::Pressure: return QBluetoothServiceDiscoveryAgent::tr("Pressure");
+ case QBluetoothUuid::Temperature: return QBluetoothServiceDiscoveryAgent::tr("Temperature");
+ case QBluetoothUuid::Humidity: return QBluetoothServiceDiscoveryAgent::tr("Humidity");
+ //: Wind speed while standing
+ case QBluetoothUuid::TrueWindSpeed: return QBluetoothServiceDiscoveryAgent::tr("True Wind Speed");
+ case QBluetoothUuid::TrueWindDirection : return QBluetoothServiceDiscoveryAgent::tr("True Wind Direction");
+ case QBluetoothUuid::ApparentWindSpeed:
+ //: Wind speed while observer is moving
+ return QBluetoothServiceDiscoveryAgent::tr("Apparent Wind Speed");
+ case QBluetoothUuid::ApparentWindDirection: return QBluetoothServiceDiscoveryAgent::tr("Apparent Wind Direction");
+ case QBluetoothUuid::GustFactor:
+ //: Factor by which wind gust is stronger than average wind
+ return QBluetoothServiceDiscoveryAgent::tr("Gust Factor");
+ case QBluetoothUuid::PollenConcentration: return QBluetoothServiceDiscoveryAgent::tr("Pollen Concentration");
+ case QBluetoothUuid::UVIndex: return QBluetoothServiceDiscoveryAgent::tr("UV Index");
+ case QBluetoothUuid::Irradiance: return QBluetoothServiceDiscoveryAgent::tr("Irradiance");
+ case QBluetoothUuid::Rainfall: return QBluetoothServiceDiscoveryAgent::tr("Rainfall");
+ case QBluetoothUuid::WindChill: return QBluetoothServiceDiscoveryAgent::tr("Wind Chill");
+ case QBluetoothUuid::HeatIndex: return QBluetoothServiceDiscoveryAgent::tr("Heat Index");
+ case QBluetoothUuid::DewPoint: return QBluetoothServiceDiscoveryAgent::tr("Dew Point");
+ case QBluetoothUuid::DescriptorValueChanged:
+ //: Environmental sensing related
+ return QBluetoothServiceDiscoveryAgent::tr("Descriptor Value Changed");
+ case QBluetoothUuid::AerobicHeartRateLowerLimit:
+ return QBluetoothServiceDiscoveryAgent::tr("Aerobic Heart Rate Lower Limit");
+ case QBluetoothUuid::AerobicHeartRateUpperLimit:
+ return QBluetoothServiceDiscoveryAgent::tr("Aerobic Heart Rate Upper Limit");
+ case QBluetoothUuid::AerobicThreshold: return QBluetoothServiceDiscoveryAgent::tr("Aerobic Threshold");
+ //: Age of person
+ case QBluetoothUuid::Age: return QBluetoothServiceDiscoveryAgent::tr("Age");
+ case QBluetoothUuid::AnaerobicHeartRateLowerLimit:
+ return QBluetoothServiceDiscoveryAgent::tr("Anaerobic Heart Rate Lower Limit");
+ case QBluetoothUuid::AnaerobicHeartRateUpperLimit:
+ return QBluetoothServiceDiscoveryAgent::tr("Anaerobic Heart Rate Upper Limit");
+ case QBluetoothUuid::AnaerobicThreshold: return QBluetoothServiceDiscoveryAgent::tr("Anaerobic Threshold");
+ case QBluetoothUuid::DateOfBirth: return QBluetoothServiceDiscoveryAgent::tr("Date Of Birth");
+ case QBluetoothUuid::DateOfThresholdAssessment: return QBluetoothServiceDiscoveryAgent::tr("Date Of Threshold Assessment");
+ case QBluetoothUuid::EmailAddress: return QBluetoothServiceDiscoveryAgent::tr("Email Address");
+ case QBluetoothUuid::FatBurnHeartRateLowerLimit:
+ return QBluetoothServiceDiscoveryAgent::tr("Fat Burn Heart Rate Lower Limit");
+ case QBluetoothUuid::FatBurnHeartRateUpperLimit:
+ return QBluetoothServiceDiscoveryAgent::tr("Fat Burn Heart Rate Upper Limit");
+ case QBluetoothUuid::FirstName: return QBluetoothServiceDiscoveryAgent::tr("First Name");
+ case QBluetoothUuid::FiveZoneHeartRateLimits: return QBluetoothServiceDiscoveryAgent::tr("5-Zone Heart Rate Limits");
+ case QBluetoothUuid::Gender: return QBluetoothServiceDiscoveryAgent::tr("Gender");
+ case QBluetoothUuid::HeartRateMax: return QBluetoothServiceDiscoveryAgent::tr("Heart Rate Maximum");
+ //: Height of a person
+ case QBluetoothUuid::Height: return QBluetoothServiceDiscoveryAgent::tr("Height");
+ case QBluetoothUuid::HipCircumference: return QBluetoothServiceDiscoveryAgent::tr("Hip Circumference");
+ case QBluetoothUuid::LastName: return QBluetoothServiceDiscoveryAgent::tr("Last Name");
+ case QBluetoothUuid::MaximumRecommendedHeartRate:
+ return QBluetoothServiceDiscoveryAgent::tr("Maximum Recommended Heart Rate");
+ case QBluetoothUuid::RestingHeartRate: return QBluetoothServiceDiscoveryAgent::tr("Resting Heart Rate");
+ case QBluetoothUuid::SportTypeForAerobicAnaerobicThresholds:
+ return QBluetoothServiceDiscoveryAgent::tr("Sport Type For Aerobic/Anaerobic Thresholds");
+ case QBluetoothUuid::ThreeZoneHeartRateLimits: return QBluetoothServiceDiscoveryAgent::tr("3-Zone Heart Rate Limits");
+ case QBluetoothUuid::TwoZoneHeartRateLimits: return QBluetoothServiceDiscoveryAgent::tr("2-Zone Heart Rate Limits");
+ case QBluetoothUuid::VO2Max: return QBluetoothServiceDiscoveryAgent::tr("Oxygen Uptake");
+ case QBluetoothUuid::WaistCircumference: return QBluetoothServiceDiscoveryAgent::tr("Waist Circumference");
+ case QBluetoothUuid::Weight: return QBluetoothServiceDiscoveryAgent::tr("Weight");
+ case QBluetoothUuid::DatabaseChangeIncrement:
+ //: Environmental sensing related
+ return QBluetoothServiceDiscoveryAgent::tr("Database Change Increment");
+ case QBluetoothUuid::UserIndex: return QBluetoothServiceDiscoveryAgent::tr("User Index");
+ case QBluetoothUuid::BodyCompositionFeature: return QBluetoothServiceDiscoveryAgent::tr("Body Composition Feature");
+ case QBluetoothUuid::BodyCompositionMeasurement: return QBluetoothServiceDiscoveryAgent::tr("Body Composition Measurement");
+ case QBluetoothUuid::WeightMeasurement: return QBluetoothServiceDiscoveryAgent::tr("Weight Measurement");
+ case QBluetoothUuid::UserControlPoint: return QBluetoothServiceDiscoveryAgent::tr("User Control Point");
+ case QBluetoothUuid::MagneticFluxDensity2D: return QBluetoothServiceDiscoveryAgent::tr("Magnetic Flux Density 2D");
+ case QBluetoothUuid::MagneticFluxDensity3D: return QBluetoothServiceDiscoveryAgent::tr("Magnetic Flux Density 3D");
+ case QBluetoothUuid::Language: return QBluetoothServiceDiscoveryAgent::tr("Language");
+ case QBluetoothUuid::BarometricPressureTrend: return QBluetoothServiceDiscoveryAgent::tr("Barometric Pressure Trend");
default:
break;
}
@@ -871,7 +1078,7 @@ QString QBluetoothUuid::characteristicToString(CharacteristicType uuid)
Returns a human-readable and translated name for the given descriptor type
represented by \a uuid.
- \sa QBluetoothUuid::CharacteristicType
+ \sa QBluetoothUuid::DescriptorType
\since 5.4
*/
@@ -885,7 +1092,7 @@ QString QBluetoothUuid::descriptorToString(QBluetoothUuid::DescriptorType uuid)
case QBluetoothUuid::ClientCharacteristicConfiguration:
return QBluetoothServiceDiscoveryAgent::tr("Client Characteristic Configuration");
case QBluetoothUuid::ServerCharacteristicConfiguration:
- return QBluetoothServiceDiscoveryAgent::tr("Server Characteristic Configuratio");
+ return QBluetoothServiceDiscoveryAgent::tr("Server Characteristic Configuration");
case QBluetoothUuid::CharacteristicPresentationFormat:
return QBluetoothServiceDiscoveryAgent::tr("Characteristic Presentation Format");
case QBluetoothUuid::CharacteristicAggregateFormat:
@@ -896,6 +1103,12 @@ QString QBluetoothUuid::descriptorToString(QBluetoothUuid::DescriptorType uuid)
return QBluetoothServiceDiscoveryAgent::tr("External Report Reference");
case QBluetoothUuid::ReportReference:
return QBluetoothServiceDiscoveryAgent::tr("Report Reference");
+ case QBluetoothUuid::EnvironmentalSensingConfiguration:
+ return QBluetoothServiceDiscoveryAgent::tr("Environmental Sensing Configuration");
+ case QBluetoothUuid::EnvironmentalSensingMeasurement:
+ return QBluetoothServiceDiscoveryAgent::tr("Environmental Sensing Measurement");
+ case QBluetoothUuid::EnvironmentalSensingTriggerSetting:
+ return QBluetoothServiceDiscoveryAgent::tr("Environmental Sensing Trigger Setting");
default:
break;
}
diff --git a/src/bluetooth/qbluetoothuuid.h b/src/bluetooth/qbluetoothuuid.h
index 2c035ffa..4646531c 100644
--- a/src/bluetooth/qbluetoothuuid.h
+++ b/src/bluetooth/qbluetoothuuid.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -77,7 +77,7 @@ public:
UdiCPlain = 0x001D,
McapControlChannel = 0x001E,
McapDataChannel = 0x001F,
- L2cap = 0x0100,
+ L2cap = 0x0100
};
enum ServiceClassUuid {
@@ -166,6 +166,12 @@ public:
CyclingSpeedAndCadence = 0x1816,
CyclingPower = 0x1818,
LocationAndNavigation = 0x1819,
+ EnvironmentalSensing = 0x181a,
+ BodyComposition = 0x181b,
+ UserData = 0x181c,
+ WeightScale = 0x181d,
+ BondManagement = 0x181e,
+ ContinuousGlucoseMonitoring = 0x181f
};
enum CharacteristicType {
@@ -180,21 +186,28 @@ public:
DateTime = 0x2a08,
DayOfWeek = 0x2a09,
DayDateTime = 0x2a0a,
+ /* 0x2a0b not defined */
ExactTime256 = 0x2a0c,
DSTOffset = 0x2a0d,
TimeZone = 0x2a0e,
LocalTimeInformation = 0x2a0f,
+ /* 0x2a10 not defined */
TimeWithDST = 0x2a11,
TimeAccuracy = 0x2a12,
TimeSource = 0x2a13,
ReferenceTimeInformation = 0x2a14,
+ /* 0x2a15 not defined */
TimeUpdateControlPoint = 0x2a16,
TimeUpdateState = 0x2a17,
GlucoseMeasurement = 0x2a18,
BatteryLevel = 0x2a19,
+ /* 0x2a1a not defined */
+ /* 0x2a1b not defined */
TemperatureMeasurement = 0x2a1c,
TemperatureType = 0x2a1d,
IntermediateTemperature = 0x2a1e,
+ /* 0x2a1f not defined */
+ /* 0x2a20 not defined */
MeasurementInterval = 0x2a21,
BootKeyboardInputReport = 0x2a22,
SystemID = 0x2a23,
@@ -206,6 +219,11 @@ public:
ManufacturerNameString = 0x2a29,
IEEE1107320601RegulatoryCertificationDataList = 0x2a2a,
CurrentTime = 0x2a2b,
+ MagneticDeclination = 0x2a2c,
+ /* 0x2a2d not defined */
+ /* 0x2a2e not defined */
+ /* 0x2a2f not defined */
+ /* 0x2a30 not defined */
ScanRefresh = 0x2a31,
BootKeyboardOutputReport = 0x2a32,
BootMouseInputReport = 0x2a33,
@@ -215,6 +233,11 @@ public:
HeartRateMeasurement = 0x2a37,
BodySensorLocation = 0x2a38,
HeartRateControlPoint = 0x2a39,
+ /* 0x2a3a not defined */
+ /* 0x2a3b not defined */
+ /* 0x2a3c not defined */
+ /* 0x2a3d not defined */
+ /* 0x2a3e not defined */
AlertStatus = 0x2a3f,
RingerControlPoint = 0x2a40,
RingerSetting = 0x2a41,
@@ -238,9 +261,19 @@ public:
RSCMeasurement = 0x2a53,
RSCFeature = 0x2a54,
SCControlPoint = 0x2a55,
+ /* 0x2a56 not defined */
+ /* 0x2a57 not defined */
+ /* 0x2a58 not defined */
+ /* 0x2a59 not defined */
+ /* 0x2a5a not defined */
CSCMeasurement = 0x2a5b,
CSCFeature = 0x2a5c,
SensorLocation = 0x2a5d,
+ /* 0x2a5e not defined */
+ /* 0x2a5f not defined */
+ /* 0x2a60 not defined */
+ /* 0x2a61 not defined */
+ /* 0x2a62 not defined */
CyclingPowerMeasurement = 0x2a63,
CyclingPowerVector = 0x2a64,
CyclingPowerFeature = 0x2a65,
@@ -250,6 +283,62 @@ public:
PositionQuality = 0x2a69,
LNFeature = 0x2a6a,
LNControlPoint = 0x2a6b,
+ Elevation = 0x2a6c,
+ Pressure = 0x2a6d,
+ Temperature = 0x2a6e,
+ Humidity = 0x2a6f,
+ TrueWindSpeed = 0x2a70,
+ TrueWindDirection = 0x2a71,
+ ApparentWindSpeed = 0x2a72,
+ ApparentWindDirection = 0x2a73,
+ GustFactor = 0x2a74,
+ PollenConcentration = 0x2a75,
+ UVIndex = 0x2a76,
+ Irradiance = 0x2a77,
+ Rainfall = 0x2a78,
+ WindChill = 0x2a79,
+ HeatIndex = 0x2a7a,
+ DewPoint = 0x2a7b,
+ /* 0x2a7c not defined */
+ DescriptorValueChanged = 0x2a7d,
+ AerobicHeartRateLowerLimit = 0x2a7e,
+ AerobicThreshold = 0x2a7f,
+ Age = 0x2a80,
+ AnaerobicHeartRateLowerLimit = 0x2a81,
+ AnaerobicHeartRateUpperLimit = 0x2a82,
+ AnaerobicThreshold = 0x2a83,
+ AerobicHeartRateUpperLimit = 0x2a84,
+ DateOfBirth = 0x2a85,
+ DateOfThresholdAssessment = 0x2a86,
+ EmailAddress = 0x2a87,
+ FatBurnHeartRateLowerLimit = 0x2a88,
+ FatBurnHeartRateUpperLimit = 0x2a89,
+ FirstName = 0x2a8a,
+ FiveZoneHeartRateLimits = 0x2a8b,
+ Gender = 0x2a8c,
+ HeartRateMax = 0x2a8d,
+ Height = 0x2a8e,
+ HipCircumference = 0x2a8f,
+ LastName = 0x2a90,
+ MaximumRecommendedHeartRate = 0x2a91,
+ RestingHeartRate = 0x2a92,
+ SportTypeForAerobicAnaerobicThresholds = 0x2a93,
+ ThreeZoneHeartRateLimits = 0x2a94,
+ TwoZoneHeartRateLimits = 0x2a95,
+ VO2Max = 0x2a96,
+ WaistCircumference = 0x2a97,
+ Weight = 0x2a98,
+ DatabaseChangeIncrement = 0x2a99,
+ UserIndex = 0x2a9a,
+ BodyCompositionFeature = 0x2a9b,
+ BodyCompositionMeasurement = 0x2a9c,
+ WeightMeasurement = 0x2a9d,
+ WeightScaleFeature = 0x2a9e,
+ UserControlPoint = 0x2a9f,
+ MagneticFluxDensity2D = 0x2aa0,
+ MagneticFluxDensity3D = 0x2aa1,
+ Language = 0x2aa2,
+ BarometricPressureTrend = 0x2aa3
};
enum DescriptorType {
@@ -262,7 +351,12 @@ public:
CharacteristicAggregateFormat = 0x2905,
ValidRange = 0x2906,
ExternalReportReference = 0x2907,
- ReportReference = 0x2908
+ ReportReference = 0x2908,
+ /* 0x2909 not defined */
+ /* 0x290a not defined */
+ EnvironmentalSensingConfiguration = 0x290b,
+ EnvironmentalSensingMeasurement = 0x290c,
+ EnvironmentalSensingTriggerSetting = 0x290d
};
QBluetoothUuid();
diff --git a/src/bluetooth/qlowenergycharacteristic.cpp b/src/bluetooth/qlowenergycharacteristic.cpp
index 2f8bd6fa..aba4a66b 100644
--- a/src/bluetooth/qlowenergycharacteristic.cpp
+++ b/src/bluetooth/qlowenergycharacteristic.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -64,9 +64,6 @@ QT_BEGIN_NAMESPACE
format or range information specifying how the characteristic's value is to be\
interpreted.
- \note This class is provided by Qt 5.4 as part of a Bluetooth Low Energy Tech Preview.
- Some API elements may change until the final release of the feature.
-
\sa QLowEnergyService, QLowEnergyDescriptor
*/
@@ -192,12 +189,14 @@ QLowEnergyCharacteristic::PropertyTypes QLowEnergyCharacteristic::properties() c
The cache is updated during the associated service's
\l {QLowEnergyService::discoverDetails()} {detail discovery}, a successful
- \l {QLowEnergyService::writeCharacteristic()}{write operation} or when an update
- notification is received.
-
- The returned \l QByteArray is empty if the characteristic does not have the
- \l {QLowEnergyCharacteristic::Read}{read permission}. However, a non-readable
- characteristic may obtain a non-empty value via a related notification or write operation.
+ \l {QLowEnergyService::readCharacteristic()}{read}/\l {QLowEnergyService::writeCharacteristic()}{write}
+ operation or when an update notification is received.
+
+ The returned \l QByteArray always remains empty if the characteristic does not
+ have the \l {QLowEnergyCharacteristic::Read}{read permission}. In such cases only
+ the \l QLowEnergyService::characteristicChanged() or
+ \l QLowEnergyService::characteristicWritten() may provice information about the
+ value of this characteristic.
*/
QByteArray QLowEnergyCharacteristic::value() const
{
@@ -212,6 +211,9 @@ QByteArray QLowEnergyCharacteristic::value() const
Returns the handle of the characteristic's value attribute;
or \c 0 if the handle cannot be accessed on the platform or
if the characteristic is invalid.
+
+ \note On OS X and iOS handles can differ from 0, but these
+ values have no special meaning outside of internal/private API.
*/
QLowEnergyHandle QLowEnergyCharacteristic::handle() const
{
@@ -312,6 +314,9 @@ bool QLowEnergyCharacteristic::isValid() const
\c 0 if the handle cannot be accessed on the platform or if the
characteristic is invalid.
+ \note On OS X and iOS handles can differ from 0, but these
+ values have no special meaning outside of internal/private API.
+
\sa isValid()
*/
QLowEnergyHandle QLowEnergyCharacteristic::attributeHandle() const
diff --git a/src/bluetooth/qlowenergycharacteristic.h b/src/bluetooth/qlowenergycharacteristic.h
index e0ed2976..4d552369 100644
--- a/src/bluetooth/qlowenergycharacteristic.h
+++ b/src/bluetooth/qlowenergycharacteristic.h
@@ -1,8 +1,8 @@
/***************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2013 BlackBerry Limited all rights reserved
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -91,6 +91,7 @@ protected:
friend class QLowEnergyService;
friend class QLowEnergyControllerPrivate;
+ friend class QLowEnergyControllerPrivateOSX;
QLowEnergyCharacteristicPrivate *data;
QLowEnergyCharacteristic(QSharedPointer<QLowEnergyServicePrivate> p,
QLowEnergyHandle handle);
diff --git a/src/bluetooth/qlowenergycontroller.cpp b/src/bluetooth/qlowenergycontroller.cpp
index 3d57ec6b..44b6a6da 100644
--- a/src/bluetooth/qlowenergycontroller.cpp
+++ b/src/bluetooth/qlowenergycontroller.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -70,10 +70,11 @@ QT_BEGIN_NAMESPACE
The first step is to establish a connection via \l connectToDevice().
Once the connection has been established, the controller's \l state()
changes to \l QLowEnergyController::ConnectedState and the \l connected()
- signal is emitted. It is important to mention that the remote device can
- usually only be connected to a single device. Therefore it is not
- possible to have multiple instances of this class being connected to the
- same remote device. The \l disconnectFromDevice() function is used to break
+ signal is emitted. It is important to mention that some platforms such as
+ a BlueZ based Linux cannot maintain two connected instances of
+ \l QLowEnergyController to the same remote device. In such cases the second
+ call to \l connectToDevice() may fail. This limitation may disappear at some
+ stage in the future. The \l disconnectFromDevice() function is used to break
the existing connection.
The second step after establishing the connection is to discover the services
@@ -92,9 +93,6 @@ QT_BEGIN_NAMESPACE
connection becomes invalid as soon as the controller disconnects from the
remote Bluetooth Low Energy device.
- \note This class is provided by Qt 5.4 as part of a Bluetooth Low Energy Tech Preview.
- Some API elements may change until the final release of the feature.
-
\sa QLowEnergyService, QLowEnergyCharacteristic, QLowEnergyDescriptor
*/
@@ -113,6 +111,8 @@ QT_BEGIN_NAMESPACE
\value InvalidBluetoothAdapterError The local Bluetooth device with the address passed to
the constructor of this class cannot be found or
there is no local Bluetooth device.
+ \value ConnectionError The attempt to connect to the remote device failed.
+ This value was introduced by Qt 5.5.
*/
/*!
@@ -194,6 +194,18 @@ QT_BEGIN_NAMESPACE
\sa discoverServices(), error()
*/
+namespace {
+class QLowEnergyControllerMetaTypes
+{
+public:
+ QLowEnergyControllerMetaTypes()
+ {
+ qRegisterMetaType<QLowEnergyController::ControllerState>();
+ qRegisterMetaType<QLowEnergyController::Error>();
+ }
+} qLowEnergyControllerMetaTypes;
+}
+
void QLowEnergyControllerPrivate::setError(
QLowEnergyController::Error newError)
{
@@ -370,6 +382,8 @@ quint16 QLowEnergyControllerPrivate::updateValueOfDescriptor(
The controller uses the local default Bluetooth adapter for
the connection management.
+
+ \obsolete
*/
QLowEnergyController::QLowEnergyController(
const QBluetoothAddress &remoteDevice,
@@ -386,6 +400,31 @@ QLowEnergyController::QLowEnergyController(
/*!
Constructs a new instance of this class with \a parent.
+ The \a remoteDeviceInfo must contain the details of the
+ remote Bluetooth Low Energy device to which this object
+ should attempt to connect later on.
+
+ The controller uses the local default Bluetooth adapter for
+ the connection management.
+
+ \since 5.5
+*/
+QLowEnergyController::QLowEnergyController(
+ const QBluetoothDeviceInfo &remoteDeviceInfo,
+ QObject *parent)
+ : QObject(parent), d_ptr(new QLowEnergyControllerPrivate())
+{
+ Q_D(QLowEnergyController);
+ d->q_ptr = this;
+ d->remoteDevice = remoteDeviceInfo.address();
+ d->localAdapter = QBluetoothLocalDevice().address();
+ d->addressType = QLowEnergyController::PublicAddress;
+ d->remoteName = remoteDeviceInfo.name();
+}
+
+/*!
+ Constructs a new instance of this class with \a parent.
+
The \a remoteDevice must contain the address of the
remote Bluetooth Low Energy device to which this object
should attempt to connect later on.
@@ -395,6 +434,8 @@ QLowEnergyController::QLowEnergyController(
\a localDevice specifies a local device that is not a local Bluetooth
adapter, \l error() is set to \l InvalidBluetoothAdapterError once
\l connectToDevice() is called.
+
+ \obsolete
*/
QLowEnergyController::QLowEnergyController(
const QBluetoothAddress &remoteDevice,
@@ -441,6 +482,16 @@ QBluetoothAddress QLowEnergyController::remoteAddress() const
}
/*!
+ Returns the name of the remote Bluetooth Low Energy device.
+
+ \since 5.5
+ */
+QString QLowEnergyController::remoteName() const
+{
+ return d_ptr->remoteName;
+}
+
+/*!
Returns the current state of the controller.
\sa stateChanged()
@@ -478,6 +529,11 @@ void QLowEnergyController::setRemoteAddressType(
is not equal to \l UnconnectedState. The \l connected() signal is emitted
once the connection is successfully established.
+ On Linux/BlueZ systems, it is not possible to connect to the same
+ remote device using two instances of this class. The second call
+ to this function may fail with an error. This limitation may
+ be removed in future releases.
+
\sa disconnectFromDevice()
*/
void QLowEnergyController::connectToDevice()
@@ -526,6 +582,13 @@ void QLowEnergyController::disconnectFromDevice()
If the controller instance is not connected or the controller has performed
the service discovery already this function will do nothing.
+
+ \note Some platforms internally cache the service list of a device
+ which was discovered in the past. This can be problematic if the remote device
+ changed its list of services or their inclusion tree. If this behavior is a
+ problem, the best workaround is to temporarily turn Bluetooth off. This
+ causes a reset of the cache data. Currently Android exhibits such a
+ cache behavior.
*/
void QLowEnergyController::discoverServices()
{
diff --git a/src/bluetooth/qlowenergycontroller.h b/src/bluetooth/qlowenergycontroller.h
index 6c4be59e..c5a4acd3 100644
--- a/src/bluetooth/qlowenergycontroller.h
+++ b/src/bluetooth/qlowenergycontroller.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -36,6 +36,7 @@
#include <QtCore/QObject>
#include <QtBluetooth/QBluetoothAddress>
+#include <QtBluetooth/QBluetoothDeviceInfo>
#include <QtBluetooth/QBluetoothUuid>
#include <QtBluetooth/QLowEnergyService>
@@ -51,7 +52,8 @@ public:
UnknownError,
UnknownRemoteDeviceError,
NetworkError,
- InvalidBluetoothAdapterError
+ InvalidBluetoothAdapterError,
+ ConnectionError
};
enum ControllerState {
@@ -60,7 +62,7 @@ public:
ConnectedState,
DiscoveringState,
DiscoveredState,
- ClosingState,
+ ClosingState
};
enum RemoteAddressType {
@@ -69,15 +71,19 @@ public:
};
explicit QLowEnergyController(const QBluetoothAddress &remoteDevice,
+ QObject *parent = 0); // TODO Qt 6 remove ctor
+ explicit QLowEnergyController(const QBluetoothDeviceInfo &remoteDevice,
QObject *parent = 0);
explicit QLowEnergyController(const QBluetoothAddress &remoteDevice,
const QBluetoothAddress &localDevice,
- QObject *parent = 0);
+ QObject *parent = 0); // TODO Qt 6 remove ctor
~QLowEnergyController();
QBluetoothAddress localAddress() const;
QBluetoothAddress remoteAddress() const;
+ QString remoteName() const;
+
ControllerState state() const;
RemoteAddressType remoteAddressType() const;
@@ -110,4 +116,7 @@ private:
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QLowEnergyController::ControllerState)
+Q_DECLARE_METATYPE(QLowEnergyController::Error)
+
#endif // QLOWENERGYCONTROLLER_H
diff --git a/src/bluetooth/qlowenergycontroller_android.cpp b/src/bluetooth/qlowenergycontroller_android.cpp
new file mode 100644
index 00000000..f48c0e85
--- /dev/null
+++ b/src/bluetooth/qlowenergycontroller_android.cpp
@@ -0,0 +1,581 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlowenergycontroller_p.h"
+#include <QtCore/QLoggingCategory>
+#include <QtAndroidExtras/QAndroidJniEnvironment>
+
+QT_BEGIN_NAMESPACE
+
+Q_DECLARE_LOGGING_CATEGORY(QT_BT_ANDROID)
+
+QLowEnergyControllerPrivate::QLowEnergyControllerPrivate()
+ : QObject(),
+ state(QLowEnergyController::UnconnectedState),
+ error(QLowEnergyController::NoError),
+ hub(0)
+{
+}
+
+QLowEnergyControllerPrivate::~QLowEnergyControllerPrivate()
+{
+}
+
+void QLowEnergyControllerPrivate::connectToDevice()
+{
+ // required to pass unit test on default backend
+ if (remoteDevice.isNull()) {
+ qWarning() << "Invalid/null remote device address";
+ setError(QLowEnergyController::UnknownRemoteDeviceError);
+ return;
+ }
+
+ setState(QLowEnergyController::ConnectingState);
+
+ if (!hub) {
+ hub = new LowEnergyNotificationHub(remoteDevice, this);
+ connect(hub, &LowEnergyNotificationHub::connectionUpdated,
+ this, &QLowEnergyControllerPrivate::connectionUpdated);
+ connect(hub, &LowEnergyNotificationHub::servicesDiscovered,
+ this, &QLowEnergyControllerPrivate::servicesDiscovered);
+ connect(hub, &LowEnergyNotificationHub::serviceDetailsDiscoveryFinished,
+ this, &QLowEnergyControllerPrivate::serviceDetailsDiscoveryFinished);
+ connect(hub, &LowEnergyNotificationHub::characteristicRead,
+ this, &QLowEnergyControllerPrivate::characteristicRead);
+ connect(hub, &LowEnergyNotificationHub::descriptorRead,
+ this, &QLowEnergyControllerPrivate::descriptorRead);
+ connect(hub, &LowEnergyNotificationHub::characteristicWritten,
+ this, &QLowEnergyControllerPrivate::characteristicWritten);
+ connect(hub, &LowEnergyNotificationHub::descriptorWritten,
+ this, &QLowEnergyControllerPrivate::descriptorWritten);
+ connect(hub, &LowEnergyNotificationHub::characteristicChanged,
+ this, &QLowEnergyControllerPrivate::characteristicChanged);
+ connect(hub, &LowEnergyNotificationHub::serviceError,
+ this, &QLowEnergyControllerPrivate::serviceError);
+ }
+
+ if (!hub->javaObject().isValid()) {
+ qCWarning(QT_BT_ANDROID) << "Cannot initiate QtBluetoothLE";
+ setError(QLowEnergyController::ConnectionError);
+ setState(QLowEnergyController::UnconnectedState);
+ return;
+ }
+
+ bool result = hub->javaObject().callMethod<jboolean>("connect");
+ if (!result) {
+ setError(QLowEnergyController::ConnectionError);
+ setState(QLowEnergyController::UnconnectedState);
+ return;
+ }
+}
+
+void QLowEnergyControllerPrivate::disconnectFromDevice()
+{
+ /* Catch an Android timeout bug. If the device is connecting but cannot
+ * physically connect it seems to ignore the disconnect call below.
+ * At least BluetoothGattCallback.onConnectionStateChange never
+ * arrives. The next BluetoothGatt.connect() works just fine though.
+ * */
+
+ QLowEnergyController::ControllerState oldState = state;
+ setState(QLowEnergyController::ClosingState);
+
+ if (hub)
+ hub->javaObject().callMethod<void>("disconnect");
+
+ if (oldState == QLowEnergyController::ConnectingState)
+ setState(QLowEnergyController::UnconnectedState);
+}
+
+void QLowEnergyControllerPrivate::discoverServices()
+{
+ if (hub && hub->javaObject().callMethod<jboolean>("discoverServices")) {
+ qCDebug(QT_BT_ANDROID) << "Service discovery initiated";
+ } else {
+ //revert to connected state
+ setError(QLowEnergyController::NetworkError);
+ setState(QLowEnergyController::ConnectedState);
+ }
+}
+
+void QLowEnergyControllerPrivate::discoverServiceDetails(const QBluetoothUuid &service)
+{
+ if (!serviceList.contains(service)) {
+ qCWarning(QT_BT_ANDROID) << "Discovery of unknown service" << service.toString()
+ << "not possible";
+ return;
+ }
+
+ if (!hub)
+ return;
+
+ //cut leading { and trailing } {xxx-xxx}
+ QString tempUuid = service.toString();
+ tempUuid.chop(1); //remove trailing '}'
+ tempUuid.remove(0, 1); //remove first '{'
+
+ QAndroidJniEnvironment env;
+ QAndroidJniObject uuid = QAndroidJniObject::fromString(tempUuid);
+ bool result = hub->javaObject().callMethod<jboolean>("discoverServiceDetails",
+ "(Ljava/lang/String;)Z",
+ uuid.object<jstring>());
+ if (!result) {
+ QSharedPointer<QLowEnergyServicePrivate> servicePrivate =
+ serviceList.value(service);
+ if (!servicePrivate.isNull()) {
+ servicePrivate->setError(QLowEnergyService::UnknownError);
+ servicePrivate->setState(QLowEnergyService::DiscoveryRequired);
+ }
+ qCWarning(QT_BT_ANDROID) << "Cannot discover details for" << service.toString();
+ return;
+ }
+
+ qCDebug(QT_BT_ANDROID) << "Discovery of" << service << "started";
+}
+
+void QLowEnergyControllerPrivate::writeCharacteristic(
+ const QSharedPointer<QLowEnergyServicePrivate> service,
+ const QLowEnergyHandle charHandle,
+ const QByteArray &newValue,
+ bool writeWithResponse)
+{
+ //TODO don't ignore WriteWithResponse, right now we assume responses
+ Q_ASSERT(!service.isNull());
+
+ if (!service->characteristicList.contains(charHandle))
+ return;
+
+ QAndroidJniEnvironment env;
+ jbyteArray payload;
+ payload = env->NewByteArray(newValue.size());
+ env->SetByteArrayRegion(payload, 0, newValue.size(),
+ (jbyte *)newValue.constData());
+
+ bool result = false;
+ if (hub) {
+ qCDebug(QT_BT_ANDROID) << "Write characteristic with handle " << charHandle
+ << newValue.toHex() << "(service:" << service->uuid
+ << ", writeWithResponse:" << writeWithResponse << ")";
+ result = hub->javaObject().callMethod<jboolean>("writeCharacteristic", "(I[BI)Z",
+ charHandle, payload,
+ writeWithResponse ? QLowEnergyService::WriteWithResponse : QLowEnergyService::WriteWithoutResponse);
+ }
+
+ if (env->ExceptionOccurred()) {
+ env->ExceptionDescribe();
+ env->ExceptionClear();
+ result = false;
+ }
+
+ env->DeleteLocalRef(payload);
+
+ if (!result)
+ service->setError(QLowEnergyService::CharacteristicWriteError);
+}
+
+void QLowEnergyControllerPrivate::writeDescriptor(
+ const QSharedPointer<QLowEnergyServicePrivate> service,
+ const QLowEnergyHandle /*charHandle*/,
+ const QLowEnergyHandle descHandle,
+ const QByteArray &newValue)
+{
+ Q_ASSERT(!service.isNull());
+
+ QAndroidJniEnvironment env;
+ jbyteArray payload;
+ payload = env->NewByteArray(newValue.size());
+ env->SetByteArrayRegion(payload, 0, newValue.size(),
+ (jbyte *)newValue.constData());
+
+ bool result = false;
+ if (hub) {
+ qCDebug(QT_BT_ANDROID) << "Write descriptor with handle " << descHandle
+ << newValue.toHex() << "(service:" << service->uuid << ")";
+ result = hub->javaObject().callMethod<jboolean>("writeDescriptor", "(I[B)Z",
+ descHandle, payload);
+ }
+
+ if (env->ExceptionOccurred()) {
+ env->ExceptionDescribe();
+ env->ExceptionClear();
+ result = false;
+ }
+
+ env->DeleteLocalRef(payload);
+
+ if (!result)
+ service->setError(QLowEnergyService::DescriptorWriteError);
+}
+
+void QLowEnergyControllerPrivate::readCharacteristic(
+ const QSharedPointer<QLowEnergyServicePrivate> service,
+ const QLowEnergyHandle charHandle)
+{
+ Q_ASSERT(!service.isNull());
+
+ if (!service->characteristicList.contains(charHandle))
+ return;
+
+ QAndroidJniEnvironment env;
+ bool result = false;
+ if (hub) {
+ qCDebug(QT_BT_ANDROID) << "Read characteristic with handle"
+ << charHandle << service->uuid;
+ result = hub->javaObject().callMethod<jboolean>("readCharacteristic",
+ "(I)Z", charHandle);
+ }
+
+ if (env->ExceptionOccurred()) {
+ env->ExceptionDescribe();
+ env->ExceptionClear();
+ result = false;
+ }
+
+ if (!result)
+ service->setError(QLowEnergyService::CharacteristicWriteError);
+}
+
+void QLowEnergyControllerPrivate::readDescriptor(
+ const QSharedPointer<QLowEnergyServicePrivate> service,
+ const QLowEnergyHandle /*charHandle*/,
+ const QLowEnergyHandle descriptorHandle)
+{
+ Q_ASSERT(!service.isNull());
+
+ QAndroidJniEnvironment env;
+ bool result = false;
+ if (hub) {
+ qCDebug(QT_BT_ANDROID) << "Read descriptor with handle"
+ << descriptorHandle << service->uuid;
+ result = hub->javaObject().callMethod<jboolean>("readDescriptor",
+ "(I)Z", descriptorHandle);
+ }
+
+ if (env->ExceptionOccurred()) {
+ env->ExceptionDescribe();
+ env->ExceptionClear();
+ result = false;
+ }
+
+ if (!result)
+ service->setError(QLowEnergyService::DescriptorWriteError);
+}
+
+void QLowEnergyControllerPrivate::connectionUpdated(
+ QLowEnergyController::ControllerState newState,
+ QLowEnergyController::Error errorCode)
+{
+ Q_Q(QLowEnergyController);
+
+ const QLowEnergyController::ControllerState oldState = state;
+ qCDebug(QT_BT_ANDROID) << "Connection updated:"
+ << "error:" << errorCode
+ << "oldState:" << oldState
+ << "newState:" << newState;
+
+ if (errorCode != QLowEnergyController::NoError) {
+ // ConnectionError if transition from Connecting to Connected
+ if (oldState == QLowEnergyController::ConnectingState) {
+ setError(QLowEnergyController::ConnectionError);
+ /* There is a bug in Android, when connecting to an unconnectable
+ * device. The connection times out and Android sends error code
+ * 133 (doesn't exist) and STATE_CONNECTED. A subsequent disconnect()
+ * call never sends a STATE_DISCONNECTED either.
+ * As workaround we will trigger disconnect when we encounter
+ * error during connect attempt. This leaves the controller
+ * in a cleaner state.
+ * */
+ newState = QLowEnergyController::UnconnectedState;
+ }
+ else
+ setError(errorCode);
+ }
+
+ setState(newState);
+ if (newState == QLowEnergyController::UnconnectedState
+ && !(oldState == QLowEnergyController::UnconnectedState
+ || oldState == QLowEnergyController::ConnectingState)) {
+ emit q->disconnected();
+ } else if (newState == QLowEnergyController::ConnectedState
+ && oldState != QLowEnergyController::ConnectedState ) {
+ emit q->connected();
+ }
+}
+
+void QLowEnergyControllerPrivate::servicesDiscovered(
+ QLowEnergyController::Error errorCode, const QString &foundServices)
+{
+ Q_Q(QLowEnergyController);
+
+ if (errorCode == QLowEnergyController::NoError) {
+ //Android delivers all services in one go
+ const QStringList list = foundServices.split(QStringLiteral(" "), QString::SkipEmptyParts);
+ foreach (const QString &entry, list) {
+ const QBluetoothUuid service(entry);
+ if (service.isNull())
+ return;
+
+ QLowEnergyServicePrivate *priv = new QLowEnergyServicePrivate();
+ priv->uuid = service;
+ priv->setController(this);
+
+ QSharedPointer<QLowEnergyServicePrivate> pointer(priv);
+ serviceList.insert(service, pointer);
+
+ emit q->serviceDiscovered(QBluetoothUuid(entry));
+ }
+
+ setState(QLowEnergyController::DiscoveredState);
+ emit q->discoveryFinished();
+ } else {
+ setError(errorCode);
+ setState(QLowEnergyController::ConnectedState);
+ }
+}
+
+void QLowEnergyControllerPrivate::serviceDetailsDiscoveryFinished(
+ const QString &serviceUuid, int startHandle, int endHandle)
+{
+ const QBluetoothUuid service(serviceUuid);
+ if (!serviceList.contains(service)) {
+ qCWarning(QT_BT_ANDROID) << "Discovery done of unknown service:"
+ << service.toString();
+ return;
+ }
+
+ //update service data
+ QSharedPointer<QLowEnergyServicePrivate> pointer =
+ serviceList.value(service);
+ pointer->startHandle = startHandle;
+ pointer->endHandle = endHandle;
+
+ if (hub && hub->javaObject().isValid()) {
+ QAndroidJniObject uuid = QAndroidJniObject::fromString(serviceUuid);
+ QAndroidJniObject javaIncludes = hub->javaObject().callObjectMethod(
+ "includedServices",
+ "(Ljava/lang/String;)Ljava/lang/String;",
+ uuid.object<jstring>());
+ if (javaIncludes.isValid()) {
+ const QStringList list = javaIncludes.toString()
+ .split(QStringLiteral(" "),
+ QString::SkipEmptyParts);
+ foreach (const QString &entry, list) {
+ const QBluetoothUuid service(entry);
+ if (service.isNull())
+ return;
+
+ pointer->includedServices.append(service);
+
+ // update the type of the included service
+ QSharedPointer<QLowEnergyServicePrivate> otherService =
+ serviceList.value(service);
+ if (!otherService.isNull())
+ otherService->type |= QLowEnergyService::IncludedService;
+ }
+ }
+ }
+
+ qCDebug(QT_BT_ANDROID) << "Service" << serviceUuid << "discovered (start:"
+ << startHandle << "end:" << endHandle << ")" << pointer.data();
+
+ pointer->setState(QLowEnergyService::ServiceDiscovered);
+}
+
+void QLowEnergyControllerPrivate::characteristicRead(
+ const QBluetoothUuid &serviceUuid, int handle,
+ const QBluetoothUuid &charUuid, int properties, const QByteArray &data)
+{
+ if (!serviceList.contains(serviceUuid))
+ return;
+
+ QSharedPointer<QLowEnergyServicePrivate> service =
+ serviceList.value(serviceUuid);
+ QLowEnergyHandle charHandle = handle;
+
+ QLowEnergyServicePrivate::CharData &charDetails =
+ service->characteristicList[charHandle];
+
+ //Android uses same property value as Qt which is the Bluetooth LE standard
+ charDetails.properties = QLowEnergyCharacteristic::PropertyType(properties);
+ charDetails.uuid = charUuid;
+ charDetails.value = data;
+ //value handle always one larger than characteristics value handle
+ charDetails.valueHandle = charHandle + 1;
+
+ if (service->state == QLowEnergyService::ServiceDiscovered) {
+ QLowEnergyCharacteristic characteristic = characteristicForHandle(charHandle);
+ if (!characteristic.isValid()) {
+ qCWarning(QT_BT_ANDROID) << "characteristicRead: Cannot find characteristic";
+ return;
+ }
+ emit service->characteristicRead(characteristic, data);
+ }
+}
+
+void QLowEnergyControllerPrivate::descriptorRead(
+ const QBluetoothUuid &serviceUuid, const QBluetoothUuid &charUuid,
+ int descHandle, const QBluetoothUuid &descUuid, const QByteArray &data)
+{
+ if (!serviceList.contains(serviceUuid))
+ return;
+
+ QSharedPointer<QLowEnergyServicePrivate> service =
+ serviceList.value(serviceUuid);
+
+ bool entryUpdated = false;
+ foreach (QLowEnergyHandle charHandle, service->characteristicList.keys()) {
+ QLowEnergyServicePrivate::CharData &charDetails =
+ service->characteristicList[charHandle];
+ if (charDetails.uuid != charUuid)
+ continue;
+
+ // new entry created if it doesn't exist
+ QLowEnergyServicePrivate::DescData &descDetails =
+ charDetails.descriptorList[descHandle];
+ descDetails.uuid = descUuid;
+ descDetails.value = data;
+ entryUpdated = true;
+ break;
+ }
+
+ if (!entryUpdated) {
+ qCWarning(QT_BT_ANDROID) << "Cannot find/update descriptor"
+ << descUuid << charUuid << serviceUuid;
+ } else if (service->state == QLowEnergyService::ServiceDiscovered){
+ QLowEnergyDescriptor descriptor = descriptorForHandle(descHandle);
+ if (!descriptor.isValid()) {
+ qCWarning(QT_BT_ANDROID) << "descriptorRead: Cannot find descriptor";
+ return;
+ }
+ emit service->descriptorRead(descriptor, data);
+ }
+}
+
+void QLowEnergyControllerPrivate::characteristicWritten(
+ int charHandle, const QByteArray &data, QLowEnergyService::ServiceError errorCode)
+{
+ QSharedPointer<QLowEnergyServicePrivate> service =
+ serviceForHandle(charHandle);
+ if (service.isNull())
+ return;
+
+ qCDebug(QT_BT_ANDROID) << "Characteristic write confirmation" << service->uuid
+ << charHandle << data.toHex() << errorCode;
+
+ if (errorCode != QLowEnergyService::NoError) {
+ service->setError(errorCode);
+ return;
+ }
+
+ QLowEnergyCharacteristic characteristic = characteristicForHandle(charHandle);
+ if (!characteristic.isValid()) {
+ qCWarning(QT_BT_ANDROID) << "characteristicWritten: Cannot find characteristic";
+ return;
+ }
+
+ // only update cache when property is readable. Otherwise it remains
+ // empty.
+ if (characteristic.properties() & QLowEnergyCharacteristic::Read)
+ updateValueOfCharacteristic(charHandle, data, false);
+ emit service->characteristicWritten(characteristic, data);
+}
+
+void QLowEnergyControllerPrivate::descriptorWritten(
+ int descHandle, const QByteArray &data, QLowEnergyService::ServiceError errorCode)
+{
+ QSharedPointer<QLowEnergyServicePrivate> service =
+ serviceForHandle(descHandle);
+ if (service.isNull())
+ return;
+
+ qCDebug(QT_BT_ANDROID) << "Descriptor write confirmation" << service->uuid
+ << descHandle << data.toHex() << errorCode;
+
+ if (errorCode != QLowEnergyService::NoError) {
+ service->setError(errorCode);
+ return;
+ }
+
+ QLowEnergyDescriptor descriptor = descriptorForHandle(descHandle);
+ if (!descriptor.isValid()) {
+ qCWarning(QT_BT_ANDROID) << "descriptorWritten: Cannot find descriptor";
+ return;
+ }
+
+ updateValueOfDescriptor(descriptor.characteristicHandle(),
+ descHandle, data, false);
+ emit service->descriptorWritten(descriptor, data);
+}
+
+void QLowEnergyControllerPrivate::characteristicChanged(
+ int charHandle, const QByteArray &data)
+{
+ QSharedPointer<QLowEnergyServicePrivate> service =
+ serviceForHandle(charHandle);
+ if (service.isNull())
+ return;
+
+ qCDebug(QT_BT_ANDROID) << "Characteristic change notification" << service->uuid
+ << charHandle << data.toHex();
+
+ QLowEnergyCharacteristic characteristic = characteristicForHandle(charHandle);
+ if (!characteristic.isValid()) {
+ qCWarning(QT_BT_ANDROID) << "characteristicChanged: Cannot find characteristic";
+ return;
+ }
+
+ // only update cache when property is readable. Otherwise it remains
+ // empty.
+ if (characteristic.properties() & QLowEnergyCharacteristic::Read)
+ updateValueOfCharacteristic(characteristic.attributeHandle(),
+ data, false);
+ emit service->characteristicChanged(characteristic, data);
+}
+
+void QLowEnergyControllerPrivate::serviceError(
+ int attributeHandle, QLowEnergyService::ServiceError errorCode)
+{
+ // ignore call if it isn't really an error
+ if (errorCode == QLowEnergyService::NoError)
+ return;
+
+ QSharedPointer<QLowEnergyServicePrivate> service =
+ serviceForHandle(attributeHandle);
+ Q_ASSERT(!service.isNull());
+
+ // ATM we don't really use attributeHandle but later on we might
+ // want to associate the error code with a char or desc
+ service->setError(errorCode);
+}
+
+QT_END_NAMESPACE
diff --git a/src/bluetooth/qlowenergycontroller_bluez.cpp b/src/bluetooth/qlowenergycontroller_bluez.cpp
index 1a3066df..bb490ba9 100644
--- a/src/bluetooth/qlowenergycontroller_bluez.cpp
+++ b/src/bluetooth/qlowenergycontroller_bluez.cpp
@@ -1,8 +1,8 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2013 Javier S. Pedro <maemo@javispedro.com>
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -216,6 +216,12 @@ QLowEnergyControllerPrivate::~QLowEnergyControllerPrivate()
void QLowEnergyControllerPrivate::connectToDevice()
{
+ if (remoteDevice.isNull()) {
+ qCWarning(QT_BT_BLUEZ) << "Invalid/null remote device address";
+ setError(QLowEnergyController::UnknownRemoteDeviceError);
+ return;
+ }
+
setState(QLowEnergyController::ConnectingState);
if (l2cpSocket)
delete l2cpSocket;
@@ -235,7 +241,7 @@ void QLowEnergyControllerPrivate::connectToDevice()
int sockfd = l2cpSocket->socketDescriptor();
if (sockfd < 0) {
qCWarning(QT_BT_BLUEZ) << "l2cp socket not initialised";
- setError(QLowEnergyController::UnknownError);
+ setError(QLowEnergyController::ConnectionError);
setState(QLowEnergyController::UnconnectedState);
return;
}
@@ -250,7 +256,7 @@ void QLowEnergyControllerPrivate::connectToDevice()
// bind the socket to the local device
if (::bind(sockfd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
qCWarning(QT_BT_BLUEZ) << qt_error_string(errno);
- setError(QLowEnergyController::UnknownError);
+ setError(QLowEnergyController::ConnectionError);
setState(QLowEnergyController::UnconnectedState);
return;
}
@@ -698,6 +704,11 @@ void QLowEnergyControllerPrivate::processReply(
const QLowEnergyHandle charHandle = (handleData & 0xffff);
const QLowEnergyHandle descriptorHandle = ((handleData >> 16) & 0xffff);
+ QSharedPointer<QLowEnergyServicePrivate> service = serviceForHandle(charHandle);
+ Q_ASSERT(!service.isNull());
+ bool isServiceDiscoveryRun
+ = !(service->state == QLowEnergyService::ServiceDiscovered);
+
if (isErrorResponse) {
Q_ASSERT(!encryptionChangePending);
encryptionChangePending = increaseEncryptLevelfRequired(response.constData()[4]);
@@ -706,6 +717,12 @@ void QLowEnergyControllerPrivate::processReply(
// Retry the same command again once the change has happened
openRequests.prepend(request);
break;
+ } else if (!isServiceDiscoveryRun) {
+ // not encryption problem -> abort readCharacteristic()/readDescriptor() run
+ if (!descriptorHandle)
+ emit service->error(QLowEnergyService::CharacteristicReadError);
+ else
+ emit service->error(QLowEnergyService::DescriptorReadError);
}
} else {
if (!descriptorHandle)
@@ -715,18 +732,32 @@ void QLowEnergyControllerPrivate::processReply(
response.mid(1), NEW_VALUE);
if (response.size() == mtuSize) {
+ qCDebug(QT_BT_BLUEZ) << "Switching to blob reads for"
+ << charHandle << descriptorHandle
+ << service->characteristicList[charHandle].uuid.toString();
// Potentially more data -> switch to blob reads
readServiceValuesByOffset(handleData, mtuSize-1,
request.reference2.toBool());
break;
+ } else if (!isServiceDiscoveryRun) {
+ // readCharacteristic() or readDescriptor() ongoing
+ if (!descriptorHandle) {
+ QLowEnergyCharacteristic ch(service, charHandle);
+ emit service->characteristicRead(ch, response.mid(1));
+ } else {
+ QLowEnergyDescriptor descriptor(service, charHandle, descriptorHandle);
+ emit service->descriptorRead(descriptor, response.mid(1));
+ }
+ break;
}
}
- if (request.reference2.toBool()) {
+ if (request.reference2.toBool() && isServiceDiscoveryRun) {
+ // we only run into this code path during the initial service discovery
+ // and not when processing readCharacteristics() after service discovery
+
//last characteristic -> progress to descriptor discovery
//last descriptor -> service discovery is done
- QSharedPointer<QLowEnergyServicePrivate> service = serviceForHandle(charHandle);
- Q_ASSERT(!service.isNull());
if (!descriptorHandle)
discoverServiceDescriptors(service->uuid);
else
@@ -737,13 +768,16 @@ void QLowEnergyControllerPrivate::processReply(
case ATT_OP_READ_BLOB_REQUEST: //error case
case ATT_OP_READ_BLOB_RESPONSE:
{
- //Reading characteristic or descriptor with value longer than MTU
+ //Reading characteristic or descriptor with value longer value than MTU
Q_ASSERT(request.command == ATT_OP_READ_BLOB_REQUEST);
uint handleData = request.reference.toUInt();
const QLowEnergyHandle charHandle = (handleData & 0xffff);
const QLowEnergyHandle descriptorHandle = ((handleData >> 16) & 0xffff);
+ QSharedPointer<QLowEnergyServicePrivate> service = serviceForHandle(charHandle);
+ Q_ASSERT(!service.isNull());
+
/*
* READ_BLOB does not require encryption setup code. BLOB commands
* are only issued after read request if the read request is too long
@@ -757,18 +791,33 @@ void QLowEnergyControllerPrivate::processReply(
else
length = updateValueOfDescriptor(charHandle, descriptorHandle,
response.mid(1), APPEND_VALUE);
+
if (response.size() == mtuSize) {
readServiceValuesByOffset(handleData, length,
request.reference2.toBool());
break;
+ } else if (service->state == QLowEnergyService::ServiceDiscovered) {
+ // readCharacteristic() or readDescriptor() ongoing
+ if (!descriptorHandle) {
+ QLowEnergyCharacteristic ch(service, charHandle);
+ emit service->characteristicRead(ch, ch.value());
+ } else {
+ QLowEnergyDescriptor descriptor(service, charHandle, descriptorHandle);
+ emit service->descriptorRead(descriptor, descriptor.value());
+ }
+ break;
}
+ } else {
+ qWarning() << "READ BLOB for char:" << charHandle
+ << "descriptor:" << descriptorHandle << "on service"
+ << service->uuid.toString() << "failed (service discovery run:"
+ << (service->state == QLowEnergyService::ServiceDiscovered) << ")";
}
if (request.reference2.toBool()) {
//last overlong characteristic -> progress to descriptor discovery
//last overlong descriptor -> service discovery is done
- QSharedPointer<QLowEnergyServicePrivate> service = serviceForHandle(charHandle);
- Q_ASSERT(!service.isNull());
+
if (!descriptorHandle)
discoverServiceDescriptors(service->uuid);
else
@@ -918,8 +967,9 @@ void QLowEnergyControllerPrivate::processReply(
const QByteArray newValue = request.reference2.toByteArray();
if (!descriptorHandle) {
- updateValueOfCharacteristic(charHandle, newValue, NEW_VALUE);
QLowEnergyCharacteristic ch(service, charHandle);
+ if (ch.properties() & QLowEnergyCharacteristic::Read)
+ updateValueOfCharacteristic(charHandle, newValue, NEW_VALUE);
emit service->characteristicWritten(ch, newValue);
} else {
updateValueOfDescriptor(charHandle, descriptorHandle, newValue, NEW_VALUE);
@@ -986,8 +1036,9 @@ void QLowEnergyControllerPrivate::processReply(
attrHandle, newValue, NEW_VALUE);
emit service->descriptorWritten(descriptor, newValue);
} else {
- updateValueOfCharacteristic(attrHandle, newValue, NEW_VALUE);
QLowEnergyCharacteristic ch(service, attrHandle);
+ if (ch.properties() & QLowEnergyCharacteristic::Read)
+ updateValueOfCharacteristic(attrHandle, newValue, NEW_VALUE);
emit service->characteristicWritten(ch, newValue);
}
}
@@ -1072,7 +1123,8 @@ void QLowEnergyControllerPrivate::sendReadByTypeRequest(
/*!
\internal
- Reads the value of characteristics and descriptors.
+ Reads all values of specific characteristic and descriptor. This function is
+ used during the initial service discovery process.
\a readCharacteristics determines whether we intend to read a characteristic;
otherwise we read a descriptor.
@@ -1083,10 +1135,10 @@ void QLowEnergyControllerPrivate::readServiceValues(
quint8 packet[READ_REQUEST_HEADER_SIZE];
if (QT_BT_BLUEZ().isDebugEnabled()) {
if (readCharacteristics)
- qCDebug(QT_BT_BLUEZ) << "Reading characteristic values for"
+ qCDebug(QT_BT_BLUEZ) << "Reading all characteristic values for"
<< serviceUuid.toString();
else
- qCDebug(QT_BT_BLUEZ) << "Reading descriptor values for"
+ qCDebug(QT_BT_BLUEZ) << "Reading all descriptor values for"
<< serviceUuid.toString();
}
@@ -1246,7 +1298,8 @@ void QLowEnergyControllerPrivate::processUnsolicitedReply(const QByteArray &payl
const QLowEnergyCharacteristic ch = characteristicForHandle(changedHandle);
if (ch.isValid() && ch.handle() == changedHandle) {
- updateValueOfCharacteristic(ch.attributeHandle(), payload.mid(3), NEW_VALUE);
+ if (ch.properties() & QLowEnergyCharacteristic::Read)
+ updateValueOfCharacteristic(ch.attributeHandle(), payload.mid(3), NEW_VALUE);
emit ch.d_ptr->characteristicChanged(ch, payload.mid(3));
} else {
qCWarning(QT_BT_BLUEZ) << "Cannot find matching characteristic for "
@@ -1574,6 +1627,84 @@ void QLowEnergyControllerPrivate::writeDescriptor(
}
/*!
+ \internal
+
+ Reads the value of one specific characteristic.
+ */
+void QLowEnergyControllerPrivate::readCharacteristic(
+ const QSharedPointer<QLowEnergyServicePrivate> service,
+ const QLowEnergyHandle charHandle)
+{
+ Q_ASSERT(!service.isNull());
+ if (!service->characteristicList.contains(charHandle))
+ return;
+
+ const QLowEnergyServicePrivate::CharData &charDetails
+ = service->characteristicList[charHandle];
+ if (!(charDetails.properties & QLowEnergyCharacteristic::Read)) {
+ // if this succeeds the device has a bug, char is advertised as
+ // non-readable. We try to be permissive and let the remote
+ // device answer to the read attempt
+ qCWarning(QT_BT_BLUEZ) << "Reading non-readable char" << charHandle;
+ }
+
+ quint8 packet[READ_REQUEST_HEADER_SIZE];
+ packet[0] = ATT_OP_READ_REQUEST;
+ bt_put_unaligned(htobs(charDetails.valueHandle), (quint16 *) &packet[1]);
+
+ QByteArray data(READ_REQUEST_HEADER_SIZE, Qt::Uninitialized);
+ memcpy(data.data(), packet, READ_REQUEST_HEADER_SIZE);
+
+ qCDebug(QT_BT_BLUEZ) << "Targeted reading characteristic" << hex << charHandle;
+
+ Request request;
+ request.payload = data;
+ request.command = ATT_OP_READ_REQUEST;
+ request.reference = charHandle;
+ // reference2 not really required but false prevents service discovery
+ // code from running in ATT_OP_READ_RESPONSE handler
+ request.reference2 = false;
+ openRequests.enqueue(request);
+
+ sendNextPendingRequest();
+}
+
+void QLowEnergyControllerPrivate::readDescriptor(
+ const QSharedPointer<QLowEnergyServicePrivate> service,
+ const QLowEnergyHandle charHandle,
+ const QLowEnergyHandle descriptorHandle)
+{
+ Q_ASSERT(!service.isNull());
+ if (!service->characteristicList.contains(charHandle))
+ return;
+
+ const QLowEnergyServicePrivate::CharData &charDetails
+ = service->characteristicList[charHandle];
+ if (!charDetails.descriptorList.contains(descriptorHandle))
+ return;
+
+ quint8 packet[READ_REQUEST_HEADER_SIZE];
+ packet[0] = ATT_OP_READ_REQUEST;
+ bt_put_unaligned(htobs(descriptorHandle), (quint16 *) &packet[1]);
+
+ QByteArray data(READ_REQUEST_HEADER_SIZE, Qt::Uninitialized);
+ memcpy(data.data(), packet, READ_REQUEST_HEADER_SIZE);
+
+ qCDebug(QT_BT_BLUEZ) << "Targeted reading descriptor" << hex << descriptorHandle;
+
+ Request request;
+ request.payload = data;
+ request.command = ATT_OP_READ_REQUEST;
+ request.reference = (charHandle | (descriptorHandle << 16));
+ // reference2 not really required but false prevents service discovery
+ // code from running in ATT_OP_READ_RESPONSE handler
+ request.reference2 = false;
+ openRequests.enqueue(request);
+
+ sendNextPendingRequest();
+}
+
+/*!
* Returns true if the encryption change was successfully requested.
* The request is triggered if we got a related ATT error.
*/
diff --git a/src/bluetooth/qlowenergycontroller_osx.mm b/src/bluetooth/qlowenergycontroller_osx.mm
new file mode 100644
index 00000000..c4628069
--- /dev/null
+++ b/src/bluetooth/qlowenergycontroller_osx.mm
@@ -0,0 +1,975 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2013 Javier S. Pedro <maemo@javispedro.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "osx/osxbtutility_p.h"
+#include "osx/uistrings_p.h"
+
+#include "qlowenergyserviceprivate_p.h"
+#include "qlowenergycontroller_osx_p.h"
+#include "qbluetoothlocaldevice.h"
+#include "qbluetoothdeviceinfo.h"
+#include "qlowenergycontroller.h"
+#include "qbluetoothuuid.h"
+
+#include <QtCore/qloggingcategory.h>
+#include <QtCore/qsharedpointer.h>
+#include <QtCore/qbytearray.h>
+#include <QtCore/qsysinfo.h>
+#include <QtCore/qglobal.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qlist.h>
+
+#define OSX_D_PTR QLowEnergyControllerPrivateOSX *osx_d_ptr = static_cast<QLowEnergyControllerPrivateOSX *>(d_ptr)
+
+QT_BEGIN_NAMESPACE
+
+namespace {
+
+
+class QLowEnergyControllerMetaTypes
+{
+public:
+ QLowEnergyControllerMetaTypes()
+ {
+ qRegisterMetaType<QLowEnergyController::ControllerState>();
+ qRegisterMetaType<QLowEnergyController::Error>();
+ }
+} qLowEnergyControllerMetaTypes;
+
+
+typedef QSharedPointer<QLowEnergyServicePrivate> ServicePrivate;
+
+// Convenience function, can return a smart pointer that 'isNull'.
+ServicePrivate qt_createLEService(QLowEnergyControllerPrivateOSX *controller, CBService *cbService, bool included)
+{
+ Q_ASSERT_X(controller, Q_FUNC_INFO, "invalid controller (null)");
+ Q_ASSERT_X(cbService, Q_FUNC_INFO, "invalid service (nil)");
+
+ CBUUID *const cbUuid = cbService.UUID;
+ if (!cbUuid) {
+ qCDebug(QT_BT_OSX) << Q_FUNC_INFO << "invalid service, "
+ "UUID is nil";
+ return ServicePrivate();
+ }
+
+ const QBluetoothUuid qtUuid(OSXBluetooth::qt_uuid(cbUuid));
+ if (qtUuid.isNull()) // Conversion error is reported by qt_uuid.
+ return ServicePrivate();
+
+ ServicePrivate newService(new QLowEnergyServicePrivate);
+ newService->uuid = qtUuid;
+ newService->setController(controller);
+
+ if (included)
+ newService->type |= QLowEnergyService::IncludedService;
+
+ // TODO: isPrimary is ... always 'NO' - to be investigated.
+ /*
+ #if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9, __IPHONE_6_0)
+ using OSXBluetooth::qt_OS_limit;
+ if (QSysInfo::MacintoshVersion >= qt_OS_limit(QSysInfo::MV_10_9, QSysInfo::MV_IOS_6_0)) {
+ if (!cbService.isPrimary) {
+ // Our guess included/not was probably wrong.
+ newService->type &= ~QLowEnergyService::PrimaryService;
+ newService->type |= QLowEnergyService::IncludedService;
+ }
+ }
+ #endif
+ */
+ // No such property before 10_9/6_0.
+ return newService;
+}
+
+typedef QList<QBluetoothUuid> UUIDList;
+
+UUIDList qt_servicesUuids(NSArray *services)
+{
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ if (!services || !services.count)
+ return UUIDList();
+
+ UUIDList uuids;
+
+ for (CBService *s in services)
+ uuids.append(OSXBluetooth::qt_uuid(s.UUID));
+
+ return uuids;
+}
+
+}
+
+QLowEnergyControllerPrivateOSX::QLowEnergyControllerPrivateOSX(QLowEnergyController *q)
+ : q_ptr(q),
+ isConnecting(false),
+ lastError(QLowEnergyController::NoError),
+ controllerState(QLowEnergyController::UnconnectedState),
+ addressType(QLowEnergyController::PublicAddress)
+{
+ // This is the "wrong" constructor - no valid device UUID to connect later.
+ Q_ASSERT_X(q, Q_FUNC_INFO, "invalid q_ptr (null)");
+ // We still create a manager, to simplify error handling later.
+ centralManager.reset([[ObjCCentralManager alloc] initWithDelegate:this]);
+ if (!centralManager) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO
+ << "failed to initialize central manager";
+ }
+}
+
+QLowEnergyControllerPrivateOSX::QLowEnergyControllerPrivateOSX(QLowEnergyController *q,
+ const QBluetoothDeviceInfo &deviceInfo)
+ : q_ptr(q),
+ deviceUuid(deviceInfo.deviceUuid()),
+ deviceName(deviceInfo.name()),
+ isConnecting(false),
+ lastError(QLowEnergyController::NoError),
+ controllerState(QLowEnergyController::UnconnectedState),
+ addressType(QLowEnergyController::PublicAddress)
+{
+ Q_ASSERT_X(q, Q_FUNC_INFO, "invalid q_ptr (null)");
+ centralManager.reset([[ObjCCentralManager alloc] initWithDelegate:this]);
+ if (!centralManager) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO
+ << "failed to initialize central manager";
+ }
+}
+
+QLowEnergyControllerPrivateOSX::~QLowEnergyControllerPrivateOSX()
+{
+}
+
+bool QLowEnergyControllerPrivateOSX::isValid() const
+{
+ // isValid means only "was able to allocate all resources",
+ // nothing more.
+ return centralManager;
+}
+
+void QLowEnergyControllerPrivateOSX::LEnotSupported()
+{
+ // Report as an error. But this should not be possible
+ // actually: before connecting to any device, we have
+ // to discover it, if it was discovered ... LE _must_
+ // be supported.
+}
+
+void QLowEnergyControllerPrivateOSX::connectSuccess()
+{
+ Q_ASSERT_X(controllerState == QLowEnergyController::ConnectingState,
+ Q_FUNC_INFO, "invalid state");
+
+ controllerState = QLowEnergyController::ConnectedState;
+
+ if (!isConnecting) {
+ emit q_ptr->stateChanged(QLowEnergyController::ConnectedState);
+ emit q_ptr->connected();
+ }
+}
+
+void QLowEnergyControllerPrivateOSX::serviceDiscoveryFinished(LEServices services)
+{
+ Q_ASSERT_X(controllerState == QLowEnergyController::DiscoveringState,
+ Q_FUNC_INFO, "invalid state");
+
+ using namespace OSXBluetooth;
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ // Now we have to traverse the discovered services tree.
+ // Essentially it's an iterative version of more complicated code from the
+ // OSXBTCentralManager's code.
+ // All Obj-C entities either auto-release, or guarded by ObjCScopedReferences.
+ if (services && [services count]) {
+ QMap<QBluetoothUuid, CBService *> discoveredCBServices;
+ //1. The first pass - none of this services is 'included' yet (we'll discover 'included'
+ // during the pass 2); we also ignore duplicates (== services with the same UUID)
+ // - since we do not have a way to distinguish them later
+ // (our API is using uuids when creating QLowEnergyServices).
+ for (CBService *cbService in services.data()) {
+ const ServicePrivate newService(qt_createLEService(this, cbService, false));
+ if (!newService.data())
+ continue;
+ if (discoveredServices.contains(newService->uuid)) {
+ // It's a bit stupid we first created it ...
+ qCDebug(QT_BT_OSX) << Q_FUNC_INFO << "discovered service with a duplicated UUID "
+ << newService->uuid;
+ continue;
+ }
+ discoveredServices.insert(newService->uuid, newService);
+ discoveredCBServices.insert(newService->uuid, cbService);
+ }
+
+ ObjCStrongReference<NSMutableArray> toVisit([[NSMutableArray alloc] initWithArray:services], false);
+ ObjCStrongReference<NSMutableArray> toVisitNext([[NSMutableArray alloc] init], false);
+ ObjCStrongReference<NSMutableSet> visited([[NSMutableSet alloc] init], false);
+
+ while (true) {
+ for (NSUInteger i = 0, e = [toVisit count]; i < e; ++i) {
+ CBService *const s = [toVisit objectAtIndex:i];
+ if (![visited containsObject:s]) {
+ [visited addObject:s];
+ if (s.includedServices && s.includedServices.count)
+ [toVisitNext addObjectsFromArray:s.includedServices];
+ }
+
+ const QBluetoothUuid uuid(qt_uuid(s.UUID));
+ if (discoveredServices.contains(uuid) && discoveredCBServices.value(uuid) == s) {
+ ServicePrivate qtService(discoveredServices.value(uuid));
+ // Add included UUIDs:
+ qtService->includedServices.append(qt_servicesUuids(s.includedServices));
+ }// Else - we ignored this CBService object.
+ }
+
+ if (![toVisitNext count])
+ break;
+
+ for (NSUInteger i = 0, e = [toVisitNext count]; i < e; ++i) {
+ CBService *const s = [toVisitNext objectAtIndex:i];
+ const QBluetoothUuid uuid(qt_uuid(s.UUID));
+ if (discoveredServices.contains(uuid)) {
+ if (discoveredCBServices.value(uuid) == s) {
+ ServicePrivate qtService(discoveredServices.value(uuid));
+ qtService->type |= QLowEnergyService::IncludedService;
+ } // Else this is the duplicate we ignored already.
+ } else {
+ // Oh, we do not even have it yet???
+ ServicePrivate newService(qt_createLEService(this, s, true));
+ discoveredServices.insert(newService->uuid, newService);
+ discoveredCBServices.insert(newService->uuid, s);
+ }
+ }
+
+ toVisit.resetWithoutRetain(toVisitNext.take());
+ toVisitNext.resetWithoutRetain([[NSMutableArray alloc] init]);
+ }
+ } else {
+ qCDebug(QT_BT_OSX) << Q_FUNC_INFO << "no services found";
+ }
+
+ foreach (const QBluetoothUuid &uuid, discoveredServices.keys()) {
+ QMetaObject::invokeMethod(q_ptr, "serviceDiscovered", Qt::QueuedConnection,
+ Q_ARG(QBluetoothUuid, uuid));
+ }
+
+ controllerState = QLowEnergyController::DiscoveredState;
+ QMetaObject::invokeMethod(q_ptr, "stateChanged", Qt::QueuedConnection,
+ Q_ARG(QLowEnergyController::ControllerState, controllerState));
+ QMetaObject::invokeMethod(q_ptr, "discoveryFinished", Qt::QueuedConnection);
+}
+
+void QLowEnergyControllerPrivateOSX::serviceDetailsDiscoveryFinished(LEService service)
+{
+ Q_ASSERT_X(!service.isNull(), Q_FUNC_INFO, "invalid service (null)");
+
+ QT_BT_MAC_AUTORELEASEPOOL;
+
+ if (!discoveredServices.contains(service->uuid)) {
+ qCDebug(QT_BT_OSX) << Q_FUNC_INFO << "unknown service uuid: "
+ << service->uuid;
+ return;
+ }
+
+ ServicePrivate qtService(discoveredServices.value(service->uuid));
+ // Assert on handles?
+ qtService->startHandle = service->startHandle;
+ qtService->endHandle = service->endHandle;
+ qtService->characteristicList = service->characteristicList;
+
+ qtService->setState(QLowEnergyService::ServiceDiscovered);
+}
+
+void QLowEnergyControllerPrivateOSX::characteristicReadNotification(QLowEnergyHandle charHandle,
+ const QByteArray &value)
+{
+ Q_ASSERT_X(charHandle, Q_FUNC_INFO, "invalid characteristic handle(0)");
+
+ ServicePrivate service(serviceForHandle(charHandle));
+ if (service.isNull())
+ return;
+
+ QLowEnergyCharacteristic characteristic(characteristicForHandle(charHandle));
+ if (!characteristic.isValid()) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "unknown characteristic";
+ return;
+ }
+
+ if (characteristic.properties() & QLowEnergyCharacteristic::Read)
+ updateValueOfCharacteristic(charHandle, value, false);
+
+ emit service->characteristicRead(characteristic, value);
+}
+
+void QLowEnergyControllerPrivateOSX::characteristicWriteNotification(QLowEnergyHandle charHandle,
+ const QByteArray &value)
+{
+ Q_ASSERT_X(charHandle, Q_FUNC_INFO, "invalid characteristic handle(0)");
+
+ ServicePrivate service(serviceForHandle(charHandle));
+ if (service.isNull()) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "can not find service for characteristic handle "
+ << charHandle;
+ return;
+ }
+
+ QLowEnergyCharacteristic characteristic(characteristicForHandle(charHandle));
+ if (!characteristic.isValid()) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "unknown characteristic";
+ return;
+ }
+
+ if (characteristic.properties() & QLowEnergyCharacteristic::Read)
+ updateValueOfCharacteristic(charHandle, value, false);
+
+ emit service->characteristicWritten(characteristic, value);
+}
+
+void QLowEnergyControllerPrivateOSX::characteristicUpdateNotification(QLowEnergyHandle charHandle,
+ const QByteArray &value)
+{
+ // TODO: write/update notifications are quite similar (except asserts/warnings messages
+ // and different signals emitted). Merge them into one function?
+ Q_ASSERT_X(charHandle, Q_FUNC_INFO, "invalid characteristic handle(0)");
+
+ ServicePrivate service(serviceForHandle(charHandle));
+ if (service.isNull()) {
+ // This can be an error (no characteristic found for this handle),
+ // it can also be that we set notify value before the service
+ // was reported (serviceDetailsDiscoveryFinished) - this happens,
+ // if we read a descriptor (characteristic client configuration),
+ // and it's (pre)set.
+ return;
+ }
+
+ QLowEnergyCharacteristic characteristic(characteristicForHandle(charHandle));
+ if (!characteristic.isValid()) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "unknown characteristic";
+ return;
+ }
+
+ if (characteristic.properties() & QLowEnergyCharacteristic::Read)
+ updateValueOfCharacteristic(charHandle, value, false);
+
+ emit service->characteristicChanged(characteristic, value);
+}
+
+void QLowEnergyControllerPrivateOSX::descriptorReadNotification(QLowEnergyHandle dHandle, const QByteArray &value)
+{
+ Q_ASSERT_X(dHandle, Q_FUNC_INFO, "invalid descriptor handle (0)");
+
+ const QLowEnergyDescriptor qtDescriptor(descriptorForHandle(dHandle));
+ if (!qtDescriptor.isValid()) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "unknown descriptor " << dHandle;
+ return;
+ }
+
+ ServicePrivate service(serviceForHandle(qtDescriptor.characteristicHandle()));
+ updateValueOfDescriptor(qtDescriptor.characteristicHandle(), dHandle, value, false);
+ emit service->descriptorRead(qtDescriptor, value);
+}
+
+void QLowEnergyControllerPrivateOSX::descriptorWriteNotification(QLowEnergyHandle dHandle, const QByteArray &value)
+{
+ Q_ASSERT_X(dHandle, Q_FUNC_INFO, "invalid descriptor handle (0)");
+
+ const QLowEnergyDescriptor qtDescriptor(descriptorForHandle(dHandle));
+ if (!qtDescriptor.isValid()) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "unknown descriptor " << dHandle;
+ return;
+ }
+
+ ServicePrivate service(serviceForHandle(qtDescriptor.characteristicHandle()));
+ // TODO: test if this data is what we expected.
+ updateValueOfDescriptor(qtDescriptor.characteristicHandle(), dHandle, value, false);
+ emit service->descriptorWritten(qtDescriptor, value);
+}
+
+void QLowEnergyControllerPrivateOSX::disconnected()
+{
+ controllerState = QLowEnergyController::UnconnectedState;
+
+ if (!isConnecting) {
+ emit q_ptr->stateChanged(QLowEnergyController::UnconnectedState);
+ emit q_ptr->disconnected();
+ }
+}
+
+void QLowEnergyControllerPrivateOSX::error(QLowEnergyController::Error errorCode)
+{
+ // Errors reported during connect and general errors.
+
+ // We're still in connectToDevice,
+ // some error was reported synchronously.
+ // Return, the error will be correctly set later
+ // by connectToDevice.
+ if (isConnecting) {
+ lastError = errorCode;
+ return;
+ }
+
+ setErrorDescription(errorCode);
+ emit q_ptr->error(lastError);
+
+ if (controllerState == QLowEnergyController::ConnectingState) {
+ controllerState = QLowEnergyController::UnconnectedState;
+ emit q_ptr->stateChanged(controllerState);
+ } else if (controllerState == QLowEnergyController::DiscoveringState) {
+ controllerState = QLowEnergyController::ConnectedState;
+ emit q_ptr->stateChanged(controllerState);
+ } // In any other case we stay in Discovered, it's
+ // a service/characteristic - related error.
+}
+
+void QLowEnergyControllerPrivateOSX::error(const QBluetoothUuid &serviceUuid,
+ QLowEnergyController::Error errorCode)
+{
+ // Errors reported while discovering service details etc.
+ Q_UNUSED(errorCode) // TODO: setError?
+
+ // We failed to discover any characteristics/descriptors.
+ if (discoveredServices.contains(serviceUuid)) {
+ ServicePrivate qtService(discoveredServices.value(serviceUuid));
+ qtService->setState(QLowEnergyService::InvalidService);
+ } else {
+ qCDebug(QT_BT_OSX) << Q_FUNC_INFO << "error reported for unknown service "
+ << serviceUuid;
+ }
+}
+
+void QLowEnergyControllerPrivateOSX::error(const QBluetoothUuid &serviceUuid,
+ QLowEnergyService::ServiceError errorCode)
+{
+ if (!discoveredServices.contains(serviceUuid)) {
+ qCDebug(QT_BT_OSX) << Q_FUNC_INFO << "unknown service uuid: "
+ << serviceUuid;
+ return;
+ }
+
+ ServicePrivate service(discoveredServices.value(serviceUuid));
+ service->setError(errorCode);
+}
+
+void QLowEnergyControllerPrivateOSX::connectToDevice()
+{
+ Q_ASSERT_X(isValid(), Q_FUNC_INFO, "invalid private controller");
+ Q_ASSERT_X(controllerState == QLowEnergyController::UnconnectedState,
+ Q_FUNC_INFO, "invalid state");
+ Q_ASSERT_X(!deviceUuid.isNull(), Q_FUNC_INFO,
+ "invalid private controller (no device uuid)");
+ Q_ASSERT_X(!isConnecting, Q_FUNC_INFO,
+ "recursive connectToDevice call");
+
+ setErrorDescription(QLowEnergyController::NoError);
+
+ isConnecting = true;// Do not emit signals if some callback is executed synchronously.
+ controllerState = QLowEnergyController::ConnectingState;
+ const QLowEnergyController::Error status = [centralManager connectToDevice:deviceUuid];
+ isConnecting = false;
+
+ if (status == QLowEnergyController::NoError && lastError == QLowEnergyController::NoError) {
+ emit q_ptr->stateChanged(controllerState);
+ if (controllerState == QLowEnergyController::ConnectedState) {
+ // If a peripheral is connected already from the Core Bluetooth's
+ // POV:
+ emit q_ptr->connected();
+ } else if (controllerState == QLowEnergyController::UnconnectedState) {
+ // Ooops, tried to connect, got peripheral disconnect instead -
+ // this happens with Core Bluetooth.
+ emit q_ptr->disconnected();
+ }
+ } else if (status != QLowEnergyController::NoError) {
+ error(status);
+ } else {
+ // Re-set the error/description and emit.
+ error(lastError);
+ }
+}
+
+void QLowEnergyControllerPrivateOSX::discoverServices()
+{
+ Q_ASSERT_X(isValid(), Q_FUNC_INFO, "invalid private controller");
+ Q_ASSERT_X(controllerState != QLowEnergyController::UnconnectedState,
+ Q_FUNC_INFO, "not connected to peripheral");
+
+ controllerState = QLowEnergyController::DiscoveringState;
+ emit q_ptr->stateChanged(QLowEnergyController::DiscoveringState);
+ [centralManager discoverServices];
+}
+
+void QLowEnergyControllerPrivateOSX::discoverServiceDetails(const QBluetoothUuid &serviceUuid)
+{
+ Q_ASSERT_X(isValid(), Q_FUNC_INFO, "invalid private controller");
+
+ if (controllerState != QLowEnergyController::DiscoveredState) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO
+ << "can not discover service details in the current state, "
+ << "QLowEnergyController::DiscoveredState is expected";
+ return;
+ }
+
+ if (!discoveredServices.contains(serviceUuid)) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "unknown service: " << serviceUuid;
+ return;
+ }
+
+ ServicePrivate qtService(discoveredServices.value(serviceUuid));
+ if ([centralManager discoverServiceDetails:serviceUuid]) {
+ qtService->setState(QLowEnergyService::DiscoveringServices);
+ } else {
+ // The error is returned by CentralManager - no
+ // service with a given UUID found on a peripheral.
+ qtService->setState(QLowEnergyService::InvalidService);
+ }
+}
+
+void QLowEnergyControllerPrivateOSX::setNotifyValue(QSharedPointer<QLowEnergyServicePrivate> service,
+ QLowEnergyHandle charHandle,
+ const QByteArray &newValue)
+{
+ Q_ASSERT_X(!service.isNull(), Q_FUNC_INFO, "invalid service (null)");
+ Q_ASSERT_X(isValid(), Q_FUNC_INFO, "invalid controller");
+
+ if (newValue.size() > 2) {
+ // Qt's API requires an error on such write.
+ // With Core Bluetooth we do not write any descriptor,
+ // but instead call a special method. So it's better to
+ // intercept wrong data size here:
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "client characteristic configuration descriptor "
+ "is 2 bytes, but value size is: " << newValue.size();
+ service->setError(QLowEnergyService::DescriptorWriteError);
+ return;
+ }
+
+ if (!discoveredServices.contains(service->uuid)) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "no service with uuid: "
+ << service->uuid << " found";
+ return;
+ }
+
+ if (!service->characteristicList.contains(charHandle)) {
+ qCDebug(QT_BT_OSX) << Q_FUNC_INFO << "no characteristic with handle: "
+ << charHandle << " found";
+ return;
+ }
+
+ if (![centralManager setNotifyValue:newValue forCharacteristic:charHandle])
+ service->setError(QLowEnergyService::DescriptorWriteError);
+}
+
+void QLowEnergyControllerPrivateOSX::readCharacteristic(QSharedPointer<QLowEnergyServicePrivate> service,
+ QLowEnergyHandle charHandle)
+{
+ Q_ASSERT_X(!service.isNull(), Q_FUNC_INFO, "invalid service (null)");
+ Q_ASSERT_X(isValid(), Q_FUNC_INFO, "invalid controller");
+
+ if (!discoveredServices.contains(service->uuid)) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "no service with uuid:"
+ << service->uuid << "found";
+ return;
+ }
+
+ if (!service->characteristicList.contains(charHandle)) {
+ qCDebug(QT_BT_OSX) << Q_FUNC_INFO << "no characteristic with handle:"
+ << charHandle << "found";
+ return;
+ }
+
+ if (![centralManager readCharacteristic:charHandle])
+ service->setError(QLowEnergyService::CharacteristicReadError);
+}
+
+void QLowEnergyControllerPrivateOSX::writeCharacteristic(QSharedPointer<QLowEnergyServicePrivate> service,
+ QLowEnergyHandle charHandle, const QByteArray &newValue,
+ bool writeWithResponse)
+{
+ Q_ASSERT_X(!service.isNull(), Q_FUNC_INFO, "invalid service (null)");
+ Q_ASSERT_X(isValid(), Q_FUNC_INFO, "invalid controller");
+
+ // We can work only with services, found on a given peripheral
+ // (== created by the given LE controller),
+ // otherwise we can not write anything at all.
+ if (!discoveredServices.contains(service->uuid)) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "no service with uuid: "
+ << service->uuid << " found";
+ return;
+ }
+
+ if (!service->characteristicList.contains(charHandle)) {
+ qCDebug(QT_BT_OSX) << Q_FUNC_INFO << "no characteristic with handle: "
+ << charHandle << " found";
+ return;
+ }
+
+ const bool result = [centralManager write:newValue
+ charHandle:charHandle
+ withResponse:writeWithResponse];
+ if (!result)
+ service->setError(QLowEnergyService::CharacteristicWriteError);
+}
+
+quint16 QLowEnergyControllerPrivateOSX::updateValueOfCharacteristic(QLowEnergyHandle charHandle,
+ const QByteArray &value,
+ bool appendValue)
+{
+ QSharedPointer<QLowEnergyServicePrivate> service = serviceForHandle(charHandle);
+ if (!service.isNull() && service->characteristicList.contains(charHandle)) {
+ if (appendValue)
+ service->characteristicList[charHandle].value += value;
+ else
+ service->characteristicList[charHandle].value = value;
+
+ return service->characteristicList[charHandle].value.size();
+ }
+
+ return 0;
+}
+
+void QLowEnergyControllerPrivateOSX::readDescriptor(QSharedPointer<QLowEnergyServicePrivate> service,
+ QLowEnergyHandle descriptorHandle)
+{
+ Q_ASSERT_X(!service.isNull(), Q_FUNC_INFO, "invalid service (null)");
+ Q_ASSERT_X(isValid(), Q_FUNC_INFO, "invalid controller");
+
+ if (!discoveredServices.contains(service->uuid)) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "no service with uuid:"
+ << service->uuid << "found";
+ return;
+ }
+
+ if (![centralManager readDescriptor:descriptorHandle])
+ service->setError(QLowEnergyService::DescriptorReadError);
+}
+
+void QLowEnergyControllerPrivateOSX::writeDescriptor(QSharedPointer<QLowEnergyServicePrivate> service,
+ QLowEnergyHandle descriptorHandle,
+ const QByteArray &newValue)
+{
+ Q_ASSERT_X(!service.isNull(), Q_FUNC_INFO, "invalid service (null)");
+ Q_ASSERT_X(isValid(), Q_FUNC_INFO, "invalid controller");
+
+ // We can work only with services found on a given peripheral
+ // (== created by the given LE controller),
+ // otherwise we can not write anything at all.
+ if (!discoveredServices.contains(service->uuid)) {
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "no service with uuid: "
+ << service->uuid << " found";
+ return;
+ }
+
+ if (![centralManager write:newValue descHandle:descriptorHandle])
+ service->setError(QLowEnergyService::DescriptorWriteError);
+}
+
+quint16 QLowEnergyControllerPrivateOSX::updateValueOfDescriptor(QLowEnergyHandle charHandle, QLowEnergyHandle descHandle,
+ const QByteArray &value, bool appendValue)
+{
+ ServicePrivate service(serviceForHandle(charHandle));
+ if (service.isNull() || !service->characteristicList.contains(charHandle))
+ return 0;
+
+ if (!service->characteristicList[charHandle].descriptorList.contains(descHandle))
+ return 0;
+
+ if (appendValue)
+ service->characteristicList[charHandle].descriptorList[descHandle].value += value;
+ else
+ service->characteristicList[charHandle].descriptorList[descHandle].value = value;
+
+ return service->characteristicList[charHandle].descriptorList[descHandle].value.size();
+}
+
+QSharedPointer<QLowEnergyServicePrivate> QLowEnergyControllerPrivateOSX::serviceForHandle(QLowEnergyHandle handle)
+{
+ foreach (QSharedPointer<QLowEnergyServicePrivate> service, discoveredServices.values()) {
+ if (service->startHandle <= handle && handle <= service->endHandle)
+ return service;
+ }
+
+ return QSharedPointer<QLowEnergyServicePrivate>();
+}
+
+QLowEnergyCharacteristic QLowEnergyControllerPrivateOSX::characteristicForHandle(QLowEnergyHandle charHandle)
+{
+ QSharedPointer<QLowEnergyServicePrivate> service(serviceForHandle(charHandle));
+ if (service.isNull())
+ return QLowEnergyCharacteristic();
+
+ if (service->characteristicList.isEmpty())
+ return QLowEnergyCharacteristic();
+
+ // Check whether it is the handle of a characteristic header
+ if (service->characteristicList.contains(charHandle))
+ return QLowEnergyCharacteristic(service, charHandle);
+
+ // Check whether it is the handle of the characteristic value or its descriptors
+ QList<QLowEnergyHandle> charHandles(service->characteristicList.keys());
+ std::sort(charHandles.begin(), charHandles.end());
+
+ for (int i = charHandles.size() - 1; i >= 0; --i) {
+ if (charHandles.at(i) > charHandle)
+ continue;
+
+ return QLowEnergyCharacteristic(service, charHandles.at(i));
+ }
+
+ return QLowEnergyCharacteristic();
+}
+
+QLowEnergyDescriptor QLowEnergyControllerPrivateOSX::descriptorForHandle(QLowEnergyHandle descriptorHandle)
+{
+ const QLowEnergyCharacteristic ch(characteristicForHandle(descriptorHandle));
+ if (!ch.isValid())
+ return QLowEnergyDescriptor();
+
+ const QLowEnergyServicePrivate::CharData charData = ch.d_ptr->characteristicList[ch.attributeHandle()];
+
+ if (charData.descriptorList.contains(descriptorHandle))
+ return QLowEnergyDescriptor(ch.d_ptr, ch.attributeHandle(), descriptorHandle);
+
+ return QLowEnergyDescriptor();
+}
+
+void QLowEnergyControllerPrivateOSX::setErrorDescription(QLowEnergyController::Error errorCode)
+{
+ // This function does not emit!
+
+ lastError = errorCode;
+
+ switch (lastError) {
+ case QLowEnergyController::NoError:
+ errorString.clear();
+ break;
+ case QLowEnergyController::UnknownRemoteDeviceError:
+ errorString = QCoreApplication::translate(LE_CONTROLLER, LEC_RDEV_NO_FOUND);
+ break;
+ case QLowEnergyController::InvalidBluetoothAdapterError:
+ errorString = QCoreApplication::translate(LE_CONTROLLER, LEC_NO_LOCAL_DEV);
+ break;
+ case QLowEnergyController::NetworkError:
+ errorString = QCoreApplication::translate(LE_CONTROLLER, LEC_IO_ERROR);
+ break;
+ case QLowEnergyController::UnknownError:
+ default:
+ errorString = QCoreApplication::translate(LE_CONTROLLER, LEC_UNKNOWN_ERROR);
+ break;
+ }
+}
+
+void QLowEnergyControllerPrivateOSX::invalidateServices()
+{
+ foreach (const QSharedPointer<QLowEnergyServicePrivate> service, discoveredServices.values()) {
+ service->setController(Q_NULLPTR);
+ service->setState(QLowEnergyService::InvalidService);
+ }
+
+ discoveredServices.clear();
+}
+
+QLowEnergyController::QLowEnergyController(const QBluetoothAddress &remoteAddress,
+ QObject *parent)
+ : QObject(parent),
+ d_ptr(new QLowEnergyControllerPrivateOSX(this))
+{
+ OSX_D_PTR;
+
+ osx_d_ptr->remoteAddress = remoteAddress;
+ osx_d_ptr->localAddress = QBluetoothLocalDevice().address();
+
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "construction with remote address "
+ "is not supported!";
+}
+
+QLowEnergyController::QLowEnergyController(const QBluetoothDeviceInfo &remoteDevice,
+ QObject *parent)
+ : QObject(parent),
+ d_ptr(new QLowEnergyControllerPrivateOSX(this, remoteDevice))
+{
+ OSX_D_PTR;
+
+ osx_d_ptr->localAddress = QBluetoothLocalDevice().address();
+ // That's the only "real" ctor - with Core Bluetooth we need a _valid_ deviceUuid
+ // from 'remoteDevice'.
+}
+
+QLowEnergyController::QLowEnergyController(const QBluetoothAddress &remoteAddress,
+ const QBluetoothAddress &localAddress,
+ QObject *parent)
+ : QObject(parent),
+ d_ptr(new QLowEnergyControllerPrivateOSX(this))
+{
+ OSX_D_PTR;
+
+ osx_d_ptr->remoteAddress = remoteAddress;
+ osx_d_ptr->localAddress = localAddress;
+
+ qCWarning(QT_BT_OSX) << Q_FUNC_INFO << "construction with remote/local "
+ "addresses is not supported!";
+}
+
+QLowEnergyController::~QLowEnergyController()
+{
+ // Deleting a peripheral will also disconnect.
+ delete d_ptr;
+}
+
+QBluetoothAddress QLowEnergyController::localAddress() const
+{
+ OSX_D_PTR;
+
+ return osx_d_ptr->localAddress;
+}
+
+QBluetoothAddress QLowEnergyController::remoteAddress() const
+{
+ OSX_D_PTR;
+
+ return osx_d_ptr->remoteAddress;
+}
+
+QString QLowEnergyController::remoteName() const
+{
+ OSX_D_PTR;
+
+ return osx_d_ptr->deviceName;
+}
+
+QLowEnergyController::ControllerState QLowEnergyController::state() const
+{
+ OSX_D_PTR;
+
+ return osx_d_ptr->controllerState;
+}
+
+QLowEnergyController::RemoteAddressType QLowEnergyController::remoteAddressType() const
+{
+ OSX_D_PTR;
+
+ return osx_d_ptr->addressType;
+}
+
+void QLowEnergyController::setRemoteAddressType(RemoteAddressType type)
+{
+ Q_UNUSED(type)
+
+ OSX_D_PTR;
+
+ osx_d_ptr->addressType = type;
+}
+
+void QLowEnergyController::connectToDevice()
+{
+ OSX_D_PTR;
+
+ // A memory allocation problem.
+ if (!osx_d_ptr->isValid())
+ return osx_d_ptr->error(UnknownError);
+
+ // No QBluetoothDeviceInfo provided during construction.
+ if (osx_d_ptr->deviceUuid.isNull())
+ return osx_d_ptr->error(UnknownRemoteDeviceError);
+
+ if (osx_d_ptr->controllerState != UnconnectedState)
+ return;
+
+ osx_d_ptr->connectToDevice();
+}
+
+void QLowEnergyController::disconnectFromDevice()
+{
+ if (state() == UnconnectedState || state() == ClosingState)
+ return;
+
+ OSX_D_PTR;
+
+ if (osx_d_ptr->isValid()) {
+ const ControllerState oldState = osx_d_ptr->controllerState;
+
+ osx_d_ptr->controllerState = ClosingState;
+ emit stateChanged(ClosingState);
+ osx_d_ptr->invalidateServices();
+ [osx_d_ptr->centralManager disconnectFromDevice];
+
+ if (oldState == ConnectingState) {
+ // With a pending connect attempt there is no
+ // guarantee we'll ever have didDisconnect callback,
+ // set the state here and now to make sure we still
+ // can connect.
+ osx_d_ptr->controllerState = UnconnectedState;
+ emit stateChanged(UnconnectedState);
+ }
+ }
+}
+
+void QLowEnergyController::discoverServices()
+{
+ if (state() != ConnectedState)
+ return;
+
+ OSX_D_PTR;
+
+ osx_d_ptr->discoverServices();
+}
+
+QList<QBluetoothUuid> QLowEnergyController::services() const
+{
+ OSX_D_PTR;
+
+ return osx_d_ptr->discoveredServices.keys();
+}
+
+QLowEnergyService *QLowEnergyController::createServiceObject(const QBluetoothUuid &serviceUuid,
+ QObject *parent)
+{
+ OSX_D_PTR;
+
+ if (!osx_d_ptr->discoveredServices.contains(serviceUuid))
+ return Q_NULLPTR;
+
+ return new QLowEnergyService(osx_d_ptr->discoveredServices.value(serviceUuid), parent);
+}
+
+QLowEnergyController::Error QLowEnergyController::error() const
+{
+ OSX_D_PTR;
+
+ return osx_d_ptr->lastError;
+}
+
+QString QLowEnergyController::errorString() const
+{
+ OSX_D_PTR;
+
+ return osx_d_ptr->errorString;
+}
+
+QT_END_NAMESPACE
diff --git a/src/bluetooth/qlowenergycontroller_osx_p.h b/src/bluetooth/qlowenergycontroller_osx_p.h
new file mode 100644
index 00000000..1a4d5707
--- /dev/null
+++ b/src/bluetooth/qlowenergycontroller_osx_p.h
@@ -0,0 +1,162 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2013 Javier S. Pedro <maemo@javispedro.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QLOWENERGYCONTROLLER_OSX_P_H
+#define QLOWENERGYCONTROLLER_OSX_P_H
+
+#include "qlowenergyserviceprivate_p.h"
+#include "osx/osxbtcentralmanager_p.h"
+#include "qlowenergycontroller_p.h"
+#include "qlowenergycontroller.h"
+#include "osx/osxbtutility_p.h"
+#include "qbluetoothaddress.h"
+#include "qbluetoothuuid.h"
+
+#include <QtCore/qsharedpointer.h>
+#include <QtCore/qglobal.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qmap.h>
+
+QT_BEGIN_NAMESPACE
+
+class QByteArray;
+
+// The suffix OSX is not the very right, it's also iOS.
+class QLowEnergyControllerPrivateOSX : public QLowEnergyControllerPrivate,
+ public OSXBluetooth::CentralManagerDelegate
+{
+ friend class QLowEnergyController;
+ friend class QLowEnergyService;
+public:
+ QLowEnergyControllerPrivateOSX(QLowEnergyController *q);
+ QLowEnergyControllerPrivateOSX(QLowEnergyController *q,
+ const QBluetoothDeviceInfo &uuid);
+ ~QLowEnergyControllerPrivateOSX();
+
+ bool isValid() const;
+
+private:
+ // CentralManagerDelegate:
+ void LEnotSupported() Q_DECL_OVERRIDE;
+ void connectSuccess() Q_DECL_OVERRIDE;
+
+ void serviceDiscoveryFinished(LEServices services) Q_DECL_OVERRIDE;
+ void serviceDetailsDiscoveryFinished(LEService service) Q_DECL_OVERRIDE;
+ void characteristicReadNotification(QLowEnergyHandle charHandle,
+ const QByteArray &value) Q_DECL_OVERRIDE;
+ void characteristicWriteNotification(QLowEnergyHandle charHandle,
+ const QByteArray &newValue) Q_DECL_OVERRIDE;
+ void characteristicUpdateNotification(QLowEnergyHandle charHandle,
+ const QByteArray &value) Q_DECL_OVERRIDE;
+ void descriptorReadNotification(QLowEnergyHandle descHandle,
+ const QByteArray &value) Q_DECL_OVERRIDE;
+ void descriptorWriteNotification(QLowEnergyHandle descHandle,
+ const QByteArray &newValue) Q_DECL_OVERRIDE;
+ void disconnected() Q_DECL_OVERRIDE;
+ void error(QLowEnergyController::Error errorCode) Q_DECL_OVERRIDE;
+ void error(const QBluetoothUuid &serviceUuid,
+ QLowEnergyController::Error errorCode) Q_DECL_OVERRIDE;
+ void error(const QBluetoothUuid &serviceUuid,
+ QLowEnergyService::ServiceError error) Q_DECL_OVERRIDE;
+
+ void connectToDevice();
+ void discoverServices();
+ void discoverServiceDetails(const QBluetoothUuid &serviceUuid);
+
+ // TODO: all these read/write /setNotify can be simplified -
+ // by just passing either characteristic or descriptor (that
+ // has all needed information - service, handle, etc.).
+ void setNotifyValue(QSharedPointer<QLowEnergyServicePrivate> service,
+ QLowEnergyHandle charHandle, const QByteArray &newValue);
+
+ void readCharacteristic(QSharedPointer<QLowEnergyServicePrivate> service,
+ QLowEnergyHandle charHandle);
+ void writeCharacteristic(QSharedPointer<QLowEnergyServicePrivate> service,
+ QLowEnergyHandle charHandle, const QByteArray &newValue,
+ bool writeWithResponse);
+
+ quint16 updateValueOfCharacteristic(QLowEnergyHandle charHandle,
+ const QByteArray &value,
+ bool appendValue);
+
+ void readDescriptor(QSharedPointer<QLowEnergyServicePrivate> service,
+ QLowEnergyHandle charHandle);
+ void writeDescriptor(QSharedPointer<QLowEnergyServicePrivate> service,
+ QLowEnergyHandle descriptorHandle,
+ const QByteArray &newValue);
+
+
+ quint16 updateValueOfDescriptor(QLowEnergyHandle charHandle,
+ QLowEnergyHandle descHandle,
+ const QByteArray &value,
+ bool appendValue);
+
+ // 'Lookup' functions:
+ QSharedPointer<QLowEnergyServicePrivate> serviceForHandle(QLowEnergyHandle serviceHandle);
+ QLowEnergyCharacteristic characteristicForHandle(QLowEnergyHandle charHandle);
+ QLowEnergyDescriptor descriptorForHandle(QLowEnergyHandle descriptorHandle);
+
+ void setErrorDescription(QLowEnergyController::Error errorCode);
+ void invalidateServices();
+
+ QLowEnergyController *q_ptr;
+ QBluetoothUuid deviceUuid;
+ QString deviceName;
+ // To be sure we set controller's state correctly
+ // (Connecting or Connected) we have to know if we're
+ // still inside connectToDevice - this is important,
+ // if a peripheral is _already_ connected from Core Bluetooth's
+ // point of view.
+ bool isConnecting;
+
+ QString errorString;
+ QLowEnergyController::Error lastError;
+
+ QBluetoothAddress localAddress;
+ QBluetoothAddress remoteAddress;
+
+ QLowEnergyController::ControllerState controllerState;
+ QLowEnergyController::RemoteAddressType addressType;
+
+ typedef OSXBluetooth::ObjCScopedPointer<ObjCCentralManager> CentralManager;
+ CentralManager centralManager;
+
+ typedef QMap<QBluetoothUuid, QSharedPointer<QLowEnergyServicePrivate> > ServiceMap;
+ typedef ServiceMap::const_iterator ConstServiceIterator;
+ typedef ServiceMap::iterator ServiceIterator;
+ ServiceMap discoveredServices;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/bluetooth/qlowenergycontroller_p.cpp b/src/bluetooth/qlowenergycontroller_p.cpp
index 7de0c604..b3c718b5 100644
--- a/src/bluetooth/qlowenergycontroller_p.cpp
+++ b/src/bluetooth/qlowenergycontroller_p.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -48,6 +48,14 @@ QLowEnergyControllerPrivate::~QLowEnergyControllerPrivate()
void QLowEnergyControllerPrivate::connectToDevice()
{
+ // required to pass unit test on default backend
+ if (remoteDevice.isNull()) {
+ qWarning() << "Invalid/null remote device address";
+ setError(QLowEnergyController::UnknownRemoteDeviceError);
+ return;
+ }
+
+ qWarning() << "QLowEnergyControllerPrivate::connectToDevice(): Not implemented";
setError(QLowEnergyController::UnknownError);
}
@@ -66,6 +74,19 @@ void QLowEnergyControllerPrivate::discoverServiceDetails(const QBluetoothUuid &/
}
+void QLowEnergyControllerPrivate::readCharacteristic(const QSharedPointer<QLowEnergyServicePrivate> /*service*/,
+ const QLowEnergyHandle /*charHandle*/)
+{
+
+}
+
+void QLowEnergyControllerPrivate::readDescriptor(const QSharedPointer<QLowEnergyServicePrivate> /*service*/,
+ const QLowEnergyHandle /*charHandle*/,
+ const QLowEnergyHandle /*descriptorHandle*/)
+{
+
+}
+
void QLowEnergyControllerPrivate::writeCharacteristic(const QSharedPointer<QLowEnergyServicePrivate> /*service*/,
const QLowEnergyHandle /*charHandle*/,
const QByteArray &/*newValue*/,
diff --git a/src/bluetooth/qlowenergycontroller_p.h b/src/bluetooth/qlowenergycontroller_p.h
index db1b346a..bb26a538 100644
--- a/src/bluetooth/qlowenergycontroller_p.h
+++ b/src/bluetooth/qlowenergycontroller_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -34,6 +34,24 @@
#ifndef QLOWENERGYCONTROLLERPRIVATE_P_H
#define QLOWENERGYCONTROLLERPRIVATE_P_H
+#if defined(QT_OSX_BLUETOOTH) || defined(QT_IOS_BLUETOOTH)
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qobject.h>
+
+QT_BEGIN_NAMESPACE
+
+class QLowEnergyControllerPrivate : public QObject
+{
+public:
+ // This class is required to make shared pointer machinery and
+ // moc (== Obj-C syntax) happy on both OS X and iOS.
+};
+
+QT_END_NAMESPACE
+
+#else
+
#include <qglobal.h>
#include <QtCore/QQueue>
#include <QtBluetooth/qbluetooth.h>
@@ -42,12 +60,17 @@
#if defined(QT_BLUEZ_BLUETOOTH) && !defined(QT_BLUEZ_NO_BTLE)
#include <QtBluetooth/QBluetoothSocket>
+#elif defined(QT_ANDROID_BLUETOOTH)
+#include <QtAndroidExtras/QAndroidJniObject>
+#include "android/lowenergynotificationhub_p.h"
#endif
QT_BEGIN_NAMESPACE
#if defined(QT_BLUEZ_BLUETOOTH) && !defined(QT_BLUEZ_NO_BTLE)
class HciManager;
+#elif defined(QT_ANDROID_BLUETOOTH)
+class LowEnergyNotificationHub;
#endif
typedef QMap<QBluetoothUuid, QSharedPointer<QLowEnergyServicePrivate> > ServiceDataMap;
@@ -89,6 +112,12 @@ public:
const QByteArray &value,
bool appendValue);
+ // read data
+ void readCharacteristic(const QSharedPointer<QLowEnergyServicePrivate> service,
+ const QLowEnergyHandle charHandle);
+ void readDescriptor(const QSharedPointer<QLowEnergyServicePrivate> service,
+ const QLowEnergyHandle charHandle,
+ const QLowEnergyHandle descriptorHandle);
// write data
void writeCharacteristic(const QSharedPointer<QLowEnergyServicePrivate> service,
@@ -103,6 +132,8 @@ public:
QBluetoothAddress remoteDevice;
QBluetoothAddress localAdapter;
+ QString remoteName;
+
QLowEnergyController::ControllerState state;
QLowEnergyController::Error error;
QString errorString;
@@ -168,6 +199,27 @@ private slots:
void l2cpErrorChanged(QBluetoothSocket::SocketError);
void l2cpReadyRead();
void encryptionChangedEvent(const QBluetoothAddress&, bool);
+#elif defined(QT_ANDROID_BLUETOOTH)
+ LowEnergyNotificationHub *hub;
+
+private slots:
+ void connectionUpdated(QLowEnergyController::ControllerState newState,
+ QLowEnergyController::Error errorCode);
+ void servicesDiscovered(QLowEnergyController::Error errorCode,
+ const QString &foundServices);
+ void serviceDetailsDiscoveryFinished(const QString& serviceUuid,
+ int startHandle, int endHandle);
+ void characteristicRead(const QBluetoothUuid &serviceUuid, int handle,
+ const QBluetoothUuid &charUuid, int properties,
+ const QByteArray& data);
+ void descriptorRead(const QBluetoothUuid &serviceUuid, const QBluetoothUuid &charUuid,
+ int handle, const QBluetoothUuid &descUuid, const QByteArray &data);
+ void characteristicWritten(int charHandle, const QByteArray &data,
+ QLowEnergyService::ServiceError errorCode);
+ void descriptorWritten(int descHandle, const QByteArray &data,
+ QLowEnergyService::ServiceError errorCode);
+ void characteristicChanged(int charHandle, const QByteArray &data);
+ void serviceError(int attributeHandle, QLowEnergyService::ServiceError errorCode);
#endif
private:
QLowEnergyController *q_ptr;
@@ -176,4 +228,6 @@ private:
QT_END_NAMESPACE
+#endif // QT_OSX_BLUETOOTH || QT_IOS_BLUETOOTH
+
#endif // QLOWENERGYCONTROLLERPRIVATE_P_H
diff --git a/src/bluetooth/qlowenergydescriptor.cpp b/src/bluetooth/qlowenergydescriptor.cpp
index 9c25baa4..cf1f46fa 100644
--- a/src/bluetooth/qlowenergydescriptor.cpp
+++ b/src/bluetooth/qlowenergydescriptor.cpp
@@ -1,8 +1,8 @@
/***************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -57,9 +57,6 @@ QT_BEGIN_NAMESPACE
The \l {QLowEnergyService::descriptorWritten()} signal
is emitted upon success. The cahced \l value() of this object is updated accordingly.
- \note This class is provided by Qt 5.4 as part of a Bluetooth Low Energy Tech Preview.
- Some API elements may change until the final release of the feature.
-
\sa QLowEnergyService, QLowEnergyCharacteristic
*/
@@ -222,6 +219,9 @@ QBluetoothUuid QLowEnergyDescriptor::uuid() const
/*!
Returns the handle of the descriptor or \c 0 if the handle
cannot be accessed on the platform or the descriptor is invalid.
+
+ \note On OS X and iOS handles can differ from 0, but these
+ values have no special meaning outside of internal/private API.
*/
QLowEnergyHandle QLowEnergyDescriptor::handle() const
{
@@ -234,8 +234,8 @@ QLowEnergyHandle QLowEnergyDescriptor::handle() const
/*!
Returns the cached value of the descriptor.
- A descriptor value may be updated using
- \l QLowEnergyService::writeDescriptor().
+ The cached descriptor value may be updated using
+ \l QLowEnergyService::writeDescriptor() or \l QLowEnergyService::readDescriptor().
*/
QByteArray QLowEnergyDescriptor::value() const
{
diff --git a/src/bluetooth/qlowenergydescriptor.h b/src/bluetooth/qlowenergydescriptor.h
index edbac253..8692a542 100644
--- a/src/bluetooth/qlowenergydescriptor.h
+++ b/src/bluetooth/qlowenergydescriptor.h
@@ -1,8 +1,8 @@
/***************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -73,6 +73,7 @@ protected:
friend class QLowEnergyCharacteristic;
friend class QLowEnergyService;
friend class QLowEnergyControllerPrivate;
+ friend class QLowEnergyControllerPrivateOSX;
QLowEnergyDescriptorPrivate *data;
QLowEnergyDescriptor(QSharedPointer<QLowEnergyServicePrivate> p,
diff --git a/src/bluetooth/qlowenergyservice.cpp b/src/bluetooth/qlowenergyservice.cpp
index d3461a96..0781def5 100644
--- a/src/bluetooth/qlowenergyservice.cpp
+++ b/src/bluetooth/qlowenergyservice.cpp
@@ -1,8 +1,8 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2013 Javier S. Pedro <maemo@javispedro.com>
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -94,11 +94,37 @@ QT_BEGIN_NAMESPACE
The values of characteristics and descriptors can be retrieved via
\l QLowEnergyCharacteristic and \l QLowEnergyDescriptor, respectively.
- However writing those attributes requires the service object. The
- \l writeCharacteristic() function attempts to write a new value to the given
+ However, direct reading or writing of these attributes requires the service object.
+ The \l readCharacteristic() function attempts to re-read the value of a characteristic.
+ Although the initial service discovery may have obtained a value already this call may
+ be required in cases where the characteristic value constantly changes without
+ any notifications being provided. An example might be a time characteristic
+ that provides a continuous value. If the read attempt is successful, the
+ \l characteristicRead() signal is emitted. A failure to read the value triggers
+ the \l CharacteristicReadError.
+ The \l writeCharacteristic() function attempts to write a new value to the given
characteristic. If the write attempt is successful, the \l characteristicWritten()
signal is emitted. A failure to write triggers the \l CharacteristicWriteError.
- Writing a descriptor follows the same pattern.
+ Reading and writing of descriptors follows the same pattern.
+
+ Every attempt is made to read or write the value of a descriptor
+ or characteristic on the hardware. This means that meta information such as
+ \l QLowEnergyCharacteristic::properties() is generally ignored when reading and writing.
+ As an example, it is possible to call \l writeCharacteristic() despite the characteristic
+ being read-only based on its meta data description. The resulting write request is
+ forwarded to the connected device and it is up to the device to respond to the
+ potentially invalid request. In this case the result is the emission of the
+ \l CharacteristicWriteError in response to the returned device error. This behavior
+ simplifies interaction with devices which report wrong meta information.
+ If it was not possible to forward the request to the remote device the
+ \l OperationError is set. A potential reason could be that the to-be-written
+ characteristic object does not even belong the current service. In
+ summary, the two types of errors permit a quick distinction of local
+ and remote error cases.
+
+ All requests are serialised based on First-In First-Out principle.
+ For example, issuing a second write request, before the previous
+ write request has finished, is delayed until the first write request has finished.
\note Currently, it is not possible to send signed write or reliable write requests.
@@ -128,14 +154,11 @@ QT_BEGIN_NAMESPACE
\snippet doc_src_qtbluetooth.cpp data_share_qlowenergyservice
- Other operations such as calls to \l writeCharacteristic(),
- writeDescriptor() or the invalidation of the service due to the
+ Other operations such as calls to \l readCharacteristic(), \l readDescriptor(), \l writeCharacteristic(),
+ \l writeDescriptor() or the invalidation of the service due to the
related \l QLowEnergyController disconnecting from the device are shared
the same way.
- \note This class is provided by Qt 5.4 as part of a Bluetooth Low Energy Tech Preview.
- Some API elements may change until the final release of the feature.
-
\sa QLowEnergyController, QLowEnergyCharacteristic, QLowEnergyDescriptor
*/
@@ -166,12 +189,20 @@ QT_BEGIN_NAMESPACE
the service while it was not yet in the
\l ServiceDiscovered \l state() or the service is invalid
due to a loss of connection to the peripheral device.
+ \value CharacteristicReadError An attempt to read a characteristic value failed. For example,
+ it might be triggered in response to a call to
+ \l readCharacteristic(). This value was introduced by Qt 5.5.
\value CharacteristicWriteError An attempt to write a new value to a characteristic
failed. For example, it might be triggered when attempting
to write to a read-only characteristic.
+ \value DescriptorReadError An attempt to read a descriptor value failed. For example,
+ it might be triggered in response to a call to
+ \l readDescriptor(). This value was introduced by Qt 5.5.
\value DescriptorWriteError An attempt to write a new value to a descriptor
failed. For example, it might be triggered when attempting
to write to a read-only descriptor.
+ \value UnknownError An unknown error occurred when interacting with the service.
+ This value was introduced by Qt 5.5.
*/
/*!
@@ -234,13 +265,34 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn void QLowEnergyService::characteristicWritten(const QLowEnergyCharacteristic &characteristic, const QByteArray &newValue);
+ \fn void QLowEnergyService::characteristicRead(const QLowEnergyCharacteristic &characteristic, const QByteArray &value)
+
+ This signal is emitted when the read request for \a characteristic successfully returned
+ its \a value. The signal might be triggered by calling \l characteristicRead(). If
+ the read operation is not successful, the \l error() signal is emitted using the
+ \l CharacteristicReadError flag.
+
+ \sa readCharacteristic()
+ \since 5.5
+ */
+
+/*!
+ \fn void QLowEnergyService::characteristicWritten(const QLowEnergyCharacteristic &characteristic, const QByteArray &newValue)
This signal is emitted when the value of \a characteristic
is successfully changed to \a newValue. The change must have been triggered
by calling \l writeCharacteristic(). If the write operation is not successful,
the \l error() signal is emitted using the \l CharacteristicWriteError flag.
+ Since this signal is an indication of a successful write operation \a newValue
+ generally matches the value that was passed to the associated
+ \l writeCharacteristic() call. However, it may happen that the two values differ
+ from each other. This can occur in cases when the written value is
+ used by the remote device to trigger an operation and it returns some other value via
+ the written and/or change notification. Such cases are very specific to the
+ target device. In any case, the reception of the written signal can still be considered
+ as a sign that the target device received the to-be-written value.
+
\note If \l writeCharacteristic() is called using the \l WriteWithoutResponse mode,
this signal and the \l error() are never emitted.
@@ -248,7 +300,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn void QLowEnergyService::characteristicChanged(const QLowEnergyCharacteristic &characteristic, const QByteArray &newValue);
+ \fn void QLowEnergyService::characteristicChanged(const QLowEnergyCharacteristic &characteristic, const QByteArray &newValue)
This signal is emitted when the value of \a characteristic is changed
by an event on the peripheral. The \a newValue parameter contains the
@@ -262,6 +314,18 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ \fn void QLowEnergyService::descriptorRead(const QLowEnergyDescriptor &descriptor, const QByteArray &value)
+
+ This signal is emitted when the read request for \a descriptor successfully returned
+ its \a value. The signal might be triggered by calling \l descriptorRead(). If
+ the read operation is not successful, the \l error() signal is emitted using the
+ \l DescriptorReadError flag.
+
+ \sa readDescriptor()
+ \since 5.5
+ */
+
+/*!
\fn void QLowEnergyService::descriptorWritten(const QLowEnergyDescriptor &descriptor, const QByteArray &newValue)
This signal is emitted when the value of \a descriptor
@@ -283,8 +347,8 @@ QLowEnergyService::QLowEnergyService(QSharedPointer<QLowEnergyServicePrivate> p,
: QObject(parent),
d_ptr(p)
{
- qRegisterMetaType<QLowEnergyService::ServiceState>("QLowEnergyService::ServiceState");
- qRegisterMetaType<QLowEnergyService::ServiceError>("QLowEnergyService::ServiceError");
+ qRegisterMetaType<QLowEnergyService::ServiceState>();
+ qRegisterMetaType<QLowEnergyService::ServiceError>();
connect(p.data(), SIGNAL(error(QLowEnergyService::ServiceError)),
this, SIGNAL(error(QLowEnergyService::ServiceError)));
@@ -296,6 +360,10 @@ QLowEnergyService::QLowEnergyService(QSharedPointer<QLowEnergyServicePrivate> p,
this, SIGNAL(characteristicWritten(QLowEnergyCharacteristic,QByteArray)));
connect(p.data(), SIGNAL(descriptorWritten(QLowEnergyDescriptor,QByteArray)),
this, SIGNAL(descriptorWritten(QLowEnergyDescriptor,QByteArray)));
+ connect(p.data(), SIGNAL(characteristicRead(QLowEnergyCharacteristic,QByteArray)),
+ this, SIGNAL(characteristicRead(QLowEnergyCharacteristic,QByteArray)));
+ connect(p.data(), SIGNAL(descriptorRead(QLowEnergyDescriptor,QByteArray)),
+ this, SIGNAL(descriptorRead(QLowEnergyDescriptor,QByteArray)));
}
/*!
@@ -363,6 +431,10 @@ QLowEnergyService::ServiceState QLowEnergyService::state() const
reached the \l ServiceDiscovered state. This field is initialised
with \l PrimaryService.
+ \note On Android, it is not possible to determine whether a service
+ is a primary or secondary service. Therefore all services
+ have the \l PrimaryService flag set.
+
*/
QLowEnergyService::ServiceTypes QLowEnergyService::type() const
{
@@ -495,6 +567,45 @@ bool QLowEnergyService::contains(const QLowEnergyCharacteristic &characteristic)
return false;
}
+
+/*!
+ Reads the value of \a characteristic. If the operation is successful, the
+ \l characteristicRead() signal is emitted; otherwise the \l CharacteristicReadError
+ is set. In general, a \a characteristic is readable, if its
+ \l QLowEnergyCharacteristic::Read property is set.
+
+ All descriptor and characteristic requests towards the same remote device are
+ serialised. A queue is employed when issuing multiple requests at the same time.
+ The queue does not eliminate duplicated read requests for the same characteristic.
+
+ A characteristic can only be read if the service is in the \l ServiceDiscovered state,
+ belongs to the service. If one of these conditions is
+ not true the \l QLowEnergyService::OperationError is set.
+
+ \note Calling this function despite \l QLowEnergyCharacteristic::properties() reporting a non-readable property
+ always attempts to read the characteristic's value on the hardware. If the hardware
+ returns with an error the \l CharacteristicWriteError is set.
+
+ \sa characteristicRead(), writeCharacteristic()
+
+ \since 5.5
+ */
+void QLowEnergyService::readCharacteristic(
+ const QLowEnergyCharacteristic &characteristic)
+{
+ Q_D(QLowEnergyService);
+
+ if (!contains(characteristic)
+ || state() != ServiceDiscovered
+ || !d->controller) {
+ d->setError(QLowEnergyService::OperationError);
+ return;
+ }
+
+ d->controller->readCharacteristic(characteristic.d_ptr,
+ characteristic.attributeHandle());
+}
+
/*!
Writes \a newValue as value for the \a characteristic. If the operation is successful,
the \l characteristicWritten() signal is emitted; otherwise the \l CharacteristicWriteError
@@ -506,13 +617,27 @@ bool QLowEnergyService::contains(const QLowEnergyCharacteristic &characteristic)
\l QLowEnergyCharacteristic::Write and \l QLowEnergyCharacteristic::WriteNoResponse
properties.
+ All descriptor and characteristic write requests towards the same remote device are
+ serialised. A queue is employed when issuing multiple write requests at the same time.
+ The queue does not eliminate duplicated write requests for the same characteristic.
+ For example, if the same descriptor is set to the value A and immediately afterwards
+ to B, the two write request are executed in the given order.
+
\note Currently, it is not possible to use signed or reliable writes as defined by the
Bluetooth specification.
A characteristic can only be written if this service is in the \l ServiceDiscovered state,
- belongs to the service and is writable.
+ and belongs to the service. If one of these conditions is
+ not true the \l QLowEnergyService::OperationError is set.
+
+ \note Calling this function despite \l QLowEnergyCharacteristic::properties() reporting
+ a non-writable property always attempts to write to the hardware.
+ Similarly, a \l WriteWithoutResponse is sent to the hardware too although the
+ characteristic may only support \l WriteWithResponse. If the hardware returns
+ with an error the \l CharacteristicWriteError is set.
+
+ \sa QLowEnergyService::characteristicWritten(), QLowEnergyService::readCharacteristic()
- \sa QLowEnergyCharacteristic::properties()
*/
void QLowEnergyService::writeCharacteristic(
const QLowEnergyCharacteristic &characteristic,
@@ -521,26 +646,21 @@ void QLowEnergyService::writeCharacteristic(
//TODO check behavior when writing to WriteSigned characteristic
Q_D(QLowEnergyService);
- // not a characteristic of this service
- if (!contains(characteristic))
- return;
-
- if (state() != ServiceDiscovered)
+ if (!contains(characteristic)
+ || state() != ServiceDiscovered
+ || !d->controller) {
d->setError(QLowEnergyService::OperationError);
-
- if (!d->controller)
return;
+ }
// don't write if properties don't permit it
- if (mode == WriteWithResponse
- && (characteristic.properties() & QLowEnergyCharacteristic::Write))
+ if (mode == WriteWithResponse)
{
d->controller->writeCharacteristic(characteristic.d_ptr,
characteristic.attributeHandle(),
newValue,
true);
- } else if (mode == WriteWithoutResponse
- && (characteristic.properties() & QLowEnergyCharacteristic::WriteNoResponse)) {
+ } else if (mode == WriteWithoutResponse) {
d->controller->writeCharacteristic(characteristic.d_ptr,
characteristic.attributeHandle(),
newValue,
@@ -573,22 +693,64 @@ bool QLowEnergyService::contains(const QLowEnergyDescriptor &descriptor) const
}
/*!
+ Reads the value of \a descriptor. If the operation is successful, the
+ \l descriptorRead() signal is emitted; otherwise the \l DescriptorReadError
+ is set.
+
+ All descriptor and characteristic requests towards the same remote device are
+ serialised. A queue is employed when issuing multiple requests at the same time.
+ The queue does not eliminate duplicated read requests for the same descriptor.
+
+ A descriptor can only be read if the service is in the \l ServiceDiscovered state
+ and the descriptor belongs to the service. If one of these conditions is
+ not true the \l QLowEnergyService::OperationError is set.
+
+ \sa descriptorRead(), writeDescriptor()
+
+ \since 5.5
+ */
+void QLowEnergyService::readDescriptor(
+ const QLowEnergyDescriptor &descriptor)
+{
+ Q_D(QLowEnergyService);
+
+ if (!contains(descriptor)
+ || state() != ServiceDiscovered
+ || !d->controller) {
+ d->setError(QLowEnergyService::OperationError);
+ return;
+ }
+
+ d->controller->readDescriptor(descriptor.d_ptr,
+ descriptor.characteristicHandle(),
+ descriptor.handle());
+}
+
+/*!
Writes \a newValue as value for \a descriptor. If the operation is successful,
the \l descriptorWritten() signal is emitted; otherwise the \l DescriptorWriteError
is emitted.
+ All descriptor and characteristic requests towards the same remote device are
+ serialised. A queue is employed when issuing multiple write requests at the same time.
+ The queue does not eliminate duplicated write requests for the same descriptor.
+ For example, if the same descriptor is set to the value A and immediately afterwards
+ to B, the two write request are executed in the given order.
+
A descriptor can only be written if this service is in the \l ServiceDiscovered state,
- belongs to the service and is writable.
+ belongs to the service. If one of these conditions is
+ not true the \l QLowEnergyService::OperationError is set.
+
+ \sa descriptorWritten(), readDescriptor()
*/
void QLowEnergyService::writeDescriptor(const QLowEnergyDescriptor &descriptor,
const QByteArray &newValue)
{
Q_D(QLowEnergyService);
- if (!contains(descriptor))
- return;
-
- if (state() != ServiceDiscovered || !d->controller) {
+ if (!contains(descriptor)
+ || state() != ServiceDiscovered
+ || !d->controller) {
d->setError(QLowEnergyService::OperationError);
return;
}
diff --git a/src/bluetooth/qlowenergyservice.h b/src/bluetooth/qlowenergyservice.h
index 903b64fe..9b6e73f4 100644
--- a/src/bluetooth/qlowenergyservice.h
+++ b/src/bluetooth/qlowenergyservice.h
@@ -1,8 +1,8 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2013 Javier S. Pedro <maemo@javispedro.com>
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -56,7 +56,10 @@ public:
NoError = 0,
OperationError,
CharacteristicWriteError,
- DescriptorWriteError
+ DescriptorWriteError,
+ UnknownError,
+ CharacteristicReadError,
+ DescriptorReadError
};
enum ServiceState {
@@ -64,7 +67,7 @@ public:
DiscoveryRequired, // we know start/end handle but nothing more
//TODO Rename DiscoveringServices -> DiscoveringDetails or DiscoveringService
DiscoveringServices,// discoverDetails() called and running
- ServiceDiscovered, // all details have been synchronized
+ ServiceDiscovered // all details have been synchronized
};
enum WriteMode {
@@ -89,11 +92,13 @@ public:
ServiceError error() const;
bool contains(const QLowEnergyCharacteristic &characteristic) const;
+ void readCharacteristic(const QLowEnergyCharacteristic &characteristic);
void writeCharacteristic(const QLowEnergyCharacteristic &characteristic,
const QByteArray &newValue,
WriteMode mode = WriteWithResponse);
bool contains(const QLowEnergyDescriptor &descriptor) const;
+ void readDescriptor(const QLowEnergyDescriptor &descriptor);
void writeDescriptor(const QLowEnergyDescriptor &descriptor,
const QByteArray &newValue);
@@ -101,8 +106,12 @@ Q_SIGNALS:
void stateChanged(QLowEnergyService::ServiceState newState);
void characteristicChanged(const QLowEnergyCharacteristic &info,
const QByteArray &value);
+ void characteristicRead(const QLowEnergyCharacteristic &info,
+ const QByteArray &value);
void characteristicWritten(const QLowEnergyCharacteristic &info,
const QByteArray &value);
+ void descriptorRead(const QLowEnergyDescriptor &info,
+ const QByteArray &value);
void descriptorWritten(const QLowEnergyDescriptor &info,
const QByteArray &value);
void error(QLowEnergyService::ServiceError error);
@@ -119,4 +128,7 @@ private:
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QLowEnergyService::ServiceState)
+Q_DECLARE_METATYPE(QLowEnergyService::ServiceError)
+
#endif // QLOWENERGYSERVICE_H
diff --git a/src/bluetooth/qlowenergyservice_osx.mm b/src/bluetooth/qlowenergyservice_osx.mm
new file mode 100644
index 00000000..b424dc96
--- /dev/null
+++ b/src/bluetooth/qlowenergyservice_osx.mm
@@ -0,0 +1,270 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2013 Javier S. Pedro <maemo@javispedro.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlowenergycontroller_osx_p.h"
+#include "qlowenergyserviceprivate_p.h"
+#include "qlowenergycharacteristic.h"
+#include "qlowenergydescriptor.h"
+#include "qlowenergyservice.h"
+#include "qbluetoothuuid.h"
+
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qlist.h>
+
+#include <algorithm>
+
+QT_BEGIN_NAMESPACE
+
+namespace {
+
+QLowEnergyControllerPrivateOSX *qt_mac_le_controller(QSharedPointer<QLowEnergyServicePrivate> d_ptr)
+{
+ if (d_ptr.isNull())
+ return Q_NULLPTR;
+
+ return static_cast<QLowEnergyControllerPrivateOSX *>(d_ptr->controller.data());
+}
+
+}
+
+QLowEnergyService::QLowEnergyService(QSharedPointer<QLowEnergyServicePrivate> d, QObject *parent)
+ : QObject(parent),
+ d_ptr(d)
+{
+ qRegisterMetaType<QLowEnergyService::ServiceState>();
+ qRegisterMetaType<QLowEnergyService::ServiceError>();
+
+ connect(d.data(), SIGNAL(error(QLowEnergyService::ServiceError)),
+ this, SIGNAL(error(QLowEnergyService::ServiceError)));
+ connect(d.data(), SIGNAL(stateChanged(QLowEnergyService::ServiceState)),
+ this, SIGNAL(stateChanged(QLowEnergyService::ServiceState)));
+ connect(d.data(), SIGNAL(characteristicChanged(QLowEnergyCharacteristic, QByteArray)),
+ this, SIGNAL(characteristicChanged(QLowEnergyCharacteristic, QByteArray)));
+ connect(d.data(), SIGNAL(characteristicWritten(QLowEnergyCharacteristic, QByteArray)),
+ this, SIGNAL(characteristicWritten(QLowEnergyCharacteristic, QByteArray)));
+ connect(d.data(), SIGNAL(descriptorWritten(QLowEnergyDescriptor, QByteArray)),
+ this, SIGNAL(descriptorWritten(QLowEnergyDescriptor, QByteArray)));
+ connect(d.data(), SIGNAL(characteristicRead(QLowEnergyCharacteristic,QByteArray)),
+ this, SIGNAL(characteristicRead(QLowEnergyCharacteristic,QByteArray)));
+ connect(d.data(), SIGNAL(descriptorRead(QLowEnergyDescriptor,QByteArray)),
+ this, SIGNAL(descriptorRead(QLowEnergyDescriptor,QByteArray)));
+
+}
+
+QLowEnergyService::~QLowEnergyService()
+{
+}
+
+QList<QBluetoothUuid> QLowEnergyService::includedServices() const
+{
+ return d_ptr->includedServices;
+}
+
+QLowEnergyService::ServiceTypes QLowEnergyService::type() const
+{
+ return d_ptr->type;
+}
+
+QLowEnergyService::ServiceState QLowEnergyService::state() const
+{
+ return d_ptr->state;
+}
+
+QLowEnergyCharacteristic QLowEnergyService::characteristic(const QBluetoothUuid &uuid) const
+{
+ foreach (const QLowEnergyHandle handle, d_ptr->characteristicList.keys()) {
+ if (d_ptr->characteristicList[handle].uuid == uuid)
+ return QLowEnergyCharacteristic(d_ptr, handle);
+ }
+
+ return QLowEnergyCharacteristic();
+}
+
+QList<QLowEnergyCharacteristic> QLowEnergyService::characteristics() const
+{
+ QList<QLowEnergyCharacteristic> result;
+ QList<QLowEnergyHandle> handles(d_ptr->characteristicList.keys());
+
+ std::sort(handles.begin(), handles.end());
+
+ foreach (const QLowEnergyHandle &handle, handles) {
+ QLowEnergyCharacteristic characteristic(d_ptr, handle);
+ result.append(characteristic);
+ }
+
+ return result;
+}
+
+QBluetoothUuid QLowEnergyService::serviceUuid() const
+{
+ return d_ptr->uuid;
+}
+
+QString QLowEnergyService::serviceName() const
+{
+ bool ok = false;
+ const quint16 clsId = d_ptr->uuid.toUInt16(&ok);
+ if (ok) {
+ QBluetoothUuid::ServiceClassUuid uuid
+ = static_cast<QBluetoothUuid::ServiceClassUuid>(clsId);
+ const QString name = QBluetoothUuid::serviceClassToString(uuid);
+ if (!name.isEmpty())
+ return name;
+ }
+
+ return qApp ? qApp->translate("QBluetoothServiceDiscoveryAgent", "Unknown Service") :
+ QStringLiteral("Unknown Service");
+}
+
+void QLowEnergyService::discoverDetails()
+{
+ QLowEnergyControllerPrivateOSX *const controller = qt_mac_le_controller(d_ptr);
+
+ if (!controller || d_ptr->state == InvalidService) {
+ d_ptr->setError(OperationError);
+ return;
+ }
+
+ if (d_ptr->state != DiscoveryRequired)
+ return;
+
+ d_ptr->setState(QLowEnergyService::DiscoveringServices);
+ controller->discoverServiceDetails(d_ptr->uuid);
+}
+
+QLowEnergyService::ServiceError QLowEnergyService::error() const
+{
+ return d_ptr->lastError;
+}
+
+bool QLowEnergyService::contains(const QLowEnergyCharacteristic &characteristic) const
+{
+ if (characteristic.d_ptr.isNull() || !characteristic.data)
+ return false;
+
+ if (d_ptr == characteristic.d_ptr
+ && d_ptr->characteristicList.contains(characteristic.attributeHandle())) {
+ return true;
+ }
+
+ return false;
+}
+
+void QLowEnergyService::readCharacteristic(const QLowEnergyCharacteristic &characteristic)
+{
+ QLowEnergyControllerPrivateOSX *const controller = qt_mac_le_controller(d_ptr);
+ if (!contains(characteristic) || state() != ServiceDiscovered || !controller) {
+ d_ptr->setError(OperationError);
+ return;
+ }
+
+ controller->readCharacteristic(characteristic.d_ptr, characteristic.attributeHandle());
+}
+
+
+void QLowEnergyService::writeCharacteristic(const QLowEnergyCharacteristic &ch, const QByteArray &newValue,
+ WriteMode mode)
+{
+ QLowEnergyControllerPrivateOSX *const controller = qt_mac_le_controller(d_ptr);
+
+ if (!contains(ch) || state() != ServiceDiscovered || !controller) {
+ d_ptr->setError(QLowEnergyService::OperationError);
+ return;
+ }
+
+ // Don't write if properties don't permit it
+ if (mode == WriteWithResponse)
+ controller->writeCharacteristic(ch.d_ptr, ch.attributeHandle(), newValue, true);
+ else if (mode == WriteWithoutResponse)
+ controller->writeCharacteristic(ch.d_ptr, ch.attributeHandle(), newValue, false);
+ else
+ d_ptr->setError(QLowEnergyService::OperationError);
+}
+
+bool QLowEnergyService::contains(const QLowEnergyDescriptor &descriptor) const
+{
+ if (descriptor.d_ptr.isNull() || !descriptor.data)
+ return false;
+
+ const QLowEnergyHandle charHandle = descriptor.characteristicHandle();
+ if (!charHandle)
+ return false;
+
+ if (d_ptr == descriptor.d_ptr && d_ptr->characteristicList.contains(charHandle)
+ && d_ptr->characteristicList[charHandle].descriptorList.contains(descriptor.handle()))
+ {
+ return true;
+ }
+
+ return false;
+}
+
+void QLowEnergyService::readDescriptor(const QLowEnergyDescriptor &descriptor)
+{
+ QLowEnergyControllerPrivateOSX *const controller = qt_mac_le_controller(d_ptr);
+ if (!contains(descriptor) || state() != ServiceDiscovered || !controller) {
+ d_ptr->setError(OperationError);
+ return;
+ }
+
+ controller->readDescriptor(descriptor.d_ptr, descriptor.handle());
+}
+
+void QLowEnergyService::writeDescriptor(const QLowEnergyDescriptor &descriptor,
+ const QByteArray &newValue)
+{
+ QLowEnergyControllerPrivateOSX *const controller = qt_mac_le_controller(d_ptr);
+ if (!contains(descriptor) || state() != ServiceDiscovered || !controller) {
+ d_ptr->setError(OperationError);
+ return;
+ }
+
+ if (descriptor.uuid() == QBluetoothUuid::ClientCharacteristicConfiguration) {
+ // We have to identify a special case - ClientCharacteristicConfiguration
+ // since with Core Bluetooth:
+ //
+ // "You cannot use this method to write the value of a client configuration descriptor
+ // (represented by the CBUUIDClientCharacteristicConfigurationString constant),
+ // which describes how notification or indications are configured for a
+ // characteristic’s value with respect to a client. If you want to manage
+ // notifications or indications for a characteristic’s value, you must
+ // use the setNotifyValue:forCharacteristic: method instead."
+ controller->setNotifyValue(descriptor.d_ptr, descriptor.characteristicHandle(), newValue);
+ } else {
+ controller->writeDescriptor(descriptor.d_ptr, descriptor.handle(), newValue);
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/bluetooth/qlowenergyserviceprivate.cpp b/src/bluetooth/qlowenergyserviceprivate.cpp
index 43bb3498..6f112017 100644
--- a/src/bluetooth/qlowenergyserviceprivate.cpp
+++ b/src/bluetooth/qlowenergyserviceprivate.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -37,6 +37,8 @@ QT_BEGIN_NAMESPACE
QLowEnergyServicePrivate::QLowEnergyServicePrivate(QObject *parent) :
QObject(parent),
+ startHandle(0),
+ endHandle(0),
type(QLowEnergyService::PrimaryService),
state(QLowEnergyService::InvalidService),
lastError(QLowEnergyService::NoError)
@@ -65,6 +67,9 @@ void QLowEnergyServicePrivate::setError(QLowEnergyService::ServiceError newError
void QLowEnergyServicePrivate::setState(QLowEnergyService::ServiceState newState)
{
+ if (state == newState)
+ return;
+
state = newState;
emit stateChanged(newState);
}
diff --git a/src/bluetooth/qlowenergyserviceprivate_p.h b/src/bluetooth/qlowenergyserviceprivate_p.h
index 4a98d589..a020341f 100644
--- a/src/bluetooth/qlowenergyserviceprivate_p.h
+++ b/src/bluetooth/qlowenergyserviceprivate_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -80,8 +80,12 @@ signals:
void error(QLowEnergyService::ServiceError error);
void characteristicChanged(const QLowEnergyCharacteristic &characteristic,
const QByteArray &newValue);
+ void characteristicRead(const QLowEnergyCharacteristic &info,
+ const QByteArray &value);
void characteristicWritten(const QLowEnergyCharacteristic &characteristic,
const QByteArray &newValue);
+ void descriptorRead(const QLowEnergyDescriptor &info,
+ const QByteArray &value);
void descriptorWritten(const QLowEnergyDescriptor &descriptor,
const QByteArray &newValue);
diff --git a/src/bluetooth/qnx/ppshelpers.cpp b/src/bluetooth/qnx/ppshelpers.cpp
index eaf9c374..215839cc 100644
--- a/src/bluetooth/qnx/ppshelpers.cpp
+++ b/src/bluetooth/qnx/ppshelpers.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2012 Research In Motion
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qnx/ppshelpers_p.h b/src/bluetooth/qnx/ppshelpers_p.h
index e771fd8e..0a3a1033 100644
--- a/src/bluetooth/qnx/ppshelpers_p.h
+++ b/src/bluetooth/qnx/ppshelpers_p.h
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2012 Research In Motion
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/bluetooth/qprivatelinearbuffer_p.h b/src/bluetooth/qprivatelinearbuffer_p.h
index b13e68d3..78fcb669 100644
--- a/src/bluetooth/qprivatelinearbuffer_p.h
+++ b/src/bluetooth/qprivatelinearbuffer_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/imports/bluetooth/plugin.cpp b/src/imports/bluetooth/plugin.cpp
index 24206106..38b464d7 100644
--- a/src/imports/bluetooth/plugin.cpp
+++ b/src/imports/bluetooth/plugin.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -67,9 +67,9 @@ public:
qmlRegisterType<QDeclarativeBluetoothService >(uri, major, minor, "BluetoothService");
qmlRegisterType<QDeclarativeBluetoothSocket >(uri, major, minor, "BluetoothSocket");
- // Register the 5.4 types
- // introduces 5.4 version, other existing 5.2 exports become automatically available under 5.2-5.4
- minor = 4;
+ // Register the 5.5 types
+ // introduces 5.5 version, other existing 5.2 exports become automatically available under 5.2-5.4
+ minor = 5;
qmlRegisterType<QDeclarativeBluetoothDiscoveryModel >(uri, major, minor, "BluetoothDiscoveryModel");
}
};
diff --git a/src/imports/bluetooth/plugins.qmltypes b/src/imports/bluetooth/plugins.qmltypes
index cf2146e2..e9b93e54 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.4'
+// 'qmlplugindump -nonrelocatable QtBluetooth 5.5'
Module {
Component {
@@ -13,7 +13,7 @@ Module {
exports: [
"QtBluetooth/BluetoothDiscoveryModel 5.0",
"QtBluetooth/BluetoothDiscoveryModel 5.2",
- "QtBluetooth/BluetoothDiscoveryModel 5.4"
+ "QtBluetooth/BluetoothDiscoveryModel 5.5"
]
exportMetaObjectRevisions: [0, 0, 0]
Enum {
diff --git a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp
index 01a53bfa..65941fec 100644
--- a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp
+++ b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp
@@ -1,8 +1,8 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel_p.h b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel_p.h
index 1834ce36..82a2129b 100644
--- a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel_p.h
+++ b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel_p.h
@@ -1,8 +1,8 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/imports/bluetooth/qdeclarativebluetoothservice.cpp b/src/imports/bluetooth/qdeclarativebluetoothservice.cpp
index 59ee2510..84506ce9 100644
--- a/src/imports/bluetooth/qdeclarativebluetoothservice.cpp
+++ b/src/imports/bluetooth/qdeclarativebluetoothservice.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/imports/bluetooth/qdeclarativebluetoothservice_p.h b/src/imports/bluetooth/qdeclarativebluetoothservice_p.h
index 0e04b790..9cb62de9 100644
--- a/src/imports/bluetooth/qdeclarativebluetoothservice_p.h
+++ b/src/imports/bluetooth/qdeclarativebluetoothservice_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp b/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp
index 96be47fb..9072f136 100644
--- a/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp
+++ b/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/imports/bluetooth/qdeclarativebluetoothsocket_p.h b/src/imports/bluetooth/qdeclarativebluetoothsocket_p.h
index 35a8c504..4ad69f9e 100644
--- a/src/imports/bluetooth/qdeclarativebluetoothsocket_p.h
+++ b/src/imports/bluetooth/qdeclarativebluetoothsocket_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/imports/nfc/plugin.cpp b/src/imports/nfc/plugin.cpp
index 52b4db9c..14f3b280 100644
--- a/src/imports/nfc/plugin.cpp
+++ b/src/imports/nfc/plugin.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -79,6 +79,10 @@ public:
// introduces 5.4 version, other existing 5.2 exports become automatically available under 5.2-5.4l
minor = 4;
qmlRegisterType<QDeclarativeNearField>(uri, major, minor, "NearField");
+
+ // Register the 5.5 types
+ minor = 5;
+ qmlRegisterType<QDeclarativeNearField, 1>(uri, major, minor, "NearField");
}
};
diff --git a/src/imports/nfc/plugins.qmltypes b/src/imports/nfc/plugins.qmltypes
index bbdc4398..6abc211d 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.4'
+// 'qmlplugindump -nonrelocatable QtNfc 5.5'
Module {
Component {
@@ -55,12 +55,17 @@ Module {
exports: [
"QtNfc/NearField 5.0",
"QtNfc/NearField 5.2",
- "QtNfc/NearField 5.4"
+ "QtNfc/NearField 5.4",
+ "QtNfc/NearField 5.5"
]
- exportMetaObjectRevisions: [0, 0, 0]
+ exportMetaObjectRevisions: [0, 0, 0, 1]
Property { name: "messageRecords"; type: "QQmlNdefRecord"; isList: true; isReadonly: true }
Property { name: "filter"; type: "QDeclarativeNdefFilter"; isList: true; isReadonly: true }
Property { name: "orderMatch"; type: "bool" }
+ Property { name: "polling"; revision: 1; type: "bool" }
+ Signal { name: "pollingChanged"; revision: 1 }
+ Signal { name: "tagFound"; revision: 1 }
+ Signal { name: "tagRemoved"; revision: 1 }
}
Component {
name: "QQmlNdefRecord"
diff --git a/src/imports/nfc/qdeclarativendeffilter.cpp b/src/imports/nfc/qdeclarativendeffilter.cpp
index 7c6d725e..a3fb1581 100644
--- a/src/imports/nfc/qdeclarativendeffilter.cpp
+++ b/src/imports/nfc/qdeclarativendeffilter.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/imports/nfc/qdeclarativendeffilter_p.h b/src/imports/nfc/qdeclarativendeffilter_p.h
index e5b2fced..0d2df237 100644
--- a/src/imports/nfc/qdeclarativendeffilter_p.h
+++ b/src/imports/nfc/qdeclarativendeffilter_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/imports/nfc/qdeclarativendefmimerecord.cpp b/src/imports/nfc/qdeclarativendefmimerecord.cpp
index 65915275..51035460 100644
--- a/src/imports/nfc/qdeclarativendefmimerecord.cpp
+++ b/src/imports/nfc/qdeclarativendefmimerecord.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/imports/nfc/qdeclarativendefmimerecord_p.h b/src/imports/nfc/qdeclarativendefmimerecord_p.h
index 8438a1f6..61459362 100644
--- a/src/imports/nfc/qdeclarativendefmimerecord_p.h
+++ b/src/imports/nfc/qdeclarativendefmimerecord_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/imports/nfc/qdeclarativendeftextrecord.cpp b/src/imports/nfc/qdeclarativendeftextrecord.cpp
index 8e5507a2..e8d9e32f 100644
--- a/src/imports/nfc/qdeclarativendeftextrecord.cpp
+++ b/src/imports/nfc/qdeclarativendeftextrecord.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/imports/nfc/qdeclarativendeftextrecord_p.h b/src/imports/nfc/qdeclarativendeftextrecord_p.h
index ca11c017..8a65a951 100644
--- a/src/imports/nfc/qdeclarativendeftextrecord_p.h
+++ b/src/imports/nfc/qdeclarativendeftextrecord_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/imports/nfc/qdeclarativendefurirecord.cpp b/src/imports/nfc/qdeclarativendefurirecord.cpp
index ec0f4bb8..356c3300 100644
--- a/src/imports/nfc/qdeclarativendefurirecord.cpp
+++ b/src/imports/nfc/qdeclarativendefurirecord.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/imports/nfc/qdeclarativendefurirecord_p.h b/src/imports/nfc/qdeclarativendefurirecord_p.h
index 02abe36e..fe29697a 100644
--- a/src/imports/nfc/qdeclarativendefurirecord_p.h
+++ b/src/imports/nfc/qdeclarativendefurirecord_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/imports/nfc/qdeclarativenearfield.cpp b/src/imports/nfc/qdeclarativenearfield.cpp
index 30d020b9..3e45047b 100644
--- a/src/imports/nfc/qdeclarativenearfield.cpp
+++ b/src/imports/nfc/qdeclarativenearfield.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -41,6 +41,8 @@
#include <qndefnfctextrecord.h>
#include <qndefnfcurirecord.h>
+#include <QtNfc/QNearFieldTarget>
+
/*!
\qmltype NearField
\instantiates QDeclarativeNearField
@@ -61,6 +63,9 @@
and \l orderMatch properties to match the required NDEF messages. Once an NDEF message is
successfully read from a tag the \l messageRecords property is updated.
+ \note For platforms using neard, filtering is currently not implemented. For more information
+ on neard see \l QNearFieldManager.
+
\snippet doc_src_qtnfc.qml QML register for messages
*/
@@ -77,6 +82,8 @@
set to NDEF messages which match the filter. If no filter is set, a message handler for
all NDEF messages will be registered.
+ \note Filtering is not supported when using neard.
+
\l QNearFieldManager::registerNdefMessageHandler()
*/
@@ -84,13 +91,47 @@
\qmlproperty bool NearField::orderMatch
This property indicates whether the order of records should be taken into account when matching
- messages.
+ messages. This is not supported when using neard.
+*/
+
+/*!
+ \qmlproperty bool NearField::polling
+ \since 5.5
+
+ This property indicates if the underlying adapter is currently in polling state. If set to \c true
+ the adapter will start polling and stop polling if set to \c false.
+
+ \note On platforms using neard, the adapter will stop polling as soon as a tag has been detected.
+ For more information see \l QNearFieldManager.
+*/
+
+/*!
+ \qmlsignal NearField::tagFound()
+ \since 5.5
+
+ This signal will be emitted when a tag has been detected.
+*/
+
+/*!
+ \qmlsignal NearField::tagRemoved()
+ \since 5.5
+
+ This signal will be emitted when a tag has been removed.
*/
QDeclarativeNearField::QDeclarativeNearField(QObject *parent)
-: QObject(parent), m_orderMatch(false), m_componentCompleted(false), m_messageUpdating(false),
- m_manager(0), m_messageHandlerId(-1)
+ : QObject(parent),
+ m_orderMatch(false),
+ m_componentCompleted(false),
+ m_messageUpdating(false),
+ m_manager(new QNearFieldManager(this)),
+ m_messageHandlerId(-1),
+ m_polling(false)
{
+ connect(m_manager, SIGNAL(targetDetected(QNearFieldTarget*)),
+ this, SLOT(_q_handleTargetDetected(QNearFieldTarget*)));
+ connect(m_manager, SIGNAL(targetLost(QNearFieldTarget*)),
+ this, SLOT(_q_handleTargetLost(QNearFieldTarget*)));
}
QQmlListProperty<QQmlNdefRecord> QDeclarativeNearField::messageRecords()
@@ -133,11 +174,30 @@ void QDeclarativeNearField::componentComplete()
registerMessageHandler();
}
-void QDeclarativeNearField::registerMessageHandler()
+bool QDeclarativeNearField::polling() const
{
- if (!m_manager)
- m_manager = new QNearFieldManager(this);
+ return m_polling;
+}
+void QDeclarativeNearField::setPolling(bool on)
+{
+ if (m_polling == on)
+ return;
+
+ if (on) {
+ if (m_manager->startTargetDetection()) {
+ m_polling = true;
+ emit pollingChanged();
+ }
+ } else {
+ m_manager->stopTargetDetection();
+ m_polling = false;
+ emit pollingChanged();
+ }
+}
+
+void QDeclarativeNearField::registerMessageHandler()
+{
if (m_messageHandlerId != -1)
m_manager->unregisterNdefMessageHandler(m_messageHandlerId);
@@ -152,6 +212,12 @@ void QDeclarativeNearField::registerMessageHandler()
}
m_messageHandlerId = m_manager->registerNdefMessageHandler(ndefFilter, this, SLOT(_q_handleNdefMessage(QNdefMessage)));
+
+ // FIXME: if a message handler has been registered we just assume that constant polling is done
+ if (m_messageHandlerId >= 0) {
+ m_polling = true;
+ emit pollingChanged();
+ }
}
void QDeclarativeNearField::_q_handleNdefMessage(const QNdefMessage &message)
@@ -170,6 +236,31 @@ void QDeclarativeNearField::_q_handleNdefMessage(const QNdefMessage &message)
emit messageRecordsChanged();
}
+void QDeclarativeNearField::_q_handleTargetLost(QNearFieldTarget *target)
+{
+ Q_UNUSED(target);
+ // FIXME: only notify that polling stopped when there is no registered message handler
+ if (m_messageHandlerId == -1) {
+ m_polling = false;
+ emit pollingChanged();
+ }
+
+ emit tagRemoved();
+}
+
+void QDeclarativeNearField::_q_handleTargetDetected(QNearFieldTarget *target)
+{
+ Q_UNUSED(target);
+
+ if (m_messageHandlerId == -1) {
+ connect(target, SIGNAL(ndefMessageRead(QNdefMessage)),
+ this, SLOT(_q_handleNdefMessage(QNdefMessage)));
+ target->readNdefMessages();
+ }
+
+ emit tagFound();
+}
+
void QDeclarativeNearField::append_messageRecord(QQmlListProperty<QQmlNdefRecord> *list,
QQmlNdefRecord *record)
{
diff --git a/src/imports/nfc/qdeclarativenearfield_p.h b/src/imports/nfc/qdeclarativenearfield_p.h
index 2e151e36..69cd08d4 100644
--- a/src/imports/nfc/qdeclarativenearfield_p.h
+++ b/src/imports/nfc/qdeclarativenearfield_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -63,6 +63,7 @@ class QDeclarativeNearField : public QObject, public QQmlParserStatus
Q_PROPERTY(QQmlListProperty<QQmlNdefRecord> messageRecords READ messageRecords NOTIFY messageRecordsChanged)
Q_PROPERTY(QQmlListProperty<QDeclarativeNdefFilter> filter READ filter NOTIFY filterChanged)
Q_PROPERTY(bool orderMatch READ orderMatch WRITE setOrderMatch NOTIFY orderMatchChanged)
+ Q_PROPERTY(bool polling READ polling WRITE setPolling NOTIFY pollingChanged REVISION 1)
Q_INTERFACES(QQmlParserStatus)
@@ -80,13 +81,22 @@ public:
void classBegin() { }
void componentComplete();
+ bool polling() const;
+ void setPolling(bool on);
+
signals:
void messageRecordsChanged();
void filterChanged();
void orderMatchChanged();
+ Q_REVISION(1) void pollingChanged();
+
+ Q_REVISION(1) void tagFound();
+ Q_REVISION(1) void tagRemoved();
private slots:
void _q_handleNdefMessage(const QNdefMessage &message);
+ void _q_handleTargetLost(QNearFieldTarget*);
+ void _q_handleTargetDetected(QNearFieldTarget*);
private:
QList<QQmlNdefRecord *> m_message;
@@ -97,6 +107,7 @@ private:
QNearFieldManager *m_manager;
int m_messageHandlerId;
+ bool m_polling;
void registerMessageHandler();
diff --git a/src/imports/nfc/qdeclarativenearfieldsocket.cpp b/src/imports/nfc/qdeclarativenearfieldsocket.cpp
index 77b12fb5..82e998ab 100644
--- a/src/imports/nfc/qdeclarativenearfieldsocket.cpp
+++ b/src/imports/nfc/qdeclarativenearfieldsocket.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/imports/nfc/qdeclarativenearfieldsocket_p.h b/src/imports/nfc/qdeclarativenearfieldsocket_p.h
index e6664d8e..8fbd0b15 100644
--- a/src/imports/nfc/qdeclarativenearfieldsocket_p.h
+++ b/src/imports/nfc/qdeclarativenearfieldsocket_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/doc/snippets/doc_src_qtnfc.cpp b/src/nfc/doc/snippets/doc_src_qtnfc.cpp
index 62aa65e2..f4d7f91a 100644
--- a/src/nfc/doc/snippets/doc_src_qtnfc.cpp
+++ b/src/nfc/doc/snippets/doc_src_qtnfc.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 Aaron McCarthy <mccarthy.aaron@gmail.com>
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/src/nfc/doc/snippets/doc_src_qtnfc.qml b/src/nfc/doc/snippets/doc_src_qtnfc.qml
index 427c24c6..65efee56 100644
--- a/src/nfc/doc/snippets/doc_src_qtnfc.qml
+++ b/src/nfc/doc/snippets/doc_src_qtnfc.qml
@@ -1,8 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2013 Aaron McCarthy <mccarthy.aaron@gmail.com>
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
@@ -18,8 +18,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/src/nfc/doc/snippets/foorecord.cpp b/src/nfc/doc/snippets/foorecord.cpp
index 2c4daeb1..14a83af3 100644
--- a/src/nfc/doc/snippets/foorecord.cpp
+++ b/src/nfc/doc/snippets/foorecord.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/src/nfc/doc/snippets/foorecord.h b/src/nfc/doc/snippets/foorecord.h
index 59d13df9..e8c130e4 100644
--- a/src/nfc/doc/snippets/foorecord.h
+++ b/src/nfc/doc/snippets/foorecord.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/src/nfc/doc/snippets/main.cpp b/src/nfc/doc/snippets/main.cpp
index 5c08502c..09d07b02 100644
--- a/src/nfc/doc/snippets/main.cpp
+++ b/src/nfc/doc/snippets/main.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/src/nfc/doc/snippets/nfc.cpp b/src/nfc/doc/snippets/nfc.cpp
index 347b7a6f..eb7ef989 100644
--- a/src/nfc/doc/snippets/nfc.cpp
+++ b/src/nfc/doc/snippets/nfc.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
@@ -17,8 +17,8 @@
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
-** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
diff --git a/src/nfc/doc/src/examples.qdoc b/src/nfc/doc/src/examples.qdoc
index 9bdbd880..7216c03c 100644
--- a/src/nfc/doc/src/examples.qdoc
+++ b/src/nfc/doc/src/examples.qdoc
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 Aaron McCarthy <mccarthy.aaron@gmail.com>
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
@@ -10,15 +10,15 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
+** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
diff --git a/src/nfc/doc/src/nfc-cpp.qdoc b/src/nfc/doc/src/nfc-cpp.qdoc
index cbb07e0c..f007dcf3 100644
--- a/src/nfc/doc/src/nfc-cpp.qdoc
+++ b/src/nfc/doc/src/nfc-cpp.qdoc
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 Aaron McCarthy <mccarthy.aaron@gmail.com>
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
@@ -10,15 +10,15 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
+** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
diff --git a/src/nfc/doc/src/nfc-index.qdoc b/src/nfc/doc/src/nfc-index.qdoc
index 77c48125..47c158d9 100644
--- a/src/nfc/doc/src/nfc-index.qdoc
+++ b/src/nfc/doc/src/nfc-index.qdoc
@@ -1,8 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2013 Aaron McCarthy <mccarthy.aaron@gmail.com>
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
@@ -11,15 +11,15 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
+** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
@@ -34,7 +34,7 @@
The NFC API provides connectivity between NFC enabled devices.
-Currently the API is supported on \l{Qt for BlackBerry}{BlackBerry 10}.
+Currently the API is supported on \l{Qt for BlackBerry}{BlackBerry 10} and Linux using \l {https://01.org/linux-nfc}{Neard} v0.14 or later.
\section1 Overview
diff --git a/src/nfc/doc/src/nfc-overview.qdoc b/src/nfc/doc/src/nfc-overview.qdoc
index b068dfb5..ac511471 100644
--- a/src/nfc/doc/src/nfc-overview.qdoc
+++ b/src/nfc/doc/src/nfc-overview.qdoc
@@ -1,8 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2013 Aaron McCarthy <mccarthy.aaron@gmail.com>
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
@@ -11,15 +11,15 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
+** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
@@ -105,7 +105,7 @@ Depending on the platform it may even be possible to start the application that
\note This feature is not available on all platforms and, in addition to the code snippets below,
may require further platform specific setup.
-\snippet annotatedurl/main.cpp QNearFieldManager register handler
+\snippet annotatedurl/annotatedurl.cpp QNearFieldManager register handler
For comparison an application that uses an empty NDEF filter (match all behavior) in combination with
\l QNearFieldManager::registerNdefMessageHandler() would behave similarly to another application that uses
diff --git a/src/nfc/doc/src/nfc-qml.qdoc b/src/nfc/doc/src/nfc-qml.qdoc
index 42e57159..3f96b39a 100644
--- a/src/nfc/doc/src/nfc-qml.qdoc
+++ b/src/nfc/doc/src/nfc-qml.qdoc
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 Aaron McCarthy <mccarthy.aaron@gmail.com>
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
@@ -10,15 +10,15 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
+** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
diff --git a/src/nfc/neard/adapter.cpp b/src/nfc/neard/adapter.cpp
new file mode 100644
index 00000000..d626678a
--- /dev/null
+++ b/src/nfc/neard/adapter.cpp
@@ -0,0 +1,25 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.8
+ * Command line was: qdbusxml2cpp -v org.neard.Adapter.xml -p adapter_p -v
+ *
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
+ *
+ * This is an auto-generated file.
+ * This file may have been hand-edited. Look for HAND-EDIT comments
+ * before re-generating it.
+ */
+
+#include "adapter_p.h"
+
+/*
+ * Implementation of interface class OrgNeardAdapterInterface
+ */
+
+OrgNeardAdapterInterface::OrgNeardAdapterInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
+ : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
+{
+}
+
+OrgNeardAdapterInterface::~OrgNeardAdapterInterface()
+{
+}
diff --git a/src/nfc/neard/adapter_p.h b/src/nfc/neard/adapter_p.h
new file mode 100644
index 00000000..76817705
--- /dev/null
+++ b/src/nfc/neard/adapter_p.h
@@ -0,0 +1,60 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.8
+ * Command line was: qdbusxml2cpp -v org.neard.Adapter.xml -p adapter_p -v
+ *
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
+ *
+ * This is an auto-generated file.
+ * Do not edit! All changes made to it will be lost.
+ */
+
+#ifndef ADAPTER_P_H_1410940487
+#define ADAPTER_P_H_1410940487
+
+#include <QtCore/QObject>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+#include <QtDBus/QtDBus>
+
+/*
+ * Proxy class for interface org.neard.Adapter
+ */
+class OrgNeardAdapterInterface: public QDBusAbstractInterface
+{
+ Q_OBJECT
+public:
+ static inline const char *staticInterfaceName()
+ { return "org.neard.Adapter"; }
+
+public:
+ OrgNeardAdapterInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
+
+ ~OrgNeardAdapterInterface();
+
+public Q_SLOTS: // METHODS
+ inline QDBusPendingReply<> StartPollLoop(const QString &name)
+ {
+ QList<QVariant> argumentList;
+ argumentList << QVariant::fromValue(name);
+ return asyncCallWithArgumentList(QStringLiteral("StartPollLoop"), argumentList);
+ }
+
+ inline QDBusPendingReply<> StopPollLoop()
+ {
+ QList<QVariant> argumentList;
+ return asyncCallWithArgumentList(QStringLiteral("StopPollLoop"), argumentList);
+ }
+
+Q_SIGNALS: // SIGNALS
+};
+
+namespace org {
+ namespace neard {
+ typedef ::OrgNeardAdapterInterface Adapter;
+ }
+}
+#endif
diff --git a/src/nfc/neard/agent.cpp b/src/nfc/neard/agent.cpp
new file mode 100644
index 00000000..faa48043
--- /dev/null
+++ b/src/nfc/neard/agent.cpp
@@ -0,0 +1,38 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.8
+ * Command line was: qdbusxml2cpp -v org.neard.Agent.xml -p agent_p -v
+ *
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
+ *
+ * This is an auto-generated file.
+ * This file may have been hand-edited. Look for HAND-EDIT comments
+ * before re-generating it.
+ */
+
+#include "agent_p.h"
+
+/*
+ * Implementation of interface class OrgNeardHandoverAgentInterface
+ */
+
+OrgNeardHandoverAgentInterface::OrgNeardHandoverAgentInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
+ : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
+{
+}
+
+OrgNeardHandoverAgentInterface::~OrgNeardHandoverAgentInterface()
+{
+}
+
+/*
+ * Implementation of interface class OrgNeardNDEFAgentInterface
+ */
+
+OrgNeardNDEFAgentInterface::OrgNeardNDEFAgentInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
+ : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
+{
+}
+
+OrgNeardNDEFAgentInterface::~OrgNeardNDEFAgentInterface()
+{
+}
diff --git a/src/nfc/neard/agent_p.h b/src/nfc/neard/agent_p.h
new file mode 100644
index 00000000..7e40ffaf
--- /dev/null
+++ b/src/nfc/neard/agent_p.h
@@ -0,0 +1,100 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.8
+ * Command line was: qdbusxml2cpp -v org.neard.Agent.xml -p agent_p -v
+ *
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
+ *
+ * This is an auto-generated file.
+ * Do not edit! All changes made to it will be lost.
+ */
+
+#ifndef AGENT_P_H_1410442485
+#define AGENT_P_H_1410442485
+
+#include <QtCore/QObject>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+#include <QtDBus/QtDBus>
+
+/*
+ * Proxy class for interface org.neard.HandoverAgent
+ */
+class OrgNeardHandoverAgentInterface: public QDBusAbstractInterface
+{
+ Q_OBJECT
+public:
+ static inline const char *staticInterfaceName()
+ { return "org.neard.HandoverAgent"; }
+
+public:
+ OrgNeardHandoverAgentInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
+
+ ~OrgNeardHandoverAgentInterface();
+
+public Q_SLOTS: // METHODS
+ inline QDBusPendingReply<> PushOOB(const QVariantMap &values)
+ {
+ QList<QVariant> argumentList;
+ argumentList << QVariant::fromValue(values);
+ return asyncCallWithArgumentList(QStringLiteral("PushOOB"), argumentList);
+ }
+
+ inline QDBusPendingReply<> Release()
+ {
+ QList<QVariant> argumentList;
+ return asyncCallWithArgumentList(QStringLiteral("Release"), argumentList);
+ }
+
+ inline QDBusPendingReply<QVariantMap> RequestOOB(const QVariantMap &values)
+ {
+ QList<QVariant> argumentList;
+ argumentList << QVariant::fromValue(values);
+ return asyncCallWithArgumentList(QStringLiteral("RequestOOB"), argumentList);
+ }
+
+Q_SIGNALS: // SIGNALS
+};
+
+/*
+ * Proxy class for interface org.neard.NDEFAgent
+ */
+class OrgNeardNDEFAgentInterface: public QDBusAbstractInterface
+{
+ Q_OBJECT
+public:
+ static inline const char *staticInterfaceName()
+ { return "org.neard.NDEFAgent"; }
+
+public:
+ OrgNeardNDEFAgentInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
+
+ ~OrgNeardNDEFAgentInterface();
+
+public Q_SLOTS: // METHODS
+ inline QDBusPendingReply<> GetNDEF(const QVariantMap &values)
+ {
+ QList<QVariant> argumentList;
+ argumentList << QVariant::fromValue(values);
+ return asyncCallWithArgumentList(QStringLiteral("GetNDEF"), argumentList);
+ }
+
+ inline QDBusPendingReply<> Release()
+ {
+ QList<QVariant> argumentList;
+ return asyncCallWithArgumentList(QStringLiteral("Release"), argumentList);
+ }
+
+Q_SIGNALS: // SIGNALS
+};
+
+namespace org {
+ namespace neard {
+ typedef ::OrgNeardHandoverAgentInterface HandoverAgent;
+ typedef ::OrgNeardNDEFAgentInterface NDEFAgent;
+ }
+}
+#endif
diff --git a/src/nfc/neard/dbusobjectmanager.cpp b/src/nfc/neard/dbusobjectmanager.cpp
new file mode 100644
index 00000000..7b3f8356
--- /dev/null
+++ b/src/nfc/neard/dbusobjectmanager.cpp
@@ -0,0 +1,26 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.8
+ * Command line was: qdbusxml2cpp -v dbus-object-manager.xml -p dbusobjectmanager -v
+ *
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
+ *
+ * This is an auto-generated file.
+ * This file may have been hand-edited. Look for HAND-EDIT comments
+ * before re-generating it.
+ */
+
+#include "dbusobjectmanager_p.h"
+
+/*
+ * Implementation of interface class OrgFreedesktopDBusObjectManagerInterface
+ */
+
+OrgFreedesktopDBusObjectManagerInterface::OrgFreedesktopDBusObjectManagerInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
+ : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
+{
+}
+
+OrgFreedesktopDBusObjectManagerInterface::~OrgFreedesktopDBusObjectManagerInterface()
+{
+}
+
diff --git a/src/nfc/neard/dbusobjectmanager_p.h b/src/nfc/neard/dbusobjectmanager_p.h
new file mode 100644
index 00000000..64d11449
--- /dev/null
+++ b/src/nfc/neard/dbusobjectmanager_p.h
@@ -0,0 +1,58 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.8
+ * Command line was: qdbusxml2cpp -v -i neard_helper_p.h org.freedesktop.dbus.objectmanager.xml -p dbusobjectmanager_p -v
+ *
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
+ *
+ * This is an auto-generated file.
+ * Do not edit! All changes made to it will be lost.
+ */
+
+#ifndef DBUSOBJECTMANAGER_H_1409928664
+#define DBUSOBJECTMANAGER_H_1409928664
+
+#include <QtCore/QObject>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+#include <QtDBus/QtDBus>
+#include "neard_helper_p.h"
+
+/*
+ * Proxy class for interface org.freedesktop.DBus.ObjectManager
+ */
+class OrgFreedesktopDBusObjectManagerInterface: public QDBusAbstractInterface
+{
+ Q_OBJECT
+public:
+ static inline const char *staticInterfaceName()
+ { return "org.freedesktop.DBus.ObjectManager"; }
+
+public:
+ OrgFreedesktopDBusObjectManagerInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
+
+ ~OrgFreedesktopDBusObjectManagerInterface();
+
+public Q_SLOTS: // METHODS
+ inline QDBusPendingReply<ManagedObjectList> GetManagedObjects()
+ {
+ QList<QVariant> argumentList;
+ return asyncCallWithArgumentList(QStringLiteral("GetManagedObjects"), argumentList);
+ }
+
+Q_SIGNALS: // SIGNALS
+ void InterfacesAdded(const QDBusObjectPath &object, InterfaceList interfaces);
+ void InterfacesRemoved(const QDBusObjectPath &object, const QStringList &interfaces);
+};
+
+namespace org {
+ namespace freedesktop {
+ namespace DBus {
+ typedef ::OrgFreedesktopDBusObjectManagerInterface ObjectManager;
+ }
+ }
+}
+#endif
diff --git a/src/nfc/neard/dbusproperties.cpp b/src/nfc/neard/dbusproperties.cpp
new file mode 100644
index 00000000..554b83d6
--- /dev/null
+++ b/src/nfc/neard/dbusproperties.cpp
@@ -0,0 +1,26 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.8
+ * Command line was: qdbusxml2cpp -v dbus-properties.xml -p dbusproperties -v
+ *
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
+ *
+ * This is an auto-generated file.
+ * This file may have been hand-edited. Look for HAND-EDIT comments
+ * before re-generating it.
+ */
+
+#include "dbusproperties_p.h" // HAND_EDIT
+
+/*
+ * Implementation of interface class OrgFreedesktopDBusPropertiesInterface
+ */
+
+OrgFreedesktopDBusPropertiesInterface::OrgFreedesktopDBusPropertiesInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
+ : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
+{
+}
+
+OrgFreedesktopDBusPropertiesInterface::~OrgFreedesktopDBusPropertiesInterface()
+{
+}
+
diff --git a/src/nfc/neard/dbusproperties_p.h b/src/nfc/neard/dbusproperties_p.h
new file mode 100644
index 00000000..ebca6278
--- /dev/null
+++ b/src/nfc/neard/dbusproperties_p.h
@@ -0,0 +1,71 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.8
+ * Command line was: qdbusxml2cpp -v org.freedesktop.dbus.properties.xml -p dbusproperties_p -v
+ *
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
+ *
+ * This is an auto-generated file.
+ * Do not edit! All changes made to it will be lost.
+ */
+
+#ifndef DBUSPROPERTIES_H_1409915780
+#define DBUSPROPERTIES_H_1409915780
+
+#include <QtCore/QObject>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+#include <QtDBus/QtDBus>
+
+/*
+ * Proxy class for interface org.freedesktop.DBus.Properties
+ */
+class OrgFreedesktopDBusPropertiesInterface: public QDBusAbstractInterface
+{
+ Q_OBJECT
+public:
+ static inline const char *staticInterfaceName()
+ { return "org.freedesktop.DBus.Properties"; }
+
+public:
+ OrgFreedesktopDBusPropertiesInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
+
+ ~OrgFreedesktopDBusPropertiesInterface();
+
+public Q_SLOTS: // METHODS
+ inline QDBusPendingReply<QDBusVariant> Get(const QString &interface, const QString &name)
+ {
+ QList<QVariant> argumentList;
+ argumentList << QVariant::fromValue(interface) << QVariant::fromValue(name);
+ return asyncCallWithArgumentList(QStringLiteral("Get"), argumentList);
+ }
+
+ inline QDBusPendingReply<QVariantMap> GetAll(const QString &interface)
+ {
+ QList<QVariant> argumentList;
+ argumentList << QVariant::fromValue(interface);
+ return asyncCallWithArgumentList(QStringLiteral("GetAll"), argumentList);
+ }
+
+ inline QDBusPendingReply<> Set(const QString &interface, const QString &name, const QDBusVariant &value)
+ {
+ QList<QVariant> argumentList;
+ argumentList << QVariant::fromValue(interface) << QVariant::fromValue(name) << QVariant::fromValue(value);
+ return asyncCallWithArgumentList(QStringLiteral("Set"), argumentList);
+ }
+
+Q_SIGNALS: // SIGNALS
+ void PropertiesChanged(const QString &interface, const QVariantMap &changed_properties, const QStringList &invalidated_properties);
+};
+
+namespace org {
+ namespace freedesktop {
+ namespace DBus {
+ typedef ::OrgFreedesktopDBusPropertiesInterface Properties;
+ }
+ }
+}
+#endif
diff --git a/src/nfc/neard/manager.cpp b/src/nfc/neard/manager.cpp
new file mode 100644
index 00000000..e1d72c6e
--- /dev/null
+++ b/src/nfc/neard/manager.cpp
@@ -0,0 +1,25 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.8
+ * Command line was: qdbusxml2cpp -v org.neard.Manager.xml -p manager_p -v
+ *
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
+ *
+ * This is an auto-generated file.
+ * This file may have been hand-edited. Look for HAND-EDIT comments
+ * before re-generating it.
+ */
+
+#include "manager_p.h"
+
+/*
+ * Implementation of interface class OrgNeardManagerInterface
+ */
+
+OrgNeardManagerInterface::OrgNeardManagerInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
+ : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
+{
+}
+
+OrgNeardManagerInterface::~OrgNeardManagerInterface()
+{
+}
diff --git a/src/nfc/neard/manager_p.h b/src/nfc/neard/manager_p.h
new file mode 100644
index 00000000..921c177b
--- /dev/null
+++ b/src/nfc/neard/manager_p.h
@@ -0,0 +1,91 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.8
+ * Command line was: qdbusxml2cpp -v org.neard.Manager.xml -p manager_p -v
+ *
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
+ *
+ * This is an auto-generated file.
+ * Do not edit! All changes made to it will be lost.
+ */
+
+#ifndef MANAGER_P_H_1410442485
+#define MANAGER_P_H_1410442485
+
+#include <QtCore/QObject>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+#include <QtDBus/QtDBus>
+
+/*
+ * Proxy class for interface org.neard.Manager
+ */
+class OrgNeardManagerInterface: public QDBusAbstractInterface
+{
+ Q_OBJECT
+public:
+ static inline const char *staticInterfaceName()
+ { return "org.neard.Manager"; }
+
+public:
+ OrgNeardManagerInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
+
+ ~OrgNeardManagerInterface();
+
+public Q_SLOTS: // METHODS
+ inline QDBusPendingReply<QVariantMap> GetProperties()
+ {
+ QList<QVariant> argumentList;
+ return asyncCallWithArgumentList(QStringLiteral("GetProperties"), argumentList);
+ }
+
+ inline QDBusPendingReply<> RegisterHandoverAgent(const QDBusObjectPath &path)
+ {
+ QList<QVariant> argumentList;
+ argumentList << QVariant::fromValue(path);
+ return asyncCallWithArgumentList(QStringLiteral("RegisterHandoverAgent"), argumentList);
+ }
+
+ inline QDBusPendingReply<> RegisterNDEFAgent(const QDBusObjectPath &path, const QString &type)
+ {
+ QList<QVariant> argumentList;
+ argumentList << QVariant::fromValue(path) << QVariant::fromValue(type);
+ return asyncCallWithArgumentList(QStringLiteral("RegisterNDEFAgent"), argumentList);
+ }
+
+ inline QDBusPendingReply<> SetProperty(const QString &name, const QDBusVariant &value)
+ {
+ QList<QVariant> argumentList;
+ argumentList << QVariant::fromValue(name) << QVariant::fromValue(value);
+ return asyncCallWithArgumentList(QStringLiteral("SetProperty"), argumentList);
+ }
+
+ inline QDBusPendingReply<> UnregisterHandoverAgent(const QDBusObjectPath &path)
+ {
+ QList<QVariant> argumentList;
+ argumentList << QVariant::fromValue(path);
+ return asyncCallWithArgumentList(QStringLiteral("UnregisterHandoverAgent"), argumentList);
+ }
+
+ inline QDBusPendingReply<> UnregisterNDEFAgent(const QDBusObjectPath &path, const QString &type)
+ {
+ QList<QVariant> argumentList;
+ argumentList << QVariant::fromValue(path) << QVariant::fromValue(type);
+ return asyncCallWithArgumentList(QStringLiteral("UnregisterNDEFAgent"), argumentList);
+ }
+
+Q_SIGNALS: // SIGNALS
+ void AdapterAdded(const QDBusObjectPath &adapter);
+ void AdapterRemoved(const QDBusObjectPath &adapter);
+ void PropertyChanged(const QString &name, const QDBusVariant &value);
+};
+
+namespace org {
+ namespace neard {
+ typedef ::OrgNeardManagerInterface Manager;
+ }
+}
+#endif
diff --git a/src/nfc/neard/neard.pri b/src/nfc/neard/neard.pri
new file mode 100644
index 00000000..8120a784
--- /dev/null
+++ b/src/nfc/neard/neard.pri
@@ -0,0 +1,22 @@
+HEADERS += neard/adapter_p.h \
+ neard/manager_p.h \
+ neard/tag_p.h \
+ neard/agent_p.h \
+ neard/dbusproperties_p.h \
+ neard/dbusobjectmanager_p.h \
+ neard/neard_helper_p.h
+
+SOURCES += neard/adapter.cpp \
+ neard/manager.cpp \
+ neard/tag.cpp \
+ neard/agent.cpp \
+ neard/dbusproperties.cpp \
+ neard/dbusobjectmanager.cpp \
+ neard/neard_helper.cpp
+
+OTHER_FILES += neard/org.freedesktop.dbus.objectmanager.xml \
+ neard/org.freedesktop.dbus.properties.xml \
+ neard/org.neard.Adapter.xml \
+ neard/org.neard.Agent.xml \
+ neard/org.neard.Manager.xml \
+ neard/org.neard.Tag.xml
diff --git a/src/nfc/neard/neard_helper.cpp b/src/nfc/neard/neard_helper.cpp
new file mode 100644
index 00000000..9e197d75
--- /dev/null
+++ b/src/nfc/neard/neard_helper.cpp
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2014 BasysKom GmbH.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QDBusMetaType>
+#include "neard_helper_p.h"
+#include "dbusobjectmanager_p.h"
+
+QT_BEGIN_NAMESPACE
+
+Q_DECLARE_LOGGING_CATEGORY(QT_NFC_NEARD)
+Q_GLOBAL_STATIC(NeardHelper, neardHelper)
+
+NeardHelper::NeardHelper(QObject *parent) :
+ QObject(parent)
+{
+ qDBusRegisterMetaType<InterfaceList>();
+ qDBusRegisterMetaType<ManagedObjectList>();
+
+ m_dbusObjectManager = new OrgFreedesktopDBusObjectManagerInterface(QStringLiteral("org.neard"),
+ QStringLiteral("/"),
+ QDBusConnection::systemBus(),
+ this);
+ if (!m_dbusObjectManager->isValid()) {
+ qCCritical(QT_NFC_NEARD) << "dbus object manager invalid";
+ return;
+ }
+
+ connect(m_dbusObjectManager, SIGNAL(InterfacesAdded(QDBusObjectPath,InterfaceList)),
+ this, SLOT(interfacesAdded(QDBusObjectPath,InterfaceList)));
+ connect(m_dbusObjectManager, SIGNAL(InterfacesRemoved(QDBusObjectPath,QStringList)),
+ this, SLOT(interfacesRemoved(QDBusObjectPath,QStringList)));
+}
+
+NeardHelper *NeardHelper::instance()
+{
+ return neardHelper();
+}
+
+OrgFreedesktopDBusObjectManagerInterface *NeardHelper::dbusObjectManager()
+{
+ return m_dbusObjectManager;
+}
+
+void NeardHelper::interfacesAdded(const QDBusObjectPath &path, InterfaceList interfaceList)
+{
+ foreach (const QString &key, interfaceList.keys()) {
+ if (key == QStringLiteral("org.neard.Tag")) {
+ emit tagFound(path);
+ break;
+ }
+ if (key == QStringLiteral("org.neard.Record")) {
+ emit recordFound(path);
+ break;
+ }
+ }
+}
+
+void NeardHelper::interfacesRemoved(const QDBusObjectPath &path, const QStringList &list)
+{
+ if (list.contains(QStringLiteral("org.neard.Record"))) {
+ qCDebug(QT_NFC_NEARD) << "record removed" << path.path();
+ emit recordRemoved(path);
+ } else if (list.contains(QStringLiteral("org.neard.Tag"))) {
+ qCDebug(QT_NFC_NEARD) << "tag removed" << path.path();
+ emit tagRemoved(path);
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/nfc/neard/neard_helper_p.h b/src/nfc/neard/neard_helper_p.h
new file mode 100644
index 00000000..274c5142
--- /dev/null
+++ b/src/nfc/neard/neard_helper_p.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2014 BasysKom GmbH.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef NEARD_HELPER_P_H
+#define NEARD_HELPER_P_H
+
+#include <QMetaType>
+#include <QDBusObjectPath>
+
+typedef QMap<QString, QVariantMap> InterfaceList;
+typedef QMap<QDBusObjectPath, InterfaceList> ManagedObjectList;
+
+Q_DECLARE_METATYPE(InterfaceList)
+Q_DECLARE_METATYPE(ManagedObjectList)
+
+class OrgFreedesktopDBusObjectManagerInterface;
+
+QT_BEGIN_NAMESPACE
+
+class NeardHelper : public QObject
+{
+ Q_OBJECT
+public:
+ NeardHelper(QObject* parent = 0);
+ static NeardHelper *instance();
+
+ OrgFreedesktopDBusObjectManagerInterface *dbusObjectManager();
+
+signals:
+ void tagFound(const QDBusObjectPath&);
+ void tagRemoved(const QDBusObjectPath&);
+ void recordFound(const QDBusObjectPath&);
+ void recordRemoved(const QDBusObjectPath&);
+
+private slots:
+ void interfacesAdded(const QDBusObjectPath&, InterfaceList);
+ void interfacesRemoved(const QDBusObjectPath&, const QStringList&);
+
+private:
+ OrgFreedesktopDBusObjectManagerInterface *m_dbusObjectManager;
+};
+
+QT_END_NAMESPACE
+
+#endif // NEARD_HELPER_P_H
diff --git a/src/nfc/neard/org.freedesktop.dbus.objectmanager.xml b/src/nfc/neard/org.freedesktop.dbus.objectmanager.xml
new file mode 100644
index 00000000..ae16f410
--- /dev/null
+++ b/src/nfc/neard/org.freedesktop.dbus.objectmanager.xml
@@ -0,0 +1,19 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="org.freedesktop.DBus.ObjectManager">
+ <method name="GetManagedObjects">
+ <arg name="objects" type="a{oa{sa{sv}}}" direction="out"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="ManagedObjectList"/>
+ </method>
+ <signal name="InterfacesAdded">
+ <arg name="object" type="o"/>
+ <arg name="interfaces" type="a{sa{sv}}"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="InterfaceList"/>
+ </signal>
+ <signal name="InterfacesRemoved">
+ <arg name="object" type="o"/>
+ <arg name="interfaces" type="as"/>
+ </signal>
+ </interface>
+</node>
diff --git a/src/nfc/neard/org.freedesktop.dbus.properties.xml b/src/nfc/neard/org.freedesktop.dbus.properties.xml
new file mode 100644
index 00000000..1449d567
--- /dev/null
+++ b/src/nfc/neard/org.freedesktop.dbus.properties.xml
@@ -0,0 +1,27 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="org.freedesktop.DBus.Properties">
+ <method name="Get">
+ <arg name="interface" type="s" direction="in"/>
+ <arg name="name" type="s" direction="in"/>
+ <arg name="value" type="v" direction="out"/>
+ </method>
+ <method name="Set">
+ <arg name="interface" type="s" direction="in"/>
+ <arg name="name" type="s" direction="in"/>
+ <arg name="value" type="v" direction="in"/>
+ </method>
+ <method name="GetAll">
+ <arg name="interface" type="s" direction="in"/>
+ <arg name="properties" type="a{sv}" direction="out"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
+ </method>
+ <signal name="PropertiesChanged">
+ <arg name="interface" type="s"/>
+ <arg name="changed_properties" type="a{sv}"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QVariantMap"/>
+ <arg name="invalidated_properties" type="as"/>
+ </signal>
+ </interface>
+</node>
diff --git a/src/nfc/neard/org.neard.Adapter.xml b/src/nfc/neard/org.neard.Adapter.xml
new file mode 100644
index 00000000..5f8c4cab
--- /dev/null
+++ b/src/nfc/neard/org.neard.Adapter.xml
@@ -0,0 +1,11 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="org.neard.Adapter">
+ <method name="StartPollLoop">
+ <arg name="name" type="s" direction="in"/>
+ </method>
+ <method name="StopPollLoop"/>
+ </interface>
+</node>
+
diff --git a/src/nfc/neard/org.neard.Agent.xml b/src/nfc/neard/org.neard.Agent.xml
new file mode 100644
index 00000000..5ec0e487
--- /dev/null
+++ b/src/nfc/neard/org.neard.Agent.xml
@@ -0,0 +1,26 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="org.neard.NDEFAgent">
+ <method name="GetNDEF">
+ <arg name="values" type="a{sv}" direction="in"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap"/>
+ </method>
+ <method name="Release">
+ </method>
+ </interface>
+ <interface name="org.neard.HandoverAgent">
+ <method name="RequestOOB">
+ <arg name="values" type="a{sv}" direction="in"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap"/>
+ <arg name="result" type="a{sv}" direction="out"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
+ </method>
+ <method name="PushOOB">
+ <arg name="values" type="a{sv}" direction="in"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap"/>
+ </method>
+ <method name="Release">
+ </method>
+ </interface>
+</node>
diff --git a/src/nfc/neard/org.neard.Manager.xml b/src/nfc/neard/org.neard.Manager.xml
new file mode 100644
index 00000000..1ed92378
--- /dev/null
+++ b/src/nfc/neard/org.neard.Manager.xml
@@ -0,0 +1,38 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="org.neard.Manager">
+ <method name="GetProperties">
+ <arg name="properties" type="a{sv}" direction="out"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
+ </method>
+ <method name="SetProperty">
+ <arg name="name" type="s" direction="in"/>
+ <arg name="value" type="v" direction="in"/>
+ </method>
+ <method name="RegisterHandoverAgent">
+ <arg name="path" type="o" direction="in"/>
+ </method>
+ <method name="UnregisterHandoverAgent">
+ <arg name="path" type="o" direction="in"/>
+ </method>
+ <method name="RegisterNDEFAgent">
+ <arg name="path" type="o" direction="in"/>
+ <arg name="type" type="s" direction="in"/>
+ </method>
+ <method name="UnregisterNDEFAgent">
+ <arg name="path" type="o" direction="in"/>
+ <arg name="type" type="s" direction="in"/>
+ </method>
+ <signal name="PropertyChanged">
+ <arg name="name" type="s"/>
+ <arg name="value" type="v"/>
+ </signal>
+ <signal name="AdapterAdded">
+ <arg name="adapter" type="o"/>
+ </signal>
+ <signal name="AdapterRemoved">
+ <arg name="adapter" type="o"/>
+ </signal>
+ </interface>
+</node>
diff --git a/src/nfc/neard/org.neard.Tag.xml b/src/nfc/neard/org.neard.Tag.xml
new file mode 100644
index 00000000..d6cbaddd
--- /dev/null
+++ b/src/nfc/neard/org.neard.Tag.xml
@@ -0,0 +1,13 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="org.neard.Tag">
+ <method name="Write">
+ <arg name="attributes" type="a{sv}" direction="in"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap"/>
+ </method>
+ <method name="GetRawNDEF">
+ <arg name="NDEF" type="ay" direction="out"/>
+ </method>
+ </interface>
+</node>
diff --git a/src/nfc/neard/tag.cpp b/src/nfc/neard/tag.cpp
new file mode 100644
index 00000000..918f7f2d
--- /dev/null
+++ b/src/nfc/neard/tag.cpp
@@ -0,0 +1,25 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.8
+ * Command line was: qdbusxml2cpp -v org.neard.Tag.xml -p tag_p -v
+ *
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
+ *
+ * This is an auto-generated file.
+ * This file may have been hand-edited. Look for HAND-EDIT comments
+ * before re-generating it.
+ */
+
+#include "tag_p.h"
+
+/*
+ * Implementation of interface class OrgNeardTagInterface
+ */
+
+OrgNeardTagInterface::OrgNeardTagInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
+ : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
+{
+}
+
+OrgNeardTagInterface::~OrgNeardTagInterface()
+{
+}
diff --git a/src/nfc/neard/tag_p.h b/src/nfc/neard/tag_p.h
new file mode 100644
index 00000000..c9a3aad3
--- /dev/null
+++ b/src/nfc/neard/tag_p.h
@@ -0,0 +1,60 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.8
+ * Command line was: qdbusxml2cpp -v org.neard.Tag.xml -p tag_p -v
+ *
+ * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
+ *
+ * This is an auto-generated file.
+ * Do not edit! All changes made to it will be lost.
+ */
+
+#ifndef TAG_P_H_1410941369
+#define TAG_P_H_1410941369
+
+#include <QtCore/QObject>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+#include <QtDBus/QtDBus>
+
+/*
+ * Proxy class for interface org.neard.Tag
+ */
+class OrgNeardTagInterface: public QDBusAbstractInterface
+{
+ Q_OBJECT
+public:
+ static inline const char *staticInterfaceName()
+ { return "org.neard.Tag"; }
+
+public:
+ OrgNeardTagInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
+
+ ~OrgNeardTagInterface();
+
+public Q_SLOTS: // METHODS
+ inline QDBusPendingReply<QByteArray> GetRawNDEF()
+ {
+ QList<QVariant> argumentList;
+ return asyncCallWithArgumentList(QStringLiteral("GetRawNDEF"), argumentList);
+ }
+
+ inline QDBusPendingReply<> Write(const QVariantMap &attributes)
+ {
+ QList<QVariant> argumentList;
+ argumentList << QVariant::fromValue(attributes);
+ return asyncCallWithArgumentList(QStringLiteral("Write"), argumentList);
+ }
+
+Q_SIGNALS: // SIGNALS
+};
+
+namespace org {
+ namespace neard {
+ typedef ::OrgNeardTagInterface Tag;
+ }
+}
+#endif
diff --git a/src/nfc/nfc.pro b/src/nfc/nfc.pro
index 7b88d4f0..7c6b6ff7 100644
--- a/src/nfc/nfc.pro
+++ b/src/nfc/nfc.pro
@@ -53,7 +53,8 @@ SOURCES += \
qqmlndefrecord.cpp \
qndefnfcsmartposterrecord.cpp \
qnearfieldsharemanager.cpp \
- qnearfieldsharetarget.cpp
+ qnearfieldsharetarget.cpp \
+ qnfc.cpp
CONFIG(blackberry) {
NFC_BACKEND_AVAILABLE = yes
@@ -99,6 +100,31 @@ CONFIG(blackberry) {
}
}
+linux:qtHaveModule(dbus) {
+ NFC_BACKEND_AVAILABLE = yes
+
+ QT += dbus
+
+ DEFINES += NEARD_NFC
+
+ PRIVATE_HEADERS += \
+ qllcpsocket_p_p.h \
+ qllcpserver_p_p.h \
+ qnearfieldmanager_neard_p.h \
+ qnearfieldsharemanagerimpl_p.h \
+ qnearfieldsharetargetimpl_p.h \
+ qnearfieldtarget_neard_p.h
+
+ SOURCES += \
+ qllcpsocket_p.cpp \
+ qllcpserver_p.cpp \
+ qnearfieldsharemanagerimpl_p.cpp \
+ qnearfieldsharetargetimpl_p.cpp \
+ qnearfieldmanager_neard.cpp
+
+ include(neard/neard.pri)
+}
+
simulator {
NFC_BACKEND_AVAILABLE = yes
diff --git a/src/nfc/qllcpserver.cpp b/src/nfc/qllcpserver.cpp
index c29295a5..4ee26eaf 100644
--- a/src/nfc/qllcpserver.cpp
+++ b/src/nfc/qllcpserver.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qllcpserver_p.cpp b/src/nfc/qllcpserver_p.cpp
index f7eca859..517dabea 100644
--- a/src/nfc/qllcpserver_p.cpp
+++ b/src/nfc/qllcpserver_p.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qllcpserver_p.h b/src/nfc/qllcpserver_p.h
index f7be4e35..83e7aa33 100644
--- a/src/nfc/qllcpserver_p.h
+++ b/src/nfc/qllcpserver_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qllcpserver_p_p.h b/src/nfc/qllcpserver_p_p.h
index fb95bea5..f101683c 100644
--- a/src/nfc/qllcpserver_p_p.h
+++ b/src/nfc/qllcpserver_p_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qllcpserver_qnx_p.cpp b/src/nfc/qllcpserver_qnx_p.cpp
index 9351d505..41168798 100644
--- a/src/nfc/qllcpserver_qnx_p.cpp
+++ b/src/nfc/qllcpserver_qnx_p.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2012 Research In Motion
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qllcpserver_qnx_p.h b/src/nfc/qllcpserver_qnx_p.h
index 005d23d3..16e33784 100644
--- a/src/nfc/qllcpserver_qnx_p.h
+++ b/src/nfc/qllcpserver_qnx_p.h
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 Research In Motion
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qllcpserver_simulator_p.cpp b/src/nfc/qllcpserver_simulator_p.cpp
index 53b92689..dea275e7 100644
--- a/src/nfc/qllcpserver_simulator_p.cpp
+++ b/src/nfc/qllcpserver_simulator_p.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qllcpserver_simulator_p.h b/src/nfc/qllcpserver_simulator_p.h
index 6381d403..938789dd 100644
--- a/src/nfc/qllcpserver_simulator_p.h
+++ b/src/nfc/qllcpserver_simulator_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qllcpsocket.cpp b/src/nfc/qllcpsocket.cpp
index 1e701e67..ae23f89c 100644
--- a/src/nfc/qllcpsocket.cpp
+++ b/src/nfc/qllcpsocket.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qllcpsocket_p.cpp b/src/nfc/qllcpsocket_p.cpp
index 700b97f0..83a789df 100644
--- a/src/nfc/qllcpsocket_p.cpp
+++ b/src/nfc/qllcpsocket_p.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qllcpsocket_p.h b/src/nfc/qllcpsocket_p.h
index 4b74e203..db49b4c0 100644
--- a/src/nfc/qllcpsocket_p.h
+++ b/src/nfc/qllcpsocket_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qllcpsocket_p_p.h b/src/nfc/qllcpsocket_p_p.h
index 7d10278d..93c6a679 100644
--- a/src/nfc/qllcpsocket_p_p.h
+++ b/src/nfc/qllcpsocket_p_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qllcpsocket_qnx_p.cpp b/src/nfc/qllcpsocket_qnx_p.cpp
index c35f570c..2351a524 100644
--- a/src/nfc/qllcpsocket_qnx_p.cpp
+++ b/src/nfc/qllcpsocket_qnx_p.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2012 Research In Motion
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qllcpsocket_qnx_p.h b/src/nfc/qllcpsocket_qnx_p.h
index de552eb3..5e3b2c06 100644
--- a/src/nfc/qllcpsocket_qnx_p.h
+++ b/src/nfc/qllcpsocket_qnx_p.h
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 Research In Motion
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qllcpsocket_simulator_p.cpp b/src/nfc/qllcpsocket_simulator_p.cpp
index d418d654..f6f40ef7 100644
--- a/src/nfc/qllcpsocket_simulator_p.cpp
+++ b/src/nfc/qllcpsocket_simulator_p.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qllcpsocket_simulator_p.h b/src/nfc/qllcpsocket_simulator_p.h
index 76af2f01..74e55199 100644
--- a/src/nfc/qllcpsocket_simulator_p.h
+++ b/src/nfc/qllcpsocket_simulator_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qndeffilter.cpp b/src/nfc/qndeffilter.cpp
index 07408729..916fa25a 100644
--- a/src/nfc/qndeffilter.cpp
+++ b/src/nfc/qndeffilter.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qndeffilter.h b/src/nfc/qndeffilter.h
index 053dfe21..56721bf1 100644
--- a/src/nfc/qndeffilter.h
+++ b/src/nfc/qndeffilter.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qndefmessage.cpp b/src/nfc/qndefmessage.cpp
index 9d5da089..356d35f5 100644
--- a/src/nfc/qndefmessage.cpp
+++ b/src/nfc/qndefmessage.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qndefmessage.h b/src/nfc/qndefmessage.h
index 1aca198c..1ecb04a0 100644
--- a/src/nfc/qndefmessage.h
+++ b/src/nfc/qndefmessage.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qndefnfcsmartposterrecord.cpp b/src/nfc/qndefnfcsmartposterrecord.cpp
index d1a6e4d5..b71b8ac2 100644
--- a/src/nfc/qndefnfcsmartposterrecord.cpp
+++ b/src/nfc/qndefnfcsmartposterrecord.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion
- ** Contact: http://www.qt-project.org/legal
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Digia. For licensing terms and
- ** conditions see http://qt.digia.com/licensing. For further information
- ** use the contact form at http://qt.digia.com/contact-us.
+ ** a written agreement between you and The Qt Company. For licensing terms
+ ** and conditions see http://www.qt.io/terms-conditions. For further
+ ** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
- ** In addition, as a special exception, Digia gives you certain additional
- ** rights. These rights are described in the Digia Qt LGPL Exception
+ ** As a special exception, The Qt Company gives you certain additional
+ ** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -92,6 +92,18 @@ QNdefNfcSmartPosterRecord::QNdefNfcSmartPosterRecord(const QNdefNfcSmartPosterRe
}
/*!
+ Assigns the \a other smart poster record to this record and returns a reference to
+ this record.
+*/
+QNdefNfcSmartPosterRecord &QNdefNfcSmartPosterRecord::operator=(const QNdefNfcSmartPosterRecord &other)
+{
+ if (this != &other)
+ d = other.d;
+
+ return *this;
+}
+
+/*!
Destroys the smart poster.
*/
QNdefNfcSmartPosterRecord::~QNdefNfcSmartPosterRecord()
@@ -602,7 +614,10 @@ bool QNdefNfcSmartPosterRecord::removeIcon(const QByteArray &type)
}
/*!
- Adds the icon record list \a icons to the smart poster. Any existing records are overwritten.
+ Adds the icon record list \a icons to the smart poster.
+ Any existing records are overwritten.
+
+ \sa hasIcon(), icon()
*/
void QNdefNfcSmartPosterRecord::setIcons(const QList<QNdefNfcIconRecord> &icons)
{
@@ -617,7 +632,13 @@ void QNdefNfcSmartPosterRecord::setIcons(const QList<QNdefNfcIconRecord> &icons)
}
/*!
- Returns the size from the size record if available. Otherwise returns 0.
+ Returns the size from the size record if available; otherwise returns 0.
+
+ The value is optional and contains the size in bytes of the object
+ that the URI refers to. It may be used by the device to determine
+ whether it can accommodate the object.
+
+ \sa setSize()
*/
quint32 QNdefNfcSmartPosterRecord::size() const
{
@@ -628,7 +649,10 @@ quint32 QNdefNfcSmartPosterRecord::size() const
}
/*!
- Sets the size record to \a size
+ Sets the record \a size. The value contains the size in bytes of
+ the object that the URI refers to.
+
+ \sa size(), hasSize()
*/
void QNdefNfcSmartPosterRecord::setSize(quint32 size)
{
@@ -642,7 +666,12 @@ void QNdefNfcSmartPosterRecord::setSize(quint32 size)
}
/*!
- Returns the type from the type record if available. Otherwise returns an empty byte array.
+ Returns the UTF-8 encoded MIME type that describes the type of the objects
+ that can be reached via uri().
+
+ If the type is not known the return QByteArray is empty.
+
+ \sa setTypeInfo(), hasTypeInfo()
*/
QByteArray QNdefNfcSmartPosterRecord::typeInfo() const
{
@@ -653,7 +682,10 @@ QByteArray QNdefNfcSmartPosterRecord::typeInfo() const
}
/*!
- Sets the type record to \a type
+ Sets the type record to \a type. \a type must be UTF-8 encoded
+ and describes the type of the object referenced by uri()
+
+ \sa typeInfo()
*/
void QNdefNfcSmartPosterRecord::setTypeInfo(const QByteArray &type)
{
diff --git a/src/nfc/qndefnfcsmartposterrecord.h b/src/nfc/qndefnfcsmartposterrecord.h
index ffd45dad..3b813a28 100644
--- a/src/nfc/qndefnfcsmartposterrecord.h
+++ b/src/nfc/qndefnfcsmartposterrecord.h
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion
- ** Contact: http://www.qt-project.org/legal
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Digia. For licensing terms and
- ** conditions see http://qt.digia.com/licensing. For further information
- ** use the contact form at http://qt.digia.com/contact-us.
+ ** a written agreement between you and The Qt Company. For licensing terms
+ ** and conditions see http://www.qt.io/terms-conditions. For further
+ ** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
- ** In addition, as a special exception, Digia gives you certain additional
- ** rights. These rights are described in the Digia Qt LGPL Exception
+ ** As a special exception, The Qt Company gives you certain additional
+ ** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -80,6 +80,7 @@ public:
QNdefNfcSmartPosterRecord();
QNdefNfcSmartPosterRecord(const QNdefRecord &other);
QNdefNfcSmartPosterRecord(const QNdefNfcSmartPosterRecord &other);
+ QNdefNfcSmartPosterRecord &operator=(const QNdefNfcSmartPosterRecord &other);
~QNdefNfcSmartPosterRecord();
void setPayload(const QByteArray &payload);
@@ -124,6 +125,7 @@ public:
quint32 size() const;
void setSize(quint32 size);
+ //TODO Qt 6 the mimetype should be QString as it is UTF-8
QByteArray typeInfo() const;
void setTypeInfo(const QByteArray &type);
diff --git a/src/nfc/qndefnfcsmartposterrecord_p.h b/src/nfc/qndefnfcsmartposterrecord_p.h
index 093a4253..a70d96cd 100644
--- a/src/nfc/qndefnfcsmartposterrecord_p.h
+++ b/src/nfc/qndefnfcsmartposterrecord_p.h
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2011 - 2012 Research In Motion
- ** Contact: http://www.qt-project.org/legal
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Digia. For licensing terms and
- ** conditions see http://qt.digia.com/licensing. For further information
- ** use the contact form at http://qt.digia.com/contact-us.
+ ** a written agreement between you and The Qt Company. For licensing terms
+ ** and conditions see http://www.qt.io/terms-conditions. For further
+ ** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
- ** In addition, as a special exception, Digia gives you certain additional
- ** rights. These rights are described in the Digia Qt LGPL Exception
+ ** As a special exception, The Qt Company gives you certain additional
+ ** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qndefnfctextrecord.cpp b/src/nfc/qndefnfctextrecord.cpp
index c06208a1..b54fd794 100644
--- a/src/nfc/qndefnfctextrecord.cpp
+++ b/src/nfc/qndefnfctextrecord.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qndefnfctextrecord.h b/src/nfc/qndefnfctextrecord.h
index 05a85949..e2f06917 100644
--- a/src/nfc/qndefnfctextrecord.h
+++ b/src/nfc/qndefnfctextrecord.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qndefnfcurirecord.cpp b/src/nfc/qndefnfcurirecord.cpp
index dabd2dae..d38e72d9 100644
--- a/src/nfc/qndefnfcurirecord.cpp
+++ b/src/nfc/qndefnfcurirecord.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qndefnfcurirecord.h b/src/nfc/qndefnfcurirecord.h
index 38686544..49f9e0bf 100644
--- a/src/nfc/qndefnfcurirecord.h
+++ b/src/nfc/qndefnfcurirecord.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qndefrecord.cpp b/src/nfc/qndefrecord.cpp
index 8961e9d7..167b7617 100644
--- a/src/nfc/qndefrecord.cpp
+++ b/src/nfc/qndefrecord.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qndefrecord.h b/src/nfc/qndefrecord.h
index 8c61d8c2..84303267 100644
--- a/src/nfc/qndefrecord.h
+++ b/src/nfc/qndefrecord.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qndefrecord_p.h b/src/nfc/qndefrecord_p.h
index 04e9c72c..40311ee0 100644
--- a/src/nfc/qndefrecord_p.h
+++ b/src/nfc/qndefrecord_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldmanager.cpp b/src/nfc/qnearfieldmanager.cpp
index 77410490..dce1a9f3 100644
--- a/src/nfc/qnearfieldmanager.cpp
+++ b/src/nfc/qnearfieldmanager.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -38,6 +38,8 @@
#include "qnearfieldmanager_simulator_p.h"
#elif defined(QNX_NFC)
#include "qnearfieldmanager_qnx_p.h"
+#elif defined(NEARD_NFC)
+#include "qnearfieldmanager_neard_p.h"
#else
#include "qnearfieldmanagerimpl_p.h"
#endif
@@ -112,6 +114,14 @@ QT_BEGIN_NAMESPACE
</filter>
</invoke-target>
\endcode
+
+ \section3 NFC on Linux
+ The \l{https://01.org/linux-nfc}{Linux NFC project} provides software to support NFC on Linux platforms.
+ The neard daemon will allow access to the supported hardware via DBus interfaces. QtNfc requires neard
+ version 0.14 which can be built from source or installed via the appropriate Linux package manager. Not
+ all API features are currently supported.
+ To allow QtNfc to access the DBus interfaces the neard daemon has to be running. In case of problems
+ debug output can be enabled by enabling categorized logging for 'qt.nfc.neard'.
*/
/*!
@@ -213,6 +223,8 @@ bool QNearFieldManager::isAvailable() const
successfully started; otherwise returns false. Causes the targetDetected() signal to be emitted
when a target is within proximity.
\sa stopTargetDetection()
+
+ \note For platforms using neard: target detection will stop as soon as a tag has been detected.
*/
bool QNearFieldManager::startTargetDetection()
{
@@ -276,6 +288,8 @@ static QMetaMethod methodForSignature(QObject *object, const char *method)
\note The \e target parameter of \a method may not be available on all platforms, in which case
\e target will be 0.
+
+ \note On platforms using neard registering message handlers is not supported.
*/
int QNearFieldManager::registerNdefMessageHandler(QNdefRecord::TypeNameFormat typeNameFormat,
diff --git a/src/nfc/qnearfieldmanager.h b/src/nfc/qnearfieldmanager.h
index 7fad3b4d..8dab134f 100644
--- a/src/nfc/qnearfieldmanager.h
+++ b/src/nfc/qnearfieldmanager.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldmanager_emulator.cpp b/src/nfc/qnearfieldmanager_emulator.cpp
index c532fea1..f1e33649 100644
--- a/src/nfc/qnearfieldmanager_emulator.cpp
+++ b/src/nfc/qnearfieldmanager_emulator.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldmanager_emulator_p.h b/src/nfc/qnearfieldmanager_emulator_p.h
index b69bf8a9..0fd980f9 100644
--- a/src/nfc/qnearfieldmanager_emulator_p.h
+++ b/src/nfc/qnearfieldmanager_emulator_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldmanager_neard.cpp b/src/nfc/qnearfieldmanager_neard.cpp
new file mode 100644
index 00000000..389d701e
--- /dev/null
+++ b/src/nfc/qnearfieldmanager_neard.cpp
@@ -0,0 +1,267 @@
+/***************************************************************************
+**
+** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
+** Copyright (C) 2014 BasysKom GmbH.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qnearfieldmanager_neard_p.h"
+#include "qnearfieldtarget_neard_p.h"
+
+#include "neard/adapter_p.h"
+#include "neard/dbusproperties_p.h"
+#include "neard/dbusobjectmanager_p.h"
+
+QT_BEGIN_NAMESPACE
+
+Q_DECLARE_LOGGING_CATEGORY(QT_NFC_NEARD)
+
+// TODO We need a constructor that lets us select an adapter
+QNearFieldManagerPrivateImpl::QNearFieldManagerPrivateImpl()
+ : QNearFieldManagerPrivate(),
+ m_neardHelper(NeardHelper::instance())
+{
+ QDBusPendingReply<ManagedObjectList> reply = m_neardHelper->dbusObjectManager()->GetManagedObjects();
+ reply.waitForFinished();
+ if (reply.isError()) {
+ qCWarning(QT_NFC_NEARD) << "Error getting managed objects";
+ return;
+ }
+
+ bool found = false;
+ foreach (const QDBusObjectPath &path, reply.value().keys()) {
+ const InterfaceList ifaceList = reply.value().value(path);
+ foreach (const QString &iface, ifaceList.keys()) {
+ if (iface == QStringLiteral("org.neard.Adapter")) {
+ found = true;
+ m_adapterPath = path.path();
+ qCDebug(QT_NFC_NEARD) << "org.neard.Adapter found for path" << m_adapterPath;
+ break;
+ }
+ }
+
+ if (found)
+ break;
+ }
+
+ if (!found) {
+ qCWarning(QT_NFC_NEARD) << "no adapter found, neard daemon running?";
+ } else {
+ connect(m_neardHelper, SIGNAL(tagFound(QDBusObjectPath)),
+ this, SLOT(handleTagFound(QDBusObjectPath)));
+ connect(m_neardHelper, SIGNAL(tagRemoved(QDBusObjectPath)),
+ this, SLOT(handleTagRemoved(QDBusObjectPath)));
+ }
+}
+
+QNearFieldManagerPrivateImpl::~QNearFieldManagerPrivateImpl()
+{
+ stopTargetDetection();
+}
+
+bool QNearFieldManagerPrivateImpl::isAvailable() const
+{
+ if (!m_neardHelper->dbusObjectManager()->isValid() || m_adapterPath.isNull()) {
+ qCWarning(QT_NFC_NEARD) << "dbus object manager invalid or adapter path invalid";
+ return false;
+ }
+
+ QDBusPendingReply<ManagedObjectList> reply = m_neardHelper->dbusObjectManager()->GetManagedObjects();
+ reply.waitForFinished();
+ if (reply.isError()) {
+ qCWarning(QT_NFC_NEARD) << "error getting managed objects";
+ return false;
+ }
+
+ foreach (const QDBusObjectPath &path, reply.value().keys()) {
+ if (m_adapterPath == path.path())
+ return true;
+ }
+
+ return false;
+}
+
+bool QNearFieldManagerPrivateImpl::startTargetDetection()
+{
+ qCDebug(QT_NFC_NEARD) << "starting target detection";
+ if (!isAvailable())
+ return false;
+
+ OrgFreedesktopDBusPropertiesInterface dbusProperties(QStringLiteral("org.neard"),
+ m_adapterPath,
+ QDBusConnection::systemBus());
+
+ if (!dbusProperties.isValid()) {
+ qCWarning(QT_NFC_NEARD) << "dbus property interface invalid";
+ return false;
+ }
+
+ // check if the adapter is currently polling
+ QDBusPendingReply<QDBusVariant> replyPolling = dbusProperties.Get(QStringLiteral("org.neard.Adapter"),
+ QStringLiteral("Polling"));
+ replyPolling.waitForFinished();
+ if (!replyPolling.isError()) {
+ if (replyPolling.value().variant().toBool()) {
+ qCDebug(QT_NFC_NEARD) << "adapter is already polling";
+ return true;
+ }
+ } else {
+ qCWarning(QT_NFC_NEARD) << "error getting 'Polling' state from property interface";
+ return false;
+ }
+
+ // check if the adapter it powered
+ QDBusPendingReply<QDBusVariant> replyPowered = dbusProperties.Get(QStringLiteral("org.neard.Adapter"),
+ QStringLiteral("Powered"));
+ replyPowered.waitForFinished();
+ if (!replyPowered.isError()) {
+ if (replyPowered.value().variant().toBool()) {
+ qCDebug(QT_NFC_NEARD) << "adapter is already powered";
+ } else {
+ QDBusPendingReply<QDBusVariant> replyTryPowering = dbusProperties.Set(QStringLiteral("org.neard.Adapter"),
+ QStringLiteral("Powered"),
+ QDBusVariant(true));
+ replyTryPowering.waitForFinished();
+ if (!replyTryPowering.isError()) {
+ qCDebug(QT_NFC_NEARD) << "powering adapter";
+ }
+ }
+ } else {
+ qCWarning(QT_NFC_NEARD) << "error getting 'Powered' state from property interface";
+ return false;
+ }
+
+ // create adapter and start poll loop
+ OrgNeardAdapterInterface neardAdapter(QStringLiteral("org.neard"),
+ m_adapterPath,
+ QDBusConnection::systemBus());
+
+ // possible modes: "Target", "Initiator", "Dual"
+ QDBusPendingReply<> replyPollLoop = neardAdapter.StartPollLoop(QStringLiteral("Dual"));
+ replyPollLoop.waitForFinished();
+ if (replyPollLoop.isError()) {
+ qCWarning(QT_NFC_NEARD) << "error when starting polling";
+ return false;
+ } else {
+ qCDebug(QT_NFC_NEARD) << "successfully started polling";
+ }
+
+ return true;
+}
+
+void QNearFieldManagerPrivateImpl::stopTargetDetection()
+{
+ qCDebug(QT_NFC_NEARD) << "stopping target detection";
+ if (!isAvailable())
+ return;
+
+ OrgFreedesktopDBusPropertiesInterface dbusProperties(QStringLiteral("org.neard"),
+ m_adapterPath,
+ QDBusConnection::systemBus());
+
+ if (!dbusProperties.isValid()) {
+ qCWarning(QT_NFC_NEARD) << "dbus property interface invalid";
+ return;
+ }
+
+ // check if the adapter is currently polling
+ QDBusPendingReply<QDBusVariant> replyPolling = dbusProperties.Get(QStringLiteral("org.neard.Adapter"),
+ QStringLiteral("Polling"));
+ replyPolling.waitForFinished();
+ if (!replyPolling.isError()) {
+ if (replyPolling.value().variant().toBool()) {
+ // create adapter and stop poll loop
+ OrgNeardAdapterInterface neardAdapter(QStringLiteral("org.neard"),
+ m_adapterPath,
+ QDBusConnection::systemBus());
+
+ QDBusPendingReply<> replyStopPolling = neardAdapter.StopPollLoop();
+ replyStopPolling.waitForFinished();
+ if (replyStopPolling.isError())
+ qCWarning(QT_NFC_NEARD) << "error when stopping polling";
+ else
+ qCDebug(QT_NFC_NEARD) << "successfully stopped polling";
+ } else {
+ qCDebug(QT_NFC_NEARD) << "already stopped polling";
+ }
+ } else {
+ qCWarning(QT_NFC_NEARD) << "error getting 'Polling' state from property interface";
+ }
+}
+
+int QNearFieldManagerPrivateImpl::registerNdefMessageHandler(QObject *object, const QMetaMethod &method)
+{
+ Q_UNUSED(object);
+ Q_UNUSED(method);
+ return -1;
+}
+
+int QNearFieldManagerPrivateImpl::registerNdefMessageHandler(const QNdefFilter &filter, QObject *object, const QMetaMethod &method)
+{
+ Q_UNUSED(filter);
+ Q_UNUSED(object);
+ Q_UNUSED(method);
+ return -1;
+}
+
+bool QNearFieldManagerPrivateImpl::unregisterNdefMessageHandler(int handlerId)
+{
+ Q_UNUSED(handlerId);
+ return false;
+}
+
+void QNearFieldManagerPrivateImpl::requestAccess(QNearFieldManager::TargetAccessModes accessModes)
+{
+ Q_UNUSED(accessModes);
+}
+
+void QNearFieldManagerPrivateImpl::releaseAccess(QNearFieldManager::TargetAccessModes accessModes)
+{
+ Q_UNUSED(accessModes);
+}
+
+void QNearFieldManagerPrivateImpl::handleTagFound(const QDBusObjectPath &path)
+{
+ NearFieldTarget<QNearFieldTarget> *nfTag = new NearFieldTarget<QNearFieldTarget>(this, path);
+ m_activeTags.insert(path.path(), nfTag);
+ emit targetDetected(nfTag);
+}
+
+void QNearFieldManagerPrivateImpl::handleTagRemoved(const QDBusObjectPath &path)
+{
+ const QString adapterPath = path.path();
+ if (m_activeTags.contains(adapterPath)) {
+ QNearFieldTarget *nfTag = m_activeTags.value(adapterPath);
+ m_activeTags.remove(adapterPath);
+ emit targetLost(nfTag);
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/nfc/qnearfieldmanager_neard_p.h b/src/nfc/qnearfieldmanager_neard_p.h
new file mode 100644
index 00000000..856851d4
--- /dev/null
+++ b/src/nfc/qnearfieldmanager_neard_p.h
@@ -0,0 +1,89 @@
+/***************************************************************************
+**
+** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
+** Copyright (C) 2014 BasysKom GmbH.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QNEARFIELDMANAGER_NEARD_H
+#define QNEARFIELDMANAGER_NEARD_H
+
+#include "qnearfieldmanager_p.h"
+#include "qnearfieldmanager.h"
+#include "qnearfieldtarget.h"
+#include "neard/neard_helper_p.h"
+
+#include <QDBusObjectPath>
+#include <QDBusVariant>
+#include <QMap>
+
+class OrgNeardManagerInterface;
+
+QT_BEGIN_NAMESPACE
+
+class QNearFieldManagerPrivateImpl : public QNearFieldManagerPrivate
+{
+ Q_OBJECT
+
+public:
+ QNearFieldManagerPrivateImpl();
+ ~QNearFieldManagerPrivateImpl();
+
+ bool isAvailable() const;
+
+ bool startTargetDetection();
+
+ void stopTargetDetection();
+
+ // not implemented
+ int registerNdefMessageHandler(QObject *object, const QMetaMethod &method);
+
+ int registerNdefMessageHandler(const QNdefFilter &filter, QObject *object, const QMetaMethod &method);
+
+ bool unregisterNdefMessageHandler(int handlerId);
+
+ void requestAccess(QNearFieldManager::TargetAccessModes accessModes);
+
+ void releaseAccess(QNearFieldManager::TargetAccessModes accessModes);
+
+private Q_SLOTS:
+ void handleTagFound(const QDBusObjectPath&);
+ void handleTagRemoved(const QDBusObjectPath&);
+
+private:
+ QString m_adapterPath;
+ QMap<QString, QNearFieldTarget*> m_activeTags;
+ NeardHelper *m_neardHelper;
+};
+
+QT_END_NAMESPACE
+
+
+#endif // QNEARFIELDMANAGER_NEARD_H
diff --git a/src/nfc/qnearfieldmanager_p.h b/src/nfc/qnearfieldmanager_p.h
index 97b2899c..e8e4788c 100644
--- a/src/nfc/qnearfieldmanager_p.h
+++ b/src/nfc/qnearfieldmanager_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldmanager_qnx.cpp b/src/nfc/qnearfieldmanager_qnx.cpp
index 78b1231c..2c3c7077 100644
--- a/src/nfc/qnearfieldmanager_qnx.cpp
+++ b/src/nfc/qnearfieldmanager_qnx.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2012 Research In Motion
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldmanager_qnx_p.h b/src/nfc/qnearfieldmanager_qnx_p.h
index 5d78ece6..6f00041a 100644
--- a/src/nfc/qnearfieldmanager_qnx_p.h
+++ b/src/nfc/qnearfieldmanager_qnx_p.h
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2012 Research In Motion
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldmanager_simulator.cpp b/src/nfc/qnearfieldmanager_simulator.cpp
index 63574de8..a304e6d3 100644
--- a/src/nfc/qnearfieldmanager_simulator.cpp
+++ b/src/nfc/qnearfieldmanager_simulator.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldmanager_simulator_p.h b/src/nfc/qnearfieldmanager_simulator_p.h
index 63ef977d..dca19982 100644
--- a/src/nfc/qnearfieldmanager_simulator_p.h
+++ b/src/nfc/qnearfieldmanager_simulator_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldmanagerimpl_p.cpp b/src/nfc/qnearfieldmanagerimpl_p.cpp
index 915f4372..58135179 100644
--- a/src/nfc/qnearfieldmanagerimpl_p.cpp
+++ b/src/nfc/qnearfieldmanagerimpl_p.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldmanagerimpl_p.h b/src/nfc/qnearfieldmanagerimpl_p.h
index 13fbd4ff..4009ed5d 100644
--- a/src/nfc/qnearfieldmanagerimpl_p.h
+++ b/src/nfc/qnearfieldmanagerimpl_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldmanagervirtualbase.cpp b/src/nfc/qnearfieldmanagervirtualbase.cpp
index 5bd0dfa7..cf25ed2b 100644
--- a/src/nfc/qnearfieldmanagervirtualbase.cpp
+++ b/src/nfc/qnearfieldmanagervirtualbase.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldmanagervirtualbase_p.h b/src/nfc/qnearfieldmanagervirtualbase_p.h
index 52bb19f0..5af376f7 100644
--- a/src/nfc/qnearfieldmanagervirtualbase_p.h
+++ b/src/nfc/qnearfieldmanagervirtualbase_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldsharemanager.cpp b/src/nfc/qnearfieldsharemanager.cpp
index a5303e4e..e9b70739 100644
--- a/src/nfc/qnearfieldsharemanager.cpp
+++ b/src/nfc/qnearfieldsharemanager.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
- ** Contact: http://www.qt-project.org/legal
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Digia. For licensing terms and
- ** conditions see http://qt.digia.com/licensing. For further information
- ** use the contact form at http://qt.digia.com/contact-us.
+ ** a written agreement between you and The Qt Company. For licensing terms
+ ** and conditions see http://www.qt.io/terms-conditions. For further
+ ** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
- ** In addition, as a special exception, Digia gives you certain additional
- ** rights. These rights are described in the Digia Qt LGPL Exception
+ ** As a special exception, The Qt Company gives you certain additional
+ ** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldsharemanager.h b/src/nfc/qnearfieldsharemanager.h
index 550858f1..330cc621 100644
--- a/src/nfc/qnearfieldsharemanager.h
+++ b/src/nfc/qnearfieldsharemanager.h
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
- ** Contact: http://www.qt-project.org/legal
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Digia. For licensing terms and
- ** conditions see http://qt.digia.com/licensing. For further information
- ** use the contact form at http://qt.digia.com/contact-us.
+ ** a written agreement between you and The Qt Company. For licensing terms
+ ** and conditions see http://www.qt.io/terms-conditions. For further
+ ** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
- ** In addition, as a special exception, Digia gives you certain additional
- ** rights. These rights are described in the Digia Qt LGPL Exception
+ ** As a special exception, The Qt Company gives you certain additional
+ ** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldsharemanager_p.h b/src/nfc/qnearfieldsharemanager_p.h
index f9f5c90b..034e9381 100644
--- a/src/nfc/qnearfieldsharemanager_p.h
+++ b/src/nfc/qnearfieldsharemanager_p.h
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
- ** Contact: http://www.qt-project.org/legal
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Digia. For licensing terms and
- ** conditions see http://qt.digia.com/licensing. For further information
- ** use the contact form at http://qt.digia.com/contact-us.
+ ** a written agreement between you and The Qt Company. For licensing terms
+ ** and conditions see http://www.qt.io/terms-conditions. For further
+ ** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
- ** In addition, as a special exception, Digia gives you certain additional
- ** rights. These rights are described in the Digia Qt LGPL Exception
+ ** As a special exception, The Qt Company gives you certain additional
+ ** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldsharemanager_qnx_p.cpp b/src/nfc/qnearfieldsharemanager_qnx_p.cpp
index 04e6a1a7..dd2814d6 100644
--- a/src/nfc/qnearfieldsharemanager_qnx_p.cpp
+++ b/src/nfc/qnearfieldsharemanager_qnx_p.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
- ** Contact: http://www.qt-project.org/legal
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Digia. For licensing terms and
- ** conditions see http://qt.digia.com/licensing. For further information
- ** use the contact form at http://qt.digia.com/contact-us.
+ ** a written agreement between you and The Qt Company. For licensing terms
+ ** and conditions see http://www.qt.io/terms-conditions. For further
+ ** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
- ** In addition, as a special exception, Digia gives you certain additional
- ** rights. These rights are described in the Digia Qt LGPL Exception
+ ** As a special exception, The Qt Company gives you certain additional
+ ** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldsharemanager_qnx_p.h b/src/nfc/qnearfieldsharemanager_qnx_p.h
index 9478bbdb..c5cea224 100644
--- a/src/nfc/qnearfieldsharemanager_qnx_p.h
+++ b/src/nfc/qnearfieldsharemanager_qnx_p.h
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
- ** Contact: http://www.qt-project.org/legal
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Digia. For licensing terms and
- ** conditions see http://qt.digia.com/licensing. For further information
- ** use the contact form at http://qt.digia.com/contact-us.
+ ** a written agreement between you and The Qt Company. For licensing terms
+ ** and conditions see http://www.qt.io/terms-conditions. For further
+ ** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
- ** In addition, as a special exception, Digia gives you certain additional
- ** rights. These rights are described in the Digia Qt LGPL Exception
+ ** As a special exception, The Qt Company gives you certain additional
+ ** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldsharemanagerimpl_p.cpp b/src/nfc/qnearfieldsharemanagerimpl_p.cpp
index 2cf8ead5..e99611f2 100644
--- a/src/nfc/qnearfieldsharemanagerimpl_p.cpp
+++ b/src/nfc/qnearfieldsharemanagerimpl_p.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
- ** Contact: http://www.qt-project.org/legal
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Digia. For licensing terms and
- ** conditions see http://qt.digia.com/licensing. For further information
- ** use the contact form at http://qt.digia.com/contact-us.
+ ** a written agreement between you and The Qt Company. For licensing terms
+ ** and conditions see http://www.qt.io/terms-conditions. For further
+ ** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
- ** In addition, as a special exception, Digia gives you certain additional
- ** rights. These rights are described in the Digia Qt LGPL Exception
+ ** As a special exception, The Qt Company gives you certain additional
+ ** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldsharemanagerimpl_p.h b/src/nfc/qnearfieldsharemanagerimpl_p.h
index dd350834..46ee2014 100644
--- a/src/nfc/qnearfieldsharemanagerimpl_p.h
+++ b/src/nfc/qnearfieldsharemanagerimpl_p.h
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
- ** Contact: http://www.qt-project.org/legal
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Digia. For licensing terms and
- ** conditions see http://qt.digia.com/licensing. For further information
- ** use the contact form at http://qt.digia.com/contact-us.
+ ** a written agreement between you and The Qt Company. For licensing terms
+ ** and conditions see http://www.qt.io/terms-conditions. For further
+ ** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
- ** In addition, as a special exception, Digia gives you certain additional
- ** rights. These rights are described in the Digia Qt LGPL Exception
+ ** As a special exception, The Qt Company gives you certain additional
+ ** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldsharetarget.cpp b/src/nfc/qnearfieldsharetarget.cpp
index 9f58b6ef..86c6318e 100644
--- a/src/nfc/qnearfieldsharetarget.cpp
+++ b/src/nfc/qnearfieldsharetarget.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
- ** Contact: http://www.qt-project.org/legal
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Digia. For licensing terms and
- ** conditions see http://qt.digia.com/licensing. For further information
- ** use the contact form at http://qt.digia.com/contact-us.
+ ** a written agreement between you and The Qt Company. For licensing terms
+ ** and conditions see http://www.qt.io/terms-conditions. For further
+ ** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
- ** In addition, as a special exception, Digia gives you certain additional
- ** rights. These rights are described in the Digia Qt LGPL Exception
+ ** As a special exception, The Qt Company gives you certain additional
+ ** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldsharetarget.h b/src/nfc/qnearfieldsharetarget.h
index 822a8ed5..cc85086f 100644
--- a/src/nfc/qnearfieldsharetarget.h
+++ b/src/nfc/qnearfieldsharetarget.h
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
- ** Contact: http://www.qt-project.org/legal
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Digia. For licensing terms and
- ** conditions see http://qt.digia.com/licensing. For further information
- ** use the contact form at http://qt.digia.com/contact-us.
+ ** a written agreement between you and The Qt Company. For licensing terms
+ ** and conditions see http://www.qt.io/terms-conditions. For further
+ ** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
- ** In addition, as a special exception, Digia gives you certain additional
- ** rights. These rights are described in the Digia Qt LGPL Exception
+ ** As a special exception, The Qt Company gives you certain additional
+ ** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldsharetarget_p.h b/src/nfc/qnearfieldsharetarget_p.h
index aa28ee2b..ab0cf8a2 100644
--- a/src/nfc/qnearfieldsharetarget_p.h
+++ b/src/nfc/qnearfieldsharetarget_p.h
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
- ** Contact: http://www.qt-project.org/legal
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Digia. For licensing terms and
- ** conditions see http://qt.digia.com/licensing. For further information
- ** use the contact form at http://qt.digia.com/contact-us.
+ ** a written agreement between you and The Qt Company. For licensing terms
+ ** and conditions see http://www.qt.io/terms-conditions. For further
+ ** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
- ** In addition, as a special exception, Digia gives you certain additional
- ** rights. These rights are described in the Digia Qt LGPL Exception
+ ** As a special exception, The Qt Company gives you certain additional
+ ** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldsharetarget_qnx_p.cpp b/src/nfc/qnearfieldsharetarget_qnx_p.cpp
index a68f7a4f..6dfea8d2 100644
--- a/src/nfc/qnearfieldsharetarget_qnx_p.cpp
+++ b/src/nfc/qnearfieldsharetarget_qnx_p.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
- ** Contact: http://www.qt-project.org/legal
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Digia. For licensing terms and
- ** conditions see http://qt.digia.com/licensing. For further information
- ** use the contact form at http://qt.digia.com/contact-us.
+ ** a written agreement between you and The Qt Company. For licensing terms
+ ** and conditions see http://www.qt.io/terms-conditions. For further
+ ** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
- ** In addition, as a special exception, Digia gives you certain additional
- ** rights. These rights are described in the Digia Qt LGPL Exception
+ ** As a special exception, The Qt Company gives you certain additional
+ ** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldsharetarget_qnx_p.h b/src/nfc/qnearfieldsharetarget_qnx_p.h
index 3afd6adb..626d2cc1 100644
--- a/src/nfc/qnearfieldsharetarget_qnx_p.h
+++ b/src/nfc/qnearfieldsharetarget_qnx_p.h
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
- ** Contact: http://www.qt-project.org/legal
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Digia. For licensing terms and
- ** conditions see http://qt.digia.com/licensing. For further information
- ** use the contact form at http://qt.digia.com/contact-us.
+ ** a written agreement between you and The Qt Company. For licensing terms
+ ** and conditions see http://www.qt.io/terms-conditions. For further
+ ** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
- ** In addition, as a special exception, Digia gives you certain additional
- ** rights. These rights are described in the Digia Qt LGPL Exception
+ ** As a special exception, The Qt Company gives you certain additional
+ ** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldsharetargetimpl_p.cpp b/src/nfc/qnearfieldsharetargetimpl_p.cpp
index f346f70e..6dbe12a0 100644
--- a/src/nfc/qnearfieldsharetargetimpl_p.cpp
+++ b/src/nfc/qnearfieldsharetargetimpl_p.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
- ** Contact: http://www.qt-project.org/legal
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Digia. For licensing terms and
- ** conditions see http://qt.digia.com/licensing. For further information
- ** use the contact form at http://qt.digia.com/contact-us.
+ ** a written agreement between you and The Qt Company. For licensing terms
+ ** and conditions see http://www.qt.io/terms-conditions. For further
+ ** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
- ** In addition, as a special exception, Digia gives you certain additional
- ** rights. These rights are described in the Digia Qt LGPL Exception
+ ** As a special exception, The Qt Company gives you certain additional
+ ** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldsharetargetimpl_p.h b/src/nfc/qnearfieldsharetargetimpl_p.h
index 5eddf0eb..74552a3e 100644
--- a/src/nfc/qnearfieldsharetargetimpl_p.h
+++ b/src/nfc/qnearfieldsharetargetimpl_p.h
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
- ** Contact: http://www.qt-project.org/legal
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Digia. For licensing terms and
- ** conditions see http://qt.digia.com/licensing. For further information
- ** use the contact form at http://qt.digia.com/contact-us.
+ ** a written agreement between you and The Qt Company. For licensing terms
+ ** and conditions see http://www.qt.io/terms-conditions. For further
+ ** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
- ** In addition, as a special exception, Digia gives you certain additional
- ** rights. These rights are described in the Digia Qt LGPL Exception
+ ** As a special exception, The Qt Company gives you certain additional
+ ** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldtagtype1.cpp b/src/nfc/qnearfieldtagtype1.cpp
index ce1af1c7..cbd1c1a6 100644
--- a/src/nfc/qnearfieldtagtype1.cpp
+++ b/src/nfc/qnearfieldtagtype1.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldtagtype1_p.h b/src/nfc/qnearfieldtagtype1_p.h
index 0825fc86..efc757a0 100644
--- a/src/nfc/qnearfieldtagtype1_p.h
+++ b/src/nfc/qnearfieldtagtype1_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldtagtype2.cpp b/src/nfc/qnearfieldtagtype2.cpp
index d323ace6..243d03e9 100644
--- a/src/nfc/qnearfieldtagtype2.cpp
+++ b/src/nfc/qnearfieldtagtype2.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldtagtype2_p.h b/src/nfc/qnearfieldtagtype2_p.h
index de02b75b..8ce5849c 100644
--- a/src/nfc/qnearfieldtagtype2_p.h
+++ b/src/nfc/qnearfieldtagtype2_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldtagtype3.cpp b/src/nfc/qnearfieldtagtype3.cpp
index df48823e..fa8fb21a 100644
--- a/src/nfc/qnearfieldtagtype3.cpp
+++ b/src/nfc/qnearfieldtagtype3.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldtagtype3_p.h b/src/nfc/qnearfieldtagtype3_p.h
index df2eb079..40d83db1 100644
--- a/src/nfc/qnearfieldtagtype3_p.h
+++ b/src/nfc/qnearfieldtagtype3_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldtagtype4.cpp b/src/nfc/qnearfieldtagtype4.cpp
index 2b111216..32c884bf 100644
--- a/src/nfc/qnearfieldtagtype4.cpp
+++ b/src/nfc/qnearfieldtagtype4.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldtagtype4_p.h b/src/nfc/qnearfieldtagtype4_p.h
index 22b79056..b0d7d8a5 100644
--- a/src/nfc/qnearfieldtagtype4_p.h
+++ b/src/nfc/qnearfieldtagtype4_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldtarget.cpp b/src/nfc/qnearfieldtarget.cpp
index 51818182..0d57e5f3 100644
--- a/src/nfc/qnearfieldtarget.cpp
+++ b/src/nfc/qnearfieldtarget.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -272,8 +272,9 @@ QNearFieldTarget::RequestId &QNearFieldTarget::RequestId::operator=(const Reques
QNearFieldTarget::QNearFieldTarget(QObject *parent)
: QObject(parent), d_ptr(new QNearFieldTargetPrivate)
{
- qRegisterMetaType<RequestId>("QNearFieldTarget::RequestId");
- qRegisterMetaType<Error>("QNearFieldTarget::Error");
+ qRegisterMetaType<QNearFieldTarget::RequestId>();
+ qRegisterMetaType<QNearFieldTarget::Error>();
+ qRegisterMetaType<QNdefMessage>();
}
/*!
diff --git a/src/nfc/qnearfieldtarget.h b/src/nfc/qnearfieldtarget.h
index f3c1292b..fef74946 100644
--- a/src/nfc/qnearfieldtarget.h
+++ b/src/nfc/qnearfieldtarget.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -63,7 +63,7 @@ public:
NfcTagType2,
NfcTagType3,
NfcTagType4,
- MifareTag,
+ MifareTag
};
enum AccessMethod {
diff --git a/src/nfc/qnearfieldtarget_emulator.cpp b/src/nfc/qnearfieldtarget_emulator.cpp
index ee0c6188..619028ef 100644
--- a/src/nfc/qnearfieldtarget_emulator.cpp
+++ b/src/nfc/qnearfieldtarget_emulator.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -187,7 +187,7 @@ bool TagType2::waitForRequestCompleted(const RequestId &id, int msecs)
TagActivator::TagActivator()
: timerId(-1)
{
- qRegisterMetaType<QNearFieldTarget::Error>("QNearFieldTarget::Error");
+ qRegisterMetaType<QNearFieldTarget::Error>();
}
TagActivator::~TagActivator()
diff --git a/src/nfc/qnearfieldtarget_emulator_p.h b/src/nfc/qnearfieldtarget_emulator_p.h
index aba30b60..075972fe 100644
--- a/src/nfc/qnearfieldtarget_emulator_p.h
+++ b/src/nfc/qnearfieldtarget_emulator_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldtarget_neard_p.h b/src/nfc/qnearfieldtarget_neard_p.h
new file mode 100644
index 00000000..ff7c3f1d
--- /dev/null
+++ b/src/nfc/qnearfieldtarget_neard_p.h
@@ -0,0 +1,404 @@
+/***************************************************************************
+**
+** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
+** Copyright (C) 2014 BasysKom GmbH.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QNEARFIELDTARGET_NEARD_P_H
+#define QNEARFIELDTARGET_NEARD_P_H
+
+#include <QDBusObjectPath>
+#include <QDBusVariant>
+
+#include <qnearfieldtarget.h>
+#include <qnearfieldtarget_p.h>
+#include <qndefrecord.h>
+#include <qndefmessage.h>
+
+#include "neard/neard_helper_p.h"
+#include "neard/dbusproperties_p.h"
+#include "neard/dbusobjectmanager_p.h"
+#include "neard/tag_p.h"
+
+#include <qndefnfctextrecord.h>
+#include <qndefnfcsmartposterrecord.h>
+#include <qndefnfcurirecord.h>
+
+QT_BEGIN_NAMESPACE
+
+Q_DECLARE_LOGGING_CATEGORY(QT_NFC_NEARD)
+
+template <typename T>
+class NearFieldTarget : public T
+{
+public:
+
+ NearFieldTarget(QObject *parent, QDBusObjectPath interfacePath)
+ : T(parent),
+ m_tagPath(interfacePath),
+ m_readRequested(false)
+ {
+ m_readErrorTimer.setSingleShot(true);
+ m_recordPathsCollectedTimer.setSingleShot(true);
+ m_delayedWriteTimer.setSingleShot(true);
+
+ qCDebug(QT_NFC_NEARD) << "tag found at path" << interfacePath.path();
+ m_dbusProperties = new OrgFreedesktopDBusPropertiesInterface(QStringLiteral("org.neard"),
+ interfacePath.path(),
+ QDBusConnection::systemBus(),
+ this);
+ if (!m_dbusProperties->isValid()) {
+ qCWarning(QT_NFC_NEARD) << "Could not connect to dbus property interface at path" << interfacePath.path();
+ return;
+ }
+
+ QDBusPendingReply<QVariantMap> reply = m_dbusProperties->GetAll(QStringLiteral("org.neard.Tag"));
+ reply.waitForFinished();
+ if (reply.isError()) {
+ qCWarning(QT_NFC_NEARD) << "Could not get properties of org.neard.Tag dbus interface";
+ return;
+ }
+
+ const QString &type = reply.value().value(QStringLiteral("Type")).toString();
+ m_type = QNearFieldTarget::ProprietaryTag;
+
+ if (type == QStringLiteral("Type 1"))
+ m_type = QNearFieldTarget::NfcTagType1;
+ else if (type == QStringLiteral("Type 2"))
+ m_type = QNearFieldTarget::NfcTagType2;
+ else if (type == QStringLiteral("Type 3"))
+ m_type = QNearFieldTarget::NfcTagType3;
+ else if (type == QStringLiteral("Type 4"))
+ m_type = QNearFieldTarget::NfcTagType4;
+
+ qCDebug(QT_NFC_NEARD) << "tag type" << type;
+
+ QObject::connect(&m_recordPathsCollectedTimer, &QTimer::timeout,
+ this, &NearFieldTarget::createNdefMessage);
+ QObject::connect(&m_readErrorTimer, &QTimer::timeout,
+ this, &NearFieldTarget::handleReadError);
+ QObject::connect(&m_delayedWriteTimer, &QTimer::timeout,
+ this, &NearFieldTarget::handleWriteRequest);
+ QObject::connect(NeardHelper::instance(), &NeardHelper::recordFound,
+ this, &NearFieldTarget::handleRecordFound);
+ }
+
+ ~NearFieldTarget()
+ {
+ }
+
+ bool isValid()
+ {
+ return m_dbusProperties->isValid() && NeardHelper::instance()->dbusObjectManager()->isValid();
+ }
+
+ QByteArray uid() const
+ {
+ return QByteArray(); // TODO figure out a workaround because neard does not offer
+ // this property
+ }
+
+ QNearFieldTarget::Type type() const
+ {
+ return m_type;
+ }
+
+ QNearFieldTarget::AccessMethods accessMethods() const
+ {
+ return QNearFieldTarget::NdefAccess;
+ }
+
+ bool hasNdefMessage()
+ {
+ return !m_recordPaths.isEmpty();
+ }
+
+ QNearFieldTarget::RequestId readNdefMessages()
+ {
+ if (isValid()) {
+ // if the user calls readNdefMessages before the previous request has been completed
+ // return the current request id.
+ if (m_currentReadRequestId.isValid())
+ return m_currentReadRequestId;
+
+ QNearFieldTarget::RequestId requestId = QNearFieldTarget::RequestId(new QNearFieldTarget::RequestIdPrivate());
+ // save the id so it can be passed along with requestCompleted
+ m_currentReadRequestId = requestId;
+ // since the triggering of interfaceAdded will ultimately lead to createNdefMessage being called
+ // we need to make sure that ndefMessagesRead will only be triggered when readNdefMessages has
+ // been called before. In case readNdefMessages is called again after that we can directly call
+ // call createNdefMessage.
+ m_readRequested = true;
+ if (hasNdefMessage())
+ createNdefMessage();
+ else
+ m_readErrorTimer.start(1000);
+
+ return requestId;
+ } else {
+ return QNearFieldTarget::RequestId();
+ }
+ }
+
+ QNearFieldTarget::RequestId sendCommand(const QByteArray &command)
+ {
+ Q_UNUSED(command);
+ return QNearFieldTarget::RequestId();
+ }
+
+ QNearFieldTarget::RequestId sendCommands(const QList<QByteArray> &commands)
+ {
+ Q_UNUSED(commands);
+ return QNearFieldTarget::RequestId();
+ }
+
+ QNearFieldTarget::RequestId writeNdefMessages(const QList<QNdefMessage> &messages)
+ {
+ // disabling write due to neard crash (see QTBUG-43802)
+ qWarning("QNearFieldTarget::WriteNdefMessages() disabled. See QTBUG-43802\n");
+ return QNearFieldTarget::RequestId();
+
+
+ // return old request id when previous write request hasn't completed
+ if (m_currentWriteRequestId.isValid())
+ return m_currentReadRequestId;
+
+ qCDebug(QT_NFC_NEARD) << "writing messages";
+ if (messages.isEmpty() || messages.first().isEmpty()) {
+ qCWarning(QT_NFC_NEARD) << "No record specified";
+ return QNearFieldTarget::RequestId();
+ }
+ if (messages.count() > 1 || messages.first().count() > 1) {
+ // neard only supports one ndef record per tag
+ qCWarning(QT_NFC_NEARD) << "Writing of only one NDEF record and message is supported";
+ return QNearFieldTarget::RequestId();
+ }
+ QNdefRecord record = messages.first().first();
+
+ if (record.typeNameFormat() == QNdefRecord::NfcRtd) {
+ m_currentWriteRequestData.clear();
+ if (record.isRecordType<QNdefNfcUriRecord>()) {
+ m_currentWriteRequestData.insert(QStringLiteral("Type"), QStringLiteral("URI"));
+ QNdefNfcUriRecord uriRecord = static_cast<QNdefNfcUriRecord>(record);
+ m_currentWriteRequestData.insert(QStringLiteral("URI"), uriRecord.uri().toString());
+ } else if (record.isRecordType<QNdefNfcSmartPosterRecord>()) {
+ m_currentWriteRequestData.insert(QStringLiteral("Type"), QStringLiteral("SmartPoster"));
+ QNdefNfcSmartPosterRecord spRecord = static_cast<QNdefNfcSmartPosterRecord>(record);
+ m_currentWriteRequestData.insert(QStringLiteral("URI"), spRecord.uri().toString());
+ // Currently neard only supports the uri property for writing
+ } else if (record.isRecordType<QNdefNfcTextRecord>()) {
+ m_currentWriteRequestData.insert(QStringLiteral("Type"), QStringLiteral("Text"));
+ QNdefNfcTextRecord textRecord = static_cast<QNdefNfcTextRecord>(record);
+ m_currentWriteRequestData.insert(QStringLiteral("Representation"), textRecord.text());
+ m_currentWriteRequestData.insert(QStringLiteral("Encoding"),
+ textRecord.encoding() == QNdefNfcTextRecord::Utf8 ?
+ QStringLiteral("UTF-8") : QStringLiteral("UTF-16") );
+ m_currentWriteRequestData.insert(QStringLiteral("Language"), textRecord.locale());
+ } else {
+ qCWarning(QT_NFC_NEARD) << "Record type not supported for writing";
+ return QNearFieldTarget::RequestId();
+ }
+
+ m_currentWriteRequestId = QNearFieldTarget::RequestId(new QNearFieldTarget::RequestIdPrivate());
+ // trigger delayed write
+ m_delayedWriteTimer.start(100);
+
+ return m_currentWriteRequestId;
+ }
+
+ return QNearFieldTarget::RequestId();
+ }
+
+private:
+ QNdefRecord readRecord(const QDBusObjectPath &path)
+ {
+ qCDebug(QT_NFC_NEARD) << "reading record for path" << path.path();
+ OrgFreedesktopDBusPropertiesInterface recordInterface(QStringLiteral("org.neard"),
+ path.path(),
+ QDBusConnection::systemBus());
+ if (!recordInterface.isValid())
+ return QNdefRecord();
+
+ QDBusPendingReply<QVariantMap> reply = recordInterface.GetAll(QStringLiteral("org.neard.Record"));
+ reply.waitForFinished();
+ if (reply.isError())
+ return QNdefRecord();
+
+ const QString &value = reply.value().value(QStringLiteral("Representation")).toString();
+ const QString &locale = reply.value().value(QStringLiteral("Language")).toString();
+ const QString &encoding = reply.value().value(QStringLiteral("Encoding")).toString();
+ const QString &uri = reply.value().value(QStringLiteral("URI")).toString();
+
+// const QString &mime = reply.value().value(QStringLiteral("MIME")).toString();
+// const QString &arr = reply.value().value(QStringLiteral("ARR")).toString();
+
+ const QString type = reply.value().value(QStringLiteral("Type")).toString();
+ if (type == QStringLiteral("Text")) {
+ QNdefNfcTextRecord textRecord;
+ textRecord.setText(value);
+ textRecord.setLocale(locale);
+ textRecord.setEncoding((encoding == QStringLiteral("UTF-8")) ? QNdefNfcTextRecord::Utf8
+ : QNdefNfcTextRecord::Utf16);
+ return textRecord;
+ } else if (type == QStringLiteral("SmartPoster")) {
+ QNdefNfcSmartPosterRecord spRecord;
+ if (!value.isEmpty()) {
+ spRecord.addTitle(value, locale, (encoding == QStringLiteral("UTF-8"))
+ ? QNdefNfcTextRecord::Utf8
+ : QNdefNfcTextRecord::Utf16);
+ }
+
+ if (!uri.isEmpty())
+ spRecord.setUri(QUrl(uri));
+
+ const QString &action = reply.value().value(QStringLiteral("Action")).toString();
+ if (!action.isEmpty()) {
+ if (action == QStringLiteral("Do"))
+ spRecord.setAction(QNdefNfcSmartPosterRecord::DoAction);
+ else if (action == QStringLiteral("Save"))
+ spRecord.setAction(QNdefNfcSmartPosterRecord::SaveAction);
+ else if (action == QStringLiteral("Edit"))
+ spRecord.setAction(QNdefNfcSmartPosterRecord::EditAction);
+ }
+
+ if (reply.value().contains(QStringLiteral("Size"))) {
+ uint size = reply.value().value(QStringLiteral("Size")).toUInt();
+ spRecord.setSize(size);
+ }
+
+ const QString &mimeType = reply.value().value(QStringLiteral("MIMEType")).toString();
+ if (!mimeType.isEmpty()) {
+ spRecord.setTypeInfo(mimeType.toUtf8());
+ }
+
+
+ return spRecord;
+ } else if (type == QStringLiteral("URI")) {
+ QNdefNfcUriRecord uriRecord;
+ uriRecord.setUri(QUrl(uri));
+ return uriRecord;
+ } else if (type == QStringLiteral("MIME")) {
+
+ } else if (type == QStringLiteral("AAR")) {
+
+ }
+
+ return QNdefRecord();
+ }
+
+ void handleRecordFound(const QDBusObjectPath &path)
+ {
+ m_recordPaths.append(path);
+ // FIXME: this timer only exists because neard doesn't currently supply enough
+ // information to let us know when all record interfaces have been added or
+ // how many records are actually contained on a tag. We assume that when no
+ // signal has been received for 100ms all record interfaces have been added.
+ m_recordPathsCollectedTimer.start(100);
+ // as soon as record paths have been added we can handle errors without the timer.
+ m_readErrorTimer.stop();
+ }
+
+ void createNdefMessage()
+ {
+ if (m_readRequested) {
+ qCDebug(QT_NFC_NEARD) << "creating Ndef message, reading" << m_recordPaths.length() << "record paths";
+ QNdefMessage newNdefMessage;
+ foreach (const QDBusObjectPath &recordPath, m_recordPaths)
+ newNdefMessage.append(readRecord(recordPath));
+
+ if (!newNdefMessage.isEmpty()) {
+ QMetaObject::invokeMethod(this, "ndefMessageRead", Qt::QueuedConnection,
+ Q_ARG(const QNdefMessage, newNdefMessage));
+ // the request id in requestCompleted has to match the one created in readNdefMessages
+ QMetaObject::invokeMethod(this, "requestCompleted", Qt::QueuedConnection,
+ Q_ARG(const QNearFieldTarget::RequestId, m_currentReadRequestId));
+ } else {
+ QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
+ Q_ARG(const QNearFieldTarget::Error, QNearFieldTarget::UnknownError),
+ Q_ARG(const QNearFieldTarget::RequestId, m_currentReadRequestId));
+ }
+
+ m_readRequested = false;
+ // invalidate the current request id
+ m_currentReadRequestId = QNearFieldTarget::RequestId(0);
+ }
+ }
+
+ void handleReadError()
+ {
+ emit QNearFieldTarget::error(QNearFieldTarget::UnknownError, m_currentReadRequestId);
+ m_currentReadRequestId = QNearFieldTarget::RequestId(0);
+ }
+
+ void handleWriteRequest()
+ {
+ OrgNeardTagInterface tagInterface(QStringLiteral("org.neard"),
+ m_tagPath.path(),
+ QDBusConnection::systemBus());
+ if (!tagInterface.isValid()) {
+ qCWarning(QT_NFC_NEARD) << "tag interface invalid";
+ } else {
+ QDBusPendingReply<> reply;
+ reply = tagInterface.Write(m_currentWriteRequestData);
+ reply.waitForFinished();
+ if (reply.isError()) {
+ qCWarning(QT_NFC_NEARD) << "Error writing to NFC tag" << reply.error();
+ QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
+ Q_ARG(const QNearFieldTarget::Error, QNearFieldTarget::UnknownError),
+ Q_ARG(const QNearFieldTarget::RequestId, m_currentWriteRequestId));
+ }
+
+ QMetaObject::invokeMethod(this, "ndefMessagesWritten", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(this, "requestCompleted", Qt::QueuedConnection,
+ Q_ARG(const QNearFieldTarget::RequestId, m_currentWriteRequestId));
+ }
+
+ // invalidate current write request
+ m_currentWriteRequestId = QNearFieldTarget::RequestId(0);
+ }
+
+protected:
+ QDBusObjectPath m_tagPath;
+ OrgFreedesktopDBusPropertiesInterface *m_dbusProperties;
+ QList<QDBusObjectPath> m_recordPaths;
+ QTimer m_recordPathsCollectedTimer;
+ QTimer m_readErrorTimer;
+ QTimer m_delayedWriteTimer;
+ QNearFieldTarget::Type m_type;
+ bool m_readRequested;
+ QNearFieldTarget::RequestId m_currentReadRequestId;
+ QNearFieldTarget::RequestId m_currentWriteRequestId;
+ QVariantMap m_currentWriteRequestData;
+};
+
+QT_END_NAMESPACE
+
+#endif // QNEARFIELDTARGET_NEARD_P_H
diff --git a/src/nfc/qnearfieldtarget_p.h b/src/nfc/qnearfieldtarget_p.h
index 48b4a943..021f6fe8 100644
--- a/src/nfc/qnearfieldtarget_p.h
+++ b/src/nfc/qnearfieldtarget_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnearfieldtarget_qnx_p.h b/src/nfc/qnearfieldtarget_qnx_p.h
index 239153be..eb785d81 100644
--- a/src/nfc/qnearfieldtarget_qnx_p.h
+++ b/src/nfc/qnearfieldtarget_qnx_p.h
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2012 Research In Motion
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnfc.cpp b/src/nfc/qnfc.cpp
new file mode 100644
index 00000000..4862461c
--- /dev/null
+++ b/src/nfc/qnfc.cpp
@@ -0,0 +1,41 @@
+/***************************************************************************
+**
+** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QLoggingCategory>
+#include <QtNfc/qnfcglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+Q_LOGGING_CATEGORY(QT_NFC_NEARD, "qt.nfc.neard")
+
+QT_END_NAMESPACE
diff --git a/src/nfc/qnfcglobal.h b/src/nfc/qnfcglobal.h
index 4b975c36..26916a94 100644
--- a/src/nfc/qnfcglobal.h
+++ b/src/nfc/qnfcglobal.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnx/qnxnfceventfilter.cpp b/src/nfc/qnx/qnxnfceventfilter.cpp
index 25af8f64..f3d3749a 100644
--- a/src/nfc/qnx/qnxnfceventfilter.cpp
+++ b/src/nfc/qnx/qnxnfceventfilter.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2012 Research In Motion
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnx/qnxnfceventfilter_p.h b/src/nfc/qnx/qnxnfceventfilter_p.h
index 4349ea71..c8a7a9ea 100644
--- a/src/nfc/qnx/qnxnfceventfilter_p.h
+++ b/src/nfc/qnx/qnxnfceventfilter_p.h
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2012 Research In Motion
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnx/qnxnfcmanager.cpp b/src/nfc/qnx/qnxnfcmanager.cpp
index de0d65dd..3db11158 100644
--- a/src/nfc/qnx/qnxnfcmanager.cpp
+++ b/src/nfc/qnx/qnxnfcmanager.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2012 Research In Motion
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnx/qnxnfcmanager_p.h b/src/nfc/qnx/qnxnfcmanager_p.h
index 4253ba1a..17425198 100644
--- a/src/nfc/qnx/qnxnfcmanager_p.h
+++ b/src/nfc/qnx/qnxnfcmanager_p.h
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2012 Research In Motion
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnx/qnxnfcsharemanager_p.cpp b/src/nfc/qnx/qnxnfcsharemanager_p.cpp
index 9ceed65e..ea6aeb13 100644
--- a/src/nfc/qnx/qnxnfcsharemanager_p.cpp
+++ b/src/nfc/qnx/qnxnfcsharemanager_p.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
- ** Contact: http://www.qt-project.org/legal
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Digia. For licensing terms and
- ** conditions see http://qt.digia.com/licensing. For further information
- ** use the contact form at http://qt.digia.com/contact-us.
+ ** a written agreement between you and The Qt Company. For licensing terms
+ ** and conditions see http://www.qt.io/terms-conditions. For further
+ ** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
- ** In addition, as a special exception, Digia gives you certain additional
- ** rights. These rights are described in the Digia Qt LGPL Exception
+ ** As a special exception, The Qt Company gives you certain additional
+ ** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qnx/qnxnfcsharemanager_p.h b/src/nfc/qnx/qnxnfcsharemanager_p.h
index 7b70eca6..d6774c41 100644
--- a/src/nfc/qnx/qnxnfcsharemanager_p.h
+++ b/src/nfc/qnx/qnxnfcsharemanager_p.h
@@ -1,7 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
- ** Contact: http://www.qt-project.org/legal
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and Digia. For licensing terms and
- ** conditions see http://qt.digia.com/licensing. For further information
- ** use the contact form at http://qt.digia.com/contact-us.
+ ** a written agreement between you and The Qt Company. For licensing terms
+ ** and conditions see http://www.qt.io/terms-conditions. For further
+ ** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
- ** In addition, as a special exception, Digia gives you certain additional
- ** rights. These rights are described in the Digia Qt LGPL Exception
+ ** As a special exception, The Qt Company gives you certain additional
+ ** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qqmlndefrecord.cpp b/src/nfc/qqmlndefrecord.cpp
index 2db40a4f..280d03a2 100644
--- a/src/nfc/qqmlndefrecord.cpp
+++ b/src/nfc/qqmlndefrecord.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qqmlndefrecord.h b/src/nfc/qqmlndefrecord.h
index 7c282e77..71cd5513 100644
--- a/src/nfc/qqmlndefrecord.h
+++ b/src/nfc/qqmlndefrecord.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qtlv.cpp b/src/nfc/qtlv.cpp
index 14624e5b..b935e4fe 100644
--- a/src/nfc/qtlv.cpp
+++ b/src/nfc/qtlv.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/qtlv_p.h b/src/nfc/qtlv_p.h
index 082c4e77..14a6dd03 100644
--- a/src/nfc/qtlv_p.h
+++ b/src/nfc/qtlv_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/targetemulator.cpp b/src/nfc/targetemulator.cpp
index 61370bf1..1fb72b4b 100644
--- a/src/nfc/targetemulator.cpp
+++ b/src/nfc/targetemulator.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/nfc/targetemulator_p.h b/src/nfc/targetemulator_p.h
index cfeb5413..30ec37ae 100644
--- a/src/nfc/targetemulator_p.h
+++ b/src/nfc/targetemulator_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/tools/sdpscanner/main.cpp b/src/tools/sdpscanner/main.cpp
index cb1bdd15..1efb6de2 100644
--- a/src/tools/sdpscanner/main.cpp
+++ b/src/tools/sdpscanner/main.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/tests/auto/qbluetoothaddress/tst_qbluetoothaddress.cpp b/tests/auto/qbluetoothaddress/tst_qbluetoothaddress.cpp
index 171726b8..c153f7d4 100644
--- a/tests/auto/qbluetoothaddress/tst_qbluetoothaddress.cpp
+++ b/tests/auto/qbluetoothaddress/tst_qbluetoothaddress.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/tests/auto/qbluetoothdevicediscoveryagent/qbluetoothdevicediscoveryagent.pro b/tests/auto/qbluetoothdevicediscoveryagent/qbluetoothdevicediscoveryagent.pro
index 6a426208..dc0851ad 100644
--- a/tests/auto/qbluetoothdevicediscoveryagent/qbluetoothdevicediscoveryagent.pro
+++ b/tests/auto/qbluetoothdevicediscoveryagent/qbluetoothdevicediscoveryagent.pro
@@ -3,5 +3,5 @@ TARGET=tst_qbluetoothdevicediscoveryagent
CONFIG += testcase
QT = core concurrent bluetooth testlib
-
+osx:QT += widgets
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp b/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp
index ca22c8ea..f4ddd8aa 100644
--- a/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp
+++ b/tests/auto/qbluetoothdevicediscoveryagent/tst_qbluetoothdevicediscoveryagent.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -36,6 +36,7 @@
#include <QDebug>
#include <QVariant>
#include <QList>
+#include <QLoggingCategory>
#include <qbluetoothaddress.h>
#include <qbluetoothdevicediscoveryagent.h>
@@ -43,8 +44,8 @@
QT_USE_NAMESPACE
-Q_DECLARE_METATYPE(QBluetoothDeviceInfo)
Q_DECLARE_METATYPE(QBluetoothDeviceDiscoveryAgent::InquiryType)
+Q_DECLARE_METATYPE(QBluetoothDeviceDiscoveryAgent::Error)
/*
* Some parts of this test require a remote and discoverable Bluetooth
@@ -90,7 +91,8 @@ private:
tst_QBluetoothDeviceDiscoveryAgent::tst_QBluetoothDeviceDiscoveryAgent()
{
- qRegisterMetaType<QBluetoothDeviceDiscoveryAgent::Error>("QBluetoothDeviceDiscoveryAgent::Error");
+ QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
+ qRegisterMetaType<QBluetoothDeviceDiscoveryAgent::Error>();
}
tst_QBluetoothDeviceDiscoveryAgent::~tst_QBluetoothDeviceDiscoveryAgent()
@@ -99,8 +101,8 @@ tst_QBluetoothDeviceDiscoveryAgent::~tst_QBluetoothDeviceDiscoveryAgent()
void tst_QBluetoothDeviceDiscoveryAgent::initTestCase()
{
- qRegisterMetaType<QBluetoothDeviceInfo>("QBluetoothDeviceInfo");
- qRegisterMetaType<QBluetoothDeviceDiscoveryAgent::InquiryType>("QBluetoothDeviceDiscoveryAgent::InquiryType");
+ qRegisterMetaType<QBluetoothDeviceInfo>();
+ qRegisterMetaType<QBluetoothDeviceDiscoveryAgent::InquiryType>();
noOfLocalDevices = QBluetoothLocalDevice::allDevices().count();
if (!noOfLocalDevices)
@@ -314,7 +316,10 @@ void tst_QBluetoothDeviceDiscoveryAgent::tst_startStopDeviceDiscoveries()
QVERIFY(errorSpy.isEmpty());
// should only have 1 cancel
QVERIFY(finishedSpy.count() == 1);
- QVERIFY(cancelSpy.isEmpty());
+
+ // On OS X, stop is synchronous (signal will be emitted immediately).
+ if (!immediateSignal)
+ QVERIFY(cancelSpy.isEmpty());
}
void tst_QBluetoothDeviceDiscoveryAgent::finished()
@@ -422,7 +427,13 @@ void tst_QBluetoothDeviceDiscoveryAgent::tst_deviceDiscovery()
}
}
}
- //For multiple Bluetooth adapter do the check only for GeneralUnlimitedInquiry
+#ifdef Q_OS_IOS
+ //On iOS, we do not have access to the local device/adapter, numberOfAdapters is 0,
+ //so we skip this test at all.
+ QSKIP("iOS: no local Bluetooth device available. Skipping remaining part of test.");
+#endif
+
+ //For multiple Bluetooth adapter do the check only for GeneralUnlimitedInquiry.
if (!(inquiryType == QBluetoothDeviceDiscoveryAgent::LimitedInquiry))
QVERIFY((numberOfAdapters-1) == counter);
}
diff --git a/tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp b/tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp
index 74a27591..faa0ed39 100644
--- a/tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp
+++ b/tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -33,6 +33,7 @@
#include <QtTest/QtTest>
+#include <QScopedPointer>
#include <QDebug>
#include <qbluetoothaddress.h>
@@ -78,8 +79,8 @@ tst_QBluetoothDeviceInfo::~tst_QBluetoothDeviceInfo()
void tst_QBluetoothDeviceInfo::initTestCase()
{
- qRegisterMetaType<QBluetoothDeviceInfo::ServiceClasses>("QBluetoothDeviceInfo::ServiceClasses");
- qRegisterMetaType<QBluetoothDeviceInfo::MajorDeviceClass>("QBluetoothDeviceInfo::MajorDeviceClass");
+ qRegisterMetaType<QBluetoothDeviceInfo::ServiceClasses>();
+ qRegisterMetaType<QBluetoothDeviceInfo::MajorDeviceClass>();
// start Bluetooth if not started
QBluetoothLocalDevice *device = new QBluetoothLocalDevice();
device->powerOn();
@@ -95,6 +96,10 @@ void tst_QBluetoothDeviceInfo::tst_construction_data()
QTest::addColumn<QBluetoothDeviceInfo::MajorDeviceClass>("majorDeviceClass");
QTest::addColumn<quint8>("minorDeviceClass");
QTest::addColumn<QBluetoothDeviceInfo::CoreConfiguration>("coreConfiguration");
+ // On OS X and iOS there are no real addresses
+ // with Core Bluetooth, only 'uuids' (128-bit) generated by Apple instead.
+ QTest::addColumn<QBluetoothUuid>("deviceUuid");
+ const QBluetoothUuid leDeviceUuid(QString("6C903349-31E2-40EF-826B-1E62C0D884E2"));
// bits 12-8 Major
// bits 7-2 Minor
@@ -105,143 +110,167 @@ void tst_QBluetoothDeviceInfo::tst_construction_data()
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::MiscellaneousDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous)
- << QBluetoothDeviceInfo::BaseRateCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000100 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000100)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ComputerDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedComputer)
- << QBluetoothDeviceInfo::BaseRateCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000104 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000104)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ComputerDevice
<< quint8(QBluetoothDeviceInfo::DesktopComputer)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000118 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000118)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ComputerDevice
<< quint8(QBluetoothDeviceInfo::WearableComputer)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000200 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x000200)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::PhoneDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedPhone)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000204 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000204)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::PhoneDevice
<< quint8(QBluetoothDeviceInfo::CellularPhone)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000214 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device" << quint32(0x000214)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::PhoneDevice
<< quint8(QBluetoothDeviceInfo::CommonIsdnAccessPhone)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000300 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000300)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::LANAccessDevice
<< quint8(QBluetoothDeviceInfo::NetworkFullService)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000320 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000320)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::LANAccessDevice
<< quint8(QBluetoothDeviceInfo::NetworkLoadFactorOne)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x0003E0 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x0003E0)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::LANAccessDevice
<< quint8(QBluetoothDeviceInfo::NetworkNoService)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000400 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000400)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::AudioVideoDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedAudioVideoDevice)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000448 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000448)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::AudioVideoDevice
<< quint8(QBluetoothDeviceInfo::GamingDevice)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000500 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000500)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::PeripheralDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedPeripheral)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x0005D8 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x0005D8)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::PeripheralDevice
<< quint8(QBluetoothDeviceInfo::KeyboardWithPointingDevicePeripheral | QBluetoothDeviceInfo::CardReaderPeripheral)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000600 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000600)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ImagingDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedImagingDevice)
- << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000680 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000680)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ImagingDevice
<< quint8(QBluetoothDeviceInfo::ImagePrinter)
- << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000700 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000700)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::WearableDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedWearableDevice)
- << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000714 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000714)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::WearableDevice
<< quint8(QBluetoothDeviceInfo::WearableGlasses)
- << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000800 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000800)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ToyDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedToy)
- << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x000814 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x000814)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::ToyDevice
<< quint8(QBluetoothDeviceInfo::ToyGame)
- << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x001f00 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x001f00)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::NoService)
<< QBluetoothDeviceInfo::UncategorizedDevice
<< quint8(0)
- << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x002000 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x002000)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::PositioningService)
<< QBluetoothDeviceInfo::MiscellaneousDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous)
- << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0x100000 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0x100000)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::InformationService)
<< QBluetoothDeviceInfo::MiscellaneousDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous)
- << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration
+ << leDeviceUuid;
QTest::newRow("0xFFE000 COD") << QBluetoothAddress("000000000000") << "My Bluetooth Device"
<< quint32(0xFFE000)
<< QBluetoothDeviceInfo::ServiceClasses(QBluetoothDeviceInfo::AllServices)
<< QBluetoothDeviceInfo::MiscellaneousDevice
<< quint8(QBluetoothDeviceInfo::UncategorizedMiscellaneous)
- << QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
+ << QBluetoothDeviceInfo::LowEnergyCoreConfiguration
+ << leDeviceUuid;
}
void tst_QBluetoothDeviceInfo::tst_construction()
@@ -262,9 +291,9 @@ void tst_QBluetoothDeviceInfo::tst_construction()
QFETCH(QBluetoothDeviceInfo::MajorDeviceClass, majorDeviceClass);
QFETCH(quint8, minorDeviceClass);
QFETCH(QBluetoothDeviceInfo::CoreConfiguration, coreConfiguration);
+ QFETCH(QBluetoothUuid, deviceUuid);
QBluetoothDeviceInfo deviceInfo(address, name, classOfDevice);
-
QVERIFY(deviceInfo.isValid());
QCOMPARE(deviceInfo.address(), address);
@@ -277,6 +306,9 @@ void tst_QBluetoothDeviceInfo::tst_construction()
deviceInfo.setCoreConfigurations(coreConfiguration);
QCOMPARE(deviceInfo.coreConfigurations(), coreConfiguration);
+ deviceInfo.setDeviceUuid(deviceUuid);
+ QCOMPARE(deviceInfo.deviceUuid(), deviceUuid);
+
QBluetoothDeviceInfo copyInfo(deviceInfo);
QVERIFY(copyInfo.isValid());
@@ -286,6 +318,40 @@ void tst_QBluetoothDeviceInfo::tst_construction()
QCOMPARE(copyInfo.majorDeviceClass(), majorDeviceClass);
QCOMPARE(copyInfo.minorDeviceClass(), minorDeviceClass);
QCOMPARE(copyInfo.coreConfigurations(), coreConfiguration);
+ QCOMPARE(copyInfo.deviceUuid(), deviceUuid);
+ }
+
+ {
+ // Test construction from the device unique UUID, without an address.
+ QFETCH(QString, name);
+ QFETCH(quint32, classOfDevice);
+ QFETCH(QBluetoothDeviceInfo::ServiceClasses, serviceClasses);
+ QFETCH(QBluetoothDeviceInfo::MajorDeviceClass, majorDeviceClass);
+ QFETCH(quint8, minorDeviceClass);
+ QFETCH(QBluetoothDeviceInfo::CoreConfiguration, coreConfiguration);
+ QFETCH(QBluetoothUuid, deviceUuid);
+
+ QBluetoothDeviceInfo deviceInfo(deviceUuid, name, classOfDevice);
+ QVERIFY(deviceInfo.isValid());
+
+ QCOMPARE(deviceInfo.name(), name);
+ QCOMPARE(deviceInfo.serviceClasses(), serviceClasses);
+ QCOMPARE(deviceInfo.majorDeviceClass(), majorDeviceClass);
+ QCOMPARE(deviceInfo.minorDeviceClass(), minorDeviceClass);
+ QCOMPARE(deviceInfo.coreConfigurations(), QBluetoothDeviceInfo::UnknownCoreConfiguration);
+
+ deviceInfo.setCoreConfigurations(coreConfiguration);
+ QCOMPARE(deviceInfo.coreConfigurations(), coreConfiguration);
+
+ QBluetoothDeviceInfo copyInfo(deviceInfo);
+ QVERIFY(copyInfo.isValid());
+
+ QCOMPARE(copyInfo.name(), name);
+ QCOMPARE(copyInfo.serviceClasses(), serviceClasses);
+ QCOMPARE(copyInfo.majorDeviceClass(), majorDeviceClass);
+ QCOMPARE(copyInfo.minorDeviceClass(), minorDeviceClass);
+ QCOMPARE(copyInfo.coreConfigurations(), coreConfiguration);
+ QCOMPARE(copyInfo.deviceUuid(), deviceUuid);
}
}
@@ -303,8 +369,11 @@ void tst_QBluetoothDeviceInfo::tst_assignment()
QFETCH(QBluetoothDeviceInfo::MajorDeviceClass, majorDeviceClass);
QFETCH(quint8, minorDeviceClass);
QFETCH(QBluetoothDeviceInfo::CoreConfiguration, coreConfiguration);
+ QFETCH(QBluetoothUuid, deviceUuid);
QBluetoothDeviceInfo deviceInfo(address, name, classOfDevice);
+
+ deviceInfo.setDeviceUuid(deviceUuid);
deviceInfo.setCoreConfigurations(coreConfiguration);
QVERIFY(deviceInfo.isValid());
@@ -320,6 +389,7 @@ void tst_QBluetoothDeviceInfo::tst_assignment()
QCOMPARE(copyInfo.majorDeviceClass(), majorDeviceClass);
QCOMPARE(copyInfo.minorDeviceClass(), minorDeviceClass);
QCOMPARE(copyInfo.coreConfigurations(), coreConfiguration);
+ QCOMPARE(copyInfo.deviceUuid(), deviceUuid);
}
{
@@ -337,6 +407,7 @@ void tst_QBluetoothDeviceInfo::tst_assignment()
QCOMPARE(copyInfo.majorDeviceClass(), majorDeviceClass);
QCOMPARE(copyInfo.minorDeviceClass(), minorDeviceClass);
QCOMPARE(copyInfo.coreConfigurations(), coreConfiguration);
+ QCOMPARE(copyInfo.deviceUuid(), deviceUuid);
}
{
@@ -364,6 +435,8 @@ void tst_QBluetoothDeviceInfo::tst_assignment()
QCOMPARE(copyInfo2.minorDeviceClass(), minorDeviceClass);
QCOMPARE(copyInfo1.coreConfigurations(), coreConfiguration);
QCOMPARE(copyInfo2.coreConfigurations(), coreConfiguration);
+ QCOMPARE(copyInfo1.deviceUuid(), deviceUuid);
+ QCOMPARE(copyInfo2.deviceUuid(), deviceUuid);
}
{
diff --git a/tests/auto/qbluetoothhostinfo/tst_qbluetoothhostinfo.cpp b/tests/auto/qbluetoothhostinfo/tst_qbluetoothhostinfo.cpp
index fea6bad3..6b86ee10 100644
--- a/tests/auto/qbluetoothhostinfo/tst_qbluetoothhostinfo.cpp
+++ b/tests/auto/qbluetoothhostinfo/tst_qbluetoothhostinfo.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/tests/auto/qbluetoothlocaldevice/qbluetoothlocaldevice.pro b/tests/auto/qbluetoothlocaldevice/qbluetoothlocaldevice.pro
index 8f31fc14..a95f9a63 100644
--- a/tests/auto/qbluetoothlocaldevice/qbluetoothlocaldevice.pro
+++ b/tests/auto/qbluetoothlocaldevice/qbluetoothlocaldevice.pro
@@ -3,5 +3,5 @@ TARGET=tst_qbluetoothlocaldevice
CONFIG += testcase
QT = core concurrent bluetooth testlib
-
+osx:QT += widgets
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp b/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp
index 30e009dd..c3456524 100644
--- a/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp
+++ b/tests/auto/qbluetoothlocaldevice/tst_qbluetoothlocaldevice.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -111,6 +111,10 @@ void tst_QBluetoothLocalDevice::initTestCase()
void tst_QBluetoothLocalDevice::tst_powerOn()
{
+#ifdef Q_OS_OSX
+ QSKIP("Not possible on OS X");
+#endif
+
QBluetoothLocalDevice localDevice;
QSignalSpy hostModeSpy(&localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)));
@@ -132,6 +136,10 @@ void tst_QBluetoothLocalDevice::tst_powerOn()
void tst_QBluetoothLocalDevice::tst_powerOff()
{
+#ifdef Q_OS_OSX
+ QSKIP("Not possible on OS X");
+#endif
+
if (!QBluetoothLocalDevice::allDevices().count())
QSKIP("Skipping test due to missing Bluetooth device");
@@ -176,6 +184,10 @@ void tst_QBluetoothLocalDevice::tst_hostModes_data()
void tst_QBluetoothLocalDevice::tst_hostModes()
{
+#ifdef Q_OS_OSX
+ QSKIP("Not possible on OS X");
+#endif
+
QFETCH(QBluetoothLocalDevice::HostMode, hostModeExpected);
QFETCH(bool, expectSignal);
@@ -229,6 +241,14 @@ void tst_QBluetoothLocalDevice::tst_name()
}
void tst_QBluetoothLocalDevice::tst_isValid()
{
+#ifdef Q_OS_OSX
+ // On OS X we can have a valid device (device.isValid() == true),
+ // that has neither a name nor a valid address - this happens
+ // if a Bluetooth adapter is OFF.
+ if (!QBluetoothLocalDevice::allDevices().count())
+ QSKIP("Skipping test due to missing Bluetooth device");
+#endif
+
QBluetoothLocalDevice localDevice;
QBluetoothAddress invalidAddress("FF:FF:FF:FF:FF:FF");
diff --git a/tests/auto/qbluetoothserver/qbluetoothserver.pro b/tests/auto/qbluetoothserver/qbluetoothserver.pro
index 4b5e5d46..870a28d7 100644
--- a/tests/auto/qbluetoothserver/qbluetoothserver.pro
+++ b/tests/auto/qbluetoothserver/qbluetoothserver.pro
@@ -3,6 +3,8 @@ TARGET = tst_qbluetoothserver
CONFIG += testcase
QT = core concurrent bluetooth testlib
+osx:QT += widgets
+osx:CONFIG += insignificant_test
OTHER_FILES += \
README.txt
diff --git a/tests/auto/qbluetoothserver/tst_qbluetoothserver.cpp b/tests/auto/qbluetoothserver/tst_qbluetoothserver.cpp
index 740ea05e..ef460289 100644
--- a/tests/auto/qbluetoothserver/tst_qbluetoothserver.cpp
+++ b/tests/auto/qbluetoothserver/tst_qbluetoothserver.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -118,14 +118,18 @@ void tst_QBluetoothServer::setHostMode(const QBluetoothAddress &localAdapter,
void tst_QBluetoothServer::initTestCase()
{
- qRegisterMetaType<QBluetooth::SecurityFlags>("QBluetooth::SecurityFlags");
- qRegisterMetaType<QBluetoothServer::Error>("QBluetoothServer::Error");
+ qRegisterMetaType<QBluetooth::SecurityFlags>();
+ qRegisterMetaType<QBluetoothServer::Error>();
QBluetoothLocalDevice device;
if (!device.isValid())
return;
initialHostMode = device.hostMode();
+#ifdef Q_OS_OSX
+ if (initialHostMode == QBluetoothLocalDevice::HostPoweredOff)
+ return;
+#endif
setHostMode(device.address(), QBluetoothLocalDevice::HostConnectable);
@@ -177,17 +181,25 @@ void tst_QBluetoothServer::tst_receive()
QFETCH(QBluetoothLocalDevice::HostMode, hostmode);
QBluetoothLocalDevice localDev;
+#ifdef Q_OS_OSX
+ if (localDev.hostMode() == QBluetoothLocalDevice::HostPoweredOff)
+ QSKIP("On OS X this test requires Bluetooth adapter ON");
+#endif
const QBluetoothAddress address = localDev.address();
bool localDeviceAvailable = localDev.isValid();
if (localDeviceAvailable) {
+ // setHostMode is noop on OS X.
setHostMode(address, hostmode);
- if (hostmode == QBluetoothLocalDevice::HostPoweredOff)
+ if (hostmode == QBluetoothLocalDevice::HostPoweredOff) {
+#ifndef Q_OS_OSX
QCOMPARE(localDevice.hostMode(), hostmode);
- else
+#endif
+ } else {
QVERIFY(localDevice.hostMode() != QBluetoothLocalDevice::HostPoweredOff);
+ }
}
QBluetoothServer server(QBluetoothServiceInfo::RfcommProtocol);
QSignalSpy errorSpy(&server, SIGNAL(error(QBluetoothServer::Error)));
diff --git a/tests/auto/qbluetoothservicediscoveryagent/qbluetoothservicediscoveryagent.pro b/tests/auto/qbluetoothservicediscoveryagent/qbluetoothservicediscoveryagent.pro
index cdf8a78b..9ae5d71d 100644
--- a/tests/auto/qbluetoothservicediscoveryagent/qbluetoothservicediscoveryagent.pro
+++ b/tests/auto/qbluetoothservicediscoveryagent/qbluetoothservicediscoveryagent.pro
@@ -3,6 +3,7 @@ TARGET = tst_qbluetoothservicediscoveryagent
CONFIG += testcase
QT = core concurrent bluetooth testlib
+osx:QT += widgets
blackberry {
LIBS += -lbtapi
}
diff --git a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp
index 5e832f2c..280dd893 100644
--- a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp
+++ b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -34,6 +34,7 @@
#include <QtTest/QtTest>
#include <QDebug>
+#include <QLoggingCategory>
#include <QVariant>
#include <QList>
@@ -46,8 +47,7 @@
QT_USE_NAMESPACE
-Q_DECLARE_METATYPE(QBluetoothDeviceInfo)
-Q_DECLARE_METATYPE(QBluetoothServiceDiscoveryAgent::Error)
+Q_DECLARE_METATYPE(QBluetoothDeviceDiscoveryAgent::Error)
// Maximum time to for bluetooth device scan
const int MaxScanTime = 5 * 60 * 1000; // 5 minutes in ms
@@ -80,7 +80,10 @@ private:
tst_QBluetoothServiceDiscoveryAgent::tst_QBluetoothServiceDiscoveryAgent()
{
+ QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
+
// start Bluetooth if not started
+#ifndef Q_OS_OSX
QBluetoothLocalDevice *device = new QBluetoothLocalDevice();
localDeviceAvailable = device->isValid();
if (localDeviceAvailable) {
@@ -89,12 +92,16 @@ tst_QBluetoothServiceDiscoveryAgent::tst_QBluetoothServiceDiscoveryAgent()
QTest::qWait(1000);
}
delete device;
+#else
+ QBluetoothLocalDevice device;
+ localDeviceAvailable = QBluetoothLocalDevice().hostMode() != QBluetoothLocalDevice::HostPoweredOff;
+#endif
- qRegisterMetaType<QBluetoothDeviceInfo>("QBluetoothDeviceInfo");
- qRegisterMetaType<QBluetoothServiceInfo>("QBluetoothServiceInfo");
- qRegisterMetaType<QList<QBluetoothUuid> >("QList<QBluetoothUuid>");
- qRegisterMetaType<QBluetoothServiceDiscoveryAgent::Error>("QBluetoothServiceDiscoveryAgent::Error");
- qRegisterMetaType<QBluetoothDeviceDiscoveryAgent::Error>("QBluetoothDeviceDiscoveryAgent::Error");
+ qRegisterMetaType<QBluetoothDeviceInfo>();
+ qRegisterMetaType<QBluetoothServiceInfo>();
+ qRegisterMetaType<QList<QBluetoothUuid> >();
+ qRegisterMetaType<QBluetoothServiceDiscoveryAgent::Error>();
+ qRegisterMetaType<QBluetoothDeviceDiscoveryAgent::Error>();
}
@@ -144,6 +151,10 @@ void tst_QBluetoothServiceDiscoveryAgent::initTestCase()
void tst_QBluetoothServiceDiscoveryAgent::tst_invalidBtAddress()
{
+#ifdef Q_OS_OSX
+ if (!localDeviceAvailable)
+ QSKIP("On OS X this test requires Bluetooth adapter in powered ON state");
+#endif
QBluetoothServiceDiscoveryAgent *discoveryAgent = new QBluetoothServiceDiscoveryAgent(QBluetoothAddress("11:11:11:11:11:11"));
QCOMPARE(discoveryAgent->error(), QBluetoothServiceDiscoveryAgent::InvalidBluetoothAdapterError);
@@ -380,7 +391,7 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery()
connect(&discoveryAgent, SIGNAL(error(QBluetoothServiceDiscoveryAgent::Error)),
this, SLOT(serviceError(QBluetoothServiceDiscoveryAgent::Error)));
- discoveryAgent.start();
+ discoveryAgent.start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
/*
* Either we wait for discovery agent to run its course (e.g. Bluez 4) or
@@ -414,6 +425,7 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery()
}
// All returned QBluetoothServiceInfo should be valid.
+ bool servicesFound = !discoveredSpy.isEmpty();
while (!discoveredSpy.isEmpty()) {
const QVariant v = discoveredSpy.takeFirst().at(0);
// Work around limitation in QMetaType and moc.
@@ -442,7 +454,8 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery()
}
- QVERIFY(discoveryAgent.discoveredServices().count() != 0);
+ if (servicesFound)
+ QVERIFY(discoveryAgent.discoveredServices().count() != 0);
discoveryAgent.clear();
QVERIFY(discoveryAgent.discoveredServices().count() == 0);
diff --git a/tests/auto/qbluetoothserviceinfo/qbluetoothserviceinfo.pro b/tests/auto/qbluetoothserviceinfo/qbluetoothserviceinfo.pro
index 563df1a9..e55bac3a 100644
--- a/tests/auto/qbluetoothserviceinfo/qbluetoothserviceinfo.pro
+++ b/tests/auto/qbluetoothserviceinfo/qbluetoothserviceinfo.pro
@@ -3,6 +3,8 @@ TARGET = tst_qbluetoothserviceinfo
CONFIG += testcase
QT = core concurrent bluetooth testlib
+osx:QT += widgets
+
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
android:!android-no-sdk {
diff --git a/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp b/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp
index 61bad7c5..83cd0b3d 100644
--- a/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp
+++ b/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -78,9 +78,9 @@ tst_QBluetoothServiceInfo::~tst_QBluetoothServiceInfo()
void tst_QBluetoothServiceInfo::initTestCase()
{
- qRegisterMetaType<QBluetoothUuid::ProtocolUuid>("QBluetoothUuid::ProtocolUuid");
- qRegisterMetaType<QUuid>("QUuid");
- qRegisterMetaType<QBluetoothServiceInfo::Protocol>("QBluetoothServiceInfo::Protocol");
+ qRegisterMetaType<QBluetoothUuid::ProtocolUuid>();
+ qRegisterMetaType<QUuid>();
+ qRegisterMetaType<QBluetoothServiceInfo::Protocol>();
// start Bluetooth if not started
QBluetoothLocalDevice *device = new QBluetoothLocalDevice();
device->powerOn();
diff --git a/tests/auto/qbluetoothsocket/qbluetoothsocket.pro b/tests/auto/qbluetoothsocket/qbluetoothsocket.pro
index 34f6e527..3c0f9e44 100644
--- a/tests/auto/qbluetoothsocket/qbluetoothsocket.pro
+++ b/tests/auto/qbluetoothsocket/qbluetoothsocket.pro
@@ -4,6 +4,7 @@ CONFIG += testcase
testcase.timeout = 250 # this test is slow
QT = core concurrent network bluetooth testlib
+osx:QT += widgets
OTHER_FILES += \
README.txt
diff --git a/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
index 6290f075..eafa3e80 100644
--- a/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+++ b/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -43,8 +43,6 @@
QT_USE_NAMESPACE
-Q_DECLARE_METATYPE(QBluetoothSocket::SocketState)
-Q_DECLARE_METATYPE(QBluetoothSocket::SocketError)
Q_DECLARE_METATYPE(QBluetoothServiceInfo::Protocol)
//same uuid as tests/bttestui
@@ -100,8 +98,8 @@ Q_DECLARE_METATYPE(tst_QBluetoothSocket::ClientConnectionShutdown)
tst_QBluetoothSocket::tst_QBluetoothSocket()
{
- qRegisterMetaType<QBluetoothSocket::SocketState>("QBluetoothSocket::SocketState");
- qRegisterMetaType<QBluetoothSocket::SocketError>("QBluetoothSocket::SocketError");
+ qRegisterMetaType<QBluetoothSocket::SocketState>();
+ qRegisterMetaType<QBluetoothSocket::SocketError>();
localDeviceFound = false; // true if we have a local adapter
done_discovery = false; //true if we found remote device
diff --git a/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp b/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp
index b39e6292..932d5d1a 100644
--- a/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp
+++ b/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -92,7 +92,6 @@ private:
tst_QBluetoothTransferManager::tst_QBluetoothTransferManager()
{
- qRegisterMetaType<QBluetoothTransferReply*>("QBluetoothTransferReply*");
}
tst_QBluetoothTransferManager::~tst_QBluetoothTransferManager()
diff --git a/tests/auto/qbluetoothtransferrequest/tst_qbluetoothtransferrequest.cpp b/tests/auto/qbluetoothtransferrequest/tst_qbluetoothtransferrequest.cpp
index a06e6ab3..e675f0dd 100644
--- a/tests/auto/qbluetoothtransferrequest/tst_qbluetoothtransferrequest.cpp
+++ b/tests/auto/qbluetoothtransferrequest/tst_qbluetoothtransferrequest.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/tests/auto/qbluetoothuuid/tst_qbluetoothuuid.cpp b/tests/auto/qbluetoothuuid/tst_qbluetoothuuid.cpp
index e905eb94..3be51834 100644
--- a/tests/auto/qbluetoothuuid/tst_qbluetoothuuid.cpp
+++ b/tests/auto/qbluetoothuuid/tst_qbluetoothuuid.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -69,7 +69,7 @@ private slots:
tst_QBluetoothUuid::tst_QBluetoothUuid()
{
- qRegisterMetaType<quint128>("quint128");
+ qRegisterMetaType<quint128>();
}
tst_QBluetoothUuid::~tst_QBluetoothUuid()
diff --git a/tests/auto/qlowenergycharacteristic/qlowenergycharacteristic.pro b/tests/auto/qlowenergycharacteristic/qlowenergycharacteristic.pro
index 33302d60..74fdbf0d 100644
--- a/tests/auto/qlowenergycharacteristic/qlowenergycharacteristic.pro
+++ b/tests/auto/qlowenergycharacteristic/qlowenergycharacteristic.pro
@@ -7,3 +7,6 @@ DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
blackberry {
LIBS += -lbtapi
}
+
+osx:CONFIG += insignificant_test
+
diff --git a/tests/auto/qlowenergycharacteristic/tst_qlowenergycharacteristic.cpp b/tests/auto/qlowenergycharacteristic/tst_qlowenergycharacteristic.cpp
index e65b573c..de77046e 100644
--- a/tests/auto/qlowenergycharacteristic/tst_qlowenergycharacteristic.cpp
+++ b/tests/auto/qlowenergycharacteristic/tst_qlowenergycharacteristic.cpp
@@ -1,8 +1,8 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited all rights reserved
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -42,8 +42,21 @@
#include <QLowEnergyController>
#include <QBluetoothLocalDevice>
+Q_DECLARE_METATYPE(QBluetoothDeviceDiscoveryAgent::Error)
+
QT_USE_NAMESPACE
+// This define must be set if the platform provides access to GATT handles
+// otherwise it must not be defined. As of now the two supported platforms
+// (Android and Bluez/Linux) provide access or some notion of it.
+#define HANDLES_PROVIDED_BY_PLATFORM
+
+#ifdef HANDLES_PROVIDED_BY_PLATFORM
+#define HANDLE_VERIFY(stmt) QVERIFY(stmt)
+#else
+#define HANDLE_VERIFY(stmt)
+#endif
+
class tst_QLowEnergyCharacteristic : public QObject
{
Q_OBJECT
@@ -62,19 +75,16 @@ private slots:
void tst_assignCompare();
private:
- QSet<QString> remoteLeDevices;
+ QList<QBluetoothDeviceInfo> remoteLeDevices;
QLowEnergyController *globalControl;
QLowEnergyService *globalService;
};
-Q_DECLARE_METATYPE(QLowEnergyController::ControllerState)
-
tst_QLowEnergyCharacteristic::tst_QLowEnergyCharacteristic() :
globalControl(0), globalService(0)
{
QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
-
- qRegisterMetaType<QLowEnergyController::ControllerState>();
+ qRegisterMetaType<QBluetoothDeviceDiscoveryAgent::Error>();
}
tst_QLowEnergyCharacteristic::~tst_QLowEnergyCharacteristic()
@@ -111,9 +121,10 @@ void tst_QLowEnergyCharacteristic::initTestCase()
// find first service with descriptor
QLowEnergyController *controller = 0;
- foreach (const QString &remoteDevice, remoteLeDevices.toList()) {
- controller = new QLowEnergyController(QBluetoothAddress(remoteDevice), this);
- qDebug() << "Connecting to" << remoteDevice;
+ foreach (const QBluetoothDeviceInfo &remoteDevice, remoteLeDevices) {
+ controller = new QLowEnergyController(remoteDevice, this);
+ qDebug() << "Connecting to" << remoteDevice.name()
+ << remoteDevice.address() << remoteDevice.deviceUuid();
controller->connectToDevice();
QTRY_IMPL(controller->state() != QLowEnergyController::ConnectingState,
20000);
@@ -148,7 +159,7 @@ void tst_QLowEnergyCharacteristic::initTestCase()
if (!ch.descriptors().isEmpty()) {
globalService = leService;
globalControl = controller;
- qWarning() << "Found service with descriptor" << remoteDevice
+ qWarning() << "Found service with descriptor" << remoteDevice.address()
<< globalService->serviceName() << globalService->serviceUuid();
break;
}
@@ -181,7 +192,7 @@ void tst_QLowEnergyCharacteristic::cleanupTestCase()
void tst_QLowEnergyCharacteristic::deviceDiscovered(const QBluetoothDeviceInfo &info)
{
if (info.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration)
- remoteLeDevices.insert(info.address().toString());
+ remoteLeDevices.append(info);
}
void tst_QLowEnergyCharacteristic::tst_constructionDefault()
@@ -276,7 +287,7 @@ void tst_QLowEnergyCharacteristic::tst_assignCompare()
target = chars[indexWithDescriptor];
QVERIFY(target.isValid());
QVERIFY(!target.name().isEmpty());
- QVERIFY(target.handle() > 0);
+ HANDLE_VERIFY(target.handle() > 0);
QVERIFY(!target.uuid().isNull());
QVERIFY(target.properties() != QLowEnergyCharacteristic::Unknown);
if (target.properties() & QLowEnergyCharacteristic::Read)
diff --git a/tests/auto/qlowenergycontroller/qlowenergycontroller.pro b/tests/auto/qlowenergycontroller/qlowenergycontroller.pro
index 159f27bf..9d25d8a3 100644
--- a/tests/auto/qlowenergycontroller/qlowenergycontroller.pro
+++ b/tests/auto/qlowenergycontroller/qlowenergycontroller.pro
@@ -1,6 +1,14 @@
QT = core bluetooth testlib
+
+# Android requires GUI application when running test
+android: QT += widgets
+
TARGET = tst_qlowenergycontroller
CONFIG += testcase
SOURCES += tst_qlowenergycontroller.cpp
+osx|ios {
+ QT += widgets
+ CONFIG += insignificant_test
+}
diff --git a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp
index 4af96f3c..50ecc099 100644
--- a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp
+++ b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -32,6 +32,7 @@
****************************************************************************/
#include <QtTest/QtTest>
+#include <QBluetoothAddress>
#include <QBluetoothLocalDevice>
#include <QBluetoothDeviceDiscoveryAgent>
#include <QBluetoothUuid>
@@ -52,6 +53,19 @@
QT_USE_NAMESPACE
+// This define must be set if the platform provides access to GATT handles
+// otherwise it must not be defined. As of now the two supported platforms
+// (Android and Bluez/Linux) provide access or some notion of it.
+#ifndef Q_OS_MAC
+#define HANDLES_PROVIDED_BY_PLATFORM
+#endif
+
+#ifdef HANDLES_PROVIDED_BY_PLATFORM
+#define HANDLE_COMPARE(actual,expected) QCOMPARE(actual,expected)
+#else
+#define HANDLE_COMPARE(actual,expected)
+#endif
+
class tst_QLowEnergyController : public QObject
{
Q_OBJECT
@@ -62,34 +76,38 @@ public:
private slots:
void initTestCase();
+ void init();
void cleanupTestCase();
+ void tst_emptyCtor();
void tst_connect();
void tst_concurrentDiscovery();
void tst_defaultBehavior();
void tst_writeCharacteristic();
void tst_writeCharacteristicNoResponse();
- void tst_writeDescriptor();
- void tst_encryption();
+ void tst_readWriteDescriptor();
+ void tst_customProgrammableDevice();
+ void tst_errorCases();
private:
void verifyServiceProperties(const QLowEnergyService *info);
QBluetoothDeviceDiscoveryAgent *devAgent;
QBluetoothAddress remoteDevice;
+ QBluetoothDeviceInfo remoteDeviceInfo;
QList<QBluetoothUuid> foundServices;
};
Q_DECLARE_METATYPE(QLowEnergyCharacteristic)
Q_DECLARE_METATYPE(QLowEnergyDescriptor)
-Q_DECLARE_METATYPE(QLowEnergyService::ServiceError)
-Q_DECLARE_METATYPE(QLowEnergyController::ControllerState)
tst_QLowEnergyController::tst_QLowEnergyController()
{
qRegisterMetaType<QLowEnergyCharacteristic>();
qRegisterMetaType<QLowEnergyDescriptor>();
- qRegisterMetaType<QLowEnergyController::ControllerState>();
//QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
+#ifndef Q_OS_MAC
+ // Core Bluetooth (OS X and iOS) does not work with addresses,
+ // making the code below useless.
const QString remote = qgetenv("BT_TEST_DEVICE");
if (!remote.isEmpty()) {
remoteDevice = QBluetoothAddress(remote);
@@ -97,6 +115,7 @@ tst_QLowEnergyController::tst_QLowEnergyController()
} else {
qWarning() << "Not using any remote device for testing. Set BT_TEST_DEVICE env to run manual tests involving a remote device";
}
+#endif
}
tst_QLowEnergyController::~tst_QLowEnergyController()
@@ -106,12 +125,19 @@ tst_QLowEnergyController::~tst_QLowEnergyController()
void tst_QLowEnergyController::initTestCase()
{
+#ifndef Q_OS_MAC
if (remoteDevice.isNull()
|| QBluetoothLocalDevice::allDevices().isEmpty()) {
qWarning("No remote device or local adapter found.");
return;
}
-
+#elif defined(Q_OS_OSX)
+ // allDevices is always empty on iOS:
+ if (QBluetoothLocalDevice::allDevices().isEmpty()) {
+ qWarning("No local adapter found.");
+ return;
+ }
+#endif
devAgent = new QBluetoothDeviceDiscoveryAgent(this);
@@ -124,7 +150,14 @@ void tst_QLowEnergyController::initTestCase()
devAgent->start();
QTRY_VERIFY_WITH_TIMEOUT(finishedSpy.count() > 0, 30000);
foreach (const QBluetoothDeviceInfo &info, devAgent->discoveredDevices()) {
+#ifndef Q_OS_MAC
if (info.address() == remoteDevice) {
+#else
+ // On OS X/iOS the only way to find the device we are
+ // interested in - is to use device's name.
+ if (info.name().contains("Sensor") && info.name().contains("Tag")) {
+#endif
+ remoteDeviceInfo = info;
deviceFound = true;
break;
}
@@ -133,8 +166,11 @@ void tst_QLowEnergyController::initTestCase()
QVERIFY2(deviceFound, "Cannot find remote device.");
// These are the services exported by the TI SensorTag
+#ifndef Q_OS_MAC
+ // Core Bluetooth somehow ignores/hides/fails to discover these services.
foundServices << QBluetoothUuid(QString("00001800-0000-1000-8000-00805f9b34fb"));
foundServices << QBluetoothUuid(QString("00001801-0000-1000-8000-00805f9b34fb"));
+#endif
foundServices << QBluetoothUuid(QString("0000180a-0000-1000-8000-00805f9b34fb"));
foundServices << QBluetoothUuid(QString("0000ffe0-0000-1000-8000-00805f9b34fb"));
foundServices << QBluetoothUuid(QString("f000aa00-0451-4000-b000-000000000000"));
@@ -148,25 +184,94 @@ void tst_QLowEnergyController::initTestCase()
foundServices << QBluetoothUuid(QString("f000ffc0-0451-4000-b000-000000000000"));
}
+/*
+ * Executed in between each test function call.
+ */
+void tst_QLowEnergyController::init()
+{
+#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
+ /*
+ * Add a delay to give Android/iOS stack time to catch up in between
+ * the multiple connect/disconnects within each test function.
+ */
+ QTest::qWait(2000);
+#endif
+}
+
void tst_QLowEnergyController::cleanupTestCase()
{
}
+void tst_QLowEnergyController::tst_emptyCtor()
+{
+ {
+ QBluetoothAddress remoteAddress;
+ QLowEnergyController control(remoteAddress);
+ QSignalSpy connectedSpy(&control, SIGNAL(connected()));
+ QSignalSpy stateSpy(&control, SIGNAL(stateChanged(QLowEnergyController::ControllerState)));
+ QSignalSpy errorSpy(&control, SIGNAL(error(QLowEnergyController::Error)));
+ QCOMPARE(control.error(), QLowEnergyController::NoError);
+ control.connectToDevice();
+
+ QTRY_VERIFY_WITH_TIMEOUT(!errorSpy.isEmpty(), 10000);
+
+ QVERIFY(connectedSpy.isEmpty());
+ QVERIFY(stateSpy.isEmpty());
+
+ QLowEnergyController::Error lastError = errorSpy[0].at(0).value<QLowEnergyController::Error>();
+ QVERIFY(lastError == QLowEnergyController::UnknownRemoteDeviceError
+ || lastError == QLowEnergyController::InvalidBluetoothAdapterError);
+ }
+
+ {
+ QBluetoothDeviceInfo deviceInfo;
+ QLowEnergyController control(deviceInfo);
+ QSignalSpy connectedSpy(&control, SIGNAL(connected()));
+ QSignalSpy stateSpy(&control, SIGNAL(stateChanged(QLowEnergyController::ControllerState)));
+ QSignalSpy errorSpy(&control, SIGNAL(error(QLowEnergyController::Error)));
+ QCOMPARE(control.error(), QLowEnergyController::NoError);
+ control.connectToDevice();
+
+ QTRY_VERIFY_WITH_TIMEOUT(!errorSpy.isEmpty(), 10000);
+
+ QVERIFY(connectedSpy.isEmpty());
+ QVERIFY(stateSpy.isEmpty());
+
+ QLowEnergyController::Error lastError = errorSpy[0].at(0).value<QLowEnergyController::Error>();
+ QVERIFY(lastError == QLowEnergyController::UnknownRemoteDeviceError // if local device on platform found
+ || lastError == QLowEnergyController::InvalidBluetoothAdapterError); // otherwise, e.g. fallback backend
+ }
+
+}
+
void tst_QLowEnergyController::tst_connect()
{
QList<QBluetoothHostInfo> localAdapters = QBluetoothLocalDevice::allDevices();
- if (localAdapters.isEmpty() || remoteDevice.isNull())
+
+#ifdef Q_OS_IOS
+ if (remoteDeviceInfo.isValid())
+#else
+ if (localAdapters.isEmpty() || !remoteDeviceInfo.isValid())
+#endif
QSKIP("No local Bluetooth or remote BTLE device found. Skipping test.");
- const QBluetoothAddress localAdapter = localAdapters.at(0).address();
- QLowEnergyController control(remoteDevice);
+ QLowEnergyController control(remoteDeviceInfo);
QSignalSpy connectedSpy(&control, SIGNAL(connected()));
QSignalSpy disconnectedSpy(&control, SIGNAL(disconnected()));
+ if (remoteDeviceInfo.name().isEmpty())
+ QVERIFY(control.remoteName().isEmpty());
+ else
+ QCOMPARE(control.remoteName(), remoteDeviceInfo.name());
+#ifndef Q_OS_IOS
+ const QBluetoothAddress localAdapter = localAdapters.at(0).address();
QCOMPARE(control.localAddress(), localAdapter);
QVERIFY(!control.localAddress().isNull());
+#endif
+#ifndef Q_OS_MAC
QCOMPARE(control.remoteAddress(), remoteDevice);
+#endif
QCOMPARE(control.state(), QLowEnergyController::UnconnectedState);
QCOMPARE(control.error(), QLowEnergyController::NoError);
QVERIFY(control.errorString().isEmpty());
@@ -209,7 +314,7 @@ void tst_QLowEnergyController::tst_connect()
QSignalSpy serviceFoundSpy(&control, SIGNAL(serviceDiscovered(QBluetoothUuid)));
QSignalSpy stateSpy(&control, SIGNAL(stateChanged(QLowEnergyController::ControllerState)));
control.discoverServices();
- QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 10000);
+ QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 20000);
QCOMPARE(stateSpy.count(), 2);
QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
QLowEnergyController::DiscoveringState);
@@ -302,12 +407,17 @@ void tst_QLowEnergyController::tst_connect()
void tst_QLowEnergyController::tst_concurrentDiscovery()
{
+#ifndef Q_OS_MAC
QList<QBluetoothHostInfo> localAdapters = QBluetoothLocalDevice::allDevices();
- if (localAdapters.isEmpty() || remoteDevice.isNull())
- QSKIP("No local Bluetooth or remote BTLE device found. Skipping test.");
+ if (localAdapters.isEmpty())
+ QSKIP("No local Bluetooth device found. Skipping test.");
+#endif
+
+ if (!remoteDeviceInfo.isValid())
+ QSKIP("No remote BTLE device found. Skipping test.");
+ QLowEnergyController control(remoteDeviceInfo);
+
- // quick setup - more elaborate test is done by connectNew()
- QLowEnergyController control(remoteDevice);
QCOMPARE(control.state(), QLowEnergyController::UnconnectedState);
QCOMPARE(control.error(), QLowEnergyController::NoError);
@@ -334,7 +444,18 @@ void tst_QLowEnergyController::tst_concurrentDiscovery()
30000);
}
+#ifdef Q_OS_ANDROID
+ QCOMPARE(control.state(), QLowEnergyController::ConnectedState);
+ QCOMPARE(control2.state(), QLowEnergyController::ConnectedState);
+ control2.disconnectFromDevice();
+ QTest::qWait(3000);
+ QCOMPARE(control.state(), QLowEnergyController::ConnectedState);
+ QCOMPARE(control2.state(), QLowEnergyController::UnconnectedState);
+#else
+ // see QTBUG-42519
+ // Linux cannot maintain two controller connections at the same time
QVERIFY(control2.error() != QLowEnergyController::NoError);
+#endif
}
/* We are testing that we can run service discovery on the same device
@@ -344,7 +465,7 @@ void tst_QLowEnergyController::tst_concurrentDiscovery()
QSignalSpy discoveryFinishedSpy(&control, SIGNAL(discoveryFinished()));
QSignalSpy stateSpy(&control, SIGNAL(stateChanged(QLowEnergyController::ControllerState)));
control.discoverServices();
- QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 10000);
+ QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 20000);
QCOMPARE(stateSpy.count(), 2);
QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
QLowEnergyController::DiscoveringState);
@@ -402,7 +523,7 @@ void tst_QLowEnergyController::tst_concurrentDiscovery()
QCOMPARE(control.state(), QLowEnergyController::ConnectedState);
stateSpy.clear();
control.discoverServices();
- QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 10000);
+ QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 20000);
QCOMPARE(stateSpy.count(), 2);
QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
QLowEnergyController::DiscoveringState);
@@ -473,7 +594,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
// Device Name
QString temp("00002a00-0000-1000-8000-00805f9b34fb");
QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp));
- QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x3));
+ HANDLE_COMPARE(chars[0].handle(), QLowEnergyHandle(0x3));
QCOMPARE(chars[0].properties(), QLowEnergyCharacteristic::Read);
QCOMPARE(chars[0].value(), QByteArray::fromHex("544920424c452053656e736f7220546167"));
QVERIFY(chars[0].isValid());
@@ -483,7 +604,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
// Appearance
temp = QString("00002a01-0000-1000-8000-00805f9b34fb");
QCOMPARE(chars[1].uuid(), QBluetoothUuid(temp));
- QCOMPARE(chars[1].handle(), QLowEnergyHandle(0x5));
+ HANDLE_COMPARE(chars[1].handle(), QLowEnergyHandle(0x5));
QCOMPARE(chars[1].properties(), QLowEnergyCharacteristic::Read);
QCOMPARE(chars[1].value(), QByteArray::fromHex("0000"));
QVERIFY(chars[1].isValid());
@@ -493,7 +614,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
// Peripheral Privacy Flag
temp = QString("00002a02-0000-1000-8000-00805f9b34fb");
QCOMPARE(chars[2].uuid(), QBluetoothUuid(temp));
- QCOMPARE(chars[2].handle(), QLowEnergyHandle(0x7));
+ HANDLE_COMPARE(chars[2].handle(), QLowEnergyHandle(0x7));
QCOMPARE(chars[2].properties(),
(QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write));
QCOMPARE(chars[2].value(), QByteArray::fromHex("00"));
@@ -504,7 +625,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
// Reconnection Address
temp = QString("00002a03-0000-1000-8000-00805f9b34fb");
QCOMPARE(chars[3].uuid(), QBluetoothUuid(temp));
- QCOMPARE(chars[3].handle(), QLowEnergyHandle(0x9));
+ HANDLE_COMPARE(chars[3].handle(), QLowEnergyHandle(0x9));
//Early firmware version had this characteristic as Read|Write and may fail
QCOMPARE(chars[3].properties(), QLowEnergyCharacteristic::Write);
if (chars[3].properties() & QLowEnergyCharacteristic::Read)
@@ -518,7 +639,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
// Peripheral Preferred Connection Parameters
temp = QString("00002a04-0000-1000-8000-00805f9b34fb");
QCOMPARE(chars[4].uuid(), QBluetoothUuid(temp));
- QCOMPARE(chars[4].handle(), QLowEnergyHandle(0xb));
+ HANDLE_COMPARE(chars[4].handle(), QLowEnergyHandle(0xb));
QCOMPARE(chars[4].properties(), QLowEnergyCharacteristic::Read);
QCOMPARE(chars[4].value(), QByteArray::fromHex("5000a0000000e803"));
QVERIFY(chars[4].isValid());
@@ -534,7 +655,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QString temp("00002a05-0000-1000-8000-00805f9b34fb");
//this should really be readable according to GATT Service spec
QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp));
- QCOMPARE(chars[0].handle(), QLowEnergyHandle(0xe));
+ HANDLE_COMPARE(chars[0].handle(), QLowEnergyHandle(0xe));
QCOMPARE(chars[0].properties(), QLowEnergyCharacteristic::Indicate);
QCOMPARE(chars[0].value(), QByteArray());
QVERIFY(chars[0].isValid());
@@ -542,7 +663,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[0].descriptors().count(), 1);
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
- QCOMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0xf));
+ HANDLE_COMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0xf));
QCOMPARE(chars[0].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration));
QCOMPARE(chars[0].descriptors().at(0).type(),
@@ -559,9 +680,11 @@ void tst_QLowEnergyController::verifyServiceProperties(
QString temp("00002a23-0000-1000-8000-00805f9b34fb");
//this should really be readable according to GATT Service spec
QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp));
- QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x12));
+ HANDLE_COMPARE(chars[0].handle(), QLowEnergyHandle(0x12));
QCOMPARE(chars[0].properties(), QLowEnergyCharacteristic::Read);
- QCOMPARE(chars[0].value(), QByteArray::fromHex("6e41ab0000296abc"));
+// Do not read the System ID as it is different for every device
+// QEXPECT_FAIL("", "The value is different on different devices", Continue);
+// QCOMPARE(chars[0].value(), QByteArray::fromHex("6e41ab0000296abc"));
QVERIFY(chars[0].isValid());
QVERIFY(info->contains(chars[0]));
QCOMPARE(chars[0].descriptors().count(), 0);
@@ -569,7 +692,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
// Model Number
temp = QString("00002a24-0000-1000-8000-00805f9b34fb");
QCOMPARE(chars[1].uuid(), QBluetoothUuid(temp));
- QCOMPARE(chars[1].handle(), QLowEnergyHandle(0x14));
+ HANDLE_COMPARE(chars[1].handle(), QLowEnergyHandle(0x14));
QCOMPARE(chars[1].properties(), QLowEnergyCharacteristic::Read);
QCOMPARE(chars[1].value(), QByteArray::fromHex("4e2e412e00"));
QVERIFY(chars[1].isValid());
@@ -579,7 +702,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
// Serial Number
temp = QString("00002a25-0000-1000-8000-00805f9b34fb");
QCOMPARE(chars[2].uuid(), QBluetoothUuid(temp));
- QCOMPARE(chars[2].handle(), QLowEnergyHandle(0x16));
+ HANDLE_COMPARE(chars[2].handle(), QLowEnergyHandle(0x16));
QCOMPARE(chars[2].properties(),
(QLowEnergyCharacteristic::Read));
QCOMPARE(chars[2].value(), QByteArray::fromHex("4e2e412e00"));
@@ -590,7 +713,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
// Firmware Revision
temp = QString("00002a26-0000-1000-8000-00805f9b34fb");
QCOMPARE(chars[3].uuid(), QBluetoothUuid(temp));
- QCOMPARE(chars[3].handle(), QLowEnergyHandle(0x18));
+ HANDLE_COMPARE(chars[3].handle(), QLowEnergyHandle(0x18));
QCOMPARE(chars[3].properties(),
(QLowEnergyCharacteristic::Read));
//FW rev. : 1.5 (Oct 23 2013)
@@ -603,7 +726,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
// Hardware Revision
temp = QString("00002a27-0000-1000-8000-00805f9b34fb");
QCOMPARE(chars[4].uuid(), QBluetoothUuid(temp));
- QCOMPARE(chars[4].handle(), QLowEnergyHandle(0x1a));
+ HANDLE_COMPARE(chars[4].handle(), QLowEnergyHandle(0x1a));
QCOMPARE(chars[4].properties(),
(QLowEnergyCharacteristic::Read));
QCOMPARE(chars[4].value(), QByteArray::fromHex("4e2e412e00"));
@@ -614,7 +737,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
// Software Revision
temp = QString("00002a28-0000-1000-8000-00805f9b34fb");
QCOMPARE(chars[5].uuid(), QBluetoothUuid(temp));
- QCOMPARE(chars[5].handle(), QLowEnergyHandle(0x1c));
+ HANDLE_COMPARE(chars[5].handle(), QLowEnergyHandle(0x1c));
QCOMPARE(chars[5].properties(),
(QLowEnergyCharacteristic::Read));
QCOMPARE(chars[5].value(), QByteArray::fromHex("4e2e412e00"));
@@ -625,7 +748,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
// Manufacturer Name
temp = QString("00002a29-0000-1000-8000-00805f9b34fb");
QCOMPARE(chars[6].uuid(), QBluetoothUuid(temp));
- QCOMPARE(chars[6].handle(), QLowEnergyHandle(0x1e));
+ HANDLE_COMPARE(chars[6].handle(), QLowEnergyHandle(0x1e));
QCOMPARE(chars[6].properties(),
(QLowEnergyCharacteristic::Read));
QCOMPARE(chars[6].value(), QByteArray::fromHex("546578617320496e737472756d656e747300"));
@@ -636,7 +759,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
// IEEE
temp = QString("00002a2a-0000-1000-8000-00805f9b34fb");
QCOMPARE(chars[7].uuid(), QBluetoothUuid(temp));
- QCOMPARE(chars[7].handle(), QLowEnergyHandle(0x20));
+ HANDLE_COMPARE(chars[7].handle(), QLowEnergyHandle(0x20));
QCOMPARE(chars[7].properties(),
(QLowEnergyCharacteristic::Read));
QCOMPARE(chars[7].value(), QByteArray::fromHex("fe006578706572696d656e74616c"));
@@ -647,7 +770,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
// PnP ID
temp = QString("00002a50-0000-1000-8000-00805f9b34fb");
QCOMPARE(chars[8].uuid(), QBluetoothUuid(temp));
- QCOMPARE(chars[8].handle(), QLowEnergyHandle(0x22));
+ HANDLE_COMPARE(chars[8].handle(), QLowEnergyHandle(0x22));
QCOMPARE(chars[8].properties(),
(QLowEnergyCharacteristic::Read));
QCOMPARE(chars[8].value(), QByteArray::fromHex("010d0000001001"));
@@ -663,7 +786,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
// Temp Data
QString temp("f000aa01-0451-4000-b000-000000000000");
QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp));
- QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x25));
+ HANDLE_COMPARE(chars[0].handle(), QLowEnergyHandle(0x25));
QCOMPARE(chars[0].properties(),
(QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Notify));
QCOMPARE(chars[0].value(), QByteArray::fromHex("00000000"));
@@ -673,7 +796,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[0].descriptors().count(), 2);
//descriptor checks
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
- QCOMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x26));
+ HANDLE_COMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x26));
QCOMPARE(chars[0].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration));
QCOMPARE(chars[0].descriptors().at(0).type(),
@@ -682,7 +805,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QVERIFY(info->contains(chars[0].descriptors().at(0)));
QCOMPARE(chars[0].descriptors().at(1).isValid(), true);
- QCOMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x27));
+ HANDLE_COMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x27));
QCOMPARE(chars[0].descriptors().at(1).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(chars[0].descriptors().at(1).type(),
@@ -695,7 +818,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
// Temp Config
temp = QString("f000aa02-0451-4000-b000-000000000000");
QCOMPARE(chars[1].uuid(), QBluetoothUuid(temp));
- QCOMPARE(chars[1].handle(), QLowEnergyHandle(0x29));
+ HANDLE_COMPARE(chars[1].handle(), QLowEnergyHandle(0x29));
QCOMPARE(chars[1].properties(),
(QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write));
QCOMPARE(chars[1].value(), QByteArray::fromHex("00"));
@@ -705,7 +828,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[1].descriptors().count(), 1);
//descriptor checks
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
- QCOMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x2a));
+ HANDLE_COMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x2a));
QCOMPARE(chars[1].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(chars[1].descriptors().at(0).type(),
@@ -720,7 +843,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
if (chars.count() > 2) {
temp = QString("f000aa03-0451-4000-b000-000000000000");
QCOMPARE(chars[2].uuid(), QBluetoothUuid(temp));
- QCOMPARE(chars[2].handle(), QLowEnergyHandle(0x2c));
+ HANDLE_COMPARE(chars[2].handle(), QLowEnergyHandle(0x2c));
QCOMPARE(chars[2].properties(),
(QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write));
QCOMPARE(chars[2].value(), QByteArray::fromHex("64"));
@@ -730,7 +853,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[2].descriptors().count(), 1);
//descriptor checks
QCOMPARE(chars[2].descriptors().at(0).isValid(), true);
- QCOMPARE(chars[2].descriptors().at(0).handle(), QLowEnergyHandle(0x2d));
+ HANDLE_COMPARE(chars[2].descriptors().at(0).handle(), QLowEnergyHandle(0x2d));
QCOMPARE(chars[2].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(chars[2].descriptors().at(0).type(),
@@ -749,7 +872,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QString temp("0000ffe1-0000-1000-8000-00805f9b34fb");
QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp));
// value different in other revisions and test may fail
- QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x6b));
+ HANDLE_COMPARE(chars[0].handle(), QLowEnergyHandle(0x6b));
QCOMPARE(chars[0].properties(),
(QLowEnergyCharacteristic::Notify));
QCOMPARE(chars[0].value(), QByteArray());
@@ -760,7 +883,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
//descriptor checks
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x6c));
+ HANDLE_COMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x6c));
QCOMPARE(chars[0].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration));
QCOMPARE(chars[0].descriptors().at(0).type(),
@@ -770,7 +893,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[0].descriptors().at(1).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x6d));
+ HANDLE_COMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x6d));
QCOMPARE(chars[0].descriptors().at(1).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(chars[0].descriptors().at(1).type(),
@@ -789,7 +912,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QString temp("f000aa11-0451-4000-b000-000000000000");
QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp));
// value different in other revisions and test may fail
- QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x30));
+ HANDLE_COMPARE(chars[0].handle(), QLowEnergyHandle(0x30));
QCOMPARE(chars[0].properties(),
(QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Notify));
QCOMPARE(chars[0].value(), QByteArray::fromHex("000000"));
@@ -800,7 +923,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x31));
+ HANDLE_COMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x31));
QCOMPARE(chars[0].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration));
QCOMPARE(chars[0].descriptors().at(0).type(),
@@ -810,7 +933,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[0].descriptors().at(1).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x32));
+ HANDLE_COMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x32));
QCOMPARE(chars[0].descriptors().at(1).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(chars[0].descriptors().at(1).type(),
@@ -823,7 +946,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
temp = QString("f000aa12-0451-4000-b000-000000000000");
QCOMPARE(chars[1].uuid(), QBluetoothUuid(temp));
// value different in other revisions and test may fail
- QCOMPARE(chars[1].handle(), QLowEnergyHandle(0x34));
+ HANDLE_COMPARE(chars[1].handle(), QLowEnergyHandle(0x34));
QCOMPARE(chars[1].properties(),
(QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write));
QCOMPARE(chars[1].value(), QByteArray::fromHex("00"));
@@ -833,7 +956,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x35));
+ HANDLE_COMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x35));
QCOMPARE(chars[1].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(chars[1].descriptors().at(0).type(),
@@ -846,7 +969,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
temp = QString("f000aa13-0451-4000-b000-000000000000");
QCOMPARE(chars[2].uuid(), QBluetoothUuid(temp));
// value different in other revisions and test may fail
- QCOMPARE(chars[2].handle(), QLowEnergyHandle(0x37));
+ HANDLE_COMPARE(chars[2].handle(), QLowEnergyHandle(0x37));
QCOMPARE(chars[2].properties(),
(QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write));
QCOMPARE(chars[2].value(), QByteArray::fromHex("64")); // don't change it or set it to 0x64
@@ -857,7 +980,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
//descriptor checks
QCOMPARE(chars[2].descriptors().at(0).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(chars[2].descriptors().at(0).handle(), QLowEnergyHandle(0x38));
+ HANDLE_COMPARE(chars[2].descriptors().at(0).handle(), QLowEnergyHandle(0x38));
QCOMPARE(chars[2].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(chars[2].descriptors().at(0).type(),
@@ -876,7 +999,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QString temp("f000aa21-0451-4000-b000-000000000000");
QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp));
// value different in other revisions and test may fail
- QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x3b));
+ HANDLE_COMPARE(chars[0].handle(), QLowEnergyHandle(0x3b));
QCOMPARE(chars[0].properties(),
(QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Notify));
QCOMPARE(chars[0].value(), QByteArray::fromHex("00000000"));
@@ -887,7 +1010,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
//descriptor checks
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x3c));
+ HANDLE_COMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x3c));
QCOMPARE(chars[0].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration));
QCOMPARE(chars[0].descriptors().at(0).type(),
@@ -897,7 +1020,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[0].descriptors().at(1).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x3d));
+ HANDLE_COMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x3d));
QCOMPARE(chars[0].descriptors().at(1).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(chars[0].descriptors().at(1).type(),
@@ -910,7 +1033,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
temp = QString("f000aa22-0451-4000-b000-000000000000");
QCOMPARE(chars[1].uuid(), QBluetoothUuid(temp));
// value different in other revisions and test may fail
- QCOMPARE(chars[1].handle(), QLowEnergyHandle(0x3f));
+ HANDLE_COMPARE(chars[1].handle(), QLowEnergyHandle(0x3f));
QCOMPARE(chars[1].properties(),
(QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write));
QCOMPARE(chars[1].value(), QByteArray::fromHex("00"));
@@ -921,7 +1044,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
//descriptor checks
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x40));
+ HANDLE_COMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x40));
QCOMPARE(chars[1].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(chars[1].descriptors().at(0).type(),
@@ -935,7 +1058,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
// Humidity Period
temp = QString("f000aa23-0451-4000-b000-000000000000");
QCOMPARE(chars[2].uuid(), QBluetoothUuid(temp));
- QCOMPARE(chars[2].handle(), QLowEnergyHandle(0x42));
+ HANDLE_COMPARE(chars[2].handle(), QLowEnergyHandle(0x42));
QCOMPARE(chars[2].properties(),
(QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write));
QCOMPARE(chars[2].value(), QByteArray::fromHex("64"));
@@ -945,7 +1068,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[2].descriptors().count(), 1);
//descriptor checks
QCOMPARE(chars[2].descriptors().at(0).isValid(), true);
- QCOMPARE(chars[2].descriptors().at(0).handle(), QLowEnergyHandle(0x43));
+ HANDLE_COMPARE(chars[2].descriptors().at(0).handle(), QLowEnergyHandle(0x43));
QCOMPARE(chars[2].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(chars[2].descriptors().at(0).type(),
@@ -964,7 +1087,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QString temp("f000aa31-0451-4000-b000-000000000000");
QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp));
// value different in other revisions and test may fail
- QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x46));
+ HANDLE_COMPARE(chars[0].handle(), QLowEnergyHandle(0x46));
QCOMPARE(chars[0].properties(),
(QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Notify));
QCOMPARE(chars[0].value(), QByteArray::fromHex("000000000000"));
@@ -975,7 +1098,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x47));
+ HANDLE_COMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x47));
QCOMPARE(chars[0].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration));
QCOMPARE(chars[0].descriptors().at(0).type(),
@@ -985,7 +1108,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[0].descriptors().at(1).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x48));
+ HANDLE_COMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x48));
QCOMPARE(chars[0].descriptors().at(1).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(chars[0].descriptors().at(1).type(),
@@ -998,7 +1121,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
temp = QString("f000aa32-0451-4000-b000-000000000000");
QCOMPARE(chars[1].uuid(), QBluetoothUuid(temp));
// value different in other revisions and test may fail
- QCOMPARE(chars[1].handle(), QLowEnergyHandle(0x4a));
+ HANDLE_COMPARE(chars[1].handle(), QLowEnergyHandle(0x4a));
QCOMPARE(chars[1].properties(),
(QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write));
QCOMPARE(chars[1].value(), QByteArray::fromHex("00"));
@@ -1008,7 +1131,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[1].descriptors().count(), 1);
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x4b));
+ HANDLE_COMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x4b));
QCOMPARE(chars[1].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(chars[1].descriptors().at(0).type(),
@@ -1022,7 +1145,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
temp = QString("f000aa33-0451-4000-b000-000000000000");
QCOMPARE(chars[2].uuid(), QBluetoothUuid(temp));
// value different in other revisions and test may fail
- QCOMPARE(chars[2].handle(), QLowEnergyHandle(0x4d));
+ HANDLE_COMPARE(chars[2].handle(), QLowEnergyHandle(0x4d));
QCOMPARE(chars[2].properties(),
(QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write));
QCOMPARE(chars[2].value(), QByteArray::fromHex("c8")); // don't change it or set it to 0xc8
@@ -1032,7 +1155,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[2].descriptors().count(), 1);
QCOMPARE(chars[2].descriptors().at(0).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(chars[2].descriptors().at(0).handle(), QLowEnergyHandle(0x4e));
+ HANDLE_COMPARE(chars[2].descriptors().at(0).handle(), QLowEnergyHandle(0x4e));
QCOMPARE(chars[2].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(chars[2].descriptors().at(0).type(),
@@ -1051,7 +1174,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QString temp("f000aa41-0451-4000-b000-000000000000");
QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp));
// value different in other revisions and test may fail
- QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x51));
+ HANDLE_COMPARE(chars[0].handle(), QLowEnergyHandle(0x51));
QCOMPARE(chars[0].properties(),
(QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Notify));
QCOMPARE(chars[0].value(), QByteArray::fromHex("00000000"));
@@ -1062,7 +1185,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
//descriptor checks
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x52));
+ HANDLE_COMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x52));
QCOMPARE(chars[0].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration));
QCOMPARE(chars[0].descriptors().at(0).type(),
@@ -1072,7 +1195,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[0].descriptors().at(1).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x53));
+ HANDLE_COMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x53));
QCOMPARE(chars[0].descriptors().at(1).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(chars[0].descriptors().at(1).type(),
@@ -1086,7 +1209,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
temp = QString("f000aa42-0451-4000-b000-000000000000");
QCOMPARE(chars[1].uuid(), QBluetoothUuid(temp));
// value different in other revisions and test may fail
- QCOMPARE(chars[1].handle(), QLowEnergyHandle(0x55));
+ HANDLE_COMPARE(chars[1].handle(), QLowEnergyHandle(0x55));
QCOMPARE(chars[1].properties(),
(QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write));
QCOMPARE(chars[1].value(), QByteArray::fromHex("00"));
@@ -1096,7 +1219,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[1].descriptors().count(), 1);
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x56));
+ HANDLE_COMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x56));
QCOMPARE(chars[1].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(chars[1].descriptors().at(0).type(),
@@ -1120,7 +1243,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
temp = QString("f000aa43-0451-4000-b000-000000000000");
QCOMPARE(calibration.uuid(), QBluetoothUuid(temp));
// value different in other revisions and test may fail
- QCOMPARE(calibration.handle(), QLowEnergyHandle(0x5b));
+ HANDLE_COMPARE(calibration.handle(), QLowEnergyHandle(0x5b));
QCOMPARE(calibration.properties(),
(QLowEnergyCharacteristic::Read));
QCOMPARE(calibration.value(), QByteArray::fromHex("00000000000000000000000000000000")); // don't change it
@@ -1131,7 +1254,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
//descriptor checks
QCOMPARE(calibration.descriptors().at(0).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(calibration.descriptors().at(0).handle(), QLowEnergyHandle(0x5c));
+ HANDLE_COMPARE(calibration.descriptors().at(0).handle(), QLowEnergyHandle(0x5c));
QCOMPARE(calibration.descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration));
QCOMPARE(calibration.descriptors().at(0).type(),
@@ -1141,7 +1264,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(calibration.descriptors().at(1).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(calibration.descriptors().at(1).handle(), QLowEnergyHandle(0x5d));
+ HANDLE_COMPARE(calibration.descriptors().at(1).handle(), QLowEnergyHandle(0x5d));
QCOMPARE(calibration.descriptors().at(1).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(calibration.descriptors().at(1).type(),
@@ -1156,7 +1279,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
temp = QString("f000aa44-0451-4000-b000-000000000000");
QCOMPARE(period.uuid(), QBluetoothUuid(temp));
// value different in other revisions and test may fail
- QCOMPARE(period.handle(), QLowEnergyHandle(0x58));
+ HANDLE_COMPARE(period.handle(), QLowEnergyHandle(0x58));
QCOMPARE(period.properties(),
(QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write));
QCOMPARE(period.value(), QByteArray::fromHex("64"));
@@ -1167,7 +1290,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
//descriptor checks
QCOMPARE(period.descriptors().at(0).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(period.descriptors().at(0).handle(), QLowEnergyHandle(0x59));
+ HANDLE_COMPARE(period.descriptors().at(0).handle(), QLowEnergyHandle(0x59));
QCOMPARE(period.descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(period.descriptors().at(0).type(),
@@ -1186,7 +1309,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QString temp("f000aa51-0451-4000-b000-000000000000");
QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp));
// value different in other revisions and test may fail
- QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x60));
+ HANDLE_COMPARE(chars[0].handle(), QLowEnergyHandle(0x60));
QCOMPARE(chars[0].properties(),
(QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Notify));
QCOMPARE(chars[0].value(), QByteArray::fromHex("000000000000"));
@@ -1197,7 +1320,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
//descriptor checks
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x61));
+ HANDLE_COMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x61));
QCOMPARE(chars[0].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration));
QCOMPARE(chars[0].descriptors().at(0).type(),
@@ -1207,7 +1330,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[0].descriptors().at(1).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x62));
+ HANDLE_COMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x62));
QCOMPARE(chars[0].descriptors().at(1).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(chars[0].descriptors().at(1).type(),
@@ -1221,7 +1344,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
temp = QString("f000aa52-0451-4000-b000-000000000000");
QCOMPARE(chars[1].uuid(), QBluetoothUuid(temp));
// value different in other revisions and test may fail
- QCOMPARE(chars[1].handle(), QLowEnergyHandle(0x64));
+ HANDLE_COMPARE(chars[1].handle(), QLowEnergyHandle(0x64));
QCOMPARE(chars[1].properties(),
(QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write));
QCOMPARE(chars[1].value(), QByteArray::fromHex("00"));
@@ -1232,7 +1355,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
//descriptor checks
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x65));
+ HANDLE_COMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x65));
QCOMPARE(chars[1].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(chars[1].descriptors().at(0).type(),
@@ -1245,7 +1368,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
temp = QString("f000aa53-0451-4000-b000-000000000000");
QCOMPARE(chars[2].uuid(), QBluetoothUuid(temp));
// value different in other revisions and test may fail
- QCOMPARE(chars[2].handle(), QLowEnergyHandle(0x67));
+ HANDLE_COMPARE(chars[2].handle(), QLowEnergyHandle(0x67));
QCOMPARE(chars[2].properties(),
(QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write));
QCOMPARE(chars[2].value(), QByteArray::fromHex("64"));
@@ -1255,7 +1378,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[2].descriptors().count(), 1);
//descriptor checks
QCOMPARE(chars[2].descriptors().at(0).isValid(), true);
- QCOMPARE(chars[2].descriptors().at(0).handle(), QLowEnergyHandle(0x68));
+ HANDLE_COMPARE(chars[2].descriptors().at(0).handle(), QLowEnergyHandle(0x68));
QCOMPARE(chars[2].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(chars[2].descriptors().at(0).type(),
@@ -1273,7 +1396,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QString temp("f000aa61-0451-4000-b000-000000000000");
QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp));
// value different in other revisions and test may fail
- QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x70));
+ HANDLE_COMPARE(chars[0].handle(), QLowEnergyHandle(0x70));
QCOMPARE(chars[0].properties(),
(QLowEnergyCharacteristic::Read));
QCOMPARE(chars[0].value(), QByteArray::fromHex("3f00"));
@@ -1283,7 +1406,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[0].descriptors().count(), 1);
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x71));
+ HANDLE_COMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x71));
QCOMPARE(chars[0].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(chars[0].descriptors().at(0).type(),
@@ -1295,7 +1418,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
// Test Config
temp = QString("f000aa62-0451-4000-b000-000000000000");
QCOMPARE(chars[1].uuid(), QBluetoothUuid(temp));
- QCOMPARE(chars[1].handle(), QLowEnergyHandle(0x73));
+ HANDLE_COMPARE(chars[1].handle(), QLowEnergyHandle(0x73));
QCOMPARE(chars[1].properties(),
(QLowEnergyCharacteristic::Read|QLowEnergyCharacteristic::Write));
QCOMPARE(chars[1].value(), QByteArray::fromHex("00"));
@@ -1306,7 +1429,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
//descriptor checks
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x74));
+ HANDLE_COMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x74));
QCOMPARE(chars[1].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(chars[1].descriptors().at(0).type(),
@@ -1323,7 +1446,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
//first characteristic
QString temp("f000ccc1-0451-4000-b000-000000000000");
QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp));
- QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x77));
+ HANDLE_COMPARE(chars[0].handle(), QLowEnergyHandle(0x77));
QCOMPARE(chars[0].properties(),
(QLowEnergyCharacteristic::Notify|QLowEnergyCharacteristic::Read));
// the connection control parameter change from platform to platform
@@ -1335,7 +1458,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[0].descriptors().count(), 2);
//descriptor checks
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
- QCOMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x78));
+ HANDLE_COMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x78));
QCOMPARE(chars[0].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration));
QCOMPARE(chars[0].descriptors().at(0).type(),
@@ -1346,7 +1469,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[0].descriptors().at(1).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x79));
+ HANDLE_COMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x79));
QCOMPARE(chars[0].descriptors().at(1).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(chars[0].descriptors().at(1).type(),
@@ -1358,7 +1481,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
//second characteristic
temp = QString("f000ccc2-0451-4000-b000-000000000000");
QCOMPARE(chars[1].uuid(), QBluetoothUuid(temp));
- QCOMPARE(chars[1].handle(), QLowEnergyHandle(0x7b));
+ HANDLE_COMPARE(chars[1].handle(), QLowEnergyHandle(0x7b));
QCOMPARE(chars[1].properties(), QLowEnergyCharacteristic::Write);
QCOMPARE(chars[1].value(), QByteArray());
QVERIFY(chars[1].isValid());
@@ -1366,7 +1489,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[1].descriptors().count(), 1);
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
- QCOMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x7c));
+ HANDLE_COMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x7c));
QCOMPARE(chars[1].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(chars[1].descriptors().at(0).type(),
@@ -1378,7 +1501,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
//third characteristic
temp = QString("f000ccc3-0451-4000-b000-000000000000");
QCOMPARE(chars[2].uuid(), QBluetoothUuid(temp));
- QCOMPARE(chars[2].handle(), QLowEnergyHandle(0x7e));
+ HANDLE_COMPARE(chars[2].handle(), QLowEnergyHandle(0x7e));
QCOMPARE(chars[2].properties(), QLowEnergyCharacteristic::Write);
QCOMPARE(chars[2].value(), QByteArray());
QVERIFY(chars[2].isValid());
@@ -1386,7 +1509,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[2].descriptors().count(), 1);
QCOMPARE(chars[2].descriptors().at(0).isValid(), true);
- QCOMPARE(chars[2].descriptors().at(0).handle(), QLowEnergyHandle(0x7f));
+ HANDLE_COMPARE(chars[2].descriptors().at(0).handle(), QLowEnergyHandle(0x7f));
QCOMPARE(chars[2].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(chars[2].descriptors().at(0).type(),
@@ -1404,7 +1527,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QString temp("f000ffc1-0451-4000-b000-000000000000");
QCOMPARE(chars[0].uuid(), QBluetoothUuid(temp));
// value different in other revisions and test may fail
- QCOMPARE(chars[0].handle(), QLowEnergyHandle(0x82));
+ HANDLE_COMPARE(chars[0].handle(), QLowEnergyHandle(0x82));
QCOMPARE(chars[0].properties(),
(QLowEnergyCharacteristic::Notify|QLowEnergyCharacteristic::Write|QLowEnergyCharacteristic::WriteNoResponse));
QCOMPARE(chars[0].value(), QByteArray());
@@ -1414,7 +1537,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[0].descriptors().count(), 2);
//descriptor checks
QCOMPARE(chars[0].descriptors().at(0).isValid(), true);
- QCOMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x83));
+ HANDLE_COMPARE(chars[0].descriptors().at(0).handle(), QLowEnergyHandle(0x83));
QCOMPARE(chars[0].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration));
QCOMPARE(chars[0].descriptors().at(0).type(),
@@ -1425,7 +1548,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[0].descriptors().at(1).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x84));
+ HANDLE_COMPARE(chars[0].descriptors().at(1).handle(), QLowEnergyHandle(0x84));
QCOMPARE(chars[0].descriptors().at(1).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(chars[0].descriptors().at(1).type(),
@@ -1438,7 +1561,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
temp = QString("f000ffc2-0451-4000-b000-000000000000");
QCOMPARE(chars[1].uuid(), QBluetoothUuid(temp));
// value different in other revisions and test may fail
- QCOMPARE(chars[1].handle(), QLowEnergyHandle(0x86));
+ HANDLE_COMPARE(chars[1].handle(), QLowEnergyHandle(0x86));
QCOMPARE(chars[1].properties(),
(QLowEnergyCharacteristic::Notify|QLowEnergyCharacteristic::Write|QLowEnergyCharacteristic::WriteNoResponse));
QCOMPARE(chars[1].value(), QByteArray());
@@ -1449,7 +1572,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
//descriptor checks
QCOMPARE(chars[1].descriptors().at(0).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x87));
+ HANDLE_COMPARE(chars[1].descriptors().at(0).handle(), QLowEnergyHandle(0x87));
QCOMPARE(chars[1].descriptors().at(0).uuid(),
QBluetoothUuid(QBluetoothUuid::ClientCharacteristicConfiguration));
QCOMPARE(chars[1].descriptors().at(0).type(),
@@ -1460,7 +1583,7 @@ void tst_QLowEnergyController::verifyServiceProperties(
QCOMPARE(chars[1].descriptors().at(1).isValid(), true);
// value different in other revisions and test may fail
- QCOMPARE(chars[1].descriptors().at(1).handle(), QLowEnergyHandle(0x88));
+ HANDLE_COMPARE(chars[1].descriptors().at(1).handle(), QLowEnergyHandle(0x88));
QCOMPARE(chars[1].descriptors().at(1).uuid(),
QBluetoothUuid(QBluetoothUuid::CharacteristicUserDescription));
QCOMPARE(chars[1].descriptors().at(1).type(),
@@ -1524,12 +1647,16 @@ void tst_QLowEnergyController::tst_defaultBehavior()
void tst_QLowEnergyController::tst_writeCharacteristic()
{
+#ifndef Q_OS_MAC
QList<QBluetoothHostInfo> localAdapters = QBluetoothLocalDevice::allDevices();
- if (localAdapters.isEmpty() || remoteDevice.isNull())
- QSKIP("No local Bluetooth or remote BTLE device found. Skipping test.");
+ if (localAdapters.isEmpty())
+ QSKIP("No local Bluetooth device found. Skipping test.");
+#endif
+
+ if (!remoteDeviceInfo.isValid())
+ QSKIP("No remote BTLE device found. Skipping test.");
+ QLowEnergyController control(remoteDeviceInfo);
- // quick setup - more elaborate test is done by connect()
- QLowEnergyController control(remoteDevice);
QCOMPARE(control.error(), QLowEnergyController::NoError);
control.connectToDevice();
@@ -1548,7 +1675,7 @@ void tst_QLowEnergyController::tst_writeCharacteristic()
QSignalSpy discoveryFinishedSpy(&control, SIGNAL(discoveryFinished()));
QSignalSpy stateSpy(&control, SIGNAL(stateChanged(QLowEnergyController::ControllerState)));
control.discoverServices();
- QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 10000);
+ QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 20000);
QCOMPARE(stateSpy.count(), 2);
QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
QLowEnergyController::DiscoveringState);
@@ -1582,6 +1709,7 @@ void tst_QLowEnergyController::tst_writeCharacteristic()
QVERIFY(service->contains(dataChar));
QVERIFY(configChar.isValid());
QVERIFY(configChar.properties() & QLowEnergyCharacteristic::Write);
+ QVERIFY(configChar.properties() & QLowEnergyCharacteristic::Read);
QVERIFY(service->contains(configChar));
QCOMPARE(dataChar.value(), QByteArray::fromHex("3f00"));
@@ -1590,11 +1718,13 @@ void tst_QLowEnergyController::tst_writeCharacteristic()
QSignalSpy writeSpy(service,
SIGNAL(characteristicWritten(QLowEnergyCharacteristic,QByteArray)));
+ QSignalSpy readSpy(service,
+ SIGNAL(characteristicRead(QLowEnergyCharacteristic,QByteArray)));
// *******************************************
// test writing of characteristic
// enable Blinking LED if not already enabled
- if (configChar.value() != QByteArray("81")) {
+ if (configChar.value() != QByteArray::fromHex("81")) {
service->writeCharacteristic(configChar, QByteArray::fromHex("81")); //0x81 blink LED D1
QTRY_VERIFY_WITH_TIMEOUT(!writeSpy.isEmpty(), 10000);
QCOMPARE(configChar.value(), QByteArray::fromHex("81"));
@@ -1606,9 +1736,27 @@ void tst_QLowEnergyController::tst_writeCharacteristic()
QVERIFY(signalChar == configChar);
writeSpy.clear();
+
}
- service->writeCharacteristic(configChar, QByteArray::fromHex("00")); //0x81 blink LED D1
+ // test direct read of configChar
+ QVERIFY(readSpy.isEmpty());
+ service->readCharacteristic(configChar);
+ QTRY_VERIFY_WITH_TIMEOUT(!readSpy.isEmpty(), 10000);
+ QCOMPARE(configChar.value(), QByteArray::fromHex("81"));
+ QCOMPARE(readSpy.count(), 1); //expect one characteristicRead signal
+ {
+ //verify the readCharacteristic()
+ QList<QVariant> firstSignalData = readSpy.first();
+ QLowEnergyCharacteristic signalChar = firstSignalData[0].value<QLowEnergyCharacteristic>();
+ QByteArray signalValue = firstSignalData[1].toByteArray();
+
+ QCOMPARE(signalValue, QByteArray::fromHex("81"));
+ QCOMPARE(signalValue, configChar.value());
+ QVERIFY(signalChar == configChar);
+ }
+
+ service->writeCharacteristic(configChar, QByteArray::fromHex("00")); //turn LED D1 off
QTRY_VERIFY_WITH_TIMEOUT(!writeSpy.isEmpty(), 10000);
QCOMPARE(configChar.value(), QByteArray::fromHex("00"));
QList<QVariant> firstSignalData = writeSpy.first();
@@ -1642,8 +1790,8 @@ void tst_QLowEnergyController::tst_writeCharacteristic()
QTRY_VERIFY_WITH_TIMEOUT(!errorSpy.isEmpty(), 10000);
QCOMPARE(errorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
- QLowEnergyService::OperationError);
- QCOMPARE(service->error(), QLowEnergyService::OperationError);
+ QLowEnergyService::CharacteristicWriteError);
+ QCOMPARE(service->error(), QLowEnergyService::CharacteristicWriteError);
QCOMPARE(writeSpy.count(), 0);
QCOMPARE(dataChar.value(), QByteArray::fromHex("3f00"));
@@ -1671,14 +1819,19 @@ void tst_QLowEnergyController::tst_writeCharacteristic()
delete service;
}
-void tst_QLowEnergyController::tst_writeDescriptor()
+void tst_QLowEnergyController::tst_readWriteDescriptor()
{
+#ifndef Q_OS_MAC
QList<QBluetoothHostInfo> localAdapters = QBluetoothLocalDevice::allDevices();
- if (localAdapters.isEmpty() || remoteDevice.isNull())
- QSKIP("No local Bluetooth or remote BTLE device found. Skipping test.");
+ if (localAdapters.isEmpty())
+ QSKIP("No local Bluetooth device found. Skipping test.");
+#endif
+
+ if (!remoteDeviceInfo.isValid())
+ QSKIP("No remote BTLE device found. Skipping test.");
+ QLowEnergyController control(remoteDeviceInfo);
// quick setup - more elaborate test is done by connect()
- QLowEnergyController control(remoteDevice);
control.connectToDevice();
{
QTRY_IMPL(control.state() != QLowEnergyController::ConnectingState,
@@ -1695,7 +1848,7 @@ void tst_QLowEnergyController::tst_writeDescriptor()
QSignalSpy discoveryFinishedSpy(&control, SIGNAL(discoveryFinished()));
QSignalSpy stateSpy(&control, SIGNAL(stateChanged(QLowEnergyController::ControllerState)));
control.discoverServices();
- QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 10000);
+ QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 20000);
QCOMPARE(stateSpy.count(), 2);
QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
QLowEnergyController::DiscoveringState);
@@ -1745,9 +1898,11 @@ void tst_QLowEnergyController::tst_writeDescriptor()
QCOMPARE(tempConfig.value(), QByteArray::fromHex("00"));
}
- // 3. Test writing to descriptor -> activate notifications
+ // 3. Test reading and writing to descriptor -> activate notifications
QSignalSpy descWrittenSpy(service,
SIGNAL(descriptorWritten(QLowEnergyDescriptor,QByteArray)));
+ QSignalSpy descReadSpy(service,
+ SIGNAL(descriptorRead(QLowEnergyDescriptor,QByteArray)));
QSignalSpy charWrittenSpy(service,
SIGNAL(characteristicWritten(QLowEnergyCharacteristic,QByteArray)));
QSignalSpy charChangedSpy(service,
@@ -1794,12 +1949,31 @@ void tst_QLowEnergyController::tst_writeDescriptor()
const QLowEnergyCharacteristic ch = entry[0].value<QLowEnergyCharacteristic>();
QCOMPARE(tempData, ch);
+
+ //check last characteristic changed value matches the characteristics current value
+ if (i == (charChangedSpy.count() - 1)) {
+ writtenValue = entry[1].toByteArray();
+ QCOMPARE(ch.value(), writtenValue);
+ QCOMPARE(tempData.value(), writtenValue);
+ }
}
service->writeCharacteristic(tempConfig, QByteArray::fromHex("00"));
}
- // 5. Test writing to descriptor -> deactivate notifications
+ // 5. Test reading and writing of/to descriptor -> deactivate notifications
+
+ service->readDescriptor(notification);
+ QTRY_VERIFY_WITH_TIMEOUT(!descReadSpy.isEmpty(), 3000);
+ QCOMPARE(descReadSpy.count(), 1);
+ firstSignalData = descReadSpy.first();
+ signalDesc = firstSignalData[0].value<QLowEnergyDescriptor>();
+ signalValue = firstSignalData[1].toByteArray();
+ QCOMPARE(signalValue, notification.value());
+ QCOMPARE(notification.value(), QByteArray::fromHex("0100"));
+ descReadSpy.clear();
+
+
service->writeDescriptor(notification, QByteArray::fromHex("0000"));
// verify
QTRY_VERIFY_WITH_TIMEOUT(!descWrittenSpy.isEmpty(), 3000);
@@ -1811,6 +1985,41 @@ void tst_QLowEnergyController::tst_writeDescriptor()
QVERIFY(notification == signalDesc);
descWrittenSpy.clear();
+ // test concurrent writeRequests
+ // they need to be queued up
+ service->writeDescriptor(notification,QByteArray::fromHex("0100"));
+ service->writeDescriptor(notification, QByteArray::fromHex("0000"));
+ service->writeDescriptor(notification, QByteArray::fromHex("0100"));
+ service->writeDescriptor(notification, QByteArray::fromHex("0000"));
+ QTRY_VERIFY_WITH_TIMEOUT(descWrittenSpy.count() == 4, 10000);
+
+ QCOMPARE(notification.value(), QByteArray::fromHex("0000"));
+ for (int i = 0; i < descWrittenSpy.count(); i++) {
+ firstSignalData = descWrittenSpy.at(i);
+ signalDesc = firstSignalData[0].value<QLowEnergyDescriptor>();
+ signalValue = firstSignalData[1].toByteArray();
+ if (i & 0x1) // odd
+ QCOMPARE(signalValue, QByteArray::fromHex("0000"));
+ else // even
+ QCOMPARE(signalValue, QByteArray::fromHex("0100"));
+ QVERIFY(notification == signalDesc);
+
+ }
+
+ // 5. Test reading and writing of/to descriptor -> deactivate notifications
+
+ service->readDescriptor(notification);
+ QTRY_VERIFY_WITH_TIMEOUT(!descReadSpy.isEmpty(), 3000);
+ QCOMPARE(descReadSpy.count(), 1);
+ firstSignalData = descReadSpy.first();
+ signalDesc = firstSignalData[0].value<QLowEnergyDescriptor>();
+ signalValue = firstSignalData[1].toByteArray();
+ QCOMPARE(signalValue, notification.value());
+ QCOMPARE(notification.value(), QByteArray::fromHex("0000"));
+ descReadSpy.clear();
+
+ descWrittenSpy.clear();
+
// *******************************************
// write wrong value -> error response required
QSignalSpy errorSpy(service, SIGNAL(error(QLowEnergyService::ServiceError)));
@@ -1820,7 +2029,15 @@ void tst_QLowEnergyController::tst_writeDescriptor()
// write 4 byte value to 2 byte characteristic
service->writeDescriptor(notification, QByteArray::fromHex("11112222"));
+#ifdef Q_OS_MAC
+ // On OS X/iOS we have a special method to set notify value,
+ // it accepts only false/true and not
+ // writing descriptors, there is only one way to find this error -
+ // immediately intercept in LE controller and set the error.
+ QVERIFY(!errorSpy.isEmpty());
+#else
QTRY_VERIFY_WITH_TIMEOUT(!errorSpy.isEmpty(), 30000);
+#endif
QCOMPARE(errorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
QLowEnergyService::DescriptorWriteError);
QCOMPARE(service->error(), QLowEnergyService::DescriptorWriteError);
@@ -1844,12 +2061,32 @@ void tst_QLowEnergyController::tst_writeDescriptor()
}
/*
- * Tests encrypted read/write.
+ * By default this test is skipped.
+ *
+ * Following tests are performed:
+ * - encrypted read and discovery
+ * - readCharacteristic() of values longer than MTU
+ * - readCharacteristic() if values equal to MTU
+ *
* This test is semi manual as the test device environment is very specific.
- * Adjust the various uuids and addresses at the top to cater for the current
- * situation. By default this test is skipped.
+ * A programmable BTLE device is required. Currently, the test requires
+ * the CSR Dev Kit using the hr_sensor example.
+ *
+ * The following changes must be done to example to be able to fully
+ * utilise the test:
+ * 1.) gap_service_db.db -> UUID_DEVICE_NAME char - add FLAG_ENCR_R
+ * => tests encrypted read/discovery
+ * 2.) dev_info_service_db.db -> UUID_DEVICE_INFO_MANUFACTURER_NAME
+ * => The default name "Cambridge Silicon Radio" must be changed
+ * to "Cambridge Silicon Radi" (new length 22)
+ * 3.) revert change 1 above and redo test. This attempts to write a
+ * char that is readable w/o encryption but writeable with encryption
+ * => tests encryption code lines in writeCharacteristic()
+ * => otherwise the read encryption would have increased security level already
+ * => programmable CSR device must be reset before each run of this test
+ * (to undo the previous write)
*/
-void tst_QLowEnergyController::tst_encryption()
+void tst_QLowEnergyController::tst_customProgrammableDevice()
{
QSKIP("Skipping encryption");
@@ -1880,7 +2117,7 @@ void tst_QLowEnergyController::tst_encryption()
QSignalSpy discoveryFinishedSpy(&control, SIGNAL(discoveryFinished()));
QSignalSpy stateSpy(&control, SIGNAL(stateChanged(QLowEnergyController::ControllerState)));
control.discoverServices();
- QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 10000);
+ QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 20000);
QCOMPARE(stateSpy.count(), 2);
QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
QLowEnergyController::DiscoveringState);
@@ -1892,33 +2129,353 @@ void tst_QLowEnergyController::tst_encryption()
QLowEnergyService *service = control.createServiceObject(serviceUuid, this);
QVERIFY(service);
+
+ // 1.) discovery triggers read of device name char which is encrypted
service->discoverDetails();
QTRY_VERIFY_WITH_TIMEOUT(
service->state() == QLowEnergyService::ServiceDiscovered, 30000);
- QLowEnergyCharacteristic characteristic = service->characteristic(
+ QLowEnergyCharacteristic encryptedChar = service->characteristic(
characterristicUuid);
+ const QByteArray encryptedReference("CSR HR Sensor");
+ QVERIFY(encryptedChar.isValid());
+ QCOMPARE(encryptedChar.value(), encryptedReference);
+
+ // 2.) read of encrypted characteristic
+ // => the discovery of the encrypted char above will have switched to
+ // encryption already.
+ QSignalSpy encryptedReadSpy(service,
+ SIGNAL(characteristicRead(QLowEnergyCharacteristic,QByteArray)));
+ QSignalSpy encryptedErrorSpy(service,
+ SIGNAL(error(QLowEnergyService::ServiceError)));
+ service->readCharacteristic(encryptedChar);
+ QTRY_VERIFY_WITH_TIMEOUT(!encryptedReadSpy.isEmpty(), 10000);
+ QVERIFY(encryptedErrorSpy.isEmpty());
+ QCOMPARE(encryptedReadSpy.count(), 1);
+ QList<QVariant> entry = encryptedReadSpy[0];
+ QVERIFY(entry[0].value<QLowEnergyCharacteristic>() == encryptedChar);
+ QCOMPARE(entry[1].toByteArray(), encryptedReference);
+ QCOMPARE(encryptedChar.value(), encryptedReference);
+
+ // 3.) write to encrypted characteristic
+ QSignalSpy encryptedWriteSpy(service,
+ SIGNAL(characteristicWritten(QLowEnergyCharacteristic,QByteArray)));
+ encryptedReadSpy.clear();
+ encryptedErrorSpy.clear();
+ const QByteArray newValue("ZZZ HR Sensor");
+ service->writeCharacteristic(encryptedChar, newValue);
+ QTRY_VERIFY_WITH_TIMEOUT(!encryptedWriteSpy.isEmpty(), 10000);
+ QVERIFY(encryptedErrorSpy.isEmpty());
+ QVERIFY(encryptedReadSpy.isEmpty());
+ QCOMPARE(encryptedWriteSpy.count(), 1);
+ entry = encryptedWriteSpy[0];
+ QVERIFY(entry[0].value<QLowEnergyCharacteristic>() == encryptedChar);
+ QCOMPARE(entry[1].toByteArray(), newValue);
+ QCOMPARE(encryptedChar.value(), newValue);
- QVERIFY(characteristic.isValid());
- qDebug() << "Encrypted char value:" << characteristic.value().toHex() << characteristic.value();
- QVERIFY(!characteristic.value().isEmpty());
+ delete service;
+
+ //change to Device Information service
+ QVERIFY(uuids.contains(QBluetoothUuid::DeviceInformation));
+ service = control.createServiceObject(QBluetoothUuid::DeviceInformation);
+ QVERIFY(service);
+
+ service->discoverDetails();
+ QTRY_VERIFY_WITH_TIMEOUT(
+ service->state() == QLowEnergyService::ServiceDiscovered, 30000);
+
+ // 4.) read of software revision string which is longer than mtu
+ // tests readCharacteristic() including blob reads
+ QSignalSpy readSpy(service,
+ SIGNAL(characteristicRead(QLowEnergyCharacteristic,QByteArray)));
+ QSignalSpy errorSpy(service,
+ SIGNAL(error(QLowEnergyService::ServiceError)));
+
+ const QByteArray expectedSoftRev("Application version 2.3.0.0");
+ QLowEnergyCharacteristic softwareRevChar
+ = service->characteristic(QBluetoothUuid::SoftwareRevisionString);
+ QVERIFY(softwareRevChar.isValid());
+ QCOMPARE(softwareRevChar.value(), expectedSoftRev);
+
+ service->readCharacteristic(softwareRevChar);
+ QTRY_VERIFY_WITH_TIMEOUT(!readSpy.isEmpty(), 10000);
+ QVERIFY(errorSpy.isEmpty());
+ QCOMPARE(readSpy.count(), 1);
+ entry = readSpy[0];
+ QVERIFY(entry[0].value<QLowEnergyCharacteristic>() == softwareRevChar);
+ QCOMPARE(entry[1].toByteArray(), expectedSoftRev);
+ QCOMPARE(softwareRevChar.value(), expectedSoftRev);
+
+
+ // 5.) read of manufacturer string which is exactly as long as single
+ // MTU size (assuming negotiated MTU is 23)
+ // => blob read test without blob being required
+ // => the read blob answer will have zero length
+
+ readSpy.clear();
+
+ // This assumes the manufacturer string was mondified via CSR SDK
+ // see function description above
+ const QByteArray expectedManufacturer("Cambridge Silicon Radi");
+ QLowEnergyCharacteristic manufacturerChar = service->characteristic(
+ QBluetoothUuid::ManufacturerNameString);
+ QVERIFY(manufacturerChar.isValid());
+ QCOMPARE(manufacturerChar.value(), expectedManufacturer);
+
+ service->readCharacteristic(manufacturerChar);
+ QTRY_VERIFY_WITH_TIMEOUT(!readSpy.isEmpty(), 10000);
+ QVERIFY(errorSpy.isEmpty());
+ QCOMPARE(readSpy.count(), 1);
+ entry = readSpy[0];
+ QVERIFY(entry[0].value<QLowEnergyCharacteristic>() == manufacturerChar);
+ QCOMPARE(entry[1].toByteArray(), expectedManufacturer);
+ QCOMPARE(manufacturerChar.value(), expectedManufacturer);
delete service;
control.disconnectFromDevice();
}
+
+/* 1.) Test with undiscovered devices
+ - read and write invalid char
+ 2.) Test with discovered devices
+ - read non-readable char
+ - write non-writable char
+ */
+void tst_QLowEnergyController::tst_errorCases()
+{
+#ifndef Q_OS_MAC
+ QList<QBluetoothHostInfo> localAdapters = QBluetoothLocalDevice::allDevices();
+ if (localAdapters.isEmpty())
+ QSKIP("No local Bluetooth device found. Skipping test.");
+#endif
+
+ if (!remoteDeviceInfo.isValid())
+ QSKIP("No remote BTLE device found. Skipping test.");
+ QLowEnergyController control(remoteDeviceInfo);
+ QCOMPARE(control.error(), QLowEnergyController::NoError);
+
+ control.connectToDevice();
+ {
+ QTRY_IMPL(control.state() != QLowEnergyController::ConnectingState,
+ 30000);
+ }
+
+ if (control.state() == QLowEnergyController::ConnectingState
+ || control.error() != QLowEnergyController::NoError) {
+ // default BTLE backend forever hangs in ConnectingState
+ QSKIP("Cannot connect to remote device");
+ }
+
+ QCOMPARE(control.state(), QLowEnergyController::ConnectedState);
+ QSignalSpy discoveryFinishedSpy(&control, SIGNAL(discoveryFinished()));
+ QSignalSpy stateSpy(&control, SIGNAL(stateChanged(QLowEnergyController::ControllerState)));
+ control.discoverServices();
+ QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 20000);
+ QCOMPARE(stateSpy.count(), 2);
+ QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
+ QLowEnergyController::DiscoveringState);
+ QCOMPARE(stateSpy.at(1).at(0).value<QLowEnergyController::ControllerState>(),
+ QLowEnergyController::DiscoveredState);
+
+
+ // Setup required uuids
+ const QBluetoothUuid irTemperaturServiceUuid(QStringLiteral("f000aa00-0451-4000-b000-000000000000"));
+ const QBluetoothUuid irCharUuid(QString("f000aa01-0451-4000-b000-000000000000"));
+ const QBluetoothUuid oadServiceUuid(QStringLiteral("f000ffc0-0451-4000-b000-000000000000"));
+ const QBluetoothUuid oadCharUuid(QString("f000ffc1-0451-4000-b000-000000000000"));
+
+ QVERIFY(control.services().contains(irTemperaturServiceUuid));
+ QVERIFY(control.services().contains(oadServiceUuid));
+
+ // Create service objects and basic tests
+ QLowEnergyService *irService = control.createServiceObject(irTemperaturServiceUuid);
+ QVERIFY(irService);
+ QCOMPARE(irService->state(), QLowEnergyService::DiscoveryRequired);
+ QVERIFY(irService->characteristics().isEmpty());
+ QLowEnergyService *oadService = control.createServiceObject(oadServiceUuid);
+ QVERIFY(oadService);
+ QCOMPARE(oadService->state(), QLowEnergyService::DiscoveryRequired);
+ QVERIFY(oadService->characteristics().isEmpty());
+
+ QLowEnergyCharacteristic invalidChar;
+ QLowEnergyDescriptor invalidDesc;
+
+ QVERIFY(!irService->contains(invalidChar));
+ QVERIFY(!irService->contains(invalidDesc));
+
+ QSignalSpy irErrorSpy(irService, SIGNAL(error(QLowEnergyService::ServiceError)));
+ QSignalSpy oadErrorSpy(oadService, SIGNAL(error(QLowEnergyService::ServiceError)));
+
+ QSignalSpy irReadSpy(irService, SIGNAL(characteristicRead(QLowEnergyCharacteristic,QByteArray)));
+ QSignalSpy irWrittenSpy(irService, SIGNAL(characteristicWritten(QLowEnergyCharacteristic,QByteArray)));
+ QSignalSpy irDescReadSpy(irService, SIGNAL(descriptorRead(QLowEnergyDescriptor,QByteArray)));
+ QSignalSpy irDescWrittenSpy(irService, SIGNAL(descriptorWritten(QLowEnergyDescriptor,QByteArray)));
+
+ QSignalSpy oadCharReadSpy(oadService, SIGNAL(descriptorRead(QLowEnergyDescriptor,QByteArray)));
+
+ // ********************************************************
+ // Test read/write to discovered service
+ // with invalid characteristic & descriptor
+
+ // discover IR Service
+ irService->discoverDetails();
+ QTRY_VERIFY_WITH_TIMEOUT(
+ irService->state() == QLowEnergyService::ServiceDiscovered, 30000);
+ QVERIFY(!irService->contains(invalidChar));
+ QVERIFY(!irService->contains(invalidDesc));
+ irErrorSpy.clear();
+
+ // read invalid characteristic
+ irService->readCharacteristic(invalidChar);
+ QTRY_VERIFY_WITH_TIMEOUT(!irErrorSpy.isEmpty(), 5000);
+ QCOMPARE(irErrorSpy.count(), 1);
+ QVERIFY(irWrittenSpy.isEmpty());
+ QVERIFY(irReadSpy.isEmpty());
+ QCOMPARE(irErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
+ QLowEnergyService::OperationError);
+ irErrorSpy.clear();
+
+ // read invalid descriptor
+ irService->readDescriptor(invalidDesc);
+ QTRY_VERIFY_WITH_TIMEOUT(!irErrorSpy.isEmpty(), 5000);
+ QCOMPARE(irErrorSpy.count(), 1);
+ QVERIFY(irDescWrittenSpy.isEmpty());
+ QVERIFY(irDescReadSpy.isEmpty());
+ QCOMPARE(irErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
+ QLowEnergyService::OperationError);
+ irErrorSpy.clear();
+
+ // write invalid characteristic
+ irService->writeCharacteristic(invalidChar, QByteArray("foo"));
+ QTRY_VERIFY_WITH_TIMEOUT(!irErrorSpy.isEmpty(), 5000);
+ QCOMPARE(irErrorSpy.count(), 1);
+ QVERIFY(irWrittenSpy.isEmpty());
+ QVERIFY(irReadSpy.isEmpty());
+ QCOMPARE(irErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
+ QLowEnergyService::OperationError);
+ irErrorSpy.clear();
+
+ // write invalid descriptor
+ irService->readDescriptor(invalidDesc);
+ QTRY_VERIFY_WITH_TIMEOUT(!irErrorSpy.isEmpty(), 5000);
+ QCOMPARE(irErrorSpy.count(), 1);
+ QVERIFY(irDescWrittenSpy.isEmpty());
+ QVERIFY(irDescReadSpy.isEmpty());
+ QCOMPARE(irErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
+ QLowEnergyService::OperationError);
+ irErrorSpy.clear();
+
+ // ********************************************************
+ // Test read/write to undiscovered service
+ // with invalid characteristic & descriptor
+
+ // read invalid characteristic
+ oadService->readCharacteristic(invalidChar);
+ QTRY_VERIFY_WITH_TIMEOUT(!oadErrorSpy.isEmpty(), 5000);
+ QCOMPARE(oadErrorSpy.count(), 1);
+ QCOMPARE(oadErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
+ QLowEnergyService::OperationError);
+ oadErrorSpy.clear();
+
+ // read invalid descriptor
+ oadService->readDescriptor(invalidDesc);
+ QTRY_VERIFY_WITH_TIMEOUT(!oadErrorSpy.isEmpty(), 5000);
+ QCOMPARE(oadErrorSpy.count(), 1);
+ QCOMPARE(oadErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
+ QLowEnergyService::OperationError);
+ oadErrorSpy.clear();
+
+ // write invalid characteristic
+ oadService->writeCharacteristic(invalidChar, QByteArray("foo"));
+ QTRY_VERIFY_WITH_TIMEOUT(!oadErrorSpy.isEmpty(), 5000);
+ QCOMPARE(oadErrorSpy.count(), 1);
+ QCOMPARE(oadErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
+ QLowEnergyService::OperationError);
+ oadErrorSpy.clear();
+
+ // write invalid descriptor
+ oadService->readDescriptor(invalidDesc);
+ QTRY_VERIFY_WITH_TIMEOUT(!oadErrorSpy.isEmpty(), 5000);
+ QCOMPARE(oadErrorSpy.count(), 1);
+ QCOMPARE(oadErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
+ QLowEnergyService::OperationError);
+ oadErrorSpy.clear();
+
+ // ********************************************************
+ // Write to non-writable char
+
+ QLowEnergyCharacteristic nonWritableChar = irService->characteristic(irCharUuid);
+ QVERIFY(nonWritableChar.isValid());
+ // not writeable in any form
+ QVERIFY(!(nonWritableChar.properties()
+ & (QLowEnergyCharacteristic::Write|QLowEnergyCharacteristic::WriteNoResponse
+ |QLowEnergyCharacteristic::WriteSigned)));
+ irService->writeCharacteristic(nonWritableChar, QByteArray("ABCD"));
+ QTRY_VERIFY_WITH_TIMEOUT(!irErrorSpy.isEmpty(), 5000);
+ QVERIFY(irWrittenSpy.isEmpty());
+ QVERIFY(irReadSpy.isEmpty());
+ QCOMPARE(irErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
+ QLowEnergyService::CharacteristicWriteError);
+ irErrorSpy.clear();
+
+ // ********************************************************
+ // Write to non-writable desc
+ // CharacteristicUserDescription is not writable
+
+ QLowEnergyDescriptor nonWritableDesc = nonWritableChar.descriptor(
+ QBluetoothUuid::CharacteristicUserDescription);
+ QVERIFY(nonWritableDesc.isValid());
+ irService->writeDescriptor(nonWritableDesc, QByteArray("ABCD"));
+ QTRY_VERIFY_WITH_TIMEOUT(!irErrorSpy.isEmpty(), 5000);
+ QVERIFY(irWrittenSpy.isEmpty());
+ QVERIFY(irReadSpy.isEmpty());
+ QCOMPARE(irErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
+ QLowEnergyService::DescriptorWriteError);
+ irErrorSpy.clear();
+
+
+ // ********************************************************
+ // Read non-readable char
+
+ // discover OAD Service
+ oadService->discoverDetails();
+ QTRY_VERIFY_WITH_TIMEOUT(
+ oadService->state() == QLowEnergyService::ServiceDiscovered, 30000);
+ oadErrorSpy.clear();
+
+ // Test reading
+ QLowEnergyCharacteristic oadChar = oadService->characteristic(oadCharUuid);
+ QVERIFY(oadChar.isValid());
+ oadService->readCharacteristic(oadChar);
+ QTRY_VERIFY_WITH_TIMEOUT(!oadErrorSpy.isEmpty(), 5000);
+ QCOMPARE(oadErrorSpy.count(), 1);
+ QVERIFY(oadCharReadSpy.isEmpty());
+ QCOMPARE(oadErrorSpy[0].at(0).value<QLowEnergyService::ServiceError>(),
+ QLowEnergyService::CharacteristicReadError);
+ oadErrorSpy.clear();
+
+ delete irService;
+ delete oadService;
+ control.disconnectFromDevice();
+}
+
/*
Tests write without responses. We utilize the Over-The-Air image update
service of the SensorTag.
*/
void tst_QLowEnergyController::tst_writeCharacteristicNoResponse()
{
+#ifndef Q_OS_MAC
QList<QBluetoothHostInfo> localAdapters = QBluetoothLocalDevice::allDevices();
- if (localAdapters.isEmpty() || remoteDevice.isNull())
- QSKIP("No local Bluetooth or remote BTLE device found. Skipping test.");
+ if (localAdapters.isEmpty())
+ QSKIP("No local Bluetooth device found. Skipping test.");
+#endif
+
+ if (!remoteDeviceInfo.isValid())
+ QSKIP("No remote BTLE device found. Skipping test.");
+ QLowEnergyController control(remoteDeviceInfo);
- // quick setup - more elaborate test is done by connect()
- QLowEnergyController control(remoteDevice);
QCOMPARE(control.error(), QLowEnergyController::NoError);
control.connectToDevice();
@@ -1937,7 +2494,7 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse()
QSignalSpy discoveryFinishedSpy(&control, SIGNAL(discoveryFinished()));
QSignalSpy stateSpy(&control, SIGNAL(stateChanged(QLowEnergyController::ControllerState)));
control.discoverServices();
- QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 10000);
+ QTRY_VERIFY_WITH_TIMEOUT(discoveryFinishedSpy.count() == 1, 20000);
QCOMPARE(stateSpy.count(), 2);
QCOMPARE(stateSpy.at(0).at(0).value<QLowEnergyController::ControllerState>(),
QLowEnergyController::DiscoveringState);
@@ -1963,6 +2520,7 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse()
QVERIFY(imageIdentityChar.isValid());
QVERIFY(imageIdentityChar.properties() & QLowEnergyCharacteristic::Write);
QVERIFY(imageIdentityChar.properties() & QLowEnergyCharacteristic::WriteNoResponse);
+ QVERIFY(!(imageIdentityChar.properties() & QLowEnergyCharacteristic::Read)); //not readable
QVERIFY(imageBlockChar.isValid());
// 2. Get "Image Identity" notification descriptor
@@ -1982,7 +2540,15 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse()
SIGNAL(characteristicChanged(QLowEnergyCharacteristic,QByteArray)));
QSignalSpy charWrittenSpy(service,
SIGNAL(characteristicWritten(QLowEnergyCharacteristic,QByteArray)));
+ QSignalSpy charReadSpy(service,
+ SIGNAL(characteristicRead(QLowEnergyCharacteristic,QByteArray)));
+ QSignalSpy errorSpy(service,
+ SIGNAL(error(QLowEnergyService::ServiceError)));
+
+ // by default the device enables the notification bit already
+ // no need to enable it. If notifications fail to arrive the
+ // platform must check default enabled notifications.
if (notification.value() != QByteArray::fromHex("0100")) {
service->writeDescriptor(notification, QByteArray::fromHex("0100"));
QTRY_VERIFY_WITH_TIMEOUT(!descWrittenSpy.isEmpty(), 3000);
@@ -1995,8 +2561,20 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse()
descWrittenSpy.clear();
}
- // 4. Trigger image identity announcement (using traditional write)
QList<QVariant> entry;
+
+ // Test direct read of non-readable characteristic
+ QVERIFY(errorSpy.isEmpty());
+ QVERIFY(charReadSpy.isEmpty());
+ service->readCharacteristic(imageIdentityChar);
+ QTRY_VERIFY_WITH_TIMEOUT(!errorSpy.isEmpty(), 10000);
+ QCOMPARE(errorSpy.count(), 1); // should throw CharacteristicReadError
+ QVERIFY(charReadSpy.isEmpty());
+ entry = errorSpy[0];
+ QCOMPARE(entry[0].value<QLowEnergyService::ServiceError>(),
+ QLowEnergyService::CharacteristicReadError);
+
+ // 4. Trigger image identity announcement (using traditional write)
bool foundOneImage = false;
// Image A
@@ -2018,6 +2596,8 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse()
QCOMPARE(imageIdentityChar, first);
foundOneImage = true;
} else {
+ // we received a notification for imageBlockChar without explicitly
+ // enabling them. This is caused by the device's default settings.
QCOMPARE(imageBlockChar, first);
qWarning() << "Invalid image A ident info";
}
@@ -2026,7 +2606,11 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse()
QLowEnergyCharacteristic second = entry[0].value<QLowEnergyCharacteristic>();
QByteArray val2 = entry[1].toByteArray();
QCOMPARE(imageIdentityChar, second);
- QCOMPARE(val2, QByteArray::fromHex("0"));
+ QVERIFY(val2 == QByteArray::fromHex("0") || val2 == val1);
+
+ // notifications on non-readable characteristics do not update cache
+ QVERIFY(imageIdentityChar.value().isEmpty());
+ QVERIFY(imageBlockChar.value().isEmpty());
charChangedSpy.clear();
charWrittenSpy.clear();
@@ -2044,6 +2628,8 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse()
QCOMPARE(imageIdentityChar, first);
foundOneImage = true;
} else {
+ // we received a notification for imageBlockChar without explicitly
+ // enabling them. This is caused by the device's default settings.
QCOMPARE(imageBlockChar, first);
qWarning() << "Invalid image B ident info";
}
@@ -2052,7 +2638,16 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse()
second = entry[0].value<QLowEnergyCharacteristic>();
val2 = entry[1].toByteArray();
QCOMPARE(imageIdentityChar, second);
- QCOMPARE(val2, QByteArray::fromHex("1"));
+
+ // notifications on non-readable characteristics do not update cache
+ QVERIFY(imageIdentityChar.value().isEmpty());
+ QVERIFY(imageBlockChar.value().isEmpty());
+
+ /* Bluez resends the last confirmed write value, other platforms
+ * send the value received by the change notification value.
+ */
+ qDebug() << "Image B(1):" << val1.toHex() << val2.toHex();
+ QVERIFY(val2 == QByteArray::fromHex("1") || val2 == val1);
QVERIFY2(foundOneImage, "The SensorTag doesn't have a valid image? (1)");
@@ -2075,15 +2670,25 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse()
first = entry[0].value<QLowEnergyCharacteristic>();
val1 = entry[1].toByteArray();
+#ifdef Q_OS_ANDROID
+ QEXPECT_FAIL("", "Android sends write confirmation when using WriteWithoutResponse",
+ Continue);
+#endif
QVERIFY(charWrittenSpy.isEmpty());
if (val1.size() == 8) {
QCOMPARE(first, imageIdentityChar);
foundOneImage = true;
} else {
+ // we received a notification for imageBlockChar without explicitly
+ // enabling them. This is caused by the device's default settings.
QCOMPARE(imageBlockChar, first);
qWarning() << "Image A not set?";
}
+ // notifications on non-readable characteristics do not update cache
+ QVERIFY(imageIdentityChar.value().isEmpty());
+ QVERIFY(imageBlockChar.value().isEmpty());
+
charChangedSpy.clear();
// Image B
@@ -2100,15 +2705,26 @@ void tst_QLowEnergyController::tst_writeCharacteristicNoResponse()
first = entry[0].value<QLowEnergyCharacteristic>();
val1 = entry[1].toByteArray();
+#ifdef Q_OS_ANDROID
+ QEXPECT_FAIL("", "Android sends write confirmation when using WriteWithoutResponse",
+ Continue);
+#endif
QVERIFY(charWrittenSpy.isEmpty());
if (val1.size() == 8) {
QCOMPARE(first, imageIdentityChar);
foundOneImage = true;
} else {
+ // we received a notification for imageBlockChar without explicitly
+ // enabling them. This is caused by the device's default settings.
QCOMPARE(imageBlockChar, first);
qWarning() << "Image B not set?";
}
+ // notifications on non-readable characteristics do not update cache
+ QVERIFY(imageIdentityChar.value().isEmpty());
+ QVERIFY(imageBlockChar.value().isEmpty());
+
+
QVERIFY2(foundOneImage, "The SensorTag doesn't have a valid image? (2)");
delete service;
diff --git a/tests/auto/qlowenergydescriptor/qlowenergydescriptor.pro b/tests/auto/qlowenergydescriptor/qlowenergydescriptor.pro
index 60b5a740..dc069ca5 100644
--- a/tests/auto/qlowenergydescriptor/qlowenergydescriptor.pro
+++ b/tests/auto/qlowenergydescriptor/qlowenergydescriptor.pro
@@ -6,3 +6,6 @@ QT = core bluetooth testlib
blackberry {
LIBS += -lbtapi
}
+
+osx:CONFIG += insignificant_test
+
diff --git a/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp b/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp
index ff958cc6..0034c221 100644
--- a/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp
+++ b/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp
@@ -1,8 +1,8 @@
/***************************************************************************
**
** Copyright (C) 2013 BlackBerry Limited all rights reserved
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -62,19 +62,15 @@ private slots:
void tst_assignCompare();
private:
- QSet<QString> remoteLeDevices;
+ QList<QBluetoothDeviceInfo> remoteLeDeviceInfos;
QLowEnergyController *globalControl;
QLowEnergyService *globalService;
};
-Q_DECLARE_METATYPE(QLowEnergyController::ControllerState)
-
tst_QLowEnergyDescriptor::tst_QLowEnergyDescriptor() :
globalControl(0), globalService(0)
{
QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
-
- qRegisterMetaType<QLowEnergyController::ControllerState>();
}
tst_QLowEnergyDescriptor::~tst_QLowEnergyDescriptor()
@@ -114,9 +110,9 @@ void tst_QLowEnergyDescriptor::initTestCase()
// find first service with descriptor
QLowEnergyController *controller = 0;
- foreach (const QString &remoteDevice, remoteLeDevices.toList()) {
- controller = new QLowEnergyController(QBluetoothAddress(remoteDevice), this);
- qDebug() << "Connecting to" << remoteDevice;
+ foreach (const QBluetoothDeviceInfo& remoteDeviceInfo, remoteLeDeviceInfos) {
+ controller = new QLowEnergyController(remoteDeviceInfo, this);
+ qDebug() << "Connecting to" << remoteDeviceInfo.address();
controller->connectToDevice();
QTRY_IMPL(controller->state() != QLowEnergyController::ConnectingState,
20000);
@@ -151,7 +147,7 @@ void tst_QLowEnergyDescriptor::initTestCase()
if (!ch.descriptors().isEmpty()) {
globalService = leService;
globalControl = controller;
- qWarning() << "Found service with descriptor" << remoteDevice
+ qWarning() << "Found service with descriptor" << remoteDeviceInfo.address()
<< globalService->serviceName() << globalService->serviceUuid();
break;
}
@@ -184,7 +180,7 @@ void tst_QLowEnergyDescriptor::cleanupTestCase()
void tst_QLowEnergyDescriptor::deviceDiscovered(const QBluetoothDeviceInfo &info)
{
if (info.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration)
- remoteLeDevices.insert(info.address().toString());
+ remoteLeDeviceInfos.append(info);
}
void tst_QLowEnergyDescriptor::tst_constructionDefault()
diff --git a/tests/auto/qndefmessage/tst_qndefmessage.cpp b/tests/auto/qndefmessage/tst_qndefmessage.cpp
index c697a5e5..4c260922 100644
--- a/tests/auto/qndefmessage/tst_qndefmessage.cpp
+++ b/tests/auto/qndefmessage/tst_qndefmessage.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/tests/auto/qndefnfcsmartposterrecord/tst_qndefnfcsmartposterrecord.cpp b/tests/auto/qndefnfcsmartposterrecord/tst_qndefnfcsmartposterrecord.cpp
index f5b51710..c5945ca9 100644
--- a/tests/auto/qndefnfcsmartposterrecord/tst_qndefnfcsmartposterrecord.cpp
+++ b/tests/auto/qndefnfcsmartposterrecord/tst_qndefnfcsmartposterrecord.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 Research In Motion
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/tests/auto/qndefrecord/tst_qndefrecord.cpp b/tests/auto/qndefrecord/tst_qndefrecord.cpp
index 5e776423..88473667 100644
--- a/tests/auto/qndefrecord/tst_qndefrecord.cpp
+++ b/tests/auto/qndefrecord/tst_qndefrecord.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/tests/auto/qnearfieldmanager/tst_qnearfieldmanager.cpp b/tests/auto/qnearfieldmanager/tst_qnearfieldmanager.cpp
index 694b6b1b..d043cbf8 100644
--- a/tests/auto/qnearfieldmanager/tst_qnearfieldmanager.cpp
+++ b/tests/auto/qnearfieldmanager/tst_qnearfieldmanager.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -75,8 +75,8 @@ tst_QNearFieldManager::tst_QNearFieldManager()
{
QDir::setCurrent(QLatin1String(SRCDIR));
- qRegisterMetaType<QNdefMessage>("QNdefMessage");
- qRegisterMetaType<QNearFieldTarget *>("QNearFieldTarget*");
+ qRegisterMetaType<QNdefMessage>();
+ qRegisterMetaType<QNearFieldTarget *>();
}
void tst_QNearFieldManager::initTestCase()
diff --git a/tests/auto/qnearfieldtagtype1/tst_qnearfieldtagtype1.cpp b/tests/auto/qnearfieldtagtype1/tst_qnearfieldtagtype1.cpp
index 0d733e1d..12969bc1 100644
--- a/tests/auto/qnearfieldtagtype1/tst_qnearfieldtagtype1.cpp
+++ b/tests/auto/qnearfieldtagtype1/tst_qnearfieldtagtype1.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -72,8 +72,8 @@ tst_QNearFieldTagType1::tst_QNearFieldTagType1()
{
QDir::setCurrent(QLatin1String(SRCDIR));
- qRegisterMetaType<QNdefMessage>("QNdefMessage");
- qRegisterMetaType<QNearFieldTarget *>("QNearFieldTarget*");
+ qRegisterMetaType<QNdefMessage>();
+ qRegisterMetaType<QNearFieldTarget *>();
}
void tst_QNearFieldTagType1::init()
diff --git a/tests/auto/qnearfieldtagtype2/tst_qnearfieldtagtype2.cpp b/tests/auto/qnearfieldtagtype2/tst_qnearfieldtagtype2.cpp
index 39a2c68b..1871c205 100644
--- a/tests/auto/qnearfieldtagtype2/tst_qnearfieldtagtype2.cpp
+++ b/tests/auto/qnearfieldtagtype2/tst_qnearfieldtagtype2.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNfc module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -74,8 +74,8 @@ tst_QNearFieldTagType2::tst_QNearFieldTagType2()
{
QDir::setCurrent(QLatin1String(SRCDIR));
- qRegisterMetaType<QNdefMessage>("QNdefMessage");
- qRegisterMetaType<QNearFieldTarget *>("QNearFieldTarget*");
+ qRegisterMetaType<QNdefMessage>();
+ qRegisterMetaType<QNearFieldTarget *>();
}
void tst_QNearFieldTagType2::init()
diff --git a/tests/bttestui/Button.qml b/tests/bttestui/Button.qml
index 03903fd0..e3b0106d 100644
--- a/tests/bttestui/Button.qml
+++ b/tests/bttestui/Button.qml
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/tests/bttestui/btlocaldevice.cpp b/tests/bttestui/btlocaldevice.cpp
index fcc0494a..fbb1e59d 100644
--- a/tests/bttestui/btlocaldevice.cpp
+++ b/tests/bttestui/btlocaldevice.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/tests/bttestui/btlocaldevice.h b/tests/bttestui/btlocaldevice.h
index 5112d142..f3f519ca 100644
--- a/tests/bttestui/btlocaldevice.h
+++ b/tests/bttestui/btlocaldevice.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/tests/bttestui/main.cpp b/tests/bttestui/main.cpp
index 6543bd7b..a5d8a3bf 100644
--- a/tests/bttestui/main.cpp
+++ b/tests/bttestui/main.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/tests/bttestui/main.qml b/tests/bttestui/main.qml
index caae54fa..ddf55d02 100644
--- a/tests/bttestui/main.qml
+++ b/tests/bttestui/main.qml
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$