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  · 

QDBusServiceWatcher Class Reference

The QDBusServiceWatcher class allows the user to watch for a bus service change. More...

 #include <QDBusServiceWatcher>

Inherits: QObject.

This class was introduced in Qt 4.6.

Public Types

flags WatchMode
enum WatchModeFlag { WatchForRegistration, WatchForUnregistration, WatchForOwnerChange }

Properties

  • 1 property inherited from QObject

Public Functions

QDBusServiceWatcher ( QObject * parent = 0 )
QDBusServiceWatcher ( const QString & service, const QDBusConnection & connection, WatchMode watchMode = WatchForOwnerChange, QObject * parent = 0 )
~QDBusServiceWatcher ()
void addWatchedService ( const QString & newService )
QDBusConnection connection () const
bool removeWatchedService ( const QString & service )
void setConnection ( const QDBusConnection & connection )
void setWatchMode ( WatchMode mode )
void setWatchedServices ( const QStringList & services )
WatchMode watchMode () const
QStringList watchedServices () const
  • 29 public functions inherited from QObject

Signals

void serviceOwnerChanged ( const QString & serviceName, const QString & oldOwner, const QString & newOwner )
void serviceRegistered ( const QString & serviceName )
void serviceUnregistered ( const QString & serviceName )

Additional Inherited Members

  • 1 public slot inherited from QObject
  • 5 static public members inherited from QObject
  • 7 protected functions inherited from QObject

Detailed Description

The QDBusServiceWatcher class allows the user to watch for a bus service change.

A QDBusServiceWatcher object can be used to notify the application about an ownership change of a service name on the bus. It has three watch modes:

  • Watching for service registration only.
  • Watching for service unregistration only.
  • Watching for any kind of service ownership change (the default mode).

Besides being created or deleted, services may change owners without a unregister/register operation happening. So the serviceRegistered() and serviceUnregistered() signals may not be emitted if that happens.

This class is more efficient than using the QDBusConnectionInterface::serviceOwnerChanged() signal because it allows one to receive only the signals for which the class is interested in.

See also QDBusConnection.

Member Type Documentation

enum QDBusServiceWatcher::WatchModeFlag
flags QDBusServiceWatcher::WatchMode

QDBusServiceWatcher supports three different watch modes, which are configured by this flag:

ConstantValueDescription
QDBusServiceWatcher::WatchForRegistration0x01watch for service registration only, ignoring any signals related to other service ownership change.
QDBusServiceWatcher::WatchForUnregistration0x02watch for service unregistration only, ignoring any signals related to other service ownership change.
QDBusServiceWatcher::WatchForOwnerChange0x03watch for any kind of service ownership change.

The WatchMode type is a typedef for QFlags<WatchModeFlag>. It stores an OR combination of WatchModeFlag values.

Property Documentation

watchMode : WatchMode

The watchMode property holds the current watch mode for this QDBusServiceWatcher object. The default value for this property is QDBusServiceWatcher::WatchForOwnershipChange.

Access functions:

WatchMode watchMode () const
void setWatchMode ( WatchMode mode )

watchedServices : QStringList

The servicesWatched property holds the list of services watched.

Note that modifying this list with setServicesWatched() is an expensive operation. If you can, prefer to change it by way of addWatchedService() and removeWatchedService().

Access functions:

QStringList watchedServices () const
void setWatchedServices ( const QStringList & services )

Member Function Documentation

QDBusServiceWatcher::QDBusServiceWatcher ( QObject * parent = 0 )

Creates a QDBusServiceWatcher object. Note that until you set a connection with setConnection(), this object will not emit any signals.

The parent parameter is passed to QObject to set the parent of this object.

QDBusServiceWatcher::QDBusServiceWatcher ( const QString & service, const QDBusConnection & connection, WatchMode watchMode = WatchForOwnerChange, QObject * parent = 0 )

Creates a QDBusServiceWatcher object and attaches it to the connection connection. Also, this function immediately starts watching for watchMode changes to service service.

The parent parameter is passed to QObject to set the parent of this object.

QDBusServiceWatcher::~QDBusServiceWatcher ()

Destroys the QDBusServiceWatcher object and releases any resources associated with it.

void QDBusServiceWatcher::addWatchedService ( const QString & newService )

Adds newService to the list of services to be watched by this object. This function is more efficient than setWatchedServices() and should be used whenever possible to add services.

QDBusConnection QDBusServiceWatcher::connection () const

Returns the QDBusConnection that this object is attached to.

See also setConnection().

bool QDBusServiceWatcher::removeWatchedService ( const QString & service )

Removes the service from the list of services being watched by this object. Note that D-Bus notifications are asynchronous, so there may still be signals pending delivery about service. Those signals will still be emitted whenever the D-Bus messages are processed.

This function returns true if any services were removed.

void QDBusServiceWatcher::serviceOwnerChanged ( const QString & serviceName, const QString & oldOwner, const QString & newOwner ) [signal]

This signal is emitted whenever this object detects that there was a service ownership change relating to the serviceName service. The oldOwner parameter contains the old owner name and newOwner is the new owner. Both oldOwner and newOwner are unique connection names.

Note that this signal is also emitted whenever the serviceName service was registered or unregistered. If it was registered, oldOwner will contain an empty string, whereas if it was unregistered, newOwner will contain an empty string.

If you need only to find out if the service is registered or unregistered only, without being notified that the ownership changed, consider using the specific modes for those operations. This class is more efficient if you use the more specific modes.

See also serviceRegistered() and serviceUnregistered().

void QDBusServiceWatcher::serviceRegistered ( const QString & serviceName ) [signal]

This signal is emitted whenever this object detects that the service serviceName became available on the bus.

See also serviceUnregistered() and serviceOwnerChanged().

void QDBusServiceWatcher::serviceUnregistered ( const QString & serviceName ) [signal]

This signal is emitted whenever this object detects that the service serviceName was unregistered from the bus and is no longer available.

See also serviceRegistered() and serviceOwnerChanged().

void QDBusServiceWatcher::setConnection ( const QDBusConnection & connection )

Sets the D-Bus connection that this object is attached to be connection. All services watched will be transferred to this connection.

Note that QDBusConnection objects are reference counted: QDBusServiceWatcher will keep a reference for this connection while it exists. The connection is not closed until the reference count drops to zero, so this will ensure that any notifications are received while this QDBusServiceWatcher object exists.

See also connection().

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 64
  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. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Developer Network au hasard

Logo

Comment fermer une application

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. 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 4.7
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