[network-manager-applet] Use the new typed nm_connection_get_setting_*() methods



commit 32bcd021e2db759081bd135ce0810ded91d7bdcc
Author: Dan Winship <danw gnome org>
Date:   Fri Mar 2 11:09:38 2012 -0500

    Use the new typed nm_connection_get_setting_*() methods

 src/applet-agent.c                             |    4 +-
 src/applet-device-bt.c                         |    4 +-
 src/applet-device-cdma.c                       |   10 ++++----
 src/applet-device-gsm.c                        |   10 ++++----
 src/applet-device-wifi.c                       |   14 ++++++------
 src/applet-device-wimax.c                      |    8 +++---
 src/applet-device-wired.c                      |   16 +++++++-------
 src/applet-dialogs.c                           |   15 ++++++-------
 src/applet-vpn-request.c                       |    6 ++--
 src/applet.c                                   |   24 +++++++++++-----------
 src/connection-editor/nm-connection-editor.c   |   10 ++++----
 src/connection-editor/nm-connection-list.c     |   19 ++++++++---------
 src/connection-editor/page-dsl.c               |    4 +-
 src/connection-editor/page-ip4.c               |    6 ++--
 src/connection-editor/page-ip6.c               |    6 ++--
 src/connection-editor/page-ppp.c               |    4 +-
 src/connection-editor/page-vpn.c               |    2 +-
 src/connection-editor/page-wired-security.c    |    2 +-
 src/connection-editor/page-wired.c             |    2 +-
 src/connection-editor/page-wireless-security.c |   14 +++++-------
 src/connection-editor/page-wireless.c          |    2 +-
 src/connection-editor/vpn-helpers.c            |    6 ++--
 src/gconf-helpers/gconf-helpers.c              |    6 ++--
 src/gconf-helpers/tests/test-upgrade.c         |    8 +++---
 src/libnm-gtk/nm-wireless-dialog.c             |   25 +++++++++++------------
 src/utils/utils.c                              |   25 +++++++++++------------
 src/wired-dialog.c                             |    2 +-
 src/wireless-security/eap-method-fast.c        |    4 +-
 src/wireless-security/eap-method-leap.c        |    4 +-
 src/wireless-security/eap-method-peap.c        |    4 +-
 src/wireless-security/eap-method-simple.c      |    4 +-
 src/wireless-security/eap-method-tls.c         |    6 ++--
 src/wireless-security/eap-method-ttls.c        |    4 +-
 src/wireless-security/eap-method.c             |    2 +-
 src/wireless-security/wireless-security.c      |    7 ++---
 src/wireless-security/ws-dynamic-wep.c         |    3 +-
 src/wireless-security/ws-leap.c                |    4 +-
 src/wireless-security/ws-wep-key.c             |    8 +++---
 src/wireless-security/ws-wpa-eap.c             |    3 +-
 src/wireless-security/ws-wpa-psk.c             |    2 +-
 40 files changed, 150 insertions(+), 159 deletions(-)
---
diff --git a/src/applet-agent.c b/src/applet-agent.c
index 6b4119f..6054480 100644
--- a/src/applet-agent.c
+++ b/src/applet-agent.c
@@ -263,7 +263,7 @@ is_connection_always_ask (NMConnection *connection)
 	/* For the given connection type, check if the secrets for that connection
 	 * are always-ask or not.
 	 */
-	s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
+	s_con = nm_connection_get_setting_connection (connection);
 	g_assert (s_con);
 	ctype = nm_setting_connection_get_connection_type (s_con);
 
@@ -765,7 +765,7 @@ delete_secrets (NMSecretAgent *agent,
 	r = request_new (agent, connection, connection_path, NULL, NULL, FALSE, NULL, NULL, callback, callback_data);
 	g_hash_table_insert (priv->requests, GUINT_TO_POINTER (r->id), r);
 
-	s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
+	s_con = nm_connection_get_setting_connection (connection);
 	g_assert (s_con);
 	uuid = nm_setting_connection_get_uuid (s_con);
 	g_assert (uuid);
diff --git a/src/applet-device-bt.c b/src/applet-device-bt.c
index a6fc091..8a262f5 100644
--- a/src/applet-device-bt.c
+++ b/src/applet-device-bt.c
@@ -194,7 +194,7 @@ bt_device_state_changed (NMDevice *device,
 		connection = applet_find_active_connection_for_device (device, applet, NULL);
 		if (connection) {
 			const char *id;
-			s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+			s_con = nm_connection_get_setting_connection (connection);
 			id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
 			if (id)
 				str = g_strdup_printf (_("You are now connected to '%s'."), id);
@@ -222,7 +222,7 @@ bt_get_icon (NMDevice *device,
 
 	id = nm_device_get_iface (NM_DEVICE (device));
 	if (connection) {
-		s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+		s_con = nm_connection_get_setting_connection (connection);
 		id = nm_setting_connection_get_id (s_con);
 	}
 
diff --git a/src/applet-device-cdma.c b/src/applet-device-cdma.c
index bd13d13..e72dddb 100644
--- a/src/applet-device-cdma.c
+++ b/src/applet-device-cdma.c
@@ -357,7 +357,7 @@ cdma_add_menu_item (NMDevice *device,
 	if (active) {
 		NMSettingConnection *s_con;
 
-		s_con = (NMSettingConnection *) nm_connection_get_setting (active, NM_TYPE_SETTING_CONNECTION);
+		s_con = nm_connection_get_setting_connection (active);
 		g_assert (s_con);
 
 		item = nm_mb_menu_item_new (nm_setting_connection_get_id (s_con),
@@ -435,7 +435,7 @@ cdma_device_state_changed (NMDevice *device,
 		if (connection) {
 			const char *id;
 
-			s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+			s_con = nm_connection_get_setting_connection (connection);
 			id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
 			if (id)
 				str = g_strdup_printf (_("You are now connected to '%s'."), id);
@@ -472,7 +472,7 @@ cdma_get_icon (NMDevice *device,
 
 	id = nm_device_get_iface (NM_DEVICE (device));
 	if (connection) {
-		s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+		s_con = nm_connection_get_setting_connection (connection);
 		id = nm_setting_connection_get_id (s_con);
 	}
 
@@ -540,11 +540,11 @@ get_cdma_secrets_cb (GtkDialog *dialog,
 {
 	SecretsRequest *req = user_data;
 	NMCdmaSecretsInfo *info = (NMCdmaSecretsInfo *) req;
-	NMSetting *setting;
+	NMSettingCdma *setting;
 	GError *error = NULL;
 
 	if (response == GTK_RESPONSE_OK) {
-		setting = nm_connection_get_setting (req->connection, NM_TYPE_SETTING_CDMA);
+		setting = nm_connection_get_setting_cdma (req->connection);
 		if (setting) {
 			g_object_set (G_OBJECT (setting),
 				          info->secret_name, gtk_entry_get_text (info->secret_entry),
diff --git a/src/applet-device-gsm.c b/src/applet-device-gsm.c
index a68f2a5..d20bf5e 100644
--- a/src/applet-device-gsm.c
+++ b/src/applet-device-gsm.c
@@ -404,7 +404,7 @@ gsm_add_menu_item (NMDevice *device,
 	if (active) {
 		NMSettingConnection *s_con;
 
-		s_con = (NMSettingConnection *) nm_connection_get_setting (active, NM_TYPE_SETTING_CONNECTION);
+		s_con = nm_connection_get_setting_connection (active);
 		g_assert (s_con);
 
 		item = nm_mb_menu_item_new (nm_setting_connection_get_id (s_con),
@@ -482,7 +482,7 @@ gsm_device_state_changed (NMDevice *device,
 		if (connection) {
 			const char *id;
 
-			s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+			s_con = nm_connection_get_setting_connection (connection);
 			id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
 			if (id)
 				str = g_strdup_printf (_("You are now connected to '%s'."), id);
@@ -519,7 +519,7 @@ gsm_get_icon (NMDevice *device,
 
 	id = nm_device_get_iface (NM_DEVICE (device));
 	if (connection) {
-		s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+		s_con = nm_connection_get_setting_connection (connection);
 		id = nm_setting_connection_get_id (s_con);
 	}
 
@@ -589,11 +589,11 @@ get_gsm_secrets_cb (GtkDialog *dialog,
 {
 	SecretsRequest *req = user_data;
 	NMGsmSecretsInfo *info = (NMGsmSecretsInfo *) req;
-	NMSetting *setting;
+	NMSettingGsm *setting;
 	GError *error = NULL;
 
 	if (response == GTK_RESPONSE_OK) {
-		setting = nm_connection_get_setting (req->connection, NM_TYPE_SETTING_GSM);
+		setting = nm_connection_get_setting_gsm (req->connection);
 		if (setting) {
 			g_object_set (G_OBJECT (setting),
 				          info->secret_name, gtk_entry_get_text (info->secret_entry),
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index 0612f12..0c9c3ee 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -602,7 +602,7 @@ create_new_ap_item (NMDeviceWifi *device,
 			NMSettingConnection *s_con;
 			GtkWidget *subitem;
 
-			s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+			s_con = nm_connection_get_setting_connection (connection);
 			subitem = gtk_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
 
 			info = g_slice_new0 (WirelessMenuItemInfo);
@@ -943,7 +943,7 @@ notify_active_ap_changed_cb (NMDeviceWifi *device,
 	if (!connection)
 		return;
 
-	s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_WIRELESS));
+	s_wireless = nm_connection_get_setting_wireless (NM_CONNECTION (connection));
 	if (!s_wireless)
 		return;
 
@@ -1055,7 +1055,7 @@ idle_check_avail_access_point_notification (gpointer datap)
 			NMConnection *connection = NM_CONNECTION (iter->data);
 			NMSettingConnection *s_con;
 
-			s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+			s_con = nm_connection_get_setting_connection (connection);
 			if (nm_setting_connection_get_autoconnect (s_con))  {
 				is_autoconnect = TRUE;
 				break;
@@ -1299,7 +1299,7 @@ wireless_get_icon (NMDevice *device,
 
 	id = nm_device_get_iface (device);
 	if (connection) {
-		s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+		s_con = nm_connection_get_setting_connection (connection);
 		id = nm_setting_connection_get_id (s_con);
 	}
 
@@ -1469,7 +1469,7 @@ wireless_dialog_response_cb (GtkDialog *foo,
 		/* Entirely new connection */
 
 		/* Don't autoconnect adhoc networks by default for now */
-		s_wifi = (NMSettingWireless *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS);
+		s_wifi = nm_connection_get_setting_wireless (connection);
 		if (s_wifi)
 			mode = nm_setting_wireless_get_mode (s_wifi);
 		if (g_strcmp0 (mode, "adhoc") == 0) {
@@ -1596,7 +1596,7 @@ get_secrets_dialog_response_cb (GtkDialog *foo,
 	}
 
 	/* Second-guess which setting NM wants secrets for. */
-	s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY));
+	s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
 	if (!s_wireless_sec) {
 		g_set_error (&error,
 		             NM_SECRET_AGENT_ERROR,
@@ -1634,7 +1634,7 @@ get_secrets_dialog_response_cb (GtkDialog *foo,
 		if (!auth_alg || strcmp (auth_alg, "leap")) {
 			NMSetting8021x *s_8021x;
 
-			s_8021x = (NMSetting8021x *) nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X);
+			s_8021x = nm_connection_get_setting_802_1x (connection);
 			if (!s_8021x) {
 				g_set_error (&error,
 				             NM_SECRET_AGENT_ERROR,
diff --git a/src/applet-device-wimax.c b/src/applet-device-wimax.c
index 5a4a6c2..05533a1 100644
--- a/src/applet-device-wimax.c
+++ b/src/applet-device-wimax.c
@@ -179,7 +179,7 @@ get_connection_for_nsp (GSList *connections, NMWimaxNsp *nsp)
 		NMConnection *candidate = NM_CONNECTION (iter->data);
 		NMSettingWimax *s_wimax;
 
-		s_wimax = (NMSettingWimax *) nm_connection_get_setting (candidate, NM_TYPE_SETTING_WIMAX);
+		s_wimax = nm_connection_get_setting_wimax (candidate);
 		if (s_wimax) {
 			candidate_name = nm_setting_wimax_get_network_name (s_wimax);
 			if (g_strcmp0 (nsp_name, candidate_name) == 0)
@@ -363,7 +363,7 @@ active_nsp_changed_cb (NMDeviceWimax *device,
 	if (!connection)
 		return;
 
-	s_wimax = (NMSettingWimax *) nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_WIMAX);
+	s_wimax = nm_connection_get_setting_wimax (NM_CONNECTION (connection));
 	if (!s_wimax)
 		return;
 
@@ -417,7 +417,7 @@ wimax_device_state_changed (NMDevice *device,
 		if (connection) {
 			const char *id;
 
-			s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+			s_con = nm_connection_get_setting_connection (connection);
 			id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
 			if (id)
 				str = g_strdup_printf (_("You are now connected to '%s'."), id);
@@ -449,7 +449,7 @@ wimax_get_icon (NMDevice *device,
 
 	id = nm_device_get_iface (NM_DEVICE (device));
 	if (connection) {
-		s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+		s_con = nm_connection_get_setting_connection (connection);
 		id = nm_setting_connection_get_id (s_con);
 	}
 
diff --git a/src/applet-device-wired.c b/src/applet-device-wired.c
index 0980355..bf32d57 100644
--- a/src/applet-device-wired.c
+++ b/src/applet-device-wired.c
@@ -263,7 +263,7 @@ wired_device_state_changed (NMDevice *device,
 		connection = applet_find_active_connection_for_device (device, applet, NULL);
 		if (connection) {
 			const char *id;
-			s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+			s_con = nm_connection_get_setting_connection (connection);
 			id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
 			if (id)
 				str = g_strdup_printf (_("You are now connected to '%s'."), id);
@@ -291,7 +291,7 @@ wired_get_icon (NMDevice *device,
 
 	id = nm_device_get_iface (NM_DEVICE (device));
 	if (connection) {
-		s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+		s_con = nm_connection_get_setting_connection (connection);
 		id = nm_setting_connection_get_id (s_con);
 	}
 
@@ -376,7 +376,7 @@ pppoe_update_ui (NMConnection *connection, NMPppoeInfo *info)
 	g_return_if_fail (NM_IS_CONNECTION (connection));
 	g_return_if_fail (info != NULL);
 
-	s_pppoe = (NMSettingPPPOE *) nm_connection_get_setting (connection, NM_TYPE_SETTING_PPPOE);
+	s_pppoe = nm_connection_get_setting_pppoe (connection);
 	g_return_if_fail (s_pppoe != NULL);
 
 	s = nm_setting_pppoe_get_username (s_pppoe);
@@ -408,7 +408,7 @@ get_pppoe_secrets_cb (GtkDialog *dialog, gint response, gpointer user_data)
 {
 	SecretsRequest *req = user_data;
 	NMPppoeInfo *info = (NMPppoeInfo *) req;
-	NMSetting *setting;
+	NMSettingPPPOE *setting;
 	GHashTable *settings = NULL;
 	GHashTable *secrets;
 	GError *error = NULL;
@@ -422,10 +422,10 @@ get_pppoe_secrets_cb (GtkDialog *dialog, gint response, gpointer user_data)
 		goto done;
 	}
 
-	setting = nm_connection_get_setting (req->connection, NM_TYPE_SETTING_PPPOE);
-	pppoe_update_setting (NM_SETTING_PPPOE (setting), info);
+	setting = nm_connection_get_setting_pppoe (req->connection);
+	pppoe_update_setting (setting, info);
 
-	secrets = nm_setting_to_hash (setting, NM_SETTING_HASH_FLAG_ONLY_SECRETS);
+	secrets = nm_setting_to_hash (NM_SETTING (setting), NM_SETTING_HASH_FLAG_ONLY_SECRETS);
 	if (!secrets) {
 		g_set_error (&error,
 		             NM_SECRET_AGENT_ERROR,
@@ -612,7 +612,7 @@ wired_get_secrets (SecretsRequest *req, GError **error)
 	NMSettingConnection *s_con;
 	const char *ctype;
 
-	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (req->connection, NM_TYPE_SETTING_CONNECTION));
+	s_con = nm_connection_get_setting_connection (req->connection);
 	if (!s_con) {
 		g_set_error (error,
 		             NM_SECRET_AGENT_ERROR,
diff --git a/src/applet-dialogs.c b/src/applet-dialogs.c
index de95b1e..b9ebc47 100644
--- a/src/applet-dialogs.c
+++ b/src/applet-dialogs.c
@@ -221,7 +221,7 @@ create_info_label_security (NMConnection *connection)
 	GtkWidget *w = NULL;
 	const char *connection_type;
 
-	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+	s_con = nm_connection_get_setting_connection (connection);
 	g_assert (s_con);
 
 	connection_type = nm_setting_connection_get_connection_type (s_con);
@@ -231,10 +231,9 @@ create_info_label_security (NMConnection *connection)
 		NMSetting8021x *s_8021x;
 		const char *security;
 
-		s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
-		s_wireless_sec = (NMSettingWirelessSecurity *) nm_connection_get_setting (connection, 
-																				  NM_TYPE_SETTING_WIRELESS_SECURITY);
-		s_8021x = (NMSetting8021x *) nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X);
+		s_wireless = nm_connection_get_setting_wireless (connection);
+		s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
+		s_8021x = nm_connection_get_setting_802_1x (connection);
 		security = s_wireless ? nm_setting_wireless_get_security (s_wireless) : NULL;
 
 		if (security && !strcmp (security, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME) && s_wireless_sec) {
@@ -254,7 +253,7 @@ create_info_label_security (NMConnection *connection)
 	} else if (!strcmp (connection_type, NM_SETTING_WIRED_SETTING_NAME)) {
 		NMSetting8021x *s_8021x;
 
-		s_8021x = (NMSetting8021x *) nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X);
+		s_8021x = nm_connection_get_setting_802_1x (connection);
 		if (s_8021x)
 			label = get_eap_label (NULL, s_8021x);
 		else
@@ -636,7 +635,7 @@ info_dialog_add_page (GtkNotebook *notebook,
 	                  0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
 	row++;
 
-	s_ip6 = (NMSettingIP6Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP6_CONFIG);
+	s_ip6 = nm_connection_get_setting_ip6_config (connection);
 	if (s_ip6)
 		 method = nm_setting_ip6_config_get_method (s_ip6);
 
@@ -988,7 +987,7 @@ applet_mobile_password_dialog_new (NMConnection *connection,
 	w = gtk_dialog_add_button (dialog, GTK_STOCK_OK, GTK_RESPONSE_OK);
 	gtk_window_set_default (GTK_WINDOW (dialog), w);
 
-	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+	s_con = nm_connection_get_setting_connection (connection);
 	id = nm_setting_connection_get_id (s_con);
 	g_assert (id);
 	tmp = g_strdup_printf (_("A password is required to connect to '%s'."), id);
diff --git a/src/applet-vpn-request.c b/src/applet-vpn-request.c
index 845f08a..505211a 100644
--- a/src/applet-vpn-request.c
+++ b/src/applet-vpn-request.c
@@ -306,7 +306,7 @@ write_connection_to_child (int fd, NMConnection *connection, GError **error)
 	NMSettingVPN *s_vpn;
 	WriteItemInfo info = { .fd = fd, .secret = FALSE, .error = error };
 
-	s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
+	s_vpn = nm_connection_get_setting_vpn (connection);
 	if (!s_vpn) {
 		g_set_error_literal (error,
 		                     NM_SECRET_AGENT_ERROR,
@@ -354,14 +354,14 @@ applet_vpn_request_get_secrets (SecretsRequest *req, GError **error)
 
 	applet_secrets_request_set_free_func (req, free_vpn_secrets_info);
 
-	s_con = (NMSettingConnection *) nm_connection_get_setting (req->connection, NM_TYPE_SETTING_CONNECTION);
+	s_con = nm_connection_get_setting_connection (req->connection);
 	g_return_val_if_fail (s_con != NULL, FALSE);
 
 	connection_type = nm_setting_connection_get_connection_type (s_con);
 	g_return_val_if_fail (connection_type != NULL, FALSE);
 	g_return_val_if_fail (strcmp (connection_type, NM_SETTING_VPN_SETTING_NAME) == 0, FALSE);
 
-	s_vpn = NM_SETTING_VPN (nm_connection_get_setting (req->connection, NM_TYPE_SETTING_VPN));
+	s_vpn = nm_connection_get_setting_vpn (req->connection);
 	g_return_val_if_fail (s_vpn != NULL, FALSE);
 
 	service_type = nm_setting_vpn_get_service_type (s_vpn);
diff --git a/src/applet.c b/src/applet.c
index 5dd93dc..cb5b5e4 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -434,7 +434,7 @@ get_device_class_from_connection (NMConnection *connection, NMApplet *applet)
 	g_return_val_if_fail (connection != NULL, NULL);
 	g_return_val_if_fail (applet != NULL, NULL);
 
-	s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
+	s_con = nm_connection_get_setting_connection (connection);
 	g_return_val_if_fail (s_con != NULL, NULL);
 
 	ctype = nm_setting_connection_get_connection_type (s_con);
@@ -647,7 +647,7 @@ applet_new_menu_item_helper (NMConnection *connection,
 	char *markup;
 	GtkWidget *label;
 
-	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+	s_con = nm_connection_get_setting_connection (connection);
 	item = gtk_image_menu_item_new_with_label ("");
 	if (add_active && (active == connection)) {
 		/* Pure evil */
@@ -988,7 +988,7 @@ make_vpn_failure_message (NMVPNConnection *vpn,
 	g_return_val_if_fail (vpn != NULL, NULL);
 
 	connection = applet_get_connection_for_active (applet, NM_ACTIVE_CONNECTION (vpn));
-	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+	s_con = nm_connection_get_setting_connection (connection);
 
 	switch (reason) {
 	case NM_VPN_CONNECTION_STATE_REASON_DEVICE_DISCONNECTED:
@@ -1034,7 +1034,7 @@ make_vpn_disconnection_message (NMVPNConnection *vpn,
 	g_return_val_if_fail (vpn != NULL, NULL);
 
 	connection = applet_get_connection_for_active (applet, NM_ACTIVE_CONNECTION (vpn));
-	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+	s_con = nm_connection_get_setting_connection (connection);
 
 	switch (reason) {
 	case NM_VPN_CONNECTION_STATE_REASON_DEVICE_DISCONNECTED:
@@ -1122,7 +1122,7 @@ get_connection_id (NMConnection *connection)
 	g_return_val_if_fail (connection != NULL, NULL);
 	g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
 
-	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+	s_con = nm_connection_get_setting_connection (connection);
 	g_return_val_if_fail (s_con != NULL, NULL);
 
 	return nm_setting_connection_get_id (s_con);
@@ -1197,7 +1197,7 @@ nma_menu_vpn_item_clicked (GtkMenuItem *item, gpointer user_data)
 		/* Connection already active; do nothing */
 		return;
 
-	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+	s_con = nm_connection_get_setting_connection (connection);
 	info = g_malloc0 (sizeof (VPNActivateInfo));
 	info->applet = applet;
 	info->vpn_name = g_strdup (nm_setting_connection_get_id (s_con));
@@ -1250,7 +1250,7 @@ applet_get_first_active_vpn_connection (NMApplet *applet,
 		if (!connection)
 			continue;
 
-		s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+		s_con = nm_connection_get_setting_connection (connection);
 		g_assert (s_con);
 
 		if (!strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_VPN_SETTING_NAME)) {
@@ -1618,12 +1618,12 @@ get_vpn_connections (NMApplet *applet)
 		NMConnection *connection = NM_CONNECTION (iter->data);
 		NMSettingConnection *s_con;
 
-		s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+		s_con = nm_connection_get_setting_connection (connection);
 		if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_VPN_SETTING_NAME))
 			/* Not a VPN connection */
 			continue;
 
-		if (!nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN)) {
+		if (!nm_connection_get_setting_vpn (connection)) {
 			g_warning ("%s: VPN connection '%s' didn't have required vpn setting.", __func__,
 			           nm_setting_connection_get_id (s_con));
 			continue;
@@ -2468,7 +2468,7 @@ get_tip_for_device_state (NMDevice *device,
 
 	id = nm_device_get_iface (device);
 	if (connection) {
-		s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
+		s_con = nm_connection_get_setting_connection (connection);
 		id = nm_setting_connection_get_id (s_con);
 	}
 
@@ -2549,7 +2549,7 @@ get_tip_for_vpn (NMActiveConnection *active, NMVPNConnectionState state, NMApple
 		NMSettingConnection *s_con;
 
 		if (!strcmp (nm_connection_get_path (candidate), path)) {
-			s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (candidate, NM_TYPE_SETTING_CONNECTION));
+			s_con = nm_connection_get_setting_connection (candidate);
 			id = nm_setting_connection_get_id (s_con);
 			break;
 		}
@@ -2832,7 +2832,7 @@ applet_agent_get_secrets_cb (AppletAgent *agent,
 	GError *error = NULL;
 	SecretsRequest *req = NULL;
 
-	s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
+	s_con = nm_connection_get_setting_connection (connection);
 	g_return_if_fail (s_con != NULL);
 
 	/* VPN secrets get handled a bit differently */
diff --git a/src/connection-editor/nm-connection-editor.c b/src/connection-editor/nm-connection-editor.c
index 743b4d2..3e9a214 100644
--- a/src/connection-editor/nm-connection-editor.c
+++ b/src/connection-editor/nm-connection-editor.c
@@ -93,7 +93,7 @@ nm_connection_editor_update_title (NMConnectionEditor *editor)
 
 	g_return_if_fail (editor != NULL);
 
-	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (editor->connection, NM_TYPE_SETTING_CONNECTION));
+	s_con = nm_connection_get_setting_connection (editor->connection);
 	g_assert (s_con);
 
 	id = nm_setting_connection_get_id (s_con);
@@ -154,7 +154,7 @@ update_sensitivity (NMConnectionEditor *editor)
 	GtkWidget *widget;
 	GSList *iter;
 
-	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (editor->connection, NM_TYPE_SETTING_CONNECTION));
+	s_con = nm_connection_get_setting_connection (editor->connection);
 
 	/* Can't modify read-only connections; can't modify anything before the
 	 * editor is initialized either.
@@ -205,7 +205,7 @@ connection_editor_validate (NMConnectionEditor *editor)
 	if (!editor_is_initialized (editor))
 		goto done;
 
-	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (editor->connection, NM_TYPE_SETTING_CONNECTION));
+	s_con = nm_connection_get_setting_connection (editor->connection);
 	g_assert (s_con);
 	if (nm_setting_connection_get_read_only (s_con))
 		goto done;
@@ -504,7 +504,7 @@ populate_connection_ui (NMConnectionEditor *editor)
 	name = GTK_WIDGET (gtk_builder_get_object (editor->builder, "connection_name"));
 	autoconnect = GTK_WIDGET (gtk_builder_get_object (editor->builder, "connection_autoconnect"));
 
-	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (editor->connection, NM_TYPE_SETTING_CONNECTION));
+	s_con = nm_connection_get_setting_connection (editor->connection);
 	if (s_con) {
 		const char *id = nm_setting_connection_get_id (s_con);
 
@@ -722,7 +722,7 @@ nm_connection_editor_set_connection (NMConnectionEditor *editor,
 	editor->orig_connection = g_object_ref (orig_connection);
 	nm_connection_editor_update_title (editor);
 
-	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (editor->connection, NM_TYPE_SETTING_CONNECTION));
+	s_con = nm_connection_get_setting_connection (editor->connection);
 	g_assert (s_con);
 
 	connection_type = nm_setting_connection_get_connection_type (s_con);
diff --git a/src/connection-editor/nm-connection-list.c b/src/connection-editor/nm-connection-list.c
index ae0296c..455334d 100644
--- a/src/connection-editor/nm-connection-list.c
+++ b/src/connection-editor/nm-connection-list.c
@@ -157,7 +157,7 @@ get_model_for_connection (NMConnectionList *list, NMRemoteConnection *connection
 	GtkTreeModel *model;
 	const char *str_type;
 
-	s_con = (NMSettingConnection *) nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_CONNECTION);
+	s_con = nm_connection_get_setting_connection (NM_CONNECTION (connection));
 	g_assert (s_con);
 	str_type = nm_setting_connection_get_connection_type (s_con);
 
@@ -285,7 +285,7 @@ update_connection_row (GtkListStore *store,
 	NMSettingConnection *s_con;
 	char *last_used;
 
-	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_CONNECTION));
+	s_con = nm_connection_get_setting_connection (NM_CONNECTION (connection));
 	g_assert (s_con);
 
 	last_used = format_last_used (nm_setting_connection_get_timestamp (s_con));
@@ -784,7 +784,7 @@ delete_clicked (GtkButton *button, gpointer user_data)
 		return;
 	}
 
-	s_con = (NMSettingConnection *) nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_CONNECTION);
+	s_con = nm_connection_get_setting_connection (NM_CONNECTION (connection));
 	g_assert (s_con);
 	id = nm_setting_connection_get_id (s_con);
 
@@ -824,8 +824,7 @@ pk_button_selection_changed_cb (GtkTreeSelection *selection, gpointer user_data)
 	if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
 		connection = get_active_connection (info->treeview);
 		if (connection) {
-			s_con = (NMSettingConnection *) nm_connection_get_setting (NM_CONNECTION (connection),
-			                                                           NM_TYPE_SETTING_CONNECTION);
+			s_con = nm_connection_get_setting_connection (NM_CONNECTION (connection));
 			g_assert (s_con);
 	
 			sensitive = !nm_setting_connection_get_read_only (s_con);
@@ -855,7 +854,7 @@ vpn_list_selection_changed_cb (GtkTreeSelection *selection, gpointer user_data)
 	if (!connection)
 		goto done;
 
-	s_vpn = NM_SETTING_VPN (nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_VPN));
+	s_vpn = nm_connection_get_setting_vpn (NM_CONNECTION (connection));
 	service_type = s_vpn ? nm_setting_vpn_get_service_type (s_vpn) : NULL;
 
 	if (!service_type)
@@ -886,7 +885,7 @@ import_success_cb (NMConnection *connection, gpointer user_data)
 	const char *message = _("The connection editor dialog could not be initialized due to an unknown error.");
 
 	/* Basic sanity checks of the connection */
-	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+	s_con = nm_connection_get_setting_connection (connection);
 	if (!s_con) {
 		s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
 		nm_connection_add_setting (connection, NM_SETTING (s_con));
@@ -915,7 +914,7 @@ import_success_cb (NMConnection *connection, gpointer user_data)
 		g_free (s);
 	}
 
-	s_vpn = NM_SETTING_VPN (nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN));
+	s_vpn = nm_connection_get_setting_vpn (connection);
 	service_type = s_vpn ? nm_setting_vpn_get_service_type (s_vpn) : NULL;
 
 	if (!service_type || !strlen (service_type)) {
@@ -1414,7 +1413,7 @@ connection_added (NMRemoteSettings *settings,
 	if (!store)
 		return;
 
-	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (NM_CONNECTION (connection), NM_TYPE_SETTING_CONNECTION));
+	s_con = nm_connection_get_setting_connection (NM_CONNECTION (connection));
 
 	last_used = format_last_used (nm_setting_connection_get_timestamp (s_con));
 
@@ -1621,7 +1620,7 @@ connections_read (NMRemoteSettings *settings, EditData *data)
 		const char *type;
 		ActionInfo *info;
 
-		s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
+		s_con = nm_connection_get_setting_connection (connection);
 		type = nm_setting_connection_get_connection_type (s_con);
 		info = find_action_info (data->self, nm_connection_lookup_setting_type (type), "edit");
 		if (info != NULL)
diff --git a/src/connection-editor/page-dsl.c b/src/connection-editor/page-dsl.c
index cb741f9..0c413b6 100644
--- a/src/connection-editor/page-dsl.c
+++ b/src/connection-editor/page-dsl.c
@@ -145,7 +145,7 @@ ce_page_dsl_new (NMConnection *connection,
 	dsl_private_init (self);
 	priv = CE_PAGE_DSL_GET_PRIVATE (self);
 
-	priv->setting = (NMSettingPPPOE *) nm_connection_get_setting (connection, NM_TYPE_SETTING_PPPOE);
+	priv->setting = nm_connection_get_setting_pppoe (connection);
 	if (!priv->setting) {
 		priv->setting = NM_SETTING_PPPOE (nm_setting_pppoe_new ());
 		nm_connection_add_setting (connection, NM_SETTING (priv->setting));
@@ -195,7 +195,7 @@ validate (CEPage *page, NMConnection *connection, GError **error)
 
 	ui_to_setting (self);
 
-	foo = g_slist_append (NULL, nm_connection_get_setting (connection, NM_TYPE_SETTING_PPP));
+	foo = g_slist_append (NULL, nm_connection_get_setting_ppp (connection));
 	valid = nm_setting_verify (NM_SETTING (priv->setting), foo, error);
 	g_slist_free (foo);
 
diff --git a/src/connection-editor/page-ip4.c b/src/connection-editor/page-ip4.c
index 6728d10..4e50a02 100644
--- a/src/connection-editor/page-ip4.c
+++ b/src/connection-editor/page-ip4.c
@@ -122,7 +122,7 @@ ip4_private_init (CEPageIP4 *self, NMConnection *connection)
 
 	builder = CE_PAGE (self)->builder;
 
-	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+	s_con = nm_connection_get_setting_connection (connection);
 	g_assert (s_con);
 	connection_type = nm_setting_connection_get_connection_type (s_con);
 	g_assert (connection_type);
@@ -989,11 +989,11 @@ ce_page_ip4_new (NMConnection *connection,
 
 	priv->window_group = gtk_window_group_new ();
 
-	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+	s_con = nm_connection_get_setting_connection (connection);
 	g_assert (s_con);
 	priv->connection_id = g_strdup (nm_setting_connection_get_id (s_con));
 
-	priv->setting = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
+	priv->setting = nm_connection_get_setting_ip4_config (connection);
 	if (!priv->setting) {
 		priv->setting = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ());
 		nm_connection_add_setting (connection, NM_SETTING (priv->setting));
diff --git a/src/connection-editor/page-ip6.c b/src/connection-editor/page-ip6.c
index ef993b8..c2e89e9 100644
--- a/src/connection-editor/page-ip6.c
+++ b/src/connection-editor/page-ip6.c
@@ -121,7 +121,7 @@ ip6_private_init (CEPageIP6 *self, NMConnection *connection)
 
 	builder = CE_PAGE (self)->builder;
 
-	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+	s_con = nm_connection_get_setting_connection (connection);
 	g_assert (s_con);
 	connection_type = nm_setting_connection_get_connection_type (s_con);
 	g_assert (connection_type);
@@ -953,11 +953,11 @@ ce_page_ip6_new (NMConnection *connection,
 
 	priv->window_group = gtk_window_group_new ();
 
-	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+	s_con = nm_connection_get_setting_connection (connection);
 	g_assert (s_con);
 	priv->connection_id = g_strdup (nm_setting_connection_get_id (s_con));
 
-	priv->setting = (NMSettingIP6Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP6_CONFIG);
+	priv->setting = nm_connection_get_setting_ip6_config (connection);
 	if (!priv->setting) {
 		priv->setting = NM_SETTING_IP6_CONFIG (nm_setting_ip6_config_new ());
 		nm_connection_add_setting (connection, NM_SETTING (priv->setting));
diff --git a/src/connection-editor/page-ppp.c b/src/connection-editor/page-ppp.c
index 2f164e0..b27bc4c 100644
--- a/src/connection-editor/page-ppp.c
+++ b/src/connection-editor/page-ppp.c
@@ -288,7 +288,7 @@ ce_page_ppp_new (NMConnection *connection,
 	ppp_private_init (self);
 	priv = CE_PAGE_PPP_GET_PRIVATE (self);
 
-	priv->setting = (NMSettingPPP *) nm_connection_get_setting (connection, NM_TYPE_SETTING_PPP);
+	priv->setting = nm_connection_get_setting_ppp (connection);
 	if (!priv->setting) {
 		priv->setting = NM_SETTING_PPP (nm_setting_ppp_new ());
 		g_object_set (G_OBJECT (priv->setting),
@@ -300,7 +300,7 @@ ce_page_ppp_new (NMConnection *connection,
 
 	priv->window_group = gtk_window_group_new ();
 
-	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+	s_con = nm_connection_get_setting_connection (connection);
 	g_assert (s_con);
 	priv->connection_id = g_strdup (nm_setting_connection_get_id (s_con));
 
diff --git a/src/connection-editor/page-vpn.c b/src/connection-editor/page-vpn.c
index 19324c9..a66da9c 100644
--- a/src/connection-editor/page-vpn.c
+++ b/src/connection-editor/page-vpn.c
@@ -114,7 +114,7 @@ ce_page_vpn_new (NMConnection *connection,
 
 	priv = CE_PAGE_VPN_GET_PRIVATE (self);
 
-	priv->setting = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
+	priv->setting = nm_connection_get_setting_vpn (connection);
 	g_assert (priv->setting);
 
 	service_type = nm_setting_vpn_get_service_type (priv->setting);
diff --git a/src/connection-editor/page-wired-security.c b/src/connection-editor/page-wired-security.c
index 2979036..a5ee203 100644
--- a/src/connection-editor/page-wired-security.c
+++ b/src/connection-editor/page-wired-security.c
@@ -130,7 +130,7 @@ ce_page_wired_security_new (NMConnection *connection,
 	g_object_ref_sink (G_OBJECT (parent->page));
 	gtk_container_set_border_width (GTK_CONTAINER (parent->page), 6);
 
-	if (nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X))
+	if (nm_connection_get_setting_802_1x (connection))
 		priv->initial_have_8021x = TRUE;
 
 	priv->enabled = GTK_TOGGLE_BUTTON (gtk_check_button_new_with_mnemonic (_("Use 802.1_X security for this connection")));
diff --git a/src/connection-editor/page-wired.c b/src/connection-editor/page-wired.c
index d202558..5de3cb2 100644
--- a/src/connection-editor/page-wired.c
+++ b/src/connection-editor/page-wired.c
@@ -278,7 +278,7 @@ ce_page_wired_new (NMConnection *connection,
 	wired_private_init (self);
 	priv = CE_PAGE_WIRED_GET_PRIVATE (self);
 
-	priv->setting = (NMSettingWired *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRED);
+	priv->setting = nm_connection_get_setting_wired (connection);
 	if (!priv->setting) {
 		priv->setting = NM_SETTING_WIRED (nm_setting_wired_new ());
 		nm_connection_add_setting (connection, NM_SETTING (priv->setting));
diff --git a/src/connection-editor/page-wireless-security.c b/src/connection-editor/page-wireless-security.c
index eae0d93..b51ab22 100644
--- a/src/connection-editor/page-wireless-security.c
+++ b/src/connection-editor/page-wireless-security.c
@@ -206,7 +206,7 @@ finish_setup (CEPageWirelessSecurity *self, gpointer unused, GError *error, gpoi
 	if (error)
 		return;
 
-	s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
+	s_wireless = nm_connection_get_setting_wireless (connection);
 	g_assert (s_wireless);
 
 	combo = GTK_COMBO_BOX (GTK_WIDGET (gtk_builder_get_object (parent->builder, "wireless_security_combo")));
@@ -222,8 +222,7 @@ finish_setup (CEPageWirelessSecurity *self, gpointer unused, GError *error, gpoi
 	if (mode && !strcmp (mode, "adhoc"))
 		is_adhoc = TRUE;
 
-	s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (nm_connection_get_setting (connection, 
-	                                               NM_TYPE_SETTING_WIRELESS_SECURITY));
+	s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
 
 	security = nm_setting_wireless_get_security (s_wireless);
 	if (!security || strcmp (security, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME))
@@ -250,7 +249,7 @@ finish_setup (CEPageWirelessSecurity *self, gpointer unused, GError *error, gpoi
 		if (default_type == NMU_SEC_STATIC_WEP) {
 			NMSettingWirelessSecurity *s_wsec;
 
-			s_wsec = (NMSettingWirelessSecurity *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY);
+			s_wsec = nm_connection_get_setting_wireless_security (connection);
 			if (s_wsec)
 				wep_type = nm_setting_wireless_security_get_wep_key_type (s_wsec);
 			if (wep_type == NM_WEP_KEY_TYPE_UNKNOWN)
@@ -355,7 +354,7 @@ ce_page_wireless_security_new (NMConnection *connection,
 	NMUtilsSecurityType default_type = NMU_SEC_NONE;
 	const char *security;
 
-	s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
+	s_wireless = nm_connection_get_setting_wireless (connection);
 	if (!s_wireless) {
 		g_set_error_literal (error, 0, 0, _("Could not load WiFi security user interface; missing WiFi setting."));
 		return NULL;
@@ -375,8 +374,7 @@ ce_page_wireless_security_new (NMConnection *connection,
 
 	self->group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
 
-	s_wsec = NM_SETTING_WIRELESS_SECURITY (nm_connection_get_setting (connection, 
-	                                       NM_TYPE_SETTING_WIRELESS_SECURITY));
+	s_wsec = nm_connection_get_setting_wireless_security (connection);
 
 	security = nm_setting_wireless_get_security (s_wireless);
 	if (!security || strcmp (security, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME))
@@ -434,7 +432,7 @@ validate (CEPage *page, NMConnection *connection, GError **error)
 	WirelessSecurity *sec;
 	gboolean valid = FALSE;
 
-	s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
+	s_wireless = nm_connection_get_setting_wireless (connection);
 	g_assert (s_wireless);
 
 	sec = wireless_security_combo_get_active (self);
diff --git a/src/connection-editor/page-wireless.c b/src/connection-editor/page-wireless.c
index fcf9f91..cc00e9e 100644
--- a/src/connection-editor/page-wireless.c
+++ b/src/connection-editor/page-wireless.c
@@ -463,7 +463,7 @@ ce_page_wireless_new (NMConnection *connection,
 	wireless_private_init (self);
 	priv = CE_PAGE_WIRELESS_GET_PRIVATE (self);
 
-	priv->setting = (NMSettingWireless *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS);
+	priv->setting = nm_connection_get_setting_wireless (connection);
 	if (!priv->setting) {
 		priv->setting = NM_SETTING_WIRELESS (nm_setting_wireless_new ());
 		nm_connection_add_setting (connection, NM_SETTING (priv->setting));
diff --git a/src/connection-editor/vpn-helpers.c b/src/connection-editor/vpn-helpers.c
index ab1ce83..943ee2c 100644
--- a/src/connection-editor/vpn-helpers.c
+++ b/src/connection-editor/vpn-helpers.c
@@ -322,14 +322,14 @@ export_vpn_to_file_cb (GtkWidget *dialog, gint response, gpointer user_data)
 			goto out;
 	}
 
-	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+	s_con = nm_connection_get_setting_connection (connection);
 	id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
 	if (!id) {
 		g_set_error (&error, 0, 0, "connection setting invalid");
 		goto done;
 	}
 
-	s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
+	s_vpn = nm_connection_get_setting_vpn (connection);
 	service_type = s_vpn ? nm_setting_vpn_get_service_type (s_vpn) : NULL;
 
 	if (!service_type) {
@@ -379,7 +379,7 @@ vpn_export (NMConnection *connection)
 	const char *service_type;
 	const char *home_folder;
 
-	s_vpn = NM_SETTING_VPN (nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN));
+	s_vpn = nm_connection_get_setting_vpn (connection);
 	service_type = s_vpn ? nm_setting_vpn_get_service_type (s_vpn) : NULL;
 
 	if (!service_type) {
diff --git a/src/gconf-helpers/gconf-helpers.c b/src/gconf-helpers/gconf-helpers.c
index 10c522d..ce76248 100644
--- a/src/gconf-helpers/gconf-helpers.c
+++ b/src/gconf-helpers/gconf-helpers.c
@@ -1697,7 +1697,7 @@ move_to_system (GConfClient *client,
 			continue;
 
 		/* Set this connection visible only to this user */
-		s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
+		s_con = nm_connection_get_setting_connection (connection);
 		g_assert (s_con);
 		nm_setting_connection_add_permission (s_con, "user", g_get_user_name (), NULL);
 
@@ -2506,7 +2506,7 @@ write_one_certificate (GConfClient *client,
 	const ObjectType **obj = &cert_objects[0];
 	gboolean handled = FALSE, success = FALSE;
 
-	s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
+	s_con = nm_connection_get_setting_connection (connection);
 	g_assert (s_con);
 	id = nm_setting_connection_get_id (s_con);
 	g_assert (id);
@@ -2766,7 +2766,7 @@ nm_gconf_write_connection (NMConnection *connection,
 	g_return_if_fail (client != NULL);
 	g_return_if_fail (dir != NULL);
 
-	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+	s_con = nm_connection_get_setting_connection (connection);
 	if (!s_con)
 		return;
 
diff --git a/src/gconf-helpers/tests/test-upgrade.c b/src/gconf-helpers/tests/test-upgrade.c
index b850395..07cbf29 100644
--- a/src/gconf-helpers/tests/test-upgrade.c
+++ b/src/gconf-helpers/tests/test-upgrade.c
@@ -257,7 +257,7 @@ upgrade_08_wifi_cb (NMConnection *connection, gpointer user_data)
 	NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
 
 	/* And check to make sure we've got our wpa-psk flags */
-	s_wsec = (NMSettingWirelessSecurity *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY);
+	s_wsec = nm_connection_get_setting_wireless_security (connection);
 	g_assert (s_wsec);
 	g_object_get (s_wsec, NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS, &flags, NULL);
 	g_assert_cmpint (flags, ==, NM_SETTING_SECRET_FLAG_AGENT_OWNED);
@@ -318,7 +318,7 @@ upgrade_08_vpnc_cb (NMConnection *connection, gpointer user_data)
 	gboolean success;
 
 	/* And check to make sure we've got our wpa-psk flags */
-	s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
+	s_vpn = nm_connection_get_setting_vpn (connection);
 	g_assert (s_vpn);
 
 	success = nm_setting_get_secret_flags (NM_SETTING (s_vpn),
@@ -388,7 +388,7 @@ upgrade_08_openvpn_saved_cb (NMConnection *connection, gpointer user_data)
 	gboolean success;
 
 	/* And check to make sure we've got our wpa-psk flags */
-	s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
+	s_vpn = nm_connection_get_setting_vpn (connection);
 	g_assert (s_vpn);
 
 	success = nm_setting_get_secret_flags (NM_SETTING (s_vpn),
@@ -460,7 +460,7 @@ upgrade_08_openvpn_not_saved_cb (NMConnection *connection, gpointer user_data)
 	gboolean success;
 
 	/* And check to make sure we've got our wpa-psk flags */
-	s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
+	s_vpn = nm_connection_get_setting_vpn (connection);
 	g_assert (s_vpn);
 
 	success = nm_setting_get_secret_flags (NM_SETTING (s_vpn),
diff --git a/src/libnm-gtk/nm-wireless-dialog.c b/src/libnm-gtk/nm-wireless-dialog.c
index ec04a83..7c77515 100644
--- a/src/libnm-gtk/nm-wireless-dialog.c
+++ b/src/libnm-gtk/nm-wireless-dialog.c
@@ -272,7 +272,7 @@ stuff_changed_cb (WirelessSecurity *sec, gpointer user_data)
 	
 	if (priv->connection) {
 		NMSettingWireless *s_wireless;
-		s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (priv->connection, NM_TYPE_SETTING_WIRELESS));
+		s_wireless = nm_connection_get_setting_wireless (priv->connection);
 		g_assert (s_wireless);
 		ssid = (GByteArray *) nm_setting_wireless_get_ssid (s_wireless);
 		free_ssid = FALSE;
@@ -375,7 +375,7 @@ connection_combo_changed (GtkWidget *combo,
 	if (priv->connection) {
 		const GByteArray *ssid;
 
-		s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (priv->connection, NM_TYPE_SETTING_WIRELESS));
+		s_wireless = nm_connection_get_setting_wireless (priv->connection);
 		ssid = nm_setting_wireless_get_ssid (s_wireless);
 		utf8_ssid = nm_utils_ssid_to_utf8 (ssid);
 		gtk_entry_set_text (GTK_ENTRY (widget), utf8_ssid);
@@ -405,8 +405,8 @@ alphabetize_connections (NMConnection *a, NMConnection *b)
 {
 	NMSettingConnection *asc, *bsc;
 
-	asc = NM_SETTING_CONNECTION (nm_connection_get_setting (a, NM_TYPE_SETTING_CONNECTION));
-	bsc = NM_SETTING_CONNECTION (nm_connection_get_setting (b, NM_TYPE_SETTING_CONNECTION));
+	asc = nm_connection_get_setting_connection (a);
+	bsc = nm_connection_get_setting_connection (b);
 
 	return strcmp (nm_setting_connection_get_id (asc),
 		       nm_setting_connection_get_id (bsc));
@@ -468,7 +468,7 @@ connection_combo_init (NMAWirelessDialog *self, NMConnection *connection)
 			const char *mode;
 			const GByteArray *setting_mac;
 
-			s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (candidate, NM_TYPE_SETTING_CONNECTION));
+			s_con = nm_connection_get_setting_connection (candidate);
 			connection_type = s_con ? nm_setting_connection_get_connection_type (s_con) : NULL;
 			if (!connection_type)
 				continue;
@@ -476,7 +476,7 @@ connection_combo_init (NMAWirelessDialog *self, NMConnection *connection)
 			if (strcmp (connection_type, NM_SETTING_WIRELESS_SETTING_NAME))
 				continue;
 
-			s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (candidate, NM_TYPE_SETTING_WIRELESS));
+			s_wireless = nm_connection_get_setting_wireless (candidate);
 			if (!s_wireless)
 				continue;
 
@@ -485,7 +485,7 @@ connection_combo_init (NMAWirelessDialog *self, NMConnection *connection)
 				NMSettingIP4Config *s_ip4;
 				const char *method = NULL;
 
-				s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (candidate, NM_TYPE_SETTING_IP4_CONFIG);
+				s_ip4 = nm_connection_get_setting_ip4_config (candidate);
 				if (s_ip4)
 					method = nm_setting_ip4_config_get_method (s_ip4);
 
@@ -522,7 +522,7 @@ connection_combo_init (NMAWirelessDialog *self, NMConnection *connection)
 		for (iter = to_add; iter; iter = g_slist_next (iter)) {
 			NMConnection *candidate = NM_CONNECTION (iter->data);
 
-			s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (candidate, NM_TYPE_SETTING_CONNECTION));
+			s_con = nm_connection_get_setting_connection (candidate);
 			gtk_list_store_append (store, &tree_iter);
 			gtk_list_store_set (store, &tree_iter,
 			                    C_NAME_COLUMN, nm_setting_connection_get_id (s_con),
@@ -874,14 +874,13 @@ security_combo_init (NMAWirelessDialog *self, gboolean secrets_only)
 		const char *mode;
 		const char *security;
 
-		s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (priv->connection, NM_TYPE_SETTING_WIRELESS));
+		s_wireless = nm_connection_get_setting_wireless (priv->connection);
 
 		mode = nm_setting_wireless_get_mode (s_wireless);
 		if (mode && !strcmp (mode, "adhoc"))
 			is_adhoc = TRUE;
 
-		wsec = NM_SETTING_WIRELESS_SECURITY (nm_connection_get_setting (priv->connection, 
-										NM_TYPE_SETTING_WIRELESS_SECURITY));
+		wsec = nm_connection_get_setting_wireless_security (priv->connection);
 
 		security = nm_setting_wireless_get_security (s_wireless);
 		if (!security || strcmp (security, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME))
@@ -1153,7 +1152,7 @@ internal_init (NMAWirelessDialog *self,
 		NMSettingWireless *s_wireless;
 		const GByteArray *ssid;
 
-		s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (priv->connection, NM_TYPE_SETTING_WIRELESS));
+		s_wireless = nm_connection_get_setting_wireless (priv->connection);
 		ssid = s_wireless ? nm_setting_wireless_get_ssid (s_wireless) : NULL;
 		if (ssid)
 			esc_ssid = nm_utils_ssid_to_utf8 (ssid);
@@ -1248,7 +1247,7 @@ nma_wireless_dialog_get_connection (NMAWirelessDialog *self,
 		wireless_security_unref (sec);
 	} else {
 		/* Unencrypted */
-		s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
+		s_wireless = nm_connection_get_setting_wireless (connection);
 		g_assert (s_wireless);
 
 		g_object_set (s_wireless, NM_SETTING_WIRELESS_SEC, NULL, NULL);
diff --git a/src/utils/utils.c b/src/utils/utils.c
index 0eb5e2d..09f4a70 100644
--- a/src/utils/utils.c
+++ b/src/utils/utils.c
@@ -247,7 +247,7 @@ utils_check_ap_compatible (NMAccessPoint *ap,
 	g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), FALSE);
 	g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
 
-	s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
+	s_wireless = nm_connection_get_setting_wireless (connection);
 	if (s_wireless == NULL)
 		return FALSE;
 	
@@ -297,8 +297,7 @@ utils_check_ap_compatible (NMAccessPoint *ap,
 			return FALSE;
 	}
 
-	s_wireless_sec = (NMSettingWirelessSecurity *) nm_connection_get_setting (connection,
-	                                                                          NM_TYPE_SETTING_WIRELESS_SECURITY);
+	s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
 
 	return nm_setting_wireless_ap_security_compatible (s_wireless,
 	                                                   s_wireless_sec,
@@ -329,7 +328,7 @@ connection_valid_for_wired (NMConnection *connection,
 	if (!is_pppoe && strcmp (connection_type, NM_SETTING_WIRED_SETTING_NAME))
 		return FALSE;
 
-	s_wired = NM_SETTING_WIRED (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRED));
+	s_wired = nm_connection_get_setting_wired (connection);
 	if (!is_pppoe && !s_wired)
 		return FALSE;
 
@@ -369,7 +368,7 @@ connection_valid_for_wireless (NMConnection *connection,
 	if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_WIRELESS_SETTING_NAME))
 		return FALSE;
 
-	s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
+	s_wireless = nm_connection_get_setting_wireless (connection);
 	g_return_val_if_fail (s_wireless != NULL, FALSE);
 
 	/* Match MAC address */
@@ -401,7 +400,7 @@ connection_valid_for_wireless (NMConnection *connection,
 	if (!setting_security || strcmp (setting_security, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME))
 		return TRUE; /* all devices can do unencrypted networks */
 
-	s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY));
+	s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
 	if (!s_wireless_sec)
 		return TRUE; /* all devices can do unencrypted networks */
 
@@ -455,7 +454,7 @@ connection_valid_for_gsm (NMConnection *connection,
 	if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_GSM_SETTING_NAME))
 		return FALSE;
 
-	s_gsm = NM_SETTING_GSM (nm_connection_get_setting (connection, NM_TYPE_SETTING_GSM));
+	s_gsm = nm_connection_get_setting_gsm (connection);
 	g_return_val_if_fail (s_gsm != NULL, FALSE);
 
 	return TRUE;
@@ -472,7 +471,7 @@ connection_valid_for_cdma (NMConnection *connection,
 	if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_CDMA_SETTING_NAME))
 		return FALSE;
 
-	s_cdma = NM_SETTING_CDMA (nm_connection_get_setting (connection, NM_TYPE_SETTING_CDMA));
+	s_cdma = nm_connection_get_setting_cdma (connection);
 	g_return_val_if_fail (s_cdma != NULL, FALSE);
 
 	return TRUE;
@@ -484,7 +483,7 @@ get_connection_bt_type (NMConnection *connection)
 	NMSettingBluetooth *s_bt;
 	const char *bt_type;
 
-	s_bt = (NMSettingBluetooth *) nm_connection_get_setting (connection, NM_TYPE_SETTING_BLUETOOTH);
+	s_bt = nm_connection_get_setting_bluetooth (connection);
 	if (!s_bt)
 		return NM_BT_CAPABILITY_NONE;
 
@@ -515,7 +514,7 @@ connection_valid_for_bt (NMConnection *connection,
 	if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_BLUETOOTH_SETTING_NAME))
 		return FALSE;
 
-	s_bt = NM_SETTING_BLUETOOTH (nm_connection_get_setting (connection, NM_TYPE_SETTING_BLUETOOTH));
+	s_bt = nm_connection_get_setting_bluetooth (connection);
 	if (!s_bt)
 		return FALSE;
 
@@ -555,7 +554,7 @@ connection_valid_for_wimax (NMConnection *connection,
 	if (strcmp (connection_type, NM_SETTING_WIMAX_SETTING_NAME))
 		return FALSE;
 
-	s_wimax = (NMSettingWimax *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIMAX);
+	s_wimax = nm_connection_get_setting_wimax (connection);
 	if (!s_wimax)
 		return FALSE;
 
@@ -588,7 +587,7 @@ utils_connection_valid_for_device (NMConnection *connection,
 	g_return_val_if_fail (connection != NULL, FALSE);
 	g_return_val_if_fail (device != NULL, FALSE);
 
-	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+	s_con = nm_connection_get_setting_connection (connection);
 	g_return_val_if_fail (s_con != NULL, FALSE);
 	g_return_val_if_fail (nm_setting_connection_get_connection_type (s_con) != NULL, FALSE);
 
@@ -739,7 +738,7 @@ utils_create_keyring_add_attr_list (NMConnection *connection,
 	NMSettingConnection *s_con;
 
 	if (connection) {
-		s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
+		s_con = nm_connection_get_setting_connection (connection);
 		g_return_val_if_fail (s_con != NULL, NULL);
 		connection_uuid = nm_setting_connection_get_uuid (s_con);
 		connection_id = nm_setting_connection_get_id (s_con);
diff --git a/src/wired-dialog.c b/src/wired-dialog.c
index 6e03fe4..921886c 100644
--- a/src/wired-dialog.c
+++ b/src/wired-dialog.c
@@ -47,7 +47,7 @@ dialog_set_network_name (NMConnection *connection, GtkEntry *entry)
 {
 	NMSettingConnection *setting;
 
-	setting = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+	setting = nm_connection_get_setting_connection (connection);
 
 	gtk_widget_set_sensitive (GTK_WIDGET (entry), FALSE);
 	gtk_entry_set_text (entry, nm_setting_connection_get_id (setting));
diff --git a/src/wireless-security/eap-method-fast.c b/src/wireless-security/eap-method-fast.c
index db4d40a..e34c3f5 100644
--- a/src/wireless-security/eap-method-fast.c
+++ b/src/wireless-security/eap-method-fast.c
@@ -136,7 +136,7 @@ fill_connection (EAPMethod *parent, NMConnection *connection)
 	gboolean enabled;
 	int pac_provisioning = 0;
 
-	s_8021x = NM_SETTING_802_1X (nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X));
+	s_8021x = nm_connection_get_setting_802_1x (connection);
 	g_assert (s_8021x);
 
 	nm_setting_802_1x_add_eap_method (s_8021x, "fast");
@@ -355,7 +355,7 @@ eap_method_fast_new (WirelessSecurity *ws_parent,
 	method->is_editor = is_editor;
 
 	if (connection)
-		s_8021x = NM_SETTING_802_1X (nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X));
+		s_8021x = nm_connection_get_setting_802_1x (connection);
 
 
 	widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_pac_provision_combo"));
diff --git a/src/wireless-security/eap-method-leap.c b/src/wireless-security/eap-method-leap.c
index c29fd49..2f57e8a 100644
--- a/src/wireless-security/eap-method-leap.c
+++ b/src/wireless-security/eap-method-leap.c
@@ -86,7 +86,7 @@ fill_connection (EAPMethod *parent, NMConnection *connection)
 	NMSetting8021x *s_8021x;
 	GtkWidget *widget;
 
-	s_8021x = NM_SETTING_802_1X (nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X));
+	s_8021x = nm_connection_get_setting_802_1x (connection);
 	g_assert (s_8021x);
 
 	nm_setting_802_1x_add_eap_method (s_8021x, "leap");
@@ -139,7 +139,7 @@ eap_method_leap_new (WirelessSecurity *ws_parent,
 	if (connection) {
 		NMSetting8021x *s_8021x;
 
-		s_8021x = NM_SETTING_802_1X (nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X));
+		s_8021x = nm_connection_get_setting_802_1x (connection);
 		if (s_8021x && nm_setting_802_1x_get_identity (s_8021x))
 			gtk_entry_set_text (GTK_ENTRY (widget), nm_setting_802_1x_get_identity (s_8021x));
 	}
diff --git a/src/wireless-security/eap-method-peap.c b/src/wireless-security/eap-method-peap.c
index c53eb71..a2d2a27 100644
--- a/src/wireless-security/eap-method-peap.c
+++ b/src/wireless-security/eap-method-peap.c
@@ -130,7 +130,7 @@ fill_connection (EAPMethod *parent, NMConnection *connection)
 	int peapver_active = 0;
 	GError *error = NULL;
 
-	s_8021x = NM_SETTING_802_1X (nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X));
+	s_8021x = nm_connection_get_setting_802_1x (connection);
 	g_assert (s_8021x);
 
 	nm_setting_802_1x_add_eap_method (s_8021x, "peap");
@@ -341,7 +341,7 @@ eap_method_peap_new (WirelessSecurity *ws_parent,
 	method->is_editor = is_editor;
 
 	if (connection)
-		s_8021x = NM_SETTING_802_1X (nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X));
+		s_8021x = nm_connection_get_setting_802_1x (connection);
 
 	widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_peap_ca_cert_button"));
 	g_assert (widget);
diff --git a/src/wireless-security/eap-method-simple.c b/src/wireless-security/eap-method-simple.c
index 08a84bf..d814194 100644
--- a/src/wireless-security/eap-method-simple.c
+++ b/src/wireless-security/eap-method-simple.c
@@ -100,7 +100,7 @@ fill_connection (EAPMethod *parent, NMConnection *connection)
 	const char *eap = NULL;
 	NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
 
-	s_8021x = NM_SETTING_802_1X (nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X));
+	s_8021x = nm_connection_get_setting_802_1x (connection);
 	g_assert (s_8021x);
 
 	/* If this is the main EAP method, clear any existing methods because the
@@ -237,7 +237,7 @@ eap_method_simple_new (WirelessSecurity *ws_parent,
 	                  (GCallback) wireless_security_changed_cb,
 	                  ws_parent);
 	if (connection) {
-		s_8021x = NM_SETTING_802_1X (nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X));
+		s_8021x = nm_connection_get_setting_802_1x (connection);
 		if (s_8021x && nm_setting_802_1x_get_identity (s_8021x))
 			gtk_entry_set_text (GTK_ENTRY (widget), nm_setting_802_1x_get_identity (s_8021x));
 	}
diff --git a/src/wireless-security/eap-method-tls.c b/src/wireless-security/eap-method-tls.c
index ece62c1..1ef042b 100644
--- a/src/wireless-security/eap-method-tls.c
+++ b/src/wireless-security/eap-method-tls.c
@@ -124,7 +124,7 @@ fill_connection (EAPMethod *parent, NMConnection *connection)
 	const char *password = NULL;
 	GError *error = NULL;
 
-	s_8021x = NM_SETTING_802_1X (nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X));
+	s_8021x = nm_connection_get_setting_802_1x (connection);
 	g_assert (s_8021x);
 
 	if (parent->phase2)
@@ -359,7 +359,7 @@ update_secrets (EAPMethod *parent, NMConnection *connection)
 	                          password_func);
 
 	/* Set the private key filepicker button path if we have a private key */
-	s_8021x = (NMSetting8021x *) nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X);
+	s_8021x = nm_connection_get_setting_802_1x (connection);
 	if (s_8021x && (scheme_func (s_8021x) == NM_SETTING_802_1X_CK_SCHEME_PATH)) {
 		filename = path_func (s_8021x);
 		if (filename) {
@@ -396,7 +396,7 @@ eap_method_tls_new (WirelessSecurity *ws_parent,
 	eap_method_nag_init (parent, "eap_tls_ca_cert_button", connection);
 
 	if (connection)
-		s_8021x = NM_SETTING_802_1X (nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X));
+		s_8021x = nm_connection_get_setting_802_1x (connection);
 
 	widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_identity_entry"));
 	g_assert (widget);
diff --git a/src/wireless-security/eap-method-ttls.c b/src/wireless-security/eap-method-ttls.c
index 1a4d6e8..7183ce0 100644
--- a/src/wireless-security/eap-method-ttls.c
+++ b/src/wireless-security/eap-method-ttls.c
@@ -125,7 +125,7 @@ fill_connection (EAPMethod *parent, NMConnection *connection)
 	GtkTreeIter iter;
 	GError *error = NULL;
 
-	s_8021x = NM_SETTING_802_1X (nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X));
+	s_8021x = nm_connection_get_setting_802_1x (connection);
 	g_assert (s_8021x);
 
 	nm_setting_802_1x_add_eap_method (s_8021x, "ttls");
@@ -341,7 +341,7 @@ eap_method_ttls_new (WirelessSecurity *ws_parent,
 	method->is_editor = is_editor;
 
 	if (connection)
-		s_8021x = NM_SETTING_802_1X (nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X));
+		s_8021x = nm_connection_get_setting_802_1x (connection);
 
 	widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_ttls_ca_cert_button"));
 	g_assert (widget);
diff --git a/src/wireless-security/eap-method.c b/src/wireless-security/eap-method.c
index a785564..04d4c32 100644
--- a/src/wireless-security/eap-method.c
+++ b/src/wireless-security/eap-method.c
@@ -253,7 +253,7 @@ eap_method_nag_init (EAPMethod *method,
 		NMSettingConnection *s_con;
 		const char *uuid;
 
-		s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+		s_con = nm_connection_get_setting_connection (connection);
 		g_assert (s_con);
 		uuid = nm_setting_connection_get_uuid (s_con);
 		g_assert (uuid);
diff --git a/src/wireless-security/wireless-security.c b/src/wireless-security/wireless-security.c
index 3377479..6ca0aa0 100644
--- a/src/wireless-security/wireless-security.c
+++ b/src/wireless-security/wireless-security.c
@@ -217,8 +217,7 @@ wireless_security_clear_ciphers (NMConnection *connection)
 
 	g_return_if_fail (connection != NULL);
 
-	s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (nm_connection_get_setting (connection,
-										  NM_TYPE_SETTING_WIRELESS_SECURITY));
+	s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
 	g_assert (s_wireless_sec);
 
 	nm_setting_wireless_security_clear_protos (s_wireless_sec);
@@ -354,7 +353,7 @@ ws_802_1x_auth_combo_init (WirelessSecurity *sec,
 		    || nm_connection_get_setting_wired (connection))
 			wired = TRUE;
 
-		s_8021x = (NMSetting8021x *) nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X);
+		s_8021x = nm_connection_get_setting_802_1x (connection);
 		if (s_8021x && nm_setting_802_1x_get_num_eap_methods (s_8021x))
 			default_method = nm_setting_802_1x_get_eap_method (s_8021x, 0);
 	}
@@ -467,7 +466,7 @@ ws_802_1x_fill_connection (WirelessSecurity *sec,
 	GtkTreeModel *model;
 	GtkTreeIter iter;
 
-	s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
+	s_wireless = nm_connection_get_setting_wireless (connection);
 	g_assert (s_wireless);
 
 	g_object_set (s_wireless, NM_SETTING_WIRELESS_SEC, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NULL);
diff --git a/src/wireless-security/ws-dynamic-wep.c b/src/wireless-security/ws-dynamic-wep.c
index 2e9c636..1714336 100644
--- a/src/wireless-security/ws-dynamic-wep.c
+++ b/src/wireless-security/ws-dynamic-wep.c
@@ -71,8 +71,7 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
 
 	ws_802_1x_fill_connection (parent, "dynamic_wep_auth_combo", connection);
 
-	s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (nm_connection_get_setting (connection, 
-										  NM_TYPE_SETTING_WIRELESS_SECURITY));
+	s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
 	g_assert (s_wireless_sec);
 
 	g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", NULL);
diff --git a/src/wireless-security/ws-leap.c b/src/wireless-security/ws-leap.c
index acf8bbf..051ed16 100644
--- a/src/wireless-security/ws-leap.c
+++ b/src/wireless-security/ws-leap.c
@@ -84,7 +84,7 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
 	GtkWidget *widget;
 	const char *leap_password = NULL, *leap_username = NULL;
 
-	s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
+	s_wireless = nm_connection_get_setting_wireless (connection);
 	g_assert (s_wireless);
 
 	g_object_set (s_wireless, NM_SETTING_WIRELESS_SEC, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NULL);
@@ -138,7 +138,7 @@ ws_leap_new (NMConnection *connection, gboolean secrets_only)
 		return NULL;
 
 	if (connection) {
-		wsec = NM_SETTING_WIRELESS_SECURITY (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY));
+		wsec = nm_connection_get_setting_wireless_security (connection);
 		if (wsec) {
 			const char *auth_alg;
 
diff --git a/src/wireless-security/ws-wep-key.c b/src/wireless-security/ws-wep-key.c
index 2b2a72b..89946b8 100644
--- a/src/wireless-security/ws-wep-key.c
+++ b/src/wireless-security/ws-wep-key.c
@@ -156,7 +156,7 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
 	key = gtk_entry_get_text (GTK_ENTRY (widget));
 	strcpy (sec->keys[sec->cur_index], key);
 
-	s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
+	s_wireless = nm_connection_get_setting_wireless (connection);
 	g_assert (s_wireless);
 
 	g_object_set (s_wireless, NM_SETTING_WIRELESS_SEC, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NULL);
@@ -225,7 +225,7 @@ update_secrets (WirelessSecurity *parent, NMConnection *connection)
 	const char *tmp;
 	int i;
 
-	s_wsec = (NMSettingWirelessSecurity *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY);
+	s_wsec = nm_connection_get_setting_wireless_security (connection);
 	for (i = 0; s_wsec && i < 4; i++) {
 		tmp = nm_setting_wireless_security_get_wep_key (s_wsec, i);
 		if (tmp)
@@ -274,12 +274,12 @@ ws_wep_key_new (NMConnection *connection,
 		NMSettingWireless *s_wireless;
 		const char *mode, *auth_alg;
 
-		s_wireless = (NMSettingWireless *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS);
+		s_wireless = nm_connection_get_setting_wireless (connection);
 		mode = s_wireless ? nm_setting_wireless_get_mode (s_wireless) : NULL;
 		if (mode && !strcmp (mode, "adhoc"))
 			is_adhoc = TRUE;
 
-		s_wsec = NM_SETTING_WIRELESS_SECURITY (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY));
+		s_wsec = nm_connection_get_setting_wireless_security (connection);
 		if (s_wsec) {
 			auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec);
 			if (auth_alg && !strcmp (auth_alg, "shared"))
diff --git a/src/wireless-security/ws-wpa-eap.c b/src/wireless-security/ws-wpa-eap.c
index 68b0293..d74347f 100644
--- a/src/wireless-security/ws-wpa-eap.c
+++ b/src/wireless-security/ws-wpa-eap.c
@@ -72,8 +72,7 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
 
 	ws_802_1x_fill_connection (parent, "wpa_eap_auth_combo", connection);
 
-	s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (nm_connection_get_setting (connection, 
-										  NM_TYPE_SETTING_WIRELESS_SECURITY));
+	s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
 	g_assert (s_wireless_sec);
 
 	g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-eap", NULL);
diff --git a/src/wireless-security/ws-wpa-psk.c b/src/wireless-security/ws-wpa-psk.c
index 6964338..f1962f1 100644
--- a/src/wireless-security/ws-wpa-psk.c
+++ b/src/wireless-security/ws-wpa-psk.c
@@ -97,7 +97,7 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
 	const char *mode;
 	gboolean is_adhoc = FALSE;
 
-	s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
+	s_wireless = nm_connection_get_setting_wireless (connection);
 	g_assert (s_wireless);
 
 	mode = nm_setting_wireless_get_mode (s_wireless);



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