/dev/tomkiewicz/gg11: 2ba83d5d5417: Gadu-Gadu: store server's ho...

Tomasz Wasilczyk tomkiewicz at cpw.pidgin.im
Sat Aug 17 04:19:42 EDT 2013


Changeset: 2ba83d5d54179e883e8d4c2bd95bf3bf43843068
Author:	 Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date:	 2013-08-17 10:19 +0200
Branch:	 default
URL: https://hg.pidgin.im/dev/tomkiewicz/gg11/rev/2ba83d5d5417

Description:

Gadu-Gadu: store server's hostname, instead of IP address, fix memory leak

diffstat:

 libpurple/protocols/gg/gg.c    |  34 +++++++++++++---------------------
 libpurple/protocols/gg/utils.c |  14 --------------
 libpurple/protocols/gg/utils.h |   2 --
 3 files changed, 13 insertions(+), 37 deletions(-)

diffs (119 lines):

diff --git a/libpurple/protocols/gg/gg.c b/libpurple/protocols/gg/gg.c
--- a/libpurple/protocols/gg/gg.c
+++ b/libpurple/protocols/gg/gg.c
@@ -474,12 +474,11 @@ static void ggp_async_login_handler(gpoi
 			break;
 		case GG_EVENT_CONN_SUCCESS:
 			{
-				const gchar * server_ip = ggp_ipv4_to_str(
-					info->session->server_addr);
 				purple_debug_info("gg", "GG_EVENT_CONN_SUCCESS:"
 					" successfully connected to %s\n",
-					server_ip);
-				ggp_servconn_add_server(server_ip);
+					info->session->connect_host);
+				ggp_servconn_add_server(info->session->
+					connect_host);
 				purple_input_remove(info->inpa);
 				info->inpa = purple_input_add(info->session->fd,
 							  PURPLE_INPUT_READ,
@@ -643,7 +642,8 @@ static void ggp_login(PurpleAccount *acc
 
 	purple_connection_set_flags(gc, PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_URLDESC);
 
-	glp = g_new0(struct gg_login_params, 1); // TODO: definitely lost
+	glp = g_new0(struct gg_login_params, 1);
+	glp->struct_size = sizeof(struct gg_login_params);
 	info = g_new0(GGPInfo, 1);
 
 	purple_connection_set_protocol_data(gc, info);
@@ -665,6 +665,7 @@ static void ggp_login(PurpleAccount *acc
 		purple_connection_error(gc,
 			PURPLE_CONNECTION_ERROR_INVALID_USERNAME,
 			_("The username specified is invalid."));
+		g_free(glp->password);
 		g_free(glp);
 		return;
 	}
@@ -695,6 +696,7 @@ static void ggp_login(PurpleAccount *acc
 			purple_connection_error(gc,
 				PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
 				_("SSL support unavailable"));
+			g_free(glp->password);
 			g_free(glp);
 			return;
 		}
@@ -713,31 +715,21 @@ static void ggp_login(PurpleAccount *acc
 		glp->protocol_version = GG_PROTOCOL_VERSION_110;
 
 	ggp_status_set_initial(gc, glp);
-	
+
 	address = purple_account_get_string(account, "gg_server", "");
 	if (address && *address)
-	{
-		glp->server_addr = inet_addr(address);
-		glp->server_port = 8074;
-		
-		if (glp->server_addr == INADDR_NONE)
-		{
-			purple_connection_error(gc,
-				PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
-				_("Provided server IP address is not valid"));
-			g_free(glp);
-			return;
-		}
-	} else
-		purple_debug_info("gg", "Trying to retrieve address from gg appmsg service\n");
+		glp->connect_host = g_strdup(address);
 
 	info->session = gg_login(glp);
+	g_free(glp->connect_host);
+	g_free(glp->password);
+	g_free(glp);
+
 	purple_connection_update_progress(gc, _("Connecting"), 0, 2);
 	if (info->session == NULL) {
 		purple_connection_error (gc,
 			PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
 			_("Connection failed"));
-		g_free(glp);
 		return;
 	}
 	info->inpa = purple_input_add(info->session->fd, PURPLE_INPUT_READ,
diff --git a/libpurple/protocols/gg/utils.c b/libpurple/protocols/gg/utils.c
--- a/libpurple/protocols/gg/utils.c
+++ b/libpurple/protocols/gg/utils.c
@@ -190,20 +190,6 @@ gchar * ggp_strjoin_list(const gchar *se
 	return joined;
 }
 
-const gchar * ggp_ipv4_to_str(uint32_t raw_ip)
-{
-	static gchar buff[INET_ADDRSTRLEN];
-	buff[0] = '\0';
-	
-	g_snprintf(buff, sizeof(buff), "%d.%d.%d.%d",
-		((raw_ip >>  0) & 0xFF),
-		((raw_ip >>  8) & 0xFF),
-		((raw_ip >> 16) & 0xFF),
-		((raw_ip >> 24) & 0xFF));
-	
-	return buff;
-}
-
 GList * ggp_list_truncate(GList *list, gint length, GDestroyNotify free_func)
 {
 	while (g_list_length(list) > length)
diff --git a/libpurple/protocols/gg/utils.h b/libpurple/protocols/gg/utils.h
--- a/libpurple/protocols/gg/utils.h
+++ b/libpurple/protocols/gg/utils.h
@@ -92,8 +92,6 @@ GList * ggp_strsplit_list(const gchar *s
 
 gchar * ggp_strjoin_list(const gchar *separator, GList *list);
 
-const gchar * ggp_ipv4_to_str(uint32_t raw_ip);
-
 GList * ggp_list_truncate(GList *list, gint length, GDestroyNotify free_func);
 
 gchar * ggp_free_if_equal(gchar *str, const gchar *pattern);



More information about the Commits mailing list