summaryrefslogtreecommitdiff
path: root/libnm-util
diff options
context:
space:
mode:
authorThomas Graf <tgraf@redhat.com>2011-10-18 13:48:43 +0200
committerDan Williams <dcbw@redhat.com>2011-10-27 11:06:17 -0500
commit594a2f677db1bce425e84856f0cf7cf0f30b3903 (patch)
treeab552e6b1bc9d2a0fbe4169b19cc0f8440794a9f /libnm-util
parentb6a911f0516b6397b314983faf49549308c6c999 (diff)
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>
Diffstat (limited to 'libnm-util')
-rw-r--r--libnm-util/Makefile.am2
-rw-r--r--libnm-util/libnm-util.ver1
-rw-r--r--libnm-util/nm-connection.c31
-rw-r--r--libnm-util/nm-connection.h2
4 files changed, 35 insertions, 1 deletions
diff --git a/libnm-util/Makefile.am b/libnm-util/Makefile.am
index 1529b4adc4..1327565ae3 100644
--- a/libnm-util/Makefile.am
+++ b/libnm-util/Makefile.am
@@ -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
diff --git a/libnm-util/libnm-util.ver b/libnm-util/libnm-util.ver
index edf5d2925e..53c2482e26 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 6a10128c24..cdc3b81f01 100644
--- a/libnm-util/nm-connection.c
+++ b/libnm-util/nm-connection.c
@@ -1051,6 +1051,37 @@ nm_connection_to_hash (NMConnection *connection, NMSettingHashFlags flags)
}
/**
+ * 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
* @func: (scope call): user-supplied function called for each setting's property
diff --git a/libnm-util/nm-connection.h b/libnm-util/nm-connection.h
index 3245f7e693..069dc84c16 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);