summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2014-04-11 14:01:34 +0200
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2014-04-11 14:01:34 +0200
commit347afa3ec58f82da2e4059c1241f3fdd8c5ad2e7 (patch)
tree2a8916afbb3731e0247cff862b73aa44c4e55fc5 /src
parentabbcb33f41117d4bf8178b87080acb34d16224f9 (diff)
parent2e0f7adbe4257cc3914db0b4a9e6f42cb12f948d (diff)
Merge remote-tracking branch 'origin/stable' into dev
Diffstat (limited to 'src')
-rw-r--r--src/bluetooth/doc/src/bluetooth-index.qdoc22
-rw-r--r--src/bluetooth/doc/src/examples.qdoc14
-rw-r--r--src/bluetooth/qbluetoothtransferreply.cpp2
-rw-r--r--src/bluetooth/qbluetoothtransferreply.h4
-rw-r--r--src/bluetooth/qbluetoothtransferreply_bluez.cpp11
-rw-r--r--src/bluetooth/qbluetoothtransferreply_qnx.cpp70
-rw-r--r--src/bluetooth/qbluetoothtransferreply_qnx_p.h11
-rw-r--r--src/nfc/doc/src/nfc-index.qdoc9
8 files changed, 101 insertions, 42 deletions
diff --git a/src/bluetooth/doc/src/bluetooth-index.qdoc b/src/bluetooth/doc/src/bluetooth-index.qdoc
index cde64891..fe9322e9 100644
--- a/src/bluetooth/doc/src/bluetooth-index.qdoc
+++ b/src/bluetooth/doc/src/bluetooth-index.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the documentation of the Qt Toolkit.
@@ -29,15 +29,21 @@
\page qtbluetooth-index.html
\title Qt Bluetooth
\brief Qt Bluetooth enables connectivity between Bluetooth enabled devices.
+\ingroup technology-apis
+
+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}).
+
+\section1 Overview
Bluetooth is a short-range (less than 100 meters) wireless technology. It
has a reasonably high data transfer rate of 2.1 Mbit/s, which makes it ideal
-for transferring data between devices. Currently the API is supported on
-Linux (Bluez 4.x), Android and BlackBerry 10.
-
-Bluetooth connectivity is based on basic device management, such as scanning
-for devices, gathering information about them, and exchanging data between
-them.
+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.
\section1 Getting started
@@ -70,12 +76,12 @@ import statement in your \c .qml file:
\list
\li \l {scanner}{QML Bluetooth Scanner}
\li \l {picturetransfer}{QML Bluetooth Picture Push}
+ \li \l {pingpong}{QML Bluetooth PingPong}
\endlist
\li C++
\list
\li \l {btchat}{Bluetooth Chat}
\li \l {btscanner}{Bluetooth Scanner}
- \li \l {bttennis}{Bluetooth Tennis}
\li \l {btfiletransfer}{Bluetooth File Transfer}
\endlist
\endlist
diff --git a/src/bluetooth/doc/src/examples.qdoc b/src/bluetooth/doc/src/examples.qdoc
index d6b73ae8..f9965075 100644
--- a/src/bluetooth/doc/src/examples.qdoc
+++ b/src/bluetooth/doc/src/examples.qdoc
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the documentation of the Qt local connectivty modules.
+** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
@@ -45,9 +45,8 @@
\li Example
\li Description
\row
- \li \l{bttennis}{Bluetooth Tennis}
- \li The classic game of \l {http://en.wikipedia.org/wiki/Pong}{Pong}. Supports multiplayer
- over Bluetooth and touch-to-play functionality on devices that support NFC.
+ \li \l{btchat}{Bluetooth Chat}
+ \li Simple chat server and client via Bluetooth.
\row
\li \l{btfiletransfer}{Bluetooth File Transfer}
\li Transfer files between Bluetooth devices.
@@ -62,9 +61,8 @@
\li Example
\li Description
\row
- \li \l{bttennis}{QML Bluetooth Tennis}
- \li The tennis game using a QML interface to the Bluetooth API. It
- must connect to an instance of the C++ \l{bttennis}{Bluetooth Tennis} game to play.
+ \li \l{pingpong}{QML Bluetooth PingPong}
+ \li A QML ping pong game demonstrating Bluetooth socket communication between two devices.
\row
\li \l{scanner}{QML Bluetooth Scanner}
\li A QML implementation of the Bluetooth device scanner.
diff --git a/src/bluetooth/qbluetoothtransferreply.cpp b/src/bluetooth/qbluetoothtransferreply.cpp
index ae97c639..9acd917d 100644
--- a/src/bluetooth/qbluetoothtransferreply.cpp
+++ b/src/bluetooth/qbluetoothtransferreply.cpp
@@ -68,6 +68,8 @@ QT_BEGIN_NAMESPACE
\value FileNotFoundError Unable to open the file specified
\value HostNotFoundError Unable to connect to the target host
\value UserCanceledTransferError User terminated the transfer
+ \value IODeviceNotReadableError File was not open before initiating the sending command
+ \value ResourceBusyError Unable to access the resource.
*/
diff --git a/src/bluetooth/qbluetoothtransferreply.h b/src/bluetooth/qbluetoothtransferreply.h
index 42571ca4..33910fd9 100644
--- a/src/bluetooth/qbluetoothtransferreply.h
+++ b/src/bluetooth/qbluetoothtransferreply.h
@@ -61,7 +61,9 @@ public:
UnknownError,
FileNotFoundError,
HostNotFoundError,
- UserCanceledTransferError
+ UserCanceledTransferError,
+ IODeviceNotReadableError,
+ ResourceBusyError
};
diff --git a/src/bluetooth/qbluetoothtransferreply_bluez.cpp b/src/bluetooth/qbluetoothtransferreply_bluez.cpp
index 8b271789..f0b4b5c2 100644
--- a/src/bluetooth/qbluetoothtransferreply_bluez.cpp
+++ b/src/bluetooth/qbluetoothtransferreply_bluez.cpp
@@ -104,6 +104,15 @@ bool QBluetoothTransferReplyBluez::start()
tempfile = new QTemporaryFile(this );
tempfile->open();
qCDebug(QT_BT_BLUEZ) << "Not a QFile, making a copy" << tempfile->fileName();
+ if (!source->isReadable()) {
+ m_errorStr = QBluetoothTransferReply::tr("QIODevice cannot be read."
+ "Make sure it is open for reading.");
+ m_error = QBluetoothTransferReply::IODeviceNotReadableError;
+ m_finished = true;
+ m_running = false;
+ QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection, Q_ARG(QBluetoothTransferReply*, this));
+ return false;
+ }
QFutureWatcher<bool> *watcher = new QFutureWatcher<bool>();
QObject::connect(watcher, SIGNAL(finished()), this, SLOT(copyDone()));
@@ -139,7 +148,7 @@ bool QBluetoothTransferReplyBluez::copyToTempFile(QIODevice *to, QIODevice *from
char *block = new char[4096];
int size;
- while((size = from->read(block, 4096))) {
+ while ((size = from->read(block, 4096)) > 0) {
if(size != to->write(block, size)){
return false;
}
diff --git a/src/bluetooth/qbluetoothtransferreply_qnx.cpp b/src/bluetooth/qbluetoothtransferreply_qnx.cpp
index bc15fbde..3f22d536 100644
--- a/src/bluetooth/qbluetoothtransferreply_qnx.cpp
+++ b/src/bluetooth/qbluetoothtransferreply_qnx.cpp
@@ -56,8 +56,11 @@
#include <QtCore/private/qcore_unix_p.h>
#include <QTime>
+#include <QDir>
+#include <QCoreApplication>
-//static const QLatin1String agentPath("/shared/tmp/opp");
+static const QString agentPath(QStringLiteral("/accounts/1000/shared/misc/"));
+static bool busy;
QT_BEGIN_NAMESPACE
@@ -69,7 +72,6 @@ QBluetoothTransferReplyQnx::QBluetoothTransferReplyQnx(QIODevice *input, const Q
{
setRequest(request);
setManager(parent);
-
ppsRegisterControl();
//qsrand(QTime::currentTime().msec());
//m_agent_path = agentPath;
@@ -87,6 +89,8 @@ QBluetoothTransferReplyQnx::QBluetoothTransferReplyQnx(QIODevice *input, const Q
*/
QBluetoothTransferReplyQnx::~QBluetoothTransferReplyQnx()
{
+ removeTempFile();
+ delete tempfile;
ppsUnregisterControl(this);
}
@@ -98,19 +102,39 @@ bool QBluetoothTransferReplyQnx::start()
QFile *file = qobject_cast<QFile *>(source);
if (!file){
-// tempfile = new QTemporaryFile(this );
-// tempfile->open();
-
-// QFutureWatcher<bool> *watcher = new QFutureWatcher<bool>();
-// QObject::connect(watcher, SIGNAL(finished()), this, SLOT(copyDone()));
+ // Deleting temporary files in case of app crash
+ QDir directory(agentPath);
+ QString appName = QStringLiteral("Qt5OPP_tmp") + QCoreApplication::applicationName();
+ if (directory.exists(appName) && !busy) {
+ QFile file(agentPath + appName);
+ file.remove();
+ }
+ else if (directory.exists(appName) && busy) {
+ m_errorStr = QBluetoothTransferReply::tr("Resurce busy.");
+ m_error = QBluetoothTransferReply::ResourceBusyError;
+ m_finished = true;
+ m_running = false;
+ Q_EMIT finished(this);
+ return false;
+ }
+ if (!source->isReadable()) {
+ m_errorStr = QBluetoothTransferReply::tr("QIODevice cannot be read."
+ "Make sure it is open for reading.");
+ m_error = QBluetoothTransferReply::IODeviceNotReadableError;
+ m_finished = true;
+ m_running = false;
+ Q_EMIT finished(this);
+ return false;
+ }
+ QString fileName = agentPath + QStringLiteral("Qt5OPP_tmp");
+ tempfile = new QFile(fileName);
+ tempfile->open(QIODevice::WriteOnly);
-// QFuture<bool> results = QtConcurrent::run(QBluetoothTransferReplyQnx::copyToTempFile, tempfile, source);
-// watcher->setFuture(results);
- //QTemporaryFile does not work properly yet
- m_error = QBluetoothTransferReply::UnknownError;
- m_finished = true;
- m_running = false;
- Q_EMIT finished(this);
+ QFutureWatcher<bool> *watcher = new QFutureWatcher<bool>();
+ QObject::connect(watcher, SIGNAL(finished()), this, SLOT(copyDone()));
+ QFuture<bool> results = QtConcurrent::run(QBluetoothTransferReplyQnx::copyToTempFile, tempfile, source);
+ watcher->setFuture(results);
+ busy = true;
} else {
if (!file->exists()) {
@@ -139,7 +163,7 @@ bool QBluetoothTransferReplyQnx::copyToTempFile(QIODevice *to, QIODevice *from)
char *block = new char[4096];
int size;
- while ((size = from->read(block, 4096))) {
+ while ((size = from->read(block, 4096)) > 0) {
if (size != to->write(block, size))
return false;
}
@@ -150,14 +174,14 @@ bool QBluetoothTransferReplyQnx::copyToTempFile(QIODevice *to, QIODevice *from)
void QBluetoothTransferReplyQnx::copyDone()
{
- qCDebug(QT_BT_QNX) << "Copy done";
startOPP(tempfile->fileName());
QObject::sender()->deleteLater();
}
void QBluetoothTransferReplyQnx::startOPP(QString filename)
{
- qCDebug(QT_BT_QNX) << "Sending Push object command";
+ qCDebug(QT_BT_QNX) << "Sending push object command"
+ << request().address().toString() << filename;
ppsSendOpp("push_object", filename.toUtf8(), request().address(), this);
}
@@ -183,6 +207,7 @@ void QBluetoothTransferReplyQnx::controlEvent(ppsResult result)
{
if (result.msg == QStringLiteral("opp_cancelled")) {
qCDebug(QT_BT_QNX) << "opp cancelled" << result.errorMsg << result.error;
+ removeTempFile();
if (m_running)
return;
m_finished = true;
@@ -215,6 +240,7 @@ void QBluetoothTransferReplyQnx::controlEvent(ppsResult result)
Q_EMIT transferProgress(sentBytes, totalBytes);
} else if (result.msg == QStringLiteral("opp_complete")) {
qCDebug(QT_BT_QNX) << "opp complete";
+ removeTempFile();
m_finished = true;
m_running = false;
Q_EMIT finished(this);
@@ -242,6 +268,16 @@ void QBluetoothTransferReplyQnx::abort()
//not supported yet
}
+void QBluetoothTransferReplyQnx::removeTempFile()
+{
+ if (tempfile) {
+ if (tempfile->exists()) {
+ tempfile->remove();
+ busy = false;
+ }
+ }
+}
+
#include "moc_qbluetoothtransferreply_qnx_p.cpp"
QT_END_NAMESPACE
diff --git a/src/bluetooth/qbluetoothtransferreply_qnx_p.h b/src/bluetooth/qbluetoothtransferreply_qnx_p.h
index 4522c8bf..cda01b79 100644
--- a/src/bluetooth/qbluetoothtransferreply_qnx_p.h
+++ b/src/bluetooth/qbluetoothtransferreply_qnx_p.h
@@ -43,18 +43,16 @@
#ifndef QBLUETOOTHTRANSFERREPLY_QNX_P_H
#define QBLUETOOTHTRANSFERREPLY_QNX_P_H
-#include <QtCore/QIODevice>
-
#include <qbluetoothtransferrequest.h>
#include <qbluetoothtransfermanager.h>
#include "qbluetoothtransferreply.h"
-#include <QTemporaryFile>
-#include <QSocketNotifier>
-
#include "qnx/ppshelpers_p.h"
+QT_FORWARD_DECLARE_CLASS(QFile)
+QT_FORWARD_DECLARE_CLASS(QIODevice)
+
QT_BEGIN_NAMESPACE
class Q_BLUETOOTH_EXPORT QBluetoothTransferReplyQnx : public QBluetoothTransferReply
@@ -80,7 +78,8 @@ private Q_SLOTS:
private:
void startOPP(QString filename);
- QTemporaryFile *tempfile;
+ void removeTempFile();
+ QFile *tempfile;
QIODevice *source;
bool m_running;
diff --git a/src/nfc/doc/src/nfc-index.qdoc b/src/nfc/doc/src/nfc-index.qdoc
index 2944a6ab..bd375ea8 100644
--- a/src/nfc/doc/src/nfc-index.qdoc
+++ b/src/nfc/doc/src/nfc-index.qdoc
@@ -1,6 +1,7 @@
/****************************************************************************
**
** 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
**
** This file is part of the documentation of the Qt Toolkit.
@@ -29,6 +30,13 @@
\page qtnfc-index.html
\title Qt NFC
\brief Enables connectivity between NFC enabled devices.
+\ingroup technology-apis
+
+The NFC API provides connectivity between NFC enabled devices.
+
+Currently the API is supported on \l{Qt for BlackBerry}{BlackBerry 10}.
+
+\section1 Overview
NFC is an extremely short-range (less than 20 centimeters) wireless technology and has a
maximum transfer rate of 424 kbit/s. NFC is ideal for transferring small packets of data when two
@@ -38,7 +46,6 @@ The NFC API provides APIs for interacting with NFC Forum Tags and NFC Forum Devi
target detection and loss, registering NDEF message handlers, reading and writing NDEF messages
on NFC Forum Tags and sending tag specific commands.
-Currently the API is supported on BlackBerry 10.
\section1 Getting started