comparison libpurple/protocols/qq/char_conv.c @ 23683: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 967344bc404d
comparison
equal deleted inserted replaced
23682:21e591b55339 23683:1c50f12b1c52
35 #define UTF8 "UTF-8" 35 #define UTF8 "UTF-8"
36 #define QQ_CHARSET_ZH_CN "GB18030" 36 #define QQ_CHARSET_ZH_CN "GB18030"
37 #define QQ_CHARSET_ENG "ISO-8859-1" 37 #define QQ_CHARSET_ENG "ISO-8859-1"
38 38
39 #define QQ_NULL_MSG "(NULL)" /* return this if conversion fails */ 39 #define QQ_NULL_MSG "(NULL)" /* return this if conversion fails */
40 #define QQ_NULL_SMILEY "(SM)" /* return this if smiley conversion fails */ 40 #define QQ_NULL_SMILEY "(Broken)" /* return this if smiley conversion fails */
41 41
42 const gchar qq_smiley_map[QQ_SMILEY_AMOUNT] = { 42 const gchar qq_smiley_map[QQ_SMILEY_AMOUNT] = {
43 0x41, 0x43, 0x42, 0x44, 0x45, 0x46, 0x47, 0x48, 43 0x41, 0x43, 0x42, 0x44, 0x45, 0x46, 0x47, 0x48,
44 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x73, 44 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x73,
45 0x74, 0x75, 0x76, 0x77, 0x8a, 0x8b, 0x8c, 0x8d, 45 0x74, 0x75, 0x76, 0x77, 0x8a, 0x8b, 0x8c, 0x8d,
111 if (error == NULL) { 111 if (error == NULL) {
112 return ret; /* conversion is OK */ 112 return ret; /* conversion is OK */
113 } 113 }
114 114
115 /* conversion error */ 115 /* conversion error */
116 purple_debug(PURPLE_DEBUG_ERROR, "QQ", "%s\n", error->message); 116 purple_debug(PURPLE_DEBUG_ERROR, "QQ_CONVERT", "%s\n", error->message);
117 117
118 qq_hex_dump(PURPLE_DEBUG_WARNING, "QQ", 118 qq_hex_dump(PURPLE_DEBUG_WARNING, "QQ_CONVERT",
119 (guint8 *) str, (len == -1) ? strlen(str) : len, 119 (guint8 *) str, (len == -1) ? strlen(str) : len,
120 "Dump failed text"); 120 "Dump failed text");
121 121
122 g_error_free(error); 122 g_error_free(error);
123 return g_strdup(QQ_NULL_MSG); 123 return g_strdup(QQ_NULL_MSG);
149 guint16 charset_code; 149 guint16 charset_code;
150 gchar *font_name, *color_code, *msg_utf8, *tmp, *ret; 150 gchar *font_name, *color_code, *msg_utf8, *tmp, *ret;
151 gint bytes = 0; 151 gint bytes = 0;
152 152
153 /* checked qq_show_packet OK */ 153 /* checked qq_show_packet OK */
154 qq_show_packet("QQ_MESG recv for font style", data, len); 154 /* qq_show_packet("QQ_MESG recv for font style", data, len); */
155 155
156 bytes += qq_get8(&font_attr, data + bytes); 156 bytes += qq_get8(&font_attr, data + bytes);
157 bytes += qq_getdata(color, 3, data + bytes); /* red,green,blue */ 157 bytes += qq_getdata(color, 3, data + bytes); /* red,green,blue */
158 color_code = g_strdup_printf("#%02x%02x%02x", color[0], color[1], color[2]); 158 color_code = g_strdup_printf("#%02x%02x%02x", color[0], color[1], color[2]);
159 159
229 gint index; 229 gint index;
230 gchar qq_smiley, *cur_seg, **segments, *ret; 230 gchar qq_smiley, *cur_seg, **segments, *ret;
231 GString *converted; 231 GString *converted;
232 232
233 converted = g_string_new(""); 233 converted = g_string_new("");
234 segments = split_data((guint8 *) text, strlen(text), "\x14", 0); 234 segments = split_data((guint8 *) text, strlen(text), "\x14\x15", 0);
235 g_string_append(converted, segments[0]); 235 g_string_append(converted, segments[0]);
236 236
237 while ((*(++segments)) != NULL) { 237 while ((*(++segments)) != NULL) {
238 cur_seg = *segments; 238 cur_seg = *segments;
239 qq_smiley = cur_seg[0]; 239 qq_smiley = cur_seg[0];
284 if (str == NULL) { 284 if (str == NULL) {
285 return; 285 return;
286 } 286 }
287 287
288 for (temp = str; *temp != 0; temp++) { 288 for (temp = str; *temp != 0; temp++) {
289 if (*temp == '\r' || *temp == '\n') *temp = 0x20; 289 if (*temp == '\r' || *temp == '\n') *temp = ' ';
290 } 290 }
291 g_strstrip(str); 291 g_strstrip(str);
292 } 292 }
293 293
294 294