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_certificates_clicked(void *data);
78 static void __setting_about_main_device_name_clicked(void *data, Evas_Object *obj);
79 static void __setting_about_main_diagnostics_usage_clicked(void *data, Evas_Object *obj);
80 /* ***************************************************
84 ***************************************************/
85 static void __about_popup_rsp_cb(void *data, Evas_Object *obj, void *event_info)
87 SettingAboutUG *ad = data;
94 static void __device_name_changed_cb(void *data, Evas_Object *obj)
96 retm_if(!data || !obj, "Data parameter is NULL");
97 //return if entry is not focused too
99 Setting_GenGroupItem_Data *list_item =
100 (Setting_GenGroupItem_Data *) data;
101 SettingAboutUG *ad = list_item->userdata;
102 retm_if(ad == NULL, "Data parameter is NULL");
104 const char *entry_str = elm_entry_entry_get(obj);
105 int entry_len = safeStrLen(entry_str);
106 SETTING_TRACE("entry_str:[%s], lenght:%d", entry_str, entry_len);
108 #if DEVNAME_BLOCK_SPACE
110 if (entry_len > 0 && NULL != strstr(entry_str, " ")) {//cancel the effect of input 'space character'
111 SETTING_TRACE("Cannot input the 'space' key or 'enter' key");
115 char *tmp = (char *)g_strdup(entry_str);
118 for (j = i; tmp[j]; j++) {
125 G_FREE(list_item->sub_desc);
126 list_item->sub_desc = (char *)g_strdup(tmp);
128 SETTING_TRACE("sub_desc:[%s]", list_item->sub_desc);
130 elm_entry_entry_set(obj, list_item->sub_desc);
131 elm_entry_cursor_end_set(obj);
135 G_FREE(list_item->sub_desc);//release first
136 list_item->sub_desc = (char *)g_strdup(entry_str);
138 if (NULL == entry_str || 0 == entry_len) {
141 ad->empty_flag = TRUE;
142 elm_entry_context_menu_disabled_set(obj, TRUE); //disable the copy&paste&search popup
143 elm_entry_magnifier_disabled_set(obj, TRUE);
144 Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
147 Evas_Object *back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
148 setting_disable_evas_object(back_btn);
149 setting_dim_evas_object(back_btn, TRUE);
151 Evas_Object *top_r_btn = elm_object_item_part_content_get(navi_it, "title_right_btn");
154 setting_disable_evas_object(top_r_btn);
155 setting_dim_evas_object(top_r_btn, TRUE);
162 ad->empty_flag = FALSE;
163 elm_entry_context_menu_disabled_set(obj, FALSE); //enable the copy&paste&search popup
164 elm_entry_magnifier_disabled_set(obj, FALSE);
165 Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
168 Evas_Object *back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
169 setting_enable_evas_object(back_btn);
170 setting_undo_dim_evas_object(back_btn, TRUE);
172 Evas_Object *top_r_btn = elm_object_item_part_content_get(navi_it, "title_right_btn");
175 setting_enable_evas_object(top_r_btn);
176 setting_undo_dim_evas_object(top_r_btn, TRUE);
185 __setting_about_device_name_changed_cb(void *data, Evas_Object *obj,
188 __device_name_changed_cb(data, obj);
194 * - No ini: Unavailable
195 * - I9500 @ target: GT-I9500
196 * - I9500 @ emul: SDK
197 * - SLP @ target: GT-SLP
200 void setting_about_main_get_phone_model_name(char* szStr, int nSize)
202 retm_if(szStr == NULL, "szStr parameter is NULL");
205 int ret = system_info_get_value_string(SYSTEM_INFO_KEY_MODEL, &value);
206 SETTING_TRACE("value : %s", value);
207 if (ret != SYSTEM_INFO_ERROR_NONE) {
208 SETTING_TRACE_ERROR("fail to call system_info_get_value_string");
210 snprintf(szStr, nSize, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
215 snprintf(szStr, nSize, "%s", value);
217 snprintf(szStr, nSize, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
223 void setting_about_main_get_sw_version(char* szStr, int nSize)
225 retm_if(szStr == NULL, "szStr parameter is NULL");
227 char *version = NULL;
228 int ret = system_info_get_value_string(SYSTEM_INFO_KEY_TIZEN_VERSION, &version);
229 if (ret != SYSTEM_INFO_ERROR_NONE) {
230 SETTING_TRACE_ERROR("fail to call system_info_get_value_string");
232 snprintf(szStr, nSize, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
236 char *build_info = NULL;
237 ret = system_info_get_value_string(SYSTEM_INFO_KEY_BUILD_STRING, &build_info);
238 if (ret != SYSTEM_INFO_ERROR_NONE) {
239 SETTING_TRACE_ERROR("fail to call system_info_get_value_string");
242 snprintf(szStr, nSize, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
246 snprintf(szStr, nSize, "SLP%s (%s)", version, build_info);
252 void setting_about_main_get_wifi_mac_address_string(char *str, int size)
254 setting_retm_if(str == NULL, "str parameter is NULL");
255 setting_retm_if(size < SETTING_ABOUT_WIFI_MAC_STR_LEN+1, "size parameter is wrong");
257 FILE *p = fopen(SETTING_ABOUT_MACINFO_PATH, "r");
260 int size = fread(str, sizeof(char), SETTING_ABOUT_WIFI_MAC_STR_LEN, p);
261 if (size != SETTING_ABOUT_WIFI_MAC_STR_LEN) {
262 SETTING_TRACE_ERROR("fail to call fread");
267 perror("open failed!");
270 SETTING_TRACE_DEBUG("get_wifi_mac_address : %s", str);
272 int wifi_state = VCONFKEY_WIFI_OFF;
273 vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
275 if((safeStrLen(str) == 0) || (wifi_state == VCONFKEY_WIFI_OFF))
276 snprintf(str, size, "%s (%s)", _("IDS_ST_HEADER_UNAVAILABLE"), _(SETTING_ABOUT_NEVER_TURN_WIFI_ON_STR));
279 void setting_about_main_get_battery_string(char *str, int size)
281 setting_retm_if(str == NULL, "str parameter is NULL");
284 char file[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
285 snprintf(file, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO,
286 "%s/%s/%s", SETTING_ABOUT_POWER_SUPPLY_PATH, "battery", "capacity");
288 char buf[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
292 fd = open(file, O_RDONLY);
294 r = read(fd, buf, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO);
295 if ((r >= 0) && (r < MAX_DISPLAY_STR_LEN_ON_PHONE_INFO)) {
298 snprintf(str, size, "%d%s", val, "\%");
300 SETTING_TRACE_ERROR("read file fail");
301 snprintf(str, size, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
306 SETTING_TRACE_ERROR("open file fail");
307 snprintf(str, size, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
311 void setting_about_main_get_bluetooth_address_string(char *str, int size)
313 setting_retm_if(str == NULL, "str parameter is NULL");
315 bluetooth_device_address_t local_address;
316 memset(&local_address, 0x0, sizeof(local_address));
319 /* for fixing BS of dbus signal */
320 bluetooth_register_callback(NULL, NULL);
322 ret = bluetooth_get_local_address(&local_address);
324 /* for fixing BS of dbus signal */
325 bluetooth_unregister_callback();
328 snprintf(str, size, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
330 snprintf(str, size, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
331 local_address.addr[0], local_address.addr[1], local_address.addr[2],
332 local_address.addr[3], local_address.addr[4], local_address.addr[5]);
334 SETTING_TRACE_DEBUG("bt address : %s", str);
337 int __stat_get_cpuinfo(float *usr_pct, float *sys_pct)
339 setting_retvm_if(usr_pct == NULL, -ENOENT, "param usr_pct is null");
340 setting_retvm_if(sys_pct == NULL, -ENOENT, "param sys_pct is null");
345 static unsigned long long usr_time = 0, nice_time = 0, sys_time = 0;
346 static unsigned long long old_usr = 0, old_nice = 0, old_sys = 0;
347 static struct timeval old_tv, cur_tv;
348 unsigned long long elapsed_tick;
354 tick_per_sec = sysconf(_SC_CLK_TCK);
355 cpu_num = sysconf(_SC_NPROCESSORS_ONLN);
360 gettimeofday(&cur_tv, NULL);
361 fp = fopen(SETTING_ABOUT_STAT_PATH, "r");
363 SETTING_TRACE_ERROR("fp == NULL");
367 char cpu_info[MAX_COMMON_BUFFER_LEN] = {0,};
368 char *cpu_info_p = fgets(cpu_info, MAX_COMMON_BUFFER_LEN, fp);
370 if(cpu_info_p == NULL) {
371 SETTING_TRACE_ERROR("fgets failed");
372 fclose(fp); // free - code
377 unsigned long long tmp_long = 0;
379 /* split cpu_info, get 3 numbers headmost*/
380 while ((substr = strsep(&cpu_info_p, " \t")) != NULL) {
382 tmp_long = strtoull(substr, &endptr, 10);
383 if (tmp_long != 0 && tmp_long != ULLONG_MAX) {
389 nice_time = tmp_long;
408 SETTING_TRACE_ERROR("old_usr == 0");
412 elapsed_tick = (cur_tv.tv_sec - old_tv.tv_sec) * tick_per_sec +
413 ((cur_tv.tv_usec - old_tv.tv_usec) * tick_per_sec) / 1000000;
416 if (elapsed_tick != 0)
418 ((float)(usr_time - old_usr) * 100 / elapsed_tick) /
423 if (elapsed_tick != 0)
425 ((float)(sys_time - old_sys) * 100 / elapsed_tick) /
432 old_nice = nice_time;
439 static Eina_Bool __timer_update_cb(const void *data)
441 retv_if(data == NULL, TRUE);
442 SettingAboutUG *ad = (SettingAboutUG *) data;
444 char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
445 if (ad->item_data_cpu) {
447 int ret = __stat_get_cpuinfo(&usr, &sys);
448 if (ret == -ENOENT) {
449 SETTING_TRACE_ERROR("call __stat_get_cpuinfo fail");
450 snprintf(str, sizeof(str), "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
452 snprintf(str, sizeof(str), "%.0f%s", usr + sys, "\%");
455 ad->item_data_cpu->sub_desc = (char *)g_strdup(str);
456 elm_object_item_data_set(ad->item_data_cpu->item, ad->item_data_cpu);
457 elm_genlist_item_update(ad->item_data_cpu->item);
460 if (ad->item_data_battery) {
461 setting_about_main_get_battery_string(str, sizeof(str));
462 /*SETTING_TRACE("str:%s", str);*/
463 ad->item_data_battery->sub_desc = (char *)g_strdup(str);
464 elm_object_item_data_set(ad->item_data_battery->item, ad->item_data_battery);
465 elm_genlist_item_update(ad->item_data_battery->item);
471 __about_main_gl_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event)
474 SettingAboutUG *ad = (SettingAboutUG *) data;
475 retm_if(event == NULL, "Invalid argument: event info is NULL");
476 Evas_Event_Mouse_Up *ev = (Evas_Event_Mouse_Up *)event;
478 if (ad->item_dev_name) {
479 Elm_Object_Item *selected_item = elm_genlist_at_xy_item_get(ad->genlsit, ev->output.x, ev->output.y, NULL);
480 if (ad->item_dev_name->item == selected_item)//do nothing..
483 elm_object_focus_set(ad->item_dev_name->eo_check, EINA_FALSE);//to make inputing words input
487 static void __entry_unfocus_cb(void *data, Evas_Object *obj, void *event_info)
490 retm_if(!data || !obj, "Data parameter is NULL");
492 Evas_Object *entry_container = elm_object_parent_widget_get(obj);
493 if (entry_container) {
494 //whe entry unfocused, its guidetext will becomes "Input here"
495 elm_object_part_text_set(entry_container, "elm.guidetext", _("IDS_ST_BODY_TAP_TO_INSERT"));
496 if (elm_entry_is_empty(obj))
497 elm_object_signal_emit(entry_container, "elm,state,guidetext,show", "elm");
498 elm_object_signal_emit(entry_container, "elm,state,eraser,hide", "elm");
501 //Setting_GenGroupItem_Data *list_item = data;
502 const char *entry_str = elm_entry_entry_get(obj);
503 char *entry_str_utf8 = NULL;
504 entry_str_utf8 = elm_entry_markup_to_utf8(entry_str);
505 //int len = safeStrLen(entry_str_utf8);
506 SETTING_TRACE("To store \"%s\" into vconf[%s]", entry_str_utf8, VCONFKEY_SETAPPL_DEVICE_NAME_STR);
508 //ecore_idler_add(__check_on_idler, ad);
509 Setting_GenGroupItem_Data *item_dev_name = data;
510 SettingAboutUG *ad = item_dev_name->userdata;
511 __device_name_changed_cb(item_dev_name, item_dev_name->eo_check);
512 //after unfocus,need updating..
513 elm_object_item_data_set(item_dev_name->item, item_dev_name);
514 elm_genlist_item_update(item_dev_name->item);
518 && elm_object_item_part_content_get(ad->navi_item, "title_right_btn")) {
519 Evas_Object *btn = elm_object_item_part_content_unset(ad->navi_item, "title_right_btn");
520 evas_object_del(btn);
522 setting_hide_input_pannel_cb(item_dev_name->eo_check);
524 if (ad->empty_flag) {
526 evas_object_del(ad->popup);
529 ad->popup = setting_create_popup_without_btn(ad, ad->win_get, NULL, _(EMPTY_LIMITATION_STR),
530 __about_popup_rsp_cb, POPUP_INTERVAL, FALSE, FALSE);
537 if (0 != vconf_set_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR, entry_str_utf8)) {
538 SETTING_TRACE_ERROR("Set vconf[%s] failed",
539 VCONFKEY_SETAPPL_DEVICE_NAME_STR);
542 FREE(entry_str_utf8);
546 static void __entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
548 ret_if(data == NULL);
549 SettingAboutUG *ad = (SettingAboutUG*)data;
550 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
551 SETTING_TRACE_DEBUG("ev->key : %s", ev->key);
552 if(safeStrCmp(ev->key, "Return") == 0)
554 // if entry has 1 char at list, hide ime.
555 if(safeStrLen(elm_entry_entry_get(obj)) == 0)
558 evas_object_del(ad->popup);
561 ad->popup = setting_create_popup_without_btn(ad, ad->win_get, NULL, _(EMPTY_LIMITATION_STR),
562 __about_popup_rsp_cb, POPUP_INTERVAL, FALSE, FALSE);
567 int setting_about_generate_genlist(void *data)
571 retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
573 SettingAboutUG *ad = (SettingAboutUG *) data;
574 bool is_emul_bin = isEmulBin();
576 Evas_Object *scroller = ad->genlsit;
577 Elm_Object_Item *item = NULL;
578 Setting_GenGroupItem_Data *item_data = NULL;
579 char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
580 (void)setting_create_Gendial_field_titleItem(scroller,
581 &(ad->itc_group_item),
582 SETTING_ABOUT_DEVICE_INFO_STR, NULL);
584 char *name_value = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
585 char *pa_sub_desc = elm_entry_utf8_to_markup(name_value);
588 ad->empty_flag = FALSE;
589 if (NULL == pa_sub_desc || '\0' == pa_sub_desc[0])
591 ad->empty_flag = TRUE;
592 Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
595 Evas_Object *back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
596 setting_disable_evas_object(back_btn);
597 setting_dim_evas_object(back_btn, TRUE);
603 char *app_name = NULL;
604 int ret_get_app_name = app_manager_get_app_name("com.samsung.oma-dm-ui", &app_name);
605 if (ret_get_app_name == APP_MANAGER_ERROR_INVALID_PACKAGE )
607 SETTING_TRACE(">>>>>>>>>>>>>>>>>> UNINSTALLED PACKAGE");
608 ad->item_dev_name = NULL;
612 setting_create_Gendial_field_def(scroller, &(ad->itc_1icon),
613 setting_about_main_mouse_up_Gendial_list_cb,
614 ad, SWALLOW_Type_LAYOUT_ENTRY,
615 NULL, NULL, 0, SETTING_ABOUT_DEVICE_NAME_STR, pa_sub_desc,
616 __setting_about_device_name_changed_cb);
617 if (ad->item_dev_name) {
618 ad->item_dev_name->userdata = ad;
619 ad->item_dev_name->isSinglelineFlag = 0;
620 ad->item_dev_name->start_change_cb = (setting_call_back_func)__entry_key_down_cb;
621 ad->item_dev_name->stop_change_cb = __entry_unfocus_cb;
622 ad->item_dev_name->limit_filter_data = calloc(1, sizeof(Elm_Entry_Filter_Accept_Set));
624 if (ad->item_dev_name->limit_filter_data) {
625 //max byte len is 31 not 31+1
626 //ad->item_dev_name->limit_filter_data->max_byte_count = MAX_DEVICE_NAME_LEN + OFFESET_ENTRY_FILTER;
627 ad->item_dev_name->limit_filter_data->max_byte_count = MAX_DEVICE_NAME_LEN;
628 ad->item_dev_name->win_main = ad->win_get;
630 //ad->item_dev_name->input_type = ELM_INPUT_PANEL_LAYOUT_NUMBER;
631 ad->item_dev_name->input_panel_disable_flag = EINA_TRUE;
633 SETTING_TRACE_ERROR("ad->item_dev_name is NULL");
640 char sel_num[TAPI_SIM_XDN_DIALING_NUMBER_LEN + 1] = { 0, };
641 setting_get_string_slp_key(STR_SLP_SETTING_SELECT_NUM, sel_num, &err);
643 if (ad->my_numbers.count == 1) {
645 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2),
647 ad, SWALLOW_Type_INVALID, NULL,
648 NULL, 0, SETTING_ABOUT_MY_NUMBER_STR,
651 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
653 SETTING_TRACE_ERROR("item_data is NULL");
655 } else if (ad->my_numbers.count > 1){
656 setting_enable_expandable_genlist(scroller, ad,
657 setting_about_main_exp_cb, NULL);
658 item_data = setting_create_Gendial_exp_parent_field(scroller,
659 &(ad->itc_2text_3_parent),
661 SWALLOW_Type_INVALID,
662 SETTING_ABOUT_MY_NUMBER_STR,
665 item_data->int_slp_setting_binded = STR_SLP_SETTING_SELECT_NUM;
667 SETTING_TRACE_ERROR("ad->data_wap is NULL");
671 SETTING_TRACE_ERROR("don't have my number");
675 memset(str, 0x00, sizeof(str));
676 setting_about_main_get_phone_model_name(str, sizeof(str));
678 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
679 NULL, SWALLOW_Type_INVALID, NULL,
680 NULL, 0, SETTING_ABOUT_MODEL_STR, str, NULL);
682 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
684 SETTING_TRACE_ERROR("item_data is NULL");
688 memset(str, 0x00, sizeof(str));
689 setting_about_main_get_sw_version(str, sizeof(str));
691 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
692 NULL, SWALLOW_Type_INVALID, NULL,
693 NULL, 0, SETTING_ABOUT_VERSION_STR, str, NULL);
695 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
697 SETTING_TRACE_ERROR("item_data is NULL");
700 // [UI] Bluetooth address
701 if ( ! is_emul_bin) { // requested by DI Kim due to BT BS on 11/26
702 memset(str, 0x00, sizeof(str));
703 setting_about_main_get_bluetooth_address_string(str, sizeof(str));
705 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
706 NULL, SWALLOW_Type_INVALID, NULL,
707 NULL, 0, SETTING_ABOUT_BLUETOOTH_STR, str, NULL);
708 if (ad->item_data_bt) {
709 elm_genlist_item_select_mode_set(ad->item_data_bt->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
711 SETTING_TRACE_ERROR("item_data is NULL");
716 memset(str, 0x00, sizeof(str));
717 setting_about_main_get_wifi_mac_address_string(str, sizeof(str));
719 SETTING_TRACE_DEBUG("[about main] get_wifi_mac_address : %s", str);
722 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
723 NULL, SWALLOW_Type_INVALID, NULL,
724 NULL, 0, SETTING_ABOUT_WIFI_STR, str, NULL);
725 if (ad->item_data_wifi) {
726 elm_genlist_item_select_mode_set(ad->item_data_wifi->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
728 SETTING_TRACE_ERROR("item_data is NULL");
732 memset(str, 0x00, sizeof(str));
733 setting_about_main_get_battery_string(str, sizeof(str));
735 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
736 NULL, SWALLOW_Type_INVALID, NULL,
737 NULL, 0, SETTING_ABOUT_BATTERY_STR, str, NULL);
739 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
740 ad->item_data_battery = item_data;
742 SETTING_TRACE_ERROR("item_data is NULL");
746 memset(str, 0x00, sizeof(str));
748 int ret = __stat_get_cpuinfo(&usr, &sys);
749 if (ret == -ENOENT) {
750 SETTING_TRACE_ERROR("call __stat_get_cpuinfo fail");
751 snprintf(str, sizeof(str), "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
753 snprintf(str, sizeof(str), "%.0f%s", usr + sys, "\%");
756 ad->item_data_cpu = item_data =
757 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
758 NULL, SWALLOW_Type_INVALID, NULL,
759 NULL, 0, SETTING_ABOUT_CPU_USAGE_STR, str, NULL);
761 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
763 SETTING_TRACE_ERROR("item_data is NULL");
768 elm_genlist_item_append(scroller, &(ad->itc_seperator), NULL, NULL,
769 ELM_GENLIST_ITEM_NONE, NULL, NULL);
770 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
772 #ifdef SUPPORT_DIAG_USAGE
773 // [UI] Diagnostics and Usage
775 setting_create_Gendial_field_def(scroller, &(ad->itc_1text),
776 setting_about_main_mouse_up_Gendial_list_cb,
777 ad, SWALLOW_Type_INVALID, NULL, NULL,
778 0, DIAGNOSTICS_USAGE_STR,
784 // implementation is in progress.
785 if (is_ug_installed_by_ug_args("setting-manage-applications-efl"))
787 setting_create_Gendial_field_def(scroller, &(ad->itc_1text),
788 setting_about_main_mouse_up_Gendial_list_cb,
789 ad, SWALLOW_Type_INVALID, NULL, NULL,
790 0, "IDS_COM_BODY_CERTIFICATES", NULL, NULL);
792 item = elm_genlist_item_append(scroller, &itc_bottom_seperator, NULL, NULL,
793 ELM_GENLIST_ITEM_NONE, NULL, NULL);
794 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
799 ecore_timer_add(2, (Ecore_Task_Cb) __timer_update_cb, ad);
801 return SETTING_RETURN_SUCCESS;
804 static int setting_about_main_create(void *cb)
808 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
810 SettingAboutUG *ad = (SettingAboutUG *) cb;
812 Evas_Object *scroller = elm_genlist_add(ad->win_main_layout);
813 retvm_if(scroller == NULL, SETTING_DRAW_ERR_FAIL_SCROLLER,
814 "Cannot set scroller object as contento of layout");
815 elm_object_style_set(scroller, "dialogue");
816 elm_genlist_clear(scroller); /* first to clear list */
818 /* Enabling illume notification property for window */
819 elm_win_conformant_set(ad->win_main_layout, 1);
820 Evas_Object *conformant = elm_conformant_add(ad->win_main_layout);
821 elm_object_style_set(conformant, "internal_layout"); /* By Kollus. 2011-01-04 */
822 evas_object_show(conformant);
823 elm_object_content_set(conformant, scroller);
824 ad->genlsit = scroller;
827 setting_create_layout_navi_bar(ad->win_main_layout, ad->win_get,
828 _(KeyStr_AboutPhone),
829 _("IDS_COM_BODY_BACK"), NULL, NULL,
830 setting_about_main_click_softkey_back_cb,
831 NULL, NULL, ad, conformant,
832 &ad->navi_bar, NULL);
834 evas_object_event_callback_add(scroller, EVAS_CALLBACK_MOUSE_UP,
835 __about_main_gl_mouse_up, ad);
837 ad->navi_item = elm_naviframe_top_item_get(ad->navi_bar);
839 setting_about_generate_genlist((void *)ad);
841 setting_view_about_main.is_create = 1;
843 return SETTING_RETURN_SUCCESS;
846 static int setting_about_main_destroy(void *cb)
850 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
852 SettingAboutUG *ad = (SettingAboutUG *) cb;
854 if (ad->update_timer) {
855 ecore_timer_del(ad->update_timer);
856 ad->update_timer = NULL;
859 evas_object_del(ad->popup);
863 if (ad->ly_main != NULL) {
864 evas_object_del(ad->ly_main);
868 setting_view_about_main.is_create = 0;
869 return SETTING_RETURN_SUCCESS;
872 static int setting_about_main_update(void *cb)
876 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
878 SettingAboutUG *ad = (SettingAboutUG *) cb;
880 if (ad->ly_main != NULL) {
881 evas_object_show(ad->ly_main);
884 return SETTING_RETURN_SUCCESS;
887 static int setting_about_main_cleanup(void *cb)
891 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
893 SettingAboutUG *ad = (SettingAboutUG *) cb;
895 if (ad->ly_main != NULL) {
896 /* evas_object_hide(ad->ly_main); */
899 return SETTING_RETURN_SUCCESS;
902 /* ***************************************************
906 ***************************************************/
908 /* ***************************************************
912 ***************************************************/
915 setting_about_main_click_softkey_back_cb(void *data, Evas_Object *obj,
920 setting_retm_if(data == NULL, "Data parameter is NULL");
922 SettingAboutUG *ad = (SettingAboutUG *) data;
923 if (ad->empty_flag) {
925 evas_object_del(ad->popup);
928 ad->popup = setting_create_popup_without_btn(ad, ad->win_get, NULL, _(EMPTY_LIMITATION_STR),
929 __about_popup_rsp_cb, POPUP_INTERVAL, FALSE, FALSE);
930 if (ad->item_dev_name) {
931 elm_object_focus_set(ad->item_dev_name->eo_check, EINA_TRUE);
936 /* Send destroy request */
937 ug_destroy_me(ad->ug);
938 //imf must be hided before view is destroyed.
939 //Following code is just to improve the hiding speed. If not add these code,
940 //the input pannel will also be hided with the view destroyed,but it works too slow.
941 if (ad->item_dev_name) {
942 elm_object_focus_set(ad->item_dev_name->eo_check, EINA_FALSE);
943 setting_hide_input_pannel_cb(ad->item_dev_name->eo_check);
957 setting_about_main_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj,
962 setting_retm_if(data == NULL, "Data parameter is NULL");
964 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
965 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
966 elm_genlist_item_selected_set(item, 0);
967 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
969 /* SettingAboutUG *ad = (SettingAboutUG *) data; */
971 SETTING_TRACE("clicking item[%s]", _(list_item->keyStr));
972 if (!safeStrCmp("IDS_ST_BODY_OPEN_SOURCE_LICENCES", list_item->keyStr)) {
974 //setting_view_change(&setting_view_about_main, &setting_view_about_licences, data);
976 } else if (!safeStrCmp("IDS_COM_BODY_CERTIFICATES", list_item->keyStr)) {
977 __setting_about_main_certificates_clicked(data);
978 } else if (!safeStrCmp(SETTING_ABOUT_DEVICE_NAME_STR, list_item->keyStr)) {
979 __setting_about_main_device_name_clicked(data, list_item->eo_check);
980 } else if (!safeStrCmp(DIAGNOSTICS_USAGE_STR, list_item->keyStr)) {
981 __setting_about_main_diagnostics_usage_clicked(data, list_item->eo_check);
985 static void __destroy_certificates_ug_cb(ui_gadget_h ug, void *priv)
989 /* restore the '<-' button on the navigate bar */
991 SettingAboutUG *ad = (SettingAboutUG *) priv; /* ad is point to priv */
995 ad->ug_loading = NULL;
1000 static void __setting_about_main_certificates_clicked(void *data)
1002 SETTING_TRACE_BEGIN;
1003 retm_if(data == NULL, "Data parameter is NULL");
1004 SettingAboutUG *ad = (SettingAboutUG *)data;
1006 struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
1011 cbs->layout_cb = setting_about_layout_ug_cb;
1012 cbs->result_cb = NULL;
1013 cbs->destroy_cb = __destroy_certificates_ug_cb;
1014 cbs->priv = (void *)ad;
1017 ug_create(ad->ug, "setting-manage-certificates-efl", UG_MODE_FULLVIEW, NULL, cbs);
1019 if (NULL == ad->ug_loading) { /* error handling */
1020 SETTING_TRACE_ERROR("NULL == ad->ug_loading");
1025 static void __top_back_cb(void *data, Evas_Object *obj,
1028 SETTING_TRACE_BEGIN;
1030 setting_retm_if(data == NULL, "Data parameter is NULL");
1032 SettingAboutUG *ad = (SettingAboutUG *) data;
1034 if (ad->item_dev_name)
1035 setting_hide_input_pannel_cb(ad->item_dev_name->eo_check);
1040 static void _input_panel_event_cb(void *data, Ecore_IMF_Context *ctx, int value)
1042 SETTING_TRACE_BEGIN;
1043 retm_if(data == NULL, "Data parameter is NULL");
1044 retm_if(ctx == NULL, "obj parameter is NULL");
1046 SettingAboutUG *ad = (SettingAboutUG *)data;
1048 if(value == ECORE_IMF_INPUT_PANEL_STATE_SHOW)
1050 SETTING_TRACE("value == ECORE_IMF_INPUT_PANEL_STATE_SHOW");
1051 if(ad->navi_item && !elm_object_item_part_content_get(ad->navi_item, "title_right_btn"))
1053 Evas_Object *r_button = setting_create_button(ad->navi_bar,
1054 dgettext("sys_string", "IDS_COM_BODY_BACK"),
1055 NAVI_BACK_BUTTON_STYLE,
1058 elm_object_item_part_content_set(ad->navi_item, "title_right_btn", r_button);
1061 else if(value == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
1063 SETTING_TRACE("value == ECORE_IMF_INPUT_PANEL_STATE_HIDE");
1064 if(ad->navi_item && elm_object_item_part_content_get(ad->navi_item, "title_right_btn")) {
1065 Evas_Object *btn = elm_object_item_part_content_unset(ad->navi_item, "title_right_btn");
1066 evas_object_del(btn);
1069 if (ad->item_dev_name) {
1070 elm_object_focus_set(ad->item_dev_name->eo_check, EINA_FALSE);
1075 static void __setting_about_main_device_name_clicked(void *data, Evas_Object *obj)
1077 SETTING_TRACE_BEGIN;
1078 retm_if(data == NULL, "Data parameter is NULL");
1079 retm_if(obj == NULL, "obj parameter is NULL");
1080 SettingAboutUG *ad = (SettingAboutUG *)data;
1082 if (!elm_object_focus_get(obj)) {
1083 elm_object_focus_set(obj, EINA_TRUE);
1086 Ecore_IMF_Context *imf_context = (Ecore_IMF_Context *)elm_entry_imf_context_get(obj);
1087 setting_retm_if(imf_context == NULL, "imf_context is NULL");
1088 ecore_imf_context_input_panel_event_callback_add(imf_context, ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_event_cb, ad);
1089 ecore_imf_context_input_panel_show(imf_context);
1093 static void __destroy_diagnostics_usage_ug_cb(ui_gadget_h ug, void *priv)
1095 SETTING_TRACE_BEGIN;
1097 /* restore the '<-' button on the navigate bar */
1099 SettingAboutUG *ad = (SettingAboutUG *) priv; /* ad is point to priv */
1103 ad->ug_loading = NULL;
1106 Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
1108 Evas_Object *back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
1110 if (back_btn != NULL) {
1111 elm_object_style_set(back_btn, NAVI_BACK_BUTTON_STYLE); /* take into effect */
1115 static void __setting_about_main_diagnostics_usage_clicked(void *data, Evas_Object *obj)
1117 SETTING_TRACE_BEGIN;
1118 retm_if(data == NULL, "Data parameter is NULL");
1119 SettingAboutUG *ad = (SettingAboutUG *)data;
1123 return; /* do nothing if ad is NULL */
1125 struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
1130 cbs->layout_cb = setting_about_layout_ug_cb;
1131 cbs->result_cb = NULL;
1132 cbs->destroy_cb = __destroy_diagnostics_usage_ug_cb;
1133 cbs->priv = (void *)ad;
1136 ug_create(ad->ug, "setting-crash-efl", UG_MODE_FULLVIEW, NULL, cbs);
1138 if (NULL == ad->ug_loading) { /* error handling */
1139 SETTING_TRACE_ERROR("NULL == ad->ug_loading");
1140 setting_create_simple_popup(ad, ad->win_get, NULL, _(UNSUPPORTED_FUNCTION));