Changeset 59ccef5


Ignore:
Timestamp:
2016-12-26T00:20:09Z (2 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
9c7ef22
Parents:
6d212f4
git-author:
dequis <dx@…> (26-12-16 00:13:57)
git-committer:
dequis <dx@…> (26-12-16 00:20:09)
Message:

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.

Location:
protocols/purple
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • protocols/purple/bpurple.h

    r6d212f4 r59ccef5  
    66
    77#define PURPLE_REQUEST_HANDLE "purple_request"
     8
     9#define PURPLE_OPT_SHOULD_SET_NICK 1
    810
    911struct purple_data
     
    1517    char *chat_list_server;
    1618    GSList *filetransfers;
     19
     20    int flags;
    1721};
    1822
  • protocols/purple/purple.c

    r6d212f4 r59ccef5  
    114114}
    115115
     116static gboolean purple_account_should_set_nick(account_t *acc)
     117{
     118        /* whitelist of protocols that tend to have numeric or meaningless usernames, and should
     119         * always offer the 'alias' as a nick.  this is just so that users don't have to do
     120         * 'account whatever set nick_format %full_name'
     121         */
     122        char *whitelist[] = {
     123                "prpl-hangouts",
     124                "prpl-eionrobb-funyahoo-plusplus",
     125                "prpl-icq",
     126                NULL,
     127        };
     128        char **p;
     129
     130        for (p = whitelist; *p; p++) {
     131                if (g_strcmp0(acc->prpl->data, *p) == 0) {
     132                        return TRUE;
     133                }
     134        }
     135
     136        return FALSE;
     137}
     138
    116139static void purple_init(account_t *acc)
    117140{
     
    367390        purple_account_set_password(pd->account, acc->pass);
    368391        purple_sync_settings(acc, pd->account);
     392
     393        if (purple_account_should_set_nick(acc)) {
     394                pd->flags = PURPLE_OPT_SHOULD_SET_NICK;
     395        }
    369396
    370397        purple_account_set_enabled(pd->account, "BitlBee", TRUE);
     
    903930                PurpleGroup *group = purple_buddy_get_group(bud);
    904931                struct im_connection *ic = purple_ic_by_pa(bud->account);
     932                struct purple_data *pd = ic->proto_data;
    905933                PurpleStatus *as;
    906934                int flags = 0;
     935                char *alias = NULL;
    907936
    908937                if (ic == NULL) {
     
    910939                }
    911940
    912                 if (bud->server_alias) {
    913                         imcb_rename_buddy(ic, bud->name, bud->server_alias);
    914                 } else if (bud->alias) {
    915                         imcb_rename_buddy(ic, bud->name, bud->alias);
     941                alias = bud->server_alias ? : bud->alias;
     942
     943                if (alias) {
     944                        imcb_rename_buddy(ic, bud->name, alias);
     945                        if (pd->flags & PURPLE_OPT_SHOULD_SET_NICK) {
     946                                imcb_buddy_nick_change(ic, bud->name, alias);
     947                        }
    916948                }
    917949
Note: See TracChangeset for help on using the changeset viewer.