diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-06-06 02:11:13 +0100 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-06-06 02:11:13 +0100 | 
| commit | 1f0224cdfd238060810679b3d6ba1a2bc49e4493 (patch) | |
| tree | 57ba738a1413a2db63847c1061cf5f45d73ac4fb /irc_user.c | |
| parent | 18da20bf7690ca3c1e9cf4b70c2749a11c75b339 (diff) | |
Send one /QUIT instead of one or more /PARTs for a user that is being
removed. Also restored netsplit simulation.
Diffstat (limited to 'irc_user.c')
| -rw-r--r-- | irc_user.c | 42 | 
1 files changed, 41 insertions, 1 deletions
| @@ -49,6 +49,7 @@ irc_user_t *irc_user_new( irc_t *irc, const char *nick )  int irc_user_free( irc_t *irc, irc_user_t *iu )  {  	GSList *l; +	gboolean send_quit = FALSE;  	if( !iu )  		return 0; @@ -57,7 +58,46 @@ int irc_user_free( irc_t *irc, irc_user_t *iu )  	g_hash_table_remove( irc->nick_user_hash, iu->key );  	for( l = irc->channels; l; l = l->next ) -		irc_channel_del_user( (irc_channel_t*) l->data, iu, FALSE, NULL ); +		send_quit |= irc_channel_del_user( (irc_channel_t*) l->data, iu, TRUE, NULL ); +	 +	if( send_quit ) +	{ +		static struct im_connection *last_ic; +		static char *msg; +		 +		if( iu->bu && +		    ( iu->bu->ic->flags & OPT_LOGGING_OUT ) && +		    iu->bu->ic != last_ic ) +		{ +			char host_prefix[] = "bitlbee."; +			char *s; +			 +			/* Irssi recognises netsplits by quitmsgs with two +			   hostnames, where a hostname is a "word" with one +			   of more dots. Mangle no-dot hostnames a bit. */ +			if( strchr( irc->root->host, '.' ) ) +				*host_prefix = '\0'; +			 +			last_ic = iu->bu->ic; +			g_free( msg ); +			if( !set_getbool( &irc->b->set, "simulate_netsplit" ) ) +				msg = g_strdup( "Account off-line" ); +			else if( ( s = strchr( iu->bu->ic->acc->user, '@' ) ) ) +				msg = g_strdup_printf( "%s%s %s", host_prefix, +				        irc->root->host, s + 1 ); +			else +				msg = g_strdup_printf( "%s%s %s.%s", +					host_prefix, irc->root->host, +					iu->bu->ic->acc->prpl->name, irc->root->host ); +		} +		else if( !iu->bu || !( iu->bu->ic->flags & OPT_LOGGING_OUT ) ) +		{ +			g_free( msg ); +			msg = g_strdup( "Removed" ); +			last_ic = NULL; +		} +		irc_send_quit( iu, msg ); +	}  	g_free( iu->nick );  	if( iu->nick != iu->user ) g_free( iu->user ); | 
