Changeset 5a8afc3 for root_commands.c


Ignore:
Timestamp:
2016-11-21T06:58:47Z (3 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
3f44e43, f8c9347
Parents:
11d4123
git-author:
dequis <dx@…> (21-11-16 06:40:54)
git-committer:
dequis <dx@…> (21-11-16 06:58:47)
Message:

Manual merge with wilmer's approach to handling missing protocols

Turns out he already implemented pretty much the same thing in the
parson branch... last year.

The differences between the two approaches are subtle (there aren't too
many ways to do this, some lines are the exact same thing) but I decided
I like his version better, so this mostly reverts a handful of my
changes while keeping others. The main advantage of his approach is that
no fake protocols are registered, no actual prpl functions are called,
and the missing prpl is a singleton constant.

New things compared to the implementation in the other branch:

  • The explain_unknown_protocol() function.
  • Fixed named chatrooms throwing a warning and losing the "account" setting when saving. See changes in irc_im.c
  • Fixed the "server" setting dropping when saving. See account.c

Differences with my previous implementation:

  • Accounts with missing protocols don't autoconnect
  • 'account list' marks them as "(missing!)"
File:
1 edited

Legend:

Unmodified
Added
Removed
  • root_commands.c

    r11d4123 r5a8afc3  
    498498
    499499                for (a = irc->b->accounts; a; a = a->next) {
    500                         char *con;
     500                        char *con = NULL, *protocol = NULL;
    501501
    502502                        if (a->ic && (a->ic->flags & OPT_LOGGED_IN)) {
     
    510510                        }
    511511
    512                         irc_rootmsg(irc, "%2d (%s): %s, %s%s", i, a->tag, a->prpl->name, a->user, con);
     512                        if (a->prpl == &protocol_missing) {
     513                                protocol = g_strdup_printf("%s (missing!)", set_getstr(&a->set, "_protocol_name"));
     514                        } else {
     515                                protocol = g_strdup(a->prpl->name);
     516                        }
     517
     518                        irc_rootmsg(irc, "%2d (%s): %s, %s%s", i, a->tag, protocol, a->user, con);
     519                        g_free(protocol);
    513520
    514521                        i++;
     
    524531
    525532                        for (a = irc->b->accounts; a; a = a->next) {
    526                                 if (!a->ic && a->auto_connect) {
     533                                if (!a->ic && a->auto_connect && a->prpl != &protocol_missing) {
    527534                                        if (strcmp(a->pass, PASSWORD_PENDING) == 0) {
    528535                                                irc_rootmsg(irc, "Enter password for account %s "
     
    584591                        irc_rootmsg(irc, "Enter password for account %s "
    585592                                    "first (use /OPER)", a->tag);
     593                } else if (a->prpl == &protocol_missing) {
     594                        char *proto = set_getstr(&a->set, "_protocol_name");
     595                        char *msg = explain_unknown_protocol(proto);
     596                        irc_rootmsg(irc, "Unknown protocol `%s'", proto);
     597                        irc_rootmsg(irc, msg);
     598                        g_free(msg);
    586599                } else {
    587600                        account_on(irc->b, a);
Note: See TracChangeset for help on using the changeset viewer.