network-manager-applet r732 - in trunk: . src/utils
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: network-manager-applet r732 - in trunk: . src/utils
- Date: Wed, 28 May 2008 21:32:18 +0000 (UTC)
Author: dcbw
Date: Wed May 28 21:32:18 2008
New Revision: 732
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=732&view=rev
Log:
2008-05-28 Dan Williams <dcbw redhat com>
* src/utils/utils.c
- (utils_get_device_description): ignore words in the product string
too; add more ignored words
Modified:
trunk/ChangeLog
trunk/src/utils/utils.c
Modified: trunk/src/utils/utils.c
==============================================================================
--- trunk/src/utils/utils.c (original)
+++ trunk/src/utils/utils.c Wed May 28 21:32:18 2008
@@ -77,7 +77,7 @@
return result;
}
-static char * vnd_ignore[] = {
+static char * ignored_words[] = {
"Semiconductor",
"Components",
"Corporation",
@@ -87,54 +87,30 @@
"Inc.",
"Inc",
"Ltd.",
+ "Multiprotocol",
+ "MAC/baseband",
+ "processor",
NULL
};
-#define DESC_TAG "description"
-
-const char *
-utils_get_device_description (NMDevice *device)
+static char *
+fixup_desc_string (const char *desc)
{
- char *description = NULL;
- const char *dev_product;
- const char *dev_vendor;
- char *product = NULL;
- char *vendor = NULL;
- char *p;
- char **words;
- char **item;
+ char *p, *temp;
+ char **words, **item;
GString *str;
- g_return_val_if_fail (device != NULL, NULL);
-
- description = g_object_get_data (G_OBJECT (device), DESC_TAG);
- if (description)
- return description;
-
- dev_product = nm_device_get_product (device);
- dev_vendor = nm_device_get_vendor (device);
- if (!dev_product || !dev_vendor)
- return NULL;
-
- /* Replace stupid '_' with ' ' */
- p = product = g_strdup (dev_product);
- while (*p) {
- if (*p == '_')
- *p = ' ';
- p++;
- }
-
- p = vendor = g_strdup (dev_vendor);
+ p = temp = g_strdup (desc);
while (*p) {
if (*p == '_' || *p == ',')
*p = ' ';
p++;
}
- str = g_string_new_len (NULL, strlen (vendor) + strlen (product));
-
- /* In a futile attempt to shorten the vendor ID, ignore certain words */
- words = g_strsplit (vendor, " ", 0);
+ /* Attmept to shorted ID by ignoring certain words */
+ words = g_strsplit (temp, " ", 0);
+ str = g_string_new_len (NULL, strlen (temp));
+ g_free (temp);
for (item = words; *item; item++) {
int i = 0;
@@ -143,8 +119,8 @@
if (g_ascii_isspace (**item) || (**item == '\0'))
continue;
- while (vnd_ignore[i] && !ignore) {
- if (!strcmp (*item, vnd_ignore[i]))
+ while (ignored_words[i] && !ignore) {
+ if (!strcmp (*item, ignored_words[i]))
ignore = TRUE;
i++;
}
@@ -157,8 +133,47 @@
}
g_strfreev (words);
+ temp = str->str;
+ g_string_free (str, FALSE);
+
+ return temp;
+}
+
+#define DESC_TAG "description"
+
+const char *
+utils_get_device_description (NMDevice *device)
+{
+ char *description = NULL;
+ const char *dev_product;
+ const char *dev_vendor;
+ char *product = NULL;
+ char *vendor = NULL;
+ GString *str;
+
+ g_return_val_if_fail (device != NULL, NULL);
+
+ description = g_object_get_data (G_OBJECT (device), DESC_TAG);
+ if (description)
+ return description;
+
+ dev_product = nm_device_get_product (device);
+ dev_vendor = nm_device_get_vendor (device);
+ if (!dev_product || !dev_vendor)
+ return NULL;
+
+ product = fixup_desc_string (dev_product);
+ vendor = fixup_desc_string (dev_vendor);
+
+ str = g_string_new_len (NULL, strlen (vendor) + strlen (product) + 1);
+
+ g_string_append (str, vendor);
+ g_free (vendor);
+
g_string_append_c (str, ' ');
g_string_append (str, product);
+ g_free (product);
+
description = str->str;
g_string_free (str, FALSE);
@@ -166,8 +181,6 @@
"description", description,
(GDestroyNotify) g_free);
- g_free (product);
- g_free (vendor);
return description;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]