changeset 9310:085190b9dd64

[gaim-migrate @ 10118] This is supposed to make us alert our buddies when we change our buddy icon, or turn it off. Except it crashes when we turn it off. But I think that's either Sean's fault or else Chip's fault. Also its supposed to make us announce our buddy icon when we log on if we have an old one set. But I don't think it does. Or was that the last commit that was supposed to do taht? either way it doesn't work for some reason, I need more packet dumps. It does succeed in announing our buddy icon to everyone when we set one. Well except people not on our list. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Sat, 19 Jun 2004 07:11:53 +0000
parents ade6b9c0dc8a
children c5fdff22b252
files src/protocols/yahoo/yahoo.c src/protocols/yahoo/yahoo_picture.c src/protocols/yahoo/yahoo_picture.h
diffstat 3 files changed, 72 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/yahoo/yahoo.c	Sat Jun 19 06:47:34 2004 +0000
+++ b/src/protocols/yahoo/yahoo.c	Sat Jun 19 07:11:53 2004 +0000
@@ -453,7 +453,7 @@
 			b = gaim_find_buddy(gc->account, name);
 			yahoo_friend_set_buddy_icon_need_request(f, FALSE);
 			if (cksum != gaim_blist_node_get_int((GaimBlistNode*)b, YAHOO_ICON_CHECKSUM_KEY))
-				yahoo_send_buddy_icon_request(gc, name);
+				yahoo_send_picture_request(gc, name);
 
 			break;
 		}
@@ -806,7 +806,7 @@
 
 		if ((f = yahoo_friend_find(gc, im->from)) && im->buddy_icon == 2) {
 			if (yahoo_friend_get_buddy_icon_need_request(f)) {
-				yahoo_send_buddy_icon_request(gc, im->from);
+				yahoo_send_picture_request(gc, im->from);
 				yahoo_friend_set_buddy_icon_need_request(f, FALSE);
 			}
 		}
--- a/src/protocols/yahoo/yahoo_picture.c	Sat Jun 19 06:47:34 2004 +0000
+++ b/src/protocols/yahoo/yahoo_picture.c	Sat Jun 19 07:11:53 2004 +0000
@@ -42,6 +42,8 @@
 	int checksum;
 };
 
+
+
 void yahoo_fetch_picture_cb(void *user_data, const char *pic_data, size_t len)
 {
 	struct yahoo_fetch_picture_data *d = user_data;
@@ -167,7 +169,7 @@
 
 	if (who) {
 		if (icon == 2)
-			yahoo_send_buddy_icon_request(gc, who);
+			yahoo_send_picture_request(gc, who);
 		else if (icon == 0)
 			gaim_buddy_icons_set_for_user(gc->account, who, NULL, 0);
 	}
@@ -199,7 +201,7 @@
 	if (who) {
 		GaimBuddy *b = gaim_find_buddy(gc->account, who);
 		if (b && (checksum != gaim_blist_node_get_int((GaimBlistNode*)b, YAHOO_ICON_CHECKSUM_KEY)))
-			yahoo_send_buddy_icon_request(gc, who);
+			yahoo_send_picture_request(gc, who);
 	}
 }
 
@@ -234,11 +236,13 @@
 		yd->picture_url = g_strdup(url);
 		gaim_account_set_string(account, YAHOO_PICURL_SETTING, url);
 		gaim_account_set_int(account, YAHOO_PICCKSUM_SETTING, yd->picture_checksum);
+		yahoo_send_picture_update(gc, 2);
+		yahoo_send_picture_checksum(gc);
 	}
 }
 
 
-void yahoo_send_buddy_icon_request(GaimConnection *gc, const char *who)
+void yahoo_send_picture_request(GaimConnection *gc, const char *who)
 {
 	struct yahoo_data *yd = gc->proto_data;
 	struct yahoo_packet *pkt;
@@ -251,6 +255,63 @@
 	yahoo_packet_free(pkt);
 }
 
+void yahoo_send_picture_checksum(GaimConnection *gc)
+{
+	struct yahoo_data *yd = gc->proto_data;
+	struct yahoo_packet *pkt;
+	char *cksum = g_strdup_printf("%d", yd->picture_checksum);
+
+	pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_CHECKSUM, YAHOO_STATUS_AVAILABLE, 0);
+	yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
+	yahoo_packet_hash(pkt, 212, "1");
+	yahoo_packet_hash(pkt, 192, cksum);
+	yahoo_send_packet(yd, pkt);
+	yahoo_packet_free(pkt);
+	g_free(cksum);
+}
+
+void yahoo_send_picture_update_to_user(GaimConnection *gc, const char *who, int type)
+{
+	struct yahoo_data *yd = gc->proto_data;
+	struct yahoo_packet *pkt;
+	char *typestr = g_strdup_printf("%d", type);
+
+	pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPDATE, YAHOO_STATUS_AVAILABLE, 0);
+	yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
+	yahoo_packet_hash(pkt, 5, who);
+	yahoo_packet_hash(pkt, 206, typestr);
+	yahoo_send_packet(yd, pkt);
+	yahoo_packet_free(pkt);
+
+	g_free(typestr);
+}
+
+struct yspufe {
+	GaimConnection *gc;
+	int type;
+};
+
+static void yahoo_send_picture_update_foreach(gpointer key, gpointer value, gpointer data)
+{
+	char *who = key;
+	YahooFriend *f = value;
+	struct yspufe *d = data;
+
+	if (f->status != YAHOO_STATUS_OFFLINE)
+		yahoo_send_picture_update_to_user(d->gc, who, d->type);
+}
+
+void yahoo_send_picture_update(GaimConnection *gc, int type)
+{
+	struct yahoo_data *yd = gc->proto_data;
+	struct yspufe data;
+
+	data.gc = gc;
+	data.type = type;
+
+	g_hash_table_foreach(yd->friends, yahoo_send_picture_update_foreach, &data);
+}
+
 void yahoo_buddy_icon_upload_data_free(struct yahoo_buddy_icon_upload_data *d)
 {
 	gaim_debug_misc("yahoo", "In yahoo_buddy_icon_upload_data_free()\n");
@@ -410,6 +471,8 @@
 		gaim_account_set_string(account, YAHOO_PICURL_SETTING, NULL);
 		gaim_account_set_int(account, YAHOO_PICCKSUM_SETTING, 0);
 		gaim_account_set_int(account, YAHOO_PICEXPIRE_SETTING, 0);
+		if (yd->logged_in)
+			yahoo_send_picture_update(gc, 0);
 		/* TODO: check if we're connected and tell everyone we ain't not one no more */
 	} else if (!stat(iconfile, &st)) {
 		file = fopen(iconfile, "rb");
--- a/src/protocols/yahoo/yahoo_picture.h	Sat Jun 19 06:47:34 2004 +0000
+++ b/src/protocols/yahoo/yahoo_picture.h	Sat Jun 19 07:11:53 2004 +0000
@@ -24,8 +24,11 @@
 #ifndef _YAHOO_PICTURE_H_
 #define _YAHOO_PICTURE_H_
 
-void yahoo_send_buddy_icon_request(GaimConnection *gc, const char *who);
+void yahoo_send_picture_request(GaimConnection *gc, const char *who);
 void yahoo_send_picture_info(GaimConnection *gc, const char *who);
+void yahoo_send_picture_checksum(GaimConnection *gc);
+void yahoo_send_picture_update(GaimConnection *gc, int type);
+void yahoo_send_picture_update_to_user(GaimConnection *gc, const char *who, int type);
 
 void yahoo_process_picture(GaimConnection *gc, struct yahoo_packet *pkt);
 void yahoo_process_picture_update(GaimConnection *gc, struct yahoo_packet *pkt);