Changeset 50988d1 for protocols/purple


Ignore:
Timestamp:
2016-10-31T00:38:32Z (8 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
fecdd71
Parents:
c94e208
Message:

purple: fix icq login when the protocol name is "oscar"

Which happens when moving from non-purple to purple.

Fixes trac ticket 1269

Since "oscar" doesn't exist in purple, the old code called
register_protocol() to associate oscar with prpl-aim, which meant that
aim accounts migrated seamlessly to purple but icq accounts broke
silently, throwing incorrect password errors.

Now the oscar protocol is special-cased to return prpl-aim or prpl-icq
depending on the first character of the username, which is the same
thing the built-in oscar protocol does.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/purple/purple.c

    rc94e208 r50988d1  
    101101}
    102102
     103static char *purple_get_account_prpl_id(account_t *acc)
     104{
     105        /* "oscar" is how non-purple bitlbee calls it,
     106         * and it might be icq or aim, depending on the username */
     107        if (g_strcmp0(acc->prpl->name, "oscar") == 0) {
     108                return (g_ascii_isdigit(acc->user[0])) ? "prpl-icq" : "prpl-aim";
     109        }
     110
     111        return acc->prpl->data;
     112}
     113
    103114static void purple_init(account_t *acc)
    104115{
    105         PurplePlugin *prpl = purple_plugins_find_with_id((char *) acc->prpl->data);
     116        char *prpl_id = purple_get_account_prpl_id(acc);
     117        PurplePlugin *prpl = purple_plugins_find_with_id(prpl_id);
    106118        PurplePluginProtocolInfo *pi = prpl->info->extra_info;
    107119        PurpleAccount *pa;
     
    269281        /* Go through all away states to figure out if away/status messages
    270282           are possible. */
    271         pa = purple_account_new(acc->user, (char *) acc->prpl->data);
     283        pa = purple_account_new(acc->user, prpl_id);
    272284        for (st = purple_account_get_status_types(pa); st; st = st->next) {
    273285                PurpleStatusPrimitive prim = purple_status_type_get_primitive(st->data);
     
    347359
    348360        ic->proto_data = pd = g_new0(struct purple_data, 1);
    349         pd->account = purple_account_new(acc->user, (char *) acc->prpl->data);
     361        pd->account = purple_account_new(acc->user, purple_get_account_prpl_id(acc));
    350362        pd->input_requests = g_hash_table_new_full(g_direct_hash, g_direct_equal,
    351363                                                   NULL, g_free);
     
    17091721                        ret = g_memdup(&funcs, sizeof(funcs));
    17101722                        ret->name = "oscar";
    1711                         ret->data = prot->info->id;
     1723                        /* purple_get_account_prpl_id() determines the actual protocol ID (icq/aim) */
     1724                        ret->data = NULL;
    17121725                        register_protocol(ret);
    17131726                }
Note: See TracChangeset for help on using the changeset viewer.