| 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]; |