[Pkg-privacy-commits] [irssi-plugin-otr] 13/267: New command "/otr finish".

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 12:41:22 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 618f64153c6dc184a18e0f7181c387e11e3fa007
Author: Uli Meis <a.sporto+bee at gmail.com>
Date:   Fri Jun 6 00:57:09 2008 +0200

    New command "/otr finish".
---
 INSTALL     | 15 +++++++++++++++
 README      |  8 ++++++--
 formats.txt |  4 +++-
 otr.c       | 24 +++++++++++++++++++++---
 otr.h       |  1 +
 otr_key.c   |  6 +++---
 otr_ops.c   | 10 ++++++++++
 otrutil.c   | 31 +++++++++++++++++++++++++++++--
 8 files changed, 88 insertions(+), 11 deletions(-)

diff --git a/INSTALL b/INSTALL
index d372465..4e33902 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,3 +1,5 @@
+---------- INSTALL ----------
+
 Usually the following will do:
 
 	$ cmake /path/to/src
@@ -8,3 +10,16 @@ Usually the following will do:
 
 1. into the system wide irssi modules folder if you're root or
 2. into ~/.irssi/modules if you're not root
+
+---------- MAJOR DEPENDENCIES ----------
+
+* 	cmake. Sry for that, but I'm not an autofoo fan. If you're running
+	< cmake-2.4.7 then configure will try to download a missing module
+	(pkgconfig) from the cmake-2.4.7 sources. Should work.
+
+*	libotr >= 3.1.0. Fragmentation has been introduced in that version so
+	nothing smaller will work.
+
+---------- OTHER DEPENDENCIES ----------
+
+irssi,wget,pkg-config,glib,python
diff --git a/README b/README
index 1341e1f..6664cf2 100644
--- a/README
+++ b/README
@@ -30,7 +30,11 @@ Commands:
 /otr authabort
 	Abort any ongoing authentication
 /otr trust
-	Trust the fingerprint of the user in the current window blindly.
-	Better use "/otr auth"
+	Trust the fingerprint of the user in the current window.
+	You should only do this after comparing fingerprints over a secure line
 /otr debug
 	Switch debug mode on/off
+/otr contexts
+	List all OTR contexts along with their fingerprints and status
+/otr finish
+	Finish an OTR conversation
diff --git a/formats.txt b/formats.txt
index fb0cf63..7e3117c 100644
--- a/formats.txt
+++ b/formats.txt
@@ -64,10 +64,12 @@ auth_successful	Authentication successful!
 auth_failed	Authentication failed!
 Commands
 cmd_otr	We're alive
-cmd_trust	failed: Can't get query details
+cmd_qnotfound	failed: Can't get query details
 cmd_auth	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.
 cmd_debug_on	Debug mode is on
 cmd_debug_off	Debug mode is off
+cmd_finish	Finished conversation with %s
+peer_finished	%s has finished the OTR conversation
 Nickignore
 nickignore	xmlconsole
 Statusbar
diff --git a/otr.c b/otr.c
index 4d369cb..94e34db 100644
--- a/otr.c
+++ b/otr.c
@@ -71,6 +71,21 @@ static void cmd_otr(const char *data,void *server,WI_ITEM_REC *item)
 }
 
 /*
+ * /otr finish
+ */
+static void cmd_finish(const char *data, void *server, WI_ITEM_REC *item)
+{
+	QUERY_REC *query = QUERY(item);
+	if (query&&query->server&&query->server->connrec) {
+		otr_finish(query->server,query->name);
+		statusbar_items_redraw("otr");
+	}
+	else
+		otr_notice(item->server,query ? query->name : NULL,
+			   TXT_CMD_QNOTFOUND);
+}
+
+/*
  * /otr trust
  */
 static void cmd_trust(const char *data, void *server, WI_ITEM_REC *item)
@@ -82,7 +97,7 @@ static void cmd_trust(const char *data, void *server, WI_ITEM_REC *item)
 	}
 	else
 		otr_notice(item->server,query ? query->name : NULL,
-			   TXT_CMD_TRUST);
+			   TXT_CMD_QNOTFOUND);
 }
 
 /*
@@ -91,7 +106,7 @@ static void cmd_trust(const char *data, void *server, WI_ITEM_REC *item)
 static void cmd_genkey(const char *data, void *server, WI_ITEM_REC *item)
 {
 	if (strcmp(data,"abort")==0)
-		keygen_abort();
+		keygen_abort(FALSE);
 	else if (strchr(data,'@'))
 		keygen_run(data);
 	else
@@ -182,7 +197,7 @@ void otr_init(void)
 {
 	regex_nickignore = g_regex_new(formats[TXT_NICKIGNORE].def,0,0,NULL);
 
-	module_register(MODULE_NAME,  "core");
+	module_register(MODULE_NAME, "core");
 
 	theme_register(formats);
 
@@ -195,6 +210,7 @@ void otr_init(void)
 	command_bind("otr", NULL, (SIGNAL_FUNC) cmd_otr);
 	command_bind("otr debug", NULL, (SIGNAL_FUNC) cmd_debug);
 	command_bind("otr trust", NULL, (SIGNAL_FUNC) cmd_trust);
+	command_bind("otr finish", NULL, (SIGNAL_FUNC) cmd_finish);
 	command_bind("otr genkey", NULL, (SIGNAL_FUNC) cmd_genkey);
 	command_bind("otr auth", NULL, (SIGNAL_FUNC) cmd_auth);
 	command_bind("otr authabort", NULL, (SIGNAL_FUNC) cmd_authabort);
@@ -220,6 +236,7 @@ void otr_deinit(void)
 	command_unbind("otr", (SIGNAL_FUNC) cmd_otr);
 	command_unbind("otr debug", (SIGNAL_FUNC) cmd_debug);
 	command_unbind("otr trust", (SIGNAL_FUNC) cmd_trust);
+	command_unbind("otr finish", (SIGNAL_FUNC) cmd_finish);
 	command_unbind("otr genkey", (SIGNAL_FUNC) cmd_genkey);
 	command_unbind("otr auth", (SIGNAL_FUNC) cmd_auth);
 	command_unbind("otr authabort", (SIGNAL_FUNC) cmd_authabort);
@@ -230,4 +247,5 @@ void otr_deinit(void)
 
 	otrlib_deinit();
 
+	theme_unregister();
 }
diff --git a/otr.h b/otr.h
index fd9030f..4bc3ffb 100644
--- a/otr.h
+++ b/otr.h
@@ -98,6 +98,7 @@ ConnContext *otr_getcontext(const char *accname,const char *nick,int create,void
 /* user interaction */
 
 void otr_trust(SERVER_REC *server, char *nick);
+void otr_finish(SERVER_REC *server, char *nick);
 void otr_auth(SERVER_REC *server, char *nick, const char *secret);
 void otr_authabort(SERVER_REC *server, char *nick);
 char *otr_contexts();
diff --git a/otr_key.c b/otr_key.c
index 48e5128..918ff27 100644
--- a/otr_key.c
+++ b/otr_key.c
@@ -79,7 +79,7 @@ void keygen_childwatch(GPid pid,gint status, gpointer data) {
 	} else if (ret==-1)
 		otr_noticest(TXT_KG_POLLERR,kg_st.accountname,strerror(errno));
 
-	keygen_abort();
+	keygen_abort(FALSE);
 }	
 
 /*
@@ -201,9 +201,9 @@ void keygen_run(const char *accname)
 /*
  * Abort ongoing key generation.
  */
-void keygen_abort()
+void keygen_abort(int ignoreidle)
 {
-	if (kg_st.status!=KEYGEN_RUNNING) {
+	if (!ignoreidle&&(kg_st.status!=KEYGEN_RUNNING)) {
 		otr_noticest(TXT_KG_NOABORT);
 		return;
 	}
diff --git a/otr_ops.c b/otr_ops.c
index a3805fb..75258cf 100644
--- a/otr_ops.c
+++ b/otr_ops.c
@@ -202,6 +202,15 @@ void ops_writefps(void *data)
 	otr_writefps();
 }
 
+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;
+}
+
 /*
  * Initialize our OtrlMessageAppOps
  */
@@ -220,4 +229,5 @@ void otr_initops() {
 	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;
 }
diff --git a/otrutil.c b/otrutil.c
index 437a9a8..b1243d2 100644
--- a/otrutil.c
+++ b/otrutil.c
@@ -59,7 +59,7 @@ void otrlib_deinit()
 		otr_state = NULL;
 	}
 
-	keygen_abort();
+	keygen_abort(TRUE);
 }
 
 
@@ -268,6 +268,28 @@ int otr_getstatus(char *mynick, char *nick, char *server)
 }
 
 /*
+ * Finish the conversation.
+ */
+void otr_finish(SERVER_REC *server, char *nick)
+{
+	ConnContext *co;
+	char accname[128];
+
+	sprintf(accname, "%s@%s", server->nick, server->connrec->address);
+
+	if (!(co = otr_getcontext(accname,nick,FALSE,NULL))) {
+		otr_noticest(TXT_CTX_NOT_FOUND,
+			     accname,nick);
+		return;
+	}
+
+	otrl_message_disconnect(otr_state,&otr_ops,NULL,accname,
+				PROTOCOLID,nick);
+
+	otr_notice(server,nick,TXT_CMD_FINISH,nick);
+}
+
+/*
  * Trust our peer.
  */
 void otr_trust(SERVER_REC *server, char *nick)
@@ -390,7 +412,8 @@ void otr_auth(SERVER_REC *server, char *nick, const char *secret)
  */
 void otr_handle_tlvs(OtrlTLV *tlvs, ConnContext *co, 
 		     struct co_info *coi, 
-		     SERVER_REC *server, const char *from) {
+		     SERVER_REC *server, const char *from) 
+{
 	int abort = FALSE;
 
 	OtrlTLV *tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP1);
@@ -469,6 +492,10 @@ void otr_handle_tlvs(OtrlTLV *tlvs, ConnContext *co,
 	if (abort)
 		otr_abort_auth(co,server,from);
 
+	tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED);
+	if (tlv)
+		otr_notice(server,from,TXT_PEER_FINISHED,from);
+
 	statusbar_items_redraw("otr");
 }
 

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