libnm-util: add nm_connection_is_type()

Adds a helper nm_connection_is_type(connection, type) which returns TRUE
if a connection is of specified type.

Signed-off-by: Thomas Graf <tgraf@redhat.com>
This commit is contained in:
Thomas Graf
2011-10-18 13:48:43 +02:00
committed by Dan Williams
parent b6a911f051
commit 594a2f677d
4 changed files with 35 additions and 1 deletions

View File

@@ -69,7 +69,7 @@ libnm_util_la_LIBADD = $(GLIB_LIBS) $(DBUS_LIBS) $(UUID_LIBS)
SYMBOL_VIS_FILE=$(srcdir)/libnm-util.ver
libnm_util_la_LDFLAGS = -Wl,--version-script=$(SYMBOL_VIS_FILE) \
-version-info "3:0:1"
-version-info "4:0:2"
if WITH_GNUTLS
libnm_util_la_SOURCES += crypto_gnutls.c

View File

@@ -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;

View File

@@ -1050,6 +1050,37 @@ nm_connection_to_hash (NMConnection *connection, NMSettingHashFlags flags)
return ret;
}
/**
* nm_connection_is_type:
* @connection: the #NMConnection
* @type: a setting name to check the connection's type against (like
* %NM_SETTING_WIRELESS_SETTING_NAME or %NM_SETTING_WIRED_SETTING_NAME)
*
* A convenience function to check if the given @connection is a particular
* type (ie wired, wifi, ppp, etc). Checks the #NMSettingConnection:type
* property of the connection and matches that against @type.
*
* Returns: %TRUE if the connection is of the given @type, %FALSE if not
**/
gboolean
nm_connection_is_type (NMConnection *connection, const char *type)
{
NMSettingConnection *s_con;
const char *type2;
g_return_val_if_fail (connection != NULL, FALSE);
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
g_return_val_if_fail (type != NULL, FALSE);
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

View File

@@ -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);