| GIO Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | Object Hierarchy | ||||
#include <gio/gio.h> enum GDBusMessageType; enum GDBusMessageFlags; enum GDBusMessageHeaderField; GDBusMessage; GDBusMessageClass; GDBusMessage * g_dbus_message_new (void); GDBusMessage * g_dbus_message_new_signal (const gchar *path,const gchar *interface_,const gchar *signal); GDBusMessage * g_dbus_message_new_method_call (const gchar *name,const gchar *path,const gchar *interface_,const gchar *method); GDBusMessage * g_dbus_message_new_method_reply (GDBusMessage *method_call_message); GDBusMessage * g_dbus_message_new_method_error (GDBusMessage *method_call_message,const gchar *error_name,const gchar *error_message_format,...); GDBusMessage * g_dbus_message_new_method_error_valist (GDBusMessage *method_call_message,const gchar *error_name,const gchar *error_message_format,va_list var_args); GDBusMessage * g_dbus_message_new_method_error_literal (GDBusMessage *method_call_message,const gchar *error_name,const gchar *error_message); gchar * g_dbus_message_print (GDBusMessage *message,guint indent); GDBusMessageType g_dbus_message_get_message_type (GDBusMessage *message); void g_dbus_message_set_message_type (GDBusMessage *message,GDBusMessageType type); guint32 g_dbus_message_get_serial (GDBusMessage *message); void g_dbus_message_set_serial (GDBusMessage *message,guint32 serial); GDBusMessageFlags g_dbus_message_get_flags (GDBusMessage *message); void g_dbus_message_set_flags (GDBusMessage *message,GDBusMessageFlags flags); GVariant * g_dbus_message_get_body (GDBusMessage *message); void g_dbus_message_set_body (GDBusMessage *message,GVariant *body); GUnixFDList * g_dbus_message_get_unix_fd_list (GDBusMessage *message); void g_dbus_message_set_unix_fd_list (GDBusMessage *message,GUnixFDList *fd_list); guint32 g_dbus_message_get_num_unix_fds (GDBusMessage *message); void g_dbus_message_set_num_unix_fds (GDBusMessage *message,guint32 value); guchar * g_dbus_message_get_header_fields (GDBusMessage *message); GVariant * g_dbus_message_get_header (GDBusMessage *message,GDBusMessageHeaderField header_field); void g_dbus_message_set_header (GDBusMessage *message,GDBusMessageHeaderField header_field,GVariant *value); const gchar * g_dbus_message_get_destination (GDBusMessage *message); void g_dbus_message_set_destination (GDBusMessage *message,const gchar *value); const gchar * g_dbus_message_get_error_name (GDBusMessage *message); void g_dbus_message_set_error_name (GDBusMessage *message,const gchar *value); const gchar * g_dbus_message_get_interface (GDBusMessage *message); void g_dbus_message_set_interface (GDBusMessage *message,const gchar *value); const gchar * g_dbus_message_get_member (GDBusMessage *message); void g_dbus_message_set_member (GDBusMessage *message,const gchar *value); const gchar * g_dbus_message_get_path (GDBusMessage *message); void g_dbus_message_set_path (GDBusMessage *message,const gchar *value); guint32 g_dbus_message_get_reply_serial (GDBusMessage *message); void g_dbus_message_set_reply_serial (GDBusMessage *message,guint32 value); const gchar * g_dbus_message_get_sender (GDBusMessage *message); void g_dbus_message_set_sender (GDBusMessage *message,const gchar *value); const gchar * g_dbus_message_get_signature (GDBusMessage *message); void g_dbus_message_set_signature (GDBusMessage *message,const gchar *value); const gchar * g_dbus_message_get_arg0 (GDBusMessage *message); guchar * g_dbus_message_to_blob (GDBusMessage *message,gsize *out_size,GDBusCapabilityFlags capabilities,GError **error); gssize g_dbus_message_bytes_needed (guchar *blob,gsize blob_len,GError **error); GDBusMessage * g_dbus_message_new_from_blob (guchar *blob,gsize blob_len,GDBusCapabilityFlags capabilities,GError **error); gboolean g_dbus_message_to_gerror (GDBusMessage *message,GError **error);
A type for representing D-Bus messages that can be sent or received on a GDBusConnection.
typedef enum {
G_DBUS_MESSAGE_TYPE_INVALID,
G_DBUS_MESSAGE_TYPE_METHOD_CALL,
G_DBUS_MESSAGE_TYPE_METHOD_RETURN,
G_DBUS_MESSAGE_TYPE_ERROR,
G_DBUS_MESSAGE_TYPE_SIGNAL
} GDBusMessageType;
Message types used in GDBusMessage.
| Message is of invalid type. | |
| Method call. | |
| Method reply. | |
| Error reply. | |
| Signal emission. |
Since 2.26
typedef enum {
G_DBUS_MESSAGE_FLAGS_NONE = 0,
G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED = (1<<0),
G_DBUS_MESSAGE_FLAGS_NO_AUTO_START = (1<<1)
} GDBusMessageFlags;
Message flags used in GDBusMessage.
| No flags set. | |
| A reply is not expected. | |
| The bus must not launch an owner for the destination name in response to this message. |
Since 2.26
typedef enum {
G_DBUS_MESSAGE_HEADER_FIELD_INVALID,
G_DBUS_MESSAGE_HEADER_FIELD_PATH,
G_DBUS_MESSAGE_HEADER_FIELD_INTERFACE,
G_DBUS_MESSAGE_HEADER_FIELD_MEMBER,
G_DBUS_MESSAGE_HEADER_FIELD_ERROR_NAME,
G_DBUS_MESSAGE_HEADER_FIELD_REPLY_SERIAL,
G_DBUS_MESSAGE_HEADER_FIELD_DESTINATION,
G_DBUS_MESSAGE_HEADER_FIELD_SENDER,
G_DBUS_MESSAGE_HEADER_FIELD_SIGNATURE,
G_DBUS_MESSAGE_HEADER_FIELD_NUM_UNIX_FDS
} GDBusMessageHeaderField;
Header fields used in GDBusMessage.
| Not a valid header field. | |
| The object path. | |
| The interface name. | |
| The method or signal name. | |
| The name of the error that occurred. | |
| The serial number the message is a reply to. | |
| The name the message is intended for. | |
| Unique name of the sender of the message (filled in by the bus). | |
| The signature of the message body. | |
| The number of UNIX file descriptors that accompany the message. |
Since 2.26
typedef struct _GDBusMessage GDBusMessage;
The GDBusMessage structure contains only private data and should only be accessed using the provided API.
Since 2.26
typedef struct {
} GDBusMessageClass;
Class structure for GDBusMessage.
Since 2.26
GDBusMessage * g_dbus_message_new (void);
Creates a new empty GDBusMessage.
Returns : |
A GDBusMessage. Free with g_object_unref().
|
Since 2.26
GDBusMessage * g_dbus_message_new_signal (const gchar *path,const gchar *interface_,const gchar *signal);
Creates a new GDBusMessage for a signal emission.
|
A valid object path. |
|
A valid D-Bus interface name or NULL.
|
|
A valid signal name. |
Returns : |
A GDBusMessage. Free with g_object_unref().
|
Since 2.26
GDBusMessage * g_dbus_message_new_method_call (const gchar *name,const gchar *path,const gchar *interface_,const gchar *method);
Creates a new GDBusMessage for a method call.
|
A valid D-Bus name or NULL.
|
|
A valid object path. |
|
A valid D-Bus interface name or NULL.
|
|
A valid method name. |
Returns : |
A GDBusMessage. Free with g_object_unref().
|
Since 2.26
GDBusMessage * g_dbus_message_new_method_reply (GDBusMessage *method_call_message);
Creates a new GDBusMessage that is a reply to method_call_message.
|
A message of type G_DBUS_MESSAGE_TYPE_METHOD_CALL to
create a reply message to.
|
Returns : |
A GDBusMessage. Free with g_object_unref().
|
Since 2.26
GDBusMessage * g_dbus_message_new_method_error (GDBusMessage *method_call_message,const gchar *error_name,const gchar *error_message_format,...);
Creates a new GDBusMessage that is an error reply to method_call_message.
|
A message of type G_DBUS_MESSAGE_TYPE_METHOD_CALL to
create a reply message to.
|
|
A valid D-Bus error name. |
|
The D-Bus error message in a printf() format.
|
|
Arguments for error_message_format.
|
Returns : |
A GDBusMessage. Free with g_object_unref().
|
Since 2.26
GDBusMessage * g_dbus_message_new_method_error_valist (GDBusMessage *method_call_message,const gchar *error_name,const gchar *error_message_format,va_list var_args);
Like g_dbus_message_new_method_error() but intended for language bindings.
|
A message of type G_DBUS_MESSAGE_TYPE_METHOD_CALL to
create a reply message to.
|
|
A valid D-Bus error name. |
|
The D-Bus error message in a printf() format.
|
|
Arguments for error_message_format.
|
Returns : |
A GDBusMessage. Free with g_object_unref().
|
Since 2.26
GDBusMessage * g_dbus_message_new_method_error_literal (GDBusMessage *method_call_message,const gchar *error_name,const gchar *error_message);
Creates a new GDBusMessage that is an error reply to method_call_message.
|
A message of type G_DBUS_MESSAGE_TYPE_METHOD_CALL to
create a reply message to.
|
|
A valid D-Bus error name. |
|
The D-Bus error message. |
Returns : |
A GDBusMessage. Free with g_object_unref().
|
Since 2.26
gchar * g_dbus_message_print (GDBusMessage *message,guint indent);
Produces a human-readable multi-line description of message.
The contents of the description has no ABI guarantees, the contents and formatting is subject to change at any time. Typical output looks something like this:
Type: method-call 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
Type: method-return 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
|
A GDBusMessage. |
|
Indentation level. |
Returns : |
A string that should be freed with g_free().
|
Since 2.26
GDBusMessageType g_dbus_message_get_message_type (GDBusMessage *message);
Gets the type of message.
|
A GDBusMessage. |
Returns : |
A 8-bit unsigned integer (typically a value from the GDBusMessageType enumeration). |
Since 2.26
void g_dbus_message_set_message_type (GDBusMessage *message,GDBusMessageType type);
Sets message to be of type.
|
A GDBusMessage. |
|
A 8-bit unsigned integer (typically a value from the GDBusMessageType enumeration). |
Since 2.26
guint32 g_dbus_message_get_serial (GDBusMessage *message);
Gets the serial for message.
|
A GDBusMessage. |
Returns : |
A guint32. |
Since 2.26
void g_dbus_message_set_serial (GDBusMessage *message,guint32 serial);
Sets the serial for message.
|
A GDBusMessage. |
|
A guint32. |
Since 2.26
GDBusMessageFlags g_dbus_message_get_flags (GDBusMessage *message);
Gets the flags for message.
|
A GDBusMessage. |
Returns : |
Flags that are set (typically values from the GDBusMessageFlags enumeration bitwise ORed together). |
Since 2.26
void g_dbus_message_set_flags (GDBusMessage *message,GDBusMessageFlags flags);
Sets the flags to set on message.
|
A GDBusMessage. |
|
Flags for message that are set (typically values from the GDBusMessageFlags
enumeration bitwise ORed together).
|
Since 2.26
GVariant * g_dbus_message_get_body (GDBusMessage *message);
Gets the body of a message.
|
A GDBusMessage. |
Returns : |
A GVariant or NULL if the body is empty. Do not free, it is owned by message.
|
Since 2.26
void g_dbus_message_set_body (GDBusMessage *message,GVariant *body);
Sets the body message. As a side-effect the
G_DBUS_MESSAGE_HEADER_FIELD_SIGNATURE header field is set to the
type string of body (or cleared if body is NULL).
If body is floating, message assumes ownership of body.
|
A GDBusMessage. |
|
Either NULL or a GVariant that is a tuple.
|
Since 2.26
GUnixFDList * g_dbus_message_get_unix_fd_list (GDBusMessage *message);
Gets the UNIX file descriptors associated with message, if any.
This method is only available on UNIX.
|
A GDBusMessage. |
Returns : |
A GUnixFDList or NULL if no file descriptors are
associated. Do not free, this object is owned by message.
|
Since 2.26
void g_dbus_message_set_unix_fd_list (GDBusMessage *message,GUnixFDList *fd_list);
Sets the UNIX file descriptors associated with message. As a
side-effect the G_DBUS_MESSAGE_HEADER_FIELD_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.
|
A GDBusMessage. |
|
A GUnixFDList or NULL.
|
Since 2.26
guint32 g_dbus_message_get_num_unix_fds (GDBusMessage *message);
Convenience getter for the G_DBUS_MESSAGE_HEADER_FIELD_NUM_UNIX_FDS header field.
|
A GDBusMessage. |
Returns : |
The value. |
Since 2.26
void g_dbus_message_set_num_unix_fds (GDBusMessage *message,guint32 value);
Convenience setter for the G_DBUS_MESSAGE_HEADER_FIELD_NUM_UNIX_FDS header field.
|
A GDBusMessage. |
|
The value to set. |
Since 2.26
guchar * g_dbus_message_get_header_fields (GDBusMessage *message);
Gets an array of all header fields on message that are set.
|
A GDBusMessage. |
Returns : |
An array of header fields terminated by
G_DBUS_MESSAGE_HEADER_FIELD_INVALID. Each element is a
guchar. Free with g_free().
|
Since 2.26
GVariant * g_dbus_message_get_header (GDBusMessage *message,GDBusMessageHeaderField header_field);
Gets a header field on message.
|
A GDBusMessage. |
|
A 8-bit unsigned integer (typically a value from the GDBusMessageHeaderField enumeration) |
Returns : |
A GVariant with the value if the header was found, NULL
otherwise. Do not free, it is owned by message.
|
Since 2.26
void g_dbus_message_set_header (GDBusMessage *message,GDBusMessageHeaderField header_field,GVariant *value);
Sets a header field on message.
If value is floating, message assumes ownership of value.
|
A GDBusMessage. |
|
A 8-bit unsigned integer (typically a value from the GDBusMessageHeaderField enumeration) |
|
A GVariant to set the header field or NULL to clear the header field.
|
Since 2.26
const gchar * g_dbus_message_get_destination (GDBusMessage *message);
Convenience getter for the G_DBUS_MESSAGE_HEADER_FIELD_DESTINATION header field.
|
A GDBusMessage. |
Returns : |
The value. |
Since 2.26
void g_dbus_message_set_destination (GDBusMessage *message,const gchar *value);
Convenience setter for the G_DBUS_MESSAGE_HEADER_FIELD_DESTINATION header field.
|
A GDBusMessage. |
|
The value to set. |
Since 2.26
const gchar * g_dbus_message_get_error_name (GDBusMessage *message);
Convenience getter for the G_DBUS_MESSAGE_HEADER_FIELD_ERROR_NAME header field.
|
A GDBusMessage. |
Returns : |
The value. |
Since 2.26
void g_dbus_message_set_error_name (GDBusMessage *message,const gchar *value);
Convenience setter for the G_DBUS_MESSAGE_HEADER_FIELD_ERROR_NAME header field.
|
A GDBusMessage. |
|
The value to set. |
Since 2.26
const gchar * g_dbus_message_get_interface (GDBusMessage *message);
Convenience getter for the G_DBUS_MESSAGE_HEADER_FIELD_INTERFACE header field.
|
A GDBusMessage. |
Returns : |
The value. |
Since 2.26
void g_dbus_message_set_interface (GDBusMessage *message,const gchar *value);
Convenience setter for the G_DBUS_MESSAGE_HEADER_FIELD_INTERFACE header field.
|
A GDBusMessage. |
|
The value to set. |
Since 2.26
const gchar * g_dbus_message_get_member (GDBusMessage *message);
Convenience getter for the G_DBUS_MESSAGE_HEADER_FIELD_MEMBER header field.
|
A GDBusMessage. |
Returns : |
The value. |
Since 2.26
void g_dbus_message_set_member (GDBusMessage *message,const gchar *value);
Convenience setter for the G_DBUS_MESSAGE_HEADER_FIELD_MEMBER header field.
|
A GDBusMessage. |
|
The value to set. |
Since 2.26
const gchar * g_dbus_message_get_path (GDBusMessage *message);
Convenience getter for the G_DBUS_MESSAGE_HEADER_FIELD_PATH header field.
|
A GDBusMessage. |
Returns : |
The value. |
Since 2.26
void g_dbus_message_set_path (GDBusMessage *message,const gchar *value);
Convenience setter for the G_DBUS_MESSAGE_HEADER_FIELD_PATH header field.
|
A GDBusMessage. |
|
The value to set. |
Since 2.26
guint32 g_dbus_message_get_reply_serial (GDBusMessage *message);
Convenience getter for the G_DBUS_MESSAGE_HEADER_FIELD_REPLY_SERIAL header field.
|
A GDBusMessage. |
Returns : |
The value. |
Since 2.26
void g_dbus_message_set_reply_serial (GDBusMessage *message,guint32 value);
Convenience setter for the G_DBUS_MESSAGE_HEADER_FIELD_REPLY_SERIAL header field.
|
A GDBusMessage. |
|
The value to set. |
Since 2.26
const gchar * g_dbus_message_get_sender (GDBusMessage *message);
Convenience getter for the G_DBUS_MESSAGE_HEADER_FIELD_SENDER header field.
|
A GDBusMessage. |
Returns : |
The value. |
Since 2.26
void g_dbus_message_set_sender (GDBusMessage *message,const gchar *value);
Convenience setter for the G_DBUS_MESSAGE_HEADER_FIELD_SENDER header field.
|
A GDBusMessage. |
|
The value to set. |
Since 2.26
const gchar * g_dbus_message_get_signature (GDBusMessage *message);
Convenience getter for the G_DBUS_MESSAGE_HEADER_FIELD_SIGNATURE header field.
|
A GDBusMessage. |
Returns : |
The value. |
Since 2.26
void g_dbus_message_set_signature (GDBusMessage *message,const gchar *value);
Convenience setter for the G_DBUS_MESSAGE_HEADER_FIELD_SIGNATURE header field.
|
A GDBusMessage. |
|
The value to set. |
Since 2.26
const gchar * g_dbus_message_get_arg0 (GDBusMessage *message);
Convenience to get the first item in the body of message.
|
A GDBusMessage. |
Returns : |
The string item or NULL if the first item in the body of
message is not a string.
|
Since 2.26
guchar * g_dbus_message_to_blob (GDBusMessage *message,gsize *out_size,GDBusCapabilityFlags capabilities,GError **error);
Serializes message to a blob.
|
A GDBusMessage. |
|
Return location for size of generated blob. |
|
A GDBusCapabilityFlags describing what protocol features are supported. |
|
Return location for error. |
Returns : |
A pointer to a valid binary D-Bus message of out_size bytes
generated by message or NULL if error is set. Free with g_free().
|
Since 2.26
gssize g_dbus_message_bytes_needed (guchar *blob,gsize blob_len,GError **error);
Utility function to calculate how many bytes are needed to
completely deserialize the D-Bus message stored at blob.
|
A blob represent a binary D-Bus message. |
|
The length of blob (must be at least 16).
|
|
Return location for error or NULL.
|
Returns : |
Number of bytes needed or -1 if error is set (e.g. if
blob contains invalid data or not enough data is available to
determine the size).
|
Since 2.26
GDBusMessage * g_dbus_message_new_from_blob (guchar *blob,gsize blob_len,GDBusCapabilityFlags capabilities,GError **error);
Creates a new GDBusMessage from the data stored at blob.
|
A blob represent a binary D-Bus message. |
|
The length of blob.
|
|
A GDBusCapabilityFlags describing what protocol features are supported. |
|
Return location for error or NULL.
|
Returns : |
A new GDBusMessage or NULL if error is set. Free with
g_object_unref().
|
Since 2.26
gboolean g_dbus_message_to_gerror (GDBusMessage *message,GError **error);
If message is not of type G_DBUS_MESSAGE_TYPE_ERROR does
nothing and returns FALSE.
Otherwise this method encodes the error in message as a GError
using g_dbus_error_set_dbus_error() using the information in the
G_DBUS_MESSAGE_HEADER_FIELD_ERROR_NAME header field of message as
well as the first string item in message's body.
|
A GDBusMessage. |
|
The GError to set. |
Returns : |
TRUE if error was set, FALSE otherwise.
|
Since 2.26