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.
24 #include "common_ip_info.h"
25 #include "i18nmanager.h"
27 #define DEFAULT_PROXY_ADDR "0.0.0.0:80"
29 #define MAX_PORT_NUMBER 65535
30 #define MAX_LABEL_LENGTH 512
35 } _view_detail_description_data_t;
37 static Elm_Object_Item* _add_description(Evas_Object* genlist, char* title,
38 char* description, Elm_Object_Item* insert_after);
40 static Elm_Genlist_Item_Class *ip_toggle_itc ;
41 static Elm_Genlist_Item_Class *description_itc ;
42 static Elm_Genlist_Item_Class *ip_entry_itc;
43 static Evas_Object *curr_unfocus_entry = NULL;
44 static int curr_unfocuc_cursor_pos = 0;
45 static char *ip_info_text_list[ENTRY_TYPE_MAX];
47 static void _ip_info_set_current_unfocussed_entry(Evas_Object *entry)
52 curr_unfocus_entry = entry;
53 curr_unfocuc_cursor_pos = elm_entry_cursor_pos_get(entry);
56 static int _ip_info_is_current_unfocused_entry(Evas_Object *entry)
58 if (curr_unfocus_entry == entry)
59 return curr_unfocuc_cursor_pos;
64 static void _ip_info_reset_current_unfocused_entry(void)
66 curr_unfocus_entry = NULL;
67 curr_unfocuc_cursor_pos = 0;
70 static void _gl_editbox_sel_cb(void *data, Evas_Object *obj, void *event_info)
72 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
73 elm_genlist_item_selected_set(item, FALSE);
76 static void _ip_info_detail_description_del(void *data, Evas_Object *obj)
78 __COMMON_FUNC_ENTER__;
80 retm_if(NULL == data);
82 _view_detail_description_data_t* det = (_view_detail_description_data_t*) data;
84 g_free(det->description);
92 static Evas_Object *_ip_info_detail_description_content_get(void *data,
93 Evas_Object *obj, const char *part)
95 __COMMON_FUNC_ENTER__;
96 retvm_if(NULL == data || NULL == part, NULL);
98 _view_detail_description_data_t* det =
99 (_view_detail_description_data_t*) data;
101 Evas_Object *layout = NULL;
102 Evas_Object *title_label = NULL;
103 char buf[MAX_LABEL_LENGTH] = {0, };
105 layout = elm_layout_add(obj);
106 elm_layout_file_set(layout, CUSTOM_GENLIST_PATH, "gl_custom_item");
107 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
108 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
110 title_label = elm_label_add(obj);
111 snprintf(buf, MAX_LABEL_LENGTH, "<font_size=40>%s</font_size>", dgettext(PACKAGE, det->title));
113 elm_object_text_set(title_label, buf);
114 evas_object_size_hint_weight_set(title_label, EVAS_HINT_EXPAND, 0);
115 evas_object_size_hint_align_set(title_label, EVAS_HINT_FILL, EVAS_HINT_FILL);
116 elm_object_part_content_set(layout, "elm.swallow.label", title_label);
118 snprintf(buf, MAX_LABEL_LENGTH, "%s", dgettext(PACKAGE, det->description));
119 elm_object_text_set(layout, buf);
121 __COMMON_FUNC_EXIT__;
125 static void _ip_info_entry_key_enter_cb(void *data, Evas_Object *obj, void *event_info)
127 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
131 Evas_Object *entry = NULL;
132 Elm_Object_Item *next_item = NULL;
134 switch (entry_info->entry_id) {
135 case ENTRY_TYPE_IP_ADDR:
136 case ENTRY_TYPE_SUBNET_MASK:
137 case ENTRY_TYPE_GATEWAY:
138 case ENTRY_TYPE_DNS_1:
139 case ENTRY_TYPE_PROXY_ADDR:
140 case ENTRY_TYPE_DNS_2:
141 next_item = elm_genlist_item_next_get(entry_info->item);
143 if (elm_object_item_disabled_get(next_item) == EINA_FALSE &&
144 elm_genlist_item_select_mode_get(next_item) != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
145 entry = elm_object_item_part_content_get(next_item, "elm.swallow.content");
147 elm_object_focus_set(entry, EINA_TRUE);
152 next_item = elm_genlist_item_next_get(next_item);
155 case ENTRY_TYPE_PROXY_PORT:
156 entry = elm_object_item_part_content_get(entry_info->item, "elm.swallow.content");
158 elm_object_focus_set(entry, EINA_FALSE);
166 static void _ip_info_entry_cursor_changed_cb(void* data, Evas_Object* obj, void* event_info)
168 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
172 if (elm_object_focus_get(obj)) {
173 if (elm_entry_is_empty(obj))
174 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,hide", "");
176 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,show", "");
179 if (entry_info->entry_txt) {
180 g_free(entry_info->entry_txt);
181 entry_info->entry_txt = NULL;
184 char *entry_text = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
185 if (entry_text != NULL && entry_text[0] != '\0')
186 entry_info->entry_txt = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
192 static void _ip_info_entry_changed_cb(void *data,
193 Evas_Object *obj, void *event_info)
195 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
200 char *entry_text = NULL;
201 char **ip_text = NULL;
207 if (elm_object_focus_get(obj)) {
208 if (elm_entry_is_empty(obj))
209 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,hide", "");
211 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,show", "");
214 panel_type = elm_entry_input_panel_layout_get(obj);
215 if (panel_type == ELM_INPUT_PANEL_LAYOUT_IP) {
217 int ip_addr[4] = { 0 };
218 char entry_ip_text[16] = { 0, };
219 gboolean fixed = FALSE;
220 entry_text = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
221 ip_text = g_strsplit(entry_text, ".", 5);
223 if (entry_text == NULL || entry_text[0] == '\0') {
224 if (entry_info->entry_txt) {
225 g_free(entry_info->entry_txt);
226 entry_info->entry_txt = NULL;
229 entry_info->entry_txt = g_strdup(DEFAULT_GUIDE_IP);
233 for (i = 0; i < 5; i++) {
234 if (ip_text[i] == NULL)
242 ip_addr[i] = atoi(ip_text[i]);
243 if (ip_addr[i] > 255) {
249 g_snprintf(entry_text, 5, "%d.", ip_addr[i]);
251 g_snprintf(entry_text, 4, "%d", ip_addr[i]);
253 g_strlcat(entry_ip_text, entry_text, sizeof(entry_ip_text));
261 entry_pos = elm_entry_cursor_pos_get(obj);
262 elm_entry_entry_set(obj, entry_ip_text);
263 elm_entry_cursor_pos_set(obj, entry_pos+1);
266 } else if (panel_type == ELM_INPUT_PANEL_LAYOUT_NUMBERONLY) {
269 entry_text = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
270 if (entry_text == NULL || *entry_text == '\0')
271 entry_info->entry_txt = NULL;
273 if (entry_text != NULL)
274 port_num = (int)strtol(entry_text, NULL, 10);
276 if (port_num > MAX_PORT_NUMBER) {
277 entry_pos = elm_entry_cursor_pos_get(obj);
278 g_snprintf(entry_text, 6, "%d", MAX_PORT_NUMBER);
279 elm_entry_entry_set(obj, entry_text);
280 elm_entry_cursor_pos_set(obj, entry_pos);
286 entry_text = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
287 if (entry_text == NULL || *entry_text == '\0')
288 entry_info->entry_txt = NULL;
295 static void _ip_info_entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
297 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
298 int curr_entry_pos = 0;
303 curr_entry_pos = _ip_info_is_current_unfocused_entry(obj);
306 elm_entry_cursor_pos_set(obj, curr_entry_pos);
308 elm_entry_cursor_end_set(obj);
310 if (!elm_entry_is_empty(obj))
311 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,show", "");
313 elm_object_item_signal_emit(entry_info->item, "elm,state,rename,hide", "");
317 static gboolean __is_valid_static_ip_string_length(const gchar *text)
320 INFO_LOG(UG_NAME_ERR, "IP address text is NULL");
323 size_t len = strlen(text);
324 if (len == 0 || len > 15) {
325 INFO_LOG(UG_NAME_ERR, "IP address text string length is not valid");
332 static void _ip_info_entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
334 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
338 _ip_info_set_current_unfocussed_entry(obj);
340 int panel_type = elm_entry_input_panel_layout_get(obj);
341 if (panel_type == ELM_INPUT_PANEL_LAYOUT_IP) {
342 int ip_addr[4] = {0};
343 char *entry_text = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
344 if (!__is_valid_static_ip_string_length(entry_text)) {
345 INFO_LOG(UG_NAME_ERR, "Invalid IP address.");
349 if (entry_text && (strlen(entry_text) > 0)) {
350 elm_entry_entry_set(obj, entry_text);
351 if (entry_info->entry_txt) {
352 g_free(entry_info->entry_txt);
353 entry_info->entry_txt = NULL;
355 entry_info->entry_txt = g_strdup(entry_text);
361 elm_object_item_signal_emit(entry_info->item, "elm,state,eraser,hide", "");
362 elm_object_item_signal_emit(entry_info->item, "elm,state,rename,show", "");
365 static void _ip_info_entry_del_callbacks(Elm_Object_Item *item)
370 Evas_Object *entry = NULL;
372 entry = elm_object_item_part_content_get(item, "elm.icon.entry");
376 evas_object_smart_callback_del(entry, "activated",
377 _ip_info_entry_key_enter_cb);
378 evas_object_smart_callback_del(entry, "cursor,changed",
379 _ip_info_entry_cursor_changed_cb);
380 evas_object_smart_callback_del(entry, "changed",
381 _ip_info_entry_changed_cb);
382 evas_object_smart_callback_del(entry, "focused",
383 _ip_info_entry_focused_cb);
384 evas_object_smart_callback_del(entry, "unfocused",
385 _ip_info_entry_unfocused_cb);
388 static void _ip_info_entry_add_callbacks(Evas_Object *entry,
389 common_utils_entry_info_t *entry_info)
394 evas_object_smart_callback_add(entry, "activated",
395 _ip_info_entry_key_enter_cb, entry_info);
396 evas_object_smart_callback_add(entry, "cursor,changed",
397 _ip_info_entry_cursor_changed_cb, entry_info);
398 evas_object_smart_callback_add(entry, "changed",
399 _ip_info_entry_changed_cb, entry_info);
400 evas_object_smart_callback_add(entry, "focused",
401 _ip_info_entry_focused_cb, entry_info);
402 evas_object_smart_callback_add(entry, "unfocused",
403 _ip_info_entry_unfocused_cb, entry_info);
406 static Evas_Object *_ip_info_entry_item_content_get(void *data, Evas_Object *obj, const char *part)
408 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
412 Evas_Object *layout = NULL;
413 Evas_Object *label = NULL;
414 Evas_Object *editfield = NULL;
415 char *guide_txt = NULL;
416 char *accepted = NULL;
417 Elm_Input_Panel_Layout panel_type;
419 char buf[MAX_LABEL_LENGTH] = {0, };
421 switch (entry_info->entry_id) {
422 case ENTRY_TYPE_IP_ADDR:
423 case ENTRY_TYPE_SUBNET_MASK:
424 case ENTRY_TYPE_GATEWAY:
425 case ENTRY_TYPE_DNS_1:
426 case ENTRY_TYPE_DNS_2:
427 guide_txt = entry_info->guide_txt;
428 panel_type = ELM_INPUT_PANEL_LAYOUT_IP;
429 return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT;
430 accepted = "0123456789.";
432 case ENTRY_TYPE_PROXY_ADDR:
433 guide_txt = DEFAULT_GUIDE_PROXY_IP;
434 panel_type = ELM_INPUT_PANEL_LAYOUT_URL;
435 return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT;
437 /* accepted = "0123456789.abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ"; */
439 case ENTRY_TYPE_PROXY_PORT:
440 guide_txt = DEFAULT_GUIDE_PROXY_PORT;
441 panel_type = ELM_INPUT_PANEL_LAYOUT_NUMBERONLY;
442 return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
443 accepted = "0123456789";
449 layout = elm_layout_add(obj);
450 elm_layout_file_set(layout, CUSTOM_GENLIST_PATH, "gl_custom_item");
451 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
452 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
454 snprintf(buf, MAX_LABEL_LENGTH, "<font_size=40>%s</font_size>",
455 dgettext(PACKAGE, entry_info->title_txt));
457 label = elm_label_add(obj);
458 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0);
459 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
460 elm_object_text_set(label, buf);
461 elm_object_part_content_set(layout, "elm.swallow.label", label);
463 editfield = elm_entry_add(obj);
464 elm_entry_single_line_set(editfield, EINA_TRUE);
465 elm_entry_scrollable_set(editfield, EINA_TRUE);
467 if (!g_strcmp0(entry_info->str_pkg_name, "wifi-qs"))
468 elm_entry_input_panel_imdata_set(editfield, "type=systempopup", 16);
470 elm_entry_cnp_mode_set(editfield, ELM_CNP_MODE_PLAINTEXT);
472 elm_object_part_text_set(editfield, "elm.guide", guide_txt);
473 if (entry_info->entry_txt && (strlen(entry_info->entry_txt) > 0) &&
474 g_strcmp0(entry_info->entry_txt, DEFAULT_GUIDE_IP) != 0) {
475 elm_entry_entry_set(editfield, entry_info->entry_txt);
478 elm_entry_input_panel_layout_set(editfield, panel_type);
480 Elm_Entry_Filter_Accept_Set digits_filter_data;
481 memset(&digits_filter_data, 0, sizeof(Elm_Entry_Filter_Accept_Set));
482 digits_filter_data.accepted = accepted;
483 elm_entry_markup_filter_append(editfield, elm_entry_filter_accept_set, &digits_filter_data);
485 if (entry_info->input_panel_cb) {
486 Ecore_IMF_Context *imf_ctxt = elm_entry_imf_context_get(editfield);
488 ecore_imf_context_input_panel_event_callback_add(
490 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
491 entry_info->input_panel_cb,
492 entry_info->input_panel_cb_data);
496 elm_entry_input_panel_return_key_type_set(editfield, return_key_type);
497 _ip_info_entry_add_callbacks(editfield, entry_info);
498 elm_object_part_content_set(layout, "elm.swallow.content", editfield);
500 if (!net_get_device_policy_wifi_profile())
501 elm_object_disabled_set(editfield, EINA_TRUE);
503 elm_object_disabled_set(editfield, EINA_FALSE);
508 static void _ip_info_entry_item_del(void *data, Evas_Object *obj)
510 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
511 if (entry_info == NULL)
514 g_free(ip_info_text_list[entry_info->entry_id]);
515 ip_info_text_list[entry_info->entry_id] = NULL;
517 if (entry_info->entry_txt) {
518 ip_info_text_list[entry_info->entry_id] = g_strdup(entry_info->entry_txt);
519 g_free(entry_info->entry_txt);
520 entry_info->entry_txt = NULL;
527 #ifdef ACCESSIBLITY_FEATURE
528 static char *_access_info_cb(void *data, Evas_Object *obj)
530 common_utils_entry_info_t *entry_info = (common_utils_entry_info_t *)data;
534 if (entry_info->entry_txt)
535 return g_strdup_printf("%s %s", entry_info->title_txt, entry_info->entry_txt);
537 return g_strdup_printf("%s %s", entry_info->title_txt, entry_info->guide_txt);
541 static void _create_static_ip_table(full_ip_info_t *ip_data)
544 retm_if(NULL == ip_data);
546 ip_info_list_t *ip_info_list_data = ip_data->ip_info_list;
547 prev_ip_info_t *prev_ip_info = ip_data->prev_ip_info;
548 common_utils_entry_info_t *edit_box_details;
549 wifi_manager_ip_config_type_e ip_type;
551 retm_if(NULL == prev_ip_info || NULL == ip_info_list_data);
552 wifi_manager_ap_h ap = ip_info_list_data->ap;
553 __COMMON_FUNC_ENTER__;
556 int ret = wifi_manager_ap_get_ip_config_type(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &ip_type);
557 if (ret != WIFI_MANAGER_ERROR_NONE)
558 INFO_LOG(UG_NAME_ERR, "Failed to get IP config_type! [%d]", ret);
560 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
561 if (edit_box_details == NULL)
564 edit_box_details->entry_id = ENTRY_TYPE_IP_ADDR;
565 edit_box_details->title_txt = "IDS_WIFI_BODY_IP_ADDRESS";
566 if (ip_type == WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC)
567 edit_box_details->entry_txt = g_strdup(DEFAULT_GUIDE_IP);
569 ret = wifi_manager_ap_get_ip_address(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &txt);
570 if (ret != WIFI_MANAGER_ERROR_NONE)
571 INFO_LOG(UG_NAME_ERR, "Failed to get IP Address! [%d]", ret);
572 edit_box_details->entry_txt = txt;
574 edit_box_details->guide_txt = DEFAULT_GUIDE_IP;
575 edit_box_details->str_pkg_name = ip_info_list_data->str_pkg_name;
576 edit_box_details->input_panel_cb = ip_info_list_data->input_panel_cb;
577 edit_box_details->input_panel_cb_data = ip_info_list_data->input_panel_cb_data;
578 edit_box_details->item = elm_genlist_item_insert_after(
579 ip_info_list_data->genlist, ip_entry_itc,
580 edit_box_details, NULL, ip_info_list_data->ip_toggle_item,
581 ELM_GENLIST_ITEM_NONE, _gl_editbox_sel_cb, NULL);
582 #ifdef ACCESSIBLITY_FEATURE
583 Evas_Object *ao = elm_object_item_access_object_get(edit_box_details->item);
584 elm_access_info_cb_set(ao, ELM_ACCESS_INFO, _access_info_cb, edit_box_details);
586 ip_info_list_data->ip_addr_item = edit_box_details->item;
588 if (ip_data->is_first_create == TRUE)
589 prev_ip_info->ip_addr = g_strdup(txt);
592 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
593 if (edit_box_details == NULL)
596 edit_box_details->entry_id = ENTRY_TYPE_SUBNET_MASK;
597 edit_box_details->title_txt = "IDS_WIFI_BODY_SUBNET_MASK";
598 if (ip_type == WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC)
599 edit_box_details->entry_txt = g_strdup(DEFAULT_GUIDE_IP);
601 ret = wifi_manager_ap_get_subnet_mask(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &txt);
602 if (ret != WIFI_MANAGER_ERROR_NONE)
603 INFO_LOG(UG_NAME_ERR, "Failed to get subnet mask! [%d]", ret);
604 edit_box_details->entry_txt = txt;
606 edit_box_details->guide_txt = DEFAULT_GUIDE_IP;
607 edit_box_details->str_pkg_name = ip_info_list_data->str_pkg_name;
608 edit_box_details->input_panel_cb = ip_info_list_data->input_panel_cb;
609 edit_box_details->input_panel_cb_data = ip_info_list_data->input_panel_cb_data;
610 edit_box_details->item = elm_genlist_item_insert_after(
611 ip_info_list_data->genlist, ip_entry_itc,
612 edit_box_details, NULL, ip_info_list_data->ip_addr_item,
613 ELM_GENLIST_ITEM_NONE, _gl_editbox_sel_cb, NULL);
614 #ifdef ACCESSIBLITY_FEATURE
615 ao = elm_object_item_access_object_get(edit_box_details->item);
616 elm_access_info_cb_set(ao, ELM_ACCESS_INFO, _access_info_cb, edit_box_details);
618 ip_info_list_data->subnet_mask_item = edit_box_details->item;
620 if (ip_data->is_first_create == TRUE)
621 prev_ip_info->subnet_mask = g_strdup(txt);
623 /* Gateway Address */
624 ret = wifi_manager_ap_get_gateway_address(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &txt);
625 if (ret != WIFI_MANAGER_ERROR_NONE)
626 INFO_LOG(UG_NAME_ERR, "Failed to get gateway address! [%d]", ret);
628 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
629 if (edit_box_details == NULL)
632 edit_box_details->entry_id = ENTRY_TYPE_GATEWAY;
633 edit_box_details->title_txt = "IDS_WIFI_BODY_GATEWAY_ADDRESS";
634 edit_box_details->entry_txt = txt;
635 edit_box_details->guide_txt = DEFAULT_GUIDE_IP;
636 edit_box_details->str_pkg_name = ip_info_list_data->str_pkg_name;
637 edit_box_details->input_panel_cb = ip_info_list_data->input_panel_cb;
638 edit_box_details->input_panel_cb_data = ip_info_list_data->input_panel_cb_data;
639 edit_box_details->item = elm_genlist_item_insert_after(
640 ip_info_list_data->genlist, ip_entry_itc,
641 edit_box_details, NULL, ip_info_list_data->subnet_mask_item,
642 ELM_GENLIST_ITEM_NONE, _gl_editbox_sel_cb, NULL);
643 #ifdef ACCESSIBLITY_FEATURE
644 ao = elm_object_item_access_object_get(edit_box_details->item);
645 elm_access_info_cb_set(ao, ELM_ACCESS_INFO, _access_info_cb, edit_box_details);
647 ip_info_list_data->gateway_addr_item = edit_box_details->item;
649 if (ip_data->is_first_create == TRUE)
650 prev_ip_info->gateway_addr = g_strdup(txt);
653 ret = wifi_manager_ap_get_dns_address(ap, 1, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &txt);
654 if (ret != WIFI_MANAGER_ERROR_NONE)
655 INFO_LOG(UG_NAME_ERR, "Failed to get DNS 1 Address! [%d]", ret);
657 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
658 if (edit_box_details == NULL)
661 edit_box_details->entry_id = ENTRY_TYPE_DNS_1;
662 edit_box_details->title_txt = "IDS_WIFI_BODY_DNS_1";
663 edit_box_details->entry_txt = txt;
664 edit_box_details->guide_txt = DEFAULT_GUIDE_IP;
665 edit_box_details->str_pkg_name = ip_info_list_data->str_pkg_name;
666 edit_box_details->input_panel_cb = ip_info_list_data->input_panel_cb;
667 edit_box_details->input_panel_cb_data = ip_info_list_data->input_panel_cb_data;
668 edit_box_details->item = elm_genlist_item_insert_after(
669 ip_info_list_data->genlist, ip_entry_itc,
670 edit_box_details, NULL, ip_info_list_data->gateway_addr_item,
671 ELM_GENLIST_ITEM_NONE, _gl_editbox_sel_cb, NULL);
672 #ifdef ACCESSIBLITY_FEATURE
673 ao = elm_object_item_access_object_get(edit_box_details->item);
674 elm_access_info_cb_set(ao, ELM_ACCESS_INFO, _access_info_cb, edit_box_details);
676 ip_info_list_data->dns_1_item = edit_box_details->item;
678 if (ip_data->is_first_create == TRUE)
679 prev_ip_info->dns_1 = g_strdup(txt);
682 ret = wifi_manager_ap_get_dns_address(ap, 2, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &txt);
683 if (ret != WIFI_MANAGER_ERROR_NONE)
684 INFO_LOG(UG_NAME_ERR, "Failed to get DNS 2 Address! [%d]", ret);
686 edit_box_details = g_try_new0(common_utils_entry_info_t, 1);
687 if (edit_box_details == NULL)
690 edit_box_details->entry_id = ENTRY_TYPE_DNS_2;
691 edit_box_details->title_txt = "IDS_WIFI_BODY_DNS_2";
692 edit_box_details->entry_txt = txt;
693 edit_box_details->guide_txt = DEFAULT_GUIDE_IP;
694 edit_box_details->str_pkg_name = ip_info_list_data->str_pkg_name;
695 edit_box_details->input_panel_cb = ip_info_list_data->input_panel_cb;
696 edit_box_details->input_panel_cb_data = ip_info_list_data->input_panel_cb_data;
697 edit_box_details->item = elm_genlist_item_insert_after(
698 ip_info_list_data->genlist, ip_entry_itc,
699 edit_box_details, NULL, ip_info_list_data->dns_1_item,
700 ELM_GENLIST_ITEM_NONE, _gl_editbox_sel_cb, NULL);
701 #ifdef ACCESSIBLITY_FEATURE
702 ao = elm_object_item_access_object_get(edit_box_details->item);
703 elm_access_info_cb_set(ao, ELM_ACCESS_INFO, _access_info_cb, edit_box_details);
705 ip_info_list_data->dns_2_item = edit_box_details->item;
707 if (ip_data->is_first_create == TRUE)
708 prev_ip_info->dns_2 = g_strdup(txt);
710 ip_data->is_first_create = FALSE;
712 __COMMON_FUNC_EXIT__;
717 static void _delete_static_ip_table(ip_info_list_t *ip_info_list_data)
719 __COMMON_FUNC_ENTER__;
721 retm_if(NULL == ip_info_list_data);
723 _ip_info_reset_current_unfocused_entry();
725 _ip_info_entry_del_callbacks(ip_info_list_data->ip_addr_item);
726 elm_object_item_del(ip_info_list_data->ip_addr_item);
727 ip_info_list_data->ip_addr_item = NULL;
729 _ip_info_entry_del_callbacks(ip_info_list_data->subnet_mask_item);
730 elm_object_item_del(ip_info_list_data->subnet_mask_item);
731 ip_info_list_data->subnet_mask_item = NULL;
733 _ip_info_entry_del_callbacks(ip_info_list_data->gateway_addr_item);
734 elm_object_item_del(ip_info_list_data->gateway_addr_item);
735 ip_info_list_data->gateway_addr_item = NULL;
737 _ip_info_entry_del_callbacks(ip_info_list_data->dns_1_item);
738 elm_object_item_del(ip_info_list_data->dns_1_item);
739 ip_info_list_data->dns_1_item = NULL;
741 _ip_info_entry_del_callbacks(ip_info_list_data->dns_2_item);
742 elm_object_item_del(ip_info_list_data->dns_2_item);
743 ip_info_list_data->dns_2_item = NULL;
745 __COMMON_FUNC_EXIT__;
748 static gboolean __genlist_item_disable_later(void *data)
750 elm_genlist_item_selected_set((Elm_Object_Item *)data, FALSE);
755 static void _gl_deselect_callback(void* data,
756 Evas_Object* obj, void* event_info)
758 common_util_managed_idle_add(__genlist_item_disable_later, event_info);
761 static char* _ip_info_iptoggle_text_get(void *data, Evas_Object *obj,
765 retvm_if(NULL == data || NULL == part, NULL);
766 full_ip_info_t *ip_data = (full_ip_info_t *) data;
768 if (!strcmp("elm.text", part)) {
769 ip_info_list_t *ip_info_list_data = ip_data->ip_info_list;
770 #ifdef ACCESSIBLITY_FEATURE
772 Evas_Object *ao = elm_object_item_access_object_get(ip_info_list_data->ip_toggle_item);
773 g_snprintf(buf, sizeof(buf), "%s%s%s",
774 sc(ip_info_list_data->str_pkg_name, I18N_TYPE_On),
775 sc(ip_info_list_data->str_pkg_name, I18N_TYPE_Off),
776 sc(ip_info_list_data->str_pkg_name, I18N_TYPE_Button));
777 elm_access_info_set(ao, ELM_ACCESS_TYPE, buf);
779 if (WIFI_MANAGER_IP_CONFIG_TYPE_STATIC == ip_info_list_data->ip_type)
780 elm_access_info_set(ao, ELM_ACCESS_STATE, sc(ip_info_list_data->str_pkg_name, I18N_TYPE_On));
782 elm_access_info_set(ao, ELM_ACCESS_STATE, sc(ip_info_list_data->str_pkg_name, I18N_TYPE_Off));
784 return (char*)g_strdup(sc(ip_info_list_data->str_pkg_name, I18N_TYPE_Static_IP));
790 static Elm_Object_Item* _add_description(Evas_Object* genlist, char* title,
791 char* description, Elm_Object_Item* insert_after)
793 retvm_if(NULL == genlist, NULL);
795 _view_detail_description_data_t* description_data =
796 g_try_new0(_view_detail_description_data_t, 1);
797 retvm_if(NULL == description_data, NULL);
799 description_data->title = g_strdup(title);
800 description_data->description = g_strdup(description);
802 Elm_Object_Item* det = NULL;
804 det = elm_genlist_item_insert_after(
806 description_itc,/*itc*/
807 description_data,/*data*/
809 insert_after, /*after than*/
810 ELM_GENLIST_ITEM_NONE, /*flags*/
811 _gl_deselect_callback,/*func*/
814 det = elm_genlist_item_append(
819 ELM_GENLIST_ITEM_NONE,
820 _gl_deselect_callback,
824 elm_genlist_item_select_mode_set(det, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
825 elm_object_item_disabled_set(det, TRUE);
830 static void __ip_info_toggle_item_sel_cb(void* data,
831 Evas_Object* obj, void* event_info)
833 __COMMON_FUNC_ENTER__;
835 const char *object_type;
836 ip_info_list_t *ip_info_list_data = NULL;
837 wifi_manager_ip_config_type_e ip_type = WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC;
838 full_ip_info_t *ip_data = (full_ip_info_t *)data;
839 retm_if(ip_data == NULL);
840 ip_info_list_data = ip_data->ip_info_list;
841 if (ip_info_list_data == NULL) {
842 __COMMON_FUNC_EXIT__;
846 if (!net_get_device_policy_wifi_profile()) {
847 SECURE_DEBUG_LOG(UG_NAME_NORMAL, "Wifi profile device policy restricts");
848 __COMMON_FUNC_EXIT__;
852 wifi_manager_ap_h ap = ip_info_list_data->ap;
854 object_type = evas_object_type_get(obj);
856 if (g_strcmp0(object_type, "elm_check") == 0) {
857 Eina_Bool ip_mode = elm_check_state_get(obj);
860 ip_type = WIFI_MANAGER_IP_CONFIG_TYPE_STATIC;
862 ip_type = WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC;
863 } else if (g_strcmp0(object_type, "elm_genlist") == 0) {
864 elm_genlist_item_selected_set(ip_info_list_data->ip_toggle_item,
867 if (ip_info_list_data->ip_type == WIFI_MANAGER_IP_CONFIG_TYPE_STATIC)
868 ip_type = WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC;
870 ip_type = WIFI_MANAGER_IP_CONFIG_TYPE_STATIC;
873 if (ip_type == WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC) {
874 char *ip_addr = NULL;
876 /* Hide input keypad if popped out */
877 ecore_imf_input_panel_hide();
879 _delete_static_ip_table(ip_info_list_data);
881 wifi_manager_ap_get_ip_address(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &ip_addr);
883 /* Dynamic IP Address */
884 ip_info_list_data->ip_addr_item = _add_description(
885 ip_info_list_data->genlist,
886 "IDS_WIFI_BODY_IP_ADDRESS",
888 ip_info_list_data->ip_toggle_item);
893 ip_info_list_data->ip_type = WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC;
894 } else if (ip_type == WIFI_MANAGER_IP_CONFIG_TYPE_STATIC) {
895 elm_object_item_del(ip_info_list_data->ip_addr_item);
896 ip_info_list_data->ip_addr_item = NULL;
897 ip_data->is_first_create = FALSE;
899 /* Create the entry layouts */
900 _create_static_ip_table(ip_data);
901 ip_info_list_data->ip_type = WIFI_MANAGER_IP_CONFIG_TYPE_STATIC;
904 if (ip_info_list_data->ip_toggle_item != NULL)
905 elm_genlist_item_update(ip_info_list_data->ip_toggle_item);
907 __COMMON_FUNC_EXIT__;
910 static Evas_Object *_ip_info_iptoggle_content_get(void *data,
911 Evas_Object *obj, const char *part)
913 __COMMON_FUNC_ENTER__;
915 retvm_if(NULL == data || NULL == obj || NULL == part, NULL);
916 full_ip_info_t *ip_data = (full_ip_info_t *) data;
917 ip_info_list_t *ip_info_list_data = ip_data->ip_info_list;
918 Evas_Object *toggle_btn = NULL;
920 if (!strcmp("elm.swallow.end", part)) {
921 toggle_btn = elm_check_add(obj);
922 elm_object_style_set(toggle_btn, "on&off");
923 elm_object_focus_allow_set(toggle_btn, EINA_FALSE);
925 if (WIFI_MANAGER_IP_CONFIG_TYPE_STATIC == ip_info_list_data->ip_type)
926 elm_check_state_set(toggle_btn, EINA_TRUE);
928 elm_check_state_set(toggle_btn, EINA_FALSE);
930 evas_object_propagate_events_set(toggle_btn, EINA_FALSE);
931 evas_object_size_hint_align_set(toggle_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
932 evas_object_size_hint_weight_set(toggle_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
933 evas_object_smart_callback_add(toggle_btn, "changed",
934 __ip_info_toggle_item_sel_cb, ip_data);
936 if (!net_get_device_policy_wifi_profile())
937 elm_object_disabled_set(toggle_btn, EINA_TRUE);
939 elm_object_disabled_set(toggle_btn, EINA_FALSE);
944 __COMMON_FUNC_EXIT__;
949 static void ip_info_print_values(wifi_manager_ap_h ap)
952 wifi_manager_ip_config_type_e type = WIFI_MANAGER_IP_CONFIG_TYPE_NONE;
954 wifi_manager_ap_get_ip_config_type(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &type);
955 if (WIFI_MANAGER_IP_CONFIG_TYPE_STATIC == type) {
956 DEBUG_LOG(UG_NAME_NORMAL, "* STATIC CONFIGURATION *");
959 wifi_manager_ap_get_ip_address(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &txt);
960 SECURE_DEBUG_LOG(UG_NAME_NORMAL, "* IP address [%s]", txt);
964 wifi_manager_ap_get_subnet_mask(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &txt);
965 SECURE_DEBUG_LOG(UG_NAME_NORMAL, "* Subnet Mask [%s]", txt);
968 /* Gateway Address */
969 wifi_manager_ap_get_gateway_address(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &txt);
970 SECURE_DEBUG_LOG(UG_NAME_NORMAL, "* Gateway address [%s]", txt);
974 wifi_manager_ap_get_dns_address(ap, 1, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &txt);
975 SECURE_DEBUG_LOG(UG_NAME_NORMAL, "* DNS-1 address [%s]", txt);
979 wifi_manager_ap_get_dns_address(ap, 2, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &txt);
980 SECURE_DEBUG_LOG(UG_NAME_NORMAL, "* DNS-2 address [%s]", txt);
983 } else if (WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC == type) {
984 DEBUG_LOG(UG_NAME_NORMAL, "* DYNAMIC CONFIGURATION *");
986 /* Dynamic IP Address */
987 wifi_manager_ap_get_ip_address(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &txt);
988 SECURE_DEBUG_LOG(UG_NAME_NORMAL, "* IP address [%s]", txt);
993 wifi_get_mac_address(&txt);
994 SECURE_DEBUG_LOG(UG_NAME_NORMAL, "* MAC address [%s]", txt);
998 wifi_manager_ap_get_proxy_address(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &txt);
999 assertm_if(NULL == txt, "NULL!!");
1001 if (!txt || !strlen(txt)) {
1004 txt = g_strdup(DEFAULT_PROXY_ADDR);
1008 char *save_str = NULL;
1009 char *proxy_addr = strtok_r(txt, ":", &save_str);
1010 SECURE_DEBUG_LOG(UG_NAME_NORMAL, "* PROXY ADDR [%s]", proxy_addr);
1013 char *proxy_port = strtok_r(NULL, ":", &save_str);
1014 SECURE_DEBUG_LOG(UG_NAME_NORMAL, "* PROXY PORT [%s]", proxy_port);
1019 #define EMULATOR_MAC_ADDR_SIZE 6
1020 #define EMULATOR_MAC_ADDR_MAX 20
1021 static int ip_info_emulator_get_random_mac(unsigned char *buf)
1023 __COMMON_FUNC_ENTER__;
1028 fp = fopen("/dev/urandom", "rb");
1030 ERROR_LOG(UG_NAME_ERR, "Could not open /dev/urandom");
1034 rc = fread(buf, 1, EMULATOR_MAC_ADDR_SIZE, fp);
1038 return rc != EMULATOR_MAC_ADDR_SIZE ? -1 : 0;
1041 void ip_info_delete_prev(prev_ip_info_t *prev_ip_info)
1043 retm_if(NULL == prev_ip_info);
1045 __COMMON_FUNC_ENTER__;
1047 g_free(prev_ip_info->ip_addr);
1048 g_free(prev_ip_info->subnet_mask);
1049 g_free(prev_ip_info->gateway_addr);
1050 g_free(prev_ip_info->dns_1);
1051 g_free(prev_ip_info->dns_2);
1052 g_free(prev_ip_info->proxy_data);
1053 g_free(prev_ip_info);
1055 __COMMON_FUNC_EXIT__;
1058 full_ip_info_t *ip_info_append_items(wifi_manager_ap_h ap, const char *pkg_name,
1059 Evas_Object *genlist, imf_ctxt_panel_cb_t input_panel_cb, void *input_panel_cb_data)
1061 __COMMON_FUNC_ENTER__;
1062 int ret = WIFI_MANAGER_ERROR_NONE;
1063 char *proxy_data = NULL;
1064 char *proxy_addr = NULL;
1065 char *proxy_port = NULL;
1066 Elm_Object_Item* item = NULL;
1067 common_utils_entry_info_t *edit_box_details;
1068 wifi_manager_proxy_type_e proxy_type;
1069 char *ip_addr = NULL;
1072 full_ip_info_t *ip_data = NULL;
1073 assertm_if(NULL == ap, "NULL!!");
1074 assertm_if(NULL == pkg_name, "NULL!!");
1075 assertm_if(NULL == genlist, "NULL!!");
1077 prev_ip_info_t *prev_ip_info = g_try_new0(prev_ip_info_t, 1);
1078 if (prev_ip_info == NULL)
1081 ip_info_list_t *ip_info_list_data = g_try_new0(ip_info_list_t, 1);
1082 if (ip_info_list_data == NULL) {
1083 g_free(prev_ip_info);
1084 prev_ip_info = NULL;
1089 ip_data = g_try_new0(full_ip_info_t, 1);
1090 if (ip_data == NULL) {
1091 g_free(prev_ip_info);
1092 g_free(ip_info_list_data);
1093 prev_ip_info = NULL;
1094 ip_info_list_data = NULL;
1098 ip_data->ip_info_list = ip_info_list_data;
1099 ip_data->prev_ip_info = prev_ip_info;
1101 ip_info_list_data->ap = ap;
1102 ip_info_list_data->str_pkg_name = pkg_name;
1103 ip_info_list_data->genlist = genlist;
1104 ip_info_list_data->input_panel_cb = input_panel_cb;
1105 ip_info_list_data->input_panel_cb_data = input_panel_cb_data;
1107 ip_toggle_itc = elm_genlist_item_class_new();
1108 ip_toggle_itc->item_style = WIFI_GENLIST_1LINE_TEXT_ICON_STYLE;
1109 ip_toggle_itc->func.text_get = _ip_info_iptoggle_text_get;
1110 ip_toggle_itc->func.content_get = _ip_info_iptoggle_content_get;
1111 ip_toggle_itc->func.state_get = NULL;
1112 ip_toggle_itc->func.del = NULL;
1114 description_itc = elm_genlist_item_class_new();
1115 description_itc->item_style = WIFI_GENLIST_FULL_STYLE;
1116 description_itc->func.text_get = NULL;
1117 description_itc->func.content_get = _ip_info_detail_description_content_get;
1118 description_itc->func.state_get = NULL;
1119 description_itc->func.del = _ip_info_detail_description_del;
1121 ip_entry_itc = elm_genlist_item_class_new();
1122 ip_entry_itc->item_style = WIFI_GENLIST_FULL_STYLE;
1123 ip_entry_itc->func.text_get = NULL;
1124 ip_entry_itc->func.content_get = _ip_info_entry_item_content_get;
1125 ip_entry_itc->func.state_get = NULL;
1126 ip_entry_itc->func.del = _ip_info_entry_item_del;
1128 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1130 /* Static/Dynamic switch button */
1131 wifi_manager_ip_config_type_e type = WIFI_MANAGER_IP_CONFIG_TYPE_NONE;
1132 ret = wifi_manager_ap_get_ip_config_type(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &type);
1133 if (ret != WIFI_MANAGER_ERROR_NONE)
1134 INFO_LOG(UG_NAME_ERR, "Failed to get ip config type! [%d]", ret);
1136 ip_info_list_data->ip_type = type;
1137 ip_info_list_data->ip_toggle_item = elm_genlist_item_append(genlist,
1138 ip_toggle_itc, ip_data, NULL, ELM_GENLIST_ITEM_NONE,
1139 __ip_info_toggle_item_sel_cb, ip_data);
1141 prev_ip_info->ip_type = type;
1144 if (WIFI_MANAGER_IP_CONFIG_TYPE_STATIC == type) {
1145 ip_data->is_first_create = TRUE;
1147 /* Create the entry layouts */
1148 _create_static_ip_table(ip_data);
1149 } else if (WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC == type) {
1150 wifi_manager_ap_get_ip_address(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &ip_addr);
1152 prev_ip_info->ip_addr = g_strdup(ip_addr);
1154 ip_info_list_data->ip_addr_item = _add_description(genlist,
1155 "IDS_WIFI_BODY_IP_ADDRESS", ip_addr, NULL);
1161 if (_is_emulator()) {
1162 char rand_addr[EMULATOR_MAC_ADDR_MAX];
1163 unsigned char rand_mac_add[EMULATOR_MAC_ADDR_SIZE + 1];
1164 if (ip_info_emulator_get_random_mac(rand_mac_add) == -1) {
1165 ERROR_LOG(UG_NAME_ERR, "Failed to get random mac address");
1169 rand_mac_add[0] &= 0xFE;
1170 rand_mac_add[0] |= 0x02;
1172 snprintf(rand_addr, EMULATOR_MAC_ADDR_MAX, "%x:%x:%x:%x:%x:%x",
1173 rand_mac_add[0], rand_mac_add[1],
1174 rand_mac_add[2], rand_mac_add[3],
1175 rand_mac_add[4], rand_mac_add[5]);
1176 item = _add_description(genlist,
1177 "IDS_WIFI_BODY_MAC_ADDRESS", rand_addr, NULL);
1178 ip_info_list_data->mac_addr_item = item;
1180 char *mac_addr = NULL;
1182 ret = wifi_manager_ap_get_bssid(ap, &mac_addr);
1183 if (ret != WIFI_MANAGER_ERROR_NONE)
1184 INFO_LOG(UG_NAME_ERR, "Failed to get bssid! [%d]", ret);
1186 item = _add_description(genlist,
1187 "IDS_WIFI_BODY_MAC_ADDRESS", mac_addr, NULL);
1188 ip_info_list_data->mac_addr_item = item;
1194 ret = wifi_manager_ap_get_proxy_type(ap, &proxy_type);
1195 assertm_if(WIFI_MANAGER_ERROR_NONE != ret, "NULL!!");
1196 prev_ip_info->proxy_type = proxy_type;
1198 ret = wifi_manager_ap_get_proxy_address(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, &proxy_data);
1199 assertm_if(NULL == proxy_data, "NULL!!");
1201 if (WIFI_MANAGER_ERROR_NONE == ret && proxy_data && strlen(proxy_data)) {
1202 temp = g_strdup(proxy_data);
1205 str2 = strrchr(temp, ':');
1207 proxy_port = g_strdup(str2 + 1);
1212 proxy_addr = g_strdup(temp);
1218 prev_ip_info->proxy_data = g_strdup(proxy_data);
1220 ERROR_LOG(UG_NAME_ERR, "Error = %d", ret);
1223 edit_box_details = g_new0(common_utils_entry_info_t, 1);
1224 edit_box_details->str_pkg_name = pkg_name;
1225 edit_box_details->entry_id = ENTRY_TYPE_PROXY_ADDR;
1226 edit_box_details->title_txt = "IDS_ST_SBODY_PROXY_ADDRESS";
1227 edit_box_details->entry_txt = proxy_addr;
1228 edit_box_details->guide_txt = DEFAULT_GUIDE_PROXY_IP;
1229 edit_box_details->input_panel_cb = input_panel_cb;
1230 edit_box_details->input_panel_cb_data = input_panel_cb_data;
1231 edit_box_details->item = elm_genlist_item_append(genlist, ip_entry_itc,
1232 edit_box_details, NULL, ELM_GENLIST_ITEM_NONE,
1233 _gl_editbox_sel_cb, NULL);
1234 #ifdef ACCESSIBLITY_FEATURE
1235 Evas_Object *ao = elm_object_item_access_object_get(edit_box_details->item);
1236 elm_access_info_cb_set(ao, ELM_ACCESS_INFO, _access_info_cb, edit_box_details);
1238 ip_info_list_data->proxy_addr_item = edit_box_details->item;
1240 edit_box_details = g_new0(common_utils_entry_info_t, 1);
1241 edit_box_details->str_pkg_name = pkg_name;
1242 edit_box_details->entry_id = ENTRY_TYPE_PROXY_PORT;
1243 edit_box_details->title_txt = "IDS_ST_SBODY_PROXY_PORT";
1244 edit_box_details->entry_txt = proxy_port;
1245 edit_box_details->guide_txt = DEFAULT_GUIDE_PROXY_PORT;
1246 edit_box_details->input_panel_cb = input_panel_cb;
1247 edit_box_details->input_panel_cb_data = input_panel_cb_data;
1248 edit_box_details->item = elm_genlist_item_append(genlist, ip_entry_itc,
1249 edit_box_details, NULL, ELM_GENLIST_ITEM_NONE,
1250 _gl_editbox_sel_cb, NULL);
1251 #ifdef ACCESSIBLITY_FEATURE
1252 ao = elm_object_item_access_object_get(edit_box_details->item);
1253 elm_access_info_cb_set(ao, ELM_ACCESS_INFO, _access_info_cb, edit_box_details);
1255 ip_info_list_data->proxy_port_item = edit_box_details->item;
1260 __COMMON_FUNC_EXIT__;
1264 static char* get_ip_info_text(entry_id_type_t e)
1266 if (ip_info_text_list[e] != NULL)
1267 return ip_info_text_list[e];
1272 static void free_ip_info_text(entry_id_type_t e)
1274 g_free(ip_info_text_list[e]);
1275 ip_info_text_list[e] = NULL;
1278 void ip_info_save_data(full_ip_info_t *ip_data)
1280 __COMMON_FUNC_ENTER__;
1281 retm_if(ip_data == NULL);
1282 ip_info_list_t *ip_info_list_data = ip_data->ip_info_list;
1283 prev_ip_info_t *prev_ip_info = ip_data->prev_ip_info;
1284 retm_if(NULL == ip_info_list_data || NULL == prev_ip_info);
1287 char* proxy_addr = NULL;
1288 char* proxy_port = NULL;
1289 wifi_manager_ap_h ap = ip_info_list_data->ap;
1290 int ret = WIFI_MANAGER_ERROR_NONE;
1291 ip_data->is_info_changed = FALSE;
1293 if (prev_ip_info->ip_type != ip_info_list_data->ip_type) {
1294 if (WIFI_MANAGER_IP_CONFIG_TYPE_DYNAMIC == ip_info_list_data->ip_type) {
1295 /* Reset the DNS addresses if dynamic */
1296 ret = wifi_manager_ap_set_dns_address(ap, 1,
1297 WIFI_MANAGER_ADDRESS_FAMILY_IPV4, DEFAULT_GUIDE_IP);
1298 if (ret == WIFI_MANAGER_ERROR_NONE)
1299 ip_data->is_info_changed = TRUE;
1301 ret = wifi_manager_ap_set_dns_address(ap, 2,
1302 WIFI_MANAGER_ADDRESS_FAMILY_IPV4, DEFAULT_GUIDE_IP);
1303 if (ret == WIFI_MANAGER_ERROR_NONE)
1304 ip_data->is_info_changed = TRUE;
1305 ip_info_list_data->dns_type = WIFI_MANAGER_DNS_CONFIG_TYPE_DYNAMIC;
1307 } else if (WIFI_MANAGER_IP_CONFIG_TYPE_STATIC == ip_info_list_data->ip_type) {
1308 ip_info_list_data->dns_type = WIFI_MANAGER_DNS_CONFIG_TYPE_STATIC;
1311 ret = wifi_manager_ap_set_ip_config_type(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4,
1312 ip_info_list_data->ip_type);
1313 retm_if(WIFI_MANAGER_ERROR_NONE != ret);
1315 ret = wifi_manager_ap_set_dns_config_type(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4,
1316 ip_info_list_data->dns_type);
1317 retm_if(WIFI_MANAGER_ERROR_NONE != ret);
1319 ip_data->is_info_changed = TRUE;
1322 if (WIFI_MANAGER_IP_CONFIG_TYPE_STATIC == ip_info_list_data->ip_type) {
1323 txt = g_strdup(get_ip_info_text(ENTRY_TYPE_IP_ADDR));
1325 txt = g_strdup(DEFAULT_GUIDE_IP);
1326 if (g_strcmp0(prev_ip_info->ip_addr, txt) != 0) {
1327 ret = wifi_manager_ap_set_ip_address(ap,
1328 WIFI_MANAGER_ADDRESS_FAMILY_IPV4, txt);
1330 if (ret == WIFI_MANAGER_ERROR_NONE)
1331 ip_data->is_info_changed = TRUE;
1333 free_ip_info_text(ENTRY_TYPE_IP_ADDR);
1336 txt = g_strdup(get_ip_info_text(ENTRY_TYPE_SUBNET_MASK));
1338 txt = g_strdup(DEFAULT_GUIDE_IP);
1339 if (g_strcmp0(prev_ip_info->subnet_mask, txt) != 0) {
1340 ret = wifi_manager_ap_set_subnet_mask(ap,
1341 WIFI_MANAGER_ADDRESS_FAMILY_IPV4, txt);
1343 if (ret == WIFI_MANAGER_ERROR_NONE)
1344 ip_data->is_info_changed = TRUE;
1346 free_ip_info_text(ENTRY_TYPE_SUBNET_MASK);
1349 txt = g_strdup(get_ip_info_text(ENTRY_TYPE_GATEWAY));
1351 txt = g_strdup(DEFAULT_GUIDE_IP);
1352 if (g_strcmp0(prev_ip_info->gateway_addr, txt) != 0) {
1353 ret = wifi_manager_ap_set_gateway_address(ap,
1354 WIFI_MANAGER_ADDRESS_FAMILY_IPV4, txt);
1356 if (ret == WIFI_MANAGER_ERROR_NONE)
1357 ip_data->is_info_changed = TRUE;
1359 free_ip_info_text(ENTRY_TYPE_GATEWAY);
1362 txt = g_strdup(get_ip_info_text(ENTRY_TYPE_DNS_1));
1364 txt = g_strdup(DEFAULT_GUIDE_IP);
1365 if (g_strcmp0(prev_ip_info->dns_1, txt) != 0) {
1366 ret = wifi_manager_ap_set_dns_address(ap, 1,
1367 WIFI_MANAGER_ADDRESS_FAMILY_IPV4, txt);
1369 if (ret == WIFI_MANAGER_ERROR_NONE)
1370 ip_data->is_info_changed = TRUE;
1372 free_ip_info_text(ENTRY_TYPE_DNS_1);
1375 txt = g_strdup(get_ip_info_text(ENTRY_TYPE_DNS_2));
1377 txt = g_strdup(DEFAULT_GUIDE_IP);
1378 if (g_strcmp0(prev_ip_info->dns_2, txt) != 0) {
1379 ret = wifi_manager_ap_set_dns_address(ap, 2,
1380 WIFI_MANAGER_ADDRESS_FAMILY_IPV4, txt);
1382 if (ret == WIFI_MANAGER_ERROR_NONE)
1383 ip_data->is_info_changed = TRUE;
1385 free_ip_info_text(ENTRY_TYPE_DNS_2);
1389 proxy_addr = g_strdup(get_ip_info_text(ENTRY_TYPE_PROXY_ADDR));
1390 if (proxy_addr == NULL) {
1391 DEBUG_LOG(UG_NAME_NORMAL, "Set proxy type - auto");
1392 if (prev_ip_info->proxy_type != WIFI_MANAGER_PROXY_TYPE_AUTO)
1393 wifi_manager_ap_set_proxy_type(ap, WIFI_MANAGER_PROXY_TYPE_AUTO);
1395 proxy_port = g_strdup(get_ip_info_text(ENTRY_TYPE_PROXY_PORT));
1397 txt = g_strdup_printf("%s:%s", proxy_addr, proxy_port);
1399 txt = g_strdup_printf("%s:%s", proxy_addr, DEFAULT_GUIDE_PROXY_PORT);
1401 DEBUG_LOG(UG_NAME_NORMAL, "Set proxy type - manual : %s", txt);
1402 if (prev_ip_info->proxy_type != WIFI_MANAGER_PROXY_TYPE_MANUAL)
1403 wifi_manager_ap_set_proxy_type(ap, WIFI_MANAGER_PROXY_TYPE_MANUAL);
1405 if (g_strcmp0(prev_ip_info->proxy_data, txt) != 0)
1406 wifi_manager_ap_set_proxy_address(ap, WIFI_MANAGER_ADDRESS_FAMILY_IPV4, txt);
1408 free_ip_info_text(ENTRY_TYPE_PROXY_ADDR);
1409 free_ip_info_text(ENTRY_TYPE_PROXY_PORT);
1419 /* ip_info_print_values(ap); */
1421 __COMMON_FUNC_EXIT__;
1424 void ip_info_remove(ip_info_list_t *ip_info_list)
1426 __COMMON_FUNC_ENTER__;
1429 g_free(ip_info_list);
1431 __COMMON_FUNC_EXIT__;
1434 void ip_info_close_all_keypads(ip_info_list_t *ip_info_list)
1436 __COMMON_FUNC_ENTER__;
1438 if (!ip_info_list) {
1439 __COMMON_FUNC_EXIT__;
1443 if (WIFI_MANAGER_IP_CONFIG_TYPE_STATIC == ip_info_list->ip_type) {
1444 if (ip_info_list->ip_addr_item)
1445 common_utils_edit_box_focus_set(ip_info_list->ip_addr_item, EINA_FALSE);
1446 if (ip_info_list->subnet_mask_item)
1447 common_utils_edit_box_focus_set(ip_info_list->subnet_mask_item, EINA_FALSE);
1448 if (ip_info_list->gateway_addr_item)
1449 common_utils_edit_box_focus_set(ip_info_list->gateway_addr_item, EINA_FALSE);
1450 if (ip_info_list->dns_1_item)
1451 common_utils_edit_box_focus_set(ip_info_list->dns_1_item, EINA_FALSE);
1452 if (ip_info_list->dns_2_item)
1453 common_utils_edit_box_focus_set(ip_info_list->dns_2_item, EINA_FALSE);
1454 if (ip_info_list->proxy_addr_item)
1455 common_utils_edit_box_focus_set(ip_info_list->proxy_addr_item, EINA_FALSE);
1456 if (ip_info_list->proxy_port_item)
1457 common_utils_edit_box_focus_set(ip_info_list->proxy_port_item, EINA_FALSE);
1459 __COMMON_FUNC_EXIT__;
1462 void ip_info_enable_all_keypads(ip_info_list_t *ip_info_list)
1464 __COMMON_FUNC_ENTER__;
1466 if (!ip_info_list) {
1467 __COMMON_FUNC_EXIT__;
1471 if (WIFI_MANAGER_IP_CONFIG_TYPE_STATIC == ip_info_list->ip_type) {
1472 if (ip_info_list->ip_addr_item)
1473 common_utils_edit_box_allow_focus_set(ip_info_list->ip_addr_item, EINA_TRUE);
1474 if (ip_info_list->subnet_mask_item)
1475 common_utils_edit_box_allow_focus_set(ip_info_list->subnet_mask_item, EINA_TRUE);
1476 if (ip_info_list->gateway_addr_item)
1477 common_utils_edit_box_allow_focus_set(ip_info_list->gateway_addr_item, EINA_TRUE);
1478 if (ip_info_list->dns_1_item)
1479 common_utils_edit_box_allow_focus_set(ip_info_list->dns_1_item, EINA_TRUE);
1480 if (ip_info_list->dns_2_item)
1481 common_utils_edit_box_allow_focus_set(ip_info_list->dns_2_item, EINA_TRUE);
1482 if (ip_info_list->proxy_addr_item)
1483 common_utils_edit_box_allow_focus_set(ip_info_list->proxy_addr_item, EINA_TRUE);
1484 if (ip_info_list->proxy_port_item)
1485 common_utils_edit_box_allow_focus_set(ip_info_list->proxy_port_item, EINA_TRUE);
1487 __COMMON_FUNC_EXIT__;