From 450f3ef6655b2a3e2db590f3c1ef47c29299cec3 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Wed, 4 Feb 2015 19:22:17 +0100 Subject: [PATCH] all: Remove Lid handling It is now handled solely in logind to take power management decisions, and in the compositor for making decisions related to available displays. --- libupower-glib/up-client.c | 70 ---------- libupower-glib/up-client.h | 2 - src/freebsd/up-backend.c | 33 ----- src/linux/Makefile.am | 2 - src/linux/integration-test | 2 - src/linux/up-backend.c | 23 +--- src/linux/up-input.c | 318 --------------------------------------------- src/linux/up-input.h | 59 --------- src/openbsd/up-backend.c | 67 ---------- src/up-daemon.c | 68 ---------- src/up-daemon.h | 4 - tools/up-tool.c | 6 - 12 files changed, 2 insertions(+), 652 deletions(-) delete mode 100644 src/linux/up-input.c delete mode 100644 src/linux/up-input.h diff --git a/libupower-glib/up-client.c b/libupower-glib/up-client.c index 48d99a0..dadea46 100644 --- a/libupower-glib/up-client.c +++ b/libupower-glib/up-client.c @@ -65,8 +65,6 @@ enum { PROP_0, PROP_DAEMON_VERSION, PROP_ON_BATTERY, - PROP_LID_IS_CLOSED, - PROP_LID_IS_PRESENT, PROP_LAST }; @@ -192,40 +190,6 @@ up_client_get_daemon_version (UpClient *client) } /** - * up_client_get_lid_is_closed: - * @client: a #UpClient instance. - * - * Get whether the laptop lid is closed. - * - * Return value: %TRUE if lid is closed or %FALSE otherwise. - * - * Since: 0.9.0 - */ -gboolean -up_client_get_lid_is_closed (UpClient *client) -{ - g_return_val_if_fail (UP_IS_CLIENT (client), FALSE); - return up_client_glue_get_lid_is_closed (client->priv->proxy); -} - -/** - * up_client_get_lid_is_present: - * @client: a #UpClient instance. - * - * Get whether a laptop lid is present on this machine. - * - * Return value: %TRUE if the machine has a laptop lid - * - * Since: 0.9.2 - */ -gboolean -up_client_get_lid_is_present (UpClient *client) -{ - g_return_val_if_fail (UP_IS_CLIENT (client), FALSE); - return up_client_glue_get_lid_is_present (client->priv->proxy); -} - -/** * up_client_get_on_battery: * @client: a #UpClient instance. * @@ -314,12 +278,6 @@ up_client_get_property (GObject *object, case PROP_ON_BATTERY: g_value_set_boolean (value, up_client_glue_get_on_battery (client->priv->proxy)); break; - case PROP_LID_IS_CLOSED: - g_value_set_boolean (value, up_client_glue_get_lid_is_closed (client->priv->proxy)); - break; - case PROP_LID_IS_PRESENT: - g_value_set_boolean (value, up_client_glue_get_lid_is_present (client->priv->proxy)); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -366,34 +324,6 @@ up_client_class_init (UpClientClass *klass) NULL, FALSE, G_PARAM_READABLE)); - /** - * UpClient:lid-is-closed: - * - * If the laptop lid is closed. - * - * Since: 0.9.0 - */ - g_object_class_install_property (object_class, - PROP_LID_IS_CLOSED, - g_param_spec_boolean ("lid-is-closed", - "If the laptop lid is closed", - NULL, - FALSE, - G_PARAM_READABLE)); - /** - * UpClient:lid-is-present: - * - * If a laptop lid is present. - * - * Since: 0.9.0 - */ - g_object_class_install_property (object_class, - PROP_LID_IS_PRESENT, - g_param_spec_boolean ("lid-is-present", - "If a laptop lid is present", - NULL, - FALSE, - G_PARAM_READABLE)); /** * UpClient::device-added: diff --git a/libupower-glib/up-client.h b/libupower-glib/up-client.h index 79c2d9e..8abbda7 100644 --- a/libupower-glib/up-client.h +++ b/libupower-glib/up-client.h @@ -80,8 +80,6 @@ char * up_client_get_critical_action (UpClient *client); /* accessors */ GPtrArray *up_client_get_devices (UpClient *client); const gchar *up_client_get_daemon_version (UpClient *client); -gboolean up_client_get_lid_is_closed (UpClient *client); -gboolean up_client_get_lid_is_present (UpClient *client); gboolean up_client_get_on_battery (UpClient *client); G_END_DECLS diff --git a/src/freebsd/up-backend.c b/src/freebsd/up-backend.c index 9fcd2b1..818d3f1 100644 --- a/src/freebsd/up-backend.c +++ b/src/freebsd/up-backend.c @@ -52,7 +52,6 @@ static void up_backend_finalize (GObject *object); 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); #define UP_BACKEND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_BACKEND, UpBackendPrivate)) @@ -139,21 +138,6 @@ up_backend_acpi_devd_notify (UpBackend *backend, const gchar *system, const gcha } } } - } else if (!strcmp (subsystem, "Lid")) { - gboolean is_present; - gboolean is_closed; - - g_object_get (backend->priv->daemon, - "lid-is-present", &is_present, NULL); - if (!is_present) { - g_warning ("received lid event without a configured lid; cold-plugging one"); - up_backend_lid_coldplug (backend); - /* FALLTHROUGH */ - } - - is_closed = (data != NULL && !strcmp (data, "notify=0x00")) ? TRUE : FALSE; - up_daemon_set_lid_is_closed (backend->priv->daemon, is_closed); - goto out; } if (native == NULL) @@ -216,21 +200,6 @@ up_backend_create_new_device (UpBackend *backend, UpAcpiNative *native) } /** - * up_backend_lid_coldplug: - **/ -static void -up_backend_lid_coldplug (UpBackend *backend) -{ - gchar *lid_state; - - lid_state = up_get_string_sysctl (NULL, "hw.acpi.lid_switch_state"); - if (lid_state && strcmp (lid_state, "NONE")) { - up_daemon_set_lid_is_present (backend->priv->daemon, TRUE); - } - g_free (lid_state); -} - -/** * up_backend_coldplug: * @backend: The %UpBackend class instance * @daemon: The %UpDaemon controlling instance @@ -276,8 +245,6 @@ up_backend_coldplug (UpBackend *backend, UpDaemon *daemon) } } - up_backend_lid_coldplug (backend); - acnative = up_acpi_native_new ("hw.acpi.acline"); up_backend_create_new_device (backend, acnative); g_object_unref (acnative); diff --git a/src/linux/Makefile.am b/src/linux/Makefile.am index 4876a57..8508eca 100644 --- a/src/linux/Makefile.am +++ b/src/linux/Makefile.am @@ -36,8 +36,6 @@ libupshared_la_SOURCES = \ up-device-hid.h \ up-device-wup.c \ up-device-wup.h \ - up-input.c \ - up-input.h \ up-backend.c \ up-native.c \ hidpp-device.c \ diff --git a/src/linux/integration-test b/src/linux/integration-test index 4e5f13e..4e0c09c 100755 --- a/src/linux/integration-test +++ b/src/linux/integration-test @@ -812,8 +812,6 @@ class Tests(unittest.TestCase): self.start_daemon() client = UPowerGlib.Client.new() self.assertRegex(client.get_daemon_version(), '^[0-9.]+$') - self.assertIn(client.get_lid_is_present(), [False, True]) - self.assertIn(client.get_lid_is_closed(), [False, True]) self.assertEqual(client.get_on_battery(), False) # FIXME: When we have a fake logind # self.assertEqual(client.get_critical_action(), 'PowerOff') diff --git a/src/linux/up-backend.c b/src/linux/up-backend.c index b7a129d..d69dc9a 100644 --- a/src/linux/up-backend.c +++ b/src/linux/up-backend.c @@ -39,7 +39,6 @@ #include "up-device-unifying.h" #include "up-device-wup.h" #include "up-device-hid.h" -#include "up-input.h" #include "up-config.h" #ifdef HAVE_IDEVICE #include "up-device-idevice.h" @@ -91,7 +90,6 @@ up_backend_device_new (UpBackend *backend, GUdevDevice *native) const gchar *subsys; const gchar *native_path; UpDevice *device = NULL; - UpInput *input; gboolean ret; subsys = g_udev_device_get_subsystem (native); @@ -158,23 +156,6 @@ up_backend_device_new (UpBackend *backend, GUdevDevice *native) /* no valid USB object */ device = NULL; - - } else if (g_strcmp0 (subsys, "input") == 0) { - - /* check input device */ - input = up_input_new (); - ret = up_input_coldplug (input, backend->priv->daemon, native); - if (ret) { - /* we now have a lid */ - up_daemon_set_lid_is_present (backend->priv->daemon, TRUE); - - /* not a power device */ - up_device_list_insert (backend->priv->managed_devices, G_OBJECT (native), G_OBJECT (input)); - - /* no valid input object */ - device = NULL; - } - g_object_unref (input); } else { native_path = g_udev_device_get_sysfs_path (native); g_warning ("native path %s (%s) ignoring", native_path, subsys); @@ -314,8 +295,8 @@ up_backend_coldplug (UpBackend *backend, UpDaemon *daemon) GList *devices; GList *l; guint i; - const gchar *subsystems_wup[] = {"power_supply", "usb", "usbmisc", "tty", "input", "hid", NULL}; - const gchar *subsystems[] = {"power_supply", "usb", "usbmisc", "input", "hid", NULL}; + const gchar *subsystems_wup[] = {"power_supply", "usb", "usbmisc", "tty", "hid", NULL}; + const gchar *subsystems[] = {"power_supply", "usb", "usbmisc", "hid", NULL}; backend->priv->daemon = g_object_ref (daemon); backend->priv->device_list = up_daemon_get_device_list (daemon); diff --git a/src/linux/up-input.c b/src/linux/up-input.c deleted file mode 100644 index e5accea..0000000 --- a/src/linux/up-input.c +++ /dev/null @@ -1,318 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2009 Richard Hughes - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "sysfs-utils.h" -#include "up-types.h" -#include "up-daemon.h" -#include "up-input.h" -#include "up-daemon.h" - -struct UpInputPrivate -{ - int eventfp; - struct input_event event; - gsize offset; - GIOChannel *channel; - UpDaemon *daemon; -}; - -G_DEFINE_TYPE (UpInput, up_input, G_TYPE_OBJECT) -#define UP_INPUT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_INPUT, UpInputPrivate)) - -/* we must use this kernel-compatible implementation */ -#define BITS_PER_LONG (sizeof(long) * 8) -#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1) -#define OFF(x) ((x)%BITS_PER_LONG) -#define BIT(x) (1UL<> OFF(bit)) & 1) - -/** - * up_input_str_to_bitmask: - **/ -static gint -up_input_str_to_bitmask (const gchar *s, glong *bitmask, size_t max_size) -{ - gint i, j; - gchar **v; - gint num_bits_set = 0; - - memset (bitmask, 0, max_size); - v = g_strsplit (s, " ", max_size); - for (i = g_strv_length (v) - 1, j = 0; i >= 0; i--, j++) { - gulong val; - - val = strtoul (v[i], NULL, 16); - bitmask[j] = val; - - while (val != 0) { - num_bits_set++; - val &= (val - 1); - } - } - g_strfreev(v); - - return num_bits_set; -} - -/** - * up_input_event_io: - **/ -static gboolean -up_input_event_io (GIOChannel *channel, GIOCondition condition, gpointer data) -{ - UpInput *input = (UpInput*) data; - GError *error = NULL; - gsize read_bytes; - glong bitmask[NBITS(SW_MAX)]; - gboolean ret; - - /* uninteresting */ - if (condition & (G_IO_HUP | G_IO_ERR | G_IO_NVAL)) - return FALSE; - - /* read event */ - while (g_io_channel_read_chars (channel, - ((gchar*)&input->priv->event) + input->priv->offset, - sizeof(struct input_event) - input->priv->offset, - &read_bytes, &error) == G_IO_STATUS_NORMAL) { - - /* not enough data */ - if (input->priv->offset + read_bytes < sizeof (struct input_event)) { - input->priv->offset = input->priv->offset + read_bytes; - g_debug ("incomplete read"); - goto out; - } - - /* we have all the data */ - input->priv->offset = 0; - - g_debug ("event.value=%d ; event.code=%d (0x%02x)", - input->priv->event.value, - input->priv->event.code, - input->priv->event.code); - - /* switch? */ - if (input->priv->event.type != EV_SW) { - g_debug ("not a switch event"); - continue; - } - - /* is not lid */ - if (input->priv->event.code != SW_LID) { - g_debug ("not a lid"); - continue; - } - - /* check switch state */ - if (ioctl (g_io_channel_unix_get_fd(channel), EVIOCGSW(sizeof (bitmask)), bitmask) < 0) { - g_debug ("ioctl EVIOCGSW failed"); - continue; - } - - /* are we set */ - ret = test_bit (input->priv->event.code, bitmask); - up_daemon_set_lid_is_closed (input->priv->daemon, ret); - } -out: - return TRUE; -} - -/** - * up_input_coldplug: - **/ -gboolean -up_input_coldplug (UpInput *input, UpDaemon *daemon, GUdevDevice *d) -{ - gboolean ret = FALSE; - gchar *path; - gchar *contents = NULL; - const gchar *native_path; - const gchar *device_file; - GError *error = NULL; - glong bitmask[NBITS(SW_MAX)]; - gint num_bits; - GIOStatus status; - - /* get sysfs path */ - native_path = g_udev_device_get_sysfs_path (d); - - /* is a switch */ - path = g_build_filename (native_path, "../capabilities/sw", NULL); - if (!g_file_test (path, G_FILE_TEST_EXISTS)) { - g_debug ("not a switch [%s]", path); - g_free (path); - path = g_build_filename (native_path, "capabilities/sw", NULL); - if (!g_file_test (path, G_FILE_TEST_EXISTS)) { - g_debug ("not a switch [%s]", path); - goto out; - } - } - - /* get caps */ - ret = g_file_get_contents (path, &contents, NULL, &error); - if (!ret) { - g_debug ("failed to get contents for [%s]: %s", path, error->message); - g_error_free (error); - goto out; - } - - /* convert to a bitmask */ - num_bits = up_input_str_to_bitmask (contents, bitmask, sizeof (bitmask)); - if ((num_bits == 0) || (num_bits >= SW_CNT)) { - g_debug ("invalid bitmask entry for %s", native_path); - ret = FALSE; - goto out; - } - - /* is this a lid? */ - if (!test_bit (SW_LID, bitmask)) { - g_debug ("not a lid: %s", native_path); - ret = FALSE; - goto out; - } - - /* get device file */ - device_file = g_udev_device_get_device_file (d); - if (device_file == NULL || device_file[0] == '\0') { - g_debug ("no device file: %s", native_path); - ret = FALSE; - goto out; - } - - /* open device file */ - input->priv->eventfp = open (device_file, O_RDONLY | O_NONBLOCK); - if (input->priv->eventfp <= 0) { - g_warning ("cannot open '%s': %s", device_file, strerror (errno)); - ret = FALSE; - goto out; - } - - /* get initial state */ - if (ioctl (input->priv->eventfp, EVIOCGSW(sizeof (bitmask)), bitmask) < 0) { - g_warning ("ioctl EVIOCGSW on %s failed", native_path); - ret = FALSE; - goto out; - } - - /* create channel */ - g_debug ("watching %s (%i)", device_file, input->priv->eventfp); - input->priv->channel = g_io_channel_unix_new (input->priv->eventfp); - - /* set binary encoding */ - status = g_io_channel_set_encoding (input->priv->channel, NULL, &error); - if (status != G_IO_STATUS_NORMAL) { - g_warning ("failed to set encoding: %s", error->message); - g_error_free (error); - ret = FALSE; - goto out; - } - - /* save daemon */ - input->priv->daemon = g_object_ref (daemon); - - /* watch this */ - g_io_add_watch (input->priv->channel, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL, up_input_event_io, input); - - /* set if we are closed */ - g_debug ("using %s for lid event", native_path); - up_daemon_set_lid_is_closed (input->priv->daemon, test_bit (SW_LID, bitmask)); -out: - g_free (path); - g_free (contents); - return ret; -} - -/** - * up_input_init: - **/ -static void -up_input_init (UpInput *input) -{ - input->priv = UP_INPUT_GET_PRIVATE (input); - input->priv->eventfp = -1; -} - -/** - * up_input_finalize: - **/ -static void -up_input_finalize (GObject *object) -{ - UpInput *input; - - g_return_if_fail (object != NULL); - g_return_if_fail (UP_IS_INPUT (object)); - - input = UP_INPUT (object); - g_return_if_fail (input->priv != NULL); - - if (input->priv->daemon != NULL) - g_object_unref (input->priv->daemon); - if (input->priv->eventfp >= 0) - close (input->priv->eventfp); - if (input->priv->channel) { - g_io_channel_shutdown (input->priv->channel, FALSE, NULL); - g_io_channel_unref (input->priv->channel); - } - G_OBJECT_CLASS (up_input_parent_class)->finalize (object); -} - -/** - * up_input_class_init: - **/ -static void -up_input_class_init (UpInputClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - object_class->finalize = up_input_finalize; - g_type_class_add_private (klass, sizeof (UpInputPrivate)); -} - -/** - * up_input_new: - **/ -UpInput * -up_input_new (void) -{ - return g_object_new (UP_TYPE_INPUT, NULL); -} - diff --git a/src/linux/up-input.h b/src/linux/up-input.h deleted file mode 100644 index c42808b..0000000 --- a/src/linux/up-input.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2009 Richard Hughes - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef __UP_INPUT_H__ -#define __UP_INPUT_H__ - -#include - -#include "up-daemon.h" - -G_BEGIN_DECLS - -#define UP_TYPE_INPUT (up_input_get_type ()) -#define UP_INPUT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), UP_TYPE_INPUT, UpInput)) -#define UP_INPUT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), UP_TYPE_INPUT, UpInputClass)) -#define UP_IS_INPUT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), UP_TYPE_INPUT)) -#define UP_IS_INPUT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), UP_TYPE_INPUT)) -#define UP_INPUT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), UP_TYPE_INPUT, UpInputClass)) - -typedef struct UpInputPrivate UpInputPrivate; - -typedef struct -{ - GObject parent; - UpInputPrivate *priv; -} UpInput; - -typedef struct -{ - GObjectClass parent_class; -} UpInputClass; - -GType up_input_get_type (void); -UpInput *up_input_new (void); -gboolean up_input_coldplug (UpInput *input, - UpDaemon *daemon, - GUdevDevice *d); - -G_END_DECLS - -#endif /* __UP_INPUT_H__ */ - diff --git a/src/openbsd/up-backend.c b/src/openbsd/up-backend.c index 20e86c0..906d520 100644 --- a/src/openbsd/up-backend.c +++ b/src/openbsd/up-backend.c @@ -34,7 +34,6 @@ static void up_backend_finalize (GObject *object); static gboolean up_backend_apm_get_power_info(struct apm_power_info*); UpDeviceState up_backend_apm_get_battery_state_value(u_char battery_state); static void up_backend_update_acpibat_state(UpDevice*, struct sensordev); -static void up_backend_update_lid_status(UpDaemon*); static gboolean up_apm_device_get_on_battery (UpDevice *device, gboolean *on_battery); static gboolean up_apm_device_get_online (UpDevice *device, gboolean *online); @@ -132,7 +131,6 @@ up_backend_coldplug (UpBackend *backend, UpDaemon *daemon) if (backend->priv->is_laptop) { - up_backend_update_lid_status(daemon); acnative = up_apm_native_new("/ac"); if (!up_device_coldplug (backend->priv->ac, backend->priv->daemon, G_OBJECT(acnative))) g_warning ("failed to coldplug ac"); @@ -232,7 +230,6 @@ up_backend_update_ac_state(UpDevice* device) gboolean ret, new_is_online, cur_is_online; struct apm_power_info a; - up_backend_update_lid_status(up_device_get_daemon(device)); ret = up_backend_apm_get_power_info(&a); if (!ret) return ret; @@ -436,70 +433,6 @@ up_apm_device_refresh(UpDevice* device) return ret; } -/* - * Check the lid status, return TRUE if one was found, FALSE otherwise. - */ -static void -up_backend_update_lid_status(UpDaemon *daemon) { - - /* Use hw.sensors.acpibtn0.indicator0=On (lid open) */ - struct sensordev sensordev; - struct sensor sensor; - size_t sdlen, slen; - int dev, numt, mib[5] = {CTL_HW, HW_SENSORS, 0, 0, 0}; - gboolean lid_found = FALSE; - gboolean lid_open = FALSE; - - sdlen = sizeof(struct sensordev); - slen = sizeof(struct sensor); - - /* go through all acpibtn devices, and check if one of the values match "lid" - if so, use that device. - */ - for (dev = 0; SENSOR_MAX_TYPES; dev++) { - mib[2] = dev; - if (sysctl(mib, 3, &sensordev, &sdlen, NULL, 0) == -1) { - if (errno == ENXIO) - continue; - if (errno == ENOENT) - break; - } - - if (strstr(sensordev.xname, "acpibtn") != NULL) { - mib[3] = SENSOR_INDICATOR; - for (numt = 0; numt < sensordev.maxnumt[SENSOR_INDICATOR]; numt++) { - mib[4] = numt; - if (sysctl(mib, 5, &sensor, &slen, NULL, 0) == -1) { - if (errno != ENOENT) { - g_warning("failed to get sensor data from %s", - sensordev.xname); - continue; - } - } - - /* - * Found an acpibtn device, now check if the - * description has got anything with a lid in it. - */ - if (strstr(sensor.desc, "lid open") == NULL) { - g_warning ("nothing here for %s with %s\n", - sensordev.xname, sensor.desc); - continue; - } else { - lid_found = TRUE; - if (sensor.value) - lid_open = TRUE; - else - lid_open = FALSE; - } - } - } - } - - up_daemon_set_lid_is_present (daemon, lid_found); - up_daemon_set_lid_is_closed (daemon, !lid_open); -} - /* thread doing kqueue() on apm device */ static gpointer up_backend_apm_event_thread(gpointer object) diff --git a/src/up-daemon.c b/src/up-daemon.c index a4ff3e1..8bee5d4 100644 --- a/src/up-daemon.c +++ b/src/up-daemon.c @@ -46,8 +46,6 @@ enum PROP_0, PROP_DAEMON_VERSION, PROP_ON_BATTERY, - PROP_LID_IS_CLOSED, - PROP_LID_IS_PRESENT, PROP_LAST }; @@ -74,8 +72,6 @@ struct UpDaemonPrivate /* Properties */ gboolean on_battery; UpDeviceLevel warning_level; - gboolean lid_is_closed; - gboolean lid_is_present; /* PropertiesChanged to be emitted */ GHashTable *changed_props; @@ -700,48 +696,6 @@ up_daemon_queue_changed_property (UpDaemon *daemon, } /** - * up_daemon_set_lid_is_closed: - **/ -void -up_daemon_set_lid_is_closed (UpDaemon *daemon, gboolean lid_is_closed) -{ - UpDaemonPrivate *priv = daemon->priv; - - /* check if we are ignoring the lid */ - if (up_config_get_boolean (priv->config, "IgnoreLid")) { - g_debug ("ignoring lid state"); - return; - } - - g_debug ("lid_is_closed = %s", lid_is_closed ? "yes" : "no"); - priv->lid_is_closed = lid_is_closed; - g_object_notify (G_OBJECT (daemon), "lid-is-closed"); - - up_daemon_queue_changed_property (daemon, "LidIsClosed", g_variant_new_boolean (lid_is_closed)); -} - -/** - * up_daemon_set_lid_is_present: - **/ -void -up_daemon_set_lid_is_present (UpDaemon *daemon, gboolean lid_is_present) -{ - UpDaemonPrivate *priv = daemon->priv; - - /* check if we are ignoring the lid */ - if (up_config_get_boolean (priv->config, "IgnoreLid")) { - g_debug ("ignoring lid state"); - return; - } - - g_debug ("lid_is_present = %s", lid_is_present ? "yes" : "no"); - priv->lid_is_present = lid_is_present; - g_object_notify (G_OBJECT (daemon), "lid-is-present"); - - up_daemon_queue_changed_property (daemon, "LidIsPresent", g_variant_new_boolean (lid_is_present)); -} - -/** * up_daemon_set_on_battery: **/ void @@ -1228,12 +1182,6 @@ up_daemon_get_property (GObject *object, guint prop_id, GValue *value, GParamSpe case PROP_ON_BATTERY: g_value_set_boolean (value, priv->on_battery); break; - case PROP_LID_IS_CLOSED: - g_value_set_boolean (value, priv->lid_is_closed); - break; - case PROP_LID_IS_PRESENT: - g_value_set_boolean (value, priv->lid_is_present); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1277,14 +1225,6 @@ up_daemon_class_init (UpDaemonClass *klass) G_PARAM_READABLE)); g_object_class_install_property (object_class, - PROP_LID_IS_PRESENT, - g_param_spec_boolean ("lid-is-present", - "Is a laptop", - "If this computer is probably a laptop", - FALSE, - G_PARAM_READABLE)); - - g_object_class_install_property (object_class, PROP_ON_BATTERY, g_param_spec_boolean ("on-battery", "On Battery", @@ -1292,14 +1232,6 @@ up_daemon_class_init (UpDaemonClass *klass) FALSE, G_PARAM_READABLE)); - g_object_class_install_property (object_class, - PROP_LID_IS_CLOSED, - g_param_spec_boolean ("lid-is-closed", - "Laptop lid is closed", - "If the laptop lid is closed", - FALSE, - G_PARAM_READABLE)); - dbus_g_object_type_install_info (UP_TYPE_DAEMON, &dbus_glib_up_daemon_object_info); dbus_g_error_domain_register (UP_DAEMON_ERROR, NULL, UP_DAEMON_TYPE_ERROR); diff --git a/src/up-daemon.h b/src/up-daemon.h index 87857b3..4f573a5 100644 --- a/src/up-daemon.h +++ b/src/up-daemon.h @@ -73,10 +73,6 @@ guint up_daemon_get_number_devices_of_type (UpDaemon *daemon, UpDeviceList *up_daemon_get_device_list (UpDaemon *daemon); gboolean up_daemon_startup (UpDaemon *daemon); void up_daemon_shutdown (UpDaemon *daemon); -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_on_battery (UpDaemon *daemon, gboolean on_battery); void up_daemon_set_warning_level (UpDaemon *daemon, diff --git a/tools/up-tool.c b/tools/up-tool.c index a2a35b0..006abce 100644 --- a/tools/up-tool.c +++ b/tools/up-tool.c @@ -121,21 +121,15 @@ up_client_print (UpClient *client) gchar *daemon_version; gboolean on_battery; UpDeviceLevel warning_level; - gboolean lid_is_closed; - gboolean lid_is_present; char *action; g_object_get (client, "daemon-version", &daemon_version, "on-battery", &on_battery, - "lid-is-closed", &lid_is_closed, - "lid-is-present", &lid_is_present, NULL); g_print (" daemon-version: %s\n", daemon_version); g_print (" on-battery: %s\n", on_battery ? "yes" : "no"); - g_print (" lid-is-closed: %s\n", lid_is_closed ? "yes" : "no"); - g_print (" lid-is-present: %s\n", lid_is_present ? "yes" : "no"); action = up_client_get_critical_action (client); g_print (" critical-action: %s\n", action); g_free (action); -- 2.1.0