Fix to check favorit value into service
[platform/upstream/connman.git] / src / service.c
index a2108bb..001c1f8 100755 (executable)
@@ -2772,14 +2772,6 @@ static void append_properties(DBusMessageIter *dict, dbus_bool_t limited,
        const char *str;
        GSList *list;
 
-       str = __connman_service_type2string(service->type);
-       if (str)
-               connman_dbus_dict_append_basic(dict, "Type",
-                                               DBUS_TYPE_STRING, &str);
-
-       connman_dbus_dict_append_array(dict, "Security",
-                               DBUS_TYPE_STRING, append_security, service);
-
 #if defined TIZEN_EXT
        unsigned int frequency = 0U;
        if (service && service->network) {
@@ -2789,6 +2781,14 @@ static void append_properties(DBusMessageIter *dict, dbus_bool_t limited,
        }
 #endif
 
+       str = __connman_service_type2string(service->type);
+       if (str)
+               connman_dbus_dict_append_basic(dict, "Type",
+                                               DBUS_TYPE_STRING, &str);
+
+       connman_dbus_dict_append_array(dict, "Security",
+                               DBUS_TYPE_STRING, append_security, service);
+
        str = state2string(service->state);
        if (str)
                connman_dbus_dict_append_basic(dict, "State",
@@ -4040,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);
                        }
 
@@ -4055,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);
@@ -4081,8 +4085,10 @@ static void set_error(struct connman_service *service,
        if (!service->path)
                return;
 
+#if !defined TIZEN_EXT
        if (!allow_property_changed(service))
                return;
+#endif
 
        str = error2string(service->error);
 
@@ -4222,31 +4228,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;
@@ -4376,11 +4357,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));
@@ -4645,8 +4621,12 @@ static DBusMessage *connect_service(DBusConnection *conn,
                                        DBusMessage *msg, void *user_data)
 {
        struct connman_service *service = user_data;
+#if defined TIZEN_EXT
+       int err = 0;
+#else
        int index, err = 0;
        GList *list;
+#endif
 
        DBG("service %p", service);
 
@@ -4686,6 +4666,7 @@ static DBusMessage *connect_service(DBusConnection *conn,
                }
        }
 
+#if !defined TIZEN_EXT
        index = __connman_service_get_index(service);
 
        for (list = service_list; list; list = list->next) {
@@ -4711,6 +4692,7 @@ static DBusMessage *connect_service(DBusConnection *conn,
        }
        if (err == -EINPROGRESS)
                return __connman_error_operation_timeout(msg);
+#endif
 
        service->ignore = false;
 
@@ -4807,9 +4789,11 @@ bool __connman_service_remove(struct connman_service *service)
                        __connman_provider_is_immutable(service->provider))
                return false;
 
+#if !defined TIZEN_EXT
        if (!service->favorite && service->state !=
                                                CONNMAN_SERVICE_STATE_FAILURE)
                return false;
+#endif
 
        __connman_service_disconnect(service);
 
@@ -5960,21 +5944,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);
@@ -6043,34 +6012,6 @@ static int check_wpspin(struct connman_service *service, const char *wpspin)
        return 0;
 }
 
-#if defined TIZEN_EXT
-static int __connman_service_connect_hidden(struct connman_service *service,
-                       const char *name, int name_len,
-                       const char *identity, const char *passphrase, void *user_data)
-{
-       GList *list;
-
-       for (list = service_list; list; list = list->next) {
-               struct connman_service *target = list->data;
-               const char *target_ssid = NULL;
-               unsigned int target_ssid_len = 0;
-
-               if (service->network != NULL &&
-                                       service->security == target->security) {
-                       target_ssid = connman_network_get_blob(service->network,
-                                                       "WiFi.SSID", &target_ssid_len);
-                       if (target_ssid_len == name_len &&
-                                                       memcmp(target_ssid, name, name_len) == 0) {
-                               return connman_network_connect_hidden(service->network,
-                                                       (char *)identity, (char *)passphrase, user_data);
-                       }
-               }
-       }
-
-       return -ENOENT;
-}
-#endif
-
 static void request_input_cb(struct connman_service *service,
                        bool values_received,
                        const char *name, int name_len,
@@ -6103,14 +6044,6 @@ static void request_input_cb(struct connman_service *service,
        }
 
        if (service->hidden && name_len > 0 && name_len <= 32) {
-#if defined TIZEN_EXT
-               /* TIZEN already has Wi-Fi hidden scan before this hidden connection */
-               err = __connman_service_connect_hidden(service, name, name_len,
-                                               identity, passphrase, user_data);
-               if (err == 0 || err == -EALREADY || err == -EINPROGRESS)
-                       return;
-#endif
-
                device = connman_network_get_device(service->network);
                security = connman_network_get_string(service->network,
                                                        "WiFi.Security");
@@ -6604,6 +6537,7 @@ static int service_indicate_state(struct connman_service *service)
 #if defined TIZEN_EXT
                if (service->type == CONNMAN_SERVICE_TYPE_WIFI)
                        service->order = 5;
+               __connman_service_auto_connect(CONNMAN_SERVICE_CONNECT_REASON_AUTO);
 #endif
                if (service->connect_reason == CONNMAN_SERVICE_CONNECT_REASON_USER &&
                        connman_agent_report_error(service, service->path,
@@ -6677,6 +6611,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,
@@ -7101,6 +7040,33 @@ static int service_connect(struct connman_service *service)
        if (service->hidden)
                return -EPERM;
 
+#if defined TIZEN_EXT
+       GList *list;
+       int index;
+
+       index = __connman_service_get_index(service);
+
+       for (list = service_list; list; list = list->next) {
+               struct connman_service *temp = list->data;
+
+               if (service->type == CONNMAN_SERVICE_TYPE_CELLULAR)
+                       break;
+
+               if (!is_connecting(temp) && !is_connected(temp))
+                       break;
+
+               if (service == temp)
+                       continue;
+
+               if (service->type != temp->type)
+                       continue;
+
+               if (__connman_service_get_index(temp) == index &&
+                               __connman_service_disconnect(temp) == -EINPROGRESS)
+                       return -EINPROGRESS;
+       }
+#endif
+
        switch (service->type) {
        case CONNMAN_SERVICE_TYPE_UNKNOWN:
        case CONNMAN_SERVICE_TYPE_SYSTEM: