diff options
| -rw-r--r-- | ipc.c | 3 | ||||
| -rw-r--r-- | ipc.h | 3 | ||||
| -rw-r--r-- | irc_channel.c | 18 | ||||
| -rw-r--r-- | irc_commands.c | 26 | ||||
| -rw-r--r-- | irc_im.c | 36 | 
5 files changed, 61 insertions, 25 deletions
| @@ -1,7 +1,7 @@    /********************************************************************\    * BitlBee -- An IRC to other IM-networks gateway                     *    *                                                                    * -  * Copyright 2002-2006 Wilmer van der Gaast and others                * +  * Copyright 2002-2010 Wilmer van der Gaast and others                *    \********************************************************************/  /* IPC - communication between BitlBee processes                        */ @@ -28,6 +28,7 @@  #include "ipc.h"  #include "commands.h"  #ifndef _WIN32 +#include <sys/uio.h>  #include <sys/un.h>  #endif @@ -1,7 +1,7 @@    /********************************************************************\    * BitlBee -- An IRC to other IM-networks gateway                     *    *                                                                    * -  * Copyright 2002-2004 Wilmer van der Gaast and others                * +  * Copyright 2002-2010 Wilmer van der Gaast and others                *    \********************************************************************/  /* IPC - communication between BitlBee processes                        */ @@ -25,7 +25,6 @@  #define BITLBEE_CORE  #include "bitlbee.h" -#include <sys/uio.h>  struct bitlbee_child diff --git a/irc_channel.c b/irc_channel.c index 70770bfb..6f9de637 100644 --- a/irc_channel.c +++ b/irc_channel.c @@ -548,24 +548,6 @@ static gboolean control_channel_init( irc_channel_t *ic )  	ic->data = icc = g_new0( struct irc_control_channel, 1 );  	icc->type = IRC_CC_TYPE_DEFAULT; -	if( bee_group_by_name( ic->irc->b, ic->name + 1, FALSE ) ) -	{ -		set_setstr( &ic->set, "group", ic->name + 1 ); -		set_setstr( &ic->set, "fill_by", "group" ); -	} -	else if( set_setstr( &ic->set, "protocol", ic->name + 1 ) ) -	{ -		set_setstr( &ic->set, "fill_by", "protocol" ); -	} -	else if( set_setstr( &ic->set, "account", ic->name + 1 ) ) -	{ -		set_setstr( &ic->set, "fill_by", "account" ); -	} -	else -	{ -		bee_irc_channel_update( ic->irc, ic, NULL ); -	} -	  	return TRUE;  } diff --git a/irc_commands.c b/irc_commands.c index 0573601d..0bf20cfc 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -140,7 +140,31 @@ static void irc_cmd_join( irc_t *irc, char **cmd )  			*comma = '\0';  		if( ( ic = irc_channel_by_name( irc, s ) ) == NULL ) +		{  			ic = irc_channel_new( irc, s ); +			 +			if( strcmp( set_getstr( &ic->set, "type" ), "control" ) != 0 ) +			{ +				/* Autoconfiguration is for control channels only ATM. */ +			} +			else if( bee_group_by_name( ic->irc->b, ic->name + 1, FALSE ) ) +			{ +				set_setstr( &ic->set, "group", ic->name + 1 ); +				set_setstr( &ic->set, "fill_by", "group" ); +			} +			else if( set_setstr( &ic->set, "protocol", ic->name + 1 ) ) +			{ +				set_setstr( &ic->set, "fill_by", "protocol" ); +			} +			else if( set_setstr( &ic->set, "account", ic->name + 1 ) ) +			{ +				set_setstr( &ic->set, "fill_by", "account" ); +			} +			else +			{ +				bee_irc_channel_update( ic->irc, ic, NULL ); +			} +		}  		if( ic == NULL )  		{ @@ -201,7 +225,7 @@ static void irc_cmd_part( irc_t *irc, char **cmd )  	{  		irc_send_num( irc, 403, "%s :No such channel", cmd[1] );  	} -	else if( irc_channel_del_user( ic, irc->user, FALSE, cmd[2] ) ) +	else if( irc_channel_del_user( ic, irc->user, IRC_CDU_PART, cmd[2] ) )  	{  		if( ic->f->part )  			ic->f->part( ic, NULL ); @@ -450,6 +450,9 @@ static gboolean bee_irc_chat_free( bee_t *bee, struct groupchat *c )  {  	irc_channel_t *ic = c->ui_data; +	if( ic == NULL ) +		return FALSE; +	  	if( ic->flags & IRC_CHANNEL_JOINED )  		irc_channel_printf( ic, "Cleaning up channel, bye!" ); @@ -463,6 +466,9 @@ static gboolean bee_irc_chat_log( bee_t *bee, struct groupchat *c, const char *t  {  	irc_channel_t *ic = c->ui_data; +	if( ic == NULL ) +		return FALSE; +	  	irc_channel_printf( ic, "%s", text );  	return TRUE; @@ -475,6 +481,9 @@ static gboolean bee_irc_chat_msg( bee_t *bee, struct groupchat *c, bee_user_t *b  	irc_channel_t *ic = c->ui_data;  	char *ts = NULL; +	if( ic == NULL ) +		return FALSE; +	  	if( sent_at > 0 && set_getbool( &bee->set, "display_timestamps" ) )  		ts = irc_format_timestamp( irc, sent_at ); @@ -487,8 +496,12 @@ static gboolean bee_irc_chat_msg( bee_t *bee, struct groupchat *c, bee_user_t *b  static gboolean bee_irc_chat_add_user( bee_t *bee, struct groupchat *c, bee_user_t *bu )  {  	irc_t *irc = bee->ui_data; +	irc_channel_t *ic = c->ui_data; -	irc_channel_add_user( c->ui_data, bu == bee->user ? irc->user : bu->ui_data ); +	if( ic == NULL ) +		return FALSE; +	 +	irc_channel_add_user( ic, bu == bee->user ? irc->user : bu->ui_data );  	return TRUE;  } @@ -496,20 +509,28 @@ static gboolean bee_irc_chat_add_user( bee_t *bee, struct groupchat *c, bee_user  static gboolean bee_irc_chat_remove_user( bee_t *bee, struct groupchat *c, bee_user_t *bu )  {  	irc_t *irc = bee->ui_data; +	irc_channel_t *ic = c->ui_data; +	 +	if( ic == NULL ) +		return FALSE;  	/* TODO: Possible bug here: If a module removes $user here instead of just  	   using imcb_chat_free() and the channel was IRC_CHANNEL_TEMP, we get into  	   a broken state around here. */ -	irc_channel_del_user( c->ui_data, bu == bee->user ? irc->user : bu->ui_data, IRC_CDU_PART, NULL ); +	irc_channel_del_user( ic, bu == bee->user ? irc->user : bu->ui_data, IRC_CDU_PART, NULL );  	return TRUE;  }  static gboolean bee_irc_chat_topic( bee_t *bee, struct groupchat *c, const char *new, bee_user_t *bu )  { +	irc_channel_t *ic = c->ui_data;  	irc_t *irc = bee->ui_data;  	irc_user_t *iu; +	if( ic == NULL ) +		return FALSE; +	  	if( bu == NULL )  		iu = irc->root;  	else if( bu == bee->user ) @@ -517,7 +538,7 @@ static gboolean bee_irc_chat_topic( bee_t *bee, struct groupchat *c, const char  	else  		iu = bu->ui_data; -	irc_channel_set_topic( c->ui_data, new, iu ); +	irc_channel_set_topic( ic, new, iu );  	return TRUE;  } @@ -528,6 +549,9 @@ static gboolean bee_irc_chat_name_hint( bee_t *bee, struct groupchat *c, const c  	irc_channel_t *ic = c->ui_data, *oic;  	char stripped[MAX_NICK_LENGTH+1], *full_name; +	if( ic == NULL ) +		return FALSE; +	  	/* Don't rename a channel if the user's in it already. */  	if( ic->flags & IRC_CHANNEL_JOINED )  		return FALSE; @@ -785,6 +809,8 @@ static char *set_eval_chat_type( set_t *set, char *value )  static gboolean bee_irc_channel_free( irc_channel_t *ic )  { +	struct groupchat *c = ic->data; +	  	set_del( &ic->set, "account" );  	set_del( &ic->set, "chat_type" );  	set_del( &ic->set, "nick" ); @@ -793,6 +819,10 @@ static gboolean bee_irc_channel_free( irc_channel_t *ic )  	ic->flags &= ~IRC_CHANNEL_TEMP; +	/* That one still points at this channel. Don't. */ +	if( c ) +		c->ui_data = NULL; +	  	return TRUE;  } | 
