diff options
Diffstat (limited to 'protocols')
| -rw-r--r-- | protocols/purple/bpurple.h | 4 | ||||
| -rw-r--r-- | protocols/purple/purple.c | 40 | 
2 files changed, 40 insertions, 4 deletions
| diff --git a/protocols/purple/bpurple.h b/protocols/purple/bpurple.h index 81be2575..9b34cdff 100644 --- a/protocols/purple/bpurple.h +++ b/protocols/purple/bpurple.h @@ -6,6 +6,8 @@  #define PURPLE_REQUEST_HANDLE "purple_request" +#define PURPLE_OPT_SHOULD_SET_NICK 1 +  struct purple_data  {      PurpleAccount *account; @@ -14,6 +16,8 @@ struct purple_data      guint next_request_id;      char *chat_list_server;      GSList *filetransfers; + +    int flags;  };  #endif /* !BPURPLE_H */ diff --git a/protocols/purple/purple.c b/protocols/purple/purple.c index 49c1ee7c..9e0dc57e 100644 --- a/protocols/purple/purple.c +++ b/protocols/purple/purple.c @@ -113,6 +113,29 @@ static char *purple_get_account_prpl_id(account_t *acc)  	return acc->prpl->data;  } +static gboolean purple_account_should_set_nick(account_t *acc) +{ +	/* whitelist of protocols that tend to have numeric or meaningless usernames, and should +	 * always offer the 'alias' as a nick.  this is just so that users don't have to do +	 * 'account whatever set nick_format %full_name' +	 */ +	char *whitelist[] = { +		"prpl-hangouts", +		"prpl-eionrobb-funyahoo-plusplus", +		"prpl-icq", +		NULL, +	}; +	char **p; + +	for (p = whitelist; *p; p++) { +		if (g_strcmp0(acc->prpl->data, *p) == 0) { +			return TRUE; +		} +	} + +	return FALSE; +} +  static void purple_init(account_t *acc)  {  	char *prpl_id = purple_get_account_prpl_id(acc); @@ -367,6 +390,10 @@ static void purple_login(account_t *acc)  	purple_account_set_password(pd->account, acc->pass);  	purple_sync_settings(acc, pd->account); +	if (purple_account_should_set_nick(acc)) { +		pd->flags = PURPLE_OPT_SHOULD_SET_NICK; +	} +  	purple_account_set_enabled(pd->account, "BitlBee", TRUE);  	if (set_getbool(&acc->set, "mail_notifications") && set_getstr(&acc->set, "mail_notifications_handle")) { @@ -902,17 +929,22 @@ static void prplcb_blist_update(PurpleBuddyList *list, PurpleBlistNode *node)  		PurpleBuddy *bud = (PurpleBuddy *) node;  		PurpleGroup *group = purple_buddy_get_group(bud);  		struct im_connection *ic = purple_ic_by_pa(bud->account); +		struct purple_data *pd = ic->proto_data;  		PurpleStatus *as;  		int flags = 0; +		char *alias = NULL;  		if (ic == NULL) {  			return;  		} -		if (bud->server_alias) { -			imcb_rename_buddy(ic, bud->name, bud->server_alias); -		} else if (bud->alias) { -			imcb_rename_buddy(ic, bud->name, bud->alias); +		alias = bud->server_alias ? : bud->alias; + +		if (alias) { +			imcb_rename_buddy(ic, bud->name, alias); +			if (pd->flags & PURPLE_OPT_SHOULD_SET_NICK) { +				imcb_buddy_nick_change(ic, bud->name, alias); +			}  		}  		if (group) { | 
