Thu, 13 Nov 2014 00:56:55 -0500
Remove -Wno-sign-compare and backport fixes from default.
| 6513 | 1 | /* |
| 15884 | 2 | * purple |
| 6513 | 3 | * |
| 4 | * Some code copyright 2003 Tim Ringenbach <omarvo@hotmail.com> | |
| 5 | * (marv on irc.freenode.net) | |
| 6 | * | |
| 7 | * This program is free software; you can redistribute it and/or modify | |
| 8 | * it under the terms of the GNU General Public License as published by | |
| 9 | * the Free Software Foundation; either version 2 of the License, or | |
| 10 | * (at your option) any later version. | |
| 11 | * | |
| 12 | * This program is distributed in the hope that it will be useful, | |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 | * GNU General Public License for more details. | |
| 16 | * | |
| 17 | * You should have received a copy of the GNU General Public License | |
| 18 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19337
diff
changeset
|
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 6513 | 20 | * |
| 21 | */ | |
| 22 | ||
| 23 | #ifdef HAVE_CONFIG_H | |
| 24 | #include "config.h" | |
|
27335
06a805d4e690
Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents:
24181
diff
changeset
|
25 | #endif /* HAVE_CONFIG_H */ |
| 6513 | 26 | |
|
10023
6b0014040323
[gaim-migrate @ 10955]
Mark Doliner <markdoliner@pidgin.im>
parents:
9164
diff
changeset
|
27 | #include "debug.h" |
|
6b0014040323
[gaim-migrate @ 10955]
Mark Doliner <markdoliner@pidgin.im>
parents:
9164
diff
changeset
|
28 | #include "internal.h" |
| 6513 | 29 | #include "prpl.h" |
|
10023
6b0014040323
[gaim-migrate @ 10955]
Mark Doliner <markdoliner@pidgin.im>
parents:
9164
diff
changeset
|
30 | |
|
27555
afb7cb5c350c
Update for file renames.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27547
diff
changeset
|
31 | #include "libymsg.h" |
| 6513 | 32 | |
|
6546
6a14dfe43d5c
[gaim-migrate @ 7068]
Mark Doliner <markdoliner@pidgin.im>
parents:
6513
diff
changeset
|
33 | #include <string.h> |
|
24181
e028e31dcc67
Do a better job of detecting if the yahoo account is connecting through a HTTP
Daniel Atallah <datallah@pidgin.im>
parents:
23173
diff
changeset
|
34 | |
|
e028e31dcc67
Do a better job of detecting if the yahoo account is connecting through a HTTP
Daniel Atallah <datallah@pidgin.im>
parents:
23173
diff
changeset
|
35 | gboolean |
|
30435
47b104e299b1
Make HTTP proxy detection in the yahoo prpls a bit more robust. This should
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29324
diff
changeset
|
36 | yahoo_account_use_http_proxy(PurpleConnection *pc) |
|
24181
e028e31dcc67
Do a better job of detecting if the yahoo account is connecting through a HTTP
Daniel Atallah <datallah@pidgin.im>
parents:
23173
diff
changeset
|
37 | { |
|
30435
47b104e299b1
Make HTTP proxy detection in the yahoo prpls a bit more robust. This should
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29324
diff
changeset
|
38 | PurpleAccount *account = purple_connection_get_account(pc); |
|
47b104e299b1
Make HTTP proxy detection in the yahoo prpls a bit more robust. This should
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29324
diff
changeset
|
39 | PurpleProxyInfo *ppi = NULL; |
|
47b104e299b1
Make HTTP proxy detection in the yahoo prpls a bit more robust. This should
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29324
diff
changeset
|
40 | PurpleProxyType type = PURPLE_PROXY_NONE; |
|
47b104e299b1
Make HTTP proxy detection in the yahoo prpls a bit more robust. This should
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29324
diff
changeset
|
41 | gboolean proxy_ssl = purple_account_get_bool(account, "proxy_ssl", FALSE); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30755
diff
changeset
|
42 | |
|
30435
47b104e299b1
Make HTTP proxy detection in the yahoo prpls a bit more robust. This should
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29324
diff
changeset
|
43 | if(proxy_ssl) |
|
47b104e299b1
Make HTTP proxy detection in the yahoo prpls a bit more robust. This should
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29324
diff
changeset
|
44 | ppi = purple_proxy_get_setup(account); |
|
47b104e299b1
Make HTTP proxy detection in the yahoo prpls a bit more robust. This should
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29324
diff
changeset
|
45 | else |
|
30755
10446db8b003
Fix connecting to Yahoo when a global proxy has been specified, but is
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
30435
diff
changeset
|
46 | ppi = purple_proxy_get_setup(NULL); |
|
30435
47b104e299b1
Make HTTP proxy detection in the yahoo prpls a bit more robust. This should
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29324
diff
changeset
|
47 | |
|
47b104e299b1
Make HTTP proxy detection in the yahoo prpls a bit more robust. This should
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29324
diff
changeset
|
48 | type = purple_proxy_info_get_type(ppi); |
|
47b104e299b1
Make HTTP proxy detection in the yahoo prpls a bit more robust. This should
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29324
diff
changeset
|
49 | |
|
47b104e299b1
Make HTTP proxy detection in the yahoo prpls a bit more robust. This should
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29324
diff
changeset
|
50 | return (type == PURPLE_PROXY_HTTP || type == PURPLE_PROXY_USE_ENVVAR); |
|
24181
e028e31dcc67
Do a better job of detecting if the yahoo account is connecting through a HTTP
Daniel Atallah <datallah@pidgin.im>
parents:
23173
diff
changeset
|
51 | } |
|
e028e31dcc67
Do a better job of detecting if the yahoo account is connecting through a HTTP
Daniel Atallah <datallah@pidgin.im>
parents:
23173
diff
changeset
|
52 | |
|
22202
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
53 | /* |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
54 | * Returns cookies formatted as a null terminated string for the given connection. |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
55 | * Must g_free return value. |
|
27335
06a805d4e690
Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents:
24181
diff
changeset
|
56 | * |
|
22202
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
57 | * TODO:will work, but must test for strict correctness |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
58 | */ |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
59 | gchar* yahoo_get_cookies(PurpleConnection *gc) |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
60 | { |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
61 | gchar *ans = NULL; |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
62 | gchar *cur; |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
63 | char firstflag = 1; |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
64 | gchar *t1,*t2,*t3; |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
65 | GSList *tmp; |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
66 | GSList *cookies; |
|
27959
f842ae57da4e
Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27683
diff
changeset
|
67 | cookies = ((YahooData*)(gc->proto_data))->cookies; |
|
22202
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
68 | tmp = cookies; |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
69 | while(tmp) |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
70 | { |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
71 | cur = tmp->data; |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
72 | t1 = ans; |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
73 | t2 = g_strrstr(cur, ";expires="); |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
74 | if(t2 == NULL) |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
75 | t2 = g_strrstr(cur, "; expires="); |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
76 | if(t2 == NULL) |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
77 | { |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
78 | if(firstflag) |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
79 | ans = g_strdup_printf("%c=%s", cur[0], cur+2); |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
80 | else |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
81 | ans = g_strdup_printf("%s; %c=%s", t1, cur[0], cur+2); |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
82 | } |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
83 | else |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
84 | { |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
85 | t3 = strstr(t2+1, ";"); |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
86 | if(t3 != NULL) |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
87 | { |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
88 | t2[0] = '\0'; |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
89 | |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
90 | if(firstflag) |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
91 | ans = g_strdup_printf("%c=%s%s", cur[0], cur+2, t3); |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
92 | else |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
93 | ans = g_strdup_printf("%s; %c=%s%s", t1, cur[0], cur+2, t3); |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
94 | |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
95 | t2[0] = ';'; |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
96 | } |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
97 | else |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
98 | { |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
99 | t2[0] = '\0'; |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
100 | |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
101 | if(firstflag) |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
102 | ans = g_strdup_printf("%c=%s", cur[0], cur+2); |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
103 | else |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
104 | ans = g_strdup_printf("%s; %c=%s", t1, cur[0], cur+2); |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
105 | |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
106 | t2[0] = ';'; |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
107 | } |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
108 | } |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
109 | if(firstflag) |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
110 | firstflag = 0; |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
111 | else |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
112 | g_free(t1); |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
113 | tmp = g_slist_next(tmp); |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
114 | } |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
115 | return ans; |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
116 | } |
|
6546
6a14dfe43d5c
[gaim-migrate @ 7068]
Mark Doliner <markdoliner@pidgin.im>
parents:
6513
diff
changeset
|
117 | |
| 7827 | 118 | /** |
| 119 | * Encode some text to send to the yahoo server. | |
| 120 | * | |
| 121 | * @param gc The connection handle. | |
| 122 | * @param str The null terminated utf8 string to encode. | |
| 123 | * @param utf8 If not @c NULL, whether utf8 is okay or not. | |
| 124 | * Even if it is okay, we may not use it. If we | |
| 125 | * used it, we set this to @c TRUE, else to | |
| 126 | * @c FALSE. If @c NULL, false is assumed, and | |
| 127 | * it is not dereferenced. | |
| 128 | * @return The g_malloced string in the appropriate encoding. | |
| 129 | */ | |
| 15884 | 130 | char *yahoo_string_encode(PurpleConnection *gc, const char *str, gboolean *utf8) |
| 7827 | 131 | { |
|
27959
f842ae57da4e
Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27683
diff
changeset
|
132 | YahooData *yd = gc->proto_data; |
| 7827 | 133 | char *ret; |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10380
diff
changeset
|
134 | const char *to_codeset; |
|
35258
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
135 | GError *error = NULL; |
| 7827 | 136 | |
|
23173
c6dde2d2e30e
applied changes from a5e7a62db1d43009f4ff463b7fe67ff3a7275a78
Daniel Atallah <datallah@pidgin.im>
parents:
22289
diff
changeset
|
137 | if (yd->jp) |
|
c6dde2d2e30e
applied changes from a5e7a62db1d43009f4ff463b7fe67ff3a7275a78
Daniel Atallah <datallah@pidgin.im>
parents:
22289
diff
changeset
|
138 | return g_strdup(str); |
| 9164 | 139 | |
| 7827 | 140 | if (utf8 && *utf8) /* FIXME: maybe don't use utf8 if it'll fit in latin1 */ |
| 141 | return g_strdup(str); | |
| 142 | ||
|
23173
c6dde2d2e30e
applied changes from a5e7a62db1d43009f4ff463b7fe67ff3a7275a78
Daniel Atallah <datallah@pidgin.im>
parents:
22289
diff
changeset
|
143 | to_codeset = purple_account_get_string(purple_connection_get_account(gc), "local_charset", "ISO-8859-1"); |
|
35258
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
144 | ret = g_convert_with_fallback(str, -1, to_codeset, "UTF-8", "?", NULL, NULL, &error); |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
145 | if (!ret) { |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
146 | if (error) { |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
147 | purple_debug_error("yahoo", "Could not convert %s from UTF-8 to " |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
148 | "%s: %d - %s\n", str ? str : "(null)", to_codeset, |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
149 | error->code, |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
150 | error->message ? error->message : "(null)"); |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
151 | g_error_free(error); |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
152 | } else { |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
153 | purple_debug_error("yahoo", "Could not convert %s from UTF-8 to " |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
154 | "%s: unkown error\n", str ? str : "(null)", to_codeset); |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
155 | } |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
156 | return g_strdup(""); |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
157 | } |
| 7827 | 158 | |
|
35258
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
159 | return ret; |
| 7827 | 160 | } |
| 161 | ||
| 162 | /** | |
| 163 | * Decode some text received from the server. | |
| 164 | * | |
| 165 | * @param gc The gc handle. | |
| 166 | * @param str The null terminated string to decode. | |
| 167 | * @param utf8 Did the server tell us it was supposed to be utf8? | |
| 168 | * @return The decoded, utf-8 string, which must be g_free()'d. | |
| 169 | */ | |
| 15884 | 170 | char *yahoo_string_decode(PurpleConnection *gc, const char *str, gboolean utf8) |
| 7827 | 171 | { |
|
27959
f842ae57da4e
Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27683
diff
changeset
|
172 | YahooData *yd = gc->proto_data; |
| 7827 | 173 | char *ret; |
| 14347 | 174 | const char *from_codeset; |
|
35258
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
175 | GError *error = NULL; |
| 7827 | 176 | |
| 177 | if (utf8) { | |
| 178 | if (g_utf8_validate(str, -1, NULL)) | |
| 179 | return g_strdup(str); | |
| 35257 | 180 | purple_debug_warning("yahoo", "Server told us a string was supposed " |
| 181 | "to be UTF-8, but it was not. Will try another encoding.\n"); | |
| 7827 | 182 | } |
| 183 | ||
| 9164 | 184 | if (yd->jp) |
| 185 | from_codeset = "SHIFT_JIS"; | |
| 186 | else | |
| 15884 | 187 | from_codeset = purple_account_get_string(purple_connection_get_account(gc), "local_charset", "ISO-8859-1"); |
| 7827 | 188 | |
|
35258
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
189 | ret = g_convert_with_fallback(str, -1, "UTF-8", from_codeset, NULL, NULL, NULL, &error); |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
190 | if (!ret) { |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
191 | if (error) { |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
192 | purple_debug_error("yahoo", "Could not convert %s from %s to " |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
193 | "UTF-8: %d - %s\n", str ? str : "(null)", from_codeset, |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
194 | error->code, error->message ? error->message : "(null)"); |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
195 | g_error_free(error); |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
196 | } else { |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
197 | purple_debug_error("yahoo", "Could not convert %s from %s to " |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
198 | "UTF-8: unkown error\n", str ? str : "(null)", |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
199 | from_codeset); |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
200 | } |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
201 | return g_strdup(""); |
|
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
202 | } |
| 7827 | 203 | |
|
35258
956f247148db
More error logging, please.
Mark Doliner <mark@kingant.net>
parents:
35257
diff
changeset
|
204 | return ret; |
| 7827 | 205 | } |
| 206 | ||
|
22259
bc9fcfd10196
disapproval of revision 'db9b3bc9d4427a6a03d1c25aac5215bf0f8e05ec'
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22248
diff
changeset
|
207 | char *yahoo_convert_to_numeric(const char *str) |
|
bc9fcfd10196
disapproval of revision 'db9b3bc9d4427a6a03d1c25aac5215bf0f8e05ec'
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22248
diff
changeset
|
208 | { |
|
22261
e80d3a79f3b8
Since I needed to bring back yahoo_convert_to_numeric, I figured I could at
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22259
diff
changeset
|
209 | GString *gstr = NULL; |
|
22289
a1f40ee48fa8
Fix (hopefully) the last problem in this function. Refs #3295.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22261
diff
changeset
|
210 | const unsigned char *p; |
|
22259
bc9fcfd10196
disapproval of revision 'db9b3bc9d4427a6a03d1c25aac5215bf0f8e05ec'
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22248
diff
changeset
|
211 | |
|
22261
e80d3a79f3b8
Since I needed to bring back yahoo_convert_to_numeric, I figured I could at
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22259
diff
changeset
|
212 | gstr = g_string_sized_new(strlen(str) * 6 + 1); |
|
e80d3a79f3b8
Since I needed to bring back yahoo_convert_to_numeric, I figured I could at
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22259
diff
changeset
|
213 | |
|
22289
a1f40ee48fa8
Fix (hopefully) the last problem in this function. Refs #3295.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22261
diff
changeset
|
214 | for (p = (unsigned char *)str; *p; p++) { |
|
22261
e80d3a79f3b8
Since I needed to bring back yahoo_convert_to_numeric, I figured I could at
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22259
diff
changeset
|
215 | g_string_append_printf(gstr, "&#%u;", *p); |
|
22259
bc9fcfd10196
disapproval of revision 'db9b3bc9d4427a6a03d1c25aac5215bf0f8e05ec'
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22248
diff
changeset
|
216 | } |
|
22261
e80d3a79f3b8
Since I needed to bring back yahoo_convert_to_numeric, I figured I could at
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22259
diff
changeset
|
217 | |
| 28009 | 218 | return g_string_free(gstr, FALSE); |
|
22259
bc9fcfd10196
disapproval of revision 'db9b3bc9d4427a6a03d1c25aac5215bf0f8e05ec'
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22248
diff
changeset
|
219 | } |
|
bc9fcfd10196
disapproval of revision 'db9b3bc9d4427a6a03d1c25aac5215bf0f8e05ec'
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22248
diff
changeset
|
220 | |
| 6513 | 221 | /* |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
222 | * The values in this hash table should probably be lowercase, since that's |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
223 | * what xhtml expects. Also because yahoo_codes_to_html() does |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
224 | * case-sensitive comparisons. |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
225 | * |
| 6513 | 226 | * I found these on some website but i don't know that they actually |
|
8735
01248ea222d3
[gaim-migrate @ 9490]
Jonathan Champ <royanee@users.sourceforge.net>
parents:
8533
diff
changeset
|
227 | * work (or are supposed to work). I didn't implement them yet. |
|
27335
06a805d4e690
Strip trailing whitespace and comment #endif marcos that close #ifdef macros
Mark Doliner <markdoliner@pidgin.im>
parents:
24181
diff
changeset
|
228 | * |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
229 | * [0;30m ---black |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
230 | * [1;37m ---white |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
231 | * [0;37m ---tan |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
232 | * [0;38m ---light black |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
233 | * [1;39m ---dark blue |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
234 | * [0;32m ---green |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
235 | * [0;33m ---yellow |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
236 | * [0;35m ---pink |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
237 | * [1;35m ---purple |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
238 | * [1;30m ---light blue |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
239 | * [0;31m ---red |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
240 | * [0;34m ---blue |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
241 | * [0;36m ---aqua |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
242 | * (shift+comma)lyellow(shift+period) ---light yellow |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
243 | * (shift+comma)lgreen(shift+period) ---light green |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
244 | * [2;30m <--white out |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
245 | */ |
| 6513 | 246 | |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
247 | static GHashTable *esc_codes_ht = NULL; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
248 | static GHashTable *tags_ht = NULL; |
| 6513 | 249 | |
| 250 | void yahoo_init_colorht() | |
| 251 | { | |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
252 | if (esc_codes_ht != NULL) |
|
27683
9ee099fab4ee
Don't double-free the color hash table when deinitializing both prpl-yahoo
Mark Doliner <markdoliner@pidgin.im>
parents:
27555
diff
changeset
|
253 | /* Hash table has already been initialized */ |
|
9ee099fab4ee
Don't double-free the color hash table when deinitializing both prpl-yahoo
Mark Doliner <markdoliner@pidgin.im>
parents:
27555
diff
changeset
|
254 | return; |
|
9ee099fab4ee
Don't double-free the color hash table when deinitializing both prpl-yahoo
Mark Doliner <markdoliner@pidgin.im>
parents:
27555
diff
changeset
|
255 | |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
256 | /* Key is the escape code string. Value is the HTML that should be |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
257 | * inserted in place of the escape code. */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
258 | esc_codes_ht = g_hash_table_new(g_str_hash, g_str_equal); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
259 | |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
260 | /* Key is the name of the HTML tag, for example "font" or "/font" |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
261 | * value is the HTML that should be inserted in place of the old tag */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
262 | tags_ht = g_hash_table_new(g_str_hash, g_str_equal); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
263 | |
|
27683
9ee099fab4ee
Don't double-free the color hash table when deinitializing both prpl-yahoo
Mark Doliner <markdoliner@pidgin.im>
parents:
27555
diff
changeset
|
264 | /* the numbers in comments are what gyach uses, but i think they're incorrect */ |
|
28045
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
265 | #ifdef USE_CSS_FORMATTING |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
266 | g_hash_table_insert(esc_codes_ht, "30", "<span style=\"color: #000000\">"); /* black */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
267 | g_hash_table_insert(esc_codes_ht, "31", "<span style=\"color: #0000FF\">"); /* blue */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
268 | g_hash_table_insert(esc_codes_ht, "32", "<span style=\"color: #008080\">"); /* cyan */ /* 00b2b2 */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
269 | g_hash_table_insert(esc_codes_ht, "33", "<span style=\"color: #808080\">"); /* gray */ /* 808080 */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
270 | g_hash_table_insert(esc_codes_ht, "34", "<span style=\"color: #008000\">"); /* green */ /* 00c200 */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
271 | g_hash_table_insert(esc_codes_ht, "35", "<span style=\"color: #FF0080\">"); /* pink */ /* ffafaf */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
272 | g_hash_table_insert(esc_codes_ht, "36", "<span style=\"color: #800080\">"); /* purple */ /* b200b2 */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
273 | g_hash_table_insert(esc_codes_ht, "37", "<span style=\"color: #FF8000\">"); /* orange */ /* ffff00 */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
274 | g_hash_table_insert(esc_codes_ht, "38", "<span style=\"color: #FF0000\">"); /* red */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
275 | g_hash_table_insert(esc_codes_ht, "39", "<span style=\"color: #808000\">"); /* olive */ /* 546b50 */ |
|
28045
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
276 | #else |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
277 | g_hash_table_insert(esc_codes_ht, "30", "<font color=\"#000000\">"); /* black */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
278 | g_hash_table_insert(esc_codes_ht, "31", "<font color=\"#0000FF\">"); /* blue */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
279 | g_hash_table_insert(esc_codes_ht, "32", "<font color=\"#008080\">"); /* cyan */ /* 00b2b2 */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
280 | g_hash_table_insert(esc_codes_ht, "33", "<font color=\"#808080\">"); /* gray */ /* 808080 */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
281 | g_hash_table_insert(esc_codes_ht, "34", "<font color=\"#008000\">"); /* green */ /* 00c200 */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
282 | g_hash_table_insert(esc_codes_ht, "35", "<font color=\"#FF0080\">"); /* pink */ /* ffafaf */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
283 | g_hash_table_insert(esc_codes_ht, "36", "<font color=\"#800080\">"); /* purple */ /* b200b2 */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
284 | g_hash_table_insert(esc_codes_ht, "37", "<font color=\"#FF8000\">"); /* orange */ /* ffff00 */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
285 | g_hash_table_insert(esc_codes_ht, "38", "<font color=\"#FF0000\">"); /* red */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
286 | g_hash_table_insert(esc_codes_ht, "39", "<font color=\"#808000\">"); /* olive */ /* 546b50 */ |
|
28045
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
287 | #endif /* !USE_CSS_FORMATTING */ |
| 6513 | 288 | |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
289 | g_hash_table_insert(esc_codes_ht, "1", "<b>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
290 | g_hash_table_insert(esc_codes_ht, "x1", "</b>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
291 | g_hash_table_insert(esc_codes_ht, "2", "<i>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
292 | g_hash_table_insert(esc_codes_ht, "x2", "</i>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
293 | g_hash_table_insert(esc_codes_ht, "4", "<u>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
294 | g_hash_table_insert(esc_codes_ht, "x4", "</u>"); |
| 6513 | 295 | |
| 6629 | 296 | /* these just tell us the text they surround is supposed |
| 15884 | 297 | * to be a link. purple figures that out on its own so we |
| 6629 | 298 | * just ignore it. |
| 299 | */ | |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
300 | g_hash_table_insert(esc_codes_ht, "l", ""); /* link start */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
301 | g_hash_table_insert(esc_codes_ht, "xl", ""); /* link end */ |
| 6629 | 302 | |
|
28045
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
303 | #ifdef USE_CSS_FORMATTING |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
304 | g_hash_table_insert(tags_ht, "black", "<span style=\"color: #000000\">"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
305 | g_hash_table_insert(tags_ht, "blue", "<span style=\"color: #0000FF\">"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
306 | g_hash_table_insert(tags_ht, "cyan", "<span style=\"color: #008284\">"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
307 | g_hash_table_insert(tags_ht, "gray", "<span style=\"color: #848284\">"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
308 | g_hash_table_insert(tags_ht, "green", "<span style=\"color: #008200\">"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
309 | g_hash_table_insert(tags_ht, "pink", "<span style=\"color: #FF0084\">"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
310 | g_hash_table_insert(tags_ht, "purple", "<span style=\"color: #840084\">"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
311 | g_hash_table_insert(tags_ht, "orange", "<span style=\"color: #FF8000\">"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
312 | g_hash_table_insert(tags_ht, "red", "<span style=\"color: #FF0000\">"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
313 | g_hash_table_insert(tags_ht, "yellow", "<span style=\"color: #848200\">"); |
| 6513 | 314 | |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
315 | g_hash_table_insert(tags_ht, "/black", "</span>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
316 | g_hash_table_insert(tags_ht, "/blue", "</span>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
317 | g_hash_table_insert(tags_ht, "/cyan", "</span>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
318 | g_hash_table_insert(tags_ht, "/gray", "</span>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
319 | g_hash_table_insert(tags_ht, "/green", "</span>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
320 | g_hash_table_insert(tags_ht, "/pink", "</span>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
321 | g_hash_table_insert(tags_ht, "/purple", "</span>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
322 | g_hash_table_insert(tags_ht, "/orange", "</span>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
323 | g_hash_table_insert(tags_ht, "/red", "</span>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
324 | g_hash_table_insert(tags_ht, "/yellow", "</span>"); |
|
28045
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
325 | #else |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
326 | g_hash_table_insert(tags_ht, "black", "<font color=\"#000000\">"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
327 | g_hash_table_insert(tags_ht, "blue", "<font color=\"#0000FF\">"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
328 | g_hash_table_insert(tags_ht, "cyan", "<font color=\"#008284\">"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
329 | g_hash_table_insert(tags_ht, "gray", "<font color=\"#848284\">"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
330 | g_hash_table_insert(tags_ht, "green", "<font color=\"#008200\">"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
331 | g_hash_table_insert(tags_ht, "pink", "<font color=\"#FF0084\">"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
332 | g_hash_table_insert(tags_ht, "purple", "<font color=\"#840084\">"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
333 | g_hash_table_insert(tags_ht, "orange", "<font color=\"#FF8000\">"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
334 | g_hash_table_insert(tags_ht, "red", "<font color=\"#FF0000\">"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
335 | g_hash_table_insert(tags_ht, "yellow", "<font color=\"#848200\">"); |
|
28045
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
336 | |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
337 | g_hash_table_insert(tags_ht, "/black", "</font>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
338 | g_hash_table_insert(tags_ht, "/blue", "</font>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
339 | g_hash_table_insert(tags_ht, "/cyan", "</font>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
340 | g_hash_table_insert(tags_ht, "/gray", "</font>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
341 | g_hash_table_insert(tags_ht, "/green", "</font>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
342 | g_hash_table_insert(tags_ht, "/pink", "</font>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
343 | g_hash_table_insert(tags_ht, "/purple", "</font>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
344 | g_hash_table_insert(tags_ht, "/orange", "</font>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
345 | g_hash_table_insert(tags_ht, "/red", "</font>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
346 | g_hash_table_insert(tags_ht, "/yellow", "</font>"); |
|
28045
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
347 | #endif /* !USE_CSS_FORMATTING */ |
| 6513 | 348 | |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
349 | /* We don't support these tags, so discard them */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
350 | g_hash_table_insert(tags_ht, "alt", ""); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
351 | g_hash_table_insert(tags_ht, "fade", ""); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
352 | g_hash_table_insert(tags_ht, "snd", ""); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
353 | g_hash_table_insert(tags_ht, "/alt", ""); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
354 | g_hash_table_insert(tags_ht, "/fade", ""); |
| 8375 | 355 | |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
356 | /* Official clients don't seem to send b, i or u tags. They use |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
357 | * the escape codes listed above. Official clients definitely send |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
358 | * font tags, though. I wonder if we can remove the opening and |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
359 | * closing b, i and u tags from here? */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
360 | g_hash_table_insert(tags_ht, "b", "<b>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
361 | g_hash_table_insert(tags_ht, "i", "<i>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
362 | g_hash_table_insert(tags_ht, "u", "<u>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
363 | g_hash_table_insert(tags_ht, "font", "<font>"); |
| 8375 | 364 | |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
365 | g_hash_table_insert(tags_ht, "/b", "</b>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
366 | g_hash_table_insert(tags_ht, "/i", "</i>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
367 | g_hash_table_insert(tags_ht, "/u", "</u>"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
368 | g_hash_table_insert(tags_ht, "/font", "</font>"); |
| 6513 | 369 | } |
| 370 | ||
| 371 | void yahoo_dest_colorht() | |
| 372 | { | |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
373 | if (esc_codes_ht == NULL) |
|
27683
9ee099fab4ee
Don't double-free the color hash table when deinitializing both prpl-yahoo
Mark Doliner <markdoliner@pidgin.im>
parents:
27555
diff
changeset
|
374 | /* Hash table has already been destroyed */ |
|
9ee099fab4ee
Don't double-free the color hash table when deinitializing both prpl-yahoo
Mark Doliner <markdoliner@pidgin.im>
parents:
27555
diff
changeset
|
375 | return; |
|
9ee099fab4ee
Don't double-free the color hash table when deinitializing both prpl-yahoo
Mark Doliner <markdoliner@pidgin.im>
parents:
27555
diff
changeset
|
376 | |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
377 | g_hash_table_destroy(esc_codes_ht); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
378 | esc_codes_ht = NULL; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
379 | g_hash_table_destroy(tags_ht); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
380 | tags_ht = NULL; |
| 6513 | 381 | } |
| 382 | ||
|
28045
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
383 | #ifndef USE_CSS_FORMATTING |
| 6629 | 384 | static int point_to_html(int x) |
| 385 | { | |
| 386 | if (x < 9) | |
| 387 | return 1; | |
| 388 | if (x < 11) | |
| 389 | return 2; | |
| 390 | if (x < 13) | |
| 391 | return 3; | |
| 392 | if (x < 17) | |
| 393 | return 4; | |
| 394 | if (x < 25) | |
| 395 | return 5; | |
| 396 | if (x < 35) | |
| 397 | return 6; | |
| 398 | return 7; | |
| 399 | } | |
|
28045
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
400 | #endif /* !USE_CSS_FORMATTING */ |
|
10380
8608e553808f
[gaim-migrate @ 11605]
Evan Schoenberg <evands@pidgin.im>
parents:
10023
diff
changeset
|
401 | |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
402 | static void append_attrs_datalist_foreach_cb(GQuark key_id, gpointer data, gpointer user_data) |
| 6629 | 403 | { |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
404 | const char *key; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
405 | const char *value; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
406 | xmlnode *cur; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
407 | |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
408 | key = g_quark_to_string(key_id); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
409 | value = data; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
410 | cur = user_data; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
411 | |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
412 | xmlnode_set_attrib(cur, key, value); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
413 | } |
| 6629 | 414 | |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
415 | /** |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
416 | * @param cur A pointer to the position in the XML tree that we're |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
417 | * currently building. This will be modified when opening a tag |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
418 | * or closing an existing tag. |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
419 | */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
420 | 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) |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
421 | { |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
422 | if (is_closing_tag) { |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
423 | xmlnode *tmp; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
424 | GSList *dangling_tags = NULL; |
|
28045
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
425 | |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
426 | /* Move up the DOM until we find the opening tag */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
427 | for (tmp = *cur; tmp != NULL; tmp = xmlnode_get_parent(tmp)) { |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
428 | /* Add one to tag_name when doing this comparison because it starts with a / */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
429 | if (g_str_equal(tmp->name, tag_name + 1)) |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
430 | /* Found */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
431 | break; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
432 | dangling_tags = g_slist_prepend(dangling_tags, tmp); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
433 | } |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
434 | if (tmp == NULL) { |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
435 | /* This is a closing tag with no opening tag. Useless. */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
436 | purple_debug_error("yahoo", "Ignoring unmatched tag %s", tag); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
437 | g_slist_free(dangling_tags); |
| 6629 | 438 | return; |
| 439 | } | |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
440 | |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
441 | /* Move our current position up, now that we've closed a tag */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
442 | *cur = xmlnode_get_parent(tmp); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
443 | |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
444 | /* Re-open any tags that were nested below the tag we just closed */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
445 | while (dangling_tags != NULL) { |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
446 | tmp = dangling_tags->data; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
447 | dangling_tags = g_slist_delete_link(dangling_tags, dangling_tags); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
448 | |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
449 | /* Create a copy of this tag+attributes (but not child tags or |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
450 | * data) at our new location */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
451 | *cur = xmlnode_new_child(*cur, tmp->name); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
452 | for (tmp = tmp->child; tmp != NULL; tmp = tmp->next) |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
453 | if (tmp->type == XMLNODE_TYPE_ATTRIB) |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
454 | xmlnode_set_attrib_full(*cur, tmp->name, |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
455 | tmp->xmlns, tmp->prefix, tmp->data); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
456 | } |
| 6629 | 457 | } else { |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
458 | const char *start; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
459 | const char *end; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
460 | GData *attributes; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
461 | char *fontsize = NULL; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
462 | |
|
35991
e6937e52930b
Fix some CWE-252 coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35258
diff
changeset
|
463 | if (!purple_markup_find_tag(tag_name, tag, &start, &end, &attributes)) |
|
e6937e52930b
Fix some CWE-252 coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35258
diff
changeset
|
464 | g_return_if_reached(); |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
465 | *cur = xmlnode_new_child(*cur, tag_name); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
466 | |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
467 | if (is_font_tag) { |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
468 | /* Special case for the font size attribute */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
469 | fontsize = g_strdup(g_datalist_get_data(&attributes, "size")); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
470 | if (fontsize != NULL) |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
471 | g_datalist_remove_data(&attributes, "size"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
472 | } |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
473 | |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
474 | /* Add all font tag attributes */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
475 | g_datalist_foreach(&attributes, append_attrs_datalist_foreach_cb, *cur); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
476 | g_datalist_clear(&attributes); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
477 | |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
478 | if (fontsize != NULL) { |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
479 | #ifdef USE_CSS_FORMATTING |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
480 | /* |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
481 | * The Yahoo font size value is given in pt, even though the HTML |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
482 | * standard for <font size="x"> treats the size as a number on a |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
483 | * scale between 1 and 7. So we insert the font size as a CSS |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
484 | * style on a span tag. |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
485 | */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
486 | gchar *tmp = g_strdup_printf("font-size: %spt", fontsize); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
487 | *cur = xmlnode_new_child(*cur, "span"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
488 | xmlnode_set_attrib(*cur, "style", tmp); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
489 | g_free(tmp); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
490 | #else |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
491 | /* |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
492 | * The Yahoo font size value is given in pt, even though the HTML |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
493 | * standard for <font size="x"> treats the size as a number on a |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
494 | * scale between 1 and 7. So we convert it to an appropriate |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
495 | * value. This loses precision, which is why CSS formatting is |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
496 | * preferred. The "absz" attribute remains here for backward |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
497 | * compatibility with UIs that might use it, but it is totally |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
498 | * not standard at all. |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
499 | */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
500 | int size, htmlsize; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
501 | gchar tmp[11]; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
502 | size = strtol(fontsize, NULL, 10); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
503 | htmlsize = point_to_html(size); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
504 | sprintf(tmp, "%u", htmlsize); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
505 | xmlnode_set_attrib(*cur, "size", tmp); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
506 | xmlnode_set_attrib(*cur, "absz", fontsize); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
507 | #endif /* !USE_CSS_FORMATTING */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
508 | g_free(fontsize); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
509 | } |
| 6629 | 510 | } |
| 511 | } | |
| 512 | ||
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
513 | /** |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
514 | * Similar to purple_markup_get_tag_name(), but works with closing tags. |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
515 | * |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
516 | * @return The lowercase name of the tag. If this is a closing tag then |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
517 | * this value starts with a forward slash. The caller must free |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
518 | * this string with g_free. |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
519 | */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
520 | static gchar *yahoo_markup_get_tag_name(const char *tag, gboolean *is_closing_tag) |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
521 | { |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
522 | size_t len; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
523 | |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
524 | *is_closing_tag = (tag[1] == '/'); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
525 | if (*is_closing_tag) |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
526 | len = strcspn(tag + 1, "> "); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
527 | else |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
528 | len = strcspn(tag + 1, "> /"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
529 | |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
530 | return g_utf8_strdown(tag + 1, len); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
531 | } |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
532 | |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
533 | /* |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
534 | * Yahoo! messages generally aren't well-formed. Their markup is |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
535 | * more of a flow from start to finish rather than a hierarchy from |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
536 | * outer to inner. They tend to open tags and close them only when |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
537 | * necessary. |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
538 | * |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
539 | * Example: <font size="8">size 8 <font size="16">size 16 <font size="8">size 8 again |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
540 | * |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
541 | * But we want to send well-formed HTML to the core, so we step through |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
542 | * the input string and build an xmlnode tree containing sanitized HTML. |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
543 | */ |
| 6629 | 544 | char *yahoo_codes_to_html(const char *x) |
| 6513 | 545 | { |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
546 | size_t x_len; |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
547 | xmlnode *html, *cur; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
548 | GString *cdata = g_string_new(NULL); |
|
36256
a437550a9308
Remove -Wno-sign-compare and backport fixes from default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35991
diff
changeset
|
549 | guint i, j; |
|
28041
84fb2d6540ea
Of course I got it backwards
Mark Doliner <markdoliner@pidgin.im>
parents:
28040
diff
changeset
|
550 | gboolean no_more_gt_brackets = FALSE; |
|
28037
ec211dfd0937
Make match a const char *, and remove two unnecessary casts
Mark Doliner <markdoliner@pidgin.im>
parents:
28036
diff
changeset
|
551 | const char *match; |
|
28307
400743761337
Oh, I guess we should escape this when printing to the debug window.
Mark Doliner <markdoliner@pidgin.im>
parents:
28298
diff
changeset
|
552 | gchar *xmlstr1, *xmlstr2, *esc; |
| 6513 | 553 | |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
554 | x_len = strlen(x); |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
555 | html = xmlnode_new("html"); |
| 6513 | 556 | |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
557 | cur = html; |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
558 | for (i = 0; i < x_len; i++) { |
| 6513 | 559 | if ((x[i] == 0x1b) && (x[i+1] == '[')) { |
|
28040
476db09dcc7a
Better variable name?
Mark Doliner <markdoliner@pidgin.im>
parents:
28038
diff
changeset
|
560 | /* This escape sequence signifies the beginning of some |
|
476db09dcc7a
Better variable name?
Mark Doliner <markdoliner@pidgin.im>
parents:
28038
diff
changeset
|
561 | * text formatting code */ |
| 6513 | 562 | j = i + 1; |
| 563 | ||
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
564 | while (j++ < x_len) { |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
565 | gchar *code; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
566 | |
| 6513 | 567 | if (x[j] != 'm') |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
568 | /* Keep looking for the end of this sequence */ |
| 6513 | 569 | continue; |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
570 | |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
571 | /* We've reached the end of the formatting sequence, yay */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
572 | |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
573 | /* Append any character data that belongs in the current node */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
574 | if (cdata->len > 0) { |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
575 | xmlnode_insert_data(cur, cdata->str, cdata->len); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
576 | g_string_truncate(cdata, 0); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
577 | } |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
578 | |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
579 | code = g_strndup(x + i + 2, j - i - 2); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
580 | if (code[0] == '#') { |
|
28045
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
581 | #ifdef USE_CSS_FORMATTING |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
582 | gchar *tmp = g_strdup_printf("color: %s", code); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
583 | cur = xmlnode_new_child(cur, "span"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
584 | xmlnode_set_attrib(cur, "style", tmp); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
585 | g_free(tmp); |
|
28045
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
586 | #else |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
587 | cur = xmlnode_new_child(cur, "font"); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
588 | xmlnode_set_attrib(cur, "color", code); |
|
28045
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
589 | #endif /* !USE_CSS_FORMATTING */ |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
590 | |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
591 | } else if ((match = g_hash_table_lookup(esc_codes_ht, code))) { |
|
28240
2022259114fc
Fix a possible crash when receiving URLs in yahoo. It doesn't crash for me
Mark Doliner <markdoliner@pidgin.im>
parents:
28107
diff
changeset
|
592 | /* Some tags are in the hash table only because we |
|
2022259114fc
Fix a possible crash when receiving URLs in yahoo. It doesn't crash for me
Mark Doliner <markdoliner@pidgin.im>
parents:
28107
diff
changeset
|
593 | * want to ignore them */ |
|
2022259114fc
Fix a possible crash when receiving URLs in yahoo. It doesn't crash for me
Mark Doliner <markdoliner@pidgin.im>
parents:
28107
diff
changeset
|
594 | if (match[0] != '\0') { |
|
2022259114fc
Fix a possible crash when receiving URLs in yahoo. It doesn't crash for me
Mark Doliner <markdoliner@pidgin.im>
parents:
28107
diff
changeset
|
595 | gboolean is_closing_tag; |
|
2022259114fc
Fix a possible crash when receiving URLs in yahoo. It doesn't crash for me
Mark Doliner <markdoliner@pidgin.im>
parents:
28107
diff
changeset
|
596 | gchar *tag_name; |
|
2022259114fc
Fix a possible crash when receiving URLs in yahoo. It doesn't crash for me
Mark Doliner <markdoliner@pidgin.im>
parents:
28107
diff
changeset
|
597 | tag_name = yahoo_markup_get_tag_name(match, &is_closing_tag); |
|
2022259114fc
Fix a possible crash when receiving URLs in yahoo. It doesn't crash for me
Mark Doliner <markdoliner@pidgin.im>
parents:
28107
diff
changeset
|
598 | yahoo_codes_to_html_add_tag(&cur, match, is_closing_tag, tag_name, FALSE); |
|
2022259114fc
Fix a possible crash when receiving URLs in yahoo. It doesn't crash for me
Mark Doliner <markdoliner@pidgin.im>
parents:
28107
diff
changeset
|
599 | g_free(tag_name); |
|
2022259114fc
Fix a possible crash when receiving URLs in yahoo. It doesn't crash for me
Mark Doliner <markdoliner@pidgin.im>
parents:
28107
diff
changeset
|
600 | } |
| 6513 | 601 | |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
602 | } else { |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
603 | purple_debug_error("yahoo", |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
604 | "Ignoring unknown ansi code 'ESC[%sm'.\n", code); |
| 6513 | 605 | } |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
606 | |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
607 | g_free(code); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
608 | i = j; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
609 | break; |
| 6513 | 610 | } |
| 611 | ||
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
612 | } else if (x[i] == '<' && !no_more_gt_brackets) { |
|
28040
476db09dcc7a
Better variable name?
Mark Doliner <markdoliner@pidgin.im>
parents:
28038
diff
changeset
|
613 | /* The start of an HTML tag */ |
| 6629 | 614 | j = i; |
| 6513 | 615 | |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
616 | while (j++ < x_len) { |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
617 | gchar *tag; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
618 | gboolean is_closing_tag; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
619 | gchar *tag_name; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
620 | |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
621 | if (x[j] != '>') { |
|
28106
686088ceb2d1
Take care of a special case where we would incorrectly parse incoming IMs
Mark Doliner <markdoliner@pidgin.im>
parents:
28103
diff
changeset
|
622 | if (x[j] == '"') { |
|
686088ceb2d1
Take care of a special case where we would incorrectly parse incoming IMs
Mark Doliner <markdoliner@pidgin.im>
parents:
28103
diff
changeset
|
623 | /* We're inside a quoted attribute value. Skip to the end */ |
|
686088ceb2d1
Take care of a special case where we would incorrectly parse incoming IMs
Mark Doliner <markdoliner@pidgin.im>
parents:
28103
diff
changeset
|
624 | j++; |
|
686088ceb2d1
Take care of a special case where we would incorrectly parse incoming IMs
Mark Doliner <markdoliner@pidgin.im>
parents:
28103
diff
changeset
|
625 | while (j != x_len && x[j] != '"') |
|
686088ceb2d1
Take care of a special case where we would incorrectly parse incoming IMs
Mark Doliner <markdoliner@pidgin.im>
parents:
28103
diff
changeset
|
626 | j++; |
|
686088ceb2d1
Take care of a special case where we would incorrectly parse incoming IMs
Mark Doliner <markdoliner@pidgin.im>
parents:
28103
diff
changeset
|
627 | } else if (x[j] == '\'') { |
|
686088ceb2d1
Take care of a special case where we would incorrectly parse incoming IMs
Mark Doliner <markdoliner@pidgin.im>
parents:
28103
diff
changeset
|
628 | /* We're inside a quoted attribute value. Skip to the end */ |
|
686088ceb2d1
Take care of a special case where we would incorrectly parse incoming IMs
Mark Doliner <markdoliner@pidgin.im>
parents:
28103
diff
changeset
|
629 | j++; |
|
686088ceb2d1
Take care of a special case where we would incorrectly parse incoming IMs
Mark Doliner <markdoliner@pidgin.im>
parents:
28103
diff
changeset
|
630 | while (j != x_len && x[j] != '\'') |
|
686088ceb2d1
Take care of a special case where we would incorrectly parse incoming IMs
Mark Doliner <markdoliner@pidgin.im>
parents:
28103
diff
changeset
|
631 | j++; |
|
686088ceb2d1
Take care of a special case where we would incorrectly parse incoming IMs
Mark Doliner <markdoliner@pidgin.im>
parents:
28103
diff
changeset
|
632 | } |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
633 | if (j != x_len) |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
634 | /* Keep looking for the end of this tag */ |
| 6513 | 635 | continue; |
| 636 | ||
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
637 | /* This < has no corresponding > */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
638 | g_string_append_c(cdata, x[i]); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
639 | no_more_gt_brackets = TRUE; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
640 | break; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
641 | } |
| 6513 | 642 | |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
643 | tag = g_strndup(x + i, j - i + 1); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
644 | tag_name = yahoo_markup_get_tag_name(tag, &is_closing_tag); |
| 6513 | 645 | |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
646 | match = g_hash_table_lookup(tags_ht, tag_name); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
647 | if (match == NULL) { |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
648 | /* Unknown tag. The user probably typed a less-than sign */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
649 | g_string_append_c(cdata, x[i]); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
650 | g_free(tag); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
651 | g_free(tag_name); |
| 6513 | 652 | break; |
| 653 | } | |
| 654 | ||
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
655 | /* Some tags are in the hash table only because we |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
656 | * want to ignore them */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
657 | if (match[0] != '\0') { |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
658 | /* Append any character data that belongs in the current node */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
659 | if (cdata->len > 0) { |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
660 | xmlnode_insert_data(cur, cdata->str, cdata->len); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
661 | g_string_truncate(cdata, 0); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
662 | } |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
663 | if (g_str_equal(tag_name, "font")) |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
664 | /* Font tags are a special case. We don't |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
665 | * necessarily want to replace the whole thing-- |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
666 | * we just want to fix the size attribute. */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
667 | yahoo_codes_to_html_add_tag(&cur, tag, is_closing_tag, tag_name, TRUE); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
668 | else |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
669 | yahoo_codes_to_html_add_tag(&cur, match, is_closing_tag, tag_name, FALSE); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
670 | } |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
671 | |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
672 | i = j; |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
673 | g_free(tag); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
674 | g_free(tag_name); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
675 | break; |
| 6513 | 676 | } |
| 677 | ||
| 678 | } else { | |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
679 | g_string_append_c(cdata, x[i]); |
| 6513 | 680 | } |
| 681 | } | |
| 682 | ||
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
683 | /* Append any remaining character data */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
684 | if (cdata->len > 0) |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
685 | xmlnode_insert_data(cur, cdata->str, cdata->len); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
686 | g_string_free(cdata, TRUE); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
687 | |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
688 | /* Serialize our HTML */ |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
689 | xmlstr1 = xmlnode_to_str(html, NULL); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
690 | xmlnode_free(html); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
691 | |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
692 | /* Strip off the outter HTML node */ |
|
28100
53d948810829
Make this enum follow our naming conventions a little better
Mark Doliner <markdoliner@pidgin.im>
parents:
28093
diff
changeset
|
693 | /* This probably isn't necessary, especially if we made the outter HTML |
|
53d948810829
Make this enum follow our naming conventions a little better
Mark Doliner <markdoliner@pidgin.im>
parents:
28093
diff
changeset
|
694 | * node an empty span. But the HTML is simpler this way. */ |
|
28973
be6a842df4b9
Make yahoo_codes_to_html not crash when given an empty string, or a string
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28786
diff
changeset
|
695 | if (!purple_strequal(xmlstr1, "<html/>")) |
|
be6a842df4b9
Make yahoo_codes_to_html not crash when given an empty string, or a string
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28786
diff
changeset
|
696 | xmlstr2 = g_strndup(xmlstr1 + 6, strlen(xmlstr1) - 13); |
|
be6a842df4b9
Make yahoo_codes_to_html not crash when given an empty string, or a string
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28786
diff
changeset
|
697 | else |
|
be6a842df4b9
Make yahoo_codes_to_html not crash when given an empty string, or a string
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
28786
diff
changeset
|
698 | xmlstr2 = g_strdup(""); |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
699 | g_free(xmlstr1); |
|
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
700 | |
|
28307
400743761337
Oh, I guess we should escape this when printing to the debug window.
Mark Doliner <markdoliner@pidgin.im>
parents:
28298
diff
changeset
|
701 | esc = g_strescape(x, NULL); |
|
400743761337
Oh, I guess we should escape this when printing to the debug window.
Mark Doliner <markdoliner@pidgin.im>
parents:
28298
diff
changeset
|
702 | purple_debug_misc("yahoo", "yahoo_codes_to_html(%s)=%s\n", esc, xmlstr2); |
|
400743761337
Oh, I guess we should escape this when printing to the debug window.
Mark Doliner <markdoliner@pidgin.im>
parents:
28298
diff
changeset
|
703 | g_free(esc); |
|
400743761337
Oh, I guess we should escape this when printing to the debug window.
Mark Doliner <markdoliner@pidgin.im>
parents:
28298
diff
changeset
|
704 | |
|
28093
e21ce2c8991d
Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <markdoliner@pidgin.im>
parents:
28051
diff
changeset
|
705 | return xmlstr2; |
| 6513 | 706 | } |
| 6629 | 707 | |
| 708 | /* borrowed from gtkimhtml */ | |
| 709 | #define MAX_FONT_SIZE 7 | |
|
10899
87d9aec5b72d
[gaim-migrate @ 12619]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
710 | #define POINT_SIZE(x) (_point_sizes [MIN ((x > 0 ? x : 1), MAX_FONT_SIZE) - 1]) |
|
14904
cab89db4854c
[gaim-migrate @ 17611]
Henning Norén <henning.noren@gmail.com>
parents:
14347
diff
changeset
|
711 | static const gint _point_sizes [] = { 8, 10, 12, 14, 20, 30, 40 }; |
| 6629 | 712 | |
|
28292
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
713 | typedef struct |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
714 | { |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
715 | gboolean bold; |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
716 | gboolean italic; |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
717 | gboolean underline; |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
718 | gboolean in_link; |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
719 | int font_size; |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
720 | char *font_face; |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
721 | char *font_color; |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
722 | } CurrentMsgState; |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
723 | |
|
28101
b82c1e37c9a0
This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <markdoliner@pidgin.im>
parents:
28100
diff
changeset
|
724 | static void yahoo_htc_list_cleanup(GSList *l) |
| 6629 | 725 | { |
|
28101
b82c1e37c9a0
This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <markdoliner@pidgin.im>
parents:
28100
diff
changeset
|
726 | while (l != NULL) { |
|
b82c1e37c9a0
This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <markdoliner@pidgin.im>
parents:
28100
diff
changeset
|
727 | g_free(l->data); |
|
b82c1e37c9a0
This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <markdoliner@pidgin.im>
parents:
28100
diff
changeset
|
728 | l = g_slist_delete_link(l, l); |
|
b82c1e37c9a0
This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <markdoliner@pidgin.im>
parents:
28100
diff
changeset
|
729 | } |
| 6629 | 730 | } |
| 731 | ||
|
28309
656e6e3170f0
This function no longer needs these two parameters
Mark Doliner <markdoliner@pidgin.im>
parents:
28308
diff
changeset
|
732 | static void parse_font_tag(GString *dest, const char *tag_name, const char *tag, |
|
656e6e3170f0
This function no longer needs these two parameters
Mark Doliner <markdoliner@pidgin.im>
parents:
28308
diff
changeset
|
733 | GSList **colors, GSList **tags) |
| 6629 | 734 | { |
|
28293
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
735 | const char *start; |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
736 | const char *end; |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
737 | GData *attributes; |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
738 | const char *attribute; |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
739 | gboolean needendtag; |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
740 | GString *tmp; |
| 6629 | 741 | |
|
35991
e6937e52930b
Fix some CWE-252 coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35258
diff
changeset
|
742 | if (!purple_markup_find_tag(tag_name, tag, &start, &end, &attributes)) |
|
e6937e52930b
Fix some CWE-252 coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35258
diff
changeset
|
743 | g_return_if_reached(); |
| 6629 | 744 | |
|
28298
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
745 | needendtag = FALSE; |
|
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
746 | tmp = g_string_new(NULL); |
|
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
747 | |
|
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
748 | attribute = g_datalist_get_data(&attributes, "color"); |
|
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
749 | if (attribute != NULL) { |
|
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
750 | g_string_append(tmp, *colors ? (*colors)->data : "\033[#000000m"); |
|
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
751 | g_string_append_printf(dest, "\033[%sm", attribute); |
|
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
752 | *colors = g_slist_prepend(*colors, |
|
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
753 | g_strdup_printf("\033[%sm", attribute)); |
|
28312
2624c0abf3ef
Fix a bug in our outgoing yahoo message formatting where messages
Mark Doliner <markdoliner@pidgin.im>
parents:
28309
diff
changeset
|
754 | } else { |
|
2624c0abf3ef
Fix a bug in our outgoing yahoo message formatting where messages
Mark Doliner <markdoliner@pidgin.im>
parents:
28309
diff
changeset
|
755 | /* We need to add a value to the colors stack even if we're not |
|
2624c0abf3ef
Fix a bug in our outgoing yahoo message formatting where messages
Mark Doliner <markdoliner@pidgin.im>
parents:
28309
diff
changeset
|
756 | * setting a color because we ALWAYS pop exactly 1 element from |
|
2624c0abf3ef
Fix a bug in our outgoing yahoo message formatting where messages
Mark Doliner <markdoliner@pidgin.im>
parents:
28309
diff
changeset
|
757 | * this stack for every </font> tag. If we don't add anything |
|
2624c0abf3ef
Fix a bug in our outgoing yahoo message formatting where messages
Mark Doliner <markdoliner@pidgin.im>
parents:
28309
diff
changeset
|
758 | * then we'll pop something that we shouldn't when we hit this |
|
2624c0abf3ef
Fix a bug in our outgoing yahoo message formatting where messages
Mark Doliner <markdoliner@pidgin.im>
parents:
28309
diff
changeset
|
759 | * corresponding </font>. */ |
|
2624c0abf3ef
Fix a bug in our outgoing yahoo message formatting where messages
Mark Doliner <markdoliner@pidgin.im>
parents:
28309
diff
changeset
|
760 | *colors = g_slist_prepend(*colors, |
|
2624c0abf3ef
Fix a bug in our outgoing yahoo message formatting where messages
Mark Doliner <markdoliner@pidgin.im>
parents:
28309
diff
changeset
|
761 | *colors ? g_strdup((*colors)->data) : g_strdup("\033[#000000m")); |
|
28298
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
762 | } |
|
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
763 | |
|
28293
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
764 | attribute = g_datalist_get_data(&attributes, "face"); |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
765 | if (attribute != NULL) { |
|
28298
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
766 | needendtag = TRUE; |
|
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
767 | g_string_append(dest, "<font "); |
|
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
768 | g_string_append_printf(dest, "face=\"%s\" ", attribute); |
|
28293
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
769 | } |
| 6629 | 770 | |
|
28293
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
771 | attribute = g_datalist_get_data(&attributes, "size"); |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
772 | if (attribute != NULL) { |
|
28298
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
773 | if (!needendtag) { |
|
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
774 | needendtag = TRUE; |
|
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
775 | g_string_append(dest, "<font "); |
|
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
776 | } |
|
28297
230a550b96df
Use a GSList here instead of a GQueue. Yay for simplification.
Mark Doliner <markdoliner@pidgin.im>
parents:
28296
diff
changeset
|
777 | |
|
28298
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
778 | g_string_append_printf(dest, "size=\"%d\" ", |
|
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
779 | POINT_SIZE(strtol(attribute, NULL, 10))); |
|
28297
230a550b96df
Use a GSList here instead of a GQueue. Yay for simplification.
Mark Doliner <markdoliner@pidgin.im>
parents:
28296
diff
changeset
|
780 | } |
| 6629 | 781 | |
|
28297
230a550b96df
Use a GSList here instead of a GQueue. Yay for simplification.
Mark Doliner <markdoliner@pidgin.im>
parents:
28296
diff
changeset
|
782 | if (needendtag) { |
|
230a550b96df
Use a GSList here instead of a GQueue. Yay for simplification.
Mark Doliner <markdoliner@pidgin.im>
parents:
28296
diff
changeset
|
783 | dest->str[dest->len-1] = '>'; |
|
230a550b96df
Use a GSList here instead of a GQueue. Yay for simplification.
Mark Doliner <markdoliner@pidgin.im>
parents:
28296
diff
changeset
|
784 | *tags = g_slist_prepend(*tags, g_strdup("</font>")); |
|
230a550b96df
Use a GSList here instead of a GQueue. Yay for simplification.
Mark Doliner <markdoliner@pidgin.im>
parents:
28296
diff
changeset
|
785 | g_string_free(tmp, TRUE); |
|
230a550b96df
Use a GSList here instead of a GQueue. Yay for simplification.
Mark Doliner <markdoliner@pidgin.im>
parents:
28296
diff
changeset
|
786 | } else { |
|
230a550b96df
Use a GSList here instead of a GQueue. Yay for simplification.
Mark Doliner <markdoliner@pidgin.im>
parents:
28296
diff
changeset
|
787 | *tags = g_slist_prepend(*tags, tmp->str); |
|
230a550b96df
Use a GSList here instead of a GQueue. Yay for simplification.
Mark Doliner <markdoliner@pidgin.im>
parents:
28296
diff
changeset
|
788 | g_string_free(tmp, FALSE); |
| 6629 | 789 | } |
|
28298
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
790 | |
|
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
791 | g_datalist_clear(&attributes); |
| 6629 | 792 | } |
| 793 | ||
| 794 | char *yahoo_html_to_codes(const char *src) | |
| 795 | { | |
|
28101
b82c1e37c9a0
This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <markdoliner@pidgin.im>
parents:
28100
diff
changeset
|
796 | GSList *colors = NULL; |
|
28298
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
797 | |
|
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
798 | /** |
|
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
799 | * A stack of char*s where each char* is the string that should be |
|
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
800 | * appended to dest in order to close all the tags that were opened |
|
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
801 | * by a <font> tag. |
|
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
802 | */ |
|
28101
b82c1e37c9a0
This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <markdoliner@pidgin.im>
parents:
28100
diff
changeset
|
803 | GSList *tags = NULL; |
|
28298
5084ac8ea136
Don't put stuff into a linked list only to iterate through the linked list
Mark Doliner <markdoliner@pidgin.im>
parents:
28297
diff
changeset
|
804 | |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
805 | size_t src_len; |
|
36256
a437550a9308
Remove -Wno-sign-compare and backport fixes from default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35991
diff
changeset
|
806 | guint i, j; |
| 6629 | 807 | GString *dest; |
| 28009 | 808 | char *esc; |
|
28292
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
809 | gboolean no_more_gt_brackets = FALSE; |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
810 | gchar *tag, *tag_name; |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
811 | gboolean is_closing_tag; |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
812 | CurrentMsgState current_state; |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
813 | |
|
28308
835e7fddf397
use memset instead of bzero for better portability and profit
Daniel Atallah <datallah@pidgin.im>
parents:
28307
diff
changeset
|
814 | memset(¤t_state, 0, sizeof(current_state)); |
| 6629 | 815 | |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
816 | src_len = strlen(src); |
|
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
817 | dest = g_string_sized_new(src_len); |
| 6629 | 818 | |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
819 | for (i = 0; i < src_len; i++) { |
|
28292
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
820 | if (src[i] == '<' && !no_more_gt_brackets) { |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
821 | /* The start of an HTML tag */ |
| 6629 | 822 | j = i; |
| 823 | ||
|
28292
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
824 | while (j++ < src_len) { |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
825 | if (src[j] != '>') { |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
826 | if (src[j] == '"') { |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
827 | /* We're inside a quoted attribute value. Skip to the end */ |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
828 | j++; |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
829 | while (j != src_len && src[j] != '"') |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
830 | j++; |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
831 | } else if (src[j] == '\'') { |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
832 | /* We're inside a quoted attribute value. Skip to the end */ |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
833 | j++; |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
834 | while (j != src_len && src[j] != '\'') |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
835 | j++; |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
836 | } |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
837 | if (j != src_len) |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
838 | /* Keep looking for the end of this tag */ |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
839 | continue; |
| 6629 | 840 | |
|
28292
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
841 | /* This < has no corresponding > */ |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
842 | g_string_append_c(dest, src[i]); |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
843 | no_more_gt_brackets = TRUE; |
| 6629 | 844 | break; |
| 845 | } | |
| 846 | ||
|
28292
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
847 | tag = g_strndup(src + i, j - i + 1); |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
848 | tag_name = yahoo_markup_get_tag_name(tag, &is_closing_tag); |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
849 | |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
850 | if (g_str_equal(tag_name, "a")) { |
|
28293
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
851 | const char *start; |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
852 | const char *end; |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
853 | GData *attributes; |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
854 | const char *attribute; |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
855 | |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
856 | /* |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
857 | * TODO: Ideally we would replace this: |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
858 | * <a href="http://pidgin.im/">Pidgin</a> |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
859 | * with this: |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
860 | * Pidgin (http://pidgin.im/) |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
861 | * |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
862 | * Currently we drop the text within the <a> tag and |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
863 | * just show the URL. Doing it the fancy way is |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
864 | * complicated when dealing with HTML tags within the |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
865 | * <a> tag. |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
866 | */ |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
867 | |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
868 | /* Append the URL */ |
|
35991
e6937e52930b
Fix some CWE-252 coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35258
diff
changeset
|
869 | if (!purple_markup_find_tag(tag_name, |
|
e6937e52930b
Fix some CWE-252 coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35258
diff
changeset
|
870 | tag, &start, &end, &attributes)) |
|
e6937e52930b
Fix some CWE-252 coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35258
diff
changeset
|
871 | { |
|
e6937e52930b
Fix some CWE-252 coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35258
diff
changeset
|
872 | g_warn_if_reached(); |
|
e6937e52930b
Fix some CWE-252 coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35258
diff
changeset
|
873 | i = j; |
|
e6937e52930b
Fix some CWE-252 coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35258
diff
changeset
|
874 | g_free(tag); |
|
e6937e52930b
Fix some CWE-252 coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35258
diff
changeset
|
875 | g_free(tag_name); |
|
e6937e52930b
Fix some CWE-252 coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35258
diff
changeset
|
876 | break; |
|
e6937e52930b
Fix some CWE-252 coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35258
diff
changeset
|
877 | } |
|
e6937e52930b
Fix some CWE-252 coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35258
diff
changeset
|
878 | |
|
28293
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
879 | attribute = g_datalist_get_data(&attributes, "href"); |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
880 | if (attribute != NULL) { |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
881 | if (purple_str_has_prefix(attribute, "mailto:")) |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
882 | attribute += 7; |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
883 | g_string_append(dest, attribute); |
|
28292
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
884 | } |
|
28293
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
885 | g_datalist_clear(&attributes); |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
886 | |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
887 | /* Skip past the closing </a> tag */ |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
888 | end = purple_strcasestr(src + j, "</a>"); |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
889 | if (end != NULL) |
|
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
890 | j = end - src + 3; |
|
28292
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
891 | |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
892 | } else if (g_str_equal(tag_name, "font")) { |
|
28309
656e6e3170f0
This function no longer needs these two parameters
Mark Doliner <markdoliner@pidgin.im>
parents:
28308
diff
changeset
|
893 | parse_font_tag(dest, tag_name, tag, &colors, &tags); |
|
28292
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
894 | } else if (g_str_equal(tag_name, "b")) { |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
895 | g_string_append(dest, "\033[1m"); |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
896 | current_state.bold = TRUE; |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
897 | } else if (g_str_equal(tag_name, "/b")) { |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
898 | if (current_state.bold) { |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
899 | g_string_append(dest, "\033[x1m"); |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
900 | current_state.bold = FALSE; |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
901 | } |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
902 | } else if (g_str_equal(tag_name, "i")) { |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
903 | current_state.italic = TRUE; |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
904 | g_string_append(dest, "\033[2m"); |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
905 | } else if (g_str_equal(tag_name, "/i")) { |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
906 | if (current_state.italic) { |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
907 | g_string_append(dest, "\033[x2m"); |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
908 | current_state.italic = FALSE; |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
909 | } |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
910 | } else if (g_str_equal(tag_name, "u")) { |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
911 | current_state.underline = TRUE; |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
912 | g_string_append(dest, "\033[4m"); |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
913 | } else if (g_str_equal(tag_name, "/u")) { |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
914 | if (current_state.underline) { |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
915 | g_string_append(dest, "\033[x4m"); |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
916 | current_state.underline = FALSE; |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
917 | } |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
918 | } else if (g_str_equal(tag_name, "/a")) { |
|
28293
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
919 | /* Do nothing */ |
|
28292
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
920 | } else if (g_str_equal(tag_name, "br")) { |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
921 | g_string_append_c(dest, '\n'); |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
922 | } else if (g_str_equal(tag_name, "/font")) { |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
923 | if (tags != NULL) { |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
924 | char *etag = tags->data; |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
925 | tags = g_slist_delete_link(tags, tags); |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
926 | g_string_append(dest, etag); |
|
28312
2624c0abf3ef
Fix a bug in our outgoing yahoo message formatting where messages
Mark Doliner <markdoliner@pidgin.im>
parents:
28309
diff
changeset
|
927 | if (colors != NULL) { |
|
2624c0abf3ef
Fix a bug in our outgoing yahoo message formatting where messages
Mark Doliner <markdoliner@pidgin.im>
parents:
28309
diff
changeset
|
928 | g_free(colors->data); |
|
2624c0abf3ef
Fix a bug in our outgoing yahoo message formatting where messages
Mark Doliner <markdoliner@pidgin.im>
parents:
28309
diff
changeset
|
929 | colors = g_slist_delete_link(colors, colors); |
|
16169
4aa4ec9afa9c
Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
930 | } |
|
28292
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
931 | g_free(etag); |
| 6629 | 932 | } |
|
29239
d5708b46eac2
Don't send <span>...</span> on Yahoo. Fixes #11242, #10961.
Fartash Faghri <fartash.faghri@gmail.com>
parents:
28973
diff
changeset
|
933 | } else if (g_str_equal(tag_name, "span") || g_str_equal(tag_name, "/span")) { |
|
d5708b46eac2
Don't send <span>...</span> on Yahoo. Fixes #11242, #10961.
Fartash Faghri <fartash.faghri@gmail.com>
parents:
28973
diff
changeset
|
934 | /* Do nothing */ |
|
28628
c06d717eb33c
Fix sending /buzz on yahoo.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28340
diff
changeset
|
935 | } else { |
|
c06d717eb33c
Fix sending /buzz on yahoo.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28340
diff
changeset
|
936 | /* We don't know what the tag is. Send it unmodified. */ |
|
c06d717eb33c
Fix sending /buzz on yahoo.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28340
diff
changeset
|
937 | g_string_append(dest, tag); |
| 6629 | 938 | } |
| 939 | ||
|
28292
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
940 | i = j; |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
941 | g_free(tag); |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
942 | g_free(tag_name); |
|
e1f21cbb9b4d
* Change yahoo_html_to_codes() a little to hopefully be more straight forward
Mark Doliner <markdoliner@pidgin.im>
parents:
28240
diff
changeset
|
943 | break; |
| 6629 | 944 | } |
| 945 | ||
| 946 | } else { | |
|
28103
3d1f5d123294
Reuse our purple_markup_unescape_entity() function instead of
Mark Doliner <markdoliner@pidgin.im>
parents:
28102
diff
changeset
|
947 | const char *entity; |
|
3d1f5d123294
Reuse our purple_markup_unescape_entity() function instead of
Mark Doliner <markdoliner@pidgin.im>
parents:
28102
diff
changeset
|
948 | int length; |
|
3d1f5d123294
Reuse our purple_markup_unescape_entity() function instead of
Mark Doliner <markdoliner@pidgin.im>
parents:
28102
diff
changeset
|
949 | |
|
3d1f5d123294
Reuse our purple_markup_unescape_entity() function instead of
Mark Doliner <markdoliner@pidgin.im>
parents:
28102
diff
changeset
|
950 | entity = purple_markup_unescape_entity(src + i, &length); |
|
3d1f5d123294
Reuse our purple_markup_unescape_entity() function instead of
Mark Doliner <markdoliner@pidgin.im>
parents:
28102
diff
changeset
|
951 | if (entity != NULL) { |
|
3d1f5d123294
Reuse our purple_markup_unescape_entity() function instead of
Mark Doliner <markdoliner@pidgin.im>
parents:
28102
diff
changeset
|
952 | /* src[i] is the start of an HTML entity */ |
|
3d1f5d123294
Reuse our purple_markup_unescape_entity() function instead of
Mark Doliner <markdoliner@pidgin.im>
parents:
28102
diff
changeset
|
953 | g_string_append(dest, entity); |
|
3d1f5d123294
Reuse our purple_markup_unescape_entity() function instead of
Mark Doliner <markdoliner@pidgin.im>
parents:
28102
diff
changeset
|
954 | i += length - 1; |
|
3d1f5d123294
Reuse our purple_markup_unescape_entity() function instead of
Mark Doliner <markdoliner@pidgin.im>
parents:
28102
diff
changeset
|
955 | } else |
|
3d1f5d123294
Reuse our purple_markup_unescape_entity() function instead of
Mark Doliner <markdoliner@pidgin.im>
parents:
28102
diff
changeset
|
956 | /* src[i] is a normal character */ |
| 8440 | 957 | g_string_append_c(dest, src[i]); |
| 6629 | 958 | } |
| 959 | } | |
| 960 | ||
| 28009 | 961 | esc = g_strescape(dest->str, NULL); |
|
28293
8f160f6f9980
Make outgoing yahoo messages with links, font color, font face or font size
Mark Doliner <markdoliner@pidgin.im>
parents:
28292
diff
changeset
|
962 | purple_debug_misc("yahoo", "yahoo_html_to_codes(%s)=%s\n", src, esc); |
| 6629 | 963 | g_free(esc); |
| 964 | ||
|
28101
b82c1e37c9a0
This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <markdoliner@pidgin.im>
parents:
28100
diff
changeset
|
965 | yahoo_htc_list_cleanup(colors); |
|
b82c1e37c9a0
This is actually a stack, not a queue, so we can use a simpler data
Mark Doliner <markdoliner@pidgin.im>
parents:
28100
diff
changeset
|
966 | yahoo_htc_list_cleanup(tags); |
| 6629 | 967 | |
| 28009 | 968 | return g_string_free(dest, FALSE); |
| 6629 | 969 | } |
|
28786
a0366821d1e4
Cannot send a file to a federated user on yahoo.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28628
diff
changeset
|
970 | |
|
a0366821d1e4
Cannot send a file to a federated user on yahoo.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28628
diff
changeset
|
971 | YahooFederation yahoo_get_federation_from_name(const char *who) |
|
a0366821d1e4
Cannot send a file to a federated user on yahoo.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28628
diff
changeset
|
972 | { |
|
a0366821d1e4
Cannot send a file to a federated user on yahoo.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28628
diff
changeset
|
973 | YahooFederation fed = YAHOO_FEDERATION_NONE; |
|
a0366821d1e4
Cannot send a file to a federated user on yahoo.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28628
diff
changeset
|
974 | if (who[3] == '/') { |
|
a0366821d1e4
Cannot send a file to a federated user on yahoo.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28628
diff
changeset
|
975 | if (!g_ascii_strncasecmp(who, "msn", 3)) |
|
a0366821d1e4
Cannot send a file to a federated user on yahoo.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28628
diff
changeset
|
976 | fed = YAHOO_FEDERATION_MSN; |
|
a0366821d1e4
Cannot send a file to a federated user on yahoo.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28628
diff
changeset
|
977 | else if (!g_ascii_strncasecmp(who, "ocs", 3)) |
|
a0366821d1e4
Cannot send a file to a federated user on yahoo.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28628
diff
changeset
|
978 | fed = YAHOO_FEDERATION_OCS; |
|
a0366821d1e4
Cannot send a file to a federated user on yahoo.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28628
diff
changeset
|
979 | else if (!g_ascii_strncasecmp(who, "ibm", 3)) |
|
a0366821d1e4
Cannot send a file to a federated user on yahoo.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28628
diff
changeset
|
980 | fed = YAHOO_FEDERATION_IBM; |
|
29324
125eb74677d6
Support Yahoo !PingBox. Includes a couple warning fixes. Fixes #7347.
Kartik Mohta <kartikmohta@gmail.com>
parents:
29239
diff
changeset
|
981 | else if (!g_ascii_strncasecmp(who, "pbx", 3)) |
|
125eb74677d6
Support Yahoo !PingBox. Includes a couple warning fixes. Fixes #7347.
Kartik Mohta <kartikmohta@gmail.com>
parents:
29239
diff
changeset
|
982 | fed = YAHOO_FEDERATION_PBX; |
|
28786
a0366821d1e4
Cannot send a file to a federated user on yahoo.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28628
diff
changeset
|
983 | } |
|
a0366821d1e4
Cannot send a file to a federated user on yahoo.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28628
diff
changeset
|
984 | return fed; |
|
a0366821d1e4
Cannot send a file to a federated user on yahoo.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28628
diff
changeset
|
985 | } |
|
a0366821d1e4
Cannot send a file to a federated user on yahoo.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28628
diff
changeset
|
986 |