Changeset b4f496e for storage_xml.c


Ignore:
Timestamp:
2016-11-19T07:32:48Z (5 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
a7baf40
Parents:
9f03c47
Message:

Improve handling of unknown protocols / missing plugins

Instead of failing to load the config, a fake prpl is created to load
the account, keep its settings, and refuse to log in with a helpful
error message.

Also added a new explain_unknown_protocol() function which returns text
which attempts to explain why a protocol is missing, handling several
typical cases, including the future removal of several dead libpurple
plugins.

That message is shown when logging in to a loaded account with a missing
protocol and when adding a new one with 'account add', with the
difference that the latter doesn't leave a placeholder fake account.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • storage_xml.c

    r9f03c47 rb4f496e  
    6060}
    6161
    62 static void handle_settings(struct xt_node *node, set_t **head)
     62static void handle_settings(struct xt_node *node, set_t **head, gboolean add_unknowns)
    6363{
    6464        struct xt_node *c;
     
    7070
    7171                if (!name) {
     72                        continue;
     73                }
     74
     75                if (add_unknowns && !set_find(head, name)) {
     76                        s = set_add(head, name, NULL, NULL, NULL);
     77                        s->flags |= ACC_SET_ONLINE_ONLY;
     78                        s->value = g_strdup(c->text);
    7279                        continue;
    7380                }
     
    99106        account_t *acc;
    100107        struct xt_node *c;
     108        gboolean is_unknown = FALSE;
    101109
    102110        handle = xt_find_attr(node, "handle");
     
    111119                prpl = find_protocol(protocol);
    112120                if (!prpl) {
    113                         irc_rootmsg(xd->irc, "Error loading user config: Protocol not found: `%s'", protocol);
    114                         return XT_ABORT;
    115                 }
     121                        irc_rootmsg(xd->irc, "Warning: Protocol not found: `%s'", protocol);
     122                        prpl = make_unknown_protocol(protocol);
     123                }
     124                is_unknown = (prpl->options & PRPL_OPT_UNKNOWN_PROTOCOL) != 0;
    116125                local = protocol_account_islocal(protocol);
    117126        }
     
    153162        g_free(password);
    154163
    155         handle_settings(node, &acc->set);
     164        handle_settings(node, &acc->set, is_unknown);
    156165
    157166        for (c = node->children; (c = xt_find_node(c, "buddy")); c = c->next) {
     
    192201        }
    193202
    194         handle_settings(node, &ic->set);
     203        handle_settings(node, &ic->set, FALSE);
    195204
    196205        return XT_HANDLED;
     
    270279        }
    271280
    272         handle_settings(node, &xd->irc->b->set);
     281        handle_settings(node, &xd->irc->b->set, FALSE);
    273282
    274283error:
Note: See TracChangeset for help on using the changeset viewer.