Index: irc.c
===================================================================
--- irc.c	(revision 73cf7fd5f066d3c0720f58af840affa3e61bad12)
+++ irc.c	(revision 226fce105c1189bde1aa321b494494d49b463e90)
@@ -1011,5 +1011,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 ) );
 	}
 	
@@ -1021,6 +1021,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 );
@@ -1030,5 +1034,5 @@
 	u->sendbuf_flags = 0;
 	
-	return( FALSE );
+	return FALSE;
 }
 
@@ -1043,5 +1047,5 @@
 		if( u->sendbuf_len > 0 && u->sendbuf_flags != flags)
 		{
-			//Flush the buffer
+			/* Flush the buffer */
 			g_source_remove( u->sendbuf_timer );
 			buddy_send_handler_delayed( u );
@@ -1051,5 +1055,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;
@@ -1058,5 +1062,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 );
 		}
 		
@@ -1074,5 +1078,5 @@
 	else
 	{
-		serv_send_im( irc, u, msg, flags );
+		bim_buddy_msg( u->gc, u->handle, msg, flags );
 	}
 }
Index: irc_commands.c
===================================================================
--- irc_commands.c	(revision 73cf7fd5f066d3c0720f58af840affa3e61bad12)
+++ irc_commands.c	(revision 226fce105c1189bde1aa321b494494d49b463e90)
@@ -448,5 +448,5 @@
 		
 		if( gc && gc->flags & OPT_LOGGED_IN )
-			proto_away( gc, u->away );
+			bim_set_away( gc, u->away );
 	}
 }
Index: protocols/nogaim.c
===================================================================
--- protocols/nogaim.c	(revision 73cf7fd5f066d3c0720f58af840affa3e61bad12)
+++ protocols/nogaim.c	(revision 226fce105c1189bde1aa321b494494d49b463e90)
@@ -38,17 +38,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 );
 
@@ -158,81 +145,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 */
 
@@ -359,5 +269,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 );
 }
 
@@ -1031,10 +941,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 );
@@ -1042,5 +958,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 );
 	
@@ -1048,5 +964,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;
@@ -1064,2 +980,93 @@
 	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 );
+}
Index: protocols/nogaim.h
===================================================================
--- protocols/nogaim.h	(revision 73cf7fd5f066d3c0720f58af840affa3e61bad12)
+++ protocols/nogaim.h	(revision 226fce105c1189bde1aa321b494494d49b463e90)
@@ -194,9 +194,9 @@
 
 /* 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 nogaim_init();
-int proto_away( struct gaim_connection *gc, char *away );
 char *set_eval_away_devoice( irc_t *irc, set_t *set, char *value );
 
