/soc/2013/ankitkv/gobjectification: 71bf359300e1: Merged default...

Ankit Vani a at nevitus.org
Mon Jun 24 01:59:46 EDT 2013


Changeset: 71bf359300e185a4d1aad78bb417ce31140c9c78
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-06-24 11:28 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/71bf359300e1

Description:

Merged default branch

diffstat:

 libpurple/obsolete.c                      |   26 +++++--
 libpurple/obsolete.h                      |    2 +
 libpurple/protocols/jabber/jabber.c       |    7 +-
 libpurple/protocols/jabber/jabber.h       |    4 +-
 libpurple/protocols/jabber/useravatar.c   |   43 ++++++-----
 libpurple/protocols/msn/msn.c             |  106 +++++++++++++----------------
 libpurple/protocols/msn/session.c         |    8 +-
 libpurple/protocols/msn/session.h         |    2 +-
 libpurple/protocols/msn/slp.c             |   36 ++++++---
 libpurple/protocols/mxit/formcmds.c       |   24 +++---
 libpurple/protocols/mxit/markup.c         |   28 +++----
 libpurple/protocols/mxit/mxit.h           |    1 +
 libpurple/protocols/mxit/protocol.c       |    4 +
 libpurple/protocols/myspace/myspace.c     |   98 ---------------------------
 libpurple/protocols/myspace/myspace.h     |    4 -
 libpurple/protocols/myspace/user.c        |   35 ++++-----
 libpurple/protocols/myspace/user.h        |    4 +-
 libpurple/protocols/yahoo/libymsg.c       |   39 +++++++---
 libpurple/protocols/yahoo/libymsg.h       |    6 +-
 libpurple/protocols/yahoo/yahoo_picture.c |   41 +++++-----
 libpurple/protocols/yahoo/yahoo_profile.c |   81 ++++++++++------------
 21 files changed, 256 insertions(+), 343 deletions(-)

diffs (truncated from 1288 to 300 lines):

diff --git a/libpurple/obsolete.c b/libpurple/obsolete.c
--- a/libpurple/obsolete.c
+++ b/libpurple/obsolete.c
@@ -23,8 +23,11 @@
 
 #include "internal.h"
 #include "debug.h"
+#include "ntlm.h"
+
+#if 0
 #include "http.h"
-#include "ntlm.h"
+#endif
 
 struct _PurpleUtilFetchUrlData
 {
@@ -65,17 +68,12 @@ struct _PurpleUtilFetchUrlData
 	gboolean chunked;
 	PurpleAccount *account;
 
+#if 0
 	PurpleHttpConnection *wrapped_request;
+#endif
 	gboolean cancelled;
 };
 
-typedef struct
-{
-	PurpleUtilFetchUrlData *url_data;
-	PurpleUtilFetchUrlCallback cb;
-	gpointer user_data;
-} PurpleUtilLegacyWrapData;
-
 /**
  * Parses a URL, returning its host, port, file path, username and password.
  *
@@ -91,6 +89,14 @@ typedef struct
 static gboolean purple_url_parse(const char *url, char **ret_host, int *ret_port,
 	char **ret_path, char **ret_user, char **ret_passwd);
 
+#if 0
+
+typedef struct
+{
+	PurpleUtilFetchUrlData *url_data;
+	PurpleUtilFetchUrlCallback cb;
+	gpointer user_data;
+} PurpleUtilLegacyWrapData;
 
 static void purple_util_fetch_url_cb(PurpleHttpConnection *http_conn,
 	PurpleHttpResponse *response, gpointer _wrap_data)
@@ -144,6 +150,8 @@ PurpleUtilFetchUrlData * purple_util_fet
 	return url_data;
 }
 
+#endif
+
 /**
  * The arguments to this function are similar to printf.
  */
@@ -761,11 +769,13 @@ purple_util_fetch_url_request(PurpleAcco
 void
 purple_util_fetch_url_cancel(PurpleUtilFetchUrlData *gfud)
 {
+#if 0
 	if (gfud->wrapped_request != NULL) {
 		gfud->cancelled = TRUE;
 		purple_http_conn_cancel(gfud->wrapped_request);
 		return;
 	}
+#endif
 
 	if (gfud->ssl_connection != NULL)
 		purple_ssl_close(gfud->ssl_connection);
diff --git a/libpurple/obsolete.h b/libpurple/obsolete.h
--- a/libpurple/obsolete.h
+++ b/libpurple/obsolete.h
@@ -57,6 +57,7 @@ typedef struct _PurpleUtilFetchUrlData P
  */
 typedef void (*PurpleUtilFetchUrlCallback)(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, gsize len, const gchar *error_message);
 
+#if 0
 /**
  * Fetches the data from a URL, and passes it to a callback function.
  *
@@ -72,6 +73,7 @@ typedef void (*PurpleUtilFetchUrlCallbac
 PurpleUtilFetchUrlData * purple_util_fetch_url(const gchar *url, gboolean full,
 	const gchar *user_agent, gboolean http11, gssize max_len,
 	PurpleUtilFetchUrlCallback cb, gpointer data);
+#endif
 
 /**
  * Fetches the data from a URL, and passes it to a callback function.
diff --git a/libpurple/protocols/jabber/jabber.c b/libpurple/protocols/jabber/jabber.c
--- a/libpurple/protocols/jabber/jabber.c
+++ b/libpurple/protocols/jabber/jabber.c
@@ -31,6 +31,7 @@
 #include "conversation.h"
 #include "debug.h"
 #include "dnssrv.h"
+#include "http.h"
 #include "imgstore.h"
 #include "message.h"
 #include "notify.h"
@@ -1642,9 +1643,9 @@ void jabber_close(PurpleConnection *gc)
 		js->bs_proxies = g_list_delete_link(js->bs_proxies, js->bs_proxies);
 	}
 
-	while(js->url_datas) {
-		purple_util_fetch_url_cancel(js->url_datas->data);
-		js->url_datas = g_slist_delete_link(js->url_datas, js->url_datas);
+	while(js->http_conns) {
+		purple_http_conn_cancel(js->http_conns->data);
+		js->http_conns = g_slist_delete_link(js->http_conns, js->http_conns);
 	}
 
 	g_free(js->stream_id);
diff --git a/libpurple/protocols/jabber/jabber.h b/libpurple/protocols/jabber/jabber.h
--- a/libpurple/protocols/jabber/jabber.h
+++ b/libpurple/protocols/jabber/jabber.h
@@ -265,10 +265,10 @@ struct _JabberStream
 	PurpleBOSHConnection *bosh;
 
 	/**
-	 * This linked list contains PurpleUtilFetchUrlData structs
+	 * This linked list contains PurpleHttpConnection structs
 	 * for when we lookup buddy icons from a url
 	 */
-	GSList *url_datas;
+	GSList *http_conns;
 
 	/* keep a hash table of JingleSessions */
 	GHashTable *sessions;
diff --git a/libpurple/protocols/jabber/useravatar.c b/libpurple/protocols/jabber/useravatar.c
--- a/libpurple/protocols/jabber/useravatar.c
+++ b/libpurple/protocols/jabber/useravatar.c
@@ -22,8 +22,8 @@
  */
 
 #include "internal.h"
-#include "obsolete.h"
 
+#include "http.h"
 #include "useravatar.h"
 #include "pep.h"
 #include "debug.h"
@@ -260,22 +260,24 @@ typedef struct _JabberBuddyAvatarUpdateU
 } JabberBuddyAvatarUpdateURLInfo;
 
 static void
-do_buddy_avatar_update_fromurl(PurpleUtilFetchUrlData *url_data,
-                               gpointer user_data, const gchar *url_text,
-                               gsize len, const gchar *error_message)
+do_buddy_avatar_update_fromurl(PurpleHttpConnection *http_conn,
+	PurpleHttpResponse *response, gpointer _info)
 {
-	JabberBuddyAvatarUpdateURLInfo *info = user_data;
+	JabberBuddyAvatarUpdateURLInfo *info = _info;
 	gpointer icon_data;
+	const gchar *got_data;
+	size_t got_len;
 
-	if(!url_text) {
-		purple_debug_error("jabber",
-		             "do_buddy_avatar_update_fromurl got error \"%s\"",
-		             error_message);
+	if (!purple_http_response_is_successfull(response)) {
+		purple_debug_error("jabber", "do_buddy_avatar_update_fromurl "
+			"got error \"%s\"",
+			purple_http_response_get_error(response));
 		goto out;
 	}
 
-	icon_data = g_memdup(url_text, len);
-	purple_buddy_icons_set_for_user(purple_connection_get_account(info->js->gc), info->from, icon_data, len, info->id);
+	got_data = purple_http_response_get_data(response, &got_len);
+	icon_data = g_memdup(got_data, got_len);
+	purple_buddy_icons_set_for_user(purple_connection_get_account(info->js->gc), info->from, icon_data, got_len, info->id);
 
 out:
 	g_free(info->from);
@@ -378,20 +380,19 @@ update_buddy_metadata(JabberStream *js, 
 				jabber_pep_request_item(js, from, NS_AVATAR_1_1_DATA, id,
 				                        do_buddy_avatar_update_data);
 			} else {
-				PurpleUtilFetchUrlData *url_data;
+				PurpleHttpRequest *req;
+				PurpleHttpConnection *http_conn;
 				JabberBuddyAvatarUpdateURLInfo *info = g_new0(JabberBuddyAvatarUpdateURLInfo, 1);
 				info->js = js;
 
-				url_data = purple_util_fetch_url(url, TRUE, NULL, TRUE,
-										  MAX_HTTP_BUDDYICON_BYTES,
-										  do_buddy_avatar_update_fromurl, info);
-				if (url_data) {
-					info->from = g_strdup(from);
-					info->id = g_strdup(id);
-					js->url_datas = g_slist_prepend(js->url_datas, url_data);
-				} else
-					g_free(info);
+				req = purple_http_request_new(url);
+				purple_http_request_set_max_len(req, MAX_HTTP_BUDDYICON_BYTES);
+				http_conn = purple_http_request(js->gc, req, do_buddy_avatar_update_fromurl, info);
+				purple_http_request_unref(req);
 
+				info->from = g_strdup(from);
+				info->id = g_strdup(id);
+				js->http_conns = g_slist_prepend(js->http_conns, http_conn);
 			}
 		}
 	}
diff --git a/libpurple/protocols/msn/msn.c b/libpurple/protocols/msn/msn.c
--- a/libpurple/protocols/msn/msn.c
+++ b/libpurple/protocols/msn/msn.c
@@ -26,8 +26,8 @@
 #include "internal.h"
 
 #include "debug.h"
+#include "http.h"
 #include "request.h"
-#include "obsolete.h"
 
 #include "accountopt.h"
 #include "contact.h"
@@ -2278,8 +2278,8 @@ msn_get_photo_url(const char *url_text)
 	return NULL;
 }
 
-static void msn_got_photo(PurpleUtilFetchUrlData *url_data, gpointer data,
-		const gchar *url_text, gsize len, const gchar *error_message);
+static void msn_got_photo(PurpleHttpConnection *http_conn, PurpleHttpResponse *response,
+	gpointer _info2_data);
 
 #endif
 
@@ -2316,10 +2316,10 @@ msn_info_strip_search_link(const char *f
 }
 
 static void
-msn_got_info(PurpleUtilFetchUrlData *url_data, gpointer data,
-		const gchar *url_text, size_t len, const gchar *error_message)
+msn_got_info(PurpleHttpConnection *http_conn,
+	PurpleHttpResponse *response, gpointer _info_data)
 {
-	MsnGetInfoData *info_data = (MsnGetInfoData *)data;
+	MsnGetInfoData *info_data = _info_data;
 	MsnSession *session;
 	PurpleNotifyUserInfo *user_info;
 	char *stripped, *p, *q, *tmp;
@@ -2331,20 +2331,20 @@ msn_got_info(PurpleUtilFetchUrlData *url
 	gboolean has_contact_info = FALSE;
 	char *url_buffer;
 	int stripped_len;
+	const gchar *got_data;
+	size_t got_len;
 #if PHOTO_SUPPORT
 	char *photo_url_text = NULL;
 	MsnGetInfoStepTwoData *info2_data = NULL;
 #endif
 
-	purple_debug_info("msn", "In msn_got_info,url_text:{%s}\n",url_text);
-
 	session = purple_connection_get_protocol_data(info_data->gc);
-	session->url_datas = g_slist_remove(session->url_datas, url_data);
+	session->http_reqs = g_slist_remove(session->http_reqs, http_conn);
 
 	user_info = purple_notify_user_info_new();
 	has_tooltip_text = msn_tooltip_extract_info_text(user_info, info_data);
 
-	if (error_message != NULL || url_text == NULL || strcmp(url_text, "") == 0)
+	if (!purple_http_response_is_successfull(response))
 	{
 		purple_notify_user_info_add_pair_html(user_info,
 				_("Error retrieving profile"), NULL);
@@ -2357,12 +2357,16 @@ msn_got_info(PurpleUtilFetchUrlData *url
 		return;
 	}
 
-	url_buffer = g_strdup(url_text);
+	got_data = purple_http_response_get_data(response, &got_len);
+
+	purple_debug_info("msn", "In msn_got_info,url_text:{%s}\n", got_data);
+
+	url_buffer = g_strdup(got_data);
 
 	/* If they have a homepage link, MSN masks it such that we need to
 	 * fetch the url out before purple_markup_strip_html() nukes it */
 	/* I don't think this works with the new spaces profiles - Stu 3/2/06 */
-	if ((p = strstr(url_text,
+	if ((p = strstr(url_buffer,
 			"Take a look at my </font><A class=viewDesc title=\"")) != NULL)
 	{
 		p += 50;
@@ -2710,7 +2714,7 @@ msn_got_info(PurpleUtilFetchUrlData *url
 
 #if PHOTO_SUPPORT
 	/* Find the URL to the photo; must be before the marshalling [Bug 994207] */
-	photo_url_text = msn_get_photo_url(url_text);
+	photo_url_text = msn_get_photo_url(got_data);
 	purple_debug_info("msn", "photo url:{%s}\n", photo_url_text ? photo_url_text : "(null)");



More information about the Commits mailing list