From 540b8c94b2e71bec626a27870bf65f3af15a88b0 Mon Sep 17 00:00:00 2001 From: hyunuktak Date: Mon, 17 Oct 2016 22:19:06 +0900 Subject: [PATCH] Fix some issues TSAM-8953 : unable to save settings in Wifi network infor TSAM-8915 : Wi-Fi network info screen display error Change-Id: Ic30c005b4bc4ea39bec92b6a60201f10512b03ac Signed-off-by: hyunuktak --- sources/libraries/Common/common_ip_info.c | 74 +++++++++++++++++++------ sources/libraries/Common/include/common_utils.h | 1 + 2 files changed, 58 insertions(+), 17 deletions(-) diff --git a/sources/libraries/Common/common_ip_info.c b/sources/libraries/Common/common_ip_info.c index eb10f7e..2fc7573 100755 --- a/sources/libraries/Common/common_ip_info.c +++ b/sources/libraries/Common/common_ip_info.c @@ -42,6 +42,7 @@ static Elm_Genlist_Item_Class description_itc ; static Elm_Genlist_Item_Class ip_entry_itc; static Evas_Object *curr_unfocus_entry = NULL; static int curr_unfocuc_cursor_pos = 0; +static char *ip_info_text_list[ENTRY_TYPE_MAX]; static void _ip_info_set_current_unfocussed_entry(Evas_Object *entry) { @@ -252,6 +253,7 @@ static void _ip_info_entry_cursor_changed_cb(void* data, Evas_Object* obj, void* } g_free(entry_text); + entry_text = NULL; } static void _ip_info_entry_changed_cb(void *data, @@ -289,11 +291,14 @@ static void _ip_info_entry_changed_cb(void *data, ip_text = g_strsplit(entry_text, ".", 5); if (entry_text == NULL || entry_text[0] == '\0') { - if (entry_info->entry_txt) + if (entry_info->entry_txt) { g_free(entry_info->entry_txt); + entry_info->entry_txt = NULL; + } entry_info->entry_txt = g_strdup(DEFAULT_GUIDE_IP); g_free(entry_text); + entry_text = NULL; } else { for (i=0; i<5; i++) { if (ip_text[i] == NULL) { @@ -321,6 +326,8 @@ static void _ip_info_entry_changed_cb(void *data, } g_free(entry_text); g_strfreev(ip_text); + entry_text = NULL; + ip_text = NULL; if (fixed == TRUE) { entry_pos = elm_entry_cursor_pos_get(obj); @@ -346,12 +353,14 @@ static void _ip_info_entry_changed_cb(void *data, } g_free(entry_text); + entry_text = NULL; } else { entry_text = elm_entry_markup_to_utf8(elm_entry_entry_get(obj)); if (entry_text == NULL || *entry_text == '\0') { entry_info->entry_txt = NULL; } g_free(entry_text); + entry_text = NULL; } } @@ -403,6 +412,7 @@ static void _ip_info_entry_unfocused_cb(void *data, Evas_Object *obj, void *even entry_info->entry_txt = g_strdup(entry_text); } g_free(entry_text); + entry_text = NULL; } elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,hide", ""); @@ -611,11 +621,17 @@ static void _ip_info_entry_item_del(void *data, Evas_Object *obj) return; } + g_free(ip_info_text_list[entry_info->entry_id]); + ip_info_text_list[entry_info->entry_id] = NULL; + if (entry_info->entry_txt) { + ip_info_text_list[entry_info->entry_id] = g_strdup(entry_info->entry_txt); g_free(entry_info->entry_txt); + entry_info->entry_txt = NULL; } g_free(entry_info); + entry_info = NULL; } #ifdef ACCESSIBLITY_FEATURE @@ -994,6 +1010,7 @@ static void __ip_info_toggle_item_sel_cb(void* data, ip_info_list_data->ip_toggle_item); g_free(ip_addr); + ip_addr = NULL; ip_info_list_data->ip_type = WIFI_IP_CONFIG_TYPE_DYNAMIC; } else if (ip_type == WIFI_IP_CONFIG_TYPE_STATIC) { @@ -1200,6 +1217,8 @@ full_ip_info_t *ip_info_append_items(wifi_ap_h ap, const char *pkg_name, if (ip_data == NULL) { g_free(prev_ip_info); g_free(ip_info_list_data); + prev_ip_info = NULL; + ip_info_list_data = NULL; return NULL; } @@ -1230,6 +1249,8 @@ full_ip_info_t *ip_info_append_items(wifi_ap_h ap, const char *pkg_name, ip_entry_itc.func.state_get = NULL; ip_entry_itc.func.del = _ip_info_entry_item_del; + elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS); + /* Static/Dynamic switch button */ wifi_ip_config_type_e type = WIFI_IP_CONFIG_TYPE_NONE; ret = wifi_ap_get_ip_config_type(ap, WIFI_ADDRESS_FAMILY_IPV4, &type); @@ -1258,6 +1279,7 @@ full_ip_info_t *ip_info_append_items(wifi_ap_h ap, const char *pkg_name, "IDS_WIFI_BODY_IP_ADDRESS", ip_addr, NULL); g_free(ip_addr); + ip_addr = NULL; } #if 0 @@ -1301,6 +1323,7 @@ full_ip_info_t *ip_info_append_items(wifi_ap_h ap, const char *pkg_name, ip_info_list_data->mac_addr_item = item; g_free(mac_addr); + mac_addr = NULL; #endif ret = wifi_ap_get_proxy_type(ap, &proxy_type); @@ -1324,6 +1347,7 @@ full_ip_info_t *ip_info_append_items(wifi_ap_h ap, const char *pkg_name, proxy_addr = g_strdup(temp); g_free(temp); + temp = NULL; } prev_ip_info->proxy_data = g_strdup(proxy_data); @@ -1366,11 +1390,26 @@ full_ip_info_t *ip_info_append_items(wifi_ap_h ap, const char *pkg_name, ip_info_list_data->proxy_port_item = edit_box_details->item; g_free(proxy_data); + proxy_data = NULL; __COMMON_FUNC_EXIT__; return ip_data; } +static char* get_ip_info_text(entry_id_type_t e) +{ + if (ip_info_text_list[e] != NULL) { + return ip_info_text_list[e]; + } + return NULL; +} + +static void free_ip_info_text(entry_id_type_t e) +{ + g_free(ip_info_text_list[e]); + ip_info_text_list[e] = NULL; +} + void ip_info_save_data(full_ip_info_t *ip_data) { __COMMON_FUNC_ENTER__; @@ -1408,7 +1447,7 @@ void ip_info_save_data(full_ip_info_t *ip_data) } if (WIFI_IP_CONFIG_TYPE_STATIC == ip_info_list_data->ip_type) { - txt = common_utils_get_list_item_entry_txt(ip_info_list_data->ip_addr_item); + txt = get_ip_info_text(ENTRY_TYPE_IP_ADDR); if (!txt) txt = g_strdup(DEFAULT_GUIDE_IP); if (g_strcmp0(prev_ip_info->ip_addr, txt) != 0) { @@ -1418,9 +1457,9 @@ void ip_info_save_data(full_ip_info_t *ip_data) if (ret == WIFI_ERROR_NONE) ip_data->is_info_changed = TRUE; } - g_free(txt); + free_ip_info_text(ENTRY_TYPE_IP_ADDR); - txt = common_utils_get_list_item_entry_txt(ip_info_list_data->subnet_mask_item); + txt = get_ip_info_text(ENTRY_TYPE_SUBNET_MASK); if (!txt) txt = g_strdup(DEFAULT_GUIDE_IP); if (g_strcmp0(prev_ip_info->subnet_mask, txt) != 0) { @@ -1430,9 +1469,9 @@ void ip_info_save_data(full_ip_info_t *ip_data) if (ret == WIFI_ERROR_NONE) ip_data->is_info_changed = TRUE; } - g_free(txt); + free_ip_info_text(ENTRY_TYPE_SUBNET_MASK); - txt = common_utils_get_list_item_entry_txt(ip_info_list_data->gateway_addr_item); + txt = get_ip_info_text(ENTRY_TYPE_GATEWAY); if (!txt) txt = g_strdup(DEFAULT_GUIDE_IP); if (g_strcmp0(prev_ip_info->gateway_addr, txt) != 0) { @@ -1442,9 +1481,9 @@ void ip_info_save_data(full_ip_info_t *ip_data) if (ret == WIFI_ERROR_NONE) ip_data->is_info_changed = TRUE; } - g_free(txt); + free_ip_info_text(ENTRY_TYPE_GATEWAY); - txt = common_utils_get_list_item_entry_txt(ip_info_list_data->dns_1_item); + txt = get_ip_info_text(ENTRY_TYPE_DNS_1); if (!txt) txt = g_strdup(DEFAULT_GUIDE_IP); if (g_strcmp0(prev_ip_info->dns_1, txt) != 0) { @@ -1454,9 +1493,9 @@ void ip_info_save_data(full_ip_info_t *ip_data) if (ret == WIFI_ERROR_NONE) ip_data->is_info_changed = TRUE; } - g_free(txt); + free_ip_info_text(ENTRY_TYPE_DNS_1); - txt = common_utils_get_list_item_entry_txt(ip_info_list_data->dns_2_item); + txt = get_ip_info_text(ENTRY_TYPE_DNS_2); if (!txt) txt = g_strdup(DEFAULT_GUIDE_IP); if (g_strcmp0(prev_ip_info->dns_2, txt) != 0) { @@ -1466,33 +1505,33 @@ void ip_info_save_data(full_ip_info_t *ip_data) if (ret == WIFI_ERROR_NONE) ip_data->is_info_changed = TRUE; } - g_free(txt); + free_ip_info_text(ENTRY_TYPE_DNS_2); } - proxy_addr = common_utils_get_list_item_entry_txt(ip_info_list_data->proxy_addr_item); + proxy_addr = get_ip_info_text(ENTRY_TYPE_PROXY_ADDR); if (proxy_addr == NULL) { DEBUG_LOG(UG_NAME_NORMAL, "Set proxy type - auto"); if (prev_ip_info->proxy_type != WIFI_PROXY_TYPE_AUTO) { wifi_ap_set_proxy_type(ap, WIFI_PROXY_TYPE_AUTO); } } else { - proxy_port = common_utils_get_list_item_entry_txt(ip_info_list_data->proxy_port_item); + proxy_port = txt = get_ip_info_text(ENTRY_TYPE_PROXY_PORT); if (proxy_port) { txt = g_strdup_printf("%s:%s", proxy_addr, proxy_port); } else { txt = g_strdup_printf("%s:%s", proxy_addr, DEFAULT_GUIDE_PROXY_PORT); } - DEBUG_LOG(UG_NAME_NORMAL, "Set proxy type - manual"); + DEBUG_LOG(UG_NAME_NORMAL, "Set proxy type - manual : %s", txt); if (prev_ip_info->proxy_type != WIFI_PROXY_TYPE_MANUAL) { wifi_ap_set_proxy_type(ap, WIFI_PROXY_TYPE_MANUAL); } if (g_strcmp0(prev_ip_info->proxy_data, txt) != 0) { wifi_ap_set_proxy_address(ap, WIFI_ADDRESS_FAMILY_IPV4, txt); } - g_free((gpointer)proxy_addr); - g_free((gpointer)proxy_port); - g_free((gpointer)txt); + + free_ip_info_text(ENTRY_TYPE_PROXY_ADDR); + free_ip_info_text(ENTRY_TYPE_PROXY_PORT); } /* ip_info_print_values(ap); */ @@ -1506,6 +1545,7 @@ void ip_info_remove(ip_info_list_t *ip_info_list) if (ip_info_list) { g_free(ip_info_list); + ip_info_list = NULL; } __COMMON_FUNC_EXIT__; diff --git a/sources/libraries/Common/include/common_utils.h b/sources/libraries/Common/include/common_utils.h index d58700c..6854d15 100755 --- a/sources/libraries/Common/include/common_utils.h +++ b/sources/libraries/Common/include/common_utils.h @@ -49,6 +49,7 @@ typedef enum { ENTRY_TYPE_DNS_2, ENTRY_TYPE_PROXY_ADDR, ENTRY_TYPE_PROXY_PORT, + ENTRY_TYPE_MAX, } entry_id_type_t; typedef struct { -- 2.7.4