From: taesub.kim Date: Fri, 29 Nov 2013 04:24:44 +0000 (+0900) Subject: Fix Wi-Fi open connection X-Git-Tag: winet_wifi_0.1~35 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8c4569b19c2e939acb7c99c047f93c56b7d2e63c;p=platform%2Fcore%2Fapi%2Fwifi.git Fix Wi-Fi open connection Change-Id: I67398841ce475f4d67c52e832fced40207ccc073 Signed-off-by: Taesub Kim --- diff --git a/debian/changelog b/debian/changelog index e272872..f1272cd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 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 diff --git a/packaging/capi-network-wifi.spec b/packaging/capi-network-wifi.spec index 788b1b7..19170c9 100644 --- a/packaging/capi-network-wifi.spec +++ b/packaging/capi-network-wifi.spec @@ -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 diff --git a/src/libnetwork.c b/src/libnetwork.c index d472339..df10a8a 100755 --- a/src/libnetwork.c +++ b/src/libnetwork.c @@ -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; diff --git a/src/net_wifi.c b/src/net_wifi.c index b46b09f..a722315 100755 --- a/src/net_wifi.c +++ b/src/net_wifi.c @@ -18,13 +18,13 @@ #include #include #include + #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); diff --git a/src/net_wifi_ap.c b/src/net_wifi_ap.c index 8c6c1ea..0afee41 100755 --- a/src/net_wifi_ap.c +++ b/src/net_wifi_ap.c @@ -20,7 +20,6 @@ #include #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)