[Xfce4-commits] <xfce4-session:master> Switch to PowerManagement DBus name.
Nick Schermer
noreply at xfce.org
Sat Mar 24 22:50:20 CET 2012
Updating branch refs/heads/master
to e8d61abb66b6a8a0ef0758116f690e825d93726c (commit)
from 1920277baad82a4e0bf21d83fa5af15259a79720 (commit)
commit e8d61abb66b6a8a0ef0758116f690e825d93726c
Author: Nick Schermer <nick at xfce.org>
Date: Wed Mar 7 22:13:47 2012 +0100
Switch to PowerManagement DBus name.
xfce4-session/xfsm-shutdown.c | 54 ++++++++++++++++++++++++++++++++++-------
1 files changed, 45 insertions(+), 9 deletions(-)
diff --git a/xfce4-session/xfsm-shutdown.c b/xfce4-session/xfsm-shutdown.c
index 4821cf4..52a9841 100644
--- a/xfce4-session/xfsm-shutdown.c
+++ b/xfce4-session/xfsm-shutdown.c
@@ -541,9 +541,9 @@ xfsm_shutdown_query_xfpm (XfsmShutdown *shutdown,
return FALSE;
proxy = dbus_g_proxy_new_for_name_owner (conn,
- "org.xfce.PowerManager",
- "/org/xfce/PowerManager",
- "org.xfce.PowerManager",
+ "org.xfce.PowerManagement",
+ "/org/xfce/PowerManagement",
+ "org.xfce.PowerManagement",
error);
if (proxy != NULL)
{
@@ -563,12 +563,11 @@ xfsm_shutdown_query_xfpm (XfsmShutdown *shutdown,
static gboolean
xfsm_shutdown_kiosk_can_shutdown (XfsmShutdown *shutdown,
- GError **error)
+ GError **error)
{
if (!shutdown->kiosk_can_shutdown)
{
- if (error != NULL)
- g_set_error_literal (error, 1, 0, _("Shutdown is blocked by the kiosk settings"));
+ g_set_error_literal (error, 1, 0, _("Shutdown is blocked by the kiosk settings"));
return FALSE;
}
@@ -577,6 +576,43 @@ xfsm_shutdown_kiosk_can_shutdown (XfsmShutdown *shutdown,
+static gboolean
+xfsm_shutdown_run_xfpm (XfsmShutdown *shutdown,
+ const gchar *method,
+ GError **error)
+{
+ DBusGConnection *conn;
+ DBusGProxy *proxy;
+ gboolean result = FALSE;
+
+ if (!xfsm_shutdown_kiosk_can_shutdown (shutdown, error))
+ return FALSE;
+
+ conn = dbus_g_bus_get (DBUS_BUS_SESSION, error);
+ if (conn == NULL)
+ return FALSE;
+
+ proxy = dbus_g_proxy_new_for_name_owner (conn,
+ "org.xfce.PowerManagement",
+ "/org/xfce/PowerManagement",
+ "org.xfce.PowerManagement",
+ error);
+
+ if (proxy != NULL)
+ {
+ result = dbus_g_proxy_call (proxy, method, error,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ g_object_unref (proxy);
+ }
+
+ dbus_g_connection_unref (conn);
+
+ return result;
+}
+
+
+
XfsmShutdown *
xfsm_shutdown_get (void)
{
@@ -700,7 +736,7 @@ xfsm_shutdown_try_suspend (XfsmShutdown *shutdown,
{
g_return_val_if_fail (XFSM_IS_SHUTDOWN (shutdown), FALSE);
- return TRUE;
+ return xfsm_shutdown_run_xfpm (shutdown, "Suspend", error);
}
@@ -711,7 +747,7 @@ xfsm_shutdown_try_hibernate (XfsmShutdown *shutdown,
{
g_return_val_if_fail (XFSM_IS_SHUTDOWN (shutdown), FALSE);
- return TRUE;
+ return xfsm_shutdown_run_xfpm (shutdown, "Hibernate", error);
}
@@ -719,7 +755,7 @@ xfsm_shutdown_try_hibernate (XfsmShutdown *shutdown,
gboolean
xfsm_shutdown_can_restart (XfsmShutdown *shutdown,
gboolean *can_restart,
- GError **error)
+ GError **error)
{
g_return_val_if_fail (XFSM_IS_SHUTDOWN (shutdown), FALSE);
More information about the Xfce4-commits
mailing list