annotate libpurple/protocols/yahoo/util.c @ 27998:617e7a90b69c

Fix a possible crash when receiving URLs in yahoo. It doesn't crash for me but it did for the guy reporting the bug. Might be architecture dependent or compile option dependent. In any case this is bad and we should release 2.6.1 tonight or tomorrow
author Mark Doliner <mark@kingant.net>
date Tue, 18 Aug 2009 23:52:14 +0000
parents 7ee833540b25
children c06114f3d58d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
2 * purple
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 * Some code copyright 2003 Tim Ringenbach <omarvo@hotmail.com>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 * (marv on irc.freenode.net)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
19681
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19197
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 #include "config.h"
27111
510f07e1f5c1 Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <mark@kingant.net>
parents: 23986
diff changeset
25 #endif /* HAVE_CONFIG_H */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "debug.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "internal.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "prpl.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30
27313
ef5f0cde8d74 Update for file renames.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27302
diff changeset
31 #include "libymsg.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include <string.h>
23986
18a1f0fe5f40 Do a better job of detecting if the yahoo account is connecting through a HTTP
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23031
diff changeset
34
18a1f0fe5f40 Do a better job of detecting if the yahoo account is connecting through a HTTP
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23031
diff changeset
35 gboolean
18a1f0fe5f40 Do a better job of detecting if the yahoo account is connecting through a HTTP
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23031
diff changeset
36 yahoo_account_use_http_proxy(PurpleConnection *conn)
18a1f0fe5f40 Do a better job of detecting if the yahoo account is connecting through a HTTP
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23031
diff changeset
37 {
18a1f0fe5f40 Do a better job of detecting if the yahoo account is connecting through a HTTP
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23031
diff changeset
38 PurpleProxyInfo *ppi = purple_proxy_get_setup(conn->account);
18a1f0fe5f40 Do a better job of detecting if the yahoo account is connecting through a HTTP
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23031
diff changeset
39 return (ppi->type == PURPLE_PROXY_HTTP || ppi->type == PURPLE_PROXY_USE_ENVVAR);
18a1f0fe5f40 Do a better job of detecting if the yahoo account is connecting through a HTTP
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23031
diff changeset
40 }
18a1f0fe5f40 Do a better job of detecting if the yahoo account is connecting through a HTTP
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23031
diff changeset
41
22018
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
42 /*
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
43 * Returns cookies formatted as a null terminated string for the given connection.
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
44 * Must g_free return value.
27111
510f07e1f5c1 Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <mark@kingant.net>
parents: 23986
diff changeset
45 *
22018
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
46 * TODO:will work, but must test for strict correctness
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
47 */
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
48 gchar* yahoo_get_cookies(PurpleConnection *gc)
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
49 {
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
50 gchar *ans = NULL;
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
51 gchar *cur;
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
52 char firstflag = 1;
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
53 gchar *t1,*t2,*t3;
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
54 GSList *tmp;
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
55 GSList *cookies;
27694
908be3822215 Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27424
diff changeset
56 cookies = ((YahooData*)(gc->proto_data))->cookies;
22018
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
57 tmp = cookies;
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
58 while(tmp)
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
59 {
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
60 cur = tmp->data;
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
61 t1 = ans;
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
62 t2 = g_strrstr(cur, ";expires=");
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
63 if(t2 == NULL)
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
64 t2 = g_strrstr(cur, "; expires=");
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
65 if(t2 == NULL)
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
66 {
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
67 if(firstflag)
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
68 ans = g_strdup_printf("%c=%s", cur[0], cur+2);
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
69 else
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
70 ans = g_strdup_printf("%s; %c=%s", t1, cur[0], cur+2);
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
71 }
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
72 else
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
73 {
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
74 t3 = strstr(t2+1, ";");
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
75 if(t3 != NULL)
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
76 {
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
77 t2[0] = '\0';
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
78
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
79 if(firstflag)
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
80 ans = g_strdup_printf("%c=%s%s", cur[0], cur+2, t3);
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
81 else
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
82 ans = g_strdup_printf("%s; %c=%s%s", t1, cur[0], cur+2, t3);
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
83
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
84 t2[0] = ';';
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
85 }
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
86 else
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
87 {
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
88 t2[0] = '\0';
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
89
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
90 if(firstflag)
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
91 ans = g_strdup_printf("%c=%s", cur[0], cur+2);
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
92 else
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
93 ans = g_strdup_printf("%s; %c=%s", t1, cur[0], cur+2);
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
94
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
95 t2[0] = ';';
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
96 }
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
97 }
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
98 if(firstflag)
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
99 firstflag = 0;
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
100 else
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
101 g_free(t1);
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
102 tmp = g_slist_next(tmp);
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
103 }
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
104 return ans;
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
105 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 * Encode some text to send to the yahoo server.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 * @param gc The connection handle.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 * @param str The null terminated utf8 string to encode.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 * @param utf8 If not @c NULL, whether utf8 is okay or not.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 * Even if it is okay, we may not use it. If we
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 * used it, we set this to @c TRUE, else to
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 * @c FALSE. If @c NULL, false is assumed, and
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 * it is not dereferenced.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 * @return The g_malloced string in the appropriate encoding.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
119 char *yahoo_string_encode(PurpleConnection *gc, const char *str, gboolean *utf8)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 {
27694
908be3822215 Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27424
diff changeset
121 YahooData *yd = gc->proto_data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 char *ret;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 const char *to_codeset;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124
23031
bf7ce9629402 applied changes from a5e7a62db1d43009f4ff463b7fe67ff3a7275a78
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22155
diff changeset
125 if (yd->jp)
bf7ce9629402 applied changes from a5e7a62db1d43009f4ff463b7fe67ff3a7275a78
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22155
diff changeset
126 return g_strdup(str);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 if (utf8 && *utf8) /* FIXME: maybe don't use utf8 if it'll fit in latin1 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 return g_strdup(str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130
23031
bf7ce9629402 applied changes from a5e7a62db1d43009f4ff463b7fe67ff3a7275a78
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22155
diff changeset
131 to_codeset = purple_account_get_string(purple_connection_get_account(gc), "local_charset", "ISO-8859-1");
bf7ce9629402 applied changes from a5e7a62db1d43009f4ff463b7fe67ff3a7275a78
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22155
diff changeset
132 ret = g_convert_with_fallback(str, -1, to_codeset, "UTF-8", "?", NULL, NULL, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 if (ret)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 return ret;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 return g_strdup("");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 * Decode some text received from the server.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 * @param gc The gc handle.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 * @param str The null terminated string to decode.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 * @param utf8 Did the server tell us it was supposed to be utf8?
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 * @return The decoded, utf-8 string, which must be g_free()'d.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
148 char *yahoo_string_decode(PurpleConnection *gc, const char *str, gboolean utf8)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 {
27694
908be3822215 Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27424
diff changeset
150 YahooData *yd = gc->proto_data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 char *ret;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 const char *from_codeset;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 if (utf8) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155 if (g_utf8_validate(str, -1, NULL))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 return g_strdup(str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 if (yd->jp)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 from_codeset = "SHIFT_JIS";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 else
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
162 from_codeset = purple_account_get_string(purple_connection_get_account(gc), "local_charset", "ISO-8859-1");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163
19197
47942d19f301 Use -1 as length with g_convert() functions instead of strlen()
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16109
diff changeset
164 ret = g_convert_with_fallback(str, -1, "UTF-8", from_codeset, NULL, NULL, NULL, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 if (ret)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 return ret;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 return g_strdup("");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171
22123
840e7e1b6dac disapproval of revision '947ccb889812585e6d53eac13fc12734d8481e33'
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22121
diff changeset
172 char *yahoo_convert_to_numeric(const char *str)
840e7e1b6dac disapproval of revision '947ccb889812585e6d53eac13fc12734d8481e33'
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22121
diff changeset
173 {
22134
33abfb98a460 Since I needed to bring back yahoo_convert_to_numeric, I figured I could at
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22123
diff changeset
174 GString *gstr = NULL;
22155
a886e43210b1 Fix (hopefully) the last problem in this function. Refs #3295.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22134
diff changeset
175 const unsigned char *p;
22123
840e7e1b6dac disapproval of revision '947ccb889812585e6d53eac13fc12734d8481e33'
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22121
diff changeset
176
22134
33abfb98a460 Since I needed to bring back yahoo_convert_to_numeric, I figured I could at
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22123
diff changeset
177 gstr = g_string_sized_new(strlen(str) * 6 + 1);
33abfb98a460 Since I needed to bring back yahoo_convert_to_numeric, I figured I could at
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22123
diff changeset
178
22155
a886e43210b1 Fix (hopefully) the last problem in this function. Refs #3295.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22134
diff changeset
179 for (p = (unsigned char *)str; *p; p++) {
22134
33abfb98a460 Since I needed to bring back yahoo_convert_to_numeric, I figured I could at
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22123
diff changeset
180 g_string_append_printf(gstr, "&#%u;", *p);
22123
840e7e1b6dac disapproval of revision '947ccb889812585e6d53eac13fc12734d8481e33'
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22121
diff changeset
181 }
22134
33abfb98a460 Since I needed to bring back yahoo_convert_to_numeric, I figured I could at
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22123
diff changeset
182
27743
a0a8b61301c8 Simplify a wee bit
Mark Doliner <mark@kingant.net>
parents: 27694
diff changeset
183 return g_string_free(gstr, FALSE);
22123
840e7e1b6dac disapproval of revision '947ccb889812585e6d53eac13fc12734d8481e33'
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22121
diff changeset
184 }
840e7e1b6dac disapproval of revision '947ccb889812585e6d53eac13fc12734d8481e33'
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22121
diff changeset
185
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 /*
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
187 * The values in this hash table should probably be lowercase, since that's
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
188 * what xhtml expects. Also because yahoo_codes_to_html() does
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
189 * case-sensitive comparisons.
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
190 *
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 * I found these on some website but i don't know that they actually
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192 * work (or are supposed to work). I didn't implement them yet.
27111
510f07e1f5c1 Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <mark@kingant.net>
parents: 23986
diff changeset
193 *
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
194 * [0;30m ---black
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
195 * [1;37m ---white
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
196 * [0;37m ---tan
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
197 * [0;38m ---light black
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
198 * [1;39m ---dark blue
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
199 * [0;32m ---green
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
200 * [0;33m ---yellow
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
201 * [0;35m ---pink
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
202 * [1;35m ---purple
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
203 * [1;30m ---light blue
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
204 * [0;31m ---red
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
205 * [0;34m ---blue
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
206 * [0;36m ---aqua
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
207 * (shift+comma)lyellow(shift+period) ---light yellow
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
208 * (shift+comma)lgreen(shift+period) ---light green
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
209 * [2;30m <--white out
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
210 */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
212 static GHashTable *esc_codes_ht = NULL;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
213 static GHashTable *tags_ht = NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 void yahoo_init_colorht()
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 {
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
217 if (esc_codes_ht != NULL)
27424
8368e4fb7d3a Don't double-free the color hash table when deinitializing both prpl-yahoo
Mark Doliner <mark@kingant.net>
parents: 27313
diff changeset
218 /* Hash table has already been initialized */
8368e4fb7d3a Don't double-free the color hash table when deinitializing both prpl-yahoo
Mark Doliner <mark@kingant.net>
parents: 27313
diff changeset
219 return;
8368e4fb7d3a Don't double-free the color hash table when deinitializing both prpl-yahoo
Mark Doliner <mark@kingant.net>
parents: 27313
diff changeset
220
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
221 /* Key is the escape code string. Value is the HTML that should be
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
222 * inserted in place of the escape code. */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
223 esc_codes_ht = g_hash_table_new(g_str_hash, g_str_equal);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
224
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
225 /* Key is the name of the HTML tag, for example "font" or "/font"
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
226 * value is the HTML that should be inserted in place of the old tag */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
227 tags_ht = g_hash_table_new(g_str_hash, g_str_equal);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
228
27424
8368e4fb7d3a Don't double-free the color hash table when deinitializing both prpl-yahoo
Mark Doliner <mark@kingant.net>
parents: 27313
diff changeset
229 /* the numbers in comments are what gyach uses, but i think they're incorrect */
27779
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27771
diff changeset
230 #ifdef USE_CSS_FORMATTING
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
231 g_hash_table_insert(esc_codes_ht, "30", "<span style=\"color: #000000\">"); /* black */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
232 g_hash_table_insert(esc_codes_ht, "31", "<span style=\"color: #0000FF\">"); /* blue */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
233 g_hash_table_insert(esc_codes_ht, "32", "<span style=\"color: #008080\">"); /* cyan */ /* 00b2b2 */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
234 g_hash_table_insert(esc_codes_ht, "33", "<span style=\"color: #808080\">"); /* gray */ /* 808080 */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
235 g_hash_table_insert(esc_codes_ht, "34", "<span style=\"color: #008000\">"); /* green */ /* 00c200 */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
236 g_hash_table_insert(esc_codes_ht, "35", "<span style=\"color: #FF0080\">"); /* pink */ /* ffafaf */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
237 g_hash_table_insert(esc_codes_ht, "36", "<span style=\"color: #800080\">"); /* purple */ /* b200b2 */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
238 g_hash_table_insert(esc_codes_ht, "37", "<span style=\"color: #FF8000\">"); /* orange */ /* ffff00 */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
239 g_hash_table_insert(esc_codes_ht, "38", "<span style=\"color: #FF0000\">"); /* red */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
240 g_hash_table_insert(esc_codes_ht, "39", "<span style=\"color: #808000\">"); /* olive */ /* 546b50 */
27779
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27771
diff changeset
241 #else
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
242 g_hash_table_insert(esc_codes_ht, "30", "<font color=\"#000000\">"); /* black */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
243 g_hash_table_insert(esc_codes_ht, "31", "<font color=\"#0000FF\">"); /* blue */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
244 g_hash_table_insert(esc_codes_ht, "32", "<font color=\"#008080\">"); /* cyan */ /* 00b2b2 */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
245 g_hash_table_insert(esc_codes_ht, "33", "<font color=\"#808080\">"); /* gray */ /* 808080 */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
246 g_hash_table_insert(esc_codes_ht, "34", "<font color=\"#008000\">"); /* green */ /* 00c200 */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
247 g_hash_table_insert(esc_codes_ht, "35", "<font color=\"#FF0080\">"); /* pink */ /* ffafaf */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
248 g_hash_table_insert(esc_codes_ht, "36", "<font color=\"#800080\">"); /* purple */ /* b200b2 */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
249 g_hash_table_insert(esc_codes_ht, "37", "<font color=\"#FF8000\">"); /* orange */ /* ffff00 */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
250 g_hash_table_insert(esc_codes_ht, "38", "<font color=\"#FF0000\">"); /* red */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
251 g_hash_table_insert(esc_codes_ht, "39", "<font color=\"#808000\">"); /* olive */ /* 546b50 */
27779
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27771
diff changeset
252 #endif /* !USE_CSS_FORMATTING */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
254 g_hash_table_insert(esc_codes_ht, "1", "<b>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
255 g_hash_table_insert(esc_codes_ht, "x1", "</b>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
256 g_hash_table_insert(esc_codes_ht, "2", "<i>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
257 g_hash_table_insert(esc_codes_ht, "x2", "</i>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
258 g_hash_table_insert(esc_codes_ht, "4", "<u>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
259 g_hash_table_insert(esc_codes_ht, "x4", "</u>");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261 /* these just tell us the text they surround is supposed
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
262 * to be a link. purple figures that out on its own so we
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263 * just ignore it.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 */
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
265 g_hash_table_insert(esc_codes_ht, "l", ""); /* link start */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
266 g_hash_table_insert(esc_codes_ht, "xl", ""); /* link end */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267
27779
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27771
diff changeset
268 #ifdef USE_CSS_FORMATTING
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
269 g_hash_table_insert(tags_ht, "black", "<span style=\"color: #000000\">");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
270 g_hash_table_insert(tags_ht, "blue", "<span style=\"color: #0000FF\">");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
271 g_hash_table_insert(tags_ht, "cyan", "<span style=\"color: #008284\">");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
272 g_hash_table_insert(tags_ht, "gray", "<span style=\"color: #848284\">");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
273 g_hash_table_insert(tags_ht, "green", "<span style=\"color: #008200\">");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
274 g_hash_table_insert(tags_ht, "pink", "<span style=\"color: #FF0084\">");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
275 g_hash_table_insert(tags_ht, "purple", "<span style=\"color: #840084\">");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
276 g_hash_table_insert(tags_ht, "orange", "<span style=\"color: #FF8000\">");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
277 g_hash_table_insert(tags_ht, "red", "<span style=\"color: #FF0000\">");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
278 g_hash_table_insert(tags_ht, "yellow", "<span style=\"color: #848200\">");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
280 g_hash_table_insert(tags_ht, "/black", "</span>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
281 g_hash_table_insert(tags_ht, "/blue", "</span>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
282 g_hash_table_insert(tags_ht, "/cyan", "</span>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
283 g_hash_table_insert(tags_ht, "/gray", "</span>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
284 g_hash_table_insert(tags_ht, "/green", "</span>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
285 g_hash_table_insert(tags_ht, "/pink", "</span>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
286 g_hash_table_insert(tags_ht, "/purple", "</span>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
287 g_hash_table_insert(tags_ht, "/orange", "</span>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
288 g_hash_table_insert(tags_ht, "/red", "</span>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
289 g_hash_table_insert(tags_ht, "/yellow", "</span>");
27779
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27771
diff changeset
290 #else
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
291 g_hash_table_insert(tags_ht, "black", "<font color=\"#000000\">");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
292 g_hash_table_insert(tags_ht, "blue", "<font color=\"#0000FF\">");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
293 g_hash_table_insert(tags_ht, "cyan", "<font color=\"#008284\">");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
294 g_hash_table_insert(tags_ht, "gray", "<font color=\"#848284\">");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
295 g_hash_table_insert(tags_ht, "green", "<font color=\"#008200\">");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
296 g_hash_table_insert(tags_ht, "pink", "<font color=\"#FF0084\">");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
297 g_hash_table_insert(tags_ht, "purple", "<font color=\"#840084\">");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
298 g_hash_table_insert(tags_ht, "orange", "<font color=\"#FF8000\">");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
299 g_hash_table_insert(tags_ht, "red", "<font color=\"#FF0000\">");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
300 g_hash_table_insert(tags_ht, "yellow", "<font color=\"#848200\">");
27779
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27771
diff changeset
301
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
302 g_hash_table_insert(tags_ht, "/black", "</font>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
303 g_hash_table_insert(tags_ht, "/blue", "</font>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
304 g_hash_table_insert(tags_ht, "/cyan", "</font>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
305 g_hash_table_insert(tags_ht, "/gray", "</font>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
306 g_hash_table_insert(tags_ht, "/green", "</font>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
307 g_hash_table_insert(tags_ht, "/pink", "</font>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
308 g_hash_table_insert(tags_ht, "/purple", "</font>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
309 g_hash_table_insert(tags_ht, "/orange", "</font>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
310 g_hash_table_insert(tags_ht, "/red", "</font>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
311 g_hash_table_insert(tags_ht, "/yellow", "</font>");
27779
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27771
diff changeset
312 #endif /* !USE_CSS_FORMATTING */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
314 /* We don't support these tags, so discard them */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
315 g_hash_table_insert(tags_ht, "alt", "");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
316 g_hash_table_insert(tags_ht, "fade", "");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
317 g_hash_table_insert(tags_ht, "snd", "");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
318 g_hash_table_insert(tags_ht, "/alt", "");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
319 g_hash_table_insert(tags_ht, "/fade", "");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
321 /* Official clients don't seem to send b, i or u tags. They use
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
322 * the escape codes listed above. Official clients definitely send
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
323 * font tags, though. I wonder if we can remove the opening and
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
324 * closing b, i and u tags from here? */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
325 g_hash_table_insert(tags_ht, "b", "<b>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
326 g_hash_table_insert(tags_ht, "i", "<i>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
327 g_hash_table_insert(tags_ht, "u", "<u>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
328 g_hash_table_insert(tags_ht, "font", "<font>");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
330 g_hash_table_insert(tags_ht, "/b", "</b>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
331 g_hash_table_insert(tags_ht, "/i", "</i>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
332 g_hash_table_insert(tags_ht, "/u", "</u>");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
333 g_hash_table_insert(tags_ht, "/font", "</font>");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
336 void yahoo_dest_colorht()
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337 {
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
338 if (esc_codes_ht == NULL)
27424
8368e4fb7d3a Don't double-free the color hash table when deinitializing both prpl-yahoo
Mark Doliner <mark@kingant.net>
parents: 27313
diff changeset
339 /* Hash table has already been destroyed */
8368e4fb7d3a Don't double-free the color hash table when deinitializing both prpl-yahoo
Mark Doliner <mark@kingant.net>
parents: 27313
diff changeset
340 return;
8368e4fb7d3a Don't double-free the color hash table when deinitializing both prpl-yahoo
Mark Doliner <mark@kingant.net>
parents: 27313
diff changeset
341
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
342 g_hash_table_destroy(esc_codes_ht);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
343 esc_codes_ht = NULL;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
344 g_hash_table_destroy(tags_ht);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
345 tags_ht = NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347
27779
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27771
diff changeset
348 #ifndef USE_CSS_FORMATTING
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 static int point_to_html(int x)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 if (x < 9)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352 return 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353 if (x < 11)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354 return 2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355 if (x < 13)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
356 return 3;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
357 if (x < 17)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358 return 4;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359 if (x < 25)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360 return 5;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361 if (x < 35)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362 return 6;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363 return 7;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364 }
27779
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27771
diff changeset
365 #endif /* !USE_CSS_FORMATTING */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
367 static void append_attrs_datalist_foreach_cb(GQuark key_id, gpointer data, gpointer user_data)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
368 {
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
369 const char *key;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
370 const char *value;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
371 xmlnode *cur;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
372
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
373 key = g_quark_to_string(key_id);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
374 value = data;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
375 cur = user_data;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
376
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
377 xmlnode_set_attrib(cur, key, value);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
378 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
379
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
380 /**
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
381 * @param cur A pointer to the position in the XML tree that we're
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
382 * currently building. This will be modified when opening a tag
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
383 * or closing an existing tag.
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
384 */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
385 static void yahoo_codes_to_html_add_tag(xmlnode **cur, const char *tag, gboolean is_closing_tag, const gchar *tag_name, gboolean is_font_tag)
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
386 {
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
387 if (is_closing_tag) {
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
388 xmlnode *tmp;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
389 GSList *dangling_tags = NULL;
27779
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27771
diff changeset
390
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
391 /* Move up the DOM until we find the opening tag */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
392 for (tmp = *cur; tmp != NULL; tmp = xmlnode_get_parent(tmp)) {
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
393 /* Add one to tag_name when doing this comparison because it starts with a / */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
394 if (g_str_equal(tmp->name, tag_name + 1))
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
395 /* Found */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
396 break;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
397 dangling_tags = g_slist_prepend(dangling_tags, tmp);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
398 }
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
399 if (tmp == NULL) {
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
400 /* This is a closing tag with no opening tag. Useless. */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
401 purple_debug_error("yahoo", "Ignoring unmatched tag %s", tag);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
402 g_slist_free(dangling_tags);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
404 }
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
405
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
406 /* Move our current position up, now that we've closed a tag */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
407 *cur = xmlnode_get_parent(tmp);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
408
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
409 /* Re-open any tags that were nested below the tag we just closed */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
410 while (dangling_tags != NULL) {
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
411 tmp = dangling_tags->data;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
412 dangling_tags = g_slist_delete_link(dangling_tags, dangling_tags);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
413
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
414 /* Create a copy of this tag+attributes (but not child tags or
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
415 * data) at our new location */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
416 *cur = xmlnode_new_child(*cur, tmp->name);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
417 for (tmp = tmp->child; tmp != NULL; tmp = tmp->next)
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
418 if (tmp->type == XMLNODE_TYPE_ATTRIB)
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
419 xmlnode_set_attrib_full(*cur, tmp->name,
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
420 tmp->xmlns, tmp->prefix, tmp->data);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
421 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
422 } else {
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
423 const char *start;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
424 const char *end;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
425 GData *attributes;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
426 char *fontsize = NULL;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
427
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
428 purple_markup_find_tag(tag_name, tag, &start, &end, &attributes);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
429 *cur = xmlnode_new_child(*cur, tag_name);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
430
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
431 if (is_font_tag) {
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
432 /* Special case for the font size attribute */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
433 fontsize = g_strdup(g_datalist_get_data(&attributes, "size"));
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
434 if (fontsize != NULL)
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
435 g_datalist_remove_data(&attributes, "size");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
436 }
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
437
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
438 /* Add all font tag attributes */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
439 g_datalist_foreach(&attributes, append_attrs_datalist_foreach_cb, *cur);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
440 g_datalist_clear(&attributes);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
441
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
442 if (fontsize != NULL) {
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
443 #ifdef USE_CSS_FORMATTING
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
444 /*
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
445 * The Yahoo font size value is given in pt, even though the HTML
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
446 * standard for <font size="x"> treats the size as a number on a
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
447 * scale between 1 and 7. So we insert the font size as a CSS
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
448 * style on a span tag.
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
449 */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
450 gchar *tmp = g_strdup_printf("font-size: %spt", fontsize);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
451 *cur = xmlnode_new_child(*cur, "span");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
452 xmlnode_set_attrib(*cur, "style", tmp);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
453 g_free(tmp);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
454 #else
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
455 /*
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
456 * The Yahoo font size value is given in pt, even though the HTML
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
457 * standard for <font size="x"> treats the size as a number on a
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
458 * scale between 1 and 7. So we convert it to an appropriate
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
459 * value. This loses precision, which is why CSS formatting is
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
460 * preferred. The "absz" attribute remains here for backward
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
461 * compatibility with UIs that might use it, but it is totally
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
462 * not standard at all.
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
463 */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
464 int size, htmlsize;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
465 gchar tmp[11];
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
466 size = strtol(fontsize, NULL, 10);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
467 htmlsize = point_to_html(size);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
468 sprintf(tmp, "%u", htmlsize);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
469 xmlnode_set_attrib(*cur, "size", tmp);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
470 xmlnode_set_attrib(*cur, "absz", fontsize);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
471 #endif /* !USE_CSS_FORMATTING */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
472 g_free(fontsize);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
473 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
474 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
475 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
476
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
477 /**
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
478 * Similar to purple_markup_get_tag_name(), but works with closing tags.
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
479 *
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
480 * @return The lowercase name of the tag. If this is a closing tag then
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
481 * this value starts with a forward slash. The caller must free
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
482 * this string with g_free.
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
483 */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
484 static gchar *yahoo_markup_get_tag_name(const char *tag, gboolean *is_closing_tag)
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
485 {
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
486 size_t len;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
487
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
488 *is_closing_tag = (tag[1] == '/');
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
489 if (*is_closing_tag)
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
490 len = strcspn(tag + 1, "> ");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
491 else
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
492 len = strcspn(tag + 1, "> /");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
493
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
494 return g_utf8_strdown(tag + 1, len);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
495 }
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
496
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
497 /*
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
498 * Yahoo! messages generally aren't well-formed. Their markup is
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
499 * more of a flow from start to finish rather than a hierarchy from
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
500 * outer to inner. They tend to open tags and close them only when
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
501 * necessary.
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
502 *
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
503 * Example: <font size="8">size 8 <font size="16">size 16 <font size="8">size 8 again
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
504 *
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
505 * But we want to send well-formed HTML to the core, so we step through
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
506 * the input string and build an xmlnode tree containing sanitized HTML.
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
507 */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
508 char *yahoo_codes_to_html(const char *x)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
509 {
27766
8660d8bc467c Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <mark@kingant.net>
parents: 27765
diff changeset
510 size_t x_len;
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
511 xmlnode *html, *cur;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
512 GString *cdata = g_string_new(NULL);
27766
8660d8bc467c Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <mark@kingant.net>
parents: 27765
diff changeset
513 int i, j;
27771
2b3a9a68e0bc Of course I got it backwards
Mark Doliner <mark@kingant.net>
parents: 27770
diff changeset
514 gboolean no_more_gt_brackets = FALSE;
27767
70219821df98 Make match a const char *, and remove two unnecessary casts
Mark Doliner <mark@kingant.net>
parents: 27766
diff changeset
515 const char *match;
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
516 gchar *xmlstr1, *xmlstr2;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
517
27766
8660d8bc467c Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <mark@kingant.net>
parents: 27765
diff changeset
518 x_len = strlen(x);
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
519 html = xmlnode_new("html");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
520
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
521 cur = html;
27766
8660d8bc467c Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <mark@kingant.net>
parents: 27765
diff changeset
522 for (i = 0; i < x_len; i++) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
523 if ((x[i] == 0x1b) && (x[i+1] == '[')) {
27770
1c9d3038a0d3 Better variable name?
Mark Doliner <mark@kingant.net>
parents: 27768
diff changeset
524 /* This escape sequence signifies the beginning of some
1c9d3038a0d3 Better variable name?
Mark Doliner <mark@kingant.net>
parents: 27768
diff changeset
525 * text formatting code */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
526 j = i + 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
527
27766
8660d8bc467c Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <mark@kingant.net>
parents: 27765
diff changeset
528 while (j++ < x_len) {
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
529 gchar *code;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
530
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
531 if (x[j] != 'm')
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
532 /* Keep looking for the end of this sequence */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
533 continue;
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
534
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
535 /* We've reached the end of the formatting sequence, yay */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
536
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
537 /* Append any character data that belongs in the current node */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
538 if (cdata->len > 0) {
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
539 xmlnode_insert_data(cur, cdata->str, cdata->len);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
540 g_string_truncate(cdata, 0);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
541 }
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
542
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
543 code = g_strndup(x + i + 2, j - i - 2);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
544 if (code[0] == '#') {
27779
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27771
diff changeset
545 #ifdef USE_CSS_FORMATTING
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
546 gchar *tmp = g_strdup_printf("color: %s", code);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
547 cur = xmlnode_new_child(cur, "span");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
548 xmlnode_set_attrib(cur, "style", tmp);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
549 g_free(tmp);
27779
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27771
diff changeset
550 #else
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
551 cur = xmlnode_new_child(cur, "font");
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
552 xmlnode_set_attrib(cur, "color", code);
27779
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27771
diff changeset
553 #endif /* !USE_CSS_FORMATTING */
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
554
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
555 } else if ((match = g_hash_table_lookup(esc_codes_ht, code))) {
27998
617e7a90b69c Fix a possible crash when receiving URLs in yahoo. It doesn't crash for me
Mark Doliner <mark@kingant.net>
parents: 27831
diff changeset
556 /* Some tags are in the hash table only because we
617e7a90b69c Fix a possible crash when receiving URLs in yahoo. It doesn't crash for me
Mark Doliner <mark@kingant.net>
parents: 27831
diff changeset
557 * want to ignore them */
617e7a90b69c Fix a possible crash when receiving URLs in yahoo. It doesn't crash for me
Mark Doliner <mark@kingant.net>
parents: 27831
diff changeset
558 if (match[0] != '\0') {
617e7a90b69c Fix a possible crash when receiving URLs in yahoo. It doesn't crash for me
Mark Doliner <mark@kingant.net>
parents: 27831
diff changeset
559 gboolean is_closing_tag;
617e7a90b69c Fix a possible crash when receiving URLs in yahoo. It doesn't crash for me
Mark Doliner <mark@kingant.net>
parents: 27831
diff changeset
560 gchar *tag_name;
617e7a90b69c Fix a possible crash when receiving URLs in yahoo. It doesn't crash for me
Mark Doliner <mark@kingant.net>
parents: 27831
diff changeset
561 tag_name = yahoo_markup_get_tag_name(match, &is_closing_tag);
617e7a90b69c Fix a possible crash when receiving URLs in yahoo. It doesn't crash for me
Mark Doliner <mark@kingant.net>
parents: 27831
diff changeset
562 yahoo_codes_to_html_add_tag(&cur, match, is_closing_tag, tag_name, FALSE);
617e7a90b69c Fix a possible crash when receiving URLs in yahoo. It doesn't crash for me
Mark Doliner <mark@kingant.net>
parents: 27831
diff changeset
563 g_free(tag_name);
617e7a90b69c Fix a possible crash when receiving URLs in yahoo. It doesn't crash for me
Mark Doliner <mark@kingant.net>
parents: 27831
diff changeset
564 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
565
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
566 } else {
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
567 purple_debug_error("yahoo",
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
568 "Ignoring unknown ansi code 'ESC[%sm'.\n", code);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
569 }
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
570
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
571 g_free(code);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
572 i = j;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
573 break;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
574 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
575
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
576 } else if (x[i] == '<' && !no_more_gt_brackets) {
27770
1c9d3038a0d3 Better variable name?
Mark Doliner <mark@kingant.net>
parents: 27768
diff changeset
577 /* The start of an HTML tag */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
578 j = i;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
579
27766
8660d8bc467c Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <mark@kingant.net>
parents: 27765
diff changeset
580 while (j++ < x_len) {
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
581 gchar *tag;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
582 gboolean is_closing_tag;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
583 gchar *tag_name;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
584
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
585 if (x[j] != '>') {
27830
f6dab0e7a817 Take care of a special case where we would incorrectly parse incoming IMs
Mark Doliner <mark@kingant.net>
parents: 27827
diff changeset
586 if (x[j] == '"') {
f6dab0e7a817 Take care of a special case where we would incorrectly parse incoming IMs
Mark Doliner <mark@kingant.net>
parents: 27827
diff changeset
587 /* We're inside a quoted attribute value. Skip to the end */
f6dab0e7a817 Take care of a special case where we would incorrectly parse incoming IMs
Mark Doliner <mark@kingant.net>
parents: 27827
diff changeset
588 j++;
f6dab0e7a817 Take care of a special case where we would incorrectly parse incoming IMs
Mark Doliner <mark@kingant.net>
parents: 27827
diff changeset
589 while (j != x_len && x[j] != '"')
f6dab0e7a817 Take care of a special case where we would incorrectly parse incoming IMs
Mark Doliner <mark@kingant.net>
parents: 27827
diff changeset
590 j++;
f6dab0e7a817 Take care of a special case where we would incorrectly parse incoming IMs
Mark Doliner <mark@kingant.net>
parents: 27827
diff changeset
591 } else if (x[j] == '\'') {
f6dab0e7a817 Take care of a special case where we would incorrectly parse incoming IMs
Mark Doliner <mark@kingant.net>
parents: 27827
diff changeset
592 /* We're inside a quoted attribute value. Skip to the end */
f6dab0e7a817 Take care of a special case where we would incorrectly parse incoming IMs
Mark Doliner <mark@kingant.net>
parents: 27827
diff changeset
593 j++;
f6dab0e7a817 Take care of a special case where we would incorrectly parse incoming IMs
Mark Doliner <mark@kingant.net>
parents: 27827
diff changeset
594 while (j != x_len && x[j] != '\'')
f6dab0e7a817 Take care of a special case where we would incorrectly parse incoming IMs
Mark Doliner <mark@kingant.net>
parents: 27827
diff changeset
595 j++;
f6dab0e7a817 Take care of a special case where we would incorrectly parse incoming IMs
Mark Doliner <mark@kingant.net>
parents: 27827
diff changeset
596 }
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
597 if (j != x_len)
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
598 /* Keep looking for the end of this tag */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
599 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
600
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
601 /* This < has no corresponding > */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
602 g_string_append_c(cdata, x[i]);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
603 no_more_gt_brackets = TRUE;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
604 break;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
605 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
606
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
607 tag = g_strndup(x + i, j - i + 1);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
608 tag_name = yahoo_markup_get_tag_name(tag, &is_closing_tag);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
609
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
610 match = g_hash_table_lookup(tags_ht, tag_name);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
611 if (match == NULL) {
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
612 /* Unknown tag. The user probably typed a less-than sign */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
613 g_string_append_c(cdata, x[i]);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
614 no_more_gt_brackets = TRUE;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
615 g_free(tag);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
616 g_free(tag_name);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
617 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
618 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
619
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
620 /* Some tags are in the hash table only because we
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
621 * want to ignore them */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
622 if (match[0] != '\0') {
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
623 /* Append any character data that belongs in the current node */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
624 if (cdata->len > 0) {
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
625 xmlnode_insert_data(cur, cdata->str, cdata->len);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
626 g_string_truncate(cdata, 0);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
627 }
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
628 if (g_str_equal(tag_name, "font"))
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
629 /* Font tags are a special case. We don't
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
630 * necessarily want to replace the whole thing--
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
631 * we just want to fix the size attribute. */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
632 yahoo_codes_to_html_add_tag(&cur, tag, is_closing_tag, tag_name, TRUE);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
633 else
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
634 yahoo_codes_to_html_add_tag(&cur, match, is_closing_tag, tag_name, FALSE);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
635 }
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
636
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
637 i = j;
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
638 g_free(tag);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
639 g_free(tag_name);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
640 break;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
641 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
642
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
643 } else {
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
644 g_string_append_c(cdata, x[i]);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
645 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
646 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
647
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
648 /* Append any remaining character data */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
649 if (cdata->len > 0)
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
650 xmlnode_insert_data(cur, cdata->str, cdata->len);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
651 g_string_free(cdata, TRUE);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
652
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
653 /* Serialize our HTML */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
654 xmlstr1 = xmlnode_to_str(html, NULL);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
655 xmlnode_free(html);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
656
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
657 /* Strip off the outter HTML node */
27824
5eca0f387c13 Make this enum follow our naming conventions a little better
Mark Doliner <mark@kingant.net>
parents: 27815
diff changeset
658 /* This probably isn't necessary, especially if we made the outter HTML
5eca0f387c13 Make this enum follow our naming conventions a little better
Mark Doliner <mark@kingant.net>
parents: 27815
diff changeset
659 * node an empty span. But the HTML is simpler this way. */
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
660 xmlstr2 = g_strndup(xmlstr1 + 6, strlen(xmlstr1) - 13);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
661 g_free(xmlstr1);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
662
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
663 purple_debug_misc("yahoo", "yahoo_codes_to_html: Returning string: '%s'.\n", xmlstr2);
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27781
diff changeset
664 return xmlstr2;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
665 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
666
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
667 /* borrowed from gtkimhtml */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
668 #define MAX_FONT_SIZE 7
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
669 #define POINT_SIZE(x) (_point_sizes [MIN ((x > 0 ? x : 1), MAX_FONT_SIZE) - 1])
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
670 static const gint _point_sizes [] = { 8, 10, 12, 14, 20, 30, 40 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
671
27824
5eca0f387c13 Make this enum follow our naming conventions a little better
Mark Doliner <mark@kingant.net>
parents: 27815
diff changeset
672 enum fatype
5eca0f387c13 Make this enum follow our naming conventions a little better
Mark Doliner <mark@kingant.net>
parents: 27815
diff changeset
673 {
5eca0f387c13 Make this enum follow our naming conventions a little better
Mark Doliner <mark@kingant.net>
parents: 27815
diff changeset
674 FATYPE_SIZE,
5eca0f387c13 Make this enum follow our naming conventions a little better
Mark Doliner <mark@kingant.net>
parents: 27815
diff changeset
675 FATYPE_COLOR,
5eca0f387c13 Make this enum follow our naming conventions a little better
Mark Doliner <mark@kingant.net>
parents: 27815
diff changeset
676 FATYPE_FACE,
5eca0f387c13 Make this enum follow our naming conventions a little better
Mark Doliner <mark@kingant.net>
parents: 27815
diff changeset
677 FATYPE_JUNK
5eca0f387c13 Make this enum follow our naming conventions a little better
Mark Doliner <mark@kingant.net>
parents: 27815
diff changeset
678 };
5eca0f387c13 Make this enum follow our naming conventions a little better
Mark Doliner <mark@kingant.net>
parents: 27815
diff changeset
679
5eca0f387c13 Make this enum follow our naming conventions a little better
Mark Doliner <mark@kingant.net>
parents: 27815
diff changeset
680 typedef struct
5eca0f387c13 Make this enum follow our naming conventions a little better
Mark Doliner <mark@kingant.net>
parents: 27815
diff changeset
681 {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
682 enum fatype type;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
683 union {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
684 int size;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
685 char *color;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
686 char *face;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
687 char *junk;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
688 } u;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
689 } fontattr;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
690
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
691 static void fontattr_free(fontattr *f)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
692 {
27824
5eca0f387c13 Make this enum follow our naming conventions a little better
Mark Doliner <mark@kingant.net>
parents: 27815
diff changeset
693 if (f->type == FATYPE_COLOR)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
694 g_free(f->u.color);
27824
5eca0f387c13 Make this enum follow our naming conventions a little better
Mark Doliner <mark@kingant.net>
parents: 27815
diff changeset
695 else if (f->type == FATYPE_FACE)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
696 g_free(f->u.face);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
697 g_free(f);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
698 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
699
27825
bc9da266d25d This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <mark@kingant.net>
parents: 27824
diff changeset
700 static void yahoo_htc_list_cleanup(GSList *l)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
701 {
27825
bc9da266d25d This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <mark@kingant.net>
parents: 27824
diff changeset
702 while (l != NULL) {
bc9da266d25d This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <mark@kingant.net>
parents: 27824
diff changeset
703 g_free(l->data);
bc9da266d25d This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <mark@kingant.net>
parents: 27824
diff changeset
704 l = g_slist_delete_link(l, l);
bc9da266d25d This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <mark@kingant.net>
parents: 27824
diff changeset
705 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
706 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
707
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
708 static void _parse_font_tag(const char *src, GString *dest, int *i, int *j,
27825
bc9da266d25d This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <mark@kingant.net>
parents: 27824
diff changeset
709 int len, GSList **colors, GSList **tags, GQueue *ftattr)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
710 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
711 int m, n, vstart;
27826
c859855474ba Use TRUE and FALSE instead of 1 and 0. I like TRUE and FALSE.
Mark Doliner <mark@kingant.net>
parents: 27825
diff changeset
712 gboolean quote = FALSE, done = FALSE;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
713
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
714 m = *j;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
715
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
716 while (1) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
717 m++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
718
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
719 if (m >= len) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
720 g_string_append(dest, &src[*i]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
721 *i = len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
722 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
723 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
724
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
725 if (src[m] == '=') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
726 n = vstart = m;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
727 while (1) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
728 n++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
729
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
730 if (n >= len) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
731 m = n;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
732 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
733 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
734
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
735 if (src[n] == '"') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
736 if (!quote) {
27826
c859855474ba Use TRUE and FALSE instead of 1 and 0. I like TRUE and FALSE.
Mark Doliner <mark@kingant.net>
parents: 27825
diff changeset
737 quote = TRUE;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
738 vstart = n;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
739 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
740 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
741 done = 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
742 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
743 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
744
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
745 if (!quote && ((src[n] == ' ') || (src[n] == '>')))
27826
c859855474ba Use TRUE and FALSE instead of 1 and 0. I like TRUE and FALSE.
Mark Doliner <mark@kingant.net>
parents: 27825
diff changeset
746 done = TRUE;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
747
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
748 if (done) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
749 if (!g_ascii_strncasecmp(&src[*j+1], "FACE", m - *j - 1)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
750 fontattr *f;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
751
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
752 f = g_new(fontattr, 1);
27824
5eca0f387c13 Make this enum follow our naming conventions a little better
Mark Doliner <mark@kingant.net>
parents: 27815
diff changeset
753 f->type = FATYPE_FACE;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
754 f->u.face = g_strndup(&src[vstart+1], n-vstart-1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
755 if (!ftattr)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
756 ftattr = g_queue_new();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
757 g_queue_push_tail(ftattr, f);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
758 m = n;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
759 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
760 } else if (!g_ascii_strncasecmp(&src[*j+1], "SIZE", m - *j - 1)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
761 fontattr *f;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
762
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
763 f = g_new(fontattr, 1);
27824
5eca0f387c13 Make this enum follow our naming conventions a little better
Mark Doliner <mark@kingant.net>
parents: 27815
diff changeset
764 f->type = FATYPE_SIZE;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
765 f->u.size = POINT_SIZE(strtol(&src[vstart+1], NULL, 10));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
766 if (!ftattr)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
767 ftattr = g_queue_new();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
768 g_queue_push_tail(ftattr, f);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
769 m = n;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
770 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
771 } else if (!g_ascii_strncasecmp(&src[*j+1], "COLOR", m - *j - 1)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
772 fontattr *f;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
773
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
774 f = g_new(fontattr, 1);
27824
5eca0f387c13 Make this enum follow our naming conventions a little better
Mark Doliner <mark@kingant.net>
parents: 27815
diff changeset
775 f->type = FATYPE_COLOR;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
776 f->u.color = g_strndup(&src[vstart+1], n-vstart-1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
777 if (!ftattr)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
778 ftattr = g_queue_new();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
779 g_queue_push_head(ftattr, f);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
780 m = n;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
781 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
782 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
783 fontattr *f;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
784
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
785 f = g_new(fontattr, 1);
27824
5eca0f387c13 Make this enum follow our naming conventions a little better
Mark Doliner <mark@kingant.net>
parents: 27815
diff changeset
786 f->type = FATYPE_JUNK;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
787 f->u.junk = g_strndup(&src[*j+1], n-*j);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
788 if (!ftattr)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
789 ftattr = g_queue_new();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
790 g_queue_push_tail(ftattr, f);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
791 m = n;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
792 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
793 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
794
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
795 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
796 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
797 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
798
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
799 if (src[m] == ' ')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
800 *j = m;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
801
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
802 if (src[m] == '>') {
27826
c859855474ba Use TRUE and FALSE instead of 1 and 0. I like TRUE and FALSE.
Mark Doliner <mark@kingant.net>
parents: 27825
diff changeset
803 gboolean needendtag = FALSE;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
804 fontattr *f;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
805 GString *tmp = g_string_new(NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
806
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
807 if (!g_queue_is_empty(ftattr)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
808 while ((f = g_queue_pop_tail(ftattr))) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
809 switch (f->type) {
27824
5eca0f387c13 Make this enum follow our naming conventions a little better
Mark Doliner <mark@kingant.net>
parents: 27815
diff changeset
810 case FATYPE_SIZE:
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
811 if (!needendtag) {
27826
c859855474ba Use TRUE and FALSE instead of 1 and 0. I like TRUE and FALSE.
Mark Doliner <mark@kingant.net>
parents: 27825
diff changeset
812 needendtag = TRUE;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
813 g_string_append(dest, "<font ");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
814 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
815
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
816 g_string_append_printf(dest, "size=\"%d\" ", f->u.size);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
817 break;
27824
5eca0f387c13 Make this enum follow our naming conventions a little better
Mark Doliner <mark@kingant.net>
parents: 27815
diff changeset
818 case FATYPE_FACE:
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
819 if (!needendtag) {
27826
c859855474ba Use TRUE and FALSE instead of 1 and 0. I like TRUE and FALSE.
Mark Doliner <mark@kingant.net>
parents: 27825
diff changeset
820 needendtag = TRUE;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
821 g_string_append(dest, "<font ");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
822 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
823
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
824 g_string_append_printf(dest, "face=\"%s\" ", f->u.face);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
825 break;
27824
5eca0f387c13 Make this enum follow our naming conventions a little better
Mark Doliner <mark@kingant.net>
parents: 27815
diff changeset
826 case FATYPE_JUNK:
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
827 if (!needendtag) {
27826
c859855474ba Use TRUE and FALSE instead of 1 and 0. I like TRUE and FALSE.
Mark Doliner <mark@kingant.net>
parents: 27825
diff changeset
828 needendtag = TRUE;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
829 g_string_append(dest, "<font ");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
830 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
831
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
832 g_string_append(dest, f->u.junk);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
833 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
834
27824
5eca0f387c13 Make this enum follow our naming conventions a little better
Mark Doliner <mark@kingant.net>
parents: 27815
diff changeset
835 case FATYPE_COLOR:
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
836 if (needendtag) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
837 g_string_append(tmp, "</font>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
838 dest->str[dest->len-1] = '>';
27826
c859855474ba Use TRUE and FALSE instead of 1 and 0. I like TRUE and FALSE.
Mark Doliner <mark@kingant.net>
parents: 27825
diff changeset
839 needendtag = TRUE;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
840 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
841
27825
bc9da266d25d This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <mark@kingant.net>
parents: 27824
diff changeset
842 g_string_append(tmp, *colors ? (*colors)->data : "\033[#000000m");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
843 g_string_append_printf(dest, "\033[%sm", f->u.color);
27825
bc9da266d25d This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <mark@kingant.net>
parents: 27824
diff changeset
844 *colors = g_slist_prepend(*colors,
bc9da266d25d This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <mark@kingant.net>
parents: 27824
diff changeset
845 g_strdup_printf("\033[%sm", f->u.color));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
846 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
847 }
27831
7ee833540b25 Let's just call this after the switch statement...
Mark Doliner <mark@kingant.net>
parents: 27830
diff changeset
848 fontattr_free(f);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
849 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
850
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
851 g_queue_free(ftattr);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
852 ftattr = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
853
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
854 if (needendtag) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
855 dest->str[dest->len-1] = '>';
27825
bc9da266d25d This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <mark@kingant.net>
parents: 27824
diff changeset
856 *tags = g_slist_prepend(*tags, g_strdup("</font>"));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
857 g_string_free(tmp, TRUE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
858 } else {
27825
bc9da266d25d This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <mark@kingant.net>
parents: 27824
diff changeset
859 *tags = g_slist_prepend(*tags, tmp->str);
27745
a7e9a0a885e9 Oh shit no it wasn't. I have no one to blame but fear itself.
Mark Doliner <mark@kingant.net>
parents: 27744
diff changeset
860 g_string_free(tmp, FALSE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
861 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
862 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
863
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
864 *i = *j = m;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
865 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
866 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
867 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
868 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
869
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
870 char *yahoo_html_to_codes(const char *src)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
871 {
27825
bc9da266d25d This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <mark@kingant.net>
parents: 27824
diff changeset
872 GSList *colors = NULL;
bc9da266d25d This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <mark@kingant.net>
parents: 27824
diff changeset
873 GSList *tags = NULL;
27766
8660d8bc467c Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <mark@kingant.net>
parents: 27765
diff changeset
874 size_t src_len;
8660d8bc467c Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <mark@kingant.net>
parents: 27765
diff changeset
875 int i, j;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
876 GString *dest;
27743
a0a8b61301c8 Simplify a wee bit
Mark Doliner <mark@kingant.net>
parents: 27694
diff changeset
877 char *esc;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
878 GQueue *ftattr = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
879 gboolean no_more_specials = FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
880
27766
8660d8bc467c Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <mark@kingant.net>
parents: 27765
diff changeset
881 src_len = strlen(src);
8660d8bc467c Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <mark@kingant.net>
parents: 27765
diff changeset
882 dest = g_string_sized_new(src_len);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
883
27766
8660d8bc467c Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <mark@kingant.net>
parents: 27765
diff changeset
884 for (i = 0; i < src_len; i++) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
885
27827
64fd19956153 Reuse our purple_markup_unescape_entity() function instead of
Mark Doliner <mark@kingant.net>
parents: 27826
diff changeset
886 if (src[i] == '<' && !no_more_specials) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
887 j = i;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
888
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
889 while (1) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
890 j++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
891
27766
8660d8bc467c Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <mark@kingant.net>
parents: 27765
diff changeset
892 if (j >= src_len) { /* no '>' */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
893 g_string_append_c(dest, src[i]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
894 no_more_specials = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
895 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
896 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
897
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
898 if (src[j] == '<') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
899 /* FIXME: This doesn't convert outgoing entities.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
900 * However, I suspect this case may never
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
901 * happen anymore because of the entities.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
902 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
903 g_string_append_len(dest, &src[i], j - i);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
904 i = j - 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
905 if (ftattr) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
906 fontattr *f;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
907
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
908 while ((f = g_queue_pop_head(ftattr)))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
909 fontattr_free(f);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
910 g_queue_free(ftattr);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
911 ftattr = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
912 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
913 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
914 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
915
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
916 if (src[j] == ' ') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
917 if (!g_ascii_strncasecmp(&src[i+1], "BODY", j - i - 1)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
918 char *t = strchr(&src[j], '>');
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
919 if (!t) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
920 g_string_append(dest, &src[i]);
27766
8660d8bc467c Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <mark@kingant.net>
parents: 27765
diff changeset
921 i = src_len;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
922 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
923 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
924 i = t - src;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
925 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
926 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
927 } else if (!g_ascii_strncasecmp(&src[i+1], "A HREF=\"", j - i - 1)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
928 j += 7;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
929 g_string_append(dest, "\033[lm");
27781
ed11d1cabbe4 Fixes #9661
Sulabh Mahajan <sulabh@soc.pidgin.im>
parents: 27779
diff changeset
930 if (purple_str_has_prefix(src + j, "mailto:"))
ed11d1cabbe4 Fixes #9661
Sulabh Mahajan <sulabh@soc.pidgin.im>
parents: 27779
diff changeset
931 j += sizeof("mailto:") - 1;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
932 while (1) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
933 g_string_append_c(dest, src[j]);
27766
8660d8bc467c Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <mark@kingant.net>
parents: 27765
diff changeset
934 if (++j >= src_len) {
8660d8bc467c Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <mark@kingant.net>
parents: 27765
diff changeset
935 i = src_len;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
936 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
937 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
938 if (src[j] == '"') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
939 g_string_append(dest, "\033[xlm");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
940 while (1) {
27766
8660d8bc467c Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <mark@kingant.net>
parents: 27765
diff changeset
941 if (++j >= src_len) {
8660d8bc467c Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <mark@kingant.net>
parents: 27765
diff changeset
942 i = src_len;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
943 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
944 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
945 if (!g_ascii_strncasecmp(&src[j], "</A>", 4)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
946 j += 3;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
947 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
948 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
949 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
950 i = j;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
951 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
952 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
953 }
16109
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15822
diff changeset
954 } else if (!g_ascii_strncasecmp(&src[i+1], "SPAN", j - i - 1)) { /* drop span tags */
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15822
diff changeset
955 while (1) {
27766
8660d8bc467c Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <mark@kingant.net>
parents: 27765
diff changeset
956 if (++j >= src_len) {
16109
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15822
diff changeset
957 g_string_append(dest, &src[i]);
27766
8660d8bc467c Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <mark@kingant.net>
parents: 27765
diff changeset
958 i = src_len;
16109
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15822
diff changeset
959 break;
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15822
diff changeset
960 }
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15822
diff changeset
961 if (src[j] == '>') {
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15822
diff changeset
962 i = j;
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15822
diff changeset
963 break;
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15822
diff changeset
964 }
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15822
diff changeset
965 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
966 } else if (g_ascii_strncasecmp(&src[i+1], "FONT", j - i - 1)) { /* not interested! */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
967 while (1) {
27766
8660d8bc467c Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <mark@kingant.net>
parents: 27765
diff changeset
968 if (++j >= src_len) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
969 g_string_append(dest, &src[i]);
27766
8660d8bc467c Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <mark@kingant.net>
parents: 27765
diff changeset
970 i = src_len;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
971 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
972 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
973 if (src[j] == '>') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
974 g_string_append_len(dest, &src[i], j - i + 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
975 i = j;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
976 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
977 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
978 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
979 } else { /* yay we have a font tag */
27825
bc9da266d25d This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <mark@kingant.net>
parents: 27824
diff changeset
980 _parse_font_tag(src, dest, &i, &j, src_len, &colors, &tags, ftattr);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
981 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
982
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
983 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
984 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
985
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
986 if (src[j] == '>') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
987 /* This has some problems like the FIXME for the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
988 * '<' case. and like that case, I suspect the case
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
989 * that this has problems is won't happen anymore anyway.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
990 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
991 int sublen = j - i - 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
992
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
993 if (sublen) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
994 if (!g_ascii_strncasecmp(&src[i+1], "B", sublen)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
995 g_string_append(dest, "\033[1m");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
996 } else if (!g_ascii_strncasecmp(&src[i+1], "/B", sublen)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
997 g_string_append(dest, "\033[x1m");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
998 } else if (!g_ascii_strncasecmp(&src[i+1], "I", sublen)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
999 g_string_append(dest, "\033[2m");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1000 } else if (!g_ascii_strncasecmp(&src[i+1], "/I", sublen)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1001 g_string_append(dest, "\033[x2m");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1002 } else if (!g_ascii_strncasecmp(&src[i+1], "U", sublen)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1003 g_string_append(dest, "\033[4m");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1004 } else if (!g_ascii_strncasecmp(&src[i+1], "/U", sublen)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1005 g_string_append(dest, "\033[x4m");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1006 } else if (!g_ascii_strncasecmp(&src[i+1], "/A", sublen)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1007 g_string_append(dest, "\033[xlm");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1008 } else if (!g_ascii_strncasecmp(&src[i+1], "BR", sublen)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1009 g_string_append_c(dest, '\n');
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1010 } else if (!g_ascii_strncasecmp(&src[i+1], "/BODY", sublen)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1011 /* mmm, </body> tags. *BURP* */
16109
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15822
diff changeset
1012 } else if (!g_ascii_strncasecmp(&src[i+1], "/SPAN", sublen)) {
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15822
diff changeset
1013 /* </span> tags. dangerously close to </spam> */
27825
bc9da266d25d This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <mark@kingant.net>
parents: 27824
diff changeset
1014 } else if (!g_ascii_strncasecmp(&src[i+1], "/FONT", sublen) && tags != NULL) {
bc9da266d25d This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <mark@kingant.net>
parents: 27824
diff changeset
1015 char *etag;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1016
27825
bc9da266d25d This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <mark@kingant.net>
parents: 27824
diff changeset
1017 etag = tags->data;
bc9da266d25d This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <mark@kingant.net>
parents: 27824
diff changeset
1018 tags = g_slist_delete_link(tags, tags);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1019 if (etag) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1020 g_string_append(dest, etag);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1021 if (!strcmp(etag, "</font>")) {
27825
bc9da266d25d This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <mark@kingant.net>
parents: 27824
diff changeset
1022 if (colors != NULL) {
bc9da266d25d This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <mark@kingant.net>
parents: 27824
diff changeset
1023 g_free(colors->data);
bc9da266d25d This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <mark@kingant.net>
parents: 27824
diff changeset
1024 colors = g_slist_delete_link(colors, colors);
bc9da266d25d This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <mark@kingant.net>
parents: 27824
diff changeset
1025 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1026 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1027 g_free(etag);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1028 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1029 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1030 g_string_append_len(dest, &src[i], j - i + 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1031 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1032 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1033 g_string_append_len(dest, &src[i], j - i + 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1034 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1035
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1036 i = j;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1037 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1038 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1039
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1040 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1041
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1042 } else {
27827
64fd19956153 Reuse our purple_markup_unescape_entity() function instead of
Mark Doliner <mark@kingant.net>
parents: 27826
diff changeset
1043 const char *entity;
64fd19956153 Reuse our purple_markup_unescape_entity() function instead of
Mark Doliner <mark@kingant.net>
parents: 27826
diff changeset
1044 int length;
64fd19956153 Reuse our purple_markup_unescape_entity() function instead of
Mark Doliner <mark@kingant.net>
parents: 27826
diff changeset
1045
64fd19956153 Reuse our purple_markup_unescape_entity() function instead of
Mark Doliner <mark@kingant.net>
parents: 27826
diff changeset
1046 entity = purple_markup_unescape_entity(src + i, &length);
64fd19956153 Reuse our purple_markup_unescape_entity() function instead of
Mark Doliner <mark@kingant.net>
parents: 27826
diff changeset
1047 if (entity != NULL) {
64fd19956153 Reuse our purple_markup_unescape_entity() function instead of
Mark Doliner <mark@kingant.net>
parents: 27826
diff changeset
1048 /* src[i] is the start of an HTML entity */
64fd19956153 Reuse our purple_markup_unescape_entity() function instead of
Mark Doliner <mark@kingant.net>
parents: 27826
diff changeset
1049 g_string_append(dest, entity);
64fd19956153 Reuse our purple_markup_unescape_entity() function instead of
Mark Doliner <mark@kingant.net>
parents: 27826
diff changeset
1050 i += length - 1;
64fd19956153 Reuse our purple_markup_unescape_entity() function instead of
Mark Doliner <mark@kingant.net>
parents: 27826
diff changeset
1051 } else
64fd19956153 Reuse our purple_markup_unescape_entity() function instead of
Mark Doliner <mark@kingant.net>
parents: 27826
diff changeset
1052 /* src[i] is a normal character */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1053 g_string_append_c(dest, src[i]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1054 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1055 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1056
27743
a0a8b61301c8 Simplify a wee bit
Mark Doliner <mark@kingant.net>
parents: 27694
diff changeset
1057 esc = g_strescape(dest->str, NULL);
27302
377e063ecda5 Convert the yahoo prpl to using the debug convenience functions instead of
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27137
diff changeset
1058 purple_debug_misc("yahoo", "yahoo_html_to_codes: Returning string: '%s'.\n", esc);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1059 g_free(esc);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1060
27825
bc9da266d25d This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <mark@kingant.net>
parents: 27824
diff changeset
1061 yahoo_htc_list_cleanup(colors);
bc9da266d25d This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <mark@kingant.net>
parents: 27824
diff changeset
1062 yahoo_htc_list_cleanup(tags);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1063
27743
a0a8b61301c8 Simplify a wee bit
Mark Doliner <mark@kingant.net>
parents: 27694
diff changeset
1064 return g_string_free(dest, FALSE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1065 }