changeset 23986:18a1f0fe5f40

Do a better job of detecting if the yahoo account is connecting through a HTTP Proxy in order to generate acceptable HTTP requests. Hopefully fixes #6527
author Daniel Atallah <daniel.atallah@gmail.com>
date Wed, 27 Aug 2008 02:52:50 +0000
parents fd646e79cccf
children c241bc48c962
files libpurple/protocols/yahoo/util.c libpurple/protocols/yahoo/yahoo.c libpurple/protocols/yahoo/yahoo.h libpurple/protocols/yahoo/yahoo_aliases.c libpurple/protocols/yahoo/yahoo_picture.c libpurple/protocols/yahoo/yahoo_profile.c
diffstat 6 files changed, 22 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/yahoo/util.c	Wed Aug 27 02:43:25 2008 +0000
+++ b/libpurple/protocols/yahoo/util.c	Wed Aug 27 02:52:50 2008 +0000
@@ -31,6 +31,14 @@
 #include "yahoo.h"
 
 #include <string.h>
+
+gboolean
+yahoo_account_use_http_proxy(PurpleConnection *conn)
+{
+	PurpleProxyInfo *ppi = purple_proxy_get_setup(conn->account);
+	return (ppi->type == PURPLE_PROXY_HTTP || ppi->type == PURPLE_PROXY_USE_ENVVAR);
+}
+
 /*
  * Returns cookies formatted as a null terminated string for the given connection.
  * Must g_free return value.
--- a/libpurple/protocols/yahoo/yahoo.c	Wed Aug 27 02:43:25 2008 +0000
+++ b/libpurple/protocols/yahoo/yahoo.c	Wed Aug 27 02:52:50 2008 +0000
@@ -3531,18 +3531,16 @@
 
 	PurpleUtilFetchUrlData *url_data;
 	const char* base_url = "http://login.yahoo.com";
-	char *request = g_strdup_printf(
-		"POST /config/cookie_token HTTP/1.0\r\n"
+	/* use whole URL if using HTTP Proxy */
+	gboolean use_whole_url = yahoo_account_use_http_proxy(gc);
+	gchar *request = g_strdup_printf(
+		"POST %s/config/cookie_token HTTP/1.0\r\n"
 		"Cookie: T=%s; path=/; domain=.yahoo.com; Y=%s;\r\n"
 		"User-Agent: Mozilla/4.0 (compatible; MSIE 5.5)\r\n"
 		"Host: login.yahoo.com\r\n"
 		"Content-Length: 0\r\n\r\n",
+		use_whole_url ? base_url : "",
 		yd->cookie_t, yd->cookie_y);
-	gboolean use_whole_url = FALSE;
-
-	/* use whole URL if using HTTP Proxy */
-	if ((gc->account->proxy_info) && (gc->account->proxy_info->type == PURPLE_PROXY_HTTP))
-	    use_whole_url = TRUE;
 
 	url_data = purple_util_fetch_url_request(base_url, use_whole_url,
 			"Mozilla/4.0 (compatible; MSIE 5.5)", TRUE, request, FALSE,
--- a/libpurple/protocols/yahoo/yahoo.h	Wed Aug 27 02:43:25 2008 +0000
+++ b/libpurple/protocols/yahoo/yahoo.h	Wed Aug 27 02:52:50 2008 +0000
@@ -204,6 +204,9 @@
 char *yahoo_codes_to_html(const char *x);
 char *yahoo_html_to_codes(const char *src);
 
+gboolean
+yahoo_account_use_http_proxy(PurpleConnection *conn);
+
 /**
  * Encode some text to send to the yahoo server.
  *
--- a/libpurple/protocols/yahoo/yahoo_aliases.c	Wed Aug 27 02:43:25 2008 +0000
+++ b/libpurple/protocols/yahoo/yahoo_aliases.c	Wed Aug 27 02:52:50 2008 +0000
@@ -155,12 +155,8 @@
 	gchar *request, *webpage, *webaddress;
 	PurpleUtilFetchUrlData *url_data;
 
-	gboolean use_whole_url = FALSE;
-
 	/* use whole URL if using HTTP Proxy */
-	if ((gc->account->proxy_info)
-	    && (gc->account->proxy_info->type == PURPLE_PROXY_HTTP))
-		use_whole_url = TRUE;
+	gboolean use_whole_url = yahoo_account_use_http_proxy(gc);
 
 	/* Using callback_data so I have access to gc in the callback function */
 	cb = g_new0(struct callback_data, 1);
@@ -266,13 +262,9 @@
 	gchar *content, *request, *webpage, *webaddress;
 	struct callback_data *cb;
 	PurpleUtilFetchUrlData *url_data;
-	gboolean use_whole_url = FALSE;
 	YahooFriend *f;
-
 	/* use whole URL if using HTTP Proxy */
-	if ((gc->account->proxy_info)
-	    && (gc->account->proxy_info->type == PURPLE_PROXY_HTTP))
-		use_whole_url = TRUE;
+	gboolean use_whole_url = yahoo_account_use_http_proxy(gc);
 
 	g_return_if_fail(who != NULL);
 	g_return_if_fail(gc != NULL);
--- a/libpurple/protocols/yahoo/yahoo_picture.c	Wed Aug 27 02:43:25 2008 +0000
+++ b/libpurple/protocols/yahoo/yahoo_picture.c	Wed Aug 27 02:52:50 2008 +0000
@@ -122,11 +122,8 @@
 		struct yahoo_fetch_picture_data *data;
 		PurpleBuddy *b = purple_find_buddy(gc->account, who);
 		const char *locksum = NULL;
-		gboolean use_whole_url = FALSE;
-
 		/* use whole URL if using HTTP Proxy */
-		if ((gc->account->proxy_info) && (gc->account->proxy_info->type == PURPLE_PROXY_HTTP))
-		    use_whole_url = TRUE;
+		gboolean use_whole_url = yahoo_account_use_http_proxy(gc);
 
 		/* FIXME: Cleanup this strtol() stuff if possible. */
 		if (b && (locksum = purple_buddy_icons_get_checksum_for_user(b)) != NULL && 
@@ -463,7 +460,8 @@
 	PurpleConnection *gc = d->gc;
 	PurpleAccount *account;
 	struct yahoo_data *yd;
-	gboolean use_whole_url = FALSE;
+	/* use whole URL if using HTTP Proxy */
+	gboolean use_whole_url = yahoo_account_use_http_proxy(gc);
 
 	account = purple_connection_get_account(gc);
 	yd = gc->proto_data;
@@ -476,10 +474,6 @@
 		yahoo_buddy_icon_upload_data_free(d);
 		return;
 	}
-	/* use whole URL if using HTTP Proxy */
-	if ((gc->account->proxy_info)
-	    	&& (gc->account->proxy_info->type == PURPLE_PROXY_HTTP))
-		use_whole_url = TRUE;
 
 	pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPLOAD, YAHOO_STATUS_AVAILABLE, yd->session_id);
 
--- a/libpurple/protocols/yahoo/yahoo_profile.c	Wed Aug 27 02:43:25 2008 +0000
+++ b/libpurple/protocols/yahoo/yahoo_profile.c	Wed Aug 27 02:52:50 2008 +0000
@@ -933,11 +933,8 @@
 	/* Try to put the photo in there too, if there's one */
 	if (photo_url_text) {
 		PurpleUtilFetchUrlData *url_data;
-		gboolean use_whole_url = FALSE;
-
 		/* use whole URL if using HTTP Proxy */
-		if ((info_data->gc->account->proxy_info) && (info_data->gc->account->proxy_info->type == PURPLE_PROXY_HTTP))
-		    use_whole_url = TRUE;
+		gboolean use_whole_url = yahoo_account_use_http_proxy(info_data->gc);
 
 		/* User-uploaded photos use a different server that requires the Host
 		 * header, but Yahoo Japan will use the "chunked" content encoding if