changeset 23991:f368b91a542b

merge of '126251205c0faf12cb73ec60a10f1cf904b8166d' and 'e25c2c739ad8e544bc841cd6a8d7004ddd61a1a5'
author Ka-Hing Cheung <khc@hxbc.us>
date Wed, 27 Aug 2008 04:52:40 +0000
parents b8d38a11f9c6 (current diff) 62387da2a57f (diff)
children 519b877a59f5
files
diffstat 7 files changed, 27 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/yahoo/util.c	Wed Aug 27 04:52:29 2008 +0000
+++ b/libpurple/protocols/yahoo/util.c	Wed Aug 27 04:52:40 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 04:52:29 2008 +0000
+++ b/libpurple/protocols/yahoo/yahoo.c	Wed Aug 27 04:52:40 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 04:52:29 2008 +0000
+++ b/libpurple/protocols/yahoo/yahoo.h	Wed Aug 27 04:52:40 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 04:52:29 2008 +0000
+++ b/libpurple/protocols/yahoo/yahoo_aliases.c	Wed Aug 27 04:52:40 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 04:52:29 2008 +0000
+++ b/libpurple/protocols/yahoo/yahoo_picture.c	Wed Aug 27 04:52:40 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 04:52:29 2008 +0000
+++ b/libpurple/protocols/yahoo/yahoo_profile.c	Wed Aug 27 04:52:40 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
--- a/libpurple/util.c	Wed Aug 27 04:52:29 2008 +0000
+++ b/libpurple/util.c	Wed Aug 27 04:52:40 2008 +0000
@@ -3578,7 +3578,10 @@
 		g_snprintf(port_str, sizeof(port_str), "80");
 	}
 
-	if (f == 1)
+	if (f == 0)
+		*host = '\0';
+
+	if (f <= 1)
 		*path = '\0';
 
 	sscanf(port_str, "%d", &port);
@@ -3589,7 +3592,7 @@
 	if (ret_user != NULL) *ret_user = g_strdup(user);
 	if (ret_passwd != NULL) *ret_passwd = g_strdup(passwd);
 
-	return TRUE;
+	return ((*host != '\0') ? TRUE : FALSE);
 }
 
 /**