changeset 13849:8d1c55309e3c

[gaim-migrate @ 16306] Keep track of the Yahoo! IMVironment specified by the people we're IMing with. When we reply to their IMs, we now send the same IMVironment instead of always sending an empty IMVironment because sending an empty IMVironment would reset their IMVironment back to nothing. This shouldn't negatively affect the Doodle stuff... but it didn't work for me when I tested it, so it's hard to tell. This is a change I made while at Meebo committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 22 Jun 2006 06:26:38 +0000
parents b43971b34053
children 0e1e59770cb0
files src/protocols/yahoo/yahoo.c src/protocols/yahoo/yahoo.h src/protocols/yahoo/yahoo_filexfer.c
diffstat 3 files changed, 70 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/yahoo/yahoo.c	Wed Jun 21 15:19:28 2006 +0000
+++ b/src/protocols/yahoo/yahoo.c	Thu Jun 22 06:26:38 2006 +0000
@@ -670,6 +670,7 @@
 
 static void yahoo_process_message(GaimConnection *gc, struct yahoo_packet *pkt)
 {
+	struct yahoo_data *yd = gc->proto_data;
 	GSList *l = pkt->hash;
 	GSList *list = NULL;
 	struct _yahoo_im *im = NULL;
@@ -712,24 +713,29 @@
 
 	/** TODO: It seems that this check should be per IM, not global */
 	/* Check for the Doodle IMV */
-	if(im != NULL && imv != NULL && !strcmp(imv, "doodle;11"))
+	if (im != NULL && imv!= NULL && im->from != NULL)
 	{
-		GaimWhiteboard *wb;
-
-		if (!yahoo_privacy_check(gc, im->from)) {
-			gaim_debug_info("yahoo", "Doodle request from %s dropped.\n", im->from);
-			return;
-		}
-
-		wb = gaim_whiteboard_get_session(gc->account, im->from);
-
-		/* If a Doodle session doesn't exist between this user */
-		if(wb == NULL)
+		g_hash_table_replace(yd->imvironments, g_strdup(im->from), g_strdup(imv));
+
+		if (strcmp(imv, "doodle;11") == 0)
 		{
-			wb = gaim_whiteboard_create(gc->account, im->from, DOODLE_STATE_REQUESTED);
-
-			yahoo_doodle_command_send_request(gc, im->from);
-			yahoo_doodle_command_send_ready(gc, im->from);
+			GaimWhiteboard *wb;
+
+			if (!yahoo_privacy_check(gc, im->from)) {
+				gaim_debug_info("yahoo", "Doodle request from %s dropped.\n", im->from);
+				return;
+			}
+
+			wb = gaim_whiteboard_get_session(gc->account, im->from);
+
+			/* If a Doodle session doesn't exist between this user */
+			if(wb == NULL)
+			{
+				wb = gaim_whiteboard_create(gc->account, im->from, DOODLE_STATE_REQUESTED);
+
+				yahoo_doodle_command_send_request(gc, im->from);
+				yahoo_doodle_command_send_ready(gc, im->from);
+			}
 		}
 	}
 
@@ -2576,6 +2582,7 @@
 	/* TODO: Is there a good grow size for the buffer? */
 	yd->txbuf = gaim_circ_buffer_new(0);
 	yd->friends = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, yahoo_friend_free);
+	yd->imvironments = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
 	yd->confs = NULL;
 	yd->conf_id = 2;
 
@@ -2628,6 +2635,7 @@
 		yahoo_c_leave(gc, 1); /* 1 = YAHOO_CHAT_ID */
 
 	g_hash_table_destroy(yd->friends);
+	g_hash_table_destroy(yd->imvironments);
 	g_free(yd->chat_name);
 
 	g_free(yd->cookie_y);
@@ -3101,14 +3109,30 @@
 		yahoo_packet_hash_str(pkt, 97, "1");
 	yahoo_packet_hash_str(pkt, 14, msg2);
 
-	/* If this message is to a user who is also Doodling with the local user,
+	/*
+	 * IMVironment.
+	 *
+	 * If this message is to a user who is also Doodling with the local user,
 	 * format the chat packet with the correct IMV information (thanks Yahoo!)
-	*/
-	wb = gaim_whiteboard_get_session(gc->account, (char*)who);
+	 *
+	 * Otherwise attempt to use the same IMVironment as the remote user,
+	 * just so that we don't inadvertantly reset their IMVironment back
+	 * to nothing.
+	 *
+	 * If they have no set an IMVironment, then use the default.
+	 */
+	wb = gaim_whiteboard_get_session(gc->account, who);
 	if (wb)
-		yahoo_packet_hash_str(pkt,   63, "doodle;11");
+		yahoo_packet_hash_str(pkt, 63, "doodle;11");
 	else
-		yahoo_packet_hash_str(pkt,   63, ";0"); /* IMvironment */
+	{
+		const char *imv;
+		imv = g_hash_table_lookup(yd->imvironments, who);
+		if (imv != NULL)
+			yahoo_packet_hash_str(pkt, 63, imv);
+		else
+			yahoo_packet_hash_str(pkt, 63, ";0");
+	}
 
 	yahoo_packet_hash_str(pkt,   64, "0"); /* no idea */
 	yahoo_packet_hash_str(pkt, 1002, "1"); /* no idea, Yahoo 6 or later only it seems */
--- a/src/protocols/yahoo/yahoo.h	Wed Jun 21 15:19:28 2006 +0000
+++ b/src/protocols/yahoo/yahoo.h	Thu Jun 22 06:26:38 2006 +0000
@@ -105,6 +105,16 @@
 	GaimCircBuffer *txbuf;
 	guint txhandler;
 	GHashTable *friends;
+
+	/**
+	 * This is used to keep track of the IMVironment chosen
+	 * by people you talk to.  We don't do very much with
+	 * this right now... but at least now if the remote user
+	 * selects an IMVironment we won't reset it back to the
+	 * default of nothing.
+	 */
+	GHashTable *imvironments;
+
 	int current_status;
 	gboolean logged_in;
 	GString *tmp_serv_blist, *tmp_serv_ilist, *tmp_serv_plist;
--- a/src/protocols/yahoo/yahoo_filexfer.c	Wed Jun 21 15:19:28 2006 +0000
+++ b/src/protocols/yahoo/yahoo_filexfer.c	Thu Jun 22 06:26:38 2006 +0000
@@ -481,14 +481,18 @@
 	char *to = NULL;
 	char *msg = NULL;
 	char *url = NULL;
+	char *imv = NULL;
 	long expires = 0;
 	GaimXfer *xfer;
+	struct yahoo_data *yd;
 	struct yahoo_xfer_data *xfer_data;
 	char *service = NULL;
 	char *filename = NULL;
 	unsigned long filesize = 0L;
 	GSList *l;
 
+	yd = gc->proto_data;
+
 	for (l = pkt->hash; l; l = l->next) {
 		struct yahoo_pair *pair = l->data;
 
@@ -508,6 +512,17 @@
 			filesize = atol(pair->value);
 		if (pair->key == 49)
 			service = pair->value;
+		if (pair->key == 63)
+			imv = pair->value;
+	}
+
+	/*
+	 * The remote user has changed their IMVironment.  We
+	 * record it for later use.
+	 */
+	if (from && imv && service && (strcmp("IMVIRONMENT", service) == 0)) {
+		g_hash_table_replace(yd->imvironments, g_strdup(from), g_strdup(imv));
+		return;
 	}
 
 	if (pkt->service == YAHOO_SERVICE_P2PFILEXFER) {