summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-09-16 14:04:02 +0200
committerAlex Blasche <alexander.blasche@digia.com>2014-09-18 10:09:50 +0200
commitea917cfce56186ac7cddddd701cfb83f8127a751 (patch)
tree41ef97aba23df27474ca19322b28f9230588ce47
parente04e8f8aec8afe130427d88a3ae891f0d1bc751f (diff)
Add missing error() signal to QBluetoothTransferReply
The signal makes error handling much more conveniant. One error situation on QNX did not emit the required finished()/errorType() signals when required. A few minor typo fixes. Task-number: QTBUG-38983 Change-Id: I89c3fbee43921c8894a0ab200ee5550e7dc44543 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r--src/bluetooth/qbluetoothtransferreply.cpp17
-rw-r--r--src/bluetooth/qbluetoothtransferreply.h3
-rw-r--r--src/bluetooth/qbluetoothtransferreply_bluez.cpp16
-rw-r--r--src/bluetooth/qbluetoothtransferreply_p.h4
-rw-r--r--src/bluetooth/qbluetoothtransferreply_qnx.cpp7
-rw-r--r--tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp8
6 files changed, 47 insertions, 8 deletions
diff --git a/src/bluetooth/qbluetoothtransferreply.cpp b/src/bluetooth/qbluetoothtransferreply.cpp
index 6ade4808..44f2f6f8 100644
--- a/src/bluetooth/qbluetoothtransferreply.cpp
+++ b/src/bluetooth/qbluetoothtransferreply.cpp
@@ -90,12 +90,23 @@ void QBluetoothTransferReply::abort()
*/
/*!
+ \fn void QBluetoothTransferReply::error(QBluetoothTransferReply::TransferError errorType)
+ \since 5.4
+
+ This signal is emitted whenever an error has occurred. The \a errorType
+ parameter indicates the type of error.
+
+ \sa error(), errorString()
+*/
+
+/*!
Constructs a new QBluetoothTransferReply with \a parent.
*/
QBluetoothTransferReply::QBluetoothTransferReply(QObject *parent)
: QObject(parent), d_ptr(new QBluetoothTransferReplyPrivate())
{
- qRegisterMetaType<QBluetoothTransferReply*>("QBluetoothTransferReply");
+ qRegisterMetaType<QBluetoothTransferReply*>();
+ qRegisterMetaType<QBluetoothTransferReply::TransferError>();
}
/*!
@@ -165,12 +176,16 @@ void QBluetoothTransferReply::setRequest(const QBluetoothTransferRequest &reques
\fn TransferError QBluetoothTransferReply::error() const
The error code of the error that occurred.
+
+ \sa errorString()
*/
/*!
\fn QString QBluetoothTransferReply::errorString() const
String describing the error. Can be displayed to the user.
+
+ \sa error()
*/
QBluetoothTransferReplyPrivate::QBluetoothTransferReplyPrivate()
diff --git a/src/bluetooth/qbluetoothtransferreply.h b/src/bluetooth/qbluetoothtransferreply.h
index a8fda6ce..37ca8fe5 100644
--- a/src/bluetooth/qbluetoothtransferreply.h
+++ b/src/bluetooth/qbluetoothtransferreply.h
@@ -79,6 +79,7 @@ Q_SIGNALS:
//TODO Remove QBluetoothTransferReply* parameter in Qt 6
void finished(QBluetoothTransferReply *);
void transferProgress(qint64 bytesTransferred, qint64 bytesTotal);
+ void error(QBluetoothTransferReply::TransferError lastError);
protected:
explicit QBluetoothTransferReply(QObject *parent = 0);
@@ -95,4 +96,6 @@ private:
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QBluetoothTransferReply::TransferError)
+
#endif // QBLUETOOTHTRANSFERREPLY_H
diff --git a/src/bluetooth/qbluetoothtransferreply_bluez.cpp b/src/bluetooth/qbluetoothtransferreply_bluez.cpp
index be5fccd0..066cab7c 100644
--- a/src/bluetooth/qbluetoothtransferreply_bluez.cpp
+++ b/src/bluetooth/qbluetoothtransferreply_bluez.cpp
@@ -69,8 +69,6 @@ QBluetoothTransferReplyBluez::QBluetoothTransferReplyBluez(QIODevice *input, con
setRequest(request);
setManager(parent);
- qRegisterMetaType<QBluetoothTransferReply*>("QBluetoothTransferReply*");
-
if (isBluez5()) {
m_clientBluez = new OrgBluezObexClient1Interface(QStringLiteral("org.bluez.obex"),
QStringLiteral("/org/bluez/obex"),
@@ -121,6 +119,8 @@ bool QBluetoothTransferReplyBluez::start()
m_error = QBluetoothTransferReply::IODeviceNotReadableError;
m_finished = true;
m_running = false;
+
+ emit QBluetoothTransferReply::error(m_error);
QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection, Q_ARG(QBluetoothTransferReply*, this));
return false;
}
@@ -137,6 +137,8 @@ bool QBluetoothTransferReplyBluez::start()
m_error = QBluetoothTransferReply::FileNotFoundError;
m_finished = true;
m_running = false;
+
+ emit QBluetoothTransferReply::error(m_error);
QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection, Q_ARG(QBluetoothTransferReply*, this));
return false;
}
@@ -145,6 +147,8 @@ bool QBluetoothTransferReplyBluez::start()
m_error = QBluetoothTransferReply::HostNotFoundError;
m_finished = true;
m_running = false;
+
+ emit QBluetoothTransferReply::error(m_error);
QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection, Q_ARG(QBluetoothTransferReply*, this));
return false;
}
@@ -201,6 +205,8 @@ void QBluetoothTransferReplyBluez::sessionCreated(QDBusPendingCallWatcher *watch
m_error = QBluetoothTransferReply::HostNotFoundError;
m_finished = true;
m_running = false;
+
+ emit QBluetoothTransferReply::error(m_error);
QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection,
Q_ARG(QBluetoothTransferReply*, this));
@@ -232,6 +238,7 @@ void QBluetoothTransferReplyBluez::sessionStarted(QDBusPendingCallWatcher *watch
cleanupSession();
+ emit QBluetoothTransferReply::error(m_error);
QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection,
Q_ARG(QBluetoothTransferReply *, this));
@@ -276,6 +283,8 @@ void QBluetoothTransferReplyBluez::sessionChanged(const QString &interface,
if (s == QStringLiteral("error")) {
m_error = QBluetoothTransferReply::UnknownError;
m_errorStr = tr("Unknown Error");
+
+ emit QBluetoothTransferReply::error(m_error);
} else { // complete
// allow progress bar to complete
emit transferProgress(m_size, m_size);
@@ -336,6 +345,7 @@ void QBluetoothTransferReplyBluez::sendReturned(QDBusPendingCallWatcher *watcher
m_error = QBluetoothTransferReply::UnknownError;
}
+ emit QBluetoothTransferReply::error(m_error);
// allow time for the developer to connect to the signal
QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection, Q_ARG(QBluetoothTransferReply*, this));
}
@@ -376,6 +386,7 @@ void QBluetoothTransferReplyBluez::Error(const QDBusObjectPath &in0, const QStri
m_error = QBluetoothTransferReply::UnknownError;
}
+ emit QBluetoothTransferReply::error(m_error);
emit finished(this);
}
@@ -444,6 +455,7 @@ void QBluetoothTransferReplyBluez::abort()
cleanupSession();
+ emit QBluetoothTransferReply::error(m_error);
emit finished(this);
}
}
diff --git a/src/bluetooth/qbluetoothtransferreply_p.h b/src/bluetooth/qbluetoothtransferreply_p.h
index caf3890d..8c6c4968 100644
--- a/src/bluetooth/qbluetoothtransferreply_p.h
+++ b/src/bluetooth/qbluetoothtransferreply_p.h
@@ -55,12 +55,8 @@ public:
QBluetoothTransferReplyPrivate();
QBluetoothTransferManager *m_manager;
- qint64 m_buffersize;
QBluetoothTransferRequest m_request;
-
- QBluetoothTransferReply *q_ptr;
-
};
QT_END_NAMESPACE
diff --git a/src/bluetooth/qbluetoothtransferreply_qnx.cpp b/src/bluetooth/qbluetoothtransferreply_qnx.cpp
index 072230b1..acd60894 100644
--- a/src/bluetooth/qbluetoothtransferreply_qnx.cpp
+++ b/src/bluetooth/qbluetoothtransferreply_qnx.cpp
@@ -106,6 +106,7 @@ bool QBluetoothTransferReplyQnx::start()
m_error = QBluetoothTransferReply::ResourceBusyError;
m_finished = true;
m_running = false;
+ emit QBluetoothTransferReply::error(m_error);
emit finished(this);
return false;
}
@@ -115,6 +116,7 @@ bool QBluetoothTransferReplyQnx::start()
m_error = QBluetoothTransferReply::IODeviceNotReadableError;
m_finished = true;
m_running = false;
+ emit QBluetoothTransferReply::error(m_error);
emit finished(this);
return false;
}
@@ -134,6 +136,7 @@ bool QBluetoothTransferReplyQnx::start()
m_error = QBluetoothTransferReply::FileNotFoundError;
m_finished = true;
m_running = false;
+ emit QBluetoothTransferReply::error(m_error);
QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection, Q_ARG(QBluetoothTransferReply*, this));
return false;
}
@@ -142,6 +145,7 @@ bool QBluetoothTransferReplyQnx::start()
m_error = QBluetoothTransferReply::HostNotFoundError;
m_finished = true;
m_running = false;
+ emit QBluetoothTransferReply::error(m_error);
QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection, Q_ARG(QBluetoothTransferReply*, this));
return false;
}
@@ -192,6 +196,8 @@ void QBluetoothTransferReplyQnx::controlReply(ppsResult result)
if (!result.errorMsg.isEmpty()) {
m_errorStr = result.errorMsg;
m_error = QBluetoothTransferReply::UnknownError;
+ emit QBluetoothTransferReply::error(m_error);
+ emit finished(this);
}
}
@@ -214,6 +220,7 @@ void QBluetoothTransferReplyQnx::controlEvent(ppsResult result)
// } else {
m_errorStr = result.errorMsg;
m_error = QBluetoothTransferReply::UnknownError;
+ emit QBluetoothTransferReply::error(m_error);
// }
emit finished(this);
} else if (result.msg == QStringLiteral("opp_update")) {
diff --git a/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp b/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp
index 89c70854..b2c55da5 100644
--- a/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp
+++ b/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp
@@ -235,6 +235,7 @@ void tst_QBluetoothTransferManager::tst_sendFile()
QBluetoothTransferReply* reply = manager.put(request, &f);
QSignalSpy finishedSpy(reply, SIGNAL(finished(QBluetoothTransferReply*)));
QSignalSpy progressSpy(reply, SIGNAL(transferProgress(qint64,qint64)));
+ QSignalSpy errorSpy(reply, SIGNAL(error(QBluetoothTransferReply::TransferError)));
QCOMPARE(reply->request(), request);
QVERIFY(reply->manager() == &manager);
@@ -253,6 +254,7 @@ void tst_QBluetoothTransferManager::tst_sendFile()
QVERIFY(progressSpy.count()>0);
QCOMPARE(reply->error(), QBluetoothTransferReply::NoError);
QCOMPARE(reply->errorString(), QString());
+ QVERIFY(errorSpy.isEmpty());
} else {
QVERIFY(progressSpy.count() == 0);
if (isInvalidFile)
@@ -260,6 +262,7 @@ void tst_QBluetoothTransferManager::tst_sendFile()
else
QVERIFY(reply->error() != QBluetoothTransferReply::NoError);
QVERIFY(!reply->errorString().isEmpty());
+ QCOMPARE(errorSpy.count(), 1);
}
QVERIFY(reply->isFinished());
@@ -274,7 +277,7 @@ void tst_QBluetoothTransferManager::tst_sendBuffer_data()
QTest::addColumn<QByteArray>("data");
QTest::newRow("Push to remote test device") << remoteAddress << true <<
- QByteArray("This is a very long byte arry which we are going to access via a QBuffer"); ;
+ QByteArray("This is a very long byte array which we are going to access via a QBuffer"); ;
QTest::newRow("Push to invalid address") << QBluetoothAddress() << false << QByteArray("test");
QTest::newRow("Push to non-existend device") << QBluetoothAddress("11:22:33:44:55:66") << false << QByteArray("test");
}
@@ -310,6 +313,7 @@ void tst_QBluetoothTransferManager::tst_sendBuffer()
QBluetoothTransferReply* reply = manager.put(request, &buffer);
QSignalSpy finishedSpy(reply, SIGNAL(finished(QBluetoothTransferReply*)));
QSignalSpy progressSpy(reply, SIGNAL(transferProgress(qint64,qint64)));
+ QSignalSpy errorSpy(reply, SIGNAL(error(QBluetoothTransferReply::TransferError)));
QCOMPARE(reply->request(), request);
QVERIFY(reply->manager() == &manager);
@@ -326,12 +330,14 @@ void tst_QBluetoothTransferManager::tst_sendBuffer()
QVERIFY(finishedSpy.count()>0);
if (expectSuccess) {
QVERIFY(progressSpy.count()>0);
+ QVERIFY(errorSpy.isEmpty());
QCOMPARE(reply->error(), QBluetoothTransferReply::NoError);
QCOMPARE(reply->errorString(), QString());
} else {
QVERIFY(progressSpy.count() == 0);
QVERIFY(reply->error() != QBluetoothTransferReply::NoError);
QVERIFY(!reply->errorString().isEmpty());
+ QCOMPARE(errorSpy.count(), 1);
}
QVERIFY(reply->isFinished());