Commit b4c36869 authored by Dan Williams's avatar Dan Williams

core: let NMDevice export itself

Saves some code and a memory allocation.
parent c958540b
......@@ -453,16 +453,19 @@ device_has_capability (NMDevice *device, NMDeviceCapabilities caps)
nm_device_set_path (NMDevice *self, const char *path)
nm_device_dbus_export (NMDevice *device)
static guint32 devcount = 0;
NMDevicePrivate *priv;
g_return_if_fail (self != NULL);
g_return_if_fail (NM_IS_DEVICE (device));
priv = NM_DEVICE_GET_PRIVATE (self);
priv = NM_DEVICE_GET_PRIVATE (device);
g_return_if_fail (priv->path == NULL);
priv->path = g_strdup (path);
priv->path = g_strdup_printf ("/org/freedesktop/NetworkManager/Devices/%d", devcount++);
nm_log_info (LOGD_DEVICE, "(%s): exported as %s", priv->iface, priv->path);
nm_dbus_manager_register_object (nm_dbus_manager_get (), priv->path, device);
const char *
......@@ -218,7 +218,7 @@ typedef void (*NMDeviceAuthRequestFunc) (NMDevice *device,
GType nm_device_get_type (void);
const char * nm_device_get_path (NMDevice *dev);
void nm_device_set_path (NMDevice *dev, const char *path);
void nm_device_dbus_export (NMDevice *device);
const char * nm_device_get_udi (NMDevice *dev);
const char * nm_device_get_iface (NMDevice *dev);
......@@ -1682,8 +1682,6 @@ add_device (NMManager *self, NMDevice *device, gboolean generate_con)
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
const char *iface, *driver, *type_desc;
char *path;
static guint32 devcount = 0;
const GSList *unmanaged_specs;
gboolean user_unmanaged, sleeping;
NMConnection *connection = NULL;
......@@ -1760,11 +1758,7 @@ add_device (NMManager *self, NMDevice *device, gboolean generate_con)
sleeping = manager_sleeping (self);
nm_device_set_initial_unmanaged_flag (device, NM_UNMANAGED_INTERNAL, sleeping);
path = g_strdup_printf ("/org/freedesktop/NetworkManager/Devices/%d", devcount++);
nm_device_set_path (device, path);
nm_dbus_manager_register_object (priv->dbus_mgr, path, device);
nm_log_info (LOGD_CORE, "(%s): exported as %s", iface, path);
g_free (path);
nm_device_dbus_export (device);
/* Don't generate a connection e.g. for devices NM just created, or
* for the loopback, or when we're sleeping. */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment