From 9582afb40caf49a2386f2bed740d9e708494312f Mon Sep 17 00:00:00 2001 From: Monsta Date: Wed, 21 Oct 2015 16:45:15 +0300 Subject: mate-session-save: try org.mate.SessionManager if org.gnome fails fixes https://github.com/mate-desktop/mate-session-manager/issues/103 --- tools/mate-session-save.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'tools/mate-session-save.c') diff --git a/tools/mate-session-save.c b/tools/mate-session-save.c index b64ae90..cec2a6b 100644 --- a/tools/mate-session-save.c +++ b/tools/mate-session-save.c @@ -37,6 +37,10 @@ #define GSM_PATH_DBUS "/org/gnome/SessionManager" #define GSM_INTERFACE_DBUS "org.gnome.SessionManager" +#define GSM_SERVICE_DBUS_OLD "org.mate.SessionManager" +#define GSM_PATH_DBUS_OLD "/org/mate/SessionManager" +#define GSM_INTERFACE_DBUS_OLD "org.mate.SessionManager" + enum { GSM_LOGOUT_MODE_NORMAL = 0, GSM_LOGOUT_MODE_NO_CONFIRMATION, @@ -105,6 +109,20 @@ static DBusGConnection* get_session_bus(void) return bus; } +static DBusGProxy* create_proxy(DBusGConnection *connection, const char *name, const char *path, const char *iface) +{ + GError* error = NULL; + DBusGProxy* proxy = dbus_g_proxy_new_for_name_owner(connection, name, path, iface, &error); + + if (proxy == NULL) + { + g_warning("Couldn't create DBus proxy: %s", error->message); + g_error_free(error); + } + + return proxy; +} + static DBusGProxy* get_sm_proxy(void) { DBusGConnection* connection; @@ -118,12 +136,20 @@ static DBusGProxy* get_sm_proxy(void) return NULL; } - sm_proxy = dbus_g_proxy_new_for_name(connection, GSM_SERVICE_DBUS, GSM_PATH_DBUS, GSM_INTERFACE_DBUS); + sm_proxy = create_proxy(connection, GSM_SERVICE_DBUS, GSM_PATH_DBUS, GSM_INTERFACE_DBUS); if (sm_proxy == NULL) { - display_error(_("Could not connect to the session manager")); - return NULL; + /* Try the old name - for the case when we've just upgraded from 1.10 + * so the old m-s-m is currently running */ + sm_proxy = create_proxy(connection, GSM_SERVICE_DBUS_OLD, GSM_PATH_DBUS_OLD, GSM_INTERFACE_DBUS_OLD); + + if (sm_proxy == NULL) + { + /* Okay, it wasn't the upgrade case, so now we can give up. */ + display_error(_("Could not connect to the session manager")); + return NULL; + } } return sm_proxy; -- cgit v1.2.1