mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
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>
This commit is contained in:
parent
bf181a3ac7
commit
0d3f56e31c
@ -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_dbus_launch (GError **error)
|
||||
{
|
||||
g_set_error (error,
|
||||
G_IO_ERROR,
|
||||
G_IO_ERROR_FAILED,
|
||||
_("Cannot determine session bus address (not implemented for this OS)"));
|
||||
return NULL;
|
||||
}
|
||||
#endif /* neither G_OS_UNIX nor G_OS_WIN32 */
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------- */
|
||||
|
||||
static gchar *
|
||||
get_session_address_platform_specific (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;
|
||||
/* 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);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------- */
|
||||
|
Loading…
Reference in New Issue
Block a user