annotate libpurple/protocols/yahoo/util.c @ 25913:2209f3440538

*** Plucked rev cdbf018a5ef98397e81d541269550d9c6fded457 (sulabh@soc.pidgin.im): Set yahoo to connected after processing the buddy list, should help get rid of the bug reported by the adium user *** Plucked rev 3952ed728efd23f39d502201b828c86acf6dffd2 (sulabh@soc.pidgin.im): yahoo login ver 16: Add another case of error reporting. Ask user to visit yahoo website in case of locked account.
author John Bailey <rekkanoryo@rekkanoryo.org>
date Fri, 19 Jun 2009 21:10:02 +0000
parents 721e64d1ddfd
children 01f1929d0936
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
2 * purple
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 * Some code copyright 2003 Tim Ringenbach <omarvo@hotmail.com>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 * (marv on irc.freenode.net)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
19680
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19197
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 #include "config.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26
25910
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
27 #include "cipher.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "debug.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "internal.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "prpl.h"
25910
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
31 #include "util.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include "yahoo.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 #include <string.h>
23916
18a1f0fe5f40 Do a better job of detecting if the yahoo account is connecting through a HTTP
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23033
diff changeset
36
25910
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
37 struct _PurpleUtilFetchUrlData
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
38 {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
39 PurpleUtilFetchUrlCallback callback;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
40 void *user_data;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
41
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
42 struct
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
43 {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
44 char *user;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
45 char *passwd;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
46 char *address;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
47 int port;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
48 char *page;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
49
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
50 } website;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
51
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
52 char *url;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
53 int num_times_redirected;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
54 gboolean full;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
55 char *user_agent;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
56 gboolean http11;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
57 char *request;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
58 gsize request_written;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
59 gboolean include_headers;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
60
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
61 gboolean is_ssl;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
62 PurpleSslConnection *ssl_connection;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
63 PurpleProxyConnectData *connect_data;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
64 int fd;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
65 guint inpa;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
66
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
67 gboolean got_headers;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
68 gboolean has_explicit_data_len;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
69 char *webdata;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
70 unsigned long len;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
71 unsigned long data_len;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
72 gssize max_len;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
73 };
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
74
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
75 /**
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
76 * The arguments to this function are similar to printf.
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
77 */
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
78 static void
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
79 purple_util_fetch_url_error(PurpleUtilFetchUrlData *gfud, const char *format, ...)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
80 {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
81 gchar *error_message;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
82 va_list args;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
83
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
84 va_start(args, format);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
85 error_message = g_strdup_vprintf(format, args);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
86 va_end(args);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
87
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
88 gfud->callback(gfud, gfud->user_data, NULL, 0, error_message);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
89 g_free(error_message);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
90 purple_util_fetch_url_cancel(gfud);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
91 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
92 static void url_fetch_connect_cb(gpointer url_data, gint source, const gchar *error_message);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
93 static void ssl_url_fetch_connect_cb(gpointer data, PurpleSslConnection *ssl_connection, PurpleInputCondition cond);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
94 static void ssl_url_fetch_error_cb(PurpleSslConnection *ssl_connection, PurpleSslErrorType error, gpointer data);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
95
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
96 static gboolean
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
97 parse_redirect(const char *data, size_t data_len,
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
98 PurpleUtilFetchUrlData *gfud)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
99 {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
100 gchar *s;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
101 gchar *new_url, *temp_url, *end;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
102 gboolean full;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
103 int len;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
104
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
105 if ((s = g_strstr_len(data, data_len, "\nLocation: ")) == NULL)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
106 /* We're not being redirected */
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
107 return FALSE;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
108
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
109 s += strlen("Location: ");
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
110 end = strchr(s, '\r');
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
111
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
112 /* Just in case :) */
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
113 if (end == NULL)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
114 end = strchr(s, '\n');
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
115
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
116 if (end == NULL)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
117 return FALSE;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
118
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
119 len = end - s;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
120
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
121 new_url = g_malloc(len + 1);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
122 strncpy(new_url, s, len);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
123 new_url[len] = '\0';
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
124
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
125 full = gfud->full;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
126
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
127 if (*new_url == '/' || g_strstr_len(new_url, len, "://") == NULL)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
128 {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
129 temp_url = new_url;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
130
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
131 new_url = g_strdup_printf("%s:%d%s", gfud->website.address,
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
132 gfud->website.port, temp_url);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
133
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
134 g_free(temp_url);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
135
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
136 full = FALSE;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
137 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
138
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
139 purple_debug_info("util", "Redirecting to %s\n", new_url);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
140
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
141 gfud->num_times_redirected++;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
142 if (gfud->num_times_redirected >= 5)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
143 {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
144 purple_util_fetch_url_error(gfud,
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
145 _("Could not open %s: Redirected too many times"),
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
146 gfud->url);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
147 return TRUE;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
148 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
149
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
150 /*
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
151 * Try again, with this new location. This code is somewhat
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
152 * ugly, but we need to reuse the gfud because whoever called
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
153 * us is holding a reference to it.
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
154 */
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
155 g_free(gfud->url);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
156 gfud->url = new_url;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
157 gfud->full = full;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
158 g_free(gfud->request);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
159 gfud->request = NULL;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
160
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
161 if (gfud->is_ssl) {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
162 gfud->is_ssl = FALSE;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
163 purple_ssl_close(gfud->ssl_connection);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
164 gfud->ssl_connection = NULL;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
165 } else {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
166 purple_input_remove(gfud->inpa);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
167 gfud->inpa = 0;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
168 close(gfud->fd);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
169 gfud->fd = -1;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
170 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
171 gfud->request_written = 0;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
172 gfud->len = 0;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
173 gfud->data_len = 0;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
174
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
175 g_free(gfud->website.user);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
176 g_free(gfud->website.passwd);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
177 g_free(gfud->website.address);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
178 g_free(gfud->website.page);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
179 purple_url_parse(new_url, &gfud->website.address, &gfud->website.port,
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
180 &gfud->website.page, &gfud->website.user, &gfud->website.passwd);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
181
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
182 if (purple_strcasestr(new_url, "https://") != NULL) {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
183 gfud->is_ssl = TRUE;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
184 gfud->ssl_connection = purple_ssl_connect(NULL,
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
185 gfud->website.address, gfud->website.port,
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
186 ssl_url_fetch_connect_cb, ssl_url_fetch_error_cb, gfud);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
187 } else {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
188 gfud->connect_data = purple_proxy_connect(NULL, NULL,
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
189 gfud->website.address, gfud->website.port,
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
190 url_fetch_connect_cb, gfud);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
191 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
192
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
193 if (gfud->ssl_connection == NULL && gfud->connect_data == NULL)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
194 {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
195 purple_util_fetch_url_error(gfud, _("Unable to connect to %s"),
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
196 gfud->website.address);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
197 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
198
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
199 return TRUE;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
200 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
201
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
202 static size_t
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
203 parse_content_len(const char *data, size_t data_len)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
204 {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
205 size_t content_len = 0;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
206 const char *p = NULL;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
207
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
208 /* This is still technically wrong, since headers are case-insensitive
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
209 * [RFC 2616, section 4.2], though this ought to catch the normal case.
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
210 * Note: data is _not_ nul-terminated.
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
211 */
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
212 if(data_len > 16) {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
213 p = (strncmp(data, "Content-Length: ", 16) == 0) ? data : NULL;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
214 if(!p)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
215 p = (strncmp(data, "CONTENT-LENGTH: ", 16) == 0)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
216 ? data : NULL;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
217 if(!p) {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
218 p = g_strstr_len(data, data_len, "\nContent-Length: ");
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
219 if (p)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
220 p++;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
221 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
222 if(!p) {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
223 p = g_strstr_len(data, data_len, "\nCONTENT-LENGTH: ");
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
224 if (p)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
225 p++;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
226 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
227
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
228 if(p)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
229 p += 16;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
230 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
231
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
232 /* If we can find a Content-Length header at all, try to sscanf it.
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
233 * Response headers should end with at least \r\n, so sscanf is safe,
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
234 * if we make sure that there is indeed a \n in our header.
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
235 */
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
236 if (p && g_strstr_len(p, data_len - (p - data), "\n")) {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
237 sscanf(p, "%" G_GSIZE_FORMAT, &content_len);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
238 purple_debug_misc("util", "parsed %" G_GSIZE_FORMAT "\n", content_len);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
239 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
240
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
241 return content_len;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
242 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
243
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
244
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
245 static void
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
246 url_fetch_recv_cb(gpointer url_data, gint source, PurpleInputCondition cond)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
247 {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
248 PurpleUtilFetchUrlData *gfud = url_data;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
249 int len;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
250 char buf[4096];
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
251 char *data_cursor;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
252 gboolean got_eof = FALSE;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
253
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
254 /*
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
255 * Read data in a loop until we can't read any more! This is a
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
256 * little confusing because we read using a different function
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
257 * depending on whether the socket is ssl or cleartext.
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
258 */
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
259 while ((gfud->is_ssl && ((len = purple_ssl_read(gfud->ssl_connection, buf, sizeof(buf))) > 0)) ||
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
260 (!gfud->is_ssl && (len = read(source, buf, sizeof(buf))) > 0))
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
261 {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
262 if(gfud->max_len != -1 && (gfud->len + len) > gfud->max_len) {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
263 purple_util_fetch_url_error(gfud, _("Error reading from %s: response too long (%d bytes limit)"),
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
264 gfud->website.address, gfud->max_len);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
265 return;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
266 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
267
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
268 /* If we've filled up our buffer, make it bigger */
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
269 if((gfud->len + len) >= gfud->data_len) {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
270 while((gfud->len + len) >= gfud->data_len)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
271 gfud->data_len += sizeof(buf);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
272
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
273 gfud->webdata = g_realloc(gfud->webdata, gfud->data_len);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
274 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
275
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
276 data_cursor = gfud->webdata + gfud->len;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
277
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
278 gfud->len += len;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
279
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
280 memcpy(data_cursor, buf, len);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
281
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
282 gfud->webdata[gfud->len] = '\0';
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
283
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
284 if(!gfud->got_headers) {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
285 char *tmp;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
286
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
287 /* See if we've reached the end of the headers yet */
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
288 if((tmp = strstr(gfud->webdata, "\r\n\r\n"))) {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
289 char * new_data;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
290 guint header_len = (tmp + 4 - gfud->webdata);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
291 size_t content_len;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
292
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
293 purple_debug_misc("util", "Response headers: '%.*s'\n",
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
294 header_len, gfud->webdata);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
295
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
296 /* See if we can find a redirect. */
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
297 if(parse_redirect(gfud->webdata, header_len, gfud))
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
298 return;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
299
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
300 gfud->got_headers = TRUE;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
301
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
302 /* No redirect. See if we can find a content length. */
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
303 content_len = parse_content_len(gfud->webdata, header_len);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
304
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
305 if(content_len == 0) {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
306 /* We'll stick with an initial 8192 */
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
307 content_len = 8192;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
308 } else {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
309 gfud->has_explicit_data_len = TRUE;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
310 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
311
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
312
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
313 /* If we're returning the headers too, we don't need to clean them out */
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
314 if(gfud->include_headers) {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
315 gfud->data_len = content_len + header_len;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
316 gfud->webdata = g_realloc(gfud->webdata, gfud->data_len);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
317 } else {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
318 size_t body_len = 0;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
319
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
320 if(gfud->len > (header_len + 1))
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
321 body_len = (gfud->len - header_len);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
322
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
323 content_len = MAX(content_len, body_len);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
324
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
325 new_data = g_try_malloc(content_len);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
326 if(new_data == NULL) {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
327 purple_debug_error("util",
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
328 "Failed to allocate %" G_GSIZE_FORMAT " bytes: %s\n",
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
329 content_len, g_strerror(errno));
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
330 purple_util_fetch_url_error(gfud,
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
331 _("Unable to allocate enough memory to hold "
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
332 "the contents from %s. The web server may "
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
333 "be trying something malicious."),
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
334 gfud->website.address);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
335
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
336 return;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
337 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
338
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
339 /* We may have read part of the body when reading the headers, don't lose it */
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
340 if(body_len > 0) {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
341 tmp += 4;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
342 memcpy(new_data, tmp, body_len);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
343 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
344
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
345 /* Out with the old... */
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
346 g_free(gfud->webdata);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
347
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
348 /* In with the new. */
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
349 gfud->len = body_len;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
350 gfud->data_len = content_len;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
351 gfud->webdata = new_data;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
352 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
353 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
354 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
355
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
356 if(gfud->has_explicit_data_len && gfud->len >= gfud->data_len) {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
357 got_eof = TRUE;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
358 break;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
359 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
360 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
361
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
362 if(len < 0) {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
363 if(errno == EAGAIN) {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
364 return;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
365 } else {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
366 purple_util_fetch_url_error(gfud, _("Error reading from %s: %s"),
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
367 gfud->website.address, g_strerror(errno));
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
368 return;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
369 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
370 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
371
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
372 if((len == 0) || got_eof) {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
373 gfud->webdata = g_realloc(gfud->webdata, gfud->len + 1);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
374 gfud->webdata[gfud->len] = '\0';
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
375
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
376 gfud->callback(gfud, gfud->user_data, gfud->webdata, gfud->len, NULL);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
377 purple_util_fetch_url_cancel(gfud);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
378 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
379 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
380
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
381 static void ssl_url_fetch_recv_cb(gpointer data, PurpleSslConnection *ssl_connection, PurpleInputCondition cond)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
382 {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
383 url_fetch_recv_cb(data, -1, cond);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
384 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
385
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
386 /*
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
387 * This function is called when the socket is available to be written
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
388 * to.
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
389 *
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
390 * @param source The file descriptor that can be written to. This can
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
391 * be an http connection or it can be the SSL connection of an
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
392 * https request. So be careful what you use it for! If it's
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
393 * an https request then use purple_ssl_write() instead of
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
394 * writing to it directly.
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
395 */
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
396 static void
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
397 url_fetch_send_cb(gpointer data, gint source, PurpleInputCondition cond)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
398 {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
399 PurpleUtilFetchUrlData *gfud;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
400 int len, total_len;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
401
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
402 gfud = data;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
403
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
404 if (gfud->request == NULL)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
405 {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
406 /* Host header is not forbidden in HTTP/1.0 requests, and HTTP/1.1
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
407 * clients must know how to handle the "chunked" transfer encoding.
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
408 * Purple doesn't know how to handle "chunked", so should always send
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
409 * the Host header regardless, to get around some observed problems
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
410 */
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
411 if (gfud->user_agent) {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
412 gfud->request = g_strdup_printf(
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
413 "GET %s%s HTTP/%s\r\n"
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
414 "Connection: close\r\n"
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
415 "User-Agent: %s\r\n"
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
416 "Accept: */*\r\n"
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
417 "Host: %s\r\n\r\n",
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
418 (gfud->full ? "" : "/"),
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
419 (gfud->full ? (gfud->url ? gfud->url : "") : (gfud->website.page ? gfud->website.page : "")),
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
420 (gfud->http11 ? "1.1" : "1.0"),
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
421 (gfud->user_agent ? gfud->user_agent : ""),
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
422 (gfud->website.address ? gfud->website.address : ""));
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
423 } else {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
424 gfud->request = g_strdup_printf(
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
425 "GET %s%s HTTP/%s\r\n"
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
426 "Connection: close\r\n"
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
427 "Accept: */*\r\n"
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
428 "Host: %s\r\n\r\n",
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
429 (gfud->full ? "" : "/"),
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
430 (gfud->full ? (gfud->url ? gfud->url : "") : (gfud->website.page ? gfud->website.page : "")),
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
431 (gfud->http11 ? "1.1" : "1.0"),
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
432 (gfud->website.address ? gfud->website.address : ""));
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
433 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
434 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
435
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
436 if(g_getenv("PURPLE_UNSAFE_DEBUG"))
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
437 purple_debug_misc("util", "Request: '%s'\n", gfud->request);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
438 else
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
439 purple_debug_misc("util", "request constructed\n");
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
440
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
441 total_len = strlen(gfud->request);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
442
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
443 if (gfud->is_ssl)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
444 len = purple_ssl_write(gfud->ssl_connection, gfud->request + gfud->request_written,
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
445 total_len - gfud->request_written);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
446 else
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
447 len = write(gfud->fd, gfud->request + gfud->request_written,
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
448 total_len - gfud->request_written);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
449
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
450 if (len < 0 && errno == EAGAIN)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
451 return;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
452 else if (len < 0) {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
453 purple_util_fetch_url_error(gfud, _("Error writing to %s: %s"),
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
454 gfud->website.address, g_strerror(errno));
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
455 return;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
456 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
457 gfud->request_written += len;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
458
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
459 if (gfud->request_written < total_len)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
460 return;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
461
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
462 /* We're done writing our request, now start reading the response */
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
463 if (gfud->is_ssl) {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
464 purple_input_remove(gfud->inpa);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
465 gfud->inpa = 0;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
466 purple_ssl_input_add(gfud->ssl_connection, ssl_url_fetch_recv_cb, gfud);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
467 } else {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
468 purple_input_remove(gfud->inpa);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
469 gfud->inpa = purple_input_add(gfud->fd, PURPLE_INPUT_READ, url_fetch_recv_cb,
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
470 gfud);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
471 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
472 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
473
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
474 static void
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
475 url_fetch_connect_cb(gpointer url_data, gint source, const gchar *error_message)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
476 {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
477 PurpleUtilFetchUrlData *gfud;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
478
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
479 gfud = url_data;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
480 gfud->connect_data = NULL;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
481
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
482 if (source == -1)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
483 {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
484 purple_util_fetch_url_error(gfud, _("Unable to connect to %s: %s"),
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
485 (gfud->website.address ? gfud->website.address : ""), error_message);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
486 return;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
487 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
488
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
489 gfud->fd = source;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
490
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
491 gfud->inpa = purple_input_add(source, PURPLE_INPUT_WRITE,
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
492 url_fetch_send_cb, gfud);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
493 url_fetch_send_cb(gfud, source, PURPLE_INPUT_WRITE);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
494 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
495
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
496 static void ssl_url_fetch_connect_cb(gpointer data, PurpleSslConnection *ssl_connection, PurpleInputCondition cond)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
497 {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
498 PurpleUtilFetchUrlData *gfud;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
499
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
500 gfud = data;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
501
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
502 gfud->inpa = purple_input_add(ssl_connection->fd, PURPLE_INPUT_WRITE,
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
503 url_fetch_send_cb, gfud);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
504 url_fetch_send_cb(gfud, ssl_connection->fd, PURPLE_INPUT_WRITE);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
505 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
506
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
507 static void ssl_url_fetch_error_cb(PurpleSslConnection *ssl_connection, PurpleSslErrorType error, gpointer data)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
508 {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
509 PurpleUtilFetchUrlData *gfud;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
510
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
511 gfud = data;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
512 gfud->ssl_connection = NULL;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
513
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
514 purple_util_fetch_url_error(gfud, _("Unable to connect to %s: %s"),
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
515 (gfud->website.address ? gfud->website.address : ""),
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
516 purple_ssl_strerror(error));
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
517 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
518
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
519 PurpleUtilFetchUrlData *
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
520 purple_util_fetch_url_request_len_with_account(PurpleAccount *account,
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
521 const char *url, gboolean full, const char *user_agent, gboolean http11,
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
522 const char *request, gboolean include_headers, gssize max_len,
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
523 PurpleUtilFetchUrlCallback callback, void *user_data)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
524 {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
525 PurpleUtilFetchUrlData *gfud;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
526
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
527 g_return_val_if_fail(url != NULL, NULL);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
528 g_return_val_if_fail(callback != NULL, NULL);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
529
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
530 if(g_getenv("PURPLE_UNSAFE_DEBUG"))
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
531 purple_debug_info("util",
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
532 "requested to fetch (%s), full=%d, user_agent=(%s), http11=%d\n",
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
533 url, full, user_agent?user_agent:"(null)", http11);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
534 else
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
535 purple_debug_info("util", "requesting to fetch a URL\n");
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
536
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
537 gfud = g_new0(PurpleUtilFetchUrlData, 1);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
538
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
539 gfud->callback = callback;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
540 gfud->user_data = user_data;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
541 gfud->url = g_strdup(url);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
542 gfud->user_agent = g_strdup(user_agent);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
543 gfud->http11 = http11;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
544 gfud->full = full;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
545 gfud->request = g_strdup(request);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
546 gfud->include_headers = include_headers;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
547 gfud->fd = -1;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
548 gfud->max_len = max_len;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
549
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
550 purple_url_parse(url, &gfud->website.address, &gfud->website.port,
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
551 &gfud->website.page, &gfud->website.user, &gfud->website.passwd);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
552
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
553 if (purple_strcasestr(url, "https://") != NULL) {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
554 if (!purple_ssl_is_supported()) {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
555 purple_util_fetch_url_error(gfud,
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
556 _("Unable to connect to %s: Server requires TLS/SSL, but no TLS/SSL support was found."),
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
557 gfud->website.address);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
558 return NULL;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
559 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
560
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
561 gfud->is_ssl = TRUE;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
562 gfud->ssl_connection = purple_ssl_connect(account,
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
563 gfud->website.address, gfud->website.port,
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
564 ssl_url_fetch_connect_cb, ssl_url_fetch_error_cb, gfud);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
565 } else {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
566 gfud->connect_data = purple_proxy_connect(NULL, account,
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
567 gfud->website.address, gfud->website.port,
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
568 url_fetch_connect_cb, gfud);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
569 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
570
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
571 if (gfud->ssl_connection == NULL && gfud->connect_data == NULL)
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
572 {
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
573 purple_util_fetch_url_error(gfud, _("Unable to connect to %s"),
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
574 gfud->website.address);
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
575 return NULL;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
576 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
577
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
578 return gfud;
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
579 }
721e64d1ddfd Ugly hack to get around needing a minor bump to make this authentication code
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 23916
diff changeset
580
23916
18a1f0fe5f40 Do a better job of detecting if the yahoo account is connecting through a HTTP
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23033
diff changeset
581 gboolean
18a1f0fe5f40 Do a better job of detecting if the yahoo account is connecting through a HTTP
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23033
diff changeset
582 yahoo_account_use_http_proxy(PurpleConnection *conn)
18a1f0fe5f40 Do a better job of detecting if the yahoo account is connecting through a HTTP
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23033
diff changeset
583 {
18a1f0fe5f40 Do a better job of detecting if the yahoo account is connecting through a HTTP
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23033
diff changeset
584 PurpleProxyInfo *ppi = purple_proxy_get_setup(conn->account);
18a1f0fe5f40 Do a better job of detecting if the yahoo account is connecting through a HTTP
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23033
diff changeset
585 return (ppi->type == PURPLE_PROXY_HTTP || ppi->type == PURPLE_PROXY_USE_ENVVAR);
18a1f0fe5f40 Do a better job of detecting if the yahoo account is connecting through a HTTP
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23033
diff changeset
586 }
18a1f0fe5f40 Do a better job of detecting if the yahoo account is connecting through a HTTP
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23033
diff changeset
587
22018
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
588 /*
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
589 * Returns cookies formatted as a null terminated string for the given connection.
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
590 * Must g_free return value.
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
591 *
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
592 * TODO:will work, but must test for strict correctness
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
593 */
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
594 gchar* yahoo_get_cookies(PurpleConnection *gc)
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
595 {
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
596 gchar *ans = NULL;
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
597 gchar *cur;
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
598 char firstflag = 1;
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
599 gchar *t1,*t2,*t3;
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
600 GSList *tmp;
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
601 GSList *cookies;
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
602 cookies = ((struct yahoo_data*)(gc->proto_data))->cookies;
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
603 tmp = cookies;
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
604 while(tmp)
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
605 {
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
606 cur = tmp->data;
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
607 t1 = ans;
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
608 t2 = g_strrstr(cur, ";expires=");
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
609 if(t2 == NULL)
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
610 t2 = g_strrstr(cur, "; expires=");
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
611 if(t2 == NULL)
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
612 {
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
613 if(firstflag)
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
614 ans = g_strdup_printf("%c=%s", cur[0], cur+2);
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
615 else
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
616 ans = g_strdup_printf("%s; %c=%s", t1, cur[0], cur+2);
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
617 }
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
618 else
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
619 {
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
620 t3 = strstr(t2+1, ";");
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
621 if(t3 != NULL)
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
622 {
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
623 t2[0] = '\0';
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
624
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
625 if(firstflag)
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
626 ans = g_strdup_printf("%c=%s%s", cur[0], cur+2, t3);
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
627 else
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
628 ans = g_strdup_printf("%s; %c=%s%s", t1, cur[0], cur+2, t3);
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
629
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
630 t2[0] = ';';
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
631 }
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
632 else
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
633 {
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
634 t2[0] = '\0';
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
635
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
636 if(firstflag)
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
637 ans = g_strdup_printf("%c=%s", cur[0], cur+2);
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
638 else
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
639 ans = g_strdup_printf("%s; %c=%s", t1, cur[0], cur+2);
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
640
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
641 t2[0] = ';';
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
642 }
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
643 }
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
644 if(firstflag)
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
645 firstflag = 0;
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
646 else
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
647 g_free(t1);
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
648 tmp = g_slist_next(tmp);
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
649 }
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
650 return ans;
118046227581 This patch from Thanumalayan S. implements Yahoo protocol version 15 file
Thanumalayan <madthanu@gmail.com>
parents: 21831
diff changeset
651 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
652
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
653 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
654 * Encode some text to send to the yahoo server.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
655 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
656 * @param gc The connection handle.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
657 * @param str The null terminated utf8 string to encode.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
658 * @param utf8 If not @c NULL, whether utf8 is okay or not.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
659 * Even if it is okay, we may not use it. If we
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
660 * used it, we set this to @c TRUE, else to
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
661 * @c FALSE. If @c NULL, false is assumed, and
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
662 * it is not dereferenced.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
663 * @return The g_malloced string in the appropriate encoding.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
664 */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
665 char *yahoo_string_encode(PurpleConnection *gc, const char *str, gboolean *utf8)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
666 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
667 struct yahoo_data *yd = gc->proto_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
668 char *ret;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
669 const char *to_codeset;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
670
23033
bf7ce9629402 applied changes from a5e7a62db1d43009f4ff463b7fe67ff3a7275a78
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22155
diff changeset
671 if (yd->jp)
bf7ce9629402 applied changes from a5e7a62db1d43009f4ff463b7fe67ff3a7275a78
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22155
diff changeset
672 return g_strdup(str);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
673
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
674 if (utf8 && *utf8) /* FIXME: maybe don't use utf8 if it'll fit in latin1 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
675 return g_strdup(str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
676
23033
bf7ce9629402 applied changes from a5e7a62db1d43009f4ff463b7fe67ff3a7275a78
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22155
diff changeset
677 to_codeset = purple_account_get_string(purple_connection_get_account(gc), "local_charset", "ISO-8859-1");
bf7ce9629402 applied changes from a5e7a62db1d43009f4ff463b7fe67ff3a7275a78
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22155
diff changeset
678 ret = g_convert_with_fallback(str, -1, to_codeset, "UTF-8", "?", NULL, NULL, NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
679
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
680 if (ret)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
681 return ret;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
682 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
683 return g_strdup("");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
684 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
685
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
686 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
687 * Decode some text received from the server.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
688 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
689 * @param gc The gc handle.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
690 * @param str The null terminated string to decode.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
691 * @param utf8 Did the server tell us it was supposed to be utf8?
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
692 * @return The decoded, utf-8 string, which must be g_free()'d.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
693 */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
694 char *yahoo_string_decode(PurpleConnection *gc, const char *str, gboolean utf8)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
695 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
696 struct yahoo_data *yd = gc->proto_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
697 char *ret;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
698 const char *from_codeset;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
699
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
700 if (utf8) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
701 if (g_utf8_validate(str, -1, NULL))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
702 return g_strdup(str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
703 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
704
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
705 if (yd->jp)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
706 from_codeset = "SHIFT_JIS";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
707 else
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
708 from_codeset = purple_account_get_string(purple_connection_get_account(gc), "local_charset", "ISO-8859-1");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
709
19197
47942d19f301 Use -1 as length with g_convert() functions instead of strlen()
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16109
diff changeset
710 ret = g_convert_with_fallback(str, -1, "UTF-8", from_codeset, NULL, NULL, NULL, NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
711
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
712 if (ret)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
713 return ret;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
714 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
715 return g_strdup("");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
716 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
717
22123
840e7e1b6dac disapproval of revision '947ccb889812585e6d53eac13fc12734d8481e33'
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22121
diff changeset
718 char *yahoo_convert_to_numeric(const char *str)
840e7e1b6dac disapproval of revision '947ccb889812585e6d53eac13fc12734d8481e33'
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22121
diff changeset
719 {
22134
33abfb98a460 Since I needed to bring back yahoo_convert_to_numeric, I figured I could at
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22123
diff changeset
720 GString *gstr = NULL;
33abfb98a460 Since I needed to bring back yahoo_convert_to_numeric, I figured I could at
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22123
diff changeset
721 char *retstr;
22155
a886e43210b1 Fix (hopefully) the last problem in this function. Refs #3295.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22134
diff changeset
722 const unsigned char *p;
22123
840e7e1b6dac disapproval of revision '947ccb889812585e6d53eac13fc12734d8481e33'
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22121
diff changeset
723
22134
33abfb98a460 Since I needed to bring back yahoo_convert_to_numeric, I figured I could at
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22123
diff changeset
724 gstr = g_string_sized_new(strlen(str) * 6 + 1);
33abfb98a460 Since I needed to bring back yahoo_convert_to_numeric, I figured I could at
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22123
diff changeset
725
22155
a886e43210b1 Fix (hopefully) the last problem in this function. Refs #3295.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22134
diff changeset
726 for (p = (unsigned char *)str; *p; p++) {
22134
33abfb98a460 Since I needed to bring back yahoo_convert_to_numeric, I figured I could at
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22123
diff changeset
727 g_string_append_printf(gstr, "&#%u;", *p);
22123
840e7e1b6dac disapproval of revision '947ccb889812585e6d53eac13fc12734d8481e33'
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22121
diff changeset
728 }
22134
33abfb98a460 Since I needed to bring back yahoo_convert_to_numeric, I figured I could at
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22123
diff changeset
729
33abfb98a460 Since I needed to bring back yahoo_convert_to_numeric, I figured I could at
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22123
diff changeset
730 retstr = gstr->str;
33abfb98a460 Since I needed to bring back yahoo_convert_to_numeric, I figured I could at
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22123
diff changeset
731
33abfb98a460 Since I needed to bring back yahoo_convert_to_numeric, I figured I could at
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22123
diff changeset
732 g_string_free(gstr, FALSE);
33abfb98a460 Since I needed to bring back yahoo_convert_to_numeric, I figured I could at
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22123
diff changeset
733
22123
840e7e1b6dac disapproval of revision '947ccb889812585e6d53eac13fc12734d8481e33'
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22121
diff changeset
734 return retstr;
840e7e1b6dac disapproval of revision '947ccb889812585e6d53eac13fc12734d8481e33'
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22121
diff changeset
735 }
840e7e1b6dac disapproval of revision '947ccb889812585e6d53eac13fc12734d8481e33'
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 22121
diff changeset
736
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
737 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
738 * I found these on some website but i don't know that they actually
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
739 * work (or are supposed to work). I didn't implement them yet.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
740 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
741 * [0;30m ---black
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
742 * [1;37m ---white
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
743 * [0;37m ---tan
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
744 * [0;38m ---light black
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
745 * [1;39m ---dark blue
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
746 * [0;32m ---green
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
747 * [0;33m ---yellow
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
748 * [0;35m ---pink
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
749 * [1;35m ---purple
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
750 * [1;30m ---light blue
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
751 * [0;31m ---red
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
752 * [0;34m ---blue
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
753 * [0;36m ---aqua
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
754 * (shift+comma)lyellow(shift+period) ---light yellow
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
755 * (shift+comma)lgreen(shift+period) ---light green
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
756 [2;30m <--white out
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
757 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
758
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
759 static GHashTable *ht = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
760
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
761 void yahoo_init_colorht()
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
762 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
763 ht = g_hash_table_new(g_str_hash, g_str_equal);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
764 /* the numbers in comments are what gyach uses, but i think they're incorrect */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
765 g_hash_table_insert(ht, "30", "<FONT COLOR=\"#000000\">"); /* black */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
766 g_hash_table_insert(ht, "31", "<FONT COLOR=\"#0000FF\">"); /* blue */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
767 g_hash_table_insert(ht, "32", "<FONT COLOR=\"#008080\">"); /* cyan */ /* 00b2b2 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
768 g_hash_table_insert(ht, "33", "<FONT COLOR=\"#808080\">"); /* gray */ /* 808080 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
769 g_hash_table_insert(ht, "34", "<FONT COLOR=\"#008000\">"); /* green */ /* 00c200 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
770 g_hash_table_insert(ht, "35", "<FONT COLOR=\"#FF0080\">"); /* pink */ /* ffafaf */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
771 g_hash_table_insert(ht, "36", "<FONT COLOR=\"#800080\">"); /* purple */ /* b200b2 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
772 g_hash_table_insert(ht, "37", "<FONT COLOR=\"#FF8000\">"); /* orange */ /* ffff00 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
773 g_hash_table_insert(ht, "38", "<FONT COLOR=\"#FF0000\">"); /* red */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
774 g_hash_table_insert(ht, "39", "<FONT COLOR=\"#808000\">"); /* olive */ /* 546b50 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
775
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
776 g_hash_table_insert(ht, "1", "<B>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
777 g_hash_table_insert(ht, "x1", "</B>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
778 g_hash_table_insert(ht, "2", "<I>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
779 g_hash_table_insert(ht, "x2", "</I>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
780 g_hash_table_insert(ht, "4", "<U>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
781 g_hash_table_insert(ht, "x4", "</U>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
782
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
783 /* these just tell us the text they surround is supposed
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
784 * to be a link. purple figures that out on its own so we
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
785 * just ignore it.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
786 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
787 g_hash_table_insert(ht, "l", ""); /* link start */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
788 g_hash_table_insert(ht, "xl", ""); /* link end */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
789
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
790 g_hash_table_insert(ht, "<black>", "<FONT COLOR=\"#000000\">");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
791 g_hash_table_insert(ht, "<blue>", "<FONT COLOR=\"#0000FF\">");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
792 g_hash_table_insert(ht, "<cyan>", "<FONT COLOR=\"#008284\">");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
793 g_hash_table_insert(ht, "<gray>", "<FONT COLOR=\"#848284\">");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
794 g_hash_table_insert(ht, "<green>", "<FONT COLOR=\"#008200\">");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
795 g_hash_table_insert(ht, "<pink>", "<FONT COLOR=\"#FF0084\">");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
796 g_hash_table_insert(ht, "<purple>", "<FONT COLOR=\"#840084\">");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
797 g_hash_table_insert(ht, "<orange>", "<FONT COLOR=\"#FF8000\">");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
798 g_hash_table_insert(ht, "<red>", "<FONT COLOR=\"#FF0000\">");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
799 g_hash_table_insert(ht, "<yellow>", "<FONT COLOR=\"#848200\">");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
800
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
801 g_hash_table_insert(ht, "</black>", "</FONT>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
802 g_hash_table_insert(ht, "</blue>", "</FONT>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
803 g_hash_table_insert(ht, "</cyan>", "</FONT>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
804 g_hash_table_insert(ht, "</gray>", "</FONT>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
805 g_hash_table_insert(ht, "</green>", "</FONT>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
806 g_hash_table_insert(ht, "</pink>", "</FONT>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
807 g_hash_table_insert(ht, "</purple>", "</FONT>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
808 g_hash_table_insert(ht, "</orange>", "</FONT>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
809 g_hash_table_insert(ht, "</red>", "</FONT>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
810 g_hash_table_insert(ht, "</yellow>", "</FONT>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
811
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
812 /* remove these once we have proper support for <FADE> and <ALT> */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
813 g_hash_table_insert(ht, "</fade>", "");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
814 g_hash_table_insert(ht, "</alt>", "");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
815
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
816 /* these are the normal html yahoo sends (besides <font>).
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
817 * anything else will get turned into &lt;tag&gt;, so if I forgot
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
818 * about something, please add it. Why Yahoo! has to send unescaped
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
819 * <'s and >'s that aren't supposed to be html is beyond me.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
820 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
821 g_hash_table_insert(ht, "<b>", "<b>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
822 g_hash_table_insert(ht, "<i>", "<i>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
823 g_hash_table_insert(ht, "<u>", "<u>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
824
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
825 g_hash_table_insert(ht, "</b>", "</b>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
826 g_hash_table_insert(ht, "</i>", "</i>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
827 g_hash_table_insert(ht, "</u>", "</u>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
828 g_hash_table_insert(ht, "</font>", "</font>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
829 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
830
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
831 void yahoo_dest_colorht()
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
832 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
833 g_hash_table_destroy(ht);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
834 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
835
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
836 static int point_to_html(int x)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
837 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
838 if (x < 9)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
839 return 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
840 if (x < 11)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
841 return 2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
842 if (x < 13)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
843 return 3;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
844 if (x < 17)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
845 return 4;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
846 if (x < 25)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
847 return 5;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
848 if (x < 35)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
849 return 6;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
850 return 7;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
851 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
852
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
853 /* The Yahoo size tag is actually an absz tag; convert it to an HTML size, and include both tags */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
854 static void _font_tags_fix_size(GString *tag, GString *dest)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
855 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
856 char *x, *end;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
857 int size;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
858
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
859 if (((x = strstr(tag->str, "size"))) && ((x = strchr(x, '=')))) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
860 while (*x && !g_ascii_isdigit(*x))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
861 x++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
862 if (*x) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
863 int htmlsize;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
864
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
865 size = strtol(x, &end, 10);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
866 htmlsize = point_to_html(size);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
867 g_string_append_len(dest, tag->str, x - tag->str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
868 g_string_append_printf(dest, "%d", htmlsize);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
869 g_string_append_printf(dest, "\" absz=\"%d", size);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
870 g_string_append(dest, end);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
871 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
872 g_string_append(dest, tag->str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
873 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
874 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
875 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
876 g_string_append(dest, tag->str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
877 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
878 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
879 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
880
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
881 char *yahoo_codes_to_html(const char *x)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
882 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
883 GString *s, *tmp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
884 int i, j, xs, nomoreendtags = 0; /* s/endtags/closinganglebrackets */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
885 char *match, *ret;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
886
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
887 s = g_string_sized_new(strlen(x));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
888
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
889 for (i = 0, xs = strlen(x); i < xs; i++) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
890 if ((x[i] == 0x1b) && (x[i+1] == '[')) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
891 j = i + 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
892
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
893 while (j++ < xs) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
894 if (x[j] != 'm')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
895 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
896 else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
897 tmp = g_string_new_len(x + i + 2, j - i - 2);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
898 if (tmp->str[0] == '#')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
899 g_string_append_printf(s, "<FONT COLOR=\"%s\">", tmp->str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
900 else if ((match = (char *) g_hash_table_lookup(ht, tmp->str)))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
901 g_string_append(s, match);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
902 else {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
903 purple_debug(PURPLE_DEBUG_ERROR, "yahoo",
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
904 "Unknown ansi code 'ESC[%sm'.\n", tmp->str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
905 g_string_free(tmp, TRUE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
906 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
907 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
908
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
909 i = j;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
910 g_string_free(tmp, TRUE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
911 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
912 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
913 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
914
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
915 } else if (!nomoreendtags && (x[i] == '<')) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
916 j = i;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
917
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
918 while (j++ < xs) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
919 if (x[j] != '>')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
920 if (j == xs) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
921 g_string_append(s, "&lt;");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
922 nomoreendtags = 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
923 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
924 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
925 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
926 else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
927 tmp = g_string_new_len(x + i, j - i + 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
928 g_string_ascii_down(tmp);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
929
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
930 if ((match = (char *) g_hash_table_lookup(ht, tmp->str)))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
931 g_string_append(s, match);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
932 else if (!strncmp(tmp->str, "<fade ", 6) ||
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
933 !strncmp(tmp->str, "<alt ", 5) ||
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
934 !strncmp(tmp->str, "<snd ", 5)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
935
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
936 /* remove this if gtkimhtml ever supports any of these */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
937 i = j;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
938 g_string_free(tmp, TRUE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
939 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
940
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
941 } else if (!strncmp(tmp->str, "<font ", 6)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
942 _font_tags_fix_size(tmp, s);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
943 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
944 g_string_append(s, "&lt;");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
945 g_string_free(tmp, TRUE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
946 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
947 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
948
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
949 i = j;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
950 g_string_free(tmp, TRUE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
951 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
952 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
953
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
954 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
955
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
956 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
957 if (x[i] == '<')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
958 g_string_append(s, "&lt;");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
959 else if (x[i] == '>')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
960 g_string_append(s, "&gt;");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
961 else if (x[i] == '&')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
962 g_string_append(s, "&amp;");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
963 else if (x[i] == '"')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
964 g_string_append(s, "&quot;");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
965 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
966 g_string_append_c(s, x[i]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
967 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
968 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
969
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
970 ret = s->str;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
971 g_string_free(s, FALSE);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
972 purple_debug(PURPLE_DEBUG_MISC, "yahoo", "yahoo_codes_to_html: Returning string: '%s'.\n", ret);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
973 return ret;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
974 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
975
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
976 /* borrowed from gtkimhtml */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
977 #define MAX_FONT_SIZE 7
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
978 #define POINT_SIZE(x) (_point_sizes [MIN ((x > 0 ? x : 1), MAX_FONT_SIZE) - 1])
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
979 static const gint _point_sizes [] = { 8, 10, 12, 14, 20, 30, 40 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
980
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
981 enum fatype { size, color, face, junk };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
982 typedef struct {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
983 enum fatype type;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
984 union {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
985 int size;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
986 char *color;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
987 char *face;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
988 char *junk;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
989 } u;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
990 } fontattr;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
991
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
992 static void fontattr_free(fontattr *f)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
993 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
994 if (f->type == color)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
995 g_free(f->u.color);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
996 else if (f->type == face)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
997 g_free(f->u.face);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
998 g_free(f);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
999 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1000
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1001 static void yahoo_htc_queue_cleanup(GQueue *q)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1002 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1003 char *tmp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1004
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1005 while ((tmp = g_queue_pop_tail(q)))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1006 g_free(tmp);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1007 g_queue_free(q);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1008 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1009
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1010 static void _parse_font_tag(const char *src, GString *dest, int *i, int *j,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1011 int len, GQueue *colors, GQueue *tags, GQueue *ftattr)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1012 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1013
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1014 int m, n, vstart;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1015 gboolean quote = 0, done = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1016
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1017 m = *j;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1018
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1019 while (1) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1020 m++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1021
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1022 if (m >= len) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1023 g_string_append(dest, &src[*i]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1024 *i = len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1025 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1026 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1027
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1028 if (src[m] == '=') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1029 n = vstart = m;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1030 while (1) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1031 n++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1032
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1033 if (n >= len) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1034 m = n;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1035 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1036 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1037
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1038 if (src[n] == '"') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1039 if (!quote) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1040 quote = 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1041 vstart = n;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1042 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1043 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1044 done = 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1045 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1046 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1047
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1048 if (!quote && ((src[n] == ' ') || (src[n] == '>')))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1049 done = 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1050
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1051 if (done) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1052 if (!g_ascii_strncasecmp(&src[*j+1], "FACE", m - *j - 1)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1053 fontattr *f;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1054
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1055 f = g_new(fontattr, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1056 f->type = face;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1057 f->u.face = g_strndup(&src[vstart+1], n-vstart-1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1058 if (!ftattr)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1059 ftattr = g_queue_new();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1060 g_queue_push_tail(ftattr, f);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1061 m = n;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1062 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1063 } else if (!g_ascii_strncasecmp(&src[*j+1], "SIZE", m - *j - 1)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1064 fontattr *f;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1065
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1066 f = g_new(fontattr, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1067 f->type = size;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1068 f->u.size = POINT_SIZE(strtol(&src[vstart+1], NULL, 10));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1069 if (!ftattr)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1070 ftattr = g_queue_new();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1071 g_queue_push_tail(ftattr, f);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1072 m = n;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1073 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1074 } else if (!g_ascii_strncasecmp(&src[*j+1], "COLOR", m - *j - 1)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1075 fontattr *f;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1076
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1077 f = g_new(fontattr, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1078 f->type = color;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1079 f->u.color = g_strndup(&src[vstart+1], n-vstart-1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1080 if (!ftattr)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1081 ftattr = g_queue_new();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1082 g_queue_push_head(ftattr, f);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1083 m = n;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1084 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1085 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1086 fontattr *f;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1087
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1088 f = g_new(fontattr, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1089 f->type = junk;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1090 f->u.junk = g_strndup(&src[*j+1], n-*j);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1091 if (!ftattr)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1092 ftattr = g_queue_new();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1093 g_queue_push_tail(ftattr, f);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1094 m = n;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1095 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1096 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1097
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1098 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1099 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1100 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1101
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1102 if (src[m] == ' ')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1103 *j = m;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1104
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1105 if (src[m] == '>') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1106 gboolean needendtag = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1107 fontattr *f;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1108 GString *tmp = g_string_new(NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1109 char *colorstr;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1110
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1111 if (!g_queue_is_empty(ftattr)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1112 while ((f = g_queue_pop_tail(ftattr))) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1113 switch (f->type) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1114 case size:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1115 if (!needendtag) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1116 needendtag = 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1117 g_string_append(dest, "<font ");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1118 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1119
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1120 g_string_append_printf(dest, "size=\"%d\" ", f->u.size);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1121 fontattr_free(f);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1122 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1123 case face:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1124 if (!needendtag) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1125 needendtag = 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1126 g_string_append(dest, "<font ");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1127 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1128
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1129 g_string_append_printf(dest, "face=\"%s\" ", f->u.face);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1130 fontattr_free(f);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1131 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1132 case junk:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1133 if (!needendtag) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1134 needendtag = 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1135 g_string_append(dest, "<font ");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1136 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1137
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1138 g_string_append(dest, f->u.junk);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1139 fontattr_free(f);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1140 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1141
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1142 case color:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1143 if (needendtag) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1144 g_string_append(tmp, "</font>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1145 dest->str[dest->len-1] = '>';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1146 needendtag = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1147 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1148
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1149 colorstr = g_queue_peek_tail(colors);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1150 g_string_append(tmp, colorstr ? colorstr : "\033[#000000m");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1151 g_string_append_printf(dest, "\033[%sm", f->u.color);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1152 g_queue_push_tail(colors, g_strdup_printf("\033[%sm", f->u.color));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1153 fontattr_free(f);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1154 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1155 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1156 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1157
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1158 g_queue_free(ftattr);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1159 ftattr = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1160
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1161 if (needendtag) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1162 dest->str[dest->len-1] = '>';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1163 g_queue_push_tail(tags, g_strdup("</font>"));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1164 g_string_free(tmp, TRUE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1165 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1166 g_queue_push_tail(tags, tmp->str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1167 g_string_free(tmp, FALSE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1168 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1169 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1170
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1171 *i = *j = m;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1172 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1173 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1174 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1175
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1176 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1177
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1178 char *yahoo_html_to_codes(const char *src)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1179 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1180 int i, j, len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1181 GString *dest;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1182 char *ret, *esc;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1183 GQueue *colors, *tags;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1184 GQueue *ftattr = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1185 gboolean no_more_specials = FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1186
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1187 colors = g_queue_new();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1188 tags = g_queue_new();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1189 dest = g_string_sized_new(strlen(src));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1190
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1191 for (i = 0, len = strlen(src); i < len; i++) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1192
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1193 if (!no_more_specials && src[i] == '<') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1194 j = i;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1195
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1196 while (1) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1197 j++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1198
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1199 if (j >= len) { /* no '>' */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1200 g_string_append_c(dest, src[i]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1201 no_more_specials = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1202 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1203 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1204
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1205 if (src[j] == '<') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1206 /* FIXME: This doesn't convert outgoing entities.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1207 * However, I suspect this case may never
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1208 * happen anymore because of the entities.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1209 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1210 g_string_append_len(dest, &src[i], j - i);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1211 i = j - 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1212 if (ftattr) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1213 fontattr *f;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1214
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1215 while ((f = g_queue_pop_head(ftattr)))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1216 fontattr_free(f);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1217 g_queue_free(ftattr);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1218 ftattr = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1219 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1220 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1221 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1222
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1223 if (src[j] == ' ') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1224 if (!g_ascii_strncasecmp(&src[i+1], "BODY", j - i - 1)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1225 char *t = strchr(&src[j], '>');
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1226 if (!t) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1227 g_string_append(dest, &src[i]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1228 i = len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1229 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1230 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1231 i = t - src;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1232 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1233 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1234 } else if (!g_ascii_strncasecmp(&src[i+1], "A HREF=\"", j - i - 1)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1235 j += 7;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1236 g_string_append(dest, "\033[lm");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1237 while (1) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1238 g_string_append_c(dest, src[j]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1239 if (++j >= len) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1240 i = len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1241 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1242 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1243 if (src[j] == '"') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1244 g_string_append(dest, "\033[xlm");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1245 while (1) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1246 if (++j >= len) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1247 i = len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1248 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1249 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1250 if (!g_ascii_strncasecmp(&src[j], "</A>", 4)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1251 j += 3;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1252 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1253 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1254 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1255 i = j;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1256 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1257 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1258 }
16109
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15823
diff changeset
1259 } else if (!g_ascii_strncasecmp(&src[i+1], "SPAN", j - i - 1)) { /* drop span tags */
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15823
diff changeset
1260 while (1) {
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15823
diff changeset
1261 if (++j >= len) {
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15823
diff changeset
1262 g_string_append(dest, &src[i]);
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15823
diff changeset
1263 i = len;
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15823
diff changeset
1264 break;
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15823
diff changeset
1265 }
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15823
diff changeset
1266 if (src[j] == '>') {
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15823
diff changeset
1267 i = j;
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15823
diff changeset
1268 break;
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15823
diff changeset
1269 }
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15823
diff changeset
1270 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1271 } else if (g_ascii_strncasecmp(&src[i+1], "FONT", j - i - 1)) { /* not interested! */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1272 while (1) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1273 if (++j >= len) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1274 g_string_append(dest, &src[i]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1275 i = len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1276 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1277 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1278 if (src[j] == '>') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1279 g_string_append_len(dest, &src[i], j - i + 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1280 i = j;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1281 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1282 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1283 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1284 } else { /* yay we have a font tag */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1285 _parse_font_tag(src, dest, &i, &j, len, colors, tags, ftattr);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1286 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1287
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1288 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1289 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1290
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1291 if (src[j] == '>') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1292 /* This has some problems like the FIXME for the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1293 * '<' case. and like that case, I suspect the case
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1294 * that this has problems is won't happen anymore anyway.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1295 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1296 int sublen = j - i - 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1297
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1298 if (sublen) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1299 if (!g_ascii_strncasecmp(&src[i+1], "B", sublen)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1300 g_string_append(dest, "\033[1m");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1301 } else if (!g_ascii_strncasecmp(&src[i+1], "/B", sublen)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1302 g_string_append(dest, "\033[x1m");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1303 } else if (!g_ascii_strncasecmp(&src[i+1], "I", sublen)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1304 g_string_append(dest, "\033[2m");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1305 } else if (!g_ascii_strncasecmp(&src[i+1], "/I", sublen)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1306 g_string_append(dest, "\033[x2m");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1307 } else if (!g_ascii_strncasecmp(&src[i+1], "U", sublen)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1308 g_string_append(dest, "\033[4m");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1309 } else if (!g_ascii_strncasecmp(&src[i+1], "/U", sublen)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1310 g_string_append(dest, "\033[x4m");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1311 } else if (!g_ascii_strncasecmp(&src[i+1], "/A", sublen)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1312 g_string_append(dest, "\033[xlm");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1313 } else if (!g_ascii_strncasecmp(&src[i+1], "BR", sublen)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1314 g_string_append_c(dest, '\n');
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1315 } else if (!g_ascii_strncasecmp(&src[i+1], "/BODY", sublen)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1316 /* mmm, </body> tags. *BURP* */
16109
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15823
diff changeset
1317 } else if (!g_ascii_strncasecmp(&src[i+1], "/SPAN", sublen)) {
8e61e7be988b Stop Yahoo sending SPAN tags, fixes Yahoo part of ticket 78
Stu Tomlinson <stu@nosnilmot.com>
parents: 15823
diff changeset
1318 /* </span> tags. dangerously close to </spam> */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1319 } else if (!g_ascii_strncasecmp(&src[i+1], "/FONT", sublen) && g_queue_peek_tail(tags)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1320 char *etag, *cl;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1321
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1322 etag = g_queue_pop_tail(tags);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1323 if (etag) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1324 g_string_append(dest, etag);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1325 if (!strcmp(etag, "</font>")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1326 cl = g_queue_pop_tail(colors);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1327 if (cl)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1328 g_free(cl);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1329 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1330 g_free(etag);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1331 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1332 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1333 g_string_append_len(dest, &src[i], j - i + 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1334 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1335 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1336 g_string_append_len(dest, &src[i], j - i + 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1337 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1338
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1339 i = j;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1340 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1341 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1342
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1343 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1344
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1345 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1346 if (((len - i) >= 4) && !strncmp(&src[i], "&lt;", 4)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1347 g_string_append_c(dest, '<');
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1348 i += 3;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1349 } else if (((len - i) >= 4) && !strncmp(&src[i], "&gt;", 4)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1350 g_string_append_c(dest, '>');
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1351 i += 3;
21831
543306932d15 Make yahoo_html_to_codes deal with &apos; in messages being sent. Also correct
Will Thompson <will.thompson@collabora.co.uk>
parents: 19680
diff changeset
1352 } else if (((len - i) >= 5) && !strncmp(&src[i], "&amp;", 5)) {
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1353 g_string_append_c(dest, '&');
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1354 i += 4;
21831
543306932d15 Make yahoo_html_to_codes deal with &apos; in messages being sent. Also correct
Will Thompson <will.thompson@collabora.co.uk>
parents: 19680
diff changeset
1355 } else if (((len - i) >= 6) && !strncmp(&src[i], "&quot;", 6)) {
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1356 g_string_append_c(dest, '"');
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1357 i += 5;
21831
543306932d15 Make yahoo_html_to_codes deal with &apos; in messages being sent. Also correct
Will Thompson <will.thompson@collabora.co.uk>
parents: 19680
diff changeset
1358 } else if (((len - i) >= 6) && !strncmp(&src[i], "&apos;", 6)) {
543306932d15 Make yahoo_html_to_codes deal with &apos; in messages being sent. Also correct
Will Thompson <will.thompson@collabora.co.uk>
parents: 19680
diff changeset
1359 g_string_append_c(dest, '\'');
543306932d15 Make yahoo_html_to_codes deal with &apos; in messages being sent. Also correct
Will Thompson <will.thompson@collabora.co.uk>
parents: 19680
diff changeset
1360 i += 5;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1361 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1362 g_string_append_c(dest, src[i]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1363 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1364 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1365 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1366
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1367 ret = dest->str;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1368 g_string_free(dest, FALSE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1369
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1370 esc = g_strescape(ret, NULL);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
1371 purple_debug(PURPLE_DEBUG_MISC, "yahoo", "yahoo_html_to_codes: Returning string: '%s'.\n", esc);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1372 g_free(esc);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1374 yahoo_htc_queue_cleanup(colors);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1375 yahoo_htc_queue_cleanup(tags);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1376
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1377 return ret;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1378 }