QDBusConnectionInterface Class
The QDBusConnectionInterface class provides access to the D-Bus bus daemon service. More…
| Header | #include <QDBusConnectionInterface> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::DBus) |
| Module | Nt D-Bus C++ Classes |
| Inherits | QDBusAbstractInterface |
List of all members, including inherited members
Public Types
Public Functions
| QDBusReply<QStringList> | registeredServiceNames() const |
| QDBusReply<QStringList> | activatableServiceNames() const |
| QDBusReply<bool> | isServiceRegistered(const QString &serviceName) const |
| QDBusReply<QString> | serviceOwner(const QString &name) const |
| QDBusReply<bool> | unregisterService(const QString &serviceName) |
| QDBusReply<QDBusConnectionInterface::RegisterServiceReply> | registerService(const QString &serviceName, ServiceQueueOptions qoption = DontQueueService, ServiceReplacementOptions roption = DontAllowReplacement) |
| QDBusReply<uint> | servicePid(const QString &serviceName) const |
| QDBusReply<uint> | serviceUid(const QString &serviceName) const |
| QDBusReply<void> | startService(const QString &name) |
Signals
| void | serviceRegistered(const QString &service) |
| void | serviceUnregistered(const QString &service) |
| void | serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner) |
| void | callWithCallbackFailed(const QDBusError &error, const QDBusMessage &call) |
Detailed Description
QDBusConnection::interface() returns the one of a connection. It lists and looks up the names on the bus, claims and releases names, and reports names that appear and disappear:
QDBusConnectionInterface *bus = QDBusConnection::sessionBus().interface();
if (bus->isServiceRegistered("org.example.Clock"))
qDebug() << "owned by" << bus->serviceOwner("org.example.Clock").value();
See also QDBusConnection and QDBusServiceWatcher.
Differences from Qt
The object lives in the thread that does the connection's I/O, so its signals reach other threads through queued connections. It listens for every NameOwnerChanged signal of the bus from the moment it is created. The NameAcquired and NameLost signals are not available.
Member Type Documentation
enum QDBusConnectionInterface::RegisterServiceReply
| Constant | Description |
|---|---|
QDBusConnectionInterface::ServiceNotRegistered | The name was not claimed. |
QDBusConnectionInterface::ServiceRegistered | This connection owns the name. |
QDBusConnectionInterface::ServiceQueued | This connection waits in the queue for the name. |
enum QDBusConnectionInterface::ServiceQueueOptions
What registerService() does when the name is taken.
| Constant | Description |
|---|---|
QDBusConnectionInterface::DontQueueService | Fail. |
QDBusConnectionInterface::QueueService | Wait in the queue for the name. |
QDBusConnectionInterface::ReplaceExistingService | Take the name if its owner allows replacement; otherwise fail. |
enum QDBusConnectionInterface::ServiceReplacementOptions
| Constant | Description |
|---|---|
QDBusConnectionInterface::DontAllowReplacement | Other connections cannot take the name away. |
QDBusConnectionInterface::AllowReplacement | Another connection may take the name with ReplaceExistingService. |
Member Function Documentation
QDBusReply<QStringList> QDBusConnectionInterface::activatableServiceNames() const
Returns the names that the bus can start a program for.
void QDBusConnectionInterface::callWithCallbackFailed(const QDBusError &error, const QDBusMessage &call)
This signal is emitted when QDBusConnection::callWithCallback() fails to deliver the result of call, with the error that occurred.
QDBusReply<bool> QDBusConnectionInterface::isServiceRegistered(const QString &serviceName) const
Returns whether a connection owns serviceName.
QDBusReply<QStringList> QDBusConnectionInterface::registeredServiceNames() const
Returns the names that exist on the bus, unique and well-known.
QDBusReply<QDBusConnectionInterface::RegisterServiceReply> QDBusConnectionInterface::registerService(const QString &serviceName, ServiceQueueOptions qoption = DontQueueService, ServiceReplacementOptions roption = DontAllowReplacement)
Claims serviceName. qoption says what happens if the name is taken, and roption whether others may take it away later.
QDBusReply<QString> QDBusConnectionInterface::serviceOwner(const QString &name) const
Returns the unique name of the connection that owns name.
void QDBusConnectionInterface::serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner)
This signal is emitted when the owner of name changes from oldOwner to newOwner.
QDBusReply<uint> QDBusConnectionInterface::servicePid(const QString &serviceName) const
Returns the process id of the connection that owns serviceName.
void QDBusConnectionInterface::serviceRegistered(const QString &service)
This signal is emitted when service gets its first owner.
QDBusReply<uint> QDBusConnectionInterface::serviceUid(const QString &serviceName) const
Returns the user id of the connection that owns serviceName.
void QDBusConnectionInterface::serviceUnregistered(const QString &service)
This signal is emitted when service loses its last owner.
QDBusReply<void> QDBusConnectionInterface::startService(const QString &name)
Asks the bus to start the program that provides name.
QDBusReply<bool> QDBusConnectionInterface::unregisterService(const QString &serviceName)
Releases serviceName. The value is true if this connection owned it.