Changes in otr.c [aea22cd:f1cf01c]
Legend:
- Unmodified
- Added
- Removed
-
otr.c
raea22cd rf1cf01c 278 278 e = otrl_privkey_read(irc->otr->us, s); 279 279 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)); 281 281 } 282 282 g_snprintf(s, 511, "%s%s.otr_fprints", global.conf->configdir, irc->user->nick); 283 283 e = otrl_privkey_read_fingerprints(irc->otr->us, s, NULL, NULL); 284 284 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)); 286 286 } 287 287 … … 291 291 } 292 292 if(kg) { 293 irc_ rootmsg(irc, "Notice: "293 irc_usermsg(irc, "Notice: " 294 294 "The accounts above do not have OTR encryption keys associated with them, yet. " 295 295 "These keys are now being generated in the background. " … … 309 309 e = otrl_privkey_write_fingerprints(irc->otr->us, s); 310 310 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)); 312 312 } 313 313 chmod(s, 0600); … … 348 348 k = otrl_privkey_find(irc->otr->us, a->user, a->prpl->name); 349 349 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); 351 351 return 0; 352 352 } 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); 354 354 return 0; 355 355 } 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); 357 357 otr_keygen(irc, a->user, a->prpl->name); 358 358 return 1; … … 365 365 char *newmsg = NULL; 366 366 OtrlTLV *tlvs = NULL; 367 char *colormsg; 367 368 irc_t *irc = iu->irc; 368 369 struct im_connection *ic = iu->bu->ic; … … 384 385 } else if(!newmsg) { 385 386 /* this was a non-OTR message */ 386 return msg;387 return g_strdup(msg); 387 388 } else { 388 389 /* OTR has processed this message */ 389 390 ConnContext *context = otrl_context_find(irc->otr->us, iu->bu->handle, 390 391 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;395 392 396 393 if(context && context->msgstate == OTRL_MSGSTATE_ENCRYPTED) { … … 400 397 !(ic->flags & OPT_DOES_HTML) && 401 398 set_getbool(&ic->bee->set, "strip_html")) { 402 strip_html( msg);399 strip_html(newmsg); 403 400 } 404 401 405 402 /* coloring */ 406 403 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; 409 406 const char *trust = context->active_fingerprint->trust; 410 411 407 if(trust && trust[0] != '\0') 412 408 color=3; /* green */ … … 414 410 color=5; /* red */ 415 411 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); 421 418 } 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);431 419 } 432 } 433 434 if(msg == newmsg) { 435 msg = g_strdup(newmsg); 436 } 420 } else { 421 colormsg = g_strdup(newmsg); 422 } 423 437 424 otrl_message_free(newmsg); 438 return msg;425 return colormsg; 439 426 } 440 427 } … … 444 431 int st; 445 432 char *otrmsg = NULL; 446 char *emsg = msg; /* the message as we hand it to libotr */447 433 ConnContext *ctx = NULL; 448 434 irc_t *irc = iu->irc; … … 454 440 } 455 441 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 456 456 ctx = otrl_context_find(irc->otr->us, 457 457 iu->bu->handle, ic->acc->user, ic->acc->prpl->name, 458 458 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 }477 459 478 460 if(otrmsg) { … … 522 504 523 505 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", 525 507 args[0], args[1]); 526 508 return; … … 528 510 529 511 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.)", 531 513 args[0], args[1], cmd->required_parameters); 532 514 return; … … 600 582 if (strcmp(accountname, recipient) == 0) { 601 583 /* huh? injecting messages to myself? */ 602 irc_ rootmsg(irc, "note to self: %s", message);584 irc_usermsg(irc, "note to self: %s", message); 603 585 } else { 604 586 /* need to drop some consts here :-( */ … … 615 597 char *msg = g_strdup(message); 616 598 irc_t *irc = ic->bee->ui_data; 617 irc_user_t *u = peeruser(irc, username, protocol);618 599 619 600 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); 626 602 627 603 g_free(msg); … … 635 611 struct im_connection *ic = check_imc(opdata, accountname, protocol); 636 612 irc_t *irc = ic->bee->ui_data; 637 irc_user_t *u = peeruser(irc, username, protocol);638 613 char hunam[45]; /* anybody looking? ;-) */ 639 614 640 615 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); 648 618 } 649 619 … … 674 644 if(!otr_update_modeflags(irc, u)) { 675 645 char *trust = u->flags & IRC_USER_OTR_TRUSTED ? "trusted" : "untrusted!"; 676 irc_user notice(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); 677 647 } 678 648 } … … 694 664 otr_update_uflags(context, u); 695 665 if(!otr_update_modeflags(irc, u)) 696 irc_user notice(u, "conversation is now in cleartext");666 irc_usermsg(irc, "conversation with %s is now in the clear", u->nick); 697 667 } 698 668 … … 715 685 if(!otr_update_modeflags(irc, u)) { 716 686 char *trust = u->flags & IRC_USER_OTR_TRUSTED ? "trusted" : "untrusted!"; 717 irc_user notice(u, "otr connection has been refreshed (%s)", trust);687 irc_usermsg(irc, "otr connection with %s has been refreshed (%s)", u->nick, trust); 718 688 } 719 689 } … … 759 729 u = irc_user_by_name(irc, args[1]); 760 730 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]); 762 732 return; 763 733 } … … 784 754 u = irc_user_by_name(irc, args[1]); 785 755 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]); 787 757 return; 788 758 } 789 759 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]); 791 761 return; 792 762 } … … 815 785 u = irc_user_by_name(irc, args[1]); 816 786 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]); 818 788 return; 819 789 } … … 822 792 u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL); 823 793 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]); 825 795 return; 826 796 } … … 834 804 835 805 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); 837 807 return; 838 808 } … … 841 811 y = hexval(*q); 842 812 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); 844 814 return; 845 815 } 846 816 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); 848 818 return; 849 819 } … … 854 824 fp = otrl_context_find_fingerprint(ctx, raw, 0, NULL); 855 825 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]); 857 827 } else { 858 828 char *trust = args[7] ? args[7] : "affirmed"; 859 829 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); 861 831 if(u->flags & IRC_USER_OTR_ENCRYPTED) 862 832 u->flags |= IRC_USER_OTR_TRUSTED; … … 886 856 ctx = otrl_context_find(irc->otr->us, handle, myhandle, protocol, 0, NULL, NULL, NULL); 887 857 if(!ctx) { 888 irc_ rootmsg(irc, "no such context");858 irc_usermsg(irc, "no such context"); 889 859 g_free(arg); 890 860 return; … … 893 863 irc_user_t *u = irc_user_by_name(irc, args[1]); 894 864 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]); 896 866 g_free(arg); 897 867 return; … … 900 870 u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL); 901 871 if(!ctx) { 902 irc_ rootmsg(irc, "no otr context with %s", args[1]);872 irc_usermsg(irc, "no otr context with %s", args[1]); 903 873 g_free(arg); 904 874 return; … … 908 878 /* show how we resolved the (nick) argument, if we did */ 909 879 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], 911 881 ctx->username, ctx->protocol, ctx->accountname, ctx->protocol); 912 882 } … … 923 893 n = atoi(args[1]); 924 894 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]); 926 896 return; 927 897 } … … 930 900 for(i=0; i<n && a; i++, a=a->next); 931 901 if(!a) { 932 irc_ rootmsg(irc, "%s: no such account", args[1]);902 irc_usermsg(irc, "%s: no such account", args[1]); 933 903 return; 934 904 } 935 905 936 906 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); 938 908 return; 939 909 } … … 957 927 958 928 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"); 960 930 return; 961 931 } … … 973 943 974 944 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", 976 946 peernick(irc, ctx->username, ctx->protocol)); 977 947 return; … … 1005 975 1006 976 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]); 1008 978 return; 1009 979 } … … 1012 982 u = irc_user_by_name(irc, args[2]); 1013 983 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]); 1015 985 return; 1016 986 } … … 1019 989 u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL); 1020 990 if(!ctx) { 1021 irc_ rootmsg(irc, "no otr context with %s", args[2]);991 irc_usermsg(irc, "no otr context with %s", args[2]); 1022 992 return; 1023 993 } … … 1030 1000 1031 1001 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"); 1033 1003 return; 1034 1004 } … … 1055 1025 u = irc_user_by_name(irc, args[2]); 1056 1026 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]); 1058 1028 return; 1059 1029 } … … 1062 1032 u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL); 1063 1033 if(!ctx) { 1064 irc_ rootmsg(irc, "no otr context with %s", args[2]);1034 irc_usermsg(irc, "no otr context with %s", args[2]); 1065 1035 return; 1066 1036 } 1067 1037 1068 1038 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]); 1070 1040 return; 1071 1041 } … … 1100 1070 else 1101 1071 { 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", 1103 1073 args[0], args[1]); 1104 1074 } … … 1126 1096 if(!context) { 1127 1097 /* 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); 1129 1099 otrl_message_abort_smp(us, ops, u->bu->ic, context); 1130 1100 otrl_sm_state_free(context->smstate); … … 1134 1104 1135 1105 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", 1137 1107 u->nick); 1138 1108 otrl_message_abort_smp(us, ops, u->bu->ic, context); … … 1144 1114 if (tlv) { 1145 1115 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); 1147 1117 otrl_message_abort_smp(us, ops, u->bu->ic, context); 1148 1118 otrl_sm_state_free(context->smstate); 1149 1119 } else { 1150 1120 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, 1152 1122 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", 1154 1124 u->nick); 1155 1125 g_free(question); … … 1160 1130 if (tlv) { 1161 1131 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); 1163 1133 otrl_message_abort_smp(us, ops, u->bu->ic, context); 1164 1134 otrl_sm_state_free(context->smstate); 1165 1135 } else { 1166 irc_ rootmsg(irc, "smp: initiated by %s"1136 irc_usermsg(irc, "smp: initiated by %s" 1167 1137 " - respond with \x02otr smp %s <secret>\x02", 1168 1138 u->nick, u->nick); … … 1173 1143 if (tlv) { 1174 1144 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); 1176 1146 otrl_message_abort_smp(us, ops, u->bu->ic, context); 1177 1147 otrl_sm_state_free(context->smstate); … … 1184 1154 if (tlv) { 1185 1155 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); 1187 1157 otrl_message_abort_smp(us, ops, u->bu->ic, context); 1188 1158 otrl_sm_state_free(context->smstate); … … 1191 1161 if(context->smstate->sm_prog_state == OTRL_SMP_PROG_SUCCEEDED) { 1192 1162 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", 1194 1164 u->nick); 1195 1165 } else { 1196 irc_ rootmsg(irc, "smp %s: secrets proved equal, fingerprint trusted",1166 irc_usermsg(irc, "smp %s: secrets proved equal, fingerprint trusted", 1197 1167 u->nick); 1198 1168 } 1199 1169 } else { 1200 1170 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", 1202 1172 u->nick); 1203 1173 } 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", 1205 1175 u->nick); 1206 1176 } … … 1213 1183 if (tlv) { 1214 1184 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); 1216 1186 otrl_message_abort_smp(us, ops, u->bu->ic, context); 1217 1187 otrl_sm_state_free(context->smstate); … … 1219 1189 /* SMP4 received, otrl_message_receiving will have set fp trust */ 1220 1190 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", 1222 1192 u->nick); 1223 1193 } 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", 1225 1195 u->nick); 1226 1196 } … … 1231 1201 tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP_ABORT); 1232 1202 if (tlv) { 1233 irc_ rootmsg(irc, "smp: received abort from %s", u->nick);1203 irc_usermsg(irc, "smp: received abort from %s", u->nick); 1234 1204 otrl_sm_state_free(context->smstate); 1235 1205 /* smp is in back in EXPECT1 */ … … 1246 1216 u = irc_user_by_name(irc, nick); 1247 1217 if(!u || !u->bu || !u->bu->ic) { 1248 irc_ rootmsg(irc, "%s: unknown user", nick);1218 irc_usermsg(irc, "%s: unknown user", nick); 1249 1219 return; 1250 1220 } 1251 1221 if(!(u->bu->flags & BEE_USER_ONLINE)) { 1252 irc_ rootmsg(irc, "%s is offline", nick);1222 irc_usermsg(irc, "%s is offline", nick); 1253 1223 return; 1254 1224 } … … 1257 1227 u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL); 1258 1228 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" 1260 1230 " %s\x02", nick, nick); 1261 1231 return; … … 1272 1242 if(question) { 1273 1243 /* 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); 1275 1245 otrl_message_initiate_smp_q(irc->otr->us, &otr_ops, u->bu->ic, ctx, 1276 1246 question, (unsigned char *)secret, strlen(secret)); … … 1281 1251 is completed or aborted! */ 1282 1252 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); 1284 1254 otrl_message_initiate_smp(irc->otr->us, &otr_ops, 1285 1255 u->bu->ic, ctx, (unsigned char *)secret, strlen(secret)); … … 1288 1258 /* if we're still in EXPECT1 but smstate is initialized, we must have 1289 1259 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); 1291 1261 otrl_message_respond_smp(irc->otr->us, &otr_ops, 1292 1262 u->bu->ic, ctx, (unsigned char *)secret, strlen(secret)); … … 1403 1373 } 1404 1374 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); 1406 1376 } else { 1407 irc_ rootmsg(irc, " %s (%s)", human, trust);1377 irc_usermsg(irc, " %s (%s)", human, trust); 1408 1378 } 1409 1379 } 1410 1380 if(count==0) 1411 irc_ rootmsg(irc, " (none)");1381 irc_usermsg(irc, " (none)"); 1412 1382 } 1413 1383 … … 1428 1398 1429 1399 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"); 1431 1401 return NULL; 1432 1402 } … … 1435 1405 *(p++) = c; 1436 1406 } 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); 1438 1408 return NULL; 1439 1409 } … … 1456 1426 } 1457 1427 if(!fp) { 1458 irc_ rootmsg(irc, "%s: no match", prefix);1428 irc_usermsg(irc, "%s: no match", prefix); 1459 1429 return NULL; 1460 1430 } … … 1469 1439 } 1470 1440 if(fp2) { 1471 irc_ rootmsg(irc, "%s: multiple matches", prefix);1441 irc_usermsg(irc, "%s: multiple matches", prefix); 1472 1442 return NULL; 1473 1443 } … … 1492 1462 1493 1463 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"); 1495 1465 return NULL; 1496 1466 } … … 1499 1469 *(p++) = c; 1500 1470 } 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); 1502 1472 return NULL; 1503 1473 } … … 1520 1490 } 1521 1491 if(!k) { 1522 irc_ rootmsg(irc, "%s: no match", prefix);1492 irc_usermsg(irc, "%s: no match", prefix); 1523 1493 return NULL; 1524 1494 } … … 1533 1503 } 1534 1504 if(k2) { 1535 irc_ rootmsg(irc, "%s: multiple matches", prefix);1505 irc_usermsg(irc, "%s: multiple matches", prefix); 1536 1506 return NULL; 1537 1507 } … … 1548 1518 1549 1519 /* list all privkeys (including ones being generated) */ 1550 irc_ rootmsg(irc, "\x1fprivate keys:\x1f");1520 irc_usermsg(irc, "\x1fprivate keys:\x1f"); 1551 1521 for(key=irc->otr->us->privkey_root; key; key=key->next) { 1552 1522 const char *hash; … … 1554 1524 switch(key->pubkey_type) { 1555 1525 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); 1557 1527 break; 1558 1528 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, 1560 1530 key->pubkey_type); 1561 1531 } … … 1566 1536 hash = otrl_privkey_fingerprint(irc->otr->us, human, key->accountname, key->protocol); 1567 1537 if(hash) /* should always succeed */ 1568 irc_ rootmsg(irc, " %s", human);1538 irc_usermsg(irc, " %s", human); 1569 1539 } 1570 1540 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, 1572 1542 irc->otr->sent_protocol); 1573 irc_ rootmsg(irc, " (being generated)");1543 irc_usermsg(irc, " (being generated)"); 1574 1544 } 1575 1545 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)"); 1578 1548 } 1579 1549 if(key == irc->otr->us->privkey_root && 1580 1550 !irc->otr->sent_accountname && 1581 1551 kg == irc->otr->todo) 1582 irc_ rootmsg(irc, " (none)");1552 irc_usermsg(irc, " (none)"); 1583 1553 1584 1554 /* 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)"); 1587 1557 for(ctx=irc->otr->us->context_root; ctx; ctx=ctx->next) {\ 1588 1558 irc_user_t *u; … … 1598 1568 1599 1569 if(ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED) { 1600 irc_ rootmsg(irc, " \x02%s\x02", userstring);1570 irc_usermsg(irc, " \x02%s\x02", userstring); 1601 1571 } else { 1602 irc_ rootmsg(irc, " %s", userstring);1572 irc_usermsg(irc, " %s", userstring); 1603 1573 } 1604 1574 … … 1606 1576 } 1607 1577 if(ctx == irc->otr->us->context_root) 1608 irc_ rootmsg(irc, " (none)");1578 irc_usermsg(irc, " (none)"); 1609 1579 } 1610 1580 … … 1613 1583 switch(ctx->otr_offer) { 1614 1584 case OFFER_NOT: 1615 irc_ rootmsg(irc, " otr offer status: none sent");1585 irc_usermsg(irc, " otr offer status: none sent"); 1616 1586 break; 1617 1587 case OFFER_SENT: 1618 irc_ rootmsg(irc, " otr offer status: awaiting reply");1588 irc_usermsg(irc, " otr offer status: awaiting reply"); 1619 1589 break; 1620 1590 case OFFER_ACCEPTED: 1621 irc_ rootmsg(irc, " otr offer status: accepted our offer");1591 irc_usermsg(irc, " otr offer status: accepted our offer"); 1622 1592 break; 1623 1593 case OFFER_REJECTED: 1624 irc_ rootmsg(irc, " otr offer status: ignored our offer");1594 irc_usermsg(irc, " otr offer status: ignored our offer"); 1625 1595 break; 1626 1596 default: 1627 irc_ rootmsg(irc, " otr offer status: %d", ctx->otr_offer);1597 irc_usermsg(irc, " otr offer status: %d", ctx->otr_offer); 1628 1598 } 1629 1599 1630 1600 switch(ctx->msgstate) { 1631 1601 case OTRL_MSGSTATE_PLAINTEXT: 1632 irc_ rootmsg(irc, " connection state: cleartext");1602 irc_usermsg(irc, " connection state: cleartext"); 1633 1603 break; 1634 1604 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); 1636 1606 break; 1637 1607 case OTRL_MSGSTATE_FINISHED: 1638 irc_ rootmsg(irc, " connection state: shut down");1608 irc_usermsg(irc, " connection state: shut down"); 1639 1609 break; 1640 1610 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)"); 1645 1615 show_fingerprints(irc, ctx); 1646 1616 } … … 1682 1652 1683 1653 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)); 1685 1655 return; 1686 1656 } … … 1689 1659 fromf = fdopen(from[0], "r"); 1690 1660 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)); 1692 1662 return; 1693 1663 } … … 1695 1665 p = fork(); 1696 1666 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)); 1698 1668 return; 1699 1669 } … … 1775 1745 myfgets(msg, 512, irc->otr->from); 1776 1746 1777 irc_ rootmsg(irc, "%s", msg);1747 irc_usermsg(irc, "%s", msg); 1778 1748 if(filename[0]) { 1779 1749 char *kf = g_strdup_printf("%s%s.otr_keys", global.conf->configdir, irc->user->nick); … … 1849 1819 1850 1820 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", 1852 1822 acc->user, acc->prpl->name); 1853 1823 } else { 1854 irc_ rootmsg(irc, "starting background keygen for %s/%s",1824 irc_usermsg(irc, "starting background keygen for %s/%s", 1855 1825 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"); 1857 1827 otr_keygen(irc, acc->user, acc->prpl->name); 1858 1828 } 1859 1829 } 1860 1861 /* vim: set noet ts=4 sw=4: */
Note: See TracChangeset
for help on using the changeset viewer.