gnome-power-manager r2780 - in trunk: . src



Author: rhughes
Date: Fri Apr 18 14:24:17 2008
New Revision: 2780
URL: http://svn.gnome.org/viewvc/gnome-power-manager?rev=2780&view=rev

Log:
2008-04-18  Richard Hughes  <richard hughsie com>

* src/gpm-cell-array.c: (gpm_cell_array_update):
* src/gpm-cell.c: (gpm_cell_refresh_hal_all),
(hal_device_property_modified_cb):
* src/gpm-info.c: (gpm_info_log_do_poll):
Be more paranoid about the rates reported from HAL, and also only add data to the graph if
it's notn-zero. Perhaps fixes rh#443069


Modified:
   trunk/ChangeLog
   trunk/src/gpm-cell-array.c
   trunk/src/gpm-cell.c
   trunk/src/gpm-info.c

Modified: trunk/src/gpm-cell-array.c
==============================================================================
--- trunk/src/gpm-cell-array.c	(original)
+++ trunk/src/gpm-cell-array.c	Fri Apr 18 14:24:17 2008
@@ -334,6 +334,12 @@
 		unit->time_discharge /= num_present;
 	}
 
+	/* sanity check to less than 100W */
+	if (unit->rate > 100*1000) {
+		gpm_warning ("sanity checking rate from %i to 0", unit->rate);
+		unit->rate = 0;
+	}
+
 	/* sanity check */
 	if (unit->is_discharging == TRUE && unit->is_charging == TRUE) {
 		gpm_warning ("Sanity check kicked in! "

Modified: trunk/src/gpm-cell.c
==============================================================================
--- trunk/src/gpm-cell.c	(original)
+++ trunk/src/gpm-cell.c	Fri Apr 18 14:24:17 2008
@@ -139,6 +139,11 @@
 		if (exists == FALSE && (unit->is_discharging == TRUE || unit->is_charging == TRUE)) {
 			gpm_warning ("could not read your battery's charge rate");
 		}
+		/* sanity check to less than 100W */
+		if (unit->rate > 100*1000) {
+			gpm_warning ("sanity checking rate from %i to 0", unit->rate);
+			unit->rate = 0;
+		}
 	}
 
 	/* sanity check that charge_level.percentage exists (if it should) */
@@ -297,6 +302,11 @@
 
 	} else if (strcmp (key, "battery.charge_level.rate") == 0) {
 		hal_gdevice_get_uint (device, key, &unit->rate, NULL);
+		/* sanity check to less than 100W */
+		if (unit->rate > 100*1000) {
+			gpm_warning ("sanity checking rate from %i to 0", unit->rate);
+			unit->rate = 0;
+		}
 
 	} else if (strcmp (key, "battery.charge_level.percentage") == 0) {
 		hal_gdevice_get_uint (device, key, &unit->percentage, NULL);

Modified: trunk/src/gpm-info.c
==============================================================================
--- trunk/src/gpm-info.c	(original)
+++ trunk/src/gpm-info.c	Fri Apr 18 14:24:17 2008
@@ -645,22 +645,18 @@
 			colour = GPM_COLOUR_CHARGED;
 		}
 
-		gpm_array_add (info->priv->percentage_data, value_x,
-			       unit->percentage, colour);
-
-		/* sanity check to less than 100W */
-		if (unit->rate < 100000) {
+		if (unit->percentage > 0) {
+			gpm_array_add (info->priv->percentage_data, value_x,
+				       unit->percentage, colour);
+		}
+		if (unit->rate > 0) {
 			gpm_array_add (info->priv->rate_data, value_x,
 				       unit->rate, colour);
 		}
-
-		/* sanity check to less than 10 hours */
-		if (unit->time_discharge < 10*60*60) {
-			gpm_array_add (info->priv->time_data, value_x,
-					   unit->time_discharge, colour);
+		if (unit->voltage > 0) {
+			gpm_array_add (info->priv->voltage_data, value_x,
+				       unit->voltage, colour);
 		}
-		gpm_array_add (info->priv->voltage_data, value_x,
-			       unit->voltage, colour);
 	}
 	return TRUE;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]