changeset 28747:ebb424b7e0a1

merge of '0bd5c5d235ae8c70b289e3b55a19523c4e28539e' and '9ba62902a7be15503ccd0006cd59c73fecc6255c'
author Mark Doliner <mark@kingant.net>
date Thu, 03 Dec 2009 08:02:54 +0000
parents 9750ec16f325 (current diff) 6846e88e76e3 (diff)
children f8da53e381dd 5af6304fde5d
files libpurple/proxy.c
diffstat 3 files changed, 40 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/oscar/clientlogin.c	Thu Dec 03 08:02:40 2009 +0000
+++ b/libpurple/protocols/oscar/clientlogin.c	Thu Dec 03 08:02:54 2009 +0000
@@ -275,13 +275,20 @@
 	char *query_string, *signature, *url;
 	gboolean use_tls = purple_account_get_bool(purple_connection_get_account(od->gc), "use_ssl", OSCAR_DEFAULT_USE_SSL);
 
-	/* Construct the GET parameters */
+	/*
+	 * Construct the GET parameters.  0x00000611 is the distid given to
+	 * us by AOL for use as the default libpurple distid.
+	 */
 	query_string = g_strdup_printf("a=%s"
+			"&distId=%d"
 			"&f=xml"
 			"&k=%s"
 			"&ts=%" PURPLE_TIME_T_MODIFIER
 			"&useTLS=%d",
-			purple_url_encode(token), get_client_key(od), hosttime, use_tls);
+			purple_url_encode(token),
+			oscar_get_ui_info_int(od->icq ? "prpl-icq-distid"
+					: "prpl-aim-distid", 0x00000611),
+			get_client_key(od), hosttime, use_tls);
 	signature = generate_signature("GET", URL_START_OSCAR_SESSION,
 			query_string, session_key);
 	url = g_strdup_printf(URL_START_OSCAR_SESSION "?%s&sig_sha256=%s",
--- a/libpurple/proxy.c	Thu Dec 03 08:02:40 2009 +0000
+++ b/libpurple/proxy.c	Thu Dec 03 08:02:54 2009 +0000
@@ -1099,6 +1099,36 @@
 			connect_data->host, connect_data->port,
 			connect_data->host, connect_data->port);
 
+	if (purple_proxy_info_get_username(connect_data->gpi) != NULL)
+	{
+		char *t1, *t2, *ntlm_type1;
+		char hostname[256];
+
+		ret = gethostname(hostname, sizeof(hostname));
+		hostname[sizeof(hostname) - 1] = '\0';
+		if (ret < 0 || hostname[0] == '\0') {
+			purple_debug_warning("proxy", "gethostname() failed -- is your hostname set?");
+			strcpy(hostname, "localhost");
+		}
+
+		t1 = g_strdup_printf("%s:%s",
+			purple_proxy_info_get_username(connect_data->gpi),
+			purple_proxy_info_get_password(connect_data->gpi) ?
+				purple_proxy_info_get_password(connect_data->gpi) : "");
+		t2 = purple_base64_encode((const guchar *)t1, strlen(t1));
+		g_free(t1);
+
+		ntlm_type1 = purple_ntlm_gen_type1(hostname, "");
+
+		g_string_append_printf(request,
+			"Proxy-Authorization: Basic %s\r\n"
+			"Proxy-Authorization: NTLM %s\r\n"
+			"Proxy-Connection: Keep-Alive\r\n",
+			t2, ntlm_type1);
+		g_free(ntlm_type1);
+		g_free(t2);
+	}
+
 	g_string_append(request, "\r\n");
 
 	connect_data->write_buf_len = request->len;
--- a/libpurple/xmlnode.c	Thu Dec 03 08:02:40 2009 +0000
+++ b/libpurple/xmlnode.c	Thu Dec 03 08:02:54 2009 +0000
@@ -588,7 +588,7 @@
 			const char *prefix = (const char *)attributes[i+1];
 			char *txt;
 			int attrib_len = attributes[i+4] - attributes[i+3];
-			char *attrib = g_strndup(attributes[i+3], attrib_len);
+			char *attrib = g_strndup((const char *)attributes[i+3], attrib_len);
 			txt = attrib;
 			attrib = purple_unescape_html(txt);
 			g_free(txt);