diff options
| -rw-r--r-- | irc_im.c | 70 | ||||
| -rw-r--r-- | nick.c | 15 | ||||
| -rw-r--r-- | protocols/account.c | 1 | ||||
| -rw-r--r-- | unix.c | 5 | 
4 files changed, 42 insertions, 49 deletions
| @@ -241,7 +241,7 @@ static gboolean bee_irc_user_typing( bee_t *bee, bee_user_t *bu, uint32_t flags  	return TRUE;  } -static gboolean bee_irc_user_nick_hint( bee_t *bee, bee_user_t *bu, const char *hint ); +static gboolean bee_irc_user_nick_update( irc_user_t *iu );  static gboolean bee_irc_user_fullname( bee_t *bee, bee_user_t *bu )  { @@ -264,30 +264,33 @@ static gboolean bee_irc_user_fullname( bee_t *bee, bee_user_t *bu )  		irc_send_msg( iu, "NOTICE", irc->user->nick, msg, NULL );  	} -	s = set_getstr( &bu->ic->acc->set, "nick_source" ); -	if( strcmp( s, "handle" ) != 0 ) -	{ -		char *name = g_strdup( bu->fullname ); -		 -		if( strcmp( s, "first_name" ) == 0 ) -		{ -			int i; -			for( i = 0; name[i] && !isspace( name[i] ); i ++ ) {} -			name[i] = '\0'; -		} -		 -		bee_irc_user_nick_hint( bee, bu, name ); -		 -		g_free( name ); -	} +	bee_irc_user_nick_update( iu );  	return TRUE;  }  static gboolean bee_irc_user_nick_hint( bee_t *bee, bee_user_t *bu, const char *hint )  { -	irc_user_t *iu = bu->ui_data; -	char newnick[MAX_NICK_LENGTH+1], *translit; +	bee_irc_user_nick_update( (irc_user_t*) bu->ui_data ); +	 +	return TRUE; +} + +static gboolean bee_irc_user_group( bee_t *bee, bee_user_t *bu ) +{ +	irc_user_t *iu = (irc_user_t *) bu->ui_data; +	irc_t *irc = (irc_t *) bee->ui_data; +	 +	bee_irc_channel_update( irc, NULL, iu ); +	bee_irc_user_nick_update( iu ); +	 +	return TRUE; +} + +static gboolean bee_irc_user_nick_update( irc_user_t *iu ) +{ +	bee_user_t *bu = iu->bu; +	char *newnick;  	if( bu->flags & BEE_USER_ONLINE )  		/* Ignore if the user is visible already. */ @@ -297,27 +300,10 @@ static gboolean bee_irc_user_nick_hint( bee_t *bee, bee_user_t *bu, const char *  		/* The user already assigned a nickname to this person. */  		return TRUE; -	/* Credits to Josay_ in #bitlbee for this idea. //TRANSLIT should -	   do lossy/approximate conversions, so letters with accents don't -	   just get stripped. Note that it depends on LC_CTYPE being set to -	   something other than C/POSIX. */ -	translit = g_convert( hint, -1, "ASCII//TRANSLIT//IGNORE", "UTF-8", -	                      NULL, NULL, NULL ); -	 -	strncpy( newnick, translit ? : hint, MAX_NICK_LENGTH ); -	newnick[MAX_NICK_LENGTH] = 0; -	g_free( translit ); -	 -	/* Some processing to make sure this string is a valid IRC nickname. */ -	nick_strip( newnick ); -	if( set_getbool( &bee->set, "lcnicks" ) ) -		nick_lc( newnick ); +	newnick = nick_get( bu );  	if( strcmp( iu->nick, newnick ) != 0 )  	{ -		/* Only do this if newnick is different from the current one. -		   If rejoining a channel, maybe we got this nick already -		   (and dedupe would only add an underscore. */  		nick_dedupe( bu, newnick );  		irc_user_set_nick( iu, newnick );  	} @@ -325,16 +311,6 @@ static gboolean bee_irc_user_nick_hint( bee_t *bee, bee_user_t *bu, const char *  	return TRUE;  } -static gboolean bee_irc_user_group( bee_t *bee, bee_user_t *bu ) -{ -	irc_user_t *iu = (irc_user_t *) bu->ui_data; -	irc_t *irc = (irc_t *) bee->ui_data; -	 -	bee_irc_channel_update( irc, NULL, iu ); -	 -	return TRUE; -} -  /* IRC->IM calls */  static gboolean bee_irc_user_privmsg_cb( gpointer data, gint fd, b_input_condition cond ); @@ -115,7 +115,7 @@ char *nick_gen( bee_user_t *bu )  	while( fmt && *fmt && ret->len < MAX_NICK_LENGTH )  	{ -		char *part, chop = '\0'; +		char *part, chop = '\0', *asc = NULL;  		if( *fmt != '%' )  		{ @@ -176,6 +176,14 @@ char *nick_gen( bee_user_t *bu )  			}  		} +		/* Credits to Josay_ in #bitlbee for this idea. //TRANSLIT +		   should do lossy/approximate conversions, so letters with +		   accents don't just get stripped. Note that it depends on +		   LC_CTYPE being set to something other than C/POSIX. */ +		if( part ) +			part = asc = g_convert( part, -1, "ASCII//TRANSLIT//IGNORE", +			                        "UTF-8", NULL, NULL, NULL ); +		  		while( part && *part && *part != chop )  		{  			if( strchr( nick_lc_chars, *part ) || @@ -184,6 +192,7 @@ char *nick_gen( bee_user_t *bu )  			part ++;  		} +		g_free( asc );  	}  	/* This returns NULL if the nick is empty or otherwise not ok. */ @@ -194,10 +203,12 @@ void nick_dedupe( bee_user_t *bu, char nick[MAX_NICK_LENGTH+1] )  {  	irc_t *irc = (irc_t*) bu->bee->ui_data;  	int inf_protection = 256; +	irc_user_t *iu;  	/* Now, find out if the nick is already in use at the moment, and make  	   subtle changes to make it unique. */ -	while( !nick_ok( nick ) || irc_user_by_name( irc, nick ) ) +	while( !nick_ok( nick ) || +	       ( ( iu = irc_user_by_name( irc, nick ) ) && iu->bu != bu ) )  	{  		if( strlen( nick ) < ( MAX_NICK_LENGTH - 1 ) )  		{ diff --git a/protocols/account.c b/protocols/account.c index 40cce2b8..2552b672 100644 --- a/protocols/account.c +++ b/protocols/account.c @@ -54,6 +54,7 @@ account_t *account_add( bee_t *bee, struct prpl *prpl, char *user, char *pass )  	s = set_add( &a->set, "auto_reconnect", "true", set_eval_bool, a );  	s = set_add( &a->set, "nick_format", NULL, NULL, a ); +	s->flags |= SET_NULL_OK;  	s = set_add( &a->set, "nick_source", "handle", NULL, a ); @@ -38,6 +38,7 @@  #include <sys/time.h>  #include <sys/wait.h>  #include <pwd.h> +#include <locale.h>  global_t global;	/* Against global namespace pollution */ @@ -51,6 +52,10 @@ int main( int argc, char *argv[] )  	char *old_cwd = NULL;  	struct sigaction sig, old; +	/* Required to make iconv to ASCII//TRANSLIT work. This makes BitlBee +	   system-locale-sensitive. :-( */ +	setlocale( LC_CTYPE, "" ); +	  	if( argc > 1 && strcmp( argv[1], "-x" ) == 0 )  		return crypt_main( argc, argv ); | 
