Gio.DBusMessage¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
|---|---|---|---|
r |
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class Gio.DBusMessage(**kwargs)¶
- Bases:
- Abstract:
No
A type for representing D-Bus messages that can be sent or received on a [class`Gio`.DBusConnection].
Added in version 2.26.
- classmethod bytes_needed(blob)[source]¶
- Parameters:
blob (
bytes) – a blob representing a binary D-Bus message.- Raises:
- Returns:
Number of bytes needed or
-1if error is set- Return type:
Utility function to calculate how many bytes are needed to completely deserialize the D-Bus message stored at blob.
An error will be returned if blob contains invalid data, or if not enough data is available to determine the size.
Added in version 2.26.
- classmethod new()[source]¶
- Returns:
The D-Bus message
- Return type:
Creates a new empty D-Bus message.
Added in version 2.26.
- classmethod new_from_blob(blob, capabilities)[source]¶
- Parameters:
blob (
bytes) – a blob representing a binary D-Bus messagecapabilities (
Gio.DBusCapabilityFlags) – flags describing what protocol features are supported
- Raises:
- Returns:
The D-Bus message
- Return type:
Creates a new D-Bus message from the data stored at blob.
You must have previously called [func`Gio`.DBusMessage.bytes_needed] on blob, and ensure that blob is at least as long as the return value from that function indicates. In particular, that means that blob must be at least 16 bytes long (but will typically be much longer).
The byte order that the message was in can be retrieved using [method`Gio`.DBusMessage.get_byte_order].
If the blob cannot be parsed, contains invalid fields, or contains invalid headers, [error`Gio`.IOErrorEnum.INVALID_ARGUMENT] will be returned.
Added in version 2.26.
- classmethod new_method_call(name, path, interface_, method)[source]¶
- Parameters:
- Returns:
The D-Bus message
- Return type:
Creates a new D-Bus message for a method call.
Added in version 2.26.
- classmethod new_signal(path, interface_, signal)[source]¶
- Parameters:
- Returns:
The D-Bus message
- Return type:
Creates a new D-Bus message for a signal emission.
Added in version 2.26.
- copy()[source]¶
- Raises:
- Returns:
A new D-Bus message
- Return type:
Copies self with a deep copy.
The returned D-Bus message is completely identical to self except that it is guaranteed to not be locked.
This operation can fail if (for example) self contains file descriptors and the per-process or system-wide open files limit is reached.
Added in version 2.26.
- get_arg0()[source]¶
- Returns:
The string item, or
NULLif the first item in the body of self is not a string- Return type:
Convenience to get the first item in the body of self.
See [method`Gio`.DBusMessage.get_arg0_path] for returning object-path-typed arg0 values.
Added in version 2.26.
- get_arg0_path()[source]¶
- Returns:
The object path item, or
NULLif the first item in the body of self is not an object path- Return type:
Convenience to get the first item in the body of self.
See [method`Gio`.DBusMessage.get_arg0] for returning string-typed arg0 values.
Added in version 2.80.
- get_body()[source]¶
- Returns:
A [type`GLib`.Variant], or
NULLif the body is empty- Return type:
GLib.VariantorNone
Gets the body of a message.
Added in version 2.26.
- get_destination()[source]¶
-
Convenience getter for the [enum`Gio`.DBusMessageHeaderField.DESTINATION] header field.
Added in version 2.26.
- get_error_name()[source]¶
-
Convenience getter for the [enum`Gio`.DBusMessageHeaderField.ERROR_NAME] header field.
Added in version 2.26.
- get_flags()[source]¶
- Returns:
Flags that are set (typically values from the [flags`Gio`.DBusMessageFlags] enumeration bitwise ORed together)
- Return type:
Gets the flags for self.
Added in version 2.26.
- get_header(header_field)[source]¶
- Parameters:
header_field (
Gio.DBusMessageHeaderField) – a 8-bit unsigned integer (typically a value from the [enum`Gio`.DBusMessageHeaderField] enumeration)- Returns:
A [type`GLib`.Variant] with the value, or
NULLif the header was not found- Return type:
GLib.VariantorNone
Gets a header field on self.
The caller is responsible for checking the type of the returned [type`GLib`.Variant] matches what is expected.
Added in version 2.26.
- get_header_fields()[source]¶
- Returns:
An array of header fields terminated by [enum`Gio`.DBusMessageHeaderField.INVALID]
- Return type:
Gets an array of all header fields on self that are set.
Each element in the array is an
unsigned char.Added in version 2.26.
- get_interface()[source]¶
-
Convenience getter for the [enum`Gio`.DBusMessageHeaderField.INTERFACE] header field.
Added in version 2.26.
- get_locked()[source]¶
- Returns:
true if self is locked, false otherwise
- Return type:
Checks whether self is locked.
To monitor changes to this value, connect to the [signal`GObject`.Object::notify] signal to listen for changes on the [property`Gio`.DBusMessage:locked] property.
Added in version 2.26.
- get_member()[source]¶
-
Convenience getter for the [enum`Gio`.DBusMessageHeaderField.MEMBER] header field.
Added in version 2.26.
- get_message_type()[source]¶
- Returns:
A 8-bit unsigned integer (typically a value from the [enum`Gio`.DBusMessageType] enumeration)
- Return type:
Gets the type of self.
Added in version 2.26.
- get_num_unix_fds()[source]¶
- Returns:
The value
- Return type:
Convenience getter for the [enum`Gio`.DBusMessageHeaderField.NUM_UNIX_FDS] header field.
Added in version 2.26.
- get_path()[source]¶
-
Convenience getter for the [enum`Gio`.DBusMessageHeaderField.PATH] header field.
Added in version 2.26.
- get_reply_serial()[source]¶
- Returns:
The value
- Return type:
Convenience getter for the [enum`Gio`.DBusMessageHeaderField.REPLY_SERIAL] header field.
Added in version 2.26.
- get_sender()[source]¶
-
Convenience getter for the [enum`Gio`.DBusMessageHeaderField.SENDER] header field.
Added in version 2.26.
- get_serial()[source]¶
- Returns:
The serial number, which should not be zero
- Return type:
Gets the serial for self.
Added in version 2.26.
- get_signature()[source]¶
- Returns:
The value
- Return type:
Convenience getter for the [enum`Gio`.DBusMessageHeaderField.SIGNATURE header field.
This will always be non-
NULL, but may be an empty string.Added in version 2.26.
- get_unix_fd_list()[source]¶
- Returns:
A [class`Gio`.UnixFDList] or
NULLif no file descriptors are associated- Return type:
Gets the UNIX file descriptors associated with self, if any.
This method is only available on UNIX.
The file descriptors normally correspond to
G_VARIANT_TYPE_HANDLEvalues in the body of the message. For example, if [method`GLib`.Variant.get_handle] returns 5, that is intended to be a reference to the file descriptor that can be accessed byg_unix_fd_list_get (list, 5, ...).Added in version 2.26.
- lock()[source]¶
Locks the message.
If self is locked already, this does nothing.
Added in version 2.26.
- new_method_error_literal(error_name, error_message)[source]¶
- Parameters:
- Returns:
The D-Bus message
- Return type:
Creates a new D-Bus message that is an error reply to self.
Added in version 2.26.
- new_method_reply()[source]¶
- Returns:
The D-Bus message
- Return type:
Creates a new D-Bus message that is a reply to self.
Added in version 2.26.
- print_(indent)[source]¶
- Parameters:
indent (
int) – indentation level- Returns:
Human readable description of self
- Return type:
Produces a human-readable multi-line description of self.
The contents and formatting are subject to change at any time and no ABI guarantees are given. Typical output looks something like this: `` Flags: none Version: 0 Serial: 4 Headers:
path -> objectpath ‘/org/gtk/GDBus/TestObject’ interface -> ‘org.gtk.GDBus.TestInterface’ member -> ‘GimmeStdout’ destination -> ‘:1.146’
Body: () UNIX File Descriptors:
(none)
or¶
Flags: no-reply-expected Version: 0 Serial: 477 Headers:
reply-serial -> uint32 4 destination -> ‘:1.159’ sender -> ‘:1.146’ num-unix-fds -> uint32 1
Body: () UNIX File Descriptors:
fd 12: dev=0:10,mode=020620,ino=5,uid=500,gid=5,rdev=136:2,size=0,atime=1273085037,mtime=1273085851,ctime=1272982635
Added in version 2.26.
- set_body(body)[source]¶
- Parameters:
body (
GLib.Variant) – a [type`GLib`.Variant] containing a tuple, orNULLif no body is needed
Sets the body of self.
As a side-effect the [enum`Gio`.DBusMessageHeaderField.SIGNATURE] header field is set to the type string of body (or cleared if body is
NULL).If body is floating, self assumes ownership of body.
Added in version 2.26.
- set_byte_order(byte_order)[source]¶
- Parameters:
byte_order (
Gio.DBusMessageByteOrder) – the byte order
Sets the byte order of self.
- set_destination(value)[source]¶
-
Convenience setter for the [enum`Gio`.DBusMessageHeaderField.DESTINATION] header field.
Added in version 2.26.
- set_error_name(value)[source]¶
-
Convenience setter for the [enum`Gio`.DBusMessageHeaderField.ERROR_NAME] header field.
Added in version 2.26.
- set_flags(flags)[source]¶
- Parameters:
flags (
Gio.DBusMessageFlags) – flags for self that are set (typically values from the [flags`Gio`.DBusMessageFlags] enumeration bitwise ORed together)
Sets the flags to set on self.
Added in version 2.26.
- set_header(header_field, value)[source]¶
- Parameters:
header_field (
Gio.DBusMessageHeaderField) – a 8-bit unsigned integer (typically a value from the [enum`Gio`.DBusMessageHeaderField enumeration)value (
GLib.VariantorNone) – a [type`GLib`.Variant] to set the header field, orNULLto clear the header field.
Sets a header field on self.
If value is floating, self assumes ownership of value.
Added in version 2.26.
- set_interface(value)[source]¶
-
Convenience setter for the [enum`Gio`.DBusMessageHeaderField.INTERFACE] header field.
Added in version 2.26.
- set_member(value)[source]¶
-
Convenience setter for the [enum`Gio`.DBusMessageHeaderField.MEMBER] header field.
Added in version 2.26.
- set_message_type(type)[source]¶
- Parameters:
type (
Gio.DBusMessageType) – a 8-bit unsigned integer (typically a value from the [enum`Gio`.DBusMessageType] enumeration)
Sets self to be of type.
Added in version 2.26.
- set_num_unix_fds(value)[source]¶
- Parameters:
value (
int) – the value to set
Convenience setter for the [enum`Gio`.DBusMessageHeaderField.NUM_UNIX_FDS] header field.
Added in version 2.26.
- set_path(value)[source]¶
-
Convenience setter for the [enum`Gio`.DBusMessageHeaderField.PATH] header field.
Added in version 2.26.
- set_reply_serial(value)[source]¶
- Parameters:
value (
int) – the value to set
Convenience setter for the [enum`Gio`.DBusMessageHeaderField.REPLY_SERIAL] header field.
Added in version 2.26.
- set_sender(value)[source]¶
-
Convenience setter for the [enum`Gio`.DBusMessageHeaderField.SENDER] header field.
Added in version 2.26.
- set_serial(serial)[source]¶
- Parameters:
serial (
int) – a serial number, which must not be zero
Sets the serial for self.
The D-Bus specification does not allow the serial to be zero.
Added in version 2.26.
- set_signature(value)[source]¶
-
Convenience setter for the [enum`Gio`.DBusMessageHeaderField.SIGNATURE] header field.
Added in version 2.26.
- set_unix_fd_list(fd_list)[source]¶
- Parameters:
fd_list (
Gio.UnixFDListorNone) – A [class`Gio`.UnixFDList], orNULLto clear
Sets the UNIX file descriptors associated with self.
As a side-effect the [enum`Gio`.DBusMessageHeaderField.NUM_UNIX_FDS] header field is set to the number of fds in fd_list (or cleared if fd_list is
NULL).This method is only available on UNIX.
When designing D-Bus APIs that are intended to be interoperable, please note that non-GDBus implementations of D-Bus can usually only access file descriptors if they are referenced by a value of type
G_VARIANT_TYPE_HANDLEin the body of the message.Added in version 2.26.
- to_blob(capabilities)[source]¶
- Parameters:
capabilities (
Gio.DBusCapabilityFlags) – flags describing what protocol features are supported- Raises:
- Returns:
A pointer to a valid binary D-Bus message of out_size bytes generated by self
- Return type:
Serializes self to a blob.
The byte order returned by [method`Gio`.DBusMessage.get_byte_order] will be used.
Added in version 2.26.
- to_gerror()[source]¶
- Raises:
- Returns:
true if error was set, false otherwise
- Return type:
Encodes the error in self as a [type`GLib`.Error].
If self is of type [enum`Gio`.DBusMessageType.ERROR], this function calls [func`Gio`.DBusError.set_dbus_error] using the information in the [enum`Gio`.DBusMessageHeaderField.ERROR_NAME] header field of self as well as the first string item in self’s body.
If self is not of type [enum`Gio`.DBusMessageType.ERROR], this function does nothing and returns false.
Added in version 2.26.