Mercurial > pidgin.yaz
comparison libpurple/protocols/yahoo/yahoo_aliases.c @ 22056:b0ed2ce8514d
A patch from Gideon N. Guillen, with some minor modifications from me. This
patch fixes retrieval of buddy icons and setting of server-side aliases when
using an HTTP proxy.
author | John Bailey <rekkanoryo@rekkanoryo.org> |
---|---|
date | Sun, 24 Feb 2008 18:20:52 +0000 |
parents | 6de09629f091 |
children | d4998f31bc1a |
comparison
equal
deleted
inserted
replaced
22016:aba0620b1a37 | 22056:b0ed2ce8514d |
---|---|
141 struct callback_data *cb; | 141 struct callback_data *cb; |
142 const char *url = YAHOO_ALIAS_FETCH_URL; | 142 const char *url = YAHOO_ALIAS_FETCH_URL; |
143 char *request, *webpage, *webaddress; | 143 char *request, *webpage, *webaddress; |
144 PurpleUtilFetchUrlData *url_data; | 144 PurpleUtilFetchUrlData *url_data; |
145 | 145 |
146 gboolean use_whole_url = FALSE; | |
147 | |
148 /* use whole URL if using HTTP Proxy */ | |
149 if ((gc->account->proxy_info) && (gc->account->proxy_info->type == PURPLE_PROXY_HTTP)) | |
150 use_whole_url = TRUE; | |
151 | |
146 /* Using callback_data so I have access to gc in the callback function */ | 152 /* Using callback_data so I have access to gc in the callback function */ |
147 cb = g_new0(struct callback_data, 1); | 153 cb = g_new0(struct callback_data, 1); |
148 cb->gc = gc; | 154 cb->gc = gc; |
149 | 155 |
150 /* Build all the info to make the web request */ | 156 /* Build all the info to make the web request */ |
151 purple_url_parse(url, &webaddress, NULL, &webpage, NULL, NULL); | 157 purple_url_parse(url, &webaddress, NULL, &webpage, NULL, NULL); |
152 request = g_strdup_printf("GET /%s HTTP/1.1\r\n" | 158 request = g_strdup_printf("GET %s%s/%s HTTP/1.1\r\n" |
153 "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\r\n" | 159 "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\r\n" |
154 "Cookie: T=%s; Y=%s\r\n" | 160 "Cookie: T=%s; Y=%s\r\n" |
155 "Host: %s\r\n" | 161 "Host: %s\r\n" |
156 "Cache-Control: no-cache\r\n\r\n", | 162 "Cache-Control: no-cache\r\n\r\n", |
157 webpage, yd->cookie_t,yd->cookie_y, webaddress); | 163 use_whole_url ? "http://" : "", use_whole_url ? webaddress : "", webpage, yd->cookie_t,yd->cookie_y, webaddress); |
158 | 164 |
159 /* We have a URL and some header information, let's connect and get some aliases */ | 165 /* We have a URL and some header information, let's connect and get some aliases */ |
160 url_data = purple_util_fetch_url_request(url, FALSE, NULL, TRUE, request, FALSE, yahoo_fetch_aliases_cb, cb); | 166 url_data = purple_util_fetch_url_request(url, use_whole_url, NULL, TRUE, request, FALSE, yahoo_fetch_aliases_cb, cb); |
161 if (url_data != NULL) { | 167 if (url_data != NULL) { |
162 yd->url_datas = g_slist_prepend(yd->url_datas, url_data); | 168 yd->url_datas = g_slist_prepend(yd->url_datas, url_data); |
163 } | 169 } |
164 | 170 |
165 g_free(webaddress); | 171 g_free(webaddress); |
223 char *content, *url, *request, *webpage, *webaddress, *strtmp; | 229 char *content, *url, *request, *webpage, *webaddress, *strtmp; |
224 int inttmp; | 230 int inttmp; |
225 struct callback_data *cb; | 231 struct callback_data *cb; |
226 PurpleBuddy *buddy; | 232 PurpleBuddy *buddy; |
227 PurpleUtilFetchUrlData *url_data; | 233 PurpleUtilFetchUrlData *url_data; |
234 gboolean use_whole_url = FALSE; | |
235 | |
236 /* use whole URL if using HTTP Proxy */ | |
237 if ((gc->account->proxy_info) && (gc->account->proxy_info->type == PURPLE_PROXY_HTTP)) | |
238 use_whole_url = TRUE; | |
228 | 239 |
229 g_return_if_fail(alias!= NULL); | 240 g_return_if_fail(alias!= NULL); |
230 g_return_if_fail(who!=NULL); | 241 g_return_if_fail(who!=NULL); |
231 g_return_if_fail(gc!=NULL); | 242 g_return_if_fail(gc!=NULL); |
232 | 243 |
252 | 263 |
253 content = g_strdup_printf("<?xml version=\"1.0\" encoding=\"utf-8\"?><ab k=\"%s\" cc=\"1\">\n" | 264 content = g_strdup_printf("<?xml version=\"1.0\" encoding=\"utf-8\"?><ab k=\"%s\" cc=\"1\">\n" |
254 "<ct e=\"1\" yi='%s' id='%s' nn='%s' pr='0' />\n</ab>\r\n", | 265 "<ct e=\"1\" yi='%s' id='%s' nn='%s' pr='0' />\n</ab>\r\n", |
255 gc->account->username, who, yu->id, g_markup_escape_text(alias, strlen(alias))); | 266 gc->account->username, who, yu->id, g_markup_escape_text(alias, strlen(alias))); |
256 | 267 |
257 request = g_strdup_printf("POST /%s HTTP/1.1\r\n" | 268 request = g_strdup_printf("POST %s%s/%s HTTP/1.1\r\n" |
258 "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\r\n" | 269 "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\r\n" |
259 "Cookie: T=%s; Y=%s\r\n" | 270 "Cookie: T=%s; Y=%s\r\n" |
260 "Host: %s\r\n" | 271 "Host: %s\r\n" |
261 "Content-Length: %" G_GSIZE_FORMAT "\r\n" | 272 "Content-Length: %" G_GSIZE_FORMAT "\r\n" |
262 "Cache-Control: no-cache\r\n\r\n" | 273 "Cache-Control: no-cache\r\n\r\n" |
263 "%s", | 274 "%s", |
264 webpage, yd->cookie_t,yd->cookie_y, webaddress, | 275 use_whole_url ? "http://" : "", use_whole_url ? webaddress : "", webpage, yd->cookie_t,yd->cookie_y, webaddress, |
265 strlen(content), content); | 276 strlen(content), content); |
266 | 277 |
267 /* We have a URL and some header information, let's connect and update the alias */ | 278 /* We have a URL and some header information, let's connect and update the alias */ |
268 url_data = purple_util_fetch_url_request(url, FALSE, NULL, TRUE, request, FALSE, yahoo_update_alias_cb, cb); | 279 url_data = purple_util_fetch_url_request(url, use_whole_url, NULL, TRUE, request, FALSE, yahoo_update_alias_cb, cb); |
269 if (url_data != NULL) { | 280 if (url_data != NULL) { |
270 yd->url_datas = g_slist_prepend(yd->url_datas, url_data); | 281 yd->url_datas = g_slist_prepend(yd->url_datas, url_data); |
271 } | 282 } |
272 | 283 |
273 g_free(content); | 284 g_free(content); |