Home · All Namespaces · All Classes · Grouped Classes · Modules · Functions |
The QObexPushService class provides an OBEX Push service. More...
#include <QObexPushService>
Inherits QObject.
Inherited by DefaultObexPushService.
The QObexPushService class provides an OBEX Push service.
The QObexPushService class can be used to provide OBEX Push services over Bluetooth, Infrared or any other OBEX capable transport. This class implements the Bluetooth Object Push Profile, and can also be used to implement the Infrared IrXfer service.
If you want to control whether an incoming file should be accepted, subclass QObexPushService and override the acceptFile() function. Subclasses can also override businessCard() to provide the default business card object that may be requested by an OBEX Push client.
When an OBEX client sends a file to the service, the acceptFile() function is called to determine whether the file transfer should be allowed. If the transfer is accepted, the putRequested() signal is emitted with the details of the incoming file, and the dataTransferProgress() signal will be emitted at intervals to show the progress of the file transfer operation. The requestFinished() signal is emitted when the transfer is complete.
Similarly, when an OBEX client requests the default business card, the businessCardRequested() signal is emitted, and the dataTransferProgress() signal will be emitted at intervals. The requestFinished() signal is emitted when the transfer is complete.
Finally, the done() signal is emitted when the OBEX client disconnects or if the connection is terminated.
You should ensure that the QIODevice provided in the constructor emits QIODevice::aboutToClose() or QObject::destroyed() when the associated transport connection is disconnected. If one of these signals are emitted, QObexPushService will know the transport connection has been lost, and will emit done() (and also requestFinished() if a Put or Get request is in progress) with error set to true, and error() will return ConnectionError.
This is particularly an issue for socket classes such as QTcpSocket that do not emit QIODevice::aboutToClose() when a disconnected() signal is emitted. In these cases, QObexPushService will not know that the transport has been disconnected. To avoid this, you can make the socket emit QIODevice::aboutToClose() when it is disconnected:
// make the socket emit aboutToClose() when disconnected() is emitted
QObject::connect(socket, SIGNAL(disconnected()), socket, SIGNAL(aboutToClose()));
Or, if the socket can be discarded as soon as it is disconnected:
// delete the socket when the transport is disconnected
QObject::connect(socket, SIGNAL(disconnected()), socket, SLOT(deleteLater()));
Defines the possible errors for a push service.
Constant | Value | Description |
---|---|---|
QObexPushService::NoError | 0 | No error has occurred. |
QObexPushService::ConnectionError | 1 | The client is unable to send data, or the client-server communication process is otherwise disrupted. If this happens, the state will change to QObexPushService::Closed. |
QObexPushService::Aborted | 2 | The request was aborted (either by the client, or by a call to abort()). |
QObexPushService::UnknownError | 100 | An error other than those specified above occurred. |
Defines the possible states for a push service.
Constant | Value | Description |
---|---|---|
QObexPushService::Ready | 0 | The service is ready to receive requests from an OBEX client. This is the default state. |
QObexPushService::Connecting | 1 | A client is connecting. |
QObexPushService::Disconnecting | 2 | A client is disconnecting. |
QObexPushService::Streaming | 3 | A file transfer operation is in progress. |
QObexPushService::Closed | 100 | The service has been closed and cannot process any more requests. The service will change to this state if a client sends a Disconnect command, or a ConnectionError occurs. |
Constructs an OBEX Push service that uses device for the transport connection. The parent is the QObject parent.
The device must be opened, or else the service will be unable to receive any client requests.
Destroys the service.
Aborts the current client request if a Put or Get request is in progress. If the request was successfully aborted, requestFinished() will be emitted with error set to true and error() will return QObexPushService::Aborted.
Due to timing issues, the request may finish before it can be aborted, in which case requestFinished() is emitted normally.
Called when a client makes a Put request to send a file to this service. The name, type, size and description parameters respectively hold the name, MIME type, size and description of the file, as sent by the client. The size will be 0 if the client did not send any information about the size of the file.
This function can be overridden to intercept the request and determine whether the request should be allowed to continue (for example, by asking the end user, or by checking some file threshold) and where the file data should be saved. To allow the request, return a QIODevice pointer, and the received file data will be written to this QIODevice. To refuse the request, return 0.
If the request is allowed to continue, the putRequested() signal is emitted, and the requestFinished() signal will be emitted when the the request has finished. The returned QIODevice pointer is accessible from currentDevice().
The default implementation attempts to save the incoming file into QDir::homePath(), using name as the name of the file. (If name contains a path, only the filename at the end of the path will be used, and if name is an empty string, the file will be saved as "received_file".) If the file is successfully created, the Put request will be accepted; otherwise, the request will be refused.
See also putRequested(), currentDevice(), dataTransferProgress(), and requestFinished().
Returns the business card that will be sent to OBEX clients who request it, as per the Business Card exchange feature of the Bluetooth Object Push Profile.
See also setBusinessCard().
This signal is emitted when an OBEX client has requested the business card from the service, and businessCard() returns a non-empty QByteArray. (If businessCard() returns an empty QByteArray, the signal is not emitted.)
The requestFinished() signal is emitted when the request is completed.
See also setBusinessCard() and businessCard().
If a Put request is in progress, this function returns the QIODevice pointer that is used to store the data from the request. If there is no Put request in progress, this function returns 0.
This function can be used to delete the QIODevice in the slot connected to the requestFinished() signal.
See also acceptFile().
This signal is emitted during file transfer operations to indicate the progress of the transfer. The done value is the number of bytes that have been sent or received so far, and total is the total number of bytes to be sent or received.
If the total number of bytes is not known, total will be 0.
This signal is emitted when the OBEX client has disconnected from the service or if the connection has been terminated. The error value is true if an error occurred during the processing; otherwise error is false.
Returns the error for the last completed request.
This signal is emitted when an OBEX client has made a Put request to the service and acceptFile() has accepted the request. The name, type, size and description parameters respectively hold the name, MIME type, size and description of the file, as sent by the client. The size will be 0 if the client did not send any information about the size of the file.
The requestFinished() signal is emitted when the Put request is completed.
See also currentDevice().
This signal is emitted when a client Put or Get request is completed. The error value is true if an error occurred during the request; otherwise error is false.
Returns the device used by this OBEX Push server session, as provided in the constructor.
Sets vCard to be the business card (in vCard format) that will be sent to OBEX clients who request it, as per the Business Card exchange feature of the Bluetooth Object Push Profile.
If no business card is set, this service will refuse all client requests for business cards.
See also businessCard().
Returns the current state of the service.
This signal is emitted when the state of the service changes. The state is the new state of the client.
Copyright © 2009 Nokia | Trademarks | Qt Extended 4.4.3 |