cpw.darkrain42.xmpp.disco: 9260183c: Use defaults provided by the server wher...

paul at darkrain42.org paul at darkrain42.org
Sat Apr 25 16:17:14 EDT 2009


-----------------------------------------------------------------
Revision: 9260183c6f6855dab27af46ebb256bc8fc71dcd1
Ancestor: d7de0393cb0ecf1d36dfaa1af478711ff793ca0c
Author: paul at darkrain42.org
Date: 2009-04-18T06:52:34
Branch: im.pidgin.cpw.darkrain42.xmpp.disco
URL: http://d.pidgin.im/viewmtn/revision/info/9260183c6f6855dab27af46ebb256bc8fc71dcd1

Modified files:
        libpurple/protocols/jabber/jabber.c

ChangeLog: 

Use defaults provided by the server where applicable and when available

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jabber.c	2f970f1aac1d4301004312513031b75824185c74
+++ libpurple/protocols/jabber/jabber.c	3cf47b47b235f3d31c24d4e0c17e2e1047718637
@@ -1015,7 +1015,7 @@ void jabber_register_parse(JabberStream 
 	PurpleRequestFields *fields;
 	PurpleRequestFieldGroup *group;
 	PurpleRequestField *field;
-	xmlnode *x, *y;
+	xmlnode *x, *y, *node;
 	char *instructions;
 	JabberRegisterCBData *cbdata;
 	gboolean registered = FALSE;
@@ -1076,40 +1076,50 @@ void jabber_register_parse(JabberStream 
 	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);
 		}
 	}
 


More information about the Commits mailing list