Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QObexPushService Class Reference
[QtBaseModule]

The QObexPushService class provides an OBEX Push service. More...

    #include <QObexPushService>

Inherits QObject.

Inherited by DefaultObexPushService.

Public Types

  • enum Error { NoError, ConnectionError, Aborted, UnknownError }
  • enum State { Ready, Connecting, Disconnecting, Streaming, Closed }

Public Functions

  • 29 public functions inherited from QObject

Public Slots

  • 1 public slot inherited from QObject

Signals

Protected Functions

  • virtual QIODevice * acceptFile ( const QString & name, const QString & type, qint64 size, const QString & description )
  • 7 protected functions inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public type inherited from QObject
  • 4 static public members inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

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.

Handling socket disconnections

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()));

Member Type Documentation

enum QObexPushService::Error

Defines the possible errors for a push service.

ConstantValueDescription
QObexPushService::NoError0No error has occurred.
QObexPushService::ConnectionError1The 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::Aborted2The request was aborted (either by the client, or by a call to abort()).
QObexPushService::UnknownError100An error other than those specified above occurred.

enum QObexPushService::State

Defines the possible states for a push service.

ConstantValueDescription
QObexPushService::Ready0The service is ready to receive requests from an OBEX client. This is the default state.
QObexPushService::Connecting1A client is connecting.
QObexPushService::Disconnecting2A client is disconnecting.
QObexPushService::Streaming3A file transfer operation is in progress.
QObexPushService::Closed100The 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.


Member Function Documentation

QObexPushService::QObexPushService ( QIODevice * device, QObject * parent = 0 )

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.

QObexPushService::~QObexPushService ()

Destroys the service.

void QObexPushService::abort ()   [slot]

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.

QIODevice * QObexPushService::acceptFile ( const QString & name, const QString & type, qint64 size, const QString & description )   [virtual protected]

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().

QByteArray QObexPushService::businessCard () const   [virtual]

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().

void QObexPushService::businessCardRequested ()   [signal]

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().

QIODevice * QObexPushService::currentDevice () const

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().

void QObexPushService::dataTransferProgress ( qint64 done, qint64 total )   [signal]

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.

void QObexPushService::done ( bool error )   [signal]

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.

Error QObexPushService::error () const

Returns the error for the last completed request.

void QObexPushService::putRequested ( const QString & name, const QString & type, qint64 size, const QString & description )   [signal]

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().

void QObexPushService::requestFinished ( bool error )   [signal]

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.

QIODevice * QObexPushService::sessionDevice () const

Returns the device used by this OBEX Push server session, as provided in the constructor.

void QObexPushService::setBusinessCard ( const QByteArray & vCard )

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().

State QObexPushService::state () const

Returns the current state of the service.

void QObexPushService::stateChanged ( QObexPushService::State state )   [signal]

This signal is emitted when the state of the service changes. The state is the new state of the client.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 94
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 48
  4. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  5. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 13
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
Page suivante

Le blog Digia au hasard

Logo

Une nouvelle ère d'IHM 3D pour les automobiles

Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt qtextended4.4
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web