diff options
author | Jiří Klimeš <jklimes@redhat.com> | 2011-06-15 14:58:04 +0200 |
---|---|---|
committer | Jiří Klimeš <jklimes@redhat.com> | 2011-06-15 14:58:04 +0200 |
commit | 8d43875cbe538d010b92c37ebbaf9221485f9324 (patch) | |
tree | df3bca790c2d0edc4270c89c56e2af70098b3be4 /libnm-glib | |
parent | acc3025dfc3c66fa7ec644cf648979b5ada6da77 (diff) | |
download | NetworkManager-8d43875cbe538d010b92c37ebbaf9221485f9324.tar.gz |
libnm-glib: add nm_client_get_device_by_iface() for NMClient
Diffstat (limited to 'libnm-glib')
-rw-r--r-- | libnm-glib/Makefile.am | 2 | ||||
-rw-r--r-- | libnm-glib/libnm-glib.ver | 1 | ||||
-rw-r--r-- | libnm-glib/nm-client.c | 34 | ||||
-rw-r--r-- | libnm-glib/nm-client.h | 1 |
4 files changed, 37 insertions, 1 deletions
diff --git a/libnm-glib/Makefile.am b/libnm-glib/Makefile.am index 08a61cc296..4eec40161d 100644 --- a/libnm-glib/Makefile.am +++ b/libnm-glib/Makefile.am @@ -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 diff --git a/libnm-glib/libnm-glib.ver b/libnm-glib/libnm-glib.ver index f42368b87a..b887e427fc 100644 --- a/libnm-glib/libnm-glib.ver +++ b/libnm-glib/libnm-glib.ver @@ -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; diff --git a/libnm-glib/nm-client.c b/libnm-glib/nm-client.c index 752510aea3..0769de1a74 100644 --- a/libnm-glib/nm-client.c +++ b/libnm-glib/nm-client.c @@ -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; diff --git a/libnm-glib/nm-client.h b/libnm-glib/nm-client.h index 450c094716..c9fd7c104f 100644 --- a/libnm-glib/nm-client.h +++ b/libnm-glib/nm-client.h @@ -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, |