mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2025-12-20 09:00:03 +01:00
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. See: https://www.freedesktop.org/software/systemd/man/org.freedesktop.login1.html
This commit is contained in:
parent
8dcf54440d
commit
07565ef6a1
13 changed files with 0 additions and 764 deletions
|
|
@ -179,26 +179,6 @@ method return sender=:1.386 -> dest=:1.451 reply_serial=2
|
||||||
</doc:para></doc:description></doc:doc>
|
</doc:para></doc:description></doc:doc>
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
<property name="LidIsClosed" type="b" access="read">
|
|
||||||
<doc:doc>
|
|
||||||
<doc:description>
|
|
||||||
<doc:para>
|
|
||||||
Indicates if the laptop lid is closed where the display cannot be seen.
|
|
||||||
</doc:para>
|
|
||||||
</doc:description>
|
|
||||||
</doc:doc>
|
|
||||||
</property>
|
|
||||||
|
|
||||||
<property name="LidIsPresent" type="b" access="read">
|
|
||||||
<doc:doc>
|
|
||||||
<doc:description>
|
|
||||||
<doc:para>
|
|
||||||
If the system has a lid device.
|
|
||||||
</doc:para>
|
|
||||||
</doc:description>
|
|
||||||
</doc:doc>
|
|
||||||
</property>
|
|
||||||
|
|
||||||
</interface>
|
</interface>
|
||||||
|
|
||||||
</node>
|
</node>
|
||||||
|
|
|
||||||
|
|
@ -63,8 +63,6 @@ enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_DAEMON_VERSION,
|
PROP_DAEMON_VERSION,
|
||||||
PROP_ON_BATTERY,
|
PROP_ON_BATTERY,
|
||||||
PROP_LID_IS_CLOSED,
|
|
||||||
PROP_LID_IS_PRESENT,
|
|
||||||
PROP_LAST
|
PROP_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -287,40 +285,6 @@ up_client_get_daemon_version (UpClient *client)
|
||||||
return up_exported_daemon_get_daemon_version (client->priv->proxy);
|
return up_exported_daemon_get_daemon_version (client->priv->proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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_exported_daemon_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_exported_daemon_get_lid_is_present (client->priv->proxy);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* up_client_get_on_battery:
|
* up_client_get_on_battery:
|
||||||
* @client: a #UpClient instance.
|
* @client: a #UpClient instance.
|
||||||
|
|
@ -414,12 +378,6 @@ up_client_get_property (GObject *object,
|
||||||
case PROP_ON_BATTERY:
|
case PROP_ON_BATTERY:
|
||||||
g_value_set_boolean (value, up_exported_daemon_get_on_battery (client->priv->proxy));
|
g_value_set_boolean (value, up_exported_daemon_get_on_battery (client->priv->proxy));
|
||||||
break;
|
break;
|
||||||
case PROP_LID_IS_CLOSED:
|
|
||||||
g_value_set_boolean (value, up_exported_daemon_get_lid_is_closed (client->priv->proxy));
|
|
||||||
break;
|
|
||||||
case PROP_LID_IS_PRESENT:
|
|
||||||
g_value_set_boolean (value, up_exported_daemon_get_lid_is_present (client->priv->proxy));
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
|
@ -466,34 +424,6 @@ up_client_class_init (UpClientClass *klass)
|
||||||
NULL,
|
NULL,
|
||||||
FALSE,
|
FALSE,
|
||||||
G_PARAM_READABLE));
|
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 | G_PARAM_DEPRECATED));
|
|
||||||
/**
|
|
||||||
* 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 | G_PARAM_DEPRECATED));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UpClient::device-added:
|
* UpClient::device-added:
|
||||||
|
|
|
||||||
|
|
@ -94,10 +94,6 @@ GPtrArray *up_client_get_devices_finish (UpClient *client,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error);
|
GError **error);
|
||||||
const gchar *up_client_get_daemon_version (UpClient *client);
|
const gchar *up_client_get_daemon_version (UpClient *client);
|
||||||
G_DEPRECATED
|
|
||||||
gboolean up_client_get_lid_is_closed (UpClient *client);
|
|
||||||
G_DEPRECATED
|
|
||||||
gboolean up_client_get_lid_is_present (UpClient *client);
|
|
||||||
gboolean up_client_get_on_battery (UpClient *client);
|
gboolean up_client_get_on_battery (UpClient *client);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,6 @@ static void up_backend_finalize (GObject *object);
|
||||||
|
|
||||||
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_acpi_devd_notify (UpBackend *backend, const gchar *system, const gchar *subsystem, const gchar *type, const gchar *data);
|
||||||
static void up_backend_create_new_device (UpBackend *backend, UpAcpiNative *native);
|
static void up_backend_create_new_device (UpBackend *backend, UpAcpiNative *native);
|
||||||
static void up_backend_lid_coldplug (UpBackend *backend);
|
|
||||||
|
|
||||||
struct UpBackendPrivate
|
struct UpBackendPrivate
|
||||||
{
|
{
|
||||||
|
|
@ -112,21 +111,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)
|
if (native == NULL)
|
||||||
|
|
@ -186,21 +170,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) {
|
|
||||||
up_daemon_set_lid_is_present (backend->priv->daemon, TRUE);
|
|
||||||
}
|
|
||||||
g_free (lid_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* up_backend_coldplug:
|
* up_backend_coldplug:
|
||||||
* @backend: The %UpBackend class instance
|
* @backend: The %UpBackend class instance
|
||||||
|
|
@ -247,8 +216,6 @@ up_backend_coldplug (UpBackend *backend, UpDaemon *daemon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
up_backend_lid_coldplug (backend);
|
|
||||||
|
|
||||||
acnative = up_acpi_native_new ("hw.acpi.acline");
|
acnative = up_acpi_native_new ("hw.acpi.acline");
|
||||||
up_backend_create_new_device (backend, acnative);
|
up_backend_create_new_device (backend, acnative);
|
||||||
g_object_unref (acnative);
|
g_object_unref (acnative);
|
||||||
|
|
|
||||||
|
|
@ -2656,8 +2656,6 @@ class Tests(dbusmock.DBusTestCase):
|
||||||
self.start_daemon()
|
self.start_daemon()
|
||||||
client = UPowerGlib.Client.new()
|
client = UPowerGlib.Client.new()
|
||||||
self.assertRegex(client.get_daemon_version(), '^[0-9.]+$')
|
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)
|
self.assertEqual(client.get_on_battery(), False)
|
||||||
self.assertEqual(client.get_critical_action(), 'HybridSleep')
|
self.assertEqual(client.get_critical_action(), 'HybridSleep')
|
||||||
self.stop_daemon()
|
self.stop_daemon()
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,6 @@ upshared += { 'linux': static_library('upshared',
|
||||||
'up-device-wup.h',
|
'up-device-wup.h',
|
||||||
'up-device-bluez.c',
|
'up-device-bluez.c',
|
||||||
'up-device-bluez.h',
|
'up-device-bluez.h',
|
||||||
'up-input.c',
|
|
||||||
'up-input.h',
|
|
||||||
'up-backend.c',
|
'up-backend.c',
|
||||||
'up-native.c',
|
'up-native.c',
|
||||||
'up-enumerator-udev.c',
|
'up-enumerator-udev.c',
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@
|
||||||
#include "up-device-wup.h"
|
#include "up-device-wup.h"
|
||||||
#include "up-device-hid.h"
|
#include "up-device-hid.h"
|
||||||
#include "up-device-bluez.h"
|
#include "up-device-bluez.h"
|
||||||
#include "up-input.h"
|
|
||||||
#include "up-config.h"
|
#include "up-config.h"
|
||||||
#ifdef HAVE_IDEVICE
|
#ifdef HAVE_IDEVICE
|
||||||
#include "up-device-idevice.h"
|
#include "up-device-idevice.h"
|
||||||
|
|
@ -59,7 +58,6 @@ struct UpBackendPrivate
|
||||||
UpDaemon *daemon;
|
UpDaemon *daemon;
|
||||||
UpDeviceList *device_list;
|
UpDeviceList *device_list;
|
||||||
GUdevClient *gudev_client;
|
GUdevClient *gudev_client;
|
||||||
UpInput *lid_device;
|
|
||||||
UpConfig *config;
|
UpConfig *config;
|
||||||
GDBusProxy *logind_proxy;
|
GDBusProxy *logind_proxy;
|
||||||
guint logind_sleep_id;
|
guint logind_sleep_id;
|
||||||
|
|
@ -82,40 +80,6 @@ static guint signals [SIGNAL_LAST] = { 0 };
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (UpBackend, up_backend, G_TYPE_OBJECT)
|
G_DEFINE_TYPE_WITH_PRIVATE (UpBackend, up_backend, G_TYPE_OBJECT)
|
||||||
|
|
||||||
static void
|
|
||||||
input_switch_changed_cb (UpInput *input,
|
|
||||||
gboolean switch_value,
|
|
||||||
UpBackend *backend)
|
|
||||||
{
|
|
||||||
up_daemon_set_lid_is_closed (backend->priv->daemon, switch_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
up_backend_uevent_signal_handler_cb (GUdevClient *client, const gchar *action,
|
|
||||||
GUdevDevice *device, gpointer user_data)
|
|
||||||
{
|
|
||||||
UpBackend *backend = UP_BACKEND (user_data);
|
|
||||||
g_autoptr(UpInput) input = NULL;
|
|
||||||
|
|
||||||
if (backend->priv->lid_device)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (g_strcmp0 (action, "add") != 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* check if the input device is a lid */
|
|
||||||
input = up_input_new ();
|
|
||||||
if (up_input_coldplug (input, device)) {
|
|
||||||
up_daemon_set_lid_is_present (backend->priv->daemon, TRUE);
|
|
||||||
g_signal_connect (G_OBJECT (input), "switch-changed",
|
|
||||||
G_CALLBACK (input_switch_changed_cb), backend);
|
|
||||||
up_daemon_set_lid_is_closed (backend->priv->daemon,
|
|
||||||
up_input_get_switch_value (input));
|
|
||||||
|
|
||||||
backend->priv->lid_device = g_steal_pointer (&input);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static UpDevice *
|
static UpDevice *
|
||||||
find_duplicate_device (UpBackend *backend,
|
find_duplicate_device (UpBackend *backend,
|
||||||
UpDevice *device)
|
UpDevice *device)
|
||||||
|
|
@ -463,25 +427,9 @@ udev_device_removed_cb (UpBackend *backend, UpDevice *device)
|
||||||
gboolean
|
gboolean
|
||||||
up_backend_coldplug (UpBackend *backend, UpDaemon *daemon)
|
up_backend_coldplug (UpBackend *backend, UpDaemon *daemon)
|
||||||
{
|
{
|
||||||
g_autolist(GUdevDevice) devices = NULL;
|
|
||||||
GList *l;
|
|
||||||
|
|
||||||
backend->priv->daemon = g_object_ref (daemon);
|
backend->priv->daemon = g_object_ref (daemon);
|
||||||
backend->priv->device_list = up_daemon_get_device_list (daemon);
|
backend->priv->device_list = up_daemon_get_device_list (daemon);
|
||||||
|
|
||||||
/* Watch udev for input devices to find the lid switch */
|
|
||||||
backend->priv->gudev_client = g_udev_client_new ((const char *[]){ "input", NULL });
|
|
||||||
g_signal_connect (backend->priv->gudev_client, "uevent",
|
|
||||||
G_CALLBACK (up_backend_uevent_signal_handler_cb), backend);
|
|
||||||
|
|
||||||
/* add all subsystems */
|
|
||||||
devices = g_udev_client_query_by_subsystem (backend->priv->gudev_client, "input");
|
|
||||||
for (l = devices; l != NULL; l = l->next)
|
|
||||||
up_backend_uevent_signal_handler_cb (backend->priv->gudev_client,
|
|
||||||
"add",
|
|
||||||
G_UDEV_DEVICE (l->data),
|
|
||||||
backend);
|
|
||||||
|
|
||||||
backend->priv->bluez_watch_id = g_bus_watch_name (G_BUS_TYPE_SYSTEM,
|
backend->priv->bluez_watch_id = g_bus_watch_name (G_BUS_TYPE_SYSTEM,
|
||||||
"org.bluez",
|
"org.bluez",
|
||||||
G_BUS_NAME_WATCHER_FLAGS_NONE,
|
G_BUS_NAME_WATCHER_FLAGS_NONE,
|
||||||
|
|
@ -517,7 +465,6 @@ up_backend_unplug (UpBackend *backend)
|
||||||
g_clear_object (&backend->priv->gudev_client);
|
g_clear_object (&backend->priv->gudev_client);
|
||||||
g_clear_object (&backend->priv->udev_enum);
|
g_clear_object (&backend->priv->udev_enum);
|
||||||
g_clear_object (&backend->priv->device_list);
|
g_clear_object (&backend->priv->device_list);
|
||||||
g_clear_object (&backend->priv->lid_device);
|
|
||||||
g_clear_object (&backend->priv->daemon);
|
g_clear_object (&backend->priv->daemon);
|
||||||
if (backend->priv->bluez_watch_id > 0) {
|
if (backend->priv->bluez_watch_id > 0) {
|
||||||
g_bus_unwatch_name (backend->priv->bluez_watch_id);
|
g_bus_unwatch_name (backend->priv->bluez_watch_id);
|
||||||
|
|
@ -828,8 +775,6 @@ up_backend_finalize (GObject *object)
|
||||||
|
|
||||||
g_clear_object (&backend->priv->logind_proxy);
|
g_clear_object (&backend->priv->logind_proxy);
|
||||||
|
|
||||||
g_clear_object (&backend->priv->lid_device);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (up_backend_parent_class)->finalize (object);
|
G_OBJECT_CLASS (up_backend_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,422 +0,0 @@
|
||||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
|
||||||
*
|
|
||||||
* Copyright (C) 2009 Richard Hughes <richard@hughsie.com>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <linux/input.h>
|
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
#include <glib/gstdio.h>
|
|
||||||
#include <glib-object.h>
|
|
||||||
|
|
||||||
#include "up-input.h"
|
|
||||||
|
|
||||||
struct _UpInput
|
|
||||||
{
|
|
||||||
GObject parent_instance;
|
|
||||||
|
|
||||||
guint watched_switch;
|
|
||||||
int last_switch_state;
|
|
||||||
struct input_event event;
|
|
||||||
gsize offset;
|
|
||||||
GIOChannel *channel;
|
|
||||||
};
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (UpInput, up_input, G_TYPE_OBJECT)
|
|
||||||
|
|
||||||
enum {
|
|
||||||
PROP_0,
|
|
||||||
PROP_WATCHED_SWITCH
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
SWITCH_CHANGED,
|
|
||||||
LAST_SIGNAL
|
|
||||||
};
|
|
||||||
|
|
||||||
static guint signals[LAST_SIGNAL] = { 0 };
|
|
||||||
|
|
||||||
/* 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(x))
|
|
||||||
#define LONG(x) ((x)/BITS_PER_LONG)
|
|
||||||
#define test_bit(bit, array) ((array[LONG(bit)] >> OFF(bit)) & 1)
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* up_input_get_device_sysfs_path:
|
|
||||||
**/
|
|
||||||
static char *
|
|
||||||
up_input_get_device_sysfs_path (GUdevDevice *device)
|
|
||||||
{
|
|
||||||
const char *root;
|
|
||||||
|
|
||||||
g_return_val_if_fail (G_UDEV_IS_DEVICE (device), FALSE);
|
|
||||||
|
|
||||||
root = g_getenv ("UMOCKDEV_DIR");
|
|
||||||
if (!root || *root == '\0')
|
|
||||||
return g_strdup (g_udev_device_get_sysfs_path (device));
|
|
||||||
|
|
||||||
return g_build_filename (root,
|
|
||||||
g_udev_device_get_sysfs_path (device),
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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)];
|
|
||||||
|
|
||||||
/* 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->event) + input->offset,
|
|
||||||
sizeof(struct input_event) - input->offset,
|
|
||||||
&read_bytes, &error) == G_IO_STATUS_NORMAL) {
|
|
||||||
|
|
||||||
/* not enough data */
|
|
||||||
if (input->offset + read_bytes < sizeof (struct input_event)) {
|
|
||||||
input->offset = input->offset + read_bytes;
|
|
||||||
g_debug ("incomplete read");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* we have all the data */
|
|
||||||
input->offset = 0;
|
|
||||||
|
|
||||||
g_debug ("event.value=%d ; event.code=%d (0x%02x)",
|
|
||||||
input->event.value,
|
|
||||||
input->event.code,
|
|
||||||
input->event.code);
|
|
||||||
|
|
||||||
/* switch? */
|
|
||||||
if (input->event.type != EV_SW) {
|
|
||||||
g_debug ("not a switch event");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* is not the watched switch */
|
|
||||||
if (input->event.code != input->watched_switch) {
|
|
||||||
g_debug ("not the watched switch");
|
|
||||||
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 */
|
|
||||||
input->last_switch_state = test_bit (input->event.code, bitmask);
|
|
||||||
g_signal_emit_by_name (G_OBJECT (input),
|
|
||||||
"switch-changed",
|
|
||||||
input->last_switch_state);
|
|
||||||
}
|
|
||||||
out:
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* up_input_coldplug:
|
|
||||||
**/
|
|
||||||
gboolean
|
|
||||||
up_input_coldplug (UpInput *input, GUdevDevice *d)
|
|
||||||
{
|
|
||||||
gboolean ret = FALSE;
|
|
||||||
gchar *path;
|
|
||||||
gchar *contents = NULL;
|
|
||||||
gchar *native_path = NULL;
|
|
||||||
const gchar *device_file;
|
|
||||||
GError *error = NULL;
|
|
||||||
glong bitmask[NBITS(SW_MAX)];
|
|
||||||
gint num_bits;
|
|
||||||
GIOStatus status;
|
|
||||||
int eventfd;
|
|
||||||
|
|
||||||
/* get sysfs path */
|
|
||||||
native_path = up_input_get_device_sysfs_path (d);
|
|
||||||
|
|
||||||
/* is a switch */
|
|
||||||
path = g_build_filename (native_path, "../capabilities/sw", NULL);
|
|
||||||
if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
|
|
||||||
char *path2;
|
|
||||||
path2 = g_build_filename (native_path, "capabilities/sw", NULL);
|
|
||||||
if (!g_file_test (path2, G_FILE_TEST_EXISTS)) {
|
|
||||||
g_debug ("not a switch [%s]", path);
|
|
||||||
g_debug ("not a switch [%s]", path2);
|
|
||||||
g_free (path2);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
g_free (path);
|
|
||||||
path = path2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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 the watched switch? */
|
|
||||||
if (!test_bit (input->watched_switch, bitmask)) {
|
|
||||||
g_debug ("not the watched switch: %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 */
|
|
||||||
eventfd = open (device_file, O_RDONLY | O_NONBLOCK);
|
|
||||||
if (eventfd < 0) {
|
|
||||||
g_warning ("cannot open '%s': %s", device_file, strerror (errno));
|
|
||||||
ret = FALSE;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get initial state */
|
|
||||||
if (ioctl (eventfd, EVIOCGSW(sizeof (bitmask)), bitmask) < 0) {
|
|
||||||
g_warning ("ioctl EVIOCGSW on %s failed", native_path);
|
|
||||||
close(eventfd);
|
|
||||||
ret = FALSE;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* create channel */
|
|
||||||
g_debug ("watching %s (%i)", device_file, eventfd);
|
|
||||||
input->channel = g_io_channel_unix_new (eventfd);
|
|
||||||
g_io_channel_set_close_on_unref (input->channel, TRUE);
|
|
||||||
|
|
||||||
/* set binary encoding */
|
|
||||||
status = g_io_channel_set_encoding (input->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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* watch this */
|
|
||||||
g_io_add_watch (input->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 watched switch event", native_path);
|
|
||||||
input->last_switch_state = test_bit (input->watched_switch, bitmask);
|
|
||||||
|
|
||||||
out:
|
|
||||||
g_free (native_path);
|
|
||||||
g_free (path);
|
|
||||||
g_free (contents);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* up_input_init:
|
|
||||||
**/
|
|
||||||
static void
|
|
||||||
up_input_init (UpInput *input)
|
|
||||||
{
|
|
||||||
input->last_switch_state = -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);
|
|
||||||
|
|
||||||
if (input->channel) {
|
|
||||||
g_io_channel_shutdown (input->channel, FALSE, NULL);
|
|
||||||
g_io_channel_unref (input->channel);
|
|
||||||
}
|
|
||||||
G_OBJECT_CLASS (up_input_parent_class)->finalize (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
up_input_set_property (GObject *object,
|
|
||||||
guint property_id,
|
|
||||||
const GValue *value,
|
|
||||||
GParamSpec *pspec)
|
|
||||||
{
|
|
||||||
UpInput *input = UP_INPUT (object);
|
|
||||||
|
|
||||||
switch (property_id) {
|
|
||||||
case PROP_WATCHED_SWITCH:
|
|
||||||
input->watched_switch = g_value_get_uint (value);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
up_input_get_property (GObject *object,
|
|
||||||
guint property_id,
|
|
||||||
GValue *value,
|
|
||||||
GParamSpec *pspec)
|
|
||||||
{
|
|
||||||
UpInput *input = UP_INPUT (object);
|
|
||||||
|
|
||||||
switch (property_id) {
|
|
||||||
case PROP_WATCHED_SWITCH:
|
|
||||||
g_value_set_uint (value, input->watched_switch);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
object_class->set_property = up_input_set_property;
|
|
||||||
object_class->get_property = up_input_get_property;
|
|
||||||
|
|
||||||
g_object_class_install_property (object_class, PROP_WATCHED_SWITCH,
|
|
||||||
g_param_spec_uint("watched-switch",
|
|
||||||
"Watched switch",
|
|
||||||
"The input switch to watch",
|
|
||||||
SW_LID, SW_MAX, SW_LID,
|
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
|
||||||
|
|
||||||
signals[SWITCH_CHANGED] = g_signal_new ("switch-changed",
|
|
||||||
G_TYPE_FROM_CLASS (klass),
|
|
||||||
G_SIGNAL_RUN_LAST,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
g_cclosure_marshal_generic,
|
|
||||||
G_TYPE_NONE,
|
|
||||||
1,
|
|
||||||
G_TYPE_BOOLEAN);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* up_input_new:
|
|
||||||
*
|
|
||||||
* Returns a #UpInput that watches the computer lid switch.
|
|
||||||
**/
|
|
||||||
UpInput *
|
|
||||||
up_input_new (void)
|
|
||||||
{
|
|
||||||
return g_object_new (UP_TYPE_INPUT, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* up_input_new_for_switch:
|
|
||||||
* @watched_switch: the identifier for the `SW_` switch to watch
|
|
||||||
*
|
|
||||||
* Returns a #UpInput that watches the switched passed as argument.
|
|
||||||
**/
|
|
||||||
UpInput *
|
|
||||||
up_input_new_for_switch (guint watched_switch)
|
|
||||||
{
|
|
||||||
return g_object_new (UP_TYPE_INPUT,
|
|
||||||
"watched-switch", watched_switch,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* up_input_get_switch_value:
|
|
||||||
* @input: a #UpInput
|
|
||||||
*
|
|
||||||
* Returns the last state of the switch. It is an error
|
|
||||||
* to call this without having successfully run
|
|
||||||
* up_input_coldplug().
|
|
||||||
**/
|
|
||||||
gboolean
|
|
||||||
up_input_get_switch_value (UpInput *input)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (UP_IS_INPUT(input), FALSE);
|
|
||||||
g_return_val_if_fail (input->last_switch_state != -1, FALSE);
|
|
||||||
|
|
||||||
return input->last_switch_state;
|
|
||||||
}
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
|
||||||
*
|
|
||||||
* Copyright (C) 2009 Richard Hughes <richard@hughsie.com>
|
|
||||||
*
|
|
||||||
* 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 <glib-object.h>
|
|
||||||
#include <gudev/gudev.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
#define UP_TYPE_INPUT (up_input_get_type ())
|
|
||||||
G_DECLARE_FINAL_TYPE (UpInput, up_input, UP, INPUT, GObject)
|
|
||||||
|
|
||||||
GType up_input_get_type (void);
|
|
||||||
UpInput *up_input_new (void);
|
|
||||||
UpInput *up_input_new_for_switch (guint watched_switch);
|
|
||||||
gboolean up_input_coldplug (UpInput *input,
|
|
||||||
GUdevDevice *d);
|
|
||||||
gboolean up_input_get_switch_value (UpInput *input);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* __UP_INPUT_H__ */
|
|
||||||
|
|
||||||
|
|
@ -36,7 +36,6 @@ static gboolean up_backend_apm_get_power_info(struct apm_power_info*);
|
||||||
static gpointer up_backend_apm_event_thread(gpointer object);
|
static gpointer up_backend_apm_event_thread(gpointer object);
|
||||||
UpDeviceState up_backend_apm_get_battery_state_value(u_char battery_state);
|
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_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_on_battery (UpDevice *device, gboolean *on_battery);
|
||||||
static gboolean up_apm_device_get_online (UpDevice *device, gboolean *online);
|
static gboolean up_apm_device_get_online (UpDevice *device, gboolean *online);
|
||||||
|
|
@ -185,7 +184,6 @@ up_backend_coldplug (UpBackend *backend, UpDaemon *daemon)
|
||||||
"update-time", (guint64) current_time,
|
"update-time", (guint64) current_time,
|
||||||
(void*) NULL);
|
(void*) NULL);
|
||||||
|
|
||||||
up_backend_update_lid_status(daemon);
|
|
||||||
if (!g_initable_init (G_INITABLE (backend->priv->ac), NULL, NULL))
|
if (!g_initable_init (G_INITABLE (backend->priv->ac), NULL, NULL))
|
||||||
g_warning ("failed to coldplug ac");
|
g_warning ("failed to coldplug ac");
|
||||||
else
|
else
|
||||||
|
|
@ -288,7 +286,6 @@ up_backend_update_ac_state(UpDevice* device)
|
||||||
gboolean ret, new_is_online, cur_is_online;
|
gboolean ret, new_is_online, cur_is_online;
|
||||||
struct apm_power_info a;
|
struct apm_power_info a;
|
||||||
|
|
||||||
up_backend_update_lid_status(up_device_get_daemon(device));
|
|
||||||
ret = up_backend_apm_get_power_info(&a);
|
ret = up_backend_apm_get_power_info(&a);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -495,71 +492,6 @@ up_apm_device_refresh(UpDevice* device, UpRefreshReason reason)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Check the lid status, return TRUE if one was found, FALSE otherwise.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
up_backend_update_lid_status(UpDaemon *daemon) {
|
|
||||||
#ifndef UPOWER_CI_DISABLE_PLATFORM_CODE
|
|
||||||
/* 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; ; 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);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/* thread doing kqueue() on apm device */
|
/* thread doing kqueue() on apm device */
|
||||||
static gpointer
|
static gpointer
|
||||||
up_backend_apm_event_thread(gpointer object)
|
up_backend_apm_event_thread(gpointer object)
|
||||||
|
|
|
||||||
|
|
@ -575,42 +575,6 @@ up_daemon_get_device_list (UpDaemon *daemon)
|
||||||
return g_object_ref (daemon->priv->power_devices);
|
return g_object_ref (daemon->priv->power_devices);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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");
|
|
||||||
up_exported_daemon_set_lid_is_closed (UP_EXPORTED_DAEMON (daemon), 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");
|
|
||||||
up_exported_daemon_set_lid_is_present (UP_EXPORTED_DAEMON (daemon), lid_is_present);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* up_daemon_set_on_battery:
|
* up_daemon_set_on_battery:
|
||||||
**/
|
**/
|
||||||
|
|
|
||||||
|
|
@ -68,10 +68,6 @@ UpDeviceList *up_daemon_get_device_list (UpDaemon *daemon);
|
||||||
gboolean up_daemon_startup (UpDaemon *daemon,
|
gboolean up_daemon_startup (UpDaemon *daemon,
|
||||||
GDBusConnection *connection);
|
GDBusConnection *connection);
|
||||||
void up_daemon_shutdown (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,
|
void up_daemon_set_on_battery (UpDaemon *daemon,
|
||||||
gboolean on_battery);
|
gboolean on_battery);
|
||||||
void up_daemon_set_warning_level (UpDaemon *daemon,
|
void up_daemon_set_warning_level (UpDaemon *daemon,
|
||||||
|
|
|
||||||
|
|
@ -116,21 +116,15 @@ up_client_print (UpClient *client)
|
||||||
{
|
{
|
||||||
gchar *daemon_version;
|
gchar *daemon_version;
|
||||||
gboolean on_battery;
|
gboolean on_battery;
|
||||||
gboolean lid_is_closed;
|
|
||||||
gboolean lid_is_present;
|
|
||||||
char *action;
|
char *action;
|
||||||
|
|
||||||
g_object_get (client,
|
g_object_get (client,
|
||||||
"daemon-version", &daemon_version,
|
"daemon-version", &daemon_version,
|
||||||
"on-battery", &on_battery,
|
"on-battery", &on_battery,
|
||||||
"lid-is-closed", &lid_is_closed,
|
|
||||||
"lid-is-present", &lid_is_present,
|
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_print (" daemon-version: %s\n", daemon_version);
|
g_print (" daemon-version: %s\n", daemon_version);
|
||||||
g_print (" on-battery: %s\n", on_battery ? "yes" : "no");
|
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);
|
action = up_client_get_critical_action (client);
|
||||||
g_print (" critical-action: %s\n", action);
|
g_print (" critical-action: %s\n", action);
|
||||||
g_free (action);
|
g_free (action);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue