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 | |
| parent | 13fa2db53edbeae0d4638db1de042b8f415f8871 (diff) | |
Allow including account tags in nicknames, and be a bit more clever about
the default tags (recognize AIM/ICQ/GTalk/Facebook).
| -rw-r--r-- | doc/user-guide/misc.xml | 1 | ||||
| -rw-r--r-- | nick.c | 6 | ||||
| -rw-r--r-- | 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:  	<varlistentry><term>%full_name</term><listitem><para>The full name of the contact.</para></listitem></varlistentry>  	<varlistentry><term>%first_name</term><listitem><para>The first name of the contact (the full name up to the first space).</para></listitem></varlistentry>  	<varlistentry><term>%group</term><listitem><para>The name of the group this contact is a member of</para></listitem></varlistentry> +	<varlistentry><term>%account</term><listitem><para>Account tag of the contact</para></listitem></varlistentry>  </variablelist>  <para> @@ -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 ); | 
