[glib/wip/kdbus-junk: 7/37] [kdbus] Initial support for two new bus types: 'user' and 'machine'
- From: Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/kdbus-junk: 7/37] [kdbus] Initial support for two new bus types: 'user' and 'machine'
- Date: Wed, 10 Dec 2014 15:57:46 +0000 (UTC)
commit 030b7014013aa3a4db19d581c4c3a6475b43b3c7
Author: Lukasz Skalski <l skalski samsung com>
Date: Mon Sep 29 17:34:05 2014 +0200
[kdbus] Initial support for two new bus types: 'user' and 'machine'
Change-Id: I3976e3935a01ea8d67b9a41997d0be8a37765d00
gio/gdbusaddress.c | 19 +++++++++++++++++++
gio/gdbusconnection.c | 10 ++++++++++
gio/gioenums.h | 6 +++++-
3 files changed, 34 insertions(+), 1 deletions(-)
---
diff --git a/gio/gdbusaddress.c b/gio/gdbusaddress.c
index 6d17b7c..58c146b 100644
--- a/gio/gdbusaddress.c
+++ b/gio/gdbusaddress.c
@@ -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)
diff --git a/gio/gdbusconnection.c b/gio/gdbusconnection.c
index 73f73f6..80e033b 100644
--- a/gio/gdbusconnection.c
+++ b/gio/gdbusconnection.c
@@ -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)
diff --git a/gio/gioenums.h b/gio/gioenums.h
index 488e04b..407f50f 100644
--- a/gio/gioenums.h
+++ b/gio/gioenums.h
@@ -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;
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]