summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-10-06 11:21:54 -0500
committerDan Williams <dcbw@redhat.com>2014-12-11 10:21:39 -0600
commitab4fd52cb0ab5faa71bc8c74369fe52f527d9486 (patch)
tree270cec6603fdcdf44e8c328eaeeb7388cff3489d
parentfb9155de443d2bc2c35aa140dd3baa38b2e009f0 (diff)
downloadNetworkManager-ab4fd52cb0ab5faa71bc8c74369fe52f527d9486.tar.gz
api/manager: add GetAllDevices() method and AllDevices property
Returns both realized and un-realized devices.
-rw-r--r--introspection/nm-manager.xml34
-rw-r--r--src/nm-manager.c35
-rw-r--r--src/nm-manager.h1
3 files changed, 67 insertions, 3 deletions
diff --git a/introspection/nm-manager.xml b/introspection/nm-manager.xml
index a9bb6dcf14..0905d034fb 100644
--- a/introspection/nm-manager.xml
+++ b/introspection/nm-manager.xml
@@ -6,12 +6,29 @@
<method name="GetDevices">
<tp:docstring>
- Get the list of network devices.
+ Get the list of realized network devices.
</tp:docstring>
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_get_devices"/>
<arg name="devices" type="ao" direction="out">
<tp:docstring>
- List of object paths of network devices known to the system.
+ List of object paths of realized network devices known to the system.
+ Realized devices are those which have backing resources (eg from the
+ kernel or a management daemon like ModemManager, teamd, etc).
+ </tp:docstring>
+ </arg>
+ </method>
+
+ <method name="GetAllDevices">
+ <tp:docstring>
+ Get the list of all network devices.
+ </tp:docstring>
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_get_all_devices"/>
+ <arg name="devices" type="ao" direction="out">
+ <tp:docstring>
+ List of object paths of realized and un-realized network devices
+ known to the system. Unrealized devices are software devices which
+ do not yet have backing resources, but for which backing resources
+ can be created if the device is activated.
</tp:docstring>
</arg>
</method>
@@ -263,7 +280,18 @@
<property name="Devices" type="ao" access="read">
<tp:docstring>
- The list of network devices/interfaces NetworkManager knows about.
+ The list of realized network devices. Realized devices are those which
+ have backing resources (eg from the kernel or a management daemon like
+ ModemManager, teamd, etc).
+ </tp:docstring>
+ </property>
+
+ <property name="AllDevices" type="ao" access="read">
+ <tp:docstring>
+ The list of both realized and un-realized network devices. Un-realized
+ devices are software devices which do not yet have backing resources,
+ but for which backing resources can be created if the device is
+ activated.
</tp:docstring>
</property>
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 9f005631f3..a2ee45da3f 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -66,6 +66,10 @@ static gboolean impl_manager_get_devices (NMManager *manager,
GPtrArray **devices,
GError **err);
+static gboolean impl_manager_get_all_devices (NMManager *manager,
+ GPtrArray **devices,
+ GError **err);
+
static gboolean impl_manager_get_device_by_ip_iface (NMManager *self,
const char *iface,
char **out_object_path,
@@ -234,6 +238,7 @@ enum {
PROP_PRIMARY_CONNECTION_TYPE,
PROP_ACTIVATING_CONNECTION,
PROP_DEVICES,
+ PROP_ALL_DEVICES,
/* Not exported */
PROP_HOSTNAME,
@@ -1965,6 +1970,20 @@ impl_manager_get_devices (NMManager *manager, GPtrArray **devices, GError **err)
}
static gboolean
+impl_manager_get_all_devices (NMManager *manager, GPtrArray **devices, GError **err)
+{
+ NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
+ GSList *iter;
+
+ *devices = g_ptr_array_sized_new (g_slist_length (priv->devices));
+
+ for (iter = priv->devices; iter; iter = iter->next)
+ g_ptr_array_add (*devices, g_strdup (nm_device_get_path (NM_DEVICE (iter->data))));
+
+ return TRUE;
+}
+
+static gboolean
impl_manager_get_device_by_ip_iface (NMManager *self,
const char *iface,
char **out_object_path,
@@ -4695,6 +4714,15 @@ get_property (GObject *object, guint prop_id,
}
g_value_take_boxed (value, array);
break;
+ case PROP_ALL_DEVICES:
+ array = g_ptr_array_sized_new (10);
+ for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
+ path = nm_device_get_path (NM_DEVICE (iter->data));
+ if (path)
+ g_ptr_array_add (array, g_strdup (path));
+ }
+ g_value_take_boxed (value, array);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -4964,6 +4992,13 @@ nm_manager_class_init (NMManagerClass *manager_class)
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property
+ (object_class, PROP_ALL_DEVICES,
+ g_param_spec_boxed (NM_MANAGER_ALL_DEVICES, "", "",
+ DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
/* signals */
signals[DEVICE_ADDED] =
g_signal_new ("device-added",
diff --git a/src/nm-manager.h b/src/nm-manager.h
index 3b00e8053a..3ba0023812 100644
--- a/src/nm-manager.h
+++ b/src/nm-manager.h
@@ -51,6 +51,7 @@
#define NM_MANAGER_PRIMARY_CONNECTION_TYPE "primary-connection-type"
#define NM_MANAGER_ACTIVATING_CONNECTION "activating-connection"
#define NM_MANAGER_DEVICES "devices"
+#define NM_MANAGER_ALL_DEVICES "all-devices"
/* Not exported */
#define NM_MANAGER_HOSTNAME "hostname"