[Pkg-privacy-commits] [irssi-plugin-otr] 80/267: Added preliminary support for libotr version 4.

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 12:41:30 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 c7d3dca216ac5f063dd08c2623dc2a03d2ec3846
Author: Uli Meis <a.sporto+bee at gmail.com>
Date:   Tue Sep 11 15:32:30 2012 +0200

    Added preliminary support for libotr version 4.
    
    * new command /otr authq <question> <secret> for q&a auth
---
 CMakeLists.txt |   4 +++
 formats.txt    |   8 +++++
 io-config.h.in |   1 +
 io_util.c      |  72 ++++++++++++++++++++++++++++++++-----
 otr.h          |  14 +++++++-
 otr_key.c      |  56 ++++++++++++++++++++++++++---
 otr_ops.c      |  97 ++++++++++++++++++++++++++++++++++++++++++++++++--
 otr_util.c     | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
 8 files changed, 332 insertions(+), 29 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7754ddd..38090e1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -93,6 +93,10 @@ FIND_PACKAGE(LibOTR REQUIRED)
 IF (LIBOTR_VERSION LESS "3.1.0")
   MESSAGE(FATAL_ERROR "Need libotr version >= 3.1.0 (fragmentation)")
 ENDIF (LIBOTR_VERSION LESS "3.1.0")
+IF (LIBOTR_VERSION LESS "4.0.0")
+  MESSAGE(STATUS "libotr<4, no Q&A authentication support")
+  SET(LIBOTR3 ON)
+ENDIF (LIBOTR_VERSION LESS "4.0.0")
 
 # LIBGCRYPT. A dependency of libotr and therefore one of ours.
 
diff --git a/formats.txt b/formats.txt
index 9778174..2afeb38 100644
--- a/formats.txt
+++ b/formats.txt
@@ -23,6 +23,12 @@ fp_not_found	no fingerprints found
 fp_loaded	fingerprints loaded
 fp_load_error	Error loading fingerprints: %s (%s)
 fp_trust	Trusting fingerprint from %s
+Instance Tags
+instag_saved	instance tags saved
+instag_save_error	Error saving instance tags: %s (%s)
+instag_not_found	no instance tags found
+instag_loaded	instance tags loaded
+instag_load_error	Error loading instance tags: %s (%s)
 Callbacks
 ops_notify_bug	BUG() in ops_notify
 ops_notify	title: %s prim: %s sec: %s
@@ -35,6 +41,7 @@ ops_still_reply	still %%9secure%9 (is reply)
 ops_still_no_reply	still %%9secure%9 (is not reply)
 ops_log	log msg: %s
 ops_inject	Couldn't inject message from %s for %s: %s
+ops_handle_msg	Message event %s, msg %s
 SendingReceiving
 send_failed	send failed: msg=%s
 send_change	couldn't find context also OTR changed the outgoing message(BUG?)
@@ -57,6 +64,7 @@ auth_responding	Responding to authentication request...
 auth_initiated	Initiated authentication...
 auth_have_old	%s wanted to authenticate but an old authentication was still ongoing.  Old authentication will be aborted, please try again.
 auth_peer	%s wants to authenticate. Type /otr auth <your-shared-secret> to complete.
+auth_peer_qa	%s wants to authenticate and asked you \"%s\". Type /otr auth <answer> to complete.
 auth_peer_reply_wrong	%s replied to an auth we didn't start.
 auth_peer_replied	%s replied to our auth request...
 auth_peer_wrong_smp3	%s sent a wrong authentication message (SMP3).
diff --git a/io-config.h.in b/io-config.h.in
index a753af6..d3cc4e8 100644
--- a/io-config.h.in
+++ b/io-config.h.in
@@ -1,3 +1,4 @@
 #cmakedefine HAVE_STRSIGNAL
 #cmakedefine HAVE_GREGEX_H
+#cmakedefine LIBOTR3
 #define IRCOTR_VERSION "${IRCOTR_VERSION}"
diff --git a/io_util.c b/io_util.c
index b347950..ca021f8 100644
--- a/io_util.c
+++ b/io_util.c
@@ -37,6 +37,25 @@ char *otr_status_txt[] = {
 	"CTX_UPDATE"
 };
 
+char *otr_msg_event_txt[] = {
+	"NONE",
+	"ENCRYPTION_REQUIRED",
+	"ENCRYPTION_ERROR",
+	"CONNECTION_ENDED",
+	"SETUP_ERROR",
+	"MSG_REFLECTED",
+	"MSG_RESENT",
+	"RCVDMSG_NOT_IN_PRIVATE",
+	"RCVDMSG_UNREADABLE",
+	"RCVDMSG_MALFORMED",
+	"LOG_HEARTBEAT_RCVD",
+	"LOG_HEARTBEAT_SENT",
+	"RCVDMSG_GENERAL_ERR",
+	"RCVDMSG_UNENCRYPTED",
+	"RCVDMSG_UNRECOGNIZED",
+	"RCVDMSG_FOR_OTHER_INSTANCE"
+};
+
 int extract_nick(char *nick, char *line)
 {
 	char *excl;
@@ -141,18 +160,50 @@ void cmd_genkey(IOUSTATE *ioustate, IRC_CTX *ircctx, int argc, char *argv[], cha
 	}
 }
 
-void cmd_auth(IOUSTATE *ioustate, IRC_CTX *ircctx, int argc, char *argv[], char *argv_eol[],
-	     char *target) {
-	if (!argc) {
+void _cmd_auth(IOUSTATE *ioustate, IRC_CTX *ircctx, int argc, char *argv[], char *argv_eol[],
+	       char *target, int qanda) {
+	char *accountname = NULL;
+	char *question = NULL;
+	char *secret;
+
+	/* have args? */
+	if (argc<(qanda ? 2 : 1)) {
 		otr_notice(ircctx,target,
 			   TXT_CMD_AUTH);
-	} else if ((argc>1)&&strchr(argv[0],'@')) {
-	    otr_auth(NULL,NULL,argv[0],argv[1]);
-	} else if (ircctx&&target) {
-		otr_auth(ircctx,target,NULL,argv_eol[0]);
-	} else {
-		otr_noticest(TXT_CMD_QNOTFOUND);
+		return;
+	}
+
+	/* have buddy? */
+	if (!(ircctx&&target)) {
+		accountname = strchr(argv[0],'@');
+		if (!accountname) {
+			otr_noticest(TXT_CMD_QNOTFOUND);
+			return;
+		}
+		ircctx = NULL;
+		target = NULL;
+		argv++;argv_eol++;argc--;
 	}
+
+	/* have question? */
+	if (qanda) {
+		question = argv[0];
+		argv++;argv_eol++;argc--;
+	}
+
+	secret  = argv_eol[0];
+
+	otr_auth(ircctx,target,accountname,question,secret);
+}
+
+void cmd_authq(IOUSTATE *ioustate, IRC_CTX *ircctx, int argc, char *argv[], char *argv_eol[],
+	     char *target) {
+	_cmd_auth(ioustate,ircctx,argc,argv,argv_eol,target,TRUE);
+}
+
+void cmd_auth(IOUSTATE *ioustate, IRC_CTX *ircctx, int argc, char *argv[], char *argv_eol[],
+	     char *target) {
+	_cmd_auth(ioustate,ircctx,argc,argv,argv_eol,target,FALSE);
 }
 
 /*
@@ -199,6 +250,9 @@ struct _cmds cmds[] = {
 	{ "trust", cmd_trust },
 	{ "authabort", cmd_authabort },
 	{ "auth", cmd_auth },
+#ifndef LIBOTR3
+	{ "authq", cmd_authq },
+#endif
 	{ "genkey", cmd_genkey },
 	{ "contexts", cmd_contexts },
 	{ NULL, NULL },
diff --git a/otr.h b/otr.h
index d6041f5..d7375ca 100644
--- a/otr.h
+++ b/otr.h
@@ -105,6 +105,7 @@ void otr_log(IRC_CTX *server, const char *to,
 #define KEYFILE    "/otr/otr.key"
 #define TMPKEYFILE "/otr/otr.key.tmp"
 #define FPSFILE    "/otr/otr.fp"
+#define INSTAGFILE "/otr/otr.instag"
 
 /* some defaults */
 #define IO_DEFAULT_POLICY "*@localhost opportunistic,*bitlbee* opportunistic,*@im.* opportunistic, *serv at irc* never"
@@ -174,6 +175,9 @@ enum {
 	IO_STC_CTX_UPDATE
 };
 
+/* libotr4 handle_msg_event */
+extern char *otr_msg_event_txt[];
+
 /* the above as text for scripting */
 extern char *otr_status_txt[];
 
@@ -211,8 +215,10 @@ ConnContext *otr_getcontext(const char *accname,const char *nick,int create,IRC_
 
 void otr_trust(IRC_CTX *server, char *nick, const char *peername);
 void otr_finish(IRC_CTX *server, char *nick, const char *peername, int inquery);
-void otr_auth(IRC_CTX *server, char *nick, const char *peername, const char *secret);
+void otr_auth(IRC_CTX *server, char *nick, const char *peername,
+	      const char *question, const char *secret);
 void otr_authabort(IRC_CTX *server, char *nick, const char *peername);
+void otr_abort_auth(ConnContext *co, IRC_CTX *ircctx, const char *nick);
 struct ctxlist_ *otr_contexts(IOUSTATE *ioustate);
 void otr_finishall(IOUSTATE *ioustate);
 
@@ -225,6 +231,12 @@ void key_load(IOUSTATE *ioustate);
 void fps_load(IOUSTATE *ioustate);
 void otr_writefps(IOUSTATE *ioustate);
 
+#ifndef LIBOTR3
+/* instance tags */
+void instag_load(IOUSTATE *ioustate);
+void otr_writeinstags(IOUSTATE *ioustate);
+#endif
+
 int extract_nick(char *nick, char *line);
 
 struct _cmds {
diff --git a/otr_key.c b/otr_key.c
index 85e137f..2646294 100644
--- a/otr_key.c
+++ b/otr_key.c
@@ -139,8 +139,8 @@ void keygen_run(IOUSTATE *ioustate, const char *accname)
 	gcry_error_t err;
 	int ret;
 	int fds[2];
-	char *filename = g_strconcat(get_client_config_dir(),TMPKEYFILE,NULL);
-	char *dir = dirname(g_strdup(filename));
+	char *filename = g_strconcat(get_client_config_dir(),TMPKEYFILE,NULL), *filenamedup = g_strdup(filename);
+	char *dir = dirname(filenamedup);
 
 	if (kg_st.status!=KEYGEN_NO) {
 		if (strcmp(accname,kg_st.accountname)!=0)
@@ -159,7 +159,7 @@ void keygen_run(IOUSTATE *ioustate, const char *accname)
 		} else
 			otr_noticest(TXT_KG_MKDIR,dir);
 	}
-	g_free(dir);
+	g_free(filenamedup);
 
 	if (pipe(fds) != 0) {
 		otr_noticest(TXT_KG_PIPE,
@@ -203,7 +203,7 @@ void keygen_run(IOUSTATE *ioustate, const char *accname)
 	err = otrl_privkey_generate(ioustate->otr_state,filename,accname,PROTOCOLID);
 	write(fds[1],&err,sizeof(err));
 
-	//g_free(filename);
+	g_free(filename);
 	_exit(0);
 }
 
@@ -252,6 +252,28 @@ void otr_writefps(IOUSTATE *ioustate)
 	g_free(filename);
 }
 
+#ifndef LIBOTR3
+/* 
+ * Write instance tags to file.
+ */
+void otr_writeinstags(IOUSTATE *ioustate)
+{
+	gcry_error_t err;
+	char *filename = g_strconcat(get_client_config_dir(),INSTAGFILE,NULL);
+
+	err = otrl_instag_write(ioustate->otr_state,filename);
+
+	if (err == GPG_ERR_NO_ERROR) {
+		otr_noticest(TXT_INSTAG_SAVED);
+	} else {
+		otr_noticest(TXT_INSTAG_SAVE_ERROR,
+			     gcry_strerror(err),
+			     gcry_strsource(err));
+	}
+	g_free(filename);
+}
+#endif
+
 /*
  * Load private keys.
  */
@@ -302,3 +324,29 @@ void fps_load(IOUSTATE *ioustate)
 	g_free(filename);
 }
 
+#ifndef LIBOTR3
+/*
+ * Load instance tags.
+ */
+void instag_load(IOUSTATE *ioustate)
+{
+	gcry_error_t err;
+	char *filename = g_strconcat(get_client_config_dir(),INSTAGFILE,NULL);
+
+	if (!g_file_test(filename, G_FILE_TEST_EXISTS)) {
+		otr_noticest(TXT_INSTAG_NOT_FOUND);
+		return;
+	}
+
+	err = otrl_instag_read(ioustate->otr_state,filename);
+
+	if (err == GPG_ERR_NO_ERROR) {
+		otr_noticest(TXT_INSTAG_LOADED);
+	} else {
+		otr_noticest(TXT_INSTAG_LOAD_ERROR,
+			     gcry_strerror(err),
+			     gcry_strsource(err));
+	}
+	g_free(filename);
+}
+#endif
diff --git a/otr_ops.c b/otr_ops.c
index df7d24b..f095ca2 100644
--- a/otr_ops.c
+++ b/otr_ops.c
@@ -102,9 +102,14 @@ void ops_inject_msg(void *opdata, const char *accountname,
 	g_strdelimit (msgcopy,"\n",' ');
 	a_serv = opdata;
 	if (!a_serv) {
+		char nick[256];
+		a_serv = ircctx_by_peername(accountname,nick);
+	}
+	if (!a_serv) {
 		otr_notice(a_serv,recipient,TXT_OPS_INJECT,
 			   accountname,recipient,message);
 	} else {
+		otr_logst(MSGLEVEL_CRAP,"%d: INJECT %s",time(NULL),msgcopy);
 		irc_send_message(a_serv, recipient, msgcopy);
 	}
 	g_free(msgcopy);
@@ -193,6 +198,10 @@ void ops_secure(void *opdata, ConnContext *context)
 	otr_notice(coi->ircctx,
 		   context->username,TXT_OPS_SEC);
 	otr_status_change(coi->ircctx,context->username,IO_STC_GONE_SECURE);
+
+	//TODO: pull master context
+	coi->finished = FALSE;
+
 	if (*trust!='\0')
 		return;
 
@@ -252,6 +261,21 @@ int ops_max_msg(void *opdata, ConnContext *context)
 	return OTR_MAX_MSG_SIZE;
 }
 
+#ifndef LIBOTR3
+void ops_handle_msg_event(void *opdata, OtrlMessageEvent msg_event,
+			 ConnContext *context, const char *message,
+			 gcry_error_t err)
+{
+	IRC_CTX *server  = opdata;
+	char *username = context->username;
+
+	otr_debug(server,
+		  username,
+		  TXT_OPS_HANDLE_MSG,
+		  otr_msg_event_txt[msg_event],message);
+}
+#endif
+
 /*
  * A context changed. 
  * I believe this is not happening for the SMP expects.
@@ -280,6 +304,66 @@ int ops_is_logged_in(void *opdata, const char *accountname,
 	return TRUE;
 }
 
+#ifndef LIBOTR3
+void ops_create_instag(void *opdata, const char *accountname,
+		      const char *protocol)
+{
+	otrl_instag_generate(IRCCTX_IO_US(ircctx)->otr_state,"/dev/null",accountname,protocol);
+	otr_writeinstags(IRCCTX_IO_US(ircctx));
+}
+
+void ops_smp_event(void *opdata, OtrlSMPEvent smp_event,
+		   ConnContext *context, unsigned short progress_percent,
+		   char *question)
+{
+	IRC_CTX *ircctx = (opdata);
+	char *from = context->username;
+	struct co_info *coi = context->app_data;
+
+	coi->received_smp_init = 
+		(smp_event==OTRL_SMPEVENT_ASK_FOR_SECRET)||
+		(smp_event==OTRL_SMPEVENT_ASK_FOR_ANSWER);
+
+	switch (smp_event) {
+	case OTRL_SMPEVENT_ASK_FOR_SECRET:
+		otr_notice(ircctx,from,TXT_AUTH_PEER,
+			   from);
+		otr_status_change(ircctx,from,IO_STC_SMP_INCOMING);
+		break;
+	case OTRL_SMPEVENT_ASK_FOR_ANSWER:
+		otr_notice(ircctx,from,TXT_AUTH_PEER_QA,from,question);
+		otr_status_change(ircctx,from,IO_STC_SMP_INCOMING);
+		break;
+	case OTRL_SMPEVENT_IN_PROGRESS:
+		otr_notice(ircctx,from,
+			   TXT_AUTH_PEER_REPLIED,
+			   from);
+		otr_status_change(ircctx,from,IO_STC_SMP_FINALIZE);
+		break;
+	case OTRL_SMPEVENT_SUCCESS:
+		otr_notice(ircctx,from,
+			   TXT_AUTH_SUCCESSFUL);
+		otr_status_change(ircctx,from,IO_STC_SMP_SUCCESS);
+		break;
+	case OTRL_SMPEVENT_ABORT:
+		otr_abort_auth(context,ircctx,from);
+		otr_status_change(ircctx,from,IO_STC_SMP_ABORTED);
+		break;
+	case OTRL_SMPEVENT_FAILURE:
+	case OTRL_SMPEVENT_CHEATED:
+	case OTRL_SMPEVENT_ERROR:
+		otr_notice(ircctx,from,TXT_AUTH_FAILED);
+		coi->smp_failed = TRUE;
+		otr_status_change(ircctx,from,IO_STC_SMP_FAILED);
+		break;
+	default:
+		otr_logst(MSGLEVEL_CRAP,"Received unknown SMP event");
+		break;
+	}
+}
+
+#endif
+
 /*
  * Initialize our OtrlMessageAppOps
  */
@@ -289,14 +373,21 @@ void otr_initops() {
 	otr_ops.policy = ops_policy;
 	otr_ops.create_privkey = ops_create_privkey;
 	otr_ops.inject_message = ops_inject_msg;
-	otr_ops.notify = ops_notify;
-	otr_ops.display_otr_message = ops_display_msg;
 	otr_ops.gone_secure = ops_secure;
 	otr_ops.gone_insecure = ops_insecure;
 	otr_ops.still_secure = ops_still_secure;
-	otr_ops.log_message = ops_log;
 	otr_ops.max_message_size = ops_max_msg;
 	otr_ops.update_context_list = ops_up_ctx_list;
 	otr_ops.write_fingerprints = ops_writefps;
 	otr_ops.is_logged_in = ops_is_logged_in;
+
+#ifdef LIBOTR3
+	otr_ops.notify = ops_notify;
+	otr_ops.display_otr_message = ops_display_msg;
+	otr_ops.log_message = ops_log;
+#else
+	otr_ops.handle_msg_event = ops_handle_msg_event;
+	otr_ops.create_instag = ops_create_instag;
+	otr_ops.handle_smp_event = ops_smp_event;
+#endif
 }
diff --git a/otr_util.c b/otr_util.c
index 777cc8d..c765e34 100644
--- a/otr_util.c
+++ b/otr_util.c
@@ -42,6 +42,9 @@ IOUSTATE *otr_init_user(char *user)
 
 	/* load keys and fingerprints */
 
+#ifndef LIBOTR3
+	instag_load(ioustate);
+#endif
 	key_load(ioustate);
 	fps_load(ioustate);
 
@@ -67,6 +70,12 @@ void otr_deinit_user(IOUSTATE *ioustate)
 int otrlib_init()
 {
 	if (!otrinited) {
+		/* apparently used in pidgin-otr to
+		 * force gcrypt to /dev/urandom */
+		/*
+		gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
+		gcry_control(GCRYCTL_ENABLE_QUICK_RANDOM, 0);
+		*/
 		OTRL_INIT;
 		otrinited = TRUE;
 	}
@@ -142,6 +151,9 @@ ConnContext *otr_getcontext(const char *accname,const char *nick,
 		nick,
 		accname,
 		PROTOCOLID,
+#ifndef LIBOTR3
+		OTRL_INSTAG_BEST,
+#endif
 		create,
 		NULL,
 		context_add_app_info,
@@ -168,6 +180,7 @@ char *otr_send(IRC_CTX *ircctx, const char *msg,const char *to)
 
 	IRCCTX_ACCNAME(accname,ircctx);
 
+	otr_logst(MSGLEVEL_CRAP,"%d: send...",time(NULL));
 	err = otrl_message_sending(
 		IRCCTX_IO_US(ircctx)->otr_state, 
 		&otr_ops, 
@@ -175,11 +188,19 @@ char *otr_send(IRC_CTX *ircctx, const char *msg,const char *to)
 		accname,
 		PROTOCOLID, 
 		to, 
+#ifndef LIBOTR3
+		OTRL_INSTAG_BEST,
+#endif
 		msg, 
 		NULL, 
 		&newmessage, 
+#ifndef LIBOTR3
+		OTRL_FRAGMENT_SEND_ALL, 
+		&co,
+#endif
 		context_add_app_info, 
 		ircctx);
+	otr_logst(MSGLEVEL_CRAP,"%d: sent",time(NULL));
 
 	if (err != 0) {
 		otr_notice(ircctx,to,TXT_SEND_FAILED,msg);
@@ -191,6 +212,7 @@ char *otr_send(IRC_CTX *ircctx, const char *msg,const char *to)
 
 	/* OTR message. Need to do fragmentation */
 
+#ifdef LIBOTR3
 	if (!(co = otr_getcontext(accname,to,FALSE,ircctx))) {
 		otr_notice(ircctx,to,TXT_SEND_CHANGE);
 		return NULL;
@@ -209,6 +231,8 @@ char *otr_send(IRC_CTX *ircctx, const char *msg,const char *to)
 	} else
 		otr_debug(ircctx,to,TXT_SEND_CONVERTED,newmessage);
 
+#endif
+
 	return NULL;
 }
 
@@ -303,7 +327,7 @@ int otr_getstatus(IRC_CTX *ircctx, const char *nick)
 			code = IO_ST_SMP_FINALIZE;
 			break;
 		default:
-			otr_logst(MSGLEVEL_CRAP,"BUG Found! Please write us a mail and describe how you got here");
+			otr_logst(MSGLEVEL_CRAP,"Encountered unknown SMP state in libotr, please let maintainers know");
 			return IO_ST_UNKNOWN;
 		}
 
@@ -349,8 +373,15 @@ void otr_finish(IRC_CTX *ircctx, char *nick, const char *peername, int inquery)
 		return;
 	}
 
-	otrl_message_disconnect(IRCCTX_IO_US(ircctx)->otr_state,&otr_ops,ircctx,accname,
-				PROTOCOLID,nick);
+	otrl_message_disconnect(IRCCTX_IO_US(ircctx)->otr_state,
+				&otr_ops,ircctx,accname,
+				PROTOCOLID,
+#ifdef LIBOTR3
+				nick);
+#else
+				nick,co->their_instance);
+#endif
+
 	otr_status_change(ircctx,nick,IO_STC_FINISHED);
 
 	if (inquery) {
@@ -365,6 +396,24 @@ void otr_finish(IRC_CTX *ircctx, char *nick, const char *peername, int inquery)
 	 * we're called cause the query window has been closed. */
 	if (coi) 
 		coi->finished = inquery;
+
+#ifndef LIBOTR3
+	// write the finished into the master as well
+	co = otrl_context_find(
+		IRCCTX_IO_US(ircctx)->otr_state,
+		nick,
+		accname,
+		PROTOCOLID,
+		OTRL_INSTAG_MASTER,
+		FALSE,
+		NULL,
+		NULL,
+		NULL);
+	coi = co->app_data;
+	if (coi) 
+		coi->finished = inquery;
+#endif
+
 }
 
 void otr_finishall(IOUSTATE *ioustate)
@@ -382,7 +431,11 @@ void otr_finishall(IOUSTATE *ioustate)
 		otrl_message_disconnect(ioustate->otr_state,&otr_ops,coi->ircctx,
 					context->accountname,
 					PROTOCOLID,
+#ifdef LIBOTR3
 					context->username);
+#else
+					context->username,context->their_instance);
+#endif
 		otr_status_change(coi->ircctx,context->username,IO_STC_FINISHED);
 
 		otr_infost(TXT_CMD_FINISH,context->username,
@@ -480,7 +533,8 @@ void otr_authabort(IRC_CTX *ircctx, char *nick, const char *peername)
 /*
  * Initiate or respond to SMP authentication.
  */
-void otr_auth(IRC_CTX *ircctx, char *nick, const char *peername, const char *secret)
+void otr_auth(IRC_CTX *ircctx, char *nick, const char *peername,
+	      const char *question, const char *secret)
 {
 	ConnContext *co;
 	char accname[128];
@@ -525,13 +579,26 @@ void otr_auth(IRC_CTX *ircctx, char *nick, const char *peername, const char *sec
 	}
 
 	if (!coi->received_smp_init) {
-		otrl_message_initiate_smp(
-			IRCCTX_IO_US(ircctx)->otr_state, 
-			&otr_ops,
-			ircctx,
-			co,
-			(unsigned char*)secret,
-			strlen(secret));
+#ifndef LIBOTR3
+		if (question)
+			otrl_message_initiate_smp_q(
+				IRCCTX_IO_US(ircctx)->otr_state, 
+				&otr_ops,
+				ircctx,
+				co,
+				question,
+				(unsigned char*)secret,
+				strlen(secret));
+		else
+#endif
+			otrl_message_initiate_smp(
+				IRCCTX_IO_US(ircctx)->otr_state, 
+				&otr_ops,
+				ircctx,
+				co,
+				(unsigned char*)secret,
+				strlen(secret));
+
 		otr_status_change(ircctx,nick,IO_STC_SMP_STARTED);
 	} else {
 		otrl_message_respond_smp(
@@ -723,6 +790,7 @@ char *otr_receive(IRC_CTX *ircctx, const char *msg,const char *from)
 		return NULL;
 	}
 
+	otr_logst(MSGLEVEL_CRAP,"%d: receive...",time(NULL));
 	ignore_message = otrl_message_receiving(
 		IRCCTX_IO_US(ircctx)->otr_state,
 		&otr_ops,
@@ -733,11 +801,28 @@ char *otr_receive(IRC_CTX *ircctx, const char *msg,const char *from)
 		msg, 
 		&newmessage,
 		&tlvs,
+#ifdef LIBOTR3
 		NULL,
 		NULL);
+#else
+		&co,
+		context_add_app_info,
+		ircctx);
+#endif
+	otr_logst(MSGLEVEL_CRAP,"%d: received",time(NULL));
 
-	if (tlvs) 
+	if (tlvs) {
+#ifdef LIBOTR3
 		otr_handle_tlvs(tlvs,co,coi,ircctx,from);
+#else
+
+		OtrlTLV *tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED);
+		if (tlv) {
+			otr_status_change(ircctx,from,IO_STC_PEER_FINISHED);
+			otr_notice(ircctx,from,TXT_PEER_FINISHED,from);
+		}
+#endif
+	}
 	
 	if (ignore_message) {
 		otr_debug(ircctx,from,

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