[glib] g_dbus_address_connect: specifically use dbus-launch for autolaunch:



commit 0d3f56e31c9099653539fa2539e05b3ba336a441
Author: Simon McVittie <simon mcvittie collabora co uk>
Date:   Wed Apr 15 19:59:50 2015 +0100

    g_dbus_address_connect: specifically use dbus-launch for autolaunch:
    
    This only alters what happens if we specifically connect to
    "autolaunch:", for instance via "DBUS_SESSION_BUS_ADDRESS=autolaunch:".
    We will still potentially try other platform-specific things if
    DBUS_SESSION_BUS_ADDRESS is unset. There are currently no other
    platform-specific things, so there is no practical difference yet,
    but I'm about to add a more-preferred fallback path before autolaunch.
    
    This matches libdbus' behaviour and the D-Bus Specification, in which
    the autolaunch: transport specifically means X11 autolaunch
    (as implemented by "dbus-launch --autolaunch") on Unix, or a
    shared-memory-based protocol on Windows. Other platform-specific
    transports or default/fallback modes, including launchd on Mac OS X
    and XDG_RUNTIME_DIR/bus on Unix, are not part of "autolaunch:".
    
    It's rather unfortunate that the same name means two different
    platform-specific mechanisms, specific to different platforms -
    if they were added today I'd call them x11: and windows-shm: or
    something - but it's been like this since 2007 so it's too late now.
    
    Bug: https://bugzilla.gnome.org/show_bug.cgi?id=747941
    Signed-off-by: Simon McVittie <simon mcvittie collabora co uk>
    Reviewed-by: Philip Withnall <philip withnall collabora co uk>

 gio/gdbusaddress.c |   38 +++++++++++++++++++++-----------------
 1 files changed, 21 insertions(+), 17 deletions(-)
---
diff --git a/gio/gdbusaddress.c b/gio/gdbusaddress.c
index 5e58065..89c4c58 100644
--- a/gio/gdbusaddress.c
+++ b/gio/gdbusaddress.c
@@ -64,6 +64,7 @@
  */
 
 static gchar *get_session_address_platform_specific (GError **error);
+static gchar *get_session_address_dbus_launch       (GError **error);
 
 /* ---------------------------------------------------------------------------------------------------- */
 
@@ -638,7 +639,7 @@ g_dbus_address_connect (const gchar   *address_entry,
   else if (g_strcmp0 (address_entry, "autolaunch:") == 0)
     {
       gchar *autolaunch_address;
-      autolaunch_address = get_session_address_platform_specific (error);
+      autolaunch_address = get_session_address_dbus_launch (error);
       if (autolaunch_address != NULL)
         {
           ret = g_dbus_address_try_connect_one (autolaunch_address, NULL, cancellable, error);
@@ -1113,9 +1114,9 @@ get_session_address_dbus_launch (GError **error)
   g_free (old_dbus_verbose);
   return ret;
 }
-#endif
 
-#ifdef G_OS_WIN32
+/* end of G_OS_UNIX case */
+#elif defined(G_OS_WIN32)
 
 #define DBUS_DAEMON_ADDRESS_INFO "DBusDaemonAddressInfo"
 #define DBUS_DAEMON_MUTEX "DBusDaemonMutex"
@@ -1413,26 +1414,29 @@ get_session_address_dbus_launch (GError **error)
 
   return address;
 }
-#endif
-
-/* ---------------------------------------------------------------------------------------------------- */
-
+#else /* neither G_OS_UNIX nor G_OS_WIN32 */
 static gchar *
-get_session_address_platform_specific (GError **error)
+get_session_address_dbus_launch (GError **error)
 {
-  gchar *ret;
-#if defined (G_OS_UNIX) || defined(G_OS_WIN32)
-  /* need to handle OS X in a different way since 'dbus-launch --autolaunch' probably won't work there */
-  ret = get_session_address_dbus_launch (error);
-#else
-  /* TODO: implement for OS X */
-  ret = NULL;
   g_set_error (error,
                G_IO_ERROR,
                G_IO_ERROR_FAILED,
                _("Cannot determine session bus address (not implemented for this OS)"));
-#endif
-  return ret;
+  return NULL;
+}
+#endif /* neither G_OS_UNIX nor G_OS_WIN32 */
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static gchar *
+get_session_address_platform_specific (GError **error)
+{
+  /* TODO (#694472): try launchd on OS X, like
+   * _dbus_lookup_session_address_launchd() does, since
+   * 'dbus-launch --autolaunch' probably won't work there
+   */
+
+  return get_session_address_dbus_launch (error);
 }
 
 /* ---------------------------------------------------------------------------------------------------- */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]