diff options
author | Mohamed Abbas <mabbas@linux.intel.com> | 2011-02-03 15:46:29 -0800 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2011-02-04 10:58:55 +0100 |
commit | 1bc70d43943373200b3bbfc69d5a6b8e880a6657 (patch) | |
tree | 8177d73d72275a245781ba2e0c294dad133009ca /plugins | |
parent | b05980e215343dac0bed5a6bb3be1ef97b223166 (diff) | |
download | connman-1bc70d43943373200b3bbfc69d5a6b8e880a6657.tar.gz connman-1bc70d43943373200b3bbfc69d5a6b8e880a6657.tar.bz2 connman-1bc70d43943373200b3bbfc69d5a6b8e880a6657.zip |
proxy: Add implementation for internal proxy framework.
Add support to call registered proxy driver and report
proxy to client.
Also Make sure we cancel proxy request if we got disconnected and still
waiting for proxy request. Also make sure we set/clear token correctly
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/portal.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/plugins/portal.c b/plugins/portal.c index 043caaf9..b2215920 100644 --- a/plugins/portal.c +++ b/plugins/portal.c @@ -39,6 +39,7 @@ #define STATUS_URL "http://www.connman.net/online/status.html" struct server_data { + unsigned int token; GWeb *web; guint request_id; }; @@ -105,10 +106,13 @@ static void proxy_callback(const char *proxy, void *user_data) proxy = getenv("http_proxy"); if (data != NULL) { - g_web_set_proxy(data->web, proxy); + if (proxy != NULL && g_strcmp0(proxy, "DIRECT") != 0) + g_web_set_proxy(data->web, proxy); data->request_id = g_web_request_get(data->web, STATUS_URL, web_result, location); + + data->token = 0; } connman_location_unref(location); @@ -117,6 +121,7 @@ static void proxy_callback(const char *proxy, void *user_data) static int location_detect(struct connman_location *location) { struct server_data *data; + struct connman_service *service; enum connman_service_type service_type; char *interface; int err; @@ -168,13 +173,17 @@ static int location_detect(struct connman_location *location) g_web_set_user_agent(data->web, "ConnMan/%s", VERSION); g_web_set_close_connection(data->web, TRUE); - err = connman_proxy_lookup(interface, STATUS_URL, - proxy_callback, location); - if (err < 0) - goto done; - connman_location_ref(location); - err = 0; + + service = connman_location_get_service(location); + data->token = connman_proxy_lookup(interface, STATUS_URL, + service, proxy_callback, location); + + if (data->token == 0) { + connman_location_unref(location); + err = -EINVAL; + } else + err = 0; done: g_free(interface); @@ -192,6 +201,11 @@ static int location_finish(struct connman_location *location) if (data->request_id > 0) g_web_cancel_request(data->web, data->request_id); + if (data->token > 0) { + connman_proxy_lookup_cancel(data->token); + connman_location_unref(location); + } + g_web_unref(data->web); g_free(data); |