diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bluetooth/qbluetoothtransferreply.cpp | 2 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothtransferreply_bluez.cpp | 34 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothtransferreply_qnx.cpp | 8 |
3 files changed, 30 insertions, 14 deletions
diff --git a/src/bluetooth/qbluetoothtransferreply.cpp b/src/bluetooth/qbluetoothtransferreply.cpp index e2903dae..d6bf4dba 100644 --- a/src/bluetooth/qbluetoothtransferreply.cpp +++ b/src/bluetooth/qbluetoothtransferreply.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ - #include "qbluetoothtransferreply.h" #include "qbluetoothtransferreply_p.h" #include "qbluetoothaddress.h" @@ -80,7 +79,6 @@ QT_BEGIN_NAMESPACE_BLUETOOTH */ void QBluetoothTransferReply::abort() { - } /*! diff --git a/src/bluetooth/qbluetoothtransferreply_bluez.cpp b/src/bluetooth/qbluetoothtransferreply_bluez.cpp index c8797894..159fdbcc 100644 --- a/src/bluetooth/qbluetoothtransferreply_bluez.cpp +++ b/src/bluetooth/qbluetoothtransferreply_bluez.cpp @@ -67,9 +67,6 @@ QBluetoothTransferReplyBluez::QBluetoothTransferReplyBluez(QIODevice *input, con client = new OrgOpenobexClientInterface(QLatin1String("org.openobex.client"), QLatin1String("/"), QDBusConnection::sessionBus()); -// manager = new OrgOpenobexManagerInterface(QLatin1String("org.openobex"), QLatin1String("/"), -// QDBusConnection::sessionBus()); - qsrand(QTime::currentTime().msec()); m_agent_path = agentPath; m_agent_path.append(QString::fromLatin1("/%1").arg(qrand())); @@ -77,10 +74,10 @@ QBluetoothTransferReplyBluez::QBluetoothTransferReplyBluez(QIODevice *input, con agent = new AgentAdaptor(this); bool res = QDBusConnection::sessionBus().registerObject(m_agent_path, this); -// res = QDBusConnection::sessionBus().registerService("org.qt.bt"); if(!res) qDebug() << "Failed Creating dbus objects"; + qRegisterMetaType<QBluetoothTransferReply*>("QBluetoothTransferReply*"); QMetaObject::invokeMethod(this, "start", Qt::QueuedConnection); } @@ -97,7 +94,6 @@ bool QBluetoothTransferReplyBluez::start() { m_running = true; -// qDebug() << "Got a:" << source->metaObject()->className(); QFile *file = qobject_cast<QFile *>(source); if(!file){ @@ -112,6 +108,14 @@ bool QBluetoothTransferReplyBluez::start() watcher->setFuture(results); } else { + if (!file->exists()) { + m_errorStr = tr("File does not exist"); + m_error = QBluetoothTransferReply::FileNotFoundError; + m_finished = true; + m_running = false; + QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection, Q_ARG(QBluetoothTransferReply*, this)); + return false; + } m_size = file->size(); startOPP(file->fileName()); } @@ -158,19 +162,20 @@ void QBluetoothTransferReplyBluez::startOPP(QString filename) void QBluetoothTransferReplyBluez::sendReturned(QDBusPendingCallWatcher *watcher) { - QDBusPendingReply<> sendReply = *watcher; if(sendReply.isError()){ - qDebug() << "Failed to send file"<< sendReply.isError() << sendReply.error().message(); m_finished = true; m_running = false; m_errorStr = sendReply.error().message(); - if(m_errorStr == QLatin1String("Could not open file for sending")) + if (m_errorStr == QStringLiteral("Could not open file for sending")) { m_error = QBluetoothTransferReply::FileNotFoundError; - else if(m_errorStr == QLatin1String("The transfer was canceled")) + m_errorStr = tr("Could not open file for sending"); + } else if (m_errorStr == QStringLiteral("The transfer was canceled")) { m_error = QBluetoothTransferReply::UserCanceledTransferError; - else + m_errorStr = tr("The transfer was canceled"); + } else { m_error = QBluetoothTransferReply::UnknownError; + } // allow time for the developer to connect to the signal QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection, Q_ARG(QBluetoothTransferReply*, this)); @@ -202,10 +207,15 @@ void QBluetoothTransferReplyBluez::Error(const QDBusObjectPath &in0, const QStri m_finished = true; m_running = false; m_errorStr = in1; - if (in1 == QLatin1String("Could not open file for sending")) + if (in1 == QStringLiteral("Could not open file for sending")) { m_error = QBluetoothTransferReply::FileNotFoundError; - else + m_errorStr = tr("Could not open file for sending"); + } else if (in1 == QStringLiteral("Operation canceled")) { + m_error = QBluetoothTransferReply::UserCanceledTransferError; + m_errorStr = tr("Operation canceled"); + } else { m_error = QBluetoothTransferReply::UnknownError; + } emit finished(this); } diff --git a/src/bluetooth/qbluetoothtransferreply_qnx.cpp b/src/bluetooth/qbluetoothtransferreply_qnx.cpp index a81a6e8e..f2f60fcd 100644 --- a/src/bluetooth/qbluetoothtransferreply_qnx.cpp +++ b/src/bluetooth/qbluetoothtransferreply_qnx.cpp @@ -109,6 +109,14 @@ bool QBluetoothTransferReplyQnx::start() Q_EMIT finished(this); } else { + if (!file->exists()) { + m_errorStr = tr("File does not exist"); + m_error = QBluetoothTransferReply::FileNotFoundError; + m_finished = true; + m_running = false; + QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection, Q_ARG(QBluetoothTransferReply*, this)); + return false; + } startOPP(file->fileName()); } return true; |