changeset 27036:c3fcdd59ab76

Allow Gadu-Gadu accounts to specify Connect Server. Refs #6691. Modified patch from kreez. Awaiting name for COPYRIGHT/ChangeLog.
author Paul Aurich <paul@darkrain42.org>
date Fri, 05 Jun 2009 05:42:05 +0000
parents b58672890b3f
children f3b0232ef1ea
files libpurple/protocols/gg/gg.c
diffstat 1 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/gg/gg.c	Fri Jun 05 04:27:53 2009 +0000
+++ b/libpurple/protocols/gg/gg.c	Fri Jun 05 05:42:05 2009 +0000
@@ -1759,6 +1759,7 @@
 	PurpleStatus *status;
 	struct gg_login_params *glp;
 	GGPInfo *info;
+	const char *address;
 
 	if (ggp_setup_proxy(account) == -1)
 		return;
@@ -1789,6 +1790,26 @@
 	glp->status = ggp_to_gg_status(status, &glp->status_descr);
 	glp->tls = 0;
 
+	address = purple_account_get_string(account, "gg_server", "");
+	if (address && *address) {
+		struct in_addr *addr = gg_gethostbyname(address);
+
+		purple_debug_info("gg", "Using gg server given by user (%s)\n", address);
+
+		if (addr == NULL) {
+			purple_debug_error("gg", "gg_gethostbyname returned error (%d): %s\n",
+			                   errno, g_strerror(errno));
+			purple_connection_error_reason(gc,
+				PURPLE_CONNECTION_ERROR_NETWORK_ERROR, /* should this be a settings error? */
+				_("Unable to resolve server"));
+			return;
+		}
+
+		glp->server_addr = inet_addr(inet_ntoa(*addr));
+		glp->server_port = 8074;
+	} else
+		purple_debug_info("gg", "Trying to retrieve address from gg appmsg service\n");
+
 	info->session = gg_login(glp);
 	if (info->session == NULL) {
 		purple_connection_error_reason (gc,
@@ -2367,6 +2388,11 @@
 	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
 						   option);
 
+	option = purple_account_option_string_new(_("GG server"),
+			"gg_server", "");
+	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
+			option);
+
 	my_protocol = plugin;
 
 	gg_debug_handler = purple_gg_debug_handler;