Mercurial > pidgin.yaz
diff libpurple/protocols/qq/group_info.c @ 24019:147ada94a1d8
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
* Add server notice and server new, and two options to turn on/off
* 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.
author | SHiNE CsyFeK <csyfek@gmail.com> |
---|---|
date | Thu, 11 Sep 2008 13:25:07 +0000 |
parents | 5f454b975a99 |
children | 23cec4360d4a 25f62d21b3f8 |
line wrap: on
line diff
--- a/libpurple/protocols/qq/group_info.c Thu Sep 11 04:19:37 2008 +0000 +++ b/libpurple/protocols/qq/group_info.c Thu Sep 11 13:25:07 2008 +0000 @@ -41,16 +41,16 @@ * this interval determines if their member info is outdated */ #define QQ_GROUP_CHAT_REFRESH_NICKNAME_INTERNAL 180 -static gboolean _is_group_member_need_update_info(qq_buddy *member) +static gboolean check_update_interval(qq_buddy *member) { g_return_val_if_fail(member != NULL, FALSE); return (member->nickname == NULL) || - (time(NULL) - member->last_refresh) > QQ_GROUP_CHAT_REFRESH_NICKNAME_INTERNAL; + (time(NULL) - member->last_update) > QQ_GROUP_CHAT_REFRESH_NICKNAME_INTERNAL; } /* this is done when we receive the reply to get_online_members sub_cmd * all member are set offline, and then only those in reply packets are online */ -static void _qq_group_set_members_all_offline(qq_group *group) +static void set_all_offline(qq_group *group) { GList *list; qq_buddy *member; @@ -64,60 +64,24 @@ } } -/* send packet to get online group member, called by keep_alive */ -void qq_send_cmd_group_all_get_online_members(PurpleConnection *gc) -{ - qq_data *qd; - qq_group *group; - GList *list; - - g_return_if_fail(gc != NULL && gc->proto_data != NULL); - qd = (qq_data *) gc->proto_data; - - list = qd->groups; - while (list != NULL) { - group = (qq_group *) list->data; - if (group->my_status == QQ_GROUP_MEMBER_STATUS_IS_MEMBER || - group->my_status == QQ_GROUP_MEMBER_STATUS_IS_ADMIN) - /* no need to get info time and time again, online members enough */ - qq_send_cmd_group_get_online_members(gc, group); - - list = list->next; - } -} - -void qq_send_cmd_group_get_online_members(PurpleConnection *gc, qq_group *group) -{ - g_return_if_fail(group != NULL); - - /* only get online members when conversation window is on */ - if (NULL == purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT,group->group_name_utf8, purple_connection_get_account(gc))) { - purple_debug(PURPLE_DEBUG_WARNING, "QQ", - "Conversation \"%s\" is not open, ignore to get online members\n", group->group_name_utf8); - return; - } - - qq_send_room_cmd_only(gc, QQ_ROOM_CMD_GET_ONLINES, group->id); -} - /* send packet to get info for each group member */ -void qq_send_cmd_group_get_members_info(PurpleConnection *gc, qq_group *group) +gint qq_request_room_get_buddies(PurpleConnection *gc, qq_group *group, gint update_class) { guint8 *raw_data; gint bytes, num; GList *list; qq_buddy *member; - g_return_if_fail(group != NULL); + g_return_val_if_fail(group != NULL, 0); for (num = 0, list = group->members; list != NULL; list = list->next) { member = (qq_buddy *) list->data; - if (_is_group_member_need_update_info(member)) + if (check_update_interval(member)) num++; } if (num <= 0) { - purple_debug(PURPLE_DEBUG_INFO, "QQ", "No group member info needs to be updated now.\n"); - return; + purple_debug_info("QQ", "No group member info needs to be updated now.\n"); + return 0; } raw_data = g_newa(guint8, 4 * num); @@ -127,12 +91,14 @@ list = group->members; while (list != NULL) { member = (qq_buddy *) list->data; - if (_is_group_member_need_update_info(member)) + if (check_update_interval(member)) bytes += qq_put32(raw_data + bytes, member->uid); list = list->next; } - qq_send_room_cmd(gc, QQ_ROOM_CMD_GET_MEMBER_INFO, group->id, raw_data, bytes); + qq_send_room_cmd_mess(gc, QQ_ROOM_CMD_GET_BUDDIES, group->id, raw_data, bytes, + update_class, 0); + return num; } void qq_process_room_cmd_get_info(guint8 *data, gint data_len, PurpleConnection *gc) @@ -174,8 +140,8 @@ bytes += qq_get32(&(group->creator_uid), data + bytes); bytes += qq_get8(&(group->auth_type), data + bytes); bytes += qq_get32(&unknown4, data + bytes); /* oldCategory */ - bytes += qq_get16(&unknown, data + bytes); - bytes += qq_get32(&(group->group_category), data + bytes); + bytes += qq_get16(&unknown, data + bytes); + bytes += qq_get32(&(group->category), data + bytes); bytes += qq_get16(&max_members, data + bytes); bytes += qq_get8(&unknown1, data + bytes); /* the following, while Eva: @@ -183,17 +149,17 @@ * 2(qunNoticeLen), qunNoticeLen(qunNoticeContent, 1(qunDescLen), * qunDestLen(qunDestcontent)) */ bytes += qq_get8(&unknown1, data + bytes); - purple_debug(PURPLE_DEBUG_INFO, "QQ", "type=%u creatorid=%u category=%u maxmembers=%u\n", - group->type8, group->creator_uid, group->group_category, max_members); - + purple_debug_info("QQ", "type=%u creatorid=%u category=%u maxmembers=%u\n", + group->type8, group->creator_uid, group->category, max_members); + /* strlen + <str content> */ - bytes += convert_as_pascal_string(data + bytes, &(group->group_name_utf8), QQ_CHARSET_DEFAULT); - purple_debug(PURPLE_DEBUG_INFO, "QQ", "group \"%s\"\n", group->group_name_utf8); + bytes += convert_as_pascal_string(data + bytes, &(group->title_utf8), QQ_CHARSET_DEFAULT); + purple_debug_info("QQ", "group \"%s\"\n", group->title_utf8); bytes += qq_get16(&unknown, data + bytes); /* 0x0000 */ bytes += convert_as_pascal_string(data + bytes, ¬ice, QQ_CHARSET_DEFAULT); - purple_debug(PURPLE_DEBUG_INFO, "QQ", "notice \"%s\"\n", notice); - bytes += convert_as_pascal_string(data + bytes, &(group->group_desc_utf8), QQ_CHARSET_DEFAULT); - purple_debug(PURPLE_DEBUG_INFO, "QQ", "group_desc \"%s\"\n", group->group_desc_utf8); + purple_debug_info("QQ", "notice \"%s\"\n", notice); + bytes += convert_as_pascal_string(data + bytes, &(group->desc_utf8), QQ_CHARSET_DEFAULT); + purple_debug_info("QQ", "group_desc \"%s\"\n", group->desc_utf8); num = 0; /* now comes the member list separated by 0x00 */ @@ -205,7 +171,7 @@ #if 0 if(organization != 0 || role != 0) { - purple_debug(PURPLE_DEBUG_INFO, "QQ_GRP", "%d, organization=%d, role=%d\n", member_uid, organization, role); + purple_debug_info("QQ_GRP", "%d, organization=%d, role=%d\n", member_uid, organization, role); } #endif @@ -214,22 +180,22 @@ member->role = role; } if(bytes > data_len) { - purple_debug(PURPLE_DEBUG_ERROR, "QQ", + purple_debug_error("QQ", "group_cmd_get_group_info: Dangerous error! maybe protocol changed, notify me!"); } - purple_debug(PURPLE_DEBUG_INFO, "QQ", "group \"%s\" has %d members\n", group->group_name_utf8, num); + purple_debug_info("QQ", "group \"%s\" has %d members\n", group->title_utf8, num); if (group->creator_uid == qd->uid) - group->my_status = QQ_GROUP_MEMBER_STATUS_IS_ADMIN; + group->my_role = QQ_ROOM_ROLE_ADMIN; qq_group_refresh(gc, group); - purple_conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, - group->group_name_utf8, purple_connection_get_account(gc)); + purple_conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, + group->title_utf8, purple_connection_get_account(gc)); if(NULL == purple_conv) { - purple_debug(PURPLE_DEBUG_WARNING, "QQ", - "Conversation \"%s\" is not open, do not set topic\n", group->group_name_utf8); + purple_debug_warning("QQ", + "Conversation \"%s\" is not open, do not set topic\n", group->title_utf8); return; } @@ -237,7 +203,7 @@ qq_filter_str(notice); group->notice_utf8 = strdup(notice); g_free(notice); - + purple_conv_chat_set_topic(PURPLE_CONV_CHAT(purple_conv), NULL, group->notice_utf8); } @@ -252,7 +218,7 @@ g_return_if_fail(data != NULL && len > 0); if (len <= 3) { - purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Invalid group online member reply, discard it!\n"); + purple_debug_error("QQ", "Invalid group online member reply, discard it!\n"); return; } @@ -263,13 +229,12 @@ group = qq_room_search_id(gc, id); if (group == NULL) { - purple_debug(PURPLE_DEBUG_ERROR, "QQ", - "We have no group info for internal id [%d]\n", id); + purple_debug_error("QQ", "We have no group info for internal id [%d]\n", id); return; } /* set all offline first, then update those online */ - _qq_group_set_members_all_offline(group); + set_all_offline(group); num = 0; while (bytes < len) { bytes += qq_get32(&member_uid, data + bytes); @@ -279,15 +244,15 @@ member->status = QQ_BUDDY_ONLINE_NORMAL; } if(bytes > len) { - purple_debug(PURPLE_DEBUG_ERROR, "QQ", - "group_cmd_get_online_members: Dangerous error! maybe protocol changed, notify developers!"); + purple_debug_error("QQ", + "group_cmd_get_online_members: Dangerous error! maybe protocol changed, notify developers!"); } - purple_debug(PURPLE_DEBUG_INFO, "QQ", "Group \"%s\" has %d online members\n", group->group_name_utf8, num); + purple_debug_info("QQ", "Group \"%s\" has %d online members\n", group->title_utf8, num); } /* process the reply to get_members_info packet */ -void qq_process_room_cmd_get_members(guint8 *data, gint len, PurpleConnection *gc) +void qq_process_room_cmd_get_buddies(guint8 *data, gint len, PurpleConnection *gc) { gint bytes; gint num; @@ -300,7 +265,7 @@ g_return_if_fail(data != NULL && len > 0); #if 0 - qq_show_packet("qq_process_room_cmd_get_members", data, len); + qq_show_packet("qq_process_room_cmd_get_buddies", data, len); #endif bytes = 0; @@ -331,19 +296,19 @@ qq_filter_str(nick); member->nickname = g_strdup(nick); g_free(nick); - + #if 0 - purple_debug(PURPLE_DEBUG_INFO, "QQ", + purple_debug_info("QQ", "member [%09d]: ext_flag=0x%02x, comm_flag=0x%02x, nick=%s\n", member_uid, member->ext_flag, member->comm_flag, member->nickname); #endif - member->last_refresh = time(NULL); + member->last_update = time(NULL); } if (bytes > len) { - purple_debug(PURPLE_DEBUG_ERROR, "QQ", + purple_debug_error("QQ", "group_cmd_get_members_info: Dangerous error! maybe protocol changed, notify developers!"); } - purple_debug(PURPLE_DEBUG_INFO, "QQ", "Group \"%s\" obtained %d member info\n", group->group_name_utf8, num); + purple_debug_info("QQ", "Group \"%s\" obtained %d member info\n", group->title_utf8, num); }