diff options
author | Richard Hughes <richard@hughsie.com> | 2008-07-25 17:14:14 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2008-07-25 17:14:14 +0100 |
commit | 4a15e42c41415a8c9cc59e23c51092e097dfe7d4 (patch) | |
tree | e7d7e9fdee493a5b3d2f5513980cc13379ff2f7e | |
parent | 36bf97d9133f4bfd1f134da6c3052785701be65d (diff) |
add a power-supply bool property so we can tell if the device is a supplier or consumer
-rw-r--r-- | src/devkit-power-source.c | 14 | ||||
-rw-r--r-- | src/org.freedesktop.DeviceKit.Power.Source.xml | 8 |
2 files changed, 22 insertions, 0 deletions
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; @@ -263,6 +269,10 @@ devkit_power_source_class_init (DevkitPowerSourceClass *klass) 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, g_param_spec_boolean ("line-power-online", NULL, NULL, FALSE, G_PARAM_READABLE)); g_object_class_install_property ( @@ -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 @@ </doc:para></doc:description></doc:doc> </property> + <property name="power-supply" type="b" access="read"> + <doc:doc><doc:description><doc:para> + 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. + </doc:para></doc:description></doc:doc> + </property> + <property name="line-power-online" type="b" access="read"> <doc:doc><doc:description><doc:para> Whether power is currently being provided through line power. |