pidgin: e4cc3b79: Improve our error handling of Gnome prox...

markdoliner at pidgin.im markdoliner at pidgin.im
Wed Mar 5 05:05:59 EST 2008


-----------------------------------------------------------------
Revision: e4cc3b79eb04e4937c5fa764f6839a8e07397651
Ancestor: 1da27deca963fa33f3fcef1c925867a8898129ec
Author: markdoliner at pidgin.im
Date: 2008-03-05T10:00:45
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/e4cc3b79eb04e4937c5fa764f6839a8e07397651

Modified files:
        libpurple/proxy.c

ChangeLog: 

Improve our error handling of Gnome proxy settings.
* If the proxy hostname is null then fallback to using Pidgin's
  proxy settings (and print a debug message).
* If a subsequent call to gconftool-2 fails then make sure we free
  the stuff we've already read.

-------------- next part --------------
============================================================
--- libpurple/proxy.c	ece2c08402f8a7f9b92b00259301e1cd68b574c4
+++ libpurple/proxy.c	a9c19b74358163c6be714ad9d454969ae81dc69c
@@ -219,41 +219,66 @@ purple_gnome_proxy_get_info(void)
 
 	g_free(tmp);
 
-	/* See whether to use a proxy. */
-	if (!g_spawn_command_line_sync("gconftool-2 -g /system/proxy/mode", &tmp,
-				       NULL, NULL, NULL))
+	/* Check whether to use a proxy. */
+	if (!g_spawn_command_line_sync("gconftool-2 -g /system/proxy/mode",
+			&tmp, NULL, NULL, NULL))
 		return purple_global_proxy_get_info();
+
 	if (!strcmp(tmp, "none\n")) {
 		info.type = PURPLE_PROXY_NONE;
 		g_free(tmp);
 		return &info;
-	} else if (strcmp(tmp, "manual\n")) {
+	}
+
+	if (strcmp(tmp, "manual\n")) {
+		/* Unknown setting.  Fallback to using our global proxy settings. */
 		g_free(tmp);
 		return purple_global_proxy_get_info();
 	}
 
 	g_free(tmp);
+
+	/* If we get this far then we know we're using an HTTP proxy */
 	info.type = PURPLE_PROXY_HTTP;
 
-	/* Get the new ones */
-	if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/host", &info.host,
-				       NULL, NULL, NULL))
+	if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/host",
+			&info.host, NULL, NULL, NULL))
 		return purple_global_proxy_get_info();
 	g_strchomp(info.host);
+	if (*info.host == '\0')
+	{
+		purple_debug_info("proxy", "Gnome proxy settings are set to "
+				"'manual' but no proxy server is specified.  Using "
+				"Pidgin's proxy settings instead.\n");
+		g_free(info.host);
+		return purple_global_proxy_get_info();
+	}
 
-	if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/authentication_user", &info.username,
-				       NULL, NULL, NULL))
+	if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/authentication_user",
+			&info.username, NULL, NULL, NULL))
+	{
+		g_free(info.host);
 		return purple_global_proxy_get_info();
+	}
 	g_strchomp(info.username);
 
-	if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/authentication_password", &info.password,
-				       NULL, NULL, NULL))
+	if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/authentication_password",
+			&info.password, NULL, NULL, NULL))
+	{
+		g_free(info.host);
+		g_free(info.username);
 		return purple_global_proxy_get_info();
+	}
 	g_strchomp(info.password);
 
-	if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/port", &tmp,
-				       NULL, NULL, NULL))
+	if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/port",
+			&tmp, NULL, NULL, NULL))
+	{
+		g_free(info.host);
+		g_free(info.username);
+		g_free(info.password);
 		return purple_global_proxy_get_info();
+	}
 	info.port = atoi(tmp);
 	g_free(tmp);
 


More information about the Commits mailing list