changeset 26615:5149ecc8f456

Use defaults provided by the server where applicable and when available
author Paul Aurich <paul@darkrain42.org>
date Sat, 18 Apr 2009 06:52:34 +0000
parents 892ffe359b51
children 464dbfad4474
files libpurple/protocols/jabber/jabber.c
diffstat 1 files changed, 22 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jabber.c	Sat Apr 18 06:51:59 2009 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Sat Apr 18 06:52:34 2009 +0000
@@ -1015,7 +1015,7 @@
 	PurpleRequestFields *fields;
 	PurpleRequestFieldGroup *group;
 	PurpleRequestField *field;
-	xmlnode *x, *y;
+	xmlnode *x, *y, *node;
 	char *instructions;
 	JabberRegisterCBData *cbdata;
 	gboolean registered = FALSE;
@@ -1076,40 +1076,50 @@
 	group = purple_request_field_group_new(NULL);
 	purple_request_fields_add_group(fields, group);
 
-	if(xmlnode_get_child(query, "username")) {
+	if((node = xmlnode_get_child(query, "username"))) {
+		char *data = xmlnode_get_data(node);
 		if(js->registration)
-			field = purple_request_field_string_new("username", _("Username"), js->user->node, FALSE);
+			field = purple_request_field_string_new("username", _("Username"), data ? data : js->user->node, FALSE);
 		else
-			field = purple_request_field_string_new("username", _("Username"), NULL, FALSE);
+			field = purple_request_field_string_new("username", _("Username"), data, FALSE);
 
 		purple_request_field_group_add_field(group, field);
+		g_free(data);
 	}
-	if(xmlnode_get_child(query, "password")) {
+	if((node = xmlnode_get_child(query, "password"))) {
 		if(js->registration)
 			field = purple_request_field_string_new("password", _("Password"),
 										purple_connection_get_password(js->gc), FALSE);
-		else
-			field = purple_request_field_string_new("password", _("Password"), NULL, FALSE);
+		else {
+			char *data = xmlnode_get_data(node);
+			field = purple_request_field_string_new("password", _("Password"), data, FALSE);
+			g_free(data);
+		}
 
 		purple_request_field_string_set_masked(field, TRUE);
 		purple_request_field_group_add_field(group, field);
 	}
 
-	if(xmlnode_get_child(query, "name")) {
+	if((node = xmlnode_get_child(query, "name"))) {
 		if(js->registration)
 			field = purple_request_field_string_new("name", _("Name"),
 													purple_account_get_alias(js->gc->account), FALSE);
-		else
-			field = purple_request_field_string_new("name", _("Name"), NULL, FALSE);
+		else {
+			char *data = xmlnode_get_data(node);
+			field = purple_request_field_string_new("name", _("Name"), data, FALSE);
+			g_free(data);
+		}
 		purple_request_field_group_add_field(group, field);
 	}
 
 	for (i = 0; registration_fields[i].name != NULL; ++i) {
-		if (xmlnode_get_child(query, registration_fields[i].name)) {
+		if ((node = xmlnode_get_child(query, registration_fields[i].name))) {
+			char *data = xmlnode_get_data(node);
 			field = purple_request_field_string_new(registration_fields[i].name,
 			                                        _(registration_fields[i].label),
-			                                        NULL, FALSE);
+			                                        data, FALSE);
 			purple_request_field_group_add_field(group, field);
+			g_free(data);
 		}
 	}