QDBusMessage Class
The QDBusMessage class represents one message sent or received over the D-Bus bus. More…
| Header | #include <QDBusMessage> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::DBus) |
| Module | Nt D-Bus C++ Classes |
List of all members, including inherited members
Public Types
| enum | MessageType |
Public Functions
| QDBusMessage() | |
| QDBusMessage(const QDBusMessage &other) | |
| QDBusMessage & | operator=(const QDBusMessage &other) |
| ~QDBusMessage() | |
| QDBusMessage | createReply(const QList<QVariant> &arguments = QList<QVariant>()) const |
| QDBusMessage | createReply(const QVariant &argument) const |
| QDBusMessage | createErrorReply(const QString &name, const QString &message) const |
| QDBusMessage | createErrorReply(const QDBusError &error) const |
| QDBusMessage | createErrorReply(QDBusError::ErrorType type, const QString &message) const |
| QString | service() const |
| QString | path() const |
| QString | interface() const |
| QString | member() const |
| QString | errorName() const |
| QString | errorMessage() const |
| MessageType | type() const |
| QString | signature() const |
| bool | isReplyRequired() const |
| void | setDelayedReply(bool enable) const |
| bool | isDelayedReply() const |
| void | setAutoStartService(bool enable) |
| bool | autoStartService() const |
| void | setInteractiveAuthorizationAllowed(bool enable) |
| bool | isInteractiveAuthorizationAllowed() const |
| void | setArguments(const QList<QVariant> &arguments) |
| QList<QVariant> | arguments() const |
| QDBusMessage & | operator<<(const QVariant &argument) |
Static Public Members
| QDBusMessage | createSignal(const QString &path, const QString &interface, const QString &name) |
| QDBusMessage | createTargetedSignal(const QString &service, const QString &path, const QString &interface, const QString &name) |
| QDBusMessage | createMethodCall(const QString &destination, const QString &path, const QString &interface, const QString &method) |
| QDBusMessage | createError(const QString &name, const QString &message) |
| QDBusMessage | createError(const QDBusError &error) |
| QDBusMessage | createError(QDBusError::ErrorType type, const QString &message) |
Detailed Description
A message is a method call, a reply to one, an error or a signal. Create one with the static functions, add arguments with operator<<() and send it with QDBusConnection:
QDBusMessage call = QDBusMessage::createMethodCall(
"org.example.Clock", "/clock", "org.example.Clock", "SetAlarm");
call << 7 << 30;
QDBusMessage reply = QDBusConnection::sessionBus().call(call);
if (reply.type() == QDBusMessage::ErrorMessage)
qWarning() << reply.errorMessage();
QDBusMessage is implicitly shared.
See also QDBusConnection and QDBusReply.
Differences from Qt
There is no QDebug stream operator and no createSignal() overload taking only a path.
Member Type Documentation
enum QDBusMessage::MessageType
The kind of a message.
| Constant | Description |
|---|---|
QDBusMessage::InvalidMessage | A message that was default-constructed or failed to parse. |
QDBusMessage::MethodCallMessage | A call of a method. |
QDBusMessage::ReplyMessage | A successful reply to a call. |
QDBusMessage::ErrorMessage | An error reply to a call. |
QDBusMessage::SignalMessage | A signal. |
Member Function Documentation
QDBusMessage::QDBusMessage()
Constructs an invalid message.
QDBusMessage::QDBusMessage(const QDBusMessage &other)
Constructs a copy of other.
QDBusMessage::~QDBusMessage()
Destroys the message.
QList<QVariant> QDBusMessage::arguments() const
Returns the arguments of the message. Containers and structures that have no C++ type are QDBusArgument values; use qdbus_cast() to extract them.
bool QDBusMessage::autoStartService() const
Returns true if the bus may start the destination service to receive this call.
QDBusMessage QDBusMessage::createError(const QString &name, const QString &message)
Returns an error message with the error name and the text message.
QDBusMessage QDBusMessage::createError(const QDBusError &error)
This is an overloaded function.
Returns an error message for error.
QDBusMessage QDBusMessage::createError(QDBusError::ErrorType type, const QString &message)
This is an overloaded function.
Returns an error message of the type type with the text message.
QDBusMessage QDBusMessage::createErrorReply(const QString &name, const QString &message) const
Returns an error reply to this call with the error name and the text message.
QDBusMessage QDBusMessage::createErrorReply(const QDBusError &error) const
This is an overloaded function.
Returns an error reply to this call for error.
QDBusMessage QDBusMessage::createErrorReply(QDBusError::ErrorType type, const QString &message) const
This is an overloaded function.
Returns an error reply to this call of the type type with the text message.
QDBusMessage QDBusMessage::createMethodCall(const QString &destination, const QString &path, const QString &interface, const QString &method)
Returns a call of method of interface on the object at path in destination. interface may be empty.
See also QDBusConnection::call().
QDBusMessage QDBusMessage::createReply(const QList<QVariant> &arguments = QList<QVariant>()) const
Returns a reply to this call that carries arguments.
QDBusMessage QDBusMessage::createReply(const QVariant &argument) const
This is an overloaded function.
Returns a reply to this call that carries the single argument.
QDBusMessage QDBusMessage::createSignal(const QString &path, const QString &interface, const QString &name)
Returns a signal name of interface, emitted by the object at path, to every connection that listens for it.
See also createTargetedSignal() and QDBusConnection::send().
QDBusMessage QDBusMessage::createTargetedSignal(const QString &service, const QString &path, const QString &interface, const QString &name)
Returns a signal name of interface, emitted by the object at path, that is sent to service only.
QString QDBusMessage::errorMessage() const
Returns the text of an error message.
QString QDBusMessage::errorName() const
Returns the name of the error of an error message.
QString QDBusMessage::interface() const
Returns the interface of a call or a signal.
bool QDBusMessage::isDelayedReply() const
Returns true if the reply to this call is to be sent later.
bool QDBusMessage::isInteractiveAuthorizationAllowed() const
Returns true if the receiver may ask the user to authorize this call.
bool QDBusMessage::isReplyRequired() const
Returns true if this is a received method call whose caller waits for a reply.
QString QDBusMessage::member() const
Returns the name of the method or signal.
QDBusMessage & QDBusMessage::operator<<(const QVariant &argument)
Appends argument to the arguments of the message and returns a reference to the message.
QDBusMessage & QDBusMessage::operator=(const QDBusMessage &other)
Makes this message a copy of other and returns a reference to it.
QString QDBusMessage::path() const
Returns the object path of a call or a signal.
QString QDBusMessage::service() const
Returns the destination of a message that is to be sent, or the unique name of the sender of a message that was received.
void QDBusMessage::setArguments(const QList<QVariant> &arguments)
Replaces the arguments of the message with arguments.
void QDBusMessage::setAutoStartService(bool enable)
Sets whether the bus may start the destination service to receive this call to enable. It is enabled by default.
void QDBusMessage::setDelayedReply(bool enable) const
Sets whether the reply to this call is sent later, by the code that handles it, to enable. Nt then sends no reply when the slot returns.
See also QDBusContext::setDelayedReply().
void QDBusMessage::setInteractiveAuthorizationAllowed(bool enable)
Sets whether the receiver may ask the user to authorize this call to enable.
QString QDBusMessage::signature() const
Returns the D-Bus signature of the arguments.
MessageType QDBusMessage::type() const
Returns the kind of the message.