QDBusConnectionInterface 类

QDBusConnectionInterface 类提供访问 D-Bus 总线守护程序服务。 更多...

头: #include <QDBusConnectionInterface>
qmake: QT += dbus
Since: Qt 4.2
继承: QDBusAbstractInterface

该类在 Qt 4.2 引入。

公共类型

enum RegisterServiceReply { ServiceNotRegistered, ServiceRegistered, ServiceQueued }
enum ServiceQueueOptions { DontQueueService, QueueService, ReplaceExistingService }
enum ServiceReplacementOptions { DontAllowReplacement, AllowReplacement }

特性

公共槽

QDBusReply<QStringList> activatableServiceNames () const
QDBusReply<bool> isServiceRegistered (const QString & serviceName ) const
QDBusReply<QDBusConnectionInterface::RegisterServiceReply> registerService (const QString & serviceName , QDBusConnectionInterface::ServiceQueueOptions qoption = DontQueueService, QDBusConnectionInterface::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 serviceRegistered (const QString & service )
void serviceUnregistered (const QString & service )

详细描述

D-Bus 总线服务器守护程序提供特殊接口 org.freedesktop.DBus ,允许客户端访问某些总线特性 (譬如:连接客户端的当前列表)。QDBusConnectionInterface 类提供对该接口的访问。

The most common uses of this class are to register and unregister service names on the bus using the registerService () 和 unregisterService () functions, query about existing names using the isServiceRegistered (), registeredServiceNames () 和 serviceOwner () functions, and to receive notification that a client has registered or de-registered through the serviceRegistered (), serviceUnregistered () and serviceOwnerChanged() signals.

成员类型文档编制

enum QDBusConnectionInterface:: RegisterServiceReply

可能的返回值来自 registerService ():

常量 描述
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 the QueueService flag and the service was already registered, so we are in queue.

serviceRegistered () signal will be emitted when the service is acquired by this application.

enum QDBusConnectionInterface:: ServiceQueueOptions

Flags for determining how a service registration should behave, in case the service name is already registered.

常量 描述
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. The serviceRegistered () signal will be emitted when that happens.
QDBusConnectionInterface::ReplaceExistingService 2 If another application already has the service name registered, attempt to replace it.

另请参阅 ServiceReplacementOptions .

enum QDBusConnectionInterface:: ServiceReplacementOptions

Flags for determining if the D-Bus server should allow another application to replace a name that this application has registered with the ReplaceExistingService 选项。

可能的值包括:

常量 描述
QDBusConnectionInterface::DontAllowReplacement 0 Do not allow another application to replace us. The service must be explicitly unregistered with unregisterService () for another application to acquire it. This is the default.
QDBusConnectionInterface::AllowReplacement 1 Allow other applications to replace us with the ReplaceExistingService option to registerService () without intervention. If that happens, the serviceUnregistered () 信号会被发射。

另请参阅 ServiceQueueOptions .

特性文档编制

activatableServiceNames : const QDBusReply < QStringList >

保持可激活的服务名称

Lists all names that can be activated on the bus.

该特性在 Qt 5.14 引入。

访问函数:

QDBusReply<QStringList> activatableServiceNames () const

registeredServiceNames : const QDBusReply < QStringList >

holds the registered service names

Lists all names currently registered on the bus.

访问函数:

QDBusReply<QStringList> registeredServiceNames () const

成员函数文档编制

[signal] void QDBusConnectionInterface:: callWithCallbackFailed (const QDBusError & error , const QDBusMessage & call )

This signal is emitted when there is an error during a QDBusConnection::callWithCallback (). error specifies the error. call is the message that couldn't be delivered.

另请参阅 QDBusConnection::callWithCallback ().

[slot] QDBusReply < bool > QDBusConnectionInterface:: isServiceRegistered (const QString & serviceName ) const

返回 true if the service name serviceName has is currently registered.

[slot] QDBusReply < QDBusConnectionInterface::RegisterServiceReply > QDBusConnectionInterface:: registerService (const QString & serviceName , QDBusConnectionInterface::ServiceQueueOptions qoption = DontQueueService, QDBusConnectionInterface::ServiceReplacementOptions roption = DontAllowReplacement)

Requests to register the service name serviceName on the bus. The qoption flag specifies how the D-Bus server should behave if serviceName is already registered. The roption flag specifies if the server should allow another application to replace our registered name.

If the service registration succeeds, the serviceRegistered () signal will be emitted. If we are placed in queue, the signal will be emitted when we obtain the name. If roption is AllowReplacement serviceUnregistered () signal will be emitted if another application replaces this one.

另请参阅 unregisterService ().

[slot] QDBusReply < QString > QDBusConnectionInterface:: serviceOwner (const QString & name ) const

Returns the unique connection name of the primary owner of the name name . If the requested name doesn't have an owner, returns a org.freedesktop.DBus.Error.NameHasNoOwner 错误。

[slot] QDBusReply < uint > QDBusConnectionInterface:: servicePid (const QString & serviceName ) const

Returns the Unix Process ID (PID) for the process currently holding the bus service serviceName .

[signal] void QDBusConnectionInterface:: serviceRegistered (const QString & service )

This signal is emitted by the D-Bus server when the bus service name (unique connection name or well-known service name) given by service is acquired by this application.

Acquisition happens after this application has requested a name using registerService ().

[slot] QDBusReply < uint > QDBusConnectionInterface:: serviceUid (const QString & serviceName ) const

Returns the Unix User ID (UID) for the process currently holding the bus service serviceName .

[signal] void QDBusConnectionInterface:: serviceUnregistered (const QString & service )

This signal is emitted by the D-Bus server when this application loses ownership of the bus service name given by service .

[slot] QDBusReply < void > QDBusConnectionInterface:: startService (const QString & name )

Requests that the bus start the service given by the name name .

[slot] QDBusReply < bool > QDBusConnectionInterface:: unregisterService (const QString & serviceName )

Releases the claim on the bus service name serviceName , that had been previously registered with registerService (). 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.