Index: bitlbee.c
===================================================================
--- bitlbee.c	(revision 64d1f45ed9ccfd90ba17592ac980dcb3436f9548)
+++ bitlbee.c	(revision a0d04d6253cf70877a11156059209e1f9a2efe31)
@@ -34,5 +34,5 @@
 #include <errno.h>
 
-gboolean bitlbee_io_new_client( GIOChannel *source, GIOCondition condition, gpointer data );
+void bitlbee_io_new_client( gpointer data, gint source, GaimInputCondition condition );
 
 int bitlbee_daemon_init()
@@ -44,5 +44,4 @@
 #endif
 	int i;
-	GIOChannel *ch;
 	FILE *fp;
 	
@@ -91,6 +90,5 @@
 	}
 	
-	ch = g_io_channel_unix_new( global.listen_socket );
-	global.listen_watch_source_id = g_io_add_watch( ch, G_IO_IN, bitlbee_io_new_client, NULL );
+	global.listen_watch_source_id = gaim_input_add( global.listen_socket, GAIM_INPUT_READ, bitlbee_io_new_client, NULL );
 	
 #ifndef _WIN32
@@ -147,5 +145,5 @@
 }
 
-gboolean bitlbee_io_current_client_read( GIOChannel *source, GIOCondition condition, gpointer data )
+void bitlbee_io_current_client_read( gpointer data, gint source, GaimInputCondition cond )
 {
 	irc_t *irc = data;
@@ -153,15 +151,9 @@
 	int st;
 	
-	if( condition & G_IO_ERR || condition & G_IO_HUP )
-	{
-		irc_abort( irc, 1, "Read error" );
-		return FALSE;
-	}
-	
 	st = read( irc->fd, line, sizeof( line ) - 1 );
 	if( st == 0 )
 	{
 		irc_abort( irc, 1, "Connection reset by peer" );
-		return FALSE;
+		goto no_more_events;
 	}
 	else if( st < 0 )
@@ -169,10 +161,10 @@
 		if( sockerr_again() )
 		{
-			return TRUE;
+			return;
 		}
 		else
 		{
 			irc_abort( irc, 1, "Read error: %s", strerror( errno ) );
-			return FALSE;
+			goto no_more_events;
 		}
 	}
@@ -195,5 +187,5 @@
 	{
 		log_message( LOGLVL_WARNING, "Abnormal termination of connection with fd %d.", irc->fd );
-		return FALSE;
+		goto no_more_events;
 	} 
 	
@@ -202,11 +194,15 @@
 	{
 		irc_abort( irc, 0, "Maximum line length exceeded" );
-		return FALSE;
-	}
-	
-	return TRUE;
-}
-
-gboolean bitlbee_io_current_client_write( GIOChannel *source, GIOCondition condition, gpointer data )
+		goto no_more_events;
+	}
+	
+	return;
+	
+no_more_events:
+	gaim_input_remove( irc->r_watch_source_id );
+	irc->r_watch_source_id = 0;
+}
+
+void bitlbee_io_current_client_write( gpointer data, gint source, GaimInputCondition cond )
 {
 	irc_t *irc = data;
@@ -215,5 +211,5 @@
 
 	if( irc->sendbuffer == NULL )
-		return( FALSE );
+		goto no_more_events;
 	
 	size = strlen( irc->sendbuffer );
@@ -223,9 +219,9 @@
 	{
 		irc_abort( irc, 1, "Write error: %s", strerror( errno ) );
-		return FALSE;
+		goto no_more_events;
 	}
 	else if( st < 0 ) /* && sockerr_again() */
 	{
-		return TRUE;
+		return;
 	}
 	
@@ -234,10 +230,9 @@
 		g_free( irc->sendbuffer );
 		irc->sendbuffer = NULL;
-		irc->w_watch_source_id = 0;
 		
 		if( irc->status == USTATUS_SHUTDOWN )
 			irc_free( irc );
 		
-		return( FALSE );
+		goto no_more_events;
 	}
 	else
@@ -247,11 +242,15 @@
 		irc->sendbuffer = temp;
 		
-		return( TRUE );
-	}
-}
-
-gboolean bitlbee_io_new_client( GIOChannel *source, GIOCondition condition, gpointer data )
-{
-	size_t size = sizeof( struct sockaddr_in );
+		return;
+	}
+	
+no_more_events:
+	gaim_input_remove( irc->w_watch_source_id );
+	irc->w_watch_source_id = 0;
+}
+
+void bitlbee_io_new_client( gpointer data, gint source, GaimInputCondition condition )
+{
+	socklen_t size = sizeof( struct sockaddr_in );
 	struct sockaddr_in conn_info;
 	int new_socket = accept( global.listen_socket, (struct sockaddr *) &conn_info, &size );
@@ -261,5 +260,5 @@
 	{
 		log_message( LOGLVL_WARNING, "Could not accept new connection: %s", strerror( errno ) );
-		return TRUE;
+		return;
 	}
 	
@@ -320,6 +319,4 @@
 		irc_new( new_socket );
 	}
-	
-	return TRUE;
 }
 
Index: bitlbee.h
===================================================================
--- bitlbee.h	(revision 64d1f45ed9ccfd90ba17592ac980dcb3436f9548)
+++ bitlbee.h	(revision a0d04d6253cf70877a11156059209e1f9a2efe31)
@@ -112,4 +112,5 @@
 #include "sock.h"
 #include "util.h"
+#include "proxy.h"
 
 typedef struct global {
@@ -128,6 +129,6 @@
 int bitlbee_inetd_init( void );
 
-gboolean bitlbee_io_current_client_read( GIOChannel *source, GIOCondition condition, gpointer data );
-gboolean bitlbee_io_current_client_write( GIOChannel *source, GIOCondition condition, gpointer data );
+void bitlbee_io_current_client_read( gpointer data, gint source, GaimInputCondition cond );
+void bitlbee_io_current_client_write( gpointer data, gint source, GaimInputCondition cond );
 
 void root_command_string( irc_t *irc, user_t *u, char *command, int flags );
Index: ipc.c
===================================================================
--- ipc.c	(revision 64d1f45ed9ccfd90ba17592ac980dcb3436f9548)
+++ ipc.c	(revision a0d04d6253cf70877a11156059209e1f9a2efe31)
@@ -463,23 +463,19 @@
 
 
-static gboolean new_ipc_client (GIOChannel *gio, GIOCondition cond, gpointer data)
+static void new_ipc_client( gpointer data, gint serversock, GaimInputCondition cond )
 {
 	struct bitlbee_child *child = g_new0( struct bitlbee_child, 1 );
-	int serversock;
-
-	serversock = g_io_channel_unix_get_fd(gio);
-
-	child->ipc_fd = accept(serversock, NULL, 0);
-
-	if (child->ipc_fd == -1) {
+	
+	child->ipc_fd = accept( serversock, NULL, 0 );
+	
+	if( child->ipc_fd == -1 )
+	{
 		log_message( LOGLVL_WARNING, "Unable to accept connection on UNIX domain socket: %s", strerror(errno) );
-		return TRUE;
+		return;
 	}
 		
 	child->ipc_inpa = gaim_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child );
-		
+	
 	child_list = g_slist_append( child_list, child );
-
-	return TRUE;
 }
 
@@ -489,5 +485,4 @@
 	struct sockaddr_un un_addr;
 	int serversock;
-	GIOChannel *gio;
 
 	/* Clean up old socket files that were hanging around.. */
@@ -517,12 +512,6 @@
 	}
 	
-	gio = g_io_channel_unix_new(serversock);
-	
-	if (gio == NULL) {
-		log_message( LOGLVL_WARNING, "Unable to create IO channel for unix socket" );
-		return 0;
-	}
-
-	g_io_add_watch(gio, G_IO_IN, new_ipc_client, NULL);
+	gaim_input_add( serversock, GAIM_INPUT_READ, new_ipc_client, NULL );
+	
 	return 1;
 }
Index: irc.c
===================================================================
--- irc.c	(revision 64d1f45ed9ccfd90ba17592ac980dcb3436f9548)
+++ irc.c	(revision a0d04d6253cf70877a11156059209e1f9a2efe31)
@@ -54,13 +54,7 @@
 	
 	irc->fd = fd;
-	irc->io_channel = g_io_channel_unix_new( fd );
-#ifdef GLIB2
-	g_io_channel_set_encoding (irc->io_channel, NULL, NULL);
-	g_io_channel_set_buffered (irc->io_channel, FALSE);
-	g_io_channel_set_flags( irc->io_channel, G_IO_FLAG_NONBLOCK, NULL );
-#else
-	fcntl( irc->fd, F_SETFL, O_NONBLOCK);
-#endif
-	irc->r_watch_source_id = g_io_add_watch( irc->io_channel, G_IO_IN | G_IO_ERR | G_IO_HUP, bitlbee_io_current_client_read, irc );
+	sock_make_nonblocking( irc->fd );
+	
+	irc->r_watch_source_id = gaim_input_add( irc->fd, GAIM_INPUT_READ, bitlbee_io_current_client_read, irc );
 	
 	irc->status = USTATUS_OFFLINE;
@@ -229,5 +223,4 @@
 		g_source_remove( irc->w_watch_source_id );
 	
-	g_io_channel_unref( irc->io_channel );
 	irc_connection_list = g_slist_remove( irc_connection_list, irc );
 	
@@ -600,16 +593,17 @@
 	strcat( line, "\r\n" );
 	
-	if( irc->sendbuffer != NULL ) {
+	if( irc->sendbuffer != NULL )
+	{
 		size = strlen( irc->sendbuffer ) + strlen( line );
 		irc->sendbuffer = g_renew ( char, irc->sendbuffer, size + 1 );
 		strcpy( ( irc->sendbuffer + strlen( irc->sendbuffer ) ), line );
 	}
-	else 
-		irc->sendbuffer = g_strdup(line);	
+	else
+	{
+		irc->sendbuffer = g_strdup(line);
+	}
 	
 	if( irc->w_watch_source_id == 0 )
-	{
-		irc->w_watch_source_id = g_io_add_watch( irc->io_channel, G_IO_OUT, bitlbee_io_current_client_write, irc );
-	}
+		irc->w_watch_source_id = gaim_input_add( irc->fd, GAIM_INPUT_WRITE, bitlbee_io_current_client_write, irc );
 	
 	return;
@@ -636,5 +630,5 @@
 		if( now )
 		{
-			bitlbee_io_current_client_write( irc->io_channel, G_IO_OUT, irc );
+			bitlbee_io_current_client_write( irc, irc->fd, GAIM_INPUT_WRITE );
 		}
 		temp = temp->next;
Index: irc.h
===================================================================
--- irc.h	(revision 64d1f45ed9ccfd90ba17592ac980dcb3436f9548)
+++ irc.h	(revision a0d04d6253cf70877a11156059209e1f9a2efe31)
@@ -93,5 +93,4 @@
 	struct set *set;
 
-	GIOChannel *io_channel;
 	gint r_watch_source_id;
 	gint w_watch_source_id;
