QDBusConnection Class
The QDBusConnection class represents a connection to the D-Bus bus daemon. More...
| Header: | #include <QDBusConnection> |
| qmake: | QT += dbus |
| Since: | Qt 4.2 |
This class was introduced in Qt 4.2.
Public Types
| enum | BusType { SessionBus, SystemBus, ActivationBus } |
| enum | ConnectionCapability { UnixFileDescriptorPassing } |
| enum | RegisterOption { ExportAdaptors, ExportScriptableSlots, ExportScriptableSignals, ExportScriptableProperties, ExportScriptableInvokables, …, ExportChildObjects } |
| enum | UnregisterMode { UnregisterNode, UnregisterTree } |
Detailed Description
This class is the initial point in a D-Bus session. Using it, you can get access to remote objects, interfaces; connect remote signals to your object's slots; register objects, etc.
D-Bus connections are created using the connectToBus() function, which opens a connection to the server daemon and does the initial handshaking, associating that connection with a name. Further attempts to connect using the same name will return the same connection.
The connection is then torn down using the disconnectFromBus() function.
Once disconnected, calling connectToBus() will not reestablish a connection, you must create a new QDBusConnection instance.
As a convenience for the two most common connection types, the sessionBus() and systemBus() functions return open connections to the session server daemon and the system server daemon, respectively. Those connections are opened when first used and are closed when the QCoreApplication destructor is run.
D-Bus also supports peer-to-peer connections, without the need for a bus server daemon. Using this facility, two applications can talk to each other and exchange messages. This can be achieved by passing an address to connectToBus() function, which was opened by another D-Bus application using QDBusServer.
Member Type Documentation
enum QDBusConnection::BusType
Specifies the type of the bus connection. The valid bus types are:
| Constant | Value | Description |
|---|---|---|
QDBusConnection::SessionBus | 0 | the session bus, associated with the running desktop session |
QDBusConnection::SystemBus | 1 | the system bus, used to communicate with system-wide processes |
QDBusConnection::ActivationBus | 2 | the activation bus, the "alias" for the bus that started the service |
On the Session Bus, one can find other applications by the same user that are sharing the same desktop session (hence the name). On the System Bus, however, processes shared for the whole system are usually found.
enum QDBusConnection::ConnectionCapability
This enum describes the available capabilities for a D-Bus connection.
| Constant | Value | Description |
|---|---|---|
QDBusConnection::UnixFileDescriptorPassing | 0x0001 | enables passing of Unix file descriptors to other processes (see QDBusUnixFileDescriptor) |
This enum was introduced or modified in Qt 4.8.
See also connectionCapabilities().
enum QDBusConnection::RegisterOption
Specifies the options for registering objects with the connection. The possible values are:
| Constant | Value | Description |
|---|---|---|
QDBusConnection::ExportAdaptors | 0x01 | export the contents of adaptors found in this object |
QDBusConnection::ExportScriptableSlots | 0x10 | export this object's scriptable slots |
QDBusConnection::ExportScriptableSignals | 0x20 | export this object's scriptable signals |
QDBusConnection::ExportScriptableProperties | 0x40 | export this object's scriptable properties |
QDBusConnection::ExportScriptableInvokables | 0x80 | export this object's scriptable invokables |
QDBusConnection::ExportScriptableContents | 0xf0 | shorthand form for ExportScriptableSlots | ExportScriptableSignals | ExportScriptableProperties |
QDBusConnection::ExportNonScriptableSlots | 0x100 | export this object's non-scriptable slots |
QDBusConnection::ExportNonScriptableSignals | 0x200 | export this object's non-scriptable signals |
QDBusConnection::ExportNonScriptableProperties | 0x400 | export this object's non-scriptable properties |
QDBusConnection::ExportNonScriptableInvokables | 0x800 | export this object's non-scriptable invokables |
QDBusConnection::ExportNonScriptableContents | 0xf00 | shorthand form for ExportNonScriptableSlots | ExportNonScriptableSignals | ExportNonScriptableProperties |
QDBusConnection::ExportAllSlots | ExportScriptableSlots|ExportNonScriptableSlots | export all of this object's slots |
QDBusConnection::ExportAllSignals | ExportScriptableSignals|ExportNonScriptableSignals | export all of this object's signals |
QDBusConnection::ExportAllProperties | ExportScriptableProperties|ExportNonScriptableProperties | export all of this object's properties |
QDBusConnection::ExportAllInvokables | ExportScriptableInvokables|ExportNonScriptableInvokables | export all of this object's invokables |
QDBusConnection::ExportAllContents | ExportScriptableContents|ExportNonScriptableContents | export all of this object's contents |
QDBusConnection::ExportChildObjects | 0x1000 | export this object's child objects |
See also registerObject(), QDBusAbstractAdaptor, and Using adaptors.
enum QDBusConnection::UnregisterMode
The mode for unregistering an object path:
| Constant | Value | Description |
|---|---|---|
QDBusConnection::UnregisterNode | 0 | unregister this node only: do not unregister child objects |
QDBusConnection::UnregisterTree | 1 | unregister this node and all its sub-tree |
Note, however, if this object was registered with the ExportChildObjects option, UnregisterNode will unregister the child objects too.