[Pkg-privacy-commits] [irssi-plugin-otr] 127/267: Massive cleanup of logging/msg statements

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 12:26:24 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch debian
in repository irssi-plugin-otr.

commit 8330c1d71697b49dbb74f76065aefa58b94e060a
Author: David Goulet <dgoulet at ev0ke.net>
Date:   Mon Nov 12 21:26:04 2012 -0500

    Massive cleanup of logging/msg statements
    
    Signed-off-by: David Goulet <dgoulet at ev0ke.net>
---
 src/cmd.c       | 194 +++++++++++++++++++++++++++++++++-----------------------
 src/cmd.h       |   4 +-
 src/irssi_otr.h |  74 ++++++++++-----------
 src/key.c       |  74 +++++++++++++--------
 src/module.c    |  12 ++--
 src/otr-ops.c   |  62 +++++++++---------
 src/otr.c       | 180 +++++++++++++++++++++-------------------------------
 src/otr.h       |  15 ++---
 src/utils.c     |   2 +-
 src/utils.h     |   2 +-
 10 files changed, 309 insertions(+), 310 deletions(-)

diff --git a/src/cmd.c b/src/cmd.c
index 7edc1b7..ccb3a48 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -24,81 +24,103 @@
 /*
  * /otr debug
  */
-static void _cmd_debug(struct otr_user_state *ustate, IRC_CTX *ircctx, int argc, char *argv[],
-		char *argv_eol[], char *target, const char *orig_args)
+static void _cmd_debug(struct otr_user_state *ustate, SERVER_REC *irssi,
+		int argc, char *argv[], char *argv_eol[], char *target,
+		const char *orig_args)
 {
 	debug = !debug;
-	otr_noticest(debug ? TXT_CMD_DEBUG_ON : TXT_CMD_DEBUG_OFF);
+	if (debug) {
+		IRSSI_INFO(NULL, NULL, "Debug on");
+	} else {
+		IRSSI_INFO(NULL, NULL, "Debug off");
+	}
 }
 
 /*
  * /otr version 
  */
-static void _cmd_version(struct otr_user_state *ustate, IRC_CTX *ircctx, int argc, char *argv[],
-		char *argv_eol[], char *target, const char *orig_args)
+static void _cmd_version(struct otr_user_state *ustate, SERVER_REC *irssi,
+		int argc, char *argv[], char *argv_eol[], char *target,
+		const char *orig_args)
 {
-	otr_noticest(TXT_CMD_VERSION, IRCOTR_VERSION);
+	IRSSI_INFO(NULL, NULL, "OTR module version: " VERSION);
 }
 
 /*
  * /otr help 
  */
-static void _cmd_help(struct otr_user_state *ustate, IRC_CTX *ircctx, int argc, char *argv[],
+static void _cmd_help(struct otr_user_state *ustate, SERVER_REC *irssi, int argc, char *argv[],
 		char *argv_eol[], char *target, const char *orig_args)
 {
-	otr_log(ircctx, target, MSGLEVEL_CRAP, otr_help);
+	IRSSI_INFO(NULL, NULL, "%s", otr_help);
 }
 
 /*
  * /otr finish 
  */
-static void _cmd_finish(struct otr_user_state *ustate, IRC_CTX *ircctx, int argc, char *argv[],
-		char *argv_eol[], char *target, const char *orig_args)
+static void _cmd_finish(struct otr_user_state *ustate, SERVER_REC *irssi,
+		int argc, char *argv[], char *argv_eol[], char *target,
+		const char *orig_args)
 {
-	if (argc) {
-		otr_finish(NULL, NULL, argv[0], TRUE);
-	} else if (ircctx && target) {
-		otr_finish(ircctx, target, NULL, TRUE);
-	} else {
-		otr_noticest(TXT_CMD_QNOTFOUND);
+	if (!irssi || !target) {
+		IRSSI_WARN(irssi, target,
+				"Failed: Can't get nick and server of current query window. "
+				"(Or maybe you're doing this in the status window?)");
+		goto end;
 	}
+
+	otr_finish(irssi, target);
+
+end:
+	return;
 }
 
 /*
  * /otr trust
  */
-static void _cmd_trust(struct otr_user_state *ustate, IRC_CTX *ircctx, int argc, char *argv[],
-		char *argv_eol[], char *target, const char *orig_args)
+static void _cmd_trust(struct otr_user_state *ustate, SERVER_REC *irssi,
+		int argc, char *argv[], char *argv_eol[], char *target,
+		const char *orig_args)
 {
-	if (argc) {
-		otr_trust(NULL, NULL, argv[0]);
-	} else if (ircctx && target) {
-		otr_trust(ircctx, target, NULL);
-	} else {
-		otr_noticest(TXT_CMD_QNOTFOUND);
+	if (!irssi || !target) {
+		IRSSI_WARN(irssi, target,
+				"Failed: Can't get nick and server of current query window. "
+				"(Or maybe you're doing this in the status window?)");
+		goto end;
 	}
+
+	otr_trust(irssi, target);
+
+end:
+	return;
 }
 
 /*
  * /otr authabort
  */
-static void _cmd_authabort(struct otr_user_state *ustate, IRC_CTX *ircctx, int argc,
-		char *argv[], char *argv_eol[], char *target, const char *orig_args)
+static void _cmd_authabort(struct otr_user_state *ustate, SERVER_REC *irssi,
+		int argc, char *argv[], char *argv_eol[], char *target,
+		const char *orig_args)
 {
-	if (argc) {
-		otr_authabort(NULL, NULL, argv[0]);
-	} else if (ircctx && target) {
-		otr_authabort(ircctx, target, NULL);
-	} else {
-		otr_noticest(TXT_CMD_QNOTFOUND);
+	if (!irssi || !target) {
+		IRSSI_WARN(irssi, target,
+				"Failed: Can't get nick and server of current query window. "
+				"(Or maybe you're doing this in the status window?)");
+		goto end;
 	}
+
+	otr_auth_abort(irssi, target);
+
+end:
+	return;
 }
 
 /*
  * /otr genkey
  */
-static void _cmd_genkey(struct otr_user_state *ustate, IRC_CTX *ircctx, int argc, char *argv[],
-		char *argv_eol[], char *target, const char *orig_args)
+static void _cmd_genkey(struct otr_user_state *ustate, SERVER_REC *irssi,
+		int argc, char *argv[], char *argv_eol[], char *target,
+		const char *orig_args)
 {
 	if (argc) {
 		if (strncmp(argv[0], "abort", strlen("abort")) == 0) {
@@ -106,53 +128,38 @@ static void _cmd_genkey(struct otr_user_state *ustate, IRC_CTX *ircctx, int argc
 		} else if (strchr(argv[0], '@')) {
 			key_generation_run(ustate, argv[0]);
 		} else {
-			otr_noticest(TXT_KG_NEEDACC);
+			IRSSI_INFO(NULL, NULL, "I need an account name. "
+					"Try something like /otr genkey mynick at irc.server.net");
 		}
 	} else {
-		otr_noticest(TXT_KG_NEEDACC);
+		IRSSI_INFO(NULL, NULL, "I need an account name. "
+				"Try something like /otr genkey mynick at irc.server.net");
 	}
 }
 
 /*
  * Generic internal function for /otr auth command.
  */
-static void _auth(struct otr_user_state *ustate, IRC_CTX *ircctx, int argc,
+static void _auth(struct otr_user_state *ustate, SERVER_REC *irssi, int argc,
 		char *argv[], char *argv_eol[], char *target, int qanda,
 		const char *orig_args)
 {
 	int ret;
-	char *accountname = NULL, *question = NULL, *secret = NULL;
-
-	/* have args? */
-	if (argc < (qanda ? 2 : 1)) {
-		otr_notice(ircctx, target, TXT_CMD_AUTH);
-		goto end;
-	}
-
-	/* have buddy? */
-	if (!(ircctx && target)) {
-		accountname = strchr(argv[0], '@');
-		if (!accountname) {
-			otr_noticest(TXT_CMD_QNOTFOUND);
-			goto end;
-		}
-		ircctx = NULL;
-		target = NULL;
-		argv++; argv_eol++; argc--;
-	}
+	char *question = NULL, *secret = NULL;
 
 	/* have question? */
 	if (qanda) {
 		ret = utils_io_extract_smp(orig_args, &question, &secret);
 		if (ret < 0) {
-			otr_notice(ircctx, target, TXT_CMD_AUTH);
+			IRSSI_NOTICE(irssi, target, "Usage: %9/otr authq [QUESTION] "
+					"SECRET%9");
 			goto end;
 		}
 	} else {
 		secret = argv_eol[0];
 	}
 
-	otr_auth(ircctx, target, accountname, question, secret);
+	otr_auth(irssi, target, question, secret);
 
 	free(question);
 	if (qanda) {
@@ -166,32 +173,51 @@ end:
 /*
  * /otr authq (Authentication with a question)
  */
-static void _cmd_authq(struct otr_user_state *ustate, IRC_CTX *ircctx, int argc,
-		char *argv[], char *argv_eol[], char *target, const char *orig_args)
+static void _cmd_authq(struct otr_user_state *ustate, SERVER_REC *irssi,
+		int argc, char *argv[], char *argv_eol[], char *target,
+		const char *orig_args)
 {
-	_auth(ustate, ircctx, argc, argv, argv_eol, target, TRUE, orig_args);
+	if (argc == 0) {
+		IRSSI_NOTICE(irssi, target, "Huh... I need a question here Bob.");
+		goto end;
+	}
+
+	_auth(ustate, irssi, argc, argv, argv_eol, target, TRUE, orig_args);
+
+end:
+	return;
 }
 
 /*
  * /otr auth
  */
-static void _cmd_auth(struct otr_user_state *ustate, IRC_CTX *ircctx, int argc, char *argv[],
-		char *argv_eol[], char *target, const char *orig_args)
+static void _cmd_auth(struct otr_user_state *ustate, SERVER_REC *irssi, int argc,
+		char *argv[], char *argv_eol[], char *target, const char *orig_args)
 {
-	_auth(ustate, ircctx, argc, argv, argv_eol, target, FALSE, orig_args);
+	if (argc == 0) {
+		IRSSI_NOTICE(irssi, target, "Huh... I need a secret here James.");
+		goto end;
+	}
+
+	_auth(ustate, irssi, argc, argv, argv_eol, target, FALSE, orig_args);
+
+end:
+	return;
 }
 
 /*
  * /otr contexts
  */
-static void _cmd_contexts(struct otr_user_state *ustate, IRC_CTX *ircctx, int argc,
-		char *argv[], char *argv_eol[], char *target, const char *orig_args)
+static void _cmd_contexts(struct otr_user_state *ustate, SERVER_REC *irssi,
+		int argc, char *argv[], char *argv_eol[], char *target,
+		const char *orig_args)
 {
 	struct ctxlist_ *ctxlist = otr_contexts(ustate), *ctxnext = ctxlist;
 	struct fplist_ *fplist, *fpnext;
 
 	if (!ctxlist) {
-		otr_infost(TXT_CTX_NOCTXS);
+		IRSSI_INFO(NULL, NULL, "No active OTR contexts found");
+		goto end;
 	}
 
 	while (ctxlist) {
@@ -215,27 +241,33 @@ static void _cmd_contexts(struct otr_user_state *ustate, IRC_CTX *ircctx, int ar
 		}
 		g_free(ctxlist);
 	}
+
+end:
+	return;
 }
 
-static void _cmd_init(struct otr_user_state *ustate, SERVER_REC *irssi, int argc,
-		char *argv[], char *argv_eol[], char *target, const char *orig_args)
+static void _cmd_init(struct otr_user_state *ustate, SERVER_REC *irssi,
+		int argc, char *argv[], char *argv_eol[], char *target,
+		const char *orig_args)
 {
 	char *msg;
 	ConnContext *ctx;
 
 	/* No server object, just ignore the request */
 	if (!irssi || !target) {
-		otr_noticest(TXT_CMD_QNOTFOUND);
+		IRSSI_WARN(irssi, target,
+				"Failed: Can't get nick and server of current query window. "
+				"(Or maybe you're doing this in the status window?)");
 		goto end;
 	}
 
 	ctx = otr_find_context(irssi, target, 0);
 	if (ctx && ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
-		IRSSI_NOTICE(irssi, target, "%9OTR%9: Already secure!");
+		IRSSI_NOTICE(irssi, target, "Already secure!");
 		goto end;
 	}
 
-	IRSSI_NOTICE(irssi, target, "%9OTR%9: Initiating OTR session...");
+	IRSSI_NOTICE(irssi, target, "Initiating OTR session...");
 
 	msg = otrl_proto_default_query_msg(target, OTRL_POLICY_DEFAULT);
 	irssi_send_message(irssi, target, msg ? msg : "?OTRv23?");
@@ -254,9 +286,10 @@ static void _cmd_forget(struct otr_user_state *ustate, SERVER_REC *irssi,
 	if (argc == 5) {
 		utils_hash_parts_to_readable_hash((const char **) argv, str_fp);
 		fp = str_fp;
-	} else if (!irssi || (irssi && argc != 0)) {
+	} else if (!irssi || (irssi && argc != 0 &&
+				(argc == 1 && argv[0] != NULL))) {
 		/* If no IRSSI or some arguments (not 5), bad command. */
-		IRSSI_NOTICE(irssi, target, "%9OTR%9: Usage %9/otr forget [FP]%9 "
+		IRSSI_NOTICE(irssi, target, "Usage %9/otr forget [FP]%9 "
 				"where FP is the five part of the fingerprint listed by "
 				"%9/otr contexts%9 or do the command inside an OTR session "
 				"private message window");
@@ -279,9 +312,10 @@ static void _cmd_distrust(struct otr_user_state *ustate, SERVER_REC *irssi,
 	if (argc == 5) {
 		utils_hash_parts_to_readable_hash((const char **) argv, str_fp);
 		fp = str_fp;
-	} else if (!irssi || (irssi && argc != 0)) {
+	} else if (!irssi || (irssi && argc != 0 &&
+				(argc == 1 && argv[0] != NULL))) {
 		/* If no IRSSI or some arguments (not 5), bad command. */
-		IRSSI_NOTICE(irssi, target, "%9OTR%9: Usage %9/otr distrust [FP]%9 "
+		IRSSI_NOTICE(irssi, target, "Usage %9/otr distrust [FP]%9 "
 				"where FP is the five part of the fingerprint listed by "
 				"%9/otr contexts%9 or do the command inside an OTR session "
 				"private message window");
@@ -318,14 +352,14 @@ static struct irssi_commands cmds[] = {
  *
  * Return TRUE if command exist and is executed else FALSE.
  */
-int cmd_generic(struct otr_user_state *ustate, IRC_CTX *ircctx, int argc, char *argv[],
-		char *argv_eol[], char *target, const char *orig_args)
+int cmd_generic(struct otr_user_state *ustate, SERVER_REC *irssi, int argc,
+		char *argv[], char *argv_eol[], char *target, const char *orig_args)
 {
 	char *cmd;
 	struct irssi_commands *commands = cmds;
 
 	if (!argc) {
-		otr_noticest(TXT_CMD_OTR);
+		IRSSI_INFO(NULL, NULL, "Alive");
 		goto done;
 	}
 
@@ -337,7 +371,7 @@ int cmd_generic(struct otr_user_state *ustate, IRC_CTX *ircctx, int argc, char *
 
 	do {
 		if (strcmp(commands->name, cmd) == 0) {
-			commands->func(ustate, ircctx, argc, argv, argv_eol, target,
+			commands->func(ustate, irssi, argc, argv, argv_eol, target,
 					orig_args);
 			goto done;
 		}
diff --git a/src/cmd.h b/src/cmd.h
index fa02f28..d331693 100644
--- a/src/cmd.h
+++ b/src/cmd.h
@@ -25,12 +25,12 @@
 
 struct irssi_commands {
 	const char *name;
-	void (*func)(struct otr_user_state *ioustate, IRC_CTX *ircctx, int argc,
+	void (*func)(struct otr_user_state *ioustate, SERVER_REC *irssi, int argc,
 			char *argv[], char *argv_eol[], char *target,
 			const char *orig_args);
 };
 
-int cmd_generic(struct otr_user_state *ioustate, IRC_CTX *ircctx, int argc,
+int cmd_generic(struct otr_user_state *ioustate, SERVER_REC *irssi, int argc,
 		char *argv[], char *argv_eol[], char *target, const char *orig_args);
 
 #endif /* IRSSI_OTR_CMD_H */
diff --git a/src/irssi_otr.h b/src/irssi_otr.h
index d2c1907..c02bc23 100644
--- a/src/irssi_otr.h
+++ b/src/irssi_otr.h
@@ -1,20 +1,22 @@
 /*
  * Off-the-Record Messaging (OTR) module for the irssi IRC client
- * Copyright (C) 2008  Uli Meis <a.sporto+bee at gmail.com>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * Copyright (C) 2008 - Uli Meis <a.sporto+bee at gmail.com>
+ *               2012 - David Goulet <dgoulet at ev0ke.net>
  *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,USA
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301,USA
  */
 
 #define UOFF_T_LONG_LONG 1
@@ -35,68 +37,58 @@
 #include <src/irc/core/irc-queries.h>
 #include <src/fe-text/statusbar-item.h>
 
-#define IRC_CTX SERVER_REC
-
 #define get_client_config_dir get_irssi_dir
 
-static IRC_CTX *IRSSI_DUP(IRC_CTX *ircctx) __attribute__ ((unused));
+static SERVER_REC *IRSSI_DUP(SERVER_REC *ircctx) __attribute__ ((unused));
 
-static IRC_CTX *IRSSI_DUP(IRC_CTX *ircctx) {
+static SERVER_REC *IRSSI_DUP(SERVER_REC *ircctx) {
 	server_ref(ircctx);
 	return ircctx;
 }
 
-static IRC_CTX *IRSSI_FREE(IRC_CTX *ircctx) __attribute__ ((unused));
+static SERVER_REC *IRSSI_FREE(SERVER_REC *ircctx) __attribute__ ((unused));
 
-static IRC_CTX *IRSSI_FREE(IRC_CTX *ircctx)
+static SERVER_REC *IRSSI_FREE(SERVER_REC *ircctx)
 {
 	server_unref(ircctx);
 	return ircctx;
 }
 
-void otr_query_create(IRC_CTX *ircctx, const char *nick);
+void otr_query_create(SERVER_REC *ircctx, const char *nick);
 
 #define IRSSI_CONN_ADDR(i) i->connrec->address
 #define IRSSI_NICK(i) i->nick
-#define IRSSI_ACCNAME(accname, i) sprintf(accname, "%s@%s", i->nick, IRSSI_CONN_ADDR(i))
-
-#define otr_noticest(formatnum,...) \
-	printformat(NULL,NULL,MSGLEVEL_MSGS, formatnum, ## __VA_ARGS__)
-
-#define otr_notice(irssi, nick, formatnum, ...) { \
-	otr_query_create(irssi, nick); \
-	printformat(irssi, nick, MSGLEVEL_MSGS, formatnum, ## __VA_ARGS__);}
 
 #define otr_infost(formatnum,...) \
-	printformat(NULL,NULL,MSGLEVEL_CRAP, formatnum, ## __VA_ARGS__)
-
-#define otr_info(server, nick, formatnum, ...) { \
-	otr_query_create(server, nick); \
-	printformat(server, nick, MSGLEVEL_CRAP, formatnum, ## __VA_ARGS__);}
-
-#define otr_debug(irssi, nick, formatnum, ...) { \
-	if (debug) { \
-		otr_query_create(irssi, nick); \
-		printformat(irssi, nick, MSGLEVEL_MSGS, formatnum, ## __VA_ARGS__); } }
+	printformat(NULL, NULL, MSGLEVEL_CRAP, formatnum, ## __VA_ARGS__)
 
 /*
  * Irssi macros for printing text to console.
  */
 #define IRSSI_MSG(fmt, ...)                                                 \
 	do {                                                                    \
-		printtext(NULL, NULL, MSGLEVEL_MSGS, fmt, ## __VA_ARGS__);          \
+		printtext(NULL, NULL, MSGLEVEL_MSGS, "%9OTR%9: " fmt,               \
+						## __VA_ARGS__);                                    \
+	} while (0)
+#define IRSSI_INFO(irssi, username, fmt, ...)                               \
+	do {                                                                    \
+		printtext(irssi, username, MSGLEVEL_CRAP, "%9OTR%9: " fmt,          \
+						## __VA_ARGS__);                                    \
 	} while (0)
 #define IRSSI_NOTICE(irssi, username, fmt, ...)                             \
 	do {                                                                    \
-		printtext(irssi, username, MSGLEVEL_MSGS, fmt, ## __VA_ARGS__);     \
+		printtext(irssi, username, MSGLEVEL_MSGS, "%9OTR%9: " fmt,          \
+						## __VA_ARGS__);                                    \
 	} while (0)
 #define IRSSI_WARN(irssi, username, fmt, ...)                               \
 	do {                                                                    \
-		printtext(irssi, username, MSGLEVEL_HILIGHT, fmt, ## __VA_ARGS__);  \
+		printtext(irssi, username, MSGLEVEL_HILIGHT, "%9OTR%9: " fmt,       \
+						## __VA_ARGS__);                                    \
 	} while (0)
 #define IRSSI_DEBUG(fmt, ...) \
 	do {                                                                    \
 		if (debug) {                                                        \
-			printtext(NULL, NULL, MSGLEVEL_MSGS, fmt, ## __VA_ARGS__); \
+			printtext(NULL, NULL, MSGLEVEL_MSGS, "%9OTR%9: " fmt,           \
+						## __VA_ARGS__);                                    \
 		}                                                                   \
 	} while (0)
diff --git a/src/key.c b/src/key.c
index 7bdf24c..24dbe7c 100644
--- a/src/key.c
+++ b/src/key.c
@@ -86,12 +86,15 @@ static void keygen_childwatch(GPid pid, gint status, gpointer data)
 				"%s", strsignal(WTERMSIG(status))
 #endif
 			);
-			otr_noticest(TXT_KG_EXITSIG, kg_st.accountname, sigstr);
+			IRSSI_INFO(NULL, NULL, "Key generation for %s, child was killed "
+					"by signal %s", kg_st.accountname, sigstr);
 		} else {
-			otr_noticest(TXT_KG_EXITED, kg_st.accountname);
+			IRSSI_INFO(NULL, NULL, "Key generation for %s, child terminated "
+					"for unknown reason", kg_st.accountname);
 		}
 	} else if (ret < 0) {
-		otr_noticest(TXT_KG_POLLERR, kg_st.accountname, strerror(errno));
+		IRSSI_INFO(NULL, NULL, "Key generation for %s. Poll error %s",
+				kg_st.accountname, strerror(errno));
 	}
 
 	key_generation_abort(kg_st.ustate, FALSE);
@@ -121,11 +124,12 @@ static gboolean keygen_complete(GIOChannel *source, GIOCondition condition,
 	g_io_channel_unref(kg_st.ch[1]);
 
 	if (err) {
-		otr_noticest(TXT_KG_FAILED, kg_st.accountname, gcry_strerror(err),
-				gcry_strsource(err));
+		IRSSI_INFO(NULL, NULL, "Key generation failed for %s (err: %s)",
+				kg_st.accountname, gcry_strerror(err));
 	} else {
 		/* reload keys */
-		otr_noticest(TXT_KG_COMPLETED, kg_st.accountname,
+		IRSSI_INFO(NULL, NULL, "Key generation for %s completed in %d seconds."
+				" Reloading keys.", kg_st.accountname,
 				time(NULL) - kg_st.started);
 		rename(tmpfilename, filename);
 		//otrl_privkey_forget_all(otr_state); <-- done by lib
@@ -149,14 +153,20 @@ static gboolean keygen_complete(GIOChannel *source, GIOCondition condition,
  * will rewrite the key file, we shouldn't change anything till it's done and
  * we've reloaded the keys.
  */
-void key_generation_run(struct otr_user_state *ustate, const char *accname) { gcry_error_t
-	err; int ret; int fds[2]; char *filename =
-		g_strconcat(get_client_config_dir(), OTR_TMP_KEYFILE, NULL); char
-		*filenamedup = g_strdup(filename); char *dir = dirname(filenamedup);
+void key_generation_run(struct otr_user_state *ustate, const char *accname)
+{
+	gcry_error_t err;
+	int ret;
+	int fds[2];
+	char *filename = g_strconcat(get_client_config_dir(), OTR_TMP_KEYFILE, NULL);
+	char *filenamedup = g_strdup(filename);
+	char *dir = dirname(filenamedup);
 
 	if (kg_st.status != KEYGEN_NO) {
 		if (strncmp(accname, kg_st.accountname, strlen(accname)) != 0) {
-			otr_noticest(TXT_KG_ABORTED_DUP, accname, kg_st.accountname);
+			IRSSI_INFO(NULL, NULL, "Key generation for %s aborted. "
+					"Key generation for %s still in progress", accname,
+					kg_st.accountname);
 		}
 		g_free(filenamedup);
 		goto end;
@@ -164,12 +174,15 @@ void key_generation_run(struct otr_user_state *ustate, const char *accname) { gc
 
 	if (!g_file_test(dir, G_FILE_TEST_EXISTS)) {
 		if (g_mkdir(dir, S_IRWXU)) {
-			otr_noticest(TXT_KG_ABORTED_DIR, accname, dir, strerror(errno));
+			IRSSI_INFO(NULL, NULL, "Key generation for %s aborted. Failed "
+					"creating directory %s (err: %s)",
+					accname, dir, strerror(errno));
 			g_free(dir);
 			g_free(filenamedup);
 			goto end;
 		} else {
-			otr_noticest(TXT_KG_MKDIR, dir);
+			IRSSI_INFO(NULL, NULL, "Key generation created directory %9%s%9",
+					dir);
 		}
 	}
 
@@ -177,7 +190,8 @@ void key_generation_run(struct otr_user_state *ustate, const char *accname) { gc
 
 	ret = pipe(fds);
 	if (ret < 0) {
-		otr_noticest(TXT_KG_PIPE, accname, strerror(errno));
+		IRSSI_INFO(NULL, NULL, "Key generation for %s. Error creating "
+				"pipe (err: %s)", accname, strerror(errno));
 		goto end;
 	}
 
@@ -191,14 +205,18 @@ void key_generation_run(struct otr_user_state *ustate, const char *accname) { gc
 
 	if ((ret = fork())) {
 		if (ret == -1) {
-			otr_noticest(TXT_KG_FORK, accname, strerror(errno));
+			IRSSI_INFO(NULL, NULL, "Key generation for %s. Fork error "
+					"(err: %s)", accname, strerror(errno));
 			goto end;
 		}
 
 		kg_st.status = KEYGEN_RUNNING;
 		kg_st.pid = ret;
 
-		otr_noticest(TXT_KG_INITIATED, accname);
+		IRSSI_INFO(NULL, NULL, "Key generation for %s initiated. "
+				"This might take several minutes or on some systems even an "
+				"hour. If you wanna check that something is happening, see if "
+				"there are two processes of your IRC client.", accname);
 
 		kg_st.cpid = g_io_add_watch(kg_st.ch[0], G_IO_IN,
 				(GIOFunc) keygen_complete, NULL);
@@ -229,12 +247,12 @@ void key_generation_abort(struct otr_user_state *ustate, int ignoreidle)
 {
 	if (kg_st.status != KEYGEN_RUNNING) {
 		if (!ignoreidle) {
-			otr_noticest(TXT_KG_NOABORT);
+			IRSSI_INFO(NULL, NULL, "No ongoing key generation to abort");
 		}
 		goto end;
 	}
 
-	otr_noticest(TXT_KG_ABORT, kg_st.accountname);
+	IRSSI_INFO(NULL, NULL, "Key generation for %s aborted", kg_st.accountname);
 
 	g_source_remove(kg_st.cpid);
 	g_source_remove(kg_st.cwid);
@@ -268,9 +286,9 @@ void key_write_fingerprints(struct otr_user_state *ustate)
 
 	err = otrl_privkey_write_fingerprints(ustate->otr_state, filename);
 	if (err == GPG_ERR_NO_ERROR) {
-		IRSSI_DEBUG("%9OTR%9: Fingerprints saved to %9%s%9", filename);
+		IRSSI_DEBUG("Fingerprints saved to %9%s%9", filename);
 	} else {
-		IRSSI_DEBUG("%9OTR%9: Error writing fingerprints: %d (%d)",
+		IRSSI_DEBUG("Error writing fingerprints: %d (%d)",
 				gcry_strerror(err), gcry_strsource(err));
 	}
 
@@ -296,9 +314,9 @@ void key_write_instags(struct otr_user_state *ustate)
 
 	err = otrl_instag_write(ustate->otr_state, filename);
 	if (err == GPG_ERR_NO_ERROR) {
-		IRSSI_DEBUG("%9OTR%9: Instance tags saved in %9%s%9", filename);
+		IRSSI_DEBUG("Instance tags saved in %9%s%9", filename);
 	} else {
-		IRSSI_DEBUG("%9OTR%9: Error saving instance tags: %d (%d)",
+		IRSSI_DEBUG("Error saving instance tags: %d (%d)",
 				gcry_strerror(err), gcry_strsource(err));
 	}
 
@@ -325,15 +343,15 @@ void key_load(struct otr_user_state *ustate)
 
 	ret = access(filename, F_OK);
 	if (ret < 0) {
-		IRSSI_DEBUG("%9OTR%9: No private keys found in %9%s%9", filename);
+		IRSSI_DEBUG("No private keys found in %9%s%9", filename);
 		goto end;
 	}
 
 	err = otrl_privkey_read(ustate->otr_state, filename);
 	if (err == GPG_ERR_NO_ERROR) {
-		IRSSI_DEBUG("%9OTR%9: Private keys loaded from %9%s%9", filename);
+		IRSSI_DEBUG("Private keys loaded from %9%s%9", filename);
 	} else {
-		IRSSI_DEBUG("%9OTR%9: Error loading private keys: %d (%d)",
+		IRSSI_DEBUG("Error loading private keys: %d (%d)",
 				gcry_strerror(err), gcry_strsource(err));
 	}
 
@@ -361,16 +379,16 @@ void key_load_fingerprints(struct otr_user_state *ustate)
 
 	ret = access(filename, F_OK);
 	if (ret < 0) {
-		IRSSI_DEBUG("%9OTR%9: No fingerprints found in %9%s%9", filename);
+		IRSSI_DEBUG("No fingerprints found in %9%s%9", filename);
 		goto end;
 	}
 
 	err = otrl_privkey_read_fingerprints(ustate->otr_state, filename, NULL,
 			NULL);
 	if (err == GPG_ERR_NO_ERROR) {
-		IRSSI_DEBUG("%9OTR%9: Fingerprints loaded from %9%s%9", filename);
+		IRSSI_DEBUG("Fingerprints loaded from %9%s%9", filename);
 	} else {
-		IRSSI_DEBUG("%9OTR%9: Error loading fingerprints: %d (%d)",
+		IRSSI_DEBUG("Error loading fingerprints: %d (%d)",
 				gcry_strerror(err), gcry_strsource(err));
 	}
 
diff --git a/src/module.c b/src/module.c
index fc78757..2e56521 100644
--- a/src/module.c
+++ b/src/module.c
@@ -124,7 +124,7 @@ end:
 static void sig_query_destroyed(QUERY_REC *query)
 {
 	if (query && query->server && query->server->connrec) {
-		otr_finish(query->server, query->name, NULL, FALSE);
+		otr_finish(query->server, query->name);
 	}
 }
 
@@ -138,7 +138,7 @@ static void cmd_otr(const char *data, void *server, WI_ITEM_REC *item)
 	QUERY_REC *query = QUERY(item);
 
 	if (*data == '\0') {
-		otr_noticest(TXT_CMD_OTR);
+		IRSSI_INFO(NULL, NULL, "Alive!");
 		goto end;
 	}
 
@@ -167,9 +167,7 @@ end:
  */
 static void cmd_quit(const char *data, void *server, WI_ITEM_REC *item)
 {
-	if (settings_get_bool("otr_finishonunload")) {
-		otr_finishall(user_state_global);
-	}
+	otr_finishall(user_state_global);
 }
 
 /*
@@ -286,9 +284,7 @@ void otr_deinit(void)
 
 	statusbar_item_unregister("otr");
 
-	if (settings_get_bool("otr_finishonunload")) {
-		otr_finishall(user_state_global);
-	}
+	otr_finishall(user_state_global);
 
 	otr_free_user(user_state_global);
 
diff --git a/src/otr-ops.c b/src/otr-ops.c
index 8048357..c733047 100644
--- a/src/otr-ops.c
+++ b/src/otr-ops.c
@@ -98,7 +98,7 @@ static void ops_inject_msg(void *opdata, const char *accountname,
 {
 	SERVER_REC *irssi = opdata;
 
-	IRSSI_DEBUG("%9OTR%9: Inject msg:\n[%s]", message);
+	IRSSI_DEBUG("Inject msg:\n[%s]", message);
 	irssi_send_message(irssi, recipient, message);
 }
 
@@ -117,7 +117,7 @@ static void ops_secure(void *opdata, ConnContext *context)
 	/* This should *really* not happened */
 	assert(context->msgstate == OTRL_MSGSTATE_ENCRYPTED);
 
-	IRSSI_NOTICE(irssi, context->username, "%9OTR%9: Gone %9secure%9");
+	IRSSI_NOTICE(irssi, context->username, "Gone %9secure%9");
 	otr_status_change(irssi, context->username, OTR_STATUS_GONE_SECURE);
 
 	opc = context->app_data;
@@ -135,7 +135,7 @@ static void ops_secure(void *opdata, ConnContext *context)
 	otrl_privkey_fingerprint(user_state_global->otr_state, ownfp,
 			context->accountname, OTR_PROTOCOL_ID);
 
-	IRSSI_NOTICE(irssi, context->username, "%9OTR%9: Your peer is not "
+	IRSSI_NOTICE(irssi, context->username, "Your peer is not "
 			"authenticated. To make sure you're talking to the right guy you can "
 			"either agree on a secret and use the authentication command "
 			"%9/otr auth%9 or %9/otr authq [QUESTION] SECRET%9. You can also "
@@ -144,8 +144,8 @@ static void ops_secure(void *opdata, ConnContext *context)
 			"%9/otr trust%9.");
 
 	IRSSI_NOTICE(irssi, context->username,
-			"%9OTR%9: Your fingerprint is: %y%s\%n.\n"
-			"%9OTR%9: %9%s's%9 fingerprint is: %r%s\%n", ownfp,
+			"Your fingerprint is: %y%s\%n.\n"
+			"%9%s's%9 fingerprint is: %r%s\%n", ownfp,
 			context->username, peerfp);
 
 end:
@@ -159,7 +159,7 @@ static void ops_insecure(void *opdata, ConnContext *context)
 {
 	SERVER_REC *irssi = opdata;
 
-	IRSSI_NOTICE(irssi, context->username, "%9OTR%9: Gone %rinsecure%r");
+	IRSSI_NOTICE(irssi, context->username, "Gone %rinsecure%r");
 	otr_status_change(irssi, context->username, OTR_STATUS_GONE_INSECURE);
 }
 
@@ -182,14 +182,14 @@ static void ops_handle_msg_event(void *opdata, OtrlMessageEvent msg_event,
 	case OTRL_MSGEVENT_NONE:
 		break;
 	case OTRL_MSGEVENT_ENCRYPTION_REQUIRED:
-		IRSSI_WARN(server, username, "%9OTR:%9 %yEncryption is required.%n");
+		IRSSI_WARN(server, username, "%yEncryption is required.%n");
 		break;
 	case OTRL_MSGEVENT_ENCRYPTION_ERROR:
-		IRSSI_WARN(server, username, "%9OTR:%9 An error occurred when "
+		IRSSI_WARN(server, username, "An error occurred when "
 				"encrypting your message. The message was NOT sent.");
 		break;
 	case OTRL_MSGEVENT_CONNECTION_ENDED:
-		IRSSI_WARN(server, username, "%9OTR: %s%9 has already closed the "
+		IRSSI_WARN(server, username, "%9%s%9 has already closed the "
 				"connection to you.", username);
 		break;
 	case OTRL_MSGEVENT_SETUP_ERROR:
@@ -198,49 +198,49 @@ static void ops_handle_msg_event(void *opdata, OtrlMessageEvent msg_event,
 		}
 		switch (err) {
 		case GPG_ERR_INV_VALUE:
-			IRSSI_WARN(server, username, "%9OTR:%9 Error setting up private "
+			IRSSI_WARN(server, username, "Error setting up private "
 					"conversation: Malformed message received");
 			break;
 		default:
-			IRSSI_WARN(server, username, "%9OTR:%9 Error up private "
+			IRSSI_WARN(server, username, "Error up private "
 					"conversation: %s", gcry_strerror(err));
 			break;
 		}
 		break;
 	case OTRL_MSGEVENT_MSG_REFLECTED:
-		IRSSI_WARN(server, username, "%9OTR:%9 Receiving our own OTR messages. "
+		IRSSI_WARN(server, username, "Receiving our own OTR messages. "
 				"You are either trying to talk to yourself, or someone is "
 				"reflecting your messages back at you.");
 		break;
 	case OTRL_MSGEVENT_MSG_RESENT:
-		IRSSI_NOTICE(server, username, "%9OTR:%9 The last message to %9%s%9 "
+		IRSSI_NOTICE(server, username, "The last message to %9%s%9 "
 				"was resent: %s", username, message);
 		break;
 	case OTRL_MSGEVENT_RCVDMSG_NOT_IN_PRIVATE:
-		IRSSI_WARN(server, username, "%9OTR:%9 The encrypted message received "
+		IRSSI_WARN(server, username, "The encrypted message received "
 				"from %s is unreadable, as you are not currently communicating "
 				"privately.", username);
 		break;
 	case OTRL_MSGEVENT_RCVDMSG_UNREADABLE:
-		IRSSI_WARN(server, username, "%9OTR:%9 We received an unreadable "
+		IRSSI_WARN(server, username, "We received an unreadable "
 				"encrypted message from %s.", username);
 		break;
 	case OTRL_MSGEVENT_RCVDMSG_MALFORMED:
-		IRSSI_WARN(server, username, "%9OTR:%9 We received a malformed data "
+		IRSSI_WARN(server, username, "We received a malformed data "
 				"message from %s.", username);
 		break;
 	case OTRL_MSGEVENT_LOG_HEARTBEAT_RCVD:
-		IRSSI_DEBUG("%9OTR:%9 Heartbeat received from %s.", username);
+		IRSSI_DEBUG("Heartbeat received from %s.", username);
 		break;
 	case OTRL_MSGEVENT_LOG_HEARTBEAT_SENT:
-		IRSSI_DEBUG("%9OTR:%9 Heartbeat sent to %s.", username);
+		IRSSI_DEBUG("Heartbeat sent to %s.", username);
 		break;
 	case OTRL_MSGEVENT_RCVDMSG_GENERAL_ERR:
-		IRSSI_WARN(server, username, "%9OTR:%9 OTR Error: %s.", message);
+		IRSSI_WARN(server, username, "General Error: %s.", message);
 		break;
 	case OTRL_MSGEVENT_RCVDMSG_UNENCRYPTED:
 		IRSSI_NOTICE(server, username,
-				"%9OTR:%9 The following message from %9%s%9 was NOT "
+				"The following message from %9%s%9 was NOT "
 				"encrypted.", username);
 		/*
 		 * This is a hack I found to send the message in a private window of
@@ -255,11 +255,11 @@ static void ops_handle_msg_event(void *opdata, OtrlMessageEvent msg_event,
 		signal_add_first("message private", (SIGNAL_FUNC) sig_message_private);
 		break;
 	case OTRL_MSGEVENT_RCVDMSG_UNRECOGNIZED:
-		IRSSI_WARN(server, username, "%9OTR:%9 Unrecognized OTR message "
+		IRSSI_WARN(server, username, "Unrecognized OTR message "
 				"received from %s.", username);
 		break;
 	case OTRL_MSGEVENT_RCVDMSG_FOR_OTHER_INSTANCE:
-		IRSSI_DEBUG("%9OTR:%9 %s has sent a message for a different instance.",
+		IRSSI_DEBUG("%s has sent a message for a different instance.",
 				username);
 		break;
 	}
@@ -295,7 +295,7 @@ static int ops_is_logged_in(void *opdata, const char *accountname,
 		ret = 0;
 	}
 
-	IRSSI_DEBUG("%9OTR%9: User %s %s logged in", accountname,
+	IRSSI_DEBUG("User %s %s logged in", accountname,
 			(ret == 0) ? "not" : "");
 
 	return ret;
@@ -328,40 +328,40 @@ static void ops_smp_event(void *opdata, OtrlSMPEvent smp_event,
 
 	switch (smp_event) {
 	case OTRL_SMPEVENT_ASK_FOR_SECRET:
-		IRSSI_NOTICE(irssi, from, "%9OTR%9: %9%s%9 wants to authenticate. "
+		IRSSI_NOTICE(irssi, from, "%9%s%9 wants to authenticate. "
 				"Type %9/otr auth <SECRET>%9 to complete.", from);
 		opc->ask_secret = 1;
 		otr_status_change(irssi, from, OTR_STATUS_SMP_INCOMING);
 		break;
 	case OTRL_SMPEVENT_ASK_FOR_ANSWER:
-		IRSSI_NOTICE(irssi, from, "%9OTR%9: %9%s%9 wants to authenticate and "
+		IRSSI_NOTICE(irssi, from, "%9%s%9 wants to authenticate and "
 				"asked this question: %9%s%9\n"
-				"%9OTR%9: Type %9/otr auth <SECRET>%9 to complete.", from,
+				"Type %9/otr auth <SECRET>%9 to complete.", from,
 				question);
 		opc->ask_secret = 1;
 		otr_status_change(irssi, from, OTR_STATUS_SMP_INCOMING);
 		break;
 	case OTRL_SMPEVENT_IN_PROGRESS:
-		IRSSI_NOTICE(irssi, from, "%9OTR%9: %9%s%9 replied to our auth request",
+		IRSSI_NOTICE(irssi, from, "%9%s%9 replied to our auth request",
 				from);
 		otr_status_change(irssi, from, OTR_STATUS_SMP_FINALIZE);
 		break;
 	case OTRL_SMPEVENT_SUCCESS:
-		IRSSI_NOTICE(irssi, from, "%9OTR%9: %GAuthentication successful%n");
+		IRSSI_NOTICE(irssi, from, "%GAuthentication successful%n");
 		otr_status_change(irssi, from, OTR_STATUS_SMP_SUCCESS);
 		break;
 	case OTRL_SMPEVENT_ABORT:
-		otr_abort_auth(context, irssi, from);
+		otr_auth_abort(irssi, context->username);
 		otr_status_change(irssi, from, OTR_STATUS_SMP_ABORTED);
 		break;
 	case OTRL_SMPEVENT_FAILURE:
 	case OTRL_SMPEVENT_CHEATED:
 	case OTRL_SMPEVENT_ERROR:
-		IRSSI_NOTICE(irssi, from, "%9OTR%9: %RAuthentication failed%n");
+		IRSSI_NOTICE(irssi, from, "%RAuthentication failed%n");
 		otr_status_change(irssi, from, OTR_STATUS_SMP_FAILED);
 		break;
 	default:
-		IRSSI_NOTICE(irssi, from, "%9OTR%9: Received unknown SMP event. "
+		IRSSI_NOTICE(irssi, from, "Received unknown SMP event. "
 			"Ignoring");
 		break;
 	}
diff --git a/src/otr.c b/src/otr.c
index 257bb09..6e83f92 100644
--- a/src/otr.c
+++ b/src/otr.c
@@ -81,15 +81,15 @@ static void instag_load(struct otr_user_state *ustate)
 
 	ret = access(filename, F_OK);
 	if (ret < 0) {
-		IRSSI_DEBUG("%9OTR%9: no instance tags found at %9%s%9", filename);
+		IRSSI_DEBUG("no instance tags found at %9%s%9", filename);
 		goto end;
 	}
 
 	err = otrl_instag_read(ustate->otr_state, filename);
 	if (err == GPG_ERR_NO_ERROR) {
-		IRSSI_DEBUG("%9OTR%9: Instance tags loaded from %9%s%9", filename);
+		IRSSI_DEBUG("Instance tags loaded from %9%s%9", filename);
 	} else {
-		IRSSI_DEBUG("%9OTR%9: Error loading instance tags: %d (%d)",
+		IRSSI_DEBUG("Error loading instance tags: %d (%d)",
 				gcry_strerror(err), gcry_strsource(err));
 	}
 
@@ -107,7 +107,7 @@ static void destroy_peer_context_cb(void *data)
 		free(opc);
 	}
 
-	IRSSI_DEBUG("%9OTR%9: Peer context freed");
+	IRSSI_DEBUG("Peer context freed");
 }
 
 static void add_peer_context_cb(void *data, ConnContext *context)
@@ -124,7 +124,7 @@ static void add_peer_context_cb(void *data, ConnContext *context)
 	context->app_data = opc;
 	context->app_data_free = destroy_peer_context_cb;
 
-	IRSSI_MSG("%9OTR%9: Peer context created for %s", context->username);
+	IRSSI_MSG("Peer context created for %s", context->username);
 }
 
 /*
@@ -243,17 +243,17 @@ int otr_send(SERVER_REC *irssi, const char *msg, const char *to, char **otr_msg)
 		goto error;
 	}
 
-	IRSSI_DEBUG("%9OTR%9: Sending message...");
+	IRSSI_DEBUG("Sending message...");
 
 	err = otrl_message_sending(user_state_global->otr_state, &otr_ops,
 		irssi, accname, OTR_PROTOCOL_ID, to, OTRL_INSTAG_BEST, msg, NULL, otr_msg,
 		OTRL_FRAGMENT_SEND_ALL_BUT_LAST, &ctx, add_peer_context_cb, irssi);
 	if (err) {
-		IRSSI_NOTICE(irssi, to, "%9OTR:%9 Send failed.");
+		IRSSI_NOTICE(irssi, to, "Send failed.");
 		goto error;
 	}
 
-	IRSSI_DEBUG("%9OTR%9: Message sent...");
+	IRSSI_DEBUG("Message sent...");
 
 	/* Add peer context to OTR context if none exists. */
 	if (ctx && !ctx->app_data) {
@@ -335,33 +335,26 @@ struct ctxlist_ *otr_contexts(struct otr_user_state *ustate)
 /*
  * Finish the conversation.
  */
-void otr_finish(SERVER_REC *irssi, char *nick, const char *peername, int inquery)
+void otr_finish(SERVER_REC *irssi, char *nick)
 {
-	ConnContext *co;
-	char nickbuf[128];
+	ConnContext *ctx;
 
-	if (peername) {
-		nick = nickbuf;
-		irssi = find_irssi_ctx_by_peername(peername, nick);
-		if (!irssi) {
-			goto end;
-		}
-	}
+	assert(irssi);
+	assert(nick);
 
-	if (!(co = otr_find_context(irssi, nick, FALSE))) {
+	ctx = otr_find_context(irssi, nick, FALSE);
+	if (!ctx) {
+		IRSSI_INFO(irssi, nick, "Nothing to do");
 		goto end;
 	}
 
 	otrl_message_disconnect(user_state_global->otr_state, &otr_ops, irssi,
-			co->accountname, OTR_PROTOCOL_ID, nick, co->their_instance);
+			ctx->accountname, OTR_PROTOCOL_ID, nick, ctx->their_instance);
 
 	otr_status_change(irssi, nick, OTR_STATUS_FINISHED);
 
-	if (inquery) {
-		otr_info(irssi, nick, TXT_CMD_FINISH, nick, IRSSI_CONN_ADDR(irssi));
-	} else {
-		otr_infost(TXT_CMD_FINISH, nick, IRSSI_CONN_ADDR(irssi));
-	}
+	IRSSI_INFO(irssi, nick, "Finished conversation with %9%s%9",
+			ctx->accountname);
 
 end:
 	return;
@@ -370,11 +363,13 @@ end:
 void otr_finishall(struct otr_user_state *ustate)
 {
 	ConnContext *context;
-	int finished = 0;
 	SERVER_REC *irssi;
 
+	assert(ustate);
+
 	for (context = ustate->otr_state->context_root; context;
 			context = context->next) {
+		/* Only finish encrypted session. */
 		if (context->msgstate != OTRL_MSGSTATE_ENCRYPTED) {
 			continue;
 		}
@@ -382,42 +377,26 @@ void otr_finishall(struct otr_user_state *ustate)
 		irssi = find_irssi_ctx_by_peername(context->accountname,
 				context->username);
 		if (!irssi) {
-			IRSSI_DEBUG("%9OTR%9: Unable to find context on /otr finishall "
+			IRSSI_DEBUG("Unable to find server window on /otr finishall "
 					"for username %s", context->username);
 			continue;
 		}
 
-		otrl_message_disconnect(ustate->otr_state, &otr_ops, irssi,
-					context->accountname, OTR_PROTOCOL_ID, context->username,
-					context->their_instance);
-		otr_status_change(irssi, context->username, OTR_STATUS_FINISHED);
-
-		otr_infost(TXT_CMD_FINISH, context->username, IRSSI_CONN_ADDR(irssi));
-		finished++;
-	}
-
-	if (!finished) {
-		otr_infost(TXT_CMD_FINISHALL_NONE);
+		otr_finish(irssi, context->username);
 	}
 }
 
 /*
  * Trust our peer.
  */
-void otr_trust(SERVER_REC *irssi, char *nick, const char *peername)
+void otr_trust(SERVER_REC *irssi, char *nick)
 {
 	ConnContext *ctx;
-	char nickbuf[128];
 	char peerfp[OTRL_PRIVKEY_FPRINT_HUMAN_LEN];
 	struct otr_peer_context *opc;
 
-	if (peername) {
-		nick = nickbuf;
-		irssi = find_irssi_ctx_by_peername(peername, nick);
-		if (!irssi) {
-			goto end;
-		}
-	}
+	assert(irssi);
+	assert(nick);
 
 	ctx = otr_find_context(irssi, nick, FALSE);
 	if (!ctx) {
@@ -427,12 +406,13 @@ void otr_trust(SERVER_REC *irssi, char *nick, const char *peername)
 	opc = ctx->app_data;
 	assert(opc);
 
+	/* Trust level is manual at this point. */
 	otrl_context_set_trust(opc->active_fingerprint, "manual");
 	otr_status_change(irssi, nick, OTR_STATUS_TRUST_MANUAL);
 
 	otrl_privkey_hash_to_human(peerfp, opc->active_fingerprint->fingerprint);
 
-	IRSSI_NOTICE(irssi, nick, "%9OTR%9: Trusting fingerprint from %9%s%9:\n"
+	IRSSI_NOTICE(irssi, nick, "Trusting fingerprint from %9%s%9:\n"
 			"%9OTR%9: %g%s%n", nick, peerfp);
 
 	key_write_fingerprints(user_state_global);
@@ -442,41 +422,29 @@ end:
 }
 
 /*
- * Abort any ongoing SMP authentication.
- */
-void otr_abort_auth(ConnContext *co, SERVER_REC *irssi, const char *nick)
-{
-	otr_notice(irssi, nick,
-			co->smstate->nextExpected != OTRL_SMP_EXPECT1 ?
-			TXT_AUTH_ABORTED_ONGOING : TXT_AUTH_ABORTED);
-
-	otrl_message_abort_smp(user_state_global->otr_state, &otr_ops,
-			irssi, co);
-	otr_status_change(irssi, nick, OTR_STATUS_SMP_ABORT);
-}
-
-/*
  * implements /otr authabort
  */
-void otr_authabort(SERVER_REC *irssi, char *nick, const char *peername)
+void otr_auth_abort(SERVER_REC *irssi, char *nick)
 {
-	ConnContext *co;
-	char nickbuf[128];
+	ConnContext *ctx;
 
-	if (peername) {
-		nick = nickbuf;
-		irssi = find_irssi_ctx_by_peername(peername, nick);
-		if (!irssi) {
-			goto end;
-		}
-	}
+	assert(irssi);
+	assert(nick);
 
-	if (!(co = otr_find_context(irssi, nick, FALSE))) {
-		otr_noticest(TXT_CTX_NOT_FOUND, co->accountname, nick);
+	ctx = otr_find_context(irssi, nick, FALSE);
+	if (!ctx) {
+		IRSSI_NOTICE(irssi, nick, "Context for %9%s%9 not found.", nick);
 		goto end;
 	}
 
-	otr_abort_auth(co, irssi, nick);
+	otrl_message_abort_smp(user_state_global->otr_state, &otr_ops, irssi, ctx);
+	otr_status_change(irssi, nick, OTR_STATUS_SMP_ABORT);
+
+	if (ctx->smstate->nextExpected != OTRL_SMP_EXPECT1) {
+		IRSSI_NOTICE(irssi, nick, "Ongoing authentication aborted");
+	} else {
+		IRSSI_NOTICE(irssi, nick, "Authentication aborted");
+	}
 
 end:
 	return;
@@ -485,25 +453,20 @@ end:
 /*
  * Initiate or respond to SMP authentication.
  */
-void otr_auth(SERVER_REC *irssi, char *nick, const char *peername,
-		const char *question, const char *secret)
+void otr_auth(SERVER_REC *irssi, char *nick, const char *question,
+		const char *secret)
 {
 	int ret;
 	ConnContext *ctx;
-	char nickbuf[128];
 	struct otr_peer_context *opc;
 
-	if (peername) {
-		nick = nickbuf;
-		irssi = find_irssi_ctx_by_peername(peername, nick);
-		if (!irssi) {
-			goto end;
-		}
-	}
+	assert(irssi);
+	assert(nick);
+	assert(secret);
 
 	ctx = otr_find_context(irssi, nick, 0);
 	if (!ctx) {
-		otr_noticest(TXT_CTX_NOT_FOUND, ctx->accountname, nick);
+		IRSSI_NOTICE(irssi, nick, "Context for %9%s%9 not found.", nick);
 		goto end;
 	}
 
@@ -512,15 +475,15 @@ void otr_auth(SERVER_REC *irssi, char *nick, const char *peername,
 	assert(opc);
 
 	if (ctx->msgstate != OTRL_MSGSTATE_ENCRYPTED) {
-		IRSSI_NOTICE(irssi, nick,
-				"%9OTR%9: You need to establish an OTR session before you "
+		IRSSI_INFO(irssi, nick,
+				"You need to establish an OTR session before you "
 				"can authenticate.");
 		goto end;
 	}
 
 	/* Aborting an ongoing auth */
 	if (ctx->smstate->nextExpected != OTRL_SMP_EXPECT1) {
-		otr_abort_auth(ctx, irssi, nick);
+		otr_auth_abort(irssi, nick);
 	}
 
 	/* reset trust level */
@@ -536,7 +499,7 @@ void otr_auth(SERVER_REC *irssi, char *nick, const char *peername,
 		otrl_message_respond_smp(user_state_global->otr_state, &otr_ops,
 				irssi, ctx, (unsigned char *) secret, strlen(secret));
 		otr_status_change(irssi, nick, OTR_STATUS_SMP_RESPONDED);
-		IRSSI_NOTICE(irssi, nick, "%9OTR%9: Responding to authentication...");
+		IRSSI_NOTICE(irssi, nick, "Responding to authentication...");
 	} else {
 		if (question) {
 			otrl_message_initiate_smp_q(user_state_global->otr_state,
@@ -548,7 +511,7 @@ void otr_auth(SERVER_REC *irssi, char *nick, const char *peername,
 				strlen(secret));
 		}
 		otr_status_change(irssi, nick, OTR_STATUS_SMP_STARTED);
-		IRSSI_NOTICE(irssi, nick, "%9OTR%9: Initiated authentication...");
+		IRSSI_NOTICE(irssi, nick, "Initiated authentication...");
 	}
 
 	opc->ask_secret = 0;
@@ -570,22 +533,24 @@ int otr_receive(SERVER_REC *irssi, const char *msg, const char *from,
 	OtrlTLV *tlvs;
 	ConnContext *ctx;
 
+	assert(irssi);
+
 	accname = create_account_name(irssi);
 	if (!accname) {
 		goto error;
 	}
 
-	IRSSI_DEBUG("%9OTR%9: Receiving message...");
+	IRSSI_DEBUG("Receiving message...");
 
 	ret = otrl_message_receiving(user_state_global->otr_state,
 		&otr_ops, irssi, accname, OTR_PROTOCOL_ID, from, msg, new_msg, &tlvs,
 		&ctx, add_peer_context_cb, irssi);
 	if (ret) {
-		IRSSI_DEBUG("%9OTR%9: Ignoring message of length %d from %s to %s.\n"
-				"%9OTR%9: %s", strlen(msg), from, accname, msg);
+		IRSSI_DEBUG("Ignoring message of length %d from %s to %s.\n"
+				"%s", strlen(msg), from, accname, msg);
 	} else {
 		if (*new_msg) {
-			IRSSI_DEBUG("%9OTR%9: Converted received message.");
+			IRSSI_DEBUG("Converted received message.");
 		}
 	}
 
@@ -598,7 +563,7 @@ int otr_receive(SERVER_REC *irssi, const char *msg, const char *from,
 	OtrlTLV *tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED);
 	if (tlv) {
 		otr_status_change(irssi, from, OTR_STATUS_PEER_FINISHED);
-		IRSSI_NOTICE(irssi, from, "%9OTR%9: %9%s%9 has finished the OTR "
+		IRSSI_NOTICE(irssi, from, "%9%s%9 has finished the OTR "
 				"conversation. If you want to continue talking enter "
 				"%9/otr finish%9 for plaintext or %9/otr init%9 to restart.",
 				from);
@@ -606,7 +571,7 @@ int otr_receive(SERVER_REC *irssi, const char *msg, const char *from,
 
 	otrl_tlv_free(tlvs);
 
-	IRSSI_DEBUG("%9OTR%9: Message received.");
+	IRSSI_DEBUG("Message received.");
 
 error:
 	free(accname);
@@ -707,7 +672,7 @@ int otr_getstatus(SERVER_REC *irssi, const char *nick)
 		code = IO_ST_FINISHED;
 		break;
 	default:
-		otr_logst(MSGLEVEL_CRAP,
+		IRSSI_INFO(irssi, nick,
 				"BUG Found! Please write us a mail and describe how you got here");
 		code = IO_ST_UNKNOWN;
 		break;
@@ -810,7 +775,7 @@ void otr_forget(SERVER_REC *irssi, const char *nick, char *str_fp,
 	struct otr_peer_context *opc;
 
 	if (!irssi && !str_fp) {
-		IRSSI_NOTICE(NULL, nick, "%9OTR%9: Need a fingerprint!");
+		IRSSI_NOTICE(NULL, nick, "Need a fingerprint!");
 		goto error;
 	}
 
@@ -830,13 +795,12 @@ void otr_forget(SERVER_REC *irssi, const char *nick, char *str_fp,
 		fp_forget = otr_find_hash_fingerprint_from_human(str_fp, ustate);
 	}
 
-	IRSSI_DEBUG("%9OTR%9: Forgetting fingerprint: %s",
-			(str_fp != NULL) ? str_fp : fp);
+	IRSSI_DEBUG("Forgetting fingerprint: %s", (str_fp != NULL) ? str_fp : fp);
 
 	if (fp_forget) {
 		/* Don't do anything if context is in encrypted state. */
 		if (fp_forget->context->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
-			IRSSI_NOTICE(irssi, nick, "%9OTR%9: Fingerprint "
+			IRSSI_NOTICE(irssi, nick, "Fingerprint "
 					"context is still encrypted. Finish the OTR "
 					"session beforehands.");
 			goto end;
@@ -847,10 +811,10 @@ void otr_forget(SERVER_REC *irssi, const char *nick, char *str_fp,
 		otrl_context_forget_fingerprint(fp_forget, 1);
 		/* Update fingerprints file. */
 		key_write_fingerprints(ustate);
-		IRSSI_NOTICE(irssi, nick, "%9OTR%9: Fingerprint %y%s%n forgotten.",
+		IRSSI_NOTICE(irssi, nick, "Fingerprint %y%s%n forgotten.",
 				fp);
 	} else {
-		IRSSI_NOTICE(irssi, nick, "%9OTR%9: Fingerprint %y%s%n NOT found",
+		IRSSI_NOTICE(irssi, nick, "Fingerprint %y%s%n NOT found",
 				(str_fp != NULL) ? str_fp : fp);
 	}
 
@@ -877,7 +841,7 @@ void otr_distrust(SERVER_REC *irssi, const char *nick, char *str_fp,
 	struct otr_peer_context *opc;
 
 	if (!irssi && !str_fp) {
-		IRSSI_NOTICE(NULL, nick, "%9OTR%9: Need a fingerprint!");
+		IRSSI_NOTICE(NULL, nick, "Need a fingerprint!");
 		goto error;
 	}
 
@@ -897,7 +861,7 @@ void otr_distrust(SERVER_REC *irssi, const char *nick, char *str_fp,
 		fp_distrust = otr_find_hash_fingerprint_from_human(str_fp, ustate);
 	}
 
-	IRSSI_DEBUG("%9OTR%9: Distrust fingerprint: %s",
+	IRSSI_DEBUG("Distrust fingerprint: %s",
 			(str_fp != NULL) ? str_fp : fp);
 
 	if (fp_distrust) {
@@ -911,10 +875,10 @@ void otr_distrust(SERVER_REC *irssi, const char *nick, char *str_fp,
 		otrl_context_set_trust(fp_distrust, "");
 		/* Update fingerprints file. */
 		key_write_fingerprints(ustate);
-		IRSSI_NOTICE(irssi, nick, "%9OTR%9: Fingerprint %y%s%n distrusted.",
+		IRSSI_NOTICE(irssi, nick, "Fingerprint %y%s%n distrusted.",
 				fp);
 	} else {
-		IRSSI_NOTICE(irssi, nick, "%9OTR%9: Fingerprint %y%s%n NOT found",
+		IRSSI_NOTICE(irssi, nick, "Fingerprint %y%s%n NOT found",
 				(str_fp != NULL) ? str_fp : fp);
 	}
 
diff --git a/src/otr.h b/src/otr.h
index 455dd4f..63fee6e 100644
--- a/src/otr.h
+++ b/src/otr.h
@@ -184,16 +184,11 @@ int otr_getstatus(SERVER_REC *irssi, const char *nick);
 
 /* user interaction */
 
-void otr_trust(SERVER_REC *irssi, char *nick,
-		const char *peername);
-void otr_finish(SERVER_REC *irssi, char *nick,
-		const char *peername, int inquery);
-void otr_auth(SERVER_REC *irssi, char *nick, const char *peername,
-		const char *question, const char *secret);
-void otr_authabort(SERVER_REC *irssi, char *nick,
-		const char *peername);
-void otr_abort_auth(ConnContext *co, SERVER_REC *irssi,
-		const char *nick);
+void otr_trust(SERVER_REC *irssi, char *nick);
+void otr_finish(SERVER_REC *irssi, char *nick);
+void otr_auth(SERVER_REC *irssi, char *nick, const char *question,
+		const char *secret);
+void otr_auth_abort(SERVER_REC *irssi, char *nick);
 struct ctxlist_ *otr_contexts(struct otr_user_state *ustate);
 void otr_finishall(struct otr_user_state *ustate);
 void otr_forget(SERVER_REC *irssi, const char *nick, char *str_fp,
diff --git a/src/utils.c b/src/utils.c
index 1268aa5..4a301dc 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -138,7 +138,7 @@ void utils_io_explode_args(const char *args, char ***argvp, char ***argv_eolp,
 	*argcp = argc;
 }
 
-void otr_log(IRC_CTX *server, const char *nick, int lvl, const char *fmt, ...)
+void otr_log(SERVER_REC *server, const char *nick, int lvl, const char *fmt, ...)
 {
 	va_list params;
 	va_start(params, fmt);
diff --git a/src/utils.h b/src/utils.h
index 2144f7f..fe2fc0d 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -32,7 +32,7 @@
 #define otr_logst(level, fmt, ...) \
 	otr_log(NULL, NULL, level, fmt, ## __VA_ARGS__)
 
-void otr_log(IRC_CTX *server, const char *to, int lvl, const char *fmt, ...);
+void otr_log(SERVER_REC *server, const char *to, int lvl, const char *fmt, ...);
 
 void utils_io_explode_args(const char *args, char ***argvp, char ***argv_eolp,
 		int *argcp);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/irssi-plugin-otr.git



More information about the Pkg-privacy-commits mailing list