Merge tag 'upstream/1.40' into tizen.
[platform/upstream/connman.git] / src / wispr.c
index 3b203fb..fb101a1 100755 (executable)
@@ -96,6 +96,8 @@ static bool wispr_portal_web_result(GWebResult *result, gpointer user_data);
 
 static GHashTable *wispr_portal_list = NULL;
 
+static bool enable_online_to_ready_transition = false;
+
 static void connman_wispr_message_init(struct connman_wispr_message *msg)
 {
        DBG("");
@@ -454,10 +456,14 @@ static void portal_manage_status(GWebResult *result,
                                &str))
                connman_info("Client-Timezone: %s", str);
 
-       free_connman_wispr_portal_context(wp_context);
+       if (!enable_online_to_ready_transition)
+               free_connman_wispr_portal_context(wp_context);
 
        __connman_service_ipconfig_indicate_state(service,
                                        CONNMAN_SERVICE_STATE_ONLINE, type);
+
+       if (enable_online_to_ready_transition)
+               __connman_service_online_check(service, type, true);
 }
 
 static bool wispr_route_request(const char *address, int ai_family,
@@ -761,7 +767,12 @@ static bool wispr_portal_web_result(GWebResult *result, gpointer user_data)
                                        wp_context->redirect_url, wp_context);
 
                break;
+       case 300:
+       case 301:
        case 302:
+       case 303:
+       case 307:
+       case 308:
                if (!g_web_supports_tls() ||
                        !g_web_result_get_header(result, "Location",
                                                        &redirect)) {
@@ -783,8 +794,8 @@ static bool wispr_portal_web_result(GWebResult *result, gpointer user_data)
                goto done;
        case 400:
        case 404:
-               if (__connman_service_online_check_failed(wp_context->service,
-                                               wp_context->type) == 0) {
+               __connman_service_online_check(wp_context->service,
+                                               wp_context->type, false);
 #if defined TIZEN_MAINTAIN_ONLINE
                        if (wp_context->type == CONNMAN_IPCONFIG_TYPE_IPV4) {
                                if (retried == 0) {
@@ -798,11 +809,6 @@ static bool wispr_portal_web_result(GWebResult *result, gpointer user_data)
                                break;
                        }
 #endif
-                       wispr_portal_error(wp_context);
-                       free_connman_wispr_portal_context(wp_context);
-                       return false;
-               }
-
                break;
        case 505:
                __connman_agent_request_browser(wp_context->service,
@@ -1024,6 +1030,7 @@ int __connman_wispr_start(struct connman_service *service,
 
 void __connman_wispr_stop(struct connman_service *service)
 {
+       struct connman_wispr_portal *wispr_portal;
        int index;
 
        DBG("service %p", service);
@@ -1035,7 +1042,22 @@ void __connman_wispr_stop(struct connman_service *service)
        if (index < 0)
                return;
 
-       g_hash_table_remove(wispr_portal_list, GINT_TO_POINTER(index));
+       wispr_portal = g_hash_table_lookup(wispr_portal_list,
+                                       GINT_TO_POINTER(index));
+       if (!wispr_portal)
+               return;
+
+       if (wispr_portal->ipv4_context) {
+               if (service == wispr_portal->ipv4_context->service)
+                       g_hash_table_remove(wispr_portal_list,
+                                       GINT_TO_POINTER(index));
+       }
+
+       if (wispr_portal->ipv6_context) {
+               if (service == wispr_portal->ipv6_context->service)
+                       g_hash_table_remove(wispr_portal_list,
+                                       GINT_TO_POINTER(index));
+       }
 }
 
 int __connman_wispr_init(void)
@@ -1046,6 +1068,9 @@ int __connman_wispr_init(void)
                                                g_direct_equal, NULL,
                                                free_connman_wispr_portal);
 
+       enable_online_to_ready_transition =
+               connman_setting_get_bool("EnableOnlineToReadyTransition");
+
        return 0;
 }