From d06eabf19ec3f849d8bab22c13d43e4eba9a48ee Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 4 Jun 2007 14:22:05 +0100 Subject: Added imcb_buddy_nick_hint so the Jabber conference module can suggest sane nicknames for chatroom participants. There'll probably be a lot of underscores now, but this is by far the cleanest way to implement this, I think. At least now whispers will work properly. Also using this function call to set names for ICQ contacts in a slightly saner way. --- nick.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'nick.c') diff --git a/nick.c b/nick.c index 5e24547a..88c3faea 100644 --- a/nick.c +++ b/nick.c @@ -56,7 +56,6 @@ char *nick_get( account_t *acc, const char *handle ) { static char nick[MAX_NICK_LENGTH+1]; char *store_handle, *found_nick; - int inf_protection = 256; memset( nick, 0, MAX_NICK_LENGTH + 1 ); @@ -82,6 +81,17 @@ char *nick_get( account_t *acc, const char *handle ) } g_free( store_handle ); + /* Make sure the nick doesn't collide with an existing one by adding + underscores and that kind of stuff, if necessary. */ + nick_dedupe( acc, handle, nick ); + + return nick; +} + +void nick_dedupe( account_t *acc, const char *handle, char nick[MAX_NICK_LENGTH+1] ) +{ + int inf_protection = 256; + /* 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 ) || user_find( acc->irc, nick ) ) @@ -119,8 +129,6 @@ char *nick_get( account_t *acc, const char *handle ) break; } } - - return nick; } /* Just check if there is a nickname set for this buddy or if we'd have to -- cgit v1.2.3