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);
513 //after unfocus,need updating..
514 elm_object_item_data_set(item_dev_name->item, item_dev_name);
515 elm_genlist_item_update(item_dev_name->item);
519 && elm_object_item_part_content_get(ad->navi_item, "title_right_btn")) {
520 Evas_Object *btn = elm_object_item_part_content_unset(ad->navi_item, "title_right_btn");
521 evas_object_del(btn);
523 setting_hide_input_pannel_cb(item_dev_name->eo_check);
525 if (ad->empty_flag) {
527 evas_object_del(ad->popup);
530 ad->popup = setting_create_popup_without_btn(ad, ad->win_get, NULL, _(EMPTY_LIMITATION_STR),
531 __about_popup_rsp_cb, POPUP_INTERVAL, FALSE, FALSE);
538 if (0 != vconf_set_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR, entry_str_utf8)) {
539 SETTING_TRACE_ERROR("Set vconf[%s] failed",
540 VCONFKEY_SETAPPL_DEVICE_NAME_STR);
543 FREE(entry_str_utf8);
547 static void __entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
549 ret_if(data == NULL);
550 SettingAboutUG *ad = (SettingAboutUG*)data;
551 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
552 SETTING_TRACE_DEBUG("ev->key : %s", ev->key);
553 if(safeStrCmp(ev->key, "Return") == 0)
555 // if entry has 1 char at list, hide ime.
556 if(safeStrLen(elm_entry_entry_get(obj)) == 0)
559 evas_object_del(ad->popup);
562 ad->popup = setting_create_popup_without_btn(ad, ad->win_get, NULL, _(EMPTY_LIMITATION_STR),
563 __about_popup_rsp_cb, POPUP_INTERVAL, FALSE, FALSE);
568 int setting_about_generate_genlist(void *data)
572 retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
574 SettingAboutUG *ad = (SettingAboutUG *) data;
575 bool is_emul_bin = isEmulBin();
577 Evas_Object *scroller = ad->genlsit;
578 Elm_Object_Item *item = NULL;
579 Setting_GenGroupItem_Data *item_data = NULL;
580 char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
581 (void)setting_create_Gendial_field_titleItem(scroller,
582 &(ad->itc_group_item),
583 SETTING_ABOUT_DEVICE_INFO_STR, NULL);
585 char *name_value = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
586 char *pa_sub_desc = elm_entry_utf8_to_markup(name_value);
589 ad->empty_flag = FALSE;
590 if (NULL == pa_sub_desc || '\0' == pa_sub_desc[0])
592 ad->empty_flag = TRUE;
593 Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
596 Evas_Object *back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
597 setting_disable_evas_object(back_btn);
598 setting_dim_evas_object(back_btn, TRUE);
604 char *app_name = NULL;
605 int ret_get_app_name = app_manager_get_app_name("com.samsung.oma-dm-ui", &app_name);
606 if (ret_get_app_name == APP_MANAGER_ERROR_INVALID_PACKAGE )
608 SETTING_TRACE(">>>>>>>>>>>>>>>>>> UNINSTALLED PACKAGE");
609 ad->item_dev_name = NULL;
613 setting_create_Gendial_field_def(scroller, &(ad->itc_1icon),
614 setting_about_main_mouse_up_Gendial_list_cb,
615 ad, SWALLOW_Type_LAYOUT_ENTRY,
616 NULL, NULL, 0, SETTING_ABOUT_DEVICE_NAME_STR, pa_sub_desc,
617 __setting_about_device_name_changed_cb);
618 if (ad->item_dev_name) {
619 ad->item_dev_name->userdata = ad;
620 ad->item_dev_name->isSinglelineFlag = 0;
621 ad->item_dev_name->start_change_cb = (setting_call_back_func)__entry_key_down_cb;
622 ad->item_dev_name->stop_change_cb = __entry_unfocus_cb;
623 ad->item_dev_name->limit_filter_data = calloc(1, sizeof(Elm_Entry_Filter_Accept_Set));
625 if (ad->item_dev_name->limit_filter_data) {
626 //max byte len is 31 not 31+1
627 //ad->item_dev_name->limit_filter_data->max_byte_count = MAX_DEVICE_NAME_LEN + OFFESET_ENTRY_FILTER;
628 ad->item_dev_name->limit_filter_data->max_byte_count = MAX_DEVICE_NAME_LEN;
629 ad->item_dev_name->win_main = ad->win_get;
631 //ad->item_dev_name->input_type = ELM_INPUT_PANEL_LAYOUT_NUMBER;
632 ad->item_dev_name->input_panel_disable_flag = EINA_TRUE;
634 SETTING_TRACE_ERROR("ad->item_dev_name is NULL");
641 char sel_num[TAPI_SIM_XDN_DIALING_NUMBER_LEN + 1] = { 0, };
642 setting_get_string_slp_key(STR_SLP_SETTING_SELECT_NUM, sel_num, &err);
644 if (ad->my_numbers.count == 1) {
646 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2),
648 ad, SWALLOW_Type_INVALID, NULL,
649 NULL, 0, SETTING_ABOUT_MY_NUMBER_STR,
652 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
654 SETTING_TRACE_ERROR("item_data is NULL");
656 } else if (ad->my_numbers.count > 1){
657 setting_enable_expandable_genlist(scroller, ad,
658 setting_about_main_exp_cb, NULL);
659 item_data = setting_create_Gendial_exp_parent_field(scroller,
660 &(ad->itc_2text_3_parent),
662 SWALLOW_Type_INVALID,
663 SETTING_ABOUT_MY_NUMBER_STR,
666 item_data->int_slp_setting_binded = STR_SLP_SETTING_SELECT_NUM;
668 SETTING_TRACE_ERROR("ad->data_wap is NULL");
672 SETTING_TRACE_ERROR("don't have my number");
676 memset(str, 0x00, sizeof(str));
677 setting_about_main_get_phone_model_name(str, sizeof(str));
679 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
680 NULL, SWALLOW_Type_INVALID, NULL,
681 NULL, 0, SETTING_ABOUT_MODEL_STR, str, NULL);
683 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
685 SETTING_TRACE_ERROR("item_data is NULL");
689 memset(str, 0x00, sizeof(str));
690 setting_about_main_get_sw_version(str, sizeof(str));
692 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
693 NULL, SWALLOW_Type_INVALID, NULL,
694 NULL, 0, SETTING_ABOUT_VERSION_STR, str, NULL);
696 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
698 SETTING_TRACE_ERROR("item_data is NULL");
701 // [UI] Bluetooth address
702 if ( ! is_emul_bin) { // requested by DI Kim due to BT BS on 11/26
703 memset(str, 0x00, sizeof(str));
704 setting_about_main_get_bluetooth_address_string(str, sizeof(str));
706 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
707 NULL, SWALLOW_Type_INVALID, NULL,
708 NULL, 0, SETTING_ABOUT_BLUETOOTH_STR, str, NULL);
709 if (ad->item_data_bt) {
710 elm_genlist_item_select_mode_set(ad->item_data_bt->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
712 SETTING_TRACE_ERROR("item_data is NULL");
717 memset(str, 0x00, sizeof(str));
718 setting_about_main_get_wifi_mac_address_string(str, sizeof(str));
720 SETTING_TRACE_DEBUG("[about main] get_wifi_mac_address : %s", str);
723 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
724 NULL, SWALLOW_Type_INVALID, NULL,
725 NULL, 0, SETTING_ABOUT_WIFI_STR, str, NULL);
726 if (ad->item_data_wifi) {
727 elm_genlist_item_select_mode_set(ad->item_data_wifi->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
729 SETTING_TRACE_ERROR("item_data is NULL");
733 memset(str, 0x00, sizeof(str));
734 setting_about_main_get_battery_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_BATTERY_STR, str, NULL);
740 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
741 ad->item_data_battery = item_data;
743 SETTING_TRACE_ERROR("item_data is NULL");
747 memset(str, 0x00, sizeof(str));
749 int ret = __stat_get_cpuinfo(&usr, &sys);
750 if (ret == -ENOENT) {
751 SETTING_TRACE_ERROR("call __stat_get_cpuinfo fail");
752 snprintf(str, sizeof(str), "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
754 snprintf(str, sizeof(str), "%.0f%s", usr + sys, "\%");
757 ad->item_data_cpu = item_data =
758 setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2), NULL,
759 NULL, SWALLOW_Type_INVALID, NULL,
760 NULL, 0, SETTING_ABOUT_CPU_USAGE_STR, str, NULL);
762 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
764 SETTING_TRACE_ERROR("item_data is NULL");
769 elm_genlist_item_append(scroller, &(ad->itc_seperator), NULL, NULL,
770 ELM_GENLIST_ITEM_NONE, NULL, NULL);
771 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
773 #ifdef SUPPORT_DIAG_USAGE
774 // [UI] Diagnostics and Usage
776 setting_create_Gendial_field_def(scroller, &(ad->itc_1text),
777 setting_about_main_mouse_up_Gendial_list_cb,
778 ad, SWALLOW_Type_INVALID, NULL, NULL,
779 0, DIAGNOSTICS_USAGE_STR,
785 // implementation is in progress.
786 if (is_ug_installed_by_ug_args("setting-manage-applications-efl"))
788 setting_create_Gendial_field_def(scroller, &(ad->itc_1text),
789 setting_about_main_mouse_up_Gendial_list_cb,
790 ad, SWALLOW_Type_INVALID, NULL, NULL,
791 0, "IDS_COM_BODY_CERTIFICATES", NULL, NULL);
793 item = elm_genlist_item_append(scroller, &itc_bottom_seperator, NULL, NULL,
794 ELM_GENLIST_ITEM_NONE, NULL, NULL);
795 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
800 ecore_timer_add(2, (Ecore_Task_Cb) __timer_update_cb, ad);
802 return SETTING_RETURN_SUCCESS;
805 static int setting_about_main_create(void *cb)
809 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
811 SettingAboutUG *ad = (SettingAboutUG *) cb;
813 Evas_Object *scroller = elm_genlist_add(ad->win_main_layout);
814 retvm_if(scroller == NULL, SETTING_DRAW_ERR_FAIL_SCROLLER,
815 "Cannot set scroller object as contento of layout");
816 elm_object_style_set(scroller, "dialogue");
817 elm_genlist_clear(scroller); /* first to clear list */
819 /* Enabling illume notification property for window */
820 elm_win_conformant_set(ad->win_main_layout, 1);
821 Evas_Object *conformant = elm_conformant_add(ad->win_main_layout);
822 elm_object_style_set(conformant, "internal_layout"); /* By Kollus. 2011-01-04 */
823 evas_object_show(conformant);
824 elm_object_content_set(conformant, scroller);
825 ad->genlsit = scroller;
828 setting_create_layout_navi_bar(ad->win_main_layout, ad->win_get,
829 _(KeyStr_AboutPhone),
830 _("IDS_COM_BODY_BACK"), NULL, NULL,
831 setting_about_main_click_softkey_back_cb,
832 NULL, NULL, ad, conformant,
833 &ad->navi_bar, NULL);
835 evas_object_event_callback_add(scroller, EVAS_CALLBACK_MOUSE_UP,
836 __about_main_gl_mouse_up, ad);
838 ad->navi_item = elm_naviframe_top_item_get(ad->navi_bar);
840 setting_about_generate_genlist((void *)ad);
842 setting_view_about_main.is_create = 1;
844 return SETTING_RETURN_SUCCESS;
847 static int setting_about_main_destroy(void *cb)
851 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
853 SettingAboutUG *ad = (SettingAboutUG *) cb;
855 if (ad->update_timer) {
856 ecore_timer_del(ad->update_timer);
857 ad->update_timer = NULL;
860 evas_object_del(ad->popup);
864 if (ad->ly_main != NULL) {
865 evas_object_del(ad->ly_main);
869 setting_view_about_main.is_create = 0;
870 return SETTING_RETURN_SUCCESS;
873 static int setting_about_main_update(void *cb)
877 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
879 SettingAboutUG *ad = (SettingAboutUG *) cb;
881 if (ad->ly_main != NULL) {
882 evas_object_show(ad->ly_main);
885 return SETTING_RETURN_SUCCESS;
888 static int setting_about_main_cleanup(void *cb)
892 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
894 SettingAboutUG *ad = (SettingAboutUG *) cb;
896 if (ad->ly_main != NULL) {
897 /* evas_object_hide(ad->ly_main); */
900 return SETTING_RETURN_SUCCESS;
903 /* ***************************************************
907 ***************************************************/
909 /* ***************************************************
913 ***************************************************/
916 setting_about_main_click_softkey_back_cb(void *data, Evas_Object *obj,
921 setting_retm_if(data == NULL, "Data parameter is NULL");
923 SettingAboutUG *ad = (SettingAboutUG *) data;
924 if (ad->empty_flag) {
926 evas_object_del(ad->popup);
929 ad->popup = setting_create_popup_without_btn(ad, ad->win_get, NULL, _(EMPTY_LIMITATION_STR),
930 __about_popup_rsp_cb, POPUP_INTERVAL, FALSE, FALSE);
931 if (ad->item_dev_name) {
932 elm_object_focus_set(ad->item_dev_name->eo_check, EINA_TRUE);
937 /* Send destroy request */
938 ug_destroy_me(ad->ug);
939 //imf must be hided before view is destroyed.
940 //Following code is just to improve the hiding speed. If not add these code,
941 //the input pannel will also be hided with the view destroyed,but it works too slow.
942 if (ad->item_dev_name) {
943 elm_object_focus_set(ad->item_dev_name->eo_check, EINA_FALSE);
944 setting_hide_input_pannel_cb(ad->item_dev_name->eo_check);
958 setting_about_main_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj,
963 setting_retm_if(data == NULL, "Data parameter is NULL");
965 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
966 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
967 elm_genlist_item_selected_set(item, 0);
968 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
970 /* SettingAboutUG *ad = (SettingAboutUG *) data; */
972 SETTING_TRACE("clicking item[%s]", _(list_item->keyStr));
973 if (!safeStrCmp("IDS_ST_BODY_OPEN_SOURCE_LICENCES", list_item->keyStr)) {
975 //setting_view_change(&setting_view_about_main, &setting_view_about_licences, data);
977 } else if (!safeStrCmp("IDS_COM_BODY_CERTIFICATES", list_item->keyStr)) {
978 __setting_about_main_certificates_clicked(data);
979 } else if (!safeStrCmp(SETTING_ABOUT_DEVICE_NAME_STR, list_item->keyStr)) {
980 __setting_about_main_device_name_clicked(data, list_item->eo_check);
981 } else if (!safeStrCmp(DIAGNOSTICS_USAGE_STR, list_item->keyStr)) {
982 __setting_about_main_diagnostics_usage_clicked(data, list_item->eo_check);
986 static void __destroy_certificates_ug_cb(ui_gadget_h ug, void *priv)
990 /* restore the '<-' button on the navigate bar */
992 SettingAboutUG *ad = (SettingAboutUG *) priv; /* ad is point to priv */
996 ad->ug_loading = NULL;
1001 static void __setting_about_main_certificates_clicked(void *data)
1003 SETTING_TRACE_BEGIN;
1004 retm_if(data == NULL, "Data parameter is NULL");
1005 SettingAboutUG *ad = (SettingAboutUG *)data;
1007 struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
1012 cbs->layout_cb = setting_about_layout_ug_cb;
1013 cbs->result_cb = NULL;
1014 cbs->destroy_cb = __destroy_certificates_ug_cb;
1015 cbs->priv = (void *)ad;
1018 ug_create(ad->ug, "setting-manage-certificates-efl", UG_MODE_FULLVIEW, NULL, cbs);
1020 if (NULL == ad->ug_loading) { /* error handling */
1021 SETTING_TRACE_ERROR("NULL == ad->ug_loading");
1026 static void __top_back_cb(void *data, Evas_Object *obj,
1029 SETTING_TRACE_BEGIN;
1031 setting_retm_if(data == NULL, "Data parameter is NULL");
1033 SettingAboutUG *ad = (SettingAboutUG *) data;
1035 if (ad->item_dev_name)
1036 setting_hide_input_pannel_cb(ad->item_dev_name->eo_check);
1041 static void _input_panel_event_cb(void *data, Ecore_IMF_Context *ctx, int value)
1043 SETTING_TRACE_BEGIN;
1044 retm_if(data == NULL, "Data parameter is NULL");
1045 retm_if(ctx == NULL, "obj parameter is NULL");
1047 SettingAboutUG *ad = (SettingAboutUG *)data;
1049 if(value == ECORE_IMF_INPUT_PANEL_STATE_SHOW)
1051 SETTING_TRACE("value == ECORE_IMF_INPUT_PANEL_STATE_SHOW");
1052 if(ad->navi_item && !elm_object_item_part_content_get(ad->navi_item, "title_right_btn"))
1054 Evas_Object *r_button = setting_create_button(ad->navi_bar,
1055 dgettext("sys_string", "IDS_COM_BODY_BACK"),
1056 NAVI_BACK_BUTTON_STYLE,
1059 elm_object_item_part_content_set(ad->navi_item, "title_right_btn", r_button);
1062 else if(value == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
1064 SETTING_TRACE("value == ECORE_IMF_INPUT_PANEL_STATE_HIDE");
1065 if(ad->navi_item && elm_object_item_part_content_get(ad->navi_item, "title_right_btn")) {
1066 Evas_Object *btn = elm_object_item_part_content_unset(ad->navi_item, "title_right_btn");
1067 evas_object_del(btn);
1070 if (ad->item_dev_name) {
1071 elm_object_focus_set(ad->item_dev_name->eo_check, EINA_FALSE);
1076 static void __setting_about_main_device_name_clicked(void *data, Evas_Object *obj)
1078 SETTING_TRACE_BEGIN;
1079 retm_if(data == NULL, "Data parameter is NULL");
1080 retm_if(obj == NULL, "obj parameter is NULL");
1081 SettingAboutUG *ad = (SettingAboutUG *)data;
1083 if (!elm_object_focus_get(obj)) {
1084 elm_object_focus_set(obj, EINA_TRUE);
1087 Ecore_IMF_Context *imf_context = (Ecore_IMF_Context *)elm_entry_imf_context_get(obj);
1088 setting_retm_if(imf_context == NULL, "imf_context is NULL");
1089 ecore_imf_context_input_panel_event_callback_add(imf_context, ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_event_cb, ad);
1090 ecore_imf_context_input_panel_show(imf_context);
1094 static void __destroy_diagnostics_usage_ug_cb(ui_gadget_h ug, void *priv)
1096 SETTING_TRACE_BEGIN;
1098 /* restore the '<-' button on the navigate bar */
1100 SettingAboutUG *ad = (SettingAboutUG *) priv; /* ad is point to priv */
1104 ad->ug_loading = NULL;
1107 Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
1109 Evas_Object *back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
1111 if (back_btn != NULL) {
1112 elm_object_style_set(back_btn, NAVI_BACK_BUTTON_STYLE); /* take into effect */
1116 static void __setting_about_main_diagnostics_usage_clicked(void *data, Evas_Object *obj)
1118 SETTING_TRACE_BEGIN;
1119 retm_if(data == NULL, "Data parameter is NULL");
1120 SettingAboutUG *ad = (SettingAboutUG *)data;
1124 return; /* do nothing if ad is NULL */
1126 struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
1131 cbs->layout_cb = setting_about_layout_ug_cb;
1132 cbs->result_cb = NULL;
1133 cbs->destroy_cb = __destroy_diagnostics_usage_ug_cb;
1134 cbs->priv = (void *)ad;
1137 ug_create(ad->ug, "setting-crash-efl", UG_MODE_FULLVIEW, NULL, cbs);
1139 if (NULL == ad->ug_loading) { /* error handling */
1140 SETTING_TRACE_ERROR("NULL == ad->ug_loading");
1141 setting_create_simple_popup(ad, ad->win_get, NULL, _(UNSUPPORTED_FUNCTION));