Mercurial > pidgin
changeset 23881:69c218fd5d54
applied changes from 5688199e261449d33b5803dafff50d860896ebcb
through 5316525f53e27f838d18a6a08b82c7d55f674591
Reapplied 5316525f53e27f838d18a6a08b82c7d55f674591
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'
committer: Daniel Atallah <daniel.atallah@gmail.com>
author | SHiNE CsyFeK <csyfek@gmail.com> |
---|---|
date | Mon, 15 Sep 2008 03:03:11 +0000 |
parents | 1a0caf9983fa |
children | bcfc98c7a55f |
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 |
diffstat | 13 files changed, 86 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/qq/ChangeLog Mon Sep 15 03:02:06 2008 +0000 +++ b/libpurple/protocols/qq/ChangeLog Mon Sep 15 03:03:11 2008 +0000 @@ -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 @@ * 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
--- a/libpurple/protocols/qq/buddy_list.c Mon Sep 15 03:02:06 2008 +0000 +++ b/libpurple/protocols/qq/buddy_list.c Mon Sep 15 03:03:11 2008 +0000 @@ -292,6 +292,7 @@ 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);
--- a/libpurple/protocols/qq/char_conv.c Mon Sep 15 03:02:06 2008 +0000 +++ b/libpurple/protocols/qq/char_conv.c Mon Sep 15 03:03:11 2008 +0000 @@ -98,7 +98,7 @@ } /* 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 @@ if (error == NULL) { return ret; /* conversion is OK */ } - + /* conversion error */ purple_debug_error("QQ_CONVERT", "%s\n", error->message); @@ -127,8 +127,8 @@ * 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 @@ 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 @@ } 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); }
--- a/libpurple/protocols/qq/group.c Mon Sep 15 03:02:06 2008 +0000 +++ b/libpurple/protocols/qq/group.c Mon Sep 15 03:03:11 2008 +0000 @@ -66,7 +66,7 @@ pce->label = _("ID: "); pce->identifier = QQ_ROOM_KEY_EXTERNAL_ID; m = g_list_append(m, pce); - + return m; } @@ -120,9 +120,9 @@ 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 @@ 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;
--- a/libpurple/protocols/qq/group.h Mon Sep 15 03:02:06 2008 +0000 +++ b/libpurple/protocols/qq/group.h Mon Sep 15 03:03:11 2008 +0000 @@ -55,6 +55,8 @@ /* 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);
--- a/libpurple/protocols/qq/group_conv.c Mon Sep 15 03:02:06 2008 +0000 +++ b/libpurple/protocols/qq/group_conv.c Mon Sep 15 03:03:11 2008 +0000 @@ -44,7 +44,7 @@ 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 @@ 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;
--- a/libpurple/protocols/qq/group_internal.c Mon Sep 15 03:02:06 2008 +0000 +++ b/libpurple/protocols/qq/group_internal.c Mon Sep 15 03:03:11 2008 +0000 @@ -143,7 +143,7 @@ } /* 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 @@ 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 @@ 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)
--- a/libpurple/protocols/qq/group_internal.h Mon Sep 15 03:02:06 2008 +0000 +++ b/libpurple/protocols/qq/group_internal.h Mon Sep 15 03:03:11 2008 +0000 @@ -44,7 +44,7 @@ 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);
--- a/libpurple/protocols/qq/qq.c Mon Sep 15 03:02:06 2008 +0000 +++ b/libpurple/protocols/qq/qq.c Mon Sep 15 03:03:11 2008 +0000 @@ -157,8 +157,13 @@ 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; @@ -518,7 +523,7 @@ */ /* 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,7 +539,15 @@ 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"); @@ -627,7 +640,7 @@ 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 @@ 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); @@ -869,7 +879,8 @@ 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);
--- a/libpurple/protocols/qq/qq.h Mon Sep 15 03:02:06 2008 +0000 +++ b/libpurple/protocols/qq/qq.h Mon Sep 15 03:03:11 2008 +0000 @@ -44,6 +44,7 @@ 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 @@ 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 @@ 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 @@ qq_interval itv_config; qq_interval itv_count; guint network_watcher; + gint resend_times; GList *transactions; /* check ack packet and resend */
--- a/libpurple/protocols/qq/qq_network.c Mon Sep 15 03:02:06 2008 +0000 +++ b/libpurple/protocols/qq/qq_network.c Mon Sep 15 03:03:11 2008 +0000 @@ -249,6 +249,9 @@ 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 @@ } 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 @@ return -1; } + qd->net_stat.sent++; if (qd->use_tcp) { bytes_sent = tcp_send_out(gc, buf, buf_len); } else {
--- a/libpurple/protocols/qq/qq_process.c Mon Sep 15 03:02:06 2008 +0000 +++ b/libpurple/protocols/qq/qq_process.c Mon Sep 15 03:03:11 2008 +0000 @@ -438,8 +438,10 @@ 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",
--- a/libpurple/protocols/qq/qq_trans.c Mon Sep 15 03:02:06 2008 +0000 +++ b/libpurple/protocols/qq/qq_trans.c Mon Sep 15 03:03:11 2008 +0000 @@ -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 @@ 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 @@ 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 @@ 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 @@ 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),