diff libgaim/protocols/qq/keep_alive.c @ 15072:902f3621aa13

[gaim-migrate @ 17855] Use the QQ faces as buddy icons instead of status icons. Also, a few minor cleanups and a bug fix for faces > 33. committer: Tailor Script <tailor@pidgin.im>
author Mark Huetsch <markhuetsch>
date Thu, 30 Nov 2006 10:30:13 +0000
parents c039c920e11c
children e952a5fc97b3
line wrap: on
line diff
--- a/libgaim/protocols/qq/keep_alive.c	Thu Nov 30 10:19:09 2006 +0000
+++ b/libgaim/protocols/qq/keep_alive.c	Thu Nov 30 10:30:13 2006 +0000
@@ -31,6 +31,7 @@
 #include "debug.h"
 #include "server.h"
 
+#include "buddy_info.h"
 #include "buddy_list.h"
 #include "buddy_status.h"
 #include "crypt.h"
@@ -118,6 +119,20 @@
 	}
 }
 
+static void _qq_update_buddy_icon(GaimAccount *account, const gchar *name, gint face)
+{
+	GaimBuddyIcon *icon = gaim_buddy_icons_find(account, name);
+	gchar *icon_num_str = face_to_icon_str(face);
+	gchar *icon_path = g_strconcat(QQBUDDYICONDIR, G_DIR_SEPARATOR_S,
+			QQ_ICON_PREFIX, icon_num_str, QQ_ICON_SUFFIX, NULL);
+	const gchar *old_path = gaim_buddy_icon_get_path(icon);
+	if (icon == NULL || old_path == NULL 
+		|| g_ascii_strcasecmp(icon_path, old_path) != 0)
+		qq_set_buddy_icon_for_user(account, name, icon_path);
+	g_free(icon_num_str);
+	g_free(icon_path);
+}
+
 void qq_update_buddy_contact(GaimConnection *gc, qq_buddy *q_bud)
 {
 	gchar *name;
@@ -161,6 +176,7 @@
 		}
 		gaim_debug(GAIM_DEBUG_INFO, "QQ", "set buddy %d to %s\n", q_bud->uid, status_id);
 		gaim_prpl_got_user_status(gc->account, name, status_id, NULL);
+		_qq_update_buddy_icon(gc->account, name, q_bud->face);
 	} else {
 		gaim_debug(GAIM_DEBUG_ERROR, "QQ", "unknown buddy: %d\n", q_bud->uid);
 	}