Index: storage_xml.c
===================================================================
--- storage_xml.c	(revision b84800d89604dee6fd837a2b8ab549346607e774)
+++ storage_xml.c	(revision 15d146925d949882037c60cab12abcbee6651fab)
@@ -54,6 +54,4 @@
 	char *current_setting;
 	account_t *current_account;
-	struct chat *current_chat;
-	set_t **current_set_head;
 	char *given_nick;
 	char *given_pass;
@@ -174,14 +172,5 @@
 		
 		if( ( setting = xml_attr( attr_names, attr_values, "name" ) ) )
-		{
-			if( xd->current_chat != NULL )
-				xd->current_set_head = &xd->current_chat->set;
-			else if( xd->current_account != NULL )
-				xd->current_set_head = &xd->current_account->set;
-			else
-				xd->current_set_head = &xd->irc->set;
-			
 			xd->current_setting = g_strdup( setting );
-		}
 		else
 			g_set_error( error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
@@ -205,21 +194,4 @@
 		}
 	}
-	else if( g_strcasecmp( element_name, "chat" ) == 0 )
-	{
-		char *handle, *channel;
-		
-		handle = xml_attr( attr_names, attr_values, "handle" );
-		channel = xml_attr( attr_names, attr_values, "channel" );
-		
-		if( xd->current_account && handle && channel )
-		{
-			xd->current_chat = chat_add( xd->irc, xd->current_account, handle, channel );
-		}
-		else
-		{
-			g_set_error( error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
-			             "Missing attributes for %s element", element_name );
-		}
-	}
 	else
 	{
@@ -242,8 +214,4 @@
 		xd->current_account = NULL;
 	}
-	else if( g_strcasecmp( element_name, "chat" ) == 0 )
-	{
-		xd->current_chat = NULL;
-	}
 }
 
@@ -252,4 +220,5 @@
 	char text[text_len+1];
 	struct xml_parsedata *xd = data;
+	irc_t *irc = xd->irc;
 	
 	strncpy( text, text_orig, text_len );
@@ -264,5 +233,6 @@
 	else if( g_strcasecmp( g_markup_parse_context_get_element( ctx ), "setting" ) == 0 && xd->current_setting )
 	{
-		set_setstr( xd->current_set_head, xd->current_setting, (char*) text );
+		set_setstr( xd->current_account ? &xd->current_account->set : &irc->set,
+		            xd->current_setting, (char*) text );
 		g_free( xd->current_setting );
 		xd->current_setting = NULL;
@@ -288,5 +258,5 @@
 }
 
-static storage_status_t xml_load_real( const char *my_nick, const char *password, irc_t *irc, xml_pass_st action )
+static storage_status_t xml_load_real( irc_t *irc, const char *my_nick, const char *password, xml_pass_st action )
 {
 	GMarkupParseContext *ctx;
@@ -295,7 +265,4 @@
 	GError *gerr = NULL;
 	int fd, st;
-	
-	if( irc && irc->status & USTATUS_IDENTIFIED )
-		return( 1 );
 	
 	xd = g_new0( struct xml_parsedata, 1 );
@@ -350,12 +317,10 @@
 		return STORAGE_OK;
 	
-	irc->status |= USTATUS_IDENTIFIED;
-	
 	return STORAGE_OK;
 }
 
-static storage_status_t xml_load( const char *my_nick, const char *password, irc_t *irc )
-{
-	return xml_load_real( my_nick, password, irc, XML_PASS_UNKNOWN );
+static storage_status_t xml_load( irc_t *irc, const char *password )
+{
+	return xml_load_real( irc, irc->nick, password, XML_PASS_UNKNOWN );
 }
 
@@ -364,5 +329,5 @@
 	/* This is a little bit risky because we have to pass NULL for the
 	   irc_t argument. This *should* be fine, if I didn't miss anything... */
-	return xml_load_real( my_nick, password, NULL, XML_PASS_CHECK_ONLY );
+	return xml_load_real( NULL, my_nick, password, XML_PASS_CHECK_ONLY );
 }
 
@@ -399,10 +364,4 @@
 	md5_byte_t pass_md5[21];
 	md5_state_t md5_state;
-	
-	if( irc->password == NULL )
-	{
-		irc_usermsg( irc, "Please register yourself if you want to save your settings." );
-		return STORAGE_OTHER_ERROR;
-	}
 	
 	path2 = g_strdup( irc->nick );
@@ -438,5 +397,5 @@
 	
 	for( set = irc->set; set; set = set->next )
-		if( set->value )
+		if( set->value && set->def )
 			if( !xml_printf( fd, 1, "<setting name=\"%s\">%s</setting>\n", set->key, set->value ) )
 				goto write_error;
@@ -447,5 +406,4 @@
 		char *pass_b64;
 		int pass_len;
-		struct chat *c;
 		
 		pass_len = arc_encode( acc->pass, strlen( acc->pass ), (unsigned char**) &pass_cr, irc->password, 12 );
@@ -466,5 +424,5 @@
 		
 		for( set = acc->set; set; set = set->next )
-			if( set->value && !( set->flags & ACC_SET_NOSAVE ) )
+			if( set->value && set->def && !( set->flags & ACC_SET_NOSAVE ) )
 				if( !xml_printf( fd, 2, "<setting name=\"%s\">%s</setting>\n", set->key, set->value ) )
 					goto write_error;
@@ -480,23 +438,4 @@
 			goto write_error;
 		
-		for( c = irc->chatrooms; c; c = c->next )
-		{
-			if( c->acc != acc )
-				continue;
-			
-			if( !xml_printf( fd, 2, "<chat handle=\"%s\" channel=\"%s\" type=\"%s\">\n",
-			                        c->handle, c->channel, "room" ) )
-				goto write_error;
-			
-			for( set = c->set; set; set = set->next )
-				if( set->value && !( set->flags & ACC_SET_NOSAVE ) )
-					if( !xml_printf( fd, 3, "<setting name=\"%s\">%s</setting>\n",
-					                        set->key, set->value ) )
-						goto write_error;
-
-			if( !xml_printf( fd, 2, "</chat>\n" ) )
-				goto write_error;
-		}
-		
 		if( !xml_printf( fd, 1, "</account>\n" ) )
 			goto write_error;
