[kdbus] Initial support for two new bus types: 'user' and 'machine'

Change-Id: I3976e3935a01ea8d67b9a41997d0be8a37765d00
This commit is contained in:
Lukasz Skalski
2014-09-29 17:34:05 +02:00
committed by Ryan Lortie
parent 95a3a2ebf7
commit 030b701401
3 changed files with 34 additions and 1 deletions

View File

@@ -1471,6 +1471,8 @@ g_dbus_address_get_for_bus_sync (GBusType bus_type,
GError **error)
{
gchar *ret;
const gchar *system_bus;
const gchar *session_bus;
const gchar *starter_bus;
GError *local_error;
@@ -1524,6 +1526,23 @@ g_dbus_address_get_for_bus_sync (GBusType bus_type,
}
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)

View File

@@ -212,6 +212,8 @@ G_LOCK_DEFINE_STATIC (message_bus_lock);
static GWeakRef the_session_bus;
static GWeakRef the_system_bus;
static GWeakRef the_user_bus;
static GWeakRef the_machine_bus;
/* Extra pseudo-member of GDBusSendMessageFlags.
* Set by initable_init() to indicate that despite not being initialized yet,
@@ -7344,6 +7346,14 @@ message_bus_get_singleton (GBusType bus_type,
ret = &the_system_bus;
break;
case G_BUS_TYPE_USER:
ret = &the_user_bus;
break;
case G_BUS_TYPE_MACHINE:
ret = &the_machine_bus;
break;
case G_BUS_TYPE_STARTER:
starter_bus = g_getenv ("DBUS_STARTER_BUS_TYPE");
if (g_strcmp0 (starter_bus, "session") == 0)

View File

@@ -912,6 +912,8 @@ typedef enum {
* @G_BUS_TYPE_NONE: Not a message bus.
* @G_BUS_TYPE_SYSTEM: The system-wide message bus.
* @G_BUS_TYPE_SESSION: The login session message bus.
* @G_BUS_TYPE_MACHINE: New bus type for kdbus transport (falls back to system bus in case of failure).
* @G_BUS_TYPE_USER: New bus type for kdbus transport (falls back to session bus in case of failure).
*
* An enumeration for well-known message buses.
*
@@ -922,7 +924,9 @@ typedef enum
G_BUS_TYPE_STARTER = -1,
G_BUS_TYPE_NONE = 0,
G_BUS_TYPE_SYSTEM = 1,
G_BUS_TYPE_SESSION = 2
G_BUS_TYPE_SESSION = 2,
G_BUS_TYPE_MACHINE = 3,
G_BUS_TYPE_USER = 4
} GBusType;
/**