Index: configure
===================================================================
--- configure	(revision 41ca004ade77a9c343efbd523dd88deb9231487e)
+++ configure	(revision 68b518d6d9a536e2117b399fe4f7fdecdd5d7131)
@@ -169,4 +169,6 @@
 fi
 
+GLIB=0
+
 if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG glib-2.0; then
 	cat<<EOF>>Makefile.settings
@@ -175,4 +177,5 @@
 EOF
 	echo '#define GLIB2' >> config.h
+	GLIB=2
 elif type glib-config > /dev/null 2> /dev/null; then
 	cat<<EOF>>Makefile.settings
@@ -181,4 +184,5 @@
 EOF
 	echo '#define GLIB1' >> config.h
+	GLIB=1
 else
 	echo 'Cannot find glib development libraries, aborting. (Install libglib-dev?)'
@@ -186,5 +190,5 @@
 fi
 
-if [ -r /usr/include/iconv.h ]; then
+if [ GLIB = 1 -o -r /usr/include/iconv.h ]; then
 	:;
 elif [ -r /usr/local/include/iconv.h ]; then
Index: ipc.h
===================================================================
--- ipc.h	(revision 41ca004ade77a9c343efbd523dd88deb9231487e)
+++ ipc.h	(revision 68b518d6d9a536e2117b399fe4f7fdecdd5d7131)
@@ -47,7 +47,7 @@
 
 void ipc_to_master( char **cmd );
-void ipc_to_master_str( char *format, ... );
+void ipc_to_master_str( char *format, ... ) G_GNUC_PRINTF( 1, 2 );
 void ipc_to_children( char **cmd );
-void ipc_to_children_str( char *format, ... );
+void ipc_to_children_str( char *format, ... ) G_GNUC_PRINTF( 1, 2 );
 
 /* We need this function in inetd mode, so let's just make it non-static. */
Index: irc.c
===================================================================
--- irc.c	(revision 41ca004ade77a9c343efbd523dd88deb9231487e)
+++ irc.c	(revision 68b518d6d9a536e2117b399fe4f7fdecdd5d7131)
@@ -832,5 +832,5 @@
 			irc_reply( irc, 332, "%s :BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", channel, c->title );
 		else
-			irc_reply( irc, 331, "%s :No topic for this channel" );
+			irc_reply( irc, 331, "%s :No topic for this channel", channel );
 	}
 }
@@ -888,5 +888,5 @@
 	if( g_hash_table_lookup( irc->watches, nick ) )
 	{
-		irc_reply( irc, 600, "%s %s %s %d :%s", u->nick, u->user, u->host, time( NULL ), "logged online" );
+		irc_reply( irc, 600, "%s %s %s %d :%s", u->nick, u->user, u->host, (int) time( NULL ), "logged online" );
 	}
 	g_free( nick );
@@ -913,5 +913,5 @@
 	if( g_hash_table_lookup( irc->watches, nick ) )
 	{
-		irc_reply( irc, 601, "%s %s %s %d :%s", u->nick, u->user, u->host, time( NULL ), "logged offline" );
+		irc_reply( irc, 601, "%s %s %s %d :%s", u->nick, u->user, u->host, (int) time( NULL ), "logged offline" );
 	}
 	g_free( nick );
@@ -1013,5 +1013,5 @@
 	else if( c && c->gc && c->gc->prpl )
 	{
-		return( serv_send_chat( irc, c->gc, c->id, s ) );
+		return( bim_chat_msg( c->gc, c->id, s ) );
 	}
 	
@@ -1023,6 +1023,10 @@
 	user_t *u = data;
 	
+	/* Shouldn't happen, but just to be sure. */
+	if( u->sendbuf_len < 2 )
+		return FALSE;
+	
 	u->sendbuf[u->sendbuf_len-2] = 0; /* Cut off the last newline */
-	serv_send_im( u->gc->irc, u, u->sendbuf, u->sendbuf_flags );
+	bim_buddy_msg( u->gc, u->handle, u->sendbuf, u->sendbuf_flags );
 	
 	g_free( u->sendbuf );
@@ -1045,5 +1049,5 @@
 		if( u->sendbuf_len > 0 && u->sendbuf_flags != flags)
 		{
-			//Flush the buffer
+			/* Flush the buffer */
 			b_event_remove( u->sendbuf_timer );
 			buddy_send_handler_delayed( u, -1, 0 );
@@ -1053,5 +1057,5 @@
 		{
 			u->sendbuf_len = strlen( msg ) + 2;
-			u->sendbuf = g_new (char, u->sendbuf_len );
+			u->sendbuf = g_new( char, u->sendbuf_len );
 			u->sendbuf[0] = 0;
 			u->sendbuf_flags = flags;
@@ -1060,5 +1064,5 @@
 		{
 			u->sendbuf_len += strlen( msg ) + 1;
-			u->sendbuf = g_renew ( char, u->sendbuf, u->sendbuf_len );
+			u->sendbuf = g_renew( char, u->sendbuf, u->sendbuf_len );
 		}
 		
@@ -1076,5 +1080,5 @@
 	else
 	{
-		serv_send_im( irc, u, msg, flags );
+		bim_buddy_msg( u->gc, u->handle, msg, flags );
 	}
 }
Index: irc.h
===================================================================
--- irc.h	(revision 41ca004ade77a9c343efbd523dd88deb9231487e)
+++ irc.h	(revision 68b518d6d9a536e2117b399fe4f7fdecdd5d7131)
@@ -103,5 +103,5 @@
 
 irc_t *irc_new( int fd );
-void irc_abort( irc_t *irc, int immed, char *format, ... );
+void irc_abort( irc_t *irc, int immed, char *format, ... ) G_GNUC_PRINTF( 3, 4 );
 void irc_free( irc_t *irc );
 
@@ -112,8 +112,8 @@
 
 void irc_vawrite( irc_t *irc, char *format, va_list params );
-void irc_write( irc_t *irc, char *format, ... );
-void irc_write_all( int now, char *format, ... );
-void irc_reply( irc_t *irc, int code, char *format, ... );
-G_MODULE_EXPORT int irc_usermsg( irc_t *irc, char *format, ... );
+void irc_write( irc_t *irc, char *format, ... ) G_GNUC_PRINTF( 2, 3 );
+void irc_write_all( int now, char *format, ... ) G_GNUC_PRINTF( 2, 3 );
+void irc_reply( irc_t *irc, int code, char *format, ... ) G_GNUC_PRINTF( 3, 4 );
+G_MODULE_EXPORT int irc_usermsg( irc_t *irc, char *format, ... ) G_GNUC_PRINTF( 2, 3 );
 char **irc_tokenize( char *buffer );
 
Index: irc_commands.c
===================================================================
--- irc_commands.c	(revision 41ca004ade77a9c343efbd523dd88deb9231487e)
+++ irc_commands.c	(revision 68b518d6d9a536e2117b399fe4f7fdecdd5d7131)
@@ -385,7 +385,7 @@
 			
 			if( u && u->online )
-				irc_reply( irc, 604, "%s %s %s %d :%s", u->nick, u->user, u->host, time( NULL ), "is online" );
+				irc_reply( irc, 604, "%s %s %s %d :%s", u->nick, u->user, u->host, (int) time( NULL ), "is online" );
 			else
-				irc_reply( irc, 605, "%s %s %s %d :%s", nick, "*", "*", time( NULL ), "is offline" );
+				irc_reply( irc, 605, "%s %s %s %d :%s", nick, "*", "*", (int) time( NULL ), "is offline" );
 		}
 		else if( cmd[i][0] == '-' )
@@ -448,5 +448,5 @@
 		
 		if( gc && gc->flags & OPT_LOGGED_IN )
-			proto_away( gc, u->away );
+			bim_set_away( gc, u->away );
 	}
 }
Index: log.h
===================================================================
--- log.h	(revision 41ca004ade77a9c343efbd523dd88deb9231487e)
+++ log.h	(revision 68b518d6d9a536e2117b399fe4f7fdecdd5d7131)
@@ -54,5 +54,5 @@
 void log_init(void);
 void log_link(int level, int output);
-void log_message(int level, char *message, ...);
+void log_message(int level, char *message, ...) G_GNUC_PRINTF( 2, 3 );
 void log_error(char *functionname);
 
Index: protocols/http_client.c
===================================================================
--- protocols/http_client.c	(revision 41ca004ade77a9c343efbd523dd88deb9231487e)
+++ protocols/http_client.c	(revision 68b518d6d9a536e2117b399fe4f7fdecdd5d7131)
@@ -240,4 +240,9 @@
 
 got_reply:
+	/* Maybe if the webserver is overloaded, or when there's bad SSL
+	   support... */
+	if( req->bytes_read == 0 )
+		goto cleanup;
+	
 	/* Zero termination is very convenient. */
 	req->reply_headers[req->bytes_read] = 0;
Index: protocols/nogaim.c
===================================================================
--- protocols/nogaim.c	(revision 41ca004ade77a9c343efbd523dd88deb9231487e)
+++ protocols/nogaim.c	(revision 68b518d6d9a536e2117b399fe4f7fdecdd5d7131)
@@ -36,17 +36,4 @@
 #include <ctype.h>
 
-static char *proto_away_alias[8][5] =
-{
-	{ "Away from computer", "Away", "Extended away", NULL },
-	{ "NA", "N/A", "Not available", NULL },
-	{ "Busy", "Do not disturb", "DND", "Occupied", NULL },
-	{ "Be right back", "BRB", NULL },
-	{ "On the phone", "Phone", "On phone", NULL },
-	{ "Out to lunch", "Lunch", "Food", NULL },
-	{ "Invisible", "Hidden" },
-	{ NULL }
-};
-static char *proto_away_alias_find( GList *gcm, char *away );
-
 static int remove_chat_buddy_silent( struct conversation *b, char *handle );
 
@@ -156,81 +143,4 @@
 GSList *get_connections() { return connections; }
 
-int proto_away( struct gaim_connection *gc, char *away )
-{
-	GList *m, *ms;
-	char *s;
-	
-	if( !away ) away = "";
-	ms = m = gc->prpl->away_states( gc );
-	
-	while( m )
-	{
-		if( *away )
-		{
-			if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 )
-				break;
-		}
-		else
-		{
-			if( g_strcasecmp( m->data, "Available" ) == 0 )
-				break;
-			if( g_strcasecmp( m->data, "Online" ) == 0 )
-				break;
-		}
-		m = m->next;
-	}
-	
-	if( m )
-	{
-		gc->prpl->set_away( gc, m->data, *away ? away : NULL );
-	}
-	else
-	{
-		s = proto_away_alias_find( ms, away );
-		if( s )
-		{
-			gc->prpl->set_away( gc, s, away );
-			if( set_getint( gc->irc, "debug" ) )
-				serv_got_crap( gc, "Setting away state to %s", s );
-		}
-		else
-			gc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away );
-	}
-	
-	g_list_free( ms );
-	
-	return( 1 );
-}
-
-static char *proto_away_alias_find( GList *gcm, char *away )
-{
-	GList *m;
-	int i, j;
-	
-	for( i = 0; *proto_away_alias[i]; i ++ )
-	{
-		for( j = 0; proto_away_alias[i][j]; j ++ )
-			if( g_strncasecmp( away, proto_away_alias[i][j], strlen( proto_away_alias[i][j] ) ) == 0 )
-				break;
-		
-		if( !proto_away_alias[i][j] )	/* If we reach the end, this row */
-			continue;		/* is not what we want. Next!    */
-		
-		/* Now find an entry in this row which exists in gcm */
-		for( j = 0; proto_away_alias[i][j]; j ++ )
-		{
-			m = gcm;
-			while( m )
-			{
-				if( g_strcasecmp( proto_away_alias[i][j], m->data ) == 0 )
-					return( proto_away_alias[i][j] );
-				m = m->next;
-			}
-		}
-	}
-	
-	return( NULL );
-}
-
 /* multi.c */
 
@@ -357,5 +267,5 @@
 	/* Also necessary when we're not away, at least for some of the
 	   protocols. */
-	proto_away( gc, u->away );
+	bim_set_away( gc, u->away );
 }
 
@@ -481,5 +391,12 @@
 	else if( gc->user->proto_opt[0] && *gc->user->proto_opt[0] )
 	{
-		u->host = g_strdup( gc->user->proto_opt[0] );
+		char *colon;
+		
+		if( ( colon = strchr( gc->user->proto_opt[0], ':' ) ) )
+			u->host = g_strndup( gc->user->proto_opt[0],
+			                     colon - gc->user->proto_opt[0] );
+		else
+			u->host = g_strdup( gc->user->proto_opt[0] );
+		
 		u->user = g_strdup( handle );
 		
@@ -1022,10 +939,16 @@
 }
 
-int serv_send_im( irc_t *irc, user_t *u, char *msg, int flags )
+
+
+
+/* The plan is to not allow straight calls to prpl functions anymore, but do
+   them all from some wrappers. We'll start to define some down here: */
+
+int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flags )
 {
 	char *buf = NULL;
 	int st;
 	
-	if( ( u->gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
+	if( ( gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
 	{
 		buf = escape_html( msg );
@@ -1033,5 +956,5 @@
 	}
 	
-	st = ((struct gaim_connection *)u->gc)->prpl->send_im( u->gc, u->handle, msg, strlen( msg ), flags );
+	st = gc->prpl->send_im( gc, handle, msg, strlen( msg ), flags );
 	g_free( buf );
 	
@@ -1039,5 +962,5 @@
 }
 
-int serv_send_chat( irc_t *irc, struct gaim_connection *gc, int id, char *msg )
+int bim_chat_msg( struct gaim_connection *gc, int id, char *msg )
 {
 	char *buf = NULL;
@@ -1055,2 +978,139 @@
 	return st;
 }
+
+static char *bim_away_alias_find( GList *gcm, char *away );
+
+int bim_set_away( struct gaim_connection *gc, char *away )
+{
+	GList *m, *ms;
+	char *s;
+	
+	if( !away ) away = "";
+	ms = m = gc->prpl->away_states( gc );
+	
+	while( m )
+	{
+		if( *away )
+		{
+			if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 )
+				break;
+		}
+		else
+		{
+			if( g_strcasecmp( m->data, "Available" ) == 0 )
+				break;
+			if( g_strcasecmp( m->data, "Online" ) == 0 )
+				break;
+		}
+		m = m->next;
+	}
+	
+	if( m )
+	{
+		gc->prpl->set_away( gc, m->data, *away ? away : NULL );
+	}
+	else
+	{
+		s = bim_away_alias_find( ms, away );
+		if( s )
+		{
+			gc->prpl->set_away( gc, s, away );
+			if( set_getint( gc->irc, "debug" ) )
+				serv_got_crap( gc, "Setting away state to %s", s );
+		}
+		else
+			gc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away );
+	}
+	
+	g_list_free( ms );
+	
+	return( 1 );
+}
+
+static char *bim_away_alias_list[8][5] =
+{
+	{ "Away from computer", "Away", "Extended away", NULL },
+	{ "NA", "N/A", "Not available", NULL },
+	{ "Busy", "Do not disturb", "DND", "Occupied", NULL },
+	{ "Be right back", "BRB", NULL },
+	{ "On the phone", "Phone", "On phone", NULL },
+	{ "Out to lunch", "Lunch", "Food", NULL },
+	{ "Invisible", "Hidden" },
+	{ NULL }
+};
+
+static char *bim_away_alias_find( GList *gcm, char *away )
+{
+	GList *m;
+	int i, j;
+	
+	for( i = 0; *bim_away_alias_list[i]; i ++ )
+	{
+		for( j = 0; bim_away_alias_list[i][j]; j ++ )
+			if( g_strncasecmp( away, bim_away_alias_list[i][j], strlen( bim_away_alias_list[i][j] ) ) == 0 )
+				break;
+		
+		if( !bim_away_alias_list[i][j] )	/* If we reach the end, this row */
+			continue;			/* is not what we want. Next!    */
+		
+		/* Now find an entry in this row which exists in gcm */
+		for( j = 0; bim_away_alias_list[i][j]; j ++ )
+		{
+			m = gcm;
+			while( m )
+			{
+				if( g_strcasecmp( bim_away_alias_list[i][j], m->data ) == 0 )
+					return( bim_away_alias_list[i][j] );
+				m = m->next;
+			}
+		}
+	}
+	
+	return( NULL );
+}
+
+void bim_add_allow( struct gaim_connection *gc, char *handle )
+{
+	if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) == NULL )
+	{
+		gc->permit = g_slist_prepend( gc->permit, g_strdup( handle ) );
+	}
+	
+	gc->prpl->add_permit( gc, handle );
+}
+
+void bim_rem_allow( struct gaim_connection *gc, char *handle )
+{
+	GSList *l;
+	
+	if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) ) )
+	{
+		g_free( l->data );
+		gc->permit = g_slist_delete_link( gc->permit, l );
+	}
+	
+	gc->prpl->rem_permit( gc, handle );
+}
+
+void bim_add_block( struct gaim_connection *gc, char *handle )
+{
+	if( g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) == NULL )
+	{
+		gc->deny = g_slist_prepend( gc->deny, g_strdup( handle ) );
+	}
+	
+	gc->prpl->add_deny( gc, handle );
+}
+
+void bim_rem_block( struct gaim_connection *gc, char *handle )
+{
+	GSList *l;
+	
+	if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) ) )
+	{
+		g_free( l->data );
+		gc->deny = g_slist_delete_link( gc->deny, l );
+	}
+	
+	gc->prpl->rem_deny( gc, handle );
+}
Index: protocols/nogaim.h
===================================================================
--- protocols/nogaim.h	(revision 41ca004ade77a9c343efbd523dd88deb9231487e)
+++ protocols/nogaim.h	(revision 68b518d6d9a536e2117b399fe4f7fdecdd5d7131)
@@ -52,5 +52,5 @@
 #define BUDDY_ALIAS_MAXLEN 388   /* because MSN names can be 387 characters */
 
-#define WEBSITE "http://www.bitlee.org/"
+#define WEBSITE "http://www.bitlbee.org/"
 #define IM_FLAG_AWAY 0x0020
 #define OPT_CONN_HTML 0x00000001
@@ -194,9 +194,14 @@
 
 /* nogaim.c */
-int serv_send_im(irc_t *irc, user_t *u, char *msg, int flags);
-int serv_send_chat(irc_t *irc, struct gaim_connection *gc, int id, char *msg );
+int bim_set_away( struct gaim_connection *gc, char *away );
+int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flags );
+int bim_chat_msg( struct gaim_connection *gc, int id, char *msg );
+
+void bim_add_allow( struct gaim_connection *gc, char *handle );
+void bim_rem_allow( struct gaim_connection *gc, char *handle );
+void bim_add_block( struct gaim_connection *gc, char *handle );
+void bim_rem_block( struct gaim_connection *gc, char *handle );
 
 void nogaim_init();
-int proto_away( struct gaim_connection *gc, char *away );
 char *set_eval_away_devoice( irc_t *irc, set_t *set, char *value );
 
@@ -210,5 +215,5 @@
 G_MODULE_EXPORT void hide_login_progress( struct gaim_connection *gc, char *msg );
 G_MODULE_EXPORT void hide_login_progress_error( struct gaim_connection *gc, char *msg );
-G_MODULE_EXPORT void serv_got_crap( struct gaim_connection *gc, char *format, ... );
+G_MODULE_EXPORT void serv_got_crap( struct gaim_connection *gc, char *format, ... ) G_GNUC_PRINTF( 2, 3 );
 G_MODULE_EXPORT void account_online( struct gaim_connection *gc );
 G_MODULE_EXPORT void signoff( struct gaim_connection *gc );
Index: protocols/oscar/aim.h
===================================================================
--- protocols/oscar/aim.h	(revision 41ca004ade77a9c343efbd523dd88deb9231487e)
+++ protocols/oscar/aim.h	(revision 68b518d6d9a536e2117b399fe4f7fdecdd5d7131)
@@ -728,6 +728,9 @@
 };
 
-#define AIM_CHATFLAGS_NOREFLECT 0x0001
-#define AIM_CHATFLAGS_AWAY      0x0002
+#define AIM_CHATFLAGS_NOREFLECT 	0x0001
+#define AIM_CHATFLAGS_AWAY      	0x0002
+#define AIM_CHATFLAGS_UNICODE		0x0004
+#define AIM_CHATFLAGS_ISO_8859_1	0x0008
+
 int aim_chat_send_im(aim_session_t *sess, aim_conn_t *conn, guint16 flags, const char *msg, int msglen);
 int aim_chat_join(aim_session_t *sess, aim_conn_t *conn, guint16 exchange, const char *roomname, guint16 instance);
Index: protocols/oscar/chat.c
===================================================================
--- protocols/oscar/chat.c	(revision 41ca004ade77a9c343efbd523dd88deb9231487e)
+++ protocols/oscar/chat.c	(revision 68b518d6d9a536e2117b399fe4f7fdecdd5d7131)
@@ -159,5 +159,19 @@
 	if (flags & AIM_CHATFLAGS_AWAY)
 		aim_addtlvtochain_noval(&otl, 0x0007);
-
+	
+	/* [WvG] This wasn't there originally, but we really should send
+	         the right charset flags, as we also do with normal
+	         messages. Hope this will work. :-) */
+	/*
+	if (flags & AIM_CHATFLAGS_UNICODE)
+		aimbs_put16(&fr->data, 0x0002);
+	else if (flags & AIM_CHATFLAGS_ISO_8859_1)
+		aimbs_put16(&fr->data, 0x0003);
+	else
+		aimbs_put16(&fr->data, 0x0000);
+	
+	aimbs_put16(&fr->data, 0x0000);
+	*/
+	
 	/*
 	 * SubTLV: Type 1: Message
Index: protocols/oscar/im.c
===================================================================
--- protocols/oscar/im.c	(revision 41ca004ade77a9c343efbd523dd88deb9231487e)
+++ protocols/oscar/im.c	(revision 68b518d6d9a536e2117b399fe4f7fdecdd5d7131)
@@ -1469,5 +1469,5 @@
 	    case 0x9c:	/* ICQ 5 seems to send this */
                 aim_send_im_ch2_statusmessage(sess, userinfo->sn, args->cookie,
-                        gc->away, sess->aim_icq_state, dc);
+                        gc->away ? gc->away : "", sess->aim_icq_state, dc);
                 break;
 
Index: protocols/oscar/oscar.c
===================================================================
--- protocols/oscar/oscar.c	(revision 41ca004ade77a9c343efbd523dd88deb9231487e)
+++ protocols/oscar/oscar.c	(revision 68b518d6d9a536e2117b399fe4f7fdecdd5d7131)
@@ -2,4 +2,6 @@
  * gaim
  *
+ * Some code copyright (C) 2002-2006, Jelmer Vernooij <jelmer@samba.org>
+ *                                    and the BitlBee team.
  * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
  * libfaim code copyright 1998, 1999 Adam Fritzler <afritz@auk.cx>
@@ -136,7 +138,7 @@
 	int i, j;
 	char *x = strchr(name, '-');
-	if (!x) return NULL;
+	if (!x) return g_strdup(name);
 	x = strchr(++x, '-');
-	if (!x) return NULL;
+	if (!x) return g_strdup(name);
 	tmp = g_strdup(++x);
 
@@ -390,5 +392,5 @@
 	if (g_strcasecmp(user->proto_opt[USEROPT_AUTH], "login.icq.com") != 0 &&
 	    g_strcasecmp(user->proto_opt[USEROPT_AUTH], "login.oscar.aol.com") != 0) {
-		serv_got_crap(gc, "Warning: Unknown OSCAR server: `%s'. Please review your configuration if the connection fails.");
+		serv_got_crap(gc, "Warning: Unknown OSCAR server: `%s'. Please review your configuration if the connection fails.",user->proto_opt[USEROPT_AUTH]);
 	}
 	
@@ -2517,4 +2519,5 @@
 	int ret;
 	guint8 len = strlen(message);
+	guint16 flags;
 	char *s;
 	
@@ -2525,5 +2528,7 @@
 		if (*s & 128)
 			break;
-	  	
+	
+	flags = AIM_CHATFLAGS_NOREFLECT;
+	
 	/* Message contains high ASCII chars, time for some translation! */
 	if (*s) {
@@ -2532,6 +2537,8 @@
 		   If we can't, fall back to UTF16. */
 		if ((ret = do_iconv("UTF-8", "ISO8859-1", message, s, len, BUF_LONG)) >= 0) {
+			flags |= AIM_CHATFLAGS_ISO_8859_1;
 			len = ret;
 		} else if ((ret = do_iconv("UTF-8", "UNICODEBIG", message, s, len, BUF_LONG)) >= 0) {
+			flags |= AIM_CHATFLAGS_UNICODE;
 			len = ret;
 		} else {
@@ -2544,5 +2551,5 @@
 	}
 	  	
-	ret = aim_chat_send_im(od->sess, ccon->conn, AIM_CHATFLAGS_NOREFLECT, s, len);
+	ret = aim_chat_send_im(od->sess, ccon->conn, flags, s, len);
 	  	
 	if (s != message) {	
@@ -2617,7 +2624,7 @@
 	int ret;
 	static int chat_id = 0;
-	char * chatname = g_new0(char, strlen(gc->username)+4);
-	
-	g_snprintf(chatname, strlen(gc->username) + 4, "%s%d", gc->username, chat_id++);
+	char * chatname;
+	
+	chatname = g_strdup_printf("%s%d", gc->username, chat_id++);
   
 	ret = oscar_chat_join(gc, chatname);
Index: root_commands.c
===================================================================
--- root_commands.c	(revision 41ca004ade77a9c343efbd523dd88deb9231487e)
+++ root_commands.c	(revision 68b518d6d9a536e2117b399fe4f7fdecdd5d7131)
@@ -56,4 +56,8 @@
 				cmd[k++] = s;
 				s --;
+			}
+			else
+			{
+				break;
 			}
 		}
@@ -554,7 +558,7 @@
 	else
 	{
-		gc->prpl->rem_permit( gc, cmd[2] );
-		gc->prpl->add_deny( gc, cmd[2] );
-		irc_usermsg( irc, "Buddy `%s' moved from your permit- to your deny-list", cmd[2] );
+		bim_rem_allow( gc, cmd[2] );
+		bim_add_block( gc, cmd[2] );
+		irc_usermsg( irc, "Buddy `%s' moved from your allow- to your block-list", cmd[2] );
 	}
 }
@@ -613,8 +617,8 @@
 	else
 	{
-		gc->prpl->rem_deny( gc, cmd[2] );
-		gc->prpl->add_permit( gc, cmd[2] );
-		
-		irc_usermsg( irc, "Buddy `%s' moved from your deny- to your permit-list", cmd[2] );
+		bim_rem_block( gc, cmd[2] );
+		bim_add_allow( gc, cmd[2] );
+		
+		irc_usermsg( irc, "Buddy `%s' moved from your block- to your allow-list", cmd[2] );
 	}
 }
Index: user.c
===================================================================
--- user.c	(revision 41ca004ade77a9c343efbd523dd88deb9231487e)
+++ user.c	(revision 68b518d6d9a536e2117b399fe4f7fdecdd5d7131)
@@ -168,6 +168,6 @@
 	u->nick = g_strdup( newnick );
 	if( !u->user ) u->user = u->nick;
-	if( !u->host ) u->user = u->host;
-	if( !u->realname ) u->user = u->realname;
+	if( !u->host ) u->host = u->nick;
+	if( !u->realname ) u->realname = u->nick;
 	
 	/* Remove the old reference to this user from the hash and create a
Index: util.c
===================================================================
--- util.c	(revision 41ca004ade77a9c343efbd523dd88deb9231487e)
+++ util.c	(revision 68b518d6d9a536e2117b399fe4f7fdecdd5d7131)
@@ -39,5 +39,12 @@
 #include <glib.h>
 #include <time.h>
+#ifdef GLIB2
+#define iconv_t GIConv
+#define iconv_open g_iconv_open
+#define iconv_close g_iconv_close
+#define iconv g_iconv
+#else
 #include <iconv.h>
+#endif
 
 void strip_linefeed(gchar *text)
