/pidgin/main: 3edc70bf4e09: Emit sending/sent signals when doing...

Tomasz Wasilczyk twasilczyk at pidgin.im
Sun Apr 27 08:27:20 EDT 2014


Changeset: 3edc70bf4e0948c863a19cde2eb3642feb404b3f
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-04-27 14:27 +0200
Branch:	 release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/3edc70bf4e09

Description:

Emit sending/sent signals when doing /me irc command. Fixes #15750

diffstat:

 autogen.sh                     |   6 +-
 libpurple/protocols/irc/cmds.c |  91 +++++++++++++++++++++++++++++++----------
 2 files changed, 72 insertions(+), 25 deletions(-)

diffs (126 lines):

diff --git a/autogen.sh b/autogen.sh
--- a/autogen.sh
+++ b/autogen.sh
@@ -160,5 +160,7 @@ run_or_die ${AUTOCONF} ${AUTOCONF_FLAGS}
 ###############################################################################
 # Run configure
 ###############################################################################
-echo "running ./configure ${CONFIGURE_FLAGS} $@"
-./configure ${CONFIGURE_FLAGS} $@
+if test -z "$NOCONFIGURE"; then
+	echo "running ./configure ${CONFIGURE_FLAGS} $@"
+	./configure ${CONFIGURE_FLAGS} $@
+fi
diff --git a/libpurple/protocols/irc/cmds.c b/libpurple/protocols/irc/cmds.c
--- a/libpurple/protocols/irc/cmds.c
+++ b/libpurple/protocols/irc/cmds.c
@@ -98,41 +98,86 @@ int irc_cmd_ctcp_action(struct irc_conn 
 	PurpleConnection *gc = purple_account_get_connection(irc->account);
 	char *action, *escaped, *dst, **newargs;
 	const char *src;
+	char *msg;
 	PurpleConversation *convo;
 
 	if (!args || !args[0] || !gc)
 		return 0;
 
-	action = g_malloc(strlen(args[0]) + 10);
+	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY,
+		target, irc->account);
 
-	sprintf(action, "\001ACTION ");
+	msg = g_strdup_printf("/me %s", args[0]);
 
-	src = args[0];
-	dst = action + 8;
-	while (*src) {
-		if (*src == '\n') {
-			if (*(src + 1) == '\0') {
-				break;
-			} else {
-				*dst++ = ' ';
-				src++;
-				continue;
+	/* XXX: we'd prefer to keep this in conversation.c */
+	if (purple_conversation_get_type(convo) == PURPLE_CONV_TYPE_IM) {
+		purple_signal_emit(purple_conversations_get_handle(),
+			"sending-im-msg", irc->account,
+			purple_conversation_get_name(convo), &msg);
+	} else {
+		purple_signal_emit(purple_conversations_get_handle(),
+			"sending-chat-msg", irc->account, &msg,
+			purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo)));
+	}
+
+	if (!msg || !msg[0]) {
+		g_free(msg);
+		return 0;
+	}
+
+	if (strncmp(msg, "/me ", 4) != 0) {
+		newargs = g_new0(char *, 2);
+		newargs[0] = g_strdup(target);
+		newargs[1] = msg;
+
+		irc_cmd_privmsg(irc, cmd, target, (const char **)newargs);
+
+		g_free(newargs[0]);
+		g_free(newargs);
+	} else {
+		action = g_malloc(strlen(&msg[4]) + 10);
+
+		sprintf(action, "\001ACTION ");
+
+		src = &msg[4];
+		dst = action + 8;
+		while (*src) {
+			if (*src == '\n') {
+				if (*(src + 1) == '\0') {
+					break;
+				} else {
+					*dst++ = ' ';
+					src++;
+					continue;
+				}
 			}
+			*dst++ = *src++;
 		}
-		*dst++ = *src++;
+		*dst++ = '\001';
+		*dst = '\0';
+
+		newargs = g_new0(char *, 2);
+		newargs[0] = g_strdup(target);
+		newargs[1] = action;
+		irc_cmd_privmsg(irc, cmd, target, (const char **)newargs);
+		g_free(newargs[0]);
+		g_free(newargs);
+		g_free(action);
 	}
-	*dst++ = '\001';
-	*dst = '\0';
 
-	newargs = g_new0(char *, 2);
-	newargs[0] = g_strdup(target);
-	newargs[1] = action;
-	irc_cmd_privmsg(irc, cmd, target, (const char **)newargs);
-	g_free(newargs[0]);
-	g_free(newargs[1]);
-	g_free(newargs);
+	/* XXX: we'd prefer to keep this in conversation.c */
+	if (purple_conversation_get_type(convo) == PURPLE_CONV_TYPE_IM) {
+		purple_signal_emit(purple_conversations_get_handle(),
+			"sent-im-msg", irc->account,
+			purple_conversation_get_name(convo), msg);
+	} else {
+		purple_signal_emit(purple_conversations_get_handle(),
+			"sent-chat-msg", irc->account, msg,
+			purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo)));
+	}
 
-	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, target, irc->account);
+	g_free(msg);
+
 	if (convo) {
 		escaped = g_markup_escape_text(args[0], -1);
 		action = g_strdup_printf("/me %s", escaped);



More information about the Commits mailing list