changeset 2273:0b5c3338fa3d

[gaim-migrate @ 2283] One of the girls on the floor of my sister's dorm lost both her parents when their plane was hijacked and crashed into the World Trade Center. my girlfriend's boss's sister-in-law's brother died when the building collapsed. my parents flew to atlanta on monday; they're safe but currently stranded there. they had planned on flying to Raleigh, NC today but now are just hoping to be able to fly home soon. how did this happen? committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Wed, 12 Sep 2001 21:29:32 +0000
parents 4ecc9a9a75d8
children f2150073cd41
files ChangeLog TODO plugins/SIGNALS src/gaim.h src/multi.c src/plugins.c src/protocols/irc/irc.c src/protocols/msn/msn.c src/protocols/oscar/oscar.c src/protocols/toc/toc.c src/server.c
diffstat 11 files changed, 77 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Sep 12 18:57:46 2001 +0000
+++ b/ChangeLog	Wed Sep 12 21:29:32 2001 +0000
@@ -15,6 +15,8 @@
 	* Added drop down selection to chat invitation
 	* Improved the look of the chat invitation dialog
 	* Improved the look of the proxy preferences
+	* event_im_recv and event_im_display_rcvd passed whether
+	  the message received was auto-response (see SIGNALS)
 
 version 0.43 (09/06/2001):
 	* Updated German Translation (thanks Daniel Seifert)
--- a/TODO	Wed Sep 12 18:57:46 2001 +0000
+++ b/TODO	Wed Sep 12 21:29:32 2001 +0000
@@ -3,6 +3,7 @@
 	Transparency for GtkIMHtml
 	Rewrite the HTML parser in GtkIMHtml
 	GPG Encryption of messages
+	Have plugin_event use varargs instead of void*
 	Better way of showing away state - and possibly in main window
 	Moving GTK/GDK and related things out of the prpls
 		TOC: file transfer (move into the core)
--- a/plugins/SIGNALS	Wed Sep 12 18:57:46 2001 +0000
+++ b/plugins/SIGNALS	Wed Sep 12 21:29:32 2001 +0000
@@ -92,12 +92,13 @@
 	removed eventually.
 
 event_im_recv:
-	struct gaim_connection *gc, char **who, char **text
+	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.
 	'text' is the actual strict text (with HTML tags and all) of the
 		message they sent.
+	'flags' is message flags.
 	
 	Note that you can modify these values. (You are encouraged to do so!)
 	Note that *other* plugins can also modify these values, so you should
@@ -107,6 +108,9 @@
 	Unfortunately, it means that most plugins that use this event need to be
 	slightly modified and then recompiled.
 
+	flags is actually a bit mask. AND with IM_FLAG_AWAY to see if they were
+	away, etc.
+
 event_im_send:
 	struct gaim_connection *gc, char *who, char **text
 
@@ -287,7 +291,7 @@
 	won't be displayed at all.
 
 event_im_displayed_rcvd:
-	struct gaim_connection *gc, char *who, char *what
+	struct gaim_connection *gc, char *who, char *what, guint32 flags
 
 	This is called after what you receive is displayed. This is useful
 	for displaying an autoresponse after the message that triggered it.
@@ -297,3 +301,4 @@
 	'gc' is the connection the message was received on.
 	'who' is who sent the message.
 	'what' is what was sent.
+	'flags' is flags on the message.
--- a/src/gaim.h	Wed Sep 12 18:57:46 2001 +0000
+++ b/src/gaim.h	Wed Sep 12 21:29:32 2001 +0000
@@ -580,6 +580,10 @@
 
 #define DEFAULT_INFO "Visit the GAIM website at <A HREF=\"http://gaim.sourceforge.net/\">http://gaim.sourceforge.net/</A>."
 
+#define IM_FLAG_AWAY     0x01
+#define IM_FLAG_CHECKBOX 0x02
+#define IM_FLAG_GAIMUSER 0x04
+
 extern int report_idle;
 extern int web_browser;
 extern GList *aim_users;
@@ -663,8 +667,6 @@
 extern void serv_close(struct gaim_connection *);
 extern void serv_touch_idle(struct gaim_connection *);
 extern void serv_finish_login();
-#define IM_FLAG_AWAY     0x01
-#define IM_FLAG_CHECKBOX 0x02
 extern int  serv_send_im(struct gaim_connection *, char *, char *, int);
 extern void serv_get_info(struct gaim_connection *, char *);
 extern void serv_get_away_msg(struct gaim_connection *, char *);
@@ -695,7 +697,7 @@
 
 /* output from serv */
 extern void serv_got_update(struct gaim_connection *, char *, int, int, time_t, time_t, int, gushort);
-extern void serv_got_im(struct gaim_connection *, char *, char *, int, time_t);
+extern void serv_got_im(struct gaim_connection *, char *, char *, guint32, time_t);
 extern void serv_got_eviled(struct gaim_connection *, char *, int);
 extern void serv_got_chat_invite(struct gaim_connection *, char *, char *, char *, GList *);
 extern struct conversation *serv_got_joined_chat(struct gaim_connection *, int, char *);
--- a/src/multi.c	Wed Sep 12 18:57:46 2001 +0000
+++ b/src/multi.c	Wed Sep 12 21:29:32 2001 +0000
@@ -1094,6 +1094,7 @@
 
 	struct aim_user *u = g_new0(struct aim_user, 1);
 	g_snprintf(u->username, sizeof(u->username), "%s", name);
+	g_snprintf(u->user_info, sizeof(u->user_info), "%s", DEFAULT_INFO);
 	u->protocol = proto;
 	u->options = opts;
 	aim_users = g_list_append(aim_users, u);
--- a/src/plugins.c	Wed Sep 12 18:57:46 2001 +0000
+++ b/src/plugins.c	Wed Sep 12 21:29:32 2001 +0000
@@ -772,12 +772,12 @@
 				}
 				break;
 
-				/* struct gaim_connection *, char **, char ** */
+				/* struct gaim_connection *, char **, char **, guint32 */
 			case event_im_recv:
 				{
 					void (*function)(struct gaim_connection *, char **, char **,
-							  void *) = g->function;
-					(*function)(arg1, arg2, arg3, g->data);
+							  guint32, void *) = g->function;
+					(*function)(arg1, arg2, arg3, (guint32)arg4, g->data);
 				}
 				break;
 
@@ -832,7 +832,6 @@
 			case event_chat_buddy_leave:
 			case event_away:
 			case event_back:
-			case event_im_displayed_rcvd:
 				{
 					void (*function)(struct gaim_connection *, char *, char *,
 							  void *) = g->function;
@@ -840,6 +839,15 @@
 				}
 				break;
 
+				/* struct gaim_connection *, char *, char *, guint32 */
+			case event_im_displayed_rcvd:
+				{
+					void (*function)(struct gaim_connection *, char *, char *,
+							  guint32, void *) = g->function;
+					(*function)(arg1, arg2, arg3, (guint32)arg4, g->data);
+				}
+				break;
+
 				/* struct gaim_connection *, char *, int */
 			case event_warned:
 				{
--- a/src/protocols/irc/irc.c	Wed Sep 12 18:57:46 2001 +0000
+++ b/src/protocols/irc/irc.c	Wed Sep 12 21:29:32 2001 +0000
@@ -683,7 +683,7 @@
 		res = g_strsplit(buf, " ", 5);
 
 		if (!strcmp(res[1], "301"))
-			serv_got_im(gc, res[3], res[4] + 1, 1, time((time_t) NULL));
+			serv_got_im(gc, res[3], res[4] + 1, IM_FLAG_AWAY, time((time_t) NULL));
 
 		g_strfreev(res);
 		return;
--- a/src/protocols/msn/msn.c	Wed Sep 12 18:57:46 2001 +0000
+++ b/src/protocols/msn/msn.c	Wed Sep 12 21:29:32 2001 +0000
@@ -17,6 +17,7 @@
 #define MSN_BUF_LEN 8192
 #define MIME_HEADER	"MIME-Version: 1.0\r\n" \
 			"Content-Type: text/plain; charset=UTF-8\r\n" \
+			"User-Agent: Gaim/" VERSION "\r\n" \
 			"X-MMS-IM-Format: FN=MS%20Sans%20Serif; EF=; CO=0; PF=0\r\n\r\n"
 
 #define MSN_ONLINE  1
@@ -434,8 +435,9 @@
 	} else if (!g_strncasecmp(buf, "MSG", 3)) {
 		char *user, *tmp = buf;
 		int length;
-		char *msg, *content, *utf;
+		char *msg, *content, *agent, *utf;
 		int len, r;
+		int flags = 0;
 
 		GET_NEXT(tmp);
 		user = tmp;
@@ -456,6 +458,11 @@
 			}
 		}
 
+		agent = strstr(msg, "User-Agent: ");
+		if (agent) {
+			if (!g_strncasecmp(agent, "User-Agent: Gaim", strlen("User-Agent: Gaim")))
+				flags |= IM_FLAG_GAIMUSER;
+		}
 		content = strstr(msg, "Content-Type: ");
 		if (!content) {
 			g_free(msg);
@@ -477,9 +484,9 @@
 			g_free(utf);
 
 			if (ms->chat)
-				serv_got_chat_in(gc, ms->chat->id, user, 0, final, time(NULL));
+				serv_got_chat_in(gc, ms->chat->id, user, flags, final, time(NULL));
 			else
-				serv_got_im(gc, user, final, 0, time(NULL));
+				serv_got_im(gc, user, final, flags, time(NULL));
 
 			g_free(final);
 		}
@@ -1206,7 +1213,7 @@
 		ms->fd = -1;
 	} else
 		/* in msn you can't send messages to yourself, so we'll fake like we received it ;) */
-		serv_got_im(gc, who, message, flags & IM_FLAG_AWAY, time(NULL));
+		serv_got_im(gc, who, message, flags | IM_FLAG_GAIMUSER, time(NULL));
 	return 0;
 }
 
--- a/src/protocols/oscar/oscar.c	Wed Sep 12 18:57:46 2001 +0000
+++ b/src/protocols/oscar/oscar.c	Wed Sep 12 21:29:32 2001 +0000
@@ -58,6 +58,7 @@
 static int gaim_caps = AIM_CAPS_CHAT |
 		       AIM_CAPS_BUDDYICON |
 		       AIM_CAPS_IMIMAGE;
+static fu8_t gaim_features[] = {0x01, 0x01, 0x01, 0x02, 0x66};
 
 struct oscar_data {
 	aim_session_t *sess;
@@ -1259,6 +1260,20 @@
 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, struct aim_userinfo_s *userinfo, struct aim_incomingim_ch1_args *args) {
 	char *tmp = g_malloc(BUF_LONG);
 	struct gaim_connection *gc = sess->aux_data;
+	int flags = 0;
+
+	if (sizeof(gaim_features) == args->featureslen) {
+		int i;
+		for (i = 0; i < args->featureslen; i++) {
+			if (gaim_features[i] != args->features[i])
+				break;
+		}
+		if (i == args->featureslen)
+			flags |= IM_FLAG_GAIMUSER;
+	}
+
+	if (args->icbmflags & AIM_IMFLAGS_AWAY)
+		flags |= IM_FLAG_AWAY;
 
 	if (args->icbmflags & AIM_IMFLAGS_HASICON) {
 		struct oscar_data *od = gc->proto_data;
@@ -1327,7 +1342,7 @@
 	} else
 		g_snprintf(tmp, BUF_LONG, "%s", args->msg);
 
-	serv_got_im(gc, userinfo->sn, tmp, args->icbmflags & AIM_IMFLAGS_AWAY, time(NULL));
+	serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL));
 	g_free(tmp);
 
 	return 1;
@@ -2076,12 +2091,11 @@
 			struct icon_req *ir = NULL;
 			char *who = normalize(name);
 			struct stat st;
-			static fu8_t features[] = {0x01, 0x01, 0x01, 0x02, 0x66};
 
 			args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES;
 
-			args.features = features;
-			args.featureslen = sizeof(features);
+			args.features = gaim_features;
+			args.featureslen = sizeof(gaim_features);
 
 			while (h) {
 				ir = h->data;
--- a/src/protocols/toc/toc.c	Wed Sep 12 18:57:46 2001 +0000
+++ b/src/protocols/toc/toc.c	Wed Sep 12 21:29:32 2001 +0000
@@ -439,7 +439,7 @@
 			message++;
 		message++;
 
-		a = (away && (*away == 'T')) ? 1 : 0;
+		a = (away && (*away == 'T')) ? IM_FLAG_AWAY : 0;
 
 		serv_got_im(gc, c, message, a, time((time_t)NULL));
 	} else if (!strcasecmp(c, "UPDATE_BUDDY")) {
--- a/src/server.c	Wed Sep 12 18:57:46 2001 +0000
+++ b/src/server.c	Wed Sep 12 21:29:32 2001 +0000
@@ -387,15 +387,26 @@
 }
 
 /* woo. i'm actually going to comment this function. isn't that fun. make sure to follow along, kids */
-void serv_got_im(struct gaim_connection *gc, char *name, char *message, int away, time_t mtime)
+void serv_got_im(struct gaim_connection *gc, char *name, char *message, guint32 flags, time_t mtime)
 {
 	char *buffy;
 	char *angel;
 	int plugin_return;
+	int away = 0;
 
 	struct conversation *cnv;
 	int new_conv = 0;
 
+	/* pay no attention to the man behind the curtain.
+	 *
+	 * the reason i feel okay with this is because it's useful to some plugins.
+	 * Gaim doesn't ever use it itself. Besides, it's not entirely accurate; it's
+	 * possible to have false negatives with most protocols. Also with some it's
+	 * easy to have false positives as well. So if you're a plugin author, don't
+	 * rely on this, still do your own checks. but uh. it's a start. */
+	if (flags & IM_FLAG_GAIMUSER)
+		debug_printf("%s is a gaim user.\n", name);
+
 	/* we should update the conversation window buttons and menu, if it exists. */
 	cnv = find_conversation(name);
 	if (cnv)
@@ -410,7 +421,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, 0);
+	plugin_return = plugin_event(event_im_recv, gc, &angel, &buffy, (void *)flags);
 
 	if (!buffy || !angel || plugin_return) {
 		if (buffy)
@@ -443,7 +454,7 @@
 	/* um. when we call write_to_conv with the message we received, it's nice to pass whether
 	 * or not it was an auto-response. so if it was an auto-response, we set the appropriate
 	 * flag. this is just so prpls don't have to know about WFLAG_* (though some do anyway) */
-	if (away)
+	if (flags & IM_FLAG_AWAY)
 		away = WFLAG_AUTO;
 
 	/* alright. two cases for how to handle this. either we're away or we're not. if we're not,
@@ -578,7 +589,7 @@
 		write_to_conv(cnv, message, away | WFLAG_RECV, NULL, mtime);
 	}
 
-	plugin_event(event_im_displayed_rcvd, gc, name, message, 0);
+	plugin_event(event_im_displayed_rcvd, gc, name, message, (void *)flags);
 	g_free(name);
 	g_free(message);
 }
@@ -635,7 +646,10 @@
 			cnv = cnv->next;
 		}
 		g_free(who);
+		who = g_strdup(b->name);
 		g_snprintf(b->name, sizeof(b->name), "%s", name);
+		handle_buddy_rename(b, who);
+		g_free(who);
 		/*gtk_label_set_text(GTK_LABEL(b->label), b->name); */
 
 		/* okay lets save the new config... */