Skip to content
Snippets Groups Projects
Commit cffedf6d authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #9688: gnome: screensaver_uninhibit must verify that the cookie has been set

parent 0db8a567
Branches
Tags
No related merge requests found
......@@ -628,8 +628,10 @@ gboolean dbus_connect_session_manager(DBusGConnection *connection)
}
*/
g_dbus_proxy_new_for_bus(G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
NULL, GS_SERVICE, GS_PATH, GS_INTERFACE, NULL, screensaver_dbus_proxy_new_cb, NULL);
g_dbus_proxy_new_for_bus(G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
NULL, GS_SERVICE, GS_PATH, GS_INTERFACE, NULL,
screensaver_dbus_proxy_new_cb, NULL);
DEBUG("DBUS: Connected to gnome session manager");
......@@ -1891,16 +1893,13 @@ dbus_send_text_message(const gchar *callID, const gchar *message)
static guint cookie;
#define GNOME_SESSION_NO_IDLE_FLAG 8
static void screensaver_inhibit_cb (GObject * source_object, GAsyncResult * res, gpointer user_data UNUSED)
static void screensaver_inhibit_cb(GObject * source_object, GAsyncResult * res,
gpointer user_data UNUSED)
{
DEBUG("Screensaver: Inhibit callback");
DEBUG(__PRETTY_FUNCTION__);
GDBusProxy *proxy = G_DBUS_PROXY(source_object);
// ScreenSaver *screensaver = (ScreenSaver *) user_data;
GVariant *value;
GError *error = NULL;
value = g_dbus_proxy_call_finish (proxy, res, &error);
GVariant *value = g_dbus_proxy_call_finish(proxy, res, &error);
if (!value) {
ERROR("Screensaver: Error: inhibiting the screensaver: %s", error->message);
g_error_free(error);
......@@ -1916,18 +1915,18 @@ static void screensaver_inhibit_cb (GObject * source_object, GAsyncResult * res,
g_variant_unref(value);
}
static void screensaver_uninhibit_cb (GObject * source_object, GAsyncResult * res, gpointer user_data UNUSED)
static void screensaver_uninhibit_cb(GObject * source_object,
GAsyncResult * res,
gpointer user_data UNUSED)
{
DEBUG("Screensaver: Uninhibit callback");
DEBUG(__PRETTY_FUNCTION__);
GDBusProxy *proxy = G_DBUS_PROXY(source_object);
// ScreenSaver *screensaver = (ScreenSaver *) user_data;
GVariant *value;
GError *error = NULL;
value = g_dbus_proxy_call_finish (proxy, res, &error);
GVariant *value = g_dbus_proxy_call_finish(proxy, res, &error);
if (!value) {
ERROR ("Screensaver: Error uninhibiting the screensaver: %s", error->message);
ERROR ("Screensaver: Error uninhibiting the screensaver: %s",
error->message);
g_error_free(error);
return;
}
......@@ -1935,42 +1934,46 @@ static void screensaver_uninhibit_cb (GObject * source_object, GAsyncResult * re
/* clear the cookie */
cookie = 0;
g_variant_unref(value);
}
void dbus_screensaver_inhibit(void)
{
guint xid = 0;
DEBUG("Screensaver: inhibit");
const gchar *appname = g_get_application_name();
if (appname == NULL) {
ERROR("Screensaver: Could not retreive application name");
ERROR("Screensaver: Could not retrieve application name");
return;
}
GVariant *parameters = g_variant_new ("(susu)", appname, xid, "Phone call ongoing", GNOME_SESSION_NO_IDLE_FLAG);
guint xid = 0;
GVariant *parameters = g_variant_new("(susu)", appname, xid,
"Phone call ongoing",
GNOME_SESSION_NO_IDLE_FLAG);
if (parameters == NULL) {
ERROR("Screensaver: Could not create session manager inhibit parameters");
return;
}
g_dbus_proxy_call(session_manager_proxy, "Inhibit", parameters,
G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL, screensaver_inhibit_cb, NULL);
G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL,
screensaver_inhibit_cb, NULL);
}
void
dbus_screensaver_uninhibit(void)
{
if (cookie == 0)
return;
DEBUG("Screensaver: uninhibit");
GVariant *parameters = g_variant_new("(u)", cookie);
if (parameters == NULL) {
ERROR("Screensaver: Could not create session manager uninhibit parameters");
ERROR("Screensaver: Could not create session manager uninhibit "
"parameters");
return;
};
}
g_dbus_proxy_call (session_manager_proxy, "Uninhibit", g_variant_new ("(u)", cookie),
G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL, screensaver_uninhibit_cb, NULL);
g_dbus_proxy_call(session_manager_proxy, "Uninhibit",
g_variant_new("(u)", cookie),
G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL,
screensaver_uninhibit_cb, NULL);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment