comparison libpurple/protocols/qq/group_info.c @ 23638:1c50f12b1c52

2008.08.02 - csyfek <csyfek(at)gmail.com> * Commit to Pidgin * Tickets: Fixes #1861 Fixes #1902 References #5112 2008.08.02 - ccpaging <ecc_hy(at)hotmail.com> * Store all keys and md5 values of qq_data in char[QQ_KEY_LENGTH] * Use random value in inikey * TEA header padding in crypt.c * Rewrite login part of qq_process 2008.07.31 - ccpaging <ecc_hy(at)hotmail.com> * Fixed: send reply when get duplicate server command. The server may not get our reply before. * Tag custom picture as text "(Broken)" 2008.07.30 - ccpaging <ecc_hy(at)hotmail.com>, csyfek <csyfek(at)gmail.com> * Change some debug message * Modify buddy status flag according to eva for QQ2006 * Modify buddy status parse and correspond to eva2 * Add getIP/putIP functions to packet_parse.c, and replace some gen_ip_str * Replace guint32 *ip with struct in_addr, and reduce g_new/g_free operation * Source file changed: Merge buddy_status into buddy_list Change login_logout to qq_base Merge keep_alive into qq_base New qq_process extract from qq_network * Fixed: Byte alignment bug in crypt.c, tested in ARM PDA * Fixed: group chat message may get in before getting group info, and so group info is empty * Add qq_send_cmd_group_get_group_info when joined a group chat in group_im.c * Add some new group command identify according eva but further program * Add some new QQ client version identify * Fixed: Identify buddy's client version by IM packet, and not by status * Add some new info in buddy's tooltip text * Add video falg to buddy's emblem. But those flag in buddy status may not prasing correctly * Use new timeout function to handle send keep_alive, resend packet, update buddy status * Add new advanced options: The end user may change interval of keep_alive, resend packet, update buddy status to feed their need. For example, saving network flow when use mobile phone. Keep alive packet must be sent in 60-120 seconds whatever client rcved data of not. The intervals of keep alive and update status should be multiple of resend's interval, Since we use counter not time() in a single timeout function for efficiency. * Rewrite qq_trans.c, and use one g_list to manage: Store server packet before login, and prase all of them when get login Store client send packet for resend scanning, confirm server reply, filter duplicate server reply Store server packet for filter out duplicate * Add QQ_MSG_SYS_NOTICE = 0x06 in sys_msg.c * Rewrite qq_proc_cmd_reply and qq_proc_cmd_server: In QQ protocol, one packet reply may need a new packet send later. We may call it packet trigger. The triggers always is hided in every qq_process_reply. Now we try to extract those triggers and put into a single function, and then every trigger should be obviously and easy to manage.
author SHiNE CsyFeK <csyfek@gmail.com>
date Sat, 02 Aug 2008 15:00:46 +0000
parents bdb38a8bf721
children 5f454b975a99
comparison
equal deleted inserted replaced
23637:21e591b55339 23638:1c50f12b1c52
25 #include "internal.h" 25 #include "internal.h"
26 26
27 #include "conversation.h" 27 #include "conversation.h"
28 #include "debug.h" 28 #include "debug.h"
29 29
30 #include "buddy_status.h"
31 #include "char_conv.h" 30 #include "char_conv.h"
32 #include "group_find.h" 31 #include "group_find.h"
33 #include "group_internal.h" 32 #include "group_internal.h"
34 #include "group_info.h" 33 #include "group_info.h"
35 #include "buddy_status.h" 34 #include "buddy_list.h"
36 #include "group_network.h" 35 #include "group_network.h"
37 36
38 /* we check who needs to update member info every minutes 37 /* we check who needs to update member info every minutes
39 * this interval determines if their member info is outdated */ 38 * this interval determines if their member info is outdated */
40 #define QQ_GROUP_CHAT_REFRESH_NICKNAME_INTERNAL 180 39 #define QQ_GROUP_CHAT_REFRESH_NICKNAME_INTERNAL 180
75 74
76 qq_send_group_cmd(gc, group, raw_data, bytes); 75 qq_send_group_cmd(gc, group, raw_data, bytes);
77 } 76 }
78 77
79 /* send packet to get online group member, called by keep_alive */ 78 /* send packet to get online group member, called by keep_alive */
79 void qq_send_cmd_group_all_get_online_members(PurpleConnection *gc)
80 {
81 qq_data *qd;
82 qq_group *group;
83 GList *list;
84
85 g_return_if_fail(gc != NULL && gc->proto_data != NULL);
86 qd = (qq_data *) gc->proto_data;
87
88 list = qd->groups;
89 while (list != NULL) {
90 group = (qq_group *) list->data;
91 if (group->my_status == QQ_GROUP_MEMBER_STATUS_IS_MEMBER ||
92 group->my_status == QQ_GROUP_MEMBER_STATUS_IS_ADMIN)
93 /* no need to get info time and time again, online members enough */
94 qq_send_cmd_group_get_online_members(gc, group);
95
96 list = list->next;
97 }
98 }
99
80 void qq_send_cmd_group_get_online_members(PurpleConnection *gc, qq_group *group) 100 void qq_send_cmd_group_get_online_members(PurpleConnection *gc, qq_group *group)
81 { 101 {
82 guint8 raw_data[16] = {0}; 102 guint8 raw_data[16] = {0};
83 gint bytes = 0; 103 gint bytes = 0;
84 104
85 g_return_if_fail(group != NULL); 105 g_return_if_fail(group != NULL);
86 106
87 /* only get online members when conversation window is on */ 107 /* only get online members when conversation window is on */
88 if (NULL == purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT,group->group_name_utf8, purple_connection_get_account(gc))) { 108 if (NULL == purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT,group->group_name_utf8, purple_connection_get_account(gc))) {
89 purple_debug(PURPLE_DEBUG_WARNING, "QQ", 109 purple_debug(PURPLE_DEBUG_WARNING, "QQ",
90 "Conversation for \"%s\" is not open, ignore to get online members\n", group->group_name_utf8); 110 "Conversation \"%s\" is not open, ignore to get online members\n", group->group_name_utf8);
91 return; 111 return;
92 } 112 }
93 113
94 bytes += qq_put8(raw_data + bytes, QQ_GROUP_CMD_GET_ONLINE_MEMBER); 114 bytes += qq_put8(raw_data + bytes, QQ_GROUP_CMD_GET_ONLINE_MEMBER);
95 bytes += qq_put32(raw_data + bytes, group->internal_group_id); 115 bytes += qq_put32(raw_data + bytes, group->internal_group_id);
111 if (_is_group_member_need_update_info(member)) 131 if (_is_group_member_need_update_info(member))
112 num++; 132 num++;
113 } 133 }
114 134
115 if (num <= 0) { 135 if (num <= 0) {
116 purple_debug(PURPLE_DEBUG_INFO, "QQ", "No group member needs to to update info now.\n"); 136 purple_debug(PURPLE_DEBUG_INFO, "QQ", "No group member info needs to be updated now.\n");
117 return; 137 return;
118 } 138 }
119 139
120 data_len = 5 + 4 * num; 140 data_len = 5 + 4 * num;
121 raw_data = g_newa(guint8, data_len); 141 raw_data = g_newa(guint8, data_len);
207 bytes += qq_get32(&member_uid, data + bytes); 227 bytes += qq_get32(&member_uid, data + bytes);
208 num++; 228 num++;
209 bytes += qq_get8(&organization, data + bytes); 229 bytes += qq_get8(&organization, data + bytes);
210 bytes += qq_get8(&role, data + bytes); 230 bytes += qq_get8(&role, data + bytes);
211 231
232 /*
212 if(organization != 0 || role != 0) { 233 if(organization != 0 || role != 0) {
213 purple_debug(PURPLE_DEBUG_INFO, "QQ", "group member %d: organization=%d, role=%d\n", member_uid, organization, role); 234 purple_debug(PURPLE_DEBUG_INFO, "QQ_GRP", "%d, organization=%d, role=%d\n", member_uid, organization, role);
214 } 235 }
236 */
215 member = qq_group_find_or_add_member(gc, group, member_uid); 237 member = qq_group_find_or_add_member(gc, group, member_uid);
216 if (member != NULL) 238 if (member != NULL)
217 member->role = role; 239 member->role = role;
218 } 240 }
219 if(bytes > len) { 241 if(bytes > len) {
229 251
230 purple_conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, 252 purple_conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT,
231 group->group_name_utf8, purple_connection_get_account(gc)); 253 group->group_name_utf8, purple_connection_get_account(gc));
232 if(NULL == purple_conv) { 254 if(NULL == purple_conv) {
233 purple_debug(PURPLE_DEBUG_WARNING, "QQ", 255 purple_debug(PURPLE_DEBUG_WARNING, "QQ",
234 "Conversation for \"%s\" is not open, do not set topic\n", group->group_name_utf8); 256 "Conversation \"%s\" is not open, do not set topic\n", group->group_name_utf8);
235 return; 257 return;
236 } 258 }
237 259
238 /* filter \r\n in notice */ 260 /* filter \r\n in notice */
239 qq_filter_str(notice); 261 qq_filter_str(notice);
320 bytes += qq_get16(&(member->face), data + bytes); 342 bytes += qq_get16(&(member->face), data + bytes);
321 bytes += qq_get8(&(member->age), data + bytes); 343 bytes += qq_get8(&(member->age), data + bytes);
322 bytes += qq_get8(&(member->gender), data + bytes); 344 bytes += qq_get8(&(member->gender), data + bytes);
323 bytes += convert_as_pascal_string(data + bytes, &nick, QQ_CHARSET_DEFAULT); 345 bytes += convert_as_pascal_string(data + bytes, &nick, QQ_CHARSET_DEFAULT);
324 bytes += qq_get16(&unknown, data + bytes); 346 bytes += qq_get16(&unknown, data + bytes);
325 bytes += qq_get8(&(member->flag1), data + bytes); 347 bytes += qq_get8(&(member->ext_flag), data + bytes);
326 bytes += qq_get8(&(member->comm_flag), data + bytes); 348 bytes += qq_get8(&(member->comm_flag), data + bytes);
327 349
328 /* filter \r\n in nick */ 350 /* filter \r\n in nick */
329 qq_filter_str(nick); 351 qq_filter_str(nick);
330 member->nickname = g_strdup(nick); 352 member->nickname = g_strdup(nick);
331 g_free(nick); 353 g_free(nick);
332 354
333 /* 355 /*
334 if (QQ_DEBUG) { 356 if (QQ_DEBUG) {
335 purple_debug(PURPLE_DEBUG_INFO, "QQ", 357 purple_debug(PURPLE_DEBUG_INFO, "QQ",
336 "member [%09d]: flag1=0x%02x, comm_flag=0x%02x, nick=%s\n", 358 "member [%09d]: ext_flag=0x%02x, comm_flag=0x%02x, nick=%s\n",
337 member_uid, member->flag1, member->comm_flag, member->nickname); 359 member_uid, member->ext_flag, member->comm_flag, member->nickname);
338 } 360 }
339 */ 361 */
340 362
341 member->last_refresh = time(NULL); 363 member->last_refresh = time(NULL);
342 } 364 }