gnome-power-manager r3171 - in branches/gnome-2-24: . src



Author: rhughes
Date: Fri Jan 23 10:53:31 2009
New Revision: 3171
URL: http://svn.gnome.org/viewvc/gnome-power-manager?rev=3171&view=rev

Log:
2009-01-23  Richard Hughes  <richard hughsie com>

* src/gpm-cell-unit.h:
* src/gpm-cell.c: (gpm_cell_refresh_hal_all), (gpm_cell_get_id):
We have to include capacity in the profile name as some vendors create
different sized batteries with the same serial number.
This break batteries that use the current voltage for the mAh to mWh
conversion when the design voltage is also invalid. In this case
use the reporting string as we don't care about units.
Patch from Stephen Gildea and Joe, many thanks.
Fixes #562576


Modified:
   branches/gnome-2-24/ChangeLog
   branches/gnome-2-24/src/gpm-cell-unit.h
   branches/gnome-2-24/src/gpm-cell.c

Modified: branches/gnome-2-24/src/gpm-cell-unit.h
==============================================================================
--- branches/gnome-2-24/src/gpm-cell-unit.h	(original)
+++ branches/gnome-2-24/src/gpm-cell-unit.h	Fri Jan 23 10:53:31 2009
@@ -47,6 +47,7 @@
 	guint		 charge_design;
 	guint		 charge_last_full;
 	guint		 charge_current;
+	guint		 reporting_design;
 	guint		 rate;
 	gfloat		 percentage;
 	guint		 time_charge;

Modified: branches/gnome-2-24/src/gpm-cell.c
==============================================================================
--- branches/gnome-2-24/src/gpm-cell.c	(original)
+++ branches/gnome-2-24/src/gpm-cell.c	Fri Jan 23 10:53:31 2009
@@ -109,6 +109,8 @@
 				 &unit->charge_last_full, NULL);
 	hal_gdevice_get_uint (device, "battery.charge_level.current",
 				 &unit->charge_current, NULL);
+	hal_gdevice_get_uint (device, "battery.reporting.design",
+				 &unit->reporting_design, NULL);
 
 	/* battery might not be rechargeable, have to check */
 	hal_gdevice_get_bool (device, "battery.is_rechargeable",
@@ -181,12 +183,12 @@
 				capacity = 100.0f / (float) unit->charge_design;
 				unit->capacity = capacity * (float) unit->charge_last_full;
 				if (unit->capacity > 100) {
-					egg_debug ("rounding down capactity from "
+					egg_debug ("rounding down capacity from "
 						   "%i to 100", unit->capacity);
 					unit->capacity = 100;
 				}
 				if (unit->capacity < 0) {
-					egg_debug ("rounding up capactity from "
+					egg_debug ("rounding up capacity from "
 						   "%i to 0", unit->capacity);
 					unit->capacity = 0;
 				}
@@ -483,8 +485,8 @@
 		g_string_append (string, cell->priv->model);
 		g_string_append_c (string, '-');
 	}
-	if (cell->priv->unit.charge_design > 0) {
-		g_string_append_printf (string, "%i", cell->priv->unit.charge_design);
+	if (cell->priv->unit.reporting_design > 0) {
+		g_string_append_printf (string, "%i", cell->priv->unit.reporting_design);
 		g_string_append_c (string, '-');
 	}
 	if (cell->priv->serial != NULL && strlen (cell->priv->serial) > 2) {



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