network-manager-applet r977 - in trunk: . src src/connection-editor



Author: dcbw
Date: Sun Oct 26 22:00:08 2008
New Revision: 977
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=977&view=rev

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

	Patch from Tambet Ingo <tambet gmail com>

	* src/applet-device-wired.c
	  src/connection-editor/page-dsl.c
		- Use pppoe setting accessors



Modified:
   trunk/ChangeLog
   trunk/src/applet-device-wired.c
   trunk/src/connection-editor/page-dsl.c

Modified: trunk/src/applet-device-wired.c
==============================================================================
--- trunk/src/applet-device-wired.c	(original)
+++ trunk/src/applet-device-wired.c	Sun Oct 26 22:00:08 2008
@@ -336,22 +336,22 @@
 {
 	const char *s;
 
-	g_free (pppoe->username);
-	pppoe->username = g_strdup (gtk_entry_get_text (info->username_entry));
-
-	g_free (pppoe->service);
 	s = gtk_entry_get_text (info->service_entry);
-	if (s && strlen (s) > 0)
-		pppoe->service = g_strdup (s);
+	if (s && strlen (s) < 1)
+		s = NULL;
 
-	g_free (pppoe->password);
-	pppoe->password = g_strdup (gtk_entry_get_text (info->password_entry));
+	g_object_set (pppoe,
+				  NM_SETTING_PPPOE_USERNAME, gtk_entry_get_text (info->username_entry),
+				  NM_SETTING_PPPOE_PASSWORD, gtk_entry_get_text (info->password_entry),
+				  NM_SETTING_PPPOE_SERVICE, s,
+				  NULL);
 }
 
 static void
 pppoe_update_ui (NMConnection *connection, NMPppoeInfo *info)
 {
 	NMSettingPPPOE *s_pppoe;
+	const char *s;
 
 	g_return_if_fail (NM_IS_CONNECTION (connection));
 	g_return_if_fail (info != NULL);
@@ -359,14 +359,17 @@
 	s_pppoe = (NMSettingPPPOE *) nm_connection_get_setting (connection, NM_TYPE_SETTING_PPPOE);
 	g_return_if_fail (s_pppoe != NULL);
 
-	if (s_pppoe->username)
-		gtk_entry_set_text (info->username_entry, s_pppoe->username);
-
-	if (s_pppoe->service)
-		gtk_entry_set_text (info->service_entry, s_pppoe->service);
-
-	if (s_pppoe->password)
-		gtk_entry_set_text (info->password_entry, s_pppoe->password);
+	s = nm_setting_pppoe_get_username (s_pppoe);
+	if (s)
+		gtk_entry_set_text (info->username_entry, s);
+
+	s = nm_setting_pppoe_get_service (s_pppoe);
+	if (s)
+		gtk_entry_set_text (info->service_entry, s);
+
+	s = nm_setting_pppoe_get_password (s_pppoe);
+	if (s)
+		gtk_entry_set_text (info->password_entry, s);
 	else {
 		GHashTable *secrets;
 		GError *error = NULL;

Modified: trunk/src/connection-editor/page-dsl.c
==============================================================================
--- trunk/src/connection-editor/page-dsl.c	(original)
+++ trunk/src/connection-editor/page-dsl.c	Sun Oct 26 22:00:08 2008
@@ -65,14 +65,16 @@
 {
 	CEPageDslPrivate *priv = CE_PAGE_DSL_GET_PRIVATE (self);
 	NMSettingPPPOE *setting = priv->setting;
-	char *password = setting->password;
+	const char *str;
 	GHashTable *secrets = NULL;
 
-	if (setting->username)
-		gtk_entry_set_text (priv->username, setting->username);
+	str = nm_setting_pppoe_get_username (setting);
+	if (str)
+		gtk_entry_set_text (priv->username, str);
 
 	/* Grab password from keyring if possible */
-	if (!password) {
+	str = nm_setting_pppoe_get_password (setting);
+	if (!str) {
 		GError *error = NULL;
 		GValue *value;
 
@@ -83,19 +85,20 @@
 		if (secrets) {
 			value = g_hash_table_lookup (secrets, NM_SETTING_PPPOE_PASSWORD);
 			if (value)
-				password = (char *) g_value_get_string (value);
+				str = g_value_get_string (value);
 		} else if (error)
 			g_error_free (error);
 	}
 
-	if (password)
-		gtk_entry_set_text (priv->password, password);
+	if (str)
+		gtk_entry_set_text (priv->password, str);
 
 	if (secrets)
 		g_hash_table_destroy (secrets);
 
-	if (setting->service)
-		gtk_entry_set_text (priv->service, setting->service);
+	str = nm_setting_pppoe_get_service (setting);
+	if (str)
+		gtk_entry_set_text (priv->service, str);
 }
 
 static void



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