From: Chris Leech Date: Fri, 15 Apr 2011 23:48:07 +0000 (-0700) Subject: corewatcher: libproxy support X-Git-Tag: accepted/trunk/20130110.014835~107 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7c912ec86effba4c49f5e359bc445e962a711690;p=platform%2Fupstream%2Fcorewatcher.git corewatcher: libproxy support add libproxy support for automatic proxy selection Signed-off-by: Chris Leech --- diff --git a/Makefile b/Makefile index 319e1e3..87c1c23 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ CC ?= gcc CFLAGS := -O2 -g -fstack-protector -D_FORTIFY_SOURCE=2 -Wall -W -Wstrict-prototypes -Wundef -fno-common -Werror-implicit-function-declaration -Wdeclaration-after-statement -Wformat -Wformat-security -Werror=format-security -MY_CFLAGS := `pkg-config --cflags libnotify gtk+-2.0` +MY_CFLAGS := `pkg-config --cflags libnotify gtk+-2.0 libproxy-1.0` # # pkg-config tends to make programs pull in a ton of libraries, not all # are needed. -Wl,--as-needed tells the linker to just drop unused ones, @@ -20,7 +20,7 @@ MY_CFLAGS := `pkg-config --cflags libnotify gtk+-2.0` # LDF_A := -Wl,--as-needed `pkg-config --libs libnotify gtk+-2.0` LDF_C := -Wl,--as-needed `pkg-config --libs glib-2.0` -LDF_D := -Wl,--as-needed `pkg-config --libs glib-2.0 dbus-glib-1` `curl-config --libs` -Wl,"-z relro" -Wl,"-z now" +LDF_D := -Wl,--as-needed `pkg-config --libs glib-2.0 dbus-glib-1 libproxy-1.0` `curl-config --libs` -Wl,"-z relro" -Wl,"-z now" all: corewatcher corewatcher-config corewatcher-applet corewatcher.8.gz @(cd po/ && $(MAKE) $@) diff --git a/submit.c b/submit.c index 3e58d85..d47e47e 100644 --- a/submit.c +++ b/submit.c @@ -32,6 +32,7 @@ #include +#include #include #include "corewatcher.h" @@ -199,7 +200,7 @@ size_t writefunction( void *ptr, size_t size, size_t nmemb, void __attribute((un return size * nmemb; } -void submit_queue_with_url(struct oops *queue, char *wsubmit_url) +void submit_queue_with_url(struct oops *queue, char *wsubmit_url, char *proxy) { int result; struct oops *oops; @@ -208,6 +209,8 @@ void submit_queue_with_url(struct oops *queue, char *wsubmit_url) handle = curl_easy_init(); curl_easy_setopt(handle, CURLOPT_URL, wsubmit_url); + if (proxy) + curl_easy_setopt(handle, CURLOPT_PROXY, proxy); oops = queue; while (oops) { @@ -289,9 +292,12 @@ void submit_queue_with_url(struct oops *queue, char *wsubmit_url) void submit_queue(void) { - int i; + int i, n; struct oops *queue, *oops, *next; CURL *handle; + pxProxyFactory *pf; + char **proxies = NULL; + char *proxy = NULL; memset(result_url, 0, 4096); @@ -304,19 +310,31 @@ void submit_queue(void) queued_backtraces = NULL; barrier(); + pf = px_proxy_factory_new(); handle = curl_easy_init(); curl_easy_setopt(handle, CURLOPT_NOBODY, 1); curl_easy_setopt(handle, CURLOPT_TIMEOUT, 5); for (i = 0; i < url_count; i++) { curl_easy_setopt(handle, CURLOPT_URL, submit_url[i]); + if (pf) + proxies = px_proxy_factory_get_proxies(pf, submit_url[i]); + if (proxies) { + proxy = proxies[0]; + curl_easy_setopt(handle, CURLOPT_PROXY, proxy); + } else { + proxy = NULL; + } if (!curl_easy_perform(handle)) { - submit_queue_with_url(queue, submit_url[i]); + submit_queue_with_url(queue, submit_url[i], proxy); break; } + for (n = 0; proxies[n]; n++) + free(proxies[n]); + free(proxies); } - + px_proxy_factory_free(pf); oops = queue; while (oops) {