Index: protocols/msn/msn.c
===================================================================
--- protocols/msn/msn.c	(revision 9bf248155cb870be9dce921d58c905f5a5c1dad3)
+++ protocols/msn/msn.c	(revision 70ac4771ebf3358d7bec9bd6fe37cde4c23223bc)
@@ -31,16 +31,12 @@
 GSList *msn_switchboards;
 
-static char *msn_set_display_name( set_t *set, char *value );
+static char *set_eval_display_name( set_t *set, char *value );
 
 static void msn_init( account_t *acc )
 {
-	set_t *s;
-	
-	s = set_add( &acc->set, "display_name", NULL, msn_set_display_name, acc );
-	s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY;
-
-	s = set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc );
-	
-	s = set_add( &acc->set, "switchboard_keepalives", "false", set_eval_bool, acc );
+	set_add( &acc->set, "display_name", NULL, set_eval_display_name, acc );
+	set_add( &acc->set, "local_display_name", "false", set_eval_bool, acc );
+	set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc );
+	set_add( &acc->set, "switchboard_keepalives", "false", set_eval_bool, acc );
 }
 
@@ -83,4 +79,10 @@
 	if( md )
 	{
+		/** Disabling MSN ft support for now.
+		while( md->filetransfers ) {
+			imcb_file_canceled( md->filetransfers->data, "Closing connection" );
+		}
+		*/
+		
 		if( md->fd >= 0 )
 			closesocket( md->fd );
@@ -102,4 +104,13 @@
 		g_free( md->grouplist );
 		
+		while( md->grpq )
+		{
+			struct msn_groupadd *ga = md->grpq->data;
+			g_free( ga->group );
+			g_free( ga->who );
+			g_free( ga );
+			md->grpq = g_slist_remove( md->grpq, ga );
+		}
+		
 		g_free( md );
 	}
@@ -120,4 +131,12 @@
 	struct msn_switchboard *sb;
 	
+#ifdef DEBUG
+	if( strcmp( who, "raw" ) == 0 )
+	{
+		msn_write( ic, message, strlen( message ) );
+		msn_write( ic, "\r\n", 2 );
+	}
+	else
+#endif
 	if( ( sb = msn_sb_by_handle( ic, who ) ) )
 	{
@@ -169,5 +188,5 @@
 static void msn_set_my_name( struct im_connection *ic, char *info )
 {
-	msn_set_display_name( set_find( &ic->acc->set, "display_name" ), info );
+	msn_set_display_name( ic, info );
 }
 
@@ -180,5 +199,5 @@
 static void msn_add_buddy( struct im_connection *ic, char *who, char *group )
 {
-	msn_buddy_list_add( ic, "FL", who, who );
+	msn_buddy_list_add( ic, "FL", who, who, group );
 }
 
@@ -221,4 +240,5 @@
 {
 	struct msn_switchboard *sb;
+	struct groupchat *c = imcb_chat_new( ic, who );
 	
 	if( ( sb = msn_sb_by_handle( ic, who ) ) )
@@ -238,8 +258,6 @@
 		msn_sb_write_msg( ic, m );
 
-		return NULL;
-	}
-	
-	return NULL;
+		return c;
+	}
 }
 
@@ -251,5 +269,5 @@
 static void msn_add_permit( struct im_connection *ic, char *who )
 {
-	msn_buddy_list_add( ic, "AL", who, who );
+	msn_buddy_list_add( ic, "AL", who, who, NULL );
 }
 
@@ -263,5 +281,5 @@
 	struct msn_switchboard *sb;
 	
-	msn_buddy_list_add( ic, "BL", who, who );
+	msn_buddy_list_add( ic, "BL", who, who, NULL );
 	
 	/* If there's still a conversation with this person, close it. */
@@ -285,16 +303,12 @@
 }
 
-static char *msn_set_display_name( set_t *set, char *value )
+static char *set_eval_display_name( set_t *set, char *value )
 {
 	account_t *acc = set->data;
 	struct im_connection *ic = acc->ic;
-	struct msn_data *md;
-	char buf[1024], *fn;
-	
-	/* Double-check. */
+	
+	/* Allow any name if we're offline. */
 	if( ic == NULL )
-		return NULL;
-	
-	md = ic->proto_data;
+		return value;
 	
 	if( strlen( value ) > 129 )
@@ -303,15 +317,9 @@
 		return NULL;
 	}
-	
-	fn = msn_http_encode( value );
-	
-	g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, ic->acc->user, fn );
-	msn_write( ic, buf, strlen( buf ) );
-	g_free( fn );
 	
 	/* Returning NULL would be better, because the server still has to
 	   confirm the name change. However, it looks a bit confusing to the
 	   user. */
-	return value;
+	return msn_set_display_name( ic, value ) ? value : NULL;
 }
 
@@ -342,4 +350,5 @@
 	ret->send_typing = msn_send_typing;
 	ret->handle_cmp = g_strcasecmp;
+	//ret->transfer_request = msn_ftp_transfer_request;
 
 	register_protocol(ret);
