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



commit 39871418092f2cd7f269ca44a7dcbd33ec386803
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 d3d0c20..da0fa97 100644
--- a/configure.ac
+++ b/configure.ac
@@ -16,6 +16,9 @@ AM_PROG_CC_C_O
 AC_PROG_INSTALL
 AC_PROG_LIBTOOL
 
+dnl Define _GNU_SOURCE for various things like strcasestr()
+AC_GNU_SOURCE
+
 AC_PATH_PROG(GCONFTOOL, gconftool-2)
 AM_GCONF_SOURCE_2
 
diff --git a/src/utils/utils.c b/src/utils/utils.c
index e6af7c4..f75cd06 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>
@@ -171,12 +172,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]