Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • otr.c

    raea22cd rf1cf01c  
    278278        e = otrl_privkey_read(irc->otr->us, s);
    279279        if(e && e!=enoent) {
    280                 irc_rootmsg(irc, "otr load: %s: %s", s, gcry_strerror(e));
     280                irc_usermsg(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_rootmsg(irc, "otr load: %s: %s", s, gcry_strerror(e));
     285                irc_usermsg(irc, "otr load: %s: %s", s, gcry_strerror(e));
    286286        }
    287287       
     
    291291        }
    292292        if(kg) {
    293                 irc_rootmsg(irc, "Notice: "
     293                irc_usermsg(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_rootmsg(irc, "otr save: %s: %s", s, gcry_strerror(e));
     311                irc_usermsg(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_rootmsg(irc, "otr: %s/%s ready", a->user, a->prpl->name);
     350                irc_usermsg(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_rootmsg(irc, "otr: keygen for %s/%s already in progress", a->user, a->prpl->name);
     353                irc_usermsg(irc, "otr: keygen for %s/%s already in progress", a->user, a->prpl->name);
    354354                return 0;
    355355        } else {
    356                 irc_rootmsg(irc, "otr: starting background keygen for %s/%s", a->user, a->prpl->name);
     356                irc_usermsg(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;
    367368        irc_t *irc = iu->irc;
    368369        struct im_connection *ic = iu->bu->ic;
     
    384385        } else if(!newmsg) {
    385386                /* this was a non-OTR message */
    386                 return msg;
     387                return g_strdup(msg);
    387388        } else {
    388389                /* OTR has processed this message */
    389390                ConnContext *context = otrl_context_find(irc->otr->us, iu->bu->handle,
    390391                        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;
    395392
    396393                if(context && context->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
     
    400397                           !(ic->flags & OPT_DOES_HTML) &&
    401398                           set_getbool(&ic->bee->set, "strip_html")) {
    402                                 strip_html(msg);
     399                                strip_html(newmsg);
    403400                        }
    404401
    405402                        /* coloring */
    406403                        if(set_getbool(&ic->bee->set, "otr_color_encrypted")) {
    407                                 int color;                /* color according to f'print trust */
    408                                 char *pre="", *sep="";    /* optional parts */
     404                                /* color according to f'print trust */
     405                                int color;
    409406                                const char *trust = context->active_fingerprint->trust;
    410 
    411407                                if(trust && trust[0] != '\0')
    412408                                        color=3;   /* green */
     
    414410                                        color=5;   /* red */
    415411
    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 ";
     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);
    421418                                }
    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);
    431419                        }
    432                 }
    433 
    434                 if(msg == newmsg) {
    435                         msg = g_strdup(newmsg);
    436                 }
     420                } else {
     421                        colormsg = g_strdup(newmsg);
     422                }
     423
    437424                otrl_message_free(newmsg);
    438                 return msg;
     425                return colormsg;
    439426        }
    440427}
     
    444431        int st;
    445432        char *otrmsg = NULL;
    446         char *emsg = msg;           /* the message as we hand it to libotr */
    447433        ConnContext *ctx = NULL;
    448434        irc_t *irc = iu->irc;
     
    454440        }
    455441
     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         }
    477459
    478460        if(otrmsg) {
     
    522504       
    523505        if(!cmd->command) {
    524                 irc_rootmsg(irc, "%s: unknown subcommand \"%s\", see \x02help otr\x02",
     506                irc_usermsg(irc, "%s: unknown subcommand \"%s\", see \x02help otr\x02",
    525507                        args[0], args[1]);
    526508                return;
     
    528510       
    529511        if(!args[cmd->required_parameters+1]) {
    530                 irc_rootmsg(irc, "%s %s: not enough arguments (%d req.)",
     512                irc_usermsg(irc, "%s %s: not enough arguments (%d req.)",
    531513                        args[0], args[1], cmd->required_parameters);
    532514                return;
     
    600582        if (strcmp(accountname, recipient) == 0) {
    601583                /* huh? injecting messages to myself? */
    602                 irc_rootmsg(irc, "note to self: %s", message);
     584                irc_usermsg(irc, "note to self: %s", message);
    603585        } else {
    604586                /* need to drop some consts here :-( */
     
    615597        char *msg = g_strdup(message);
    616598        irc_t *irc = ic->bee->ui_data;
    617         irc_user_t *u = peeruser(irc, username, protocol);
    618599
    619600        strip_html(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         }
     601        irc_usermsg(irc, "otr: %s", msg);
    626602
    627603        g_free(msg);
     
    635611        struct im_connection *ic = check_imc(opdata, accountname, protocol);
    636612        irc_t *irc = ic->bee->ui_data;
    637         irc_user_t *u = peeruser(irc, username, protocol);
    638613        char hunam[45];         /* anybody looking? ;-) */
    639614       
    640615        otrl_privkey_hash_to_human(hunam, fingerprint);
    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         }
     616        irc_usermsg(irc, "new fingerprint for %s: %s",
     617                peernick(irc, username, protocol), hunam);
    648618}
    649619
     
    674644        if(!otr_update_modeflags(irc, u)) {
    675645                char *trust = u->flags & IRC_USER_OTR_TRUSTED ? "trusted" : "untrusted!";
    676                 irc_usernotice(u, "conversation is now off the record (%s)", trust);
     646                irc_usermsg(irc, "conversation with %s is now off the record (%s)", u->nick, trust);
    677647        }
    678648}
     
    694664        otr_update_uflags(context, u);
    695665        if(!otr_update_modeflags(irc, u))
    696                 irc_usernotice(u, "conversation is now in cleartext");
     666                irc_usermsg(irc, "conversation with %s is now in the clear", u->nick);
    697667}
    698668
     
    715685        if(!otr_update_modeflags(irc, u)) {
    716686                char *trust = u->flags & IRC_USER_OTR_TRUSTED ? "trusted" : "untrusted!";
    717                 irc_usernotice(u, "otr connection has been refreshed (%s)", trust);
     687                irc_usermsg(irc, "otr connection with %s has been refreshed (%s)", u->nick, trust);
    718688        }
    719689}
     
    759729        u = irc_user_by_name(irc, args[1]);
    760730        if(!u || !u->bu || !u->bu->ic) {
    761                 irc_rootmsg(irc, "%s: unknown user", args[1]);
     731                irc_usermsg(irc, "%s: unknown user", args[1]);
    762732                return;
    763733        }
     
    784754        u = irc_user_by_name(irc, args[1]);
    785755        if(!u || !u->bu || !u->bu->ic) {
    786                 irc_rootmsg(irc, "%s: unknown user", args[1]);
     756                irc_usermsg(irc, "%s: unknown user", args[1]);
    787757                return;
    788758        }
    789759        if(!(u->bu->flags & BEE_USER_ONLINE)) {
    790                 irc_rootmsg(irc, "%s is offline", args[1]);
     760                irc_usermsg(irc, "%s is offline", args[1]);
    791761                return;
    792762        }
     
    815785        u = irc_user_by_name(irc, args[1]);
    816786        if(!u || !u->bu || !u->bu->ic) {
    817                 irc_rootmsg(irc, "%s: unknown user", args[1]);
     787                irc_usermsg(irc, "%s: unknown user", args[1]);
    818788                return;
    819789        }
     
    822792                u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
    823793        if(!ctx) {
    824                 irc_rootmsg(irc, "%s: no otr context with user", args[1]);
     794                irc_usermsg(irc, "%s: no otr context with user", args[1]);
    825795                return;
    826796        }
     
    834804                       
    835805                        if(!*p || !*q) {
    836                                 irc_rootmsg(irc, "failed: truncated fingerprint block %d", i+1);
     806                                irc_usermsg(irc, "failed: truncated fingerprint block %d", i+1);
    837807                                return;
    838808                        }
     
    841811                        y = hexval(*q);
    842812                        if(x<0) {
    843                                 irc_rootmsg(irc, "failed: %d. hex digit of block %d out of range", 2*j+1, i+1);
     813                                irc_usermsg(irc, "failed: %d. hex digit of block %d out of range", 2*j+1, i+1);
    844814                                return;
    845815                        }
    846816                        if(y<0) {
    847                                 irc_rootmsg(irc, "failed: %d. hex digit of block %d out of range", 2*j+2, i+1);
     817                                irc_usermsg(irc, "failed: %d. hex digit of block %d out of range", 2*j+2, i+1);
    848818                                return;
    849819                        }
     
    854824        fp = otrl_context_find_fingerprint(ctx, raw, 0, NULL);
    855825        if(!fp) {
    856                 irc_rootmsg(irc, "failed: no such fingerprint for %s", args[1]);
     826                irc_usermsg(irc, "failed: no such fingerprint for %s", args[1]);
    857827        } else {
    858828                char *trust = args[7] ? args[7] : "affirmed";
    859829                otrl_context_set_trust(fp, trust);
    860                 irc_rootmsg(irc, "fingerprint match, trust set to \"%s\"", trust);
     830                irc_usermsg(irc, "fingerprint match, trust set to \"%s\"", trust);
    861831                if(u->flags & IRC_USER_OTR_ENCRYPTED)
    862832                        u->flags |= IRC_USER_OTR_TRUSTED;
     
    886856                        ctx = otrl_context_find(irc->otr->us, handle, myhandle, protocol, 0, NULL, NULL, NULL);
    887857                        if(!ctx) {
    888                                 irc_rootmsg(irc, "no such context");
     858                                irc_usermsg(irc, "no such context");
    889859                                g_free(arg);
    890860                                return;
     
    893863                        irc_user_t *u = irc_user_by_name(irc, args[1]);
    894864                        if(!u || !u->bu || !u->bu->ic) {
    895                                 irc_rootmsg(irc, "%s: unknown user", args[1]);
     865                                irc_usermsg(irc, "%s: unknown user", args[1]);
    896866                                g_free(arg);
    897867                                return;
     
    900870                                u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
    901871                        if(!ctx) {
    902                                 irc_rootmsg(irc, "no otr context with %s", args[1]);
     872                                irc_usermsg(irc, "no otr context with %s", args[1]);
    903873                                g_free(arg);
    904874                                return;
     
    908878                /* show how we resolved the (nick) argument, if we did */
    909879                if(handle!=arg) {
    910                         irc_rootmsg(irc, "%s is %s/%s; we are %s/%s to them", args[1],
     880                        irc_usermsg(irc, "%s is %s/%s; we are %s/%s to them", args[1],
    911881                                ctx->username, ctx->protocol, ctx->accountname, ctx->protocol);
    912882                }
     
    923893        n = atoi(args[1]);
    924894        if(n<0 || (!n && strcmp(args[1], "0"))) {
    925                 irc_rootmsg(irc, "%s: invalid account number", args[1]);
     895                irc_usermsg(irc, "%s: invalid account number", args[1]);
    926896                return;
    927897        }
     
    930900        for(i=0; i<n && a; i++, a=a->next);
    931901        if(!a) {
    932                 irc_rootmsg(irc, "%s: no such account", args[1]);
     902                irc_usermsg(irc, "%s: no such account", args[1]);
    933903                return;
    934904        }
    935905       
    936906        if(keygen_in_progress(irc, a->user, a->prpl->name)) {
    937                 irc_rootmsg(irc, "keygen for account %d already in progress", n);
     907                irc_usermsg(irc, "keygen for account %d already in progress", n);
    938908                return;
    939909        }
     
    957927       
    958928        if(fp == fp->context->active_fingerprint) {
    959                 irc_rootmsg(irc, "that fingerprint is active, terminate otr connection first");
     929                irc_usermsg(irc, "that fingerprint is active, terminate otr connection first");
    960930                return;
    961931        }
     
    973943       
    974944        if(ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
    975                 irc_rootmsg(irc, "active otr connection with %s, terminate it first",
     945                irc_usermsg(irc, "active otr connection with %s, terminate it first",
    976946                        peernick(irc, ctx->username, ctx->protocol));
    977947                return;
     
    1005975               
    1006976                if(!args[3]) {
    1007                         irc_rootmsg(irc, "otr %s %s: not enough arguments (2 req.)", args[0], args[1]);
     977                        irc_usermsg(irc, "otr %s %s: not enough arguments (2 req.)", args[0], args[1]);
    1008978                        return;
    1009979                }
     
    1012982                u = irc_user_by_name(irc, args[2]);
    1013983                if(!u || !u->bu || !u->bu->ic) {
    1014                         irc_rootmsg(irc, "%s: unknown user", args[2]);
     984                        irc_usermsg(irc, "%s: unknown user", args[2]);
    1015985                        return;
    1016986                }
     
    1019989                        u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
    1020990                if(!ctx) {
    1021                         irc_rootmsg(irc, "no otr context with %s", args[2]);
     991                        irc_usermsg(irc, "no otr context with %s", args[2]);
    1022992                        return;
    1023993                }
     
    10301000               
    10311001                if(fp == ctx->active_fingerprint) {
    1032                         irc_rootmsg(irc, "that fingerprint is active, terminate otr connection first");
     1002                        irc_usermsg(irc, "that fingerprint is active, terminate otr connection first");
    10331003                        return;
    10341004                }
     
    10551025                u = irc_user_by_name(irc, args[2]);
    10561026                if(!u || !u->bu || !u->bu->ic) {
    1057                         irc_rootmsg(irc, "%s: unknown user", args[2]);
     1027                        irc_usermsg(irc, "%s: unknown user", args[2]);
    10581028                        return;
    10591029                }
     
    10621032                        u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
    10631033                if(!ctx) {
    1064                         irc_rootmsg(irc, "no otr context with %s", args[2]);
     1034                        irc_usermsg(irc, "no otr context with %s", args[2]);
    10651035                        return;
    10661036                }
    10671037               
    10681038                if(ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
    1069                         irc_rootmsg(irc, "active otr connection with %s, terminate it first", args[2]);
     1039                        irc_usermsg(irc, "active otr connection with %s, terminate it first", args[2]);
    10701040                        return;
    10711041                }
     
    11001070        else
    11011071        {
    1102                 irc_rootmsg(irc, "otr %s: unknown subcommand \"%s\", see \x02help otr forget\x02",
     1072                irc_usermsg(irc, "otr %s: unknown subcommand \"%s\", see \x02help otr forget\x02",
    11031073                        args[0], args[1]);
    11041074        }
     
    11261096        if(!context) {
    11271097                /* huh? out of memory or what? */
    1128                 irc_rootmsg(irc, "smp: failed to get otr context for %s", u->nick);
     1098                irc_usermsg(irc, "smp: failed to get otr context for %s", u->nick);
    11291099                otrl_message_abort_smp(us, ops, u->bu->ic, context);
    11301100                otrl_sm_state_free(context->smstate);
     
    11341104
    11351105        if (context->smstate->sm_prog_state == OTRL_SMP_PROG_CHEATED) {
    1136                 irc_rootmsg(irc, "smp %s: opponent violated protocol, aborting",
     1106                irc_usermsg(irc, "smp %s: opponent violated protocol, aborting",
    11371107                        u->nick);
    11381108                otrl_message_abort_smp(us, ops, u->bu->ic, context);
     
    11441114        if (tlv) {
    11451115                if (nextMsg != OTRL_SMP_EXPECT1) {
    1146                         irc_rootmsg(irc, "smp %s: spurious SMP1Q received, aborting", u->nick);
     1116                        irc_usermsg(irc, "smp %s: spurious SMP1Q received, aborting", u->nick);
    11471117                        otrl_message_abort_smp(us, ops, u->bu->ic, context);
    11481118                        otrl_sm_state_free(context->smstate);
    11491119                } else {
    11501120                        char *question = g_strndup((char *)tlv->data, tlv->len);
    1151                         irc_rootmsg(irc, "smp: initiated by %s with question: \x02\"%s\"\x02", u->nick,
     1121                        irc_usermsg(irc, "smp: initiated by %s with question: \x02\"%s\"\x02", u->nick,
    11521122                                question);
    1153                         irc_rootmsg(irc, "smp: respond with \x02otr smp %s <answer>\x02",
     1123                        irc_usermsg(irc, "smp: respond with \x02otr smp %s <answer>\x02",
    11541124                                u->nick);
    11551125                        g_free(question);
     
    11601130        if (tlv) {
    11611131                if (nextMsg != OTRL_SMP_EXPECT1) {
    1162                         irc_rootmsg(irc, "smp %s: spurious SMP1 received, aborting", u->nick);
     1132                        irc_usermsg(irc, "smp %s: spurious SMP1 received, aborting", u->nick);
    11631133                        otrl_message_abort_smp(us, ops, u->bu->ic, context);
    11641134                        otrl_sm_state_free(context->smstate);
    11651135                } else {
    1166                         irc_rootmsg(irc, "smp: initiated by %s"
     1136                        irc_usermsg(irc, "smp: initiated by %s"
    11671137                                " - respond with \x02otr smp %s <secret>\x02",
    11681138                                u->nick, u->nick);
     
    11731143        if (tlv) {
    11741144                if (nextMsg != OTRL_SMP_EXPECT2) {
    1175                         irc_rootmsg(irc, "smp %s: spurious SMP2 received, aborting", u->nick);
     1145                        irc_usermsg(irc, "smp %s: spurious SMP2 received, aborting", u->nick);
    11761146                        otrl_message_abort_smp(us, ops, u->bu->ic, context);
    11771147                        otrl_sm_state_free(context->smstate);
     
    11841154        if (tlv) {
    11851155                if (nextMsg != OTRL_SMP_EXPECT3) {
    1186                         irc_rootmsg(irc, "smp %s: spurious SMP3 received, aborting", u->nick);
     1156                        irc_usermsg(irc, "smp %s: spurious SMP3 received, aborting", u->nick);
    11871157                        otrl_message_abort_smp(us, ops, u->bu->ic, context);
    11881158                        otrl_sm_state_free(context->smstate);
     
    11911161                        if(context->smstate->sm_prog_state == OTRL_SMP_PROG_SUCCEEDED) {
    11921162                                if(context->smstate->received_question) {
    1193                                         irc_rootmsg(irc, "smp %s: correct answer, you are trusted",
     1163                                        irc_usermsg(irc, "smp %s: correct answer, you are trusted",
    11941164                                                u->nick);
    11951165                                } else {
    1196                                         irc_rootmsg(irc, "smp %s: secrets proved equal, fingerprint trusted",
     1166                                        irc_usermsg(irc, "smp %s: secrets proved equal, fingerprint trusted",
    11971167                                                u->nick);
    11981168                                }
    11991169                        } else {
    12001170                                if(context->smstate->received_question) {
    1201                                         irc_rootmsg(irc, "smp %s: wrong answer, you are not trusted",
     1171                                        irc_usermsg(irc, "smp %s: wrong answer, you are not trusted",
    12021172                                                u->nick);
    12031173                                } else {
    1204                                         irc_rootmsg(irc, "smp %s: secrets did not match, fingerprint not trusted",
     1174                                        irc_usermsg(irc, "smp %s: secrets did not match, fingerprint not trusted",
    12051175                                                u->nick);
    12061176                                }
     
    12131183        if (tlv) {
    12141184                if (nextMsg != OTRL_SMP_EXPECT4) {
    1215                         irc_rootmsg(irc, "smp %s: spurious SMP4 received, aborting", u->nick);
     1185                        irc_usermsg(irc, "smp %s: spurious SMP4 received, aborting", u->nick);
    12161186                        otrl_message_abort_smp(us, ops, u->bu->ic, context);
    12171187                        otrl_sm_state_free(context->smstate);
     
    12191189                        /* SMP4 received, otrl_message_receiving will have set fp trust */
    12201190                        if(context->smstate->sm_prog_state == OTRL_SMP_PROG_SUCCEEDED) {
    1221                                 irc_rootmsg(irc, "smp %s: secrets proved equal, fingerprint trusted",
     1191                                irc_usermsg(irc, "smp %s: secrets proved equal, fingerprint trusted",
    12221192                                        u->nick);
    12231193                        } else {
    1224                                 irc_rootmsg(irc, "smp %s: secrets did not match, fingerprint not trusted",
     1194                                irc_usermsg(irc, "smp %s: secrets did not match, fingerprint not trusted",
    12251195                                        u->nick);
    12261196                        }
     
    12311201        tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP_ABORT);
    12321202        if (tlv) {
    1233                 irc_rootmsg(irc, "smp: received abort from %s", u->nick);
     1203                irc_usermsg(irc, "smp: received abort from %s", u->nick);
    12341204                otrl_sm_state_free(context->smstate);
    12351205                /* smp is in back in EXPECT1 */
     
    12461216        u = irc_user_by_name(irc, nick);
    12471217        if(!u || !u->bu || !u->bu->ic) {
    1248                 irc_rootmsg(irc, "%s: unknown user", nick);
     1218                irc_usermsg(irc, "%s: unknown user", nick);
    12491219                return;
    12501220        }
    12511221        if(!(u->bu->flags & BEE_USER_ONLINE)) {
    1252                 irc_rootmsg(irc, "%s is offline", nick);
     1222                irc_usermsg(irc, "%s is offline", nick);
    12531223                return;
    12541224        }
     
    12571227                u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
    12581228        if(!ctx || ctx->msgstate != OTRL_MSGSTATE_ENCRYPTED) {
    1259                 irc_rootmsg(irc, "smp: otr inactive with %s, try \x02otr connect"
     1229                irc_usermsg(irc, "smp: otr inactive with %s, try \x02otr connect"
    12601230                                " %s\x02", nick, nick);
    12611231                return;
     
    12721242        if(question) {
    12731243                /* this was 'otr smpq', just initiate */
    1274                 irc_rootmsg(irc, "smp: initiating with %s...", u->nick);
     1244                irc_usermsg(irc, "smp: initiating with %s...", u->nick);
    12751245                otrl_message_initiate_smp_q(irc->otr->us, &otr_ops, u->bu->ic, ctx,
    12761246                        question, (unsigned char *)secret, strlen(secret));
     
    12811251                   is completed or aborted! */
    12821252                if(ctx->smstate->secret == NULL) {
    1283                         irc_rootmsg(irc, "smp: initiating with %s...", u->nick);
     1253                        irc_usermsg(irc, "smp: initiating with %s...", u->nick);
    12841254                        otrl_message_initiate_smp(irc->otr->us, &otr_ops,
    12851255                                u->bu->ic, ctx, (unsigned char *)secret, strlen(secret));
     
    12881258                        /* if we're still in EXPECT1 but smstate is initialized, we must have
    12891259                           received the SMP1, so let's issue a response */
    1290                         irc_rootmsg(irc, "smp: responding to %s...", u->nick);
     1260                        irc_usermsg(irc, "smp: responding to %s...", u->nick);
    12911261                        otrl_message_respond_smp(irc->otr->us, &otr_ops,
    12921262                                u->bu->ic, ctx, (unsigned char *)secret, strlen(secret));
     
    14031373                }
    14041374                if(fp == ctx->active_fingerprint) {
    1405                         irc_rootmsg(irc, "    \x02%s (%s)\x02", human, trust);
     1375                        irc_usermsg(irc, "    \x02%s (%s)\x02", human, trust);
    14061376                } else {
    1407                         irc_rootmsg(irc, "    %s (%s)", human, trust);
     1377                        irc_usermsg(irc, "    %s (%s)", human, trust);
    14081378                }
    14091379        }
    14101380        if(count==0)
    1411                 irc_rootmsg(irc, "    (none)");
     1381                irc_usermsg(irc, "    (none)");
    14121382}
    14131383
     
    14281398                       
    14291399                        if(n>=40) {
    1430                                 irc_rootmsg(irc, "too many fingerprint digits given, expected at most 40");
     1400                                irc_usermsg(irc, "too many fingerprint digits given, expected at most 40");
    14311401                                return NULL;
    14321402                        }
     
    14351405                                *(p++) = c;
    14361406                        } else {
    1437                                 irc_rootmsg(irc, "invalid hex digit '%c' in block %d", args[i][j], i+1);
     1407                                irc_usermsg(irc, "invalid hex digit '%c' in block %d", args[i][j], i+1);
    14381408                                return NULL;
    14391409                        }
     
    14561426        }
    14571427        if(!fp) {
    1458                 irc_rootmsg(irc, "%s: no match", prefix);
     1428                irc_usermsg(irc, "%s: no match", prefix);
    14591429                return NULL;
    14601430        }
     
    14691439        }
    14701440        if(fp2) {
    1471                 irc_rootmsg(irc, "%s: multiple matches", prefix);
     1441                irc_usermsg(irc, "%s: multiple matches", prefix);
    14721442                return NULL;
    14731443        }
     
    14921462                       
    14931463                        if(n>=40) {
    1494                                 irc_rootmsg(irc, "too many fingerprint digits given, expected at most 40");
     1464                                irc_usermsg(irc, "too many fingerprint digits given, expected at most 40");
    14951465                                return NULL;
    14961466                        }
     
    14991469                                *(p++) = c;
    15001470                        } else {
    1501                                 irc_rootmsg(irc, "invalid hex digit '%c' in block %d", args[i][j], i+1);
     1471                                irc_usermsg(irc, "invalid hex digit '%c' in block %d", args[i][j], i+1);
    15021472                                return NULL;
    15031473                        }
     
    15201490        }
    15211491        if(!k) {
    1522                 irc_rootmsg(irc, "%s: no match", prefix);
     1492                irc_usermsg(irc, "%s: no match", prefix);
    15231493                return NULL;
    15241494        }
     
    15331503        }
    15341504        if(k2) {
    1535                 irc_rootmsg(irc, "%s: multiple matches", prefix);
     1505                irc_usermsg(irc, "%s: multiple matches", prefix);
    15361506                return NULL;
    15371507        }
     
    15481518
    15491519        /* list all privkeys (including ones being generated) */
    1550         irc_rootmsg(irc, "\x1fprivate keys:\x1f");
     1520        irc_usermsg(irc, "\x1fprivate keys:\x1f");
    15511521        for(key=irc->otr->us->privkey_root; key; key=key->next) {
    15521522                const char *hash;
     
    15541524                switch(key->pubkey_type) {
    15551525                case OTRL_PUBKEY_TYPE_DSA:
    1556                         irc_rootmsg(irc, "  %s/%s - DSA", key->accountname, key->protocol);
     1526                        irc_usermsg(irc, "  %s/%s - DSA", key->accountname, key->protocol);
    15571527                        break;
    15581528                default:
    1559                         irc_rootmsg(irc, "  %s/%s - type %d", key->accountname, key->protocol,
     1529                        irc_usermsg(irc, "  %s/%s - type %d", key->accountname, key->protocol,
    15601530                                key->pubkey_type);
    15611531                }
     
    15661536                hash = otrl_privkey_fingerprint(irc->otr->us, human, key->accountname, key->protocol);
    15671537                if(hash) /* should always succeed */
    1568                         irc_rootmsg(irc, "    %s", human);
     1538                        irc_usermsg(irc, "    %s", human);
    15691539        }
    15701540        if(irc->otr->sent_accountname) {
    1571                 irc_rootmsg(irc, "  %s/%s - DSA", irc->otr->sent_accountname,
     1541                irc_usermsg(irc, "  %s/%s - DSA", irc->otr->sent_accountname,
    15721542                        irc->otr->sent_protocol);
    1573                 irc_rootmsg(irc, "    (being generated)");
     1543                irc_usermsg(irc, "    (being generated)");
    15741544        }
    15751545        for(kg=irc->otr->todo; kg; kg=kg->next) {
    1576                 irc_rootmsg(irc, "  %s/%s - DSA", kg->accountname, kg->protocol);
    1577                 irc_rootmsg(irc, "    (queued)");
     1546                irc_usermsg(irc, "  %s/%s - DSA", kg->accountname, kg->protocol);
     1547                irc_usermsg(irc, "    (queued)");
    15781548        }
    15791549        if(key == irc->otr->us->privkey_root &&
    15801550           !irc->otr->sent_accountname &&
    15811551           kg == irc->otr->todo)
    1582                 irc_rootmsg(irc, "  (none)");
     1552                irc_usermsg(irc, "  (none)");
    15831553
    15841554        /* list all contexts */
    1585         irc_rootmsg(irc, "%s", "");
    1586         irc_rootmsg(irc, "\x1f" "connection contexts:\x1f (bold=currently encrypted)");
     1555        irc_usermsg(irc, "%s", "");
     1556        irc_usermsg(irc, "\x1f" "connection contexts:\x1f (bold=currently encrypted)");
    15871557        for(ctx=irc->otr->us->context_root; ctx; ctx=ctx->next) {\
    15881558                irc_user_t *u;
     
    15981568               
    15991569                if(ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
    1600                         irc_rootmsg(irc, "  \x02%s\x02", userstring);
     1570                        irc_usermsg(irc, "  \x02%s\x02", userstring);
    16011571                } else {
    1602                         irc_rootmsg(irc, "  %s", userstring);
     1572                        irc_usermsg(irc, "  %s", userstring);
    16031573                }
    16041574               
     
    16061576        }
    16071577        if(ctx == irc->otr->us->context_root)
    1608                 irc_rootmsg(irc, "  (none)");
     1578                irc_usermsg(irc, "  (none)");
    16091579}
    16101580
     
    16131583        switch(ctx->otr_offer) {
    16141584        case OFFER_NOT:
    1615                 irc_rootmsg(irc, "  otr offer status: none sent");
     1585                irc_usermsg(irc, "  otr offer status: none sent");
    16161586                break;
    16171587        case OFFER_SENT:
    1618                 irc_rootmsg(irc, "  otr offer status: awaiting reply");
     1588                irc_usermsg(irc, "  otr offer status: awaiting reply");
    16191589                break;
    16201590        case OFFER_ACCEPTED:
    1621                 irc_rootmsg(irc, "  otr offer status: accepted our offer");
     1591                irc_usermsg(irc, "  otr offer status: accepted our offer");
    16221592                break;
    16231593        case OFFER_REJECTED:
    1624                 irc_rootmsg(irc, "  otr offer status: ignored our offer");
     1594                irc_usermsg(irc, "  otr offer status: ignored our offer");
    16251595                break;
    16261596        default:
    1627                 irc_rootmsg(irc, "  otr offer status: %d", ctx->otr_offer);
     1597                irc_usermsg(irc, "  otr offer status: %d", ctx->otr_offer);
    16281598        }
    16291599
    16301600        switch(ctx->msgstate) {
    16311601        case OTRL_MSGSTATE_PLAINTEXT:
    1632                 irc_rootmsg(irc, "  connection state: cleartext");
     1602                irc_usermsg(irc, "  connection state: cleartext");
    16331603                break;
    16341604        case OTRL_MSGSTATE_ENCRYPTED:
    1635                 irc_rootmsg(irc, "  connection state: encrypted (v%d)", ctx->protocol_version);
     1605                irc_usermsg(irc, "  connection state: encrypted (v%d)", ctx->protocol_version);
    16361606                break;
    16371607        case OTRL_MSGSTATE_FINISHED:
    1638                 irc_rootmsg(irc, "  connection state: shut down");
     1608                irc_usermsg(irc, "  connection state: shut down");
    16391609                break;
    16401610        default:
    1641                 irc_rootmsg(irc, "  connection state: %d", ctx->msgstate);
    1642         }
    1643 
    1644         irc_rootmsg(irc, "  fingerprints: (bold=active)");     
     1611                irc_usermsg(irc, "  connection state: %d", ctx->msgstate);
     1612        }
     1613
     1614        irc_usermsg(irc, "  fingerprints: (bold=active)");     
    16451615        show_fingerprints(irc, ctx);
    16461616}
     
    16821652               
    16831653                if(pipe(to) < 0 || pipe(from) < 0) {
    1684                         irc_rootmsg(irc, "otr keygen: couldn't create pipe: %s", strerror(errno));
     1654                        irc_usermsg(irc, "otr keygen: couldn't create pipe: %s", strerror(errno));
    16851655                        return;
    16861656                }
     
    16891659                fromf = fdopen(from[0], "r");
    16901660                if(!tof || !fromf) {
    1691                         irc_rootmsg(irc, "otr keygen: couldn't streamify pipe: %s", strerror(errno));
     1661                        irc_usermsg(irc, "otr keygen: couldn't streamify pipe: %s", strerror(errno));
    16921662                        return;
    16931663                }
     
    16951665                p = fork();
    16961666                if(p<0) {
    1697                         irc_rootmsg(irc, "otr keygen: couldn't fork: %s", strerror(errno));
     1667                        irc_usermsg(irc, "otr keygen: couldn't fork: %s", strerror(errno));
    16981668                        return;
    16991669                }
     
    17751745        myfgets(msg, 512, irc->otr->from);
    17761746       
    1777         irc_rootmsg(irc, "%s", msg);
     1747        irc_usermsg(irc, "%s", msg);
    17781748        if(filename[0]) {
    17791749                char *kf = g_strdup_printf("%s%s.otr_keys", global.conf->configdir, irc->user->nick);
     
    18491819       
    18501820        if(keygen_in_progress(irc, acc->user, acc->prpl->name)) {
    1851                 irc_rootmsg(irc, "keygen for %s/%s already in progress",
     1821                irc_usermsg(irc, "keygen for %s/%s already in progress",
    18521822                        acc->user, acc->prpl->name);
    18531823        } else {
    1854                 irc_rootmsg(irc, "starting background keygen for %s/%s",
     1824                irc_usermsg(irc, "starting background keygen for %s/%s",
    18551825                        acc->user, acc->prpl->name);
    1856                 irc_rootmsg(irc, "you will be notified when it completes");
     1826                irc_usermsg(irc, "you will be notified when it completes");
    18571827                otr_keygen(irc, acc->user, acc->prpl->name);
    18581828        }
    18591829}
    1860 
    1861 /* vim: set noet ts=4 sw=4: */
Note: See TracChangeset for help on using the changeset viewer.