[PATCH 2/2] Add nm_connection_get_setting_serial()



Signed-off-by: Thomas Graf <tgraf redhat com>
---
 libnm-util/libnm-util.ver                         |    1 +
 libnm-util/nm-connection.c                        |   18 ++++++++++++++++++
 libnm-util/nm-connection.h                        |    2 ++
 src/nm-device-bt.c                                |    2 +-
 src/settings/plugins/keyfile/tests/test-keyfile.c |    4 ++--
 5 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/libnm-util/libnm-util.ver b/libnm-util/libnm-util.ver
index edf5d29..23ad6d8 100644
--- a/libnm-util/libnm-util.ver
+++ b/libnm-util/libnm-util.ver
@@ -25,6 +25,7 @@ global:
 	nm_connection_get_setting_olpc_mesh;
 	nm_connection_get_setting_ppp;
 	nm_connection_get_setting_pppoe;
+	nm_connection_get_setting_serial;
 	nm_connection_get_setting_vpn;
 	nm_connection_get_setting_wimax;
 	nm_connection_get_setting_wired;
diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c
index 76af7e0..550a15a 100644
--- a/libnm-util/nm-connection.c
+++ b/libnm-util/nm-connection.c
@@ -42,6 +42,7 @@
 #include "nm-setting-wired.h"
 #include "nm-setting-wireless.h"
 #include "nm-setting-wireless-security.h"
+#include "nm-setting-serial.h"
 #include "nm-setting-vpn.h"
 #include "nm-setting-olpc-mesh.h"
 
@@ -1444,6 +1445,23 @@ nm_connection_get_setting_pppoe (NMConnection *connection)
 }
 
 /**
+ * nm_connection_get_setting_serial:
+ * @connection: the #NMConnection
+ *
+ * A shortcut to return any #NMSettingSerial the connection might contain.
+ *
+ * Returns: (transfer none): an #NMSettingSerial if the connection contains one, otherwise NULL
+ **/
+NMSettingSerial *
+nm_connection_get_setting_serial (NMConnection *connection)
+{
+	g_return_val_if_fail (connection != NULL, NULL);
+	g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
+
+	return (NMSettingSerial *) nm_connection_get_setting (connection, NM_TYPE_SETTING_SERIAL);
+}
+
+/**
  * nm_connection_get_setting_vpn:
  * @connection: the #NMConnection
  *
diff --git a/libnm-util/nm-connection.h b/libnm-util/nm-connection.h
index 3245f7e..575121f 100644
--- a/libnm-util/nm-connection.h
+++ b/libnm-util/nm-connection.h
@@ -40,6 +40,7 @@
 #include <nm-setting-olpc-mesh.h>
 #include <nm-setting-ppp.h>
 #include <nm-setting-pppoe.h>
+#include <nm-setting-serial.h>
 #include <nm-setting-vpn.h>
 #include <nm-setting-wimax.h>
 #include <nm-setting-wired.h>
@@ -189,6 +190,7 @@ NMSettingIP6Config *       nm_connection_get_setting_ip6_config        (NMConnec
 NMSettingOlpcMesh *        nm_connection_get_setting_olpc_mesh         (NMConnection *connection);
 NMSettingPPP *             nm_connection_get_setting_ppp               (NMConnection *connection);
 NMSettingPPPOE *           nm_connection_get_setting_pppoe             (NMConnection *connection);
+NMSettingSerial *          nm_connection_get_setting_serial            (NMConnection *connection);
 NMSettingVPN *             nm_connection_get_setting_vpn               (NMConnection *connection);
 NMSettingWimax *           nm_connection_get_setting_wimax             (NMConnection *connection);
 NMSettingWired *           nm_connection_get_setting_wired             (NMConnection *connection);
diff --git a/src/nm-device-bt.c b/src/nm-device-bt.c
index 6b4f61a..2193c15 100644
--- a/src/nm-device-bt.c
+++ b/src/nm-device-bt.c
@@ -278,7 +278,7 @@ real_complete_connection (NMDevice *device,
 
 	s_gsm = nm_connection_get_setting_gsm (connection);
 	s_cdma = nm_connection_get_setting_cdma (connection);
-	s_serial = (NMSettingSerial *) nm_connection_get_setting (connection, NM_TYPE_SETTING_SERIAL);
+	s_serial = nm_connection_get_setting_serial (connection);
 	s_ppp = nm_connection_get_setting_ppp (connection);
 
 	s_bt = nm_connection_get_setting_bluetooth (connection);
diff --git a/src/settings/plugins/keyfile/tests/test-keyfile.c b/src/settings/plugins/keyfile/tests/test-keyfile.c
index 5c9ced7..bf95418 100644
--- a/src/settings/plugins/keyfile/tests/test-keyfile.c
+++ b/src/settings/plugins/keyfile/tests/test-keyfile.c
@@ -1952,7 +1952,7 @@ test_read_bt_dun_connection (void)
 
 	/* ===== SERIAL SETTING ===== */
 
-	s_serial = NM_SETTING_SERIAL (nm_connection_get_setting (connection, NM_TYPE_SETTING_SERIAL));
+	s_serial = nm_connection_get_setting_serial (connection);
 	ASSERT (s_serial != NULL,
 	        "connection-verify-serial", "failed to verify %s: missing %s setting",
 	        TEST_BT_DUN_FILE,
@@ -2215,7 +2215,7 @@ test_read_gsm_connection (void)
 
 	/* ===== SERIAL SETTING ===== */
 
-	s_serial = NM_SETTING_SERIAL (nm_connection_get_setting (connection, NM_TYPE_SETTING_SERIAL));
+	s_serial = nm_connection_get_setting_serial (connection);
 	ASSERT (s_serial != NULL,
 	        "connection-verify-serial", "failed to verify %s: missing %s setting",
 	        TEST_GSM_FILE,
-- 
1.7.6.4



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