annotate src/protocols/yahoo/util.c @ 12813:547c199072c8

[gaim-migrate @ 15161] - fixes to sametime administrative notification message dialog to make them a little less obscure as to what the heck they are - added an extra step to the sametime connection login between authenticating and starting services - fix to outgoing encoding of html formatted messages in sametime to use NCR encoding - addition of gaim_utf8_ncr_encode to util.h - fix of minor possible (unlikely) memleak in gaim_utf8_ncr_decode committer: Tailor Script <tailor@pidgin.im>
author Christopher O'Brien <siege@pidgin.im>
date Wed, 11 Jan 2006 03:07:01 +0000
parents f4e58e94ced3
children 76d8b0032f50
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1 /*
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
2 * gaim
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
3 *
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
4 * Some code copyright 2003 Tim Ringenbach <omarvo@hotmail.com>
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
5 * (marv on irc.freenode.net)
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
6 *
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
10 * (at your option) any later version.
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
11 *
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
15 * GNU General Public License for more details.
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
16 *
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
20 *
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
21 */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
22
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
24 #include "config.h"
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
25 #endif
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
26
10023
34bce9529cf4 [gaim-migrate @ 10955]
Mark Doliner <mark@kingant.net>
parents: 9164
diff changeset
27 #include "debug.h"
34bce9529cf4 [gaim-migrate @ 10955]
Mark Doliner <mark@kingant.net>
parents: 9164
diff changeset
28 #include "internal.h"
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
29 #include "prpl.h"
10023
34bce9529cf4 [gaim-migrate @ 10955]
Mark Doliner <mark@kingant.net>
parents: 9164
diff changeset
30
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
31 #include "yahoo.h"
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
32
6546
e34907332e46 [gaim-migrate @ 7068]
Mark Doliner <mark@kingant.net>
parents: 6513
diff changeset
33 #include <string.h>
e34907332e46 [gaim-migrate @ 7068]
Mark Doliner <mark@kingant.net>
parents: 6513
diff changeset
34
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
35 /**
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
36 * Encode some text to send to the yahoo server.
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
37 *
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
38 * @param gc The connection handle.
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
39 * @param str The null terminated utf8 string to encode.
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
40 * @param utf8 If not @c NULL, whether utf8 is okay or not.
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
41 * Even if it is okay, we may not use it. If we
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
42 * used it, we set this to @c TRUE, else to
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
43 * @c FALSE. If @c NULL, false is assumed, and
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
44 * it is not dereferenced.
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
45 * @return The g_malloced string in the appropriate encoding.
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
46 */
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
47 char *yahoo_string_encode(GaimConnection *gc, const char *str, gboolean *utf8)
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
48 {
9164
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
49 struct yahoo_data *yd = gc->proto_data;
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
50 char *ret;
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10380
diff changeset
51 const char *to_codeset;
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
52
9164
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
53 if (yd->jp && utf8 && *utf8)
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
54 *utf8 = FALSE;
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
55
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
56 if (utf8 && *utf8) /* FIXME: maybe don't use utf8 if it'll fit in latin1 */
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
57 return g_strdup(str);
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
58
9164
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
59 if (yd->jp)
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
60 to_codeset = "SHIFT_JIS";
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
61 else
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
62 to_codeset = "ISO-8859-1";
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
63
8955
eb3c59b0a16c [gaim-migrate @ 9728]
Tim Ringenbach <marv@pidgin.im>
parents: 8735
diff changeset
64 ret = g_convert_with_fallback(str, strlen(str), to_codeset, "UTF-8", "?", NULL, NULL, NULL);
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
65 if (ret)
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
66 return ret;
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
67 else
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
68 return g_strdup("");
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
69 }
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
70
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
71 /**
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
72 * Decode some text received from the server.
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
73 *
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
74 * @param gc The gc handle.
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
75 * @param str The null terminated string to decode.
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
76 * @param utf8 Did the server tell us it was supposed to be utf8?
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
77 * @return The decoded, utf-8 string, which must be g_free()'d.
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
78 */
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
79 char *yahoo_string_decode(GaimConnection *gc, const char *str, gboolean utf8)
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
80 {
9164
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
81 struct yahoo_data *yd = gc->proto_data;
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
82 char *ret;
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
83 char *from_codeset;
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
84
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
85 if (utf8) {
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
86 if (g_utf8_validate(str, -1, NULL))
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
87 return g_strdup(str);
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
88 }
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
89
9164
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
90 if (yd->jp)
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
91 from_codeset = "SHIFT_JIS";
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
92 else
76125b842b23 [gaim-migrate @ 9949]
Tim Ringenbach <marv@pidgin.im>
parents: 8955
diff changeset
93 from_codeset = "ISO-8859-1";
7827
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
94
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
95 ret = g_convert_with_fallback(str, strlen(str), "UTF-8", from_codeset, NULL, NULL, NULL, NULL);
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
96
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
97 if (ret)
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
98 return ret;
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
99 else
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
100 return g_strdup("");
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
101 }
ee32e030c9be [gaim-migrate @ 8479]
Ethan Blanton <elb@pidgin.im>
parents: 6631
diff changeset
102
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
103 /*
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
104 * I found these on some website but i don't know that they actually
8735
92cbf9713795 [gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents: 8533
diff changeset
105 * work (or are supposed to work). I didn't implement them yet.
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
106 *
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
107 * [0;30m ---black
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
108 * [1;37m ---white
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
109 * [0;37m ---tan
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
110 * [0;38m ---light black
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
111 * [1;39m ---dark blue
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
112 * [0;32m ---green
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
113 * [0;33m ---yellow
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
114 * [0;35m ---pink
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
115 * [1;35m ---purple
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
116 * [1;30m ---light blue
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
117 * [0;31m ---red
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
118 * [0;34m ---blue
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
119 * [0;36m ---aqua
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
120 * (shift+comma)lyellow(shift+period) ---light yellow
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
121 * (shift+comma)lgreen(shift+period) ---light green
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
122 [2;30m <--white out
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
123 */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
124
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
125 static GHashTable *ht = NULL;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
126
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
127 void yahoo_init_colorht()
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
128 {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
129 ht = g_hash_table_new(g_str_hash, g_str_equal);
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
130 /* the numbers in comments are what gyach uses, but i think they're incorrect */
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
131 g_hash_table_insert(ht, "30", "<FONT COLOR=\"#000000\">"); /* black */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
132 g_hash_table_insert(ht, "31", "<FONT COLOR=\"#0000FF\">"); /* blue */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
133 g_hash_table_insert(ht, "32", "<FONT COLOR=\"#008080\">"); /* cyan */ /* 00b2b2 */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
134 g_hash_table_insert(ht, "33", "<FONT COLOR=\"#808080\">"); /* gray */ /* 808080 */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
135 g_hash_table_insert(ht, "34", "<FONT COLOR=\"#008000\">"); /* green */ /* 00c200 */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
136 g_hash_table_insert(ht, "35", "<FONT COLOR=\"#FF0080\">"); /* pink */ /* ffafaf */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
137 g_hash_table_insert(ht, "36", "<FONT COLOR=\"#800080\">"); /* purple */ /* b200b2 */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
138 g_hash_table_insert(ht, "37", "<FONT COLOR=\"#FF8000\">"); /* orange */ /* ffff00 */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
139 g_hash_table_insert(ht, "38", "<FONT COLOR=\"#FF0000\">"); /* red */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
140 g_hash_table_insert(ht, "39", "<FONT COLOR=\"#808000\">"); /* olive */ /* 546b50 */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
141
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
142 g_hash_table_insert(ht, "1", "<B>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
143 g_hash_table_insert(ht, "x1", "</B>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
144 g_hash_table_insert(ht, "2", "<I>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
145 g_hash_table_insert(ht, "x2", "</I>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
146 g_hash_table_insert(ht, "4", "<U>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
147 g_hash_table_insert(ht, "x4", "</U>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
148
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
149 /* these just tell us the text they surround is supposed
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
150 * to be a link. gaim figures that out on its own so we
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
151 * just ignore it.
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
152 */
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
153 g_hash_table_insert(ht, "l", ""); /* link start */
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
154 g_hash_table_insert(ht, "xl", ""); /* link end */
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
155
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
156 g_hash_table_insert(ht, "<black>", "<FONT COLOR=\"#000000\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
157 g_hash_table_insert(ht, "<blue>", "<FONT COLOR=\"#0000FF\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
158 g_hash_table_insert(ht, "<cyan>", "<FONT COLOR=\"#008284\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
159 g_hash_table_insert(ht, "<gray>", "<FONT COLOR=\"#848284\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
160 g_hash_table_insert(ht, "<green>", "<FONT COLOR=\"#008200\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
161 g_hash_table_insert(ht, "<pink>", "<FONT COLOR=\"#FF0084\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
162 g_hash_table_insert(ht, "<purple>", "<FONT COLOR=\"#840084\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
163 g_hash_table_insert(ht, "<orange>", "<FONT COLOR=\"#FF8000\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
164 g_hash_table_insert(ht, "<red>", "<FONT COLOR=\"#FF0000\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
165 g_hash_table_insert(ht, "<yellow>", "<FONT COLOR=\"#848200\">");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
166
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
167 g_hash_table_insert(ht, "</black>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
168 g_hash_table_insert(ht, "</blue>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
169 g_hash_table_insert(ht, "</cyan>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
170 g_hash_table_insert(ht, "</gray>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
171 g_hash_table_insert(ht, "</green>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
172 g_hash_table_insert(ht, "</pink>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
173 g_hash_table_insert(ht, "</purple>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
174 g_hash_table_insert(ht, "</orange>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
175 g_hash_table_insert(ht, "</red>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
176 g_hash_table_insert(ht, "</yellow>", "</FONT>");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
177
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
178 /* remove these once we have proper support for <FADE> and <ALT> */
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
179 g_hash_table_insert(ht, "</fade>", "");
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
180 g_hash_table_insert(ht, "</alt>", "");
8375
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
181
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
182 /* these are the normal html yahoo sends (besides <font>).
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
183 * anything else will get turned into &lt;tag&gt;, so if I forgot
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
184 * about something, please add it. Why Yahoo! has to send unescaped
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
185 * <'s and >'s that aren't supposed to be html is beyond me.
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
186 */
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
187 g_hash_table_insert(ht, "<b>", "<b>");
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
188 g_hash_table_insert(ht, "<i>", "<i>");
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
189 g_hash_table_insert(ht, "<u>", "<u>");
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
190
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
191 g_hash_table_insert(ht, "</b>", "</b>");
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
192 g_hash_table_insert(ht, "</i>", "</i>");
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
193 g_hash_table_insert(ht, "</u>", "</u>");
8440
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
194 g_hash_table_insert(ht, "</font>", "</font>");
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
195 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
196
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
197 void yahoo_dest_colorht()
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
198 {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
199 g_hash_table_destroy(ht);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
200 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
201
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
202 static int point_to_html(int x)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
203 {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
204 if (x < 9)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
205 return 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
206 if (x < 11)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
207 return 2;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
208 if (x < 13)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
209 return 3;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
210 if (x < 17)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
211 return 4;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
212 if (x < 25)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
213 return 5;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
214 if (x < 35)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
215 return 6;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
216 return 7;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
217 }
10380
bed8d9a7bb88 [gaim-migrate @ 11605]
Tim Ringenbach <marv@pidgin.im>
parents: 10023
diff changeset
218
bed8d9a7bb88 [gaim-migrate @ 11605]
Tim Ringenbach <marv@pidgin.im>
parents: 10023
diff changeset
219 /* The Yahoo size tag is actually an absz tag; convert it to an HTML size, and include both tags */
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
220 static void _font_tags_fix_size(GString *tag, GString *dest)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
221 {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
222 char *x, *end;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
223 int size;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
224
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
225 if (((x = strstr(tag->str, "size"))) && ((x = strchr(tag->str, '=')))) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
226 while (*x && !g_ascii_isdigit(*x))
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
227 x++;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
228 if (*x) {
10380
bed8d9a7bb88 [gaim-migrate @ 11605]
Tim Ringenbach <marv@pidgin.im>
parents: 10023
diff changeset
229 int htmlsize;
bed8d9a7bb88 [gaim-migrate @ 11605]
Tim Ringenbach <marv@pidgin.im>
parents: 10023
diff changeset
230
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
231 size = strtol(x, &end, 10);
10380
bed8d9a7bb88 [gaim-migrate @ 11605]
Tim Ringenbach <marv@pidgin.im>
parents: 10023
diff changeset
232 htmlsize = point_to_html(size);
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
233 g_string_append_len(dest, tag->str, x - tag->str);
10380
bed8d9a7bb88 [gaim-migrate @ 11605]
Tim Ringenbach <marv@pidgin.im>
parents: 10023
diff changeset
234 g_string_append_printf(dest, "%d", htmlsize);
bed8d9a7bb88 [gaim-migrate @ 11605]
Tim Ringenbach <marv@pidgin.im>
parents: 10023
diff changeset
235 g_string_append_printf(dest, "\" absz=\"%d", size);
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
236 g_string_append(dest, end);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
237 } else {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
238 g_string_append(dest, tag->str);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
239 return;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
240 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
241 } else {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
242 g_string_append(dest, tag->str);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
243 return;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
244 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
245 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
246
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
247 char *yahoo_codes_to_html(const char *x)
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
248 {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
249 GString *s, *tmp;
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
250 int i, j, xs, nomoreendtags = 0; /* s/endtags/closinganglebrackets */
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
251 char *match, *ret;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
252
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
253 s = g_string_sized_new(strlen(x));
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
254
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
255 for (i = 0, xs = strlen(x); i < xs; i++) {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
256 if ((x[i] == 0x1b) && (x[i+1] == '[')) {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
257 j = i + 1;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
258
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
259 while (j++ < xs) {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
260 if (x[j] != 'm')
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
261 continue;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
262 else {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
263 tmp = g_string_new_len(x + i + 2, j - i - 2);
6621
42fdf16f1dad [gaim-migrate @ 7145]
Mark Doliner <mark@kingant.net>
parents: 6546
diff changeset
264 if (tmp->str[0] == '#')
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
265 g_string_append_printf(s, "<FONT COLOR=\"%s\">", tmp->str);
6546
e34907332e46 [gaim-migrate @ 7068]
Mark Doliner <mark@kingant.net>
parents: 6513
diff changeset
266 else if ((match = (char *) g_hash_table_lookup(ht, tmp->str)))
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
267 g_string_append(s, match);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
268 else {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
269 gaim_debug(GAIM_DEBUG_ERROR, "yahoo",
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
270 "Unknown ansi code 'ESC[%sm'.\n", tmp->str);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
271 g_string_free(tmp, TRUE);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
272 break;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
273 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
274
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
275 i = j;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
276 g_string_free(tmp, TRUE);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
277 break;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
278 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
279 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
280
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
281 } else if (!nomoreendtags && (x[i] == '<')) {
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
282 j = i;
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
283
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
284 while (j++ < xs) {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
285 if (x[j] != '>')
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
286 if (j == xs) {
8375
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
287 g_string_append(s, "&lt;");
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
288 nomoreendtags = 1;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
289 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
290 else
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
291 continue;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
292 else {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
293 tmp = g_string_new_len(x + i, j - i + 1);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
294 g_string_ascii_down(tmp);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
295
6546
e34907332e46 [gaim-migrate @ 7068]
Mark Doliner <mark@kingant.net>
parents: 6513
diff changeset
296 if ((match = (char *) g_hash_table_lookup(ht, tmp->str)))
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
297 g_string_append(s, match);
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
298 else if (!strncmp(tmp->str, "<fade ", 6) ||
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
299 !strncmp(tmp->str, "<alt ", 5) ||
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
300 !strncmp(tmp->str, "<snd ", 5)) {
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
301
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
302 /* remove this if gtkimhtml ever supports any of these */
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
303 i = j;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
304 g_string_free(tmp, TRUE);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
305 break;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
306
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
307 } else if (!strncmp(tmp->str, "<font ", 6)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
308 _font_tags_fix_size(tmp, s);
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
309 } else {
8375
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
310 g_string_append(s, "&lt;");
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
311 g_string_free(tmp, TRUE);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
312 break;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
313 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
314
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
315 i = j;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
316 g_string_free(tmp, TRUE);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
317 break;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
318 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
319
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
320 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
321
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
322 } else {
8375
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
323 if (x[i] == '<')
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
324 g_string_append(s, "&lt;");
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
325 else if (x[i] == '>')
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
326 g_string_append(s, "&gt;");
8440
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
327 else if (x[i] == '&')
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
328 g_string_append(s, "&amp;");
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
329 else if (x[i] == '"')
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
330 g_string_append(s, "&quot;");
8375
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
331 else
1556970088d4 [gaim-migrate @ 9102]
Luke Schierer <lschiere@pidgin.im>
parents: 7827
diff changeset
332 g_string_append_c(s, x[i]);
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
333 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
334 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
335
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
336 ret = s->str;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
337 g_string_free(s, FALSE);
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
338 gaim_debug(GAIM_DEBUG_MISC, "yahoo", "yahoo_codes_to_html: Returning string: '%s'.\n", ret);
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
339 return ret;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
340 }
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
341
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
342 /* borrowed from gtkimhtml */
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
343 #define MAX_FONT_SIZE 7
10899
1e6bdc7175e9 [gaim-migrate @ 12619]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
344 #define POINT_SIZE(x) (_point_sizes [MIN ((x > 0 ? x : 1), MAX_FONT_SIZE) - 1])
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
345 static gint _point_sizes [] = { 8, 10, 12, 14, 20, 30, 40 };
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
346
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
347 enum fatype { size, color, face, junk };
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
348 typedef struct {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
349 enum fatype type;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
350 union {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
351 int size;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
352 char *color;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
353 char *face;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
354 char *junk;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
355 } u;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
356 } fontattr;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
357
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
358 static void fontattr_free(fontattr *f)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
359 {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
360 if (f->type == color)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
361 g_free(f->u.color);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
362 else if (f->type == face)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
363 g_free(f->u.face);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
364 g_free(f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
365 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
366
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
367 static void yahoo_htc_queue_cleanup(GQueue *q)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
368 {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
369 char *tmp;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
370
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
371 while ((tmp = g_queue_pop_tail(q)))
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
372 g_free(tmp);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
373 g_queue_free(q);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
374 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
375
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
376 static void _parse_font_tag(const char *src, GString *dest, int *i, int *j,
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
377 int len, GQueue *colors, GQueue *tags, GQueue *ftattr)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
378 {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
379
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
380 int m, n, vstart;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
381 gboolean quote = 0, done = 0;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
382
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
383 m = *j;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
384
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
385 while (1) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
386 m++;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
387
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
388 if (m >= len) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
389 g_string_append(dest, &src[*i]);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
390 *i = len;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
391 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
392 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
393
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
394 if (src[m] == '=') {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
395 n = vstart = m;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
396 while (1) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
397 n++;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
398
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
399 if (n >= len) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
400 m = n;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
401 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
402 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
403
6631
f80e23e66de0 [gaim-migrate @ 7155]
Mark Doliner <mark@kingant.net>
parents: 6629
diff changeset
404 if (src[n] == '"') {
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
405 if (!quote) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
406 quote = 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
407 vstart = n;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
408 continue;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
409 } else {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
410 done = 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
411 }
6631
f80e23e66de0 [gaim-migrate @ 7155]
Mark Doliner <mark@kingant.net>
parents: 6629
diff changeset
412 }
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
413
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
414 if (!quote && ((src[n] == ' ') || (src[n] == '>')))
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
415 done = 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
416
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
417 if (done) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
418 if (!g_ascii_strncasecmp(&src[*j+1], "FACE", m - *j - 1)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
419 fontattr *f;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
420
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
421 f = g_new(fontattr, 1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
422 f->type = face;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
423 f->u.face = g_strndup(&src[vstart+1], n-vstart-1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
424 if (!ftattr)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
425 ftattr = g_queue_new();
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
426 g_queue_push_tail(ftattr, f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
427 m = n;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
428 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
429 } else if (!g_ascii_strncasecmp(&src[*j+1], "SIZE", m - *j - 1)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
430 fontattr *f;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
431
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
432 f = g_new(fontattr, 1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
433 f->type = size;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
434 f->u.size = POINT_SIZE(strtol(&src[vstart+1], NULL, 10));
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
435 if (!ftattr)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
436 ftattr = g_queue_new();
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
437 g_queue_push_tail(ftattr, f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
438 m = n;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
439 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
440 } else if (!g_ascii_strncasecmp(&src[*j+1], "COLOR", m - *j - 1)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
441 fontattr *f;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
442
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
443 f = g_new(fontattr, 1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
444 f->type = color;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
445 f->u.color = g_strndup(&src[vstart+1], n-vstart-1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
446 if (!ftattr)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
447 ftattr = g_queue_new();
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
448 g_queue_push_head(ftattr, f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
449 m = n;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
450 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
451 } else {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
452 fontattr *f;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
453
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
454 f = g_new(fontattr, 1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
455 f->type = junk;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
456 f->u.junk = g_strndup(&src[*j+1], n-*j);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
457 if (!ftattr)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
458 ftattr = g_queue_new();
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
459 g_queue_push_tail(ftattr, f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
460 m = n;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
461 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
462 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
463
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
464 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
465 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
466 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
467
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
468 if (src[m] == ' ')
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
469 *j = m;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
470
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
471 if (src[m] == '>') {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
472 gboolean needendtag = 0;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
473 fontattr *f;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
474 GString *tmp = g_string_new(NULL);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
475 char *colorstr;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
476
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
477 if (!g_queue_is_empty(ftattr)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
478 while ((f = g_queue_pop_tail(ftattr))) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
479 switch (f->type) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
480 case size:
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
481 if (!needendtag) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
482 needendtag = 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
483 g_string_append(dest, "<font ");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
484 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
485
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
486 g_string_append_printf(dest, "size=\"%d\" ", f->u.size);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
487 fontattr_free(f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
488 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
489 case face:
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
490 if (!needendtag) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
491 needendtag = 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
492 g_string_append(dest, "<font ");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
493 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
494
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
495 g_string_append_printf(dest, "face=\"%s\" ", f->u.face);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
496 fontattr_free(f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
497 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
498 case junk:
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
499 if (!needendtag) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
500 needendtag = 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
501 g_string_append(dest, "<font ");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
502 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
503
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
504 g_string_append(dest, f->u.junk);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
505 fontattr_free(f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
506 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
507
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
508 case color:
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
509 if (needendtag) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
510 g_string_append(tmp, "</font>");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
511 dest->str[dest->len-1] = '>';
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
512 needendtag = 0;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
513 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
514
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
515 colorstr = g_queue_peek_tail(colors);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
516 g_string_append(tmp, colorstr ? colorstr : "\033[#000000m");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
517 g_string_append_printf(dest, "\033[%sm", f->u.color);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
518 g_queue_push_tail(colors, g_strdup_printf("\033[%sm", f->u.color));
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
519 fontattr_free(f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
520 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
521 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
522 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
523
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
524 g_queue_free(ftattr);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
525 ftattr = NULL;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
526
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
527 if (needendtag) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
528 dest->str[dest->len-1] = '>';
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
529 g_queue_push_tail(tags, g_strdup("</font>"));
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
530 g_string_free(tmp, TRUE);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
531 } else {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
532 g_queue_push_tail(tags, tmp->str);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
533 g_string_free(tmp, FALSE);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
534 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
535 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
536
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
537 *i = *j = m;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
538 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
539 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
540 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
541
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
542 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
543
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
544 char *yahoo_html_to_codes(const char *src)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
545 {
6631
f80e23e66de0 [gaim-migrate @ 7155]
Mark Doliner <mark@kingant.net>
parents: 6629
diff changeset
546 int i, j, len;
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
547 GString *dest;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
548 char *ret, *esc;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
549 GQueue *colors, *tags;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
550 GQueue *ftattr = NULL;
8440
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
551 gboolean no_more_specials = FALSE;
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
552
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
553 colors = g_queue_new();
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
554 tags = g_queue_new();
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
555 dest = g_string_sized_new(strlen(src));
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
556
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
557 for (i = 0, len = strlen(src); i < len; i++) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
558
8440
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
559 if (!no_more_specials && src[i] == '<') {
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
560 j = i;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
561
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
562 while (1) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
563 j++;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
564
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
565 if (j >= len) { /* no '>' */
8440
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
566 g_string_append_c(dest, src[i]);
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
567 no_more_specials = TRUE;
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
568 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
569 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
570
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
571 if (src[j] == '<') {
8440
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
572 /* FIXME: This doesn't convert outgoing entities.
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
573 * However, I suspect this case may never
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
574 * happen anymore because of the entities.
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
575 */
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
576 g_string_append_len(dest, &src[i], j - i);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
577 i = j - 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
578 if (ftattr) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
579 fontattr *f;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
580
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
581 while ((f = g_queue_pop_head(ftattr)))
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
582 fontattr_free(f);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
583 g_queue_free(ftattr);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
584 ftattr = NULL;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
585 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
586 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
587 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
588
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
589 if (src[j] == ' ') {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
590 if (!g_ascii_strncasecmp(&src[i+1], "BODY", j - i - 1)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
591 char *t = strchr(&src[j], '>');
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
592 if (!t) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
593 g_string_append(dest, &src[i]);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
594 i = len;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
595 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
596 } else {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
597 i = t - src;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
598 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
599 }
8533
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
600 } else if (!g_ascii_strncasecmp(&src[i+1], "A HREF=\"", j - i - 1)) {
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
601 j += 7;
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
602 g_string_append(dest, "\033[lm");
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
603 while (1) {
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
604 g_string_append_c(dest, src[j]);
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
605 if (++j >= len) {
8480
b0cebd011cc0 [gaim-migrate @ 9213]
Luke Schierer <lschiere@pidgin.im>
parents: 8455
diff changeset
606 i = len;
b0cebd011cc0 [gaim-migrate @ 9213]
Luke Schierer <lschiere@pidgin.im>
parents: 8455
diff changeset
607 break;
b0cebd011cc0 [gaim-migrate @ 9213]
Luke Schierer <lschiere@pidgin.im>
parents: 8455
diff changeset
608 }
8533
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
609 if (src[j] == '"') {
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
610 g_string_append(dest, "\033[xlm");
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
611 while (1) {
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
612 if (++j >= len) {
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
613 i = len;
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
614 break;
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
615 }
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
616 if (!g_ascii_strncasecmp(&src[j], "</A>", 4)) {
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
617 j += 3;
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
618 break;
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
619 }
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
620 }
ef3d81aa663a [gaim-migrate @ 9272]
Luke Schierer <lschiere@pidgin.im>
parents: 8480
diff changeset
621 i = j;
8480
b0cebd011cc0 [gaim-migrate @ 9213]
Luke Schierer <lschiere@pidgin.im>
parents: 8455
diff changeset
622 break;
b0cebd011cc0 [gaim-migrate @ 9213]
Luke Schierer <lschiere@pidgin.im>
parents: 8455
diff changeset
623 }
b0cebd011cc0 [gaim-migrate @ 9213]
Luke Schierer <lschiere@pidgin.im>
parents: 8455
diff changeset
624 }
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
625 } else if (g_ascii_strncasecmp(&src[i+1], "FONT", j - i - 1)) { /* not interested! */
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
626 while (1) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
627 if (++j >= len) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
628 g_string_append(dest, &src[i]);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
629 i = len;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
630 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
631 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
632 if (src[j] == '>') {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
633 g_string_append_len(dest, &src[i], j - i + 1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
634 i = j;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
635 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
636 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
637 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
638 } else { /* yay we have a font tag */
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
639 _parse_font_tag(src, dest, &i, &j, len, colors, tags, ftattr);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
640 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
641
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
642 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
643 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
644
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
645 if (src[j] == '>') {
8440
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
646 /* This has some problems like the FIXME for the
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
647 * '<' case. and like that case, I suspect the case
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
648 * that this has problems is won't happen anymore anyway.
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
649 */
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
650 int sublen = j - i - 1;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
651
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
652 if (sublen) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
653 if (!g_ascii_strncasecmp(&src[i+1], "B", sublen)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
654 g_string_append(dest, "\033[1m");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
655 } else if (!g_ascii_strncasecmp(&src[i+1], "/B", sublen)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
656 g_string_append(dest, "\033[x1m");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
657 } else if (!g_ascii_strncasecmp(&src[i+1], "I", sublen)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
658 g_string_append(dest, "\033[2m");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
659 } else if (!g_ascii_strncasecmp(&src[i+1], "/I", sublen)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
660 g_string_append(dest, "\033[x2m");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
661 } else if (!g_ascii_strncasecmp(&src[i+1], "U", sublen)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
662 g_string_append(dest, "\033[4m");
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
663 } else if (!g_ascii_strncasecmp(&src[i+1], "/U", sublen)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
664 g_string_append(dest, "\033[x4m");
8480
b0cebd011cc0 [gaim-migrate @ 9213]
Luke Schierer <lschiere@pidgin.im>
parents: 8455
diff changeset
665 } else if (!g_ascii_strncasecmp(&src[i+1], "/A", sublen)) {
b0cebd011cc0 [gaim-migrate @ 9213]
Luke Schierer <lschiere@pidgin.im>
parents: 8455
diff changeset
666 g_string_append(dest, "\033[xlm");
8455
622fd4e800b4 [gaim-migrate @ 9185]
Luke Schierer <lschiere@pidgin.im>
parents: 8440
diff changeset
667 } else if (!g_ascii_strncasecmp(&src[i+1], "BR", sublen)) {
622fd4e800b4 [gaim-migrate @ 9185]
Luke Schierer <lschiere@pidgin.im>
parents: 8440
diff changeset
668 g_string_append_c(dest, '\n');
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
669 } else if (!g_ascii_strncasecmp(&src[i+1], "/BODY", sublen)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
670 /* mmm, </body> tags. *BURP* */
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
671 } else if (!g_ascii_strncasecmp(&src[i+1], "/FONT", sublen) && g_queue_peek_tail(tags)) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
672 char *etag, *cl;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
673
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
674 etag = g_queue_pop_tail(tags);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
675 if (etag) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
676 g_string_append(dest, etag);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
677 if (!strcmp(etag, "</font>")) {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
678 cl = g_queue_pop_tail(colors);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
679 if (cl)
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
680 g_free(cl);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
681 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
682 g_free(etag);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
683 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
684 } else {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
685 g_string_append_len(dest, &src[i], j - i + 1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
686 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
687 } else {
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
688 g_string_append_len(dest, &src[i], j - i + 1);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
689 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
690
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
691 i = j;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
692 break;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
693 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
694
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
695 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
696
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
697 } else {
8440
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
698 if (((len - i) >= 4) && !strncmp(&src[i], "&lt;", 4)) {
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
699 g_string_append_c(dest, '<');
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
700 i += 3;
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
701 } else if (((len - i) >= 4) && !strncmp(&src[i], "&gt;", 4)) {
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
702 g_string_append_c(dest, '>');
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
703 i += 3;
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
704 } else if (((len - i) >= 5) && !strncmp(&src[i], "&amp;", 4)) {
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
705 g_string_append_c(dest, '&');
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
706 i += 4;
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
707 } else if (((len - i) >= 6) && !strncmp(&src[i], "&quot;", 4)) {
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
708 g_string_append_c(dest, '"');
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
709 i += 5;
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
710 } else {
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
711 g_string_append_c(dest, src[i]);
be172fe866ac [gaim-migrate @ 9170]
Luke Schierer <lschiere@pidgin.im>
parents: 8376
diff changeset
712 }
6629
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
713 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
714 }
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
715
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
716 ret = dest->str;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
717 g_string_free(dest, FALSE);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
718
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
719 esc = g_strescape(ret, NULL);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
720 gaim_debug(GAIM_DEBUG_MISC, "yahoo", "yahoo_html_to_codes: Returning string: '%s'.\n", esc);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
721 g_free(esc);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
722
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
723 yahoo_htc_queue_cleanup(colors);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
724 yahoo_htc_queue_cleanup(tags);
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
725
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
726 return ret;
bdc448cf4cb6 [gaim-migrate @ 7153]
Luke Schierer <lschiere@pidgin.im>
parents: 6621
diff changeset
727 }