Index: protocols/nogaim.c
===================================================================
--- protocols/nogaim.c	(revision fa29d09342c79b886efacee4cfc3078be5f5a722)
+++ protocols/nogaim.c	(revision 0da65d5fb37691ed4d31f7ab4058732f1440db6b)
@@ -36,5 +36,5 @@
 #include <ctype.h>
 
-static int remove_chat_buddy_silent( struct conversation *b, char *handle );
+static int remove_chat_buddy_silent( struct groupchat *b, char *handle );
 
 GSList *connections;
@@ -115,23 +115,23 @@
 void nogaim_init()
 {
-	extern void msn_init();
-	extern void oscar_init();
-	extern void byahoo_init();
-	extern void jabber_init();
+	extern void msn_initmodule();
+	extern void oscar_initmodule();
+	extern void byahoo_initmodule();
+	extern void jabber_initmodule();
 
 #ifdef WITH_MSN
-	msn_init();
+	msn_initmodule();
 #endif
 
 #ifdef WITH_OSCAR
-	oscar_init();
+	oscar_initmodule();
 #endif
 	
 #ifdef WITH_YAHOO
-	byahoo_init();
+	byahoo_initmodule();
 #endif
 	
 #ifdef WITH_JABBER
-	jabber_init();
+	jabber_initmodule();
 #endif
 
@@ -145,57 +145,57 @@
 /* multi.c */
 
-struct gaim_connection *new_gaim_conn( account_t *acc )
-{
-	struct gaim_connection *gc;
-	
-	gc = g_new0( struct gaim_connection, 1 );
+struct im_connection *new_gaim_conn( account_t *acc )
+{
+	struct im_connection *ic;
+	
+	ic = g_new0( struct im_connection, 1 );
 	
 	/* Maybe we should get rid of this memory waste later. ;-) */
-	g_snprintf( gc->username, sizeof( gc->username ), "%s", acc->user );
-	g_snprintf( gc->password, sizeof( gc->password ), "%s", acc->pass );
-	
-	gc->irc = acc->irc;
-	gc->acc = acc;
-	acc->gc = gc;
-	
-	connections = g_slist_append( connections, gc );
-	
-	return( gc );
-}
-
-void destroy_gaim_conn( struct gaim_connection *gc )
+	g_snprintf( ic->username, sizeof( ic->username ), "%s", acc->user );
+	g_snprintf( ic->password, sizeof( ic->password ), "%s", acc->pass );
+	
+	ic->irc = acc->irc;
+	ic->acc = acc;
+	acc->ic = ic;
+	
+	connections = g_slist_append( connections, ic );
+	
+	return( ic );
+}
+
+void destroy_gaim_conn( struct im_connection *ic )
 {
 	account_t *a;
 	
 	/* Destroy the pointer to this connection from the account list */
-	for( a = gc->irc->accounts; a; a = a->next )
-		if( a->gc == gc )
-		{
-			a->gc = NULL;
+	for( a = ic->irc->accounts; a; a = a->next )
+		if( a->ic == ic )
+		{
+			a->ic = NULL;
 			break;
 		}
 	
-	connections = g_slist_remove( connections, gc );
-	g_free( gc );
-}
-
-void set_login_progress( struct gaim_connection *gc, int step, char *msg )
-{
-	serv_got_crap( gc, "Logging in: %s", msg );
+	connections = g_slist_remove( connections, ic );
+	g_free( ic );
+}
+
+void set_login_progress( struct im_connection *ic, int step, char *msg )
+{
+	serv_got_crap( ic, "Logging in: %s", msg );
 }
 
 /* Errors *while* logging in */
-void hide_login_progress( struct gaim_connection *gc, char *msg )
-{
-	serv_got_crap( gc, "Login error: %s", msg );
+void hide_login_progress( struct im_connection *ic, char *msg )
+{
+	serv_got_crap( ic, "Login error: %s", msg );
 }
 
 /* Errors *after* logging in */
-void hide_login_progress_error( struct gaim_connection *gc, char *msg )
-{
-	serv_got_crap( gc, "Logged out: %s", msg );
-}
-
-void serv_got_crap( struct gaim_connection *gc, char *format, ... )
+void hide_login_progress_error( struct im_connection *ic, char *msg )
+{
+	serv_got_crap( ic, "Logged out: %s", msg );
+}
+
+void serv_got_crap( struct im_connection *ic, char *format, ... )
 {
 	va_list params;
@@ -207,18 +207,18 @@
 	va_end( params );
 
-	if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) ||
-	    ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) )
+	if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) ||
+	    ( ( ic->flags & OPT_CONN_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
 		strip_html( text );
 	
 	/* Try to find a different connection on the same protocol. */
-	for( a = gc->irc->accounts; a; a = a->next )
-		if( a->prpl == gc->acc->prpl && a->gc != gc )
+	for( a = ic->irc->accounts; a; a = a->next )
+		if( a->prpl == ic->acc->prpl && a->ic != ic )
 			break;
 	
 	/* If we found one, include the screenname in the message. */
 	if( a )
-		irc_usermsg( gc->irc, "%s(%s) - %s", gc->acc->prpl->name, gc->username, text );
+		irc_usermsg( ic->irc, "%s(%s) - %s", ic->acc->prpl->name, ic->username, text );
 	else
-		irc_usermsg( gc->irc, "%s - %s", gc->acc->prpl->name, text );
+		irc_usermsg( ic->irc, "%s - %s", ic->acc->prpl->name, text );
 	
 	g_free( text );
@@ -227,13 +227,13 @@
 static gboolean send_keepalive( gpointer d, gint fd, b_input_condition cond )
 {
-	struct gaim_connection *gc = d;
-	
-	if( gc->acc->prpl->keepalive )
-		gc->acc->prpl->keepalive( gc );
+	struct im_connection *ic = d;
+	
+	if( ic->acc->prpl->keepalive )
+		ic->acc->prpl->keepalive( ic );
 	
 	return TRUE;
 }
 
-void account_online( struct gaim_connection *gc )
+void account_online( struct im_connection *ic )
 {
 	user_t *u;
@@ -242,17 +242,17 @@
 	   the whole login sequence again, so these "late" calls to this
 	   function should be handled correctly. (IOW, ignored) */
-	if( gc->flags & OPT_LOGGED_IN )
+	if( ic->flags & OPT_LOGGED_IN )
 		return;
 	
-	u = user_find( gc->irc, gc->irc->nick );
-	
-	serv_got_crap( gc, "Logged in" );
-	
-	gc->keepalive = b_timeout_add( 60000, send_keepalive, gc );
-	gc->flags |= OPT_LOGGED_IN;
+	u = user_find( ic->irc, ic->irc->nick );
+	
+	serv_got_crap( ic, "Logged in" );
+	
+	ic->keepalive = b_timeout_add( 60000, send_keepalive, ic );
+	ic->flags |= OPT_LOGGED_IN;
 	
 	/* Also necessary when we're not away, at least for some of the
 	   protocols. */
-	bim_set_away( gc, u->away );
+	bim_set_away( ic, u->away );
 }
 
@@ -274,7 +274,7 @@
 }
 
-void signoff( struct gaim_connection *gc )
-{
-	irc_t *irc = gc->irc;
+void signoff( struct im_connection *ic )
+{
+	irc_t *irc = ic->irc;
 	user_t *t, *u = irc->users;
 	account_t *a;
@@ -282,19 +282,19 @@
 	/* Nested calls might happen sometimes, this is probably the best
 	   place to catch them. */
-	if( gc->flags & OPT_LOGGING_OUT )
+	if( ic->flags & OPT_LOGGING_OUT )
 		return;
 	else
-		gc->flags |= OPT_LOGGING_OUT;
-	
-	serv_got_crap( gc, "Signing off.." );
-	
-	b_event_remove( gc->keepalive );
-	gc->keepalive = 0;
-	gc->acc->prpl->close( gc );
-	b_event_remove( gc->inpa );
+		ic->flags |= OPT_LOGGING_OUT;
+	
+	serv_got_crap( ic, "Signing off.." );
+	
+	b_event_remove( ic->keepalive );
+	ic->keepalive = 0;
+	ic->acc->prpl->logout( ic );
+	b_event_remove( ic->inpa );
 	
 	while( u )
 	{
-		if( u->gc == gc )
+		if( u->ic == ic )
 		{
 			t = u->next;
@@ -306,8 +306,8 @@
 	}
 	
-	query_del_by_gc( gc->irc, gc );
+	query_del_by_conn( ic->irc, ic );
 	
 	for( a = irc->accounts; a; a = a->next )
-		if( a->gc == gc )
+		if( a->ic == ic )
 			break;
 	
@@ -316,14 +316,14 @@
 		/* Uhm... This is very sick. */
 	}
-	else if( !gc->wants_to_die && set_getbool( &irc->set, "auto_reconnect" ) &&
+	else if( !ic->wants_to_die && set_getbool( &irc->set, "auto_reconnect" ) &&
 	         set_getbool( &a->set, "auto_reconnect" ) )
 	{
 		int delay = set_getint( &irc->set, "auto_reconnect_delay" );
 		
-		serv_got_crap( gc, "Reconnecting in %d seconds..", delay );
+		serv_got_crap( ic, "Reconnecting in %d seconds..", delay );
 		a->reconnect = b_timeout_add( delay * 1000, auto_reconnect, a );
 	}
 	
-	destroy_gaim_conn( gc );
+	destroy_gaim_conn( ic );
 }
 
@@ -331,19 +331,19 @@
 /* dialogs.c */
 
-void do_error_dialog( struct gaim_connection *gc, char *msg, char *title )
+void do_error_dialog( struct im_connection *ic, char *msg, char *title )
 {
 	if( msg && title )
-		serv_got_crap( gc, "Error: %s: %s", title, msg );
+		serv_got_crap( ic, "Error: %s: %s", title, msg );
 	else if( msg )
-		serv_got_crap( gc, "Error: %s", msg );
+		serv_got_crap( ic, "Error: %s", msg );
 	else if( title )
-		serv_got_crap( gc, "Error: %s", title );
+		serv_got_crap( ic, "Error: %s", title );
 	else
-		serv_got_crap( gc, "Error" );
-}
-
-void do_ask_dialog( struct gaim_connection *gc, char *msg, void *data, void *doit, void *dont )
-{
-	query_add( gc->irc, gc, msg, doit, dont, data );
+		serv_got_crap( ic, "Error" );
+}
+
+void do_ask_dialog( struct im_connection *ic, char *msg, void *data, void *doit, void *dont )
+{
+	query_add( ic->irc, ic, msg, doit, dont, data );
 }
 
@@ -351,18 +351,18 @@
 /* list.c */
 
-void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *realname )
+void add_buddy( struct im_connection *ic, char *group, char *handle, char *realname )
 {
 	user_t *u;
 	char nick[MAX_NICK_LENGTH+1];
 	char *s;
-	irc_t *irc = gc->irc;
+	irc_t *irc = ic->irc;
 	
 	if( set_getbool( &irc->set, "debug" ) && 0 ) /* This message is too useless */
-		serv_got_crap( gc, "Receiving user add from handle: %s", handle );
-	
-	if( user_findhandle( gc, handle ) )
+		serv_got_crap( ic, "Receiving user add from handle: %s", handle );
+	
+	if( user_findhandle( ic, handle ) )
 	{
 		if( set_getbool( &irc->set, "debug" ) )
-			serv_got_crap( gc, "User already exists, ignoring add request: %s", handle );
+			serv_got_crap( ic, "User already exists, ignoring add request: %s", handle );
 		
 		return;
@@ -372,7 +372,7 @@
 	
 	memset( nick, 0, MAX_NICK_LENGTH + 1 );
-	strcpy( nick, nick_get( gc->acc, handle, realname ) );
-	
-	u = user_add( gc->irc, nick );
+	strcpy( nick, nick_get( ic->acc, handle, realname ) );
+	
+	u = user_add( ic->irc, nick );
 	
 	if( !realname || !*realname ) realname = nick;
@@ -384,13 +384,13 @@
 		u->user = g_strndup( handle, s - handle );
 	}
-	else if( gc->acc->server )
+	else if( ic->acc->server )
 	{
 		char *colon;
 		
-		if( ( colon = strchr( gc->acc->server, ':' ) ) )
-			u->host = g_strndup( gc->acc->server,
-			                     colon - gc->acc->server );
+		if( ( colon = strchr( ic->acc->server, ':' ) ) )
+			u->host = g_strndup( ic->acc->server,
+			                     colon - ic->acc->server );
 		else
-			u->host = g_strdup( gc->acc->server );
+			u->host = g_strdup( ic->acc->server );
 		
 		u->user = g_strdup( handle );
@@ -403,9 +403,9 @@
 	else
 	{
-		u->host = g_strdup( gc->acc->prpl->name );
+		u->host = g_strdup( ic->acc->prpl->name );
 		u->user = g_strdup( handle );
 	}
 	
-	u->gc = gc;
+	u->ic = ic;
 	u->handle = g_strdup( handle );
 	if( group ) u->group = g_strdup( group );
@@ -414,10 +414,10 @@
 }
 
-struct buddy *find_buddy( struct gaim_connection *gc, char *handle )
+struct buddy *find_buddy( struct im_connection *ic, char *handle )
 {
 	static struct buddy b[1];
 	user_t *u;
 	
-	u = user_findhandle( gc, handle );
+	u = user_findhandle( ic, handle );
 	
 	if( !u )
@@ -428,10 +428,10 @@
 	strncpy( b->show, u->realname, BUDDY_ALIAS_MAXLEN );
 	b->present = u->online;
-	b->gc = u->gc;
+	b->ic = u->ic;
 	
 	return( b );
 }
 
-void signoff_blocked( struct gaim_connection *gc )
+void signoff_blocked( struct im_connection *ic )
 {
 	return; /* Make all blocked users look invisible (TODO?) */
@@ -439,7 +439,7 @@
 
 
-void serv_buddy_rename( struct gaim_connection *gc, char *handle, char *realname )
-{
-	user_t *u = user_findhandle( gc, handle );
+void serv_buddy_rename( struct im_connection *ic, char *handle, char *realname )
+{
+	user_t *u = user_findhandle( ic, handle );
 	
 	if( !u ) return;
@@ -451,6 +451,6 @@
 		u->realname = g_strdup( realname );
 		
-		if( ( gc->flags & OPT_LOGGED_IN ) && set_getbool( &gc->irc->set, "display_namechanges" ) )
-			serv_got_crap( gc, "User `%s' changed name to `%s'", u->nick, u->realname );
+		if( ( ic->flags & OPT_LOGGED_IN ) && set_getbool( &ic->irc->set, "display_namechanges" ) )
+			serv_got_crap( ic, "User `%s' changed name to `%s'", u->nick, u->realname );
 	}
 }
@@ -461,5 +461,5 @@
 struct show_got_added_data
 {
-	struct gaim_connection *gc;
+	struct im_connection *ic;
 	char *handle;
 };
@@ -473,11 +473,11 @@
 void show_got_added_yes( gpointer w, struct show_got_added_data *data )
 {
-	data->gc->acc->prpl->add_buddy( data->gc, data->handle );
-	add_buddy( data->gc, NULL, data->handle, data->handle );
+	data->ic->acc->prpl->add_buddy( data->ic, data->handle, NULL );
+	add_buddy( data->ic, NULL, data->handle, data->handle );
 	
 	return show_got_added_no( w, data );
 }
 
-void show_got_added( struct gaim_connection *gc, char *handle, const char *realname )
+void show_got_added( struct im_connection *ic, char *handle, const char *realname )
 {
 	struct show_got_added_data *data = g_new0( struct show_got_added_data, 1 );
@@ -485,12 +485,12 @@
 	
 	/* TODO: Make a setting for this! */
-	if( user_findhandle( gc, handle ) != NULL )
+	if( user_findhandle( ic, handle ) != NULL )
 		return;
 	
 	s = g_strdup_printf( "The user %s is not in your buddy list yet. Do you want to add him/her now?", handle );
 	
-	data->gc = gc;
+	data->ic = ic;
 	data->handle = g_strdup( handle );
-	query_add( gc->irc, gc, s, show_got_added_yes, show_got_added_no, data );
+	query_add( ic->irc, ic, s, show_got_added_yes, show_got_added_no, data );
 }
 
@@ -498,24 +498,24 @@
 /* server.c */                    
 
-void serv_got_update( struct gaim_connection *gc, char *handle, int loggedin, int evil, time_t signon, time_t idle, int type, guint caps )
+void serv_got_update( struct im_connection *ic, char *handle, int loggedin, int evil, time_t signon, time_t idle, int type, guint caps )
 {
 	user_t *u;
 	int oa, oo;
 	
-	u = user_findhandle( gc, handle );
+	u = user_findhandle( ic, handle );
 	
 	if( !u )
 	{
-		if( g_strcasecmp( set_getstr( &gc->irc->set, "handle_unknown" ), "add" ) == 0 )
-		{
-			add_buddy( gc, NULL, handle, NULL );
-			u = user_findhandle( gc, handle );
+		if( g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "add" ) == 0 )
+		{
+			add_buddy( ic, NULL, handle, NULL );
+			u = user_findhandle( ic, handle );
 		}
 		else
 		{
-			if( set_getbool( &gc->irc->set, "debug" ) || g_strcasecmp( set_getstr( &gc->irc->set, "handle_unknown" ), "ignore" ) != 0 )
+			if( set_getbool( &ic->irc->set, "debug" ) || g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "ignore" ) != 0 )
 			{
-				serv_got_crap( gc, "serv_got_update() for handle %s:", handle );
-				serv_got_crap( gc, "loggedin = %d, type = %d", loggedin, type );
+				serv_got_crap( ic, "serv_got_update() for handle %s:", handle );
+				serv_got_crap( ic, "loggedin = %d, type = %d", loggedin, type );
 			}
 			
@@ -537,24 +537,24 @@
 	if( loggedin && !u->online )
 	{
-		irc_spawn( gc->irc, u );
+		irc_spawn( ic->irc, u );
 		u->online = 1;
 	}
 	else if( !loggedin && u->online )
 	{
-		struct conversation *c;
-		
-		irc_kill( gc->irc, u );
+		struct groupchat *c;
+		
+		irc_kill( ic->irc, u );
 		u->online = 0;
 		
 		/* Remove him/her from the conversations to prevent PART messages after he/she QUIT already */
-		for( c = gc->conversations; c; c = c->next )
+		for( c = ic->conversations; c; c = c->next )
 			remove_chat_buddy_silent( c, handle );
 	}
 	
-	if( ( type & UC_UNAVAILABLE ) && ( strcmp( gc->acc->prpl->name, "oscar" ) == 0 || strcmp( gc->acc->prpl->name, "icq" ) == 0 ) )
+	if( ( type & UC_UNAVAILABLE ) && ( strcmp( ic->acc->prpl->name, "oscar" ) == 0 || strcmp( ic->acc->prpl->name, "icq" ) == 0 ) )
 	{
 		u->away = g_strdup( "Away" );
 	}
-	else if( ( type & UC_UNAVAILABLE ) && ( strcmp( gc->acc->prpl->name, "jabber" ) == 0 ) )
+	else if( ( type & UC_UNAVAILABLE ) && ( strcmp( ic->acc->prpl->name, "jabber" ) == 0 ) )
 	{
 		if( type & UC_DND )
@@ -565,7 +565,7 @@
 			u->away = g_strdup( "Away" );
 	}
-	else if( ( type & UC_UNAVAILABLE ) && gc->acc->prpl->get_status_string )
-	{
-		u->away = g_strdup( gc->acc->prpl->get_status_string( gc, type ) );
+	else if( ( type & UC_UNAVAILABLE ) && ic->acc->prpl->get_status_string )
+	{
+		u->away = g_strdup( ic->acc->prpl->get_status_string( ic, type ) );
 	}
 	else
@@ -573,20 +573,20 @@
 	
 	/* LISPy... */
-	if( ( set_getbool( &gc->irc->set, "away_devoice" ) ) &&		/* Don't do a thing when user doesn't want it */
+	if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) &&		/* Don't do a thing when user doesn't want it */
 	    ( u->online ) &&						/* Don't touch offline people */
 	    ( ( ( u->online != oo ) && !u->away ) ||			/* Voice joining people */
 	      ( ( u->online == oo ) && ( oa == !u->away ) ) ) )		/* (De)voice people changing state */
 	{
-		irc_write( gc->irc, ":%s MODE %s %cv %s", gc->irc->myhost,
-		                                                gc->irc->channel, u->away?'-':'+', u->nick );
-	}
-}
-
-void serv_got_im( struct gaim_connection *gc, char *handle, char *msg, guint32 flags, time_t mtime, gint len )
-{
-	irc_t *irc = gc->irc;
+		irc_write( ic->irc, ":%s MODE %s %cv %s", ic->irc->myhost,
+		                                                ic->irc->channel, u->away?'-':'+', u->nick );
+	}
+}
+
+void serv_got_im( struct im_connection *ic, char *handle, char *msg, guint32 flags, time_t mtime, gint len )
+{
+	irc_t *irc = ic->irc;
 	user_t *u;
 	
-	u = user_findhandle( gc, handle );
+	u = user_findhandle( ic, handle );
 	
 	if( !u )
@@ -597,5 +597,5 @@
 		{
 			if( set_getbool( &irc->set, "debug" ) )
-				serv_got_crap( gc, "Ignoring message from unknown handle %s", handle );
+				serv_got_crap( ic, "Ignoring message from unknown handle %s", handle );
 			
 			return;
@@ -613,17 +613,17 @@
 			}
 			
-			add_buddy( gc, NULL, handle, NULL );
-			u = user_findhandle( gc, handle );
+			add_buddy( ic, NULL, handle, NULL );
+			u = user_findhandle( ic, handle );
 			u->is_private = private;
 		}
 		else
 		{
-			serv_got_crap( gc, "Message from unknown handle %s:", handle );
+			serv_got_crap( ic, "Message from unknown handle %s:", handle );
 			u = user_find( irc, irc->mynick );
 		}
 	}
 	
-	if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) ||
-	    ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) )
+	if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) ||
+	    ( ( ic->flags & OPT_CONN_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
 		strip_html( msg );
 
@@ -661,12 +661,12 @@
 }
 
-void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout, int type )
+void serv_got_typing( struct im_connection *ic, char *handle, int timeout, int type )
 {
 	user_t *u;
 	
-	if( !set_getbool( &gc->irc->set, "typing_notice" ) )
+	if( !set_getbool( &ic->irc->set, "typing_notice" ) )
 		return;
 	
-	if( ( u = user_findhandle( gc, handle ) ) ) {
+	if( ( u = user_findhandle( ic, handle ) ) ) {
 		/* If type is:
 		 * 0: user has stopped typing
@@ -677,17 +677,17 @@
 			char buf[256]; 
 			g_snprintf(buf, 256, "\1TYPING %d\1", type); 
-			irc_privmsg( gc->irc, u, "PRIVMSG", gc->irc->nick, NULL, buf );
-		}
-	}
-}
-
-void serv_got_chat_left( struct conversation *c )
-{
-	struct gaim_connection *gc = c->gc;
-	struct conversation *l = NULL;
+			irc_privmsg( ic->irc, u, "PRIVMSG", ic->irc->nick, NULL, buf );
+		}
+	}
+}
+
+void serv_got_chat_left( struct groupchat *c )
+{
+	struct im_connection *ic = c->ic;
+	struct groupchat *l = NULL;
 	GList *ir;
 	
-	if( set_getbool( &gc->irc->set, "debug" ) )
-		serv_got_crap( gc, "You were removed from conversation 0x%x", (int) c );
+	if( set_getbool( &ic->irc->set, "debug" ) )
+		serv_got_crap( ic, "You were removed from conversation 0x%x", (int) c );
 	
 	if( c )
@@ -697,10 +697,10 @@
 			user_t *u, *r;
 			
-			r = user_find( gc->irc, gc->irc->mynick );
-			irc_privmsg( gc->irc, r, "PRIVMSG", c->channel, "", "Cleaning up channel, bye!" );
+			r = user_find( ic->irc, ic->irc->mynick );
+			irc_privmsg( ic->irc, r, "PRIVMSG", c->channel, "", "Cleaning up channel, bye!" );
 			
-			u = user_find( gc->irc, gc->irc->nick );
-			irc_kick( gc->irc, u, c->channel, r );
-			/* irc_part( gc->irc, u, c->channel ); */
+			u = user_find( ic->irc, ic->irc->nick );
+			irc_kick( ic->irc, u, c->channel, r );
+			/* irc_part( ic->irc, u, c->channel ); */
 		}
 		
@@ -708,5 +708,5 @@
 			l->next = c->next;
 		else
-			gc->conversations = c->next;
+			ic->conversations = c->next;
 		
 		for( ir = c->in_room; ir; ir = ir->next )
@@ -719,45 +719,45 @@
 }
 
-void serv_got_chat_in( struct conversation *c, char *who, int whisper, char *msg, time_t mtime )
-{
-	struct gaim_connection *gc = c->gc;
+void serv_got_chat_in( struct groupchat *c, char *who, int whisper, char *msg, time_t mtime )
+{
+	struct im_connection *ic = c->ic;
 	user_t *u;
 	
 	/* Gaim sends own messages through this too. IRC doesn't want this, so kill them */
-	if( g_strcasecmp( who, gc->username ) == 0 )
+	if( g_strcasecmp( who, ic->username ) == 0 )
 		return;
 	
-	u = user_findhandle( gc, who );
-	
-	if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) ||
-	    ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) )
+	u = user_findhandle( ic, who );
+	
+	if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) ||
+	    ( ( ic->flags & OPT_CONN_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
 		strip_html( msg );
 	
 	if( c && u )
-		irc_privmsg( gc->irc, u, "PRIVMSG", c->channel, "", msg );
+		irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", msg );
 	else
-		serv_got_crap( gc, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, msg );
-}
-
-struct conversation *serv_got_joined_chat( struct gaim_connection *gc, char *handle )
-{
-	struct conversation *c;
+		serv_got_crap( ic, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, msg );
+}
+
+struct groupchat *serv_got_joined_chat( struct im_connection *ic, char *handle )
+{
+	struct groupchat *c;
 	
 	/* This one just creates the conversation structure, user won't see anything yet */
 	
-	if( gc->conversations )
-	{
-		for( c = gc->conversations; c->next; c = c->next );
-		c = c->next = g_new0( struct conversation, 1 );
+	if( ic->conversations )
+	{
+		for( c = ic->conversations; c->next; c = c->next );
+		c = c->next = g_new0( struct groupchat, 1 );
 	}
 	else
-		gc->conversations = c = g_new0( struct conversation, 1 );
-	
-	c->gc = gc;
+		ic->conversations = c = g_new0( struct groupchat, 1 );
+	
+	c->ic = ic;
 	c->title = g_strdup( handle );
-	c->channel = g_strdup_printf( "&chat_%03d", gc->irc->c_id++ );
-	
-	if( set_getbool( &gc->irc->set, "debug" ) )
-		serv_got_crap( gc, "Creating new conversation: (id=0x%x,handle=%s)", (int) c, handle );
+	c->channel = g_strdup_printf( "&chat_%03d", ic->irc->c_id++ );
+	
+	if( set_getbool( &ic->irc->set, "debug" ) )
+		serv_got_crap( ic, "Creating new conversation: (id=0x%x,handle=%s)", (int) c, handle );
 	
 	return c;
@@ -767,18 +767,18 @@
 /* buddy_chat.c */
 
-void add_chat_buddy( struct conversation *b, char *handle )
-{
-	user_t *u = user_findhandle( b->gc, handle );
+void add_chat_buddy( struct groupchat *b, char *handle )
+{
+	user_t *u = user_findhandle( b->ic, handle );
 	int me = 0;
 	
-	if( set_getbool( &b->gc->irc->set, "debug" ) )
-		serv_got_crap( b->gc, "User %s added to conversation 0x%x", handle, (int) b );
+	if( set_getbool( &b->ic->irc->set, "debug" ) )
+		serv_got_crap( b->ic, "User %s added to conversation 0x%x", handle, (int) b );
 	
 	/* It might be yourself! */
-	if( b->gc->acc->prpl->handle_cmp( handle, b->gc->username ) == 0 )
-	{
-		u = user_find( b->gc->irc, b->gc->irc->nick );
+	if( b->ic->acc->prpl->handle_cmp( handle, b->ic->username ) == 0 )
+	{
+		u = user_find( b->ic->irc, b->ic->irc->nick );
 		if( !b->joined )
-			irc_join( b->gc->irc, u, b->channel );
+			irc_join( b->ic->irc, u, b->channel );
 		b->joined = me = 1;
 	}
@@ -788,6 +788,6 @@
 	if( !u )
 	{
-		add_buddy( b->gc, NULL, handle, NULL );
-		u = user_findhandle( b->gc, handle );
+		add_buddy( b->ic, NULL, handle, NULL );
+		u = user_findhandle( b->ic, handle );
 	}
 	
@@ -796,21 +796,21 @@
 	{
 		if( b->joined )
-			irc_join( b->gc->irc, u, b->channel );
+			irc_join( b->ic->irc, u, b->channel );
 		b->in_room = g_list_append( b->in_room, g_strdup( handle ) );
 	}
 }
 
-void remove_chat_buddy( struct conversation *b, char *handle, char *reason )
+void remove_chat_buddy( struct groupchat *b, char *handle, char *reason )
 {
 	user_t *u;
 	int me = 0;
 	
-	if( set_getbool( &b->gc->irc->set, "debug" ) )
-		serv_got_crap( b->gc, "User %s removed from conversation 0x%x (%s)", handle, (int) b, reason ? reason : "" );
+	if( set_getbool( &b->ic->irc->set, "debug" ) )
+		serv_got_crap( b->ic, "User %s removed from conversation 0x%x (%s)", handle, (int) b, reason ? reason : "" );
 	
 	/* It might be yourself! */
-	if( g_strcasecmp( handle, b->gc->username ) == 0 )
-	{
-		u = user_find( b->gc->irc, b->gc->irc->nick );
+	if( g_strcasecmp( handle, b->ic->username ) == 0 )
+	{
+		u = user_find( b->ic->irc, b->ic->irc->nick );
 		b->joined = 0;
 		me = 1;
@@ -818,13 +818,13 @@
 	else
 	{
-		u = user_findhandle( b->gc, handle );
+		u = user_findhandle( b->ic, handle );
 	}
 	
 	if( remove_chat_buddy_silent( b, handle ) )
 		if( ( b->joined || me ) && u )
-			irc_part( b->gc->irc, u, b->channel );
-}
-
-static int remove_chat_buddy_silent( struct conversation *b, char *handle )
+			irc_part( b->ic->irc, u, b->channel );
+}
+
+static int remove_chat_buddy_silent( struct groupchat *b, char *handle )
 {
 	GList *i;
@@ -850,8 +850,8 @@
 /* Misc. BitlBee stuff which shouldn't really be here */
 
-struct conversation *chat_by_channel( char *channel )
-{
-	struct gaim_connection *gc;
-	struct conversation *c;
+struct groupchat *chat_by_channel( char *channel )
+{
+	struct im_connection *ic;
+	struct groupchat *c;
 	GSList *l;
 	
@@ -859,6 +859,6 @@
 	for( l = connections; l; l = l->next )
 	{
-		gc = l->data;
-		for( c = gc->conversations; c && g_strcasecmp( c->channel, channel ) != 0; c = c->next );
+		ic = l->data;
+		for( c = ic->conversations; c && g_strcasecmp( c->channel, channel ) != 0; c = c->next );
 		if( c )
 			return c;
@@ -899,5 +899,5 @@
 		while( u )
 		{
-			if( u->gc && u->online && !u->away )
+			if( u->ic && u->online && !u->away )
 			{
 				if( ( strlen( list ) + strlen( u->nick ) ) >= 79 )
@@ -933,10 +933,10 @@
    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 )
+int bim_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags )
 {
 	char *buf = NULL;
 	int st;
 	
-	if( ( gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
+	if( ( ic->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
 	{
 		buf = escape_html( msg );
@@ -944,5 +944,5 @@
 	}
 	
-	st = gc->acc->prpl->send_im( gc, handle, msg, strlen( msg ), flags );
+	st = ic->acc->prpl->send_im( ic, handle, msg, flags );
 	g_free( buf );
 	
@@ -950,10 +950,10 @@
 }
 
-int bim_chat_msg( struct conversation *c, char *msg )
+int bim_chat_msg( struct groupchat *c, char *msg, int flags )
 {
 	char *buf = NULL;
 	int st;
 	
-	if( ( c->gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
+	if( ( c->ic->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
 	{
 		buf = escape_html( msg );
@@ -961,13 +961,13 @@
 	}
 	
-	st = c->gc->acc->prpl->chat_send( c, msg );
+	c->ic->acc->prpl->chat_send( c, msg, flags );
 	g_free( buf );
 	
-	return st;
+	return 1;
 }
 
 static char *bim_away_alias_find( GList *gcm, char *away );
 
-int bim_set_away( struct gaim_connection *gc, char *away )
+int bim_set_away( struct im_connection *ic, char *away )
 {
 	GList *m, *ms;
@@ -975,5 +975,5 @@
 	
 	if( !away ) away = "";
-	ms = m = gc->acc->prpl->away_states( gc );
+	ms = m = ic->acc->prpl->away_states( ic );
 	
 	while( m )
@@ -996,5 +996,5 @@
 	if( m )
 	{
-		gc->acc->prpl->set_away( gc, m->data, *away ? away : NULL );
+		ic->acc->prpl->set_away( ic, m->data, *away ? away : NULL );
 	}
 	else
@@ -1003,10 +1003,10 @@
 		if( s )
 		{
-			gc->acc->prpl->set_away( gc, s, away );
-			if( set_getbool( &gc->irc->set, "debug" ) )
-				serv_got_crap( gc, "Setting away state to %s", s );
+			ic->acc->prpl->set_away( ic, s, away );
+			if( set_getbool( &ic->irc->set, "debug" ) )
+				serv_got_crap( ic, "Setting away state to %s", s );
 		}
 		else
-			gc->acc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away );
+			ic->acc->prpl->set_away( ic, GAIM_AWAY_CUSTOM, away );
 	}
 	
@@ -1056,47 +1056,47 @@
 }
 
-void bim_add_allow( struct gaim_connection *gc, char *handle )
-{
-	if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) == NULL )
-	{
-		gc->permit = g_slist_prepend( gc->permit, g_strdup( handle ) );
-	}
-	
-	gc->acc->prpl->add_permit( gc, handle );
-}
-
-void bim_rem_allow( struct gaim_connection *gc, char *handle )
+void bim_add_allow( struct im_connection *ic, char *handle )
+{
+	if( g_slist_find_custom( ic->permit, handle, (GCompareFunc) ic->acc->prpl->handle_cmp ) == NULL )
+	{
+		ic->permit = g_slist_prepend( ic->permit, g_strdup( handle ) );
+	}
+	
+	ic->acc->prpl->add_permit( ic, handle );
+}
+
+void bim_rem_allow( struct im_connection *ic, char *handle )
 {
 	GSList *l;
 	
-	if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) ) )
+	if( ( l = g_slist_find_custom( ic->permit, handle, (GCompareFunc) ic->acc->prpl->handle_cmp ) ) )
 	{
 		g_free( l->data );
-		gc->permit = g_slist_delete_link( gc->permit, l );
-	}
-	
-	gc->acc->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->acc->prpl->handle_cmp ) == NULL )
-	{
-		gc->deny = g_slist_prepend( gc->deny, g_strdup( handle ) );
-	}
-	
-	gc->acc->prpl->add_deny( gc, handle );
-}
-
-void bim_rem_block( struct gaim_connection *gc, char *handle )
+		ic->permit = g_slist_delete_link( ic->permit, l );
+	}
+	
+	ic->acc->prpl->rem_permit( ic, handle );
+}
+
+void bim_add_block( struct im_connection *ic, char *handle )
+{
+	if( g_slist_find_custom( ic->deny, handle, (GCompareFunc) ic->acc->prpl->handle_cmp ) == NULL )
+	{
+		ic->deny = g_slist_prepend( ic->deny, g_strdup( handle ) );
+	}
+	
+	ic->acc->prpl->add_deny( ic, handle );
+}
+
+void bim_rem_block( struct im_connection *ic, char *handle )
 {
 	GSList *l;
 	
-	if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) ) )
+	if( ( l = g_slist_find_custom( ic->deny, handle, (GCompareFunc) ic->acc->prpl->handle_cmp ) ) )
 	{
 		g_free( l->data );
-		gc->deny = g_slist_delete_link( gc->deny, l );
-	}
-	
-	gc->acc->prpl->rem_deny( gc, handle );
-}
+		ic->deny = g_slist_delete_link( ic->deny, l );
+	}
+	
+	ic->acc->prpl->rem_deny( ic, handle );
+}
