From: Thomas Graf <[email protected]> Adds a helper nm_connection_is_type(connection, type) which returns TRUE if a connection is of specified type.
Signed-off-by: Thomas Graf <[email protected]> Signed-off-by: Weiping Pan <[email protected]> --- libnm-util/libnm-util.ver | 1 + libnm-util/nm-connection.c | 15 +++++++++++++++ libnm-util/nm-connection.h | 2 ++ 3 files changed, 18 insertions(+), 0 deletions(-) diff --git a/libnm-util/libnm-util.ver b/libnm-util/libnm-util.ver index edf5d29..53c2482 100644 --- a/libnm-util/libnm-util.ver +++ b/libnm-util/libnm-util.ver @@ -32,6 +32,7 @@ global: nm_connection_get_setting_wireless_security; nm_connection_get_type; nm_connection_get_uuid; + nm_connection_is_type; nm_connection_lookup_setting_type; nm_connection_lookup_setting_type_by_quark; nm_connection_need_secrets; diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c index 6a10128..e3bbeae 100644 --- a/libnm-util/nm-connection.c +++ b/libnm-util/nm-connection.c @@ -1050,6 +1050,21 @@ nm_connection_to_hash (NMConnection *connection, NMSettingHashFlags flags) return ret; } +gboolean +nm_connection_is_type (NMConnection *connection, const char *type) +{ + NMSettingConnection *s_con; + const char *type2; + + s_con = nm_connection_get_setting_connection (connection); + g_assert (s_con); + + type2 = nm_setting_connection_get_connection_type (s_con); + g_assert (type2); + + return !strcmp (type2, type); +} + /** * nm_connection_for_each_setting_value: * @connection: the #NMConnection diff --git a/libnm-util/nm-connection.h b/libnm-util/nm-connection.h index 3245f7e..069dc84 100644 --- a/libnm-util/nm-connection.h +++ b/libnm-util/nm-connection.h @@ -161,6 +161,8 @@ void nm_connection_set_path (NMConnection *connection, const char * nm_connection_get_path (NMConnection *connection); +gboolean nm_connection_is_type (NMConnection *connection, const char *type); + void nm_connection_for_each_setting_value (NMConnection *connection, NMSettingValueIterFn func, gpointer user_data); -- 1.7.4.4 _______________________________________________ networkmanager-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/networkmanager-list
