Logo Search packages:      
Sourcecode: kdbus version File versions  Download package

QDBusConnection Class Reference

#include <qdbusconnection.h>

List of all members.

Detailed Description

Provides access to a specific DBus bus.

In order to access a DBus message bus an application has to connect to it. This is very similar to connecting to an FTP server using QFtp, where any number of commands can be sent in sequence over the same connection.

Additionally to the asynchronous command execution provided by QFtp a QDBusConnection can also execute synchronous (blocking) calls so the code around those calls stays closer to in-process method incovations.

However it is recommended to only perform blocking calls on DBus service methods that are likely to be processed fast.

QDBusConnection implements a shared resource, i.e. if you create a connection with a specific name in one part of your code and then create one with the same name somewhere else, the second creation will actually return the same shared connection object the first caller created.

The application can be connected to more than one message bus simultaniously using one or more connections per bus, however the most common case is to have one connection per bus.

The two main bus types are:

While QDBusConnection provides the basic API to access DBus services it is more convenient to use QDBusProxy on top of the connection.

See sections Using DBus as a client and Providing services over DBus for examples

Definition at line 169 of file qdbusconnection.h.

Public Types

enum  BusType { SessionBus, SystemBus, ActivationBus }
enum  NameRequestMode { NoReplace = 0, AllowReplace = 1, ReplaceExisting = 2 }
 Flags for controlling the behavior name collision handling. More...

Public Member Functions

bool connect (QObject *object, const char *slot)
 Connects an object to receive DBus signals.
bool disconnect (QObject *object, const char *slot)
 Disconnects a given receiver from the DBus signal handling.
void dispatch () const
 Processes buffered inbound messages.
void flush () const
 Flushes buffered outgoing message.
bool isConnected () const
 Returns whether the connection is connected to a bus.
QDBusError lastError () const
 Returns the last error seen by the connection.
QDBusConnectionoperator= (const QDBusConnection &other)
 Creates a shallow copy of the given connection.
 QDBusConnection (const QDBusConnection &other)
 Creates a shallow copy of the given connection.
 QDBusConnection (const QString &name)
 Creates a connection handle to a named connection.
 QDBusConnection ()
 Creates an empty/disconnected connection handle.
bool registerObject (const QString &path, QDBusObjectBase *object)
 Registers a service object for a given path.
bool requestName (const QString &name, int modeFlags=NoReplace)
 Requests to be addressable on the bus by a given name.
void scheduleDispatch () const
 Request a delayed check for inbound buffer processing.
bool send (const QDBusMessage &message) const
 Sends a message over the bus.
int sendWithAsyncReply (const QDBusMessage &message, QObject *receiver, const char *slot) const
 Sends a message over the bus, specifying a receiver object for replies.
QDBusMessage sendWithReply (const QDBusMessage &message, QDBusError *error=0) const
 Sends a message over the bus and waits for the reply.
QString uniqueName () const
 Returns the connection identifier assigned at connect.
void unregisterObject (const QString &path)
 Unregister a service object on a given path.
 ~QDBusConnection ()
 Destroys the connection handle.

Static Public Member Functions

static QDBusConnection addConnection (const QString &address, const QString &name=default_connection_name)
 Add a connection to a bus at a specific address.
static QDBusConnection addConnection (BusType type, const QString &name=default_connection_name)
 Add a connection to a bus with a specific bus type.
static void closeConnection (const QString &name=default_connection_name)
 Closes a connection with a given name.

Public Attributes

QT_STATIC_CONST char * default_connection_name = "qt_dbus_default_connection"

Private Attributes

QDBusConnectionPrivate * d

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index