summaryrefslogtreecommitdiff
path: root/tools/mate-session-save.c
diff options
context:
space:
mode:
authorClement Lefebvre <[email protected]>2015-10-22 10:36:44 +0100
committerClement Lefebvre <[email protected]>2015-10-22 10:36:44 +0100
commit26ccdb0321012706798a43d8a1f5e5ae6ccbe362 (patch)
treea72e24e82df9896d6cb3ce69a8cff8dc44ad26b3 /tools/mate-session-save.c
parentc1b21ea58c3811aef7ee747671817dce44229796 (diff)
parent9582afb40caf49a2386f2bed740d9e708494312f (diff)
downloadmate-session-manager-26ccdb0321012706798a43d8a1f5e5ae6ccbe362.tar.bz2
mate-session-manager-26ccdb0321012706798a43d8a1f5e5ae6ccbe362.tar.xz
Merge pull request #104 from mate-desktop/session-save-fix
mate-session-save: try org.mate.SessionManager if org.gnome fails
Diffstat (limited to 'tools/mate-session-save.c')
-rw-r--r--tools/mate-session-save.c32
1 files changed, 29 insertions, 3 deletions
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;