
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQDBusConnectionInterface class provides access to the D-Bus bus daemon service.More...
| Header: | #include <QDBusConnectionInterface> |
| Since: | Qt 4.2 |
| Inherits: | QDBusAbstractInterface |
| enum | RegisterServiceReply { ServiceNotRegistered, ServiceRegistered, ServiceQueued } |
| enum | ServiceQueueOptions { DontQueueService, QueueService, ReplaceExistingService } |
| enum | ServiceReplacementOptions { DontAllowReplacement, AllowReplacement } |
| QDBusReply<bool> | isServiceRegistered(const QString & serviceName) const |
| QDBusReply<QDBusConnectionInterface::RegisterServiceReply> | registerService(const QString & serviceName, ServiceQueueOptions qoption = DontQueueService, ServiceReplacementOptions roption = DontAllowReplacement) |
| QDBusReply<QStringList> | registeredServiceNames() const |
| QDBusReply<QString> | serviceOwner(const QString & name) const |
| QDBusReply<uint> | servicePid(const QString & serviceName) const |
| QDBusReply<uint> | serviceUid(const QString & serviceName) const |
| QDBusReply<void> | startService(const QString & name) |
| QDBusReply<bool> | unregisterService(const QString & serviceName) |
| void | callWithCallbackFailed(const QDBusError & error, const QDBusMessage & call) |
| void | serviceOwnerChanged(const QString & name, const QString & oldOwner, const QString & newOwner) |
| void | serviceRegistered(const QString & serviceName) |
| void | serviceUnregistered(const QString & serviceName) |
TheQDBusConnectionInterface class provides access to the D-Bus bus daemon service.
The D-Bus bus server daemon provides one special interfaceorg.freedesktop.DBus that allows clients to access certain properties of the bus, such as the current list of clients connected. TheQDBusConnectionInterface class provides access to that interface.
The most common uses of this class are to register and unregister service names on the bus using theregisterService() andunregisterService() functions, query about existing names using theisServiceRegistered(),registeredServiceNames() andserviceOwner() functions, and to receive notification that a client has registered or de-registered through theserviceRegistered(),serviceUnregistered() andserviceOwnerChanged() signals.
The possible return values fromregisterService():
| Constant | Value | Description |
|---|---|---|
QDBusConnectionInterface::ServiceNotRegistered | 0 | The call failed and the service name was not registered. |
QDBusConnectionInterface::ServiceRegistered | 1 | The caller is now the owner of the service name. |
QDBusConnectionInterface::ServiceQueued | 2 | The caller specified theQueueService flag and the service was already registered, so we are in queue. |
TheserviceRegistered() signal will be emitted when the service is acquired by this application.
Flags for determining how a service registration should behave, in case the service name is already registered.
| Constant | Value | Description |
|---|---|---|
QDBusConnectionInterface::DontQueueService | 0 | If an application requests a name that is already owned, no queueing will be performed. The registeredService() call will simply fail. This is the default. |
QDBusConnectionInterface::QueueService | 1 | Attempts to register the requested service, but do not try to replace it if another application already has it registered. Instead, simply put this application in queue, until it is given up. TheserviceRegistered() signal will be emitted when that happens. |
QDBusConnectionInterface::ReplaceExistingService | 2 | If another application already has the service name registered, attempt to replace it. |
See alsoServiceReplacementOptions.
Flags for determining if the D-Bus server should allow another application to replace a name that this application has registered with theReplaceExistingService option.
The possible values are:
| Constant | Value | Description |
|---|---|---|
QDBusConnectionInterface::DontAllowReplacement | 0 | Do not allow another application to replace us. The service must be explicitly unregistered withunregisterService() for another application to acquire it. This is the default. |
QDBusConnectionInterface::AllowReplacement | 1 | Allow other applications to replace us with theReplaceExistingService option toregisterService() without intervention. If that happens, theserviceUnregistered() signal will be emitted. |
See alsoServiceQueueOptions.
This property holds the registered service names.
Lists all names currently registered on the bus.
Access functions:
| QDBusReply<QStringList> | registeredServiceNames() const |
[signal]void QDBusConnectionInterface::callWithCallbackFailed(constQDBusError & error, constQDBusMessage & call)This signal is emitted when there is an error during aQDBusConnection::callWithCallback().error specifies the error.call is the message that couldn't be delivered.
See alsoQDBusConnection::callWithCallback().
[slot]QDBusReply<bool> QDBusConnectionInterface::isServiceRegistered(constQString & serviceName) constReturns true if the service nameserviceName has is currently registered.
[slot]QDBusReply<QDBusConnectionInterface::RegisterServiceReply> QDBusConnectionInterface::registerService(constQString & serviceName,ServiceQueueOptions qoption = DontQueueService,ServiceReplacementOptions roption = DontAllowReplacement)Requests to register the service nameserviceName on the bus. Theqoption flag specifies how the D-Bus server should behave ifserviceName is already registered. Theroption flag specifies if the server should allow another application to replace our registered name.
If the service registration succeeds, theserviceRegistered() signal will be emitted. If we are placed in queue, the signal will be emitted when we obtain the name. Ifroption isAllowReplacement, theserviceUnregistered() signal will be emitted if another application replaces this one.
See alsounregisterService().
[slot]QDBusReply<QString> QDBusConnectionInterface::serviceOwner(constQString & name) constReturns the unique connection name of the primary owner of the namename. If the requested name doesn't have an owner, returns aorg.freedesktop.DBus.Error.NameHasNoOwner error.
[signal]void QDBusConnectionInterface::serviceOwnerChanged(constQString & name, constQString & oldOwner, constQString & newOwner)This signal is emitted by the D-Bus server whenever a service ownership change happens in the bus, including apparition and disparition of names.
This signal means the applicationoldOwner lost ownership of bus namename to applicationnewOwner. IfoldOwner is an empty string, it means the namename has just been created; ifnewOwner is empty, the namename has no current owner and is no longer available.
Note:connecting to this signal will make the application listen for and receive every single service ownership change on the bus. Depending on how many services are running, this make the application be activated to receive more signals than it needs. To avoid this problem, use theQDBusServiceWatcher class, which can listen for specific changes.
[slot]QDBusReply<uint> QDBusConnectionInterface::servicePid(constQString & serviceName) constReturns the Unix Process ID (PID) for the process currently holding the bus serviceserviceName.
[signal]void QDBusConnectionInterface::serviceRegistered(constQString & serviceName)This signal is emitted by the D-Bus server when the bus service name (unique connection name or well-known service name) given byserviceName is acquired by this application.
Acquisition happens after this application has requested a name usingregisterService().
[slot]QDBusReply<uint> QDBusConnectionInterface::serviceUid(constQString & serviceName) constReturns the Unix User ID (UID) for the process currently holding the bus serviceserviceName.
[signal]void QDBusConnectionInterface::serviceUnregistered(constQString & serviceName)This signal is emitted by the D-Bus server when this application loses ownership of the bus service name given byserviceName.
[slot]QDBusReply<void> QDBusConnectionInterface::startService(constQString & name)Requests that the bus start the service given by the namename.
[slot]QDBusReply<bool> QDBusConnectionInterface::unregisterService(constQString & serviceName)Releases the claim on the bus service nameserviceName, that had been previously registered withregisterService(). If this application had ownership of the name, it will be released for other applications to claim. If it only had the name queued, it gives up its position in the queue.
© 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.