mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-09-06 00:55:56 +00:00
api/core: add Devices property to the Manager
This commit is contained in:
parent
b69e7c451e
commit
a59ccc4cbb
|
@ -275,6 +275,12 @@
|
|||
<arg name="state" type="u" direction="out" tp:type="NM_STATE"/>
|
||||
</method>
|
||||
|
||||
<property name="Devices" type="ao" access="read">
|
||||
<tp:docstring>
|
||||
The list of network devices/interfaces NetworkManager knows about.
|
||||
</tp:docstring>
|
||||
</property>
|
||||
|
||||
<property name="NetworkingEnabled" type="b" access="read">
|
||||
<tp:docstring>
|
||||
Indicates if overall networking is currently enabled or not. See the
|
||||
|
|
|
@ -289,6 +289,7 @@ enum {
|
|||
PROP_CONNECTIVITY,
|
||||
PROP_PRIMARY_CONNECTION,
|
||||
PROP_ACTIVATING_CONNECTION,
|
||||
PROP_DEVICES,
|
||||
|
||||
/* Not exported */
|
||||
PROP_HOSTNAME,
|
||||
|
@ -818,6 +819,7 @@ remove_device (NMManager *manager, NMDevice *device, gboolean quitting)
|
|||
|
||||
nm_settings_device_removed (priv->settings, device, quitting);
|
||||
g_signal_emit (manager, signals[DEVICE_REMOVED], 0, device);
|
||||
g_object_notify (G_OBJECT (manager), NM_MANAGER_DEVICES);
|
||||
g_object_unref (device);
|
||||
|
||||
priv->devices = g_slist_remove (priv->devices, device);
|
||||
|
@ -1912,6 +1914,7 @@ add_device (NMManager *self, NMDevice *device, gboolean generate_con)
|
|||
|
||||
nm_settings_device_added (priv->settings, device);
|
||||
g_signal_emit (self, signals[DEVICE_ADDED], 0, device);
|
||||
g_object_notify (G_OBJECT (self), NM_MANAGER_DEVICES);
|
||||
|
||||
/* New devices might be master interfaces for virtual interfaces; so we may
|
||||
* need to create new virtual interfaces now.
|
||||
|
@ -4840,7 +4843,7 @@ get_property (GObject *object, guint prop_id,
|
|||
NMManager *self = NM_MANAGER (object);
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
||||
GSList *iter;
|
||||
GPtrArray *active;
|
||||
GPtrArray *array;
|
||||
const char *path;
|
||||
|
||||
switch (prop_id) {
|
||||
|
@ -4876,13 +4879,13 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_boolean (value, priv->radio_states[RFKILL_TYPE_WIMAX].hw_enabled);
|
||||
break;
|
||||
case PROP_ACTIVE_CONNECTIONS:
|
||||
active = g_ptr_array_sized_new (3);
|
||||
array = g_ptr_array_sized_new (3);
|
||||
for (iter = priv->active_connections; iter; iter = g_slist_next (iter)) {
|
||||
path = nm_active_connection_get_path (NM_ACTIVE_CONNECTION (iter->data));
|
||||
if (path)
|
||||
g_ptr_array_add (active, g_strdup (path));
|
||||
g_ptr_array_add (array, g_strdup (path));
|
||||
}
|
||||
g_value_take_boxed (value, active);
|
||||
g_value_take_boxed (value, array);
|
||||
break;
|
||||
case PROP_CONNECTIVITY:
|
||||
g_value_set_uint (value, nm_connectivity_get_state (priv->connectivity));
|
||||
|
@ -4901,6 +4904,15 @@ get_property (GObject *object, guint prop_id,
|
|||
case PROP_SLEEPING:
|
||||
g_value_set_boolean (value, priv->sleeping);
|
||||
break;
|
||||
case PROP_DEVICES:
|
||||
array = g_ptr_array_sized_new (5);
|
||||
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;
|
||||
|
@ -5201,6 +5213,14 @@ nm_manager_class_init (NMManagerClass *manager_class)
|
|||
FALSE,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_DEVICES,
|
||||
g_param_spec_boxed (NM_MANAGER_DEVICES,
|
||||
"Devices",
|
||||
"Devices",
|
||||
DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
/* signals */
|
||||
signals[DEVICE_ADDED] =
|
||||
g_signal_new ("device-added",
|
||||
|
|
|
@ -65,6 +65,7 @@ typedef enum {
|
|||
#define NM_MANAGER_CONNECTIVITY "connectivity"
|
||||
#define NM_MANAGER_PRIMARY_CONNECTION "primary-connection"
|
||||
#define NM_MANAGER_ACTIVATING_CONNECTION "activating-connection"
|
||||
#define NM_MANAGER_DEVICES "devices"
|
||||
|
||||
/* Not exported */
|
||||
#define NM_MANAGER_HOSTNAME "hostname"
|
||||
|
|
Loading…
Reference in a new issue