diff src/gtkconv.c @ 9324:af707cc1e229

[gaim-migrate @ 10132] Now when your buddies unset their icon, you'll no longer see it. Well on Yahoo! anyway, I doubt OSCAR actually ever tells the core when a buddy unsets his icon, since Chip just added the ability to do that a couple days ago. The caching needs to be fixed up, the file itself is never removed. I made gtkblist use GtkPixbufLoader, which i'm worried about because gtkconv has a comment about that leaking. The GaimBuddyIcon's end up being loaded from gtkblist.c, which is wrong, I think. However, they were previously not being created at all I think, except for new icons. So basicly, gtkconv and gtkblist use GaimBuddyIcon instead of loading the icon straight into a GdkPixap or whatever from the file. gtkblist will still read the file if it can't find a GaimBuddyIcon, but it creates one from the file, instead of just using the file. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Sun, 20 Jun 2004 06:57:54 +0000
parents a4257646861a
children 222eb83af4d3
line wrap: on
line diff
--- a/src/gtkconv.c	Sun Jun 20 05:39:21 2004 +0000
+++ b/src/gtkconv.c	Sun Jun 20 06:57:54 2004 +0000
@@ -5425,8 +5425,6 @@
 	FILE *file;
 	GError *err = NULL;
 
-	GaimBuddy *buddy;
-
 	const void *data;
 	size_t len;
 
@@ -5445,6 +5443,8 @@
 
 	GaimButtonStyle button_type;
 
+	GaimBuddyIcon *icon;
+
 	g_return_if_fail(conv != NULL);
 	g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv));
 	g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_IM);
@@ -5465,54 +5465,32 @@
 	if (gtkconv->u.im->anim)
 		g_object_unref(G_OBJECT(gtkconv->u.im->anim));
 
-	if((buddy = gaim_find_buddy(gaim_conversation_get_account(conv),
-					gaim_conversation_get_name(conv))) != NULL) {
-		const char *iconfile;
-		if((iconfile = gaim_blist_node_get_string((GaimBlistNode*)buddy,
-												  "buddy_icon"))) {
-			GaimBuddyIcon *icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv));
-			struct stat st;
-			if ((icon == NULL) && (!stat(iconfile, &st))) {
-				FILE *file = fopen(iconfile, "rb");
-				if (file) {
-					char *data = g_malloc(st.st_size);
-					fread(data, 1, st.st_size, file);
-					fclose(file);
-					gaim_buddy_icons_set_for_user(gaim_conversation_get_account(conv), gaim_conversation_get_name(conv), data, st.st_size);
-					g_free(data);
-				}
-				return;
-			}
-			else
-				gtkconv->u.im->anim =
-					gdk_pixbuf_animation_new_from_file(iconfile, &err); /* LEAK */
-		}
-	}
-	else
-	{
-		GaimBuddyIcon *icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv));
-
-		if (icon == NULL)
-			return;
-
-		data = gaim_buddy_icon_get_data(icon, &len);
-
-		/* this is such an evil hack, i don't know why i'm even considering it.
-		 * we'll do it differently when gdk-pixbuf-loader isn't leaky anymore. */
-		g_snprintf(filename, sizeof(filename),
-				"%s" G_DIR_SEPARATOR_S "gaimicon-%s.%d",
-				g_get_tmp_dir(), gaim_conversation_get_name(conv), getpid());
-
-		if (!(file = fopen(filename, "wb")))
-			return;
-
-		fwrite(data, 1, len, file);
-		fclose(file);
-
-		gtkconv->u.im->anim = gdk_pixbuf_animation_new_from_file(filename, &err);
-		/* make sure we remove the file as soon as possible */
-		unlink(filename);
-	}
+
+
+	icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv));
+
+	if (icon == NULL)
+		return;
+
+	data = gaim_buddy_icon_get_data(icon, &len);
+
+	/* this is such an evil hack, i don't know why i'm even considering it.
+	 * we'll do it differently when gdk-pixbuf-loader isn't leaky anymore. */
+	/* gdk-pixbuf-loader was leaky? is it still? */
+	g_snprintf(filename, sizeof(filename),
+			"%s" G_DIR_SEPARATOR_S "gaimicon-%s.%d",
+			g_get_tmp_dir(), gaim_conversation_get_name(conv), getpid());
+
+	if (!(file = fopen(filename, "wb")))
+		return;
+
+	fwrite(data, 1, len, file);
+	fclose(file);
+
+	gtkconv->u.im->anim = gdk_pixbuf_animation_new_from_file(filename, &err);
+	/* make sure we remove the file as soon as possible */
+	unlink(filename);
+
 
 	if (err) {
 		gaim_debug(GAIM_DEBUG_ERROR, "gtkconv",