From 286b28eabf39d98d642c73c34a16a599e61dfc99 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 13 Mar 2010 01:02:47 +0000 Subject: Added nick_source account setting to allow using full name fields for generating nicknames instead of just the handle. --- account.c | 2 ++ doc/user-guide/commands.xml | 15 +++++++++++++++ protocols/nogaim.c | 18 ++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/account.c b/account.c index 99c3ff53..a844d229 100644 --- a/account.c +++ b/account.c @@ -54,6 +54,8 @@ account_t *account_add( irc_t *irc, 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_source", "handle", NULL, a ); + s = set_add( &a->set, "password", NULL, set_eval_account, a ); s->flags |= ACC_SET_NOSAVE | SET_NULL_OK; diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml index a7d06cf1..931608ee 100644 --- a/doc/user-guide/commands.xml +++ b/doc/user-guide/commands.xml @@ -607,6 +607,21 @@ + + handle + handle, full_name, first_name + + + + By default, BitlBee generates a nickname for every contact by taking its handle and chopping off everything after the @. In some cases, this gives very inconvenient nicknames. The Facebook XMPP server is a good example, as all Facebook XMPP handles are numeric. + + + + With this setting set to full_name, the person's full name is used to generate a nickname. Or if you don't like long nicknames, set this setting to first_name instead and only the first word will be used. Note that the full name can be full of non-ASCII characters which will be stripped off. + + + + both both, root, user, none diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 603905ab..6ee89e29 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -447,6 +447,7 @@ struct buddy *imcb_find_buddy( struct im_connection *ic, char *handle ) void imcb_rename_buddy( struct im_connection *ic, char *handle, char *realname ) { user_t *u = user_findhandle( ic, handle ); + char *set; if( !u || !realname ) return; @@ -459,6 +460,23 @@ void imcb_rename_buddy( struct im_connection *ic, char *handle, char *realname ) if( ( ic->flags & OPT_LOGGED_IN ) && set_getbool( &ic->irc->set, "display_namechanges" ) ) imcb_log( ic, "User `%s' changed name to `%s'", u->nick, u->realname ); } + + set = set_getstr( &ic->acc->set, "nick_source" ); + if( strcmp( set, "handle" ) != 0 ) + { + char *name = g_strdup( realname ); + + if( strcmp( set, "first_name" ) == 0 ) + { + int i; + for( i = 0; name[i] && !isspace( name[i] ); i ++ ) {} + name[i] = '\0'; + } + + imcb_buddy_nick_hint( ic, handle, name ); + + g_free( name ); + } } void imcb_remove_buddy( struct im_connection *ic, char *handle, char *group ) -- cgit v1.2.3