changeset 16208:85d5942e80e9

Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to Pidgin Monotone. Original commit messages: Bug 1671638 fixed bhpan. Bug 1658961 fixed by gnap. Fixed a bug where gaim was playing n x n times user leaving chat room sound when opening a QQ protocol chat room, n equaling the number of users in the chat room. Patch by gnap.
author Mark Doliner <mark@kingant.net>
date Mon, 16 Apr 2007 06:37:20 +0000
parents 6ded371da50f
children 416a125b66ac
files libpurple/protocols/qq/buddy_info.c libpurple/protocols/qq/buddy_info.h libpurple/protocols/qq/buddy_list.c libpurple/protocols/qq/group_conv.c libpurple/protocols/qq/group_im.c libpurple/protocols/qq/im.c
diffstat 6 files changed, 48 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/qq/buddy_info.c	Mon Apr 16 05:37:44 2007 +0000
+++ b/libpurple/protocols/qq/buddy_info.c	Mon Apr 16 06:37:20 2007 +0000
@@ -741,19 +741,17 @@
 	qq_send_cmd(gc, QQ_CMD_GET_LEVEL, TRUE, 0, TRUE, buf, 5);
 }
 
-/*
 void qq_send_packet_get_buddies_levels(PurpleConnection *gc)
 {
-	guint8 *buf, *tmp, size;
+	guint8 *buf, *tmp;
+	guint16 size;
 	qq_buddy *q_bud;
 	qq_data *qd = (qq_data *) gc->proto_data;
 	GList *node = qd->buddies;
 
 	if (qd->buddies) {
-*/
 		/* server only sends back levels for online buddies, no point
  	 	* in asking for anyone else */
-/*
 		size = 4*g_list_length(qd->buddies) + 1;
 		buf = g_new0(guint8, size);
 		tmp = buf + 1;
@@ -772,7 +770,6 @@
 		g_free(buf);
 	}
 }
-*/
 
 void qq_process_get_level_reply(guint8 *buf, gint buf_len, PurpleConnection *gc)
 {
--- a/libpurple/protocols/qq/buddy_info.h	Mon Apr 16 05:37:44 2007 +0000
+++ b/libpurple/protocols/qq/buddy_info.h	Mon Apr 16 06:37:20 2007 +0000
@@ -93,9 +93,7 @@
 void qq_process_get_info_reply(guint8 *buf, gint buf_len, PurpleConnection *gc);
 void qq_info_query_free(qq_data *qd);
 void qq_send_packet_get_level(PurpleConnection *gc, guint32 uid);
-/*
 void qq_send_packet_get_buddies_levels(PurpleConnection *gc);
-*/
 void qq_process_get_level_reply(guint8 *buf, gint buf_len, PurpleConnection *gc);
 
 #endif
--- a/libpurple/protocols/qq/buddy_list.c	Mon Apr 16 05:37:44 2007 +0000
+++ b/libpurple/protocols/qq/buddy_list.c	Mon Apr 16 06:37:20 2007 +0000
@@ -234,7 +234,7 @@
 
 			qq_send_packet_get_buddies_online(gc, position);
 		} else {
-			/* qq_send_packet_get_buddies_levels(gc); */
+			qq_send_packet_get_buddies_levels(gc);
 			qq_refresh_all_buddy_status(gc);
 		}
 
--- a/libpurple/protocols/qq/group_conv.c	Mon Apr 16 05:37:44 2007 +0000
+++ b/libpurple/protocols/qq/group_conv.c	Mon Apr 16 06:37:20 2007 +0000
@@ -50,36 +50,54 @@
 {
 	GList *names, *list, *flags;
 	qq_buddy *member;
-	gchar *member_name;
+	gchar *member_name, *member_uid;
 	PurpleConversation *conv;
 	gint flag;
 	g_return_if_fail(group != NULL);
 
 	names = NULL;
 	flags = NULL;
-	conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, 
+	conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT,
 			group->group_name_utf8, purple_connection_get_account(gc));
 	if (conv != NULL && group->members != NULL) {
 		list = group->members;
 		while (list != NULL) {
 			member = (qq_buddy *) list->data;
-			/* always put it even offline */
-			names = g_list_append(names,
-					/* we need unique identifiers for everyone in the chat or else we'll 
- 					* run into problems with functions like get_cb_real_name from qq.c */
-					(member->nickname != NULL && *(member->nickname) != '\0') ?
+
+			/* we need unique identifiers for everyone in the chat or else we'll
+			 * run into problems with functions like get_cb_real_name from qq.c */
+			member_name =   (member->nickname != NULL && *(member->nickname) != '\0') ?
 					g_strdup_printf("%s (qq-%u)", member->nickname, member->uid) :
-					g_strdup_printf("(qq-%u)", member->uid));
+					g_strdup_printf("(qq-%u)", member->uid);
+			member_uid = g_strdup_printf("(qq-%u)", member->uid);
+
 			flag = 0;
 			/* TYPING to put online above OP and FOUNDER */
-			if (is_online(member->status)) flag |= (PURPLE_CBFLAGS_TYPING | PURPLE_CBFLAGS_VOICE);
+			if (is_online(member->status))
+				flag |= (PURPLE_CBFLAGS_TYPING | PURPLE_CBFLAGS_VOICE);
 			if(1 == (member->role & 1)) flag |= PURPLE_CBFLAGS_OP;
 			if(member->uid == group->creator_uid) flag |= PURPLE_CBFLAGS_FOUNDER;
-			flags = g_list_append(flags, GINT_TO_POINTER(flag));
+
+			if (purple_conv_chat_find_user(PURPLE_CONV_CHAT(conv), member_name))
+			{
+				purple_conv_chat_user_set_flags(PURPLE_CONV_CHAT(conv),
+						member_name,
+						flag);
+			} else if (purple_conv_chat_find_user(PURPLE_CONV_CHAT(conv), member_uid))
+			{
+				purple_conv_chat_user_set_flags(PURPLE_CONV_CHAT(conv),
+						member_uid,
+						flag);
+				purple_conv_chat_rename_user(PURPLE_CONV_CHAT(conv), member_uid, member_name);
+			} else {
+				/* always put it even offline */
+				names = g_list_append(names, member_name);
+				flags = g_list_append(flags, GINT_TO_POINTER(flag));
+			}
+			g_free(member_uid);
 			list = list->next;
 		}
-		
-		purple_conv_chat_clear_users(PURPLE_CONV_CHAT(conv));
+
 		purple_conv_chat_add_users(PURPLE_CONV_CHAT(conv), names, NULL, flags, FALSE);
 	}
 	/* clean up names */
@@ -88,5 +106,5 @@
 		names = g_list_remove(names, member_name);
 		g_free(member_name);
 	}
-	g_list_free(flags);	
+	g_list_free(flags);
 }
--- a/libpurple/protocols/qq/group_im.c	Mon Apr 16 05:37:44 2007 +0000
+++ b/libpurple/protocols/qq/group_im.c	Mon Apr 16 06:37:20 2007 +0000
@@ -63,6 +63,7 @@
 	g_return_if_fail(group != NULL && msg != NULL);
 
 	msg_filtered = purple_markup_strip_html(msg);
+	purple_debug_info("QQ_MESG", "filterd qq qun mesg: %s\n", msg_filtered);
 	msg_len = strlen(msg_filtered);
 	data_len = 7 + msg_len + QQ_SEND_IM_AFTER_MSG_LEN;
 	raw_data = g_newa(guint8, data_len);
--- a/libpurple/protocols/qq/im.c	Mon Apr 16 05:37:44 2007 +0000
+++ b/libpurple/protocols/qq/im.c	Mon Apr 16 06:37:20 2007 +0000
@@ -123,7 +123,7 @@
 			    const gchar *font_name,
 			    gboolean is_bold, gboolean is_italic, gboolean is_underline, gint tail_len)
 {
-	gchar *s1, *s2;
+	gchar *s1;
 	unsigned char *rgb;
 	gint font_name_len;
 	guint8 *send_im_tail;
@@ -159,13 +159,20 @@
 		s1 = g_strndup(font_color + 1, 6);
 		/* Henry: maybe this is a bug of purple, the string should have
 		 * the length of odd number @_@
+		 * George Ang: This BUG maybe fixed by Purple. adding new byte
+		 * would cause a crash.
 		 */
-		s2 = g_strdup_printf("%sH", s1);
-		rgb = purple_base16_decode(s2, NULL);
+		/* s2 = g_strdup_printf("%sH", s1); */
+		rgb = purple_base16_decode(s1, NULL);
 		g_free(s1);
-		g_free(s2);
-		memcpy(send_im_tail + 2, rgb, 3);
-		g_free(rgb);
+		/* g_free(s2); */
+		if (rgb)
+		{
+			memcpy(send_im_tail + 2, rgb, 3);
+			g_free(rgb);
+		} else {
+			send_im_tail[2] = send_im_tail[3] = send_im_tail[4] = 0;
+		}
 	} else {
 		send_im_tail[2] = send_im_tail[3] = send_im_tail[4] = 0;
 	}