merge: branch 'lr/ugly-descriptions'

https://bugzilla.gnome.org/show_bug.cgi?id=791292
This commit is contained in:
Lubomir Rintel 2018-02-23 19:47:44 +01:00
commit 8b003e6d06
4 changed files with 2765 additions and 295 deletions

View file

@ -1297,222 +1297,6 @@ nm_device_get_available_connections (NMDevice *device)
return NM_DEVICE_GET_PRIVATE (device)->available_connections;
}
void
_nm_device_set_udev (NMDevice *device, struct udev *udev)
{
NMDevicePrivate *priv;
nm_assert (NM_IS_DEVICE (device));
nm_assert (udev);
priv = NM_DEVICE_GET_PRIVATE (device);
nm_assert (!priv->udev);
priv->udev = udev_ref (udev);
}
static char *
_get_udev_property (NMDevice *device,
const char *enc_prop, /* ID_XXX_ENC */
const char *db_prop) /* ID_XXX_FROM_DATABASE */
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
struct udev_device *udev_device, *tmpdev;
const char *ifname;
guint32 count = 0;
char *enc_value = NULL, *db_value = NULL;
if (!priv->udev)
return NULL;
ifname = nm_device_get_iface (device);
if (!ifname)
return NULL;
udev_device = udev_device_new_from_subsystem_sysname (priv->udev, "net", ifname);
if (!udev_device) {
udev_device = udev_device_new_from_subsystem_sysname (priv->udev, "tty", ifname);
if (!udev_device)
return NULL;
}
/* Walk up the chain of the device and its parents a few steps to grab
* vendor and device ID information off it.
*/
tmpdev = udev_device;
while ((count++ < 3) && tmpdev && !enc_value) {
if (!enc_value)
enc_value = nm_udev_utils_property_decode_cp (udev_device_get_property_value (tmpdev, enc_prop));
if (!db_value)
db_value = g_strdup (udev_device_get_property_value (tmpdev, db_prop));
tmpdev = udev_device_get_parent (tmpdev);
}
udev_device_unref (udev_device);
/* Prefer the encoded value which comes directly from the device
* over the hwdata database value.
*/
if (enc_value) {
g_free (db_value);
return enc_value;
}
return db_value;
}
static char *
_get_udev_property_utf8safe (NMDevice *device,
const char *enc_prop, /* ID_XXX_ENC */
const char *db_prop) /* ID_XXX_FROM_DATABASE */
{
return nm_utils_str_utf8safe_escape_take (_get_udev_property (device,
enc_prop,
db_prop),
NM_UTILS_STR_UTF8_SAFE_FLAG_ESCAPE_CTRL);
}
/**
* nm_device_get_product:
* @device: a #NMDevice
*
* Gets the product string of the #NMDevice.
*
* Returns: the product name of the device. This is the internal string used by the
* device, and must not be modified.
*
* The string is backslash escaped (C escaping) for invalid characters. The escaping
* can be reverted with g_strcompress(), however the result may not be valid UTF-8.
**/
const char *
nm_device_get_product (NMDevice *device)
{
NMDevicePrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
priv = NM_DEVICE_GET_PRIVATE (device);
if (!priv->product) {
priv->product = _get_udev_property_utf8safe (device, "ID_MODEL_ENC", "ID_MODEL_FROM_DATABASE");
/* Sometimes ID_PRODUCT_FROM_DATABASE is used? */
if (!priv->product)
priv->product = _get_udev_property_utf8safe (device, "ID_MODEL_ENC", "ID_PRODUCT_FROM_DATABASE");
if (!priv->product)
priv->product = g_strdup ("");
}
return priv->product;
}
/**
* nm_device_get_vendor:
* @device: a #NMDevice
*
* Gets the vendor string of the #NMDevice.
*
* Returns: the vendor name of the device. This is the internal string used by the
* device, and must not be modified.
*
* The string is backslash escaped (C escaping) for invalid characters. The escaping
* can be reverted with g_strcompress(), however the result may not be valid UTF-8.
**/
const char *
nm_device_get_vendor (NMDevice *device)
{
NMDevicePrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
priv = NM_DEVICE_GET_PRIVATE (device);
if (!priv->vendor)
priv->vendor = _get_udev_property_utf8safe (device, "ID_VENDOR_ENC", "ID_VENDOR_FROM_DATABASE");
if (!priv->vendor)
priv->vendor = g_strdup ("");
return priv->vendor;
}
static void
ensure_description (NMDevice *device)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
GParamSpec *name_prop;
gs_free char *short_product = NULL;
priv->short_vendor = nm_str_realloc (nm_utils_fixup_desc_string (nm_device_get_vendor (device)));
/* Grab device's preferred name, if any */
name_prop = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (device)), "name");
if (name_prop) {
g_object_get (device, "name", &priv->description, NULL);
if (priv->description && priv->description[0])
return;
g_clear_pointer (&priv->description, g_free);
}
if ( !priv->short_vendor
|| !(short_product = nm_utils_fixup_desc_string (nm_device_get_product (device)))) {
priv->description = g_strdup (nm_device_get_iface (device) ?: "");
return;
}
/* Another quick hack; if all of the fixed up vendor string
* is found in product, ignore the vendor.
*/
{
gs_free char *pdown = g_ascii_strdown (short_product, -1);
gs_free char *vdown = g_ascii_strdown (priv->short_vendor, -1);
if (!strstr (pdown, vdown))
priv->description = g_strconcat (priv->short_vendor, " ", short_product, NULL);
else
priv->description = g_steal_pointer (&short_product);
}
}
static const char *
get_short_vendor (NMDevice *device)
{
NMDevicePrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
priv = NM_DEVICE_GET_PRIVATE (device);
if (!priv->description)
ensure_description (device);
return priv->short_vendor;
}
/**
* nm_device_get_description:
* @device: an #NMDevice
*
* Gets a description of @device, based on its vendor and product names.
*
* Returns: a description of @device. If either the vendor or the
* product name is unknown, this returns the interface name.
*/
const char *
nm_device_get_description (NMDevice *device)
{
NMDevicePrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
priv = NM_DEVICE_GET_PRIVATE (device);
if (!priv->description)
ensure_description (device);
return priv->description;
}
static const char *
get_type_name (NMDevice *device)
{
@ -1643,6 +1427,224 @@ out:
return NULL;
}
void
_nm_device_set_udev (NMDevice *device, struct udev *udev)
{
NMDevicePrivate *priv;
nm_assert (NM_IS_DEVICE (device));
nm_assert (udev);
priv = NM_DEVICE_GET_PRIVATE (device);
nm_assert (!priv->udev);
priv->udev = udev_ref (udev);
}
static char *
_get_udev_property (NMDevice *device,
const char *enc_prop, /* ID_XXX_ENC */
const char *db_prop) /* ID_XXX_FROM_DATABASE */
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
struct udev_device *udev_device, *tmpdev;
const char *ifname;
guint32 count = 0;
char *enc_value = NULL, *db_value = NULL;
if (!priv->udev)
return NULL;
ifname = nm_device_get_iface (device);
if (!ifname)
return NULL;
udev_device = udev_device_new_from_subsystem_sysname (priv->udev, "net", ifname);
if (!udev_device) {
udev_device = udev_device_new_from_subsystem_sysname (priv->udev, "tty", ifname);
if (!udev_device)
return NULL;
}
/* Walk up the chain of the device and its parents a few steps to grab
* vendor and device ID information off it.
*/
tmpdev = udev_device;
while ((count++ < 3) && tmpdev && !enc_value) {
if (!enc_value)
enc_value = nm_udev_utils_property_decode_cp (udev_device_get_property_value (tmpdev, enc_prop));
if (!db_value)
db_value = g_strdup (udev_device_get_property_value (tmpdev, db_prop));
tmpdev = udev_device_get_parent (tmpdev);
}
udev_device_unref (udev_device);
/* Prefer the hwdata database value over what comes directly
* from the device. */
if (db_value) {
g_free (enc_value);
return db_value;
}
return enc_value;
}
static char *
_get_udev_property_utf8safe (NMDevice *device,
const char *enc_prop, /* ID_XXX_ENC */
const char *db_prop) /* ID_XXX_FROM_DATABASE */
{
return nm_utils_str_utf8safe_escape_take (_get_udev_property (device,
enc_prop,
db_prop),
NM_UTILS_STR_UTF8_SAFE_FLAG_ESCAPE_CTRL);
}
/**
* nm_device_get_product:
* @device: a #NMDevice
*
* Gets the product string of the #NMDevice.
*
* Returns: the product name of the device. This is the internal string used by the
* device, and must not be modified.
*
* The string is backslash escaped (C escaping) for invalid characters. The escaping
* can be reverted with g_strcompress(), however the result may not be valid UTF-8.
**/
const char *
nm_device_get_product (NMDevice *device)
{
NMDevicePrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
priv = NM_DEVICE_GET_PRIVATE (device);
if (!priv->product) {
priv->product = _get_udev_property_utf8safe (device, "ID_MODEL_ENC", "ID_MODEL_FROM_DATABASE");
/* Sometimes ID_PRODUCT_FROM_DATABASE is used? */
if (!priv->product)
priv->product = _get_udev_property_utf8safe (device, "ID_MODEL_ENC", "ID_PRODUCT_FROM_DATABASE");
if (!priv->product)
priv->product = g_strdup ("");
}
return priv->product;
}
/**
* nm_device_get_vendor:
* @device: a #NMDevice
*
* Gets the vendor string of the #NMDevice.
*
* Returns: the vendor name of the device. This is the internal string used by the
* device, and must not be modified.
*
* The string is backslash escaped (C escaping) for invalid characters. The escaping
* can be reverted with g_strcompress(), however the result may not be valid UTF-8.
**/
const char *
nm_device_get_vendor (NMDevice *device)
{
NMDevicePrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
priv = NM_DEVICE_GET_PRIVATE (device);
if (!priv->vendor)
priv->vendor = _get_udev_property_utf8safe (device, "ID_VENDOR_ENC", "ID_VENDOR_FROM_DATABASE");
if (!priv->vendor)
priv->vendor = g_strdup ("");
return priv->vendor;
}
static void
ensure_description (NMDevice *device)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
GParamSpec *name_prop;
gs_free char *short_product = NULL;
priv->short_vendor = nm_str_realloc (nm_utils_fixup_vendor_string (nm_device_get_vendor (device)));
/* Grab device's preferred name, if any */
name_prop = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (device)), "name");
if (name_prop) {
g_object_get (device, "name", &priv->description, NULL);
if (priv->description && priv->description[0])
return;
g_clear_pointer (&priv->description, g_free);
}
if (!priv->short_vendor) {
priv->description = g_strdup (nm_device_get_iface (device) ?: "");
return;
}
short_product = nm_utils_fixup_product_string (nm_device_get_product (device));
if (short_product == NULL)
short_product = g_strdup (get_type_name (device));
/* Another quick hack; if all of the fixed up vendor string
* is found in product, ignore the vendor.
*/
{
gs_free char *pdown = g_ascii_strdown (short_product, -1);
gs_free char *vdown = g_ascii_strdown (priv->short_vendor, -1);
if (!strstr (pdown, vdown))
priv->description = g_strconcat (priv->short_vendor, " ", short_product, NULL);
else
priv->description = g_steal_pointer (&short_product);
}
}
static const char *
get_short_vendor (NMDevice *device)
{
NMDevicePrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
priv = NM_DEVICE_GET_PRIVATE (device);
if (!priv->description)
ensure_description (device);
return priv->short_vendor;
}
/**
* nm_device_get_description:
* @device: an #NMDevice
*
* Gets a description of @device, based on its vendor and product names.
*
* Returns: a description of @device. If either the vendor or the
* product name is unknown, this returns the interface name.
*/
const char *
nm_device_get_description (NMDevice *device)
{
NMDevicePrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
priv = NM_DEVICE_GET_PRIVATE (device);
if (!priv->description)
ensure_description (device);
return priv->description;
}
static gboolean
find_duplicates (char **names,
gboolean *duplicates,

View file

@ -16,7 +16,7 @@
* Boston, MA 02110-1301 USA.
*
* Copyright 2007 - 2008 Novell, Inc.
* Copyright 2007 - 2017 Red Hat, Inc.
* Copyright 2007 - 2018 Red Hat, Inc.
*/
#include "nm-default.h"
@ -25,52 +25,14 @@
/*****************************************************************************/
char *
nm_utils_fixup_desc_string (const char *desc)
static char *
_fixup_string (const char *desc,
const char *const *ignored_phrases,
const char *const *ignored_words,
gboolean square_brackets_sensible)
{
static const char *const IGNORED_PHRASES[] = {
"Multiprotocol MAC/baseband processor",
"Wireless LAN Controller",
"Wireless LAN Adapter",
"Wireless Adapter",
"Network Connection",
"Wireless Cardbus Adapter",
"Wireless CardBus Adapter",
"54 Mbps Wireless PC Card",
"Wireless PC Card",
"Wireless PC",
"PC Card with XJACK(r) Antenna",
"Wireless cardbus",
"Wireless LAN PC Card",
"Technology Group Ltd.",
"Communication S.p.A.",
"Business Mobile Networks BV",
"Mobile Broadband Minicard Composite Device",
"Mobile Communications AB",
"(PC-Suite Mode)",
};
static const char *const IGNORED_WORDS[] = {
"Semiconductor",
"Components",
"Corporation",
"Communications",
"Company",
"Corp.",
"Corp",
"Co.",
"Inc.",
"Inc",
"Incorporated",
"Ltd.",
"Limited.",
"Intel?",
"chipset",
"adapter",
"[hex]",
"NDIS",
"Module",
};
char *desc_full;
gboolean in_paren = FALSE;
char *p, *q;
int i;
@ -88,18 +50,23 @@ nm_utils_fixup_desc_string (const char *desc)
p = q + 1;
}
/* replace '_', ',', and ASCII controll characters with space. */
/* replace '_', ',', ASCII control characters and parentheses, with space. */
for (p = desc_full; p[0]; p++) {
if (*p == '(')
in_paren = TRUE;
if ( NM_IN_SET (*p, '_', ',')
|| *p < ' ')
|| *p < ' '
|| in_paren)
*p = ' ';
if (*p == ')')
in_paren = FALSE;
}
/* Attempt to shorten ID by ignoring certain phrases */
for (i = 0; i < G_N_ELEMENTS (IGNORED_PHRASES); i++) {
p = strstr (desc_full, IGNORED_PHRASES[i]);
for (i = 0; ignored_phrases[i]; i++) {
p = strstr (desc_full, ignored_phrases[i]);
if (p) {
const char *eow = &p[strlen (IGNORED_PHRASES[i])];
const char *eow = &p[strlen (ignored_phrases[i])];
/* require that the phrase is delimited by space, or
* at the beginning or end of the description. */
@ -112,7 +79,7 @@ nm_utils_fixup_desc_string (const char *desc)
/* Attempt to shorten ID by ignoring certain individual words.
* - word-split the description at spaces
* - coalesce multiple spaces
* - skip over IGNORED_WORDS */
* - skip over ignored_words */
p = desc_full;
q = desc_full;
for (;;) {
@ -131,9 +98,7 @@ nm_utils_fixup_desc_string (const char *desc)
if (eow)
*eow = '\0';
if (nm_utils_strv_find_first ((char **) IGNORED_WORDS,
G_N_ELEMENTS (IGNORED_WORDS),
p) >= 0)
if (nm_utils_strv_find_first ((char **) ignored_words, -1, p) >= 0)
goto next;
l = strlen (p);
@ -152,12 +117,448 @@ next:
*q++ = '\0';
p = strchr (desc_full, '[');
if (p == desc_full) {
/* All we're left with is in square brackets.
* Always prefer that to a blank string.*/
square_brackets_sensible = TRUE;
}
if (square_brackets_sensible) {
/* If there's a [<string>] that survived the substitution, then the string
* is a short form that is generally preferrable. */
q = strchr (desc_full, ']');
if (p && q > p) {
p++;
memmove (desc_full, p, q - p);
desc_full[q - p] = '\0';
}
} else {
/* [<string>] sometimes contains the preferred human-readable name, but
* mostly it's utterly useless. Sigh. Drop it. */
if (p) {
if (p > desc_full && p[-1] == ' ')
p--;
*p = '\0';
}
}
if (!desc_full[0]) {
g_free (desc_full);
return NULL;
}
return desc_full;
}
char *
nm_utils_fixup_vendor_string (const char *desc)
{
static const char *const IGNORED_PHRASES[] = {
"Access Systems",
"Business Mobile Networks BV",
"Communications & Multimedia",
"Company of Japan",
"Computer Co.",
"Computer Corp.",
"Computer Corporation",
"Computer Inc.",
"Computer, Inc.",
"Information and Communication Products",
"Macao Commercial Offshore",
"Mobile Phones",
"(M) Son",
"Multimedia Internet Technology",
"Technology Group Ltd.",
"Wireless Networks",
"Wireless Solutions",
NULL,
};
static const char *const IGNORED_WORDS[] = {
"AB",
"AG",
"A/S",
"ASA",
"B.V.",
"Chips",
"Co.",
"Co",
"Communications",
"Components",
"Computers",
"Computertechnik",
"corp.",
"Corp.",
"Corp",
"Corporation",
"Design",
"Electronics",
"Enterprise",
"Enterprises",
"Europe",
"GmbH",
"Hardware",
"[hex]",
"Holdings",
"Inc.",
"Inc",
"INC.",
"Incorporated",
"Instruments",
"International",
"Intl.",
"Labs",
"Limited.",
"Limited",
"Ltd.",
"Ltd",
"Microelectronics",
"Microsystems",
"MSM",
"Multimedia",
"Networks",
"Norway",
"Optical",
"PCS",
"Semiconductor",
"Systems",
"Systemtechnik",
"Techcenter",
"Technik",
"Technologies",
"Technology",
"TECHNOLOGY",
"Telephonics",
"USA",
"WCDMA",
NULL,
};
char *desc_full;
char *p;
desc_full = _fixup_string (desc, IGNORED_PHRASES, IGNORED_WORDS, TRUE);
if (!desc_full)
return NULL;
/* Chop off everything after a slash. */
for (p = desc_full; *p; p++) {
if ((p[0] == ' ' && p[1] == '/') || p[0] == '/') {
p[0] = '\0';
break;
}
}
nm_assert (g_utf8_validate (desc_full, -1, NULL));
return desc_full;
}
char *
nm_utils_fixup_product_string (const char *desc)
{
static const char *const IGNORED_PHRASES[] = {
"100/10 MBit",
"10/100 Mbps",
"1.0 GbE",
"10 GbE",
"10 Gigabit",
"10 Mbps",
"1/10 Gigabit",
"150 Mbps",
"2.5 GbE",
"54 Mbps",
"Attached Port",
"+ BT",
"\"CDC Subset\"",
"CE Media Processor",
"Controller Area Network",
"Converged Network",
"DEC-Tulip compatible",
"Dish Adapter",
"Double 108 Mbps",
"Dual Band",
"Dual Port",
"Embedded UTP",
"Ethernet Connection",
"Ethernet Pro 100",
"Express Module",
"Fabric Adapter",
"Fast Ethernet",
"for 10GBASE-T" ,
"for 10GbE backplane" ,
"for 10GbE QSFP+" ,
"for 10GbE SFP+" ,
"for 1GbE",
"for 20GbE backplane" ,
"for 25GbE backplane" ,
"for 25GbE SFP28" ,
"for 40GbE backplane" ,
"for 40GbE QSFP+" ,
"G Adapter",
"Gigabit Desktop Network",
"Gigabit Ethernet",
"Gigabit or",
"Host Interface",
"Host Virtual Interface",
"IEEE 802.11a/b/g",
"IEEE 802.11g",
"IEEE 802.11G",
"IEEE 802.11n",
"MAC + PHY",
"Mini Card",
"Mini Wireless",
"multicore SoC",
"Multi Function",
"N Draft 11n Wireless",
"Network Connection",
"Network Everywhere",
"N Wireless",
"N+ Wireless",
"OCT To Fast Ethernet Converter",
"PC Card",
"PCI Express",
"Platform Controller Hub",
"Plus Bluetooth",
"Quad Gigabit",
"rev 1",
"rev 17",
"rev 2",
"rev A",
"rev B",
"rev F",
"TO Ethernet",
"Turbo Wireless Adapter",
"Unified Wire",
"USB 1.1",
"USB 2.0",
"Virtual media for",
"WiFi Link",
"+ WiMAX",
"WiMAX/WiFi Link",
"Wireless G",
"Wireless G+",
"Wireless Lan",
"Wireless Mini adapter",
"Wireless Mini Adapter",
"Wireless N",
"with 1000-BASE-T interface",
"with CX4 copper interface",
"with Range Amplifier",
"with SR-XFP optical interface",
"w/ Upgradable Antenna",
NULL,
};
static const char *const IGNORED_WORDS[] = {
"1000BaseSX",
"1000BASE-T",
"1000Base-ZX",
"100/10M",
"100baseFx",
"100Base-MII",
"100Base-T",
"100BaseT4",
"100Base-TX",
"100BaseTX",
"100GbE",
"100Mbps",
"100MBps",
"10/100",
"10/100/1000",
"10/100/1000Base-T",
"10/100/1000BASE-T",
"10/100BaseT",
"10/100baseTX",
"10/100BaseTX",
"10/100/BNC",
"10/100M",
"10/20-Gigabit",
"10/25/40/50GbE",
"10/40G",
"10base-FL",
"10BaseT",
"10BASE-T",
"10G",
"10Gb",
"10Gb/25Gb",
"10Gb/25Gb/40Gb/50Gb",
"10Gbase-T",
"10GBase-T",
"10GBASE-T",
"10GbE",
"10Gbps",
"10-Giga",
"10-Gigabit",
"10mbps",
"10Mbps",
"1/10GbE",
"1/10-Gigabit",
"11b/g/n",
"11g",
"150Mbps",
"16Gbps/10Gbps",
"1GbE",
"1x2:2",
"20GbE",
"25Gb",
"25GbE",
"2-Port",
"2x3:3",
"3G",
"3G/4G",
"3x3:3",
"40GbE",
"4G",
"54g",
"54M",
"54Mbps",
"56k",
"5G",
"802.11",
"802.11a/b/g",
"802.11abg",
"802.11a/b/g/n",
"802.11abgn",
"802.11ac",
"802.11ad",
"802.11a/g",
"802.11b",
"802.11b/g",
"802.11bg",
"802.11b/g/n",
"802.11bgn",
"802.11b/g/n-draft",
"802.11g",
"802.11n",
"802.11N",
"802.11n/b/g",
"802.11ng",
"802AIN",
"802UIG-1",
"adapter",
"Adapter",
"adaptor",
"ADSL",
"Basic",
"CAN-Bus",
"card",
"Card",
"Cardbus",
"CardBus",
"CDMA",
"CNA",
"Composite",
"controller",
"Controller",
"Copper",
"DB",
"Desktop",
"device",
"Device",
"dongle",
"driver",
"Dual-band",
"Dual-Protocol",
"EISA",
"Enhanced",
"ethernet.",
"ethernet",
"Ethernet",
"Ethernet/RNDIS",
"ExpressModule",
"family",
"Family",
"Fast/Gigabit",
"Fiber",
"gigabit",
"Gigabit",
"G-NIC",
"Hi-Gain",
"Hi-Speed",
"HSDPA",
"HSUPA",
"integrated",
"Integrated",
"interface",
"LAN",
"LAN+Winmodem",
"Laptop",
"LTE",
"LTE/UMTS/GSM",
"MAC",
"Micro",
"Mini-Card",
"Mini-USB",
"misprogrammed",
"modem",
"Modem",
"Modem/Networkcard",
"Module",
"Multimode",
"Multithreaded",
"Name:",
"net",
"network",
"Network",
"n/g/b",
"NIC",
"Notebook",
"OEM",
"PCI",
"PCI64",
"PCIe",
"PCI-E",
"PCI-Express",
"PCI-X",
"PCMCIA",
"PDA",
"PnP",
"RDMA",
"RJ-45",
"Series",
"Server",
"SoC",
"Switch",
"Technologies",
"TOE",
"USB",
"USB2.0",
"USB/Ethernet",
"UTP",
"UTP/Coax",
"v1",
"v1.1",
"v2",
"V2.0",
"v3",
"v4",
"wifi",
"Wi-Fi",
"WiFi",
"wireless",
"Wireless",
"Wireless-150N",
"Wireless-300N",
"Wireless-G",
"Wireless-N",
"WLAN",
NULL,
};
char *desc_full;
char *p;
desc_full = _fixup_string (desc, IGNORED_PHRASES, IGNORED_WORDS, FALSE);
if (!desc_full)
return NULL;
/* Chop off everything after a '-'. */
for (p = desc_full; *p; p++) {
if (p[0] == ' ' && p[1] == '-' && p[2] == ' ') {
p[0] = '\0';
break;
}
}
nm_assert (g_utf8_validate (desc_full, -1, NULL));
return desc_full;
}

View file

@ -15,7 +15,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Copyright 2017 Red Hat, Inc.
* Copyright 2017, 2018 Red Hat, Inc.
*/
#ifndef __NM_LIBNM_UTILS_H__
@ -25,6 +25,7 @@
#error Cannot use this header.
#endif
char *nm_utils_fixup_desc_string (const char *desc);
char *nm_utils_fixup_vendor_string (const char *desc);
char *nm_utils_fixup_product_string (const char *desc);
#endif /* __NM_LIBNM_UTILS_H__ */

File diff suppressed because it is too large Load diff