Commit 8d43875c authored by Jiří Klimeš's avatar Jiří Klimeš

libnm-glib: add nm_client_get_device_by_iface() for NMClient

parent acc3025d
......@@ -139,7 +139,7 @@ libnm_glib_la_LIBADD = \
SYMBOL_VIS_FILE=$(srcdir)/libnm-glib.ver
libnm_glib_la_LDFLAGS = -Wl,--version-script=$(SYMBOL_VIS_FILE) \
-version-info "5:0:1"
-version-info "6:0:2"
noinst_PROGRAMS = libnm-glib-test
......
......@@ -33,6 +33,7 @@ global:
nm_client_deactivate_connection;
nm_client_get_active_connections;
nm_client_get_device_by_path;
nm_client_get_device_by_iface;
nm_client_get_devices;
nm_client_get_manager_running;
nm_client_get_permission_result;
......
......@@ -557,6 +557,40 @@ nm_client_get_device_by_path (NMClient *client, const char *object_path)
return device;
}
/**
* nm_client_get_device_by_iface:
* @client: a #NMClient
* @iface: the interface name to search for
*
* Gets a #NMDevice from a #NMClient.
*
* Returns: (transfer none): the #NMDevice for the given @iface or %NULL if none is found.
**/
NMDevice *
nm_client_get_device_by_iface (NMClient *client, const char *iface)
{
const GPtrArray *devices;
int i;
NMDevice *device = NULL;
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
g_return_val_if_fail (iface, NULL);
devices = nm_client_get_devices (client);
if (!devices)
return NULL;
for (i = 0; i < devices->len; i++) {
NMDevice *candidate = g_ptr_array_index (devices, i);
if (!strcmp (nm_device_get_iface (candidate), iface)) {
device = candidate;
break;
}
}
return device;
}
typedef struct {
NMClient *client;
NMClientActivateFn act_fn;
......
......@@ -108,6 +108,7 @@ NMClient *nm_client_new (void);
const GPtrArray *nm_client_get_devices (NMClient *client);
NMDevice *nm_client_get_device_by_path (NMClient *client, const char *object_path);
NMDevice *nm_client_get_device_by_iface (NMClient *client, const char *iface);
typedef void (*NMClientActivateFn) (NMClient *client,
NMActiveConnection *active_connection,
......
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