# HG changeset patch # User Daniel Atallah # Date 1221447882 0 # Node ID a3ac735ae75b0e7b46c3fbad0b752a4adcd29d2d # Parent fe2d4fc77b057d8f76f938f8f1f3be88befc78f8# Parent 22745e6a3136560f8d8188843021c8c6718bef2e merge of '021e8f6b481be8a2183a6c94379b98ef008cc534' and 'e1d5be5f19e8b35d0d80e2059ec14559d1192e22' diff -r fe2d4fc77b05 -r a3ac735ae75b libpurple/protocols/qq/ChangeLog --- a/libpurple/protocols/qq/ChangeLog Sat Sep 13 23:31:33 2008 +0000 +++ b/libpurple/protocols/qq/ChangeLog Mon Sep 15 03:04:42 2008 +0000 @@ -1,20 +1,3 @@ -2008.09.05 - ccpaging - * Filter chars 0x01-0x20 in nickname - -2008.09.05 - ccpaging - * 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 - * Bugfix: can not send message to the QUN blocked adding - * Tickets: - Fixes #6957 - -2008.09.02 - ccpaging - * 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 * 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 @@ -22,8 +5,6 @@ * 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 * Commit to Pidgin diff -r fe2d4fc77b05 -r a3ac735ae75b libpurple/protocols/qq/buddy_list.c --- a/libpurple/protocols/qq/buddy_list.c Sat Sep 13 23:31:33 2008 +0000 +++ b/libpurple/protocols/qq/buddy_list.c Mon Sep 15 03:04:42 2008 +0000 @@ -292,7 +292,6 @@ 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); diff -r fe2d4fc77b05 -r a3ac735ae75b libpurple/protocols/qq/char_conv.c --- a/libpurple/protocols/qq/char_conv.c Sat Sep 13 23:31:33 2008 +0000 +++ b/libpurple/protocols/qq/char_conv.c Mon Sep 15 03:04:42 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,8 +286,7 @@ } for (temp = str; *temp != 0; temp++) { - /*if (*temp == '\r' || *temp == '\n') *temp = ' ';*/ - if (*temp > 0 && *temp < 0x20) *temp = ' '; + if (*temp == '\r' || *temp == '\n') *temp = ' '; } g_strstrip(str); } diff -r fe2d4fc77b05 -r a3ac735ae75b libpurple/protocols/qq/group.c --- a/libpurple/protocols/qq/group.c Sat Sep 13 23:31:33 2008 +0000 +++ b/libpurple/protocols/qq/group.c Mon Sep 15 03:04:42 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_room_create_by_hashtable(gc, chat->components); + group = qq_group_from_hashtable(gc, chat->components); if (group == NULL) continue; diff -r fe2d4fc77b05 -r a3ac735ae75b libpurple/protocols/qq/group.h --- a/libpurple/protocols/qq/group.h Sat Sep 13 23:31:33 2008 +0000 +++ b/libpurple/protocols/qq/group.h Mon Sep 15 03:04:42 2008 +0000 @@ -55,8 +55,6 @@ /* 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); diff -r fe2d4fc77b05 -r a3ac735ae75b libpurple/protocols/qq/group_conv.c --- a/libpurple/protocols/qq/group_conv.c Sat Sep 13 23:31:33 2008 +0000 +++ b/libpurple/protocols/qq/group_conv.c Mon Sep 15 03:04:42 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 conversation per group */ + /* show only one window per group */ return conv; } @@ -52,10 +52,8 @@ 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); - 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); + /* qq_update_room(gc, 0, group->id); */ + qq_send_room_cmd_only(gc, QQ_ROOM_CMD_GET_ONLINES, group->id); return conv; } return NULL; diff -r fe2d4fc77b05 -r a3ac735ae75b libpurple/protocols/qq/group_internal.c --- a/libpurple/protocols/qq/group_internal.c Sat Sep 13 23:31:33 2008 +0000 +++ b/libpurple/protocols/qq/group_internal.c Mon Sep 15 03:04:42 2008 +0000 @@ -143,7 +143,7 @@ } /* create a qq_group from hashtable */ -qq_group *qq_room_create_by_hashtable(PurpleConnection *gc, GHashTable *data) +qq_group *qq_group_from_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) diff -r fe2d4fc77b05 -r a3ac735ae75b libpurple/protocols/qq/group_internal.h --- a/libpurple/protocols/qq/group_internal.h Sat Sep 13 23:31:33 2008 +0000 +++ b/libpurple/protocols/qq/group_internal.h Mon Sep 15 03:04:42 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_room_create_by_hashtable(PurpleConnection *gc, GHashTable *data); +qq_group *qq_group_from_hashtable(PurpleConnection *gc, GHashTable *data); void qq_group_refresh(PurpleConnection *gc, qq_group *group); diff -r fe2d4fc77b05 -r a3ac735ae75b libpurple/protocols/qq/qq.c --- a/libpurple/protocols/qq/qq.c Sat Sep 13 23:31:33 2008 +0000 +++ b/libpurple/protocols/qq/qq.c Mon Sep 15 03:04:42 2008 +0000 @@ -157,13 +157,8 @@ 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->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.resend = purple_account_get_int(account, "resend_interval", 10); + if (qd->itv_config.resend <= 0) qd->itv_config.resend = 10; 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; @@ -523,7 +518,7 @@ */ /* show a brief summary of what we get from login packet */ -static void _qq_menu_account_info(PurplePluginAction *action) +static void _qq_menu_show_login_info(PurplePluginAction *action) { PurpleConnection *gc = (PurpleConnection *) action->context; qq_data *qd; @@ -539,15 +534,7 @@ g_string_append_printf(info, _("Server: %s
\n"), qd->curr_server); g_string_append_printf(info, _("Connection Mode: %s
\n"), qd->use_tcp ? "TCP" : "UDP"); - g_string_append_printf(info, _("My Internet Address: %s
\n"), inet_ntoa(qd->my_ip)); - - g_string_append(info, "
\n"); - g_string_append(info, "Network Status
\n"); - g_string_append_printf(info, _("Sent: %lu
\n"), qd->net_stat.sent); - g_string_append_printf(info, _("Resend: %lu
\n"), qd->net_stat.resend); - g_string_append_printf(info, _("Lost: %lu
\n"), qd->net_stat.lost); - g_string_append_printf(info, _("Received: %lu
\n"), qd->net_stat.rcved); - g_string_append_printf(info, _("Received Duplicate: %lu
\n"), qd->net_stat.rcved_dup); + g_string_append_printf(info, _("My Public IP: %s
\n"), inet_ntoa(qd->my_ip)); g_string_append(info, "
\n"); g_string_append(info, "Information below may not be accurate
\n"); @@ -640,7 +627,7 @@ act = purple_plugin_action_new(_("Change Password"), _qq_menu_change_password); m = g_list_append(m, act); - act = purple_plugin_action_new(_("Account Information"), _qq_menu_account_info); + act = purple_plugin_action_new(_("Show Login Information"), _qq_menu_show_login_info); m = g_list_append(m, act); /* @@ -867,6 +854,9 @@ 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); @@ -877,8 +867,7 @@ 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); diff -r fe2d4fc77b05 -r a3ac735ae75b libpurple/protocols/qq/qq.h --- a/libpurple/protocols/qq/qq.h Sat Sep 13 23:31:33 2008 +0000 +++ b/libpurple/protocols/qq/qq.h Mon Sep 15 03:04:42 2008 +0000 @@ -44,7 +44,6 @@ 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; @@ -52,14 +51,6 @@ 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 */ @@ -105,7 +96,6 @@ 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*/ @@ -119,7 +109,6 @@ qq_interval itv_config; qq_interval itv_count; guint network_watcher; - gint resend_times; GList *transactions; /* check ack packet and resend */ diff -r fe2d4fc77b05 -r a3ac735ae75b libpurple/protocols/qq/qq_network.c --- a/libpurple/protocols/qq/qq_network.c Sat Sep 13 23:31:33 2008 +0000 +++ b/libpurple/protocols/qq/qq_network.c Mon Sep 15 03:04:42 2008 +0000 @@ -249,9 +249,6 @@ 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); @@ -278,7 +275,6 @@ } 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; } @@ -1050,7 +1046,6 @@ return -1; } - qd->net_stat.sent++; if (qd->use_tcp) { bytes_sent = tcp_send_out(gc, buf, buf_len); } else { diff -r fe2d4fc77b05 -r a3ac735ae75b libpurple/protocols/qq/qq_process.c --- a/libpurple/protocols/qq/qq_process.c Sat Sep 13 23:31:33 2008 +0000 +++ b/libpurple/protocols/qq/qq_process.c Mon Sep 15 03:04:42 2008 +0000 @@ -438,10 +438,8 @@ break; case QQ_ROOM_CMD_GET_BUDDIES: qq_process_room_cmd_get_buddies(data + bytes, data_len - bytes, gc); - if (group != NULL) { - group->is_got_info = TRUE; + if (group != NULL) qq_group_conv_refresh_online_member(gc, group); - } break; default: purple_debug_warning("QQ", "Unknow room cmd 0x%02X %s\n", diff -r fe2d4fc77b05 -r a3ac735ae75b libpurple/protocols/qq/qq_trans.c --- a/libpurple/protocols/qq/qq_trans.c Sat Sep 13 23:31:33 2008 +0000 +++ b/libpurple/protocols/qq/qq_trans.c Mon Sep 15 03:04:42 2008 +0000 @@ -35,6 +35,8 @@ #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*/ @@ -186,7 +188,7 @@ if (cmd == QQ_CMD_TOKEN || cmd == QQ_CMD_LOGIN || cmd == QQ_CMD_KEEP_ALIVE) { trans->flag |= QQ_TRANS_IS_IMPORT; } - trans->send_retries = qd->resend_times; + trans->send_retries = QQ_RESEND_MAX; #if 0 purple_debug_info("QQ_TRANS", "Add client cmd, seq %d, data %p, len %d\n", trans->seq, trans->data, trans->data_len); @@ -226,7 +228,7 @@ trans->room_cmd = room_cmd; trans->room_id = room_id; - trans->send_retries = qd->resend_times; + trans->send_retries = QQ_RESEND_MAX; #if 0 purple_debug_info("QQ_TRANS", "Add room cmd, seq %d, data %p, len %d\n", trans->seq, trans->data, trans->data_len); @@ -371,7 +373,6 @@ 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), @@ -380,7 +381,6 @@ 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),