diff options
-rw-r--r-- | examples/bluetooth/btfiletransfer/remoteselector.cpp | 2 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothtransfermanager.cpp | 11 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothtransfermanager.h | 5 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothtransfermanager_bluez.cpp | 6 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothtransferreply.cpp | 73 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothtransferreply.h | 12 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothtransferreply_bluez.cpp | 25 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothtransferreply_bluez_p.h | 19 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothtransferreply_p.h | 4 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothtransferrequest.h | 3 |
10 files changed, 43 insertions, 117 deletions
diff --git a/examples/bluetooth/btfiletransfer/remoteselector.cpp b/examples/bluetooth/btfiletransfer/remoteselector.cpp index 423e3e55..f75a70fe 100644 --- a/examples/bluetooth/btfiletransfer/remoteselector.cpp +++ b/examples/bluetooth/btfiletransfer/remoteselector.cpp @@ -228,7 +228,7 @@ void RemoteSelector::on_sendButton_clicked() return; } - connect(reply, SIGNAL(uploadProgress(qint64,qint64)), p, SLOT(uploadProgress(qint64,qint64))); + connect(reply, SIGNAL(transferProgress(qint64,qint64)), p, SLOT(uploadProgress(qint64,qint64))); connect(reply, SIGNAL(finished(QBluetoothTransferReply*)), p, SLOT(finished(QBluetoothTransferReply*))); connect(p, SIGNAL(rejected()), reply, SLOT(abort())); } diff --git a/src/bluetooth/qbluetoothtransfermanager.cpp b/src/bluetooth/qbluetoothtransfermanager.cpp index 1e8397f1..d1067731 100644 --- a/src/bluetooth/qbluetoothtransfermanager.cpp +++ b/src/bluetooth/qbluetoothtransfermanager.cpp @@ -50,16 +50,7 @@ QT_BEGIN_NAMESPACE_BLUETOOTH \brief The QBluetoothTransferManager class transfers data to another device using Object Push Profile (OPP). - QBluetoothTransferManager uses OBEX to send get and put commands to remote devices. -*/ - -/*! - \enum QBluetoothTransferManager::Operation - - This enum describes the type of operation that a transfer request is for. - - \value GetOperation The get operation is used to retrieve an object from a remote device. Not implemented. - \value PutOperation The put operation is used to send an object to a remote device. + QBluetoothTransferManager uses OBEX to send put commands to remote devices. */ /*! diff --git a/src/bluetooth/qbluetoothtransfermanager.h b/src/bluetooth/qbluetoothtransfermanager.h index 7e0c4b55..1ede6f41 100644 --- a/src/bluetooth/qbluetoothtransfermanager.h +++ b/src/bluetooth/qbluetoothtransfermanager.h @@ -60,11 +60,6 @@ class Q_BLUETOOTH_EXPORT QBluetoothTransferManager : public QObject Q_OBJECT public: - enum Operation { - GetOperation, - PutOperation - }; - explicit QBluetoothTransferManager(QObject *parent = 0); ~QBluetoothTransferManager(); diff --git a/src/bluetooth/qbluetoothtransfermanager_bluez.cpp b/src/bluetooth/qbluetoothtransfermanager_bluez.cpp index f7e7aec9..5bb0b956 100644 --- a/src/bluetooth/qbluetoothtransfermanager_bluez.cpp +++ b/src/bluetooth/qbluetoothtransfermanager_bluez.cpp @@ -50,14 +50,10 @@ QBluetoothTransferReply *QBluetoothTransferManager::put(const QBluetoothTransfer QIODevice *data) { - QBluetoothTransferReplyBluez *rep = new QBluetoothTransferReplyBluez(data); - - rep->setAddress(request.address()); + QBluetoothTransferReplyBluez *rep = new QBluetoothTransferReplyBluez(data, request); connect(rep, SIGNAL(finished(QBluetoothTransferReply*)), this, SIGNAL(finished(QBluetoothTransferReply*))); - rep->start(); - return rep; } diff --git a/src/bluetooth/qbluetoothtransferreply.cpp b/src/bluetooth/qbluetoothtransferreply.cpp index 7f3a3e88..e2903dae 100644 --- a/src/bluetooth/qbluetoothtransferreply.cpp +++ b/src/bluetooth/qbluetoothtransferreply.cpp @@ -55,18 +55,8 @@ QT_BEGIN_NAMESPACE_BLUETOOTH In additional to a copy of the QBluetoothTransferRequest object used to create the request, QBluetoothTransferReply contains the contents of the reply itself. - QBluetoothTransferReply is a sequential-access QIODevice, which means that once data is read - from the object, it is no longer kept by the device. It is the application's - responsibility to keep this data if it needs to. Whenever more data is received and processed, - the readyRead() signal is emitted. - - The downloadProgress() signal is also emitted when data is received, but the number of bytes - contained in it may not represent the actual bytes received, if any transformation is done to - the contents (for example, decompressing and removing the protocol overhead). - - Even though QBluetoothTransferReply is a QIODevice connected to the contents of the reply, it - emits the uploadProgress() signal, which indicates the progress of the upload for - operations that have such content. + After the file transfer has started, QBluetoothTransferReply emits the transferProgress() signal, + which indicates the progress of the file transfer. */ /*! @@ -94,30 +84,23 @@ void QBluetoothTransferReply::abort() } /*! - \fn void QBluetoothTransferReply::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) - - This signal is emitted whenever data is received. The \a bytesReceived parameter contains the - total number of bytes received so far out of \a bytesTotal expected for the entire transfer. -*/ - -/*! \fn void QBluetoothTransferReply::finished(QBluetoothTransferReply *reply) This signal is emitted when the transfer is complete for \a reply. */ /*! - \fn void QBluetoothTransferReply::uploadProgress(qint64 bytesSent, qint64 bytesTotal) + \fn void QBluetoothTransferReply::transferProgress(qint64 bytesTransferred, qint64 bytesTotal) - This signal is emitted whenever data is sent. The \a bytesSent parameter contains the total - number of bytes sent so far out of \a bytesTotal. + This signal is emitted whenever data is transferred. The \a bytesTransferred parameter contains the total + number of bytes transferred so far out of \a bytesTotal. */ /*! Constructs a new QBluetoothTransferReply with \a parent. */ QBluetoothTransferReply::QBluetoothTransferReply(QObject *parent) -: QObject(parent), d_ptr(new QBluetoothTransferReplyPrivate) + : QObject(parent), d_ptr(new QBluetoothTransferReplyPrivate()) { qRegisterMetaType<QBluetoothTransferReply*>("QBluetoothTransferReply"); } @@ -131,16 +114,6 @@ QBluetoothTransferReply::~QBluetoothTransferReply() } /*! - Returns the attribute associated with \a code. If the attribute has not been set, it - returns an invalid QVariant. -*/ -QVariant QBluetoothTransferReply::attribute(QBluetoothTransferRequest::Attribute code) const -{ - Q_D(const QBluetoothTransferReply); - return d->m_attributes[code]; -} - -/*! \fn bool QBluetoothTransferReply::isFinished() const Returns true if this reply has finished, otherwise false. @@ -163,44 +136,36 @@ QBluetoothTransferManager *QBluetoothTransferReply::manager() const } /*! - Returns the type of operation that this reply is for. + Returns the QBluetoothTransferRequest that was used to create this QBluetoothTransferReply + object. */ -QBluetoothTransferManager::Operation QBluetoothTransferReply::operation() const +QBluetoothTransferRequest QBluetoothTransferReply::request() const { Q_D(const QBluetoothTransferReply); - return d->m_operation; + return d->m_request; } /*! - Sets the operation of this QBluetoothTransferReply to \a operation. -*/ -void QBluetoothTransferReply::setOperation(QBluetoothTransferManager::Operation operation) -{ - Q_D(QBluetoothTransferReply); - d->m_operation = operation; -} - -/*! - \fn QBluetoothTransferReply::setAttribute(QBluetoothTransferRequest::Attribute code, const QVariant &value) + \fn QBluetoothTransferReply::setManager(QBluetoothTransferManager *manager) - Set the attribute associated with the \a code to \a value. + Set the reply's manager to the \a manager. */ -void QBluetoothTransferReply::setAttribute(QBluetoothTransferRequest::Attribute code, const QVariant &value) + +void QBluetoothTransferReply::setManager(QBluetoothTransferManager *manager) { Q_D(QBluetoothTransferReply); - d->m_attributes.insert(code, value); + d->m_manager = manager; } /*! - \fn QBluetoothTransferReply::setManager(QBluetoothTransferManager *manager) + \fn QBluetoothTransferReply::setRequest(const QBluetoothTransferRequest &request) - Set the reply's manager to the \a manager. + Set the reply's request to \a request. */ - -void QBluetoothTransferReply::setManager(QBluetoothTransferManager *manager) +void QBluetoothTransferReply::setRequest(const QBluetoothTransferRequest &request) { Q_D(QBluetoothTransferReply); - d->m_manager = manager; + d->m_request = request; } /*! diff --git a/src/bluetooth/qbluetoothtransferreply.h b/src/bluetooth/qbluetoothtransferreply.h index 00469881..f9200c05 100644 --- a/src/bluetooth/qbluetoothtransferreply.h +++ b/src/bluetooth/qbluetoothtransferreply.h @@ -67,31 +67,27 @@ public: ~QBluetoothTransferReply(); - QVariant attribute(QBluetoothTransferRequest::Attribute code) const; virtual bool isFinished() const = 0; virtual bool isRunning() const = 0; QBluetoothTransferManager *manager() const; - QBluetoothTransferManager::Operation operation() const; - virtual TransferError error() const = 0; virtual QString errorString() const = 0; + QBluetoothTransferRequest request() const; + public Q_SLOTS: void abort(); Q_SIGNALS: - void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); void finished(QBluetoothTransferReply *); - void uploadProgress(qint64 bytesSent, qint64 bytesTotal); + void transferProgress(qint64 bytesTransferred, qint64 bytesTotal); protected: explicit QBluetoothTransferReply(QObject *parent = 0); - void setAttribute(QBluetoothTransferRequest::Attribute code, const QVariant &value); - void setOperation(QBluetoothTransferManager::Operation operation); void setManager(QBluetoothTransferManager *manager); -// void setRequest(QBluetoothTransferRequest *request); + void setRequest(const QBluetoothTransferRequest &request); protected: QBluetoothTransferReplyPrivate *d_ptr; diff --git a/src/bluetooth/qbluetoothtransferreply_bluez.cpp b/src/bluetooth/qbluetoothtransferreply_bluez.cpp index 3e270d96..c8797894 100644 --- a/src/bluetooth/qbluetoothtransferreply_bluez.cpp +++ b/src/bluetooth/qbluetoothtransferreply_bluez.cpp @@ -57,11 +57,13 @@ static const QLatin1String agentPath("/qt/agent"); QT_BEGIN_NAMESPACE_BLUETOOTH -QBluetoothTransferReplyBluez::QBluetoothTransferReplyBluez(QIODevice *input, QObject *parent) +QBluetoothTransferReplyBluez::QBluetoothTransferReplyBluez(QIODevice *input, const QBluetoothTransferRequest &request, + QObject *parent) : QBluetoothTransferReply(parent), tempfile(0), source(input), m_running(false), m_finished(false), m_size(0), m_error(QBluetoothTransferReply::NoError), m_errorStr(), m_transfer_path() { + setRequest(request); client = new OrgOpenobexClientInterface(QLatin1String("org.openobex.client"), QLatin1String("/"), QDBusConnection::sessionBus()); @@ -78,6 +80,8 @@ QBluetoothTransferReplyBluez::QBluetoothTransferReplyBluez(QIODevice *input, QOb // res = QDBusConnection::sessionBus().registerService("org.qt.bt"); if(!res) qDebug() << "Failed Creating dbus objects"; + + QMetaObject::invokeMethod(this, "start", Qt::QueuedConnection); } /*! @@ -141,7 +145,7 @@ void QBluetoothTransferReplyBluez::startOPP(QString filename) QVariantMap device; QStringList files; - device.insert(QString::fromLatin1("Destination"), address.toString()); + device.insert(QString::fromLatin1("Destination"), request().address().toString()); files << filename; QDBusObjectPath path(m_agent_path); @@ -209,7 +213,7 @@ void QBluetoothTransferReplyBluez::Error(const QDBusObjectPath &in0, const QStri void QBluetoothTransferReplyBluez::Progress(const QDBusObjectPath &in0, qulonglong in1) { Q_UNUSED(in0); - emit uploadProgress(in1, m_size); + emit transferProgress(in1, m_size); } void QBluetoothTransferReplyBluez::Release() @@ -255,21 +259,6 @@ void QBluetoothTransferReplyBluez::abort() } } -void QBluetoothTransferReplyBluez::setAddress(const QBluetoothAddress &destination) -{ - address = destination; -} - -qint64 QBluetoothTransferReplyBluez::readData(char*, qint64) -{ - return 0; -} - -qint64 QBluetoothTransferReplyBluez::writeData(const char*, qint64) -{ - return 0; -} - #include "moc_qbluetoothtransferreply_bluez_p.cpp" QT_END_NAMESPACE_BLUETOOTH diff --git a/src/bluetooth/qbluetoothtransferreply_bluez_p.h b/src/bluetooth/qbluetoothtransferreply_bluez_p.h index a3556bea..941b024c 100644 --- a/src/bluetooth/qbluetoothtransferreply_bluez_p.h +++ b/src/bluetooth/qbluetoothtransferreply_bluez_p.h @@ -61,27 +61,22 @@ class Q_BLUETOOTH_EXPORT QBluetoothTransferReplyBluez : public QBluetoothTransfe Q_OBJECT public: - explicit QBluetoothTransferReplyBluez(QIODevice *input, QObject *parent = 0); + explicit QBluetoothTransferReplyBluez(QIODevice *input, const QBluetoothTransferRequest &request, + QObject *parent = 0); ~QBluetoothTransferReplyBluez(); - QVariant attribute(QBluetoothTransferRequest::Attribute code) const; bool isFinished() const; bool isRunning() const; - bool start(); - - void startOPP(QString filename); - - void setAddress(const QBluetoothAddress &address); - QBluetoothTransferReply::TransferError error() const; QString errorString() const; -protected: - qint64 readData(char*, qint64); - qint64 writeData(const char*, qint64); +private Q_SLOTS: + bool start(); private: + void startOPP(QString filename); + OrgOpenobexClientInterface *client; OrgOpenobexManagerInterface *manager; AgentAdaptor *agent; @@ -94,8 +89,6 @@ private: quint64 m_size; - QBluetoothAddress address; - QBluetoothTransferReply::TransferError m_error; QString m_errorStr; diff --git a/src/bluetooth/qbluetoothtransferreply_p.h b/src/bluetooth/qbluetoothtransferreply_p.h index 0f28b47c..71a3e474 100644 --- a/src/bluetooth/qbluetoothtransferreply_p.h +++ b/src/bluetooth/qbluetoothtransferreply_p.h @@ -52,10 +52,10 @@ public: QBluetoothTransferReplyPrivate(); QBluetoothTransferManager *m_manager; - QBluetoothTransferManager::Operation m_operation; - QMap<int, QVariant> m_attributes; qint64 m_buffersize; + QBluetoothTransferRequest m_request; + QBluetoothTransferReply *q_ptr; }; diff --git a/src/bluetooth/qbluetoothtransferrequest.h b/src/bluetooth/qbluetoothtransferrequest.h index 8b6b7e09..0d4c7f88 100644 --- a/src/bluetooth/qbluetoothtransferrequest.h +++ b/src/bluetooth/qbluetoothtransferrequest.h @@ -43,6 +43,7 @@ #define QBLUETOOTHTRANSFERREQUEST_H #include <QtBluetooth/qbluetoothglobal.h> +#include <QtBluetooth/QBluetoothAddress> #include <QtCore/QtGlobal> #include <QtCore/QVariant> @@ -63,7 +64,7 @@ public: NameAttribute }; - QBluetoothTransferRequest(const QBluetoothAddress &address); + QBluetoothTransferRequest(const QBluetoothAddress &address = QBluetoothAddress()); QBluetoothTransferRequest(const QBluetoothTransferRequest &other); ~QBluetoothTransferRequest(); |