[Pkg-privacy-commits] [irssi-plugin-otr] 121/267: Add ask_secret variable to peer context

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 8c72ed7a67031b1d1b9621ae6ee6f7a74b240679
Author: David Goulet <dgoulet at ev0ke.net>
Date:   Thu Nov 8 18:17:31 2012 -0500

    Add ask_secret variable to peer context
    
    Fix some output message formating and small things here and there.
    
    Signed-off-by: David Goulet <dgoulet at ev0ke.net>
---
 src/cmd.c     |  2 ++
 src/key.c     |  2 +-
 src/key.h     |  2 +-
 src/otr-ops.c | 65 ++++++++++++++++++++++++++++++++++-------------------------
 src/otr.c     |  6 ++++--
 src/otr.h     |  1 +
 6 files changed, 46 insertions(+), 32 deletions(-)

diff --git a/src/cmd.c b/src/cmd.c
index bab2439..03a1dea 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -228,6 +228,8 @@ static void _cmd_init(struct otr_user_state *ustate, SERVER_REC *irssi, int argc
 		goto end;
 	}
 
+	IRSSI_NOTICE(irssi, target, "%9OTR%9: Initiating OTR session...");
+
 	msg = otrl_proto_default_query_msg(target, OTRL_POLICY_DEFAULT);
 	irssi_send_message(irssi, target, msg ? msg : "?OTRv23?");
 	free(msg);
diff --git a/src/key.c b/src/key.c
index 0e353d3..7bdf24c 100644
--- a/src/key.c
+++ b/src/key.c
@@ -282,7 +282,7 @@ error_filename:
 /*
  * Write instance tags to file.
  */
-void otr_writeinstags(struct otr_user_state *ustate)
+void key_write_instags(struct otr_user_state *ustate)
 {
 	gcry_error_t err;
 	char *filename;
diff --git a/src/key.h b/src/key.h
index 70d3d42..4facb51 100644
--- a/src/key.h
+++ b/src/key.h
@@ -28,6 +28,6 @@ void key_generation_run(struct otr_user_state *ustate, const char *accname);
 void key_load(struct otr_user_state *ustate);
 void key_load_fingerprints(struct otr_user_state *ustate);
 void key_write_fingerprints(struct otr_user_state *ustate);
-void otr_writeinstags(struct otr_user_state *ustate);
+void key_write_instags(struct otr_user_state *ustate);
 
 #endif /* IRSSI_OTR_KEY_H */
diff --git a/src/otr-ops.c b/src/otr-ops.c
index c989495..5cfb6f5 100644
--- a/src/otr-ops.c
+++ b/src/otr-ops.c
@@ -133,10 +133,11 @@ static void ops_secure(void *opdata, ConnContext *context)
 
 	IRSSI_NOTICE(irssi, context->username, "%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, recommended, use %9/otr authq [QUESTION] SECRET%9 "
-			"or use the traditional way and compare fingerprints "
-			"(e.g. telephone) and subsequently enter %9/otr trust%9.");
+			"either agree on a secret and use the authentication command "
+			"%9/otr auth%9 or %9/otr authq [QUESTION] SECRET%9. You can also "
+			"use the traditional way and compare fingerprints "
+			"(e.g. telephone or GPG-signed mail) and subsequently enter "
+			"%9/otr trust%9.");
 
 	IRSSI_NOTICE(irssi, context->username,
 			"%9OTR%9: Your fingerprint is: %y%s\%n.\n"
@@ -159,17 +160,6 @@ static void ops_insecure(void *opdata, ConnContext *context)
 }
 
 /*
- * Still secure? Need to find out what that means...
- */
-static void ops_still_secure(void *opdata, ConnContext *context, int is_reply)
-{
-	SERVER_REC *irssi = opdata;
-
-	otr_notice(irssi, context->username,
-			is_reply ?  TXT_OPS_STILL_REPLY : TXT_OPS_STILL_NO_REPLY);
-}
-
-/*
  * Really critical with IRC. Unfortunately, we can't tell our peer which size
  * to use.
  */
@@ -247,7 +237,7 @@ static void ops_handle_msg_event(void *opdata, OtrlMessageEvent msg_event,
 	case OTRL_MSGEVENT_RCVDMSG_UNENCRYPTED:
 		IRSSI_NOTICE(server, username,
 				"%9OTR:%9 The following message from %9%s%9 was NOT "
-				"encrypted: [%s]", username, message);
+				"encrypted.", username);
 		/*
 		 * This is a hack I found to send the message in a private window of
 		 * the username without creating an infinite loop since the 'message
@@ -290,10 +280,21 @@ static void ops_write_fingerprints(void *data)
 static int ops_is_logged_in(void *opdata, const char *accountname,
 		const char *protocol, const char *recipient)
 {
-	/*TODO register a handler for event 401 no such nick and set
-	 * a variable offline=TRUE. Reset it to false in otr_receive and
-	 * otr_send */
-	return TRUE;
+	int ret;
+	SERVER_REC *irssi = opdata;
+
+	if (irssi) {
+		/* Logged in */
+		ret = 1;
+	} else {
+		/* Not */
+		ret = 0;
+	}
+
+	IRSSI_DEBUG("%9OTR%9: User %s %s logged in", accountname,
+			(ret == 0) ? "not" : "");
+
+	return ret;
 }
 
 static void ops_create_instag(void *opdata, const char *accountname,
@@ -301,7 +302,7 @@ static void ops_create_instag(void *opdata, const char *accountname,
 {
 	otrl_instag_generate(user_state_global->otr_state, "/dev/null",
 			accountname, protocol);
-	otr_writeinstags(user_state_global);
+	key_write_instags(user_state_global);
 }
 
 static void ops_smp_event(void *opdata, OtrlSMPEvent smp_event,
@@ -323,19 +324,26 @@ static void ops_smp_event(void *opdata, OtrlSMPEvent smp_event,
 
 	switch (smp_event) {
 	case OTRL_SMPEVENT_ASK_FOR_SECRET:
-		otr_notice(irssi, from, TXT_AUTH_PEER, from);
+		IRSSI_NOTICE(irssi, from, "%9OTR%9: %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:
-		otr_notice(irssi, from, TXT_AUTH_PEER_QA, from, question);
+		IRSSI_NOTICE(irssi, from, "%9OTR%9: %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,
+				question);
+		opc->ask_secret = 1;
 		otr_status_change(irssi, from, OTR_STATUS_SMP_INCOMING);
 		break;
 	case OTRL_SMPEVENT_IN_PROGRESS:
-		otr_notice(irssi, from, TXT_AUTH_PEER_REPLIED, from);
+		IRSSI_NOTICE(irssi, from, "%9OTR%9: %9%s%9 replied to our auth request",
+				from);
 		otr_status_change(irssi, from, OTR_STATUS_SMP_FINALIZE);
 		break;
 	case OTRL_SMPEVENT_SUCCESS:
-		otr_notice(irssi, from, TXT_AUTH_SUCCESSFUL);
+		IRSSI_NOTICE(irssi, from, "%9OTR%9: %GAuthentication successful%n");
 		otr_status_change(irssi, from, OTR_STATUS_SMP_SUCCESS);
 		break;
 	case OTRL_SMPEVENT_ABORT:
@@ -345,11 +353,12 @@ static void ops_smp_event(void *opdata, OtrlSMPEvent smp_event,
 	case OTRL_SMPEVENT_FAILURE:
 	case OTRL_SMPEVENT_CHEATED:
 	case OTRL_SMPEVENT_ERROR:
-		otr_notice(irssi, from, TXT_AUTH_FAILED);
+		IRSSI_NOTICE(irssi, from, "%9OTR%9: %RAuthentication failed%n");
 		otr_status_change(irssi, from, OTR_STATUS_SMP_FAILED);
 		break;
 	default:
-		otr_logst(MSGLEVEL_CRAP, "Received unknown SMP event");
+		IRSSI_NOTICE(irssi, from, "%9OTR%9: Received unknown SMP event. "
+			"Ignoring");
 		break;
 	}
 }
@@ -367,7 +376,7 @@ OtrlMessageAppOps otr_ops = {
 	ops_write_fingerprints,
 	ops_secure,
 	ops_insecure,
-	ops_still_secure,
+	NULL, /* still_secure */
 	ops_max_msg,
 	NULL, /* accoun_name */
 	NULL, /* account_name_free */
diff --git a/src/otr.c b/src/otr.c
index 9e76add..30b14af 100644
--- a/src/otr.c
+++ b/src/otr.c
@@ -541,7 +541,7 @@ void otr_auth(SERVER_REC *irssi, char *nick, const char *peername,
 		}
 	}
 
-	if (opc->smp_event == OTRL_SMPEVENT_ASK_FOR_SECRET) {
+	if (opc->ask_secret) {
 		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);
@@ -560,6 +560,8 @@ void otr_auth(SERVER_REC *irssi, char *nick, const char *peername,
 		IRSSI_NOTICE(irssi, nick, "%9OTR%9: Initiated authentication...");
 	}
 
+	opc->ask_secret = 0;
+
 end:
 	free(accname);
 	return;
@@ -606,7 +608,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: %s has finished the OTR "
+		IRSSI_NOTICE(irssi, from, "%9OTR%9: %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);
diff --git a/src/otr.h b/src/otr.h
index 7586ed9..68fb338 100644
--- a/src/otr.h
+++ b/src/otr.h
@@ -80,6 +80,7 @@ struct otr_user_state {
  */
 struct otr_peer_context {
 	OtrlSMPEvent smp_event;
+	unsigned int ask_secret;
 };
 
 /* these are returned by /otr contexts */

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