Merge "[connman]: Fixed Scan Issue" into tizen
[platform/upstream/connman.git] / src / service.c
index 1fbcc74..1eae380 100755 (executable)
@@ -157,6 +157,13 @@ struct connman_service {
         */
        int user_pdn_connection_refcount;
        bool storage_reload;
+       /*
+        * Description: In case of EAP security type,
+        *                                user can select the keymgmt type for roaming(802.11r).
+        *                                - FT, CCKM, OKC, ...
+        */
+       char *keymgmt_type;
+       int disconnect_reason;
 #endif
 #if defined TIZEN_TV_EXT
        enum connman_dnsconfig_method dns_config_method;
@@ -2765,6 +2772,15 @@ static void append_properties(DBusMessageIter *dict, dbus_bool_t limited,
        const char *str;
        GSList *list;
 
+#if defined TIZEN_EXT
+       unsigned int frequency = 0U;
+       if (service && service->network) {
+               frequency = connman_network_get_frequency(service->network);
+               connman_dbus_dict_append_basic(dict, "Frequency",
+                               DBUS_TYPE_UINT16, &frequency);
+       }
+#endif
+
        str = __connman_service_type2string(service->type);
        if (str)
                connman_dbus_dict_append_basic(dict, "Type",
@@ -2836,6 +2852,10 @@ static void append_properties(DBusMessageIter *dict, dbus_bool_t limited,
 
                connman_dbus_dict_append_dict(dict, "Ethernet",
                                                append_ethernet, service);
+
+               connman_dbus_dict_append_basic(dict, "DisconnectReason",
+                               DBUS_TYPE_INT32, &service->disconnect_reason);
+
                break;
 #endif
        case CONNMAN_SERVICE_TYPE_ETHERNET:
@@ -4020,9 +4040,11 @@ static DBusMessage *set_property(DBusConnection *conn,
                if (err < 0) {
                        if (is_connected_state(service, state) ||
                                        is_connecting_state(service, state)) {
-                               __connman_network_enable_ipconfig(service->network,
+                               if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
+                                       __connman_network_enable_ipconfig(service->network,
                                                        service->ipconfig_ipv4);
-                               __connman_network_enable_ipconfig(service->network,
+                               else
+                                       __connman_network_enable_ipconfig(service->network,
                                                        service->ipconfig_ipv6);
                        }
 
@@ -4035,10 +4057,12 @@ static DBusMessage *set_property(DBusConnection *conn,
                        ipv6_configuration_changed(service);
 
                if (is_connecting(service) || is_connected(service)) {
-                       __connman_network_enable_ipconfig(service->network,
-                                                       service->ipconfig_ipv4);
-                       __connman_network_enable_ipconfig(service->network,
-                                                       service->ipconfig_ipv6);
+                       if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
+                               __connman_network_enable_ipconfig(service->network,
+                                                               service->ipconfig_ipv4);
+                       else
+                               __connman_network_enable_ipconfig(service->network,
+                                                               service->ipconfig_ipv6);
                }
 
                service_save(service);
@@ -4202,31 +4226,6 @@ void __connman_service_set_active_session(bool enable, GSList *list)
                        active_count);
 }
 
-#if defined TIZEN_CONNMAN_USE_BLACKLIST
-static connman_bool_t is_allowed(struct connman_service *service)
-{
-       connman_bool_t allowed;
-       const char *security = NULL;
-
-       if (!service)
-               return false;
-
-       security = security2string(service->security);
-       if (!security)
-               return false;
-
-       /* check if service is existed in blacklist */
-       allowed = __connman_agent_request_blacklist_check(service->name,
-                       security, service->eap);
-       if (allowed == false) {
-               DBG("service %p is not allowed", service);
-               service->autoconnect = false;
-       }
-
-       return allowed;
-}
-#endif
-
 struct preferred_tech_data {
        GList *preferred_list;
        enum connman_service_type type;
@@ -4275,6 +4274,9 @@ static GList *preferred_tech_list_get(void)
                                 */
                                if (service->type == CONNMAN_SERVICE_TYPE_CELLULAR)
                                        break;
+
+                               if (service->type == CONNMAN_SERVICE_TYPE_BLUETOOTH)
+                                       break;
 #endif
                                return NULL;
                        }
@@ -4353,11 +4355,6 @@ static bool auto_connect_service(GList *services,
                                CONNMAN_SERVICE_STATE_IDLE)
                        continue;
 
-#if defined TIZEN_CONNMAN_USE_BLACKLIST
-               if (is_allowed(service) == false)
-                       continue;
-#endif
-
                if (autoconnecting && !active_sessions[service->type]) {
                        DBG("service %p type %s has no users", service,
                                __connman_service_type2string(service->type));
@@ -5937,21 +5934,6 @@ void __connman_service_set_search_domains(struct connman_service *service,
        searchdomain_add_all(service);
 }
 
-#if defined TIZEN_EXT
-void __connman_service_set_autoconnect(struct connman_service *service,
-                                               bool autoconnect)
-{
-       if (service == NULL)
-               return;
-
-       if (service->autoconnect != autoconnect) {
-               DBG("updated autoconnect flag (%d)", autoconnect);
-               service->autoconnect = autoconnect;
-               service_save(service);
-       }
-}
-#endif
-
 static void service_complete(struct connman_service *service)
 {
        reply_pending(service, EIO);
@@ -5975,7 +5957,14 @@ static void report_error_cb(void *user_context, bool retry,
                /* It is not relevant to stay on Failure state
                 * when failing is due to wrong user input */
                __connman_service_clear_error(service);
+#if defined TIZEN_EXT
+               /* Reseting the state back in case of failure state */
+               service->state_ipv4 = service->state_ipv6 =
+                               CONNMAN_SERVICE_STATE_IDLE;
 
+               if (service->error != CONNMAN_SERVICE_ERROR_AUTH_FAILED)
+                       set_error(service, CONNMAN_SERVICE_ERROR_UNKNOWN);
+#endif
                service_complete(service);
                __connman_connection_update_gateway();
        }
@@ -6531,6 +6520,7 @@ static int service_indicate_state(struct connman_service *service)
                reply_pending(service, ECONNABORTED);
 
                def_service = __connman_service_get_default();
+               service->disconnect_reason = connman_network_get_disconnect_reason(service->network);
 
                if (!__connman_notifier_is_connected() &&
                        def_service &&
@@ -6646,6 +6636,11 @@ int __connman_service_indicate_error(struct connman_service *service,
                                service->error == CONNMAN_SERVICE_ERROR_CONNECT_FAILED)
                        __connman_service_disconnect_default(service);
 
+               if (service->type == CONNMAN_SERVICE_TYPE_WIFI &&
+                               service->error == CONNMAN_SERVICE_ERROR_INVALID_KEY) {
+                       g_free(service->passphrase);
+                       service->passphrase = NULL;
+               }
 #endif
 
        __connman_service_ipconfig_indicate_state(service,