diff options
author | Richard Hughes <richard@hughsie.com> | 2008-11-07 12:34:52 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2008-11-07 12:34:52 +0000 |
commit | 885c3e474898b641f23d365688aa77852345996a (patch) | |
tree | 903c892c4628b222a49fef4e77175164b809e7a4 | |
parent | eded5b20fc7b609f846a46c347b25109a40191a5 (diff) |
bugfix: use 0 for unknown, not -1 as some values like rate and voltage are valid when negative
-rw-r--r-- | libdevkit-power/dkp-object.c | 18 | ||||
-rw-r--r-- | src/dkp-device.c | 6 | ||||
-rw-r--r-- | src/dkp-supply.c | 16 | ||||
-rw-r--r-- | src/org.freedesktop.DeviceKit.Power.Device.xml | 4 |
4 files changed, 22 insertions, 22 deletions
diff --git a/libdevkit-power/dkp-object.c b/libdevkit-power/dkp-object.c index fa73504..931bc52 100644 --- a/libdevkit-power/dkp-object.c +++ b/libdevkit-power/dkp-object.c @@ -36,15 +36,15 @@ dkp_object_clear_internal (DkpObject *obj) { obj->type = DKP_DEVICE_TYPE_UNKNOWN; obj->update_time = 0; - obj->energy = -1; - obj->energy_full = -1; - obj->energy_full_design = -1; - obj->energy_rate = -1; - obj->voltage = -1; - obj->percentage = -1; - obj->capacity = -1; - obj->time_to_empty = -1; - obj->time_to_full = -1; + obj->energy = 0; + obj->energy_full = 0; + obj->energy_full_design = 0; + obj->energy_rate = 0; + obj->voltage = 0; + obj->percentage = 0; + obj->capacity = 0; + obj->time_to_empty = 0; + obj->time_to_full = 0; obj->state = DKP_DEVICE_STATE_UNKNOWN; obj->technology = DKP_DEVICE_TECHNOLGY_UNKNOWN; obj->vendor = NULL; diff --git a/src/dkp-device.c b/src/dkp-device.c index c1ae6e6..5aafbd2 100644 --- a/src/dkp-device.c +++ b/src/dkp-device.c @@ -792,15 +792,15 @@ dkp_device_class_init (DkpDeviceClass *klass) g_object_class_install_property ( object_class, PROP_BATTERY_TIME_TO_EMPTY, - g_param_spec_int64 ("time-to-empty", NULL, NULL, -1, G_MAXINT64, -1, G_PARAM_READABLE)); + g_param_spec_int64 ("time-to-empty", NULL, NULL, 0, G_MAXINT64, 0, G_PARAM_READABLE)); g_object_class_install_property ( object_class, PROP_BATTERY_TIME_TO_FULL, - g_param_spec_int64 ("time-to-full", NULL, NULL, -1, G_MAXINT64, -1, G_PARAM_READABLE)); + g_param_spec_int64 ("time-to-full", NULL, NULL, 0, G_MAXINT64, 0, G_PARAM_READABLE)); g_object_class_install_property ( object_class, PROP_BATTERY_PERCENTAGE, - g_param_spec_double ("percentage", NULL, NULL, -1, 100, -1, G_PARAM_READABLE)); + g_param_spec_double ("percentage", NULL, NULL, 0, 100, 0, G_PARAM_READABLE)); g_object_class_install_property ( object_class, PROP_BATTERY_TECHNOLOGY, diff --git a/src/dkp-supply.c b/src/dkp-supply.c index 623e34a..dbd4a16 100644 --- a/src/dkp-supply.c +++ b/src/dkp-supply.c @@ -91,7 +91,7 @@ dkp_supply_reset_values (DkpSupply *supply) native_path = g_strdup (obj->native_path); supply->priv->has_coldplug_values = FALSE; - supply->priv->energy_old = -1; + supply->priv->energy_old = 0; supply->priv->energy_old_timespec.tv_sec = 0; dkp_object_clear (obj); @@ -320,11 +320,11 @@ dkp_supply_refresh_battery (DkpSupply *supply) * to calculate the true rate. We should set the rate zero, and wait * for the BIOS to stabilise. */ if (obj->energy_rate == 0xffff) - obj->energy_rate = -1; + obj->energy_rate = 0; /* sanity check to less than 100W */ if (obj->energy_rate > 100*1000) - obj->energy_rate = -1; + obj->energy_rate = 0; /* the hardware reporting failed -- try to calculate this */ if (obj->energy_rate < 0) { @@ -339,8 +339,8 @@ dkp_supply_refresh_battery (DkpSupply *supply) obj->percentage = 100.0; /* calculate a quick and dirty time remaining value */ - obj->time_to_empty = -1; - obj->time_to_full = -1; + obj->time_to_empty = 0; + obj->time_to_full = 0; if (obj->energy_rate > 0) { if (state == DKP_DEVICE_STATE_DISCHARGING) { obj->time_to_empty = 3600 * (obj->energy / obj->energy_rate); @@ -351,9 +351,9 @@ dkp_supply_refresh_battery (DkpSupply *supply) /* check the remaining time is under a set limit, to deal with broken primary batteries rate */ if (obj->time_to_empty > (100 * 60 * 60)) - obj->time_to_empty = -1; + obj->time_to_empty = 0; if (obj->time_to_full > (100 * 60 * 60)) - obj->time_to_full = -1; + obj->time_to_full = 0; /* set the old status */ supply->priv->energy_old = obj->energy; @@ -361,7 +361,7 @@ dkp_supply_refresh_battery (DkpSupply *supply) /* we changed state */ if (obj->state != state) { - supply->priv->energy_old = -1; + supply->priv->energy_old = 0; obj->state = state; } diff --git a/src/org.freedesktop.DeviceKit.Power.Device.xml b/src/org.freedesktop.DeviceKit.Power.Device.xml index 51721c0..a2d2c16 100644 --- a/src/org.freedesktop.DeviceKit.Power.Device.xml +++ b/src/org.freedesktop.DeviceKit.Power.Device.xml @@ -268,7 +268,7 @@ <property name="time-to-empty" type="x" access="read"> <doc:doc><doc:description><doc:para> Number of seconds until the power source is considered empty. - Is set to -1 if unknown. + Is set to 0 if unknown. </doc:para><doc:para> This property is only valid if the property <doc:ref type="property" to="Source:type">type</doc:ref> @@ -279,7 +279,7 @@ <property name="time-to-full" type="x" access="read"> <doc:doc><doc:description><doc:para> Number of seconds until the power source is considered full. - Is set to -1 if unknown. + Is set to 0 if unknown. </doc:para><doc:para> This property is only valid if the property <doc:ref type="property" to="Source:type">type</doc:ref> |