Fix Wi-Fi open connection 85/13185/1
authortaesub.kim <taesub.kim@samsung.com>
Fri, 29 Nov 2013 04:24:44 +0000 (13:24 +0900)
committertaesub.kim <taesub.kim@samsung.com>
Fri, 29 Nov 2013 04:25:42 +0000 (13:25 +0900)
Change-Id: I67398841ce475f4d67c52e832fced40207ccc073
Signed-off-by: Taesub Kim <taesub.kim@samsung.com>
debian/changelog
packaging/capi-network-wifi.spec
src/libnetwork.c
src/net_wifi.c
src/net_wifi_ap.c

index e272872..f1272cd 100644 (file)
@@ -1,3 +1,11 @@
+capi-network-wifi (0.1.2-19) unstable; urgency=low
+
+  * Fix Wi-Fi open connection
+  * Git: framework/api/wifi
+  * Tag: capi-network-wifi_0.1.2-19
+
+ -- Taesub Kim <taesub.kim@samsung.com>  Fri, 29 Nov 2013 12:04:46 +0900
+
 capi-network-wifi (0.1.2-17) unstable; urgency=low
 
   * Handle NET_ERR_ACTIVE_CONNECTION_EXISTS event and correct the unit of data transfer rate
index 788b1b7..19170c9 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-network-wifi
 Summary:    Network Wi-Fi library in TIZEN C API
-Version:    0.1.2_18
+Version:    0.1.2_19
 Release:    1
 Group:      System/Network
 License:    Apache-2.0
index d472339..df10a8a 100755 (executable)
@@ -390,7 +390,8 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data)
                is_requested = true;
                /* fall through */
        case NET_EVENT_OPEN_IND:
-               if (strstr(event_cb->ProfileName, "/wifi_") == NULL) return;
+               if (_wifi_libnet_check_profile_name_validity(event_cb->ProfileName) != true)
+                       return;
 
                result = __libnet_convert_to_ap_error_type(event_cb->Error);
                WIFI_LOG(WIFI_INFO, "Got Open RSP/IND : %s\n",
@@ -429,7 +430,8 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data)
                is_requested = true;
                /* fall through */
        case NET_EVENT_CLOSE_IND:
-               if (strstr(event_cb->ProfileName, "/wifi_") == NULL) return;
+               if (_wifi_libnet_check_profile_name_validity(event_cb->ProfileName) != true)
+                       return;
 
                result = __libnet_convert_to_ap_error_type(event_cb->Error);
                WIFI_LOG(WIFI_INFO, "Got Close RSP/IND : %s\n",
@@ -440,7 +442,6 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data)
 
                switch (event_cb->Error) {
                case NET_ERR_NONE:
-                       /* Successful PDP Deactivation */
                        WIFI_LOG(WIFI_INFO, "Connection close succeeded!\n");
                        if (net_get_profile_info(event_cb->ProfileName, &prof_info) == NET_ERR_NONE)
                                __libnet_state_changed_cb(event_cb->ProfileName, &prof_info,
@@ -456,7 +457,8 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data)
 
                break;
        case NET_EVENT_NET_STATE_IND:
-               if (strstr(event_cb->ProfileName, "/wifi_") == NULL) return;
+               if (_wifi_libnet_check_profile_name_validity(event_cb->ProfileName) != true)
+                       return;
 
                WIFI_LOG(WIFI_INFO, "Got State changed IND\n");
 
@@ -585,27 +587,21 @@ void _wifi_libnet_remove_from_ap_list(wifi_ap_h ap_h)
 
 bool _wifi_libnet_check_profile_name_validity(const char *profile_name)
 {
-       const char *profile_header = "/net/connman/service/wifi_";
+       const char *profile_prefix = "/net/connman/service/wifi_";
        int i = 0;
-       int string_len = 0;
 
-       if (profile_name == NULL || strlen(profile_name) <= strlen(profile_header)) {
+       if (profile_name == NULL ||
+                       g_str_has_prefix(profile_name, profile_prefix) != TRUE) {
                WIFI_LOG(WIFI_ERROR, "Error!!! Profile name is invalid\n");
                return false;
        }
 
-       string_len = strlen(profile_name);
-
-       if (strncmp(profile_header, profile_name, strlen(profile_header)) == 0) {
-               for (;i < string_len;i++) {
-                       if (isgraph(profile_name[i]) == 0) {
-                               WIFI_LOG(WIFI_ERROR, "Error!!! Profile name is invalid\n");
-                               return false;
-                       }
+       while (profile_name[i] != '\0') {
+               if (isgraph(profile_name[i]) == 0) {
+                       WIFI_LOG(WIFI_ERROR, "Error!!! Profile name is invalid\n");
+                       return false;
                }
-       } else {
-               WIFI_LOG(WIFI_ERROR, "Error!!! Profile name is invalid\n");
-               return false;
+               i++;
        }
 
        return true;
@@ -779,18 +775,23 @@ bool _wifi_libnet_foreach_found_hidden_aps(wifi_found_ap_cb callback, void *user
 
 int _wifi_libnet_open_profile(wifi_ap_h ap_h, wifi_connected_cb callback, void* user_data)
 {
-       net_profile_info_t *ap_info = ap_h;
-       net_profile_name_t profile_name;
        int rv;
+       bool valid_profile;
+       net_profile_name_t profile_name;
+       net_profile_info_t *ap_info = ap_h;
 
        g_strlcpy(profile_name.ProfileName, ap_info->ProfileName, NET_PROFILE_NAME_LEN_MAX+1);
 
-       if (ap_info->ProfileInfo.Wlan.security_info.sec_mode == WLAN_SEC_MODE_IEEE8021X)
-               rv = __libnet_connect_with_wifi_info(ap_info);
-       else if (_wifi_libnet_check_profile_name_validity(ap_info->ProfileName) == false)
-               rv = __libnet_connect_with_wifi_info(ap_info);
-       else
+       valid_profile =
+                       _wifi_libnet_check_profile_name_validity(profile_name.ProfileName);
+
+       if (valid_profile == true && ap_info->Favourite)
+               rv = net_open_connection_with_profile(profile_name.ProfileName);
+       else if (valid_profile == true &&
+                       ap_info->ProfileInfo.Wlan.security_info.sec_mode == WLAN_SEC_MODE_NONE)
                rv = net_open_connection_with_profile(profile_name.ProfileName);
+       else
+               rv = __libnet_connect_with_wifi_info(ap_info);
 
        if (rv != NET_ERR_NONE)
                return WIFI_ERROR_OPERATION_FAILED;
index b46b09f..a722315 100755 (executable)
 #include <string.h>
 #include <glib.h>
 #include <vconf/vconf.h>
+
 #include "net_wifi_private.h"
 
 static bool is_init = false;
 static wifi_rssi_level_changed_cb rssi_level_changed_cb = NULL;
 static void *rssi_level_changed_user_data = NULL;
 
-
 static void __rssi_level_changed_cb(keynode_t *node, void *user_data)
 {
        int rssi_level = vconf_keynode_get_int(node);
index 8c6c1ea..0afee41 100755 (executable)
@@ -20,7 +20,6 @@
 #include <glib.h>
 #include "net_wifi_private.h"
 
-
 static char* __ap_convert_ip_to_string(net_addr_t *ip_addr)
 {
        unsigned char *ipaddr = (unsigned char *)&ip_addr->Data.Ipv4.s_addr;
@@ -29,7 +28,7 @@ static char* __ap_convert_ip_to_string(net_addr_t *ip_addr)
        if (ipstr == NULL)
                return NULL;
 
-       snprintf(ipstr, 16, "%d.%d.%d.%d", ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3]);
+       g_snprintf(ipstr, 16, "%d.%d.%d.%d", ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3]);
 
        return ipstr;
 }
@@ -844,10 +843,7 @@ int wifi_ap_set_passphrase(wifi_ap_h ap, const char* passphrase)
                return WIFI_ERROR_OPERATION_FAILED;
        }
 
-       if (_wifi_libnet_check_profile_name_validity(profile_info->ProfileName) == false)
-               return WIFI_ERROR_NONE;
-
-       return _wifi_update_ap_info(profile_info);
+       return WIFI_ERROR_NONE;
 }
 
 int wifi_ap_is_wps_supported(wifi_ap_h ap, bool* supported)