/soc/2013/ankitkv/gobjectification: b8d8c1516d74: Merged default...

Ankit Vani a at nevitus.org
Sun Jun 23 04:06:44 EDT 2013


Changeset: b8d8c1516d74458b42b26d751ac0e66d4cad4c29
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-06-23 13:35 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/b8d8c1516d74

Description:

Merged default branch

diffstat:

 .hgignore                                  |   4 +
 libpurple/http.c                           |  26 +++++-----
 libpurple/http.h                           |   2 +-
 libpurple/obsolete.c                       |  18 ++++++-
 libpurple/obsolete.h                       |  16 ------
 libpurple/protocols/jabber/bosh.c          |  26 +++++-----
 libpurple/protocols/jabber/oob.c           |  24 +++++---
 libpurple/protocols/msn/soap.c             |  31 ++++++-----
 libpurple/protocols/mxit/http.c            |   4 +-
 libpurple/protocols/mxit/http.h            |   2 +-
 libpurple/protocols/mxit/protocol.c        |  17 +++--
 libpurple/protocols/yahoo/yahoo_aliases.c  |  48 ++++++++++--------
 libpurple/protocols/yahoo/yahoo_filexfer.c |  46 ++++++++++++++---
 libpurple/protocols/yahoo/yahoochat.c      |  22 +++++++-
 libpurple/proxy.c                          |  62 +++++++++++------------
 libpurple/tests/test_cipher.c              |   8 +-
 libpurple/upnp.c                           |  77 ++++++++++++-----------------
 17 files changed, 242 insertions(+), 191 deletions(-)

diffs (truncated from 1013 to 300 lines):

diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -1,3 +1,6 @@
+syntax: glob
+.*.swp
+
 syntax: regexp
 (.*/)?TAGS$
 (.*/)?\.svn
@@ -72,6 +75,7 @@ libpurple/purple-client-example
 libpurple/purple.h$
 libpurple/tests/check_libpurple
 libpurple/tests/libpurple..
+^libpurple/tests/test-suite\.log$
 libpurple/version.h$
 libpurple/win32/libpurplerc.rc$
 libtool
diff --git a/libpurple/http.c b/libpurple/http.c
--- a/libpurple/http.c
+++ b/libpurple/http.c
@@ -125,7 +125,7 @@ struct _PurpleHttpResponse
 struct _PurpleHttpURL
 {
 	gchar *protocol;
-	gchar *user;
+	gchar *username;
 	gchar *password;
 	gchar *host;
 	int port;
@@ -2118,7 +2118,7 @@ purple_http_url_parse(const char *raw_ur
 			return NULL;
 		}
 
-		url->user = g_match_info_fetch(match_info, 1);
+		url->username = g_match_info_fetch(match_info, 1);
 		url->password = g_match_info_fetch(match_info, 2);
 		url->host = g_match_info_fetch(match_info, 3);
 		port_str = g_match_info_fetch(match_info, 4);
@@ -2126,9 +2126,9 @@ purple_http_url_parse(const char *raw_ur
 		if (port_str && port_str[0])
 			url->port = atoi(port_str);
 
-		if (url->user[0] == '\0') {
-			g_free(url->user);
-			url->user = NULL;
+		if (url->username[0] == '\0') {
+			g_free(url->username);
+			url->username = NULL;
 		}
 		if (url->password[0] == '\0') {
 			g_free(url->password);
@@ -2174,7 +2174,7 @@ purple_http_url_free(PurpleHttpURL *pars
 		return;
 
 	g_free(parsed_url->protocol);
-	g_free(parsed_url->user);
+	g_free(parsed_url->username);
 	g_free(parsed_url->password);
 	g_free(parsed_url->host);
 	g_free(parsed_url->path);
@@ -2191,8 +2191,8 @@ purple_http_url_relative(PurpleHttpURL *
 	if (relative_url->host) {
 		g_free(base_url->protocol);
 		base_url->protocol = g_strdup(relative_url->protocol);
-		g_free(base_url->user);
-		base_url->user = g_strdup(relative_url->user);
+		g_free(base_url->username);
+		base_url->username = g_strdup(relative_url->username);
 		g_free(base_url->password);
 		base_url->password = g_strdup(relative_url->password);
 		g_free(base_url->host);
@@ -2243,9 +2243,9 @@ purple_http_url_print(PurpleHttpURL *par
 			"https"))
 			port_is_default = TRUE;
 	}
-	if (parsed_url->user || parsed_url->password) {
-		if (parsed_url->user)
-			g_string_append(url, parsed_url->user);
+	if (parsed_url->username || parsed_url->password) {
+		if (parsed_url->username)
+			g_string_append(url, parsed_url->username);
 		g_string_append_printf(url, ":%s", parsed_url->password);
 		g_string_append(url, "@");
 		before_host_printed = TRUE;
@@ -2282,11 +2282,11 @@ purple_http_url_get_protocol(const Purpl
 }
 
 const gchar *
-purple_http_url_get_user(const PurpleHttpURL *parsed_url)
+purple_http_url_get_username(const PurpleHttpURL *parsed_url)
 {
 	g_return_val_if_fail(parsed_url != NULL, NULL);
 
-	return parsed_url->user;
+	return parsed_url->username;
 }
 
 const gchar *
diff --git a/libpurple/http.h b/libpurple/http.h
--- a/libpurple/http.h
+++ b/libpurple/http.h
@@ -284,7 +284,7 @@ purple_http_url_get_protocol(const Purpl
  * @return           The username.
  */
 const gchar *
-purple_http_url_get_user(const PurpleHttpURL *parsed_url);
+purple_http_url_get_username(const PurpleHttpURL *parsed_url);
 
 /**
  * Gets the password part of URL.
diff --git a/libpurple/obsolete.c b/libpurple/obsolete.c
--- a/libpurple/obsolete.c
+++ b/libpurple/obsolete.c
@@ -76,6 +76,22 @@ typedef struct
 	gpointer user_data;
 } PurpleUtilLegacyWrapData;
 
+/**
+ * Parses a URL, returning its host, port, file path, username and password.
+ *
+ * The returned data must be freed.
+ *
+ * @param url      The URL to parse.
+ * @param ret_host The returned host.
+ * @param ret_port The returned port.
+ * @param ret_path The returned path.
+ * @param ret_user The returned username.
+ * @param ret_passwd The returned password.
+ */
+static gboolean purple_url_parse(const char *url, char **ret_host, int *ret_port,
+	char **ret_path, char **ret_user, char **ret_passwd);
+
+
 static void purple_util_fetch_url_cb(PurpleHttpConnection *http_conn,
 	PurpleHttpResponse *response, gpointer _wrap_data)
 {
@@ -786,7 +802,7 @@ purple_util_fetch_url_cancel(PurpleUtilF
  *       purple_util_fetch_url() ignores the "https" and attempts to
  *       fetch the URL via http again, which gets redirected again.
  */
-gboolean
+static gboolean
 purple_url_parse(const char *url, char **ret_host, int *ret_port,
 			   char **ret_path, char **ret_user, char **ret_passwd)
 {
diff --git a/libpurple/obsolete.h b/libpurple/obsolete.h
--- a/libpurple/obsolete.h
+++ b/libpurple/obsolete.h
@@ -104,22 +104,6 @@ PurpleUtilFetchUrlData *purple_util_fetc
  */
 void purple_util_fetch_url_cancel(PurpleUtilFetchUrlData *url_data);
 
-/**
- * Parses a URL, returning its host, port, file path, username and password.
- *
- * The returned data must be freed.
- *
- * @param url      The URL to parse.
- * @param ret_host The returned host.
- * @param ret_port The returned port.
- * @param ret_path The returned path.
- * @param ret_user The returned username.
- * @param ret_passwd The returned password.
- */
-gboolean purple_url_parse(const char *url, char **ret_host, int *ret_port,
-						char **ret_path, char **ret_user, char **ret_passwd);
-
-
 /*@}*/
 
 #endif /* _PURPLE_OBSOLETE_H_ */
diff --git a/libpurple/protocols/jabber/bosh.c b/libpurple/protocols/jabber/bosh.c
--- a/libpurple/protocols/jabber/bosh.c
+++ b/libpurple/protocols/jabber/bosh.c
@@ -25,7 +25,7 @@
 #include "core.h"
 #include "cipher.h"
 #include "debug.h"
-#include "obsolete.h"
+#include "http.h"
 #include "prpl.h"
 #include "util.h"
 #include "xmlnode.h"
@@ -200,33 +200,33 @@ PurpleBOSHConnection*
 jabber_bosh_connection_init(JabberStream *js, const char *url)
 {
 	PurpleBOSHConnection *conn;
-	char *host, *path, *user, *passwd;
-	int port;
+	PurpleHttpURL *url_p;
 
-	if (!purple_url_parse(url, &host, &port, &path, &user, &passwd)) {
+	url_p = purple_http_url_parse(url);
+	if (!url_p) {
 		purple_debug_info("jabber", "Unable to parse given URL.\n");
 		return NULL;
 	}
 
 	conn = g_new0(PurpleBOSHConnection, 1);
-	conn->host = host;
-	conn->port = port;
-	conn->path = g_strdup_printf("/%s", path);
-	g_free(path);
+	conn->host = g_strdup(purple_http_url_get_host(url_p));
+	conn->port = purple_http_url_get_port(url_p);
+	conn->path = g_strdup(purple_http_url_get_path(url_p));
 	conn->pipelining = TRUE;
 
-	if (purple_ip_address_is_valid(host))
+	if (purple_ip_address_is_valid(purple_http_url_get_host(url_p)))
 		js->serverFQDN = g_strdup(js->user->domain);
 	else
-		js->serverFQDN = g_strdup(host);
+		js->serverFQDN = g_strdup(purple_http_url_get_host(url_p));
 
-	if ((user && user[0] != '\0') || (passwd && passwd[0] != '\0')) {
+	if (purple_http_url_get_username(url_p) ||
+		purple_http_url_get_password(url_p))
+	{
 		purple_debug_info("jabber", "Ignoring unexpected username and password "
 		                            "in BOSH URL.\n");
 	}
 
-	g_free(user);
-	g_free(passwd);
+	purple_http_url_free(url_p);
 
 	conn->js = js;
 
diff --git a/libpurple/protocols/jabber/oob.c b/libpurple/protocols/jabber/oob.c
--- a/libpurple/protocols/jabber/oob.c
+++ b/libpurple/protocols/jabber/oob.c
@@ -23,7 +23,7 @@
 #include "internal.h"
 #include "debug.h"
 #include "ft.h"
-#include "obsolete.h"
+#include "http.h"
 #include "util.h"
 
 #include "jabber.h"
@@ -200,8 +200,9 @@ void jabber_oob_parse(JabberStream *js, 
 	JabberOOBXfer *jox;
 	PurpleXfer *xfer;
 	char *filename;
-	char *url;
+	char *url_raw;
 	xmlnode *urlnode;
+	PurpleHttpURL *url;
 
 	if(type != JABBER_IQ_SET)
 		return;
@@ -212,15 +213,20 @@ void jabber_oob_parse(JabberStream *js, 
 	if(!(urlnode = xmlnode_get_child(querynode, "url")))
 		return;
 
-	url = xmlnode_get_data(urlnode);
+	url_raw = xmlnode_get_data(urlnode);
+	url = purple_http_url_parse(url_raw);
+	g_free(url_raw);
+
+	if (!url)
+		return;
 
 	jox = g_new0(JabberOOBXfer, 1);
-	if (!purple_url_parse(url, &jox->address, &jox->port, &jox->page, NULL, NULL)) {
-		g_free(url);
-		g_free(jox);
-		return;
-	}
-	g_free(url);
+	jox->address = g_strdup(purple_http_url_get_host(url));
+	jox->port = purple_http_url_get_port(url);
+	jox->page = g_strdup(purple_http_url_get_path(url));
+
+	purple_http_url_free(url);
+
 	jox->js = js;
 	jox->headers = g_string_new("");
 	jox->iq_id = g_strdup(id);
diff --git a/libpurple/protocols/msn/soap.c b/libpurple/protocols/msn/soap.c
--- a/libpurple/protocols/msn/soap.c
+++ b/libpurple/protocols/msn/soap.c
@@ -27,7 +27,7 @@
 
 #include "soap.h"
 
-#include "obsolete.h"
+#include "http.h"
 #include "session.h"
 
 #include "debug.h"
@@ -270,27 +270,28 @@ msn_soap_message_send(MsnSession *sessio
 }
 
 static gboolean
-msn_soap_handle_redirect(MsnSoapConnection *conn, const char *url)
+msn_soap_handle_redirect(MsnSoapConnection *conn, const char *url_raw)
 {



More information about the Commits mailing list