[Pkg-privacy-commits] [irssi-plugin-otr] 136/267: Fix: Finish all command now does its job

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 12:41:36 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 d3c9a7c21c603df2a6e9870a19dc18cadceb497e
Author: David Goulet <dgoulet at ev0ke.net>
Date:   Wed Nov 14 17:19:14 2012 -0500

    Fix: Finish all command now does its job
    
    Signed-off-by: David Goulet <dgoulet at ev0ke.net>
---
 src/irssi_otr.h |  2 --
 src/module.c    | 43 -------------------------------------------
 src/otr.c       | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 src/otr.h       |  2 --
 4 files changed, 50 insertions(+), 51 deletions(-)

diff --git a/src/irssi_otr.h b/src/irssi_otr.h
index 8607d8f..a11807b 100644
--- a/src/irssi_otr.h
+++ b/src/irssi_otr.h
@@ -56,8 +56,6 @@ static SERVER_REC *IRSSI_FREE(SERVER_REC *ircctx)
 	return ircctx;
 }
 
-void otr_query_create(SERVER_REC *ircctx, const char *nick);
-
 #define IRSSI_CONN_ADDR(i) i->connrec->address
 #define IRSSI_NICK(i) i->nick
 
diff --git a/src/module.c b/src/module.c
index 7b77719..73cc9f4 100644
--- a/src/module.c
+++ b/src/module.c
@@ -270,16 +270,6 @@ void irssi_send_message(SERVER_REC *irssi, const char *recipient,
 	}
 }
 
-void otr_query_create(SERVER_REC *server, const char *nick)
-{
-	if (!server || !nick || !settings_get_bool("otr_createqueries") ||
-			query_find(server, nick)) {
-		return;
-	}
-
-	irc_query_create(server->tag, nick, TRUE);
-}
-
 /*
  * irssi init()
  */
@@ -353,36 +343,3 @@ void otr_deinit(void)
 
 	theme_unregister();
 }
-
-SERVER_REC *find_irssi_ctx_by_peername(const char *peername, const char *nick)
-{
-	GSList *tmp;
-	char pname[256];
-	char *address, *_nick = strdup(nick);
-	SERVER_REC *server = NULL;
-
-	strncpy(pname, peername, sizeof(pname));
-
-	address = strchr(pname, '@');
-	if (!address) {
-		goto error;
-	}
-
-	*address = '\0';
-	strncpy(_nick, pname, strlen(_nick));
-	*address++ = '@';
-
-	for (tmp = servers; tmp != NULL; tmp = tmp->next) {
-		server = tmp->data;
-
-		if (g_ascii_strncasecmp(server->connrec->address, address,
-					strlen(server->connrec->address))) {
-			goto error;
-		}
-	}
-
-	return server;
-
-error:
-	return NULL;
-}
diff --git a/src/otr.c b/src/otr.c
index 062d7b8..c45b3d7 100644
--- a/src/otr.c
+++ b/src/otr.c
@@ -127,6 +127,53 @@ static void add_peer_context_cb(void *data, ConnContext *context)
 	IRSSI_DEBUG("Peer context created for %s", context->username);
 }
 
+static SERVER_REC *find_irssi_by_account_name(const char *accname)
+{
+	GSList *tmp;
+	size_t nick_len;
+	char *address, *nick = NULL;
+	SERVER_REC *server, *srv = NULL;
+
+	assert(accname);
+
+	address = strchr(accname, '@');
+	if (!address) {
+		goto error;
+	}
+
+	/* Calculate the nickname length. */
+	nick_len = address - accname;
+
+	/* Allocate right size for the nickname plus the NULL terminated byte. */
+	nick = malloc(nick_len + 1);
+	if (!nick) {
+		/* ENOMEM */
+		goto error;
+	}
+
+	/* Get the nick from the account name. */
+	strncpy(nick, accname, nick_len);
+	nick[nick_len] = '\0';
+
+	/* Move after the @ */
+	address++;
+
+	for (tmp = servers; tmp; tmp = tmp->next) {
+		server = tmp->data;
+		if (g_ascii_strncasecmp(server->connrec->address, address,
+					strlen(server->connrec->address)) == 0 &&
+				strncmp(server->nick, nick, strlen(nick)) == 0) {
+			srv = server;
+			break;
+		}
+	}
+
+	free(nick);
+
+error:
+	return srv;
+}
+
 /*
  * Get a context from a pair.
  */
@@ -374,11 +421,10 @@ void otr_finishall(struct otr_user_state *ustate)
 			continue;
 		}
 
-		irssi = find_irssi_ctx_by_peername(context->accountname,
-				context->username);
+		irssi = find_irssi_by_account_name(context->accountname);
 		if (!irssi) {
-			IRSSI_DEBUG("Unable to find server window on /otr finishall "
-					"for username %s", context->username);
+			IRSSI_DEBUG("Unable to find server window for account %s",
+					context->accountname);
 			continue;
 		}
 
diff --git a/src/otr.h b/src/otr.h
index 81d4c2e..60cad2a 100644
--- a/src/otr.h
+++ b/src/otr.h
@@ -160,8 +160,6 @@ void irssi_send_message(SERVER_REC *irssi, const char *recipient,
 void otr_status_change(SERVER_REC *irssi, const char *nick,
 		enum otr_status_event event);
 
-SERVER_REC *find_irssi_ctx_by_peername(const char *peername, const char *nick);
-
 /* init stuff */
 
 struct otr_user_state *otr_init_user(const char *user);

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