Index: protocols/purple/purple.c
===================================================================
--- protocols/purple/purple.c	(revision 0f7ee7e53f6bcb2d1d262a94c278440413c0103a)
+++ protocols/purple/purple.c	(revision b74b287af7ee980b01b89e911e21ec8f163d24b3)
@@ -93,4 +93,41 @@
 }
 
+static void purple_sync_settings( account_t *acc, PurpleAccount *pa )
+{
+	PurplePlugin *prpl = purple_plugins_find_with_id( pa->protocol_id );
+	PurplePluginProtocolInfo *pi = prpl->info->extra_info;
+	GList *i;
+	
+	for( i = pi->protocol_options; i; i = i->next )
+	{
+		PurpleAccountOption *o = i->data;
+		const char *name;
+		set_t *s;
+		
+		name = purple_account_option_get_setting( o );
+		s = set_find( &acc->set, name );
+		if( s->value == NULL )
+			continue;
+		
+		switch( purple_account_option_get_type( o ) )
+		{
+		case PURPLE_PREF_STRING:
+			purple_account_set_string( pa, name, set_getstr( &acc->set, name ) );
+			break;
+		
+		case PURPLE_PREF_INT:
+			purple_account_set_int( pa, name, set_getint( &acc->set, name ) );
+			break;
+		
+		case PURPLE_PREF_BOOLEAN:
+			purple_account_set_bool( pa, name, set_getbool( &acc->set, name ) );
+			break;
+		
+		default:
+			break;
+		}
+	}
+}
+
 static void purple_login( account_t *acc )
 {
@@ -103,8 +140,7 @@
 	purple_connections = g_slist_prepend( purple_connections, ic );
 	
-	pa = purple_account_new( acc->user, acc->prpl->name );
+	ic->proto_data = pa = purple_account_new( acc->user, acc->prpl->name );
 	purple_account_set_password( pa, acc->pass );
-	
-	ic->proto_data = pa;
+	purple_sync_settings( acc, pa );
 	
 	purple_account_set_enabled( pa, "BitlBee", TRUE );
@@ -117,5 +153,5 @@
 	purple_account_set_enabled( pa, "BitlBee", FALSE );
 	purple_connections = g_slist_remove( purple_connections, ic );
-	purple_account_destroy( pa );
+	purple_accounts_remove( pa );
 }
 
@@ -194,5 +230,7 @@
 	
 	if( ic != NULL )
+	{
 		imc_logout( ic, TRUE );
+	}
 }
 
Index: set.c
===================================================================
--- set.c	(revision 0f7ee7e53f6bcb2d1d262a94c278440413c0103a)
+++ set.c	(revision b74b287af7ee980b01b89e911e21ec8f163d24b3)
@@ -63,5 +63,5 @@
 }
 
-set_t *set_find( set_t **head, char *key )
+set_t *set_find( set_t **head, const char *key )
 {
 	set_t *s = *head;
@@ -77,5 +77,5 @@
 }
 
-char *set_getstr( set_t **head, char *key )
+char *set_getstr( set_t **head, const char *key )
 {
 	set_t *s = set_find( head, key );
@@ -87,5 +87,5 @@
 }
 
-int set_getint( set_t **head, char *key )
+int set_getint( set_t **head, const char *key )
 {
 	char *s = set_getstr( head, key );
@@ -101,5 +101,5 @@
 }
 
-int set_getbool( set_t **head, char *key )
+int set_getbool( set_t **head, const char *key )
 {
 	char *s = set_getstr( head, key );
@@ -111,5 +111,5 @@
 }
 
-int set_setstr( set_t **head, char *key, char *value )
+int set_setstr( set_t **head, const char *key, char *value )
 {
 	set_t *s = set_find( head, key );
@@ -150,5 +150,5 @@
 }
 
-int set_setint( set_t **head, char *key, int value )
+int set_setint( set_t **head, const char *key, int value )
 {
 	char s[24];	/* Not quite 128-bit clean eh? ;-) */
@@ -158,5 +158,5 @@
 }
 
-void set_del( set_t **head, char *key )
+void set_del( set_t **head, const char *key )
 {
 	set_t *s = *head, *t = NULL;
@@ -182,5 +182,5 @@
 }
 
-int set_reset( set_t **head, char *key )
+int set_reset( set_t **head, const char *key )
 {
 	set_t *s;
Index: set.h
===================================================================
--- set.h	(revision 0f7ee7e53f6bcb2d1d262a94c278440413c0103a)
+++ set.h	(revision b74b287af7ee980b01b89e911e21ec8f163d24b3)
@@ -76,21 +76,21 @@
 
 /* Returns the raw set_t. Might be useful sometimes. */
-set_t *set_find( set_t **head, char *key );
+set_t *set_find( set_t **head, const char *key );
 
 /* Returns a pointer to the string value of this setting. Don't modify the
    returned string, and don't free() it! */
-G_MODULE_EXPORT char *set_getstr( set_t **head, char *key );
+G_MODULE_EXPORT char *set_getstr( set_t **head, const char *key );
 
 /* Get an integer. In previous versions set_getint() was also used to read
    boolean values, but this SHOULD be done with set_getbool() now! */
-G_MODULE_EXPORT int set_getint( set_t **head, char *key );
-G_MODULE_EXPORT int set_getbool( set_t **head, char *key );
+G_MODULE_EXPORT int set_getint( set_t **head, const char *key );
+G_MODULE_EXPORT int set_getbool( set_t **head, const char *key );
 
 /* set_setstr() strdup()s the given value, so after using this function
    you can free() it, if you want. */
-int set_setstr( set_t **head, char *key, char *value );
-int set_setint( set_t **head, char *key, int value );
-void set_del( set_t **head, char *key );
-int set_reset( set_t **head, char *key );
+int set_setstr( set_t **head, const char *key, char *value );
+int set_setint( set_t **head, const char *key, int value );
+void set_del( set_t **head, const char *key );
+int set_reset( set_t **head, const char *key );
 
 /* Two very useful generic evaluators. */
