From 06b39f28ca532b21c9ddb1ce36c17d3f7121c388 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 13 Jul 2010 01:17:37 +0100 Subject: Automatically convert nick_source settings to their nick_convert equivalent. --- protocols/account.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'protocols/account.c') diff --git a/protocols/account.c b/protocols/account.c index 2552b672..cf9cbe71 100644 --- a/protocols/account.c +++ b/protocols/account.c @@ -27,6 +27,8 @@ #include "bitlbee.h" #include "account.h" +static char *set_eval_nick_source( set_t *set, char *value ); + account_t *account_add( bee_t *bee, struct prpl *prpl, char *user, char *pass ) { account_t *a; @@ -56,7 +58,8 @@ account_t *account_add( bee_t *bee, struct prpl *prpl, char *user, char *pass ) 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 ); + s = set_add( &a->set, "nick_source", "handle", set_eval_nick_source, a ); + s->flags |= ACC_SET_NOSAVE; /* Just for bw compatibility! */ s = set_add( &a->set, "password", NULL, set_eval_account, a ); s->flags |= ACC_SET_NOSAVE | SET_NULL_OK; @@ -154,6 +157,21 @@ char *set_eval_account( set_t *set, char *value ) return SET_INVALID; } +/* For bw compatibility, have this write-only setting. */ +static char *set_eval_nick_source( set_t *set, char *value ) +{ + account_t *a = set->data; + + if( strcmp( value, "full_name" ) == 0 ) + set_setstr( &a->set, "nick_format", "%full_name" ); + else if( strcmp( value, "first_name" ) == 0 ) + set_setstr( &a->set, "nick_format", "%first_name" ); + else + set_setstr( &a->set, "nick_format", "%-@nick" ); + + return value; +} + account_t *account_get( bee_t *bee, char *id ) { account_t *a, *ret = NULL; -- cgit v1.2.3