pidgin: 5316525f: 2008.09.11 - csyfek <csyfek(at)gmail.com...

csyfek at gmail.com csyfek at gmail.com
Fri Sep 12 10:30:33 EDT 2008


-----------------------------------------------------------------
Revision: 5316525f53e27f838d18a6a08b82c7d55f674591
Ancestor: 5688199e261449d33b5803dafff50d860896ebcb
Author: csyfek at gmail.com
Date: 2008-09-11T13:34:33
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/5316525f53e27f838d18a6a08b82c7d55f674591

Modified files:
        libpurple/protocols/qq/ChangeLog
        libpurple/protocols/qq/buddy_list.c
        libpurple/protocols/qq/char_conv.c
        libpurple/protocols/qq/group.c
        libpurple/protocols/qq/group.h
        libpurple/protocols/qq/group_conv.c
        libpurple/protocols/qq/group_internal.c
        libpurple/protocols/qq/group_internal.h
        libpurple/protocols/qq/qq.c libpurple/protocols/qq/qq.h
        libpurple/protocols/qq/qq_network.c
        libpurple/protocols/qq/qq_process.c
        libpurple/protocols/qq/qq_trans.c

ChangeLog: 

2008.09.11 - csyfek <csyfek(at)gmail.com>
	* Commit to Pidgin

2008.09.05 - ccpaging <ccpaging(at)gmail.com>
	* Filter chars 0x01-0x20 in nickname

2008.09.05 - ccpaging <ccpaging(at)gmail.com>
	* Fixed compilation even pidgin-udp-patch not applied
	* Place and analysis 'before login packet' after login. packages will be updated slowly and server may send 
lots of 'server command packet', while 'before login packet' is placed after 'finished update'

-------------- next part --------------
============================================================
--- libpurple/protocols/qq/ChangeLog	d1c1aa5ec35e4616ee6b82d1902fb89aa8c8e8d8
+++ libpurple/protocols/qq/ChangeLog	0456e2f7c48bc5b2c037bffffd418e018963ef04
@@ -1,3 +1,20 @@
+2008.09.05 - ccpaging <ccpaging(at)gmail.com>
+	* Filter chars 0x01-0x20 in nickname
+
+2008.09.05 - ccpaging <ccpaging(at)gmail.com>
+	* Fixed compilation even pidgin-udp-patch not applied
+	* Place and analysis 'before login packet' after login. packages will be updated slowly and server may send lots of 'server command packet', while 'before login packet' is placed after 'finished update'
+
+2008.09.02 - ccpaging <ccpaging(at)gmail.com>
+	* Bugfix: can not send message to the QUN blocked adding
+	* Tickets:
+		Fixes #6957
+
+2008.09.02 - ccpaging <ccpaging(at)gmail.com>
+	* Use new tactics of information update:
+		1. send next package till the previous package received
+		2. fix duplicated get_room_info and get_room_buddies commands
+
 2008.08.16 - ccpaging <ecc_hy(at)hotmail.com>
 	* Rename group to room. If you used pidginqq before, this may create a new room with same title, you may delete old one
 	* Replace purple_debug with purple_debug_info, purple_debug_warning, purple_debug_error
@@ -5,6 +22,8 @@ 2008.08.16 - ccpaging <ecc_hy(at)hotmail
 	* Minor modify for reducing transaction's debug infor
 	* Minor modifies for system notice and QQ news.
 	* Add 4 new strings need translate compare with p10.
+	* Tickets:
+		Fixes #6990
 
 2008.08.10 - csyfek <csyfek(at)gmail.com>
 	* Commit to Pidgin
============================================================
--- libpurple/protocols/qq/buddy_list.c	f14c4c18ff26ac1ab9185899b1c84f094a00da8a
+++ libpurple/protocols/qq/buddy_list.c	7ecaa1ef8197c4a10c2459438c1235736cdb97fb
@@ -292,6 +292,7 @@ guint16 qq_process_get_buddies_list_repl
 
 		pascal_len = convert_as_pascal_string(data + bytes, &q_bud->nickname, QQ_CHARSET_DEFAULT);
 		bytes += pascal_len;
+		qq_filter_str(q_bud->nickname);
 
 		bytes += qq_get16(&unknown, data + bytes);
 		bytes += qq_get8(&q_bud->ext_flag, data + bytes);
============================================================
--- libpurple/protocols/qq/char_conv.c	5ab4d96c8a4512a964b50263e2fd8588ecc37dc0
+++ libpurple/protocols/qq/char_conv.c	eee3c39ca1bb92e50e3b9092341ffce8d4071f19
@@ -98,7 +98,7 @@ static gboolean _check_underline(gchar f
 }
 
 /* convert a string from from_charset to to_charset, using g_convert */
-static gchar *_my_convert(const gchar *str, gssize len, const gchar *to_charset, const gchar *from_charset) 
+static gchar *_my_convert(const gchar *str, gssize len, const gchar *to_charset, const gchar *from_charset)
 {
 	GError *error = NULL;
 	gchar *ret;
@@ -111,7 +111,7 @@ static gchar *_my_convert(const gchar *s
 	if (error == NULL) {
 		return ret;	/* conversion is OK */
 	}
-	
+
 	/* conversion error */
 	purple_debug_error("QQ_CONVERT", "%s\n", error->message);
 
@@ -127,8 +127,8 @@ static gchar *_my_convert(const gchar *s
  * take the input as a pascal string and return a converted c-string in UTF-8
  * returns the number of bytes read, return -1 if fatal error
  * the converted UTF-8 will be saved in ret
- */ 
-gint convert_as_pascal_string(guint8 *data, gchar **ret, const gchar *from_charset) 
+ */
+gint convert_as_pascal_string(guint8 *data, gchar **ret, const gchar *from_charset)
 {
 	guint8 len;
 
@@ -222,7 +222,7 @@ gchar *qq_to_utf8(const gchar *str, cons
 	return _my_convert(str, -1, UTF8, from_charset);
 }
 
-/* QQ uses binary code for smiley, while purple uses strings. 
+/* QQ uses binary code for smiley, while purple uses strings.
  * There is a mapping relation between these two. */
 gchar *qq_smiley_to_purple(gchar *text)
 {
@@ -286,7 +286,8 @@ void qq_filter_str(gchar *str) {
 	}
 
 	for (temp = str; *temp != 0; temp++) {
-		if (*temp == '\r' || *temp == '\n')  *temp = ' ';
+		/*if (*temp == '\r' || *temp == '\n')  *temp = ' ';*/
+		if (*temp > 0 && *temp < 0x20)  *temp = ' ';
 	}
 	g_strstrip(str);
 }
============================================================
--- libpurple/protocols/qq/group.c	b63a859e4c351c158e6a89d580e3f27d8c274c59
+++ libpurple/protocols/qq/group.c	4156644554b1da039cbb013b3ca1318d700fedd5
@@ -66,7 +66,7 @@ GList *qq_chat_info(PurpleConnection *gc
 	pce->label = _("ID: ");
 	pce->identifier = QQ_ROOM_KEY_EXTERNAL_ID;
 	m = g_list_append(m, pce);
-	
+
 	return m;
 }
 
@@ -120,9 +120,9 @@ PurpleRoomlist *qq_roomlist_get_list(Pur
 	purple_request_input(gc, _("QQ Qun"),
 			   _("Please enter Qun number"),
 			   _("You can only search for permanent Qun\n"),
-			   NULL, FALSE, FALSE, NULL, 
-			   _("Search"), G_CALLBACK(_qq_group_search_callback), 
-			   _("Cancel"), G_CALLBACK(_qq_group_search_cancel_callback), 
+			   NULL, FALSE, FALSE, NULL,
+			   _("Search"), G_CALLBACK(_qq_group_search_callback),
+			   _("Cancel"), G_CALLBACK(_qq_group_search_cancel_callback),
 			   purple_connection_get_account(gc), NULL, NULL,
 			   gc);
 
@@ -170,7 +170,7 @@ void qq_group_init(PurpleConnection *gc)
 		chat = (PurpleChat *) node;
 		if (account != chat->account)	/* not qq account*/
 			continue;
-		group = qq_group_from_hashtable(gc, chat->components);
+		group = qq_room_create_by_hashtable(gc, chat->components);
 		if (group == NULL)
 			continue;
 
============================================================
--- libpurple/protocols/qq/group.h	138edcd1acfee105682a012c88f97c552670320b
+++ libpurple/protocols/qq/group.h	a5ada1a95240ff97011fc79af2478f1c5964af15
@@ -55,6 +55,8 @@ typedef struct _qq_group {
 	/* all these will be loaded from the network */
 	gchar *notice_utf8;	/* group notice by admin */
 	GList *members;
+
+	gboolean is_got_info;
 } qq_group;
 
 GList *qq_chat_info(PurpleConnection *gc);
============================================================
--- libpurple/protocols/qq/group_conv.c	eacacc7569f2243765407fc3e1c386cdc5f530de
+++ libpurple/protocols/qq/group_conv.c	074bbf6f60a497fd05ecc24032b818243819bbb2
@@ -44,7 +44,7 @@ PurpleConversation *qq_room_conv_create(
 	conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT,
 			group->title_utf8, purple_connection_get_account(gc));
 	if (conv != NULL)	{
-		/* show only one window per group */
+		/* show only one conversation per group */
 		return conv;
 	}
 
@@ -52,8 +52,10 @@ PurpleConversation *qq_room_conv_create(
 	conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, group->title_utf8, purple_connection_get_account(gc));
 	if (conv != NULL) {
 		purple_conv_chat_set_topic(PURPLE_CONV_CHAT(conv), NULL, group->notice_utf8);
-		/* qq_update_room(gc, 0, group->id); */
-		qq_send_room_cmd_only(gc, QQ_ROOM_CMD_GET_ONLINES, group->id);
+		if (group->is_got_info)
+			qq_send_room_cmd_only(gc, QQ_ROOM_CMD_GET_ONLINES, group->id);
+		else
+			qq_update_room(gc, 0, group->id);
 		return conv;
 	}
 	return NULL;
============================================================
--- libpurple/protocols/qq/group_internal.c	5b542d1d030bca842d226cd9a8045b6b53d6d190
+++ libpurple/protocols/qq/group_internal.c	9c1c472072ff1a2fbe1ca02066b0ecb6b9ebf9b6
@@ -143,7 +143,7 @@ GHashTable *qq_group_to_hashtable(qq_gro
 }
 
 /* create a qq_group from hashtable */
-qq_group *qq_group_from_hashtable(PurpleConnection *gc, GHashTable *data)
+qq_group *qq_room_create_by_hashtable(PurpleConnection *gc, GHashTable *data)
 {
 	qq_data *qd;
 	qq_group *group;
@@ -168,9 +168,9 @@ qq_group *qq_group_from_hashtable(Purple
 	group->title_utf8 = g_strdup(g_hash_table_lookup(data, QQ_ROOM_KEY_TITLE_UTF8));
 	group->desc_utf8 = g_strdup(g_hash_table_lookup(data, QQ_ROOM_KEY_DESC_UTF8));
 	group->my_role_desc = get_role_desc(group);
+	group->is_got_info = FALSE;
 
 	qd->groups = g_list_append(qd->groups, group);
-
 	return group;
 }
 
@@ -192,7 +192,7 @@ void qq_group_refresh(PurpleConnection *
 	if (chat == NULL) {
 		return;
 	}
-	
+
 	/* we have a local record, update its info */
 	/* if there is title_utf8, we update the group name */
 	if (group->title_utf8 != NULL && strlen(group->title_utf8) > 0)
============================================================
--- libpurple/protocols/qq/group_internal.h	07c09e08f1a14b607fcbd926aad0a5a0f5900a0f
+++ libpurple/protocols/qq/group_internal.h	6317c67efddb6b8443fadeca54a641ae7efc5a93
@@ -44,7 +44,7 @@ GHashTable *qq_group_to_hashtable(qq_gro
 void qq_group_delete_internal_record(qq_data *qd, guint32 id);
 
 GHashTable *qq_group_to_hashtable(qq_group *group);
-qq_group *qq_group_from_hashtable(PurpleConnection *gc, GHashTable *data);
+qq_group *qq_room_create_by_hashtable(PurpleConnection *gc, GHashTable *data);
 
 void qq_group_refresh(PurpleConnection *gc, qq_group *group);
 
============================================================
--- libpurple/protocols/qq/qq.c	43967e6bc88020c0ef86b63b79e4ecb5ef1a22b6
+++ libpurple/protocols/qq/qq.c	e0cfd8ddb5718cead0b5a384dfc8aa2445c7a5d2
@@ -157,9 +157,14 @@ static void qq_login(PurpleAccount *acco
 	qd->is_show_notice = purple_account_get_bool(account, "show_notice", TRUE);
 	qd->is_show_news = purple_account_get_bool(account, "show_news", TRUE);
 
-	qd->itv_config.resend = purple_account_get_int(account, "resend_interval", 10);
-	if (qd->itv_config.resend <= 0) qd->itv_config.resend = 10;
+	qd->resend_times = purple_prefs_get_int("/plugins/prpl/qq/resend_times");
+	if (qd->resend_times <= 1) qd->itv_config.resend = 4;
 
+	qd->itv_config.resend = purple_prefs_get_int("/plugins/prpl/qq/resend_interval");
+	if (qd->itv_config.resend <= 0) qd->itv_config.resend = 3;
+	purple_debug_info("QQ", "Resend interval %d, retries %d\n",
+			qd->itv_config.resend, qd->resend_times);
+
 	qd->itv_config.keep_alive = purple_account_get_int(account, "keep_alive_interval", 60);
 	if (qd->itv_config.keep_alive < 30) qd->itv_config.keep_alive = 30;
 	qd->itv_config.keep_alive /= qd->itv_config.resend;
@@ -518,7 +523,7 @@ static void _qq_menu_block_buddy(PurpleB
 */
 
 /* show a brief summary of what we get from login packet */
-static void _qq_menu_show_login_info(PurplePluginAction *action)
+static void _qq_menu_account_info(PurplePluginAction *action)
 {
 	PurpleConnection *gc = (PurpleConnection *) action->context;
 	qq_data *qd;
@@ -534,9 +539,17 @@ static void _qq_menu_show_login_info(Pur
 
 	g_string_append_printf(info, _("<b>Server</b>: %s<br>\n"), qd->curr_server);
 	g_string_append_printf(info, _("<b>Connection Mode</b>: %s<br>\n"), qd->use_tcp ? "TCP" : "UDP");
-	g_string_append_printf(info, _("<b>My Public IP</b>: %s<br>\n"), inet_ntoa(qd->my_ip));
+	g_string_append_printf(info, _("<b>My Internet Address</b>: %s<br>\n"), inet_ntoa(qd->my_ip));
 
 	g_string_append(info, "<hr>\n");
+	g_string_append(info, "<i>Network Status</i><br>\n");
+	g_string_append_printf(info, _("<b>Sent</b>: %lu<br>\n"), qd->net_stat.sent);
+	g_string_append_printf(info, _("<b>Resend</b>: %lu<br>\n"), qd->net_stat.resend);
+	g_string_append_printf(info, _("<b>Lost</b>: %lu<br>\n"), qd->net_stat.lost);
+	g_string_append_printf(info, _("<b>Received</b>: %lu<br>\n"), qd->net_stat.rcved);
+	g_string_append_printf(info, _("<b>Received Duplicate</b>: %lu<br>\n"), qd->net_stat.rcved_dup);
+
+	g_string_append(info, "<hr>\n");
 	g_string_append(info, "<i>Information below may not be accurate</i><br>\n");
 
 	g_string_append_printf(info, _("<b>Login Time</b>: %s<br>\n"), ctime(&qd->login_time));
@@ -627,7 +640,7 @@ static GList *_qq_actions(PurplePlugin *
 	act = purple_plugin_action_new(_("Change Password"), _qq_menu_change_password);
 	m = g_list_append(m, act);
 
-	act = purple_plugin_action_new(_("Show Login Information"), _qq_menu_show_login_info);
+	act = purple_plugin_action_new(_("Account Information"), _qq_menu_account_info);
 	m = g_list_append(m, act);
 
 	/*
@@ -854,9 +867,6 @@ static void init_plugin(PurplePlugin *pl
 	option = purple_account_option_bool_new(_("Show server news"), "show_news", TRUE);
 	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
 
-	option = purple_account_option_int_new(_("Resend interval(s)"), "resend_interval", 10);
-	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
-
 	option = purple_account_option_int_new(_("Keep alive interval(s)"), "keep_alive_interval", 60);
 	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
 
@@ -867,7 +877,8 @@ static void init_plugin(PurplePlugin *pl
 	purple_prefs_add_bool("/plugins/prpl/qq/show_status_by_icon", TRUE);
 	purple_prefs_add_bool("/plugins/prpl/qq/show_fake_video", FALSE);
 	purple_prefs_add_bool("/plugins/prpl/qq/show_room_when_newin", TRUE);
-
+	purple_prefs_add_int("/plugins/prpl/qq/resend_interval", 3);
+	purple_prefs_add_int("/plugins/prpl/qq/resend_times", 4);
 }
 
 PURPLE_INIT_PLUGIN(qq, init_plugin, info);
============================================================
--- libpurple/protocols/qq/qq.h	744eff96c4a552453b9054ce00bc80d710d77d7c
+++ libpurple/protocols/qq/qq.h	866faa0e5fe798560f5cb6de1aaa37723043a965
@@ -44,6 +44,7 @@ typedef struct _qq_interval qq_interval;
 typedef struct _qq_data qq_data;
 typedef struct _qq_buddy qq_buddy;
 typedef struct _qq_interval qq_interval;
+typedef struct _qq_net_stat qq_net_stat;
 
 struct _qq_interval {
 	gint resend;
@@ -51,6 +52,14 @@ struct _qq_interval {
 	gint update;
 };
 
+struct _qq_net_stat {
+	glong sent;
+	glong resend;
+	glong lost;
+	glong rcved;
+	glong rcved_dup;
+};
+
 struct _qq_buddy {
 	guint32 uid;
 	guint16 face;		/* index: 0 - 299 */
@@ -96,6 +105,7 @@ struct _qq_data {
 	gint udp_can_write_handler; 	/* socket can_write handle, use in udp connecting and tcp send out */
 #endif
 	gint fd;							/* socket file handler */
+	qq_net_stat net_stat;
 
 	GList *servers;
 	gchar *curr_server;		/* point to servers->data, do not free*/
@@ -109,6 +119,7 @@ struct _qq_data {
 	qq_interval itv_config;
 	qq_interval itv_count;
 	guint network_watcher;
+	gint resend_times;
 
 	GList *transactions;	/* check ack packet and resend */
 
============================================================
--- libpurple/protocols/qq/qq_network.c	46f30e26139c5aa84713e9a81550bb3a0d2de032
+++ libpurple/protocols/qq/qq_network.c	41e879497e4be7ac3f8e367ef4f164f8c275d904
@@ -249,6 +249,9 @@ static gboolean packet_process(PurpleCon
 
 	qd = (qq_data *) gc->proto_data;
 
+	qd->net_stat.rcved++;
+	if (qd->net_stat.rcved <= 0)	memset(&(qd->net_stat), 0, sizeof(qd->net_stat));
+
 	/* Len, header and tail tag have been checked before */
 	bytes = 0;
 	bytes += packet_get_header(&header_tag, &source_tag, &cmd, &seq, buf + bytes);
@@ -275,6 +278,7 @@ static gboolean packet_process(PurpleCon
 	}
 
 	if (qq_trans_is_dup(trans)) {
+		qd->net_stat.rcved_dup++;
 		purple_debug_info("QQ", "dup [%05d] %s, discard...\n", seq, qq_get_cmd_desc(cmd));
 		return TRUE;
 	}
@@ -1046,6 +1050,7 @@ static gint packet_send_out(PurpleConnec
 		return -1;
 	}
 
+	qd->net_stat.sent++;
 	if (qd->use_tcp) {
 		bytes_sent = tcp_send_out(gc, buf, buf_len);
 	} else {
============================================================
--- libpurple/protocols/qq/qq_process.c	1b1f4c1be42f11ec70e8b37dc0a7dc1c7015553c
+++ libpurple/protocols/qq/qq_process.c	92d4fd7a3a8e5d7db7b46fcbac1d64024464831d
@@ -438,8 +438,10 @@ void qq_proc_room_cmd(PurpleConnection *
 		break;
 	case QQ_ROOM_CMD_GET_BUDDIES:
 		qq_process_room_cmd_get_buddies(data + bytes, data_len - bytes, gc);
-		if (group != NULL)
+		if (group != NULL) {
+			group->is_got_info = TRUE;
 			qq_group_conv_refresh_online_member(gc, group);
+		}
 		break;
 	default:
 		purple_debug_warning("QQ", "Unknow room cmd 0x%02X %s\n",
============================================================
--- libpurple/protocols/qq/qq_trans.c	ac83d3befeef2abc89cd7b646e04786c9414a267
+++ libpurple/protocols/qq/qq_trans.c	e34b93f6399a872a447715a13e8dc4e1b6866dd5
@@ -35,8 +35,6 @@
 #include "qq_process.h"
 #include "qq_trans.h"
 
-#define QQ_RESEND_MAX               4	/* max resend per packet */
-
 enum {
 	QQ_TRANS_IS_SERVER = 0x01,			/* Is server command or client command */
 	QQ_TRANS_IS_IMPORT = 0x02,			/* Only notice if not get reply; or resend, disconn if reties get 0*/
@@ -188,7 +186,7 @@ void qq_trans_add_client_cmd(PurpleConne
 	if (cmd == QQ_CMD_TOKEN || cmd == QQ_CMD_LOGIN || cmd == QQ_CMD_KEEP_ALIVE) {
 		trans->flag |= QQ_TRANS_IS_IMPORT;
 	}
-	trans->send_retries = QQ_RESEND_MAX;
+	trans->send_retries = qd->resend_times;
 #if 0
 	purple_debug_info("QQ_TRANS", "Add client cmd, seq %d, data %p, len %d\n",
 			trans->seq, trans->data, trans->data_len);
@@ -228,7 +226,7 @@ void qq_trans_add_room_cmd(PurpleConnect
 
 	trans->room_cmd = room_cmd;
 	trans->room_id = room_id;
-	trans->send_retries = QQ_RESEND_MAX;
+	trans->send_retries = qd->resend_times;
 #if 0
 	purple_debug_info("QQ_TRANS", "Add room cmd, seq %d, data %p, len %d\n",
 			trans->seq, trans->data, trans->data_len);
@@ -373,6 +371,7 @@ gboolean qq_trans_scan(PurpleConnection 
 				return TRUE;
 			}
 
+			qd->net_stat.lost++;
 			purple_debug_error("QQ_TRANS",
 				"Lost [%d] %s, data %p, len %d, retries %d\n",
 				trans->seq, qq_get_cmd_desc(trans->cmd),
@@ -381,6 +380,7 @@ gboolean qq_trans_scan(PurpleConnection 
 			continue;
 		}
 
+		qd->net_stat.resend++;
 		purple_debug_warning("QQ_TRANS",
 				"Resend [%d] %s data %p, len %d, send_retries %d\n",
 				trans->seq, qq_get_cmd_desc(trans->cmd),


More information about the Commits mailing list