4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
6 * Contact: MyoungJune Park <mj2004.park@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
21 #include <setting-cfg.h>
22 #include <setting-about-main.h>
24 #include <iniparser.h>
25 #include <sys/types.h>
28 #include <bluetooth-api.h>
31 #include <app_manager.h>
33 #define DEVNAME_BLOCK_SPACE 0
34 // #define SUPPORT_DIAG_USAGE
36 /** @todo : need to handle unicode encoded input characters */
38 #define MAX_DEVICE_NAME_LEN 24
39 #define EMPTY_LIMITATION_STR "IDS_ST_BODY_THE_NAME_FIELD_CANNOT_BE_EMPTY"
40 #define DIAGNOSTICS_USAGE_STR "Diagnostics and Usage"
41 #define SOFTWARE_UPDATE_STR "IDS_ST_MBODY_SOFTWARE_UPDATE"
44 static int setting_about_main_create(void *cb);
45 static int setting_about_main_destroy(void *cb);
46 static int setting_about_main_update(void *cb);
47 static int setting_about_main_cleanup(void *cb);
49 setting_view setting_view_about_main = {
50 .create = setting_about_main_create,
51 .destroy = setting_about_main_destroy,
52 .update = setting_about_main_update,
53 .cleanup = setting_about_main_cleanup,
56 static void __setting_about_main_exp_cb(void *data, Evas_Object *obj, void *event_info);
59 * Do process when clicking '<-' button
65 static void setting_about_main_click_softkey_back_cb(void *data,
70 * Do process when clicking on some genlist item
76 static void setting_about_main_mouse_up_Gendial_list_cb(void *data,
80 static void __setting_about_main_mobile_ap_turn_off_ask_resp_cb(void *data,
84 static void __setting_about_main_certificates_clicked(void *data);
85 static void __setting_about_main_device_name_clicked(void *data, Evas_Object *obj);
86 static void __setting_about_main_diagnostics_usage_clicked(void *data, Evas_Object *obj);
88 static void __setting_about_sub_list_rd_change(void *data, Evas_Object *obj, void *event_info);
89 /* ***************************************************
93 ***************************************************/
94 static void __about_popup_rsp_cb(void *data, Evas_Object *obj, void *event_info)
96 SettingAboutUG *ad = data;
103 static void __device_name_changed_cb(void *data, Evas_Object *obj)
105 retm_if(!data || !obj, "Data parameter is NULL");
106 //return if entry is not focused too
108 Setting_GenGroupItem_Data *list_item =
109 (Setting_GenGroupItem_Data *) data;
110 SettingAboutUG *ad = list_item->userdata;
111 retm_if(ad == NULL, "Data parameter is NULL");
113 const char *entry_str = elm_entry_entry_get(obj);
114 int entry_len = safeStrLen(entry_str);
115 SETTING_TRACE("entry_str:[%s], lenght:%d", entry_str, entry_len);
117 #if DEVNAME_BLOCK_SPACE
119 if (entry_len > 0 && NULL != strstr(entry_str, " ")) {//cancel the effect of input 'space character'
120 SETTING_TRACE("Cannot input the 'space' key or 'enter' key");
124 char *tmp = (char *)g_strdup(entry_str);
127 for (j = i; tmp[j]; j++) {
134 G_FREE(list_item->sub_desc);
135 list_item->sub_desc = (char *)g_strdup(tmp);
137 SETTING_TRACE("sub_desc:[%s]", list_item->sub_desc);
139 elm_entry_entry_set(obj, list_item->sub_desc);
140 elm_entry_cursor_end_set(obj);
144 G_FREE(list_item->sub_desc);//release first
145 list_item->sub_desc = (char *)g_strdup(entry_str);
147 if (NULL == entry_str || 0 == entry_len) {
150 ad->empty_flag = TRUE;
151 Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
154 Evas_Object *back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
155 setting_disable_evas_object(back_btn);
156 setting_dim_evas_object(back_btn, TRUE);
158 Evas_Object *top_r_btn = elm_object_item_part_content_get(navi_it, "title_right_btn");
161 setting_disable_evas_object(top_r_btn);
162 setting_dim_evas_object(top_r_btn, TRUE);
169 ad->empty_flag = FALSE;
170 Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
173 Evas_Object *back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
174 setting_enable_evas_object(back_btn);
175 setting_undo_dim_evas_object(back_btn, TRUE);
177 Evas_Object *top_r_btn = elm_object_item_part_content_get(navi_it, "title_right_btn");
180 setting_enable_evas_object(top_r_btn);
181 setting_undo_dim_evas_object(top_r_btn, TRUE);
190 __setting_about_device_name_changed_cb(void *data, Evas_Object *obj,
193 __device_name_changed_cb(data, obj);
199 * - No ini: Unavailable
200 * - I9500 @ target: GT-I9500
201 * - I9500 @ emul: SDK
202 * - SLP @ target: GT-SLP
205 void setting_about_main_get_phone_model_name(char* szStr, int nSize)
207 retm_if(szStr == NULL, "szStr parameter is NULL");
212 const char* szBinVer = NULL;
214 dictionary* dic = iniparser_load(SETTING_ABOUT_INFO_PATH);
216 szBinVer = (char*)iniparser_getstr(dic, "Version:Build");
218 char* str = g_strdup(szBinVer);
225 sscanf(str, "%s %s", szBin, szEmul);
231 if (!strncmp(szEmul, "emul", 4)) {
232 snprintf(szStr, nSize, "%s", "SDK");
234 if (!strncmp(szBin, "I9500", 5)) {
235 snprintf(szStr, nSize, "GT-%s", szBin);
236 } else if (!strncmp(szBin, "SLP", 3)) {
237 snprintf(szStr, nSize, "GT-%s", szBin);
239 snprintf(szStr, nSize, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
244 iniparser_freedict(dic);
249 void setting_about_main_get_sw_version(char* szStr, int nSize)
251 retm_if(szStr == NULL, "szStr parameter is NULL");
253 dictionary* dic = iniparser_load(SETTING_ABOUT_INFO_PATH);
255 snprintf(szStr, nSize, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
258 g_strdup((char*)iniparser_getstr(dic, "Version:Build"));
260 g_strdup((char*)iniparser_getstr(dic, "Version:Major"));
262 g_strdup((char*)iniparser_getstr(dic, "Version:Minor"));
265 char* pPos = szBinVer;
267 if ('.' == *pPos) *pPos = '\0';
271 szBinVer = g_strdup(_("IDS_ST_HEADER_UNAVAILABLE"));
274 szVerMaj = g_strdup("-");
277 szVerMin = g_strdup("-");
280 snprintf(szStr, nSize, "SLP%s.%s (%s)", szVerMaj, szVerMin, szBinVer);
287 iniparser_freedict(dic);
292 void setting_about_main_get_wifi_mac_address_string(char *str, int size)
294 setting_retm_if(str == NULL, "str parameter is NULL");
295 setting_retm_if(size < SETTING_ABOUT_WIFI_MAC_STR_LEN+1, "size parameter is wrong");
297 FILE *p = fopen(SETTING_ABOUT_MACINFO_PATH, "r");
300 int size = fread(str, sizeof(char), SETTING_ABOUT_WIFI_MAC_STR_LEN, p);
301 if (size != SETTING_ABOUT_WIFI_MAC_STR_LEN) {
302 SETTING_TRACE_ERROR("fail to call fread");
307 perror("open failed!");
310 SETTING_TRACE_DEBUG("get_wifi_mac_address : %s", str);
312 int wifi_state = VCONFKEY_WIFI_OFF;
313 vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
315 if((safeStrLen(str) == 0) || (wifi_state == VCONFKEY_WIFI_OFF))
316 snprintf(str, size, "%s (%s)", _("IDS_ST_HEADER_UNAVAILABLE"), _(SETTING_ABOUT_NEVER_TURN_WIFI_ON_STR));
319 void setting_about_main_get_battery_string(char *str, int size)
321 setting_retm_if(str == NULL, "str parameter is NULL");
324 char file[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
325 snprintf(file, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO,
326 "%s/%s/%s", SETTING_ABOUT_POWER_SUPPLY_PATH, "battery", "capacity");
328 char buf[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
332 fd = open(file, O_RDONLY);
334 r = read(fd, buf, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO);
335 if ((r >= 0) && (r < MAX_DISPLAY_STR_LEN_ON_PHONE_INFO)) {
338 snprintf(str, size, "%d%s", val, "\%");
340 SETTING_TRACE_ERROR("read file fail");
341 snprintf(str, size, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
346 SETTING_TRACE_ERROR("open file fail");
347 snprintf(str, size, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
351 void setting_about_main_get_bluetooth_address_string(char *str, int size)
353 setting_retm_if(str == NULL, "str parameter is NULL");
355 bluetooth_device_address_t local_address;
356 memset(&local_address, 0x0, sizeof(local_address));
359 /* for fixing BS of dbus signal */
360 bluetooth_register_callback(NULL, NULL);
362 ret = bluetooth_get_local_address(&local_address);
364 /* for fixing BS of dbus signal */
365 bluetooth_unregister_callback();
368 snprintf(str, size, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
370 snprintf(str, size, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
371 local_address.addr[0], local_address.addr[1], local_address.addr[2],
372 local_address.addr[3], local_address.addr[4], local_address.addr[5]);
374 SETTING_TRACE_DEBUG("bt address : %s", str);
377 int __stat_get_cpuinfo(float *usr_pct, float *sys_pct)
379 setting_retvm_if(usr_pct == NULL, -ENOENT, "param usr_pct is null");
380 setting_retvm_if(sys_pct == NULL, -ENOENT, "param sys_pct is null");
385 static unsigned long long usr_time = 0, nice_time = 0, sys_time = 0;
386 static unsigned long long old_usr = 0, old_nice = 0, old_sys = 0;
387 static struct timeval old_tv, cur_tv;
388 unsigned long long elapsed_tick;
394 tick_per_sec = sysconf(_SC_CLK_TCK);
395 cpu_num = sysconf(_SC_NPROCESSORS_ONLN);
400 gettimeofday(&cur_tv, NULL);
401 fp = fopen(SETTING_ABOUT_STAT_PATH, "r");
403 SETTING_TRACE_ERROR("fp == NULL");
407 char cpu_info[MAX_COMMON_BUFFER_LEN] = {0,};
408 char *cpu_info_p = fgets(cpu_info, MAX_COMMON_BUFFER_LEN, fp);
410 if(cpu_info_p == NULL) {
411 SETTING_TRACE_ERROR("fgets failed");
412 fclose(fp); // free - code
417 unsigned long long tmp_long = 0;
419 /* split cpu_info, get 3 numbers headmost*/
420 while ((substr = strsep(&cpu_info_p, " \t")) != NULL) {
422 tmp_long = strtoull(substr, &endptr, 10);
423 if (tmp_long != 0 && tmp_long != ULLONG_MAX) {
429 nice_time = tmp_long;
448 SETTING_TRACE_ERROR("old_usr == 0");
452 elapsed_tick = (cur_tv.tv_sec - old_tv.tv_sec) * tick_per_sec +
453 ((cur_tv.tv_usec - old_tv.tv_usec) * tick_per_sec) / 1000000;
456 if (elapsed_tick != 0)
458 ((float)(usr_time - old_usr) * 100 / elapsed_tick) /
463 if (elapsed_tick != 0)
465 ((float)(sys_time - old_sys) * 100 / elapsed_tick) /
472 old_nice = nice_time;
479 static Eina_Bool __timer_update_cb(const void *data)
481 retv_if(data == NULL, TRUE);
482 SettingAboutUG *ad = (SettingAboutUG *) data;
484 char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
485 if (ad->item_data_cpu) {
487 int ret = __stat_get_cpuinfo(&usr, &sys);
488 if (ret == -ENOENT) {
489 SETTING_TRACE_ERROR("call __stat_get_cpuinfo fail");
490 snprintf(str, sizeof(str), "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
492 snprintf(str, sizeof(str), "%.0f%s", usr + sys, "\%");
495 ad->item_data_cpu->sub_desc = (char *)g_strdup(str);
496 elm_object_item_data_set(ad->item_data_cpu->item, ad->item_data_cpu);
497 elm_genlist_item_update(ad->item_data_cpu->item);
500 if (ad->item_data_battery) {
501 setting_about_main_get_battery_string(str, sizeof(str));
502 /*SETTING_TRACE("str:%s", str);*/
503 ad->item_data_battery->sub_desc = (char *)g_strdup(str);
504 elm_object_item_data_set(ad->item_data_battery->item, ad->item_data_battery);
505 elm_genlist_item_update(ad->item_data_battery->item);
511 __about_main_gl_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event)
514 SettingAboutUG *ad = (SettingAboutUG *) data;
515 retm_if(event == NULL, "Invalid argument: event info is NULL");
516 Evas_Event_Mouse_Up *ev = (Evas_Event_Mouse_Up *)event;
518 if (ad->item_dev_name) {
519 Elm_Object_Item *selected_item = elm_genlist_at_xy_item_get(ad->genlsit, ev->output.x, ev->output.y, NULL);
520 if (ad->item_dev_name->item == selected_item)//do nothing..
523 elm_object_focus_set(ad->item_dev_name->eo_check, EINA_FALSE);//to make inputing words input
527 static void __entry_unfocus_cb(void *data, Evas_Object *obj, void *event_info)
530 retm_if(!data || !obj, "Data parameter is NULL");
532 Evas_Object *entry_container = elm_object_parent_widget_get(obj);
533 if (entry_container) {
534 //whe entry unfocused, its guidetext will becomes "Input here"
535 elm_object_part_text_set(entry_container, "elm.guidetext", _("IDS_ST_BODY_TAP_TO_INSERT"));
536 if (elm_entry_is_empty(obj))
537 elm_object_signal_emit(entry_container, "elm,state,guidetext,show", "elm");
538 elm_object_signal_emit(entry_container, "elm,state,eraser,hide", "elm");
541 //Setting_GenGroupItem_Data *list_item = data;
542 const char *entry_str = elm_entry_entry_get(obj);
543 char *entry_str_utf8 = NULL;
544 entry_str_utf8 = elm_entry_markup_to_utf8(entry_str);
545 //int len = safeStrLen(entry_str_utf8);
546 SETTING_TRACE("To store \"%s\" into vconf[%s]", entry_str_utf8, VCONFKEY_SETAPPL_DEVICE_NAME_STR);
548 //ecore_idler_add(__check_on_idler, ad);
549 Setting_GenGroupItem_Data *item_dev_name = data;
550 SettingAboutUG *ad = item_dev_name->userdata;
551 __device_name_changed_cb(item_dev_name, item_dev_name->eo_check);
552 //after unfocus,need updating..
553 elm_object_item_data_set(item_dev_name->item, item_dev_name);
554 elm_genlist_item_update(item_dev_name->item);
558 && elm_object_item_part_content_get(ad->navi_item, "title_right_btn")) {
559 Evas_Object *btn = elm_object_item_part_content_unset(ad->navi_item, "title_right_btn");
560 evas_object_del(btn);
562 setting_hide_input_pannel_cb(item_dev_name->eo_check);
564 if (ad->empty_flag) {
566 evas_object_del(ad->popup);
569 ad->popup = setting_create_popup_without_btn(ad, ad->win_get, NULL, _(EMPTY_LIMITATION_STR),
570 __about_popup_rsp_cb, POPUP_INTERVAL, FALSE, FALSE);
577 if (0 != vconf_set_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR, entry_str_utf8)) {
578 SETTING_TRACE_ERROR("Set vconf[%s] failed",
579 VCONFKEY_SETAPPL_DEVICE_NAME_STR);
582 FREE(entry_str_utf8);
586 static void __entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
588 ret_if(data == NULL);
589 SettingAboutUG *ad = (SettingAboutUG*)data;
590 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
591 SETTING_TRACE_DEBUG("ev->key : %s", ev->key);
593 SETTING_TRACE("ad->item_dev_name->eo_check:%p", ad->item_dev_name->eo_check);
594 SETTING_TRACE("obj:%p, %s", obj, elm_entry_entry_get(obj));
595 if(safeStrCmp(ev->key, "Return") == 0)
597 // if entry has 1 char at list, hide ime.
598 if(safeStrLen(elm_entry_entry_get(obj)) > 0)
600 ecore_imf_context_input_panel_hide((Ecore_IMF_Context*)elm_entry_imf_context_get(obj));
605 evas_object_del(ad->popup);
608 ad->popup = setting_create_popup_without_btn(ad, ad->win_get, NULL, _(EMPTY_LIMITATION_STR),
609 __about_popup_rsp_cb, POPUP_INTERVAL, FALSE, FALSE);
612 Evas_Object *entry_container = elm_object_parent_widget_get(obj);
613 if(safeStrLen(elm_entry_entry_get(obj)) > 0) {
614 elm_object_signal_emit(entry_container, "elm,state,guidetext,hide", "elm");
616 //elm_object_part_text_set(entry_container, "elm.guidetext", _("IDS_ST_BODY_TAP_TO_INSERT"));
617 elm_object_signal_emit(entry_container, "elm,state,guidetext,show", "elm");
623 int setting_about_generate_genlist(void *data)
627 retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
629 SettingAboutUG *ad = (SettingAboutUG *) data;
631 Evas_Object *scroller = ad->genlsit;
632 Elm_Object_Item *item = NULL;
633 Setting_GenGroupItem_Data *item_data = NULL;
634 char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
635 (void)setting_create_Gendial_field_titleItem(scroller,
636 &(ad->itc_group_item),
637 SETTING_ABOUT_DEVICE_INFO_STR, NULL);
639 char *name_value = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
640 char *pa_sub_desc = elm_entry_utf8_to_markup(name_value);
643 ad->empty_flag = FALSE;
644 if (NULL == pa_sub_desc || '\0' == pa_sub_desc[0])
646 ad->empty_flag = TRUE;
647 Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
650 Evas_Object *back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
651 setting_disable_evas_object(back_btn);
652 setting_dim_evas_object(back_btn, TRUE);
658 char *app_name = NULL;
659 int ret_get_app_name = app_manager_get_app_name("com.samsung.oma-dm-ui", &app_name);
660 if (ret_get_app_name == APP_MANAGER_ERROR_INVALID_PACKAGE )
662 SETTING_TRACE(">>>>>>>>>>>>>>>>>> UNINSTALLED PACKAGE");
663 ad->item_dev_name = NULL;
667 setting_create_Gendial_field_def(scroller, &(ad->itc_1icon),
668 setting_about_main_mouse_up_Gendial_list_cb,
669 ad, SWALLOW_Type_LAYOUT_ENTRY,
670 NULL, NULL, 0, SETTING_ABOUT_DEVICE_NAME_STR, pa_sub_desc,
671 __setting_about_device_name_changed_cb);
672 if (ad->item_dev_name) {
673 ad->item_dev_name->userdata = ad;
674 ad->item_dev_name->isSinglelineFlag = 1;
675 ad->item_dev_name->start_change_cb = (setting_call_back_func)__entry_key_down_cb;
676 ad->item_dev_name->stop_change_cb = __entry_unfocus_cb;
677 ad->item_dev_name->limit_filter_data = calloc(1, sizeof(Elm_Entry_Filter_Accept_Set));
679 if (ad->item_dev_name->limit_filter_data) {
680 //max byte len is 31 not 31+1
681 //ad->item_dev_name->limit_filter_data->max_byte_count = MAX_DEVICE_NAME_LEN + OFFESET_ENTRY_FILTER;
682 ad->item_dev_name->limit_filter_data->max_byte_count = MAX_DEVICE_NAME_LEN;
683 ad->item_dev_name->win_main = ad->win_get;
685 //ad->item_dev_name->input_type = ELM_INPUT_PANEL_LAYOUT_NUMBER;
686 ad->item_dev_name->input_panel_disable_flag = EINA_TRUE;
688 SETTING_TRACE_ERROR("ad->item_dev_name is NULL");
694 if (ad->my_numbers.count == 1) {
696 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2),
697 setting_about_main_mouse_up_Gendial_list_cb,
698 ad, SWALLOW_Type_INVALID, NULL,
699 NULL, 0, SETTING_ABOUT_MY_NUMBER_STR,
700 ad->my_numbers.list[0].name, NULL);
702 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
704 SETTING_TRACE_ERROR("item_data is NULL");
706 } else if (ad->my_numbers.count > 1){
707 setting_enable_expandable_genlist(scroller, ad,
708 __setting_about_main_exp_cb, NULL);
709 item_data = setting_create_Gendial_exp_parent_field(scroller,
710 &(ad->itc_2text_3_parent),
712 SWALLOW_Type_INVALID,
713 SETTING_ABOUT_MY_NUMBER_STR,
714 ad->my_numbers.list[ad->my_number_sel_idx].name);
717 SETTING_TRACE_ERROR("don't have my number");
721 memset(str, 0x00, sizeof(str));
722 setting_about_main_get_phone_model_name(str, sizeof(str));
724 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
725 NULL, SWALLOW_Type_INVALID, NULL,
726 NULL, 0, SETTING_ABOUT_MODEL_STR, str, NULL);
728 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
730 SETTING_TRACE_ERROR("item_data is NULL");
734 memset(str, 0x00, sizeof(str));
735 setting_about_main_get_sw_version(str, sizeof(str));
737 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
738 NULL, SWALLOW_Type_INVALID, NULL,
739 NULL, 0, SETTING_ABOUT_VERSION_STR, str, NULL);
741 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
743 SETTING_TRACE_ERROR("item_data is NULL");
746 // [UI] Bluetooth address
747 if ( ! isEmulBin()) { // requested by DI Kim due to BT BS on 11/26
748 memset(str, 0x00, sizeof(str));
749 setting_about_main_get_bluetooth_address_string(str, sizeof(str));
751 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
752 NULL, SWALLOW_Type_INVALID, NULL,
753 NULL, 0, SETTING_ABOUT_BLUETOOTH_STR, str, NULL);
754 if (ad->item_data_bt) {
755 elm_genlist_item_select_mode_set(ad->item_data_bt->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
757 SETTING_TRACE_ERROR("item_data is NULL");
762 memset(str, 0x00, sizeof(str));
763 setting_about_main_get_wifi_mac_address_string(str, sizeof(str));
765 SETTING_TRACE_DEBUG("[about main] get_wifi_mac_address : %s", str);
768 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
769 NULL, SWALLOW_Type_INVALID, NULL,
770 NULL, 0, SETTING_ABOUT_WIFI_STR, str, NULL);
771 if (ad->item_data_wifi) {
772 elm_genlist_item_select_mode_set(ad->item_data_wifi->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
774 SETTING_TRACE_ERROR("item_data is NULL");
778 memset(str, 0x00, sizeof(str));
779 setting_about_main_get_battery_string(str, sizeof(str));
781 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
782 NULL, SWALLOW_Type_INVALID, NULL,
783 NULL, 0, SETTING_ABOUT_BATTERY_STR, str, NULL);
785 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
786 ad->item_data_battery = item_data;
788 SETTING_TRACE_ERROR("item_data is NULL");
792 memset(str, 0x00, sizeof(str));
794 int ret = __stat_get_cpuinfo(&usr, &sys);
795 if (ret == -ENOENT) {
796 SETTING_TRACE_ERROR("call __stat_get_cpuinfo fail");
797 snprintf(str, sizeof(str), "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
799 snprintf(str, sizeof(str), "%.0f%s", usr + sys, "\%");
802 ad->item_data_cpu = item_data =
803 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
804 NULL, SWALLOW_Type_INVALID, NULL,
805 NULL, 0, SETTING_ABOUT_CPU_USAGE_STR, str, NULL);
807 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
809 SETTING_TRACE_ERROR("item_data is NULL");
814 elm_genlist_item_append(scroller, &(ad->itc_seperator), NULL, NULL,
815 ELM_GENLIST_ITEM_NONE, NULL, NULL);
816 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
818 #ifdef SUPPORT_DIAG_USAGE
819 // [UI] Diagnostics and Usage
821 setting_create_Gendial_field_def(scroller, &(ad->itc_1text),
822 setting_about_main_mouse_up_Gendial_list_cb,
823 ad, SWALLOW_Type_INVALID, NULL, NULL,
824 0, DIAGNOSTICS_USAGE_STR,
830 // [UI] Software update
832 setting_create_Gendial_field_def(scroller, &(ad->itc_1text),
833 setting_about_main_mouse_up_Gendial_list_cb,
834 ad, SWALLOW_Type_INVALID, NULL, NULL,
835 0, SOFTWARE_UPDATE_STR,
840 // implementation is in progress.
841 if (is_ug_installed_by_ug_args("setting-manage-applications-efl"))
843 setting_create_Gendial_field_def(scroller, &(ad->itc_1text),
844 setting_about_main_mouse_up_Gendial_list_cb,
845 ad, SWALLOW_Type_INVALID, NULL, NULL,
846 0, "IDS_COM_BODY_CERTIFICATES", NULL, NULL);
848 item = elm_genlist_item_append(scroller, &itc_bottom_seperator, NULL, NULL,
849 ELM_GENLIST_ITEM_NONE, NULL, NULL);
850 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
855 ecore_timer_add(2, (Ecore_Task_Cb) __timer_update_cb, ad);
857 return SETTING_RETURN_SUCCESS;
860 static int setting_about_main_create(void *cb)
864 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
866 SettingAboutUG *ad = (SettingAboutUG *) cb;
868 Evas_Object *scroller = elm_genlist_add(ad->win_main_layout);
869 retvm_if(scroller == NULL, SETTING_DRAW_ERR_FAIL_SCROLLER,
870 "Cannot set scroller object as contento of layout");
871 elm_object_style_set(scroller, "dialogue");
872 elm_genlist_clear(scroller); /* first to clear list */
874 /* Enabling illume notification property for window */
875 elm_win_conformant_set(ad->win_main_layout, 1);
876 Evas_Object *conformant = elm_conformant_add(ad->win_main_layout);
877 elm_object_style_set(conformant, "internal_layout"); /* By Kollus. 2011-01-04 */
878 evas_object_show(conformant);
879 elm_object_content_set(conformant, scroller);
880 ad->genlsit = scroller;
883 setting_create_layout_navi_bar(ad->win_main_layout, ad->win_get,
884 _(KeyStr_AboutPhone),
885 _("IDS_COM_BODY_BACK"), NULL, NULL,
886 setting_about_main_click_softkey_back_cb,
887 NULL, NULL, ad, conformant,
888 &ad->navi_bar, NULL);
890 evas_object_event_callback_add(scroller, EVAS_CALLBACK_MOUSE_UP,
891 __about_main_gl_mouse_up, ad);
893 ad->navi_item = elm_naviframe_top_item_get(ad->navi_bar);
897 setting_get_int_slp_key(INT_SLP_SETTING_SIM_SLOT, &value, &err);
898 if (VCONFKEY_TELEPHONY_SIM_INSERTED != value)
900 setting_about_generate_genlist((void *)ad);
902 if (ad->handle && !ad->tapi_responsed) {//not responsed yet
903 //SETTING_TRACE(">>> IF THERE'S SIM CARD, THIS LINE SHOULD NOT WORK");
904 } else {//already responsed
909 setting_view_about_main.is_create = 1;
911 return SETTING_RETURN_SUCCESS;
914 static int setting_about_main_destroy(void *cb)
918 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
920 SettingAboutUG *ad = (SettingAboutUG *) cb;
922 if (ad->update_timer) {
923 ecore_timer_del(ad->update_timer);
924 ad->update_timer = NULL;
927 evas_object_del(ad->popup);
931 if (ad->ly_main != NULL) {
932 evas_object_del(ad->ly_main);
936 setting_view_about_main.is_create = 0;
937 return SETTING_RETURN_SUCCESS;
940 static int setting_about_main_update(void *cb)
944 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
946 SettingAboutUG *ad = (SettingAboutUG *) cb;
948 if (ad->ly_main != NULL) {
949 evas_object_show(ad->ly_main);
952 return SETTING_RETURN_SUCCESS;
955 static int setting_about_main_cleanup(void *cb)
959 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
961 SettingAboutUG *ad = (SettingAboutUG *) cb;
963 if (ad->ly_main != NULL) {
964 /* evas_object_hide(ad->ly_main); */
967 return SETTING_RETURN_SUCCESS;
970 /* ***************************************************
974 ***************************************************/
976 /* ***************************************************
980 ***************************************************/
983 setting_about_main_click_softkey_back_cb(void *data, Evas_Object *obj,
988 setting_retm_if(data == NULL, "Data parameter is NULL");
990 SettingAboutUG *ad = (SettingAboutUG *) data;
991 if (ad->empty_flag) {
993 evas_object_del(ad->popup);
996 ad->popup = setting_create_popup_without_btn(ad, ad->win_get, NULL, _(EMPTY_LIMITATION_STR),
997 __about_popup_rsp_cb, POPUP_INTERVAL, FALSE, FALSE);
998 if (ad->item_dev_name) {
999 elm_object_focus_set(ad->item_dev_name->eo_check, EINA_TRUE);
1004 /* Send destroy request */
1005 ug_destroy_me(ad->ug);
1006 //imf must be hided before view is destroyed.
1007 //Following code is just to improve the hiding speed. If not add these code,
1008 //the input pannel will also be hided with the view destroyed,but it works too slow.
1009 if (ad->item_dev_name) {
1010 elm_object_focus_set(ad->item_dev_name->eo_check, EINA_FALSE);
1011 setting_hide_input_pannel_cb(ad->item_dev_name->eo_check);
1025 setting_about_main_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj,
1028 SETTING_TRACE_BEGIN;
1030 setting_retm_if(data == NULL, "Data parameter is NULL");
1032 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
1033 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
1034 elm_genlist_item_selected_set(item, 0);
1035 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
1037 /* SettingAboutUG *ad = (SettingAboutUG *) data; */
1039 SETTING_TRACE("clicking item[%s]", _(list_item->keyStr));
1040 if (!safeStrCmp("IDS_ST_BODY_OPEN_SOURCE_LICENCES", list_item->keyStr)) {
1042 //setting_view_change(&setting_view_about_main, &setting_view_about_licences, data);
1044 } else if (!safeStrCmp("IDS_COM_BODY_CERTIFICATES", list_item->keyStr)) {
1045 __setting_about_main_certificates_clicked(data);
1046 } else if (!safeStrCmp(SETTING_ABOUT_DEVICE_NAME_STR, list_item->keyStr)) {
1047 __setting_about_main_device_name_clicked(data, list_item->eo_check);
1048 } else if (!safeStrCmp(DIAGNOSTICS_USAGE_STR, list_item->keyStr)) {
1049 __setting_about_main_diagnostics_usage_clicked(data, list_item->eo_check);
1050 } else if (!safeStrCmp(SOFTWARE_UPDATE_STR, list_item->keyStr)) {
1052 if(aul_app_is_running("com.samsung.oma-dm-ui"))
1054 SETTING_TRACE_DEBUG("oma-dm-ui is already launched. ");
1055 aul_open_app("com.samsung.oma-dm-ui");
1059 SETTING_TRACE_DEBUG("oma-dm-ui will be launched. ");
1060 aul_launch_app("com.samsung.oma-dm-ui", NULL);
1066 static void __destroy_certificates_ug_cb(ui_gadget_h ug, void *priv)
1068 SETTING_TRACE_BEGIN;
1070 /* restore the '<-' button on the navigate bar */
1072 SettingAboutUG *ad = (SettingAboutUG *) priv; /* ad is point to priv */
1076 ad->ug_loading = NULL;
1081 static void __setting_about_main_certificates_clicked(void *data)
1083 SETTING_TRACE_BEGIN;
1084 retm_if(data == NULL, "Data parameter is NULL");
1085 SettingAboutUG *ad = (SettingAboutUG *)data;
1087 struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
1092 cbs->layout_cb = setting_about_layout_ug_cb;
1093 cbs->result_cb = NULL;
1094 cbs->destroy_cb = __destroy_certificates_ug_cb;
1095 cbs->priv = (void *)ad;
1098 ug_create(ad->ug, "setting-manage-certificates-efl", UG_MODE_FULLVIEW, NULL, cbs);
1100 if (NULL == ad->ug_loading) { /* error handling */
1101 SETTING_TRACE_ERROR("NULL == ad->ug_loading");
1106 static void __top_back_cb(void *data, Evas_Object *obj,
1109 SETTING_TRACE_BEGIN;
1111 setting_retm_if(data == NULL, "Data parameter is NULL");
1113 SettingAboutUG *ad = (SettingAboutUG *) data;
1115 if (ad->item_dev_name)
1116 setting_hide_input_pannel_cb(ad->item_dev_name->eo_check);
1121 static void _input_panel_event_cb(void *data, Ecore_IMF_Context *ctx, int value)
1123 SETTING_TRACE_BEGIN;
1124 retm_if(data == NULL, "Data parameter is NULL");
1125 retm_if(ctx == NULL, "obj parameter is NULL");
1127 SettingAboutUG *ad = (SettingAboutUG *)data;
1129 if(value == ECORE_IMF_INPUT_PANEL_STATE_SHOW)
1131 SETTING_TRACE("value == ECORE_IMF_INPUT_PANEL_STATE_SHOW");
1132 if(ad->navi_item && !elm_object_item_part_content_get(ad->navi_item, "title_right_btn"))
1134 Evas_Object *r_button = setting_create_button(ad->navi_bar,
1135 dgettext("sys_string", "IDS_COM_BODY_BACK"),
1136 NAVI_BACK_BUTTON_STYLE,
1139 elm_object_item_part_content_set(ad->navi_item, "title_right_btn", r_button);
1142 else if(value == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
1144 SETTING_TRACE("value == ECORE_IMF_INPUT_PANEL_STATE_HIDE");
1145 if(ad->navi_item && elm_object_item_part_content_get(ad->navi_item, "title_right_btn")) {
1146 Evas_Object *btn = elm_object_item_part_content_unset(ad->navi_item, "title_right_btn");
1147 evas_object_del(btn);
1150 if (ad->item_dev_name) {
1151 elm_object_focus_set(ad->item_dev_name->eo_check, EINA_FALSE);
1156 static void __setting_about_main_device_name_clicked(void *data, Evas_Object *obj)
1158 SETTING_TRACE_BEGIN;
1159 retm_if(data == NULL, "Data parameter is NULL");
1160 retm_if(obj == NULL, "obj parameter is NULL");
1161 SettingAboutUG *ad = (SettingAboutUG *)data;
1163 int mobile_ap_status = VCONFKEY_MOBILE_HOTSPOT_MODE_NONE;
1165 int ret = setting_get_int_slp_key(INT_SLP_SETTING_MOBILE_AP_STATUS, &mobile_ap_status, &err);
1166 setting_retm_if(ret == SETTING_RETURN_FAIL, "Get vconf failed");
1168 if (!elm_object_focus_get(obj)) {
1169 elm_object_focus_set(obj, EINA_TRUE);
1172 if ((mobile_ap_status & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) && !ad->popup_showed_flag) {
1174 evas_object_del(ad->popup);
1177 ad->popup = setting_create_popup_with_btn(ad, ad->win_get,
1178 NULL, _(SETTING_ABOUT_MOBILE_AP_TURNED_OFF),
1179 __setting_about_main_mobile_ap_turn_off_ask_resp_cb, 0,
1180 1, _("IDS_COM_SK_OK"));
1182 Ecore_IMF_Context *imf_context = (Ecore_IMF_Context *)elm_entry_imf_context_get(obj);
1183 setting_retm_if(imf_context == NULL, "imf_context is NULL");
1184 ecore_imf_context_input_panel_event_callback_add(imf_context, ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_event_cb, ad);
1185 ecore_imf_context_input_panel_show(imf_context);
1190 static void __destroy_diagnostics_usage_ug_cb(ui_gadget_h ug, void *priv)
1192 SETTING_TRACE_BEGIN;
1194 /* restore the '<-' button on the navigate bar */
1196 SettingAboutUG *ad = (SettingAboutUG *) priv; /* ad is point to priv */
1200 ad->ug_loading = NULL;
1203 Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
1205 Evas_Object *back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
1207 if (back_btn != NULL) {
1208 elm_object_style_set(back_btn, NAVI_BACK_BUTTON_STYLE); /* take into effect */
1212 static void __setting_about_main_diagnostics_usage_clicked(void *data, Evas_Object *obj)
1214 SETTING_TRACE_BEGIN;
1215 retm_if(data == NULL, "Data parameter is NULL");
1216 SettingAboutUG *ad = (SettingAboutUG *)data;
1220 return; /* do nothing if ad is NULL */
1222 struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
1227 cbs->layout_cb = setting_about_layout_ug_cb;
1228 cbs->result_cb = NULL;
1229 cbs->destroy_cb = __destroy_diagnostics_usage_ug_cb;
1230 cbs->priv = (void *)ad;
1233 ug_create(ad->ug, "setting-crash-efl", UG_MODE_FULLVIEW, NULL, cbs);
1235 if (NULL == ad->ug_loading) { /* error handling */
1236 SETTING_TRACE_ERROR("NULL == ad->ug_loading");
1237 setting_create_simple_popup(ad, ad->win_get, NULL, _(UNSUPPORTED_FUNCTION));
1242 static void __setting_about_main_mobile_ap_turn_off_ask_resp_cb(void *data,
1246 SETTING_TRACE_BEGIN;
1247 setting_retm_if(data == NULL, "Data parameter is NULL");
1248 SettingAboutUG *ad = (SettingAboutUG *)data;
1249 int response_type = btn_type(obj);
1251 if (POPUP_RESPONSE_OK == response_type) {
1252 ad->popup_showed_flag = TRUE;
1254 if (ad->item_dev_name) {
1255 Ecore_IMF_Context *imf_context = elm_entry_imf_context_get(ad->item_dev_name->eo_check);
1256 setting_retm_if(imf_context == NULL, "imf_context is NULL");
1257 ecore_imf_context_input_panel_show(imf_context);
1263 evas_object_del(ad->popup);
1268 static void __setting_about_main_exp_cb(void *data, Evas_Object *obj, void *event_info)
1270 SETTING_TRACE_BEGIN;
1271 setting_retm_if(data == NULL, "Data parameter is NULL");
1272 setting_retm_if(event_info == NULL, "event_info parameter is NULL");
1274 SettingAboutUG *ad = (SettingAboutUG *) data;
1275 Elm_Object_Item *parentItem = event_info; /* parent item */
1276 Evas_Object *scroller = elm_object_item_widget_get(parentItem);
1278 Evas_Object *rgd = elm_radio_add(scroller);
1279 elm_radio_value_set(rgd, -1);
1282 Setting_GenGroupItem_Data *item_data = NULL;
1283 for(; i < SETTING_ABOUT_MY_NUMBERS_LEN; i++) {
1284 if (ad->my_numbers.list[i].name == NULL) {
1288 item_data = setting_create_Gendial_exp_sub_field(scroller,
1289 &(ad->itc_1icon_1text_sub),
1290 NULL, NULL, parentItem,
1291 SWALLOW_Type_1RADIO, rgd,
1293 ad->my_numbers.list[i].name, __setting_about_sub_list_rd_change);
1295 item_data->userdata = ad;
1296 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1298 SETTING_TRACE_ERROR("item_data is NULL");
1301 elm_radio_value_set(rgd, ad->my_number_sel_idx);
1304 static void __setting_about_sub_list_rd_change(void *data, Evas_Object *obj, void *event_info) {
1305 SETTING_TRACE_BEGIN;
1306 retm_if(data == NULL, "Data parameter is NULL");
1307 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
1308 SettingAboutUG *ad = (SettingAboutUG *) list_item->userdata;
1309 SETTING_TRACE("my_number_sel_idx = %d", ad->my_number_sel_idx);
1310 elm_radio_value_set(obj, ad->my_number_sel_idx);