network-manager-applet r989 - in trunk: . src src/connection-editor src/gconf-helpers



Author: dcbw
Date: Wed Oct 29 14:37:22 2008
New Revision: 989
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=989&view=rev

Log:
2008-10-29  Dan Williams  <dcbw redhat com>

	* src/applet-dialogs.c
	  src/connection-editor/ip4-routes-dialog.c
	  src/connection-editor/ip4-routes-dialog.h
	  src/connection-editor/page-ip4.c
	  src/gconf-helpers/gconf-upgrade.c
	  src/wireless-dialog.c
		- Use IP4 setting accessors; fix leaks



Modified:
   trunk/ChangeLog
   trunk/src/applet-dialogs.c
   trunk/src/connection-editor/ip4-routes-dialog.c
   trunk/src/connection-editor/ip4-routes-dialog.h
   trunk/src/connection-editor/page-ip4.c
   trunk/src/gconf-helpers/gconf-upgrade.c
   trunk/src/wireless-dialog.c

Modified: trunk/src/applet-dialogs.c
==============================================================================
--- trunk/src/applet-dialogs.c	(original)
+++ trunk/src/applet-dialogs.c	Wed Oct 29 14:37:22 2008
@@ -239,7 +239,7 @@
 	const char *iface;
 	NMIP4Config *ip4_config;
 	const GArray *dns;
-	NMSettingIP4Address *def_addr;
+	NMIP4Address *def_addr;
 	guint32 hostmask, network, bcast, netmask;
 	int row = 0;
 
@@ -345,13 +345,13 @@
 							   create_info_label (_("IP Address:")),
 							   0, 1, row, row + 1);
 	gtk_table_attach_defaults (table,
-							   create_info_label (ip4_address_as_string (def_addr->address)),
+							   create_info_label (ip4_address_as_string (nm_ip4_address_get_address (def_addr))),
 							   1, 2, row, row + 1);
 	row++;
 
 	/* Broadcast */
-	netmask = nm_utils_ip4_prefix_to_netmask (def_addr->prefix);
-	network = ntohl (def_addr->address) & ntohl (netmask);
+	netmask = nm_utils_ip4_prefix_to_netmask (nm_ip4_address_get_prefix (def_addr));
+	network = ntohl (nm_ip4_address_get_address (def_addr)) & ntohl (netmask);
 	hostmask = ~ntohl (netmask);
 	bcast = htonl (network | hostmask);
 
@@ -373,12 +373,12 @@
 	row++;
 
 	/* Gateway */
-	if (def_addr->gateway) {
+	if (nm_ip4_address_get_gateway (def_addr)) {
 		gtk_table_attach_defaults (table,
 								   create_info_label (_("Default Route:")),
 								   0, 1, row, row + 1);
 		gtk_table_attach_defaults (table,
-								   create_info_label (ip4_address_as_string (def_addr->gateway)),
+								   create_info_label (ip4_address_as_string (nm_ip4_address_get_gateway (def_addr))),
 								   1, 2, row, row + 1);
 		row++;
 	}

Modified: trunk/src/connection-editor/ip4-routes-dialog.c
==============================================================================
--- trunk/src/connection-editor/ip4-routes-dialog.c	(original)
+++ trunk/src/connection-editor/ip4-routes-dialog.c	Wed Oct 29 14:37:22 2008
@@ -52,7 +52,7 @@
 	widget = glade_xml_get_widget (xml, "ip4_routes");
 	store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (widget)));
 	gtk_list_store_append (store, &iter);
-	gtk_list_store_set (store, &iter, 0, g_strdup (""), -1);
+	gtk_list_store_set (store, &iter, COL_ADDRESS, "", -1);
 
 	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
 	gtk_tree_selection_select_iter (selection, &iter);
@@ -186,19 +186,17 @@
 }
 
 GtkWidget *
-ip4_routes_dialog_new (GSList *routes,
-                       gboolean automatic,
-                       gboolean ignore_auto_routes)
+ip4_routes_dialog_new (NMSettingIP4Config *s_ip4, gboolean automatic)
 {
 	GladeXML *xml;
 	GtkWidget *dialog, *widget;
-	GSList *iter;
 	GtkListStore *store;
 	GtkTreeIter model_iter;
 	GtkTreeSelection *selection;
 	gint offset;
 	GtkTreeViewColumn *column;
 	GtkCellRenderer *renderer;
+	int i;
 
 	xml = glade_xml_new (GLADEDIR "/ce-page-ip4.glade", "ip4_routes_dialog", NULL);
 	if (!xml) {
@@ -221,10 +219,11 @@
 	store = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
 
 	/* Add existing routes */
-	for (iter = routes; iter; iter = g_slist_next (iter)) {
-		NMSettingIP4Route *route = (NMSettingIP4Route *) iter->data;
+	for (i = 0; i < nm_setting_ip4_config_get_num_routes (s_ip4); i++) {
+		NMIP4Route *route = nm_setting_ip4_config_get_route (s_ip4, i);
 		struct in_addr tmp_addr;
-		char ip_string[50];
+		char ip_string[INET_ADDRSTRLEN];
+		char *tmp;
 
 		if (!route) {
 			g_warning ("%s: empty IP4 route structure!", __func__);
@@ -233,17 +232,21 @@
 
 		gtk_list_store_append (store, &model_iter);
 
-		tmp_addr.s_addr = route->address;
+		tmp_addr.s_addr = nm_ip4_route_get_dest (route);;
 		if (inet_ntop (AF_INET, &tmp_addr, &ip_string[0], sizeof (ip_string)))
-			gtk_list_store_set (store, &model_iter, COL_ADDRESS, g_strdup (ip_string), -1);
+			gtk_list_store_set (store, &model_iter, COL_ADDRESS, ip_string, -1);
 
-		gtk_list_store_set (store, &model_iter, COL_PREFIX, g_strdup_printf ("%d", route->prefix), -1);
+		tmp = g_strdup_printf ("%d", nm_ip4_route_get_prefix (route));
+		gtk_list_store_set (store, &model_iter, COL_PREFIX, tmp, -1);
+		g_free (tmp);
 
-		tmp_addr.s_addr = route->next_hop;
+		tmp_addr.s_addr = nm_ip4_route_get_next_hop (route);
 		if (inet_ntop (AF_INET, &tmp_addr, &ip_string[0], sizeof (ip_string)))
-			gtk_list_store_set (store, &model_iter, COL_NEXT_HOP, g_strdup (ip_string), -1);
+			gtk_list_store_set (store, &model_iter, COL_NEXT_HOP, ip_string, -1);
 
-		gtk_list_store_set (store, &model_iter, COL_METRIC, g_strdup_printf ("%d", route->metric), -1);
+		tmp = g_strdup_printf ("%d", nm_ip4_route_get_metric (route));
+		gtk_list_store_set (store, &model_iter, COL_METRIC, tmp, -1);
+		g_free (tmp);
 	}
 
 	widget = glade_xml_get_widget (xml, "ip4_routes");
@@ -327,7 +330,8 @@
 	                  glade_xml_get_widget (xml, "ip4_routes"));
 
 	widget = glade_xml_get_widget (xml, "ip4_ignore_auto_routes");
-	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), ignore_auto_routes);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget),
+	                              nm_setting_ip4_config_get_ignore_auto_routes (s_ip4));
 	gtk_widget_set_sensitive (widget, automatic);
 
 	return dialog;
@@ -415,13 +419,11 @@
 	model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
 	iter_valid = gtk_tree_model_get_iter_first (model, &tree_iter);
 
-	g_slist_foreach (s_ip4->routes, (GFunc) g_free, NULL);
-	g_slist_free (s_ip4->routes);
-	s_ip4->routes = NULL;
+	nm_setting_ip4_config_clear_routes (s_ip4);
 
 	while (iter_valid) {
 		guint32 addr = 0, prefix = 0, next_hop = 0, metric = 0;
-		NMSettingIP4Route *route;
+		NMIP4Route *route;
 
 		/* Address */
 		if (!get_one_addr (model, &tree_iter, COL_ADDRESS, "address", TRUE, &addr))
@@ -437,19 +439,21 @@
 		/* Prefix (optional) */
 		get_one_int (model, &tree_iter, COL_METRIC, "metric", G_MAXUINT32, &metric);
 
-		route = g_malloc0 (sizeof (NMSettingIP4Route));
-		route->address = addr;
-		route->prefix = prefix;
-		route->next_hop = next_hop;
-		route->metric = metric;
-
-		s_ip4->routes = g_slist_append (s_ip4->routes, route);
+		route = nm_ip4_route_new ();
+		nm_ip4_route_set_dest (route, addr);
+		nm_ip4_route_set_prefix (route, prefix);
+		nm_ip4_route_set_next_hop (route, next_hop);
+		nm_ip4_route_set_metric (route, metric);
+		nm_setting_ip4_config_add_route (s_ip4, route);
+		nm_ip4_route_unref (route);
 
 	next:
 		iter_valid = gtk_tree_model_iter_next (model, &tree_iter);
 	}
 
 	widget = glade_xml_get_widget (xml, "ip4_ignore_auto_routes");
-	s_ip4->ignore_auto_routes = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+	g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES,
+	              gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)),
+	              NULL);
 }
 

Modified: trunk/src/connection-editor/ip4-routes-dialog.h
==============================================================================
--- trunk/src/connection-editor/ip4-routes-dialog.h	(original)
+++ trunk/src/connection-editor/ip4-routes-dialog.h	Wed Oct 29 14:37:22 2008
@@ -28,9 +28,7 @@
 
 #include "nm-setting-ip4-config.h"
 
-GtkWidget *ip4_routes_dialog_new (GSList *routes,
-                                  gboolean automatic,
-                                  gboolean ignore_auto_routes);
+GtkWidget *ip4_routes_dialog_new (NMSettingIP4Config *s_ip4, gboolean automatic);
 
 void ip4_routes_dialog_update_setting (GtkWidget *dialog, NMSettingIP4Config *s_ip4);
 

Modified: trunk/src/connection-editor/page-ip4.c
==============================================================================
--- trunk/src/connection-editor/page-ip4.c	(original)
+++ trunk/src/connection-editor/page-ip4.c	Wed Oct 29 14:37:22 2008
@@ -23,6 +23,7 @@
 #include <string.h>
 #include <errno.h>
 #include <stdlib.h>
+#include <arpa/inet.h>
 
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>
@@ -267,23 +268,25 @@
 	NMSettingIP4Config *setting = priv->setting;
 	GtkListStore *store;
 	GtkTreeIter model_iter;
-	GSList *iter;
 	int method = IP4_METHOD_AUTO;
 	GString *string = NULL;
 	SetMethodInfo info;
+	const char *str_method;
+	int i;
 
 	/* Method */
 	gtk_combo_box_set_active (priv->method, 0);
-	if (setting->method) {
-		if (!strcmp (setting->method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL))
+	str_method = nm_setting_ip4_config_get_method (setting);
+	if (str_method) {
+		if (!strcmp (str_method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL))
 			method = IP4_METHOD_LINK_LOCAL;
-		else if (!strcmp (setting->method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL))
+		else if (!strcmp (str_method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL))
 			method = IP4_METHOD_MANUAL;
-		else if (!strcmp (setting->method, NM_SETTING_IP4_CONFIG_METHOD_SHARED))
+		else if (!strcmp (str_method, NM_SETTING_IP4_CONFIG_METHOD_SHARED))
 			method = IP4_METHOD_SHARED;
 	}
 
-	if (method == IP4_METHOD_AUTO && setting->ignore_auto_dns)
+	if (method == IP4_METHOD_AUTO && nm_setting_ip4_config_get_ignore_auto_dns (setting))
 		method = IP4_METHOD_AUTO_ADDRESSES;
 
 	info.method = method;
@@ -292,10 +295,12 @@
 
 	/* Addresses */
 	store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
-	for (iter = setting->addresses; iter; iter = g_slist_next (iter)) {
-		NMSettingIP4Address *addr = (NMSettingIP4Address *) iter->data;
+	for (i = 0; i < nm_setting_ip4_config_get_num_addresses (setting); i++) {
+		NMIP4Address *addr = nm_setting_ip4_config_get_address (setting, i);
 		struct in_addr tmp_addr;
-		gchar *ip_string;
+		char buf[INET_ADDRSTRLEN + 1];
+		char *tmp;
+		const char *ignored;
 
 		if (!addr) {
 			g_warning ("%s: empty IP4 Address structure!", __func__);
@@ -304,15 +309,17 @@
 
 		gtk_list_store_append (store, &model_iter);
 
-		tmp_addr.s_addr = addr->address;
-		ip_string = inet_ntoa (tmp_addr);
-		gtk_list_store_set (store, &model_iter, COL_ADDRESS, g_strdup (ip_string), -1);
-
-		gtk_list_store_set (store, &model_iter, COL_PREFIX, g_strdup_printf ("%d", addr->prefix), -1);
-
-		tmp_addr.s_addr = addr->gateway;
-		ip_string = inet_ntoa (tmp_addr);
-		gtk_list_store_set (store, &model_iter, COL_GATEWAY, g_strdup (ip_string), -1);
+		tmp_addr.s_addr = nm_ip4_address_get_address (addr);
+		ignored = inet_ntop (AF_INET, &tmp_addr, &buf[0], sizeof (buf));
+		gtk_list_store_set (store, &model_iter, COL_ADDRESS, buf, -1);
+
+		tmp = g_strdup_printf ("%d", nm_ip4_address_get_prefix (addr));
+		gtk_list_store_set (store, &model_iter, COL_PREFIX, tmp, -1);
+		g_free (tmp);
+
+		tmp_addr.s_addr = nm_ip4_address_get_gateway (addr);
+		ignored = inet_ntop (AF_INET, &tmp_addr, &buf[0], sizeof (buf));
+		gtk_list_store_set (store, &model_iter, COL_GATEWAY, buf, -1);
 	}
 
 	gtk_tree_view_set_model (priv->addr_list, GTK_TREE_MODEL (store));
@@ -321,41 +328,39 @@
 	g_object_unref (store);
 
 	/* DNS servers */
-	if (setting->dns) {
-		int i;
-
-		string = g_string_new ("");
-		for (i = 0; i < setting->dns->len; i++) {
-			struct in_addr tmp_addr;
-			char *ip_string;
-
-			tmp_addr.s_addr = g_array_index (setting->dns, guint32, i);
-			if (!tmp_addr.s_addr)
-				continue;
+	string = g_string_new ("");
+	for (i = 0; i < nm_setting_ip4_config_get_num_dns (setting); i++) {
+		struct in_addr tmp_addr;
+		char buf[INET_ADDRSTRLEN + 1];
+		const char *ignored;
 
-			ip_string = inet_ntoa (tmp_addr);
-			if (string->len)
-				g_string_append (string, ", ");
-			g_string_append (string, ip_string);
-		}
+		tmp_addr.s_addr = nm_setting_ip4_config_get_dns (setting, i);
+		if (!tmp_addr.s_addr)
+			continue;
 
-		gtk_entry_set_text (priv->dns_servers, string->str);
-		g_string_free (string, TRUE);
+		ignored = inet_ntop (AF_INET, &tmp_addr, &buf[0], sizeof (buf));
+		if (string->len)
+			g_string_append (string, ", ");
+		g_string_append (string, buf);
 	}
+	gtk_entry_set_text (priv->dns_servers, string->str);
+	g_string_free (string, TRUE);
 
 	/* DNS searches */
 	string = g_string_new ("");
-	for (iter = setting->dns_search; iter; iter = g_slist_next (iter)) {
+	for (i = 0; i < nm_setting_ip4_config_get_num_dns_searches (setting); i++) {
 		if (string->len)
 			g_string_append (string, ", ");
-		g_string_append (string, g_strdup (iter->data));
+		g_string_append (string, nm_setting_ip4_config_get_dns_search (setting, i));
 	}
 	gtk_entry_set_text (priv->dns_searches, string->str);
 	g_string_free (string, TRUE);
 
 	if ((method == IP4_METHOD_AUTO) || (method = IP4_METHOD_AUTO_ADDRESSES)) {
-		if (setting->dhcp_client_id)
-			gtk_entry_set_text (priv->dhcp_client_id, setting->dhcp_client_id);
+		if (nm_setting_ip4_config_get_dhcp_client_id (setting)) {
+			gtk_entry_set_text (priv->dhcp_client_id,
+			                    nm_setting_ip4_config_get_dhcp_client_id (setting));
+		}
 	}
 }
 
@@ -372,7 +377,7 @@
 
 	store = GTK_LIST_STORE (gtk_tree_view_get_model (priv->addr_list));
 	gtk_list_store_append (store, &iter);
-	gtk_list_store_set (store, &iter, 0, g_strdup (""), -1);
+	gtk_list_store_set (store, &iter, COL_ADDRESS, "", -1);
 
 	selection = gtk_tree_view_get_selection (priv->addr_list);
 	gtk_tree_selection_select_iter (selection, &iter);
@@ -529,14 +534,17 @@
 	CEPageIP4Private *priv = CE_PAGE_IP4_GET_PRIVATE (self);
 	GtkWidget *dialog, *toplevel;
 	gboolean automatic = FALSE;
+	const char *method;
+	char *tmp;
 
 	toplevel = gtk_widget_get_toplevel (CE_PAGE (self)->page);
 	g_return_if_fail (GTK_WIDGET_TOPLEVEL (toplevel));
 
-	if (!priv->setting->method || !strcmp (priv->setting->method, NM_SETTING_IP4_CONFIG_METHOD_AUTO))
+	method = nm_setting_ip4_config_get_method (priv->setting);
+	if (!method || !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO))
 		automatic = TRUE;
-	
-	dialog = ip4_routes_dialog_new (priv->setting->routes, automatic, priv->setting->ignore_auto_routes);
+
+	dialog = ip4_routes_dialog_new (priv->setting, automatic);
 	if (!dialog) {
 		g_warning ("%s: failed to create the routes dialog!", __func__);
 		return;
@@ -549,7 +557,9 @@
 	}
 
 	gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (toplevel));
-	gtk_window_set_title (GTK_WINDOW (dialog), g_strdup_printf (_("Editing IPv4 routes for %s"), priv->connection_id));
+	tmp = g_strdup_printf (_("Editing IPv4 routes for %s"), priv->connection_id);
+	gtk_window_set_title (GTK_WINDOW (dialog), tmp);
+	g_free (tmp);
 
 	g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (routes_dialog_response_cb), self);
 	g_signal_connect (G_OBJECT (dialog), "close", G_CALLBACK (routes_dialog_close_cb), self);

Modified: trunk/src/gconf-helpers/gconf-upgrade.c
==============================================================================
--- trunk/src/gconf-helpers/gconf-upgrade.c	(original)
+++ trunk/src/gconf-helpers/gconf-upgrade.c	Wed Oct 29 14:37:22 2008
@@ -498,10 +498,10 @@
 	}
 }
 
-static GSList *
-convert_routes (GSList *str_routes)
+static void
+add_routes (NMSettingIP4Config *s_ip4, GSList *str_routes)
 {
-	GSList *routes = NULL, *iter;
+	GSList *iter;
 
 	for (iter = str_routes; iter; iter = g_slist_next (iter)) {
 		struct in_addr tmp;
@@ -525,21 +525,20 @@
 		/* don't pass the prefix to inet_pton() */
 		*p = '\0';
 		if (inet_pton (AF_INET, str_route, &tmp) > 0) {
-			NMSettingIP4Route *route;
+			NMIP4Route *route;
 
-			route = g_new0 (NMSettingIP4Route, 1);
-			route->address = tmp.s_addr;
-			route->prefix = (guint32) prefix;
+			route = nm_ip4_route_new ();
+			nm_ip4_route_set_dest (route, tmp.s_addr);
+			nm_ip4_route_set_prefix (route, (guint32) prefix);
 
-			routes = g_slist_append (routes, route);
+			nm_setting_ip4_config_add_route (s_ip4, route);
+			nm_ip4_route_unref (route);
 		} else
 			g_warning ("Ignoring invalid route '%s'", str_route);
 
 next:
 		g_free (str_route);
 	}
-
-	return routes;
 }
 
 static NMConnection *
@@ -601,7 +600,7 @@
 
 	if (str_routes) {
 		s_ip4 = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ());
-		s_ip4->routes = convert_routes (str_routes);
+		add_routes (s_ip4, str_routes);
 	}
 
 	connection = nm_connection_new ();
@@ -1070,15 +1069,13 @@
 	gconf_client_suggest_sync (client, NULL);
 }
 
-static gboolean
-convert_route (const char *in_route, NMSettingIP4Route *converted)
+static NMIP4Route *
+convert_route (const char *in_route)
 {
+	NMIP4Route *route = NULL;
 	struct in_addr tmp;
 	char *p, *str_route;
 	long int prefix = 32;
-	gboolean success = FALSE;
-
-	memset (converted, 0, sizeof (*converted));
 
 	str_route = g_strdup (in_route);
 	p = strchr (str_route, '/');
@@ -1101,13 +1098,13 @@
 		goto out;
 	}
 
-	converted->address = tmp.s_addr;
-	converted->prefix = (guint32) prefix;
-	success = TRUE;
+	route = nm_ip4_route_new ();
+	nm_ip4_route_set_dest (route, tmp.s_addr);
+	nm_ip4_route_set_prefix (route, (guint32) prefix);
 
 out:
 	g_free (str_route);
-	return success;
+	return route;
 }
 
 #define VPN_KEY_ROUTES "routes"
@@ -1136,20 +1133,27 @@
 
 		/* Convert 'x.x.x.x/x' into a route structure */
 		for (routes_iter = old_routes; routes_iter; routes_iter = g_slist_next (routes_iter)) {
-			NMSettingIP4Route route;
+			NMIP4Route *route;
 
-			if (convert_route (routes_iter->data, &route)) {
+			route = convert_route (routes_iter->data);
+			if (route) {
 				GArray *tmp_route;
+				guint32 tmp;
 
 				if (!new_routes)
 					new_routes = g_ptr_array_sized_new (3);
 
 				tmp_route = g_array_sized_new (FALSE, TRUE, sizeof (guint32), 4);
-				g_array_append_val (tmp_route, route.address);
-				g_array_append_val (tmp_route, route.prefix);
-				g_array_append_val (tmp_route, route.next_hop);
-				g_array_append_val (tmp_route, route.metric);
+				tmp = nm_ip4_route_get_dest (route);
+				g_array_append_val (tmp_route, tmp);
+				tmp = nm_ip4_route_get_prefix (route);
+				g_array_append_val (tmp_route, tmp);
+				tmp = nm_ip4_route_get_next_hop (route);
+				g_array_append_val (tmp_route, tmp);
+				tmp = nm_ip4_route_get_metric (route);
+				g_array_append_val (tmp_route, tmp);
 				g_ptr_array_add (new_routes, tmp_route);
+				nm_ip4_route_unref (route);
 			}
 		}
 

Modified: trunk/src/wireless-dialog.c
==============================================================================
--- trunk/src/wireless-dialog.c	(original)
+++ trunk/src/wireless-dialog.c	Wed Oct 29 14:37:22 2008
@@ -428,7 +428,7 @@
 
 			s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (candidate, NM_TYPE_SETTING_CONNECTION));
 			connection_type = s_con ? nm_setting_connection_get_connection_type (s_con) : NULL;
-			if (connection_type)
+			if (!connection_type)
 				continue;
 
 			if (strcmp (connection_type, NM_SETTING_WIRELESS_SETTING_NAME))
@@ -441,9 +441,13 @@
 			/* If creating a new Ad-Hoc network, only show shared network connections */
 			if (priv->adhoc_create) {
 				NMSettingIP4Config *s_ip4;
+				const char *method = NULL;
 
 				s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (candidate, NM_TYPE_SETTING_IP4_CONFIG);
-				if (!s_ip4 || strcmp (s_ip4->method, "shared"))
+				if (s_ip4)
+					method = nm_setting_ip4_config_get_method (s_ip4);
+
+				if (!s_ip4 || strcmp (method, "shared"))
 					continue;
 
 				/* Ignore non-Ad-Hoc connections too */
@@ -1024,7 +1028,7 @@
 			g_object_set (s_wireless, NM_SETTING_WIRELESS_MODE, "adhoc", NULL);
 
 			s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
-			s_ip4->method = g_strdup ("shared");
+			g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_SHARED, NULL);
 			nm_connection_add_setting (connection, (NMSetting *) s_ip4);
 		}
 



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