summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dkp-daemon.c42
-rw-r--r--src/dkp-daemon.h6
-rw-r--r--src/org.freedesktop.DeviceKit.Power.xml46
3 files changed, 80 insertions, 14 deletions
diff --git a/src/dkp-daemon.c b/src/dkp-daemon.c
index d1f1baf..c3a2b83 100644
--- a/src/dkp-daemon.c
+++ b/src/dkp-daemon.c
@@ -826,6 +826,32 @@ dkp_daemon_get_low_battery (DkpDaemon *daemon, DBusGMethodInvocation *context)
}
/**
+ * dkp_daemon_can_suspend:
+ *
+ * TODO: Ask PolicyKit and check in DeviceKit.conf
+ **/
+gboolean
+dkp_daemon_can_suspend (DkpDaemon *daemon, gboolean interactive, DBusGMethodInvocation *context)
+{
+ /* for now, assume we can suspend under all circumstances */
+ dbus_g_method_return (context, TRUE);
+ return TRUE;
+}
+
+/**
+ * dkp_daemon_can_hibernate:
+ *
+ * TODO: Ask PolicyKit and check in DeviceKit.conf
+ **/
+gboolean
+dkp_daemon_can_hibernate (DkpDaemon *daemon, gboolean interactive, DBusGMethodInvocation *context)
+{
+ /* for now, assume we can hibernate under all circumstances */
+ dbus_g_method_return (context, TRUE);
+ return TRUE;
+}
+
+/**
* dkp_daemon_suspend:
**/
gboolean
@@ -834,8 +860,6 @@ dkp_daemon_suspend (DkpDaemon *daemon, DBusGMethodInvocation *context)
gboolean ret;
GError *error;
GError *error_local = NULL;
- gchar *argv;
- const gchar *quirks;
PolKitCaller *pk_caller;
pk_caller = dkp_daemon_local_get_caller_for_context (daemon, context);
@@ -845,11 +869,7 @@ dkp_daemon_suspend (DkpDaemon *daemon, DBusGMethodInvocation *context)
if (!dkp_daemon_local_check_auth (daemon, pk_caller, "org.freedesktop.devicekit.power.suspend", context))
goto out;
- /* TODO: where from? */
- quirks = "--quirk-s3-bios --quirk-s3-mode";
-
- argv = g_strdup_printf ("/usr/sbin/pm-suspend %s", quirks);
- ret = g_spawn_command_line_async (argv, &error_local);
+ ret = g_spawn_command_line_async ("/usr/sbin/pm-suspend", &error_local);
if (!ret) {
error = g_error_new (DKP_DAEMON_ERROR,
DKP_DAEMON_ERROR_GENERAL,
@@ -874,8 +894,6 @@ dkp_daemon_hibernate (DkpDaemon *daemon, DBusGMethodInvocation *context)
gboolean ret;
GError *error;
GError *error_local = NULL;
- gchar *argv;
- const gchar *quirks;
PolKitCaller *pk_caller;
pk_caller = dkp_daemon_local_get_caller_for_context (daemon, context);
@@ -885,11 +903,7 @@ dkp_daemon_hibernate (DkpDaemon *daemon, DBusGMethodInvocation *context)
if (!dkp_daemon_local_check_auth (daemon, pk_caller, "org.freedesktop.devicekit.power.hibernate", context))
goto out;
- /* TODO: where from? */
- quirks = "--quirk-s3-bios --quirk-s3-mode";
-
- argv = g_strdup_printf ("/usr/sbin/pm-hibernate %s", quirks);
- ret = g_spawn_command_line_async (argv, &error_local);
+ ret = g_spawn_command_line_async ("/usr/sbin/pm-hibernate", &error_local);
if (!ret) {
error = g_error_new (DKP_DAEMON_ERROR,
DKP_DAEMON_ERROR_GENERAL,
diff --git a/src/dkp-daemon.h b/src/dkp-daemon.h
index d779086..80b2cc1 100644
--- a/src/dkp-daemon.h
+++ b/src/dkp-daemon.h
@@ -85,6 +85,12 @@ gboolean dkp_daemon_suspend (DkpDaemon *daemon,
DBusGMethodInvocation *context);
gboolean dkp_daemon_hibernate (DkpDaemon *daemon,
DBusGMethodInvocation *context);
+gboolean dkp_daemon_can_suspend (DkpDaemon *daemon,
+ gboolean interactive,
+ DBusGMethodInvocation *context);
+gboolean dkp_daemon_can_hibernate (DkpDaemon *daemon,
+ gboolean interactive,
+ DBusGMethodInvocation *context);
G_END_DECLS
diff --git a/src/org.freedesktop.DeviceKit.Power.xml b/src/org.freedesktop.DeviceKit.Power.xml
index 8f9fa25..28d872e 100644
--- a/src/org.freedesktop.DeviceKit.Power.xml
+++ b/src/org.freedesktop.DeviceKit.Power.xml
@@ -135,6 +135,52 @@
<!-- ************************************************************ -->
+ <method name="CanSuspend">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg name="interactive" direction="in" type="b">
+ <doc:doc>
+ <doc:summary>
+ If we are allowed to be interactive, and ask the user to authorise
+ the action.
+ </doc:summary>
+ </doc:doc>
+ </arg>
+ <doc:doc>
+ <doc:description>
+ <doc:para>
+ Returns if the computer is able to suspend.
+ This function should be used to decide whether to show the
+ Supend menu item or button in GUI programs.
+ </doc:para>
+ </doc:description>
+ </doc:doc>
+ </method>
+
+ <!-- ************************************************************ -->
+
+ <method name="CanHibernate">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg name="interactive" direction="in" type="b">
+ <doc:doc>
+ <doc:summary>
+ If we are allowed to be interactive, and ask the user to authorise
+ the action.
+ </doc:summary>
+ </doc:doc>
+ </arg>
+ <doc:doc>
+ <doc:description>
+ <doc:para>
+ Returns if the computer is able to hibernate.
+ This function should be used to decide whether to show the
+ Hibernate menu item or button in GUI programs.
+ </doc:para>
+ </doc:description>
+ </doc:doc>
+ </method>
+
+ <!-- ************************************************************ -->
+
<method name="Suspend">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<doc:doc>