gnome-power-manager r2650 - in branches/gnome-2-20: . src
- From: rhughes svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-power-manager r2650 - in branches/gnome-2-20: . src
- Date: Sun, 3 Feb 2008 19:13:54 +0000 (GMT)
Author: rhughes
Date: Sun Feb 3 19:13:54 2008
New Revision: 2650
URL: http://svn.gnome.org/viewvc/gnome-power-manager?rev=2650&view=rev
Log:
2008-02-03 Richard Hughes <richard hughsie com>
* src/gpm-cell.c: (gpm_cell_get_id):
Filter out invalid characters in the model and serial numbers else
we may get an invalid id and fail to do the time profiling.
Fixes #514077.
Modified:
branches/gnome-2-20/ChangeLog
branches/gnome-2-20/src/gpm-cell.c
Modified: branches/gnome-2-20/src/gpm-cell.c
==============================================================================
--- branches/gnome-2-20/src/gpm-cell.c (original)
+++ branches/gnome-2-20/src/gpm-cell.c Sun Feb 3 19:13:54 2008
@@ -443,18 +443,27 @@
gchar *
gpm_cell_get_id (GpmCell *cell)
{
+ 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) {
- return g_strdup (cell->priv->serial);
- }
- if (cell->priv->model != NULL && strlen (cell->priv->model) > 2) {
- return g_strdup (cell->priv->model);
+ /* 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);
+ } else {
+ /* just return something generic */
+ id = g_strdup ("generic_id");
}
- /* if we have no info, just return something generic */
- return g_strdup ("generic_id");
+
+ /* the id may have invalid chars that need to be replaced */
+ g_strdelimit (id, "\\\t\"' ", '_');
+
+ return id;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]