daemon: Remove obsolete features

This commit is contained in:
Bastien Nocera 2013-10-10 11:55:03 +02:00
parent 030e2c9d36
commit 1ee642e705
12 changed files with 1 additions and 1465 deletions

View file

@ -15,7 +15,6 @@ AM_CPPFLAGS = \
-DHISTORY_DIR=\""$(historydir)"\" \
-D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT \
-DUP_COMPILATION \
-DUP_DISABLE_DEPRECATED \
-DG_LOG_DOMAIN=\"UPower\" \
-I$(top_srcdir)/libupower-glib \
-I$(top_srcdir) \
@ -130,11 +129,6 @@ upowerd_LDFLAGS = \
$(PIE_LDFLAGS) \
$(RELRO_LDFLAGS)
if HAVE_SYSTEMDUTILDIR
systemsleepdir = $(systemdutildir)/system-sleep
systemsleep_SCRIPTS = notify-upower.sh
endif
if UP_BUILD_TESTS
check-local: upowerd
env GI_TYPELIB_PATH=$(top_builddir)/libupower-glib:$(GI_REPOSITORY_PATH) LD_LIBRARY_PATH=$(top_builddir)/libupower-glib/.libs:$(LD_LIBRARY_PATH) top_builddir=$(top_builddir) $(srcdir)/linux/integration-test -v
@ -233,7 +227,6 @@ EXTRA_DIST = \
org.freedesktop.UPower.KbdBacklight.xml \
org.freedesktop.UPower.Wakeups.xml \
up-marshal.list \
$(systemsleep_SCRIPTS) \
$(systemdservice_in_files) \
$(dbusservice_in_files) \
$(dbusconf_in_files)

View file

@ -230,74 +230,3 @@ up_backend_new (void)
{
return g_object_new (UP_TYPE_BACKEND, NULL);
}
/**
* up_backend_kernel_can_suspend:
**/
gboolean
up_backend_kernel_can_suspend (UpBackend *backend)
{
return FALSE;
}
/**
* up_backend_kernel_can_hibernate:
**/
gboolean
up_backend_kernel_can_hibernate (UpBackend *backend)
{
return FALSE;
}
/**
* up_backend_has_encrypted_swap:
**/
gboolean
up_backend_has_encrypted_swap (UpBackend *backend)
{
return FALSE;
}
/**
* up_backend_get_used_swap:
*
* Return value: a percentage value
**/
gfloat
up_backend_get_used_swap (UpBackend *backend)
{
return 0.0;
}
/**
* up_backend_get_suspend_command:
**/
const gchar *
up_backend_get_suspend_command (UpBackend *backend)
{
return "/bin/true";
}
/**
* up_backend_get_hibernate_command:
**/
const gchar *
up_backend_get_hibernate_command (UpBackend *backend)
{
return "/bin/true";
}
/**
* up_backend_get_powersave_command:
**/
const gchar *
up_backend_get_powersave_command (UpBackend *backend, gboolean powersave)
{
return "/bin/true";
}
gboolean
up_backend_emits_resuming (UpBackend *backend)
{
return FALSE;
}

View file

@ -44,8 +44,6 @@
#include "up-device.h"
#define UP_BACKEND_REFRESH_TIMEOUT 30 /* seconds */
#define UP_BACKEND_SUSPEND_COMMAND "/usr/sbin/zzz"
#define UP_BACKEND_HIBERNATE_COMMAND "/usr/sbin/acpiconf -s 4"
static void up_backend_class_init (UpBackendClass *klass);
static void up_backend_init (UpBackend *backend);
@ -55,7 +53,6 @@ static gboolean up_backend_refresh_devices (gpointer user_data);
static gboolean up_backend_acpi_devd_notify (UpBackend *backend, const gchar *system, const gchar *subsystem, const gchar *type, const gchar *data);
static gboolean up_backend_create_new_device (UpBackend *backend, UpAcpiNative *native);
static void up_backend_lid_coldplug (UpBackend *backend);
static gboolean up_backend_supports_sleep_state (const gchar *state);
#define UP_BACKEND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_BACKEND, UpBackendPrivate))
@ -298,65 +295,6 @@ up_backend_coldplug (UpBackend *backend, UpDaemon *daemon)
return TRUE;
}
/**
* up_backend_get_powersave_command:
**/
const gchar *
up_backend_get_powersave_command (UpBackend *backend, gboolean powersave)
{
/* XXX: Do we want to use powerd here? */
return NULL;
}
/**
* up_backend_get_suspend_command:
**/
const gchar *
up_backend_get_suspend_command (UpBackend *backend)
{
return UP_BACKEND_SUSPEND_COMMAND;
}
/**
* up_backend_get_hibernate_command:
**/
const gchar *
up_backend_get_hibernate_command (UpBackend *backend)
{
return UP_BACKEND_HIBERNATE_COMMAND;
}
gboolean
up_backend_emits_resuming (UpBackend *backend)
{
return FALSE;
}
/**
* up_backend_kernel_can_suspend:
**/
gboolean
up_backend_kernel_can_suspend (UpBackend *backend)
{
return up_backend_supports_sleep_state ("S3");
}
/**
* up_backend_kernel_can_hibernate:
**/
gboolean
up_backend_kernel_can_hibernate (UpBackend *backend)
{
return up_backend_supports_sleep_state ("S4");
}
gboolean
up_backend_has_encrypted_swap (UpBackend *backend)
{
/* XXX: Add support for GELI? */
return FALSE;
}
/* Return value: a percentage value */
gfloat
up_backend_get_used_swap (UpBackend *backend)
@ -392,26 +330,6 @@ out:
return percent;
}
/**
* up_backend_supports_sleep_state:
**/
static gboolean
up_backend_supports_sleep_state (const gchar *state)
{
gchar *sleep_states;
gboolean ret = FALSE;
sleep_states = up_get_string_sysctl (NULL, "hw.acpi.supported_sleep_state");
if (sleep_states != NULL) {
if (strstr (sleep_states, state) != NULL)
ret = TRUE;
}
g_free (sleep_states);
return ret;
}
/**
* up_backend_class_init:
* @klass: The UpBackendClass

View file

@ -722,8 +722,6 @@ class Tests(unittest.TestCase):
client = UPowerGlib.Client.new()
self.assertTrue(client.get_properties_sync(None))
self.assertRegex(client.get_daemon_version(), '^[0-9.]+$')
self.assertIn(client.get_can_hibernate(), [False, True])
self.assertIn(client.get_can_suspend(), [False, True])
self.assertIn(client.get_is_docked(), [False, True])
self.assertIn(client.get_lid_is_present(), [False, True])
self.assertIn(client.get_lid_is_closed(), [False, True])

View file

@ -49,15 +49,6 @@
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
#ifdef ENABLE_DEPRECATED
#define LOGIND_AVAILABLE() (access("/run/systemd/seats/", F_OK) >= 0)
#define SD_HIBERNATE_COMMAND "gdbus call --system --dest org.freedesktop.login1 --object-path /org/freedesktop/login1 --method org.freedesktop.login1.Manager.Hibernate 'true'"
#define SD_SUSPEND_COMMAND "gdbus call --system --dest org.freedesktop.login1 --object-path /org/freedesktop/login1 --method org.freedesktop.login1.Manager.Suspend 'true'"
#endif
static void up_backend_class_init (UpBackendClass *klass);
static void up_backend_init (UpBackend *backend);
static void up_backend_finalize (GObject *object);
@ -78,9 +69,6 @@ struct UpBackendPrivate
enum {
SIGNAL_DEVICE_ADDED,
SIGNAL_DEVICE_REMOVED,
#ifdef ENABLE_DEPRECATED
SIGNAL_RESUMING,
#endif
SIGNAL_LAST
};
@ -91,13 +79,6 @@ G_DEFINE_TYPE (UpBackend, up_backend, G_TYPE_OBJECT)
static gboolean up_backend_device_add (UpBackend *backend, GUdevDevice *native);
static void up_backend_device_remove (UpBackend *backend, GUdevDevice *native);
#ifdef ENABLE_DEPRECATED
#define UP_BACKEND_SUSPEND_COMMAND "/usr/sbin/pm-suspend"
#define UP_BACKEND_HIBERNATE_COMMAND "/usr/sbin/pm-hibernate"
#define UP_BACKEND_POWERSAVE_TRUE_COMMAND "/usr/sbin/pm-powersave true"
#define UP_BACKEND_POWERSAVE_FALSE_COMMAND "/usr/sbin/pm-powersave false"
#endif
/**
* up_backend_device_new:
**/
@ -367,273 +348,6 @@ up_backend_coldplug (UpBackend *backend, UpDaemon *daemon)
return TRUE;
}
#ifdef ENABLE_DEPRECATED
/**
* up_backend_supports_sleep_state:
*
* use pm-is-supported to test for supported sleep states
**/
static gboolean
up_backend_supports_sleep_state (const gchar *state)
{
gboolean ret = FALSE;
gchar *command;
GError *error = NULL;
gint exit_status;
/* run script from pm-utils */
command = g_strdup_printf ("/usr/bin/pm-is-supported --%s", state);
g_debug ("excuting command: %s", command);
ret = g_spawn_command_line_sync (command, NULL, NULL, &exit_status, &error);
if (!ret) {
g_warning ("failed to run script: %s", error->message);
g_error_free (error);
goto out;
}
ret = (WIFEXITED(exit_status) && (WEXITSTATUS(exit_status) == EXIT_SUCCESS));
out:
g_free (command);
return ret;
}
/**
* up_backend_kernel_can_suspend:
**/
gboolean
up_backend_kernel_can_suspend (UpBackend *backend)
{
return up_backend_supports_sleep_state ("suspend");
}
/**
* up_backend_kernel_can_hibernate:
**/
gboolean
up_backend_kernel_can_hibernate (UpBackend *backend)
{
return up_backend_supports_sleep_state ("hibernate");
}
/**
* up_backend_has_encrypted_swap:
*
* user@local:~$ cat /proc/swaps
* Filename Type Size Used Priority
* /dev/mapper/cryptswap1 partition 4803392 35872 -1
*
* user@local:~$ cat /etc/crypttab
* # <target name> <source device> <key file> <options>
* cryptswap1 /dev/sda5 /dev/urandom swap,cipher=aes-cbc-essiv:sha256
*
* Loop over the swap partitions in /proc/swaps, looking for matches in /etc/crypttab
**/
gboolean
up_backend_has_encrypted_swap (UpBackend *backend)
{
gchar *contents_swaps = NULL;
gchar *contents_crypttab = NULL;
gchar **lines_swaps = NULL;
gchar **lines_crypttab = NULL;
GError *error = NULL;
gboolean ret;
gboolean encrypted_swap = FALSE;
const gchar *filename_swaps = "/proc/swaps";
const gchar *filename_crypttab = "/etc/crypttab";
GPtrArray *devices = NULL;
gchar *device;
guint i, j;
/* get swaps data */
ret = g_file_get_contents (filename_swaps, &contents_swaps, NULL, &error);
if (!ret) {
g_warning ("failed to open %s: %s", filename_swaps, error->message);
g_error_free (error);
goto out;
}
/* get crypttab data */
ret = g_file_get_contents (filename_crypttab, &contents_crypttab, NULL, &error);
if (!ret) {
if (error->code != G_FILE_ERROR_NOENT) {
g_warning ("failed to open %s: %s", filename_crypttab, error->message);
}
g_error_free (error);
goto out;
}
/* split both into lines */
lines_swaps = g_strsplit (contents_swaps, "\n", -1);
lines_crypttab = g_strsplit (contents_crypttab, "\n", -1);
/* get valid swap devices */
devices = g_ptr_array_new_with_free_func (g_free);
for (i=0; lines_swaps[i] != NULL; i++) {
/* is a device? */
if (lines_swaps[i][0] != '/')
continue;
/* only look at first parameter */
g_strdelimit (lines_swaps[i], "\t ", '\0');
/* add base device to list */
device = g_path_get_basename (lines_swaps[i]);
g_debug ("adding swap device: %s", device);
g_ptr_array_add (devices, device);
}
/* no swap devices? */
if (devices->len == 0) {
g_debug ("no swap devices");
goto out;
}
/* find matches in crypttab */
for (i=0; lines_crypttab[i] != NULL; i++) {
/* ignore invalid lines */
if (lines_crypttab[i][0] == '#' ||
lines_crypttab[i][0] == '\n' ||
lines_crypttab[i][0] == '\t' ||
lines_crypttab[i][0] == '\0')
continue;
/* only look at first parameter */
g_strdelimit (lines_crypttab[i], "\t ", '\0');
/* is a swap device? */
for (j=0; j<devices->len; j++) {
device = g_ptr_array_index (devices, j);
if (g_strcmp0 (device, lines_crypttab[i]) == 0) {
g_debug ("swap device %s is encrypted (so cannot hibernate)", device);
encrypted_swap = TRUE;
goto out;
}
g_debug ("swap device %s is not encrypted (allows hibernate)", device);
}
}
out:
if (devices != NULL)
g_ptr_array_unref (devices);
g_free (contents_swaps);
g_free (contents_crypttab);
g_strfreev (lines_swaps);
g_strfreev (lines_crypttab);
return encrypted_swap;
}
/**
* up_backend_get_used_swap:
*
* Return value: a percentage value how much of the available swap memory would
* be taken by currently active memory
**/
gfloat
up_backend_get_used_swap (UpBackend *backend)
{
gchar *contents = NULL;
gchar **lines = NULL;
GError *error = NULL;
gchar **tokens;
gboolean ret;
guint active = 0;
guint swap_free = 0;
guint swap_total = 0;
guint len;
guint i;
gfloat percentage = 0.0f;
const gchar *filename = "/proc/meminfo";
/* get memory data */
ret = g_file_get_contents (filename, &contents, NULL, &error);
if (!ret) {
g_warning ("failed to open %s: %s", filename, error->message);
g_error_free (error);
goto out;
}
/* process each line */
lines = g_strsplit (contents, "\n", -1);
for (i=1; lines[i] != NULL; i++) {
tokens = g_strsplit_set (lines[i], ": ", -1);
len = g_strv_length (tokens);
if (len > 3) {
if (g_strcmp0 (tokens[0], "SwapFree") == 0)
swap_free = atoi (tokens[len-2]);
if (g_strcmp0 (tokens[0], "SwapTotal") == 0)
swap_total = atoi (tokens[len-2]);
else if (g_strcmp0 (tokens[0], "Active(anon)") == 0)
active = atoi (tokens[len-2]);
}
g_strfreev (tokens);
}
/* first check if we even have swap, if not consider all swap space used */
if (swap_total == 0) {
g_debug ("no swap space found");
percentage = 100.0f;
goto out;
}
/* work out how close to the line we are */
if (swap_free > 0 && active > 0)
percentage = (active * 100) / swap_free;
g_debug ("total swap available %i kb, active memory %i kb (%.1f%%)", swap_free, active, percentage);
out:
g_free (contents);
g_strfreev (lines);
return percentage;
}
/**
* up_backend_get_suspend_command:
**/
const gchar *
up_backend_get_suspend_command (UpBackend *backend)
{
if (LOGIND_AVAILABLE())
return SD_SUSPEND_COMMAND;
else
return UP_BACKEND_SUSPEND_COMMAND;
}
/**
* up_backend_get_hibernate_command:
**/
const gchar *
up_backend_get_hibernate_command (UpBackend *backend)
{
if (LOGIND_AVAILABLE())
return SD_HIBERNATE_COMMAND;
else
return UP_BACKEND_HIBERNATE_COMMAND;
}
gboolean
up_backend_emits_resuming (UpBackend *backend)
{
if (LOGIND_AVAILABLE())
return TRUE;
else
return FALSE;
}
#endif
#ifdef ENABLE_DEPRECATED
/**
* up_backend_get_powersave_command:
**/
const gchar *
up_backend_get_powersave_command (UpBackend *backend, gboolean powersave)
{
if (powersave)
return UP_BACKEND_POWERSAVE_TRUE_COMMAND;
return UP_BACKEND_POWERSAVE_FALSE_COMMAND;
}
#endif
/**
* up_backend_class_init:
* @klass: The UpBackendClass
@ -656,35 +370,10 @@ up_backend_class_init (UpBackendClass *klass)
G_STRUCT_OFFSET (UpBackendClass, device_removed),
NULL, NULL, up_marshal_VOID__POINTER_POINTER,
G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
#ifdef ENABLE_DEPRECATED
signals [SIGNAL_RESUMING] =
g_signal_new ("resuming",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (UpBackendClass, resuming),
NULL, NULL, g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
#endif
g_type_class_add_private (klass, sizeof (UpBackendPrivate));
}
#ifdef ENABLE_DEPRECATED
static DBusHandlerResult
message_filter (DBusConnection *connection,
DBusMessage *message,
void *user_data)
{
UpBackend *backend = user_data;
if (dbus_message_is_signal (message, "org.freedesktop.UPower", "Resuming")) {
g_debug ("received Resuming signal");
g_signal_emit (backend, signals[SIGNAL_RESUMING], 0);
return DBUS_HANDLER_RESULT_HANDLED;
}
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
#endif
/**
* up_backend_init:
**/
@ -696,15 +385,6 @@ up_backend_init (UpBackend *backend)
backend->priv->daemon = NULL;
backend->priv->device_list = NULL;
backend->priv->managed_devices = up_device_list_new ();
#ifdef ENABLE_DEPRECATED
if (LOGIND_AVAILABLE()) {
DBusGConnection *bus;
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
backend->priv->connection = dbus_g_connection_get_connection (bus);
dbus_connection_add_filter (backend->priv->connection, message_filter, backend, NULL);
}
#endif
}
/**
@ -729,11 +409,6 @@ up_backend_finalize (GObject *object)
g_object_unref (backend->priv->managed_devices);
#ifdef ENABLE_DEPRECATED
if (backend->priv->connection)
dbus_connection_remove_filter (backend->priv->connection, message_filter, backend);
#endif
G_OBJECT_CLASS (up_backend_parent_class)->finalize (object);
}

View file

@ -33,7 +33,6 @@ struct UpDockPrivate
UpDaemon *daemon;
GUdevClient *gudev_client;
guint poll_id;
guint notify_resume_id;
};
G_DEFINE_TYPE (UpDock, up_dock, G_TYPE_OBJECT)
@ -120,17 +119,6 @@ up_dock_set_should_poll (UpDock *dock, gboolean should_poll)
}
}
/**
* up_dock_notify_resume_cb
*/
static void
up_dock_notify_resume_cb (UpDaemon *daemon,
const gchar *sleep_kind,
UpDock *dock)
{
up_dock_refresh (dock);
}
/**
* up_dock_coldplug:
**/
@ -139,9 +127,6 @@ up_dock_coldplug (UpDock *dock, UpDaemon *daemon)
{
/* save daemon */
dock->priv->daemon = g_object_ref (daemon);
dock->priv->notify_resume_id = g_signal_connect (dock->priv->daemon, "notify-resume",
G_CALLBACK (up_dock_notify_resume_cb),
dock);
return up_dock_refresh (dock);
}
@ -185,8 +170,6 @@ up_dock_finalize (GObject *object)
g_return_if_fail (dock->priv != NULL);
g_object_unref (dock->priv->gudev_client);
if (dock->priv->notify_resume_id != 0)
g_signal_handler_disconnect (dock->priv->daemon, dock->priv->notify_resume_id);
if (dock->priv->daemon != NULL)
g_object_unref (dock->priv->daemon);
if (dock->priv->poll_id != 0)

View file

@ -1,7 +0,0 @@
#!/bin/bash
[ "$1" = "post" ] && exec /usr/bin/dbus-send \
--system --type=signal \
--dest=org.freedesktop.UPower \
/org/freedesktop/UPower \
org.freedesktop.UPower.Resuming
exit 0

View file

@ -27,10 +27,6 @@
#include "up-device.h"
#include <string.h> /* strcmp() */
#define UP_BACKEND_SUSPEND_COMMAND "/usr/sbin/zzz"
#define UP_BACKEND_POWERSAVE_TRUE_COMMAND "/usr/sbin/apm -C"
#define UP_BACKEND_POWERSAVE_FALSE_COMMAND "/usr/sbin/apm -A"
static void up_backend_class_init (UpBackendClass *klass);
static void up_backend_init (UpBackend *backend);
static void up_backend_finalize (GObject *object);
@ -176,72 +172,6 @@ up_backend_coldplug (UpBackend *backend, UpDaemon *daemon)
}
/**
* up_backend_get_powersave_command:
**/
const gchar *
up_backend_get_powersave_command (UpBackend *backend, gboolean powersave)
{
if (powersave)
return UP_BACKEND_POWERSAVE_TRUE_COMMAND;
return UP_BACKEND_POWERSAVE_FALSE_COMMAND;
}
/**
* up_backend_get_suspend_command:
**/
const gchar *
up_backend_get_suspend_command (UpBackend *backend)
{
return UP_BACKEND_SUSPEND_COMMAND;
}
/**
* up_backend_get_hibernate_command:
**/
const gchar *
up_backend_get_hibernate_command (UpBackend *backend)
{
return NULL;
}
gboolean
up_backend_emits_resuming (UpBackend *backend)
{
return FALSE;
}
/**
* up_backend_kernel_can_suspend:
**/
gboolean
up_backend_kernel_can_suspend (UpBackend *backend)
{
return TRUE;
}
/**
* up_backend_kernel_can_hibernate:
**/
gboolean
up_backend_kernel_can_hibernate (UpBackend *backend)
{
return FALSE;
}
gboolean
up_backend_has_encrypted_swap (UpBackend *backend)
{
return FALSE;
}
/* Return value: a percentage value */
gfloat
up_backend_get_used_swap (UpBackend *backend)
{
return 0;
}
/**
* OpenBSD specific code
**/

View file

@ -113,219 +113,12 @@ method return sender=:1.386 -> dest=:1.451 reply_serial=2
<!-- ************************************************************ -->
<signal name="Sleeping">
<doc:doc>
<doc:description>
<doc:para>
This signal is sent when the session is about to be suspended or
hibernated.
</doc:para>
<doc:para>
This signal is DEPRECATED. Use NotifySleep() instead.
</doc:para>
</doc:description>
</doc:doc>
</signal>
<!-- ************************************************************ -->
<signal name="NotifySleep">
<doc:doc>
<doc:description>
<doc:para>
This signal is sent when the session is about to be suspended or
hibernated.
Session and system programs have one second to do anything required
before the sleep action is taken (such as sending out Avahi or
Jabber messages).
</doc:para>
</doc:description>
</doc:doc>
<arg name="action" direction="out" type="s">
<doc:doc>
<doc:summary>
The sleep action type, e.g. <doc:tt>suspend</doc:tt>,
<doc:tt>hibernate</doc:tt> or <doc:tt>hybrid</doc:tt>.
</doc:summary>
</doc:doc>
</arg>
</signal>
<!-- ************************************************************ -->
<signal name="Resuming">
<doc:doc>
<doc:description>
<doc:para>
This signal is sent when the session has just returned from
Suspend() or Hibernate().
</doc:para>
<doc:para>
This signal is DEPRECATED. Use NotifyResume() instead.
</doc:para>
</doc:description>
</doc:doc>
</signal>
<!-- ************************************************************ -->
<signal name="NotifyResume">
<doc:doc>
<doc:description>
<doc:para>
This signal is sent when the session has just returned from
Suspend() or Hibernate().
Session and system programs can then do anything required (such as
sending out Avahi or Jabber messages).
</doc:para>
</doc:description>
</doc:doc>
<arg name="action" direction="out" type="s">
<doc:doc>
<doc:summary>
The sleep action type, e.g. <doc:tt>suspend</doc:tt>,
<doc:tt>hibernate</doc:tt> or <doc:tt>hybrid</doc:tt>.
</doc:summary>
</doc:doc>
</arg>
</signal>
<!-- ************************************************************ -->
<method name="AboutToSleep">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<doc:doc>
<doc:description>
<doc:para>
This method tells UPower that the Suspend() or Hibernate() method
is about to be called.
This allows UPower to emit the Suspending signal whilst
session activities are happening that have to be done before the
suspend process is started.
</doc:para>
<doc:para>
This method would typically be called by the session power
management daemon, before it locks the screen and waits for the
screen to fade to black.
The session power management component would then call Suspend() or
Hibernate() when these syncronous tasks have completed.
</doc:para>
<doc:para>
If this method is not called than nothing bad will happen and
Suspend() or Hibernate() will block for the required second.
</doc:para>
</doc:description>
</doc:doc>
<arg name="action" direction="in" type="s">
<doc:doc>
<doc:summary>
The sleep action type, e.g. <doc:tt>suspend</doc:tt> or
<doc:tt>hibernate</doc:tt>.
</doc:summary>
</doc:doc>
</arg>
</method>
<!-- ************************************************************ -->
<method name="Suspend">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<doc:doc>
<doc:description>
<doc:para>
Suspends the computer into a low power state.
System state is not preserved if the power is lost.
</doc:para>
<doc:para>
If AboutToSleep() has not been called then UPower will send
the Sleeping() signal and block for one second.
</doc:para>
<doc:para>
If AboutToSleep() has been called less than one second
before this method is called then UPower will block for the
remaining time to complete one second of delay.
</doc:para>
</doc:description>
</doc:doc>
</method>
<!-- ************************************************************ -->
<method name="SuspendAllowed">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg name="allowed" direction="out" type="b">
<doc:doc><doc:summary>TRUE if allowed, otherwise FALSE</doc:summary></doc:doc>
</arg>
<doc:doc>
<doc:description>
<doc:para>
Check if the caller has (or can get) the PolicyKit privilege to call
<doc:ref type="method" to="Power.Suspend">Suspend</doc:ref>.
</doc:para>
</doc:description>
</doc:doc>
</method>
<!-- ************************************************************ -->
<method name="Hibernate">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<doc:doc>
<doc:description>
<doc:para>
Hibernates the computer into a low power state.
System state is preserved if the power is lost.
</doc:para>
<doc:para>
If AboutToSleep() has not been called then UPower will send
the Sleeping() signal and block for one second.
</doc:para>
<doc:para>
If AboutToSleep() has been called less than one second
before this method is called then UPower will block for the
remaining time to complete one second of delay.
</doc:para>
</doc:description>
</doc:doc>
</method>
<!-- ************************************************************ -->
<method name="HibernateAllowed">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg name="allowed" direction="out" type="b">
<doc:doc><doc:summary>TRUE if allowed, otherwise FALSE</doc:summary></doc:doc>
</arg>
<doc:doc>
<doc:description>
<doc:para>
Check if the caller has (or can get) the PolicyKit privilege to call
<doc:ref type="method" to="Power.Hibernate">Hibernate</doc:ref>.
</doc:para>
</doc:description>
</doc:doc>
</method>
<!-- ************************************************************ -->
<property name="DaemonVersion" type="s" access="read">
<doc:doc><doc:description><doc:para>
Version of the running daemon, e.g. <doc:tt>002</doc:tt>.
</doc:para></doc:description></doc:doc>
</property>
<property name="CanSuspend" type="b" access="read">
<doc:doc><doc:description><doc:para>
Whether the system is able to suspend.
</doc:para></doc:description></doc:doc>
</property>
<property name="CanHibernate" type="b" access="read">
<doc:doc><doc:description><doc:para>
Whether the system is able to hibernate.
</doc:para></doc:description></doc:doc>
</property>
<property name="OnBattery" type="b" access="read">
<doc:doc><doc:description><doc:para>
Indicates whether the system is running on battery power.
@ -360,24 +153,6 @@ method return sender=:1.386 -> dest=:1.451 reply_serial=2
</doc:doc>
</property>
<property name="LidForceSleep" type="b" access="read">
<doc:doc>
<doc:description>
<doc:para>
If the system really has to sleep when the lid is closed.
Some laptops actually melt (!) if the lid is closed and the
computer keeps running. We blacklist those, and do something
sane for the other machines.
</doc:para>
<doc:para>
This allows us to set the default session policy to not
suspend on lid close if the laptop is docked, and be sure
the machine is not going to melt.
</doc:para>
</doc:description>
</doc:doc>
</property>
<property name="IsDocked" type="b" access="read">
<doc:doc>
<doc:description>

View file

@ -61,9 +61,6 @@ typedef struct
void (* device_removed) (UpBackend *backend,
GObject *native,
UpDevice *device);
#ifdef ENABLE_DEPRECATED
void (* resuming) (UpBackend *backend);
#endif
} UpBackendClass;
GType up_backend_get_type (void);
@ -72,21 +69,6 @@ void up_backend_test (gpointer user_data);
gboolean up_backend_coldplug (UpBackend *backend,
UpDaemon *daemon);
#ifdef ENABLE_DEPRECATED
gboolean up_backend_kernel_can_suspend (UpBackend *backend);
gboolean up_backend_kernel_can_hibernate (UpBackend *backend);
gboolean up_backend_has_encrypted_swap (UpBackend *backend);
gfloat up_backend_get_used_swap (UpBackend *backend);
const gchar *up_backend_get_suspend_command (UpBackend *backend);
const gchar *up_backend_get_hibernate_command (UpBackend *backend);
#endif
#ifdef ENABLE_DEPRECATED
const gchar *up_backend_get_powersave_command (UpBackend *backend,
gboolean powersave);
#endif
#ifdef ENABLE_DEPRECATED
gboolean up_backend_emits_resuming (UpBackend *backend);
#endif
G_END_DECLS

View file

@ -46,13 +46,10 @@ enum
{
PROP_0,
PROP_DAEMON_VERSION,
PROP_CAN_SUSPEND,
PROP_CAN_HIBERNATE,
PROP_ON_BATTERY,
PROP_ON_LOW_BATTERY,
PROP_LID_IS_CLOSED,
PROP_LID_IS_PRESENT,
PROP_LID_FORCE_SLEEP,
PROP_IS_DOCKED,
PROP_LAST
};
@ -63,10 +60,6 @@ enum
SIGNAL_DEVICE_REMOVED,
SIGNAL_DEVICE_CHANGED,
SIGNAL_CHANGED,
SIGNAL_SLEEPING,
SIGNAL_RESUMING,
SIGNAL_NOTIFY_SLEEP,
SIGNAL_NOTIFY_RESUME,
SIGNAL_LAST,
};
@ -84,27 +77,10 @@ struct UpDaemonPrivate
gboolean on_low_battery;
gboolean lid_is_closed;
gboolean lid_is_present;
gboolean lid_force_sleep;
gboolean is_docked;
#ifdef ENABLE_DEPRECATED
gboolean kernel_can_suspend;
gboolean kernel_can_hibernate;
gboolean hibernate_has_encrypted_swap;
#endif
gboolean during_coldplug;
#ifdef ENABLE_DEPRECATED
gboolean sent_sleeping_signal;
#endif
guint battery_poll_id;
guint battery_poll_count;
#ifdef ENABLE_DEPRECATED
GTimer *about_to_sleep_timer;
guint about_to_sleep_id;
guint conf_sleep_timeout;
gboolean conf_allow_hibernate_encrypted_swap;
gboolean conf_run_powersave_command;
#endif
const gchar *sleep_kind;
};
static void up_daemon_finalize (GObject *object);
@ -116,12 +92,6 @@ G_DEFINE_TYPE (UpDaemon, up_daemon, G_TYPE_OBJECT)
#define UP_DAEMON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_DAEMON, UpDaemonPrivate))
/* if using more memory compared to usable swap, disable hibernate */
/* Native Linux suspend-to-disk does not use compression, and needs 2 KB of
* page meta information for each MB of active memory. Add some error margin
* here, though. */
#define UP_DAEMON_SWAP_WATERLINE 98.f /* % */
/* refresh all the devices after this much time when on-battery has changed */
#define UP_DAEMON_ON_BATTERY_REFRESH_DEVICES_DELAY 1 /* seconds */
#define UP_DAEMON_POLL_BATTERY_NUMBER_TIMES 5
@ -239,35 +209,6 @@ up_daemon_get_on_ac_local (UpDaemon *daemon)
return result;
}
#ifdef ENABLE_DEPRECATED
/**
* up_daemon_set_powersave:
**/
static gboolean
up_daemon_set_powersave (UpDaemon *daemon, gboolean powersave)
{
gboolean ret = FALSE;
const gchar *command;
GError *error = NULL;
/* run script */
command = up_backend_get_powersave_command (daemon->priv->backend, powersave);
if (command == NULL) {
g_warning ("no powersave command set");
goto out;
}
g_debug ("excuting command: %s", command);
ret = g_spawn_command_line_async (command, &error);
if (!ret) {
g_warning ("failed to run script: %s", error->message);
g_error_free (error);
goto out;
}
out:
return ret;
}
#endif
/**
* up_daemon_refresh_battery_devices:
**/
@ -323,439 +264,6 @@ up_daemon_enumerate_devices (UpDaemon *daemon, DBusGMethodInvocation *context)
return TRUE;
}
/**
* up_daemon_about_to_sleep:
**/
gboolean
up_daemon_about_to_sleep (UpDaemon *daemon,
const gchar *sleep_kind,
DBusGMethodInvocation *context)
{
GError *error;
#ifdef ENABLE_DEPRECATED
PolkitSubject *subject = NULL;
UpDaemonPrivate *priv = daemon->priv;
/* already requested */
if (priv->about_to_sleep_id != 0) {
error = g_error_new (UP_DAEMON_ERROR,
UP_DAEMON_ERROR_GENERAL,
"Sleep has already been requested and is pending");
dbus_g_method_return_error (context, error);
g_error_free (error);
goto out;
}
subject = up_polkit_get_subject (priv->polkit, context);
if (subject == NULL)
goto out;
/* TODO: use another PolicyKit context? */
if (!up_polkit_check_auth (priv->polkit, subject, "org.freedesktop.upower.suspend", context))
goto out;
/* we've told the clients we're going down */
g_debug ("emitting sleeping");
g_signal_emit (daemon, signals[SIGNAL_SLEEPING], 0);
g_signal_emit (daemon, signals[SIGNAL_NOTIFY_SLEEP], 0,
sleep_kind);
g_timer_start (priv->about_to_sleep_timer);
daemon->priv->sent_sleeping_signal = TRUE;
dbus_g_method_return (context, NULL);
out:
if (subject != NULL)
g_object_unref (subject);
return TRUE;
#else
/* just return an error */
error = g_error_new_literal (UP_DAEMON_ERROR,
UP_DAEMON_ERROR_GENERAL,
"Method is deprecated, please port to org.freedesktop.login1.Manager.Inhibit");
dbus_g_method_return_error (context, error);
g_error_free (error);
return FALSE;
#endif
}
/* temp object for deferred callback */
typedef struct {
UpDaemon *daemon;
DBusGMethodInvocation *context;
gchar *command;
gulong handler;
} UpDaemonDeferredSleep;
#ifdef ENABLE_DEPRECATED
static void
emit_resuming (UpDaemonDeferredSleep *sleep)
{
UpDaemon *daemon = sleep->daemon;
UpDaemonPrivate *priv = daemon->priv;
/* emit signal for session components */
g_debug ("emitting resuming");
g_signal_emit (daemon, signals[SIGNAL_RESUMING], 0);
g_signal_emit (daemon, signals[SIGNAL_NOTIFY_RESUME], 0,
priv->sleep_kind);
/* reset the about-to-sleep logic */
g_timer_reset (priv->about_to_sleep_timer);
g_timer_stop (priv->about_to_sleep_timer);
/* actually return from the DBus call now */
dbus_g_method_return (sleep->context, NULL);
/* clear timer */
priv->about_to_sleep_id = 0;
priv->sent_sleeping_signal = FALSE;
/* delete temp object */
if (sleep->handler)
g_signal_handler_disconnect (priv->backend, sleep->handler);
g_object_unref (sleep->daemon);
g_free (sleep->command);
g_free (sleep);
}
/**
* up_daemon_deferred_sleep_cb:
**/
static gboolean
up_daemon_deferred_sleep_cb (UpDaemonDeferredSleep *sleep)
{
GError *error;
GError *error_local = NULL;
gchar *stdout = NULL;
gchar *stderr = NULL;
gboolean ret;
UpDaemon *daemon = sleep->daemon;
UpDaemonPrivate *priv = daemon->priv;
if (up_backend_emits_resuming (priv->backend)) {
sleep->handler = g_signal_connect_swapped (priv->backend, "resuming",
G_CALLBACK (emit_resuming), sleep);
}
/* run the command */
g_debug ("Running %s", sleep->command);
ret = g_spawn_command_line_sync (sleep->command, &stdout, &stderr, NULL, &error_local);
if (!ret) {
error = g_error_new (UP_DAEMON_ERROR,
UP_DAEMON_ERROR_GENERAL,
"Failed to spawn: %s, stdout:%s, stderr:%s", error_local->message, stdout, stderr);
g_error_free (error_local);
dbus_g_method_return_error (sleep->context, error);
g_error_free (error);
goto out;
}
if (!up_backend_emits_resuming (priv->backend))
emit_resuming (sleep);
out:
g_free (stdout);
g_free (stderr);
return FALSE;
}
/**
* up_daemon_deferred_sleep:
**/
static void
up_daemon_deferred_sleep (UpDaemon *daemon, const gchar *command, DBusGMethodInvocation *context)
{
UpDaemonDeferredSleep *sleep;
UpDaemonPrivate *priv = daemon->priv;
gfloat elapsed;
/* create callback object */
sleep = g_new0 (UpDaemonDeferredSleep, 1);
sleep->daemon = g_object_ref (daemon);
sleep->context = context;
sleep->command = g_strdup (command);
/* we didn't use AboutToSleep() so send the signal for clients now */
if (!priv->sent_sleeping_signal) {
g_debug ("no AboutToSleep(), so emitting ::Sleeping()");
g_signal_emit (daemon, signals[SIGNAL_SLEEPING], 0);
g_signal_emit (daemon, signals[SIGNAL_NOTIFY_SLEEP], 0,
priv->sleep_kind);
priv->about_to_sleep_id = g_timeout_add (priv->conf_sleep_timeout,
(GSourceFunc) up_daemon_deferred_sleep_cb, sleep);
#if GLIB_CHECK_VERSION(2,25,8)
g_source_set_name_by_id (priv->about_to_sleep_id, "[UpDaemon] about-to-sleep no signal");
#endif
return;
}
/* about to sleep */
elapsed = 1000.0f * g_timer_elapsed (priv->about_to_sleep_timer, NULL);
g_debug ("between AboutToSleep() and %s was %fms", sleep->command, elapsed);
if (elapsed < priv->conf_sleep_timeout) {
/* we have to wait for the difference in time */
priv->about_to_sleep_id = g_timeout_add (priv->conf_sleep_timeout - elapsed,
(GSourceFunc) up_daemon_deferred_sleep_cb, sleep);
#if GLIB_CHECK_VERSION(2,25,8)
g_source_set_name_by_id (priv->about_to_sleep_id, "[UpDaemon] about-to-sleep less");
#endif
} else {
/* we can do this straight away */
priv->about_to_sleep_id = g_idle_add ((GSourceFunc) up_daemon_deferred_sleep_cb, sleep);
#if GLIB_CHECK_VERSION(2,25,8)
g_source_set_name_by_id (priv->about_to_sleep_id, "[UpDaemon] about-to-sleep more");
#endif
}
}
#endif
/**
* up_daemon_suspend:
**/
gboolean
up_daemon_suspend (UpDaemon *daemon, DBusGMethodInvocation *context)
{
GError *error;
#ifdef ENABLE_DEPRECATED
PolkitSubject *subject = NULL;
const gchar *command;
UpDaemonPrivate *priv = daemon->priv;
/* no kernel support */
if (!priv->kernel_can_suspend) {
error = g_error_new (UP_DAEMON_ERROR,
UP_DAEMON_ERROR_GENERAL,
"No kernel support");
dbus_g_method_return_error (context, error);
g_error_free (error);
goto out;
}
subject = up_polkit_get_subject (priv->polkit, context);
if (subject == NULL)
goto out;
if (!up_polkit_check_auth (priv->polkit, subject, "org.freedesktop.upower.suspend", context))
goto out;
/* already requested */
if (priv->about_to_sleep_id != 0) {
error = g_error_new (UP_DAEMON_ERROR,
UP_DAEMON_ERROR_GENERAL,
"Sleep has already been requested and is pending");
dbus_g_method_return_error (context, error);
g_error_free (error);
goto out;
}
/* do this deferred action */
priv->sleep_kind = "suspend";
command = up_backend_get_suspend_command (priv->backend);
up_daemon_deferred_sleep (daemon, command, context);
out:
if (subject != NULL)
g_object_unref (subject);
return TRUE;
#else
/* just return an error */
error = g_error_new_literal (UP_DAEMON_ERROR,
UP_DAEMON_ERROR_GENERAL,
"Method is deprecated, please port to org.freedesktop.login1.Manager.Suspend");
dbus_g_method_return_error (context, error);
g_error_free (error);
return FALSE;
#endif
}
/**
* up_daemon_suspend_allowed:
**/
gboolean
up_daemon_suspend_allowed (UpDaemon *daemon, DBusGMethodInvocation *context)
{
GError *error;
#ifdef ENABLE_DEPRECATED
gboolean ret;
PolkitSubject *subject = NULL;
UpDaemonPrivate *priv = daemon->priv;
subject = up_polkit_get_subject (priv->polkit, context);
if (subject == NULL)
goto out;
error = NULL;
ret = up_polkit_is_allowed (priv->polkit, subject, "org.freedesktop.upower.suspend", &error);
if (error) {
dbus_g_method_return_error (context, error);
g_error_free (error);
}
else {
dbus_g_method_return (context, ret);
}
out:
if (subject != NULL)
g_object_unref (subject);
return TRUE;
#else
/* just return an error */
error = g_error_new_literal (UP_DAEMON_ERROR,
UP_DAEMON_ERROR_GENERAL,
"Method is deprecated, please port to org.freedesktop.login1.Manager.CanSuspend");
dbus_g_method_return_error (context, error);
g_error_free (error);
return FALSE;
#endif
}
#ifdef ENABLE_DEPRECATED
/**
* up_daemon_check_hibernate_swap:
*
* Check current memory usage whether we have enough swap space for
* hibernate.
**/
static gboolean
up_daemon_check_hibernate_swap (UpDaemon *daemon)
{
gfloat waterline;
if (daemon->priv->kernel_can_hibernate) {
waterline = up_backend_get_used_swap (daemon->priv->backend);
if (waterline < UP_DAEMON_SWAP_WATERLINE) {
g_debug ("enough swap to for hibernate");
return TRUE;
} else {
g_debug ("not enough swap to hibernate");
return FALSE;
}
}
return FALSE;
}
#endif
/**
* up_daemon_hibernate:
**/
gboolean
up_daemon_hibernate (UpDaemon *daemon, DBusGMethodInvocation *context)
{
GError *error;
#ifdef ENABLE_DEPRECATED
PolkitSubject *subject = NULL;
const gchar *command;
UpDaemonPrivate *priv = daemon->priv;
/* no kernel support */
if (!priv->kernel_can_hibernate) {
error = g_error_new (UP_DAEMON_ERROR,
UP_DAEMON_ERROR_GENERAL,
"No kernel support");
dbus_g_method_return_error (context, error);
g_error_free (error);
goto out;
}
/* enough swap? */
if (!up_daemon_check_hibernate_swap (daemon)) {
error = g_error_new (UP_DAEMON_ERROR,
UP_DAEMON_ERROR_GENERAL,
"Not enough swap space");
dbus_g_method_return_error (context, error);
g_error_free (error);
goto out;
}
/* encrypted swap and no override? */
if (priv->hibernate_has_encrypted_swap &&
!priv->conf_allow_hibernate_encrypted_swap) {
error = g_error_new (UP_DAEMON_ERROR,
UP_DAEMON_ERROR_GENERAL,
"Swap space is encrypted, use AllowHibernateEncryptedSwap to override");
dbus_g_method_return_error (context, error);
g_error_free (error);
goto out;
}
subject = up_polkit_get_subject (priv->polkit, context);
if (subject == NULL)
goto out;
if (!up_polkit_check_auth (priv->polkit, subject, "org.freedesktop.upower.hibernate", context))
goto out;
/* already requested */
if (priv->about_to_sleep_id != 0) {
error = g_error_new (UP_DAEMON_ERROR,
UP_DAEMON_ERROR_GENERAL,
"Sleep has already been requested and is pending");
dbus_g_method_return_error (context, error);
g_error_free (error);
goto out;
}
/* do this deferred action */
priv->sleep_kind = "hibernate";
command = up_backend_get_hibernate_command (priv->backend);
up_daemon_deferred_sleep (daemon, command, context);
out:
if (subject != NULL)
g_object_unref (subject);
return TRUE;
#else
/* just return an error */
error = g_error_new_literal (UP_DAEMON_ERROR,
UP_DAEMON_ERROR_GENERAL,
"Method is deprecated, please port to org.freedesktop.login1.Manager.Hibernate");
dbus_g_method_return_error (context, error);
g_error_free (error);
return FALSE;
#endif
}
/**
* up_daemon_hibernate_allowed:
**/
gboolean
up_daemon_hibernate_allowed (UpDaemon *daemon, DBusGMethodInvocation *context)
{
GError *error;
#ifdef ENABLE_DEPRECATED
gboolean ret;
PolkitSubject *subject = NULL;
UpDaemonPrivate *priv = daemon->priv;
subject = up_polkit_get_subject (priv->polkit, context);
if (subject == NULL)
goto out;
error = NULL;
ret = up_polkit_is_allowed (priv->polkit, subject, "org.freedesktop.upower.hibernate", &error);
if (error) {
dbus_g_method_return_error (context, error);
g_error_free (error);
}
else {
dbus_g_method_return (context, ret);
}
out:
if (subject != NULL)
g_object_unref (subject);
return TRUE;
#else
/* just return an error */
error = g_error_new_literal (UP_DAEMON_ERROR,
UP_DAEMON_ERROR_GENERAL,
"Method is deprecated, please port to org.freedesktop.login1.Manager.CanHibernate");
dbus_g_method_return_error (context, error);
g_error_free (error);
return FALSE;
#endif
}
/**
* up_daemon_register_power_daemon:
**/
@ -834,11 +342,6 @@ up_daemon_startup (UpDaemon *daemon)
priv->during_coldplug = FALSE;
g_debug ("daemon now not coldplug");
#ifdef ENABLE_DEPRECATED
/* set power policy */
if (priv->conf_run_powersave_command)
up_daemon_set_powersave (daemon, priv->on_battery);
#endif
out:
return ret;
}
@ -871,18 +374,6 @@ up_daemon_set_lid_is_closed (UpDaemon *daemon, gboolean lid_is_closed)
g_object_notify (G_OBJECT (daemon), "lid-is-closed");
}
/**
* up_daemon_set_lid_force_sleep:
**/
void
up_daemon_set_lid_force_sleep (UpDaemon *daemon, gboolean lid_force_sleep)
{
UpDaemonPrivate *priv = daemon->priv;
g_debug ("lid_force_sleep = %s", lid_force_sleep ? "yes" : "no");
priv->lid_force_sleep = lid_force_sleep;
g_object_notify (G_OBJECT (daemon), "lid-enforce-sleep");
}
/**
* up_daemon_set_lid_is_present:
**/
@ -1008,12 +499,6 @@ up_daemon_device_changed_cb (UpDevice *device, UpDaemon *daemon)
ret = (up_daemon_get_on_battery_local (daemon) && !up_daemon_get_on_ac_local (daemon));
if (ret != priv->on_battery) {
up_daemon_set_on_battery (daemon, ret);
#ifdef ENABLE_DEPRECATED
/* set power policy */
if (priv->conf_run_powersave_command)
up_daemon_set_powersave (daemon, ret);
#endif
}
ret = up_daemon_get_on_low_battery_local (daemon);
if (ret != priv->on_low_battery)
@ -1155,10 +640,6 @@ up_daemon_init (UpDaemon *daemon)
daemon->priv->during_coldplug = FALSE;
daemon->priv->battery_poll_id = 0;
daemon->priv->battery_poll_count = 0;
#ifdef ENABLE_DEPRECATED
daemon->priv->conf_sleep_timeout = 1000;
daemon->priv->conf_run_powersave_command = TRUE;
#endif
/* load some values from the config file */
file = g_key_file_new ();
@ -1171,14 +652,7 @@ up_daemon_init (UpDaemon *daemon)
}
ret = g_key_file_load_from_file (file, filename, G_KEY_FILE_NONE, &error);
if (ret) {
#ifdef ENABLE_DEPRECATED
daemon->priv->conf_sleep_timeout =
g_key_file_get_integer (file, "UPower", "SleepTimeout", NULL);
daemon->priv->conf_allow_hibernate_encrypted_swap =
g_key_file_get_boolean (file, "UPower", "AllowHibernateEncryptedSwap", NULL);
daemon->priv->conf_run_powersave_command =
g_key_file_get_boolean (file, "UPower", "RunPowersaveCommand", NULL);
#endif
/* FIXME: Do something? */
} else {
g_warning ("failed to load config file %s: %s", filename, error->message);
g_error_free (error);
@ -1192,12 +666,6 @@ up_daemon_init (UpDaemon *daemon)
g_signal_connect (daemon->priv->backend, "device-removed",
G_CALLBACK (up_daemon_device_removed_cb), daemon);
/* use a timer for the about-to-sleep logic */
#ifdef ENABLE_DEPRECATED
daemon->priv->about_to_sleep_timer = g_timer_new ();
g_timer_stop (daemon->priv->about_to_sleep_timer);
#endif
/* watch when these properties change */
g_signal_connect (daemon, "notify::lid-is-present",
G_CALLBACK (up_daemon_properties_changed_cb), daemon);
@ -1207,16 +675,6 @@ up_daemon_init (UpDaemon *daemon)
G_CALLBACK (up_daemon_properties_changed_cb), daemon);
g_signal_connect (daemon, "notify::on-low-battery",
G_CALLBACK (up_daemon_properties_changed_cb), daemon);
/* check if we have support */
#ifdef ENABLE_DEPRECATED
daemon->priv->kernel_can_suspend = up_backend_kernel_can_suspend (daemon->priv->backend);
daemon->priv->kernel_can_hibernate = up_backend_kernel_can_hibernate (daemon->priv->backend);
/* is the swap usable? */
if (daemon->priv->kernel_can_hibernate)
daemon->priv->hibernate_has_encrypted_swap = up_backend_has_encrypted_swap (daemon->priv->backend);
#endif
}
/**
@ -1266,23 +724,6 @@ up_daemon_get_property (GObject *object, guint prop_id, GValue *value, GParamSpe
case PROP_DAEMON_VERSION:
g_value_set_string (value, PACKAGE_VERSION);
break;
case PROP_CAN_SUSPEND:
#ifdef ENABLE_DEPRECATED
g_value_set_boolean (value, priv->kernel_can_suspend);
#else
g_value_set_boolean (value, FALSE);
#endif
break;
case PROP_CAN_HIBERNATE:
#ifdef ENABLE_DEPRECATED
g_value_set_boolean (value, (priv->kernel_can_hibernate &&
up_daemon_check_hibernate_swap (daemon) &&
(!priv->hibernate_has_encrypted_swap ||
priv->conf_allow_hibernate_encrypted_swap)));
#else
g_value_set_boolean (value, FALSE);
#endif
break;
case PROP_ON_BATTERY:
g_value_set_boolean (value, priv->on_battery);
break;
@ -1295,9 +736,6 @@ up_daemon_get_property (GObject *object, guint prop_id, GValue *value, GParamSpe
case PROP_LID_IS_PRESENT:
g_value_set_boolean (value, priv->lid_is_present);
break;
case PROP_LID_FORCE_SLEEP:
g_value_set_boolean (value, priv->lid_force_sleep);
break;
case PROP_IS_DOCKED:
g_value_set_boolean (value, priv->is_docked);
break;
@ -1351,38 +789,6 @@ up_daemon_class_init (UpDaemonClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
signals[SIGNAL_SLEEPING] =
g_signal_new ("sleeping",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
signals[SIGNAL_NOTIFY_SLEEP] =
g_signal_new ("notify-sleep",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
0, NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1, G_TYPE_STRING);
signals[SIGNAL_RESUMING] =
g_signal_new ("resuming",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
signals[SIGNAL_NOTIFY_RESUME] =
g_signal_new ("notify-resume",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
0, NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1, G_TYPE_STRING);
g_object_class_install_property (object_class,
PROP_DAEMON_VERSION,
g_param_spec_string ("daemon-version",
@ -1399,14 +805,6 @@ up_daemon_class_init (UpDaemonClass *klass)
FALSE,
G_PARAM_READABLE));
g_object_class_install_property (object_class,
PROP_LID_FORCE_SLEEP,
g_param_spec_boolean ("lid-force-sleep",
"Enforce sleep on lid close",
"If this computer has to sleep on lid close",
FALSE,
G_PARAM_READABLE));
g_object_class_install_property (object_class,
PROP_IS_DOCKED,
g_param_spec_boolean ("is-docked",
@ -1415,22 +813,6 @@ up_daemon_class_init (UpDaemonClass *klass)
FALSE,
G_PARAM_READABLE));
g_object_class_install_property (object_class,
PROP_CAN_SUSPEND,
g_param_spec_boolean ("can-suspend",
"Can Suspend",
"Whether the system can suspend",
FALSE,
G_PARAM_READABLE));
g_object_class_install_property (object_class,
PROP_CAN_HIBERNATE,
g_param_spec_boolean ("can-hibernate",
"Can Hibernate",
"Whether the system can hibernate",
FALSE,
G_PARAM_READABLE));
g_object_class_install_property (object_class,
PROP_ON_BATTERY,
g_param_spec_boolean ("on-battery",
@ -1480,9 +862,6 @@ up_daemon_finalize (GObject *object)
g_object_unref (priv->polkit);
g_object_unref (priv->config);
g_object_unref (priv->backend);
#ifdef ENABLE_DEPRECATED
g_timer_destroy (priv->about_to_sleep_timer);
#endif
G_OBJECT_CLASS (up_daemon_parent_class)->finalize (object);
}

View file

@ -77,8 +77,6 @@ void up_daemon_set_lid_is_closed (UpDaemon *daemon,
gboolean lid_is_closed);
void up_daemon_set_lid_is_present (UpDaemon *daemon,
gboolean lid_is_present);
void up_daemon_set_lid_force_sleep (UpDaemon *daemon,
gboolean lid_force_sleep);
void up_daemon_set_is_docked (UpDaemon *daemon,
gboolean is_docked);
void up_daemon_set_on_battery (UpDaemon *daemon,
@ -93,23 +91,6 @@ gboolean up_daemon_get_on_battery (UpDaemon *daemon,
DBusGMethodInvocation *context);
gboolean up_daemon_get_low_battery (UpDaemon *daemon,
DBusGMethodInvocation *context);
gboolean up_daemon_suspend (UpDaemon *daemon,
DBusGMethodInvocation *context);
gboolean up_daemon_about_to_sleep (UpDaemon *daemon,
const gchar *sleep_kind,
DBusGMethodInvocation *context);
gboolean up_daemon_suspend_allowed (UpDaemon *daemon,
DBusGMethodInvocation *context);
gboolean up_daemon_hibernate (UpDaemon *daemon,
DBusGMethodInvocation *context);
gboolean up_daemon_hibernate_allowed (UpDaemon *daemon,
DBusGMethodInvocation *context);
gboolean up_daemon_can_suspend (UpDaemon *daemon,
gboolean interactive,
DBusGMethodInvocation *context);
gboolean up_daemon_can_hibernate (UpDaemon *daemon,
gboolean interactive,
DBusGMethodInvocation *context);
G_END_DECLS