QDBusMessage#
The QDBusMessage
class represents one message sent or received over the D-Bus bus. More…
Synopsis#
Functions#
def
arguments
()def
autoStartService
()def
createErrorReply
(type, msg)def
createErrorReply
(err)def
createErrorReply
(name, msg)def
createReply
([arguments=list()])def
createReply
(argument)def
errorMessage
()def
errorName
()def
interface
()def
isDelayedReply
()def
isReplyRequired
()def
member
()def
__lshift__
(arg)def
path
()def
service
()def
setArguments
(arguments)def
setAutoStartService
(enable)def
setDelayedReply
(enable)def
setInteractiveAuthorizationAllowed
(enable)def
signature
()def
swap
(other)def
type
()
Static functions#
def
createError
(type, msg)def
createError
(err)def
createError
(name, msg)def
createMethodCall
(destination, path, interface, method)def
createSignal
(path, interface, name)def
createTargetedSignal
(service, path, interface, name)
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description#
This object can represent any of the four different types of messages ( MessageType
) that can occur on the bus:
Method calls
Method return values
Signal emissions
Error codes
Objects of this type are created with the static createError()
, createMethodCall()
and createSignal()
functions. Use the send()
function to send the messages.
- class PySide6.QtDBus.QDBusMessage#
PySide6.QtDBus.QDBusMessage(other)
- Parameters:
other –
PySide6.QtDBus.QDBusMessage
Constructs an empty, invalid QDBusMessage
object.
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.
- PySide6.QtDBus.QDBusMessage.MessageType#
The possible message types:
Constant
Description
QDBusMessage.MethodCallMessage
a message representing an outgoing or incoming method call
QDBusMessage.SignalMessage
a message representing an outgoing or incoming signal emission
QDBusMessage.ReplyMessage
a message representing the return values of a method call
QDBusMessage.ErrorMessage
a message representing an error condition in response to a method call
QDBusMessage.InvalidMessage
an invalid message: this is never set on messages received from D-Bus
- PySide6.QtDBus.QDBusMessage.arguments()#
Returns the list of arguments that are going to be sent or were received from D-Bus.
See also
- PySide6.QtDBus.QDBusMessage.autoStartService()#
- Return type:
bool
Returns the auto start flag, as set by setAutoStartService()
. By default, this flag is true, which means Qt D-Bus will auto start a service, if it is not running already.
See also
- static PySide6.QtDBus.QDBusMessage.createError(type, msg)#
- Parameters:
type –
ErrorType
msg – str
- Return type:
Constructs a new DBus message for the error type type
using the message msg
. Returns the DBus message.
- static PySide6.QtDBus.QDBusMessage.createError(err)
- Parameters:
- Return type:
Constructs a new DBus message representing the given error
.
- static PySide6.QtDBus.QDBusMessage.createError(name, msg)
- Parameters:
name – str
msg – str
- Return type:
Constructs a new DBus message representing an error, with the given name
and msg
.
- PySide6.QtDBus.QDBusMessage.createErrorReply(type, msg)#
- Parameters:
type –
ErrorType
msg – str
- Return type:
Constructs a new DBus reply message for the error type type
using the message msg
. Returns the DBus message.
- PySide6.QtDBus.QDBusMessage.createErrorReply(err)
- Parameters:
- Return type:
Constructs a new DBus message representing an error reply message, from the given error
object.
- PySide6.QtDBus.QDBusMessage.createErrorReply(name, msg)
- Parameters:
name – str
msg – str
- Return type:
Constructs a new DBus message representing an error reply message, with the given name
and msg
.
- static PySide6.QtDBus.QDBusMessage.createMethodCall(destination, path, interface, method)#
- Parameters:
destination – str
path – str
interface – str
method – str
- Return type:
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 QDBusInterface
class provides a simpler abstraction to synchronous method calling.
This function returns a QDBusMessage
object that can be sent with call()
.
- PySide6.QtDBus.QDBusMessage.createReply([arguments=list()])#
- Parameters:
arguments –
- Return type:
Constructs a new DBus message representing a reply, with the given arguments
.
- PySide6.QtDBus.QDBusMessage.createReply(argument)
- Parameters:
argument – object
- Return type:
Constructs a new DBus message representing a reply, with the given argument
.
- static PySide6.QtDBus.QDBusMessage.createSignal(path, interface, name)#
- Parameters:
path – str
interface – str
name – str
- Return type:
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 send()
function.
- static PySide6.QtDBus.QDBusMessage.createTargetedSignal(service, path, interface, name)#
- Parameters:
service – str
path – str
interface – str
name – str
- Return type:
Constructs a new DBus message with the given path
, interface
and name
, representing a signal emission to a specific destination.
A DBus signal is emitted from one application and is received only by the application owning the destination service
name.
The QDBusMessage
object that is returned can be sent using the send()
function.
- PySide6.QtDBus.QDBusMessage.errorMessage()#
- Return type:
str
Returns the human-readable message associated with the error that was received.
- PySide6.QtDBus.QDBusMessage.errorName()#
- Return type:
str
Returns the name of the error that was received.
- PySide6.QtDBus.QDBusMessage.interface()#
- Return type:
str
Returns the interface of the method being called (in the case of a method call) or of the signal being received from.
- PySide6.QtDBus.QDBusMessage.isDelayedReply()#
- Return type:
bool
Returns the delayed reply flag, as set by setDelayedReply()
. By default, this flag is false, which means Qt D-Bus will generate automatic replies when necessary.
- PySide6.QtDBus.QDBusMessage.isInteractiveAuthorizationAllowed()#
- Return type:
bool
Returns the interactive authorization allowed flag, as set by setInteractiveAuthorizationAllowed()
. By default this flag is false and the other end is expected to make any authorization decisions non-interactively and promptly.
See also
- PySide6.QtDBus.QDBusMessage.isReplyRequired()#
- Return type:
bool
Returns the flag that indicates if this message should see a reply or not. This is only meaningful for method call messages
: any other kind of message cannot have replies and this function will always return false for them.
- PySide6.QtDBus.QDBusMessage.member()#
- Return type:
str
Returns the name of the signal that was emitted or the name of the method that was called.
- PySide6.QtDBus.QDBusMessage.__lshift__(arg)#
- Parameters:
arg – object
- Return type:
Appends the argument arg
to the list of arguments to be sent over D-Bus in a method call or signal emission.
- PySide6.QtDBus.QDBusMessage.path()#
- Return type:
str
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).
- PySide6.QtDBus.QDBusMessage.service()#
- Return type:
str
Returns the name of the service or the bus address of the remote method call.
- PySide6.QtDBus.QDBusMessage.setArguments(arguments)#
- Parameters:
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
- PySide6.QtDBus.QDBusMessage.setAutoStartService(enable)#
- Parameters:
enable – bool
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.
See also
- PySide6.QtDBus.QDBusMessage.setDelayedReply(enable)#
- Parameters:
enable – bool
Sets whether the message will be replied later (if enable
is true) or if an automatic reply should be generated by Qt D-Bus (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.
See also
- PySide6.QtDBus.QDBusMessage.setInteractiveAuthorizationAllowed(enable)#
- Parameters:
enable – bool
Sets the interactive authorization flag to enable
. This flag only makes sense for method call messages, where it tells the D-Bus server that the caller of the method is prepared to wait for interactive authorization to take place (for instance via Polkit) before the actual method is processed.
By default this flag is false and the other end is expected to make any authorization decisions non-interactively and promptly.
The org.freedesktop.DBus.Error.InteractiveAuthorizationRequired
error indicates that authorization failed, but could have succeeded if this flag had been set.
See also
- PySide6.QtDBus.QDBusMessage.signature()#
- Return type:
str
Returns the signature of the signal that was received or for the output arguments of a method call.
- PySide6.QtDBus.QDBusMessage.swap(other)#
- Parameters:
other –
PySide6.QtDBus.QDBusMessage
Swaps this QDBusMessage
instance with other
.
- PySide6.QtDBus.QDBusMessage.type()#
- Return type:
Returns the message type.