diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-07-28 10:24:47 +0200 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-07-28 10:24:47 +0200 |
commit | 3b3c50d9c6709c56c34bbbf9d94717485e2eb04b (patch) | |
tree | 5b1b7e21a93107c93c8a4cba8a9e85570929d80b /protocols/account.c | |
parent | 13fa2db53edbeae0d4638db1de042b8f415f8871 (diff) |
Allow including account tags in nicknames, and be a bit more clever about
the default tags (recognize AIM/ICQ/GTalk/Facebook).
Diffstat (limited to 'protocols/account.c')
-rw-r--r-- | protocols/account.c | 27 |
1 files changed, 21 insertions, 6 deletions
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 ); |