Sat, 01 Aug 2009 04:24:39 +0000
jabber: Better inactivity timer logic.
| 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 |
|
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
|
36 | yahoo_account_use_http_proxy(PurpleConnection *conn) |
|
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 | { |
|
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
|
38 | PurpleProxyInfo *ppi = purple_proxy_get_setup(conn->account); |
|
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
|
39 | return (ppi->type == PURPLE_PROXY_HTTP || ppi->type == PURPLE_PROXY_USE_ENVVAR); |
|
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
|
40 | } |
|
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
|
41 | |
|
22202
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
42 | /* |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
43 | * 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
|
44 | * 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
|
45 | * |
|
22202
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
46 | * 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
|
47 | */ |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
48 | 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
|
49 | { |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
50 | gchar *ans = NULL; |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
51 | gchar *cur; |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
52 | char firstflag = 1; |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
53 | 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
|
54 | GSList *tmp; |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
55 | 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
|
56 | 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
|
57 | tmp = cookies; |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
58 | while(tmp) |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
59 | { |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
60 | cur = tmp->data; |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
61 | t1 = ans; |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
62 | 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
|
63 | if(t2 == NULL) |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
64 | 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
|
65 | if(t2 == NULL) |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
66 | { |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
67 | if(firstflag) |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
68 | 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
|
69 | else |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
70 | 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
|
71 | } |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
72 | else |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
73 | { |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
74 | 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
|
75 | if(t3 != NULL) |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
76 | { |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
77 | t2[0] = '\0'; |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
78 | |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
79 | if(firstflag) |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
80 | 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
|
81 | else |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
82 | 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
|
83 | |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
84 | t2[0] = ';'; |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
85 | } |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
86 | else |
|
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", 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
|
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", 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
|
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 | } |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
98 | if(firstflag) |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
99 | firstflag = 0; |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
100 | else |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
101 | g_free(t1); |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
102 | 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
|
103 | } |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
104 | return ans; |
|
e42ab2e3eba1
This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan Sankaranarayanan <madthanu@gmail.com>
parents:
21946
diff
changeset
|
105 | } |
|
6546
6a14dfe43d5c
[gaim-migrate @ 7068]
Mark Doliner <markdoliner@pidgin.im>
parents:
6513
diff
changeset
|
106 | |
| 7827 | 107 | /** |
| 108 | * Encode some text to send to the yahoo server. | |
| 109 | * | |
| 110 | * @param gc The connection handle. | |
| 111 | * @param str The null terminated utf8 string to encode. | |
| 112 | * @param utf8 If not @c NULL, whether utf8 is okay or not. | |
| 113 | * Even if it is okay, we may not use it. If we | |
| 114 | * used it, we set this to @c TRUE, else to | |
| 115 | * @c FALSE. If @c NULL, false is assumed, and | |
| 116 | * it is not dereferenced. | |
| 117 | * @return The g_malloced string in the appropriate encoding. | |
| 118 | */ | |
| 15884 | 119 | char *yahoo_string_encode(PurpleConnection *gc, const char *str, gboolean *utf8) |
| 7827 | 120 | { |
|
27959
f842ae57da4e
Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27683
diff
changeset
|
121 | YahooData *yd = gc->proto_data; |
| 7827 | 122 | char *ret; |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10380
diff
changeset
|
123 | const char *to_codeset; |
| 7827 | 124 | |
|
23173
c6dde2d2e30e
applied changes from a5e7a62db1d43009f4ff463b7fe67ff3a7275a78
Daniel Atallah <datallah@pidgin.im>
parents:
22289
diff
changeset
|
125 | if (yd->jp) |
|
c6dde2d2e30e
applied changes from a5e7a62db1d43009f4ff463b7fe67ff3a7275a78
Daniel Atallah <datallah@pidgin.im>
parents:
22289
diff
changeset
|
126 | return g_strdup(str); |
| 9164 | 127 | |
| 7827 | 128 | if (utf8 && *utf8) /* FIXME: maybe don't use utf8 if it'll fit in latin1 */ |
| 129 | return g_strdup(str); | |
| 130 | ||
|
23173
c6dde2d2e30e
applied changes from a5e7a62db1d43009f4ff463b7fe67ff3a7275a78
Daniel Atallah <datallah@pidgin.im>
parents:
22289
diff
changeset
|
131 | to_codeset = purple_account_get_string(purple_connection_get_account(gc), "local_charset", "ISO-8859-1"); |
|
c6dde2d2e30e
applied changes from a5e7a62db1d43009f4ff463b7fe67ff3a7275a78
Daniel Atallah <datallah@pidgin.im>
parents:
22289
diff
changeset
|
132 | ret = g_convert_with_fallback(str, -1, to_codeset, "UTF-8", "?", NULL, NULL, NULL); |
| 7827 | 133 | |
| 134 | if (ret) | |
| 135 | return ret; | |
| 136 | else | |
| 137 | return g_strdup(""); | |
| 138 | } | |
| 139 | ||
| 140 | /** | |
| 141 | * Decode some text received from the server. | |
| 142 | * | |
| 143 | * @param gc The gc handle. | |
| 144 | * @param str The null terminated string to decode. | |
| 145 | * @param utf8 Did the server tell us it was supposed to be utf8? | |
| 146 | * @return The decoded, utf-8 string, which must be g_free()'d. | |
| 147 | */ | |
| 15884 | 148 | char *yahoo_string_decode(PurpleConnection *gc, const char *str, gboolean utf8) |
| 7827 | 149 | { |
|
27959
f842ae57da4e
Move from "struct yahoo_data" to "YahooData" to be consistent with other structs
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27683
diff
changeset
|
150 | YahooData *yd = gc->proto_data; |
| 7827 | 151 | char *ret; |
| 14347 | 152 | const char *from_codeset; |
| 7827 | 153 | |
| 154 | if (utf8) { | |
| 155 | if (g_utf8_validate(str, -1, NULL)) | |
| 156 | return g_strdup(str); | |
| 157 | } | |
| 158 | ||
| 9164 | 159 | if (yd->jp) |
| 160 | from_codeset = "SHIFT_JIS"; | |
| 161 | else | |
| 15884 | 162 | from_codeset = purple_account_get_string(purple_connection_get_account(gc), "local_charset", "ISO-8859-1"); |
| 7827 | 163 | |
|
19337
68471e68386a
Use -1 as length with g_convert() functions instead of strlen()
Daniel Atallah <datallah@pidgin.im>
parents:
16169
diff
changeset
|
164 | ret = g_convert_with_fallback(str, -1, "UTF-8", from_codeset, NULL, NULL, NULL, NULL); |
| 7827 | 165 | |
| 166 | if (ret) | |
| 167 | return ret; | |
| 168 | else | |
| 169 | return g_strdup(""); | |
| 170 | } | |
| 171 | ||
|
22259
bc9fcfd10196
disapproval of revision 'db9b3bc9d4427a6a03d1c25aac5215bf0f8e05ec'
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22248
diff
changeset
|
172 | char *yahoo_convert_to_numeric(const char *str) |
|
bc9fcfd10196
disapproval of revision 'db9b3bc9d4427a6a03d1c25aac5215bf0f8e05ec'
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22248
diff
changeset
|
173 | { |
|
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
|
174 | GString *gstr = NULL; |
|
22289
a1f40ee48fa8
Fix (hopefully) the last problem in this function. Refs #3295.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22261
diff
changeset
|
175 | const unsigned char *p; |
|
22259
bc9fcfd10196
disapproval of revision 'db9b3bc9d4427a6a03d1c25aac5215bf0f8e05ec'
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22248
diff
changeset
|
176 | |
|
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
|
177 | 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
|
178 | |
|
22289
a1f40ee48fa8
Fix (hopefully) the last problem in this function. Refs #3295.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22261
diff
changeset
|
179 | 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
|
180 | g_string_append_printf(gstr, "&#%u;", *p); |
|
22259
bc9fcfd10196
disapproval of revision 'db9b3bc9d4427a6a03d1c25aac5215bf0f8e05ec'
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22248
diff
changeset
|
181 | } |
|
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
|
182 | |
| 28009 | 183 | return g_string_free(gstr, FALSE); |
|
22259
bc9fcfd10196
disapproval of revision 'db9b3bc9d4427a6a03d1c25aac5215bf0f8e05ec'
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22248
diff
changeset
|
184 | } |
|
bc9fcfd10196
disapproval of revision 'db9b3bc9d4427a6a03d1c25aac5215bf0f8e05ec'
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
22248
diff
changeset
|
185 | |
| 6513 | 186 | /* |
| 187 | * 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
|
188 | * 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
|
189 | * |
| 6513 | 190 | * [0;30m ---black |
| 191 | * [1;37m ---white | |
| 192 | * [0;37m ---tan | |
| 193 | * [0;38m ---light black | |
| 194 | * [1;39m ---dark blue | |
| 195 | * [0;32m ---green | |
| 196 | * [0;33m ---yellow | |
| 197 | * [0;35m ---pink | |
| 198 | * [1;35m ---purple | |
| 199 | * [1;30m ---light blue | |
| 200 | * [0;31m ---red | |
| 201 | * [0;34m ---blue | |
| 202 | * [0;36m ---aqua | |
| 203 | * (shift+comma)lyellow(shift+period) ---light yellow | |
| 204 | * (shift+comma)lgreen(shift+period) ---light green | |
| 205 | [2;30m <--white out | |
| 206 | */ | |
| 207 | ||
| 208 | static GHashTable *ht = NULL; | |
| 209 | ||
| 210 | void yahoo_init_colorht() | |
| 211 | { | |
|
27683
9ee099fab4ee
Don't double-free the color hash table when deinitializing both prpl-yahoo
Mark Doliner <markdoliner@pidgin.im>
parents:
27555
diff
changeset
|
212 | if (ht != NULL) |
|
9ee099fab4ee
Don't double-free the color hash table when deinitializing both prpl-yahoo
Mark Doliner <markdoliner@pidgin.im>
parents:
27555
diff
changeset
|
213 | /* 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
|
214 | return; |
|
9ee099fab4ee
Don't double-free the color hash table when deinitializing both prpl-yahoo
Mark Doliner <markdoliner@pidgin.im>
parents:
27555
diff
changeset
|
215 | |
| 6513 | 216 | ht = g_hash_table_new(g_str_hash, g_str_equal); |
|
27683
9ee099fab4ee
Don't double-free the color hash table when deinitializing both prpl-yahoo
Mark Doliner <markdoliner@pidgin.im>
parents:
27555
diff
changeset
|
217 | /* 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
|
218 | #ifdef USE_CSS_FORMATTING |
|
28016
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
219 | g_hash_table_insert(ht, "30", "<span style=\"color: #000000\">"); /* black */ |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
220 | g_hash_table_insert(ht, "31", "<span style=\"color: #0000FF\">"); /* blue */ |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
221 | g_hash_table_insert(ht, "32", "<span style=\"color: #008080\">"); /* cyan */ /* 00b2b2 */ |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
222 | g_hash_table_insert(ht, "33", "<span style=\"color: #808080\">"); /* gray */ /* 808080 */ |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
223 | g_hash_table_insert(ht, "34", "<span style=\"color: #008000\">"); /* green */ /* 00c200 */ |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
224 | g_hash_table_insert(ht, "35", "<span style=\"color: #FF0080\">"); /* pink */ /* ffafaf */ |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
225 | g_hash_table_insert(ht, "36", "<span style=\"color: #800080\">"); /* purple */ /* b200b2 */ |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
226 | g_hash_table_insert(ht, "37", "<span style=\"color: #FF8000\">"); /* orange */ /* ffff00 */ |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
227 | g_hash_table_insert(ht, "38", "<span style=\"color: #FF0000\">"); /* red */ |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
228 | g_hash_table_insert(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
|
229 | #else |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
230 | g_hash_table_insert(ht, "30", "<font color=\"#000000\">"); /* black */ |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
231 | g_hash_table_insert(ht, "31", "<font color=\"#0000FF\">"); /* blue */ |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
232 | g_hash_table_insert(ht, "32", "<font color=\"#008080\">"); /* cyan */ /* 00b2b2 */ |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
233 | g_hash_table_insert(ht, "33", "<font color=\"#808080\">"); /* gray */ /* 808080 */ |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
234 | g_hash_table_insert(ht, "34", "<font color=\"#008000\">"); /* green */ /* 00c200 */ |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
235 | g_hash_table_insert(ht, "35", "<font color=\"#FF0080\">"); /* pink */ /* ffafaf */ |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
236 | g_hash_table_insert(ht, "36", "<font color=\"#800080\">"); /* purple */ /* b200b2 */ |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
237 | g_hash_table_insert(ht, "37", "<font color=\"#FF8000\">"); /* orange */ /* ffff00 */ |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
238 | g_hash_table_insert(ht, "38", "<font color=\"#FF0000\">"); /* red */ |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
239 | g_hash_table_insert(ht, "39", "<font color=\"#808000\">"); /* olive */ /* 546b50 */ |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
240 | #endif /* !USE_CSS_FORMATTING */ |
| 6513 | 241 | |
|
28015
c09be470c8ec
Whoops, I forgot to add the test!
Mark Doliner <markdoliner@pidgin.im>
parents:
28011
diff
changeset
|
242 | g_hash_table_insert(ht, "1", "<b>"); |
|
c09be470c8ec
Whoops, I forgot to add the test!
Mark Doliner <markdoliner@pidgin.im>
parents:
28011
diff
changeset
|
243 | g_hash_table_insert(ht, "x1", "</b>"); |
|
c09be470c8ec
Whoops, I forgot to add the test!
Mark Doliner <markdoliner@pidgin.im>
parents:
28011
diff
changeset
|
244 | g_hash_table_insert(ht, "2", "<i>"); |
|
c09be470c8ec
Whoops, I forgot to add the test!
Mark Doliner <markdoliner@pidgin.im>
parents:
28011
diff
changeset
|
245 | g_hash_table_insert(ht, "x2", "</i>"); |
|
c09be470c8ec
Whoops, I forgot to add the test!
Mark Doliner <markdoliner@pidgin.im>
parents:
28011
diff
changeset
|
246 | g_hash_table_insert(ht, "4", "<u>"); |
|
c09be470c8ec
Whoops, I forgot to add the test!
Mark Doliner <markdoliner@pidgin.im>
parents:
28011
diff
changeset
|
247 | g_hash_table_insert(ht, "x4", "</u>"); |
| 6513 | 248 | |
| 6629 | 249 | /* these just tell us the text they surround is supposed |
| 15884 | 250 | * to be a link. purple figures that out on its own so we |
| 6629 | 251 | * just ignore it. |
| 252 | */ | |
| 253 | g_hash_table_insert(ht, "l", ""); /* link start */ | |
| 254 | g_hash_table_insert(ht, "xl", ""); /* link end */ | |
| 255 | ||
|
28045
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
256 | #ifdef USE_CSS_FORMATTING |
|
28016
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
257 | g_hash_table_insert(ht, "<black>", "<span style=\"color: #000000\">"); |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
258 | g_hash_table_insert(ht, "<blue>", "<span style=\"color: #0000FF\">"); |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
259 | g_hash_table_insert(ht, "<cyan>", "<span style=\"color: #008284\">"); |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
260 | g_hash_table_insert(ht, "<gray>", "<span style=\"color: #848284\">"); |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
261 | g_hash_table_insert(ht, "<green>", "<span style=\"color: #008200\">"); |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
262 | g_hash_table_insert(ht, "<pink>", "<span style=\"color: #FF0084\">"); |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
263 | g_hash_table_insert(ht, "<purple>", "<span style=\"color: #840084\">"); |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
264 | g_hash_table_insert(ht, "<orange>", "<span style=\"color: #FF8000\">"); |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
265 | g_hash_table_insert(ht, "<red>", "<span style=\"color: #FF0000\">"); |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
266 | g_hash_table_insert(ht, "<yellow>", "<span style=\"color: #848200\">"); |
| 6513 | 267 | |
|
28016
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
268 | g_hash_table_insert(ht, "</black>", "</span>"); |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
269 | g_hash_table_insert(ht, "</blue>", "</span>"); |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
270 | g_hash_table_insert(ht, "</cyan>", "</span>"); |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
271 | g_hash_table_insert(ht, "</gray>", "</span>"); |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
272 | g_hash_table_insert(ht, "</green>", "</span>"); |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
273 | g_hash_table_insert(ht, "</pink>", "</span>"); |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
274 | g_hash_table_insert(ht, "</purple>", "</span>"); |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
275 | g_hash_table_insert(ht, "</orange>", "</span>"); |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
276 | g_hash_table_insert(ht, "</red>", "</span>"); |
|
b29a702b1176
Change Yahoo to send <span> tags with a color style attribute instead of <font>
Mark Doliner <markdoliner@pidgin.im>
parents:
28015
diff
changeset
|
277 | g_hash_table_insert(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
|
278 | #else |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
279 | g_hash_table_insert(ht, "<black>", "<font color=\"#000000\">"); |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
280 | g_hash_table_insert(ht, "<blue>", "<font color=\"#0000FF\">"); |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
281 | g_hash_table_insert(ht, "<cyan>", "<font color=\"#008284\">"); |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
282 | g_hash_table_insert(ht, "<gray>", "<font color=\"#848284\">"); |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
283 | g_hash_table_insert(ht, "<green>", "<font color=\"#008200\">"); |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
284 | g_hash_table_insert(ht, "<pink>", "<font color=\"#FF0084\">"); |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
285 | g_hash_table_insert(ht, "<purple>", "<font color=\"#840084\">"); |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
286 | g_hash_table_insert(ht, "<orange>", "<font color=\"#FF8000\">"); |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
287 | g_hash_table_insert(ht, "<red>", "<font color=\"#FF0000\">"); |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
288 | g_hash_table_insert(ht, "<yellow>", "<font color=\"#848200\">"); |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
289 | |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
290 | g_hash_table_insert(ht, "</black>", "</font>"); |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
291 | g_hash_table_insert(ht, "</blue>", "</font>"); |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
292 | g_hash_table_insert(ht, "</cyan>", "</font>"); |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
293 | g_hash_table_insert(ht, "</gray>", "</font>"); |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
294 | g_hash_table_insert(ht, "</green>", "</font>"); |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
295 | g_hash_table_insert(ht, "</pink>", "</font>"); |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
296 | g_hash_table_insert(ht, "</purple>", "</font>"); |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
297 | g_hash_table_insert(ht, "</orange>", "</font>"); |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
298 | g_hash_table_insert(ht, "</red>", "</font>"); |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
299 | g_hash_table_insert(ht, "</yellow>", "</font>"); |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
300 | #endif /* !USE_CSS_FORMATTING */ |
| 6513 | 301 | |
| 302 | /* remove these once we have proper support for <FADE> and <ALT> */ | |
| 303 | g_hash_table_insert(ht, "</fade>", ""); | |
| 304 | g_hash_table_insert(ht, "</alt>", ""); | |
| 8375 | 305 | |
| 306 | /* these are the normal html yahoo sends (besides <font>). | |
| 307 | * anything else will get turned into <tag>, so if I forgot | |
| 308 | * about something, please add it. Why Yahoo! has to send unescaped | |
| 309 | * <'s and >'s that aren't supposed to be html is beyond me. | |
| 310 | */ | |
| 311 | g_hash_table_insert(ht, "<b>", "<b>"); | |
| 312 | g_hash_table_insert(ht, "<i>", "<i>"); | |
| 313 | g_hash_table_insert(ht, "<u>", "<u>"); | |
| 314 | ||
| 315 | g_hash_table_insert(ht, "</b>", "</b>"); | |
| 316 | g_hash_table_insert(ht, "</i>", "</i>"); | |
| 317 | g_hash_table_insert(ht, "</u>", "</u>"); | |
| 8440 | 318 | g_hash_table_insert(ht, "</font>", "</font>"); |
| 6513 | 319 | } |
| 320 | ||
| 321 | void yahoo_dest_colorht() | |
| 322 | { | |
|
27683
9ee099fab4ee
Don't double-free the color hash table when deinitializing both prpl-yahoo
Mark Doliner <markdoliner@pidgin.im>
parents:
27555
diff
changeset
|
323 | if (ht == NULL) |
|
9ee099fab4ee
Don't double-free the color hash table when deinitializing both prpl-yahoo
Mark Doliner <markdoliner@pidgin.im>
parents:
27555
diff
changeset
|
324 | /* 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
|
325 | return; |
|
9ee099fab4ee
Don't double-free the color hash table when deinitializing both prpl-yahoo
Mark Doliner <markdoliner@pidgin.im>
parents:
27555
diff
changeset
|
326 | |
| 6513 | 327 | g_hash_table_destroy(ht); |
|
27683
9ee099fab4ee
Don't double-free the color hash table when deinitializing both prpl-yahoo
Mark Doliner <markdoliner@pidgin.im>
parents:
27555
diff
changeset
|
328 | ht = NULL; |
| 6513 | 329 | } |
| 330 | ||
|
28045
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
331 | #ifndef USE_CSS_FORMATTING |
| 6629 | 332 | static int point_to_html(int x) |
| 333 | { | |
| 334 | if (x < 9) | |
| 335 | return 1; | |
| 336 | if (x < 11) | |
| 337 | return 2; | |
| 338 | if (x < 13) | |
| 339 | return 3; | |
| 340 | if (x < 17) | |
| 341 | return 4; | |
| 342 | if (x < 25) | |
| 343 | return 5; | |
| 344 | if (x < 35) | |
| 345 | return 6; | |
| 346 | return 7; | |
| 347 | } | |
|
28045
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
348 | #endif /* !USE_CSS_FORMATTING */ |
|
10380
8608e553808f
[gaim-migrate @ 11605]
Evan Schoenberg <evands@pidgin.im>
parents:
10023
diff
changeset
|
349 | |
|
28045
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
350 | /* |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
351 | * The Yahoo font size value is given in pt, even thougth the HTML |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
352 | * standard for <font size="x"> treats the size as a number on a |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
353 | * scale between 1 and 7. Let's get rid of this shoddyness and |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
354 | * convert it to CSS. |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
355 | */ |
|
28038
44f90f5073e0
Stop using a GString when a gchar* will do fine
Mark Doliner <markdoliner@pidgin.im>
parents:
28037
diff
changeset
|
356 | static void _font_tags_fix_size(const char *tag, GString *dest) |
| 6629 | 357 | { |
| 358 | char *x, *end; | |
| 359 | int size; | |
| 360 | ||
|
28038
44f90f5073e0
Stop using a GString when a gchar* will do fine
Mark Doliner <markdoliner@pidgin.im>
parents:
28037
diff
changeset
|
361 | if (((x = strstr(tag, "size"))) && ((x = strchr(x, '=')))) { |
| 6629 | 362 | while (*x && !g_ascii_isdigit(*x)) |
| 363 | x++; | |
| 364 | if (*x) { | |
|
28045
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
365 | #ifndef USE_CSS_FORMATTING |
|
10380
8608e553808f
[gaim-migrate @ 11605]
Evan Schoenberg <evands@pidgin.im>
parents:
10023
diff
changeset
|
366 | int htmlsize; |
|
28045
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
367 | #endif /* !USE_CSS_FORMATTING */ |
|
10380
8608e553808f
[gaim-migrate @ 11605]
Evan Schoenberg <evands@pidgin.im>
parents:
10023
diff
changeset
|
368 | |
| 6629 | 369 | size = strtol(x, &end, 10); |
|
28045
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
370 | |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
371 | #ifdef USE_CSS_FORMATTING |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
372 | g_string_append_len(dest, tag, x - tag - 7); |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
373 | g_string_append(dest, end + 1); |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
374 | g_string_append_printf(dest, "<span style=\"font-size: %dpt\">", size); |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
375 | #else |
|
10380
8608e553808f
[gaim-migrate @ 11605]
Evan Schoenberg <evands@pidgin.im>
parents:
10023
diff
changeset
|
376 | htmlsize = point_to_html(size); |
|
28038
44f90f5073e0
Stop using a GString when a gchar* will do fine
Mark Doliner <markdoliner@pidgin.im>
parents:
28037
diff
changeset
|
377 | g_string_append_len(dest, tag, x - tag); |
|
10380
8608e553808f
[gaim-migrate @ 11605]
Evan Schoenberg <evands@pidgin.im>
parents:
10023
diff
changeset
|
378 | g_string_append_printf(dest, "%d", htmlsize); |
|
8608e553808f
[gaim-migrate @ 11605]
Evan Schoenberg <evands@pidgin.im>
parents:
10023
diff
changeset
|
379 | g_string_append_printf(dest, "\" absz=\"%d", size); |
| 6629 | 380 | g_string_append(dest, end); |
|
28045
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
381 | #endif /* !USE_CSS_FORMATTING */ |
| 6629 | 382 | } else { |
|
28038
44f90f5073e0
Stop using a GString when a gchar* will do fine
Mark Doliner <markdoliner@pidgin.im>
parents:
28037
diff
changeset
|
383 | g_string_append(dest, tag); |
| 6629 | 384 | return; |
| 385 | } | |
| 386 | } else { | |
|
28038
44f90f5073e0
Stop using a GString when a gchar* will do fine
Mark Doliner <markdoliner@pidgin.im>
parents:
28037
diff
changeset
|
387 | g_string_append(dest, tag); |
| 6629 | 388 | return; |
| 389 | } | |
| 390 | } | |
| 391 | ||
| 392 | char *yahoo_codes_to_html(const char *x) | |
| 6513 | 393 | { |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
394 | size_t x_len; |
|
28038
44f90f5073e0
Stop using a GString when a gchar* will do fine
Mark Doliner <markdoliner@pidgin.im>
parents:
28037
diff
changeset
|
395 | GString *s; |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
396 | int i, j; |
|
28038
44f90f5073e0
Stop using a GString when a gchar* will do fine
Mark Doliner <markdoliner@pidgin.im>
parents:
28037
diff
changeset
|
397 | gchar *tmp; |
|
28041
84fb2d6540ea
Of course I got it backwards
Mark Doliner <markdoliner@pidgin.im>
parents:
28040
diff
changeset
|
398 | 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
|
399 | const char *match; |
| 6513 | 400 | |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
401 | x_len = strlen(x); |
|
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
402 | s = g_string_sized_new(x_len); |
| 6513 | 403 | |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
404 | for (i = 0; i < x_len; i++) { |
| 6513 | 405 | if ((x[i] == 0x1b) && (x[i+1] == '[')) { |
|
28040
476db09dcc7a
Better variable name?
Mark Doliner <markdoliner@pidgin.im>
parents:
28038
diff
changeset
|
406 | /* This escape sequence signifies the beginning of some |
|
476db09dcc7a
Better variable name?
Mark Doliner <markdoliner@pidgin.im>
parents:
28038
diff
changeset
|
407 | * text formatting code */ |
| 6513 | 408 | j = i + 1; |
| 409 | ||
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
410 | while (j++ < x_len) { |
| 6513 | 411 | if (x[j] != 'm') |
| 412 | continue; | |
| 413 | else { | |
|
28038
44f90f5073e0
Stop using a GString when a gchar* will do fine
Mark Doliner <markdoliner@pidgin.im>
parents:
28037
diff
changeset
|
414 | /* We've reached the end of the formatting code, yay */ |
|
44f90f5073e0
Stop using a GString when a gchar* will do fine
Mark Doliner <markdoliner@pidgin.im>
parents:
28037
diff
changeset
|
415 | tmp = g_strndup(x + i + 2, j - i - 2); |
|
44f90f5073e0
Stop using a GString when a gchar* will do fine
Mark Doliner <markdoliner@pidgin.im>
parents:
28037
diff
changeset
|
416 | if (tmp[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
|
417 | #ifdef USE_CSS_FORMATTING |
|
28038
44f90f5073e0
Stop using a GString when a gchar* will do fine
Mark Doliner <markdoliner@pidgin.im>
parents:
28037
diff
changeset
|
418 | g_string_append_printf(s, "<span style=\"color: %s\">", 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
|
419 | #else |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
420 | g_string_append_printf(s, "<font color=\"%s\">", tmp); |
|
dca626985d99
Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <markdoliner@pidgin.im>
parents:
28041
diff
changeset
|
421 | #endif /* !USE_CSS_FORMATTING */ |
|
28038
44f90f5073e0
Stop using a GString when a gchar* will do fine
Mark Doliner <markdoliner@pidgin.im>
parents:
28037
diff
changeset
|
422 | else if ((match = g_hash_table_lookup(ht, tmp))) |
| 6513 | 423 | g_string_append(s, match); |
| 424 | else { | |
|
27547
c136491361eb
Convert the yahoo prpl to using the debug convenience functions instead of
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27361
diff
changeset
|
425 | purple_debug_error("yahoo", |
|
28038
44f90f5073e0
Stop using a GString when a gchar* will do fine
Mark Doliner <markdoliner@pidgin.im>
parents:
28037
diff
changeset
|
426 | "Unknown ansi code 'ESC[%sm'.\n", tmp); |
|
44f90f5073e0
Stop using a GString when a gchar* will do fine
Mark Doliner <markdoliner@pidgin.im>
parents:
28037
diff
changeset
|
427 | g_free(tmp); |
| 6513 | 428 | break; |
| 429 | } | |
| 430 | ||
| 431 | i = j; | |
|
28038
44f90f5073e0
Stop using a GString when a gchar* will do fine
Mark Doliner <markdoliner@pidgin.im>
parents:
28037
diff
changeset
|
432 | g_free(tmp); |
| 6513 | 433 | break; |
| 434 | } | |
| 435 | } | |
| 436 | ||
|
28041
84fb2d6540ea
Of course I got it backwards
Mark Doliner <markdoliner@pidgin.im>
parents:
28040
diff
changeset
|
437 | } else if (!no_more_gt_brackets && (x[i] == '<')) { |
|
28040
476db09dcc7a
Better variable name?
Mark Doliner <markdoliner@pidgin.im>
parents:
28038
diff
changeset
|
438 | /* The start of an HTML tag */ |
| 6629 | 439 | j = i; |
| 6513 | 440 | |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
441 | while (j++ < x_len) { |
| 6513 | 442 | if (x[j] != '>') |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
443 | if (j == x_len) { |
| 8375 | 444 | g_string_append(s, "<"); |
|
28041
84fb2d6540ea
Of course I got it backwards
Mark Doliner <markdoliner@pidgin.im>
parents:
28040
diff
changeset
|
445 | no_more_gt_brackets = TRUE; |
| 6513 | 446 | } |
| 447 | else | |
| 448 | continue; | |
| 449 | else { | |
|
28038
44f90f5073e0
Stop using a GString when a gchar* will do fine
Mark Doliner <markdoliner@pidgin.im>
parents:
28037
diff
changeset
|
450 | tmp = g_strndup(x + i, j - i + 1); |
|
44f90f5073e0
Stop using a GString when a gchar* will do fine
Mark Doliner <markdoliner@pidgin.im>
parents:
28037
diff
changeset
|
451 | g_ascii_strdown(tmp, -1); |
| 6513 | 452 | |
|
28038
44f90f5073e0
Stop using a GString when a gchar* will do fine
Mark Doliner <markdoliner@pidgin.im>
parents:
28037
diff
changeset
|
453 | if ((match = g_hash_table_lookup(ht, tmp))) |
| 6513 | 454 | g_string_append(s, match); |
|
28038
44f90f5073e0
Stop using a GString when a gchar* will do fine
Mark Doliner <markdoliner@pidgin.im>
parents:
28037
diff
changeset
|
455 | else if (!strncmp(tmp, "<fade ", 6) || |
|
44f90f5073e0
Stop using a GString when a gchar* will do fine
Mark Doliner <markdoliner@pidgin.im>
parents:
28037
diff
changeset
|
456 | !strncmp(tmp, "<alt ", 5) || |
|
44f90f5073e0
Stop using a GString when a gchar* will do fine
Mark Doliner <markdoliner@pidgin.im>
parents:
28037
diff
changeset
|
457 | !strncmp(tmp, "<snd ", 5)) { |
| 6513 | 458 | |
| 6629 | 459 | /* remove this if gtkimhtml ever supports any of these */ |
| 6513 | 460 | i = j; |
|
28038
44f90f5073e0
Stop using a GString when a gchar* will do fine
Mark Doliner <markdoliner@pidgin.im>
parents:
28037
diff
changeset
|
461 | g_free(tmp); |
| 6513 | 462 | break; |
| 463 | ||
|
28038
44f90f5073e0
Stop using a GString when a gchar* will do fine
Mark Doliner <markdoliner@pidgin.im>
parents:
28037
diff
changeset
|
464 | } else if (!strncmp(tmp, "<font ", 6)) { |
| 6629 | 465 | _font_tags_fix_size(tmp, s); |
| 6513 | 466 | } else { |
| 8375 | 467 | g_string_append(s, "<"); |
|
28038
44f90f5073e0
Stop using a GString when a gchar* will do fine
Mark Doliner <markdoliner@pidgin.im>
parents:
28037
diff
changeset
|
468 | g_free(tmp); |
| 6513 | 469 | break; |
| 470 | } | |
| 471 | ||
| 472 | i = j; | |
|
28038
44f90f5073e0
Stop using a GString when a gchar* will do fine
Mark Doliner <markdoliner@pidgin.im>
parents:
28037
diff
changeset
|
473 | g_free(tmp); |
| 6513 | 474 | break; |
| 475 | } | |
| 476 | ||
| 477 | } | |
| 478 | ||
| 479 | } else { | |
| 8375 | 480 | if (x[i] == '<') |
| 481 | g_string_append(s, "<"); | |
| 482 | else if (x[i] == '>') | |
| 483 | g_string_append(s, ">"); | |
| 8440 | 484 | else if (x[i] == '&') |
| 485 | g_string_append(s, "&"); | |
| 486 | else if (x[i] == '"') | |
| 487 | g_string_append(s, """); | |
| 8375 | 488 | else |
| 489 | g_string_append_c(s, x[i]); | |
| 6513 | 490 | } |
| 491 | } | |
| 492 | ||
| 28009 | 493 | purple_debug_misc("yahoo", "yahoo_codes_to_html: Returning string: '%s'.\n", s->str); |
| 494 | return g_string_free(s, FALSE); | |
| 6513 | 495 | } |
| 6629 | 496 | |
| 497 | /* borrowed from gtkimhtml */ | |
| 498 | #define MAX_FONT_SIZE 7 | |
|
10899
87d9aec5b72d
[gaim-migrate @ 12619]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
499 | #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
|
500 | static const gint _point_sizes [] = { 8, 10, 12, 14, 20, 30, 40 }; |
| 6629 | 501 | |
| 502 | enum fatype { size, color, face, junk }; | |
| 503 | typedef struct { | |
| 504 | enum fatype type; | |
| 505 | union { | |
| 506 | int size; | |
| 507 | char *color; | |
| 508 | char *face; | |
| 509 | char *junk; | |
| 510 | } u; | |
| 511 | } fontattr; | |
| 512 | ||
| 513 | static void fontattr_free(fontattr *f) | |
| 514 | { | |
| 515 | if (f->type == color) | |
| 516 | g_free(f->u.color); | |
| 517 | else if (f->type == face) | |
| 518 | g_free(f->u.face); | |
| 519 | g_free(f); | |
| 520 | } | |
| 521 | ||
| 522 | static void yahoo_htc_queue_cleanup(GQueue *q) | |
| 523 | { | |
| 524 | char *tmp; | |
| 525 | ||
| 526 | while ((tmp = g_queue_pop_tail(q))) | |
| 527 | g_free(tmp); | |
| 528 | g_queue_free(q); | |
| 529 | } | |
| 530 | ||
| 531 | static void _parse_font_tag(const char *src, GString *dest, int *i, int *j, | |
| 532 | int len, GQueue *colors, GQueue *tags, GQueue *ftattr) | |
| 533 | { | |
| 534 | ||
| 535 | int m, n, vstart; | |
| 536 | gboolean quote = 0, done = 0; | |
| 537 | ||
| 538 | m = *j; | |
| 539 | ||
| 540 | while (1) { | |
| 541 | m++; | |
| 542 | ||
| 543 | if (m >= len) { | |
| 544 | g_string_append(dest, &src[*i]); | |
| 545 | *i = len; | |
| 546 | break; | |
| 547 | } | |
| 548 | ||
| 549 | if (src[m] == '=') { | |
| 550 | n = vstart = m; | |
| 551 | while (1) { | |
| 552 | n++; | |
| 553 | ||
| 554 | if (n >= len) { | |
| 555 | m = n; | |
| 556 | break; | |
| 557 | } | |
| 558 | ||
|
6631
a2608d595a32
[gaim-migrate @ 7155]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6629
diff
changeset
|
559 | if (src[n] == '"') { |
| 6629 | 560 | if (!quote) { |
| 561 | quote = 1; | |
| 562 | vstart = n; | |
| 563 | continue; | |
| 564 | } else { | |
| 565 | done = 1; | |
| 566 | } | |
|
6631
a2608d595a32
[gaim-migrate @ 7155]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6629
diff
changeset
|
567 | } |
| 6629 | 568 | |
| 569 | if (!quote && ((src[n] == ' ') || (src[n] == '>'))) | |
| 570 | done = 1; | |
| 571 | ||
| 572 | if (done) { | |
| 573 | if (!g_ascii_strncasecmp(&src[*j+1], "FACE", m - *j - 1)) { | |
| 574 | fontattr *f; | |
| 575 | ||
| 576 | f = g_new(fontattr, 1); | |
| 577 | f->type = face; | |
| 578 | f->u.face = g_strndup(&src[vstart+1], n-vstart-1); | |
| 579 | if (!ftattr) | |
| 580 | ftattr = g_queue_new(); | |
| 581 | g_queue_push_tail(ftattr, f); | |
| 582 | m = n; | |
| 583 | break; | |
| 584 | } else if (!g_ascii_strncasecmp(&src[*j+1], "SIZE", m - *j - 1)) { | |
| 585 | fontattr *f; | |
| 586 | ||
| 587 | f = g_new(fontattr, 1); | |
| 588 | f->type = size; | |
| 589 | f->u.size = POINT_SIZE(strtol(&src[vstart+1], NULL, 10)); | |
| 590 | if (!ftattr) | |
| 591 | ftattr = g_queue_new(); | |
| 592 | g_queue_push_tail(ftattr, f); | |
| 593 | m = n; | |
| 594 | break; | |
| 595 | } else if (!g_ascii_strncasecmp(&src[*j+1], "COLOR", m - *j - 1)) { | |
| 596 | fontattr *f; | |
| 597 | ||
| 598 | f = g_new(fontattr, 1); | |
| 599 | f->type = color; | |
| 600 | f->u.color = g_strndup(&src[vstart+1], n-vstart-1); | |
| 601 | if (!ftattr) | |
| 602 | ftattr = g_queue_new(); | |
| 603 | g_queue_push_head(ftattr, f); | |
| 604 | m = n; | |
| 605 | break; | |
| 606 | } else { | |
| 607 | fontattr *f; | |
| 608 | ||
| 609 | f = g_new(fontattr, 1); | |
| 610 | f->type = junk; | |
| 611 | f->u.junk = g_strndup(&src[*j+1], n-*j); | |
| 612 | if (!ftattr) | |
| 613 | ftattr = g_queue_new(); | |
| 614 | g_queue_push_tail(ftattr, f); | |
| 615 | m = n; | |
| 616 | break; | |
| 617 | } | |
| 618 | ||
| 619 | } | |
| 620 | } | |
| 621 | } | |
| 622 | ||
| 623 | if (src[m] == ' ') | |
| 624 | *j = m; | |
| 625 | ||
| 626 | if (src[m] == '>') { | |
| 627 | gboolean needendtag = 0; | |
| 628 | fontattr *f; | |
| 629 | GString *tmp = g_string_new(NULL); | |
| 630 | char *colorstr; | |
| 631 | ||
| 632 | if (!g_queue_is_empty(ftattr)) { | |
| 633 | while ((f = g_queue_pop_tail(ftattr))) { | |
| 634 | switch (f->type) { | |
| 635 | case size: | |
| 636 | if (!needendtag) { | |
| 637 | needendtag = 1; | |
| 638 | g_string_append(dest, "<font "); | |
| 639 | } | |
| 640 | ||
| 641 | g_string_append_printf(dest, "size=\"%d\" ", f->u.size); | |
| 642 | fontattr_free(f); | |
| 643 | break; | |
| 644 | case face: | |
| 645 | if (!needendtag) { | |
| 646 | needendtag = 1; | |
| 647 | g_string_append(dest, "<font "); | |
| 648 | } | |
| 649 | ||
| 650 | g_string_append_printf(dest, "face=\"%s\" ", f->u.face); | |
| 651 | fontattr_free(f); | |
| 652 | break; | |
| 653 | case junk: | |
| 654 | if (!needendtag) { | |
| 655 | needendtag = 1; | |
| 656 | g_string_append(dest, "<font "); | |
| 657 | } | |
| 658 | ||
| 659 | g_string_append(dest, f->u.junk); | |
| 660 | fontattr_free(f); | |
| 661 | break; | |
| 662 | ||
| 663 | case color: | |
| 664 | if (needendtag) { | |
| 665 | g_string_append(tmp, "</font>"); | |
| 666 | dest->str[dest->len-1] = '>'; | |
| 667 | needendtag = 0; | |
| 668 | } | |
| 669 | ||
| 670 | colorstr = g_queue_peek_tail(colors); | |
| 671 | g_string_append(tmp, colorstr ? colorstr : "\033[#000000m"); | |
| 672 | g_string_append_printf(dest, "\033[%sm", f->u.color); | |
| 673 | g_queue_push_tail(colors, g_strdup_printf("\033[%sm", f->u.color)); | |
| 674 | fontattr_free(f); | |
| 675 | break; | |
| 676 | } | |
| 677 | } | |
| 678 | ||
| 679 | g_queue_free(ftattr); | |
| 680 | ftattr = NULL; | |
| 681 | ||
| 682 | if (needendtag) { | |
| 683 | dest->str[dest->len-1] = '>'; | |
| 684 | g_queue_push_tail(tags, g_strdup("</font>")); | |
| 685 | g_string_free(tmp, TRUE); | |
| 686 | } else { | |
| 687 | g_queue_push_tail(tags, tmp->str); | |
|
28011
f2c4d9b5e41f
Oh shit no it wasn't. I have no one to blame but fear itself.
Mark Doliner <markdoliner@pidgin.im>
parents:
28010
diff
changeset
|
688 | g_string_free(tmp, FALSE); |
| 6629 | 689 | } |
| 690 | } | |
| 691 | ||
| 692 | *i = *j = m; | |
| 693 | break; | |
| 694 | } | |
| 695 | } | |
| 696 | ||
| 697 | } | |
| 698 | ||
| 699 | char *yahoo_html_to_codes(const char *src) | |
| 700 | { | |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
701 | GQueue *colors, *tags; |
|
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
702 | size_t src_len; |
|
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
703 | int i, j; |
| 6629 | 704 | GString *dest; |
| 28009 | 705 | char *esc; |
| 6629 | 706 | GQueue *ftattr = NULL; |
| 8440 | 707 | gboolean no_more_specials = FALSE; |
| 6629 | 708 | |
| 709 | colors = g_queue_new(); | |
| 710 | tags = g_queue_new(); | |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
711 | src_len = strlen(src); |
|
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
712 | dest = g_string_sized_new(src_len); |
| 6629 | 713 | |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
714 | for (i = 0; i < src_len; i++) { |
| 6629 | 715 | |
| 8440 | 716 | if (!no_more_specials && src[i] == '<') { |
| 6629 | 717 | j = i; |
| 718 | ||
| 719 | while (1) { | |
| 720 | j++; | |
| 721 | ||
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
722 | if (j >= src_len) { /* no '>' */ |
| 8440 | 723 | g_string_append_c(dest, src[i]); |
| 724 | no_more_specials = TRUE; | |
| 6629 | 725 | break; |
| 726 | } | |
| 727 | ||
| 728 | if (src[j] == '<') { | |
| 8440 | 729 | /* FIXME: This doesn't convert outgoing entities. |
| 730 | * However, I suspect this case may never | |
| 731 | * happen anymore because of the entities. | |
| 732 | */ | |
| 6629 | 733 | g_string_append_len(dest, &src[i], j - i); |
| 734 | i = j - 1; | |
| 735 | if (ftattr) { | |
| 736 | fontattr *f; | |
| 737 | ||
| 738 | while ((f = g_queue_pop_head(ftattr))) | |
| 739 | fontattr_free(f); | |
| 740 | g_queue_free(ftattr); | |
| 741 | ftattr = NULL; | |
| 742 | } | |
| 743 | break; | |
| 744 | } | |
| 745 | ||
| 746 | if (src[j] == ' ') { | |
| 747 | if (!g_ascii_strncasecmp(&src[i+1], "BODY", j - i - 1)) { | |
| 748 | char *t = strchr(&src[j], '>'); | |
| 749 | if (!t) { | |
| 750 | g_string_append(dest, &src[i]); | |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
751 | i = src_len; |
| 6629 | 752 | break; |
| 753 | } else { | |
| 754 | i = t - src; | |
| 755 | break; | |
| 756 | } | |
| 8533 | 757 | } else if (!g_ascii_strncasecmp(&src[i+1], "A HREF=\"", j - i - 1)) { |
| 758 | j += 7; | |
| 759 | g_string_append(dest, "\033[lm"); | |
| 760 | while (1) { | |
| 761 | g_string_append_c(dest, src[j]); | |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
762 | if (++j >= src_len) { |
|
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
763 | i = src_len; |
| 8480 | 764 | break; |
| 765 | } | |
| 8533 | 766 | if (src[j] == '"') { |
| 767 | g_string_append(dest, "\033[xlm"); | |
| 768 | while (1) { | |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
769 | if (++j >= src_len) { |
|
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
770 | i = src_len; |
| 8533 | 771 | break; |
| 772 | } | |
| 773 | if (!g_ascii_strncasecmp(&src[j], "</A>", 4)) { | |
| 774 | j += 3; | |
| 775 | break; | |
| 776 | } | |
| 777 | } | |
| 778 | i = j; | |
| 8480 | 779 | break; |
| 780 | } | |
| 781 | } | |
|
16169
4aa4ec9afa9c
Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
782 | } else if (!g_ascii_strncasecmp(&src[i+1], "SPAN", j - i - 1)) { /* drop span tags */ |
|
4aa4ec9afa9c
Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
783 | while (1) { |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
784 | if (++j >= src_len) { |
|
16169
4aa4ec9afa9c
Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
785 | g_string_append(dest, &src[i]); |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
786 | i = src_len; |
|
16169
4aa4ec9afa9c
Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
787 | break; |
|
4aa4ec9afa9c
Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
788 | } |
|
4aa4ec9afa9c
Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
789 | if (src[j] == '>') { |
|
4aa4ec9afa9c
Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
790 | i = j; |
|
4aa4ec9afa9c
Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
791 | break; |
|
4aa4ec9afa9c
Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
792 | } |
|
4aa4ec9afa9c
Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
793 | } |
| 6629 | 794 | } else if (g_ascii_strncasecmp(&src[i+1], "FONT", j - i - 1)) { /* not interested! */ |
| 795 | while (1) { | |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
796 | if (++j >= src_len) { |
| 6629 | 797 | g_string_append(dest, &src[i]); |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
798 | i = src_len; |
| 6629 | 799 | break; |
| 800 | } | |
| 801 | if (src[j] == '>') { | |
| 802 | g_string_append_len(dest, &src[i], j - i + 1); | |
| 803 | i = j; | |
| 804 | break; | |
| 805 | } | |
| 806 | } | |
| 807 | } else { /* yay we have a font tag */ | |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
808 | _parse_font_tag(src, dest, &i, &j, src_len, colors, tags, ftattr); |
| 6629 | 809 | } |
| 810 | ||
| 811 | break; | |
| 812 | } | |
| 813 | ||
| 814 | if (src[j] == '>') { | |
| 8440 | 815 | /* This has some problems like the FIXME for the |
| 816 | * '<' case. and like that case, I suspect the case | |
| 817 | * that this has problems is won't happen anymore anyway. | |
| 818 | */ | |
| 6629 | 819 | int sublen = j - i - 1; |
| 820 | ||
| 821 | if (sublen) { | |
| 822 | if (!g_ascii_strncasecmp(&src[i+1], "B", sublen)) { | |
| 823 | g_string_append(dest, "\033[1m"); | |
| 824 | } else if (!g_ascii_strncasecmp(&src[i+1], "/B", sublen)) { | |
| 825 | g_string_append(dest, "\033[x1m"); | |
| 826 | } else if (!g_ascii_strncasecmp(&src[i+1], "I", sublen)) { | |
| 827 | g_string_append(dest, "\033[2m"); | |
| 828 | } else if (!g_ascii_strncasecmp(&src[i+1], "/I", sublen)) { | |
| 829 | g_string_append(dest, "\033[x2m"); | |
| 830 | } else if (!g_ascii_strncasecmp(&src[i+1], "U", sublen)) { | |
| 831 | g_string_append(dest, "\033[4m"); | |
| 832 | } else if (!g_ascii_strncasecmp(&src[i+1], "/U", sublen)) { | |
| 833 | g_string_append(dest, "\033[x4m"); | |
| 8480 | 834 | } else if (!g_ascii_strncasecmp(&src[i+1], "/A", sublen)) { |
| 835 | g_string_append(dest, "\033[xlm"); | |
| 8455 | 836 | } else if (!g_ascii_strncasecmp(&src[i+1], "BR", sublen)) { |
| 837 | g_string_append_c(dest, '\n'); | |
| 6629 | 838 | } else if (!g_ascii_strncasecmp(&src[i+1], "/BODY", sublen)) { |
| 839 | /* mmm, </body> tags. *BURP* */ | |
|
16169
4aa4ec9afa9c
Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
840 | } else if (!g_ascii_strncasecmp(&src[i+1], "/SPAN", sublen)) { |
|
4aa4ec9afa9c
Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
841 | /* </span> tags. dangerously close to </spam> */ |
| 6629 | 842 | } else if (!g_ascii_strncasecmp(&src[i+1], "/FONT", sublen) && g_queue_peek_tail(tags)) { |
| 843 | char *etag, *cl; | |
| 844 | ||
| 845 | etag = g_queue_pop_tail(tags); | |
| 846 | if (etag) { | |
| 847 | g_string_append(dest, etag); | |
| 848 | if (!strcmp(etag, "</font>")) { | |
| 849 | cl = g_queue_pop_tail(colors); | |
| 850 | if (cl) | |
| 851 | g_free(cl); | |
| 852 | } | |
| 853 | g_free(etag); | |
| 854 | } | |
| 855 | } else { | |
| 856 | g_string_append_len(dest, &src[i], j - i + 1); | |
| 857 | } | |
| 858 | } else { | |
| 859 | g_string_append_len(dest, &src[i], j - i + 1); | |
| 860 | } | |
| 861 | ||
| 862 | i = j; | |
| 863 | break; | |
| 864 | } | |
| 865 | ||
| 866 | } | |
| 867 | ||
| 868 | } else { | |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
869 | if (((src_len - i) >= 4) && !strncmp(&src[i], "<", 4)) { |
| 8440 | 870 | g_string_append_c(dest, '<'); |
| 871 | i += 3; | |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
872 | } else if (((src_len - i) >= 4) && !strncmp(&src[i], ">", 4)) { |
| 8440 | 873 | g_string_append_c(dest, '>'); |
| 874 | i += 3; | |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
875 | } else if (((src_len - i) >= 5) && !strncmp(&src[i], "&", 5)) { |
| 8440 | 876 | g_string_append_c(dest, '&'); |
| 877 | i += 4; | |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
878 | } else if (((src_len - i) >= 6) && !strncmp(&src[i], """, 6)) { |
| 8440 | 879 | g_string_append_c(dest, '"'); |
| 880 | i += 5; | |
|
28036
b9c7f979cd4f
Minor optimization when sending and receiving messages on Yahoo: only
Mark Doliner <markdoliner@pidgin.im>
parents:
28035
diff
changeset
|
881 | } else if (((src_len - i) >= 6) && !strncmp(&src[i], "'", 6)) { |
|
21946
f444fc9e2d18
Make yahoo_html_to_codes deal with ' in messages being sent. Also correct
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
882 | g_string_append_c(dest, '\''); |
|
f444fc9e2d18
Make yahoo_html_to_codes deal with ' in messages being sent. Also correct
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
883 | i += 5; |
| 8440 | 884 | } else { |
| 885 | g_string_append_c(dest, src[i]); | |
| 886 | } | |
| 6629 | 887 | } |
| 888 | } | |
| 889 | ||
| 28009 | 890 | esc = g_strescape(dest->str, NULL); |
|
27547
c136491361eb
Convert the yahoo prpl to using the debug convenience functions instead of
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
27361
diff
changeset
|
891 | purple_debug_misc("yahoo", "yahoo_html_to_codes: Returning string: '%s'.\n", esc); |
| 6629 | 892 | g_free(esc); |
| 893 | ||
| 894 | yahoo_htc_queue_cleanup(colors); | |
| 895 | yahoo_htc_queue_cleanup(tags); | |
| 896 | ||
| 28009 | 897 | return g_string_free(dest, FALSE); |
| 6629 | 898 | } |