wispr: Request a browser action through agent api
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Tue, 14 Feb 2012 10:05:43 +0000 (12:05 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 14 Feb 2012 13:55:55 +0000 (14:55 +0100)
src/wispr.c

index 9c45c72..9c0ed43 100644 (file)
@@ -64,6 +64,8 @@ struct connman_wispr_portal_context {
 
        const char *status_url;
 
+       char *redirect_url;
+
        /* WISPr specific */
        GWebParser *wispr_parser;
        struct connman_wispr_message wispr_msg;
@@ -130,6 +132,8 @@ static void free_connman_wispr_portal_context(struct connman_wispr_portal_contex
 
        g_web_unref(wp_context->web);
 
+       g_free(wp_context->redirect_url);
+
        g_web_parser_unref(wp_context->wispr_parser);
        connman_wispr_message_init(&wp_context->wispr_msg);
 
@@ -563,15 +567,23 @@ static gboolean wispr_portal_web_result(GWebResult *result, gpointer user_data)
                if (g_web_result_get_header(result, "X-ConnMan-Status",
                                                                &str) == TRUE)
                        portal_manage_status(result, wp_context);
+               else
+                       __connman_agent_request_browser(wp_context->service,
+                               NULL, wp_context->redirect_url, wp_context);
 
                break;
        case 302:
                if (g_web_result_get_header(result, "Location",
-                                               &redirect) == FALSE)
+                                               &redirect) == FALSE) {
+                       __connman_agent_request_browser(wp_context->service,
+                               NULL, wp_context->status_url, wp_context);
                        break;
+               }
 
                DBG("Redirect URL: %s", redirect);
 
+               wp_context->redirect_url = g_strdup(redirect);
+
                wp_context->request_id = g_web_request_get(wp_context->web,
                                redirect, wispr_portal_web_result, wp_context);