diff options
author | Mark Doliner <markdoliner@pidgin.im> | 2008-03-05 10:00:45 +0000 |
---|---|---|
committer | Mark Doliner <markdoliner@pidgin.im> | 2008-03-05 10:00:45 +0000 |
commit | beedf6bb157e6f664137ef28004482f2c5cbe501 (patch) | |
tree | 51ed92b4fac6195cf67e51902cbd8ce1c6afe6d9 /libpurple/proxy.c | |
parent | dc8446334a6e411dfed14d57fecea13af7745ad1 (diff) | |
download | pidgin-beedf6bb157e6f664137ef28004482f2c5cbe501.tar.gz |
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.
Diffstat (limited to 'libpurple/proxy.c')
-rw-r--r-- | libpurple/proxy.c | 51 |
1 files changed, 38 insertions, 13 deletions
diff --git a/libpurple/proxy.c b/libpurple/proxy.c index 0e02e56c62..ffccbfccc2 100644 --- a/libpurple/proxy.c +++ b/libpurple/proxy.c @@ -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); |