Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QDBusServiceWatcher Class

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

Header:#include <QDBusServiceWatcher>
Since: Qt 4.6
Inherits:QObject

Public Types

flagsWatchMode
enumWatchModeFlag { WatchForRegistration, WatchForUnregistration, WatchForOwnerChange }

Properties

Public Functions

QDBusServiceWatcher(QObject * parent = 0)
QDBusServiceWatcher(const QString & service, const QDBusConnection & connection, WatchMode watchMode = WatchForOwnerChange, QObject * parent = 0)
~QDBusServiceWatcher()
voidaddWatchedService(const QString & newService)
QDBusConnectionconnection() const
boolremoveWatchedService(const QString & service)
voidsetConnection(const QDBusConnection & connection)
voidsetWatchMode(WatchMode mode)
voidsetWatchedServices(const QStringList & services)
WatchModewatchMode() const
QStringListwatchedServices() const
  • 29 public functions inherited fromQObject

Signals

voidserviceOwnerChanged(const QString & serviceName, const QString & oldOwner, const QString & newOwner)
voidserviceRegistered(const QString & serviceName)
voidserviceUnregistered(const QString & serviceName)

Additional Inherited Members

  • 1 public slot inherited fromQObject
  • 7 static public members inherited fromQObject
  • 8 protected functions inherited fromQObject

Detailed Description

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

AQDBusServiceWatcher 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 theserviceRegistered() andserviceUnregistered() signals may not be emitted if that happens.

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

See alsoQDBusConnection.

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 forQFlags<WatchModeFlag>. It stores an OR combination of WatchModeFlag values.

Property Documentation

watchMode :WatchMode

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

Access functions:

WatchModewatchMode() const
voidsetWatchMode(WatchMode mode)

watchedServices :QStringList

TheservicesWatched 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 ofaddWatchedService() andremoveWatchedService().

Access functions:

QStringListwatchedServices() const
voidsetWatchedServices(const QStringList & services)

Member Function Documentation

QDBusServiceWatcher::QDBusServiceWatcher(QObject * parent = 0)

Creates aQDBusServiceWatcher object. Note that until you set a connection withsetConnection(), this object will not emit any signals.

Theparent parameter is passed toQObject to set the parent of this object.

QDBusServiceWatcher::QDBusServiceWatcher(constQString & service, constQDBusConnection & connection,WatchMode watchMode = WatchForOwnerChange,QObject * parent = 0)

Creates aQDBusServiceWatcher object and attaches it to theconnection connection. Also, this function immediately starts watching forwatchMode changes to serviceservice.

Theparent parameter is passed toQObject to set the parent of this object.

QDBusServiceWatcher::~QDBusServiceWatcher()

Destroys theQDBusServiceWatcher object and releases any resources associated with it.

void QDBusServiceWatcher::addWatchedService(constQString & newService)

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

QDBusConnection QDBusServiceWatcher::connection() const

Returns theQDBusConnection that this object is attached to.

See alsosetConnection().

bool QDBusServiceWatcher::removeWatchedService(constQString & service)

Removes theservice 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 aboutservice. Those signals will still be emitted whenever the D-Bus messages are processed.

This function returns true if any services were removed.

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

This signal is emitted whenever this object detects that there was a service ownership change relating to theserviceName service. TheoldOwner parameter contains the old owner name andnewOwner is the new owner. BotholdOwner andnewOwner are unique connection names.

Note that this signal is also emitted whenever theserviceName 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 alsoserviceRegistered() andserviceUnregistered().

[signal]void QDBusServiceWatcher::serviceRegistered(constQString & serviceName)

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

See alsoserviceUnregistered() andserviceOwnerChanged().

[signal]void QDBusServiceWatcher::serviceUnregistered(constQString & serviceName)

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

See alsoserviceRegistered() andserviceOwnerChanged().

void QDBusServiceWatcher::setConnection(constQDBusConnection & connection)

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

Note thatQDBusConnection 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 thisQDBusServiceWatcher object exists.

See alsoconnection().

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp