pidgin: 48605797: Add yet another URL fetching function. ...

rekkanoryo at pidgin.im rekkanoryo at pidgin.im
Fri May 29 20:10:39 EDT 2009


-----------------------------------------------------------------
Revision: 48605797160fa0786446ea54f38b8b1e963b9f84
Ancestor: af18689b86389686230fc6ce83cbba52690ce0cb
Author: rekkanoryo at pidgin.im
Date: 2009-05-30T00:07:50
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/48605797160fa0786446ea54f38b8b1e963b9f84

Modified files:
        libpurple/util.c libpurple/util.h

ChangeLog: 

Add yet another URL fetching function.  This one takes an account as a
parameter.  It's needed because the Yahoo 16 code uses URL fetching as part
of its login process, and without giving the account to purple_proxy_connect
(which wass called in purple_util_fetch_url_request_len), we ignore account-
specific proxy configurations.  This is a bad thing, as evidenced by Adium's
ticket 12231.  In adding this function, I deprecated
purple_util_fetch_url_request_len and made it a shell that calls this new
function with a NULL account parameter.  This maintains the previous behavior
without a mountain of duplicated code.

-------------- next part --------------
============================================================
--- libpurple/util.c	6636073b5d8e946be861ea7173d96bfe502f82c9
+++ libpurple/util.c	170a4c10aa88e6c499b8579b628135213d21215c
@@ -4008,7 +4008,7 @@ purple_util_fetch_url_request(const char
 		const char *request, gboolean include_headers,
 		PurpleUtilFetchUrlCallback callback, void *user_data)
 {
-	return purple_util_fetch_url_request_len(url, full,
+	return purple_util_fetch_url_request_len_with_account(NULL, url, full,
 					     user_agent, http11,
 					     request, include_headers, -1,
 					     callback, user_data);
@@ -4020,6 +4020,17 @@ purple_util_fetch_url_request_len(const 
 		const char *request, gboolean include_headers, gssize max_len,
 		PurpleUtilFetchUrlCallback callback, void *user_data)
 {
+	return purple_util_fetch_url_request_len_with_account(NULL, url, full,
+			user_agent, http11, request, include_headers, max_len, callback,
+			user_data);
+}
+
+PurpleUtilFetchUrlData *
+purple_util_fetch_url_request_len_with_account(PurpleAccount *account,
+		const char *url, gboolean full,	const char *user_agent, gboolean http11,
+		const char *request, gboolean include_headers, gssize max_len,
+		PurpleUtilFetchUrlCallback callback, void *user_data)
+{
 	PurpleUtilFetchUrlData *gfud;
 
 	g_return_val_if_fail(url      != NULL, NULL);
@@ -4057,11 +4068,11 @@ purple_util_fetch_url_request_len(const 
 		}
 
 		gfud->is_ssl = TRUE;
-		gfud->ssl_connection = purple_ssl_connect(NULL,
+		gfud->ssl_connection = purple_ssl_connect(account,
 				gfud->website.address, gfud->website.port,
 				ssl_url_fetch_connect_cb, ssl_url_fetch_error_cb, gfud);
 	} else {
-		gfud->connect_data = purple_proxy_connect(NULL, NULL,
+		gfud->connect_data = purple_proxy_connect(NULL, account,
 				gfud->website.address, gfud->website.port,
 				url_fetch_connect_cb, gfud);
 	}
============================================================
--- libpurple/util.h	9361ede4cf89416c188328b0c3ccabe59be6c037
+++ libpurple/util.h	086a2679177585f705af31fddca2f6f248811fb4
@@ -1106,9 +1106,33 @@ PurpleUtilFetchUrlData *purple_util_fetc
  * @param max_len    The maximum number of bytes to retrieve (-1 for unlimited)
  * @param callback   The callback function.
  * @param data       The user data to pass to the callback function.
+ * @deprecated       In 3.0.0, this will go away.
+ */
+PurpleUtilFetchUrlData *purple_util_fetch_url_request_len(const gchar *url,
+		gboolean full, const gchar *user_agent, gboolean http11,
+		const gchar *request, gboolean include_headers, gssize max_len,
+		PurpleUtilFetchUrlCallback callback, gpointer data);
+
+/**
+ * Fetches the data from a URL, and passes it to a callback function.
+ *
+ * @param account    The account for which the request is needed, or NULL.
+ * @param url        The URL.
+ * @param full       TRUE if this is the full URL, or FALSE if it's a
+ *                   partial URL.
+ * @param user_agent The user agent field to use, or NULL.
+ * @param http11     TRUE if HTTP/1.1 should be used to download the file.
+ * @param request    A HTTP request to send to the server instead of the
+ *                   standard GET
+ * @param include_headers
+ *                   If TRUE, include the HTTP headers in the response.
+ * @param max_len    The maximum number of bytes to retrieve (-1 for unlimited)
+ * @param callback   The callback function.
+ * @param data       The user data to pass to the callback function.
  * @deprecated       In 3.0.0, we'll rename this to "purple_util_fetch_url_request" and get rid of the old one
  */
-PurpleUtilFetchUrlData *purple_util_fetch_url_request_len(const gchar *url,
+PurpleUtilFetchUrlData *purple_util_fetch_url_request_len_with_account(
+		PurpleAccount *account, const gchar *url,
 		gboolean full, const gchar *user_agent, gboolean http11,
 		const gchar *request, gboolean include_headers, gssize max_len,
 		PurpleUtilFetchUrlCallback callback, gpointer data);


More information about the Commits mailing list