Qt 4.8
|
The QDBusMessage class represents one message sent or received over the D-Bus bus. More...
#include <qdbusmessage.h>
Public Types | |
enum | MessageType { InvalidMessage, MethodCallMessage, ReplyMessage, ErrorMessage, SignalMessage } |
The possible message types: More... | |
Public Functions | |
QList< QVariant > | arguments () const |
Returns the list of arguments that are going to be sent or were received from D-Bus. More... | |
bool | autoStartService () const |
Returns the auto start flag, as set by setAutoStartService(). More... | |
QDBusMessage | createErrorReply (const QString name, const QString &msg) const |
Constructs a new DBus message representing an error reply message, with the given name and msg. More... | |
QDBusMessage | createErrorReply (const QDBusError &err) const |
Constructs a new DBus message representing an error reply message, from the given error object. More... | |
QDBusMessage | createErrorReply (QDBusError::ErrorType type, const QString &msg) const |
Constructs a new DBus reply message for the error type type using the message msg. More... | |
QDBusMessage | createReply (const QList< QVariant > &arguments=QList< QVariant >()) const |
Constructs a new DBus message representing a reply, with the given arguments. More... | |
QDBusMessage | createReply (const QVariant &argument) const |
Constructs a new DBus message representing a reply, with the given argument. More... | |
QString | errorMessage () const |
Returns the human-readable message associated with the error that was received. More... | |
QString | errorName () const |
Returns the name of the error that was received. More... | |
QString | interface () const |
Returns the interface of the method being called (in the case of a method call) or of the signal being received from. More... | |
bool | isDelayedReply () const |
Returns the delayed reply flag, as set by setDelayedReply(). More... | |
bool | isReplyRequired () const |
Returns the flag that indicates if this message should see a reply or not. More... | |
QString | member () const |
Returns the name of the signal that was emitted or the name of the method that was called. More... | |
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. More... | |
QDBusMessage & | operator= (const QDBusMessage &other) |
Copies the contents of the object given by other. More... | |
QString | 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). More... | |
QDBusMessage () | |
Constructs an empty, invalid QDBusMessage object. More... | |
QDBusMessage (const QDBusMessage &other) | |
Constructs a copy of the object given by other. More... | |
QString | service () const |
Returns the name of the service or the bus address of the remote method call. More... | |
void | setArguments (const QList< QVariant > &arguments) |
Sets the arguments that are going to be sent over D-Bus to arguments. More... | |
void | setAutoStartService (bool enable) |
Sets the auto start flag to enable. More... | |
void | setDelayedReply (bool enable) const |
Sets whether the message will be replied later (if enable is true) or if an automatic reply should be generated by QtDBus (if enable is false). More... | |
QString | signature () const |
Returns the signature of the signal that was received or for the output arguments of a method call. More... | |
MessageType | type () const |
Returns the message type. More... | |
~QDBusMessage () | |
Disposes of the object and frees any resources that were being held. More... | |
Static Public Functions | |
static QDBusMessage | createError (const QString &name, const QString &msg) |
Constructs a new DBus message representing an error, with the given name and msg. More... | |
static QDBusMessage | createError (const QDBusError &err) |
Constructs a new DBus message representing the given error. More... | |
static QDBusMessage | createError (QDBusError::ErrorType type, const QString &msg) |
Constructs a new DBus message for the error type type using the message msg. More... | |
static QDBusMessage | createMethodCall (const QString &destination, const QString &path, const QString &interface, const QString &method) |
Constructs a new DBus message representing a method call. More... | |
static QDBusMessage | createSignal (const QString &path, const QString &interface, const QString &name) |
Constructs a new DBus message with the given path, interface and name, representing a signal emission. More... | |
Properties | |
QDBusMessagePrivate * | d_ptr |
Friends | |
class | QDBusMessagePrivate |
The QDBusMessage class represents one message sent or received over the D-Bus bus.
This object can represent any of the four different types of messages (MessageType) that can occur on the bus:
Objects of this type are created with the static createError(), createMethodCall() and createSignal() functions. Use the QDBusConnection::send() function to send the messages.
Definition at line 59 of file qdbusmessage.h.
The possible message types:
Enumerator | |
---|---|
InvalidMessage | |
MethodCallMessage | |
ReplyMessage | |
ErrorMessage | |
SignalMessage |
Definition at line 62 of file qdbusmessage.h.
QDBusMessage::QDBusMessage | ( | ) |
Constructs an empty, invalid QDBusMessage object.
Definition at line 543 of file qdbusmessage.cpp.
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.
Definition at line 555 of file qdbusmessage.cpp.
QDBusMessage::~QDBusMessage | ( | ) |
Disposes of the object and frees any resources that were being held.
Definition at line 564 of file qdbusmessage.cpp.
Returns the list of arguments that are going to be sent or were received from D-Bus.
Definition at line 735 of file qdbusmessage.cpp.
Referenced by QDBusPendingReplyData::argumentAt(), QIcdEngine::asyncUpdateConfigurationsSlot(), QDBusAbstractInterface::callWithArgumentList(), QIcdEngine::connectionStateSignalsSlot(), QDBusConnectionPrivate::deliverCall(), do_dbus_call(), QDBusConnectionPrivate::findMetaObject(), QDBusConnectionPrivate::getNameOwnerNoCache(), QDBusConnectionPrivate::handleSignal(), messageToScriptValue(), QDBusInterfacePrivate::metacall(), operator<<(), operator<<(), QDBusConnectionPrivate::prepareReply(), qDBusPropertyGet(), qDBusPropertyGetAll(), qDBusPropertySet(), qDBusReplyFill(), QDBusConnectionInterface::registerService(), QIcdEngine::requestUpdate(), QNetworkSessionPrivateImpl::stateChange(), and QDBusConnectionInterface::unregisterService().
bool QDBusMessage::autoStartService | ( | ) | const |
Returns the auto start flag, as set by setAutoStartService().
By default, this flag is true, which means QtDBus will auto start a service, if it is not running already.
Definition at line 714 of file qdbusmessage.cpp.
|
static |
Constructs a new DBus message representing an error, with the given name and msg.
Definition at line 427 of file qdbusmessage.cpp.
Referenced by QDBusConnection::call(), QDBusAbstractInterface::callWithArgumentList(), QDBusPendingCallPrivate::checkReceivedSignature(), QScriptDBusMessageConstructor::createError(), createErrorReply(), QDBusPendingCall::fromError(), QDBusMessagePrivate::makeLocal(), QDBusPendingCall::operator=(), QDBusConnectionPrivate::sendWithReply(), QDBusConnectionPrivate::sendWithReplyAsync(), and QDBusConnectionPrivate::sendWithReplyLocal().
|
inlinestatic |
Constructs a new DBus message representing the given error.
Definition at line 80 of file qdbusmessage.h.
|
inlinestatic |
Constructs a new DBus message for the error type type using the message msg.
Returns the DBus message.
Definition at line 82 of file qdbusmessage.h.
QDBusMessage QDBusMessage::createErrorReply | ( | const QString | name, |
const QString & | msg | ||
) | const |
Constructs a new DBus message representing an error reply message, with the given name and msg.
Definition at line 486 of file qdbusmessage.cpp.
Referenced by QScriptDBusMessageConstructor::createErrorReply(), QDBusConnectionPrivate::deliverCall(), QDBusConnectionPrivate::handleObjectCall(), interfaceNotFoundError(), propertyNotFoundError(), propertyWriteReply(), and QDBusConnectionPrivate::sendError().
|
inline |
Constructs a new DBus message representing an error reply message, from the given error object.
Definition at line 90 of file qdbusmessage.h.
QDBusMessage QDBusMessage::createErrorReply | ( | QDBusError::ErrorType | type, |
const QString & | msg | ||
) | const |
Constructs a new DBus reply message for the error type type using the message msg.
Returns the DBus message.
Definition at line 530 of file qdbusmessage.cpp.
|
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().
Definition at line 410 of file qdbusmessage.cpp.
Referenced by QDBusAbstractInterface::asyncCallWithArgumentList(), QDBusAbstractInterface::callWithArgumentList(), QDBusAbstractInterface::callWithCallback(), QScriptDBusMessageConstructor::createMethodCall(), do_dbus_call(), QDBusConnectionPrivate::findMetaObject(), QDBusConnectionPrivate::getNameOwnerNoCache(), QDBusAbstractInterfacePrivate::property(), and QDBusAbstractInterfacePrivate::setProperty().
QDBusMessage QDBusMessage::createReply | ( | const QList< QVariant > & | arguments = QList<QVariant>() | ) | const |
Constructs a new DBus message representing a reply, with the given arguments.
Definition at line 465 of file qdbusmessage.cpp.
Referenced by QDBusConnectionPrivate::activateInternalFilters(), QScriptDBusMessageConstructor::createReply(), QDBusConnectionPrivate::deliverCall(), propertyWriteReply(), qDBusPropertyGet(), and qDBusPropertyGetAll().
|
inline |
Constructs a new DBus message representing a reply, with the given argument.
Definition at line 86 of file qdbusmessage.h.
|
static |
Constructs a new DBus message with the given path, interface and name, 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 QDBusMessage object that is returned can be sent using the QDBusConnection::send() function.
Definition at line 379 of file qdbusmessage.cpp.
Referenced by QScriptDBusMessageConstructor::createSignal(), and QDBusConnectionPrivate::relaySignal().
QString QDBusMessage::errorMessage | ( | ) | const |
Returns the human-readable message associated with the error that was received.
Definition at line 88 of file qdbusmessage.cpp.
Referenced by operator<<(), QDBusError::QDBusError(), and QOfonoPrimaryDataContextInterface::setProp().
QString QDBusMessage::errorName | ( | ) | const |
Returns the name of the error that was received.
Definition at line 622 of file qdbusmessage.cpp.
Referenced by operator<<(), and QDBusError::QDBusError().
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.
Definition at line 604 of file qdbusmessage.cpp.
Referenced by QDBusConnectionPrivate::activateObject(), QDBusConnectionPrivate::handleSignal(), messageToScriptValue(), operator<<(), QDBusConnectionPrivate::send(), QDBusConnectionPrivate::sendError(), QDBusConnectionPrivate::sendWithReply(), and QDBusConnectionPrivate::sendWithReplyAsync().
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.
Definition at line 675 of file qdbusmessage.cpp.
Referenced by QDBusConnectionPrivate::deliverCall(), QDBusContext::isDelayedReply(), and messageToScriptValue().
bool QDBusMessage::isReplyRequired | ( | ) | const |
Returns the flag that indicates if this message should see a reply or not.
This is only meaningful for MethodCallMessage{method call messages}: any other kind of message cannot have replies and this function will always return false for them.
Definition at line 644 of file qdbusmessage.cpp.
Referenced by QDBusConnectionPrivate::deliverCall(), and messageToScriptValue().
QString QDBusMessage::member | ( | ) | const |
Returns the name of the signal that was emitted or the name of the method that was called.
Definition at line 612 of file qdbusmessage.cpp.
Referenced by QDBusConnectionPrivate::activateCall(), QDBusConnectionPrivate::activateInternalFilters(), QDBusConnectionPrivate::handleSignal(), messageToScriptValue(), operator<<(), QDBusConnectionPrivate::send(), QDBusConnectionPrivate::sendError(), QDBusConnectionPrivate::sendWithReply(), QDBusConnectionPrivate::sendWithReplyAsync(), and QDBusConnectionPrivate::sendWithReplyLocal().
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.
Definition at line 745 of file qdbusmessage.cpp.
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.
Definition at line 577 of file qdbusmessage.cpp.
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).
Definition at line 595 of file qdbusmessage.cpp.
Referenced by QDBusConnectionPrivate::activateInternalFilters(), QDBusConnectionPrivate::activateObject(), QNmDBusHelper::deviceStateChanged(), QDBusConnectionPrivate::handleObjectCall(), QDBusConnectionPrivate::handleSignal(), interfaceNotFoundError(), messageToScriptValue(), operator<<(), QOfonoDBusHelper::propertyChanged(), QConnmanDBusHelper::propertyChanged(), propertyNotFoundError(), QDBusConnectionPrivate::send(), QDBusConnectionPrivate::sendError(), QDBusConnectionPrivate::sendWithReply(), QDBusConnectionPrivate::sendWithReplyAsync(), QDBusConnectionPrivate::sendWithReplyLocal(), QNmDBusHelper::slotAccessPointAdded(), QNmDBusHelper::slotAccessPointRemoved(), QNmDBusHelper::slotPropertiesChanged(), and QNmDBusHelper::slotSettingsRemoved().
QString QDBusMessage::service | ( | ) | const |
Returns the name of the service or the bus address of the remote method call.
Definition at line 586 of file qdbusmessage.cpp.
Referenced by QDBusConnectionPrivate::handleSignal(), messageToScriptValue(), operator<<(), QDBusConnectionPrivate::send(), QDBusConnectionPrivate::sendWithReply(), and QDBusConnectionPrivate::sendWithReplyAsync().
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.
Definition at line 725 of file qdbusmessage.cpp.
Referenced by QDBusAbstractInterface::asyncCallWithArgumentList(), QDBusAbstractInterface::callWithArgumentList(), QDBusAbstractInterface::callWithCallback(), createReply(), do_dbus_call(), QDBusConnectionInterface::registerService(), QDBusConnectionPrivate::relaySignal(), scriptValueToMessage(), and QDBusConnectionInterface::unregisterService().
void QDBusMessage::setAutoStartService | ( | bool | enable | ) |
Sets the auto start flag to enable.
This flag only makes sense for method call messages, where it tells the D-Bus server to either auto start the service responsible for the service name, or not to auto start it.
By default this flag is true, i.e. a service is autostarted. This means:
When the service that this method call is sent to is already running, the method call is sent to it. If the service is not running yet, the D-Bus daemon is requested to autostart the service that is assigned to this service name. This is handled by .service files that are placed in a directory known to the D-Bus server. These files then each contain a service name and the path to a program that should be executed when this service name is requested.
Definition at line 700 of file qdbusmessage.cpp.
void QDBusMessage::setDelayedReply | ( | bool | enable | ) | const |
Sets whether the message will be replied later (if enable is true) or if an automatic reply should be generated by QtDBus (if enable is false).
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.
Definition at line 665 of file qdbusmessage.cpp.
Referenced by scriptValueToMessage(), and QDBusContext::setDelayedReply().
QString QDBusMessage::signature | ( | ) | const |
Returns the signature of the signal that was received or for the output arguments of a method call.
Definition at line 633 of file qdbusmessage.cpp.
Referenced by QDBusConnectionPrivate::activateCall(), QDBusConnectionPrivate::activateInternalFilters(), QDBusConnectionPrivate::findMetaObject(), QDBusConnectionPrivate::handleSignal(), messageToScriptValue(), operator<<(), QDBusConnectionPrivate::sendError(), and QDBusConnectionPrivate::sendWithReplyLocal().
QDBusMessage::MessageType QDBusMessage::type | ( | ) | const |
Returns the message type.
Definition at line 755 of file qdbusmessage.cpp.
Referenced by QDBusPendingCallWatcherHelper::emitSignals(), QDBusConnectionPrivate::findMetaObject(), QDBusPendingCall::fromCompletedCall(), QDBusConnectionPrivate::getNameOwnerNoCache(), QDBusConnectionPrivate::handleMessage(), messageToScriptValue(), QDBusInterfacePrivate::metacall(), operator<<(), QDBusPendingCall::operator=(), QDBusError::QDBusError(), QDBusPendingCallWatcher::QDBusPendingCallWatcher(), QDBusConnectionInterface::registerService(), QDBusConnectionPrivate::send(), QDBusConnectionPrivate::sendWithReply(), QDBusConnectionPrivate::sendWithReplyLocal(), QOfonoPrimaryDataContextInterface::setProp(), and QDBusConnectionInterface::unregisterService().
|
friend |
Definition at line 118 of file qdbusmessage.h.
|
private |
Definition at line 119 of file qdbusmessage.h.
Referenced by createError(), createErrorReply(), createMethodCall(), createReply(), createSignal(), QDBusMessagePrivate::fromDBusMessage(), QDBusMessagePrivate::isLocal(), QDBusMessagePrivate::makeLocal(), QDBusMessagePrivate::makeLocalReply(), operator=(), QDBusMessage(), QDBusMessagePrivate::setParametersValidated(), and QDBusMessagePrivate::toDBusMessage().