Re: [gpm] reset statistics gathered
- From: Richard Hughes <hughsient gmail com>
- To: Vitaly Bordug <vbordug gmail com>
- Cc: gnome-power-manager-list gnome org
- Subject: Re: [gpm] reset statistics gathered
- Date: Tue, 27 May 2008 14:16:23 +0100
On Sat, 2008-05-24 at 06:39 +0400, Vitaly Bordug wrote:
> В Sun, 18 May 2008 10:25:58 +0100
> Richard Hughes <hughsient gmail com> пишет:
>
> > On Sun, 2008-05-18 at 13:22 +0400, Vitaly Bordug wrote:
> > > battery.serial = '' (string)
> >
> > Helpfully, the serial numbers are blank, hence g-p-m can't tell the
> > difference (it usually keeps one profile for each battery).
> >
> > Could you get the lshal output with one battery in, then remove it,
> > insert the second, and then email me the result. Maybe we can use
> > capacity or something to detect the different battery.
> Here is it (it seems we could stick to battery.reporting.design to
> differenciate batteries if serial is empty).
I'm guessing the attached patch fixes it for you?
> OT question: what can be accomplished to study HAL to consume ACPI
> events from my multimedia keys?
Do they send HAL ButtonPressed events or INPUT keycodes?
Richard.
Index: src/gpm-cell.c
===================================================================
--- src/gpm-cell.c (revision 2807)
+++ src/gpm-cell.c (working copy)
@@ -458,24 +458,39 @@
gchar *
gpm_cell_get_id (GpmCell *cell)
{
+ GString *string;
gchar *id = NULL;
g_return_val_if_fail (cell != NULL, NULL);
g_return_val_if_fail (GPM_IS_CELL (cell), NULL);
- /* try to use these in order of uniqueness */
- if (cell->priv->serial != NULL && strlen (cell->priv->serial) > 2) {
- /* serial number */
- id = g_strdup (cell->priv->serial);
- } else if (cell->priv->model != NULL && strlen (cell->priv->model) > 2) {
- /* model number */
- id = g_strdup (cell->priv->model);
+ string = g_string_new ("");
+
+ /* in an ideal world, model-capacity-serial */
+ if (strlen (cell->priv->model) > 2) {
+ 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);
+ g_string_append_c (string, '-');
+ }
+ if (strlen (cell->priv->serial) > 2) {
+ g_string_append (string, cell->priv->serial);
+ g_string_append_c (string, '-');
+ }
+
+ /* make sure we are sane */
+ if (string->len == 0) {
+ /* just use something generic */
+ g_string_append (string, "generic_id");
} else {
- /* just return something generic */
- id = g_strdup ("generic_id");
+ /* remove trailing '-' */
+ g_string_set_size (string, string->len - 1);
}
/* the id may have invalid chars that need to be replaced */
+ id = g_string_free (string, FALSE);
g_strdelimit (id, "\\\t\"' /", '_');
return id;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]