summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2009-07-06 10:13:02 +0100
committerRichard Hughes <richard@hughsie.com>2009-07-06 10:13:02 +0100
commit161d2d50c1fd04d6b184cc6c6c13a65ae97328ca (patch)
tree22f5b92b923edd73d45f6aac17825f3c7b00b2f6
parentff42e21d331ca21e5bfd225920a774bf348a53ab (diff)
parent86f6278f61d30e6ca97bdf421299d156b6607fda (diff)
downloadupower-161d2d50c1fd04d6b184cc6c6c13a65ae97328ca.tar.gz
Fix conflicts
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac16
-rw-r--r--devkit-power-gobject/.gitignore1
-rw-r--r--devkit-power-gobject/Makefile.am5
-rw-r--r--devkit-power-gobject/devicekit-power.h1
-rw-r--r--devkit-power-gobject/dkp-client.c32
-rw-r--r--devkit-power-gobject/dkp-client.h2
-rw-r--r--devkit-power-gobject/dkp-device.c77
-rw-r--r--devkit-power-gobject/dkp-enum.c15
-rw-r--r--devkit-power-gobject/dkp-version.h.in39
-rw-r--r--rules/95-devkit-power-battery-recall-dell.rules61
-rw-r--r--rules/95-devkit-power-battery-recall-fujitsu.rules31
-rw-r--r--rules/95-devkit-power-battery-recall-gateway.rules28
-rw-r--r--rules/95-devkit-power-battery-recall-ibm.rules35
-rw-r--r--rules/95-devkit-power-battery-recall-lenovo.rules24
-rw-r--r--rules/95-devkit-power-battery-recall-toshiba.rules29
-rw-r--r--rules/95-devkit-power-csr.rules (renamed from src/95-devkit-power-csr.rules)0
-rw-r--r--rules/95-devkit-power-hid.rules58
-rw-r--r--rules/95-devkit-power-wup.rules (renamed from src/95-devkit-power-wup.rules)0
-rw-r--r--rules/Makefile.am20
-rw-r--r--src/95-devkit-power-hid.rules50
-rw-r--r--src/Makefile.am28
-rw-r--r--src/dkp-daemon.c102
-rw-r--r--src/dkp-device-hid.c72
-rw-r--r--src/dkp-device-list.c51
-rw-r--r--src/dkp-device-list.h10
-rw-r--r--src/dkp-device-supply.c46
-rw-r--r--src/dkp-device.c87
-rw-r--r--src/dkp-device.h1
-rw-r--r--src/dkp-input.c1
-rw-r--r--src/org.freedesktop.DeviceKit.Power.Device.xml39
-rw-r--r--src/org.freedesktop.DeviceKit.Power.xml11
-rw-r--r--tools/Makefile.am1
-rw-r--r--tools/dkp-tool.c44
34 files changed, 815 insertions, 204 deletions
diff --git a/Makefile.am b/Makefile.am
index 2a80cda..95bc714 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in
-SUBDIRS = devkit-power-gobject src doc tools policy po
+SUBDIRS = devkit-power-gobject src doc tools policy po rules
# Creating ChangeLog from git log (taken from cairo/Makefile.am):
ChangeLog: $(srcdir)/ChangeLog
diff --git a/configure.ac b/configure.ac
index 3573ecc..5508c62 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6,6 +6,12 @@ AM_INIT_AUTOMAKE(DeviceKit-power, 009)
AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE
+# enable nice build output on automake1.11
+m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
+
+# use this in dkp-version.h
+AC_SUBST(VERSION)
+
# libtool versioning - this applies to devkit-power-gobject
#
# See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 for details
@@ -50,6 +56,14 @@ AM_CONDITIONAL(MAN_PAGES_ENABLED, test x$enable_man_pages = xyes)
GTK_DOC_CHECK([1.3])
+# udev rules go in /lib, not /usr/lib
+if test "$prefix" = "/usr" -o "$prefix" = "/usr/local" ; then
+ slashlibdir=/lib
+else
+ slashlibdir=$prefix/lib
+fi
+AC_SUBST(slashlibdir)
+
#### gcc warning flags
dnl ---------------------------------------------------------------------------
@@ -175,7 +189,9 @@ doc/version.xml
doc/man/Makefile
doc/dbus/Makefile
policy/Makefile
+rules/Makefile
devkit-power-gobject/Makefile
+devkit-power-gobject/dkp-version.h
po/Makefile.in
])
diff --git a/devkit-power-gobject/.gitignore b/devkit-power-gobject/.gitignore
index e9199c5..2455079 100644
--- a/devkit-power-gobject/.gitignore
+++ b/devkit-power-gobject/.gitignore
@@ -8,4 +8,5 @@
*.gcov
*.gcda
*.gcno
+dkp-version.h
diff --git a/devkit-power-gobject/Makefile.am b/devkit-power-gobject/Makefile.am
index 1aebc3c..588ebce 100644
--- a/devkit-power-gobject/Makefile.am
+++ b/devkit-power-gobject/Makefile.am
@@ -14,6 +14,7 @@ lib_LTLIBRARIES = \
libdevkit_power_includedir = $(includedir)/DeviceKit-power/devkit-power-gobject
libdevkit_power_include_HEADERS = \
devicekit-power.h \
+ dkp-version.h \
dkp-client.h \
dkp-device.h \
dkp-wakeups.h \
@@ -25,6 +26,7 @@ libdevkit_power_include_HEADERS = \
libdevkit_power_gobject_la_SOURCES = \
devicekit-power.h \
+ dkp-version.h \
dkp-client.c \
dkp-client.h \
dkp-device.c \
@@ -53,6 +55,9 @@ libdevkit_power_gobject_la_LDFLAGS = \
-no-undefined \
-export-symbols-regex '^dkp_.*'
+EXTRA_DIST = \
+ dkp-version.h.in
+
clean-local:
rm -f *~
diff --git a/devkit-power-gobject/devicekit-power.h b/devkit-power-gobject/devicekit-power.h
index 85f1af9..6d173a9 100644
--- a/devkit-power-gobject/devicekit-power.h
+++ b/devkit-power-gobject/devicekit-power.h
@@ -28,6 +28,7 @@
#define __DEVICEKIT_POWER_H_INSIDE__
+#include <devkit-power-gobject/dkp-version.h>
#include <devkit-power-gobject/dkp-client.h>
#include <devkit-power-gobject/dkp-device.h>
#include <devkit-power-gobject/dkp-enum.h>
diff --git a/devkit-power-gobject/dkp-client.c b/devkit-power-gobject/dkp-client.c
index c547d00..e8efe3d 100644
--- a/devkit-power-gobject/dkp-client.c
+++ b/devkit-power-gobject/dkp-client.c
@@ -50,6 +50,7 @@ struct DkpClientPrivate
gboolean lid_is_closed;
gboolean on_battery;
gboolean on_low_battery;
+ gboolean lid_is_present;
};
enum {
@@ -67,7 +68,9 @@ enum {
PROP_CAN_HIBERNATE,
PROP_ON_BATTERY,
PROP_ON_LOW_BATTERY,
- PROP_LID_IS_CLOSED
+ PROP_LID_IS_CLOSED,
+ PROP_LID_IS_PRESENT,
+ PROP_LAST
};
static guint signals [DKP_CLIENT_LAST_SIGNAL] = { 0 };
@@ -293,6 +296,13 @@ dkp_client_ensure_properties (DkpClient *client)
}
client->priv->on_low_battery = g_value_get_boolean (value);
+ value = g_hash_table_lookup (props, "lid-is-present");
+ if (value == NULL) {
+ g_warning ("No 'lid-is-present' property");
+ goto out;
+ }
+ client->priv->lid_is_present = g_value_get_boolean (value);
+
/* cached */
client->priv->have_properties = TRUE;
@@ -301,6 +311,7 @@ out:
g_hash_table_unref (props);
}
+#ifndef DKP_DISABLE_DEPRECATED
/**
* dkp_client_get_daemon_version:
* @client : a #DkpClient instance.
@@ -339,7 +350,7 @@ dkp_client_can_hibernate (DkpClient *client)
*
* Get whether the laptop lid is closed.
*
- * Return value: TRUE if lid is closed FALSE other wise.
+ * Return value: %TRUE if lid is closed or %FALSE otherwise.
*/
gboolean
dkp_client_lid_is_closed (DkpClient *client)
@@ -396,6 +407,7 @@ dkp_client_on_low_battery (DkpClient *client)
dkp_client_ensure_properties (client);
return client->priv->on_low_battery;
}
+#endif
/**
* dkp_client_add:
@@ -479,18 +491,21 @@ dkp_client_get_property (GObject *object,
case PROP_CAN_SUSPEND:
g_value_set_boolean (value, client->priv->can_suspend);
break;
- case PROP_CAN_HIBERNATE:
+ case PROP_CAN_HIBERNATE:
g_value_set_boolean (value, client->priv->can_hibernate);
break;
case PROP_ON_BATTERY:
g_value_set_boolean (value, client->priv->on_battery);
break;
- case PROP_ON_LOW_BATTERY:
+ case PROP_ON_LOW_BATTERY:
g_value_set_boolean (value, client->priv->on_low_battery);
break;
- case PROP_LID_IS_CLOSED:
+ case PROP_LID_IS_CLOSED:
g_value_set_boolean (value, client->priv->lid_is_closed);
break;
+ case PROP_LID_IS_PRESENT:
+ g_value_set_boolean (value, client->priv->lid_is_present);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -553,6 +568,13 @@ dkp_client_class_init (DkpClientClass *klass)
FALSE,
G_PARAM_READABLE));
+ g_object_class_install_property (object_class,
+ PROP_LID_IS_PRESENT,
+ g_param_spec_boolean ("lid-is-present",
+ NULL, NULL,
+ FALSE,
+ G_PARAM_READABLE));
+
signals [DKP_DEVICE_ADDED] =
g_signal_new ("device-added",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
diff --git a/devkit-power-gobject/dkp-client.h b/devkit-power-gobject/dkp-client.h
index 722ad5b..1644387 100644
--- a/devkit-power-gobject/dkp-client.h
+++ b/devkit-power-gobject/dkp-client.h
@@ -79,12 +79,14 @@ gboolean dkp_client_suspend (DkpClient *client,
GError **error);
gboolean dkp_client_hibernate (DkpClient *client,
GError **error);
+#ifndef DKP_DISABLE_DEPRECATED
const gchar *dkp_client_get_daemon_version (DkpClient *client);
gboolean dkp_client_can_hibernate (DkpClient *client);
gboolean dkp_client_lid_is_closed (DkpClient *client);
gboolean dkp_client_can_suspend (DkpClient *client);
gboolean dkp_client_on_battery (DkpClient *client);
gboolean dkp_client_on_low_battery (DkpClient *client);
+#endif
G_END_DECLS
diff --git a/devkit-power-gobject/dkp-device.c b/devkit-power-gobject/dkp-device.c
index 0ca881c..0c4910c 100644
--- a/devkit-power-gobject/dkp-device.c
+++ b/devkit-power-gobject/dkp-device.c
@@ -69,6 +69,9 @@ struct DkpDevicePrivate
gint64 time_to_empty; /* seconds */
gint64 time_to_full; /* seconds */
gdouble percentage; /* percent */
+ gboolean recall_notice;
+ gchar *recall_vendor;
+ gchar *recall_url;
};
enum {
@@ -96,7 +99,11 @@ enum {
PROP_VOLTAGE,
PROP_TIME_TO_EMPTY,
PROP_TIME_TO_FULL,
- PROP_PERCENTAGE
+ PROP_PERCENTAGE,
+ PROP_RECALL_NOTICE,
+ PROP_RECALL_VENDOR,
+ PROP_RECALL_URL,
+ PROP_LAST
};
enum {
@@ -188,10 +195,14 @@ dkp_device_collect_props_cb (const char *key, const GValue *value, DkpDevice *de
device->priv->capacity = g_value_get_double (value);
else if (g_strcmp0 (key, "state") == 0)
device->priv->state = g_value_get_uint (value);
- else {
+ else if (g_strcmp0 (key, "recall-notice") == 0)
+ device->priv->recall_notice = g_value_get_boolean (value);
+ else if (g_strcmp0 (key, "recall-vendor") == 0)
+ device->priv->recall_vendor = g_strdup (g_value_get_string (value));
+ else if (g_strcmp0 (key, "recall-url") == 0)
+ device->priv->recall_url = g_strdup (g_value_get_string (value));
+ else
g_warning ("unhandled property '%s'", key);
- g_assert_not_reached ();
- }
}
/**
@@ -405,7 +416,8 @@ dkp_device_print (const DkpDevice *device)
g_print (" rechargeable: %s\n", dkp_device_print_bool_to_text (device->priv->is_rechargeable));
if (device->priv->type == DKP_DEVICE_TYPE_BATTERY ||
device->priv->type == DKP_DEVICE_TYPE_MOUSE ||
- device->priv->type == DKP_DEVICE_TYPE_KEYBOARD)
+ device->priv->type == DKP_DEVICE_TYPE_KEYBOARD ||
+ device->priv->type == DKP_DEVICE_TYPE_UPS)
g_print (" state: %s\n", dkp_device_state_to_text (device->priv->state));
if (device->priv->type == DKP_DEVICE_TYPE_BATTERY) {
g_print (" energy: %g Wh\n", device->priv->energy);
@@ -450,6 +462,12 @@ dkp_device_print (const DkpDevice *device)
}
if (device->priv->type == DKP_DEVICE_TYPE_LINE_POWER)
g_print (" online: %s\n", dkp_device_print_bool_to_text (device->priv->online));
+ if (device->priv->type == DKP_DEVICE_TYPE_BATTERY) {
+ if (device->priv->recall_notice) {
+ g_print (" recall vendor: %s\n", device->priv->recall_vendor);
+ g_print (" recall url: %s\n", device->priv->recall_url);
+ }
+ }
/* if we can, get history */
if (device->priv->has_history) {
@@ -721,6 +739,17 @@ dkp_device_set_property (GObject *object, guint prop_id, const GValue *value, GP
case PROP_TECHNOLOGY:
device->priv->technology = g_value_get_uint (value);
break;
+ case PROP_RECALL_NOTICE:
+ device->priv->recall_notice = g_value_get_boolean (value);
+ break;
+ case PROP_RECALL_VENDOR:
+ g_free (device->priv->recall_vendor);
+ device->priv->recall_vendor = g_strdup (g_value_get_string (value));
+ break;
+ case PROP_RECALL_URL:
+ g_free (device->priv->recall_url);
+ device->priv->recall_url = g_strdup (g_value_get_string (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -808,6 +837,15 @@ dkp_device_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
case PROP_PERCENTAGE:
g_value_set_double (value, device->priv->percentage);
break;
+ case PROP_RECALL_NOTICE:
+ g_value_set_boolean (value, device->priv->recall_notice);
+ break;
+ case PROP_RECALL_VENDOR:
+ g_value_set_string (value, device->priv->recall_vendor);
+ break;
+ case PROP_RECALL_URL:
+ g_value_set_string (value, device->priv->recall_url);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1053,6 +1091,33 @@ dkp_device_class_init (DkpDeviceClass *klass)
g_param_spec_double ("percentage", NULL, NULL,
0.0, 100.f, 100.0,
G_PARAM_READWRITE));
+ /**
+ * DkpDevice:recall-notice:
+ */
+ g_object_class_install_property (object_class,
+ PROP_RECALL_NOTICE,
+ g_param_spec_boolean ("recall-notice",
+ NULL, NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+ /**
+ * DkpDevice:recall-vendor:
+ */
+ g_object_class_install_property (object_class,
+ PROP_RECALL_VENDOR,
+ g_param_spec_string ("recall-vendor",
+ NULL, NULL,
+ NULL,
+ G_PARAM_READWRITE));
+ /**
+ * DkpDevice:recall-url:
+ */
+ g_object_class_install_property (object_class,
+ PROP_RECALL_URL,
+ g_param_spec_string ("recall-url",
+ NULL, NULL,
+ NULL,
+ G_PARAM_READWRITE));
g_type_class_add_private (klass, sizeof (DkpDevicePrivate));
}
@@ -1088,6 +1153,8 @@ dkp_device_finalize (GObject *object)
g_free (device->priv->model);
g_free (device->priv->serial);
g_free (device->priv->native_path);
+ g_free (device->priv->recall_vendor);
+ g_free (device->priv->recall_url);
if (device->priv->proxy_device != NULL)
g_object_unref (device->priv->proxy_device);
if (device->priv->proxy_props != NULL)
diff --git a/devkit-power-gobject/dkp-enum.c b/devkit-power-gobject/dkp-enum.c
index 0db6662..4c53517 100644
--- a/devkit-power-gobject/dkp-enum.c
+++ b/devkit-power-gobject/dkp-enum.c
@@ -56,11 +56,8 @@ dkp_device_type_to_text (DkpDeviceType type_enum)
case DKP_DEVICE_TYPE_PHONE:
type = "phone";
break;
- case DKP_DEVICE_TYPE_UNKNOWN:
- type = "unknown";
- break;
default:
- g_assert_not_reached ();
+ type = "unknown";
break;
}
return type;
@@ -113,11 +110,8 @@ dkp_device_state_to_text (DkpDeviceState state_enum)
case DKP_DEVICE_STATE_FULLY_CHARGED:
state = "fully-charged";
break;
- case DKP_DEVICE_STATE_UNKNOWN:
- state = "unknown";
- break;
default:
- g_assert_not_reached ();
+ state = "unknown";
break;
}
return state;
@@ -168,11 +162,8 @@ dkp_device_technology_to_text (DkpDeviceTechnology technology_enum)
case DKP_DEVICE_TECHNOLOGY_NICKEL_METAL_HYDRIDE:
technology = "nickel-metal-hydride";
break;
- case DKP_DEVICE_TECHNOLOGY_UNKNOWN:
- technology = "unknown";
- break;
default:
- g_assert_not_reached ();
+ technology = "unknown";
break;
}
return technology;
diff --git a/devkit-power-gobject/dkp-version.h.in b/devkit-power-gobject/dkp-version.h.in
new file mode 100644
index 0000000..528cda4
--- /dev/null
+++ b/devkit-power-gobject/dkp-version.h.in
@@ -0,0 +1,39 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2009 Richard Hughes <richard@hughsie.com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#if !defined (__DEVICEKIT_POWER_H_INSIDE__) && !defined (DKP_COMPILATION)
+#error "Only <devicekit-power.h> can be included directly."
+#endif
+
+#ifndef __DKP_VERSION_H
+#define __DKP_VERSION_H
+
+/* compile time version
+ */
+#define DKP_COMPILE_VERSION (0x@VERSION@)
+
+/* check whether a the version is above the compile time version.
+ */
+#define DKP_CHECK_VERSION(ver) \
+ (DKP_COMPILE_VERSION > (ver) || \
+ (DKP_COMPILE_VERSION == (ver)))
+
+#endif /* __DKP_VERSION_H */
diff --git a/rules/95-devkit-power-battery-recall-dell.rules b/rules/95-devkit-power-battery-recall-dell.rules
new file mode 100644
index 0000000..a9eeabb
--- /dev/null
+++ b/rules/95-devkit-power-battery-recall-dell.rules
@@ -0,0 +1,61 @@
+##############################################################################################################
+# Battery recall notices: Dell
+#
+# These are properties defining the behavior:
+# DKP_RECALL_NOTICE
+# DKP_RECALL_VENDOR
+# DKP_RECALL_URL
+#
+
+# only match power_supply devices
+SUBSYSTEM!="power_supply", GOTO="dkp_battery_recall_dell_end"
+
+# only match batteries
+ATTR{type}!="Battery", GOTO="dkp_battery_recall_dell_end"
+
+# only match correct manufacturer
+ATTR{manufacturer}!="Dell", GOTO="dkp_battery_recall_dell_end"
+
+ATTR{model_name}=="1K055", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="C5446", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="F2100", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="KD494", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="W5915", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="Y1333", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="3K590", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="C6269", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="F5132", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="OR331", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="X5308", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="Y4500", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="5P474", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="C6270", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="GD785", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="M3006", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="X5329", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="Y5466", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="6P922", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="D2961", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="H3191", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="RD857", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="X5332", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="C2603", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="D5555", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="J1524", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="TD349", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="X5333", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="C5339", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="D6024", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="JD616", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="U5867", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="X5875", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="C5340", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="D6025", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="JD617", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="U5882", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="X5877", ENV{DKP_RECALL_NOTICE}="1"
+
+ENV{DKP_RECALL_NOTICE}=="1", ENV{DKP_RECALL_VENDOR}="Dell", ENV{DKP_RECALL_URL}="https://www.dellbatteryprogram.com"
+
+LABEL="dkp_battery_recall_dell_end"
+
diff --git a/rules/95-devkit-power-battery-recall-fujitsu.rules b/rules/95-devkit-power-battery-recall-fujitsu.rules
new file mode 100644
index 0000000..7d95e36
--- /dev/null
+++ b/rules/95-devkit-power-battery-recall-fujitsu.rules
@@ -0,0 +1,31 @@
+##############################################################################################################
+# Battery recall notices: Fujitsu
+#
+# These are properties defining the behavior:
+# DKP_RECALL_NOTICE
+# DKP_RECALL_VENDOR
+# DKP_RECALL_URL
+#
+
+# only match power_supply devices
+SUBSYSTEM!="power_supply", GOTO="dkp_battery_recall_fujitsu_end"
+
+# only match batteries
+ATTR{type}!="Battery", GOTO="dkp_battery_recall_fujitsu_end"
+
+# only match correct manufacturer
+ATTR{manufacturer}!="Fujitsu", GOTO="dkp_battery_recall_fujitsu_end"
+
+ATTR{model_name}=="CP255100", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="CP255108", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="CP229720", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="CP229725", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="CP234003", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="CP234019", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="CP283030", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="CP267910", ENV{DKP_RECALL_NOTICE}="1"
+
+ENV{DKP_RECALL_NOTICE}=="1", ENV{DKP_RECALL_VENDOR}="Fujitsu", ENV{DKP_RECALL_URL}="http://www.computers.us.fujitsu.com/battery/"
+
+LABEL="dkp_battery_recall_fujitsu_end"
+
diff --git a/rules/95-devkit-power-battery-recall-gateway.rules b/rules/95-devkit-power-battery-recall-gateway.rules
new file mode 100644
index 0000000..fe08a4e
--- /dev/null
+++ b/rules/95-devkit-power-battery-recall-gateway.rules
@@ -0,0 +1,28 @@
+##############################################################################################################
+# Battery recall notices: Gateway
+#
+# These are properties defining the behavior:
+# DKP_RECALL_NOTICE
+# DKP_RECALL_VENDOR
+# DKP_RECALL_URL
+#
+
+# only match power_supply devices
+SUBSYSTEM!="power_supply", GOTO="dkp_battery_recall_gateway_end"
+
+# only match batteries
+ATTR{type}!="Battery", GOTO="dkp_battery_recall_gateway_end"
+
+# only match correct manufacturer
+ATTR{manufacturer}!="Gateway", GOTO="dkp_battery_recall_gateway_end"
+
+ATTR{model_name}=="916C4610F", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="916C4720F", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="916C4730F", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="916C5010F", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="W230", ENV{DKP_RECALL_NOTICE}="1"
+
+ENV{DKP_RECALL_NOTICE}=="1", ENV{DKP_RECALL_VENDOR}="Gateway", ENV{DKP_RECALL_URL}="http://www.gateway.com/battery/\n"
+
+LABEL="dkp_battery_recall_gateway_end"
+
diff --git a/rules/95-devkit-power-battery-recall-ibm.rules b/rules/95-devkit-power-battery-recall-ibm.rules
new file mode 100644
index 0000000..ecff4fb
--- /dev/null
+++ b/rules/95-devkit-power-battery-recall-ibm.rules
@@ -0,0 +1,35 @@
+##############################################################################################################
+# Battery recall notices: IBM
+#
+# These are properties defining the behavior:
+# DKP_RECALL_NOTICE
+# DKP_RECALL_VENDOR
+# DKP_RECALL_URL
+#
+
+# only match power_supply devices
+SUBSYSTEM!="power_supply", GOTO="dkp_battery_recall_ibm_end"
+
+# only match batteries
+ATTR{type}!="Battery", GOTO="dkp_battery_recall_ibm_end"
+
+# only match correct manufacturer
+ATTR{manufacturer}!="SONY", GOTO="dkp_battery_recall_ibm_end"
+
+ATTR{model_name}=="92P1072", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="92P1073", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="92P1088", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="92P1089", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="92P1142", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="92P1141", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="92P1170", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="92P1169", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="93P5028", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="92P1174", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="92P1173", ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="93P5030", ENV{DKP_RECALL_NOTICE}="1"
+
+ENV{DKP_RECALL_NOTICE}=="1", ENV{DKP_RECALL_VENDOR}="LENOVO", ENV{DKP_RECALL_URL}="http://www.lenovo.com/batteryprogram"
+
+LABEL="dkp_battery_recall_ibm_end"
+
diff --git a/rules/95-devkit-power-battery-recall-lenovo.rules b/rules/95-devkit-power-battery-recall-lenovo.rules
new file mode 100644
index 0000000..536630f
--- /dev/null
+++ b/rules/95-devkit-power-battery-recall-lenovo.rules
@@ -0,0 +1,24 @@
+##############################################################################################################
+# Battery recall notices: Lenovo
+#
+# These are properties defining the behavior:
+# DKP_RECALL_NOTICE
+# DKP_RECALL_VENDOR
+# DKP_RECALL_URL
+#
+
+# only match power_supply devices
+SUBSYSTEM!="power_supply", GOTO="dkp_battery_recall_lenovo_end"
+
+# only match batteries
+ATTR{type}!="Battery", GOTO="dkp_battery_recall_lenovo_end"
+
+# only match correct manufacturer
+ATTR{manufacturer}!="SANYO", GOTO="dkp_battery_recall_lenovo_end"
+
+ATTR{model_name}=="92P1131", ENV{DKP_RECALL_NOTICE}="1"
+
+ENV{DKP_RECALL_NOTICE}=="1", ENV{DKP_RECALL_VENDOR}="LENOVO", ENV{DKP_RECALL_URL}="http://www.lenovo.com/batteryprogram"
+
+LABEL="dkp_battery_recall_lenovo_end"
+
diff --git a/rules/95-devkit-power-battery-recall-toshiba.rules b/rules/95-devkit-power-battery-recall-toshiba.rules
new file mode 100644
index 0000000..4a20a57
--- /dev/null
+++ b/rules/95-devkit-power-battery-recall-toshiba.rules
@@ -0,0 +1,29 @@
+##############################################################################################################
+# Battery recall notices: Toshiba
+#
+# These are properties defining the behavior:
+# DKP_RECALL_NOTICE
+# DKP_RECALL_VENDOR
+# DKP_RECALL_URL
+#
+
+# only match power_supply devices
+SUBSYSTEM!="power_supply", GOTO="dkp_battery_recall_toshiba_end"
+
+# only match batteries
+ATTR{type}!="Battery", GOTO="dkp_battery_recall_toshiba_end"
+
+# only match correct manufacturer
+ATTR{manufacturer}!="TOSHIBA", GOTO="dkp_battery_recall_toshiba_end"
+
+ATTR{model_name}=="PA3465U, ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="PA3399U, ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="PA3400U, ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="PA3465U, ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="PA3399U, ENV{DKP_RECALL_NOTICE}="1"
+ATTR{model_name}=="PA3400U, ENV{DKP_RECALL_NOTICE}="1"
+
+ENV{DKP_RECALL_NOTICE}=="1", ENV{DKP_RECALL_VENDOR}="Toshiba", ENV{DKP_RECALL_URL}="http://bxinfo.toshiba.com/"
+
+LABEL="dkp_battery_recall_toshiba_end"
+
diff --git a/src/95-devkit-power-csr.rules b/rules/95-devkit-power-csr.rules
index c14e323..c14e323 100644
--- a/src/95-devkit-power-csr.rules
+++ b/rules/95-devkit-power-csr.rules
diff --git a/rules/95-devkit-power-hid.rules b/rules/95-devkit-power-hid.rules
new file mode 100644
index 0000000..464aefa
--- /dev/null
+++ b/rules/95-devkit-power-hid.rules
@@ -0,0 +1,58 @@
+##############################################################################################################
+# Uninterruptable Power Supplies with USB HID interfaces
+#
+
+# only support USB, else ignore
+SUBSYSTEM!="usb", GOTO="dkp_hid_end"
+
+# if usbraw device, ignore
+KERNEL!="hiddev*", GOTO="dkp_hid_end"
+
+# if an interface, ignore
+ENV{DEVTYPE}=="usb_interface", GOTO="dkp_hid_end"
+
+ATTRS{idVendor}=="0463", ENV{DKP_VENDOR}="MGE Systems"
+ATTRS{idVendor}=="051d", ENV{DKP_VENDOR}="APC"
+ATTRS{idVendor}=="0764", ENV{DKP_VENDOR}="CyberPower"
+ATTRS{idVendor}=="09ae", ENV{DKP_VENDOR}="Tripp Lite"
+ATTRS{idVendor}=="050d", ENV{DKP_VENDOR}="Belkin"
+ATTRS{idVendor}=="06da", ENV{DKP_VENDOR}="Liebert"
+ATTRS{idVendor}=="0925", ENV{DKP_VENDOR}="Kebo"
+
+# MGE UPS SYSTEMS
+ATTRS{idVendor}=="0463", ATTRS{idProduct}=="0001", ENV{DKP_BATTERY_TYPE}="ups"
+ATTRS{idVendor}=="0463", ATTRS{idProduct}=="ffff", ENV{DKP_BATTERY_TYPE}="ups"
+
+# APC
+ATTRS{idVendor}=="051d", ATTRS{idProduct}=="0002", ENV{DKP_BATTERY_TYPE}="ups"
+
+# CyberPower
+ATTRS{idVendor}=="0764", ATTRS{idProduct}=="0005", ENV{DKP_BATTERY_TYPE}="ups"
+ATTRS{idVendor}=="0764", ATTRS{idProduct}=="0501", ENV{DKP_BATTERY_TYPE}="ups"
+
+# Tripp Lite
+ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="1003", ENV{DKP_BATTERY_TYPE}="ups"
+ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="2005", ENV{DKP_BATTERY_TYPE}="ups"
+ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="2007", ENV{DKP_BATTERY_TYPE}="ups"
+ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="3012", ENV{DKP_BATTERY_TYPE}="ups"
+ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="4002", ENV{DKP_BATTERY_TYPE}="ups"
+ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="4003", ENV{DKP_BATTERY_TYPE}="ups"
+
+# Belkin
+ATTRS{idVendor}=="050d", ATTRS{idProduct}=="0375", ENV{DKP_BATTERY_TYPE}="ups"
+ATTRS{idVendor}=="050d", ATTRS{idProduct}=="0551", ENV{DKP_BATTERY_TYPE}="ups"
+ATTRS{idVendor}=="050d", ATTRS{idProduct}=="0751", ENV{DKP_BATTERY_TYPE}="ups"
+ATTRS{idVendor}=="050d", ATTRS{idProduct}=="0900", ENV{DKP_BATTERY_TYPE}="ups"
+ATTRS{idVendor}=="050d", ATTRS{idProduct}=="0910", ENV{DKP_BATTERY_TYPE}="ups"
+ATTRS{idVendor}=="050d", ATTRS{idProduct}=="0912", ENV{DKP_BATTERY_TYPE}="ups"
+ATTRS{idVendor}=="050d", ATTRS{idProduct}=="0980", ENV{DKP_BATTERY_TYPE}="ups"
+ATTRS{idVendor}=="050d", ATTRS{idProduct}=="1100", ENV{DKP_BATTERY_TYPE}="ups"
+
+# Liebert
+ATTRS{idVendor}=="06da", ATTRS{idProduct}=="ffff", ENV{DKP_BATTERY_TYPE}="ups"
+
+# Kebo
+ATTRS{idVendor}=="0925", ATTRS{idProduct}=="1234", ENV{DKP_BATTERY_TYPE}="ups"
+
+LABEL="dkp_hid_end"
+
diff --git a/src/95-devkit-power-wup.rules b/rules/95-devkit-power-wup.rules
index f42c6d0..f42c6d0 100644
--- a/src/95-devkit-power-wup.rules
+++ b/rules/95-devkit-power-wup.rules
diff --git a/rules/Makefile.am b/rules/Makefile.am
new file mode 100644
index 0000000..f7af3ae
--- /dev/null
+++ b/rules/Makefile.am
@@ -0,0 +1,20 @@
+## Process this file with automake to produce Makefile.in
+
+udevrulesdir = $(slashlibdir)/udev/rules.d
+udevrules_DATA = \
+ 95-devkit-power-battery-recall-dell.rules \
+ 95-devkit-power-battery-recall-fujitsu.rules \
+ 95-devkit-power-battery-recall-gateway.rules \
+ 95-devkit-power-battery-recall-ibm.rules \
+ 95-devkit-power-battery-recall-lenovo.rules \
+ 95-devkit-power-battery-recall-toshiba.rules \
+ 95-devkit-power-wup.rules \
+ 95-devkit-power-hid.rules \
+ 95-devkit-power-csr.rules
+
+EXTRA_DIST = \
+ $(udevrules_DATA)
+
+clean-local :
+ rm -f *~
+
diff --git a/src/95-devkit-power-hid.rules b/src/95-devkit-power-hid.rules
deleted file mode 100644
index 6523e23..0000000
--- a/src/95-devkit-power-hid.rules
+++ /dev/null
@@ -1,50 +0,0 @@
-##############################################################################################################
-# Uninterruptable Power Supplies with USBHID interface
-#
-SUBSYSTEM!="usb", GOTO="dkp_hid_end"
-
-ATTR{idVendor}=="0463", ENV{DKP_VENDOR}="MGE Systems"
-ATTR{idVendor}=="051d", ENV{DKP_VENDOR}="APC"
-ATTR{idVendor}=="0764", ENV{DKP_VENDOR}="CyberPower"
-ATTR{idVendor}=="09ae", ENV{DKP_VENDOR}="Tripp Lite"
-ATTR{idVendor}=="050d", ENV{DKP_VENDOR}="Belkin"
-ATTR{idVendor}=="06da", ENV{DKP_VENDOR}="Liebert"
-ATTR{idVendor}=="0925", ENV{DKP_VENDOR}="Kebo"
-
-# MGE UPS SYSTEMS
-ATTR{idVendor}=="0463", ATTR{idProduct}=="0001", ENV{DKP_BATTERY_TYPE}="ups"
-ATTR{idVendor}=="0463", ATTR{idProduct}=="ffff", ENV{DKP_BATTERY_TYPE}="ups"
-
-# APC
-ATTR{idVendor}=="051d", ATTR{idProduct}=="0002", ENV{DKP_BATTERY_TYPE}="ups"
-
-# CyberPower
-ATTR{idVendor}=="0764", ATTR{idProduct}=="0005", ENV{DKP_BATTERY_TYPE}="ups"
-ATTR{idVendor}=="0764", ATTR{idProduct}=="0501", ENV{DKP_BATTERY_TYPE}="ups"
-
-# Tripp Lite
-ATTR{idVendor}=="09ae", ATTR{idProduct}=="1003", ENV{DKP_BATTERY_TYPE}="ups"
-ATTR{idVendor}=="09ae", ATTR{idProduct}=="2005", ENV{DKP_BATTERY_TYPE}="ups"
-ATTR{idVendor}=="09ae", ATTR{idProduct}=="2007", ENV{DKP_BATTERY_TYPE}="ups"
-ATTR{idVendor}=="09ae", ATTR{idProduct}=="3012", ENV{DKP_BATTERY_TYPE}="ups"
-ATTR{idVendor}=="09ae", ATTR{idProduct}=="4002", ENV{DKP_BATTERY_TYPE}="ups"
-ATTR{idVendor}=="09ae", ATTR{idProduct}=="4003", ENV{DKP_BATTERY_TYPE}="ups"
-
-# Belkin
-ATTR{idVendor}=="050d", ATTR{idProduct}=="0375", ENV{DKP_BATTERY_TYPE}="ups"
-ATTR{idVendor}=="050d", ATTR{idProduct}=="0551", ENV{DKP_BATTERY_TYPE}="ups"
-ATTR{idVendor}=="050d", ATTR{idProduct}=="0751", ENV{DKP_BATTERY_TYPE}="ups"
-ATTR{idVendor}=="050d", ATTR{idProduct}=="0900", ENV{DKP_BATTERY_TYPE}="ups"
-ATTR{idVendor}=="050d", ATTR{idProduct}=="0910", ENV{DKP_BATTERY_TYPE}="ups"
-ATTR{idVendor}=="050d", ATTR{idProduct}=="0912", ENV{DKP_BATTERY_TYPE}="ups"
-ATTR{idVendor}=="050d", ATTR{idProduct}=="0980", ENV{DKP_BATTERY_TYPE}="ups"
-ATTR{idVendor}=="050d", ATTR{idProduct}=="1100", ENV{DKP_BATTERY_TYPE}="ups"
-
-# Liebert
-ATTR{idVendor}=="06da", ATTR{idProduct}=="ffff", ENV{DKP_BATTERY_TYPE}="ups"
-
-# Kebo
-ATTR{idVendor}=="0925", ATTR{idProduct}=="1234", ENV{DKP_BATTERY_TYPE}="ups"
-
-LABEL="dkp_hid_end"
-
diff --git a/src/Makefile.am b/src/Makefile.am
index 0878f25..2e51035 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,6 +12,7 @@ INCLUDES = \
-D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT \
-DG_UDEV_API_IS_SUBJECT_TO_CHANGE \
-DDKP_COMPILATION \
+ -DDKP_DISABLE_DEPRECATED \
-DEGG_LOG_FILE=\""$(DKP_LOG_DIR)/DeviceKit-power"\" \
-DEGG_VERBOSE="\"DKP_VERBOSE\"" \
-DEGG_LOGGING="\"DKP_LOGGING\"" \
@@ -55,13 +56,13 @@ dkp-wakeups-glue.h: org.freedesktop.DeviceKit.Power.Wakeups.xml Makefile.am
libexec_PROGRAMS = devkit-power-daemon
dbusifdir = $(datadir)/dbus-1/interfaces
-dbusif_DATA = \
- org.freedesktop.DeviceKit.Power.xml \
- org.freedesktop.DeviceKit.Power.Device.xml \
- org.freedesktop.DeviceKit.Power.QoS.xml \
+dbusif_DATA = \
+ org.freedesktop.DeviceKit.Power.xml \
+ org.freedesktop.DeviceKit.Power.Device.xml \
+ org.freedesktop.DeviceKit.Power.QoS.xml \
org.freedesktop.DeviceKit.Power.Wakeups.xml
-devkit_power_daemon_SOURCES = \
+devkit_power_daemon_SOURCES = \
egg-debug.c \
egg-debug.h \
dkp-polkit.h dkp-polkit.c \
@@ -80,13 +81,13 @@ devkit_power_daemon_SOURCES = \
dkp-main.c \
$(BUILT_SOURCES)
-devkit_power_daemon_CPPFLAGS = \
+devkit_power_daemon_CPPFLAGS = \
-I$(top_srcdir)/src \
-DG_LOG_DOMAIN=\"dkp-daemon\" \
$(DISABLE_DEPRECATED) \
$(AM_CPPFLAGS)
-devkit_power_daemon_LDADD = \
+devkit_power_daemon_LDADD = \
-lm \
$(USB_LIBS) \
$(GIO_LIBS) \
@@ -109,12 +110,6 @@ dbusconf_DATA = $(dbusconf_in_files:.conf.in=.conf)
$(dbusconf_DATA): $(dbusconf_in_files) Makefile
cp $< $@
-udevrulesdir = $(sysconfdir)/udev/rules.d
-udevrules_DATA = \
- 95-devkit-power-wup.rules \
- 95-devkit-power-hid.rules \
- 95-devkit-power-csr.rules
-
install-data-hook:
if test -w $(DESTDIR)$(prefix)/; then \
mkdir -p $(DESTDIR)$(localstatedir)/lib/DeviceKit-power; \
@@ -123,15 +118,12 @@ install-data-hook:
CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = \
- org.freedesktop.DeviceKit.Power.xml \
+ org.freedesktop.DeviceKit.Power.xml \
org.freedesktop.DeviceKit.Power.Device.xml \
org.freedesktop.DeviceKit.Power.QoS.xml \
org.freedesktop.DeviceKit.Power.Wakeups.xml \
dkp-marshal.list \
- 95-devkit-power-csr.rules \
- 95-devkit-power-hid.rules \
- 95-devkit-power-wup.rules \
- $(service_in_files) \
+ $(service_in_files) \
$(dbusconf_in_files)
clean-local :
diff --git a/src/dkp-daemon.c b/src/dkp-daemon.c
index 1d9d7e1..b80e2ba 100644
--- a/src/dkp-daemon.c
+++ b/src/dkp-daemon.c
@@ -56,6 +56,8 @@ enum
PROP_ON_BATTERY,
PROP_ON_LOW_BATTERY,
PROP_LID_IS_CLOSED,
+ PROP_LID_IS_PRESENT,
+ PROP_LAST
};
enum
@@ -76,12 +78,13 @@ struct DkpDaemonPrivate
DBusGConnection *connection;
DBusGProxy *proxy;
DkpPolkit *polkit;
- DkpDeviceList *list;
- GPtrArray *inputs;
+ DkpDeviceList *power_devices;
+ DkpDeviceList *managed_devices;
gboolean on_battery;
gboolean low_battery;
GUdevClient *gudev_client;
gboolean lid_is_closed;
+ gboolean lid_is_present;
};
static void dkp_daemon_class_init (DkpDaemonClass *klass);
@@ -220,6 +223,10 @@ dkp_daemon_get_property (GObject *object,
g_value_set_boolean (value, daemon->priv->lid_is_closed);
break;
+ case PROP_LID_IS_PRESENT:
+ g_value_set_boolean (value, daemon->priv->lid_is_present);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -282,6 +289,14 @@ dkp_daemon_class_init (DkpDaemonClass *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_CAN_SUSPEND,
g_param_spec_boolean ("can-suspend",
"Can Suspend",
@@ -334,8 +349,8 @@ dkp_daemon_init (DkpDaemon *daemon)
{
daemon->priv = DKP_DAEMON_GET_PRIVATE (daemon);
daemon->priv->polkit = dkp_polkit_new ();
+ daemon->priv->lid_is_present = FALSE;
daemon->priv->lid_is_closed = FALSE;
- daemon->priv->inputs = g_ptr_array_new ();
}
/**
@@ -359,14 +374,12 @@ dkp_daemon_finalize (GObject *object)
dbus_g_connection_unref (daemon->priv->connection);
if (daemon->priv->gudev_client != NULL)
g_object_unref (daemon->priv->gudev_client);
- if (daemon->priv->list != NULL)
- g_object_unref (daemon->priv->list);
+ if (daemon->priv->power_devices != NULL)
+ g_object_unref (daemon->priv->power_devices);
+ if (daemon->priv->managed_devices != NULL)
+ g_object_unref (daemon->priv->managed_devices);
g_object_unref (daemon->priv->polkit);
- /* unref inputs */
- g_ptr_array_foreach (daemon->priv->inputs, (GFunc) g_object_unref, NULL);
- g_ptr_array_free (daemon->priv->inputs, TRUE);
-
G_OBJECT_CLASS (dkp_daemon_parent_class)->finalize (object);
}
@@ -389,7 +402,7 @@ dkp_daemon_get_on_battery_local (DkpDaemon *daemon)
const GPtrArray *array;
/* ask each device */
- array = dkp_device_list_get_array (daemon->priv->list);
+ array = dkp_device_list_get_array (daemon->priv->power_devices);
for (i=0; i<array->len; i++) {
device = (DkpDevice *) g_ptr_array_index (array, i);
ret = dkp_device_get_on_battery (device, &on_battery);
@@ -417,7 +430,7 @@ dkp_daemon_get_low_battery_local (DkpDaemon *daemon)
const GPtrArray *array;
/* ask each device */
- array = dkp_device_list_get_array (daemon->priv->list);
+ array = dkp_device_list_get_array (daemon->priv->power_devices);
for (i=0; i<array->len; i++) {
device = (DkpDevice *) g_ptr_array_index (array, i);
ret = dkp_device_get_low_battery (device, &low_battery);
@@ -445,7 +458,7 @@ dkp_daemon_get_on_ac_local (DkpDaemon *daemon)
const GPtrArray *array;
/* ask each device */
- array = dkp_device_list_get_array (daemon->priv->list);
+ array = dkp_device_list_get_array (daemon->priv->power_devices);
for (i=0; i<array->len; i++) {
device = (DkpDevice *) g_ptr_array_index (array, i);
ret = dkp_device_get_online (device, &online);
@@ -489,16 +502,18 @@ out:
static void
gpk_daemon_device_changed (DkpDaemon *daemon, GUdevDevice *d, gboolean synthesized)
{
+ GObject *object;
DkpDevice *device;
gboolean ret;
/* first, change the device and add it if it doesn't exist */
- device = dkp_device_list_lookup (daemon->priv->list, d);
- if (device != NULL) {
+ object = dkp_device_list_lookup (daemon->priv->power_devices, d);
+ if (object != NULL) {
+ device = DKP_DEVICE (object);
egg_debug ("changed %s", dkp_device_get_object_path (device));
dkp_device_changed (device, d, synthesized);
} else {
- egg_debug ("treating change event as add on %s", dkp_device_get_object_path (device));
+ egg_debug ("treating change event as add on %s", g_udev_device_get_sysfs_path (d));
dkp_daemon_device_add (daemon, d, TRUE);
}
@@ -524,11 +539,10 @@ gpk_daemon_device_changed (DkpDaemon *daemon, GUdevDevice *d, gboolean synthesiz
* dkp_daemon_device_went_away:
**/
static void
-dkp_daemon_device_went_away (gpointer user_data, GObject *_device)
+dkp_daemon_device_went_away (gpointer user_data, GObject *device)
{
DkpDaemon *daemon = DKP_DAEMON (user_data);
- DkpDevice *device = DKP_DEVICE (_device);
- dkp_device_list_remove (daemon->priv->list, device);
+ dkp_device_list_remove (daemon->priv->power_devices, device);
}
/**
@@ -597,8 +611,11 @@ gpk_daemon_device_get (DkpDaemon *daemon, GUdevDevice *d)
goto out;
}
- /* we can't use the device list as it's not a DkpDevice */
- g_ptr_array_add (daemon->priv->inputs, input);
+ /* we now have a lid */
+ daemon->priv->lid_is_present = TRUE;
+
+ /* not a power device */
+ dkp_device_list_insert (daemon->priv->managed_devices, d, G_OBJECT (input));
/* no valid input object */
device = NULL;
@@ -617,12 +634,14 @@ out:
static gboolean
gpk_daemon_device_add (DkpDaemon *daemon, GUdevDevice *d, gboolean emit_event)
{
+ GObject *object;
DkpDevice *device;
gboolean ret = TRUE;
/* does device exist in db? */
- device = dkp_device_list_lookup (daemon->priv->list, d);
- if (device != NULL) {
+ object = dkp_device_list_lookup (daemon->priv->power_devices, d);
+ if (object != NULL) {
+ device = DKP_DEVICE (object);
/* we already have the device; treat as change event */
egg_debug ("treating add event as change event on %s", dkp_device_get_object_path (device));
dkp_daemon_device_changed (daemon, d, FALSE);
@@ -639,7 +658,7 @@ gpk_daemon_device_add (DkpDaemon *daemon, GUdevDevice *d, gboolean emit_event)
* it's unreffed. So if we ref it, it'll never go away.
*/
g_object_weak_ref (G_OBJECT (device), dkp_daemon_device_went_away, daemon);
- dkp_device_list_insert (daemon->priv->list, d, device);
+ dkp_device_list_insert (daemon->priv->power_devices, d, G_OBJECT (device));
if (emit_event) {
g_signal_emit (daemon, signals[DEVICE_ADDED_SIGNAL], 0,
dkp_device_get_object_path (device));
@@ -655,13 +674,15 @@ out:
static void
gpk_daemon_device_remove (DkpDaemon *daemon, GUdevDevice *d)
{
+ GObject *object;
DkpDevice *device;
/* does device exist in db? */
- device = dkp_device_list_lookup (daemon->priv->list, d);
- if (device == NULL) {
+ object = dkp_device_list_lookup (daemon->priv->power_devices, d);
+ if (object == NULL) {
egg_debug ("ignoring remove event on %s", g_udev_device_get_sysfs_path (d));
} else {
+ device = DKP_DEVICE (object);
dkp_device_removed (device);
g_signal_emit (daemon, signals[DEVICE_REMOVED_SIGNAL], 0,
dkp_device_get_object_path (device));
@@ -692,31 +713,6 @@ gpk_daemon_uevent_signal_handler_cb (GUdevClient *client, const gchar *action,
}
}
-#if 0
-/**
- * dkp_daemon_throw_error:
- **/
-static gboolean
-dkp_daemon_throw_error (DBusGMethodInvocation *context, int error_code, const char *format, ...)
-{
- GError *error;
- va_list args;
- gchar *message;
-
- va_start (args, format);
- message = g_strdup_vprintf (format, args);
- va_end (args);
-
- error = g_error_new (DKP_DAEMON_ERROR, error_code, message);
- dbus_g_method_return_error (context, error);
- g_error_free (error);
- g_free (message);
- return TRUE;
-}
-#endif
-
-/* exported methods */
-
/**
* dkp_daemon_enumerate_devices:
**/
@@ -730,7 +726,7 @@ dkp_daemon_enumerate_devices (DkpDaemon *daemon, DBusGMethodInvocation *context)
/* build a pointer array of the object paths */
object_paths = g_ptr_array_new ();
- array = dkp_device_list_get_array (daemon->priv->list);
+ array = dkp_device_list_get_array (daemon->priv->power_devices);
for (i=0; i<array->len; i++) {
device = (DkpDevice *) g_ptr_array_index (array, i);
g_ptr_array_add (object_paths, g_strdup (dkp_device_get_object_path (device)));
@@ -885,7 +881,9 @@ dkp_daemon_new (void)
daemon = DKP_DAEMON (g_object_new (DKP_TYPE_DAEMON, NULL));
- daemon->priv->list = dkp_device_list_new ();
+ daemon->priv->power_devices = dkp_device_list_new ();
+ daemon->priv->managed_devices = dkp_device_list_new ();
+
if (!dkp_daemon_register_power_daemon (DKP_DAEMON (daemon))) {
g_object_unref (daemon);
return NULL;
diff --git a/src/dkp-device-hid.c b/src/dkp-device-hid.c
index 9412de8..a2853e7 100644
--- a/src/dkp-device-hid.c
+++ b/src/dkp-device-hid.c
@@ -63,21 +63,21 @@
#define DKP_DEVICE_HID_SHUTDOWN_IMMINENT 0x840069
#define DKP_DEVICE_HID_PRODUCT 0x8400fe
#define DKP_DEVICE_HID_SERIAL_NUMBER 0x8400ff
-#define DKP_DEVICE_HID_CHARGING 0x850044
+#define DKP_DEVICE_HID_CHARGING 0x850044
#define DKP_DEVICE_HID_DISCHARGING 0x850045
#define DKP_DEVICE_HID_REMAINING_CAPACITY 0x850066
-#define DKP_DEVICE_HID_RUNTIME_TO_EMPTY 0x850068
+#define DKP_DEVICE_HID_RUNTIME_TO_EMPTY 0x850068
#define DKP_DEVICE_HID_AC_PRESENT 0x8500d0
#define DKP_DEVICE_HID_BATTERY_PRESENT 0x8500d1
#define DKP_DEVICE_HID_DESIGN_CAPACITY 0x850083
#define DKP_DEVICE_HID_DEVICE_NAME 0x850088
-#define DKP_DEVICE_HID_DEVICE_CHEMISTRY 0x850089
+#define DKP_DEVICE_HID_DEVICE_CHEMISTRY 0x850089
#define DKP_DEVICE_HID_RECHARGEABLE 0x85008b
#define DKP_DEVICE_HID_OEM_INFORMATION 0x85008f
#define DKP_DEVICE_HID_PAGE_GENERIC_DESKTOP 0x01
#define DKP_DEVICE_HID_PAGE_CONSUMER_PRODUCT 0x0c
-#define DKP_DEVICE_HID_PAGE_USB_MONITOR 0x80
+#define DKP_DEVICE_HID_PAGE_USB_MONITOR 0x80
#define DKP_DEVICE_HID_PAGE_USB_ENUMERATED_VALUES 0x81
#define DKP_DEVICE_HID_PAGE_VESA_VIRTUAL_CONTROLS 0x82
#define DKP_DEVICE_HID_PAGE_RESERVED_MONITOR 0x83
@@ -180,10 +180,10 @@ dkp_device_hid_convert_device_technology (const gchar *type)
}
/**
- * dkp_device_hid_set_obj:
+ * dkp_device_hid_set_values:
**/
static gboolean
-dkp_device_hid_set_obj (DkpDeviceHid *hid, int code, int value)
+dkp_device_hid_set_values (DkpDeviceHid *hid, int code, int value)
{
const gchar *type;
gboolean ret = TRUE;
@@ -191,10 +191,10 @@ dkp_device_hid_set_obj (DkpDeviceHid *hid, int code, int value)
switch (code) {
case DKP_DEVICE_HID_REMAINING_CAPACITY:
- g_object_set (device, "percentage", value, NULL);
+ g_object_set (device, "percentage", (gfloat) value, NULL);
break;
case DKP_DEVICE_HID_RUNTIME_TO_EMPTY:
- g_object_set (device, "time-to-empty", value, NULL);
+ g_object_set (device, "time-to-empty", (gint64) value, NULL);
break;
case DKP_DEVICE_HID_CHARGING:
if (value != 0)
@@ -227,7 +227,7 @@ dkp_device_hid_set_obj (DkpDeviceHid *hid, int code, int value)
g_object_set (device, "serial", dkp_device_hid_get_string (hid, value), NULL);
break;
case DKP_DEVICE_HID_DESIGN_CAPACITY:
- g_object_set (device, "energy-full-design", value, NULL);
+ g_object_set (device, "energy-full-design", (gfloat) value, NULL);
break;
default:
ret = FALSE;
@@ -247,6 +247,7 @@ dkp_device_hid_get_all_data (DkpDeviceHid *hid)
struct hiddev_usage_ref uref;
int rtype;
guint i, j;
+ gboolean ret = FALSE;
/* get all results */
for (rtype = HID_REPORT_TYPE_MIN; rtype <= HID_REPORT_TYPE_MAX; rtype++) {
@@ -270,13 +271,32 @@ dkp_device_hid_get_all_data (DkpDeviceHid *hid)
ioctl (hid->priv->fd, HIDIOCGUSAGE, &uref);
/* process each */
- dkp_device_hid_set_obj (hid, uref.usage_code, uref.value);
+ dkp_device_hid_set_values (hid, uref.usage_code, uref.value);
+
+ /* we got some data */
+ ret = TRUE;
}
}
rinfo.report_id |= HID_REPORT_ID_NEXT;
}
}
- return TRUE;
+ return ret;
+}
+
+/**
+ * dkp_device_hid_fixup_state:
+ **/
+static void
+dkp_device_hid_fixup_state (DkpDevice *device)
+{
+ gdouble percentage;
+
+ /* map states the UPS cannot express */
+ g_object_get (device, "percentage", &percentage, NULL);
+ if (percentage < 0.01)
+ g_object_set (device, "state", DKP_DEVICE_STATE_EMPTY, NULL);
+ if (percentage > 99.9)
+ g_object_set (device, "state", DKP_DEVICE_STATE_FULLY_CHARGED, NULL);
}
/**
@@ -312,6 +332,7 @@ dkp_device_hid_coldplug (DkpDevice *device)
}
/* connect to the device */
+ egg_debug ("using device: %s", device_file);
hid->priv->fd = open (device_file, O_RDONLY | O_NONBLOCK);
if (hid->priv->fd < 0) {
egg_debug ("cannot open device file %s", device_file);
@@ -342,11 +363,14 @@ dkp_device_hid_coldplug (DkpDevice *device)
NULL);
/* coldplug everything */
- dkp_device_hid_get_all_data (hid);
-
- /* coldplug */
- ret = dkp_device_hid_refresh (device);
+ ret = dkp_device_hid_get_all_data (hid);
+ if (!ret) {
+ egg_debug ("failed to coldplug: %s", device_file);
+ goto out;
+ }
+ /* fix up device states */
+ dkp_device_hid_fixup_state (device);
out:
return ret;
}
@@ -371,21 +395,33 @@ dkp_device_hid_refresh (DkpDevice *device)
g_get_current_time (&time);
g_object_set (device, "update-time", (guint64) time.tv_sec, NULL);
- /* read any data -- it's okay if there's nothing as we are non-blocking */
+ /* read any data */
rd = read (hid->priv->fd, ev, sizeof (ev));
- if (rd < (int) sizeof (ev[0])) {
+
+ /* it's okay if there's nothing as we are non-blocking */
+ if (rd == -1) {
+ egg_debug ("no data");
ret = FALSE;
goto out;
}
+ /* did we read enough data? */
+ if (rd < (int) sizeof (ev[0])) {
+ egg_warning ("incomplete read (%i<%i)", rd, (int) sizeof (ev[0]));
+ goto out;
+ }
+
/* process each event */
for (i=0; i < rd / sizeof (ev[0]); i++) {
- set = dkp_device_hid_set_obj (hid, ev[i].hid, ev[i].value);
+ set = dkp_device_hid_set_values (hid, ev[i].hid, ev[i].value);
/* if only takes one match to make refresh a success */
if (set)
ret = TRUE;
}
+
+ /* fix up device states */
+ dkp_device_hid_fixup_state (device);
out:
return ret;
}
diff --git a/src/dkp-device-list.c b/src/dkp-device-list.c
index 0e08001..fee7bc8 100644
--- a/src/dkp-device-list.c
+++ b/src/dkp-device-list.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
- * Copyright (C) 2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2008-2009 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
@@ -26,7 +26,7 @@
#include <glib.h>
#include "egg-debug.h"
-#include "dkp-device.h"
+
#include "dkp-device-list.h"
static void dkp_device_list_class_init (DkpDeviceListClass *klass);
@@ -38,7 +38,7 @@ static void dkp_device_list_finalize (GObject *object);
struct DkpDeviceListPrivate
{
GPtrArray *array;
- GHashTable *map_native_path_to_device;
+ GHashTable *map_native_path_to_object;
};
G_DEFINE_TYPE (DkpDeviceList, dkp_device_list, G_TYPE_OBJECT)
@@ -46,42 +46,42 @@ G_DEFINE_TYPE (DkpDeviceList, dkp_device_list, G_TYPE_OBJECT)
/**
* dkp_device_list_lookup:
*
- * Convert a %GUdevDevice into a %DkpDevice -- we use the native path
+ * Convert a %GUdevDevice into a %GObject -- we use the native path
* to look these up as it's the only thing they share.
**/
-DkpDevice *
-dkp_device_list_lookup (DkpDeviceList *list, GUdevDevice *d)
+GObject *
+dkp_device_list_lookup (DkpDeviceList *list, GUdevDevice *device)
{
- DkpDevice *device;
+ GObject *object;
const gchar *native_path;
g_return_val_if_fail (DKP_IS_DEVICE_LIST (list), NULL);
/* does device exist in db? */
- native_path = g_udev_device_get_sysfs_path (d);
- device = g_hash_table_lookup (list->priv->map_native_path_to_device, native_path);
- return device;
+ native_path = g_udev_device_get_sysfs_path (device);
+ object = g_hash_table_lookup (list->priv->map_native_path_to_object, native_path);
+ return object;
}
/**
* dkp_device_list_insert:
*
- * Insert a %GUdevDevice device and it's mapping to a %DkpDevice device
+ * Insert a %GUdevDevice device and it's mapping to a backing %GObject
* into a list of devices.
**/
gboolean
-dkp_device_list_insert (DkpDeviceList *list, GUdevDevice *d, DkpDevice *device)
+dkp_device_list_insert (DkpDeviceList *list, GUdevDevice *device, GObject *object)
{
const gchar *native_path;
g_return_val_if_fail (DKP_IS_DEVICE_LIST (list), FALSE);
- g_return_val_if_fail (d != NULL, FALSE);
g_return_val_if_fail (device != NULL, FALSE);
+ g_return_val_if_fail (object != NULL, FALSE);
- native_path = g_udev_device_get_sysfs_path (d);
- g_hash_table_insert (list->priv->map_native_path_to_device,
- g_strdup (native_path), device);
- g_ptr_array_add (list->priv->array, device);
+ native_path = g_udev_device_get_sysfs_path (device);
+ g_hash_table_insert (list->priv->map_native_path_to_object,
+ g_strdup (native_path), object);
+ g_ptr_array_add (list->priv->array, g_object_ref (object));
egg_debug ("added %s", native_path);
return TRUE;
}
@@ -103,15 +103,16 @@ dkp_device_list_remove_cb (gpointer key, gpointer value, gpointer user_data)
* dkp_device_list_remove:
**/
gboolean
-dkp_device_list_remove (DkpDeviceList *list, DkpDevice *device)
+dkp_device_list_remove (DkpDeviceList *list, GObject *object)
{
g_return_val_if_fail (DKP_IS_DEVICE_LIST (list), FALSE);
- g_return_val_if_fail (device != NULL, FALSE);
+ g_return_val_if_fail (object != NULL, FALSE);
/* remove the device from the db */
- g_hash_table_foreach_remove (list->priv->map_native_path_to_device,
- dkp_device_list_remove_cb, device);
- g_ptr_array_remove (list->priv->array, device);
+ g_hash_table_foreach_remove (list->priv->map_native_path_to_object,
+ dkp_device_list_remove_cb, object);
+ g_ptr_array_remove (list->priv->array, object);
+ g_object_unref (object);
return TRUE;
}
@@ -148,7 +149,7 @@ dkp_device_list_init (DkpDeviceList *list)
{
list->priv = DKP_DEVICE_LIST_GET_PRIVATE (list);
list->priv->array = g_ptr_array_new ();
- list->priv->map_native_path_to_device = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ list->priv->map_native_path_to_object = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
}
/**
@@ -163,8 +164,10 @@ dkp_device_list_finalize (GObject *object)
g_return_if_fail (DKP_IS_DEVICE_LIST (object));
list = DKP_DEVICE_LIST (object);
+
+ g_ptr_array_foreach (list->priv->array, (GFunc) g_object_unref, NULL);
g_ptr_array_free (list->priv->array, TRUE);
- g_hash_table_unref (list->priv->map_native_path_to_device);
+ g_hash_table_unref (list->priv->map_native_path_to_object);
G_OBJECT_CLASS (dkp_device_list_parent_class)->finalize (object);
}
diff --git a/src/dkp-device-list.h b/src/dkp-device-list.h
index 67d11ec..943e78f 100644
--- a/src/dkp-device-list.h
+++ b/src/dkp-device-list.h
@@ -53,13 +53,13 @@ typedef struct
GType dkp_device_list_get_type (void);
DkpDeviceList *dkp_device_list_new (void);
-DkpDevice *dkp_device_list_lookup (DkpDeviceList *list,
- GUdevDevice *d);
+GObject *dkp_device_list_lookup (DkpDeviceList *list,
+ GUdevDevice *device);
gboolean dkp_device_list_insert (DkpDeviceList *list,
- GUdevDevice *d,
- DkpDevice *device);
+ GUdevDevice *device,
+ GObject *object);
gboolean dkp_device_list_remove (DkpDeviceList *list,
- DkpDevice *device);
+ GObject *object);
const GPtrArray *dkp_device_list_get_array (DkpDeviceList *list);
G_END_DECLS
diff --git a/src/dkp-device-supply.c b/src/dkp-device-supply.c
index 9550999..58c66a4 100644
--- a/src/dkp-device-supply.c
+++ b/src/dkp-device-supply.c
@@ -41,6 +41,7 @@
#define DKP_DEVICE_SUPPLY_REFRESH_TIMEOUT 30 /* seconds */
#define DKP_DEVICE_SUPPLY_UNKNOWN_TIMEOUT 2 /* seconds */
#define DKP_DEVICE_SUPPLY_UNKNOWN_RETRIES 30
+#define DKP_DEVICE_SUPPLY_CHARGED_THRESHOLD 95.0f /* % */
struct DkpDeviceSupplyPrivate
{
@@ -329,6 +330,11 @@ dkp_device_supply_refresh_battery (DkpDeviceSupply *supply)
gchar *manufacturer;
gchar *model_name;
gchar *serial_number;
+ gboolean recall_notice;
+ const gchar *recall_vendor = NULL;
+ const gchar *recall_url = NULL;
+ DkpDaemon *daemon;
+ gboolean on_battery;
d = dkp_device_get_d (device);
if (d == NULL) {
@@ -378,6 +384,13 @@ dkp_device_supply_refresh_battery (DkpDeviceSupply *supply)
model_name = dkp_device_supply_get_string (native_path, "model_name");
serial_number = dkp_device_supply_get_string (native_path, "serial_number");
+ /* are we possibly recalled by the vendor? */
+ recall_notice = devkit_device_has_property (d, "DKP_RECALL_NOTICE");
+ if (recall_notice) {
+ recall_vendor = devkit_device_get_property (d, "DKP_RECALL_VENDOR");
+ recall_url = devkit_device_get_property (d, "DKP_RECALL_URL");
+ }
+
g_object_set (device,
"vendor", manufacturer,
"model", model_name,
@@ -385,6 +398,9 @@ dkp_device_supply_refresh_battery (DkpDeviceSupply *supply)
"is-rechargeable", TRUE, /* assume true for laptops */
"has-history", TRUE,
"has-statistics", TRUE,
+ "recall-notice", recall_notice,
+ "recall-vendor", recall_vendor,
+ "recall-url", recall_url,
NULL);
g_free (manufacturer);
@@ -509,6 +525,36 @@ dkp_device_supply_refresh_battery (DkpDeviceSupply *supply)
percentage = 100.0f;
}
+ /* some batteries stop charging much before 100% */
+ if (state == DKP_DEVICE_STATE_UNKNOWN &&
+ percentage > DKP_DEVICE_SUPPLY_CHARGED_THRESHOLD) {
+ egg_warning ("fixing up unknown %f", percentage);
+ state = DKP_DEVICE_STATE_FULLY_CHARGED;
+ }
+
+ /* the battery isn't charging or discharging, it's just
+ * sitting there half full doing nothing: try to guess a state */
+ if (state == DKP_DEVICE_STATE_UNKNOWN) {
+
+ /* get global battery status */
+ daemon = dkp_device_get_daemon (device);
+ g_object_get (daemon,
+ "on-battery", &on_battery,
+ NULL);
+ g_object_unref (daemon);
+
+ /* try to find a suitable icon depending on AC state */
+ if (on_battery) {
+ state = DKP_DEVICE_STATE_DISCHARGING;
+ } else {
+ state = DKP_DEVICE_STATE_CHARGING;
+ }
+
+ /* print what we did */
+ egg_warning ("guessing battery state '%s' using global on-battery:%i",
+ dkp_device_state_to_text (state), on_battery);
+ }
+
/* calculate a quick and dirty time remaining value */
time_to_empty = 0;
time_to_full = 0;
diff --git a/src/dkp-device.c b/src/dkp-device.c
index eedb62a..81d5dc6 100644
--- a/src/dkp-device.c
+++ b/src/dkp-device.c
@@ -80,6 +80,9 @@ struct DkpDevicePrivate
gint64 time_to_empty; /* seconds */
gint64 time_to_full; /* seconds */
gdouble percentage; /* percent */
+ gboolean recall_notice;
+ gchar *recall_vendor;
+ gchar *recall_url;
};
static void dkp_device_class_init (DkpDeviceClass *klass);
@@ -114,6 +117,10 @@ enum
PROP_TIME_TO_FULL,
PROP_PERCENTAGE,
PROP_TECHNOLOGY,
+ PROP_RECALL_NOTICE,
+ PROP_RECALL_VENDOR,
+ PROP_RECALL_URL,
+ PROP_LAST
};
enum
@@ -249,6 +256,15 @@ dkp_device_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
case PROP_TECHNOLOGY:
g_value_set_uint (value, device->priv->technology);
break;
+ case PROP_RECALL_NOTICE:
+ g_value_set_boolean (value, device->priv->recall_notice);
+ break;
+ case PROP_RECALL_VENDOR:
+ g_value_set_string (value, device->priv->recall_vendor);
+ break;
+ case PROP_RECALL_URL:
+ g_value_set_string (value, device->priv->recall_url);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -340,6 +356,17 @@ dkp_device_set_property (GObject *object, guint prop_id, const GValue *value, GP
case PROP_TECHNOLOGY:
device->priv->technology = g_value_get_uint (value);
break;
+ case PROP_RECALL_NOTICE:
+ device->priv->recall_notice = g_value_get_boolean (value);
+ break;
+ case PROP_RECALL_VENDOR:
+ g_free (device->priv->recall_vendor);
+ device->priv->recall_vendor = g_strdup (g_value_get_string (value));
+ break;
+ case PROP_RECALL_URL:
+ g_free (device->priv->recall_url);
+ device->priv->recall_url = g_strdup (g_value_get_string (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -475,6 +502,19 @@ out:
}
/**
+ * dkp_device_get_daemon:
+ *
+ * Returns a refcounted #DkpDaemon instance, or %NULL
+ **/
+DkpDaemon *
+dkp_device_get_daemon (DkpDevice *device)
+{
+ if (device->priv->daemon == NULL)
+ return NULL;
+ return g_object_ref (device->priv->daemon);
+}
+
+/**
* dkp_device_coldplug:
*
* Return %TRUE on success, %FALSE if we failed to get data and should be removed
@@ -498,18 +538,28 @@ dkp_device_coldplug (DkpDevice *device, DkpDaemon *daemon, GUdevDevice *d)
/* coldplug source */
ret = klass->coldplug (device);
- if (!ret)
+ if (!ret) {
+ egg_debug ("failed to coldplug %p", device);
goto out;
+ }
/* only put on the bus if we succeeded */
ret = dkp_device_register_device (device);
- if (!ret)
+ if (!ret) {
+ egg_warning ("failed to register device");
goto out;
+ }
- /* force a refresh */
+ /* force a refresh, although failure isn't fatal */
ret = dkp_device_refresh_internal (device);
- if (!ret)
+ if (!ret) {
+ egg_debug ("failed to refresh");
+
+ /* TODO: refresh should really have seporate
+ * success _and_ changed parameters */
+ ret = TRUE;
goto out;
+ }
/* get the id so we can load the old history */
id = dkp_device_get_id (device);
@@ -865,6 +915,8 @@ dkp_device_finalize (GObject *object)
g_free (device->priv->model);
g_free (device->priv->serial);
g_free (device->priv->native_path);
+ g_free (device->priv->recall_vendor);
+ g_free (device->priv->recall_url);
G_OBJECT_CLASS (dkp_device_parent_class)->finalize (object);
}
@@ -1104,6 +1156,33 @@ dkp_device_class_init (DkpDeviceClass *klass)
g_param_spec_double ("percentage", NULL, NULL,
0.0, 100.f, 100.0,
G_PARAM_READWRITE));
+ /**
+ * DkpDevice:recall-notice:
+ */
+ g_object_class_install_property (object_class,
+ PROP_RECALL_NOTICE,
+ g_param_spec_boolean ("recall-notice",
+ NULL, NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+ /**
+ * DkpDevice:recall-vendor:
+ */
+ g_object_class_install_property (object_class,
+ PROP_RECALL_VENDOR,
+ g_param_spec_string ("recall-vendor",
+ NULL, NULL,
+ NULL,
+ G_PARAM_READWRITE));
+ /**
+ * DkpDevice:recall-url:
+ */
+ g_object_class_install_property (object_class,
+ PROP_RECALL_URL,
+ g_param_spec_string ("recall-url",
+ NULL, NULL,
+ NULL,
+ G_PARAM_READWRITE));
dbus_g_error_domain_register (DKP_DEVICE_ERROR, NULL, DKP_DEVICE_TYPE_ERROR);
}
diff --git a/src/dkp-device.h b/src/dkp-device.h
index bde3850..ed9e983 100644
--- a/src/dkp-device.h
+++ b/src/dkp-device.h
@@ -77,6 +77,7 @@ GType dkp_device_get_type (void);
gboolean dkp_device_coldplug (DkpDevice *device,
DkpDaemon *daemon,
GUdevDevice *d);
+DkpDaemon *dkp_device_get_daemon (DkpDevice *device);
gboolean dkp_device_changed (DkpDevice *device,
GUdevDevice *d,
gboolean synthesized);
diff --git a/src/dkp-input.c b/src/dkp-input.c
index d76ac44..87bd7db 100644
--- a/src/dkp-input.c
+++ b/src/dkp-input.c
@@ -294,7 +294,6 @@ dkp_input_finalize (GObject *object)
if (input->priv->channel) {
g_io_channel_shutdown (input->priv->channel, FALSE, NULL);
g_io_channel_unref (input->priv->channel);
- egg_error ("moooo");
}
G_OBJECT_CLASS (dkp_input_parent_class)->finalize (object);
}
diff --git a/src/org.freedesktop.DeviceKit.Power.Device.xml b/src/org.freedesktop.DeviceKit.Power.Device.xml
index bdaa58d..b3f14c7 100644
--- a/src/org.freedesktop.DeviceKit.Power.Device.xml
+++ b/src/org.freedesktop.DeviceKit.Power.Device.xml
@@ -655,6 +655,45 @@ method return sender=:1.386 -> dest=:1.477 reply_serial=2
</doc:doc>
</property>
+ <property name="recall-notice" type="b" access="read">
+ <doc:doc>
+ <doc:description>
+ <doc:para>
+ If the device may have been recalled by the vendor due to a suspected
+ fault.
+ This key does not imply the device is faulty, only that it approximatly
+ matches the description from the vendor of units that were recalled.
+ </doc:para>
+ </doc:description>
+ </doc:doc>
+ </property>
+
+ <property name="recall-vendor" type="s" access="read">
+ <doc:doc>
+ <doc:description>
+ <doc:para>
+ The vendor that is handling the hardware recall.
+ </doc:para>
+ <doc:para>
+ This property is only valid if the property recall-notice is true.
+ </doc:para>
+ </doc:description>
+ </doc:doc>
+ </property>
+
+ <property name="recall-url" type="s" access="read">
+ <doc:doc>
+ <doc:description>
+ <doc:para>
+ The URL to visit about the hardware recall.
+ </doc:para>
+ <doc:para>
+ This property is only valid if the property recall-notice is true.
+ </doc:para>
+ </doc:description>
+ </doc:doc>
+ </property>
+
</interface>
</node>
diff --git a/src/org.freedesktop.DeviceKit.Power.xml b/src/org.freedesktop.DeviceKit.Power.xml
index 6b5ce03..dd310cd 100644
--- a/src/org.freedesktop.DeviceKit.Power.xml
+++ b/src/org.freedesktop.DeviceKit.Power.xml
@@ -129,7 +129,6 @@ method return sender=:1.386 -> dest=:1.451 reply_serial=2
<!-- ************************************************************ -->
-
<property name="daemon-version" type="s" access="read">
<doc:doc><doc:description><doc:para>
Version of the running daemon, e.g. <doc:tt>002</doc:tt>.
@@ -172,6 +171,16 @@ method return sender=:1.386 -> dest=:1.451 reply_serial=2
</doc:doc>
</property>
+ <property name="lid-is-present" type="b" access="read">
+ <doc:doc>
+ <doc:description>
+ <doc:para>
+ If the system has a lid device.
+ </doc:para>
+ </doc:description>
+ </doc:doc>
+ </property>
+
<signal name="Changed">
<doc:doc>
<doc:description>
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 6c22e7f..e21a9a6 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -10,6 +10,7 @@ INCLUDES = \
-DPACKAGE_LIB_DIR=\""$(libdir)"\" \
-D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT \
-DDKP_COMPILATION \
+ -DDKP_DISABLE_DEPRECATED \
-DEGG_LOG_FILE=\""$(DKP_LOG_DIR)/DeviceKit-power"\" \
-DEGG_VERBOSE="\"DKP_VERBOSE\"" \
-DEGG_LOGGING="\"DKP_LOGGING\"" \
diff --git a/tools/dkp-tool.c b/tools/dkp-tool.c
index 80c7d29..e9d58b2 100644
--- a/tools/dkp-tool.c
+++ b/tools/dkp-tool.c
@@ -78,15 +78,39 @@ dkp_tool_device_removed_cb (DkpClient *client, const DkpDevice *device, gpointer
g_print ("\n");
}
+/**
+ * dkp_client_print:
+ **/
static void
dkp_client_print (DkpClient *client)
{
- g_print (" daemon-version: %s\n", dkp_client_get_daemon_version (client));
- g_print (" can-suspend: %s\n", dkp_client_can_suspend (client) ? "yes" : "no");
- g_print (" can-hibernate %s\n", dkp_client_can_hibernate (client) ? "yes" : "no");
- g_print (" on-battery: %s\n", dkp_client_on_battery (client) ? "yes" : "no");
- g_print (" on-low-battery: %s\n", dkp_client_on_low_battery (client) ? "yes" : "no");
- g_print (" lid-is-closed: %s\n", dkp_client_lid_is_closed (client) ? "yes" : "no");
+ gchar *daemon_version;
+ gboolean can_suspend;
+ gboolean can_hibernate;
+ gboolean on_battery;
+ gboolean on_low_battery;
+ gboolean lid_is_closed;
+ gboolean lid_is_present;
+
+ g_object_get (client,
+ "daemon-version", &daemon_version,
+ "can-suspend", &can_suspend,
+ "can-hibernate", &can_hibernate,
+ "on-battery", &on_battery,
+ "on-low_battery", &on_low_battery,
+ "lid-is-closed", &lid_is_closed,
+ "lid-is-present", &lid_is_present,
+ NULL);
+
+ g_print (" daemon-version: %s\n", daemon_version);
+ g_print (" can-suspend: %s\n", can_suspend ? "yes" : "no");
+ g_print (" can-hibernate %s\n", can_hibernate ? "yes" : "no");
+ g_print (" on-battery: %s\n", on_battery ? "yes" : "no");
+ g_print (" on-low-battery: %s\n", on_low_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");
+
+ g_free (daemon_version);
}
/**
@@ -209,10 +233,14 @@ main (int argc, char **argv)
client = dkp_client_new ();
if (opt_version) {
+ gchar *daemon_version;
+ g_object_get (client,
+ "daemon-version", &daemon_version,
+ NULL);
g_print ("DeviceKit-power client version %s\n"
"DeviceKit-power daemon version %s\n",
- PACKAGE_VERSION,
- dkp_client_get_daemon_version (client));
+ PACKAGE_VERSION, daemon_version);
+ g_free (daemon_version);
retval = 0;
goto out;
}