Commit ebaa8657 authored by Tristan Matthews's avatar Tristan Matthews

Merge branch 'master' into upgrade_to_ccrtp2

parents 0c4e7645 cffedf6d
...@@ -613,7 +613,7 @@ screensaver_dbus_proxy_new_cb (GObject * source UNUSED, GAsyncResult *result, gp ...@@ -613,7 +613,7 @@ screensaver_dbus_proxy_new_cb (GObject * source UNUSED, GAsyncResult *result, gp
gboolean dbus_connect_session_manager(DBusGConnection *connection) gboolean dbus_connect_session_manager(DBusGConnection *connection)
{ {
if(connection == NULL) { if (connection == NULL) {
ERROR("DBUS: Error connection is NULL"); ERROR("DBUS: Error connection is NULL");
return FALSE; return FALSE;
} }
...@@ -628,8 +628,10 @@ gboolean dbus_connect_session_manager(DBusGConnection *connection) ...@@ -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, g_dbus_proxy_new_for_bus(G_BUS_TYPE_SESSION,
NULL, GS_SERVICE, GS_PATH, GS_INTERFACE, NULL, screensaver_dbus_proxy_new_cb, NULL); 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"); DEBUG("DBUS: Connected to gnome session manager");
...@@ -1891,86 +1893,87 @@ dbus_send_text_message(const gchar *callID, const gchar *message) ...@@ -1891,86 +1893,87 @@ dbus_send_text_message(const gchar *callID, const gchar *message)
static guint cookie; static guint cookie;
#define GNOME_SESSION_NO_IDLE_FLAG 8 #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);
GDBusProxy *proxy = G_DBUS_PROXY (source_object);
// ScreenSaver *screensaver = (ScreenSaver *) user_data;
GVariant *value;
GError *error = NULL; GError *error = NULL;
GVariant *value = g_dbus_proxy_call_finish(proxy, res, &error);
value = g_dbus_proxy_call_finish (proxy, res, &error);
if (!value) { if (!value) {
ERROR ("Screensaver: Error: inhibiting the screensaver: %s", error->message); ERROR("Screensaver: Error: inhibiting the screensaver: %s", error->message);
g_error_free (error); g_error_free(error);
return; return;
} }
/* save the cookie */ /* save the cookie */
if (g_variant_is_of_type (value, G_VARIANT_TYPE ("(u)"))) if (g_variant_is_of_type(value, G_VARIANT_TYPE("(u)")))
g_variant_get (value, "(u)", &cookie); g_variant_get(value, "(u)", &cookie);
else else
cookie = 0; cookie = 0;
g_variant_unref (value); 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);
GDBusProxy *proxy = G_DBUS_PROXY (source_object);
// ScreenSaver *screensaver = (ScreenSaver *) user_data;
GVariant *value;
GError *error = NULL; GError *error = NULL;
value = g_dbus_proxy_call_finish (proxy, res, &error); GVariant *value = g_dbus_proxy_call_finish(proxy, res, &error);
if (!value) { if (!value) {
ERROR ("Screensaver: Error uninhibiting the screensaver: %s", error->message); ERROR ("Screensaver: Error uninhibiting the screensaver: %s",
g_error_free (error); error->message);
g_error_free(error);
return; return;
} }
/* clear the cookie */ /* clear the cookie */
cookie = 0; cookie = 0;
g_variant_unref (value); g_variant_unref(value);
} }
void dbus_screensaver_inhibit(void) void dbus_screensaver_inhibit(void)
{ {
guint xid = 0;
DEBUG("Screensaver: inhibit");
const gchar *appname = g_get_application_name(); const gchar *appname = g_get_application_name();
if(appname == NULL) { if (appname == NULL) {
ERROR("Screensaver: Could not retreive application name"); ERROR("Screensaver: Could not retrieve application name");
return; return;
} }
GVariant *parameters = g_variant_new ("(susu)", appname, xid, "Phone call ongoing", GNOME_SESSION_NO_IDLE_FLAG); guint xid = 0;
if(parameters == NULL) { 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"); ERROR("Screensaver: Could not create session manager inhibit parameters");
return; return;
} }
g_dbus_proxy_call (session_manager_proxy, "Inhibit", parameters, 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 void
dbus_screensaver_uninhibit(void) dbus_screensaver_uninhibit(void)
{ {
if (cookie == 0)
return;
DEBUG("Screensaver: uninhibit"); DEBUG("Screensaver: uninhibit");
GVariant *parameters = g_variant_new("(u)", cookie); GVariant *parameters = g_variant_new("(u)", cookie);
if(parameters == NULL) { if (parameters == NULL) {
ERROR("Screensaver: Could not create session manager uninhibit parameters"); ERROR("Screensaver: Could not create session manager uninhibit "
"parameters");
return; return;
}; }
g_dbus_proxy_call (session_manager_proxy, "Uninhibit", g_variant_new ("(u)", cookie), g_dbus_proxy_call(session_manager_proxy, "Uninhibit",
G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL, screensaver_uninhibit_cb, NULL); g_variant_new("(u)", cookie),
G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL,
screensaver_uninhibit_cb, NULL);
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment