diff options
author | dequis <dx@dxzone.com.ar> | 2016-12-25 21:13:57 -0300 |
---|---|---|
committer | dequis <dx@dxzone.com.ar> | 2016-12-25 21:20:09 -0300 |
commit | 59ccef5cc9f1ed67112248c20649ce8005188173 (patch) | |
tree | 5048e4a2299b879f1c50a68c11a3cd5c47aa65c2 | |
parent | 6d212f401cf7eeb3eabe315e610578f5aac74607 (diff) |
purple: Call imcb_buddy_nick_change() on a few whitelisted plugins
The whitelist includes hangouts, funyahoo and icq.
These plugins tend to have numeric or meaningless usernames. With this
change, users don't have to do 'ac whatever set nick_format %full_name'
anymore. Just sugar.
-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) { |