PySide6.QtDBus.QDBusServiceWatcher¶
- class QDBusServiceWatcher¶
- The - QDBusServiceWatcherclass allows the user to watch for a bus service change. More…- Synopsis¶- Properties¶- watchModeᅟ- The current watch mode for this QDBusServiceWatcher object
- watchedServicesᅟ- The list of services watched
 - Methods¶- def - __init__()
- def - connection()
- def - setConnection()
- def - setWatchMode()
- def - watchMode()
 - Signals¶- Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- A - QDBusServiceWatcherobject 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 - class WatchModeFlag¶
- (inherits - enum.Flag)- QDBusServiceWatchersupports three different watch modes, which are configured by this flag:- Constant - Description - QDBusServiceWatcher.WatchForRegistration - watch for service registration only, ignoring any signals related to other service ownership change. - QDBusServiceWatcher.WatchForUnregistration - watch for service unregistration only, ignoring any signals related to other service ownership change. - QDBusServiceWatcher.WatchForOwnerChange - watch for any kind of service ownership change. 
 - Note - Properties can be used directly when - from __feature__ import true_propertyis used or via accessor functions otherwise.- property watchModeᅟ: Combination of QDBusServiceWatcher.WatchModeFlag¶
 - This property holds the current watch mode for this - QDBusServiceWatcherobject..- The default value for this property is QDBusServiceWatcher::WatchForOwnershipChange. - Access functions:
 - property watchedServicesᅟ: list of strings¶
 - This property holds the list of services watched.. - Note - Modifying this list with setServicesWatched() is an expensive operation. If you can, prefer to change it by way of - addWatchedService()and- removeWatchedService().- Access functions:
 - Creates a - QDBusServiceWatcherobject. Note that until you set a connection with- setConnection(), this object will not emit any signals.- The - parentparameter is passed to QObject to set the parent of this object.- __init__(service, connection[, watchMode=QDBusServiceWatcher.WatchModeFlag.WatchForOwnerChange[, parent=None]])
- Parameters:
- service – str 
- connection – - QDBusConnection
- watchMode – Combination of - WatchModeFlag
- parent – - QObject
 
 
 - Creates a - QDBusServiceWatcherobject and attaches it to the- connectionconnection. Also, this function immediately starts watching for- watchModechanges to service- service.- The - parentparameter is passed to QObject to set the parent of this object.- addWatchedService(newService)¶
- Parameters:
- newService – str 
 
 - Adds - newServiceto 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.- Removes any existing binding of - watchedServices.- connection()¶
- Return type:
 
 - Returns the - QDBusConnectionthat this object is attached to.- See also - removeWatchedService(service)¶
- Parameters:
- service – str 
- Return type:
- bool 
 
 - Removes the - servicefrom 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.- Removes any existing binding of - watchedServices.- This function returns - trueif any services were removed.- serviceOwnerChanged(service, oldOwner, newOwner)¶
- Parameters:
- service – str 
- oldOwner – str 
- newOwner – str 
 
 
 - This signal is emitted whenever this object detects that there was a service ownership change relating to the - serviceNameservice. The- oldOwnerparameter contains the old owner name and- newOwneris the new owner. Both- oldOwnerand- newOwnerare unique connection names.- Note that this signal is also emitted whenever the - serviceNameservice was registered or unregistered. If it was registered,- oldOwnerwill contain an empty string, whereas if it was unregistered,- newOwnerwill 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(service)¶
- Parameters:
- service – str 
 
 - This signal is emitted whenever this object detects that the service - serviceNamebecame available on the bus.- serviceUnregistered(service)¶
- Parameters:
- service – str 
 
 - This signal is emitted whenever this object detects that the service - serviceNamewas unregistered from the bus and is no longer available.- See also - setConnection(connection)¶
- Parameters:
- connection – - QDBusConnection
 
 - Sets the D-Bus connection that this object is attached to be - connection. All services watched will be transferred to this connection.- Note that - QDBusConnectionobjects are reference counted:- QDBusServiceWatcherwill 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- QDBusServiceWatcherobject exists.- See also - setWatchMode(mode)¶
- Parameters:
- mode – Combination of - WatchModeFlag
 - See also 
 - Setter of property - watchModeᅟ.- setWatchedServices(services)¶
- Parameters:
- services – list of strings 
 
 - Sets the list of D-Bus services being watched to be - services.- Note that setting the entire list means removing all previous rules for watching services and adding new ones. This is an expensive operation and should be avoided, if possible. Instead, use - addWatchedService()and- removeWatchedService()if you can to manipulate entries in the list.- Removes any existing binding of - watchedServices.- See also - Setter of property - watchedServicesᅟ.- watchMode()¶
- Return type:
- Combination of - WatchModeFlag
 - See also 
 - Getter of property - watchModeᅟ.- watchedServices()¶
- Return type:
- list of strings 
 
 - Returns the list of D-Bus services that are being watched. - See also - Getter of property - watchedServicesᅟ.