Index: otr.c
===================================================================
--- otr.c	(revision f1cf01c5eb91fdd3effe04a27cdc5a268ff5ee66)
+++ otr.c	(revision aea22cd1e0e955848c143a8fc36978391e9a4846)
@@ -278,10 +278,10 @@
 	e = otrl_privkey_read(irc->otr->us, s);
 	if(e && e!=enoent) {
-		irc_usermsg(irc, "otr load: %s: %s", s, gcry_strerror(e));
+		irc_rootmsg(irc, "otr load: %s: %s", s, gcry_strerror(e));
 	}
 	g_snprintf(s, 511, "%s%s.otr_fprints", global.conf->configdir, irc->user->nick);
 	e = otrl_privkey_read_fingerprints(irc->otr->us, s, NULL, NULL);
 	if(e && e!=enoent) {
-		irc_usermsg(irc, "otr load: %s: %s", s, gcry_strerror(e));
+		irc_rootmsg(irc, "otr load: %s: %s", s, gcry_strerror(e));
 	}
 	
@@ -291,5 +291,5 @@
 	}
 	if(kg) {
-		irc_usermsg(irc, "Notice: "
+		irc_rootmsg(irc, "Notice: "
 			"The accounts above do not have OTR encryption keys associated with them, yet. "
 			"These keys are now being generated in the background. "
@@ -309,5 +309,5 @@
 	e = otrl_privkey_write_fingerprints(irc->otr->us, s);
 	if(e) {
-		irc_usermsg(irc, "otr save: %s: %s", s, gcry_strerror(e));
+		irc_rootmsg(irc, "otr save: %s: %s", s, gcry_strerror(e));
 	}
 	chmod(s, 0600);
@@ -348,11 +348,11 @@
 	k = otrl_privkey_find(irc->otr->us, a->user, a->prpl->name);
 	if(k) {
-		irc_usermsg(irc, "otr: %s/%s ready", a->user, a->prpl->name);
+		irc_rootmsg(irc, "otr: %s/%s ready", a->user, a->prpl->name);
 		return 0;
 	} if(keygen_in_progress(irc, a->user, a->prpl->name)) {
-		irc_usermsg(irc, "otr: keygen for %s/%s already in progress", a->user, a->prpl->name);
+		irc_rootmsg(irc, "otr: keygen for %s/%s already in progress", a->user, a->prpl->name);
 		return 0;
 	} else {
-		irc_usermsg(irc, "otr: starting background keygen for %s/%s", a->user, a->prpl->name);
+		irc_rootmsg(irc, "otr: starting background keygen for %s/%s", a->user, a->prpl->name);
 		otr_keygen(irc, a->user, a->prpl->name);
 		return 1;
@@ -365,5 +365,4 @@
 	char *newmsg = NULL;
 	OtrlTLV *tlvs = NULL;
-	char *colormsg;
 	irc_t *irc = iu->irc;
 	struct im_connection *ic = iu->bu->ic;
@@ -385,9 +384,13 @@
 	} else if(!newmsg) {
 		/* this was a non-OTR message */
-		return g_strdup(msg);
+		return msg;
 	} else {
 		/* OTR has processed this message */
 		ConnContext *context = otrl_context_find(irc->otr->us, iu->bu->handle,
 			ic->acc->user, ic->acc->prpl->name, 0, NULL, NULL, NULL);
+
+		/* we're done with the original msg, which will be caller-freed. */
+		/* NB: must not change the newmsg pointer, since we free it. */
+		msg = newmsg;
 
 		if(context && context->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
@@ -397,12 +400,13 @@
 			   !(ic->flags & OPT_DOES_HTML) &&
 			   set_getbool(&ic->bee->set, "strip_html")) {
-				strip_html(newmsg);
+				strip_html(msg);
 			}
 
 			/* coloring */
 			if(set_getbool(&ic->bee->set, "otr_color_encrypted")) {
-				/* color according to f'print trust */
-				int color;
+				int color;                /* color according to f'print trust */
+				char *pre="", *sep="";    /* optional parts */
 				const char *trust = context->active_fingerprint->trust;
+
 				if(trust && trust[0] != '\0')
 					color=3;   /* green */
@@ -410,18 +414,27 @@
 					color=5;   /* red */
 
-				if(newmsg[0] == ',') {
-					/* could be a problem with the color code */
-					/* insert a space between color spec and message */
-					colormsg = g_strdup_printf("\x03%.2d %s\x0F", color, newmsg);
-				} else {
-					colormsg = g_strdup_printf("\x03%.2d%s\x0F", color, newmsg);
+				/* in a query window, keep "/me " uncolored at the beginning */
+				if(g_strncasecmp(msg, "/me ", 4) == 0
+				   && irc_user_msgdest(iu) == irc->user->nick) {
+					msg += 4;  /* skip */
+					pre = "/me ";
 				}
+
+				/* comma in first place could mess with the color code */
+				if(msg[0] == ',') {
+				    /* insert a space between color spec and message */
+				    sep = " ";
+				}
+
+				msg = g_strdup_printf("%s\x03%.2d%s%s\x0F", pre,
+					color, sep, msg);
 			}
-		} else {
-			colormsg = g_strdup(newmsg);
-		}
-
+		}
+
+		if(msg == newmsg) {
+			msg = g_strdup(newmsg);
+		}
 		otrl_message_free(newmsg);
-		return colormsg;
+		return msg;
 	}
 }
@@ -431,4 +444,5 @@
 	int st;
 	char *otrmsg = NULL;
+	char *emsg = msg;           /* the message as we hand it to libotr */
 	ConnContext *ctx = NULL;
 	irc_t *irc = iu->irc;
@@ -440,21 +454,25 @@
 	}
 
-	/* HTML encoding */
-	/* consider OTR plaintext to be HTML if otr_does_html is set */
-	if(set_getbool(&ic->bee->set, "otr_does_html") &&
-	   (g_strncasecmp(msg, "<html>", 6) != 0)) {
-		msg = escape_html(msg);
-	}
-	
-	st = otrl_message_sending(irc->otr->us, &otr_ops, ic,
-		ic->acc->user, ic->acc->prpl->name, iu->bu->handle,
-		msg, NULL, &otrmsg, NULL, NULL);
-	if(st) {
-		return NULL;
-	}
-
 	ctx = otrl_context_find(irc->otr->us,
 			iu->bu->handle, ic->acc->user, ic->acc->prpl->name,
 			1, NULL, NULL, NULL);
+
+	/* HTML encoding */
+	/* consider OTR plaintext to be HTML if otr_does_html is set */
+	if(ctx && ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED &&
+	   set_getbool(&ic->bee->set, "otr_does_html") &&
+	   (g_strncasecmp(msg, "<html>", 6) != 0)) {
+		emsg = escape_html(msg);
+	}
+	
+	st = otrl_message_sending(irc->otr->us, &otr_ops, ic,
+		ic->acc->user, ic->acc->prpl->name, iu->bu->handle,
+		emsg, NULL, &otrmsg, NULL, NULL);
+	if(emsg != msg) {
+		g_free(emsg);   /* we're done with this one */
+	}
+	if(st) {
+		return NULL;
+	}
 
 	if(otrmsg) {
@@ -504,5 +522,5 @@
 	
 	if(!cmd->command) {
-		irc_usermsg(irc, "%s: unknown subcommand \"%s\", see \x02help otr\x02",
+		irc_rootmsg(irc, "%s: unknown subcommand \"%s\", see \x02help otr\x02",
 			args[0], args[1]);
 		return;
@@ -510,5 +528,5 @@
 	
 	if(!args[cmd->required_parameters+1]) {
-		irc_usermsg(irc, "%s %s: not enough arguments (%d req.)",
+		irc_rootmsg(irc, "%s %s: not enough arguments (%d req.)",
 			args[0], args[1], cmd->required_parameters);
 		return;
@@ -582,5 +600,5 @@
 	if (strcmp(accountname, recipient) == 0) {
 		/* huh? injecting messages to myself? */
-		irc_usermsg(irc, "note to self: %s", message);
+		irc_rootmsg(irc, "note to self: %s", message);
 	} else {
 		/* need to drop some consts here :-( */
@@ -597,7 +615,13 @@
 	char *msg = g_strdup(message);
 	irc_t *irc = ic->bee->ui_data;
+	irc_user_t *u = peeruser(irc, username, protocol);
 
 	strip_html(msg);
-	irc_usermsg(irc, "otr: %s", msg);
+	if(u) {
+		/* display as a notice from this particular user */
+		irc_usernotice(u, "%s", msg);
+	} else {
+		irc_rootmsg(irc, "[otr] %s", msg);
+	}
 
 	g_free(msg);
@@ -611,9 +635,15 @@
 	struct im_connection *ic = check_imc(opdata, accountname, protocol);
 	irc_t *irc = ic->bee->ui_data;
+	irc_user_t *u = peeruser(irc, username, protocol);
 	char hunam[45];		/* anybody looking? ;-) */
 	
 	otrl_privkey_hash_to_human(hunam, fingerprint);
-	irc_usermsg(irc, "new fingerprint for %s: %s",
-		peernick(irc, username, protocol), hunam);
+	if(u) {
+		irc_usernotice(u, "new fingerprint: %s", hunam);
+	} else {
+		/* this case shouldn't normally happen */
+		irc_rootmsg(irc, "new fingerprint for %s/%s: %s",
+			username, protocol, hunam);
+	}
 }
 
@@ -644,5 +674,5 @@
 	if(!otr_update_modeflags(irc, u)) {
 		char *trust = u->flags & IRC_USER_OTR_TRUSTED ? "trusted" : "untrusted!";
-		irc_usermsg(irc, "conversation with %s is now off the record (%s)", u->nick, trust);
+		irc_usernotice(u, "conversation is now off the record (%s)", trust);
 	}
 }
@@ -664,5 +694,5 @@
 	otr_update_uflags(context, u);
 	if(!otr_update_modeflags(irc, u))
-		irc_usermsg(irc, "conversation with %s is now in the clear", u->nick);
+		irc_usernotice(u, "conversation is now in cleartext");
 }
 
@@ -685,5 +715,5 @@
 	if(!otr_update_modeflags(irc, u)) {
 		char *trust = u->flags & IRC_USER_OTR_TRUSTED ? "trusted" : "untrusted!";
-		irc_usermsg(irc, "otr connection with %s has been refreshed (%s)", u->nick, trust);
+		irc_usernotice(u, "otr connection has been refreshed (%s)", trust);
 	}
 }
@@ -729,5 +759,5 @@
 	u = irc_user_by_name(irc, args[1]);
 	if(!u || !u->bu || !u->bu->ic) {
-		irc_usermsg(irc, "%s: unknown user", args[1]);
+		irc_rootmsg(irc, "%s: unknown user", args[1]);
 		return;
 	}
@@ -754,9 +784,9 @@
 	u = irc_user_by_name(irc, args[1]);
 	if(!u || !u->bu || !u->bu->ic) {
-		irc_usermsg(irc, "%s: unknown user", args[1]);
+		irc_rootmsg(irc, "%s: unknown user", args[1]);
 		return;
 	}
 	if(!(u->bu->flags & BEE_USER_ONLINE)) {
-		irc_usermsg(irc, "%s is offline", args[1]);
+		irc_rootmsg(irc, "%s is offline", args[1]);
 		return;
 	}
@@ -785,5 +815,5 @@
 	u = irc_user_by_name(irc, args[1]);
 	if(!u || !u->bu || !u->bu->ic) {
-		irc_usermsg(irc, "%s: unknown user", args[1]);
+		irc_rootmsg(irc, "%s: unknown user", args[1]);
 		return;
 	}
@@ -792,5 +822,5 @@
 		u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
 	if(!ctx) {
-		irc_usermsg(irc, "%s: no otr context with user", args[1]);
+		irc_rootmsg(irc, "%s: no otr context with user", args[1]);
 		return;
 	}
@@ -804,5 +834,5 @@
 			
 			if(!*p || !*q) {
-				irc_usermsg(irc, "failed: truncated fingerprint block %d", i+1);
+				irc_rootmsg(irc, "failed: truncated fingerprint block %d", i+1);
 				return;
 			}
@@ -811,9 +841,9 @@
 			y = hexval(*q);
 			if(x<0) {
-				irc_usermsg(irc, "failed: %d. hex digit of block %d out of range", 2*j+1, i+1);
+				irc_rootmsg(irc, "failed: %d. hex digit of block %d out of range", 2*j+1, i+1);
 				return;
 			}
 			if(y<0) {
-				irc_usermsg(irc, "failed: %d. hex digit of block %d out of range", 2*j+2, i+1);
+				irc_rootmsg(irc, "failed: %d. hex digit of block %d out of range", 2*j+2, i+1);
 				return;
 			}
@@ -824,9 +854,9 @@
 	fp = otrl_context_find_fingerprint(ctx, raw, 0, NULL);
 	if(!fp) {
-		irc_usermsg(irc, "failed: no such fingerprint for %s", args[1]);
+		irc_rootmsg(irc, "failed: no such fingerprint for %s", args[1]);
 	} else {
 		char *trust = args[7] ? args[7] : "affirmed";
 		otrl_context_set_trust(fp, trust);
-		irc_usermsg(irc, "fingerprint match, trust set to \"%s\"", trust);
+		irc_rootmsg(irc, "fingerprint match, trust set to \"%s\"", trust);
 		if(u->flags & IRC_USER_OTR_ENCRYPTED)
 			u->flags |= IRC_USER_OTR_TRUSTED;
@@ -856,5 +886,5 @@
 			ctx = otrl_context_find(irc->otr->us, handle, myhandle, protocol, 0, NULL, NULL, NULL);
 			if(!ctx) {
-				irc_usermsg(irc, "no such context");
+				irc_rootmsg(irc, "no such context");
 				g_free(arg);
 				return;
@@ -863,5 +893,5 @@
 			irc_user_t *u = irc_user_by_name(irc, args[1]);
 			if(!u || !u->bu || !u->bu->ic) {
-				irc_usermsg(irc, "%s: unknown user", args[1]);
+				irc_rootmsg(irc, "%s: unknown user", args[1]);
 				g_free(arg);
 				return;
@@ -870,5 +900,5 @@
 				u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
 			if(!ctx) {
-				irc_usermsg(irc, "no otr context with %s", args[1]);
+				irc_rootmsg(irc, "no otr context with %s", args[1]);
 				g_free(arg);
 				return;
@@ -878,5 +908,5 @@
 		/* show how we resolved the (nick) argument, if we did */
 		if(handle!=arg) {
-			irc_usermsg(irc, "%s is %s/%s; we are %s/%s to them", args[1],
+			irc_rootmsg(irc, "%s is %s/%s; we are %s/%s to them", args[1],
 				ctx->username, ctx->protocol, ctx->accountname, ctx->protocol);
 		}
@@ -893,5 +923,5 @@
 	n = atoi(args[1]);
 	if(n<0 || (!n && strcmp(args[1], "0"))) {
-		irc_usermsg(irc, "%s: invalid account number", args[1]);
+		irc_rootmsg(irc, "%s: invalid account number", args[1]);
 		return;
 	}
@@ -900,10 +930,10 @@
 	for(i=0; i<n && a; i++, a=a->next);
 	if(!a) {
-		irc_usermsg(irc, "%s: no such account", args[1]);
+		irc_rootmsg(irc, "%s: no such account", args[1]);
 		return;
 	}
 	
 	if(keygen_in_progress(irc, a->user, a->prpl->name)) {
-		irc_usermsg(irc, "keygen for account %d already in progress", n);
+		irc_rootmsg(irc, "keygen for account %d already in progress", n);
 		return;
 	}
@@ -927,5 +957,5 @@
 	
 	if(fp == fp->context->active_fingerprint) {
-		irc_usermsg(irc, "that fingerprint is active, terminate otr connection first");
+		irc_rootmsg(irc, "that fingerprint is active, terminate otr connection first");
 		return;
 	}
@@ -943,5 +973,5 @@
 	
 	if(ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
-		irc_usermsg(irc, "active otr connection with %s, terminate it first",
+		irc_rootmsg(irc, "active otr connection with %s, terminate it first",
 			peernick(irc, ctx->username, ctx->protocol));
 		return;
@@ -975,5 +1005,5 @@
 		
 		if(!args[3]) {
-			irc_usermsg(irc, "otr %s %s: not enough arguments (2 req.)", args[0], args[1]);
+			irc_rootmsg(irc, "otr %s %s: not enough arguments (2 req.)", args[0], args[1]);
 			return;
 		}
@@ -982,5 +1012,5 @@
 		u = irc_user_by_name(irc, args[2]);
 		if(!u || !u->bu || !u->bu->ic) {
-			irc_usermsg(irc, "%s: unknown user", args[2]);
+			irc_rootmsg(irc, "%s: unknown user", args[2]);
 			return;
 		}
@@ -989,5 +1019,5 @@
 			u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
 		if(!ctx) {
-			irc_usermsg(irc, "no otr context with %s", args[2]);
+			irc_rootmsg(irc, "no otr context with %s", args[2]);
 			return;
 		}
@@ -1000,5 +1030,5 @@
 		
 		if(fp == ctx->active_fingerprint) {
-			irc_usermsg(irc, "that fingerprint is active, terminate otr connection first");
+			irc_rootmsg(irc, "that fingerprint is active, terminate otr connection first");
 			return;
 		}
@@ -1025,5 +1055,5 @@
 		u = irc_user_by_name(irc, args[2]);
 		if(!u || !u->bu || !u->bu->ic) {
-			irc_usermsg(irc, "%s: unknown user", args[2]);
+			irc_rootmsg(irc, "%s: unknown user", args[2]);
 			return;
 		}
@@ -1032,10 +1062,10 @@
 			u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
 		if(!ctx) {
-			irc_usermsg(irc, "no otr context with %s", args[2]);
+			irc_rootmsg(irc, "no otr context with %s", args[2]);
 			return;
 		}
 		
 		if(ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
-			irc_usermsg(irc, "active otr connection with %s, terminate it first", args[2]);
+			irc_rootmsg(irc, "active otr connection with %s, terminate it first", args[2]);
 			return;
 		}
@@ -1070,5 +1100,5 @@
 	else
 	{
-		irc_usermsg(irc, "otr %s: unknown subcommand \"%s\", see \x02help otr forget\x02",
+		irc_rootmsg(irc, "otr %s: unknown subcommand \"%s\", see \x02help otr forget\x02",
 			args[0], args[1]);
 	}
@@ -1096,5 +1126,5 @@
 	if(!context) {
 		/* huh? out of memory or what? */
-		irc_usermsg(irc, "smp: failed to get otr context for %s", u->nick);
+		irc_rootmsg(irc, "smp: failed to get otr context for %s", u->nick);
 		otrl_message_abort_smp(us, ops, u->bu->ic, context);
 		otrl_sm_state_free(context->smstate);
@@ -1104,5 +1134,5 @@
 
 	if (context->smstate->sm_prog_state == OTRL_SMP_PROG_CHEATED) {
-		irc_usermsg(irc, "smp %s: opponent violated protocol, aborting",
+		irc_rootmsg(irc, "smp %s: opponent violated protocol, aborting",
 			u->nick);
 		otrl_message_abort_smp(us, ops, u->bu->ic, context);
@@ -1114,12 +1144,12 @@
 	if (tlv) {
 		if (nextMsg != OTRL_SMP_EXPECT1) {
-			irc_usermsg(irc, "smp %s: spurious SMP1Q received, aborting", u->nick);
+			irc_rootmsg(irc, "smp %s: spurious SMP1Q received, aborting", u->nick);
 			otrl_message_abort_smp(us, ops, u->bu->ic, context);
 			otrl_sm_state_free(context->smstate);
 		} else {
 			char *question = g_strndup((char *)tlv->data, tlv->len);
-			irc_usermsg(irc, "smp: initiated by %s with question: \x02\"%s\"\x02", u->nick,
+			irc_rootmsg(irc, "smp: initiated by %s with question: \x02\"%s\"\x02", u->nick,
 				question);
-			irc_usermsg(irc, "smp: respond with \x02otr smp %s <answer>\x02",
+			irc_rootmsg(irc, "smp: respond with \x02otr smp %s <answer>\x02",
 				u->nick);
 			g_free(question);
@@ -1130,9 +1160,9 @@
 	if (tlv) {
 		if (nextMsg != OTRL_SMP_EXPECT1) {
-			irc_usermsg(irc, "smp %s: spurious SMP1 received, aborting", u->nick);
+			irc_rootmsg(irc, "smp %s: spurious SMP1 received, aborting", u->nick);
 			otrl_message_abort_smp(us, ops, u->bu->ic, context);
 			otrl_sm_state_free(context->smstate);
 		} else {
-			irc_usermsg(irc, "smp: initiated by %s"
+			irc_rootmsg(irc, "smp: initiated by %s"
 				" - respond with \x02otr smp %s <secret>\x02",
 				u->nick, u->nick);
@@ -1143,5 +1173,5 @@
 	if (tlv) {
 		if (nextMsg != OTRL_SMP_EXPECT2) {
-			irc_usermsg(irc, "smp %s: spurious SMP2 received, aborting", u->nick);
+			irc_rootmsg(irc, "smp %s: spurious SMP2 received, aborting", u->nick);
 			otrl_message_abort_smp(us, ops, u->bu->ic, context);
 			otrl_sm_state_free(context->smstate);
@@ -1154,5 +1184,5 @@
 	if (tlv) {
 		if (nextMsg != OTRL_SMP_EXPECT3) {
-			irc_usermsg(irc, "smp %s: spurious SMP3 received, aborting", u->nick);
+			irc_rootmsg(irc, "smp %s: spurious SMP3 received, aborting", u->nick);
 			otrl_message_abort_smp(us, ops, u->bu->ic, context);
 			otrl_sm_state_free(context->smstate);
@@ -1161,16 +1191,16 @@
 			if(context->smstate->sm_prog_state == OTRL_SMP_PROG_SUCCEEDED) {
 				if(context->smstate->received_question) {
-					irc_usermsg(irc, "smp %s: correct answer, you are trusted",
+					irc_rootmsg(irc, "smp %s: correct answer, you are trusted",
 						u->nick);
 				} else {
-					irc_usermsg(irc, "smp %s: secrets proved equal, fingerprint trusted",
+					irc_rootmsg(irc, "smp %s: secrets proved equal, fingerprint trusted",
 						u->nick);
 				}
 			} else {
 				if(context->smstate->received_question) {
-					irc_usermsg(irc, "smp %s: wrong answer, you are not trusted",
+					irc_rootmsg(irc, "smp %s: wrong answer, you are not trusted",
 						u->nick);
 				} else {
-					irc_usermsg(irc, "smp %s: secrets did not match, fingerprint not trusted",
+					irc_rootmsg(irc, "smp %s: secrets did not match, fingerprint not trusted",
 						u->nick);
 				}
@@ -1183,5 +1213,5 @@
 	if (tlv) {
 		if (nextMsg != OTRL_SMP_EXPECT4) {
-			irc_usermsg(irc, "smp %s: spurious SMP4 received, aborting", u->nick);
+			irc_rootmsg(irc, "smp %s: spurious SMP4 received, aborting", u->nick);
 			otrl_message_abort_smp(us, ops, u->bu->ic, context);
 			otrl_sm_state_free(context->smstate);
@@ -1189,8 +1219,8 @@
 			/* SMP4 received, otrl_message_receiving will have set fp trust */
 			if(context->smstate->sm_prog_state == OTRL_SMP_PROG_SUCCEEDED) {
-				irc_usermsg(irc, "smp %s: secrets proved equal, fingerprint trusted",
+				irc_rootmsg(irc, "smp %s: secrets proved equal, fingerprint trusted",
 					u->nick);
 			} else {
-				irc_usermsg(irc, "smp %s: secrets did not match, fingerprint not trusted",
+				irc_rootmsg(irc, "smp %s: secrets did not match, fingerprint not trusted",
 					u->nick);
 			}
@@ -1201,5 +1231,5 @@
 	tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP_ABORT);
 	if (tlv) {
-	 	irc_usermsg(irc, "smp: received abort from %s", u->nick);
+	 	irc_rootmsg(irc, "smp: received abort from %s", u->nick);
 		otrl_sm_state_free(context->smstate);
 		/* smp is in back in EXPECT1 */
@@ -1216,9 +1246,9 @@
 	u = irc_user_by_name(irc, nick);
 	if(!u || !u->bu || !u->bu->ic) {
-		irc_usermsg(irc, "%s: unknown user", nick);
+		irc_rootmsg(irc, "%s: unknown user", nick);
 		return;
 	}
 	if(!(u->bu->flags & BEE_USER_ONLINE)) {
-		irc_usermsg(irc, "%s is offline", nick);
+		irc_rootmsg(irc, "%s is offline", nick);
 		return;
 	}
@@ -1227,5 +1257,5 @@
 		u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
 	if(!ctx || ctx->msgstate != OTRL_MSGSTATE_ENCRYPTED) {
-		irc_usermsg(irc, "smp: otr inactive with %s, try \x02otr connect"
+		irc_rootmsg(irc, "smp: otr inactive with %s, try \x02otr connect"
 				" %s\x02", nick, nick);
 		return;
@@ -1242,5 +1272,5 @@
 	if(question) {
 		/* this was 'otr smpq', just initiate */
-		irc_usermsg(irc, "smp: initiating with %s...", u->nick);
+		irc_rootmsg(irc, "smp: initiating with %s...", u->nick);
 		otrl_message_initiate_smp_q(irc->otr->us, &otr_ops, u->bu->ic, ctx,
 			question, (unsigned char *)secret, strlen(secret));
@@ -1251,5 +1281,5 @@
 		   is completed or aborted! */ 
 		if(ctx->smstate->secret == NULL) {
-			irc_usermsg(irc, "smp: initiating with %s...", u->nick);
+			irc_rootmsg(irc, "smp: initiating with %s...", u->nick);
 			otrl_message_initiate_smp(irc->otr->us, &otr_ops,
 				u->bu->ic, ctx, (unsigned char *)secret, strlen(secret));
@@ -1258,5 +1288,5 @@
 			/* if we're still in EXPECT1 but smstate is initialized, we must have
 			   received the SMP1, so let's issue a response */
-			irc_usermsg(irc, "smp: responding to %s...", u->nick);
+			irc_rootmsg(irc, "smp: responding to %s...", u->nick);
 			otrl_message_respond_smp(irc->otr->us, &otr_ops,
 				u->bu->ic, ctx, (unsigned char *)secret, strlen(secret));
@@ -1373,11 +1403,11 @@
 		}
 		if(fp == ctx->active_fingerprint) {
-			irc_usermsg(irc, "    \x02%s (%s)\x02", human, trust);
+			irc_rootmsg(irc, "    \x02%s (%s)\x02", human, trust);
 		} else {
-			irc_usermsg(irc, "    %s (%s)", human, trust);
+			irc_rootmsg(irc, "    %s (%s)", human, trust);
 		}
 	}
 	if(count==0)
-		irc_usermsg(irc, "    (none)");
+		irc_rootmsg(irc, "    (none)");
 }
 
@@ -1398,5 +1428,5 @@
 			
 			if(n>=40) {
-				irc_usermsg(irc, "too many fingerprint digits given, expected at most 40");
+				irc_rootmsg(irc, "too many fingerprint digits given, expected at most 40");
 				return NULL;
 			}
@@ -1405,5 +1435,5 @@
 				*(p++) = c;
 			} else {
-				irc_usermsg(irc, "invalid hex digit '%c' in block %d", args[i][j], i+1);
+				irc_rootmsg(irc, "invalid hex digit '%c' in block %d", args[i][j], i+1);
 				return NULL;
 			}
@@ -1426,5 +1456,5 @@
 	}
 	if(!fp) {
-		irc_usermsg(irc, "%s: no match", prefix);
+		irc_rootmsg(irc, "%s: no match", prefix);
 		return NULL;
 	}
@@ -1439,5 +1469,5 @@
 	}
 	if(fp2) {
-		irc_usermsg(irc, "%s: multiple matches", prefix);
+		irc_rootmsg(irc, "%s: multiple matches", prefix);
 		return NULL;
 	}
@@ -1462,5 +1492,5 @@
 			
 			if(n>=40) {
-				irc_usermsg(irc, "too many fingerprint digits given, expected at most 40");
+				irc_rootmsg(irc, "too many fingerprint digits given, expected at most 40");
 				return NULL;
 			}
@@ -1469,5 +1499,5 @@
 				*(p++) = c;
 			} else {
-				irc_usermsg(irc, "invalid hex digit '%c' in block %d", args[i][j], i+1);
+				irc_rootmsg(irc, "invalid hex digit '%c' in block %d", args[i][j], i+1);
 				return NULL;
 			}
@@ -1490,5 +1520,5 @@
 	}
 	if(!k) {
-		irc_usermsg(irc, "%s: no match", prefix);
+		irc_rootmsg(irc, "%s: no match", prefix);
 		return NULL;
 	}
@@ -1503,5 +1533,5 @@
 	}
 	if(k2) {
-		irc_usermsg(irc, "%s: multiple matches", prefix);
+		irc_rootmsg(irc, "%s: multiple matches", prefix);
 		return NULL;
 	}
@@ -1518,5 +1548,5 @@
 
 	/* list all privkeys (including ones being generated) */
-	irc_usermsg(irc, "\x1fprivate keys:\x1f");
+	irc_rootmsg(irc, "\x1fprivate keys:\x1f");
 	for(key=irc->otr->us->privkey_root; key; key=key->next) {
 		const char *hash;
@@ -1524,8 +1554,8 @@
 		switch(key->pubkey_type) {
 		case OTRL_PUBKEY_TYPE_DSA:
-			irc_usermsg(irc, "  %s/%s - DSA", key->accountname, key->protocol);
+			irc_rootmsg(irc, "  %s/%s - DSA", key->accountname, key->protocol);
 			break;
 		default:
-			irc_usermsg(irc, "  %s/%s - type %d", key->accountname, key->protocol,
+			irc_rootmsg(irc, "  %s/%s - type %d", key->accountname, key->protocol,
 				key->pubkey_type);
 		}
@@ -1536,23 +1566,23 @@
 		hash = otrl_privkey_fingerprint(irc->otr->us, human, key->accountname, key->protocol);
 		if(hash) /* should always succeed */
-			irc_usermsg(irc, "    %s", human);
+			irc_rootmsg(irc, "    %s", human);
 	}
 	if(irc->otr->sent_accountname) {
-		irc_usermsg(irc, "  %s/%s - DSA", irc->otr->sent_accountname,
+		irc_rootmsg(irc, "  %s/%s - DSA", irc->otr->sent_accountname,
 			irc->otr->sent_protocol);
-		irc_usermsg(irc, "    (being generated)");
+		irc_rootmsg(irc, "    (being generated)");
 	}
 	for(kg=irc->otr->todo; kg; kg=kg->next) {
-		irc_usermsg(irc, "  %s/%s - DSA", kg->accountname, kg->protocol);
-		irc_usermsg(irc, "    (queued)");
+		irc_rootmsg(irc, "  %s/%s - DSA", kg->accountname, kg->protocol);
+		irc_rootmsg(irc, "    (queued)");
 	}
 	if(key == irc->otr->us->privkey_root &&
 	   !irc->otr->sent_accountname &&
 	   kg == irc->otr->todo)
-		irc_usermsg(irc, "  (none)");
+		irc_rootmsg(irc, "  (none)");
 
 	/* list all contexts */
-	irc_usermsg(irc, "%s", "");
-	irc_usermsg(irc, "\x1f" "connection contexts:\x1f (bold=currently encrypted)");
+	irc_rootmsg(irc, "%s", "");
+	irc_rootmsg(irc, "\x1f" "connection contexts:\x1f (bold=currently encrypted)");
 	for(ctx=irc->otr->us->context_root; ctx; ctx=ctx->next) {\
 		irc_user_t *u;
@@ -1568,7 +1598,7 @@
 		
 		if(ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
-			irc_usermsg(irc, "  \x02%s\x02", userstring);
+			irc_rootmsg(irc, "  \x02%s\x02", userstring);
 		} else {
-			irc_usermsg(irc, "  %s", userstring);
+			irc_rootmsg(irc, "  %s", userstring);
 		}
 		
@@ -1576,5 +1606,5 @@
 	}
 	if(ctx == irc->otr->us->context_root)
-		irc_usermsg(irc, "  (none)");
+		irc_rootmsg(irc, "  (none)");
 }
 
@@ -1583,34 +1613,34 @@
 	switch(ctx->otr_offer) {
 	case OFFER_NOT:
-		irc_usermsg(irc, "  otr offer status: none sent");
+		irc_rootmsg(irc, "  otr offer status: none sent");
 		break;
 	case OFFER_SENT:
-		irc_usermsg(irc, "  otr offer status: awaiting reply");
+		irc_rootmsg(irc, "  otr offer status: awaiting reply");
 		break;
 	case OFFER_ACCEPTED:
-		irc_usermsg(irc, "  otr offer status: accepted our offer");
+		irc_rootmsg(irc, "  otr offer status: accepted our offer");
 		break;
 	case OFFER_REJECTED:
-		irc_usermsg(irc, "  otr offer status: ignored our offer");
+		irc_rootmsg(irc, "  otr offer status: ignored our offer");
 		break;
 	default:
-		irc_usermsg(irc, "  otr offer status: %d", ctx->otr_offer);
+		irc_rootmsg(irc, "  otr offer status: %d", ctx->otr_offer);
 	}
 
 	switch(ctx->msgstate) {
 	case OTRL_MSGSTATE_PLAINTEXT:
-		irc_usermsg(irc, "  connection state: cleartext");
+		irc_rootmsg(irc, "  connection state: cleartext");
 		break;
 	case OTRL_MSGSTATE_ENCRYPTED:
-		irc_usermsg(irc, "  connection state: encrypted (v%d)", ctx->protocol_version);
+		irc_rootmsg(irc, "  connection state: encrypted (v%d)", ctx->protocol_version);
 		break;
 	case OTRL_MSGSTATE_FINISHED:
-		irc_usermsg(irc, "  connection state: shut down");
+		irc_rootmsg(irc, "  connection state: shut down");
 		break;
 	default:
-		irc_usermsg(irc, "  connection state: %d", ctx->msgstate);
-	}
-
-	irc_usermsg(irc, "  fingerprints: (bold=active)");	
+		irc_rootmsg(irc, "  connection state: %d", ctx->msgstate);
+	}
+
+	irc_rootmsg(irc, "  fingerprints: (bold=active)");	
 	show_fingerprints(irc, ctx);
 }
@@ -1652,5 +1682,5 @@
 		
 		if(pipe(to) < 0 || pipe(from) < 0) {
-			irc_usermsg(irc, "otr keygen: couldn't create pipe: %s", strerror(errno));
+			irc_rootmsg(irc, "otr keygen: couldn't create pipe: %s", strerror(errno));
 			return;
 		}
@@ -1659,5 +1689,5 @@
 		fromf = fdopen(from[0], "r");
 		if(!tof || !fromf) {
-			irc_usermsg(irc, "otr keygen: couldn't streamify pipe: %s", strerror(errno));
+			irc_rootmsg(irc, "otr keygen: couldn't streamify pipe: %s", strerror(errno));
 			return;
 		}
@@ -1665,5 +1695,5 @@
 		p = fork();
 		if(p<0) {
-			irc_usermsg(irc, "otr keygen: couldn't fork: %s", strerror(errno));
+			irc_rootmsg(irc, "otr keygen: couldn't fork: %s", strerror(errno));
 			return;
 		}
@@ -1745,5 +1775,5 @@
 	myfgets(msg, 512, irc->otr->from);
 	
-	irc_usermsg(irc, "%s", msg);
+	irc_rootmsg(irc, "%s", msg);
 	if(filename[0]) {
 		char *kf = g_strdup_printf("%s%s.otr_keys", global.conf->configdir, irc->user->nick);
@@ -1819,11 +1849,13 @@
 	
 	if(keygen_in_progress(irc, acc->user, acc->prpl->name)) {
-		irc_usermsg(irc, "keygen for %s/%s already in progress",
+		irc_rootmsg(irc, "keygen for %s/%s already in progress",
 			acc->user, acc->prpl->name);
 	} else {
-		irc_usermsg(irc, "starting background keygen for %s/%s",
+		irc_rootmsg(irc, "starting background keygen for %s/%s",
 			acc->user, acc->prpl->name);
-		irc_usermsg(irc, "you will be notified when it completes");
+		irc_rootmsg(irc, "you will be notified when it completes");
 		otr_keygen(irc, acc->user, acc->prpl->name);
 	}
 }
+
+/* vim: set noet ts=4 sw=4: */
