From 4a15e42c41415a8c9cc59e23c51092e097dfe7d4 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 25 Jul 2008 17:14:14 +0100 Subject: [PATCH] add a power-supply bool property so we can tell if the device is a supplier or consumer --- src/devkit-power-source.c | 14 ++++++++++++++ src/org.freedesktop.DeviceKit.Power.Source.xml | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/src/devkit-power-source.c b/src/devkit-power-source.c index d6b9412..c94e632 100644 --- a/src/devkit-power-source.c +++ b/src/devkit-power-source.c @@ -64,6 +64,7 @@ struct DevkitPowerSourcePrivate DevkitPowerType type; gboolean has_coldplug_values; + gboolean power_supply; gboolean line_power_online; gboolean battery_is_present; gboolean battery_is_rechargeable; @@ -98,6 +99,7 @@ enum PROP_UPDATE_TIME, PROP_TYPE, PROP_LINE_POWER_ONLINE, + PROP_POWER_SUPPLY, PROP_BATTERY_CAPACITY, PROP_BATTERY_IS_PRESENT, PROP_BATTERY_IS_RECHARGEABLE, @@ -158,6 +160,10 @@ get_property (GObject *object, g_value_set_string (value, devkit_power_convert_type_to_text (source->priv->type)); break; + case PROP_POWER_SUPPLY: + g_value_set_boolean (value, source->priv->power_supply); + break; + case PROP_LINE_POWER_ONLINE: g_value_set_boolean (value, source->priv->line_power_online); break; @@ -261,6 +267,10 @@ devkit_power_source_class_init (DevkitPowerSourceClass *klass) object_class, PROP_TYPE, g_param_spec_string ("type", NULL, NULL, NULL, G_PARAM_READABLE)); + g_object_class_install_property ( + object_class, + PROP_BATTERY_IS_PRESENT, + g_param_spec_boolean ("power-supply", NULL, NULL, FALSE, G_PARAM_READABLE)); g_object_class_install_property ( object_class, PROP_LINE_POWER_ONLINE, @@ -527,6 +537,7 @@ devkit_power_source_reset_values (DevkitPowerSource *source) source->priv->serial = NULL; source->priv->line_power_online = FALSE; source->priv->battery_is_present = FALSE; + source->priv->power_supply = FALSE; source->priv->battery_is_rechargeable = FALSE; source->priv->has_coldplug_values = FALSE; } @@ -600,6 +611,9 @@ update_battery (DevkitPowerSource *source) if (!source->priv->has_coldplug_values) { char *technology_native; + /* when we add via sysfs power_supply class then we know this is true */ + source->priv->power_supply = TRUE; + /* the ACPI spec is bad at defining battery type constants */ technology_native = g_strstrip (sysfs_get_string (source->priv->native_path, "technology")); source->priv->battery_technology = devkit_power_convert_acpi_technology_to_enum (technology_native); diff --git a/src/org.freedesktop.DeviceKit.Power.Source.xml b/src/org.freedesktop.DeviceKit.Power.Source.xml index 5efbfda..f8e1594 100644 --- a/src/org.freedesktop.DeviceKit.Power.Source.xml +++ b/src/org.freedesktop.DeviceKit.Power.Source.xml @@ -97,6 +97,14 @@ + + + If the power device is used to supply the system. + This would be set TRUE for laptop batteries and UPS devices, + but set FALSE for wireless mice or PDAs. + + + Whether power is currently being provided through line power.