QDBusServiceWatcher Class
The QDBusServiceWatcher class allows the user to watch for a bus service change. More...
| Header: | #include <QDBusServiceWatcher> |
| qmake: | QT += dbus |
| Since: | Qt 4.6 |
| Inherits: | QObject |
This class was introduced in Qt 4.6.
Public Types
| enum | WatchModeFlag { WatchForRegistration, WatchForUnregistration, WatchForOwnerChange } |
Properties
- watchMode : WatchMode
- watchedServices : QStringList
Public Functions
| void | setWatchMode(QDBusServiceWatcher::WatchMode mode) |
| void | setWatchedServices(const QStringList &services) |
| QDBusServiceWatcher::WatchMode | watchMode() const |
| QStringList | watchedServices() const |
Detailed Description
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.
Ending a service name with the character '*' will match all service names within the specified namespace.
For example "com.example.backend1*" will match
- com.example.backend1
- com.example.backend1.foo
- com.example.backend1.foo.bar
Substrings in the same domain will not be matched, i.e "com.example.backend12".
See also QDBusConnection.
Member Type Documentation
enum QDBusServiceWatcher::WatchModeFlag
QDBusServiceWatcher supports three different watch modes, which are configured by this flag:
| Constant | Value | Description |
|---|---|---|
QDBusServiceWatcher::WatchForRegistration | 0x01 | watch for service registration only, ignoring any signals related to other service ownership change. |
QDBusServiceWatcher::WatchForUnregistration | 0x02 | watch for service unregistration only, ignoring any signals related to other service ownership change. |
QDBusServiceWatcher::WatchForOwnerChange | 0x03 | watch for any kind of service ownership change. |
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:
| QDBusServiceWatcher::WatchMode | watchMode() const |
| void | setWatchMode(QDBusServiceWatcher::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) |