summaryrefslogtreecommitdiff
path: root/src/trg-client.c
diff options
context:
space:
mode:
authorGravatar Alan Fitton <ajf@eth0.org.uk>2011-03-07 20:39:04 +0000
committerGravatar Alan Fitton <ajf@eth0.org.uk>2011-03-07 20:39:04 +0000
commit4073ac25ea4f0b38bef0ad09664e4e66e6fe7f00 (patch)
tree626f8923ef9ad83f2d47b6dd4f6b3994ca563afd /src/trg-client.c
parentecbd6bbb7423bc9b6f329f937bf740b7dc87598d (diff)
support proxy configuration using libproxy (optional). might add a getenv() fallback sometime.
Diffstat (limited to 'src/trg-client.c')
-rw-r--r--src/trg-client.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/trg-client.c b/src/trg-client.c
index cdbebfc..2353669 100644
--- a/src/trg-client.c
+++ b/src/trg-client.c
@@ -17,10 +17,18 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <string.h>
#include <glib-object.h>
#include <gconf/gconf-client.h>
+#ifdef HAVE_LIBPROXY
+#include <proxy.h>
+#endif
+
#include "trg-client.h"
#include "trg-preferences.h"
@@ -57,6 +65,9 @@ int trg_client_populate_with_settings(trg_client * tc, GConfClient * gconf)
gint port;
gchar *host;
GError *error = NULL;
+#ifdef HAVE_LIBPROXY
+ pxProxyFactory *pf = NULL;
+#endif
g_free(tc->url);
tc->url = NULL;
@@ -97,5 +108,25 @@ int trg_client_populate_with_settings(trg_client * tc, GConfClient * gconf)
gconf_client_get_string(gconf, TRG_GCONF_KEY_PASSWORD, &error);
check_for_error(error);
+ g_free(tc->proxy);
+ tc->proxy = NULL;
+
+#ifdef HAVE_LIBPROXY
+ if ((pf = px_proxy_factory_new())) {
+ char **proxies = px_proxy_factory_get_proxies(pf, tc->url);
+ int i;
+
+ for (i = 0; proxies[i]; i++) {
+ if (g_str_has_prefix(proxies[i], "http")) {
+ g_free(tc->proxy);
+ tc->proxy = g_strdup(proxies[i]);
+ }
+ g_free(proxies[i]);
+ }
+
+ g_free(proxies);
+ }
+#endif
+
return 0;
}