Changeset b4f496e for protocols


Ignore:
Timestamp:
2016-11-19T07:32:48Z (8 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.

Location:
protocols
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • protocols/Makefile

    r9f03c47 rb4f496e  
    1313
    1414# [SH] Program variables
    15 objects = account.o bee.o bee_chat.o bee_ft.o bee_user.o nogaim.o
     15objects = account.o bee.o bee_chat.o bee_ft.o bee_user.o nogaim.o unknown.o
    1616
    1717
  • protocols/nogaim.c

    r9f03c47 rb4f496e  
    160160GList *protocols = NULL;
    161161GList *disabled_protocols = NULL;
     162static struct prpl *unknown_prpl;
    162163
    163164void register_protocol(struct prpl *p)
     
    191192}
    192193
     194struct prpl *make_unknown_protocol(const char *name)
     195{
     196        struct prpl *ret = g_memdup(unknown_prpl, sizeof(struct prpl));
     197        ret->name = g_strdup(name);
     198        register_protocol(ret);
     199        return ret;
     200}
     201
    193202gboolean is_protocol_disabled(const char *name)
    194203{
    195204        return g_list_find_custom(disabled_protocols, name, proto_name_cmp) != NULL;
     205}
     206
     207/* Returns heap allocated string with text attempting to explain why a protocol is missing
     208 * Free the return value with g_free() */
     209char *explain_unknown_protocol(const char *name)
     210{
     211        char *extramsg = NULL;
     212
     213        if (is_protocol_disabled(name)) {
     214                return g_strdup("Protocol disabled in the global config (bitlbee.conf)");
     215        }
     216
     217        if (strcmp(name, "yahoo") == 0) {
     218                return g_strdup("The old yahoo protocol is gone, try the funyahoo++ libpurple plugin instead.");
     219        }
     220
     221#ifdef WITH_PURPLE
     222        if ((strcmp(name, "msn") == 0) ||
     223            (strcmp(name, "loubserp-mxit") == 0) ||
     224            (strcmp(name, "myspace") == 0)) {
     225                return g_strdup("This protocol has been removed from your libpurple version.");
     226        }
     227
     228        if (strcmp(name, "hipchat") == 0) {
     229                return g_strdup("This account type isn't supported by libpurple's jabber.");
     230        }
     231
     232#else
     233        if (strcmp(name, "aim") == 0 || strcmp(name, "icq") == 0) {
     234                return g_strdup("This account uses libpurple specific aliases for oscar. "
     235                                "Re-add the account with `account add oscar ...'");
     236        }
     237
     238        extramsg = "If this is a libpurple plugin, you might need to install bitlbee-libpurple instead.";
     239#endif
     240        return g_strconcat("The protocol plugin is not installed or could not be loaded. "
     241                           "Use the `plugins' command to list available protocols. ",
     242                           extramsg, NULL);
    196243}
    197244
     
    204251        extern void twitter_initmodule();
    205252        extern void purple_initmodule();
     253        extern void unknown_prpl_initmodule();
     254
     255        unknown_prpl_initmodule(&unknown_prpl);
    206256
    207257#ifdef WITH_MSN
  • protocols/nogaim.h

    r9f03c47 rb4f496e  
    159159        /* The protocol is not suitable for OTR, see OPT_NOOTR */
    160160        PRPL_OPT_NOOTR = 1 << 12,
     161
     162        /* This prpl is a placeholder for a missing protocol */
     163        PRPL_OPT_UNKNOWN_PROTOCOL = 1 << 13,
    161164} prpl_options_t;
    162165
     
    321324G_MODULE_EXPORT struct prpl *find_protocol(const char *name);
    322325G_MODULE_EXPORT gboolean is_protocol_disabled(const char *name);
     326G_MODULE_EXPORT struct prpl *make_unknown_protocol(const char *name);
     327G_MODULE_EXPORT char *explain_unknown_protocol(const char *name);
    323328/* When registering a new protocol, you should allocate space for a new prpl
    324329 * struct, initialize it (set the function pointers to point to your
Note: See TracChangeset for help on using the changeset viewer.