[Pkg-privacy-commits] [irssi-plugin-otr] 44/267: Finish conversations on unload. Also added a setting otr_finishonunload to disable this.

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 12:41:26 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 42b018f9a5384f852f4eef1757a77d5c4d1ae747
Author: Uli Meis <a.sporto+bee at gmail.com>
Date:   Wed Jan 28 11:28:58 2009 +0100

    Finish conversations on unload. Also added a setting otr_finishonunload to disable
    this.
---
 ChangeLog   |  1 +
 formats.txt |  3 ++-
 irssi_otr.c |  4 ++++
 otr.h       |  1 +
 otr_util.c  | 28 +++++++++++++++++++++++++++-
 xchat_otr.c | 23 +++++++++++++++++++++--
 6 files changed, 56 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 779f3cc..5e62f75 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,5 @@
 Version 0.3
+	* finish conversations on unload unless otr_finishonunload is off
 	* added settings otr_policy, otr_policy_known and otr_ignore
 	* fixed two segfault sources
 	* key generation now operates on a temp file
diff --git a/formats.txt b/formats.txt
index c358a4f..593c3ca 100644
--- a/formats.txt
+++ b/formats.txt
@@ -70,7 +70,8 @@ cmd_qnotfound	Failed: Can't get nick and server of current query window. (Or may
 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
+cmd_finish	Finished conversation with %s@%s.
+cmd_finishall_none	No conversations to finish.
 cmd_version	This is irssi-otr version %s
 peer_finished	%s has finished the OTR conversation. If you want to continue talking enter %9/otr finish%9 for plaintext or ?OTR? to restart OTR.
 Contexts
diff --git a/irssi_otr.c b/irssi_otr.c
index a3aae4f..69c4144 100644
--- a/irssi_otr.c
+++ b/irssi_otr.c
@@ -323,6 +323,7 @@ void otr_init(void)
 	settings_add_str("otr", "otr_policy",IO_DEFAULT_POLICY);
 	settings_add_str("otr", "otr_policy_known",IO_DEFAULT_POLICY_KNOWN);
 	settings_add_str("otr", "otr_ignore",IO_DEFAULT_IGNORE);
+	settings_add_bool("otr", "otr_finishonunload",TRUE);
 	read_settings();
 	signal_add("setup changed", (SIGNAL_FUNC) read_settings);
 
@@ -360,6 +361,9 @@ void otr_deinit(void)
 
 	statusbar_item_unregister("otr");
 
+	if (settings_get_bool("otr_finishonunload"))
+		otr_finishall();
+
 	otrlib_deinit();
 
 	theme_unregister();
diff --git a/otr.h b/otr.h
index 7dc73e8..3e73310 100644
--- a/otr.h
+++ b/otr.h
@@ -149,6 +149,7 @@ 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_authabort(IRC_CTX *server, char *nick, const char *peername);
 struct ctxlist_ *otr_contexts();
+void otr_finishall();
 
 
 /* key/fingerprint stuff */
diff --git a/otr_util.c b/otr_util.c
index b804de4..b9c3d19 100644
--- a/otr_util.c
+++ b/otr_util.c
@@ -331,7 +331,7 @@ void otr_finish(IRC_CTX *ircctx, char *nick, const char *peername, int inquery)
 
 	otr_info(inquery ? ircctx : NULL,
 		   inquery ? nick : NULL,
-		   TXT_CMD_FINISH,nick);
+		   TXT_CMD_FINISH,nick,IRCCTX_ADDR(ircctx));
 
 	coi = co->app_data;
 
@@ -344,6 +344,32 @@ void otr_finish(IRC_CTX *ircctx, char *nick, const char *peername, int inquery)
 		*pserver = '@';
 }
 
+void otr_finishall()
+{
+	ConnContext *context;
+	int finished=0;
+
+	for(context = otr_state->context_root; context; 
+	    context = context->next) {
+		struct co_info *coi = context->app_data;
+
+		if (context->msgstate!=OTRL_MSGSTATE_ENCRYPTED)
+			continue;
+
+		otrl_message_disconnect(otr_state,&otr_ops,coi->ircctx,
+					context->accountname,
+					PROTOCOLID,
+					context->username);
+
+		otr_infost(TXT_CMD_FINISH,context->username,
+			   IRCCTX_ADDR(coi->ircctx));
+		finished++;
+	}
+
+	if (!finished)
+		otr_infost(TXT_CMD_FINISHALL_NONE);
+}
+
 /*
  * Trust our peer.
  */
diff --git a/xchat_otr.c b/xchat_otr.c
index e3cf9f6..5c5b8ad 100644
--- a/xchat_otr.c
+++ b/xchat_otr.c
@@ -11,6 +11,7 @@ xchat_plugin *ph;
 static char set_policy[512] = IO_DEFAULT_POLICY;
 static char set_policy_known[512] = IO_DEFAULT_POLICY_KNOWN;
 static char set_ignore[512] = IO_DEFAULT_IGNORE;
+static int set_finishonunload = TRUE;
 
 int extract_nick(char *nick, char *line)
 {
@@ -97,10 +98,14 @@ int cmd_otr(char *word[], char *word_eol[], void *userdata)
 			regex_nickignore = g_regex_new(word_eol[4],0,0,NULL);
 			strcpy(set_ignore,word_eol[4]);
 #endif
+		} else if (strcmp(word[3],"finishonunload")==0) {
+			set_finishonunload = (strcasecmp(word[4],"true")==0);
 		} else {
 			xchat_printf(ph, "policy: %s\n"
-				     "policy_known: %s\nignore: %s\n",
-				     set_policy,set_policy_known,set_ignore);
+				     "policy_known: %s\nignore: %s\n"
+				     "finishonunload: %s\n",
+				     set_policy,set_policy_known,set_ignore,
+				     set_finishonunload ? "true" : "false");
 		}
 		
 	}
@@ -219,6 +224,20 @@ int xchat_plugin_init(xchat_plugin *plugin_handle,
 	return 1;
 }
 
+int xchat_plugin_deinit()
+{
+#ifdef HAVE_GREGEX_H
+	g_regex_unref(regex_nickignore);
+#endif
+
+	if (set_finishonunload)
+		otr_finishall();
+
+	otrlib_deinit();
+
+	return 1;
+}
+
 void printformat(IRC_CTX *ircctx, const char *nick, int lvl, int fnum, ...)
 {
 	va_list params;

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