|  | Home · All Classes · Main Classes · Grouped Classes · Modules · Functions |

# QDBusMessage Class Reference
[QtDBus module]

Represents one message sent or received over the DBus bus. More...

    #include <QDBusMessage>

- List of all members, including inherited members

### Public Types

- enum MessageType { MethodCallMessage, SignalMessage, ReplyMessage, ErrorMessage, InvalidMessage }

### Public Functions

- QDBusMessage ()
- QDBusMessage ( const QDBusMessage & other )
- ~QDBusMessage ()
- void append ( const QVariant & arg )
- const QList<QVariant> & arguments () const
- const QVariant & at ( int index ) const
- QDBusConnection connection () const
- int count () const
- QString interface () const
- bool isDelayedReply () const
- bool isEmpty () const
- bool isReplyRequired () const
- QString member () const
- QString path () const
- bool send ()
- bool sendError ( const QString & name, const QString & msg = QString() ) const
- bool sendError ( const QDBusError & error ) const
- bool sendReply ( const QVariantList & arguments = QVariantList() ) const
- bool sendReply ( const QVariant & arg ) const
- QString service () const
- void setArguments ( const QList<QVariant> & arguments )
- void setDelayedReply ( bool enable )
- QString signature () const
- MessageType type () const
- QDBusMessage & operator+= ( const QVariant & arg )
- QDBusMessage & operator<< ( const QVariant & arg )
- QDBusMessage & operator= ( const QDBusMessage & other )

### Static Public Members

- QDBusMessage methodCall ( const QString & service, const QString & path, const QString & interface, const QString & method, const QDBusConnection & connection )
- QDBusMessage signal ( const QString & path, const QString & interface, const QString & name, const QDBusConnection & connection )

## Detailed Description

Represents one message sent or received over the DBus bus.

This object can represent any of four different types of messages possible on the bus (see MessageType)

- Method calls
- Method return values
- Signal emissions
- Error codes

Objects of this type are created with the static functions signal or methodCall. Method return values and errors are sent using the sendError() and sendReply() functions and are only available on received method calls.

## Member Type Documentation

### enum QDBusMessage::MessageType

The possible message types:

Constant | Value | Description
--- | --- | ---
`QDBusMessage::MethodCallMessage` | `1` | a message representing an outgoing or incoming method call
`QDBusMessage::SignalMessage` | `4` | a message representing an outgoing or incoming signal emission
`QDBusMessage::ReplyMessage` | `2` | a message representing the return values of a method call
`QDBusMessage::ErrorMessage` | `3` | a message representing an error condition in response to a method call
`QDBusMessage::InvalidMessage` | `0` | an invalid message: this is never set on messages received from D-Bus

## Member Function Documentation

### QDBusMessage::QDBusMessage ()

Constructs an empty, invalid QDBusMessage object.

See also methodCall() and signal().

### QDBusMessage::QDBusMessage ( const QDBusMessage & other )

Constructs a copy of the object given by other.

Note: QDBusMessage objects are shared. Modifications made to the copy will affect the original one as well. See setDelayedReply() for more information.

### QDBusMessage::~QDBusMessage ()

Disposes of the object and frees any resources that were being held.

### void QDBusMessage::append ( const QVariant & arg )

Appends the argument arg to the list of arguments to be sent over D-BUS in a method call or signal emission.

### const QList<QVariant> & QDBusMessage::arguments () const

Returns the list of arguments that are going to be sent or were received from D-BUS.

See also setArguments().

### const QVariant & QDBusMessage::at ( int index ) const

Returns the argument at position index in the argument list. The value of index must be larger than or equal to 0 and less than argumentCount(). This is equivalent to calling QList::at() on the value returned by arguments().

### QDBusConnection QDBusMessage::connection () const

Returns the connection this message was received on or an unconnected QDBusConnection object if this isn't a message that has been received.

### int QDBusMessage::count () const

Returns the number of arguments that were received from D-BUS. The value returned from this function is the size of the QList that is returned by arguments().

### QString QDBusMessage::interface () const

Returns the interface of the method being called (in the case of a method call) or of the signal being received from.

### bool QDBusMessage::isDelayedReply () const

Returns the delayed reply flag, as set by setDelayedReply(). By default, this flag is false, which means QtDBus will generate automatic replies when necessary.

### bool QDBusMessage::isEmpty () const

### bool QDBusMessage::isReplyRequired () const

Returns the flag that indicates if this message should see a reply or not. This is only meaningful for MethodCall messages: any other kind of message cannot have replies and this function will always return false for them.

### QString QDBusMessage::member () const

Returns the name of the signal that was emitted, the name of the error that was received or the name of the method that was called.

### QDBusMessage QDBusMessage::methodCall ( const QString & service, const QString & path, const QString & interface, const QString & method, const QDBusConnection & connection ) `[static]`

Constructs a new DBus message representing a method call. A method call always informs its destination address (service, path, interface and method).

The DBus bus allows calling a method on a given remote object without specifying the destination interface, if the method name is unique. However, if two interfaces on the remote object export the same method name, the result is undefined (one of the two may be called or an error may be returned).

When using DBus in a peer-to-peer context (i.e., not on a bus), the service parameter is optional.

The QDBusObject and QDBusInterface classes provide a simpler abstraction to synchronous method calling.

This function returns a QDBusMessage object that can be sent with QDBusConnection::call().

### QString QDBusMessage::path () const

Returns the path of the object that this message is being sent to (in the case of a method call) or being received from (for a signal).

### bool QDBusMessage::send ()

### bool QDBusMessage::sendError ( const QString & name, const QString & msg = QString() ) const

Constructs a D-BUS message representing an error condition described by the name parameter and sends it. The msg parameter is optional and may contain a human-readable description of the error.

### bool QDBusMessage::sendError ( const QDBusError & error ) const

This is an overloaded member function, provided for convenience.

Constructs a D-BUS message representing an error condition described by the error parameter and sends it.

### bool QDBusMessage::sendReply ( const QVariantList & arguments = QVariantList() ) const

Constructs a new D-BUS message representing the return values from a called method and sends it to the caller. The arguments list contains the arguments to be returned.

### bool QDBusMessage::sendReply ( const QVariant & arg ) const

This is an overloaded member function, provided for convenience.

Constructs a new D-BUS message representing the return values from a called method and sends it to the caller. The arg value will be sent to the caller as a return value.

### QString QDBusMessage::service () const

Returns the name of the service or the bus address of the remote method call.

### void QDBusMessage::setArguments ( const QList<QVariant> & arguments )

Sets the arguments that are going to be sent over D-BUS to arguments. Those will be the arguments to a method call or the parameters in the signal.

See also arguments().

### void QDBusMessage::setDelayedReply ( bool enable )

Sets the flag indicating whether the message will be replied later or if an automatic reply should be generated by QtDBus.

In D-BUS, all method calls must generate a reply to the caller, unless the caller explicitly indicates otherwise (see isReplyRequired()). QtDBus automatically generates such replies for any slots being called, but it also allows slots to indicate whether they will take responsibility of sending the reply at a later time, after the function has finished processing.

See QtDBus Delayed Replies for more information/

See also isDelayedReply.

### QDBusMessage QDBusMessage::signal ( const QString & path, const QString & interface, const QString & name, const QDBusConnection & connection ) `[static]`

Constructs a new DBus message representing a signal emission. A DBus signal is emitted from one application and is received by all applications that are listening for that signal from that interface.

The signal will be constructed to represent a signal coming from the path path, interface interface and signal name name.

The QDBusMessage object that is returned can be sent with QDBusConnection::send().

### QString QDBusMessage::signature () const

Returns the signature of the signal that was received or for the output arguments of a method call.

### MessageType QDBusMessage::type () const

Returns the message type.

### QDBusMessage & QDBusMessage::operator+= ( const QVariant & arg )

Appends the argument arg to the list of arguments to be sent over D-BUS in a method call or signal emission.

See also append().

### QDBusMessage & QDBusMessage::operator<< ( const QVariant & arg )

Appends the argument arg to the list of arguments to be sent over D-BUS in a method call or signal emission.

See also append().

### QDBusMessage & QDBusMessage::operator= ( const QDBusMessage & other )

Copies the contents of the object given by other.

Note: QDBusMessage objects are shared. Modifications made to the copy will affect the original one as well. See setDelayedReply() for more information.