summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-05-20 16:25:21 -0500
committerDan Williams <dcbw@redhat.com>2014-06-06 13:43:45 -0500
commitb4c368692ddddbd8aca36625fd6a3a296689deff (patch)
tree6b11ba5b845d134afe63a5707f5ab667e8f57c69
parentc958540bcc53ca3a4acdcb50debcecbce917e167 (diff)
downloadNetworkManager-b4c368692ddddbd8aca36625fd6a3a296689deff.tar.gz
core: let NMDevice export itself
Saves some code and a memory allocation.
-rw-r--r--src/devices/nm-device.c11
-rw-r--r--src/devices/nm-device.h2
-rw-r--r--src/nm-manager.c8
3 files changed, 9 insertions, 12 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index b8244649f6..ae53f0a60f 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -453,16 +453,19 @@ device_has_capability (NMDevice *device, NMDeviceCapabilities caps)
/***********************************************************/
void
-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 *
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index bc9a52ec97..3015283371 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -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);
diff --git a/src/nm-manager.c b/src/nm-manager.c
index d3d6662c43..4fd8957f88 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -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. */