summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2008-07-24 18:15:40 +0100
committerRichard Hughes <richard@hughsie.com>2008-07-24 18:15:40 +0100
commit1f41f03776976073f56aaeb85e6635df43dd8d6c (patch)
tree8455bcb272475767a8eb8afa36b16db55e925b7b
parenta1f9c0528097593c62822329ba1e66bf3a3f8d16 (diff)
export battery-is-present as some batteries in laptops and UPSs can be removed
-rw-r--r--src/devkit-power-source.c13
-rw-r--r--src/org.freedesktop.DeviceKit.Power.Source.xml12
2 files changed, 25 insertions, 0 deletions
diff --git a/src/devkit-power-source.c b/src/devkit-power-source.c
index f5a3720..25fde0a 100644
--- a/src/devkit-power-source.c
+++ b/src/devkit-power-source.c
@@ -63,6 +63,7 @@ struct DevkitPowerSourcePrivate
DevkitPowerType type;
gboolean line_power_online;
+ gboolean battery_is_present;
gboolean battery_is_rechargeable;
DevkitPowerState battery_state;
DevkitPowerTechnology battery_technology;
@@ -95,6 +96,7 @@ enum
PROP_TYPE,
PROP_LINE_POWER_ONLINE,
PROP_BATTERY_CAPACITY,
+ PROP_BATTERY_IS_PRESENT,
PROP_BATTERY_IS_RECHARGEABLE,
PROP_BATTERY_STATE,
PROP_BATTERY_ENERGY,
@@ -156,6 +158,10 @@ get_property (GObject *object,
case PROP_LINE_POWER_ONLINE:
g_value_set_boolean (value, source->priv->line_power_online);
break;
+
+ case PROP_BATTERY_IS_PRESENT:
+ g_value_set_boolean (value, source->priv->battery_is_present);
+ break;
case PROP_BATTERY_IS_RECHARGEABLE:
g_value_set_boolean (value, source->priv->battery_is_rechargeable);
break;
@@ -262,6 +268,10 @@ devkit_power_source_class_init (DevkitPowerSourceClass *klass)
g_param_spec_double ("battery-energy", NULL, NULL, 0, G_MAXDOUBLE, 0, G_PARAM_READABLE));
g_object_class_install_property (
object_class,
+ PROP_BATTERY_IS_PRESENT,
+ g_param_spec_boolean ("battery-is-present", NULL, NULL, FALSE, G_PARAM_READABLE));
+ g_object_class_install_property (
+ object_class,
PROP_BATTERY_IS_RECHARGEABLE,
g_param_spec_boolean ("battery-is-rechargeable", NULL, NULL, FALSE, G_PARAM_READABLE));
g_object_class_install_property (
@@ -510,6 +520,9 @@ update_battery (DevkitPowerSource *source)
* This is just a very quick hack for now.
*/
+ /* are we present? */
+ source->priv->battery_is_present = sysfs_get_bool (source->priv->native_path, "present");
+
status = g_strstrip (sysfs_get_string (source->priv->native_path, "status"));
is_charging = strcasecmp (status, "charging") == 0;
is_discharging = strcasecmp (status, "discharging") == 0;
diff --git a/src/org.freedesktop.DeviceKit.Power.Source.xml b/src/org.freedesktop.DeviceKit.Power.Source.xml
index d2c33b9..5efbfda 100644
--- a/src/org.freedesktop.DeviceKit.Power.Source.xml
+++ b/src/org.freedesktop.DeviceKit.Power.Source.xml
@@ -202,6 +202,18 @@
</doc:para></doc:description></doc:doc>
</property>
+ <property name="battery-is-present" type="b" access="read">
+ <doc:doc><doc:description><doc:para>
+ If the power source is present in the bay.
+ This field is required as some batteries are hot-removable, for example
+ expensive UPS and most laptop batteries.
+ </doc:para><doc:para>
+ This property is only valid if the property
+ <doc:ref type="property" to="Source:type">type</doc:ref>
+ has the value "battery".
+ </doc:para></doc:description></doc:doc>
+ </property>
+
<property name="battery-state" type="s" access="read">
<doc:doc><doc:description><doc:para>
The battery power state.