2008-03-07 Dan Williams <dcbw@redhat.com>

* src/nm-hal-manager.c
		- (nm_get_device_driver_name): use net.originating_device first, fall
			back to physical device.  HAL has deprecated physical_device.

	* libnm-glib/nm-device.c
		- (get_product_and_vendor): use net.originating_device first, fall
			back to physical device.  HAL has deprecated physical_device.
		- (nm_device_update_description): s/physical_device_udi/orig_dev_udi



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3386 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams
2008-03-07 17:13:38 +00:00
parent 07ec50353e
commit 593520f9a8
3 changed files with 62 additions and 22 deletions

View File

@@ -1,3 +1,14 @@
2008-03-07 Dan Williams <dcbw@redhat.com>
* src/nm-hal-manager.c
- (nm_get_device_driver_name): use net.originating_device first, fall
back to physical device. HAL has deprecated physical_device.
* libnm-glib/nm-device.c
- (get_product_and_vendor): use net.originating_device first, fall
back to physical device. HAL has deprecated physical_device.
- (nm_device_update_description): s/physical_device_udi/orig_dev_udi
2008-03-07 Dan Williams <dcbw@redhat.com> 2008-03-07 Dan Williams <dcbw@redhat.com>
* src/nm-netlink.c * src/nm-netlink.c

View File

@@ -273,7 +273,7 @@ nm_device_get_state (NMDevice *device)
static char * static char *
get_product_and_vendor (DBusGConnection *connection, get_product_and_vendor (DBusGConnection *connection,
const char *udi, const char *udi,
gboolean want_physdev, gboolean want_origdev,
gboolean warn, gboolean warn,
char **product, char **product,
char **vendor) char **vendor)
@@ -313,14 +313,38 @@ get_product_and_vendor (DBusGConnection *connection,
err = NULL; err = NULL;
} }
if (!dbus_g_proxy_call (proxy, "GetPropertyString", &err, if (want_origdev) {
G_TYPE_STRING, want_physdev ? "net.physical_device" : "info.parent", dbus_g_proxy_call (proxy, "GetPropertyString", NULL,
G_TYPE_INVALID, G_TYPE_STRING, "net.originating_device",
G_TYPE_STRING, &parent, G_TYPE_INVALID,
G_TYPE_INVALID)) { G_TYPE_STRING, &parent,
g_warning ("Error getting physical device info from HAL: %s", err->message); G_TYPE_INVALID);
g_error_free (err);
} if (!parent) {
/* Older HAL uses 'physical_device' */
dbus_g_proxy_call (proxy, "GetPropertyString", &err,
G_TYPE_STRING, "net.physical_device",
G_TYPE_INVALID,
G_TYPE_STRING, &parent,
G_TYPE_INVALID);
}
if (err || !parent) {
g_warning ("Error getting originating device info from HAL: %s",
err ? err->message : "unknown error");
if (err)
g_error_free (err);
}
} else {
if (!dbus_g_proxy_call (proxy, "GetPropertyString", &err,
G_TYPE_STRING, "info.parent",
G_TYPE_INVALID,
G_TYPE_STRING, &parent,
G_TYPE_INVALID)) {
g_warning ("Error getting parent device info from HAL: %s", err->message);
g_error_free (err);
}
}
if (parent && tmp_product && tmp_vendor) { if (parent && tmp_product && tmp_vendor) {
*product = tmp_product; *product = tmp_product;
@@ -340,7 +364,7 @@ nm_device_update_description (NMDevice *device)
NMDevicePrivate *priv; NMDevicePrivate *priv;
DBusGConnection *connection; DBusGConnection *connection;
char *udi; char *udi;
char *physical_device_udi = NULL; char *orig_dev_udi = NULL;
char *pd_parent_udi = NULL; char *pd_parent_udi = NULL;
g_return_if_fail (NM_IS_DEVICE (device)); g_return_if_fail (NM_IS_DEVICE (device));
@@ -354,9 +378,9 @@ nm_device_update_description (NMDevice *device)
connection = nm_object_get_connection (NM_OBJECT (device)); connection = nm_object_get_connection (NM_OBJECT (device));
g_return_if_fail (connection != NULL); g_return_if_fail (connection != NULL);
/* First, get the physical device info */ /* First, get the originating device info */
udi = nm_device_get_udi (device); udi = nm_device_get_udi (device);
physical_device_udi = get_product_and_vendor (connection, udi, TRUE, FALSE, &priv->product, &priv->vendor); orig_dev_udi = get_product_and_vendor (connection, udi, TRUE, FALSE, &priv->product, &priv->vendor);
g_free (udi); g_free (udi);
/* Ignore product and vendor for the Network Interface */ /* Ignore product and vendor for the Network Interface */
@@ -367,17 +391,17 @@ nm_device_update_description (NMDevice *device)
priv->vendor = NULL; priv->vendor = NULL;
} }
/* Get product and vendor off the physical device if possible */ /* Get product and vendor off the originating device if possible */
pd_parent_udi = get_product_and_vendor (connection, pd_parent_udi = get_product_and_vendor (connection,
physical_device_udi, orig_dev_udi,
FALSE, FALSE,
FALSE, FALSE,
&priv->product, &priv->product,
&priv->vendor); &priv->vendor);
g_free (physical_device_udi); g_free (orig_dev_udi);
/* If one of the product/vendor isn't found on the physical device, try the /* If one of the product/vendor isn't found on the originating device, try the
* parent of the physical device. * parent of the originating device.
*/ */
if (!priv->product || !priv->vendor) { if (!priv->product || !priv->vendor) {
char *ignore; char *ignore;

View File

@@ -68,16 +68,21 @@ get_creator (NMHalManager *manager, const char *udi)
static char * static char *
nm_get_device_driver_name (LibHalContext *ctx, const char *udi) nm_get_device_driver_name (LibHalContext *ctx, const char *udi)
{ {
char *physdev_udi; char *origdev_udi;
char *driver_name = NULL; char *driver_name = NULL;
physdev_udi = libhal_device_get_property_string (ctx, udi, "net.physical_device", NULL); origdev_udi = libhal_device_get_property_string (ctx, udi, "net.originating_device", NULL);
if (physdev_udi && libhal_device_property_exists (ctx, physdev_udi, "info.linux.driver", NULL)) { if (!origdev_udi) {
char *drv = libhal_device_get_property_string (ctx, physdev_udi, "info.linux.driver", NULL); /* Older HAL uses 'physical_device' */
origdev_udi = libhal_device_get_property_string (ctx, udi, "net.physical_device", NULL);
}
if (origdev_udi && libhal_device_property_exists (ctx, origdev_udi, "info.linux.driver", NULL)) {
char *drv = libhal_device_get_property_string (ctx, origdev_udi, "info.linux.driver", NULL);
driver_name = g_strdup (drv); driver_name = g_strdup (drv);
libhal_free_string (drv); libhal_free_string (drv);
} }
libhal_free_string (physdev_udi); libhal_free_string (origdev_udi);
return driver_name; return driver_name;
} }