Changeset e67e513 for otr.c


Ignore:
Timestamp:
2011-10-03T14:56:58Z (13 years ago)
Author:
unknown <pesco@…>
Branches:
master
Children:
409c2de
Parents:
3231485
Message:

rename irc_usermsg to irc_rootmsg.
add new irc_usermsg, irc_usernotice.
deliver user-specific messages from libotr as notices to that user.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • otr.c

    r3231485 re67e513  
    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;
     
    521521       
    522522        if(!cmd->command) {
    523                 irc_usermsg(irc, "%s: unknown subcommand \"%s\", see \x02help otr\x02",
     523                irc_rootmsg(irc, "%s: unknown subcommand \"%s\", see \x02help otr\x02",
    524524                        args[0], args[1]);
    525525                return;
     
    527527       
    528528        if(!args[cmd->required_parameters+1]) {
    529                 irc_usermsg(irc, "%s %s: not enough arguments (%d req.)",
     529                irc_rootmsg(irc, "%s %s: not enough arguments (%d req.)",
    530530                        args[0], args[1], cmd->required_parameters);
    531531                return;
     
    599599        if (strcmp(accountname, recipient) == 0) {
    600600                /* huh? injecting messages to myself? */
    601                 irc_usermsg(irc, "note to self: %s", message);
     601                irc_rootmsg(irc, "note to self: %s", message);
    602602        } else {
    603603                /* need to drop some consts here :-( */
     
    618618        strip_html(msg);
    619619        if(u) {
    620                 /* display message like it came from this particular user */
    621                 bee_irc_msg_from_user(u, msg, 0 /* sent_at */);
     620                /* display as a notice from this particular user */
     621                irc_usernotice(u, "%s", msg);
    622622        } else {
    623                 irc_usermsg(irc, "otr: %s", msg);
     623                irc_rootmsg(irc, "[otr] %s", msg);
    624624        }
    625625
     
    637637       
    638638        otrl_privkey_hash_to_human(hunam, fingerprint);
    639         irc_usermsg(irc, "new fingerprint for %s: %s",
     639        irc_rootmsg(irc, "new fingerprint for %s: %s",
    640640                peernick(irc, username, protocol), hunam);
    641641}
     
    667667        if(!otr_update_modeflags(irc, u)) {
    668668                char *trust = u->flags & IRC_USER_OTR_TRUSTED ? "trusted" : "untrusted!";
    669                 irc_usermsg(irc, "conversation with %s is now off the record (%s)", u->nick, trust);
     669                irc_rootmsg(irc, "conversation with %s is now off the record (%s)", u->nick, trust);
    670670        }
    671671}
     
    687687        otr_update_uflags(context, u);
    688688        if(!otr_update_modeflags(irc, u))
    689                 irc_usermsg(irc, "conversation with %s is now in the clear", u->nick);
     689                irc_rootmsg(irc, "conversation with %s is now in the clear", u->nick);
    690690}
    691691
     
    708708        if(!otr_update_modeflags(irc, u)) {
    709709                char *trust = u->flags & IRC_USER_OTR_TRUSTED ? "trusted" : "untrusted!";
    710                 irc_usermsg(irc, "otr connection with %s has been refreshed (%s)", u->nick, trust);
     710                irc_rootmsg(irc, "otr connection with %s has been refreshed (%s)", u->nick, trust);
    711711        }
    712712}
     
    752752        u = irc_user_by_name(irc, args[1]);
    753753        if(!u || !u->bu || !u->bu->ic) {
    754                 irc_usermsg(irc, "%s: unknown user", args[1]);
     754                irc_rootmsg(irc, "%s: unknown user", args[1]);
    755755                return;
    756756        }
     
    777777        u = irc_user_by_name(irc, args[1]);
    778778        if(!u || !u->bu || !u->bu->ic) {
    779                 irc_usermsg(irc, "%s: unknown user", args[1]);
     779                irc_rootmsg(irc, "%s: unknown user", args[1]);
    780780                return;
    781781        }
    782782        if(!(u->bu->flags & BEE_USER_ONLINE)) {
    783                 irc_usermsg(irc, "%s is offline", args[1]);
     783                irc_rootmsg(irc, "%s is offline", args[1]);
    784784                return;
    785785        }
     
    808808        u = irc_user_by_name(irc, args[1]);
    809809        if(!u || !u->bu || !u->bu->ic) {
    810                 irc_usermsg(irc, "%s: unknown user", args[1]);
     810                irc_rootmsg(irc, "%s: unknown user", args[1]);
    811811                return;
    812812        }
     
    815815                u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
    816816        if(!ctx) {
    817                 irc_usermsg(irc, "%s: no otr context with user", args[1]);
     817                irc_rootmsg(irc, "%s: no otr context with user", args[1]);
    818818                return;
    819819        }
     
    827827                       
    828828                        if(!*p || !*q) {
    829                                 irc_usermsg(irc, "failed: truncated fingerprint block %d", i+1);
     829                                irc_rootmsg(irc, "failed: truncated fingerprint block %d", i+1);
    830830                                return;
    831831                        }
     
    834834                        y = hexval(*q);
    835835                        if(x<0) {
    836                                 irc_usermsg(irc, "failed: %d. hex digit of block %d out of range", 2*j+1, i+1);
     836                                irc_rootmsg(irc, "failed: %d. hex digit of block %d out of range", 2*j+1, i+1);
    837837                                return;
    838838                        }
    839839                        if(y<0) {
    840                                 irc_usermsg(irc, "failed: %d. hex digit of block %d out of range", 2*j+2, i+1);
     840                                irc_rootmsg(irc, "failed: %d. hex digit of block %d out of range", 2*j+2, i+1);
    841841                                return;
    842842                        }
     
    847847        fp = otrl_context_find_fingerprint(ctx, raw, 0, NULL);
    848848        if(!fp) {
    849                 irc_usermsg(irc, "failed: no such fingerprint for %s", args[1]);
     849                irc_rootmsg(irc, "failed: no such fingerprint for %s", args[1]);
    850850        } else {
    851851                char *trust = args[7] ? args[7] : "affirmed";
    852852                otrl_context_set_trust(fp, trust);
    853                 irc_usermsg(irc, "fingerprint match, trust set to \"%s\"", trust);
     853                irc_rootmsg(irc, "fingerprint match, trust set to \"%s\"", trust);
    854854                if(u->flags & IRC_USER_OTR_ENCRYPTED)
    855855                        u->flags |= IRC_USER_OTR_TRUSTED;
     
    879879                        ctx = otrl_context_find(irc->otr->us, handle, myhandle, protocol, 0, NULL, NULL, NULL);
    880880                        if(!ctx) {
    881                                 irc_usermsg(irc, "no such context");
     881                                irc_rootmsg(irc, "no such context");
    882882                                g_free(arg);
    883883                                return;
     
    886886                        irc_user_t *u = irc_user_by_name(irc, args[1]);
    887887                        if(!u || !u->bu || !u->bu->ic) {
    888                                 irc_usermsg(irc, "%s: unknown user", args[1]);
     888                                irc_rootmsg(irc, "%s: unknown user", args[1]);
    889889                                g_free(arg);
    890890                                return;
     
    893893                                u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
    894894                        if(!ctx) {
    895                                 irc_usermsg(irc, "no otr context with %s", args[1]);
     895                                irc_rootmsg(irc, "no otr context with %s", args[1]);
    896896                                g_free(arg);
    897897                                return;
     
    901901                /* show how we resolved the (nick) argument, if we did */
    902902                if(handle!=arg) {
    903                         irc_usermsg(irc, "%s is %s/%s; we are %s/%s to them", args[1],
     903                        irc_rootmsg(irc, "%s is %s/%s; we are %s/%s to them", args[1],
    904904                                ctx->username, ctx->protocol, ctx->accountname, ctx->protocol);
    905905                }
     
    916916        n = atoi(args[1]);
    917917        if(n<0 || (!n && strcmp(args[1], "0"))) {
    918                 irc_usermsg(irc, "%s: invalid account number", args[1]);
     918                irc_rootmsg(irc, "%s: invalid account number", args[1]);
    919919                return;
    920920        }
     
    923923        for(i=0; i<n && a; i++, a=a->next);
    924924        if(!a) {
    925                 irc_usermsg(irc, "%s: no such account", args[1]);
     925                irc_rootmsg(irc, "%s: no such account", args[1]);
    926926                return;
    927927        }
    928928       
    929929        if(keygen_in_progress(irc, a->user, a->prpl->name)) {
    930                 irc_usermsg(irc, "keygen for account %d already in progress", n);
     930                irc_rootmsg(irc, "keygen for account %d already in progress", n);
    931931                return;
    932932        }
     
    950950       
    951951        if(fp == fp->context->active_fingerprint) {
    952                 irc_usermsg(irc, "that fingerprint is active, terminate otr connection first");
     952                irc_rootmsg(irc, "that fingerprint is active, terminate otr connection first");
    953953                return;
    954954        }
     
    966966       
    967967        if(ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
    968                 irc_usermsg(irc, "active otr connection with %s, terminate it first",
     968                irc_rootmsg(irc, "active otr connection with %s, terminate it first",
    969969                        peernick(irc, ctx->username, ctx->protocol));
    970970                return;
     
    998998               
    999999                if(!args[3]) {
    1000                         irc_usermsg(irc, "otr %s %s: not enough arguments (2 req.)", args[0], args[1]);
     1000                        irc_rootmsg(irc, "otr %s %s: not enough arguments (2 req.)", args[0], args[1]);
    10011001                        return;
    10021002                }
     
    10051005                u = irc_user_by_name(irc, args[2]);
    10061006                if(!u || !u->bu || !u->bu->ic) {
    1007                         irc_usermsg(irc, "%s: unknown user", args[2]);
     1007                        irc_rootmsg(irc, "%s: unknown user", args[2]);
    10081008                        return;
    10091009                }
     
    10121012                        u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
    10131013                if(!ctx) {
    1014                         irc_usermsg(irc, "no otr context with %s", args[2]);
     1014                        irc_rootmsg(irc, "no otr context with %s", args[2]);
    10151015                        return;
    10161016                }
     
    10231023               
    10241024                if(fp == ctx->active_fingerprint) {
    1025                         irc_usermsg(irc, "that fingerprint is active, terminate otr connection first");
     1025                        irc_rootmsg(irc, "that fingerprint is active, terminate otr connection first");
    10261026                        return;
    10271027                }
     
    10481048                u = irc_user_by_name(irc, args[2]);
    10491049                if(!u || !u->bu || !u->bu->ic) {
    1050                         irc_usermsg(irc, "%s: unknown user", args[2]);
     1050                        irc_rootmsg(irc, "%s: unknown user", args[2]);
    10511051                        return;
    10521052                }
     
    10551055                        u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
    10561056                if(!ctx) {
    1057                         irc_usermsg(irc, "no otr context with %s", args[2]);
     1057                        irc_rootmsg(irc, "no otr context with %s", args[2]);
    10581058                        return;
    10591059                }
    10601060               
    10611061                if(ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
    1062                         irc_usermsg(irc, "active otr connection with %s, terminate it first", args[2]);
     1062                        irc_rootmsg(irc, "active otr connection with %s, terminate it first", args[2]);
    10631063                        return;
    10641064                }
     
    10931093        else
    10941094        {
    1095                 irc_usermsg(irc, "otr %s: unknown subcommand \"%s\", see \x02help otr forget\x02",
     1095                irc_rootmsg(irc, "otr %s: unknown subcommand \"%s\", see \x02help otr forget\x02",
    10961096                        args[0], args[1]);
    10971097        }
     
    11191119        if(!context) {
    11201120                /* huh? out of memory or what? */
    1121                 irc_usermsg(irc, "smp: failed to get otr context for %s", u->nick);
     1121                irc_rootmsg(irc, "smp: failed to get otr context for %s", u->nick);
    11221122                otrl_message_abort_smp(us, ops, u->bu->ic, context);
    11231123                otrl_sm_state_free(context->smstate);
     
    11271127
    11281128        if (context->smstate->sm_prog_state == OTRL_SMP_PROG_CHEATED) {
    1129                 irc_usermsg(irc, "smp %s: opponent violated protocol, aborting",
     1129                irc_rootmsg(irc, "smp %s: opponent violated protocol, aborting",
    11301130                        u->nick);
    11311131                otrl_message_abort_smp(us, ops, u->bu->ic, context);
     
    11371137        if (tlv) {
    11381138                if (nextMsg != OTRL_SMP_EXPECT1) {
    1139                         irc_usermsg(irc, "smp %s: spurious SMP1Q received, aborting", u->nick);
     1139                        irc_rootmsg(irc, "smp %s: spurious SMP1Q received, aborting", u->nick);
    11401140                        otrl_message_abort_smp(us, ops, u->bu->ic, context);
    11411141                        otrl_sm_state_free(context->smstate);
    11421142                } else {
    11431143                        char *question = g_strndup((char *)tlv->data, tlv->len);
    1144                         irc_usermsg(irc, "smp: initiated by %s with question: \x02\"%s\"\x02", u->nick,
     1144                        irc_rootmsg(irc, "smp: initiated by %s with question: \x02\"%s\"\x02", u->nick,
    11451145                                question);
    1146                         irc_usermsg(irc, "smp: respond with \x02otr smp %s <answer>\x02",
     1146                        irc_rootmsg(irc, "smp: respond with \x02otr smp %s <answer>\x02",
    11471147                                u->nick);
    11481148                        g_free(question);
     
    11531153        if (tlv) {
    11541154                if (nextMsg != OTRL_SMP_EXPECT1) {
    1155                         irc_usermsg(irc, "smp %s: spurious SMP1 received, aborting", u->nick);
     1155                        irc_rootmsg(irc, "smp %s: spurious SMP1 received, aborting", u->nick);
    11561156                        otrl_message_abort_smp(us, ops, u->bu->ic, context);
    11571157                        otrl_sm_state_free(context->smstate);
    11581158                } else {
    1159                         irc_usermsg(irc, "smp: initiated by %s"
     1159                        irc_rootmsg(irc, "smp: initiated by %s"
    11601160                                " - respond with \x02otr smp %s <secret>\x02",
    11611161                                u->nick, u->nick);
     
    11661166        if (tlv) {
    11671167                if (nextMsg != OTRL_SMP_EXPECT2) {
    1168                         irc_usermsg(irc, "smp %s: spurious SMP2 received, aborting", u->nick);
     1168                        irc_rootmsg(irc, "smp %s: spurious SMP2 received, aborting", u->nick);
    11691169                        otrl_message_abort_smp(us, ops, u->bu->ic, context);
    11701170                        otrl_sm_state_free(context->smstate);
     
    11771177        if (tlv) {
    11781178                if (nextMsg != OTRL_SMP_EXPECT3) {
    1179                         irc_usermsg(irc, "smp %s: spurious SMP3 received, aborting", u->nick);
     1179                        irc_rootmsg(irc, "smp %s: spurious SMP3 received, aborting", u->nick);
    11801180                        otrl_message_abort_smp(us, ops, u->bu->ic, context);
    11811181                        otrl_sm_state_free(context->smstate);
     
    11841184                        if(context->smstate->sm_prog_state == OTRL_SMP_PROG_SUCCEEDED) {
    11851185                                if(context->smstate->received_question) {
    1186                                         irc_usermsg(irc, "smp %s: correct answer, you are trusted",
     1186                                        irc_rootmsg(irc, "smp %s: correct answer, you are trusted",
    11871187                                                u->nick);
    11881188                                } else {
    1189                                         irc_usermsg(irc, "smp %s: secrets proved equal, fingerprint trusted",
     1189                                        irc_rootmsg(irc, "smp %s: secrets proved equal, fingerprint trusted",
    11901190                                                u->nick);
    11911191                                }
    11921192                        } else {
    11931193                                if(context->smstate->received_question) {
    1194                                         irc_usermsg(irc, "smp %s: wrong answer, you are not trusted",
     1194                                        irc_rootmsg(irc, "smp %s: wrong answer, you are not trusted",
    11951195                                                u->nick);
    11961196                                } else {
    1197                                         irc_usermsg(irc, "smp %s: secrets did not match, fingerprint not trusted",
     1197                                        irc_rootmsg(irc, "smp %s: secrets did not match, fingerprint not trusted",
    11981198                                                u->nick);
    11991199                                }
     
    12061206        if (tlv) {
    12071207                if (nextMsg != OTRL_SMP_EXPECT4) {
    1208                         irc_usermsg(irc, "smp %s: spurious SMP4 received, aborting", u->nick);
     1208                        irc_rootmsg(irc, "smp %s: spurious SMP4 received, aborting", u->nick);
    12091209                        otrl_message_abort_smp(us, ops, u->bu->ic, context);
    12101210                        otrl_sm_state_free(context->smstate);
     
    12121212                        /* SMP4 received, otrl_message_receiving will have set fp trust */
    12131213                        if(context->smstate->sm_prog_state == OTRL_SMP_PROG_SUCCEEDED) {
    1214                                 irc_usermsg(irc, "smp %s: secrets proved equal, fingerprint trusted",
     1214                                irc_rootmsg(irc, "smp %s: secrets proved equal, fingerprint trusted",
    12151215                                        u->nick);
    12161216                        } else {
    1217                                 irc_usermsg(irc, "smp %s: secrets did not match, fingerprint not trusted",
     1217                                irc_rootmsg(irc, "smp %s: secrets did not match, fingerprint not trusted",
    12181218                                        u->nick);
    12191219                        }
     
    12241224        tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP_ABORT);
    12251225        if (tlv) {
    1226                 irc_usermsg(irc, "smp: received abort from %s", u->nick);
     1226                irc_rootmsg(irc, "smp: received abort from %s", u->nick);
    12271227                otrl_sm_state_free(context->smstate);
    12281228                /* smp is in back in EXPECT1 */
     
    12391239        u = irc_user_by_name(irc, nick);
    12401240        if(!u || !u->bu || !u->bu->ic) {
    1241                 irc_usermsg(irc, "%s: unknown user", nick);
     1241                irc_rootmsg(irc, "%s: unknown user", nick);
    12421242                return;
    12431243        }
    12441244        if(!(u->bu->flags & BEE_USER_ONLINE)) {
    1245                 irc_usermsg(irc, "%s is offline", nick);
     1245                irc_rootmsg(irc, "%s is offline", nick);
    12461246                return;
    12471247        }
     
    12501250                u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
    12511251        if(!ctx || ctx->msgstate != OTRL_MSGSTATE_ENCRYPTED) {
    1252                 irc_usermsg(irc, "smp: otr inactive with %s, try \x02otr connect"
     1252                irc_rootmsg(irc, "smp: otr inactive with %s, try \x02otr connect"
    12531253                                " %s\x02", nick, nick);
    12541254                return;
     
    12651265        if(question) {
    12661266                /* this was 'otr smpq', just initiate */
    1267                 irc_usermsg(irc, "smp: initiating with %s...", u->nick);
     1267                irc_rootmsg(irc, "smp: initiating with %s...", u->nick);
    12681268                otrl_message_initiate_smp_q(irc->otr->us, &otr_ops, u->bu->ic, ctx,
    12691269                        question, (unsigned char *)secret, strlen(secret));
     
    12741274                   is completed or aborted! */
    12751275                if(ctx->smstate->secret == NULL) {
    1276                         irc_usermsg(irc, "smp: initiating with %s...", u->nick);
     1276                        irc_rootmsg(irc, "smp: initiating with %s...", u->nick);
    12771277                        otrl_message_initiate_smp(irc->otr->us, &otr_ops,
    12781278                                u->bu->ic, ctx, (unsigned char *)secret, strlen(secret));
     
    12811281                        /* if we're still in EXPECT1 but smstate is initialized, we must have
    12821282                           received the SMP1, so let's issue a response */
    1283                         irc_usermsg(irc, "smp: responding to %s...", u->nick);
     1283                        irc_rootmsg(irc, "smp: responding to %s...", u->nick);
    12841284                        otrl_message_respond_smp(irc->otr->us, &otr_ops,
    12851285                                u->bu->ic, ctx, (unsigned char *)secret, strlen(secret));
     
    13961396                }
    13971397                if(fp == ctx->active_fingerprint) {
    1398                         irc_usermsg(irc, "    \x02%s (%s)\x02", human, trust);
     1398                        irc_rootmsg(irc, "    \x02%s (%s)\x02", human, trust);
    13991399                } else {
    1400                         irc_usermsg(irc, "    %s (%s)", human, trust);
     1400                        irc_rootmsg(irc, "    %s (%s)", human, trust);
    14011401                }
    14021402        }
    14031403        if(count==0)
    1404                 irc_usermsg(irc, "    (none)");
     1404                irc_rootmsg(irc, "    (none)");
    14051405}
    14061406
     
    14211421                       
    14221422                        if(n>=40) {
    1423                                 irc_usermsg(irc, "too many fingerprint digits given, expected at most 40");
     1423                                irc_rootmsg(irc, "too many fingerprint digits given, expected at most 40");
    14241424                                return NULL;
    14251425                        }
     
    14281428                                *(p++) = c;
    14291429                        } else {
    1430                                 irc_usermsg(irc, "invalid hex digit '%c' in block %d", args[i][j], i+1);
     1430                                irc_rootmsg(irc, "invalid hex digit '%c' in block %d", args[i][j], i+1);
    14311431                                return NULL;
    14321432                        }
     
    14491449        }
    14501450        if(!fp) {
    1451                 irc_usermsg(irc, "%s: no match", prefix);
     1451                irc_rootmsg(irc, "%s: no match", prefix);
    14521452                return NULL;
    14531453        }
     
    14621462        }
    14631463        if(fp2) {
    1464                 irc_usermsg(irc, "%s: multiple matches", prefix);
     1464                irc_rootmsg(irc, "%s: multiple matches", prefix);
    14651465                return NULL;
    14661466        }
     
    14851485                       
    14861486                        if(n>=40) {
    1487                                 irc_usermsg(irc, "too many fingerprint digits given, expected at most 40");
     1487                                irc_rootmsg(irc, "too many fingerprint digits given, expected at most 40");
    14881488                                return NULL;
    14891489                        }
     
    14921492                                *(p++) = c;
    14931493                        } else {
    1494                                 irc_usermsg(irc, "invalid hex digit '%c' in block %d", args[i][j], i+1);
     1494                                irc_rootmsg(irc, "invalid hex digit '%c' in block %d", args[i][j], i+1);
    14951495                                return NULL;
    14961496                        }
     
    15131513        }
    15141514        if(!k) {
    1515                 irc_usermsg(irc, "%s: no match", prefix);
     1515                irc_rootmsg(irc, "%s: no match", prefix);
    15161516                return NULL;
    15171517        }
     
    15261526        }
    15271527        if(k2) {
    1528                 irc_usermsg(irc, "%s: multiple matches", prefix);
     1528                irc_rootmsg(irc, "%s: multiple matches", prefix);
    15291529                return NULL;
    15301530        }
     
    15411541
    15421542        /* list all privkeys (including ones being generated) */
    1543         irc_usermsg(irc, "\x1fprivate keys:\x1f");
     1543        irc_rootmsg(irc, "\x1fprivate keys:\x1f");
    15441544        for(key=irc->otr->us->privkey_root; key; key=key->next) {
    15451545                const char *hash;
     
    15471547                switch(key->pubkey_type) {
    15481548                case OTRL_PUBKEY_TYPE_DSA:
    1549                         irc_usermsg(irc, "  %s/%s - DSA", key->accountname, key->protocol);
     1549                        irc_rootmsg(irc, "  %s/%s - DSA", key->accountname, key->protocol);
    15501550                        break;
    15511551                default:
    1552                         irc_usermsg(irc, "  %s/%s - type %d", key->accountname, key->protocol,
     1552                        irc_rootmsg(irc, "  %s/%s - type %d", key->accountname, key->protocol,
    15531553                                key->pubkey_type);
    15541554                }
     
    15591559                hash = otrl_privkey_fingerprint(irc->otr->us, human, key->accountname, key->protocol);
    15601560                if(hash) /* should always succeed */
    1561                         irc_usermsg(irc, "    %s", human);
     1561                        irc_rootmsg(irc, "    %s", human);
    15621562        }
    15631563        if(irc->otr->sent_accountname) {
    1564                 irc_usermsg(irc, "  %s/%s - DSA", irc->otr->sent_accountname,
     1564                irc_rootmsg(irc, "  %s/%s - DSA", irc->otr->sent_accountname,
    15651565                        irc->otr->sent_protocol);
    1566                 irc_usermsg(irc, "    (being generated)");
     1566                irc_rootmsg(irc, "    (being generated)");
    15671567        }
    15681568        for(kg=irc->otr->todo; kg; kg=kg->next) {
    1569                 irc_usermsg(irc, "  %s/%s - DSA", kg->accountname, kg->protocol);
    1570                 irc_usermsg(irc, "    (queued)");
     1569                irc_rootmsg(irc, "  %s/%s - DSA", kg->accountname, kg->protocol);
     1570                irc_rootmsg(irc, "    (queued)");
    15711571        }
    15721572        if(key == irc->otr->us->privkey_root &&
    15731573           !irc->otr->sent_accountname &&
    15741574           kg == irc->otr->todo)
    1575                 irc_usermsg(irc, "  (none)");
     1575                irc_rootmsg(irc, "  (none)");
    15761576
    15771577        /* list all contexts */
    1578         irc_usermsg(irc, "%s", "");
    1579         irc_usermsg(irc, "\x1f" "connection contexts:\x1f (bold=currently encrypted)");
     1578        irc_rootmsg(irc, "%s", "");
     1579        irc_rootmsg(irc, "\x1f" "connection contexts:\x1f (bold=currently encrypted)");
    15801580        for(ctx=irc->otr->us->context_root; ctx; ctx=ctx->next) {\
    15811581                irc_user_t *u;
     
    15911591               
    15921592                if(ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
    1593                         irc_usermsg(irc, "  \x02%s\x02", userstring);
     1593                        irc_rootmsg(irc, "  \x02%s\x02", userstring);
    15941594                } else {
    1595                         irc_usermsg(irc, "  %s", userstring);
     1595                        irc_rootmsg(irc, "  %s", userstring);
    15961596                }
    15971597               
     
    15991599        }
    16001600        if(ctx == irc->otr->us->context_root)
    1601                 irc_usermsg(irc, "  (none)");
     1601                irc_rootmsg(irc, "  (none)");
    16021602}
    16031603
     
    16061606        switch(ctx->otr_offer) {
    16071607        case OFFER_NOT:
    1608                 irc_usermsg(irc, "  otr offer status: none sent");
     1608                irc_rootmsg(irc, "  otr offer status: none sent");
    16091609                break;
    16101610        case OFFER_SENT:
    1611                 irc_usermsg(irc, "  otr offer status: awaiting reply");
     1611                irc_rootmsg(irc, "  otr offer status: awaiting reply");
    16121612                break;
    16131613        case OFFER_ACCEPTED:
    1614                 irc_usermsg(irc, "  otr offer status: accepted our offer");
     1614                irc_rootmsg(irc, "  otr offer status: accepted our offer");
    16151615                break;
    16161616        case OFFER_REJECTED:
    1617                 irc_usermsg(irc, "  otr offer status: ignored our offer");
     1617                irc_rootmsg(irc, "  otr offer status: ignored our offer");
    16181618                break;
    16191619        default:
    1620                 irc_usermsg(irc, "  otr offer status: %d", ctx->otr_offer);
     1620                irc_rootmsg(irc, "  otr offer status: %d", ctx->otr_offer);
    16211621        }
    16221622
    16231623        switch(ctx->msgstate) {
    16241624        case OTRL_MSGSTATE_PLAINTEXT:
    1625                 irc_usermsg(irc, "  connection state: cleartext");
     1625                irc_rootmsg(irc, "  connection state: cleartext");
    16261626                break;
    16271627        case OTRL_MSGSTATE_ENCRYPTED:
    1628                 irc_usermsg(irc, "  connection state: encrypted (v%d)", ctx->protocol_version);
     1628                irc_rootmsg(irc, "  connection state: encrypted (v%d)", ctx->protocol_version);
    16291629                break;
    16301630        case OTRL_MSGSTATE_FINISHED:
    1631                 irc_usermsg(irc, "  connection state: shut down");
     1631                irc_rootmsg(irc, "  connection state: shut down");
    16321632                break;
    16331633        default:
    1634                 irc_usermsg(irc, "  connection state: %d", ctx->msgstate);
    1635         }
    1636 
    1637         irc_usermsg(irc, "  fingerprints: (bold=active)");     
     1634                irc_rootmsg(irc, "  connection state: %d", ctx->msgstate);
     1635        }
     1636
     1637        irc_rootmsg(irc, "  fingerprints: (bold=active)");     
    16381638        show_fingerprints(irc, ctx);
    16391639}
     
    16751675               
    16761676                if(pipe(to) < 0 || pipe(from) < 0) {
    1677                         irc_usermsg(irc, "otr keygen: couldn't create pipe: %s", strerror(errno));
     1677                        irc_rootmsg(irc, "otr keygen: couldn't create pipe: %s", strerror(errno));
    16781678                        return;
    16791679                }
     
    16821682                fromf = fdopen(from[0], "r");
    16831683                if(!tof || !fromf) {
    1684                         irc_usermsg(irc, "otr keygen: couldn't streamify pipe: %s", strerror(errno));
     1684                        irc_rootmsg(irc, "otr keygen: couldn't streamify pipe: %s", strerror(errno));
    16851685                        return;
    16861686                }
     
    16881688                p = fork();
    16891689                if(p<0) {
    1690                         irc_usermsg(irc, "otr keygen: couldn't fork: %s", strerror(errno));
     1690                        irc_rootmsg(irc, "otr keygen: couldn't fork: %s", strerror(errno));
    16911691                        return;
    16921692                }
     
    17681768        myfgets(msg, 512, irc->otr->from);
    17691769       
    1770         irc_usermsg(irc, "%s", msg);
     1770        irc_rootmsg(irc, "%s", msg);
    17711771        if(filename[0]) {
    17721772                char *kf = g_strdup_printf("%s%s.otr_keys", global.conf->configdir, irc->user->nick);
     
    18421842       
    18431843        if(keygen_in_progress(irc, acc->user, acc->prpl->name)) {
    1844                 irc_usermsg(irc, "keygen for %s/%s already in progress",
     1844                irc_rootmsg(irc, "keygen for %s/%s already in progress",
    18451845                        acc->user, acc->prpl->name);
    18461846        } else {
    1847                 irc_usermsg(irc, "starting background keygen for %s/%s",
     1847                irc_rootmsg(irc, "starting background keygen for %s/%s",
    18481848                        acc->user, acc->prpl->name);
    1849                 irc_usermsg(irc, "you will be notified when it completes");
     1849                irc_rootmsg(irc, "you will be notified when it completes");
    18501850                otr_keygen(irc, acc->user, acc->prpl->name);
    18511851        }
    18521852}
    18531853
    1854 /* vim: noet ts=4 sw=4 */
     1854/* vim: set noet ts=4 sw=4: */
Note: See TracChangeset for help on using the changeset viewer.