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 <sys/types.h>
27 #include <bluetooth-api.h>
30 #include <app_manager.h>
31 #include <system_info.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 * Do process when clicking '<-' button
62 static void setting_about_main_click_softkey_back_cb(void *data,
67 * Do process when clicking on some genlist item
73 static void setting_about_main_mouse_up_Gendial_list_cb(void *data,
77 static void __setting_about_main_mobile_ap_turn_off_ask_resp_cb(void *data,
81 static void __setting_about_main_certificates_clicked(void *data);
82 static void __setting_about_main_device_name_clicked(void *data, Evas_Object *obj);
83 static void __setting_about_main_diagnostics_usage_clicked(void *data, Evas_Object *obj);
84 /* ***************************************************
88 ***************************************************/
89 static void __about_popup_rsp_cb(void *data, Evas_Object *obj, void *event_info)
91 SettingAboutUG *ad = data;
98 static void __device_name_changed_cb(void *data, Evas_Object *obj)
100 retm_if(!data || !obj, "Data parameter is NULL");
101 //return if entry is not focused too
103 Setting_GenGroupItem_Data *list_item =
104 (Setting_GenGroupItem_Data *) data;
105 SettingAboutUG *ad = list_item->userdata;
106 retm_if(ad == NULL, "Data parameter is NULL");
108 const char *entry_str = elm_entry_entry_get(obj);
109 int entry_len = safeStrLen(entry_str);
110 SETTING_TRACE("entry_str:[%s], lenght:%d", entry_str, entry_len);
112 #if DEVNAME_BLOCK_SPACE
114 if (entry_len > 0 && NULL != strstr(entry_str, " ")) {//cancel the effect of input 'space character'
115 SETTING_TRACE("Cannot input the 'space' key or 'enter' key");
119 char *tmp = (char *)g_strdup(entry_str);
122 for (j = i; tmp[j]; j++) {
129 G_FREE(list_item->sub_desc);
130 list_item->sub_desc = (char *)g_strdup(tmp);
132 SETTING_TRACE("sub_desc:[%s]", list_item->sub_desc);
134 elm_entry_entry_set(obj, list_item->sub_desc);
135 elm_entry_cursor_end_set(obj);
139 G_FREE(list_item->sub_desc);//release first
140 list_item->sub_desc = (char *)g_strdup(entry_str);
142 if (NULL == entry_str || 0 == entry_len) {
145 ad->empty_flag = TRUE;
146 elm_entry_context_menu_disabled_set(obj, TRUE); //disable the copy&paste&search popup
147 elm_entry_magnifier_disabled_set(obj, TRUE);
148 Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
151 Evas_Object *back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
152 setting_disable_evas_object(back_btn);
153 setting_dim_evas_object(back_btn, TRUE);
155 Evas_Object *top_r_btn = elm_object_item_part_content_get(navi_it, "title_right_btn");
158 setting_disable_evas_object(top_r_btn);
159 setting_dim_evas_object(top_r_btn, TRUE);
166 ad->empty_flag = FALSE;
167 elm_entry_context_menu_disabled_set(obj, FALSE); //enable the copy&paste&search popup
168 elm_entry_magnifier_disabled_set(obj, FALSE);
169 Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
172 Evas_Object *back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
173 setting_enable_evas_object(back_btn);
174 setting_undo_dim_evas_object(back_btn, TRUE);
176 Evas_Object *top_r_btn = elm_object_item_part_content_get(navi_it, "title_right_btn");
179 setting_enable_evas_object(top_r_btn);
180 setting_undo_dim_evas_object(top_r_btn, TRUE);
189 __setting_about_device_name_changed_cb(void *data, Evas_Object *obj,
192 __device_name_changed_cb(data, obj);
198 * - No ini: Unavailable
199 * - I9500 @ target: GT-I9500
200 * - I9500 @ emul: SDK
201 * - SLP @ target: GT-SLP
204 void setting_about_main_get_phone_model_name(char* szStr, int nSize)
206 retm_if(szStr == NULL, "szStr parameter is NULL");
209 int ret = system_info_get_value_string(SYSTEM_INFO_KEY_MODEL, &value);
210 SETTING_TRACE("value : %s", value);
211 if (ret != SYSTEM_INFO_ERROR_NONE) {
212 SETTING_TRACE_ERROR("fail to call system_info_get_value_string");
214 snprintf(szStr, nSize, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
219 snprintf(szStr, nSize, "%s", value);
221 snprintf(szStr, nSize, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
227 void setting_about_main_get_sw_version(char* szStr, int nSize)
229 retm_if(szStr == NULL, "szStr parameter is NULL");
231 char *version = NULL;
232 int ret = system_info_get_value_string(SYSTEM_INFO_KEY_TIZEN_VERSION, &version);
233 if (ret != SYSTEM_INFO_ERROR_NONE) {
234 SETTING_TRACE_ERROR("fail to call system_info_get_value_string");
236 snprintf(szStr, nSize, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
240 char *build_info = NULL;
241 ret = system_info_get_value_string(SYSTEM_INFO_KEY_BUILD_STRING, &build_info);
242 if (ret != SYSTEM_INFO_ERROR_NONE) {
243 SETTING_TRACE_ERROR("fail to call system_info_get_value_string");
246 snprintf(szStr, nSize, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
250 snprintf(szStr, nSize, "SLP%s (%s)", version, build_info);
256 void setting_about_main_get_wifi_mac_address_string(char *str, int size)
258 setting_retm_if(str == NULL, "str parameter is NULL");
259 setting_retm_if(size < SETTING_ABOUT_WIFI_MAC_STR_LEN+1, "size parameter is wrong");
261 FILE *p = fopen(SETTING_ABOUT_MACINFO_PATH, "r");
264 int size = fread(str, sizeof(char), SETTING_ABOUT_WIFI_MAC_STR_LEN, p);
265 if (size != SETTING_ABOUT_WIFI_MAC_STR_LEN) {
266 SETTING_TRACE_ERROR("fail to call fread");
271 perror("open failed!");
274 SETTING_TRACE_DEBUG("get_wifi_mac_address : %s", str);
276 int wifi_state = VCONFKEY_WIFI_OFF;
277 vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
279 if((safeStrLen(str) == 0) || (wifi_state == VCONFKEY_WIFI_OFF))
280 snprintf(str, size, "%s (%s)", _("IDS_ST_HEADER_UNAVAILABLE"), _(SETTING_ABOUT_NEVER_TURN_WIFI_ON_STR));
283 void setting_about_main_get_battery_string(char *str, int size)
285 setting_retm_if(str == NULL, "str parameter is NULL");
288 char file[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
289 snprintf(file, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO,
290 "%s/%s/%s", SETTING_ABOUT_POWER_SUPPLY_PATH, "battery", "capacity");
292 char buf[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
296 fd = open(file, O_RDONLY);
298 r = read(fd, buf, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO);
299 if ((r >= 0) && (r < MAX_DISPLAY_STR_LEN_ON_PHONE_INFO)) {
302 snprintf(str, size, "%d%s", val, "\%");
304 SETTING_TRACE_ERROR("read file fail");
305 snprintf(str, size, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
310 SETTING_TRACE_ERROR("open file fail");
311 snprintf(str, size, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
315 void setting_about_main_get_bluetooth_address_string(char *str, int size)
317 setting_retm_if(str == NULL, "str parameter is NULL");
319 bluetooth_device_address_t local_address;
320 memset(&local_address, 0x0, sizeof(local_address));
323 /* for fixing BS of dbus signal */
324 bluetooth_register_callback(NULL, NULL);
326 ret = bluetooth_get_local_address(&local_address);
328 /* for fixing BS of dbus signal */
329 bluetooth_unregister_callback();
332 snprintf(str, size, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
334 snprintf(str, size, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
335 local_address.addr[0], local_address.addr[1], local_address.addr[2],
336 local_address.addr[3], local_address.addr[4], local_address.addr[5]);
338 SETTING_TRACE_DEBUG("bt address : %s", str);
341 int __stat_get_cpuinfo(float *usr_pct, float *sys_pct)
343 setting_retvm_if(usr_pct == NULL, -ENOENT, "param usr_pct is null");
344 setting_retvm_if(sys_pct == NULL, -ENOENT, "param sys_pct is null");
349 static unsigned long long usr_time = 0, nice_time = 0, sys_time = 0;
350 static unsigned long long old_usr = 0, old_nice = 0, old_sys = 0;
351 static struct timeval old_tv, cur_tv;
352 unsigned long long elapsed_tick;
358 tick_per_sec = sysconf(_SC_CLK_TCK);
359 cpu_num = sysconf(_SC_NPROCESSORS_ONLN);
364 gettimeofday(&cur_tv, NULL);
365 fp = fopen(SETTING_ABOUT_STAT_PATH, "r");
367 SETTING_TRACE_ERROR("fp == NULL");
371 char cpu_info[MAX_COMMON_BUFFER_LEN] = {0,};
372 char *cpu_info_p = fgets(cpu_info, MAX_COMMON_BUFFER_LEN, fp);
374 if(cpu_info_p == NULL) {
375 SETTING_TRACE_ERROR("fgets failed");
376 fclose(fp); // free - code
381 unsigned long long tmp_long = 0;
383 /* split cpu_info, get 3 numbers headmost*/
384 while ((substr = strsep(&cpu_info_p, " \t")) != NULL) {
386 tmp_long = strtoull(substr, &endptr, 10);
387 if (tmp_long != 0 && tmp_long != ULLONG_MAX) {
393 nice_time = tmp_long;
412 SETTING_TRACE_ERROR("old_usr == 0");
416 elapsed_tick = (cur_tv.tv_sec - old_tv.tv_sec) * tick_per_sec +
417 ((cur_tv.tv_usec - old_tv.tv_usec) * tick_per_sec) / 1000000;
420 if (elapsed_tick != 0)
422 ((float)(usr_time - old_usr) * 100 / elapsed_tick) /
427 if (elapsed_tick != 0)
429 ((float)(sys_time - old_sys) * 100 / elapsed_tick) /
436 old_nice = nice_time;
443 static Eina_Bool __timer_update_cb(const void *data)
445 retv_if(data == NULL, TRUE);
446 SettingAboutUG *ad = (SettingAboutUG *) data;
448 char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
449 if (ad->item_data_cpu) {
451 int ret = __stat_get_cpuinfo(&usr, &sys);
452 if (ret == -ENOENT) {
453 SETTING_TRACE_ERROR("call __stat_get_cpuinfo fail");
454 snprintf(str, sizeof(str), "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
456 snprintf(str, sizeof(str), "%.0f%s", usr + sys, "\%");
459 ad->item_data_cpu->sub_desc = (char *)g_strdup(str);
460 elm_object_item_data_set(ad->item_data_cpu->item, ad->item_data_cpu);
461 elm_genlist_item_update(ad->item_data_cpu->item);
464 if (ad->item_data_battery) {
465 setting_about_main_get_battery_string(str, sizeof(str));
466 /*SETTING_TRACE("str:%s", str);*/
467 ad->item_data_battery->sub_desc = (char *)g_strdup(str);
468 elm_object_item_data_set(ad->item_data_battery->item, ad->item_data_battery);
469 elm_genlist_item_update(ad->item_data_battery->item);
475 __about_main_gl_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event)
478 SettingAboutUG *ad = (SettingAboutUG *) data;
479 retm_if(event == NULL, "Invalid argument: event info is NULL");
480 Evas_Event_Mouse_Up *ev = (Evas_Event_Mouse_Up *)event;
482 if (ad->item_dev_name) {
483 Elm_Object_Item *selected_item = elm_genlist_at_xy_item_get(ad->genlsit, ev->output.x, ev->output.y, NULL);
484 if (ad->item_dev_name->item == selected_item)//do nothing..
487 elm_object_focus_set(ad->item_dev_name->eo_check, EINA_FALSE);//to make inputing words input
491 static void __entry_unfocus_cb(void *data, Evas_Object *obj, void *event_info)
494 retm_if(!data || !obj, "Data parameter is NULL");
496 Evas_Object *entry_container = elm_object_parent_widget_get(obj);
497 if (entry_container) {
498 //whe entry unfocused, its guidetext will becomes "Input here"
499 elm_object_part_text_set(entry_container, "elm.guidetext", _("IDS_ST_BODY_TAP_TO_INSERT"));
500 if (elm_entry_is_empty(obj))
501 elm_object_signal_emit(entry_container, "elm,state,guidetext,show", "elm");
502 elm_object_signal_emit(entry_container, "elm,state,eraser,hide", "elm");
505 //Setting_GenGroupItem_Data *list_item = data;
506 const char *entry_str = elm_entry_entry_get(obj);
507 char *entry_str_utf8 = NULL;
508 entry_str_utf8 = elm_entry_markup_to_utf8(entry_str);
509 //int len = safeStrLen(entry_str_utf8);
510 SETTING_TRACE("To store \"%s\" into vconf[%s]", entry_str_utf8, VCONFKEY_SETAPPL_DEVICE_NAME_STR);
512 //ecore_idler_add(__check_on_idler, ad);
513 Setting_GenGroupItem_Data *item_dev_name = data;
514 SettingAboutUG *ad = item_dev_name->userdata;
515 __device_name_changed_cb(item_dev_name, item_dev_name->eo_check);
516 //after unfocus,need updating..
517 elm_object_item_data_set(item_dev_name->item, item_dev_name);
518 elm_genlist_item_update(item_dev_name->item);
522 && elm_object_item_part_content_get(ad->navi_item, "title_right_btn")) {
523 Evas_Object *btn = elm_object_item_part_content_unset(ad->navi_item, "title_right_btn");
524 evas_object_del(btn);
526 setting_hide_input_pannel_cb(item_dev_name->eo_check);
528 if (ad->empty_flag) {
530 evas_object_del(ad->popup);
533 ad->popup = setting_create_popup_without_btn(ad, ad->win_get, NULL, _(EMPTY_LIMITATION_STR),
534 __about_popup_rsp_cb, POPUP_INTERVAL, FALSE, FALSE);
541 if (0 != vconf_set_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR, entry_str_utf8)) {
542 SETTING_TRACE_ERROR("Set vconf[%s] failed",
543 VCONFKEY_SETAPPL_DEVICE_NAME_STR);
546 FREE(entry_str_utf8);
550 static void __entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
552 ret_if(data == NULL);
553 SettingAboutUG *ad = (SettingAboutUG*)data;
554 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
555 SETTING_TRACE_DEBUG("ev->key : %s", ev->key);
557 SETTING_TRACE("ad->item_dev_name->eo_check:%p", ad->item_dev_name->eo_check);
558 SETTING_TRACE("obj:%p, %s", obj, elm_entry_entry_get(obj));
559 if(safeStrCmp(ev->key, "Return") == 0)
561 // if entry has 1 char at list, hide ime.
562 if(safeStrLen(elm_entry_entry_get(obj)) > 0)
564 ecore_imf_context_input_panel_hide((Ecore_IMF_Context*)elm_entry_imf_context_get(obj));
569 evas_object_del(ad->popup);
572 ad->popup = setting_create_popup_without_btn(ad, ad->win_get, NULL, _(EMPTY_LIMITATION_STR),
573 __about_popup_rsp_cb, POPUP_INTERVAL, FALSE, FALSE);
576 Evas_Object *entry_container = elm_object_parent_widget_get(obj);
577 if(safeStrLen(elm_entry_entry_get(obj)) > 0) {
578 elm_object_signal_emit(entry_container, "elm,state,guidetext,hide", "elm");
580 //elm_object_part_text_set(entry_container, "elm.guidetext", _("IDS_ST_BODY_TAP_TO_INSERT"));
581 elm_object_signal_emit(entry_container, "elm,state,guidetext,show", "elm");
587 int setting_about_generate_genlist(void *data)
591 retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
593 SettingAboutUG *ad = (SettingAboutUG *) data;
594 bool is_emul_bin = isEmulBin();
596 Evas_Object *scroller = ad->genlsit;
597 Elm_Object_Item *item = NULL;
598 Setting_GenGroupItem_Data *item_data = NULL;
599 char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
600 (void)setting_create_Gendial_field_titleItem(scroller,
601 &(ad->itc_group_item),
602 SETTING_ABOUT_DEVICE_INFO_STR, NULL);
604 char *name_value = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
605 char *pa_sub_desc = elm_entry_utf8_to_markup(name_value);
608 ad->empty_flag = FALSE;
609 if (NULL == pa_sub_desc || '\0' == pa_sub_desc[0])
611 ad->empty_flag = TRUE;
612 Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
615 Evas_Object *back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
616 setting_disable_evas_object(back_btn);
617 setting_dim_evas_object(back_btn, TRUE);
623 char *app_name = NULL;
624 int ret_get_app_name = app_manager_get_app_name("com.samsung.oma-dm-ui", &app_name);
625 if (ret_get_app_name == APP_MANAGER_ERROR_INVALID_PACKAGE )
627 SETTING_TRACE(">>>>>>>>>>>>>>>>>> UNINSTALLED PACKAGE");
628 ad->item_dev_name = NULL;
632 setting_create_Gendial_field_def(scroller, &(ad->itc_1icon),
633 setting_about_main_mouse_up_Gendial_list_cb,
634 ad, SWALLOW_Type_LAYOUT_ENTRY,
635 NULL, NULL, 0, SETTING_ABOUT_DEVICE_NAME_STR, pa_sub_desc,
636 __setting_about_device_name_changed_cb);
637 if (ad->item_dev_name) {
638 ad->item_dev_name->userdata = ad;
639 ad->item_dev_name->isSinglelineFlag = 1;
640 ad->item_dev_name->start_change_cb = (setting_call_back_func)__entry_key_down_cb;
641 ad->item_dev_name->stop_change_cb = __entry_unfocus_cb;
642 ad->item_dev_name->limit_filter_data = calloc(1, sizeof(Elm_Entry_Filter_Accept_Set));
644 if (ad->item_dev_name->limit_filter_data) {
645 //max byte len is 31 not 31+1
646 //ad->item_dev_name->limit_filter_data->max_byte_count = MAX_DEVICE_NAME_LEN + OFFESET_ENTRY_FILTER;
647 ad->item_dev_name->limit_filter_data->max_byte_count = MAX_DEVICE_NAME_LEN;
648 ad->item_dev_name->win_main = ad->win_get;
650 //ad->item_dev_name->input_type = ELM_INPUT_PANEL_LAYOUT_NUMBER;
651 ad->item_dev_name->input_panel_disable_flag = EINA_TRUE;
653 SETTING_TRACE_ERROR("ad->item_dev_name is NULL");
660 char sel_num[TAPI_SIM_XDN_DIALING_NUMBER_LEN + 1] = { 0, };
661 setting_get_string_slp_key(STR_SLP_SETTING_SELECT_NUM, sel_num, &err);
663 if (ad->my_numbers.count == 1) {
665 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2),
667 ad, SWALLOW_Type_INVALID, NULL,
668 NULL, 0, SETTING_ABOUT_MY_NUMBER_STR,
671 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
673 SETTING_TRACE_ERROR("item_data is NULL");
675 } else if (ad->my_numbers.count > 1){
676 setting_enable_expandable_genlist(scroller, ad,
677 setting_about_main_exp_cb, NULL);
678 item_data = setting_create_Gendial_exp_parent_field(scroller,
679 &(ad->itc_2text_3_parent),
681 SWALLOW_Type_INVALID,
682 SETTING_ABOUT_MY_NUMBER_STR,
685 item_data->int_slp_setting_binded = STR_SLP_SETTING_SELECT_NUM;
687 SETTING_TRACE_ERROR("ad->data_wap is NULL");
691 SETTING_TRACE_ERROR("don't have my number");
695 memset(str, 0x00, sizeof(str));
696 setting_about_main_get_phone_model_name(str, sizeof(str));
698 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
699 NULL, SWALLOW_Type_INVALID, NULL,
700 NULL, 0, SETTING_ABOUT_MODEL_STR, str, 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");
708 memset(str, 0x00, sizeof(str));
709 setting_about_main_get_sw_version(str, sizeof(str));
711 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
712 NULL, SWALLOW_Type_INVALID, NULL,
713 NULL, 0, SETTING_ABOUT_VERSION_STR, str, NULL);
715 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
717 SETTING_TRACE_ERROR("item_data is NULL");
720 // [UI] Bluetooth address
721 if ( ! is_emul_bin) { // requested by DI Kim due to BT BS on 11/26
722 memset(str, 0x00, sizeof(str));
723 setting_about_main_get_bluetooth_address_string(str, sizeof(str));
725 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
726 NULL, SWALLOW_Type_INVALID, NULL,
727 NULL, 0, SETTING_ABOUT_BLUETOOTH_STR, str, NULL);
728 if (ad->item_data_bt) {
729 elm_genlist_item_select_mode_set(ad->item_data_bt->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
731 SETTING_TRACE_ERROR("item_data is NULL");
736 memset(str, 0x00, sizeof(str));
737 setting_about_main_get_wifi_mac_address_string(str, sizeof(str));
739 SETTING_TRACE_DEBUG("[about main] get_wifi_mac_address : %s", str);
742 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
743 NULL, SWALLOW_Type_INVALID, NULL,
744 NULL, 0, SETTING_ABOUT_WIFI_STR, str, NULL);
745 if (ad->item_data_wifi) {
746 elm_genlist_item_select_mode_set(ad->item_data_wifi->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
748 SETTING_TRACE_ERROR("item_data is NULL");
752 memset(str, 0x00, sizeof(str));
753 setting_about_main_get_battery_string(str, sizeof(str));
755 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
756 NULL, SWALLOW_Type_INVALID, NULL,
757 NULL, 0, SETTING_ABOUT_BATTERY_STR, str, NULL);
759 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
760 ad->item_data_battery = item_data;
762 SETTING_TRACE_ERROR("item_data is NULL");
766 memset(str, 0x00, sizeof(str));
768 int ret = __stat_get_cpuinfo(&usr, &sys);
769 if (ret == -ENOENT) {
770 SETTING_TRACE_ERROR("call __stat_get_cpuinfo fail");
771 snprintf(str, sizeof(str), "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
773 snprintf(str, sizeof(str), "%.0f%s", usr + sys, "\%");
776 ad->item_data_cpu = item_data =
777 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
778 NULL, SWALLOW_Type_INVALID, NULL,
779 NULL, 0, SETTING_ABOUT_CPU_USAGE_STR, str, NULL);
781 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
783 SETTING_TRACE_ERROR("item_data is NULL");
788 elm_genlist_item_append(scroller, &(ad->itc_seperator), NULL, NULL,
789 ELM_GENLIST_ITEM_NONE, NULL, NULL);
790 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
792 #ifdef SUPPORT_DIAG_USAGE
793 // [UI] Diagnostics and Usage
795 setting_create_Gendial_field_def(scroller, &(ad->itc_1text),
796 setting_about_main_mouse_up_Gendial_list_cb,
797 ad, SWALLOW_Type_INVALID, NULL, NULL,
798 0, DIAGNOSTICS_USAGE_STR,
804 // [UI] Software update
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, SOFTWARE_UPDATE_STR,
814 // implementation is in progress.
815 if (is_ug_installed_by_ug_args("setting-manage-applications-efl"))
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, "IDS_COM_BODY_CERTIFICATES", NULL, NULL);
822 item = elm_genlist_item_append(scroller, &itc_bottom_seperator, NULL, NULL,
823 ELM_GENLIST_ITEM_NONE, NULL, NULL);
824 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
829 ecore_timer_add(2, (Ecore_Task_Cb) __timer_update_cb, ad);
831 return SETTING_RETURN_SUCCESS;
834 static int setting_about_main_create(void *cb)
838 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
840 SettingAboutUG *ad = (SettingAboutUG *) cb;
842 Evas_Object *scroller = elm_genlist_add(ad->win_main_layout);
843 retvm_if(scroller == NULL, SETTING_DRAW_ERR_FAIL_SCROLLER,
844 "Cannot set scroller object as contento of layout");
845 elm_object_style_set(scroller, "dialogue");
846 elm_genlist_clear(scroller); /* first to clear list */
848 /* Enabling illume notification property for window */
849 elm_win_conformant_set(ad->win_main_layout, 1);
850 Evas_Object *conformant = elm_conformant_add(ad->win_main_layout);
851 elm_object_style_set(conformant, "internal_layout"); /* By Kollus. 2011-01-04 */
852 evas_object_show(conformant);
853 elm_object_content_set(conformant, scroller);
854 ad->genlsit = scroller;
857 setting_create_layout_navi_bar(ad->win_main_layout, ad->win_get,
858 _(KeyStr_AboutPhone),
859 _("IDS_COM_BODY_BACK"), NULL, NULL,
860 setting_about_main_click_softkey_back_cb,
861 NULL, NULL, ad, conformant,
862 &ad->navi_bar, NULL);
864 evas_object_event_callback_add(scroller, EVAS_CALLBACK_MOUSE_UP,
865 __about_main_gl_mouse_up, ad);
867 ad->navi_item = elm_naviframe_top_item_get(ad->navi_bar);
869 setting_about_generate_genlist((void *)ad);
871 setting_view_about_main.is_create = 1;
873 return SETTING_RETURN_SUCCESS;
876 static int setting_about_main_destroy(void *cb)
880 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
882 SettingAboutUG *ad = (SettingAboutUG *) cb;
884 if (ad->update_timer) {
885 ecore_timer_del(ad->update_timer);
886 ad->update_timer = NULL;
889 evas_object_del(ad->popup);
893 if (ad->ly_main != NULL) {
894 evas_object_del(ad->ly_main);
898 setting_view_about_main.is_create = 0;
899 return SETTING_RETURN_SUCCESS;
902 static int setting_about_main_update(void *cb)
906 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
908 SettingAboutUG *ad = (SettingAboutUG *) cb;
910 if (ad->ly_main != NULL) {
911 evas_object_show(ad->ly_main);
914 return SETTING_RETURN_SUCCESS;
917 static int setting_about_main_cleanup(void *cb)
921 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
923 SettingAboutUG *ad = (SettingAboutUG *) cb;
925 if (ad->ly_main != NULL) {
926 /* evas_object_hide(ad->ly_main); */
929 return SETTING_RETURN_SUCCESS;
932 /* ***************************************************
936 ***************************************************/
938 /* ***************************************************
942 ***************************************************/
945 setting_about_main_click_softkey_back_cb(void *data, Evas_Object *obj,
950 setting_retm_if(data == NULL, "Data parameter is NULL");
952 SettingAboutUG *ad = (SettingAboutUG *) data;
953 if (ad->empty_flag) {
955 evas_object_del(ad->popup);
958 ad->popup = setting_create_popup_without_btn(ad, ad->win_get, NULL, _(EMPTY_LIMITATION_STR),
959 __about_popup_rsp_cb, POPUP_INTERVAL, FALSE, FALSE);
960 if (ad->item_dev_name) {
961 elm_object_focus_set(ad->item_dev_name->eo_check, EINA_TRUE);
966 /* Send destroy request */
967 ug_destroy_me(ad->ug);
968 //imf must be hided before view is destroyed.
969 //Following code is just to improve the hiding speed. If not add these code,
970 //the input pannel will also be hided with the view destroyed,but it works too slow.
971 if (ad->item_dev_name) {
972 elm_object_focus_set(ad->item_dev_name->eo_check, EINA_FALSE);
973 setting_hide_input_pannel_cb(ad->item_dev_name->eo_check);
987 setting_about_main_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj,
992 setting_retm_if(data == NULL, "Data parameter is NULL");
994 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
995 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
996 elm_genlist_item_selected_set(item, 0);
997 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
999 /* SettingAboutUG *ad = (SettingAboutUG *) data; */
1001 SETTING_TRACE("clicking item[%s]", _(list_item->keyStr));
1002 if (!safeStrCmp("IDS_ST_BODY_OPEN_SOURCE_LICENCES", list_item->keyStr)) {
1004 //setting_view_change(&setting_view_about_main, &setting_view_about_licences, data);
1006 } else if (!safeStrCmp("IDS_COM_BODY_CERTIFICATES", list_item->keyStr)) {
1007 __setting_about_main_certificates_clicked(data);
1008 } else if (!safeStrCmp(SETTING_ABOUT_DEVICE_NAME_STR, list_item->keyStr)) {
1009 __setting_about_main_device_name_clicked(data, list_item->eo_check);
1010 } else if (!safeStrCmp(DIAGNOSTICS_USAGE_STR, list_item->keyStr)) {
1011 __setting_about_main_diagnostics_usage_clicked(data, list_item->eo_check);
1012 } else if (!safeStrCmp(SOFTWARE_UPDATE_STR, list_item->keyStr)) {
1014 if(aul_app_is_running("com.samsung.oma-dm-ui"))
1016 SETTING_TRACE_DEBUG("oma-dm-ui is already launched. ");
1017 aul_open_app("com.samsung.oma-dm-ui");
1021 SETTING_TRACE_DEBUG("oma-dm-ui will be launched. ");
1022 aul_launch_app("com.samsung.oma-dm-ui", NULL);
1028 static void __destroy_certificates_ug_cb(ui_gadget_h ug, void *priv)
1030 SETTING_TRACE_BEGIN;
1032 /* restore the '<-' button on the navigate bar */
1034 SettingAboutUG *ad = (SettingAboutUG *) priv; /* ad is point to priv */
1038 ad->ug_loading = NULL;
1043 static void __setting_about_main_certificates_clicked(void *data)
1045 SETTING_TRACE_BEGIN;
1046 retm_if(data == NULL, "Data parameter is NULL");
1047 SettingAboutUG *ad = (SettingAboutUG *)data;
1049 struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
1054 cbs->layout_cb = setting_about_layout_ug_cb;
1055 cbs->result_cb = NULL;
1056 cbs->destroy_cb = __destroy_certificates_ug_cb;
1057 cbs->priv = (void *)ad;
1060 ug_create(ad->ug, "setting-manage-certificates-efl", UG_MODE_FULLVIEW, NULL, cbs);
1062 if (NULL == ad->ug_loading) { /* error handling */
1063 SETTING_TRACE_ERROR("NULL == ad->ug_loading");
1068 static void __top_back_cb(void *data, Evas_Object *obj,
1071 SETTING_TRACE_BEGIN;
1073 setting_retm_if(data == NULL, "Data parameter is NULL");
1075 SettingAboutUG *ad = (SettingAboutUG *) data;
1077 if (ad->item_dev_name)
1078 setting_hide_input_pannel_cb(ad->item_dev_name->eo_check);
1083 static void _input_panel_event_cb(void *data, Ecore_IMF_Context *ctx, int value)
1085 SETTING_TRACE_BEGIN;
1086 retm_if(data == NULL, "Data parameter is NULL");
1087 retm_if(ctx == NULL, "obj parameter is NULL");
1089 SettingAboutUG *ad = (SettingAboutUG *)data;
1091 if(value == ECORE_IMF_INPUT_PANEL_STATE_SHOW)
1093 SETTING_TRACE("value == ECORE_IMF_INPUT_PANEL_STATE_SHOW");
1094 if(ad->navi_item && !elm_object_item_part_content_get(ad->navi_item, "title_right_btn"))
1096 Evas_Object *r_button = setting_create_button(ad->navi_bar,
1097 dgettext("sys_string", "IDS_COM_BODY_BACK"),
1098 NAVI_BACK_BUTTON_STYLE,
1101 elm_object_item_part_content_set(ad->navi_item, "title_right_btn", r_button);
1104 else if(value == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
1106 SETTING_TRACE("value == ECORE_IMF_INPUT_PANEL_STATE_HIDE");
1107 if(ad->navi_item && elm_object_item_part_content_get(ad->navi_item, "title_right_btn")) {
1108 Evas_Object *btn = elm_object_item_part_content_unset(ad->navi_item, "title_right_btn");
1109 evas_object_del(btn);
1112 if (ad->item_dev_name) {
1113 elm_object_focus_set(ad->item_dev_name->eo_check, EINA_FALSE);
1118 static void __setting_about_main_device_name_clicked(void *data, Evas_Object *obj)
1120 SETTING_TRACE_BEGIN;
1121 retm_if(data == NULL, "Data parameter is NULL");
1122 retm_if(obj == NULL, "obj parameter is NULL");
1123 SettingAboutUG *ad = (SettingAboutUG *)data;
1125 int mobile_ap_status = VCONFKEY_MOBILE_HOTSPOT_MODE_NONE;
1127 int ret = setting_get_int_slp_key(INT_SLP_SETTING_MOBILE_AP_STATUS, &mobile_ap_status, &err);
1128 //setting_retm_if(ret == SETTING_RETURN_FAIL, "Get vconf failed");
1130 if (!elm_object_focus_get(obj)) {
1131 elm_object_focus_set(obj, EINA_TRUE);
1134 if ((mobile_ap_status & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) && !ad->popup_showed_flag) {
1136 evas_object_del(ad->popup);
1139 ad->popup = setting_create_popup_with_btn(ad, ad->win_get,
1140 NULL, _(SETTING_ABOUT_MOBILE_AP_TURNED_OFF),
1141 __setting_about_main_mobile_ap_turn_off_ask_resp_cb, 0,
1142 1, _("IDS_COM_SK_OK"));
1144 Ecore_IMF_Context *imf_context = (Ecore_IMF_Context *)elm_entry_imf_context_get(obj);
1145 setting_retm_if(imf_context == NULL, "imf_context is NULL");
1146 ecore_imf_context_input_panel_event_callback_add(imf_context, ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_event_cb, ad);
1147 ecore_imf_context_input_panel_show(imf_context);
1152 static void __destroy_diagnostics_usage_ug_cb(ui_gadget_h ug, void *priv)
1154 SETTING_TRACE_BEGIN;
1156 /* restore the '<-' button on the navigate bar */
1158 SettingAboutUG *ad = (SettingAboutUG *) priv; /* ad is point to priv */
1162 ad->ug_loading = NULL;
1165 Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
1167 Evas_Object *back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
1169 if (back_btn != NULL) {
1170 elm_object_style_set(back_btn, NAVI_BACK_BUTTON_STYLE); /* take into effect */
1174 static void __setting_about_main_diagnostics_usage_clicked(void *data, Evas_Object *obj)
1176 SETTING_TRACE_BEGIN;
1177 retm_if(data == NULL, "Data parameter is NULL");
1178 SettingAboutUG *ad = (SettingAboutUG *)data;
1182 return; /* do nothing if ad is NULL */
1184 struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
1189 cbs->layout_cb = setting_about_layout_ug_cb;
1190 cbs->result_cb = NULL;
1191 cbs->destroy_cb = __destroy_diagnostics_usage_ug_cb;
1192 cbs->priv = (void *)ad;
1195 ug_create(ad->ug, "setting-crash-efl", UG_MODE_FULLVIEW, NULL, cbs);
1197 if (NULL == ad->ug_loading) { /* error handling */
1198 SETTING_TRACE_ERROR("NULL == ad->ug_loading");
1199 setting_create_simple_popup(ad, ad->win_get, NULL, _(UNSUPPORTED_FUNCTION));
1204 static void __setting_about_main_mobile_ap_turn_off_ask_resp_cb(void *data,
1208 SETTING_TRACE_BEGIN;
1209 setting_retm_if(data == NULL, "Data parameter is NULL");
1210 SettingAboutUG *ad = (SettingAboutUG *)data;
1211 int response_type = btn_type(obj);
1213 if (POPUP_RESPONSE_OK == response_type) {
1214 ad->popup_showed_flag = TRUE;
1216 if (ad->item_dev_name) {
1217 Ecore_IMF_Context *imf_context = elm_entry_imf_context_get(ad->item_dev_name->eo_check);
1218 setting_retm_if(imf_context == NULL, "imf_context is NULL");
1219 ecore_imf_context_input_panel_show(imf_context);
1225 evas_object_del(ad->popup);