4 * Copyright 2012 Samsung Electronics Co., Ltd
6 * Licensed under the Flora License, Version 1.1 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.tizenopensource.org/license
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
23 #include "common_utils.h"
25 #include "common_ip_info.h"
26 #include "i18nmanager.h"
28 #define DEFAULT_PROXY_ADDR "0.0.0.0:80"
29 #define IPV4_DEFAULT_ADDR "0.0.0.0"
30 #define IPV6_DEFAULT_ADDR "::"
32 #define MAX_PORT_NUMBER 65535
33 #define MAX_LABEL_LENGTH 512
38 } _view_detail_description_data_t;
40 static Elm_Object_Item* _add_description(Evas_Object* genlist, char* title,
41 char* description, Elm_Object_Item* insert_after);
43 static Elm_Genlist_Item_Class *ip_toggle_itc ;
44 static Elm_Genlist_Item_Class *description_itc ;
45 static Elm_Genlist_Item_Class *ip_entry_itc;
46 static Evas_Object *curr_unfocus_entry = NULL;
47 static int curr_unfocuc_cursor_pos = 0;
48 static char *ip_info_text_list[ENTRY_TYPE_MAX];
50 extern genlist_info_t g_genlist_info[WIFI_GENLIST_STYLE_MAX];
52 static void _ip_info_set_current_unfocussed_entry(Evas_Object *entry)
57 curr_unfocus_entry = entry;
58 curr_unfocuc_cursor_pos = elm_entry_cursor_pos_get(entry);
61 static int _ip_info_is_current_unfocused_entry(Evas_Object *entry)
63 if (curr_unfocus_entry == entry)
64 return curr_unfocuc_cursor_pos;
69 static void _ip_info_reset_current_unfocused_entry(void)
71 curr_unfocus_entry = NULL;
72 curr_unfocuc_cursor_pos = 0;
75 static void _gl_editbox_sel_cb(void *data, Evas_Object *obj, void *event_info)
77 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
78 elm_genlist_item_selected_set(item, FALSE);
81 static void _ip_info_detail_description_del(void *data, Evas_Object *obj)
83 __COMMON_FUNC_ENTER__;
85 retm_if(NULL == data);
87 _view_detail_description_data_t* det = (_view_detail_description_data_t*) data;
89 g_free(det->description);
97 static Evas_Object *_ip_info_detail_description_content_get(void *data,
98 Evas_Object *obj, const char *part)
100 __COMMON_FUNC_ENTER__;
101 retvm_if(NULL == data || NULL == part, NULL);
103 _view_detail_description_data_t* det =
104 (_view_detail_description_data_t*) data;
106 Evas_Object *layout = NULL;
107 Evas_Object *title_label = NULL;
108 UG_TYPE ug_type = common_util_get_ug_type();
109 char buf[MAX_LABEL_LENGTH] = {0, };
110 int font_size = ug_type == UG_VIEW_IOT_COMMON ? 20 : 40;
112 layout = elm_layout_add(obj);
113 if (ug_type == UG_VIEW_IOT_COMMON)
114 elm_layout_file_set(layout, CUSTOM_GENLIST_PATH, "gl_custom_common_item");
116 elm_layout_file_set(layout, CUSTOM_GENLIST_PATH, "gl_custom_item");
118 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
119 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
121 title_label = elm_label_add(obj);
122 snprintf(buf, MAX_LABEL_LENGTH, "<font_size=%d>%s</font_size>",
123 font_size, dgettext(PACKAGE, det->title));
125 elm_object_text_set(title_label, buf);
126 evas_object_size_hint_weight_set(title_label, EVAS_HINT_EXPAND, 0);
127 evas_object_size_hint_align_set(title_label, EVAS_HINT_FILL, EVAS_HINT_FILL);
128 elm_object_part_content_set(layout, "elm.swallow.label", title_label);
130 if (det->description) {
131 snprintf(buf, MAX_LABEL_LENGTH, "%s", dgettext(PACKAGE, det->description));
132 elm_object_text_set(layout, buf);
135 __COMMON_FUNC_EXIT__;
139 static void _ip_info_entry_key_enter_cb(void *data, Evas_Object *obj, void *event_info)
141 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
145 Evas_Object *entry = NULL;
146 Elm_Object_Item *next_item = NULL;
148 switch (entry_info->entry_id) {
149 case ENTRY_TYPE_IP_ADDR:
150 case ENTRY_TYPE_SUBNET_MASK:
151 case ENTRY_TYPE_GATEWAY:
152 case ENTRY_TYPE_DNS_1:
153 case ENTRY_TYPE_PROXY_ADDR:
154 case ENTRY_TYPE_DNS_2:
155 next_item = elm_genlist_item_next_get(entry_info->item);
157 if (elm_object_item_disabled_get(next_item) == EINA_FALSE &&
158 elm_genlist_item_select_mode_get(next_item) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
159 entry = elm_object_item_part_content_get(next_item, "elm.swallow.content");
161 elm_object_focus_set(entry, EINA_TRUE);
166 next_item = elm_genlist_item_next_get(next_item);
169 case ENTRY_TYPE_PROXY_PORT:
170 entry = elm_object_item_part_content_get(entry_info->item, "elm.swallow.content");
172 elm_object_focus_set(entry, EINA_FALSE);
180 static void _ip_info_entry_cursor_changed_cb(void* data, Evas_Object* obj, void* event_info)
182 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
186 if (elm_object_focus_get(obj)) {
187 if (elm_entry_is_empty(obj))
188 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,hide", "");
190 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,show", "");
193 if (entry_info->entry_txt) {
194 g_free(entry_info->entry_txt);
195 entry_info->entry_txt = NULL;
198 char *entry_text = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
199 if (entry_text != NULL && entry_text[0] != '\0')
200 entry_info->entry_txt = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
206 static void _ip_info_entry_changed_cb(void *data,
207 Evas_Object *obj, void *event_info)
209 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
214 char *entry_text = NULL;
215 char **ip_text = NULL;
221 if (elm_object_focus_get(obj)) {
222 if (elm_entry_is_empty(obj))
223 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,hide", "");
225 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,show", "");
228 panel_type = elm_entry_input_panel_layout_get(obj);
229 if (panel_type == ELM_INPUT_PANEL_LAYOUT_IP) {
231 int ip_addr[4] = { 0 };
232 char entry_ip_text[16] = { 0, };
233 gboolean fixed = FALSE;
234 entry_text = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
235 ip_text = g_strsplit(entry_text, ".", 5);
237 if (entry_text == NULL || entry_text[0] == '\0') {
238 if (entry_info->entry_txt) {
239 g_free(entry_info->entry_txt);
240 entry_info->entry_txt = NULL;
243 entry_info->entry_txt = g_strdup(DEFAULT_GUIDE_IP);
247 for (i = 0; i < 5; i++) {
248 if (ip_text[i] == NULL)
256 ip_addr[i] = atoi(ip_text[i]);
257 if (ip_addr[i] > 255) {
263 g_snprintf(entry_text, 5, "%d.", ip_addr[i]);
265 g_snprintf(entry_text, 4, "%d", ip_addr[i]);
267 g_strlcat(entry_ip_text, entry_text, sizeof(entry_ip_text));
275 entry_pos = elm_entry_cursor_pos_get(obj);
276 elm_entry_entry_set(obj, entry_ip_text);
277 elm_entry_cursor_pos_set(obj, entry_pos+1);
280 } else if (panel_type == ELM_INPUT_PANEL_LAYOUT_NUMBERONLY) {
283 entry_text = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
284 if (entry_text == NULL || *entry_text == '\0')
285 entry_info->entry_txt = NULL;
287 if (entry_text != NULL)
288 port_num = (int)strtol(entry_text, NULL, 10);
290 if (port_num > MAX_PORT_NUMBER) {
291 entry_pos = elm_entry_cursor_pos_get(obj);
292 g_snprintf(entry_text, 6, "%d", MAX_PORT_NUMBER);
293 elm_entry_entry_set(obj, entry_text);
294 elm_entry_cursor_pos_set(obj, entry_pos);
300 entry_text = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
301 if (entry_text == NULL || *entry_text == '\0')
302 entry_info->entry_txt = NULL;
309 static void _ip_info_entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
311 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
312 int curr_entry_pos = 0;
317 curr_entry_pos = _ip_info_is_current_unfocused_entry(obj);
320 elm_entry_cursor_pos_set(obj, curr_entry_pos);
322 elm_entry_cursor_end_set(obj);
324 if (!elm_entry_is_empty(obj))
325 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,show", "");
327 elm_object_item_signal_emit(entry_info->item, "elm,state,rename,hide", "");
331 static gboolean __is_valid_static_ip_string_length(const gchar *text)
334 INFO_LOG(UG_NAME_ERR, "IP address text is NULL");
337 size_t len = strlen(text);
338 if (len == 0 || len > 15) {
339 INFO_LOG(UG_NAME_ERR, "IP address text string length is not valid");
346 static void _ip_info_entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
348 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
352 _ip_info_set_current_unfocussed_entry(obj);
354 int panel_type = elm_entry_input_panel_layout_get(obj);
355 if (panel_type == ELM_INPUT_PANEL_LAYOUT_IP) {
356 char *entry_text = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
357 if (!__is_valid_static_ip_string_length(entry_text)) {
358 INFO_LOG(UG_NAME_ERR, "Invalid IP address.");
362 if (entry_text && (strlen(entry_text) > 0)) {
363 elm_entry_entry_set(obj, entry_text);
364 if (entry_info->entry_txt) {
365 g_free(entry_info->entry_txt);
366 entry_info->entry_txt = NULL;
368 entry_info->entry_txt = g_strdup(entry_text);
374 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,hide", "");
375 elm_object_item_signal_emit(entry_info->item, "elm,state,rename,show", "");
378 static void _ip_info_entry_del_callbacks(Elm_Object_Item *item)
383 Evas_Object *entry = NULL;
385 entry = elm_object_item_part_content_get(item, "elm.icon.entry");
389 evas_object_smart_callback_del(entry, "activated",
390 _ip_info_entry_key_enter_cb);
391 evas_object_smart_callback_del(entry, "cursor,changed",
392 _ip_info_entry_cursor_changed_cb);
393 evas_object_smart_callback_del(entry, "changed",
394 _ip_info_entry_changed_cb);
395 evas_object_smart_callback_del(entry, "focused",
396 _ip_info_entry_focused_cb);
397 evas_object_smart_callback_del(entry, "unfocused",
398 _ip_info_entry_unfocused_cb);
401 static void _ip_info_entry_add_callbacks(Evas_Object *entry,
402 common_utils_entry_info_t *entry_info)
407 evas_object_smart_callback_add(entry, "activated",
408 _ip_info_entry_key_enter_cb, entry_info);
409 evas_object_smart_callback_add(entry, "cursor,changed",
410 _ip_info_entry_cursor_changed_cb, entry_info);
411 evas_object_smart_callback_add(entry, "changed",
412 _ip_info_entry_changed_cb, entry_info);
413 evas_object_smart_callback_add(entry, "focused",
414 _ip_info_entry_focused_cb, entry_info);
415 evas_object_smart_callback_add(entry, "unfocused",
416 _ip_info_entry_unfocused_cb, entry_info);
419 static Evas_Object *_ip_info_entry_item_content_get(void *data, Evas_Object *obj, const char *part)
421 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
425 Evas_Object *layout = NULL;
426 Evas_Object *label = NULL;
427 Evas_Object *editfield = NULL;
428 char *guide_txt = NULL;
429 char *accepted = NULL;
430 Elm_Input_Panel_Layout panel_type;
431 UG_TYPE ug_type = common_util_get_ug_type();
433 char buf[MAX_LABEL_LENGTH] = {0, };
434 int font_size = ug_type == UG_VIEW_IOT_COMMON ? 20 : 40;
436 switch (entry_info->entry_id) {
437 case ENTRY_TYPE_IP_ADDR:
438 case ENTRY_TYPE_SUBNET_MASK:
439 case ENTRY_TYPE_GATEWAY:
440 case ENTRY_TYPE_DNS_1:
441 case ENTRY_TYPE_DNS_2:
442 guide_txt = entry_info->guide_txt;
443 panel_type = ELM_INPUT_PANEL_LAYOUT_IP;
444 return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT;
445 accepted = "0123456789.";
447 case ENTRY_TYPE_PROXY_ADDR:
448 guide_txt = DEFAULT_GUIDE_PROXY_IP;
449 panel_type = ELM_INPUT_PANEL_LAYOUT_URL;
450 return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT;
452 /* accepted = "0123456789.abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ"; */
454 case ENTRY_TYPE_PROXY_PORT:
455 guide_txt = DEFAULT_GUIDE_PROXY_PORT;
456 panel_type = ELM_INPUT_PANEL_LAYOUT_NUMBERONLY;
457 return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
458 accepted = "0123456789";
464 layout = elm_layout_add(obj);
465 if (ug_type == UG_VIEW_IOT_COMMON)
466 elm_layout_file_set(layout, CUSTOM_GENLIST_PATH, "gl_custom_common_item");
468 elm_layout_file_set(layout, CUSTOM_GENLIST_PATH, "gl_custom_item");
470 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
471 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
473 snprintf(buf, MAX_LABEL_LENGTH, "<font_size=%d>%s</font_size>",
474 font_size, dgettext(PACKAGE, entry_info->title_txt));
476 label = elm_label_add(obj);
477 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0);
478 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
479 elm_object_text_set(label, buf);
480 elm_object_part_content_set(layout, "elm.swallow.label", label);
482 editfield = elm_entry_add(obj);
483 elm_entry_single_line_set(editfield, EINA_TRUE);
484 elm_entry_scrollable_set(editfield, EINA_TRUE);
486 if (!g_strcmp0(entry_info->str_pkg_name, "wifi-qs"))
487 elm_entry_input_panel_imdata_set(editfield, "type=systempopup", 16);
489 elm_entry_cnp_mode_set(editfield, ELM_CNP_MODE_PLAINTEXT);
491 elm_object_part_text_set(editfield, "elm.guide", guide_txt);
492 if (entry_info->entry_txt && (strlen(entry_info->entry_txt) > 0) &&
493 g_strcmp0(entry_info->entry_txt, DEFAULT_GUIDE_IP) != 0) {
494 elm_entry_entry_set(editfield, entry_info->entry_txt);
497 elm_entry_input_panel_layout_set(editfield, panel_type);
499 Elm_Entry_Filter_Accept_Set digits_filter_data;
500 memset(&digits_filter_data, 0, sizeof(Elm_Entry_Filter_Accept_Set));
501 digits_filter_data.accepted = accepted;
502 elm_entry_markup_filter_append(editfield, elm_entry_filter_accept_set, &digits_filter_data);
504 if (entry_info->input_panel_cb) {
505 Ecore_IMF_Context *imf_ctxt = elm_entry_imf_context_get(editfield);
507 ecore_imf_context_input_panel_event_callback_add(
509 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
510 entry_info->input_panel_cb,
511 entry_info->input_panel_cb_data);
515 elm_entry_input_panel_return_key_type_set(editfield, return_key_type);
516 _ip_info_entry_add_callbacks(editfield, entry_info);
517 elm_object_part_content_set(layout, "elm.swallow.content", editfield);
522 static void _ip_info_entry_item_del(void *data, Evas_Object *obj)
524 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
525 if (entry_info == NULL)
528 g_free(ip_info_text_list[entry_info->entry_id]);
529 ip_info_text_list[entry_info->entry_id] = NULL;
531 if (entry_info->entry_txt) {
532 ip_info_text_list[entry_info->entry_id] = g_strdup(entry_info->entry_txt);
533 g_free(entry_info->entry_txt);
534 entry_info->entry_txt = NULL;
541 #ifdef ACCESSIBLITY_FEATURE
542 static char *_access_info_cb(void *data, Evas_Object *obj)
544 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
548 if (entry_info->entry_txt)
549 return g_strdup_printf("%s %s", entry_info->title_txt, entry_info->entry_txt);
551 return g_strdup_printf("%s %s", entry_info->title_txt, entry_info->guide_txt);
555 static void _create_static_ip_table(full_ip_info_t *ip_data)
558 retm_if(NULL == ip_data);
560 ip_info_list_t *ip_info_list_data = ip_data->ip_info_list;
561 prev_ip_info_t *prev_ip_info = ip_data->prev_ip_info;
562 common_utils_entry_info_t *edit_box_details;
563 wifi_manager_ip_config_type_e ip_type;
565 retm_if(NULL == prev_ip_info || NULL == ip_info_list_data);
566 wifi_manager_ap_h ap = ip_info_list_data->ap;
567 __COMMON_FUNC_ENTER__;
570 int ret = wifi_manager_ap_get_ip_config_type(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &ip_type);
571 if (ret != WIFI_MANAGER_ERROR_NONE)
572 INFO_LOG(UG_NAME_ERR, "Failed to get IP config_type! [%d]", ret);
574 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
575 if (edit_box_details == NULL)
578 edit_box_details->entry_id = ENTRY_TYPE_IP_ADDR;
579 edit_box_details->title_txt = "IDS_WIFI_BODY_IP_ADDRESS";
580 if (ip_type == WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC)
581 edit_box_details->entry_txt = g_strdup(DEFAULT_GUIDE_IP);
583 ret = wifi_manager_ap_get_ip_address(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &txt);
584 if (ret != WIFI_MANAGER_ERROR_NONE)
585 INFO_LOG(UG_NAME_ERR, "Failed to get IP Address! [%d]", ret);
586 edit_box_details->entry_txt = txt;
588 edit_box_details->guide_txt = DEFAULT_GUIDE_IP;
589 edit_box_details->str_pkg_name = ip_info_list_data->str_pkg_name;
590 edit_box_details->input_panel_cb = ip_info_list_data->input_panel_cb;
591 edit_box_details->input_panel_cb_data = ip_info_list_data->input_panel_cb_data;
592 edit_box_details->item = elm_genlist_item_insert_after(
593 ip_info_list_data->genlist, ip_entry_itc,
594 edit_box_details, NULL, ip_info_list_data->ip_toggle_item,
595 ELM_GENLIST_ITEM_NONE, _gl_editbox_sel_cb, NULL);
596 #ifdef ACCESSIBLITY_FEATURE
597 Evas_Object *ao = elm_object_item_access_object_get(edit_box_details->item);
598 elm_access_info_cb_set(ao, ELM_ACCESS_INFO, _access_info_cb, edit_box_details);
600 ip_info_list_data->ip_addr_item = edit_box_details->item;
602 if (ip_data->is_first_create == TRUE)
603 prev_ip_info->ip_addr = g_strdup(txt);
606 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
607 if (edit_box_details == NULL)
610 edit_box_details->entry_id = ENTRY_TYPE_SUBNET_MASK;
611 edit_box_details->title_txt = "IDS_WIFI_BODY_SUBNET_MASK";
612 if (ip_type == WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC)
613 edit_box_details->entry_txt = g_strdup(DEFAULT_GUIDE_IP);
615 ret = wifi_manager_ap_get_subnet_mask(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &txt);
616 if (ret != WIFI_MANAGER_ERROR_NONE)
617 INFO_LOG(UG_NAME_ERR, "Failed to get subnet mask! [%d]", ret);
618 edit_box_details->entry_txt = txt;
620 edit_box_details->guide_txt = DEFAULT_GUIDE_IP;
621 edit_box_details->str_pkg_name = ip_info_list_data->str_pkg_name;
622 edit_box_details->input_panel_cb = ip_info_list_data->input_panel_cb;
623 edit_box_details->input_panel_cb_data = ip_info_list_data->input_panel_cb_data;
624 edit_box_details->item = elm_genlist_item_insert_after(
625 ip_info_list_data->genlist, ip_entry_itc,
626 edit_box_details, NULL, ip_info_list_data->ip_addr_item,
627 ELM_GENLIST_ITEM_NONE, _gl_editbox_sel_cb, NULL);
628 #ifdef ACCESSIBLITY_FEATURE
629 ao = elm_object_item_access_object_get(edit_box_details->item);
630 elm_access_info_cb_set(ao, ELM_ACCESS_INFO, _access_info_cb, edit_box_details);
632 ip_info_list_data->subnet_mask_item = edit_box_details->item;
634 if (ip_data->is_first_create == TRUE)
635 prev_ip_info->subnet_mask = g_strdup(txt);
637 /* Gateway Address */
638 ret = wifi_manager_ap_get_gateway_address(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &txt);
639 if (ret != WIFI_MANAGER_ERROR_NONE)
640 INFO_LOG(UG_NAME_ERR, "Failed to get gateway address! [%d]", ret);
642 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
643 if (edit_box_details == NULL)
646 edit_box_details->entry_id = ENTRY_TYPE_GATEWAY;
647 edit_box_details->title_txt = "IDS_WIFI_BODY_GATEWAY_ADDRESS";
648 edit_box_details->entry_txt = txt;
649 edit_box_details->guide_txt = DEFAULT_GUIDE_IP;
650 edit_box_details->str_pkg_name = ip_info_list_data->str_pkg_name;
651 edit_box_details->input_panel_cb = ip_info_list_data->input_panel_cb;
652 edit_box_details->input_panel_cb_data = ip_info_list_data->input_panel_cb_data;
653 edit_box_details->item = elm_genlist_item_insert_after(
654 ip_info_list_data->genlist, ip_entry_itc,
655 edit_box_details, NULL, ip_info_list_data->subnet_mask_item,
656 ELM_GENLIST_ITEM_NONE, _gl_editbox_sel_cb, NULL);
657 #ifdef ACCESSIBLITY_FEATURE
658 ao = elm_object_item_access_object_get(edit_box_details->item);
659 elm_access_info_cb_set(ao, ELM_ACCESS_INFO, _access_info_cb, edit_box_details);
661 ip_info_list_data->gateway_addr_item = edit_box_details->item;
663 if (ip_data->is_first_create == TRUE)
664 prev_ip_info->gateway_addr = g_strdup(txt);
666 /* Network Prefix Length */
667 Elm_Object_Item* item = NULL;
668 ret = wifi_manager_ap_get_subnet_mask(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV6, &txt);
669 INFO_LOG(UG_NAME_ERR, "Prefix Length = [%s]", txt);
670 if (ret != WIFI_MANAGER_ERROR_NONE)
671 INFO_LOG(UG_NAME_ERR, "Failed to get prefix length! [%d]", ret);
673 item = _add_description(ip_info_list_data->genlist,
674 "IDS_ST_BODY_NETWORK_PREFIX_LENGTH", txt, ip_info_list_data->gateway_addr_item);
675 ip_info_list_data->prefix_length_item = item;
681 ret = wifi_manager_ap_get_dns_address(ap, 1, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &txt);
682 if (ret != WIFI_MANAGER_ERROR_NONE)
683 INFO_LOG(UG_NAME_ERR, "Failed to get DNS 1 Address! [%d]", ret);
685 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
686 if (edit_box_details == NULL)
689 edit_box_details->entry_id = ENTRY_TYPE_DNS_1;
690 edit_box_details->title_txt = "IDS_WIFI_BODY_DNS_1";
691 edit_box_details->entry_txt = txt;
692 edit_box_details->guide_txt = DEFAULT_GUIDE_IP;
693 edit_box_details->str_pkg_name = ip_info_list_data->str_pkg_name;
694 edit_box_details->input_panel_cb = ip_info_list_data->input_panel_cb;
695 edit_box_details->input_panel_cb_data = ip_info_list_data->input_panel_cb_data;
696 edit_box_details->item = elm_genlist_item_insert_after(
697 ip_info_list_data->genlist, ip_entry_itc,
698 edit_box_details, NULL, ip_info_list_data->prefix_length_item,
699 ELM_GENLIST_ITEM_NONE, _gl_editbox_sel_cb, NULL);
700 #ifdef ACCESSIBLITY_FEATURE
701 ao = elm_object_item_access_object_get(edit_box_details->item);
702 elm_access_info_cb_set(ao, ELM_ACCESS_INFO, _access_info_cb, edit_box_details);
704 ip_info_list_data->dns_1_item = edit_box_details->item;
706 if (ip_data->is_first_create == TRUE)
707 prev_ip_info->dns_1 = g_strdup(txt);
710 ret = wifi_manager_ap_get_dns_address(ap, 2, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &txt);
711 if (ret != WIFI_MANAGER_ERROR_NONE)
712 INFO_LOG(UG_NAME_ERR, "Failed to get DNS 2 Address! [%d]", ret);
714 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
715 if (edit_box_details == NULL)
718 edit_box_details->entry_id = ENTRY_TYPE_DNS_2;
719 edit_box_details->title_txt = "IDS_WIFI_BODY_DNS_2";
720 edit_box_details->entry_txt = txt;
721 edit_box_details->guide_txt = DEFAULT_GUIDE_IP;
722 edit_box_details->str_pkg_name = ip_info_list_data->str_pkg_name;
723 edit_box_details->input_panel_cb = ip_info_list_data->input_panel_cb;
724 edit_box_details->input_panel_cb_data = ip_info_list_data->input_panel_cb_data;
725 edit_box_details->item = elm_genlist_item_insert_after(
726 ip_info_list_data->genlist, ip_entry_itc,
727 edit_box_details, NULL, ip_info_list_data->dns_1_item,
728 ELM_GENLIST_ITEM_NONE, _gl_editbox_sel_cb, NULL);
729 #ifdef ACCESSIBLITY_FEATURE
730 ao = elm_object_item_access_object_get(edit_box_details->item);
731 elm_access_info_cb_set(ao, ELM_ACCESS_INFO, _access_info_cb, edit_box_details);
733 ip_info_list_data->dns_2_item = edit_box_details->item;
735 if (ip_data->is_first_create == TRUE)
736 prev_ip_info->dns_2 = g_strdup(txt);
738 ip_data->is_first_create = FALSE;
740 __COMMON_FUNC_EXIT__;
745 static void _delete_static_ip_table(ip_info_list_t *ip_info_list_data)
747 __COMMON_FUNC_ENTER__;
749 retm_if(NULL == ip_info_list_data);
751 _ip_info_reset_current_unfocused_entry();
753 _ip_info_entry_del_callbacks(ip_info_list_data->ip_addr_item);
754 elm_object_item_del(ip_info_list_data->ip_addr_item);
755 ip_info_list_data->ip_addr_item = NULL;
757 _ip_info_entry_del_callbacks(ip_info_list_data->subnet_mask_item);
758 elm_object_item_del(ip_info_list_data->subnet_mask_item);
759 ip_info_list_data->subnet_mask_item = NULL;
761 _ip_info_entry_del_callbacks(ip_info_list_data->gateway_addr_item);
762 elm_object_item_del(ip_info_list_data->gateway_addr_item);
763 ip_info_list_data->gateway_addr_item = NULL;
765 elm_object_item_del(ip_info_list_data->prefix_length_item);
766 ip_info_list_data->prefix_length_item = NULL;
768 _ip_info_entry_del_callbacks(ip_info_list_data->dns_1_item);
769 elm_object_item_del(ip_info_list_data->dns_1_item);
770 ip_info_list_data->dns_1_item = NULL;
772 _ip_info_entry_del_callbacks(ip_info_list_data->dns_2_item);
773 elm_object_item_del(ip_info_list_data->dns_2_item);
774 ip_info_list_data->dns_2_item = NULL;
776 __COMMON_FUNC_EXIT__;
779 static gboolean __genlist_item_disable_later(void *data)
781 elm_genlist_item_selected_set((Elm_Object_Item *)data, FALSE);
786 static void _gl_deselect_callback(void* data,
787 Evas_Object* obj, void* event_info)
789 common_util_managed_idle_add(__genlist_item_disable_later, event_info);
792 static char* _ip_info_iptoggle_text_get(void *data, Evas_Object *obj,
796 retvm_if(NULL == data || NULL == part, NULL);
797 full_ip_info_t *ip_data = (full_ip_info_t *) data;
799 if (!strcmp(g_genlist_info[WIFI_GENLIST_1LINE_STYLE].text_part, part)) {
800 ip_info_list_t *ip_info_list_data = ip_data->ip_info_list;
801 #ifdef ACCESSIBLITY_FEATURE
803 Evas_Object *ao = elm_object_item_access_object_get(ip_info_list_data->ip_toggle_item);
804 g_snprintf(buf, sizeof(buf), "%s%s%s",
805 sc(ip_info_list_data->str_pkg_name, I18N_TYPE_On),
806 sc(ip_info_list_data->str_pkg_name, I18N_TYPE_Off),
807 sc(ip_info_list_data->str_pkg_name, I18N_TYPE_Button));
808 elm_access_info_set(ao, ELM_ACCESS_TYPE, buf);
810 if (WIFI_MANAGER_IP_CONFIG_TYPE_STATIC == ip_info_list_data->ip_type)
811 elm_access_info_set(ao, ELM_ACCESS_STATE, sc(ip_info_list_data->str_pkg_name, I18N_TYPE_On));
813 elm_access_info_set(ao, ELM_ACCESS_STATE, sc(ip_info_list_data->str_pkg_name, I18N_TYPE_Off));
815 return (char*)g_strdup(sc(ip_info_list_data->str_pkg_name, I18N_TYPE_Static_IP));
821 static Elm_Object_Item* _add_description(Evas_Object* genlist, char* title,
822 char* description, Elm_Object_Item* insert_after)
824 retvm_if(NULL == genlist, NULL);
826 _view_detail_description_data_t* description_data =
827 g_try_new0(_view_detail_description_data_t, 1);
828 retvm_if(NULL == description_data, NULL);
830 description_data->title = g_strdup(title);
831 description_data->description = g_strdup(description);
833 Elm_Object_Item* det = NULL;
835 det = elm_genlist_item_insert_after(
837 description_itc,/*itc*/
838 description_data,/*data*/
840 insert_after, /*after than*/
841 ELM_GENLIST_ITEM_NONE, /*flags*/
842 _gl_deselect_callback,/*func*/
845 det = elm_genlist_item_append(
850 ELM_GENLIST_ITEM_NONE,
851 _gl_deselect_callback,
855 elm_genlist_item_select_mode_set(det, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
856 elm_object_item_disabled_set(det, TRUE);
861 static bool __ap_foreach_ipv6_callback(char *ipv6_address, void *user_data)
866 if (!(*buf = (char *)malloc(strlen(ipv6_address) + 1))) {
867 ERROR_LOG(UG_NAME_ERR, "Failed to allocate memory");
871 strncpy(*buf, ipv6_address, strlen(ipv6_address) + 1);
873 if (!(*buf = (char *)realloc(*buf, strlen(*buf) + strlen(ipv6_address) + 5))) {
874 ERROR_LOG(UG_NAME_ERR, "Failed to realloc memory");
877 strncat(*buf, "<br>", 5);
878 strncat(*buf, ipv6_address, strlen(ipv6_address) + 1);
884 static void __ip_info_toggle_item_sel_cb(void* data,
885 Evas_Object* obj, void* event_info)
887 __COMMON_FUNC_ENTER__;
889 const char *object_type;
890 ip_info_list_t *ip_info_list_data = NULL;
891 wifi_manager_ip_config_type_e ip_type = WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC;
892 full_ip_info_t *ip_data = (full_ip_info_t *)data;
893 retm_if(ip_data == NULL);
894 ip_info_list_data = ip_data->ip_info_list;
895 if (ip_info_list_data == NULL) {
896 __COMMON_FUNC_EXIT__;
900 wifi_manager_ap_h ap = ip_info_list_data->ap;
902 object_type = evas_object_type_get(obj);
904 if (g_strcmp0(object_type, "elm_check") == 0) {
905 Eina_Bool ip_mode = elm_check_state_get(obj);
908 ip_type = WIFI_MANAGER_IP_CONFIG_TYPE_STATIC;
910 ip_type = WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC;
911 } else if (g_strcmp0(object_type, "elm_genlist") == 0) {
912 elm_genlist_item_selected_set(ip_info_list_data->ip_toggle_item,
915 if (ip_info_list_data->ip_type == WIFI_MANAGER_IP_CONFIG_TYPE_STATIC)
916 ip_type = WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC;
918 ip_type = WIFI_MANAGER_IP_CONFIG_TYPE_STATIC;
921 if (ip_type == WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC) {
922 char *ip_addr = NULL;
923 char *ipv6_addr = NULL;
925 /* Hide input keypad if popped out */
926 ecore_imf_input_panel_hide();
928 _delete_static_ip_table(ip_info_list_data);
930 wifi_manager_ap_get_ip_address(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &ip_addr);
931 wifi_manager_ap_foreach_ipv6_address(ap, __ap_foreach_ipv6_callback, &ipv6_addr);
933 /* Dynamic IP Address */
934 ip_info_list_data->ip_addr_item = _add_description(
935 ip_info_list_data->genlist,
936 "IDS_WIFI_BODY_IP_ADDRESS",
938 ip_info_list_data->ip_toggle_item);
940 if (g_strcmp0(ip_addr, IPV4_DEFAULT_ADDR) || (!g_strcmp0(ip_addr, IPV4_DEFAULT_ADDR) && !g_strcmp0(ipv6_addr, IPV6_DEFAULT_ADDR)))
941 ip_info_list_data->ipv4_addr_item = _add_description(
942 ip_info_list_data->genlist,
945 ip_info_list_data->ip_addr_item);
947 if (g_strcmp0(ipv6_addr, IPV6_DEFAULT_ADDR)) {
948 if (ip_info_list_data->ipv4_addr_item)
949 ip_info_list_data->ipv6_addr_item = _add_description(
950 ip_info_list_data->genlist,
953 ip_info_list_data->ipv4_addr_item);
955 ip_info_list_data->ipv6_addr_item = _add_description(
956 ip_info_list_data->genlist,
959 ip_info_list_data->ip_addr_item);
969 ip_info_list_data->ip_type = WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC;
970 } else if (ip_type == WIFI_MANAGER_IP_CONFIG_TYPE_STATIC) {
971 elm_object_item_del(ip_info_list_data->ip_addr_item);
972 ip_info_list_data->ip_addr_item = NULL;
974 elm_object_item_del(ip_info_list_data->ipv4_addr_item);
975 ip_info_list_data->ipv4_addr_item = NULL;
977 elm_object_item_del(ip_info_list_data->ipv6_addr_item);
978 ip_info_list_data->ipv6_addr_item = NULL;
980 ip_data->is_first_create = FALSE;
982 /* Create the entry layouts */
983 _create_static_ip_table(ip_data);
984 ip_info_list_data->ip_type = WIFI_MANAGER_IP_CONFIG_TYPE_STATIC;
987 if (ip_info_list_data->ip_toggle_item != NULL)
988 elm_genlist_item_update(ip_info_list_data->ip_toggle_item);
990 __COMMON_FUNC_EXIT__;
993 static Evas_Object *_ip_info_iptoggle_content_get(void *data,
994 Evas_Object *obj, const char *part)
996 __COMMON_FUNC_ENTER__;
998 retvm_if(NULL == data || NULL == obj || NULL == part, NULL);
999 full_ip_info_t *ip_data = (full_ip_info_t *) data;
1000 ip_info_list_t *ip_info_list_data = ip_data->ip_info_list;
1001 Evas_Object *toggle_btn = NULL;
1003 if (!strcmp(g_genlist_info[WIFI_GENLIST_1LINE_STYLE].sub_content_part, part)) {
1004 toggle_btn = elm_check_add(obj);
1005 elm_object_style_set(toggle_btn, "on&off");
1006 elm_object_focus_allow_set(toggle_btn, EINA_FALSE);
1008 if (WIFI_MANAGER_IP_CONFIG_TYPE_STATIC == ip_info_list_data->ip_type)
1009 elm_check_state_set(toggle_btn, EINA_TRUE);
1011 elm_check_state_set(toggle_btn, EINA_FALSE);
1013 evas_object_propagate_events_set(toggle_btn, EINA_FALSE);
1014 evas_object_size_hint_align_set(toggle_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
1015 evas_object_size_hint_weight_set(toggle_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1016 evas_object_smart_callback_add(toggle_btn, "changed",
1017 __ip_info_toggle_item_sel_cb, ip_data);
1020 __COMMON_FUNC_EXIT__;
1025 static void ip_info_print_values(wifi_manager_ap_h ap)
1028 wifi_manager_ip_config_type_e type = WIFI_MANAGER_IP_CONFIG_TYPE_NONE;
1030 wifi_manager_ap_get_ip_config_type(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &type);
1031 if (WIFI_MANAGER_IP_CONFIG_TYPE_STATIC == type) {
1032 DEBUG_LOG(UG_NAME_NORMAL, "* STATIC CONFIGURATION *");
1035 wifi_manager_ap_get_ip_address(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &txt);
1036 SECURE_DEBUG_LOG(UG_NAME_NORMAL, "* IP address [%s]", txt);
1040 wifi_manager_ap_get_subnet_mask(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &txt);
1041 SECURE_DEBUG_LOG(UG_NAME_NORMAL, "* Subnet Mask [%s]", txt);
1044 /* Gateway Address */
1045 wifi_manager_ap_get_gateway_address(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &txt);
1046 SECURE_DEBUG_LOG(UG_NAME_NORMAL, "* Gateway address [%s]", txt);
1050 wifi_manager_ap_get_dns_address(ap, 1, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &txt);
1051 SECURE_DEBUG_LOG(UG_NAME_NORMAL, "* DNS-1 address [%s]", txt);
1055 wifi_manager_ap_get_dns_address(ap, 2, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &txt);
1056 SECURE_DEBUG_LOG(UG_NAME_NORMAL, "* DNS-2 address [%s]", txt);
1059 } else if (WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC == type) {
1060 DEBUG_LOG(UG_NAME_NORMAL, "* DYNAMIC CONFIGURATION *");
1062 /* Dynamic IP Address */
1063 wifi_manager_ap_get_ip_address(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &txt);
1064 SECURE_DEBUG_LOG(UG_NAME_NORMAL, "* IP address [%s]", txt);
1069 wifi_get_mac_address(&txt);
1070 SECURE_DEBUG_LOG(UG_NAME_NORMAL, "* MAC address [%s]", txt);
1074 wifi_manager_ap_get_proxy_address(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &txt);
1075 assertm_if(NULL == txt, "NULL!!");
1077 if (!txt || !strlen(txt)) {
1080 txt = g_strdup(DEFAULT_PROXY_ADDR);
1084 char *save_str = NULL;
1085 char *proxy_addr = strtok_r(txt, ":", &save_str);
1086 SECURE_DEBUG_LOG(UG_NAME_NORMAL, "* PROXY ADDR [%s]", proxy_addr);
1089 char *proxy_port = strtok_r(NULL, ":", &save_str);
1090 SECURE_DEBUG_LOG(UG_NAME_NORMAL, "* PROXY PORT [%s]", proxy_port);
1095 #define EMULATOR_MAC_ADDR_SIZE 6
1096 #define EMULATOR_MAC_ADDR_MAX 20
1097 static int ip_info_emulator_get_random_mac(unsigned char *buf)
1099 __COMMON_FUNC_ENTER__;
1104 fp = fopen("/dev/urandom", "rb");
1106 ERROR_LOG(UG_NAME_ERR, "Could not open /dev/urandom");
1110 rc = fread(buf, 1, EMULATOR_MAC_ADDR_SIZE, fp);
1114 return rc != EMULATOR_MAC_ADDR_SIZE ? -1 : 0;
1117 void ip_info_delete_prev(prev_ip_info_t *prev_ip_info)
1119 retm_if(NULL == prev_ip_info);
1121 __COMMON_FUNC_ENTER__;
1123 g_free(prev_ip_info->ip_addr);
1124 g_free(prev_ip_info->subnet_mask);
1125 g_free(prev_ip_info->gateway_addr);
1126 g_free(prev_ip_info->dns_1);
1127 g_free(prev_ip_info->dns_2);
1128 g_free(prev_ip_info->proxy_data);
1129 g_free(prev_ip_info);
1131 __COMMON_FUNC_EXIT__;
1134 full_ip_info_t *ip_info_append_items(wifi_manager_ap_h ap, const char *pkg_name,
1135 Evas_Object *genlist, imf_ctxt_panel_cb_t input_panel_cb, void *input_panel_cb_data)
1137 __COMMON_FUNC_ENTER__;
1138 int ret = WIFI_MANAGER_ERROR_NONE;
1139 char *proxy_data = NULL;
1140 char *proxy_addr = NULL;
1141 char *proxy_port = NULL;
1142 Elm_Object_Item* item = NULL;
1143 common_utils_entry_info_t *edit_box_details;
1144 wifi_manager_proxy_type_e proxy_type;
1145 char *ip_addr = NULL;
1146 char *ipv6_addr = NULL;
1149 full_ip_info_t *ip_data = NULL;
1150 assertm_if(NULL == ap, "NULL!!");
1151 assertm_if(NULL == pkg_name, "NULL!!");
1152 assertm_if(NULL == genlist, "NULL!!");
1154 prev_ip_info_t *prev_ip_info = g_try_new0(prev_ip_info_t, 1);
1155 if (prev_ip_info == NULL)
1158 ip_info_list_t *ip_info_list_data = g_try_new0(ip_info_list_t, 1);
1159 if (ip_info_list_data == NULL) {
1160 g_free(prev_ip_info);
1161 prev_ip_info = NULL;
1166 ip_data = g_try_new0(full_ip_info_t, 1);
1167 if (ip_data == NULL) {
1168 g_free(prev_ip_info);
1169 g_free(ip_info_list_data);
1170 prev_ip_info = NULL;
1171 ip_info_list_data = NULL;
1175 ip_data->ip_info_list = ip_info_list_data;
1176 ip_data->prev_ip_info = prev_ip_info;
1178 ip_info_list_data->ap = ap;
1179 ip_info_list_data->str_pkg_name = pkg_name;
1180 ip_info_list_data->genlist = genlist;
1181 ip_info_list_data->input_panel_cb = input_panel_cb;
1182 ip_info_list_data->input_panel_cb_data = input_panel_cb_data;
1184 ip_toggle_itc = elm_genlist_item_class_new();
1185 ip_toggle_itc->item_style = g_genlist_info[WIFI_GENLIST_1LINE_STYLE].style_name;
1186 ip_toggle_itc->func.text_get = _ip_info_iptoggle_text_get;
1187 ip_toggle_itc->func.content_get = _ip_info_iptoggle_content_get;
1188 ip_toggle_itc->func.state_get = NULL;
1189 ip_toggle_itc->func.del = NULL;
1191 description_itc = elm_genlist_item_class_new();
1192 description_itc->item_style = g_genlist_info[WIFI_GENLIST_FULL_STYLE].style_name;
1193 description_itc->func.text_get = NULL;
1194 description_itc->func.content_get = _ip_info_detail_description_content_get;
1195 description_itc->func.state_get = NULL;
1196 description_itc->func.del = _ip_info_detail_description_del;
1198 ip_entry_itc = elm_genlist_item_class_new();
1199 ip_entry_itc->item_style = g_genlist_info[WIFI_GENLIST_FULL_STYLE].style_name;
1200 ip_entry_itc->func.text_get = NULL;
1201 ip_entry_itc->func.content_get = _ip_info_entry_item_content_get;
1202 ip_entry_itc->func.state_get = NULL;
1203 ip_entry_itc->func.del = _ip_info_entry_item_del;
1205 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1207 /* Static/Dynamic switch button */
1208 wifi_manager_ip_config_type_e type = WIFI_MANAGER_IP_CONFIG_TYPE_NONE;
1209 ret = wifi_manager_ap_get_ip_config_type(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &type);
1210 if (ret != WIFI_MANAGER_ERROR_NONE)
1211 INFO_LOG(UG_NAME_ERR, "Failed to get ip config type! [%d]", ret);
1213 ip_info_list_data->ip_type = type;
1214 ip_info_list_data->ip_toggle_item = elm_genlist_item_append(genlist,
1215 ip_toggle_itc, ip_data, NULL, ELM_GENLIST_ITEM_NONE,
1216 __ip_info_toggle_item_sel_cb, ip_data);
1218 prev_ip_info->ip_type = type;
1221 if (WIFI_MANAGER_IP_CONFIG_TYPE_STATIC == type) {
1222 ip_data->is_first_create = TRUE;
1224 /* Create the entry layouts */
1225 _create_static_ip_table(ip_data);
1226 } else if (WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC == type) {
1227 wifi_manager_ap_get_ip_address(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &ip_addr);
1228 wifi_manager_ap_foreach_ipv6_address(ap, __ap_foreach_ipv6_callback, &ipv6_addr);
1230 prev_ip_info->ip_addr = g_strdup(ip_addr);
1232 ip_info_list_data->ip_addr_item = _add_description(genlist,
1233 "IDS_WIFI_BODY_IP_ADDRESS", NULL, NULL);
1235 if (g_strcmp0(ip_addr, IPV4_DEFAULT_ADDR) || (!g_strcmp0(ip_addr, IPV4_DEFAULT_ADDR) && !g_strcmp0(ipv6_addr, IPV6_DEFAULT_ADDR)))
1236 ip_info_list_data->ipv4_addr_item = _add_description(genlist,
1237 "IDS_ST_BODY_IPV4", ip_addr, NULL);
1239 if (g_strcmp0(ipv6_addr, IPV6_DEFAULT_ADDR))
1240 ip_info_list_data->ipv6_addr_item = _add_description(genlist,
1241 "IDS_ST_BODY_IPV6", ipv6_addr, NULL);
1250 if (_is_emulator()) {
1251 char rand_addr[EMULATOR_MAC_ADDR_MAX];
1252 unsigned char rand_mac_add[EMULATOR_MAC_ADDR_SIZE + 1];
1253 if (ip_info_emulator_get_random_mac(rand_mac_add) == -1) {
1254 ERROR_LOG(UG_NAME_ERR, "Failed to get random mac address");
1258 rand_mac_add[0] &= 0xFE;
1259 rand_mac_add[0] |= 0x02;
1261 snprintf(rand_addr, EMULATOR_MAC_ADDR_MAX, "%x:%x:%x:%x:%x:%x",
1262 rand_mac_add[0], rand_mac_add[1],
1263 rand_mac_add[2], rand_mac_add[3],
1264 rand_mac_add[4], rand_mac_add[5]);
1265 item = _add_description(genlist,
1266 "IDS_WIFI_BODY_MAC_ADDRESS", rand_addr, NULL);
1267 ip_info_list_data->mac_addr_item = item;
1269 char *mac_addr = NULL;
1271 ret = wifi_manager_ap_get_bssid(ap, &mac_addr);
1272 if (ret != WIFI_MANAGER_ERROR_NONE)
1273 INFO_LOG(UG_NAME_ERR, "Failed to get bssid! [%d]", ret);
1275 item = _add_description(genlist,
1276 "IDS_WIFI_BODY_MAC_ADDRESS", mac_addr, NULL);
1277 ip_info_list_data->mac_addr_item = item;
1283 ret = wifi_manager_ap_get_proxy_type(ap, &proxy_type);
1284 assertm_if(WIFI_MANAGER_ERROR_NONE != ret, "NULL!!");
1285 prev_ip_info->proxy_type = proxy_type;
1287 ret = wifi_manager_ap_get_proxy_address(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &proxy_data);
1288 assertm_if(NULL == proxy_data, "NULL!!");
1290 if (WIFI_MANAGER_ERROR_NONE == ret && proxy_data && strlen(proxy_data)) {
1291 temp = g_strdup(proxy_data);
1294 str2 = strrchr(temp, ':');
1296 proxy_port = g_strdup(str2 + 1);
1301 proxy_addr = g_strdup(temp);
1307 prev_ip_info->proxy_data = g_strdup(proxy_data);
1309 ERROR_LOG(UG_NAME_ERR, "Error = %d", ret);
1312 edit_box_details = g_new0(common_utils_entry_info_t, 1);
1313 edit_box_details->str_pkg_name = pkg_name;
1314 edit_box_details->entry_id = ENTRY_TYPE_PROXY_ADDR;
1315 edit_box_details->title_txt = "IDS_ST_SBODY_PROXY_ADDRESS";
1316 edit_box_details->entry_txt = proxy_addr;
1317 edit_box_details->guide_txt = DEFAULT_GUIDE_PROXY_IP;
1318 edit_box_details->input_panel_cb = input_panel_cb;
1319 edit_box_details->input_panel_cb_data = input_panel_cb_data;
1320 edit_box_details->item = elm_genlist_item_append(genlist, ip_entry_itc,
1321 edit_box_details, NULL, ELM_GENLIST_ITEM_NONE,
1322 _gl_editbox_sel_cb, NULL);
1323 #ifdef ACCESSIBLITY_FEATURE
1324 Evas_Object *ao = elm_object_item_access_object_get(edit_box_details->item);
1325 elm_access_info_cb_set(ao, ELM_ACCESS_INFO, _access_info_cb, edit_box_details);
1327 ip_info_list_data->proxy_addr_item = edit_box_details->item;
1329 edit_box_details = g_new0(common_utils_entry_info_t, 1);
1330 edit_box_details->str_pkg_name = pkg_name;
1331 edit_box_details->entry_id = ENTRY_TYPE_PROXY_PORT;
1332 edit_box_details->title_txt = "IDS_ST_SBODY_PROXY_PORT";
1333 edit_box_details->entry_txt = proxy_port;
1334 edit_box_details->guide_txt = DEFAULT_GUIDE_PROXY_PORT;
1335 edit_box_details->input_panel_cb = input_panel_cb;
1336 edit_box_details->input_panel_cb_data = input_panel_cb_data;
1337 edit_box_details->item = elm_genlist_item_append(genlist, ip_entry_itc,
1338 edit_box_details, NULL, ELM_GENLIST_ITEM_NONE,
1339 _gl_editbox_sel_cb, NULL);
1340 #ifdef ACCESSIBLITY_FEATURE
1341 ao = elm_object_item_access_object_get(edit_box_details->item);
1342 elm_access_info_cb_set(ao, ELM_ACCESS_INFO, _access_info_cb, edit_box_details);
1344 ip_info_list_data->proxy_port_item = edit_box_details->item;
1349 __COMMON_FUNC_EXIT__;
1353 static char* get_ip_info_text(entry_id_type_t e)
1355 if (ip_info_text_list[e] != NULL)
1356 return ip_info_text_list[e];
1361 static void free_ip_info_text(entry_id_type_t e)
1363 g_free(ip_info_text_list[e]);
1364 ip_info_text_list[e] = NULL;
1367 void ip_info_save_data(full_ip_info_t *ip_data)
1369 __COMMON_FUNC_ENTER__;
1370 retm_if(ip_data == NULL);
1371 ip_info_list_t *ip_info_list_data = ip_data->ip_info_list;
1372 prev_ip_info_t *prev_ip_info = ip_data->prev_ip_info;
1373 retm_if(NULL == ip_info_list_data || NULL == prev_ip_info);
1376 char* proxy_addr = NULL;
1377 char* proxy_port = NULL;
1378 wifi_manager_ap_h ap = ip_info_list_data->ap;
1379 int ret = WIFI_MANAGER_ERROR_NONE;
1380 ip_data->is_info_changed = FALSE;
1382 if (prev_ip_info->ip_type != ip_info_list_data->ip_type) {
1383 if (WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC == ip_info_list_data->ip_type) {
1384 /* Reset the DNS addresses if dynamic */
1385 ret = wifi_manager_ap_set_dns_address(ap, 1,
1386 WIFI_MANAGER_ADDRESS_FAMILY_IPV4, DEFAULT_GUIDE_IP);
1387 if (ret == WIFI_MANAGER_ERROR_NONE)
1388 ip_data->is_info_changed = TRUE;
1390 ret = wifi_manager_ap_set_dns_address(ap, 2,
1391 WIFI_MANAGER_ADDRESS_FAMILY_IPV4, DEFAULT_GUIDE_IP);
1392 if (ret == WIFI_MANAGER_ERROR_NONE)
1393 ip_data->is_info_changed = TRUE;
1394 ip_info_list_data->dns_type = WIFI_MANAGER_DNS_CONFIG_TYPE_DYNAMIC;
1396 } else if (WIFI_MANAGER_IP_CONFIG_TYPE_STATIC == ip_info_list_data->ip_type) {
1397 ip_info_list_data->dns_type = WIFI_MANAGER_DNS_CONFIG_TYPE_STATIC;
1400 ret = wifi_manager_ap_set_ip_config_type(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4,
1401 ip_info_list_data->ip_type);
1402 retm_if(WIFI_MANAGER_ERROR_NONE != ret);
1404 ret = wifi_manager_ap_set_dns_config_type(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4,
1405 ip_info_list_data->dns_type);
1406 retm_if(WIFI_MANAGER_ERROR_NONE != ret);
1408 ip_data->is_info_changed = TRUE;
1411 if (WIFI_MANAGER_IP_CONFIG_TYPE_STATIC == ip_info_list_data->ip_type) {
1412 txt = g_strdup(get_ip_info_text(ENTRY_TYPE_IP_ADDR));
1414 txt = g_strdup(DEFAULT_GUIDE_IP);
1415 if (g_strcmp0(prev_ip_info->ip_addr, txt) != 0) {
1416 ret = wifi_manager_ap_set_ip_address(ap,
1417 WIFI_MANAGER_ADDRESS_FAMILY_IPV4, txt);
1419 if (ret == WIFI_MANAGER_ERROR_NONE)
1420 ip_data->is_info_changed = TRUE;
1422 free_ip_info_text(ENTRY_TYPE_IP_ADDR);
1425 txt = g_strdup(get_ip_info_text(ENTRY_TYPE_SUBNET_MASK));
1427 txt = g_strdup(DEFAULT_GUIDE_IP);
1428 if (g_strcmp0(prev_ip_info->subnet_mask, txt) != 0) {
1429 ret = wifi_manager_ap_set_subnet_mask(ap,
1430 WIFI_MANAGER_ADDRESS_FAMILY_IPV4, txt);
1432 if (ret == WIFI_MANAGER_ERROR_NONE)
1433 ip_data->is_info_changed = TRUE;
1435 free_ip_info_text(ENTRY_TYPE_SUBNET_MASK);
1438 txt = g_strdup(get_ip_info_text(ENTRY_TYPE_GATEWAY));
1440 txt = g_strdup(DEFAULT_GUIDE_IP);
1441 if (g_strcmp0(prev_ip_info->gateway_addr, txt) != 0) {
1442 ret = wifi_manager_ap_set_gateway_address(ap,
1443 WIFI_MANAGER_ADDRESS_FAMILY_IPV4, txt);
1445 if (ret == WIFI_MANAGER_ERROR_NONE)
1446 ip_data->is_info_changed = TRUE;
1448 free_ip_info_text(ENTRY_TYPE_GATEWAY);
1451 txt = g_strdup(get_ip_info_text(ENTRY_TYPE_DNS_1));
1453 txt = g_strdup(DEFAULT_GUIDE_IP);
1454 if (g_strcmp0(prev_ip_info->dns_1, txt) != 0) {
1455 ret = wifi_manager_ap_set_dns_address(ap, 1,
1456 WIFI_MANAGER_ADDRESS_FAMILY_IPV4, txt);
1458 if (ret == WIFI_MANAGER_ERROR_NONE)
1459 ip_data->is_info_changed = TRUE;
1461 free_ip_info_text(ENTRY_TYPE_DNS_1);
1464 txt = g_strdup(get_ip_info_text(ENTRY_TYPE_DNS_2));
1466 txt = g_strdup(DEFAULT_GUIDE_IP);
1467 if (g_strcmp0(prev_ip_info->dns_2, txt) != 0) {
1468 ret = wifi_manager_ap_set_dns_address(ap, 2,
1469 WIFI_MANAGER_ADDRESS_FAMILY_IPV4, txt);
1471 if (ret == WIFI_MANAGER_ERROR_NONE)
1472 ip_data->is_info_changed = TRUE;
1474 free_ip_info_text(ENTRY_TYPE_DNS_2);
1478 proxy_addr = g_strdup(get_ip_info_text(ENTRY_TYPE_PROXY_ADDR));
1479 if (proxy_addr == NULL) {
1480 DEBUG_LOG(UG_NAME_NORMAL, "Set proxy type - auto");
1481 if (prev_ip_info->proxy_type != WIFI_MANAGER_PROXY_TYPE_AUTO)
1482 if (wifi_manager_ap_set_proxy_type(ap, WIFI_MANAGER_PROXY_TYPE_AUTO)
1483 != WIFI_MANAGER_ERROR_NONE)
1484 ERROR_LOG(UG_NAME_NORMAL, "Fail to set proxy type");
1486 proxy_port = g_strdup(get_ip_info_text(ENTRY_TYPE_PROXY_PORT));
1488 txt = g_strdup_printf("%s:%s", proxy_addr, proxy_port);
1490 txt = g_strdup_printf("%s:%s", proxy_addr, DEFAULT_GUIDE_PROXY_PORT);
1492 DEBUG_LOG(UG_NAME_NORMAL, "Set proxy type - manual : %s", txt);
1493 if (prev_ip_info->proxy_type != WIFI_MANAGER_PROXY_TYPE_MANUAL) {
1494 if (wifi_manager_ap_set_proxy_type(ap, WIFI_MANAGER_PROXY_TYPE_MANUAL)
1495 != WIFI_MANAGER_ERROR_NONE)
1496 ERROR_LOG(UG_NAME_NORMAL, "Fail to set proxy type");
1499 if (g_strcmp0(prev_ip_info->proxy_data, txt) != 0) {
1500 if (wifi_manager_ap_set_proxy_address(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, txt)
1501 != WIFI_MANAGER_ERROR_NONE)
1502 ERROR_LOG(UG_NAME_NORMAL, "Fail to set proxy address");
1505 free_ip_info_text(ENTRY_TYPE_PROXY_ADDR);
1506 free_ip_info_text(ENTRY_TYPE_PROXY_PORT);
1516 /* ip_info_print_values(ap); */
1518 __COMMON_FUNC_EXIT__;
1521 void ip_info_remove(ip_info_list_t *ip_info_list)
1523 __COMMON_FUNC_ENTER__;
1526 g_free(ip_info_list);
1528 __COMMON_FUNC_EXIT__;
1531 void ip_info_close_all_keypads(ip_info_list_t *ip_info_list)
1533 __COMMON_FUNC_ENTER__;
1535 if (!ip_info_list) {
1536 __COMMON_FUNC_EXIT__;
1540 if (WIFI_MANAGER_IP_CONFIG_TYPE_STATIC == ip_info_list->ip_type) {
1541 if (ip_info_list->ip_addr_item)
1542 common_utils_edit_box_focus_set(ip_info_list->ip_addr_item, EINA_FALSE);
1543 if (ip_info_list->subnet_mask_item)
1544 common_utils_edit_box_focus_set(ip_info_list->subnet_mask_item, EINA_FALSE);
1545 if (ip_info_list->gateway_addr_item)
1546 common_utils_edit_box_focus_set(ip_info_list->gateway_addr_item, EINA_FALSE);
1547 if (ip_info_list->dns_1_item)
1548 common_utils_edit_box_focus_set(ip_info_list->dns_1_item, EINA_FALSE);
1549 if (ip_info_list->dns_2_item)
1550 common_utils_edit_box_focus_set(ip_info_list->dns_2_item, EINA_FALSE);
1551 if (ip_info_list->proxy_addr_item)
1552 common_utils_edit_box_focus_set(ip_info_list->proxy_addr_item, EINA_FALSE);
1553 if (ip_info_list->proxy_port_item)
1554 common_utils_edit_box_focus_set(ip_info_list->proxy_port_item, EINA_FALSE);
1556 __COMMON_FUNC_EXIT__;
1559 void ip_info_enable_all_keypads(ip_info_list_t *ip_info_list)
1561 __COMMON_FUNC_ENTER__;
1563 if (!ip_info_list) {
1564 __COMMON_FUNC_EXIT__;
1568 if (WIFI_MANAGER_IP_CONFIG_TYPE_STATIC == ip_info_list->ip_type) {
1569 if (ip_info_list->ip_addr_item)
1570 common_utils_edit_box_allow_focus_set(ip_info_list->ip_addr_item, EINA_TRUE);
1571 if (ip_info_list->subnet_mask_item)
1572 common_utils_edit_box_allow_focus_set(ip_info_list->subnet_mask_item, EINA_TRUE);
1573 if (ip_info_list->gateway_addr_item)
1574 common_utils_edit_box_allow_focus_set(ip_info_list->gateway_addr_item, EINA_TRUE);
1575 if (ip_info_list->dns_1_item)
1576 common_utils_edit_box_allow_focus_set(ip_info_list->dns_1_item, EINA_TRUE);
1577 if (ip_info_list->dns_2_item)
1578 common_utils_edit_box_allow_focus_set(ip_info_list->dns_2_item, EINA_TRUE);
1579 if (ip_info_list->proxy_addr_item)
1580 common_utils_edit_box_allow_focus_set(ip_info_list->proxy_addr_item, EINA_TRUE);
1581 if (ip_info_list->proxy_port_item)
1582 common_utils_edit_box_allow_focus_set(ip_info_list->proxy_port_item, EINA_TRUE);
1584 __COMMON_FUNC_EXIT__;