diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-03-13 01:02:47 +0000 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-03-13 01:02:47 +0000 |
commit | 286b28eabf39d98d642c73c34a16a599e61dfc99 (patch) | |
tree | c1d152c5c3e0e8353b7097a5aa521a761c6fe976 | |
parent | 1be0d260da62542dd27b8a6f5d367a2e79191a8d (diff) |
Added nick_source account setting to allow using full name fields for
generating nicknames instead of just the handle.
-rw-r--r-- | account.c | 2 | ||||
-rw-r--r-- | doc/user-guide/commands.xml | 15 | ||||
-rw-r--r-- | protocols/nogaim.c | 18 |
3 files changed, 35 insertions, 0 deletions
@@ -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 @@ </description> </bitlbee-setting> + <bitlbee-setting name="nick_source" type="string" scope="account"> + <default>handle</default> + <possible-values>handle, full_name, first_name</possible-values> + + <description> + <para> + 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. + </para> + + <para> + With this setting set to <emphasis>full_name</emphasis>, the person's full name is used to generate a nickname. Or if you don't like long nicknames, set this setting to <emphasis>first_name</emphasis> 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. + </para> + </description> + </bitlbee-setting> + <bitlbee-setting name="ops" type="string" scope="global"> <default>both</default> <possible-values>both, root, user, none</possible-values> 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 ) |