#ifdef G_OS_UNIX
#include <gio/gunixsocketaddress.h>
+#include <gio/gkdbusconnection.h>
#endif
#ifdef G_OS_WIN32
return ret;
}
+static int
+g_dbus_is_supported_address_kdbus (const gchar *transport_name)
+{
+ int supported = 0;
+
+ supported = g_strcmp0 (transport_name, "kernel") == 0;
+
+ return supported;
+}
+
/**
* g_dbus_is_supported_address:
* @string: A string.
goto out;
supported = FALSE;
- if (g_strcmp0 (transport_name, "unix") == 0)
+ if ((g_strcmp0 (transport_name, "unix") == 0)
+ || g_dbus_is_supported_address_kdbus (transport_name))
supported = is_valid_unix (a[n], key_value_pairs, error);
else if (g_strcmp0 (transport_name, "tcp") == 0)
supported = is_valid_tcp (a[n], key_value_pairs, error);
{
}
#ifdef G_OS_UNIX
- else if (g_strcmp0 (transport_name, "unix") == 0)
+ if ((g_strcmp0 (transport_name, "unix") == 0)
+ || g_dbus_is_supported_address_kdbus (transport_name))
{
const gchar *path;
const gchar *abstract;
if (connectable != NULL)
{
- GSocketClient *client;
- GSocketConnection *connection;
- g_assert (ret == NULL);
- client = g_socket_client_new ();
- connection = g_socket_client_connect (client,
- connectable,
- cancellable,
- error);
- g_object_unref (connectable);
- g_object_unref (client);
- if (connection == NULL)
- goto out;
+ if (g_dbus_is_supported_address_kdbus (transport_name))
+ {
+ GKdbusConnection *connection;
+ gboolean status;
+
+ const gchar *path;
+ path = g_hash_table_lookup (key_value_pairs, "path");
- ret = G_IO_STREAM (connection);
+ g_assert (ret == NULL);
+ connection = _g_kdbus_connection_new ();
+ status = _g_kdbus_connection_connect (connection,
+ path,
+ cancellable,
+ error);
+ g_object_unref (connectable);
+
+ if (!status)
+ goto out;
+
+ ret = G_IO_STREAM (connection);
+ }
+ else
+ {
+ GSocketClient *client;
+ GSocketConnection *connection;
+
+ g_assert (ret == NULL);
+ client = g_socket_client_new ();
+ connection = g_socket_client_connect (client,
+ connectable,
+ cancellable,
+ error);
+ g_object_unref (connectable);
+ g_object_unref (client);
+ if (connection == NULL)
+ goto out;
+
+ ret = G_IO_STREAM (connection);
+ }
if (nonce_file != NULL)
{
GError **error)
{
gchar *ret;
+ const gchar *system_bus;
+ const gchar *session_bus;
const gchar *starter_bus;
GError *local_error;
}
break;
+ case G_BUS_TYPE_MACHINE:
+ system_bus = g_getenv ("DBUS_SYSTEM_BUS_ADDRESS");
+ if (system_bus == NULL)
+ ret = g_strdup ("kernel:path=/dev/kdbus/0-system/bus;unix:path=/var/run/dbus/system_bus_socket");
+ else
+ ret = g_strdup_printf ("kernel:path=/dev/kdbus/0-system/bus;%s", system_bus);
+ break;
+
+ case G_BUS_TYPE_USER:
+ session_bus = g_getenv ("DBUS_SESSION_BUS_ADDRESS");
+ if (session_bus == NULL)
+ ret = g_strdup_printf ("kernel:path=/dev/kdbus/%d-user/bus;%s", getuid(),
+ get_session_address_platform_specific (&local_error));
+ else
+ ret = g_strdup_printf ("kernel:path=/dev/kdbus/%d-user/bus;%s", getuid(), session_bus);
+ break;
+
case G_BUS_TYPE_STARTER:
starter_bus = g_getenv ("DBUS_STARTER_BUS_TYPE");
if (g_strcmp0 (starter_bus, "session") == 0)