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>
32 #include <system_info.h>
34 #define DEVNAME_BLOCK_SPACE 0
35 // #define SUPPORT_DIAG_USAGE
37 /** @todo : need to handle unicode encoded input characters */
39 #define MAX_DEVICE_NAME_LEN 24
40 #define EMPTY_LIMITATION_STR "IDS_ST_BODY_THE_NAME_FIELD_CANNOT_BE_EMPTY"
41 #define DIAGNOSTICS_USAGE_STR "Diagnostics and Usage"
42 #define SOFTWARE_UPDATE_STR "IDS_ST_MBODY_SOFTWARE_UPDATE"
45 static int setting_about_main_create(void *cb);
46 static int setting_about_main_destroy(void *cb);
47 static int setting_about_main_update(void *cb);
48 static int setting_about_main_cleanup(void *cb);
50 setting_view setting_view_about_main = {
51 .create = setting_about_main_create,
52 .destroy = setting_about_main_destroy,
53 .update = setting_about_main_update,
54 .cleanup = setting_about_main_cleanup,
57 * Do process when clicking '<-' button
63 static void setting_about_main_click_softkey_back_cb(void *data,
68 * Do process when clicking on some genlist item
74 static void setting_about_main_mouse_up_Gendial_list_cb(void *data,
78 static void __setting_about_main_mobile_ap_turn_off_ask_resp_cb(void *data,
82 static void __setting_about_main_certificates_clicked(void *data);
83 static void __setting_about_main_device_name_clicked(void *data, Evas_Object *obj);
84 static void __setting_about_main_diagnostics_usage_clicked(void *data, Evas_Object *obj);
85 /* ***************************************************
89 ***************************************************/
90 static void __about_popup_rsp_cb(void *data, Evas_Object *obj, void *event_info)
92 SettingAboutUG *ad = data;
99 static void __device_name_changed_cb(void *data, Evas_Object *obj)
101 retm_if(!data || !obj, "Data parameter is NULL");
102 //return if entry is not focused too
104 Setting_GenGroupItem_Data *list_item =
105 (Setting_GenGroupItem_Data *) data;
106 SettingAboutUG *ad = list_item->userdata;
107 retm_if(ad == NULL, "Data parameter is NULL");
109 const char *entry_str = elm_entry_entry_get(obj);
110 int entry_len = safeStrLen(entry_str);
111 SETTING_TRACE("entry_str:[%s], lenght:%d", entry_str, entry_len);
113 #if DEVNAME_BLOCK_SPACE
115 if (entry_len > 0 && NULL != strstr(entry_str, " ")) {//cancel the effect of input 'space character'
116 SETTING_TRACE("Cannot input the 'space' key or 'enter' key");
120 char *tmp = (char *)g_strdup(entry_str);
123 for (j = i; tmp[j]; j++) {
130 G_FREE(list_item->sub_desc);
131 list_item->sub_desc = (char *)g_strdup(tmp);
133 SETTING_TRACE("sub_desc:[%s]", list_item->sub_desc);
135 elm_entry_entry_set(obj, list_item->sub_desc);
136 elm_entry_cursor_end_set(obj);
140 G_FREE(list_item->sub_desc);//release first
141 list_item->sub_desc = (char *)g_strdup(entry_str);
143 if (NULL == entry_str || 0 == entry_len) {
146 ad->empty_flag = TRUE;
147 Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
150 Evas_Object *back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
151 setting_disable_evas_object(back_btn);
152 setting_dim_evas_object(back_btn, TRUE);
154 Evas_Object *top_r_btn = elm_object_item_part_content_get(navi_it, "title_right_btn");
157 setting_disable_evas_object(top_r_btn);
158 setting_dim_evas_object(top_r_btn, TRUE);
165 ad->empty_flag = FALSE;
166 Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
169 Evas_Object *back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
170 setting_enable_evas_object(back_btn);
171 setting_undo_dim_evas_object(back_btn, TRUE);
173 Evas_Object *top_r_btn = elm_object_item_part_content_get(navi_it, "title_right_btn");
176 setting_enable_evas_object(top_r_btn);
177 setting_undo_dim_evas_object(top_r_btn, TRUE);
186 __setting_about_device_name_changed_cb(void *data, Evas_Object *obj,
189 __device_name_changed_cb(data, obj);
195 * - No ini: Unavailable
196 * - I9500 @ target: GT-I9500
197 * - I9500 @ emul: SDK
198 * - SLP @ target: GT-SLP
201 void setting_about_main_get_phone_model_name(char* szStr, int nSize)
203 retm_if(szStr == NULL, "szStr parameter is NULL");
206 int ret = system_info_get_value_string(SYSTEM_INFO_KEY_MODEL, &value);
207 SETTING_TRACE("value : %s", value);
208 if (ret != SYSTEM_INFO_ERROR_NONE) {
209 SETTING_TRACE_ERROR("fail to call system_info_get_value_string");
211 snprintf(szStr, nSize, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
216 snprintf(szStr, nSize, "%s", value);
218 snprintf(szStr, nSize, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
224 void setting_about_main_get_sw_version(char* szStr, int nSize)
226 retm_if(szStr == NULL, "szStr parameter is NULL");
228 dictionary* dic = iniparser_load(SETTING_ABOUT_INFO_PATH);
230 snprintf(szStr, nSize, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
233 g_strdup((char*)iniparser_getstr(dic, "Version:Build"));
235 g_strdup((char*)iniparser_getstr(dic, "Version:Major"));
237 g_strdup((char*)iniparser_getstr(dic, "Version:Minor"));
240 char* pPos = szBinVer;
242 if ('.' == *pPos) *pPos = '\0';
246 szBinVer = g_strdup(_("IDS_ST_HEADER_UNAVAILABLE"));
249 szVerMaj = g_strdup("-");
252 szVerMin = g_strdup("-");
255 snprintf(szStr, nSize, "SLP%s.%s (%s)", szVerMaj, szVerMin, szBinVer);
262 iniparser_freedict(dic);
267 void setting_about_main_get_wifi_mac_address_string(char *str, int size)
269 setting_retm_if(str == NULL, "str parameter is NULL");
270 setting_retm_if(size < SETTING_ABOUT_WIFI_MAC_STR_LEN+1, "size parameter is wrong");
272 FILE *p = fopen(SETTING_ABOUT_MACINFO_PATH, "r");
275 int size = fread(str, sizeof(char), SETTING_ABOUT_WIFI_MAC_STR_LEN, p);
276 if (size != SETTING_ABOUT_WIFI_MAC_STR_LEN) {
277 SETTING_TRACE_ERROR("fail to call fread");
282 perror("open failed!");
285 SETTING_TRACE_DEBUG("get_wifi_mac_address : %s", str);
287 int wifi_state = VCONFKEY_WIFI_OFF;
288 vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
290 if((safeStrLen(str) == 0) || (wifi_state == VCONFKEY_WIFI_OFF))
291 snprintf(str, size, "%s (%s)", _("IDS_ST_HEADER_UNAVAILABLE"), _(SETTING_ABOUT_NEVER_TURN_WIFI_ON_STR));
294 void setting_about_main_get_battery_string(char *str, int size)
296 setting_retm_if(str == NULL, "str parameter is NULL");
299 char file[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
300 snprintf(file, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO,
301 "%s/%s/%s", SETTING_ABOUT_POWER_SUPPLY_PATH, "battery", "capacity");
303 char buf[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
307 fd = open(file, O_RDONLY);
309 r = read(fd, buf, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO);
310 if ((r >= 0) && (r < MAX_DISPLAY_STR_LEN_ON_PHONE_INFO)) {
313 snprintf(str, size, "%d%s", val, "\%");
315 SETTING_TRACE_ERROR("read file fail");
316 snprintf(str, size, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
321 SETTING_TRACE_ERROR("open file fail");
322 snprintf(str, size, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
326 void setting_about_main_get_bluetooth_address_string(char *str, int size)
328 setting_retm_if(str == NULL, "str parameter is NULL");
330 bluetooth_device_address_t local_address;
331 memset(&local_address, 0x0, sizeof(local_address));
334 /* for fixing BS of dbus signal */
335 bluetooth_register_callback(NULL, NULL);
337 ret = bluetooth_get_local_address(&local_address);
339 /* for fixing BS of dbus signal */
340 bluetooth_unregister_callback();
343 snprintf(str, size, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
345 snprintf(str, size, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
346 local_address.addr[0], local_address.addr[1], local_address.addr[2],
347 local_address.addr[3], local_address.addr[4], local_address.addr[5]);
349 SETTING_TRACE_DEBUG("bt address : %s", str);
352 int __stat_get_cpuinfo(float *usr_pct, float *sys_pct)
354 setting_retvm_if(usr_pct == NULL, -ENOENT, "param usr_pct is null");
355 setting_retvm_if(sys_pct == NULL, -ENOENT, "param sys_pct is null");
360 static unsigned long long usr_time = 0, nice_time = 0, sys_time = 0;
361 static unsigned long long old_usr = 0, old_nice = 0, old_sys = 0;
362 static struct timeval old_tv, cur_tv;
363 unsigned long long elapsed_tick;
369 tick_per_sec = sysconf(_SC_CLK_TCK);
370 cpu_num = sysconf(_SC_NPROCESSORS_ONLN);
375 gettimeofday(&cur_tv, NULL);
376 fp = fopen(SETTING_ABOUT_STAT_PATH, "r");
378 SETTING_TRACE_ERROR("fp == NULL");
382 char cpu_info[MAX_COMMON_BUFFER_LEN] = {0,};
383 char *cpu_info_p = fgets(cpu_info, MAX_COMMON_BUFFER_LEN, fp);
385 if(cpu_info_p == NULL) {
386 SETTING_TRACE_ERROR("fgets failed");
387 fclose(fp); // free - code
392 unsigned long long tmp_long = 0;
394 /* split cpu_info, get 3 numbers headmost*/
395 while ((substr = strsep(&cpu_info_p, " \t")) != NULL) {
397 tmp_long = strtoull(substr, &endptr, 10);
398 if (tmp_long != 0 && tmp_long != ULLONG_MAX) {
404 nice_time = tmp_long;
423 SETTING_TRACE_ERROR("old_usr == 0");
427 elapsed_tick = (cur_tv.tv_sec - old_tv.tv_sec) * tick_per_sec +
428 ((cur_tv.tv_usec - old_tv.tv_usec) * tick_per_sec) / 1000000;
431 if (elapsed_tick != 0)
433 ((float)(usr_time - old_usr) * 100 / elapsed_tick) /
438 if (elapsed_tick != 0)
440 ((float)(sys_time - old_sys) * 100 / elapsed_tick) /
447 old_nice = nice_time;
454 static Eina_Bool __timer_update_cb(const void *data)
456 retv_if(data == NULL, TRUE);
457 SettingAboutUG *ad = (SettingAboutUG *) data;
459 char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
460 if (ad->item_data_cpu) {
462 int ret = __stat_get_cpuinfo(&usr, &sys);
463 if (ret == -ENOENT) {
464 SETTING_TRACE_ERROR("call __stat_get_cpuinfo fail");
465 snprintf(str, sizeof(str), "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
467 snprintf(str, sizeof(str), "%.0f%s", usr + sys, "\%");
470 ad->item_data_cpu->sub_desc = (char *)g_strdup(str);
471 elm_object_item_data_set(ad->item_data_cpu->item, ad->item_data_cpu);
472 elm_genlist_item_update(ad->item_data_cpu->item);
475 if (ad->item_data_battery) {
476 setting_about_main_get_battery_string(str, sizeof(str));
477 /*SETTING_TRACE("str:%s", str);*/
478 ad->item_data_battery->sub_desc = (char *)g_strdup(str);
479 elm_object_item_data_set(ad->item_data_battery->item, ad->item_data_battery);
480 elm_genlist_item_update(ad->item_data_battery->item);
486 __about_main_gl_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event)
489 SettingAboutUG *ad = (SettingAboutUG *) data;
490 retm_if(event == NULL, "Invalid argument: event info is NULL");
491 Evas_Event_Mouse_Up *ev = (Evas_Event_Mouse_Up *)event;
493 if (ad->item_dev_name) {
494 Elm_Object_Item *selected_item = elm_genlist_at_xy_item_get(ad->genlsit, ev->output.x, ev->output.y, NULL);
495 if (ad->item_dev_name->item == selected_item)//do nothing..
498 elm_object_focus_set(ad->item_dev_name->eo_check, EINA_FALSE);//to make inputing words input
502 static void __entry_unfocus_cb(void *data, Evas_Object *obj, void *event_info)
505 retm_if(!data || !obj, "Data parameter is NULL");
507 Evas_Object *entry_container = elm_object_parent_widget_get(obj);
508 if (entry_container) {
509 //whe entry unfocused, its guidetext will becomes "Input here"
510 elm_object_part_text_set(entry_container, "elm.guidetext", _("IDS_ST_BODY_TAP_TO_INSERT"));
511 if (elm_entry_is_empty(obj))
512 elm_object_signal_emit(entry_container, "elm,state,guidetext,show", "elm");
513 elm_object_signal_emit(entry_container, "elm,state,eraser,hide", "elm");
516 //Setting_GenGroupItem_Data *list_item = data;
517 const char *entry_str = elm_entry_entry_get(obj);
518 char *entry_str_utf8 = NULL;
519 entry_str_utf8 = elm_entry_markup_to_utf8(entry_str);
520 //int len = safeStrLen(entry_str_utf8);
521 SETTING_TRACE("To store \"%s\" into vconf[%s]", entry_str_utf8, VCONFKEY_SETAPPL_DEVICE_NAME_STR);
523 //ecore_idler_add(__check_on_idler, ad);
524 Setting_GenGroupItem_Data *item_dev_name = data;
525 SettingAboutUG *ad = item_dev_name->userdata;
526 __device_name_changed_cb(item_dev_name, item_dev_name->eo_check);
527 //after unfocus,need updating..
528 elm_object_item_data_set(item_dev_name->item, item_dev_name);
529 elm_genlist_item_update(item_dev_name->item);
533 && elm_object_item_part_content_get(ad->navi_item, "title_right_btn")) {
534 Evas_Object *btn = elm_object_item_part_content_unset(ad->navi_item, "title_right_btn");
535 evas_object_del(btn);
537 setting_hide_input_pannel_cb(item_dev_name->eo_check);
539 if (ad->empty_flag) {
541 evas_object_del(ad->popup);
544 ad->popup = setting_create_popup_without_btn(ad, ad->win_get, NULL, _(EMPTY_LIMITATION_STR),
545 __about_popup_rsp_cb, POPUP_INTERVAL, FALSE, FALSE);
552 if (0 != vconf_set_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR, entry_str_utf8)) {
553 SETTING_TRACE_ERROR("Set vconf[%s] failed",
554 VCONFKEY_SETAPPL_DEVICE_NAME_STR);
557 FREE(entry_str_utf8);
561 static void __entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
563 ret_if(data == NULL);
564 SettingAboutUG *ad = (SettingAboutUG*)data;
565 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
566 SETTING_TRACE_DEBUG("ev->key : %s", ev->key);
568 SETTING_TRACE("ad->item_dev_name->eo_check:%p", ad->item_dev_name->eo_check);
569 SETTING_TRACE("obj:%p, %s", obj, elm_entry_entry_get(obj));
570 if(safeStrCmp(ev->key, "Return") == 0)
572 // if entry has 1 char at list, hide ime.
573 if(safeStrLen(elm_entry_entry_get(obj)) > 0)
575 ecore_imf_context_input_panel_hide((Ecore_IMF_Context*)elm_entry_imf_context_get(obj));
580 evas_object_del(ad->popup);
583 ad->popup = setting_create_popup_without_btn(ad, ad->win_get, NULL, _(EMPTY_LIMITATION_STR),
584 __about_popup_rsp_cb, POPUP_INTERVAL, FALSE, FALSE);
587 Evas_Object *entry_container = elm_object_parent_widget_get(obj);
588 if(safeStrLen(elm_entry_entry_get(obj)) > 0) {
589 elm_object_signal_emit(entry_container, "elm,state,guidetext,hide", "elm");
591 //elm_object_part_text_set(entry_container, "elm.guidetext", _("IDS_ST_BODY_TAP_TO_INSERT"));
592 elm_object_signal_emit(entry_container, "elm,state,guidetext,show", "elm");
598 int setting_about_generate_genlist(void *data)
602 retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
604 SettingAboutUG *ad = (SettingAboutUG *) data;
605 bool is_emul_bin = isEmulBin();
607 Evas_Object *scroller = ad->genlsit;
608 Elm_Object_Item *item = NULL;
609 Setting_GenGroupItem_Data *item_data = NULL;
610 char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
611 (void)setting_create_Gendial_field_titleItem(scroller,
612 &(ad->itc_group_item),
613 SETTING_ABOUT_DEVICE_INFO_STR, NULL);
615 char *name_value = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
616 char *pa_sub_desc = elm_entry_utf8_to_markup(name_value);
619 ad->empty_flag = FALSE;
620 if (NULL == pa_sub_desc || '\0' == pa_sub_desc[0])
622 ad->empty_flag = TRUE;
623 Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
626 Evas_Object *back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
627 setting_disable_evas_object(back_btn);
628 setting_dim_evas_object(back_btn, TRUE);
634 char *app_name = NULL;
635 int ret_get_app_name = app_manager_get_app_name("com.samsung.oma-dm-ui", &app_name);
636 if (ret_get_app_name == APP_MANAGER_ERROR_INVALID_PACKAGE )
638 SETTING_TRACE(">>>>>>>>>>>>>>>>>> UNINSTALLED PACKAGE");
639 ad->item_dev_name = NULL;
643 setting_create_Gendial_field_def(scroller, &(ad->itc_1icon),
644 setting_about_main_mouse_up_Gendial_list_cb,
645 ad, SWALLOW_Type_LAYOUT_ENTRY,
646 NULL, NULL, 0, SETTING_ABOUT_DEVICE_NAME_STR, pa_sub_desc,
647 __setting_about_device_name_changed_cb);
648 if (ad->item_dev_name) {
649 ad->item_dev_name->userdata = ad;
650 ad->item_dev_name->isSinglelineFlag = 1;
651 ad->item_dev_name->start_change_cb = (setting_call_back_func)__entry_key_down_cb;
652 ad->item_dev_name->stop_change_cb = __entry_unfocus_cb;
653 ad->item_dev_name->limit_filter_data = calloc(1, sizeof(Elm_Entry_Filter_Accept_Set));
655 if (ad->item_dev_name->limit_filter_data) {
656 //max byte len is 31 not 31+1
657 //ad->item_dev_name->limit_filter_data->max_byte_count = MAX_DEVICE_NAME_LEN + OFFESET_ENTRY_FILTER;
658 ad->item_dev_name->limit_filter_data->max_byte_count = MAX_DEVICE_NAME_LEN;
659 ad->item_dev_name->win_main = ad->win_get;
661 //ad->item_dev_name->input_type = ELM_INPUT_PANEL_LAYOUT_NUMBER;
662 ad->item_dev_name->input_panel_disable_flag = EINA_TRUE;
664 SETTING_TRACE_ERROR("ad->item_dev_name is NULL");
671 char sel_num[TAPI_SIM_XDN_DIALING_NUMBER_LEN + 1] = { 0, };
672 setting_get_string_slp_key(STR_SLP_SETTING_SELECT_NUM, sel_num, &err);
674 if (ad->my_numbers.count == 1) {
676 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2),
678 ad, SWALLOW_Type_INVALID, NULL,
679 NULL, 0, SETTING_ABOUT_MY_NUMBER_STR,
682 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
684 SETTING_TRACE_ERROR("item_data is NULL");
686 } else if (ad->my_numbers.count > 1){
687 setting_enable_expandable_genlist(scroller, ad,
688 setting_about_main_exp_cb, NULL);
689 item_data = setting_create_Gendial_exp_parent_field(scroller,
690 &(ad->itc_2text_3_parent),
692 SWALLOW_Type_INVALID,
693 SETTING_ABOUT_MY_NUMBER_STR,
696 item_data->int_slp_setting_binded = STR_SLP_SETTING_SELECT_NUM;
698 SETTING_TRACE_ERROR("ad->data_wap is NULL");
702 SETTING_TRACE_ERROR("don't have my number");
706 memset(str, 0x00, sizeof(str));
707 setting_about_main_get_phone_model_name(str, sizeof(str));
709 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
710 NULL, SWALLOW_Type_INVALID, NULL,
711 NULL, 0, SETTING_ABOUT_MODEL_STR, str, NULL);
713 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
715 SETTING_TRACE_ERROR("item_data is NULL");
719 memset(str, 0x00, sizeof(str));
720 setting_about_main_get_sw_version(str, sizeof(str));
722 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
723 NULL, SWALLOW_Type_INVALID, NULL,
724 NULL, 0, SETTING_ABOUT_VERSION_STR, str, NULL);
726 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
728 SETTING_TRACE_ERROR("item_data is NULL");
731 // [UI] Bluetooth address
732 if ( ! is_emul_bin) { // requested by DI Kim due to BT BS on 11/26
733 memset(str, 0x00, sizeof(str));
734 setting_about_main_get_bluetooth_address_string(str, sizeof(str));
736 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
737 NULL, SWALLOW_Type_INVALID, NULL,
738 NULL, 0, SETTING_ABOUT_BLUETOOTH_STR, str, NULL);
739 if (ad->item_data_bt) {
740 elm_genlist_item_select_mode_set(ad->item_data_bt->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
742 SETTING_TRACE_ERROR("item_data is NULL");
747 memset(str, 0x00, sizeof(str));
748 setting_about_main_get_wifi_mac_address_string(str, sizeof(str));
750 SETTING_TRACE_DEBUG("[about main] get_wifi_mac_address : %s", str);
753 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
754 NULL, SWALLOW_Type_INVALID, NULL,
755 NULL, 0, SETTING_ABOUT_WIFI_STR, str, NULL);
756 if (ad->item_data_wifi) {
757 elm_genlist_item_select_mode_set(ad->item_data_wifi->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
759 SETTING_TRACE_ERROR("item_data is NULL");
763 memset(str, 0x00, sizeof(str));
764 setting_about_main_get_battery_string(str, sizeof(str));
766 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
767 NULL, SWALLOW_Type_INVALID, NULL,
768 NULL, 0, SETTING_ABOUT_BATTERY_STR, str, NULL);
770 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
771 ad->item_data_battery = item_data;
773 SETTING_TRACE_ERROR("item_data is NULL");
777 memset(str, 0x00, sizeof(str));
779 int ret = __stat_get_cpuinfo(&usr, &sys);
780 if (ret == -ENOENT) {
781 SETTING_TRACE_ERROR("call __stat_get_cpuinfo fail");
782 snprintf(str, sizeof(str), "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
784 snprintf(str, sizeof(str), "%.0f%s", usr + sys, "\%");
787 ad->item_data_cpu = item_data =
788 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
789 NULL, SWALLOW_Type_INVALID, NULL,
790 NULL, 0, SETTING_ABOUT_CPU_USAGE_STR, str, NULL);
792 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
794 SETTING_TRACE_ERROR("item_data is NULL");
799 elm_genlist_item_append(scroller, &(ad->itc_seperator), NULL, NULL,
800 ELM_GENLIST_ITEM_NONE, NULL, NULL);
801 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
803 #ifdef SUPPORT_DIAG_USAGE
804 // [UI] Diagnostics and Usage
806 setting_create_Gendial_field_def(scroller, &(ad->itc_1text),
807 setting_about_main_mouse_up_Gendial_list_cb,
808 ad, SWALLOW_Type_INVALID, NULL, NULL,
809 0, DIAGNOSTICS_USAGE_STR,
815 // [UI] Software update
817 setting_create_Gendial_field_def(scroller, &(ad->itc_1text),
818 setting_about_main_mouse_up_Gendial_list_cb,
819 ad, SWALLOW_Type_INVALID, NULL, NULL,
820 0, SOFTWARE_UPDATE_STR,
825 // implementation is in progress.
826 if (is_ug_installed_by_ug_args("setting-manage-applications-efl"))
828 setting_create_Gendial_field_def(scroller, &(ad->itc_1text),
829 setting_about_main_mouse_up_Gendial_list_cb,
830 ad, SWALLOW_Type_INVALID, NULL, NULL,
831 0, "IDS_COM_BODY_CERTIFICATES", NULL, NULL);
833 item = elm_genlist_item_append(scroller, &itc_bottom_seperator, NULL, NULL,
834 ELM_GENLIST_ITEM_NONE, NULL, NULL);
835 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
840 ecore_timer_add(2, (Ecore_Task_Cb) __timer_update_cb, ad);
842 return SETTING_RETURN_SUCCESS;
845 static int setting_about_main_create(void *cb)
849 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
851 SettingAboutUG *ad = (SettingAboutUG *) cb;
853 Evas_Object *scroller = elm_genlist_add(ad->win_main_layout);
854 retvm_if(scroller == NULL, SETTING_DRAW_ERR_FAIL_SCROLLER,
855 "Cannot set scroller object as contento of layout");
856 elm_object_style_set(scroller, "dialogue");
857 elm_genlist_clear(scroller); /* first to clear list */
859 /* Enabling illume notification property for window */
860 elm_win_conformant_set(ad->win_main_layout, 1);
861 Evas_Object *conformant = elm_conformant_add(ad->win_main_layout);
862 elm_object_style_set(conformant, "internal_layout"); /* By Kollus. 2011-01-04 */
863 evas_object_show(conformant);
864 elm_object_content_set(conformant, scroller);
865 ad->genlsit = scroller;
868 setting_create_layout_navi_bar(ad->win_main_layout, ad->win_get,
869 _(KeyStr_AboutPhone),
870 _("IDS_COM_BODY_BACK"), NULL, NULL,
871 setting_about_main_click_softkey_back_cb,
872 NULL, NULL, ad, conformant,
873 &ad->navi_bar, NULL);
875 evas_object_event_callback_add(scroller, EVAS_CALLBACK_MOUSE_UP,
876 __about_main_gl_mouse_up, ad);
878 ad->navi_item = elm_naviframe_top_item_get(ad->navi_bar);
880 setting_about_generate_genlist((void *)ad);
882 setting_view_about_main.is_create = 1;
884 return SETTING_RETURN_SUCCESS;
887 static int setting_about_main_destroy(void *cb)
891 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
893 SettingAboutUG *ad = (SettingAboutUG *) cb;
895 if (ad->update_timer) {
896 ecore_timer_del(ad->update_timer);
897 ad->update_timer = NULL;
900 evas_object_del(ad->popup);
904 if (ad->ly_main != NULL) {
905 evas_object_del(ad->ly_main);
909 setting_view_about_main.is_create = 0;
910 return SETTING_RETURN_SUCCESS;
913 static int setting_about_main_update(void *cb)
917 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
919 SettingAboutUG *ad = (SettingAboutUG *) cb;
921 if (ad->ly_main != NULL) {
922 evas_object_show(ad->ly_main);
925 return SETTING_RETURN_SUCCESS;
928 static int setting_about_main_cleanup(void *cb)
932 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
934 SettingAboutUG *ad = (SettingAboutUG *) cb;
936 if (ad->ly_main != NULL) {
937 /* evas_object_hide(ad->ly_main); */
940 return SETTING_RETURN_SUCCESS;
943 /* ***************************************************
947 ***************************************************/
949 /* ***************************************************
953 ***************************************************/
956 setting_about_main_click_softkey_back_cb(void *data, Evas_Object *obj,
961 setting_retm_if(data == NULL, "Data parameter is NULL");
963 SettingAboutUG *ad = (SettingAboutUG *) data;
964 if (ad->empty_flag) {
966 evas_object_del(ad->popup);
969 ad->popup = setting_create_popup_without_btn(ad, ad->win_get, NULL, _(EMPTY_LIMITATION_STR),
970 __about_popup_rsp_cb, POPUP_INTERVAL, FALSE, FALSE);
971 if (ad->item_dev_name) {
972 elm_object_focus_set(ad->item_dev_name->eo_check, EINA_TRUE);
977 /* Send destroy request */
978 ug_destroy_me(ad->ug);
979 //imf must be hided before view is destroyed.
980 //Following code is just to improve the hiding speed. If not add these code,
981 //the input pannel will also be hided with the view destroyed,but it works too slow.
982 if (ad->item_dev_name) {
983 elm_object_focus_set(ad->item_dev_name->eo_check, EINA_FALSE);
984 setting_hide_input_pannel_cb(ad->item_dev_name->eo_check);
998 setting_about_main_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj,
1001 SETTING_TRACE_BEGIN;
1003 setting_retm_if(data == NULL, "Data parameter is NULL");
1005 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
1006 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
1007 elm_genlist_item_selected_set(item, 0);
1008 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
1010 /* SettingAboutUG *ad = (SettingAboutUG *) data; */
1012 SETTING_TRACE("clicking item[%s]", _(list_item->keyStr));
1013 if (!safeStrCmp("IDS_ST_BODY_OPEN_SOURCE_LICENCES", list_item->keyStr)) {
1015 //setting_view_change(&setting_view_about_main, &setting_view_about_licences, data);
1017 } else if (!safeStrCmp("IDS_COM_BODY_CERTIFICATES", list_item->keyStr)) {
1018 __setting_about_main_certificates_clicked(data);
1019 } else if (!safeStrCmp(SETTING_ABOUT_DEVICE_NAME_STR, list_item->keyStr)) {
1020 __setting_about_main_device_name_clicked(data, list_item->eo_check);
1021 } else if (!safeStrCmp(DIAGNOSTICS_USAGE_STR, list_item->keyStr)) {
1022 __setting_about_main_diagnostics_usage_clicked(data, list_item->eo_check);
1023 } else if (!safeStrCmp(SOFTWARE_UPDATE_STR, list_item->keyStr)) {
1025 if(aul_app_is_running("com.samsung.oma-dm-ui"))
1027 SETTING_TRACE_DEBUG("oma-dm-ui is already launched. ");
1028 aul_open_app("com.samsung.oma-dm-ui");
1032 SETTING_TRACE_DEBUG("oma-dm-ui will be launched. ");
1033 aul_launch_app("com.samsung.oma-dm-ui", NULL);
1039 static void __destroy_certificates_ug_cb(ui_gadget_h ug, void *priv)
1041 SETTING_TRACE_BEGIN;
1043 /* restore the '<-' button on the navigate bar */
1045 SettingAboutUG *ad = (SettingAboutUG *) priv; /* ad is point to priv */
1049 ad->ug_loading = NULL;
1054 static void __setting_about_main_certificates_clicked(void *data)
1056 SETTING_TRACE_BEGIN;
1057 retm_if(data == NULL, "Data parameter is NULL");
1058 SettingAboutUG *ad = (SettingAboutUG *)data;
1060 struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
1065 cbs->layout_cb = setting_about_layout_ug_cb;
1066 cbs->result_cb = NULL;
1067 cbs->destroy_cb = __destroy_certificates_ug_cb;
1068 cbs->priv = (void *)ad;
1071 ug_create(ad->ug, "setting-manage-certificates-efl", UG_MODE_FULLVIEW, NULL, cbs);
1073 if (NULL == ad->ug_loading) { /* error handling */
1074 SETTING_TRACE_ERROR("NULL == ad->ug_loading");
1079 static void __top_back_cb(void *data, Evas_Object *obj,
1082 SETTING_TRACE_BEGIN;
1084 setting_retm_if(data == NULL, "Data parameter is NULL");
1086 SettingAboutUG *ad = (SettingAboutUG *) data;
1088 if (ad->item_dev_name)
1089 setting_hide_input_pannel_cb(ad->item_dev_name->eo_check);
1094 static void _input_panel_event_cb(void *data, Ecore_IMF_Context *ctx, int value)
1096 SETTING_TRACE_BEGIN;
1097 retm_if(data == NULL, "Data parameter is NULL");
1098 retm_if(ctx == NULL, "obj parameter is NULL");
1100 SettingAboutUG *ad = (SettingAboutUG *)data;
1102 if(value == ECORE_IMF_INPUT_PANEL_STATE_SHOW)
1104 SETTING_TRACE("value == ECORE_IMF_INPUT_PANEL_STATE_SHOW");
1105 if(ad->navi_item && !elm_object_item_part_content_get(ad->navi_item, "title_right_btn"))
1107 Evas_Object *r_button = setting_create_button(ad->navi_bar,
1108 dgettext("sys_string", "IDS_COM_BODY_BACK"),
1109 NAVI_BACK_BUTTON_STYLE,
1112 elm_object_item_part_content_set(ad->navi_item, "title_right_btn", r_button);
1115 else if(value == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
1117 SETTING_TRACE("value == ECORE_IMF_INPUT_PANEL_STATE_HIDE");
1118 if(ad->navi_item && elm_object_item_part_content_get(ad->navi_item, "title_right_btn")) {
1119 Evas_Object *btn = elm_object_item_part_content_unset(ad->navi_item, "title_right_btn");
1120 evas_object_del(btn);
1123 if (ad->item_dev_name) {
1124 elm_object_focus_set(ad->item_dev_name->eo_check, EINA_FALSE);
1129 static void __setting_about_main_device_name_clicked(void *data, Evas_Object *obj)
1131 SETTING_TRACE_BEGIN;
1132 retm_if(data == NULL, "Data parameter is NULL");
1133 retm_if(obj == NULL, "obj parameter is NULL");
1134 SettingAboutUG *ad = (SettingAboutUG *)data;
1136 int mobile_ap_status = VCONFKEY_MOBILE_HOTSPOT_MODE_NONE;
1138 int ret = setting_get_int_slp_key(INT_SLP_SETTING_MOBILE_AP_STATUS, &mobile_ap_status, &err);
1139 setting_retm_if(ret == SETTING_RETURN_FAIL, "Get vconf failed");
1141 if (!elm_object_focus_get(obj)) {
1142 elm_object_focus_set(obj, EINA_TRUE);
1145 if ((mobile_ap_status & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) && !ad->popup_showed_flag) {
1147 evas_object_del(ad->popup);
1150 ad->popup = setting_create_popup_with_btn(ad, ad->win_get,
1151 NULL, _(SETTING_ABOUT_MOBILE_AP_TURNED_OFF),
1152 __setting_about_main_mobile_ap_turn_off_ask_resp_cb, 0,
1153 1, _("IDS_COM_SK_OK"));
1155 Ecore_IMF_Context *imf_context = (Ecore_IMF_Context *)elm_entry_imf_context_get(obj);
1156 setting_retm_if(imf_context == NULL, "imf_context is NULL");
1157 ecore_imf_context_input_panel_event_callback_add(imf_context, ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_event_cb, ad);
1158 ecore_imf_context_input_panel_show(imf_context);
1163 static void __destroy_diagnostics_usage_ug_cb(ui_gadget_h ug, void *priv)
1165 SETTING_TRACE_BEGIN;
1167 /* restore the '<-' button on the navigate bar */
1169 SettingAboutUG *ad = (SettingAboutUG *) priv; /* ad is point to priv */
1173 ad->ug_loading = NULL;
1176 Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
1178 Evas_Object *back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
1180 if (back_btn != NULL) {
1181 elm_object_style_set(back_btn, NAVI_BACK_BUTTON_STYLE); /* take into effect */
1185 static void __setting_about_main_diagnostics_usage_clicked(void *data, Evas_Object *obj)
1187 SETTING_TRACE_BEGIN;
1188 retm_if(data == NULL, "Data parameter is NULL");
1189 SettingAboutUG *ad = (SettingAboutUG *)data;
1193 return; /* do nothing if ad is NULL */
1195 struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
1200 cbs->layout_cb = setting_about_layout_ug_cb;
1201 cbs->result_cb = NULL;
1202 cbs->destroy_cb = __destroy_diagnostics_usage_ug_cb;
1203 cbs->priv = (void *)ad;
1206 ug_create(ad->ug, "setting-crash-efl", UG_MODE_FULLVIEW, NULL, cbs);
1208 if (NULL == ad->ug_loading) { /* error handling */
1209 SETTING_TRACE_ERROR("NULL == ad->ug_loading");
1210 setting_create_simple_popup(ad, ad->win_get, NULL, _(UNSUPPORTED_FUNCTION));
1215 static void __setting_about_main_mobile_ap_turn_off_ask_resp_cb(void *data,
1219 SETTING_TRACE_BEGIN;
1220 setting_retm_if(data == NULL, "Data parameter is NULL");
1221 SettingAboutUG *ad = (SettingAboutUG *)data;
1222 int response_type = btn_type(obj);
1224 if (POPUP_RESPONSE_OK == response_type) {
1225 ad->popup_showed_flag = TRUE;
1227 if (ad->item_dev_name) {
1228 Ecore_IMF_Context *imf_context = elm_entry_imf_context_get(ad->item_dev_name->eo_check);
1229 setting_retm_if(imf_context == NULL, "imf_context is NULL");
1230 ecore_imf_context_input_panel_show(imf_context);
1236 evas_object_del(ad->popup);