Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • otr.c

    rf1cf01c raea22cd  
    278278        e = otrl_privkey_read(irc->otr->us, s);
    279279        if(e && e!=enoent) {
    280                 irc_usermsg(irc, "otr load: %s: %s", s, gcry_strerror(e));
     280                irc_rootmsg(irc, "otr load: %s: %s", s, gcry_strerror(e));
    281281        }
    282282        g_snprintf(s, 511, "%s%s.otr_fprints", global.conf->configdir, irc->user->nick);
    283283        e = otrl_privkey_read_fingerprints(irc->otr->us, s, NULL, NULL);
    284284        if(e && e!=enoent) {
    285                 irc_usermsg(irc, "otr load: %s: %s", s, gcry_strerror(e));
     285                irc_rootmsg(irc, "otr load: %s: %s", s, gcry_strerror(e));
    286286        }
    287287       
     
    291291        }
    292292        if(kg) {
    293                 irc_usermsg(irc, "Notice: "
     293                irc_rootmsg(irc, "Notice: "
    294294                        "The accounts above do not have OTR encryption keys associated with them, yet. "
    295295                        "These keys are now being generated in the background. "
     
    309309        e = otrl_privkey_write_fingerprints(irc->otr->us, s);
    310310        if(e) {
    311                 irc_usermsg(irc, "otr save: %s: %s", s, gcry_strerror(e));
     311                irc_rootmsg(irc, "otr save: %s: %s", s, gcry_strerror(e));
    312312        }
    313313        chmod(s, 0600);
     
    348348        k = otrl_privkey_find(irc->otr->us, a->user, a->prpl->name);
    349349        if(k) {
    350                 irc_usermsg(irc, "otr: %s/%s ready", a->user, a->prpl->name);
     350                irc_rootmsg(irc, "otr: %s/%s ready", a->user, a->prpl->name);
    351351                return 0;
    352352        } if(keygen_in_progress(irc, a->user, a->prpl->name)) {
    353                 irc_usermsg(irc, "otr: keygen for %s/%s already in progress", a->user, a->prpl->name);
     353                irc_rootmsg(irc, "otr: keygen for %s/%s already in progress", a->user, a->prpl->name);
    354354                return 0;
    355355        } else {
    356                 irc_usermsg(irc, "otr: starting background keygen for %s/%s", a->user, a->prpl->name);
     356                irc_rootmsg(irc, "otr: starting background keygen for %s/%s", a->user, a->prpl->name);
    357357                otr_keygen(irc, a->user, a->prpl->name);
    358358                return 1;
     
    365365        char *newmsg = NULL;
    366366        OtrlTLV *tlvs = NULL;
    367         char *colormsg;
    368367        irc_t *irc = iu->irc;
    369368        struct im_connection *ic = iu->bu->ic;
     
    385384        } else if(!newmsg) {
    386385                /* this was a non-OTR message */
    387                 return g_strdup(msg);
     386                return msg;
    388387        } else {
    389388                /* OTR has processed this message */
    390389                ConnContext *context = otrl_context_find(irc->otr->us, iu->bu->handle,
    391390                        ic->acc->user, ic->acc->prpl->name, 0, NULL, NULL, NULL);
     391
     392                /* we're done with the original msg, which will be caller-freed. */
     393                /* NB: must not change the newmsg pointer, since we free it. */
     394                msg = newmsg;
    392395
    393396                if(context && context->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
     
    397400                           !(ic->flags & OPT_DOES_HTML) &&
    398401                           set_getbool(&ic->bee->set, "strip_html")) {
    399                                 strip_html(newmsg);
     402                                strip_html(msg);
    400403                        }
    401404
    402405                        /* coloring */
    403406                        if(set_getbool(&ic->bee->set, "otr_color_encrypted")) {
    404                                 /* color according to f'print trust */
    405                                 int color;
     407                                int color;                /* color according to f'print trust */
     408                                char *pre="", *sep="";    /* optional parts */
    406409                                const char *trust = context->active_fingerprint->trust;
     410
    407411                                if(trust && trust[0] != '\0')
    408412                                        color=3;   /* green */
     
    410414                                        color=5;   /* red */
    411415
    412                                 if(newmsg[0] == ',') {
    413                                         /* could be a problem with the color code */
    414                                         /* insert a space between color spec and message */
    415                                         colormsg = g_strdup_printf("\x03%.2d %s\x0F", color, newmsg);
    416                                 } else {
    417                                         colormsg = g_strdup_printf("\x03%.2d%s\x0F", color, newmsg);
     416                                /* in a query window, keep "/me " uncolored at the beginning */
     417                                if(g_strncasecmp(msg, "/me ", 4) == 0
     418                                   && irc_user_msgdest(iu) == irc->user->nick) {
     419                                        msg += 4;  /* skip */
     420                                        pre = "/me ";
    418421                                }
     422
     423                                /* comma in first place could mess with the color code */
     424                                if(msg[0] == ',') {
     425                                    /* insert a space between color spec and message */
     426                                    sep = " ";
     427                                }
     428
     429                                msg = g_strdup_printf("%s\x03%.2d%s%s\x0F", pre,
     430                                        color, sep, msg);
    419431                        }
    420                 } else {
    421                         colormsg = g_strdup(newmsg);
    422                 }
    423 
     432                }
     433
     434                if(msg == newmsg) {
     435                        msg = g_strdup(newmsg);
     436                }
    424437                otrl_message_free(newmsg);
    425                 return colormsg;
     438                return msg;
    426439        }
    427440}
     
    431444        int st;
    432445        char *otrmsg = NULL;
     446        char *emsg = msg;           /* the message as we hand it to libotr */
    433447        ConnContext *ctx = NULL;
    434448        irc_t *irc = iu->irc;
     
    440454        }
    441455
    442         /* HTML encoding */
    443         /* consider OTR plaintext to be HTML if otr_does_html is set */
    444         if(set_getbool(&ic->bee->set, "otr_does_html") &&
    445            (g_strncasecmp(msg, "<html>", 6) != 0)) {
    446                 msg = escape_html(msg);
    447         }
    448        
    449         st = otrl_message_sending(irc->otr->us, &otr_ops, ic,
    450                 ic->acc->user, ic->acc->prpl->name, iu->bu->handle,
    451                 msg, NULL, &otrmsg, NULL, NULL);
    452         if(st) {
    453                 return NULL;
    454         }
    455 
    456456        ctx = otrl_context_find(irc->otr->us,
    457457                        iu->bu->handle, ic->acc->user, ic->acc->prpl->name,
    458458                        1, NULL, NULL, NULL);
     459
     460        /* HTML encoding */
     461        /* consider OTR plaintext to be HTML if otr_does_html is set */
     462        if(ctx && ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED &&
     463           set_getbool(&ic->bee->set, "otr_does_html") &&
     464           (g_strncasecmp(msg, "<html>", 6) != 0)) {
     465                emsg = escape_html(msg);
     466        }
     467       
     468        st = otrl_message_sending(irc->otr->us, &otr_ops, ic,
     469                ic->acc->user, ic->acc->prpl->name, iu->bu->handle,
     470                emsg, NULL, &otrmsg, NULL, NULL);
     471        if(emsg != msg) {
     472                g_free(emsg);   /* we're done with this one */
     473        }
     474        if(st) {
     475                return NULL;
     476        }
    459477
    460478        if(otrmsg) {
     
    504522       
    505523        if(!cmd->command) {
    506                 irc_usermsg(irc, "%s: unknown subcommand \"%s\", see \x02help otr\x02",
     524                irc_rootmsg(irc, "%s: unknown subcommand \"%s\", see \x02help otr\x02",
    507525                        args[0], args[1]);
    508526                return;
     
    510528       
    511529        if(!args[cmd->required_parameters+1]) {
    512                 irc_usermsg(irc, "%s %s: not enough arguments (%d req.)",
     530                irc_rootmsg(irc, "%s %s: not enough arguments (%d req.)",
    513531                        args[0], args[1], cmd->required_parameters);
    514532                return;
     
    582600        if (strcmp(accountname, recipient) == 0) {
    583601                /* huh? injecting messages to myself? */
    584                 irc_usermsg(irc, "note to self: %s", message);
     602                irc_rootmsg(irc, "note to self: %s", message);
    585603        } else {
    586604                /* need to drop some consts here :-( */
     
    597615        char *msg = g_strdup(message);
    598616        irc_t *irc = ic->bee->ui_data;
     617        irc_user_t *u = peeruser(irc, username, protocol);
    599618
    600619        strip_html(msg);
    601         irc_usermsg(irc, "otr: %s", msg);
     620        if(u) {
     621                /* display as a notice from this particular user */
     622                irc_usernotice(u, "%s", msg);
     623        } else {
     624                irc_rootmsg(irc, "[otr] %s", msg);
     625        }
    602626
    603627        g_free(msg);
     
    611635        struct im_connection *ic = check_imc(opdata, accountname, protocol);
    612636        irc_t *irc = ic->bee->ui_data;
     637        irc_user_t *u = peeruser(irc, username, protocol);
    613638        char hunam[45];         /* anybody looking? ;-) */
    614639       
    615640        otrl_privkey_hash_to_human(hunam, fingerprint);
    616         irc_usermsg(irc, "new fingerprint for %s: %s",
    617                 peernick(irc, username, protocol), hunam);
     641        if(u) {
     642                irc_usernotice(u, "new fingerprint: %s", hunam);
     643        } else {
     644                /* this case shouldn't normally happen */
     645                irc_rootmsg(irc, "new fingerprint for %s/%s: %s",
     646                        username, protocol, hunam);
     647        }
    618648}
    619649
     
    644674        if(!otr_update_modeflags(irc, u)) {
    645675                char *trust = u->flags & IRC_USER_OTR_TRUSTED ? "trusted" : "untrusted!";
    646                 irc_usermsg(irc, "conversation with %s is now off the record (%s)", u->nick, trust);
     676                irc_usernotice(u, "conversation is now off the record (%s)", trust);
    647677        }
    648678}
     
    664694        otr_update_uflags(context, u);
    665695        if(!otr_update_modeflags(irc, u))
    666                 irc_usermsg(irc, "conversation with %s is now in the clear", u->nick);
     696                irc_usernotice(u, "conversation is now in cleartext");
    667697}
    668698
     
    685715        if(!otr_update_modeflags(irc, u)) {
    686716                char *trust = u->flags & IRC_USER_OTR_TRUSTED ? "trusted" : "untrusted!";
    687                 irc_usermsg(irc, "otr connection with %s has been refreshed (%s)", u->nick, trust);
     717                irc_usernotice(u, "otr connection has been refreshed (%s)", trust);
    688718        }
    689719}
     
    729759        u = irc_user_by_name(irc, args[1]);
    730760        if(!u || !u->bu || !u->bu->ic) {
    731                 irc_usermsg(irc, "%s: unknown user", args[1]);
     761                irc_rootmsg(irc, "%s: unknown user", args[1]);
    732762                return;
    733763        }
     
    754784        u = irc_user_by_name(irc, args[1]);
    755785        if(!u || !u->bu || !u->bu->ic) {
    756                 irc_usermsg(irc, "%s: unknown user", args[1]);
     786                irc_rootmsg(irc, "%s: unknown user", args[1]);
    757787                return;
    758788        }
    759789        if(!(u->bu->flags & BEE_USER_ONLINE)) {
    760                 irc_usermsg(irc, "%s is offline", args[1]);
     790                irc_rootmsg(irc, "%s is offline", args[1]);
    761791                return;
    762792        }
     
    785815        u = irc_user_by_name(irc, args[1]);
    786816        if(!u || !u->bu || !u->bu->ic) {
    787                 irc_usermsg(irc, "%s: unknown user", args[1]);
     817                irc_rootmsg(irc, "%s: unknown user", args[1]);
    788818                return;
    789819        }
     
    792822                u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
    793823        if(!ctx) {
    794                 irc_usermsg(irc, "%s: no otr context with user", args[1]);
     824                irc_rootmsg(irc, "%s: no otr context with user", args[1]);
    795825                return;
    796826        }
     
    804834                       
    805835                        if(!*p || !*q) {
    806                                 irc_usermsg(irc, "failed: truncated fingerprint block %d", i+1);
     836                                irc_rootmsg(irc, "failed: truncated fingerprint block %d", i+1);
    807837                                return;
    808838                        }
     
    811841                        y = hexval(*q);
    812842                        if(x<0) {
    813                                 irc_usermsg(irc, "failed: %d. hex digit of block %d out of range", 2*j+1, i+1);
     843                                irc_rootmsg(irc, "failed: %d. hex digit of block %d out of range", 2*j+1, i+1);
    814844                                return;
    815845                        }
    816846                        if(y<0) {
    817                                 irc_usermsg(irc, "failed: %d. hex digit of block %d out of range", 2*j+2, i+1);
     847                                irc_rootmsg(irc, "failed: %d. hex digit of block %d out of range", 2*j+2, i+1);
    818848                                return;
    819849                        }
     
    824854        fp = otrl_context_find_fingerprint(ctx, raw, 0, NULL);
    825855        if(!fp) {
    826                 irc_usermsg(irc, "failed: no such fingerprint for %s", args[1]);
     856                irc_rootmsg(irc, "failed: no such fingerprint for %s", args[1]);
    827857        } else {
    828858                char *trust = args[7] ? args[7] : "affirmed";
    829859                otrl_context_set_trust(fp, trust);
    830                 irc_usermsg(irc, "fingerprint match, trust set to \"%s\"", trust);
     860                irc_rootmsg(irc, "fingerprint match, trust set to \"%s\"", trust);
    831861                if(u->flags & IRC_USER_OTR_ENCRYPTED)
    832862                        u->flags |= IRC_USER_OTR_TRUSTED;
     
    856886                        ctx = otrl_context_find(irc->otr->us, handle, myhandle, protocol, 0, NULL, NULL, NULL);
    857887                        if(!ctx) {
    858                                 irc_usermsg(irc, "no such context");
     888                                irc_rootmsg(irc, "no such context");
    859889                                g_free(arg);
    860890                                return;
     
    863893                        irc_user_t *u = irc_user_by_name(irc, args[1]);
    864894                        if(!u || !u->bu || !u->bu->ic) {
    865                                 irc_usermsg(irc, "%s: unknown user", args[1]);
     895                                irc_rootmsg(irc, "%s: unknown user", args[1]);
    866896                                g_free(arg);
    867897                                return;
     
    870900                                u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
    871901                        if(!ctx) {
    872                                 irc_usermsg(irc, "no otr context with %s", args[1]);
     902                                irc_rootmsg(irc, "no otr context with %s", args[1]);
    873903                                g_free(arg);
    874904                                return;
     
    878908                /* show how we resolved the (nick) argument, if we did */
    879909                if(handle!=arg) {
    880                         irc_usermsg(irc, "%s is %s/%s; we are %s/%s to them", args[1],
     910                        irc_rootmsg(irc, "%s is %s/%s; we are %s/%s to them", args[1],
    881911                                ctx->username, ctx->protocol, ctx->accountname, ctx->protocol);
    882912                }
     
    893923        n = atoi(args[1]);
    894924        if(n<0 || (!n && strcmp(args[1], "0"))) {
    895                 irc_usermsg(irc, "%s: invalid account number", args[1]);
     925                irc_rootmsg(irc, "%s: invalid account number", args[1]);
    896926                return;
    897927        }
     
    900930        for(i=0; i<n && a; i++, a=a->next);
    901931        if(!a) {
    902                 irc_usermsg(irc, "%s: no such account", args[1]);
     932                irc_rootmsg(irc, "%s: no such account", args[1]);
    903933                return;
    904934        }
    905935       
    906936        if(keygen_in_progress(irc, a->user, a->prpl->name)) {
    907                 irc_usermsg(irc, "keygen for account %d already in progress", n);
     937                irc_rootmsg(irc, "keygen for account %d already in progress", n);
    908938                return;
    909939        }
     
    927957       
    928958        if(fp == fp->context->active_fingerprint) {
    929                 irc_usermsg(irc, "that fingerprint is active, terminate otr connection first");
     959                irc_rootmsg(irc, "that fingerprint is active, terminate otr connection first");
    930960                return;
    931961        }
     
    943973       
    944974        if(ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
    945                 irc_usermsg(irc, "active otr connection with %s, terminate it first",
     975                irc_rootmsg(irc, "active otr connection with %s, terminate it first",
    946976                        peernick(irc, ctx->username, ctx->protocol));
    947977                return;
     
    9751005               
    9761006                if(!args[3]) {
    977                         irc_usermsg(irc, "otr %s %s: not enough arguments (2 req.)", args[0], args[1]);
     1007                        irc_rootmsg(irc, "otr %s %s: not enough arguments (2 req.)", args[0], args[1]);
    9781008                        return;
    9791009                }
     
    9821012                u = irc_user_by_name(irc, args[2]);
    9831013                if(!u || !u->bu || !u->bu->ic) {
    984                         irc_usermsg(irc, "%s: unknown user", args[2]);
     1014                        irc_rootmsg(irc, "%s: unknown user", args[2]);
    9851015                        return;
    9861016                }
     
    9891019                        u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
    9901020                if(!ctx) {
    991                         irc_usermsg(irc, "no otr context with %s", args[2]);
     1021                        irc_rootmsg(irc, "no otr context with %s", args[2]);
    9921022                        return;
    9931023                }
     
    10001030               
    10011031                if(fp == ctx->active_fingerprint) {
    1002                         irc_usermsg(irc, "that fingerprint is active, terminate otr connection first");
     1032                        irc_rootmsg(irc, "that fingerprint is active, terminate otr connection first");
    10031033                        return;
    10041034                }
     
    10251055                u = irc_user_by_name(irc, args[2]);
    10261056                if(!u || !u->bu || !u->bu->ic) {
    1027                         irc_usermsg(irc, "%s: unknown user", args[2]);
     1057                        irc_rootmsg(irc, "%s: unknown user", args[2]);
    10281058                        return;
    10291059                }
     
    10321062                        u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
    10331063                if(!ctx) {
    1034                         irc_usermsg(irc, "no otr context with %s", args[2]);
     1064                        irc_rootmsg(irc, "no otr context with %s", args[2]);
    10351065                        return;
    10361066                }
    10371067               
    10381068                if(ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
    1039                         irc_usermsg(irc, "active otr connection with %s, terminate it first", args[2]);
     1069                        irc_rootmsg(irc, "active otr connection with %s, terminate it first", args[2]);
    10401070                        return;
    10411071                }
     
    10701100        else
    10711101        {
    1072                 irc_usermsg(irc, "otr %s: unknown subcommand \"%s\", see \x02help otr forget\x02",
     1102                irc_rootmsg(irc, "otr %s: unknown subcommand \"%s\", see \x02help otr forget\x02",
    10731103                        args[0], args[1]);
    10741104        }
     
    10961126        if(!context) {
    10971127                /* huh? out of memory or what? */
    1098                 irc_usermsg(irc, "smp: failed to get otr context for %s", u->nick);
     1128                irc_rootmsg(irc, "smp: failed to get otr context for %s", u->nick);
    10991129                otrl_message_abort_smp(us, ops, u->bu->ic, context);
    11001130                otrl_sm_state_free(context->smstate);
     
    11041134
    11051135        if (context->smstate->sm_prog_state == OTRL_SMP_PROG_CHEATED) {
    1106                 irc_usermsg(irc, "smp %s: opponent violated protocol, aborting",
     1136                irc_rootmsg(irc, "smp %s: opponent violated protocol, aborting",
    11071137                        u->nick);
    11081138                otrl_message_abort_smp(us, ops, u->bu->ic, context);
     
    11141144        if (tlv) {
    11151145                if (nextMsg != OTRL_SMP_EXPECT1) {
    1116                         irc_usermsg(irc, "smp %s: spurious SMP1Q received, aborting", u->nick);
     1146                        irc_rootmsg(irc, "smp %s: spurious SMP1Q received, aborting", u->nick);
    11171147                        otrl_message_abort_smp(us, ops, u->bu->ic, context);
    11181148                        otrl_sm_state_free(context->smstate);
    11191149                } else {
    11201150                        char *question = g_strndup((char *)tlv->data, tlv->len);
    1121                         irc_usermsg(irc, "smp: initiated by %s with question: \x02\"%s\"\x02", u->nick,
     1151                        irc_rootmsg(irc, "smp: initiated by %s with question: \x02\"%s\"\x02", u->nick,
    11221152                                question);
    1123                         irc_usermsg(irc, "smp: respond with \x02otr smp %s <answer>\x02",
     1153                        irc_rootmsg(irc, "smp: respond with \x02otr smp %s <answer>\x02",
    11241154                                u->nick);
    11251155                        g_free(question);
     
    11301160        if (tlv) {
    11311161                if (nextMsg != OTRL_SMP_EXPECT1) {
    1132                         irc_usermsg(irc, "smp %s: spurious SMP1 received, aborting", u->nick);
     1162                        irc_rootmsg(irc, "smp %s: spurious SMP1 received, aborting", u->nick);
    11331163                        otrl_message_abort_smp(us, ops, u->bu->ic, context);
    11341164                        otrl_sm_state_free(context->smstate);
    11351165                } else {
    1136                         irc_usermsg(irc, "smp: initiated by %s"
     1166                        irc_rootmsg(irc, "smp: initiated by %s"
    11371167                                " - respond with \x02otr smp %s <secret>\x02",
    11381168                                u->nick, u->nick);
     
    11431173        if (tlv) {
    11441174                if (nextMsg != OTRL_SMP_EXPECT2) {
    1145                         irc_usermsg(irc, "smp %s: spurious SMP2 received, aborting", u->nick);
     1175                        irc_rootmsg(irc, "smp %s: spurious SMP2 received, aborting", u->nick);
    11461176                        otrl_message_abort_smp(us, ops, u->bu->ic, context);
    11471177                        otrl_sm_state_free(context->smstate);
     
    11541184        if (tlv) {
    11551185                if (nextMsg != OTRL_SMP_EXPECT3) {
    1156                         irc_usermsg(irc, "smp %s: spurious SMP3 received, aborting", u->nick);
     1186                        irc_rootmsg(irc, "smp %s: spurious SMP3 received, aborting", u->nick);
    11571187                        otrl_message_abort_smp(us, ops, u->bu->ic, context);
    11581188                        otrl_sm_state_free(context->smstate);
     
    11611191                        if(context->smstate->sm_prog_state == OTRL_SMP_PROG_SUCCEEDED) {
    11621192                                if(context->smstate->received_question) {
    1163                                         irc_usermsg(irc, "smp %s: correct answer, you are trusted",
     1193                                        irc_rootmsg(irc, "smp %s: correct answer, you are trusted",
    11641194                                                u->nick);
    11651195                                } else {
    1166                                         irc_usermsg(irc, "smp %s: secrets proved equal, fingerprint trusted",
     1196                                        irc_rootmsg(irc, "smp %s: secrets proved equal, fingerprint trusted",
    11671197                                                u->nick);
    11681198                                }
    11691199                        } else {
    11701200                                if(context->smstate->received_question) {
    1171                                         irc_usermsg(irc, "smp %s: wrong answer, you are not trusted",
     1201                                        irc_rootmsg(irc, "smp %s: wrong answer, you are not trusted",
    11721202                                                u->nick);
    11731203                                } else {
    1174                                         irc_usermsg(irc, "smp %s: secrets did not match, fingerprint not trusted",
     1204                                        irc_rootmsg(irc, "smp %s: secrets did not match, fingerprint not trusted",
    11751205                                                u->nick);
    11761206                                }
     
    11831213        if (tlv) {
    11841214                if (nextMsg != OTRL_SMP_EXPECT4) {
    1185                         irc_usermsg(irc, "smp %s: spurious SMP4 received, aborting", u->nick);
     1215                        irc_rootmsg(irc, "smp %s: spurious SMP4 received, aborting", u->nick);
    11861216                        otrl_message_abort_smp(us, ops, u->bu->ic, context);
    11871217                        otrl_sm_state_free(context->smstate);
     
    11891219                        /* SMP4 received, otrl_message_receiving will have set fp trust */
    11901220                        if(context->smstate->sm_prog_state == OTRL_SMP_PROG_SUCCEEDED) {
    1191                                 irc_usermsg(irc, "smp %s: secrets proved equal, fingerprint trusted",
     1221                                irc_rootmsg(irc, "smp %s: secrets proved equal, fingerprint trusted",
    11921222                                        u->nick);
    11931223                        } else {
    1194                                 irc_usermsg(irc, "smp %s: secrets did not match, fingerprint not trusted",
     1224                                irc_rootmsg(irc, "smp %s: secrets did not match, fingerprint not trusted",
    11951225                                        u->nick);
    11961226                        }
     
    12011231        tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP_ABORT);
    12021232        if (tlv) {
    1203                 irc_usermsg(irc, "smp: received abort from %s", u->nick);
     1233                irc_rootmsg(irc, "smp: received abort from %s", u->nick);
    12041234                otrl_sm_state_free(context->smstate);
    12051235                /* smp is in back in EXPECT1 */
     
    12161246        u = irc_user_by_name(irc, nick);
    12171247        if(!u || !u->bu || !u->bu->ic) {
    1218                 irc_usermsg(irc, "%s: unknown user", nick);
     1248                irc_rootmsg(irc, "%s: unknown user", nick);
    12191249                return;
    12201250        }
    12211251        if(!(u->bu->flags & BEE_USER_ONLINE)) {
    1222                 irc_usermsg(irc, "%s is offline", nick);
     1252                irc_rootmsg(irc, "%s is offline", nick);
    12231253                return;
    12241254        }
     
    12271257                u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
    12281258        if(!ctx || ctx->msgstate != OTRL_MSGSTATE_ENCRYPTED) {
    1229                 irc_usermsg(irc, "smp: otr inactive with %s, try \x02otr connect"
     1259                irc_rootmsg(irc, "smp: otr inactive with %s, try \x02otr connect"
    12301260                                " %s\x02", nick, nick);
    12311261                return;
     
    12421272        if(question) {
    12431273                /* this was 'otr smpq', just initiate */
    1244                 irc_usermsg(irc, "smp: initiating with %s...", u->nick);
     1274                irc_rootmsg(irc, "smp: initiating with %s...", u->nick);
    12451275                otrl_message_initiate_smp_q(irc->otr->us, &otr_ops, u->bu->ic, ctx,
    12461276                        question, (unsigned char *)secret, strlen(secret));
     
    12511281                   is completed or aborted! */
    12521282                if(ctx->smstate->secret == NULL) {
    1253                         irc_usermsg(irc, "smp: initiating with %s...", u->nick);
     1283                        irc_rootmsg(irc, "smp: initiating with %s...", u->nick);
    12541284                        otrl_message_initiate_smp(irc->otr->us, &otr_ops,
    12551285                                u->bu->ic, ctx, (unsigned char *)secret, strlen(secret));
     
    12581288                        /* if we're still in EXPECT1 but smstate is initialized, we must have
    12591289                           received the SMP1, so let's issue a response */
    1260                         irc_usermsg(irc, "smp: responding to %s...", u->nick);
     1290                        irc_rootmsg(irc, "smp: responding to %s...", u->nick);
    12611291                        otrl_message_respond_smp(irc->otr->us, &otr_ops,
    12621292                                u->bu->ic, ctx, (unsigned char *)secret, strlen(secret));
     
    13731403                }
    13741404                if(fp == ctx->active_fingerprint) {
    1375                         irc_usermsg(irc, "    \x02%s (%s)\x02", human, trust);
     1405                        irc_rootmsg(irc, "    \x02%s (%s)\x02", human, trust);
    13761406                } else {
    1377                         irc_usermsg(irc, "    %s (%s)", human, trust);
     1407                        irc_rootmsg(irc, "    %s (%s)", human, trust);
    13781408                }
    13791409        }
    13801410        if(count==0)
    1381                 irc_usermsg(irc, "    (none)");
     1411                irc_rootmsg(irc, "    (none)");
    13821412}
    13831413
     
    13981428                       
    13991429                        if(n>=40) {
    1400                                 irc_usermsg(irc, "too many fingerprint digits given, expected at most 40");
     1430                                irc_rootmsg(irc, "too many fingerprint digits given, expected at most 40");
    14011431                                return NULL;
    14021432                        }
     
    14051435                                *(p++) = c;
    14061436                        } else {
    1407                                 irc_usermsg(irc, "invalid hex digit '%c' in block %d", args[i][j], i+1);
     1437                                irc_rootmsg(irc, "invalid hex digit '%c' in block %d", args[i][j], i+1);
    14081438                                return NULL;
    14091439                        }
     
    14261456        }
    14271457        if(!fp) {
    1428                 irc_usermsg(irc, "%s: no match", prefix);
     1458                irc_rootmsg(irc, "%s: no match", prefix);
    14291459                return NULL;
    14301460        }
     
    14391469        }
    14401470        if(fp2) {
    1441                 irc_usermsg(irc, "%s: multiple matches", prefix);
     1471                irc_rootmsg(irc, "%s: multiple matches", prefix);
    14421472                return NULL;
    14431473        }
     
    14621492                       
    14631493                        if(n>=40) {
    1464                                 irc_usermsg(irc, "too many fingerprint digits given, expected at most 40");
     1494                                irc_rootmsg(irc, "too many fingerprint digits given, expected at most 40");
    14651495                                return NULL;
    14661496                        }
     
    14691499                                *(p++) = c;
    14701500                        } else {
    1471                                 irc_usermsg(irc, "invalid hex digit '%c' in block %d", args[i][j], i+1);
     1501                                irc_rootmsg(irc, "invalid hex digit '%c' in block %d", args[i][j], i+1);
    14721502                                return NULL;
    14731503                        }
     
    14901520        }
    14911521        if(!k) {
    1492                 irc_usermsg(irc, "%s: no match", prefix);
     1522                irc_rootmsg(irc, "%s: no match", prefix);
    14931523                return NULL;
    14941524        }
     
    15031533        }
    15041534        if(k2) {
    1505                 irc_usermsg(irc, "%s: multiple matches", prefix);
     1535                irc_rootmsg(irc, "%s: multiple matches", prefix);
    15061536                return NULL;
    15071537        }
     
    15181548
    15191549        /* list all privkeys (including ones being generated) */
    1520         irc_usermsg(irc, "\x1fprivate keys:\x1f");
     1550        irc_rootmsg(irc, "\x1fprivate keys:\x1f");
    15211551        for(key=irc->otr->us->privkey_root; key; key=key->next) {
    15221552                const char *hash;
     
    15241554                switch(key->pubkey_type) {
    15251555                case OTRL_PUBKEY_TYPE_DSA:
    1526                         irc_usermsg(irc, "  %s/%s - DSA", key->accountname, key->protocol);
     1556                        irc_rootmsg(irc, "  %s/%s - DSA", key->accountname, key->protocol);
    15271557                        break;
    15281558                default:
    1529                         irc_usermsg(irc, "  %s/%s - type %d", key->accountname, key->protocol,
     1559                        irc_rootmsg(irc, "  %s/%s - type %d", key->accountname, key->protocol,
    15301560                                key->pubkey_type);
    15311561                }
     
    15361566                hash = otrl_privkey_fingerprint(irc->otr->us, human, key->accountname, key->protocol);
    15371567                if(hash) /* should always succeed */
    1538                         irc_usermsg(irc, "    %s", human);
     1568                        irc_rootmsg(irc, "    %s", human);
    15391569        }
    15401570        if(irc->otr->sent_accountname) {
    1541                 irc_usermsg(irc, "  %s/%s - DSA", irc->otr->sent_accountname,
     1571                irc_rootmsg(irc, "  %s/%s - DSA", irc->otr->sent_accountname,
    15421572                        irc->otr->sent_protocol);
    1543                 irc_usermsg(irc, "    (being generated)");
     1573                irc_rootmsg(irc, "    (being generated)");
    15441574        }
    15451575        for(kg=irc->otr->todo; kg; kg=kg->next) {
    1546                 irc_usermsg(irc, "  %s/%s - DSA", kg->accountname, kg->protocol);
    1547                 irc_usermsg(irc, "    (queued)");
     1576                irc_rootmsg(irc, "  %s/%s - DSA", kg->accountname, kg->protocol);
     1577                irc_rootmsg(irc, "    (queued)");
    15481578        }
    15491579        if(key == irc->otr->us->privkey_root &&
    15501580           !irc->otr->sent_accountname &&
    15511581           kg == irc->otr->todo)
    1552                 irc_usermsg(irc, "  (none)");
     1582                irc_rootmsg(irc, "  (none)");
    15531583
    15541584        /* list all contexts */
    1555         irc_usermsg(irc, "%s", "");
    1556         irc_usermsg(irc, "\x1f" "connection contexts:\x1f (bold=currently encrypted)");
     1585        irc_rootmsg(irc, "%s", "");
     1586        irc_rootmsg(irc, "\x1f" "connection contexts:\x1f (bold=currently encrypted)");
    15571587        for(ctx=irc->otr->us->context_root; ctx; ctx=ctx->next) {\
    15581588                irc_user_t *u;
     
    15681598               
    15691599                if(ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
    1570                         irc_usermsg(irc, "  \x02%s\x02", userstring);
     1600                        irc_rootmsg(irc, "  \x02%s\x02", userstring);
    15711601                } else {
    1572                         irc_usermsg(irc, "  %s", userstring);
     1602                        irc_rootmsg(irc, "  %s", userstring);
    15731603                }
    15741604               
     
    15761606        }
    15771607        if(ctx == irc->otr->us->context_root)
    1578                 irc_usermsg(irc, "  (none)");
     1608                irc_rootmsg(irc, "  (none)");
    15791609}
    15801610
     
    15831613        switch(ctx->otr_offer) {
    15841614        case OFFER_NOT:
    1585                 irc_usermsg(irc, "  otr offer status: none sent");
     1615                irc_rootmsg(irc, "  otr offer status: none sent");
    15861616                break;
    15871617        case OFFER_SENT:
    1588                 irc_usermsg(irc, "  otr offer status: awaiting reply");
     1618                irc_rootmsg(irc, "  otr offer status: awaiting reply");
    15891619                break;
    15901620        case OFFER_ACCEPTED:
    1591                 irc_usermsg(irc, "  otr offer status: accepted our offer");
     1621                irc_rootmsg(irc, "  otr offer status: accepted our offer");
    15921622                break;
    15931623        case OFFER_REJECTED:
    1594                 irc_usermsg(irc, "  otr offer status: ignored our offer");
     1624                irc_rootmsg(irc, "  otr offer status: ignored our offer");
    15951625                break;
    15961626        default:
    1597                 irc_usermsg(irc, "  otr offer status: %d", ctx->otr_offer);
     1627                irc_rootmsg(irc, "  otr offer status: %d", ctx->otr_offer);
    15981628        }
    15991629
    16001630        switch(ctx->msgstate) {
    16011631        case OTRL_MSGSTATE_PLAINTEXT:
    1602                 irc_usermsg(irc, "  connection state: cleartext");
     1632                irc_rootmsg(irc, "  connection state: cleartext");
    16031633                break;
    16041634        case OTRL_MSGSTATE_ENCRYPTED:
    1605                 irc_usermsg(irc, "  connection state: encrypted (v%d)", ctx->protocol_version);
     1635                irc_rootmsg(irc, "  connection state: encrypted (v%d)", ctx->protocol_version);
    16061636                break;
    16071637        case OTRL_MSGSTATE_FINISHED:
    1608                 irc_usermsg(irc, "  connection state: shut down");
     1638                irc_rootmsg(irc, "  connection state: shut down");
    16091639                break;
    16101640        default:
    1611                 irc_usermsg(irc, "  connection state: %d", ctx->msgstate);
    1612         }
    1613 
    1614         irc_usermsg(irc, "  fingerprints: (bold=active)");     
     1641                irc_rootmsg(irc, "  connection state: %d", ctx->msgstate);
     1642        }
     1643
     1644        irc_rootmsg(irc, "  fingerprints: (bold=active)");     
    16151645        show_fingerprints(irc, ctx);
    16161646}
     
    16521682               
    16531683                if(pipe(to) < 0 || pipe(from) < 0) {
    1654                         irc_usermsg(irc, "otr keygen: couldn't create pipe: %s", strerror(errno));
     1684                        irc_rootmsg(irc, "otr keygen: couldn't create pipe: %s", strerror(errno));
    16551685                        return;
    16561686                }
     
    16591689                fromf = fdopen(from[0], "r");
    16601690                if(!tof || !fromf) {
    1661                         irc_usermsg(irc, "otr keygen: couldn't streamify pipe: %s", strerror(errno));
     1691                        irc_rootmsg(irc, "otr keygen: couldn't streamify pipe: %s", strerror(errno));
    16621692                        return;
    16631693                }
     
    16651695                p = fork();
    16661696                if(p<0) {
    1667                         irc_usermsg(irc, "otr keygen: couldn't fork: %s", strerror(errno));
     1697                        irc_rootmsg(irc, "otr keygen: couldn't fork: %s", strerror(errno));
    16681698                        return;
    16691699                }
     
    17451775        myfgets(msg, 512, irc->otr->from);
    17461776       
    1747         irc_usermsg(irc, "%s", msg);
     1777        irc_rootmsg(irc, "%s", msg);
    17481778        if(filename[0]) {
    17491779                char *kf = g_strdup_printf("%s%s.otr_keys", global.conf->configdir, irc->user->nick);
     
    18191849       
    18201850        if(keygen_in_progress(irc, acc->user, acc->prpl->name)) {
    1821                 irc_usermsg(irc, "keygen for %s/%s already in progress",
     1851                irc_rootmsg(irc, "keygen for %s/%s already in progress",
    18221852                        acc->user, acc->prpl->name);
    18231853        } else {
    1824                 irc_usermsg(irc, "starting background keygen for %s/%s",
     1854                irc_rootmsg(irc, "starting background keygen for %s/%s",
    18251855                        acc->user, acc->prpl->name);
    1826                 irc_usermsg(irc, "you will be notified when it completes");
     1856                irc_rootmsg(irc, "you will be notified when it completes");
    18271857                otr_keygen(irc, acc->user, acc->prpl->name);
    18281858        }
    18291859}
     1860
     1861/* vim: set noet ts=4 sw=4: */
Note: See TracChangeset for help on using the changeset viewer.