changeset 3163:e102d1629c71

[gaim-migrate @ 3179] event_chat_recv takes char** arguments, so you can change the incoming text and sender. event_im_recv takes a guint32* for its flags, so you can change the flags too. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Tue, 23 Apr 2002 16:30:09 +0000
parents 7dfd1871c39d
children cdfaf2e1b4f0
files ChangeLog plugins/SIGNALS src/module.c src/server.c
diffstat 4 files changed, 33 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Apr 22 23:40:53 2002 +0000
+++ b/ChangeLog	Tue Apr 23 16:30:09 2002 +0000
@@ -9,6 +9,8 @@
 	* Finnish translation update (Thanks, Tero Kuusela)
 	* Jabber improvements (Thanks, Nathan Walp)
 	* More keyboard shortcuts
+	* event_chat_recv takes char**'s, and event_im_recv takes
+	  a *guint32 for flags
 
 version 0.56 (04/11/2002):
 	* German translation update (Thanks Karsten Weiss)
--- a/plugins/SIGNALS	Mon Apr 22 23:40:53 2002 +0000
+++ b/plugins/SIGNALS	Tue Apr 23 16:30:09 2002 +0000
@@ -93,7 +93,7 @@
 	removed eventually.
 
 event_im_recv:
-	struct gaim_connection *gc, char **who, char **text, guint32 flags
+	struct gaim_connection *gc, char **who, char **text, guint32 *flags
 
 	'gc' is the connection that received the message.
 	'who' is the username of the person who sent the message.
@@ -211,7 +211,7 @@
 	'who' is the screenname of the person who left.
 
 event_chat_recv:
-	struct gaim_connection *gc, int id, char *who, char *text
+	struct gaim_connection *gc, int id, char **who, char **text
 
 	'gc' is the connection that received the message.
 	'who' should be too.
@@ -219,6 +219,9 @@
 	'id' is the id of the room that received the message (see
 	event_chat_join)
 
+	Like event_im_recv, you are allowed and encouraged to change
+	these values	
+
 	Note that because of the bizarre way chat works, you also receive
 	messages that you send. I didn't design it, AOL did.
 
--- a/src/module.c	Mon Apr 22 23:40:53 2002 +0000
+++ b/src/module.c	Tue Apr 23 16:30:09 2002 +0000
@@ -449,8 +449,8 @@
 			debug_printf("%s: %s %d %s\n", event_name(event),
 					((struct gaim_connection *)arg1)->username,
 					(int)arg2,
-					(char *)arg3 ? (char *)arg3 : "",
-					(char *)arg4 ? (char *)arg4 : "");
+					*(char **)arg3 ? *(char **)arg3 : "",
+					*(char **)arg4 ? *(char **)arg4 : "");
 			break;
 		case event_chat_send_invite:
 			debug_printf("%s: %s %d %s %s\n", event_name(event),
--- a/src/server.c	Mon Apr 22 23:40:53 2002 +0000
+++ b/src/server.c	Tue Apr 23 16:30:09 2002 +0000
@@ -498,7 +498,7 @@
 		buffy = g_malloc(MAX(strlen(message) + 1, BUF_LONG));
 		strcpy(buffy, message);
 		angel = g_strdup(name);
-		plugin_return = plugin_event(event_im_recv, gc, &angel, &buffy, (void *)flags);
+		plugin_return = plugin_event(event_im_recv, gc, &angel, &buffy, (void *)&flags);
 
 		if (!buffy || !angel || plugin_return) {
 			if (buffy)
@@ -971,6 +971,8 @@
 	GSList *bcs = g->buddy_chats;
 	struct conversation *b = NULL;
 	char *buf;
+	char *buffy, *angel;
+	int plugin_return;
 
 	while (bcs) {
 		b = (struct conversation *)bcs->data;
@@ -983,8 +985,26 @@
 	if (!b)
 		return;
 
-	if (plugin_event(event_chat_recv, g, (void *)b->id, who, message))
+	
+	/* plugin stuff. we pass a char ** but we don't want to pass what's been given us
+	 * by the prpls. so we create temp holders and pass those instead. it's basically
+	 * just to avoid segfaults. of course, if the data is binary, plugins don't see it.
+	 * bitch all you want; i really don't want you to be dealing with it. */
+	
+	buffy = g_malloc(MAX(strlen(message) + 1, BUF_LONG));
+	strcpy(buffy, message);
+	angel = g_strdup(who);
+	plugin_return = plugin_event(event_chat_recv, g, (void *)b->id, &angel, &buffy);
+
+	if (!buffy || !angel || plugin_return) {
+		if (buffy)
+			g_free(buffy);
+		if (angel)
+			g_free(angel);
 		return;
+	}
+	who = angel;
+	message = buffy;
 
 	buf = g_malloc(MAX(strlen(message) * 2, 8192));
 	strcpy(buf, message);
@@ -998,6 +1018,8 @@
 		w = 0;
 
 	chat_write(b, who, w, buf, mtime);
+	g_free(who);
+	g_free(message);
 	g_free(buf);
 }