Re: [PATCH 2/8] connection: Add nm_connection_is_type()



On Tue, 2011-10-18 at 13:48 +0200, Thomas Graf wrote:
> Adds a helper nm_connection_is_type(connection, type) which returns TRUE
> if a connection is of specified type.

Pushed this to git master already after adding code docs and some
argument checks.

Thanks!
Dan

> Signed-off-by: Thomas Graf <tgraf redhat com>
> ---
>  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 5e2f66b..0ee5917 100644
> --- a/libnm-util/libnm-util.ver
> +++ b/libnm-util/libnm-util.ver
> @@ -33,6 +33,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 0fec83a..740cb58 100644
> --- a/libnm-util/nm-connection.c
> +++ b/libnm-util/nm-connection.c
> @@ -1056,6 +1056,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 b99a7cc..6014138 100644
> --- a/libnm-util/nm-connection.h
> +++ b/libnm-util/nm-connection.h
> @@ -162,6 +162,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);




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]