mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2026-05-07 13:08:06 +02:00
add a power-supply bool property so we can tell if the device is a supplier or consumer
This commit is contained in:
parent
36bf97d913
commit
4a15e42c41
2 changed files with 22 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue