summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNelson Marques <[email protected]>2012-12-05 16:12:28 +0000
committerNelson Marques <[email protected]>2012-12-05 16:12:28 +0000
commitca4b57cdd02c223763c9d60742630127340bbeee (patch)
tree78adb2430ee3ddb9cdcacf01d187c044c8bda323
parent97b9833a9a50572798e97a47f4dfa69f3363f00a (diff)
downloadmate-screensaver-ca4b57cdd02c223763c9d60742630127340bbeee.tar.bz2
mate-screensaver-ca4b57cdd02c223763c9d60742630127340bbeee.tar.xz
prevent mate-screensaver to launch a 2nd instance
-rw-r--r--src/gs-listener-dbus.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/gs-listener-dbus.c b/src/gs-listener-dbus.c
index ed1199f..99e05df 100644
--- a/src/gs-listener-dbus.c
+++ b/src/gs-listener-dbus.c
@@ -2204,7 +2204,7 @@ gboolean
gs_listener_acquire (GSListener *listener,
GError **error)
{
- gboolean acquired;
+ int acquired;
DBusError buserror;
gboolean is_connected;
@@ -2254,7 +2254,8 @@ gs_listener_acquire (GSListener *listener,
acquired = dbus_bus_request_name (listener->priv->connection,
GS_LISTENER_SERVICE,
- 0, &buserror) != -1;
+ DBUS_NAME_FLAG_DO_NOT_QUEUE,
+ &buserror);
if (dbus_error_is_set (&buserror))
{
g_set_error (error,
@@ -2263,6 +2264,14 @@ gs_listener_acquire (GSListener *listener,
"%s",
buserror.message);
}
+ if (acquired == DBUS_REQUEST_NAME_REPLY_EXISTS) {
+ g_set_error (error,
+ GS_LISTENER_ERROR,
+ GS_LISTENER_ERROR_ACQUISITION_FAILURE,
+ "%s",
+ _("screensaver already running in this session"));
+ return FALSE;
+ }
dbus_error_free (&buserror);
@@ -2331,7 +2340,7 @@ gs_listener_acquire (GSListener *listener,
}
finish:
- return acquired;
+ return (acquired != -1);
}
static char *