comparison libpurple/protocols/qq/char_conv.c @ 23050:9a5d140400f1

patch-02-fix-multiarch
author SHiNE CsyFeK <csyfek@gmail.com>
date Tue, 24 Jun 2008 11:58:57 +0000
parents 44b4e8bd759b
children 190bc4ecf6c3
comparison
equal deleted inserted replaced
23048:13a9b56f83b0 23050:9a5d140400f1
140 140
141 /* convert QQ formatted msg to Purple formatted msg (and UTF-8) */ 141 /* convert QQ formatted msg to Purple formatted msg (and UTF-8) */
142 gchar *qq_encode_to_purple(guint8 *data, gint len, const gchar *msg) 142 gchar *qq_encode_to_purple(guint8 *data, gint len, const gchar *msg)
143 { 143 {
144 GString *encoded; 144 GString *encoded;
145 guint8 font_attr, font_size, color[3], bar, *cursor; 145 guint8 font_attr, font_size, color[3], bar;
146 gboolean is_bold, is_italic, is_underline; 146 gboolean is_bold, is_italic, is_underline;
147 guint16 charset_code; 147 guint16 charset_code;
148 gchar *font_name, *color_code, *msg_utf8, *tmp, *ret; 148 gchar *font_name, *color_code, *msg_utf8, *tmp, *ret;
149 149 gint bytes = 0;
150 cursor = data; 150
151 /* checked _qq_show_packet OK */
151 _qq_show_packet("QQ_MESG recv for font style", data, len); 152 _qq_show_packet("QQ_MESG recv for font style", data, len);
152 153
153 read_packet_b(data, &cursor, len, &font_attr); 154 bytes += qq_get8(&font_attr, data + bytes);
154 read_packet_data(data, &cursor, len, color, 3); /* red,green,blue */ 155 bytes += qq_getdata(color, 3, data + bytes); /* red,green,blue */
155 color_code = g_strdup_printf("#%02x%02x%02x", color[0], color[1], color[2]); 156 color_code = g_strdup_printf("#%02x%02x%02x", color[0], color[1], color[2]);
156 157
157 read_packet_b(data, &cursor, len, &bar); /* skip, not sure of its use */ 158 bytes += qq_get8(&bar, data + bytes); /* skip, not sure of its use */
158 read_packet_w(data, &cursor, len, &charset_code); 159 bytes += qq_get16(&charset_code, data + bytes);
159 160
160 tmp = g_strndup((gchar *) cursor, data + len - cursor); 161 tmp = g_strndup((gchar *)(data + bytes), len - bytes);
161 font_name = qq_to_utf8(tmp, QQ_CHARSET_DEFAULT); 162 font_name = qq_to_utf8(tmp, QQ_CHARSET_DEFAULT);
162 g_free(tmp); 163 g_free(tmp);
163 164
164 font_size = _get_size(font_attr); 165 font_size = _get_size(font_attr);
165 is_bold = _check_bold(font_attr); 166 is_bold = _check_bold(font_attr);
175 encoded = g_string_new(""); 176 encoded = g_string_new("");
176 177
177 /* Henry: The range QQ sends rounds from 8 to 22, where a font size 178 /* Henry: The range QQ sends rounds from 8 to 22, where a font size
178 * of 10 is equal to 3 in html font tag */ 179 * of 10 is equal to 3 in html font tag */
179 g_string_append_printf(encoded, 180 g_string_append_printf(encoded,
180 "<font color=\"%s\"><font face=\"%s\"><font size=\"%d\">", 181 "<font color=\"%s\"><font face=\"%s\"><font size=\"%d\">",
181 color_code, font_name, font_size / 3); 182 color_code, font_name, font_size / 3);
182 purple_debug(PURPLE_DEBUG_INFO, "QQ_MESG", 183 purple_debug(PURPLE_DEBUG_INFO, "QQ_MESG",
183 "recv <font color=\"%s\"><font face=\"%s\"><font size=\"%d\">\n", 184 "recv <font color=\"%s\"><font face=\"%s\"><font size=\"%d\">\n",
184 color_code, font_name, font_size / 3); 185 color_code, font_name, font_size / 3);
185 g_string_append(encoded, msg_utf8); 186 g_string_append(encoded, msg_utf8);
186 187
187 if (is_bold) { 188 if (is_bold) {
188 g_string_prepend(encoded, "<b>"); 189 g_string_prepend(encoded, "<b>");
189 g_string_append(encoded, "</b>"); 190 g_string_append(encoded, "</b>");