Changeset 94e7eb3 for otr.c


Ignore:
Timestamp:
2008-02-10T17:56:59Z (12 years ago)
Author:
Sven Moritz Hallberg <sm@…>
Branches:
master
Children:
5d62040
Parents:
8521b02
Message:

add 'otr keygen' command

File:
1 edited

Legend:

Unmodified
Added
Removed
  • otr.c

    r8521b02 r94e7eb3  
    5353void cmd_otr_trust(irc_t *irc, char **args);
    5454void cmd_otr_info(irc_t *irc, char **args);
     55void cmd_otr_keygen(irc_t *irc, char **args);
    5556/* void cmd_otr_forget(irc_t *irc, char **args); */
    5657
     
    6162        { "trust",       6, &cmd_otr_trust,      0 },
    6263        { "info",        0, &cmd_otr_info,       0 },
     64        { "keygen",      1, &cmd_otr_keygen,     0 },
    6365        /*
    6466        { "forget",      1, &cmd_otr_forget,     0 },
     
    771773}
    772774
     775void cmd_otr_keygen(irc_t *irc, char **args)
     776{
     777        int i, n;
     778        account_t *a;
     779       
     780        n = atoi(args[1]);
     781        if(n<0 || (!n && strcmp(args[1], "0"))) {
     782                irc_usermsg(irc, "%s: invalid account number", args[1]);
     783                return;
     784        }
     785       
     786        a = irc->accounts;
     787        for(i=0; i<n && a; i++, a=a->next);
     788        if(!a) {
     789                irc_usermsg(irc, "%s: no such account", args[1]);
     790                return;
     791        }
     792       
     793        if(otrl_privkey_find(irc->otr_us, a->user, a->prpl->name)) {
     794                char *s = g_strdup_printf("account %d already has a key, replace it?", n);
     795                query_add(irc, a->ic, s, yes_keygen, no_keygen, a);
     796        } else {
     797                otr_keygen(irc, a->user, a->prpl->name);
     798        }
     799}
     800
    773801
    774802/*** local helpers / subroutines: ***/
     
    12201248        account_t *acc = (account_t *)data;
    12211249       
    1222         irc_usermsg(acc->irc, "proceeding without key, otr inoperable on %s/%s",
     1250        irc_usermsg(acc->irc, "keygen cancelled for %s/%s",
    12231251                acc->user, acc->prpl->name);
    1224         /* TODO:
    1225         irc_usermsg(acc->irc, "setting otr policy for %s/%s to \"never\"",
    1226                 acc->user, acc->prpl->name);
    1227         set_setstr(acc->set, "otr_policy", "never");
    1228         */
    12291252}
    12301253
Note: See TracChangeset for help on using the changeset viewer.