diff options
author | Tambet Ingo <tambet@gmail.com> | 2009-01-13 11:23:02 +0200 |
---|---|---|
committer | Tambet Ingo <tambet@gmail.com> | 2009-01-13 11:23:02 +0200 |
commit | 50d2a8b80c25f25e3327127d725277c70570cff3 (patch) | |
tree | dc3b78b7537db7217cc1e3cbae904c6874fbec53 /plugins/mm-plugin-hso.c | |
parent | 9804a216860e04c6e6f98b5bbced9213bf49aadb (diff) |
If none of the HSO serial device parents match none of the network device
parents, try to match "grandparents" as well.
Diffstat (limited to 'plugins/mm-plugin-hso.c')
-rw-r--r-- | plugins/mm-plugin-hso.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/plugins/mm-plugin-hso.c b/plugins/mm-plugin-hso.c index 7fa852ca..a2805832 100644 --- a/plugins/mm-plugin-hso.c +++ b/plugins/mm-plugin-hso.c @@ -140,6 +140,45 @@ get_netdev (LibHalContext *ctx, const char *udi) libhal_free_string (netdev_parent); } + + if (!netdev) { + /* Didn't find from netdev's parents. Try again with "grandparents" */ + char *serial_grandparent; + + serial_grandparent = libhal_device_get_property_string (ctx, serial_parent, "info.parent", NULL); + if (!serial_grandparent) + goto cleanup; + + for (i = 0; netdevs && !netdev && (i < num); i++) { + char *netdev_parent, *tmp; + + tmp = libhal_device_get_property_string (ctx, netdevs[i], "net.originating_device", NULL); + if (!tmp) + tmp = libhal_device_get_property_string (ctx, netdevs[i], "net.physical_device", NULL); + if (!tmp) + tmp = libhal_device_get_property_string (ctx, netdevs[i], "info.parent", NULL); + if (!tmp) + continue; + + netdev_parent = libhal_device_get_property_string (ctx, tmp, "info.parent", NULL); + libhal_free_string (tmp); + + if (netdev_parent) { + if (!strcmp (netdev_parent, serial_grandparent)) { + /* We found it */ + tmp = libhal_device_get_property_string (ctx, netdevs[i], "net.interface", NULL); + if (tmp) { + netdev = g_strdup (tmp); + libhal_free_string (tmp); + } + } + + libhal_free_string (netdev_parent); + } + } + } + + cleanup: libhal_free_string_array (netdevs); libhal_free_string (serial_parent); |