D-Bus Utilities

D-Bus Utilities — Various utilities related to D-Bus

Includes

#include <gio/gio.h>

Description

Various utility routines related to D-Bus.

Functions

g_dbus_generate_guid ()

gchar *
g_dbus_generate_guid (void);

Generate a D-Bus GUID that can be used with e.g. g_dbus_connection_new().

See the D-Bus specification regarding what strings are valid D-Bus GUID (for example, D-Bus GUIDs are not RFC-4122 compliant).

Returns

A valid D-Bus GUID. Free with g_free().

Since: 2.26


g_dbus_is_guid ()

gboolean
g_dbus_is_guid (const gchar *string);

Checks if string is a D-Bus GUID.

See the D-Bus specification regarding what strings are valid D-Bus GUID (for example, D-Bus GUIDs are not RFC-4122 compliant).

Parameters

string

The string to check.

 

Returns

TRUE if string is a guid, FALSE otherwise.

Since: 2.26


g_dbus_is_name ()

gboolean
g_dbus_is_name (const gchar *string);

Checks if string is a valid D-Bus bus name (either unique or well-known).

Parameters

string

The string to check.

 

Returns

TRUE if valid, FALSE otherwise.

Since: 2.26


g_dbus_is_unique_name ()

gboolean
g_dbus_is_unique_name (const gchar *string);

Checks if string is a valid D-Bus unique bus name.

Parameters

string

The string to check.

 

Returns

TRUE if valid, FALSE otherwise.

Since: 2.26


g_dbus_is_member_name ()

gboolean
g_dbus_is_member_name (const gchar *string);

Checks if string is a valid D-Bus member (e.g. signal or method) name.

Parameters

string

The string to check.

 

Returns

TRUE if valid, FALSE otherwise.

Since: 2.26


g_dbus_is_interface_name ()

gboolean
g_dbus_is_interface_name (const gchar *string);

Checks if string is a valid D-Bus interface name.

Parameters

string

The string to check.

 

Returns

TRUE if valid, FALSE otherwise.

Since: 2.26


g_dbus_gvalue_to_gvariant ()

GVariant *
g_dbus_gvalue_to_gvariant (const GValue *gvalue,
                           const GVariantType *type);

Converts a GValue to a GVariant of the type indicated by the type parameter.

The conversion is using the following rules:

This can fail if e.g. gvalue is of type G_TYPE_STRING and type is 'i'. It will also fail for any GType (including e.g. G_TYPE_OBJECT and G_TYPE_BOXED derived-types) not in the table above.

Note that if gvalue is of type G_TYPE_VARIANT and its value is NULL, the empty GVariant instance (never NULL) for type is returned (e.g. 0 for scalar types, the empty string for string types, '/' for object path types, the empty array for any array type and so on).

See the g_dbus_gvariant_to_gvalue() function for how to convert a GVariant to a GValue.

Parameters

gvalue

A GValue to convert to a GVariant

 

type

A GVariantType

 

Returns

A GVariant (never floating) of GVariantType type holding the data from gvalue or NULL in case of failure. Free with g_variant_unref().

Since: 2.30


g_dbus_gvariant_to_gvalue ()

void
g_dbus_gvariant_to_gvalue (GVariant *value,
                           GValue *out_gvalue);

Converts a GVariant to a GValue. If value is floating, it is consumed.

The rules specified in the g_dbus_gvalue_to_gvariant() function are used - this function is essentially its reverse form. So, a GVariant containing any basic or string array type will be converted to a GValue containing a basic value or string array. Any other GVariant (handle, variant, tuple, dict entry) will be converted to a GValue containing that GVariant.

The conversion never fails - a valid GValue is always returned in out_gvalue .

Parameters

value

A GVariant.

 

out_gvalue

Return location pointing to a zero-filled (uninitialized) GValue.

[out]

Since: 2.30

Types and Values