[kdbus] Initial support for two new bus types: 'user' and 'machine'
authorLukasz Skalski <l.skalski@samsung.com>
Mon, 29 Sep 2014 15:34:05 +0000 (17:34 +0200)
committerMaciej Wereski <m.wereski@partner.samsung.com>
Fri, 10 Jul 2015 09:47:43 +0000 (11:47 +0200)
Change-Id: I3976e3935a01ea8d67b9a41997d0be8a37765d00

gio/gdbusaddress.c
gio/gdbusconnection.c
gio/gioenums.h

index 6d17b7c..58c146b 100644 (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)
index 73f73f6..80e033b 100644 (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)
index 488e04b..407f50f 100644 (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;
 
 /**