Changeset 9f03c47


Ignore:
Timestamp:
2016-11-14T00:37:14Z (8 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
537d9b9, b4f496e
Parents:
ea90275
Message:

Improve support for protocols which don't require a password

This adds a prpl_options_t enum with flags, which mostly just brings
OPT_PROTO_{NO_PASSWORD,PASSWORD_OPTIONAL} from libpurple as
PRPL_OPT_{NO_PASSWORD,PASSWORD_OPTIONAL}

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • otr.c

    rea90275 r9f03c47  
    429429
    430430        /* don't do OTR on certain (not classic IM) protocols, e.g. twitter */
    431         if (a->prpl->options & OPT_NOOTR) {
     431        if (a->prpl->options & PRPL_OPT_NOOTR) {
    432432                return 0;
    433433        }
     
    457457
    458458        /* don't do OTR on certain (not classic IM) protocols, e.g. twitter */
    459         if (ic->acc->prpl->options & OPT_NOOTR ||
     459        if (ic->acc->prpl->options & PRPL_OPT_NOOTR ||
    460460            iu->bu->flags & BEE_USER_NOOTR) {
    461461                return msg;
  • protocols/nogaim.h

    rea90275 r9f03c47  
    140140};
    141141
     142/* This enum takes a few things from libpurple and a few things from old OPT_ flags.
     143 * The only flag that was used before this struct was PRPL_OPT_NOOTR.
     144 *
     145 * The libpurple ones only use the same values as the PurpleProtocolOptions
     146 * enum for convenience, but there's no promise of direct compatibility with
     147 * those values. As of libpurple 2.8.0 they use up to 0x800 (1 << 11), which is
     148 * a nice coincidence.
     149 */
     150typedef enum {
     151        /* The protocol doesn't use passwords
     152         * Mirrors libpurple's OPT_PROTO_NO_PASSWORD */
     153        PRPL_OPT_NO_PASSWORD = 1 << 4,
     154
     155        /* The protocol doesn't require passwords, but may use them
     156         * Mirrors libpurple's OPT_PROTO_PASSWORD_OPTIONAL */
     157        PRPL_OPT_PASSWORD_OPTIONAL = 1 << 7,
     158
     159        /* The protocol is not suitable for OTR, see OPT_NOOTR */
     160        PRPL_OPT_NOOTR = 1 << 12,
     161} prpl_options_t;
     162
    142163struct prpl {
    143164        int options;
  • protocols/purple/purple.c

    rea90275 r9f03c47  
    17251725        for (prots = purple_plugins_get_protocols(); prots; prots = prots->next) {
    17261726                PurplePlugin *prot = prots->data;
     1727                PurplePluginProtocolInfo *pi = prot->info->extra_info;
    17271728                struct prpl *ret;
    17281729
     
    17381739                        ret->name += 5;
    17391740                }
     1741
     1742                if (pi->options & OPT_PROTO_NO_PASSWORD) {
     1743                        ret->options |= PRPL_OPT_NO_PASSWORD;
     1744                }
     1745
     1746                if (pi->options & OPT_PROTO_PASSWORD_OPTIONAL) {
     1747                        ret->options |= PRPL_OPT_PASSWORD_OPTIONAL;
     1748                }
     1749
    17401750                register_protocol(ret);
    17411751
  • protocols/twitter/twitter.c

    rea90275 r9f03c47  
    10921092        struct prpl *ret = g_new0(struct prpl, 1);
    10931093
    1094         ret->options = OPT_NOOTR;
     1094        ret->options = PRPL_OPT_NOOTR | PRPL_OPT_NO_PASSWORD;
    10951095        ret->name = "twitter";
    10961096        ret->login = twitter_login;
     
    11191119        ret = g_memdup(ret, sizeof(struct prpl));
    11201120        ret->name = "identica";
     1121        ret->options =  PRPL_OPT_NOOTR;
    11211122        register_protocol(ret);
    11221123}
  • root_commands.c

    rea90275 r9f03c47  
    470470                                irc_rootmsg(irc, "No need to enter a password for this "
    471471                                            "account since it's using OAuth");
     472                        } else if (prpl->options & PRPL_OPT_NO_PASSWORD) {
     473                                *a->pass = '\0';
     474                        } else if (prpl->options & PRPL_OPT_PASSWORD_OPTIONAL) {
     475                                *a->pass = '\0';
     476                                irc_rootmsg(irc, "Passwords are optional for this account. "
     477                                            "If you wish to enter the password with /OPER, do "
     478                                            "account %s set -del password", a->tag);
    472479                        } else {
    473480                                irc_rootmsg(irc, "You can now use the /OPER command to "
     
    479486                                }
    480487                        }
     488                } else if (prpl->options & PRPL_OPT_NO_PASSWORD) {
     489                        irc_rootmsg(irc, "Note: this account doesn't use password for login");
    481490                }
    482491
Note: See TracChangeset for help on using the changeset viewer.