[network-manager-applet] trivial: device description string fixup



commit fb11fe41e783f0f2aa45d32818f27e4f181958cc
Author: Dan Williams <dcbw redhat com>
Date:   Thu Apr 29 21:30:13 2010 -0700

    trivial: device description string fixup
    
    If all of the 'vendor' is found in 'product', don't use the vendor
    string at all.

 configure.ac      |    3 +++
 src/utils/utils.c |   14 ++++++++++----
 2 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 5d5f8ec..35d14cf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,6 +22,9 @@ AC_PROG_CC
 AM_PROG_CC_C_O
 AC_PROG_INSTALL
 
+dnl Define _GNU_SOURCE for various things like strcasestr()
+AC_GNU_SOURCE
+
 dnl Initialize libtool
 LT_PREREQ([2.2.6])
 LT_INIT
diff --git a/src/utils/utils.c b/src/utils/utils.c
index ffb7905..227c382 100644
--- a/src/utils/utils.c
+++ b/src/utils/utils.c
@@ -17,9 +17,10 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2007 Red Hat, Inc.
+ * (C) Copyright 2007 - 2010 Red Hat, Inc.
  */
 
+#include <config.h>
 #include <string.h>
 #include <netinet/ether.h>
 #include <glib.h>
@@ -173,12 +174,17 @@ utils_get_device_description (NMDevice *device)
 
 	str = g_string_new_len (NULL, strlen (vendor) + strlen (product) + 1);
 
-	g_string_append (str, vendor);
-	g_free (vendor);
+	/* Another quick hack; if all of the fixed up vendor string
+	 * is found in product, ignore the vendor.
+	 */
+	if (!strcasestr (product, vendor)) {
+		g_string_append (str, vendor);
+		g_string_append_c (str, ' ');
+	}
 
-	g_string_append_c (str, ' ');
 	g_string_append (str, product);
 	g_free (product);
+	g_free (vendor);
 
 	description = str->str;
 	g_string_free (str, FALSE);



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