[Pkg-privacy-commits] [irssi-plugin-otr] 156/267: Fix: Irssi formats of the status bar

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 12:41:38 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 3cb0aedfddcdc256ca7e46fe2cb7d8fd9d5056fb
Author: David Goulet <dgoulet at ev0ke.net>
Date:   Tue Nov 27 21:39:26 2012 -0500

    Fix: Irssi formats of the status bar
    
    Signed-off-by: David Goulet <dgoulet at ev0ke.net>
---
 src/Makefile.am   |   7 +--
 src/cmd.c         |   2 +-
 src/irssi_otr.h   |   1 -
 src/module.c      |   9 ++--
 src/otr-formats.c | 155 +++++++++++++-----------------------------------------
 src/otr-formats.h | 146 +++++++++++++-------------------------------------
 src/otr.c         |  49 ++++-------------
 src/otr.h         |  21 ++------
 8 files changed, 98 insertions(+), 292 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 86ca640..034069c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -16,9 +16,10 @@ INCLUDES = -I$(top_srcdir)/src $(IRSSI_INCLUDE)
 plugindir = $(IRSSI_MODULE_DIR)
 plugin_LTLIBRARIES = otr.la
 
-otr_la_SOURCES = key.c key.h cmd.c cmd.h otr.c otr-ops.c \
-					utils.h utils.c otr.h module.c irssi_otr.h \
-					otr-formats.c otr-formats.h
+otr_la_SOURCES = otr-formats.c otr-formats.h \
+                 key.c key.h cmd.c cmd.h otr.c otr-ops.c \
+                 utils.h utils.c otr.h module.c irssi_otr.h
+
 otr_la_LDFLAGS = -avoid-version -module
 otr_la_LDFLAGS += $(LIBOTR_LIBS) $(LIBGCRYPT_LIBS)
 
diff --git a/src/cmd.c b/src/cmd.c
index dbcd939..e02f983 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -52,7 +52,7 @@ static void _cmd_version(struct otr_user_state *ustate, SERVER_REC *irssi,
 static void _cmd_help(struct otr_user_state *ustate, SERVER_REC *irssi,
 		const char *target, const void *data)
 {
-	IRSSI_INFO(NULL, NULL, "%s", otr_help);
+	/* TODO: Add help message. */
 }
 
 /*
diff --git a/src/irssi_otr.h b/src/irssi_otr.h
index a5f0c6a..71b568e 100644
--- a/src/irssi_otr.h
+++ b/src/irssi_otr.h
@@ -30,7 +30,6 @@
 #include <src/core/queries.h>
 #include <src/fe-common/core/printtext.h>
 #include <src/fe-common/core/fe-windows.h>
-#include <src/fe-common/core/module-formats.h>
 #include <src/core/modules.h>
 #include <src/core/settings.h>
 #include <src/irc/core/irc.h>
diff --git a/src/module.c b/src/module.c
index de445d1..000746b 100644
--- a/src/module.c
+++ b/src/module.c
@@ -28,6 +28,7 @@
 
 #include "cmd.h"
 #include "otr.h"
+#include "otr-formats.h"
 #include "utils.h"
 
 static const char *signal_args_otr_event[] = {
@@ -220,14 +221,14 @@ static void otr_statusbar(struct SBAR_ITEM_REC *item, int get_size_only)
 {
 	WI_ITEM_REC *wi = active_win->active;
 	QUERY_REC *query = QUERY(wi);
-	int formatnum = 0;
+	enum otr_status_format formatnum = TXT_OTR_MODULE_NAME;
 
 	if (query && query->server && query->server->connrec) {
-		formatnum = otr_getstatus_format(query->server, query->name);
+		formatnum = otr_get_status_format(query->server, query->name);
 	}
 
 	statusbar_item_default_handler(item, get_size_only,
-			formatnum ? formats[formatnum].def : "", " ", FALSE);
+			formatnum ? otr_formats[formatnum].def : "", " ", FALSE);
 }
 
 static void read_settings(void)
@@ -253,7 +254,7 @@ void otr_init(void)
 {
 	module_register(MODULE_NAME, "core");
 
-	theme_register(formats);
+	theme_register(otr_formats);
 
 	otr_lib_init();
 
diff --git a/src/otr-formats.c b/src/otr-formats.c
index a7ff5fd..1dfda58 100644
--- a/src/otr-formats.c
+++ b/src/otr-formats.c
@@ -1,121 +1,38 @@
+/*
+ * Off-the-Record Messaging (OTR) modules for IRC
+ *
+ * Copyright (C) - 2012  David Goulet <dgoulet at ev0ke.net>
+ *
+ * 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.
+ *
+ * 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
+ */
+
 #include "otr.h"
-char *otr_help = "%9- OTR help -%9\nQuick start:  Do \"%_/load otr%_\"  (irssi syntax), write  \"%_?OTR?%_\" to your  OTR buddy,\nwait until the now ongoing key  generation finishes and write \"%_?OTR?%_\" again. You\nshould \"%_go secure%_\".\n\nKey generation happens in a separate  process and its duration mainly depends on\nthe available entropy. On  my desktop it takes about 6  Minutes, about 2 Minutes\nif I run  \"%_du /%_\" in parallel  and on an idle  server system it can  even ta [...]
-FORMAT_REC formats[] = {
-	{ MODULE_NAME, "otr", 0}
-	,
-		{ NULL, "Keys", 0 }
-	,
-		{ "kg_failed", "%9OTR%9: Key generation for $0: failed: $1 ($2)", 3, { 0, 0, 0 }},
-		{ "kg_completed", "%9OTR%9: Key generation for $0: completed in $1 seconds. Reloading keys", 2, { 0, 1 }},
-		{ "kg_aborted_dup", "%9OTR%9: Key generation for $0: aborted. Key generation for $1 still in progress", 2, { 0, 0 }},
-		{ "kg_aborted_dir", "%9OTR%9: Key generation for $0: aborted, failed creating directory $1: $2", 3, { 0, 0, 0 }},
-		{ "kg_mkdir", "%9OTR%9: created directory $0", 1, { 0 }},
-		{ "kg_pipe", "%9OTR%9: Key generation for $0: error creating pipe: $1", 2, { 0, 0 }},
-		{ "kg_fork", "%9OTR%9: Key generation for $0: fork() error: $1", 2, { 0, 0 }},
-		{ "kg_initiated", "%9OTR%9: Key generation for $0: 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.", 1, { 0 }},
-		{ "kg_exited", "%9OTR%9: Key generation for $0: child terminated for unknown reason", 1, { 0 }},
-		{ "kg_exitsig", "%9OTR%9: Key generation for $0: child was killed by signal $1", 2, { 0, 0 }},
-		{ "kg_pollerr", "%9OTR%9: Key generation for $0: error poll()ing child: $1", 2, { 0, 0 }},
-		{ "kg_abort", "%9OTR%9: Key generation for $0: aborted", 1, { 0 }},
-		{ "kg_needacc", "%9OTR%9: I need an account name. Try something like /otr genkey mynick at irc.server.net", 0},
-		{ "kg_noabort", "%9OTR%9: No ongoing key generation to abort", 0},
-		{ "key_not_found", "%9OTR%9: no private keys found", 0},
-		{ "key_loaded", "%9OTR%9: private keys loaded", 0},
-		{ "key_load_error", "%9OTR%9: Error loading private keys: $0 ($1)", 2, { 0, 0 }},
-		{ NULL, "Fingerprints", 0 }
-	,
-		{ "fp_saved", "%9OTR%9: fingerprints saved", 0},
-		{ "fp_save_error", "%9OTR%9: Error saving fingerprints: $0 ($1)", 2, { 0, 0 }},
-		{ "fp_not_found", "%9OTR%9: no fingerprints found", 0},
-		{ "fp_loaded", "%9OTR%9: fingerprints loaded", 0},
-		{ "fp_load_error", "%9OTR%9: Error loading fingerprints: $0 ($1)", 2, { 0, 0 }},
-		{ "fp_trust", "%9OTR%9: Trusting fingerprint from $0", 1, { 0 }},
-		{ NULL, "Instance Tags", 0 }
-	,
-		{ "instag_saved", "%9OTR%9: instance tags saved", 0},
-		{ "instag_save_error", "%9OTR%9: Error saving instance tags: $0 ($1)", 2, { 0, 0 }},
-		{ "instag_not_found", "%9OTR%9: no instance tags found", 0},
-		{ "instag_loaded", "%9OTR%9: instance tags loaded", 0},
-		{ "instag_load_error", "%9OTR%9: Error loading instance tags: $0 ($1)", 2, { 0, 0 }},
-		{ NULL, "Callbacks", 0 }
-	,
-		{ "ops_notify_bug", "%9OTR%9: BUG() in ops_notify", 0},
-		{ "ops_notify", "%9OTR%9: title: $0 prim: $1 sec: $2", 3, { 0, 0, 0 }},
-		{ "ops_display_bug", "%9OTR%9: BUG() in ops_display", 0},
-		{ "ops_display", "%9OTR%9: msg: $0", 1, { 0 }},
-		{ "ops_sec", "%9OTR%9: gone %9secure%9", 0},
-		{ "ops_fpcomp", "%9OTR%9: 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 described in %9/otr auth%9, or use the traditional way and compare fingerprints over a secure line (e.g. telephone) and subsequently enter %9/otr trust%9.  Your fingerprint is: $0. $1's fingerprint: $2", 3, { 0, 0, 0 }},
-		{ "ops_insec", "%9OTR%9: gone %9insecure%9", 0},
-		{ "ops_still_reply", "%9OTR%9: still %9secure%9 (is reply)", 0},
-		{ "ops_still_no_reply", "%9OTR%9: still %9secure%9 (is not reply)", 0},
-		{ "ops_log", "%9OTR%9: log msg: $0", 1, { 0 }},
-		{ "ops_inject", "%9OTR%9: Couldn't inject message from $0 for $1: $2", 3, { 0, 0, 0 }},
-		{ "ops_handle_msg", "%9OTR%9: Message event $0, msg $1", 2, { 0, 0 }},
-		{ NULL, "SendingReceiving", 0 }
-	,
-		{ "send_failed", "%9OTR%9: send failed: msg=$0", 1, { 0 }},
-		{ "send_change", "%9OTR%9: couldn't find context also OTR changed the outgoing message(BUG?)", 0},
-		{ "send_fragment", "%9OTR%9: failed to fragment message: msg=$0", 1, { 0 }},
-		{ "send_converted", "%9OTR%9: OTR converted sent message to $0", 1, { 0 }},
-		{ "receive_ignore_query", "%9OTR%9: ignoring rest of OTR default query msg", 0},
-		{ "receive_dequeued", "%9OTR%9: dequeued msg of length $0", 1, { 1 }},
-		{ "receive_queued", "%9OTR%9: queued msg of length $0", 1, { 1 }},
-		{ "receive_ignore", "%9OTR%9: ignoring protocol message of length $0, acc=$1, from=$2: $3", 4, { 1, 0, 0, 0 }},
-		{ "receive_converted", "%9OTR%9: OTR converted received message", 0},
-		{ "otr_better_two", "%9OTR%9: <b>$0</b> has requested an <a href=\"http://otr.cypherpunks.ca/\">Off-the-Record private conversation</a>.  However, you do not have a plugin to support that.", 1, { 0 }},
-		{ "otr_better_three", "%9OTR%9: See <a href=\"http://otr.cypherpunks.ca/\">http://otr.cypherpunks.ca/</a> for more information.", 0},
-		{ NULL, "Context", 0 }
-	,
-		{ "ctx_not_found", "%9OTR%9: couldn't find context: acc=$0 nick=$1", 2, { 0, 0 }},
-		{ "ctx_not_create", "%9OTR%9: couldn't create/find context: acc=$0 from=$1", 2, { 0, 0 }},
-		{ NULL, "Authentication", 0 }
-	,
-		{ "auth_aborted_ongoing", "%9OTR%9: Ongoing authentication aborted", 0},
-		{ "auth_aborted", "%9OTR%9: Authentication aborted", 0},
-		{ "auth_responding", "%9OTR%9: Responding to authentication request...", 0},
-		{ "auth_initiated", "%9OTR%9: Initiated authentication...", 0},
-		{ "auth_have_old", "%9OTR%9: $0 wanted to authenticate but an old authentication was still ongoing.  Old authentication will be aborted, please try again.", 1, { 0 }},
-		{ "auth_peer", "%9OTR%9: $0 wants to authenticate. Type /otr auth <your-shared-secret> to complete.", 1, { 0 }},
-		{ "auth_peer_qa", "%9OTR%9: $0 wants to authenticate and asked you \"$1\". Type /otr auth <answer> to complete.", 2, { 0, 0 }},
-		{ "auth_peer_reply_wrong", "%9OTR%9: $0 replied to an auth we didn't start.", 1, { 0 }},
-		{ "auth_peer_replied", "%9OTR%9: $0 replied to our auth request...", 1, { 0 }},
-		{ "auth_peer_wrong_smp3", "%9OTR%9: $0 sent a wrong authentication message (SMP3).", 1, { 0 }},
-		{ "auth_peer_wrong_smp4", "%9OTR%9: $0 sent a wrong authentication message (SMP4).", 1, { 0 }},
-		{ "auth_successful", "%9OTR%9: %GAuthentication successful!%n", 0},
-		{ "auth_failed", "%9OTR%9: %RAuthentication failed!%n", 0},
-		{ "auth_needenc", "%9OTR%9: You need to establish an OTR session before you can authenticate.", 0},
-		{ NULL, "Commands", 0 }
-	,
-		{ "cmd_otr", "%9OTR%9: We're alive", 0},
-		{ "cmd_qnotfound", "%9OTR%9: Failed: Can't get nick and server of current query window. (Or maybe you're doing this in the status window?)", 0},
-		{ "cmd_auth", "%9OTR%9: Please agree on a secret with your peer and then initiate the authentication with /otr auth <secret> or let him initiate. Should you initiate your peer will after a little while be instructed to enter the secret as well. Once he has done so the authentication will finish up. Should you have both typed in the same secret the authentication should be successful.", 0},
-		{ "cmd_debug_on", "%9OTR%9: Debug mode is on", 0},
-		{ "cmd_debug_off", "%9OTR%9: Debug mode is off", 0},
-		{ "cmd_finish", "%9OTR%9: Finished conversation with $0@$1.", 2, { 0, 0 }},
-		{ "cmd_finishall_none", "%9OTR%9: No conversations to finish.", 0},
-		{ "cmd_version", "%9OTR%9: This is irc-otr version $0", 1, { 0 }},
-		{ "peer_finished", "%9OTR%9: $0 has finished the OTR conversation. If you want to continue talking enter %9/otr finish%9 for plaintext or ?OTR? to restart OTR.", 1, { 0 }},
-		{ NULL, "Contexts", 0 }
-	,
-		{ "ctx_ctx_unencrypted", "%9$[20]0%9    $[30]1    plaintext", 2, { 0, 0 }},
-		{ "ctx_ctx_encrypted", "%9$[20]0%9    $[30]1    %gencrypted%n", 2, { 0, 0 }},
-		{ "ctx_ctx_finished", "%9$[20]0%9    $[30]1    finished", 2, { 0, 0 }},
-		{ "ctx_ctx_unknown", "%9$[20]0%9    $[30]1    unknown state(BUG?)", 2, { 0, 0 }},
-		{ "ctx_fps_no", "$0 %rnot authenticated%n", 1, { 0 }},
-		{ "ctx_fps_smp", "$0 %gauthenticated%n via shared secret (SMP)", 1, { 0 }},
-		{ "ctx_fps_man", "$0 %gauthenticated%n manually", 1, { 0 }},
-		{ "ctx_noctxs", "No active OTR contexts found", 0},
-		{ NULL, "Statusbar", 0 }
-	,
-		{ "st_plaintext", "{sb plaintext}", 0},
-		{ "st_untrusted", "{sb %GOTR%n (%runverified%n)}", 0},
-		{ "st_trust_smp", "{sb %GOTR%n}", 0},
-		{ "st_trust_manual", "{sb %GOTR%n}", 0},
-		{ "st_smp_incoming", "{sb {%GOTR%n %9Auth requested%9}}", 0},
-		{ "st_smp_outgoing", "{sb {%GOTR%n %9Waiting auth reply%9}}", 0},
-		{ "st_smp_finalize", "{sb {%GOTR%n %9Finalizing auth%9}}", 0},
-		{ "st_smp_unknown", "{sb {hilight unknown auth state!}}", 0},
-		{ "st_finished", "{sb %yfinished%n}", 0},
-		{ "st_unknown", "{sb {hilight state unknown (BUG!)}}", 0},
-		{ NULL, NULL, 0 }
+#include "otr-formats.h"
+
+FORMAT_REC otr_formats[] = {
+	{ MODULE_NAME, "OTR", 0 },
+
+	/* Status bar format. */
+	{ NULL, "Statusbar", 0 } ,
+
+	{ "stb_plaintext", "{sb plaintext}", 0},
+	{ "stb_finished", "{sb %yfinished%n}", 0},
+	{ "stb_unknown", "{sb {hilight state unknown (BUG!)}}", 0},
+	{ "stb_untrusted", "{sb %GOTR%n (%runverified%n)}", 0},
+	{ "stb_trust", "{sb %GOTR%n}", 0},
+
+	/* Last element. */
+	{ NULL, NULL, 0 }
 };
diff --git a/src/otr-formats.h b/src/otr-formats.h
index b1adacb..778f476 100644
--- a/src/otr-formats.h
+++ b/src/otr-formats.h
@@ -1,111 +1,41 @@
-extern char *otr_help;
+/*
+ * Off-the-Record Messaging (OTR) modules for IRC
+ *
+ * Copyright (C) - 2012  David Goulet <dgoulet at ev0ke.net>
+ *
+ * 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.
+ *
+ * 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
+ */
 
-enum {
-TXT_OTR_MODULE_NAME,
-TXT_OTR_FILL_0,
-TXT_KG_FAILED,
-TXT_KG_COMPLETED,
-TXT_KG_ABORTED_DUP,
-TXT_KG_ABORTED_DIR,
-TXT_KG_MKDIR,
-TXT_KG_PIPE,
-TXT_KG_FORK,
-TXT_KG_INITIATED,
-TXT_KG_EXITED,
-TXT_KG_EXITSIG,
-TXT_KG_POLLERR,
-TXT_KG_ABORT,
-TXT_KG_NEEDACC,
-TXT_KG_NOABORT,
-TXT_KEY_NOT_FOUND,
-TXT_KEY_LOADED,
-TXT_KEY_LOAD_ERROR,
-TXT_OTR_FILL_1,
-TXT_FP_SAVED,
-TXT_FP_SAVE_ERROR,
-TXT_FP_NOT_FOUND,
-TXT_FP_LOADED,
-TXT_FP_LOAD_ERROR,
-TXT_FP_TRUST,
-TXT_OTR_FILL_2,
-TXT_INSTAG_SAVED,
-TXT_INSTAG_SAVE_ERROR,
-TXT_INSTAG_NOT_FOUND,
-TXT_INSTAG_LOADED,
-TXT_INSTAG_LOAD_ERROR,
-TXT_OTR_FILL_3,
-TXT_OPS_NOTIFY_BUG,
-TXT_OPS_NOTIFY,
-TXT_OPS_DISPLAY_BUG,
-TXT_OPS_DISPLAY,
-TXT_OPS_SEC,
-TXT_OPS_FPCOMP,
-TXT_OPS_INSEC,
-TXT_OPS_STILL_REPLY,
-TXT_OPS_STILL_NO_REPLY,
-TXT_OPS_LOG,
-TXT_OPS_INJECT,
-TXT_OPS_HANDLE_MSG,
-TXT_OTR_FILL_4,
-TXT_SEND_FAILED,
-TXT_SEND_CHANGE,
-TXT_SEND_FRAGMENT,
-TXT_SEND_CONVERTED,
-TXT_RECEIVE_IGNORE_QUERY,
-TXT_RECEIVE_DEQUEUED,
-TXT_RECEIVE_QUEUED,
-TXT_RECEIVE_IGNORE,
-TXT_RECEIVE_CONVERTED,
-TXT_OTR_BETTER_TWO,
-TXT_OTR_BETTER_THREE,
-TXT_OTR_FILL_5,
-TXT_CTX_NOT_FOUND,
-TXT_CTX_NOT_CREATE,
-TXT_OTR_FILL_6,
-TXT_AUTH_ABORTED_ONGOING,
-TXT_AUTH_ABORTED,
-TXT_AUTH_RESPONDING,
-TXT_AUTH_INITIATED,
-TXT_AUTH_HAVE_OLD,
-TXT_AUTH_PEER,
-TXT_AUTH_PEER_QA,
-TXT_AUTH_PEER_REPLY_WRONG,
-TXT_AUTH_PEER_REPLIED,
-TXT_AUTH_PEER_WRONG_SMP3,
-TXT_AUTH_PEER_WRONG_SMP4,
-TXT_AUTH_SUCCESSFUL,
-TXT_AUTH_FAILED,
-TXT_AUTH_NEEDENC,
-TXT_OTR_FILL_7,
-TXT_CMD_OTR,
-TXT_CMD_QNOTFOUND,
-TXT_CMD_AUTH,
-TXT_CMD_DEBUG_ON,
-TXT_CMD_DEBUG_OFF,
-TXT_CMD_FINISH,
-TXT_CMD_FINISHALL_NONE,
-TXT_CMD_VERSION,
-TXT_PEER_FINISHED,
-TXT_OTR_FILL_8,
-TXT_CTX_CTX_UNENCRYPTED,
-TXT_CTX_CTX_ENCRYPTED,
-TXT_CTX_CTX_FINISHED,
-TXT_CTX_CTX_UNKNOWN,
-TXT_CTX_FPS_NO,
-TXT_CTX_FPS_SMP,
-TXT_CTX_FPS_MAN,
-TXT_CTX_NOCTXS,
-TXT_OTR_FILL_9,
-TXT_ST_PLAINTEXT,
-TXT_ST_UNTRUSTED,
-TXT_ST_TRUST_SMP,
-TXT_ST_TRUST_MANUAL,
-TXT_ST_SMP_INCOMING,
-TXT_ST_SMP_OUTGOING,
-TXT_ST_SMP_FINALIZE,
-TXT_ST_SMP_UNKNOWN,
-TXT_ST_FINISHED,
-TXT_ST_UNKNOWN
+#ifndef IRSSI_OTR_FORMATS_H
+#define IRSSI_OTR_FORMATS_H
+
+#include "irssi_otr.h"
+
+/*
+ * Must be in sync with the otr_formats array.
+ */
+enum otr_status_format {
+	TXT_OTR_MODULE_NAME      = 0,
+	TXT_OTR_FILL_1           = 1,
+	TXT_STB_PLAINTEXT        = 2,
+	TXT_STB_FINISHED         = 3,
+	TXT_STB_UNKNOWN          = 4,
+	TXT_STB_UNTRUSTED        = 5,
+	TXT_STB_TRUST            = 6,
 };
 
-extern FORMAT_REC formats[];
+extern FORMAT_REC otr_formats[];
+
+#endif /* IRSSI_OTR_FORMATS_H */
diff --git a/src/otr.c b/src/otr.c
index 489f225..44f6006 100644
--- a/src/otr.c
+++ b/src/otr.c
@@ -24,6 +24,7 @@
 #include <gcrypt.h>
 #include <unistd.h>
 
+#include "otr-formats.h"
 #include "key.h"
 
 static const char *statusbar_txt[] = {
@@ -728,39 +729,41 @@ void otr_setpolicies(struct otr_user_state *ustate, const char *policies, int kn
 /*
  * Get the OTR status of this conversation.
  */
-int otr_getstatus(SERVER_REC *irssi, const char *nick)
+enum otr_status_format otr_get_status_format(SERVER_REC *irssi,
+		const char *nick)
 {
-	int ret, code = 0;
+	int ret;
+	enum otr_status_format code;
 	ConnContext *ctx = NULL;
 
 	assert(irssi);
 
 	ctx = otr_find_context(irssi, nick, FALSE);
 	if (!ctx) {
-		code = IO_ST_PLAINTEXT;
+		code = TXT_STB_PLAINTEXT;
 		goto end;
 	}
 
 	switch (ctx->msgstate) {
 	case OTRL_MSGSTATE_PLAINTEXT:
-		code = IO_ST_PLAINTEXT;
+		code = TXT_STB_PLAINTEXT;
 		break;
 	case OTRL_MSGSTATE_ENCRYPTED:
 		/* Begin by checking trust. */
 		ret = otrl_context_is_fingerprint_trusted(ctx->active_fingerprint);
 		if (ret) {
-			code = IO_ST_TRUST_SMP;
+			code = TXT_STB_TRUST;
 		} else {
-			code = IO_ST_UNTRUSTED;
+			code = TXT_STB_UNTRUSTED;
 		}
 		break;
 	case OTRL_MSGSTATE_FINISHED:
-		code = IO_ST_FINISHED;
+		code = TXT_STB_FINISHED;
 		break;
 	default:
 		IRSSI_WARN(irssi, nick, "BUG Found! "
 				"Please write us a mail and describe how you got here");
-		code = IO_ST_UNKNOWN;
+		code = TXT_STB_UNKNOWN;
 		break;
 	}
 
@@ -773,36 +776,6 @@ end:
 	return code;
 }
 
-
-/*
- * Get a format describing the OTR status of this conversation.
- */
-int otr_getstatus_format(SERVER_REC *irssi, const char *nick)
-{
-	int status = otr_getstatus(irssi, nick);
-
-	switch (status) {
-	case IO_ST_PLAINTEXT:
-		return TXT_ST_PLAINTEXT;
-	case IO_ST_FINISHED:
-		return TXT_ST_FINISHED;
-	case IO_ST_UNTRUSTED:
-		return TXT_ST_UNTRUSTED;
-	case IO_ST_SMP_INCOMING:
-		return TXT_ST_SMP_INCOMING;
-	case IO_ST_SMP_OUTGOING:
-		return TXT_ST_SMP_OUTGOING;
-	case IO_ST_SMP_FINALIZE:
-		return TXT_ST_SMP_FINALIZE;
-	case IO_ST_TRUST_MANUAL:
-		return TXT_ST_TRUST_MANUAL;
-	case IO_ST_TRUST_SMP:
-		return TXT_ST_TRUST_SMP;
-	default:
-		return TXT_ST_SMP_UNKNOWN;
-	}
-}
-
 /*
  * Change status bar text for a given nickname.
  */
diff --git a/src/otr.h b/src/otr.h
index 704b13c..45c7ca5 100644
--- a/src/otr.h
+++ b/src/otr.h
@@ -32,8 +32,6 @@
 /* irssi module name */
 #define MODULE_NAME "otr"
 
-#include "otr-formats.h"
-
 /*
  * XXX: Maybe this should be configurable?
  */
@@ -82,19 +80,6 @@ struct otr_peer_context {
 	Fingerprint *active_fingerprint;
 };
 
-/* returned by otr_getstatus */
-enum otr_status {
-	IO_ST_PLAINTEXT        = 0,
-	IO_ST_FINISHED         = 1,
-	IO_ST_SMP_INCOMING     = 2,
-	IO_ST_SMP_OUTGOING     = 3,
-	IO_ST_SMP_FINALIZE     = 4,
-	IO_ST_UNKNOWN          = 5,
-	IO_ST_UNTRUSTED        = 6,
-	IO_ST_TRUST_MANUAL     = 7,
-	IO_ST_TRUST_SMP        = 8,
-};
-
 /* given to otr_status_change */
 enum otr_status_event {
 	OTR_STATUS_FINISHED,
@@ -153,8 +138,6 @@ int otr_send(SERVER_REC *irssi, const char *msg, const char *to,
 int otr_receive(SERVER_REC *irssi, const char *msg,
 		const char *from, char **new_msg);
 
-int otr_getstatus(SERVER_REC *irssi, const char *nick);
-
 /* user interaction */
 
 void otr_finish(SERVER_REC *irssi, const char *nick);
@@ -170,7 +153,9 @@ void otr_distrust(SERVER_REC *irssi, const char *nick, char *str_fp,
 void otr_trust(SERVER_REC *irssi, const char *nick, char *str_fp,
 		struct otr_user_state *ustate);
 
-int otr_getstatus_format(SERVER_REC *irssi, const char *nick);
+enum otr_status_format otr_get_status_format(SERVER_REC *irssi,
+		const char *nick);
+
 struct otr_peer_context *otr_create_peer_context(void);
 ConnContext *otr_find_context(SERVER_REC *irssi, const char *nick, int create);
 Fingerprint *otr_find_hash_fingerprint_from_human(const char *human_fp,

-- 
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