From 3b3c50d9c6709c56c34bbbf9d94717485e2eb04b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 28 Jul 2010 10:24:47 +0200 Subject: Allow including account tags in nicknames, and be a bit more clever about the default tags (recognize AIM/ICQ/GTalk/Facebook). --- doc/user-guide/misc.xml | 1 + nick.c | 6 ++++++ protocols/account.c | 27 +++++++++++++++++++++------ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/doc/user-guide/misc.xml b/doc/user-guide/misc.xml index bb06a658..7829a432 100644 --- a/doc/user-guide/misc.xml +++ b/doc/user-guide/misc.xml @@ -200,6 +200,7 @@ text that will be copied to the nick, combined with several variables: %full_nameThe full name of the contact. %first_nameThe first name of the contact (the full name up to the first space). %groupThe name of the group this contact is a member of + %accountAccount tag of the contact diff --git a/nick.c b/nick.c index c0e3a003..87d8fa00 100644 --- a/nick.c +++ b/nick.c @@ -178,6 +178,12 @@ char *nick_gen( bee_user_t *bu ) fmt += 5; break; } + else if( g_strncasecmp( fmt, "account", 7 ) == 0 ) + { + part = bu->ic->acc->tag; + fmt += 7; + break; + } else { return NULL; diff --git a/protocols/account.c b/protocols/account.c index 7fceae91..50b7be8e 100644 --- a/protocols/account.c +++ b/protocols/account.c @@ -72,21 +72,36 @@ account_t *account_add( bee_t *bee, struct prpl *prpl, char *user, char *pass ) s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY; set_setstr( &a->set, "username", user ); - if( account_by_tag( bee, prpl->name ) ) + /* Hardcode some more clever tag guesses. */ + strcpy( tag, prpl->name ); + if( strcmp( prpl->name, "oscar" ) == 0 ) { + if( isdigit( a->user[0] ) ) + strcpy( tag, "icq" ); + else + strcpy( tag, "aim" ); + } + else if( strcmp( prpl->name, "jabber" ) == 0 ) + { + if( strstr( a->user, "@gmail.com" ) || + strstr( a->user, "@googlemail.com" ) ) + strcpy( tag, "gtalk" ); + else if( strstr( a->user, "@chat.facebook.com" ) ) + strcpy( tag, "fb" ); + } + + if( account_by_tag( bee, tag ) ) + { + char *numpos = tag + strlen( tag ); int i; for( i = 2; i < 10000; i ++ ) { - sprintf( tag, "%s%d", prpl->name, i ); + sprintf( numpos, "%d", i ); if( !account_by_tag( bee, tag ) ) break; } } - else - { - strcpy( tag, prpl->name ); - } set_setstr( &a->set, "tag", tag ); a->nicks = g_hash_table_new_full( g_str_hash, g_str_equal, g_free, g_free ); -- cgit v1.2.3