Merge "Fix N_SE-9270,N_SE-9282 and the max limition string" into 2.0_beta
[apps/core/preloaded/settings.git] / setting-about / src / setting-about-main.c
1 /*
2  * setting
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
5  *
6  * Contact: MyoungJune Park <mj2004.park@samsung.com>
7  *
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  *
20  */
21 #include <setting-cfg.h>
22 #include <setting-about-main.h>
23 #include <aul.h>
24 #include <sys/types.h>
25 #include <sys/stat.h>
26 #include <fcntl.h>
27 #include <bluetooth-api.h>
28
29
30 #include <app_manager.h>
31 #include <system_info.h>
32
33 #define DEVNAME_BLOCK_SPACE     0
34 // #define SUPPORT_DIAG_USAGE
35
36 /** @todo : need to handle unicode encoded input characters */
37
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"
42
43
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);
48
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,
54 };
55 /**
56 * Do process when clicking '<-' button
57 *
58 * @param data
59 * @param obj
60 * @param event_info
61 */
62 static void setting_about_main_click_softkey_back_cb(void *data,
63                                                      Evas_Object *obj,
64                                                      void *event_info);
65
66 /**
67 * Do process when clicking on some genlist item
68 *
69 * @param data
70 * @param obj
71 * @param event_info
72 */
73 static void setting_about_main_mouse_up_Gendial_list_cb(void *data,
74                                                         Evas_Object *obj,
75                                                         void *event_info);
76
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 /* ***************************************************
81  *
82  *basic func
83  *
84  ***************************************************/
85 static void __about_popup_rsp_cb(void *data, Evas_Object *obj, void *event_info)
86 {
87         SettingAboutUG *ad = data;
88         if (obj) {
89                 evas_object_del(obj);
90                 obj = NULL;
91         }
92         ad->popup = NULL;
93 }
94 static void __device_name_changed_cb(void *data, Evas_Object *obj)
95 {
96         retm_if(!data || !obj, "Data parameter is NULL");
97         //return if entry is not focused too
98
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");
103
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);
107
108 #if DEVNAME_BLOCK_SPACE
109         //block 'Space' key
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");
112
113                 int i = 0;
114                 int j = 0;
115                 char *tmp = (char *)g_strdup(entry_str);
116                 for (; tmp[i];) {
117                         if (tmp[i] == ' ') {
118                                 for (j = i; tmp[j]; j++) {
119                                         tmp[j] = tmp[j + 1];
120                                 }
121                         } else {
122                                 i++;
123                         }
124                 }
125                 G_FREE(list_item->sub_desc);
126                 list_item->sub_desc = (char *)g_strdup(tmp);
127                 G_FREE(tmp);
128                 SETTING_TRACE("sub_desc:[%s]", list_item->sub_desc);
129
130                 elm_entry_entry_set(obj, list_item->sub_desc);
131                 elm_entry_cursor_end_set(obj);
132         }
133 #endif
134         //for genlist update
135         G_FREE(list_item->sub_desc);//release first
136         list_item->sub_desc = (char *)g_strdup(entry_str);
137
138         if (NULL == entry_str || 0 == entry_len) {
139                 if (!ad->empty_flag)
140                 {
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);
145                         if (navi_it)
146                         {
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);
150
151                                 Evas_Object *top_r_btn = elm_object_item_part_content_get(navi_it, "title_right_btn");
152                                 if(top_r_btn)
153                                 {
154                                         setting_disable_evas_object(top_r_btn);
155                                         setting_dim_evas_object(top_r_btn, TRUE);
156                                 }
157                         }
158                 }
159         } else {
160                 if (ad->empty_flag)
161                 {
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);
166                         if (navi_it)
167                         {
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);
171
172                                 Evas_Object *top_r_btn = elm_object_item_part_content_get(navi_it, "title_right_btn");
173                                 if(top_r_btn)
174                                 {
175                                         setting_enable_evas_object(top_r_btn);
176                                         setting_undo_dim_evas_object(top_r_btn, TRUE);
177                                 }
178                         }
179                 }
180         }
181
182 }
183
184 static void
185 __setting_about_device_name_changed_cb(void *data, Evas_Object *obj,
186                                        void *event_info)
187 {
188         __device_name_changed_cb(data, obj);
189 }
190
191
192 /**
193  *      Model Name:
194  *              - No ini: Unavailable
195  *              - I9500 @ target: GT-I9500
196  *              - I9500 @ emul: SDK
197  *              - SLP   @ target: GT-SLP
198  *              - SLP   @ emul: SDK
199  */
200 void setting_about_main_get_phone_model_name(char* szStr, int nSize)
201 {
202         retm_if(szStr == NULL, "szStr parameter is NULL");
203
204         char *value = 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");
209                 FREE(value);
210                 snprintf(szStr, nSize, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
211                 return;
212         }
213
214         if (value) {
215                 snprintf(szStr, nSize, "%s", value);
216         } else {
217                 snprintf(szStr, nSize, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
218         }
219
220         FREE(value);
221 }
222
223 void setting_about_main_get_sw_version(char* szStr, int nSize)
224 {
225         retm_if(szStr == NULL, "szStr parameter is NULL");
226
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");
231                 FREE(version);
232                 snprintf(szStr, nSize, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
233                 return;
234         }
235
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");
240                 FREE(version);
241                 FREE(build_info);
242                 snprintf(szStr, nSize, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
243                 return;
244         }
245
246         snprintf(szStr, nSize, "SLP%s (%s)", version, build_info);
247
248         FREE(version);
249         FREE(build_info);
250 }
251
252 void setting_about_main_get_wifi_mac_address_string(char *str, int size)
253 {
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");
256
257         FILE *p = fopen(SETTING_ABOUT_MACINFO_PATH, "r");
258
259         if (p) {
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");
263                 }
264                 fclose(p);
265                 p = NULL;
266         } else {
267                 perror("open failed!");
268         }
269
270         SETTING_TRACE_DEBUG("get_wifi_mac_address : %s", str);
271
272         int wifi_state = VCONFKEY_WIFI_OFF;
273         vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
274
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));
277 }
278
279 void setting_about_main_get_battery_string(char *str, int size)
280 {
281         setting_retm_if(str == NULL, "str parameter is NULL");
282
283         int val = -1;
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");
287
288         char buf[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
289         int fd = 0;
290         int r = 0;
291
292         fd = open(file, O_RDONLY);
293         if (fd != -1) {
294                 r = read(fd, buf, MAX_DISPLAY_STR_LEN_ON_PHONE_INFO);
295                 if ((r >= 0) && (r < MAX_DISPLAY_STR_LEN_ON_PHONE_INFO)) {
296                         buf[r] = '\0';
297                         val = atoi(buf);
298                         snprintf(str, size, "%d%s", val, "\%");
299                 } else {
300                         SETTING_TRACE_ERROR("read file fail");
301                         snprintf(str, size, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
302                 }
303
304                 close(fd);
305         } else {
306                 SETTING_TRACE_ERROR("open file fail");
307                 snprintf(str, size, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
308         }
309 }
310
311 void setting_about_main_get_bluetooth_address_string(char *str, int size)
312 {
313         setting_retm_if(str == NULL, "str parameter is NULL");
314
315         bluetooth_device_address_t local_address;
316         memset(&local_address, 0x0, sizeof(local_address));
317         int ret = 0;
318
319         /* for fixing BS of dbus signal */
320         bluetooth_register_callback(NULL, NULL);
321
322         ret = bluetooth_get_local_address(&local_address);
323
324         /* for fixing BS of dbus signal */
325         bluetooth_unregister_callback();
326
327         if (ret < 0) {
328                 snprintf(str, size, "%s", _("IDS_ST_HEADER_UNAVAILABLE"));
329         } else {
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]);
333         }
334         SETTING_TRACE_DEBUG("bt address : %s", str);
335 }
336
337 int __stat_get_cpuinfo(float *usr_pct, float *sys_pct)
338 {
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");
341
342         /*  default value */
343         *usr_pct = 0.0;
344         *sys_pct = 0.0;
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;
349         long tick_per_sec;
350         long cpu_num;
351         FILE *fp = NULL;
352         int ret = 0;
353
354         tick_per_sec = sysconf(_SC_CLK_TCK);
355         cpu_num = sysconf(_SC_NPROCESSORS_ONLN);
356
357         if (cpu_num < 1)
358                 cpu_num = 1;
359
360         gettimeofday(&cur_tv, NULL);
361         fp = fopen(SETTING_ABOUT_STAT_PATH, "r");
362         if (fp == NULL) {
363                 SETTING_TRACE_ERROR("fp == NULL");
364                 return -ENOENT;
365         }
366
367         char cpu_info[MAX_COMMON_BUFFER_LEN] = {0,};
368         char *cpu_info_p = fgets(cpu_info, MAX_COMMON_BUFFER_LEN, fp);
369
370                 if(cpu_info_p == NULL) {
371                         SETTING_TRACE_ERROR("fgets failed");
372                         fclose(fp);   // free - code
373                         return -ENOENT;
374                 }
375
376         char *substr = NULL;
377         unsigned long long tmp_long = 0;
378         int i = 0;
379         /* split cpu_info, get 3 numbers headmost*/
380         while ((substr = strsep(&cpu_info_p, " \t")) != NULL) {
381                 char* endptr = NULL;
382                 tmp_long = strtoull(substr, &endptr, 10);
383                 if (tmp_long != 0 && tmp_long != ULLONG_MAX) {
384                         switch (i) {
385                         case 0:
386                                 usr_time = tmp_long;
387                                 break;
388                         case 1:
389                                 nice_time = tmp_long;
390                                 break;
391                         case 2:
392                                 sys_time = tmp_long;
393                                 break;
394                         default:
395                                 break;
396                         }
397                         i++;
398                 }
399                 if (i >= 3) {
400                         break;
401                 }
402         }
403
404         fclose(fp);
405         fp = NULL;
406         if (old_usr == 0) {
407                 ret = -EAGAIN;
408                 SETTING_TRACE_ERROR("old_usr == 0");
409                 goto out;
410         }
411
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;
414
415         /* REMOVE BS */
416         if (elapsed_tick != 0)
417                 *usr_pct =
418                     ((float)(usr_time - old_usr) * 100 / elapsed_tick) /
419                     cpu_num;
420         else
421                 *usr_pct = 0;
422         /* REMOVE BS */
423         if (elapsed_tick != 0)
424                 *sys_pct =
425                     ((float)(sys_time - old_sys) * 100 / elapsed_tick) /
426                     cpu_num;
427         else
428                 *sys_pct = 0;
429
430  out:
431         old_usr = usr_time;
432         old_nice = nice_time;
433         old_sys = sys_time;
434         old_tv = cur_tv;
435
436         return ret;
437 }
438
439 static Eina_Bool __timer_update_cb(const void *data)
440 {
441         retv_if(data == NULL, TRUE);
442         SettingAboutUG *ad = (SettingAboutUG *) data;
443
444         char str[MAX_DISPLAY_STR_LEN_ON_PHONE_INFO] = { 0, };
445         if (ad->item_data_cpu) {
446                 float usr, sys;
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"));
451                 } else {
452                         snprintf(str, sizeof(str), "%.0f%s", usr + sys, "\%");
453                 }
454
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);
458         }
459
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);
466         }
467         return TRUE;
468 }
469
470 static void
471 __about_main_gl_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event)
472 {
473         ret_if(!data);
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;
477
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..
481                         return;
482
483                 elm_object_focus_set(ad->item_dev_name->eo_check, EINA_FALSE);//to make inputing words input
484         }
485 }
486
487 static void __entry_unfocus_cb(void *data, Evas_Object *obj, void *event_info)
488 {
489         SETTING_TRACE_BEGIN;
490         retm_if(!data || !obj, "Data parameter is NULL");
491
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");
499         }
500
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);
507
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 #if 0
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);
516 #endif
517
518         if(ad->navi_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);
522         }
523         setting_hide_input_pannel_cb(item_dev_name->eo_check);
524         if (item_dev_name) {
525                 if (ad->empty_flag) {
526                         if (ad->popup) {
527                                 evas_object_del(ad->popup);
528                                 ad->popup = NULL;
529                         }
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);
532                         return;
533                 } else {
534                 }
535         }
536
537
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);
541         }
542
543         FREE(entry_str_utf8);
544
545 }
546
547 static void __entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
548 {
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)
554         {
555                 // if entry has 1 char at list, hide ime.
556                 if(safeStrLen(elm_entry_entry_get(obj)) == 0)
557                 {
558                         if (ad->popup) {
559                                 evas_object_del(ad->popup);
560                                 ad->popup = NULL;
561                         }
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);
564                 }
565         }
566 }
567
568 int setting_about_generate_genlist(void *data)
569 {
570         SETTING_TRACE_BEGIN;
571         /* error check */
572         retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
573
574         SettingAboutUG *ad = (SettingAboutUG *) data;
575         bool is_emul_bin = isEmulBin();
576
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);
584         /* Device name */
585         char *name_value = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
586         char *pa_sub_desc = elm_entry_utf8_to_markup(name_value);
587         FREE(name_value);
588
589         ad->empty_flag = FALSE;
590         if (NULL == pa_sub_desc || '\0' == pa_sub_desc[0])
591         {
592                 ad->empty_flag = TRUE;
593                 Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
594                 if (navi_it)
595                 {
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);
599                 }
600         }
601
602
603         // [UI] Device name
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 )
607         {
608                 SETTING_TRACE(">>>>>>>>>>>>>>>>>> UNINSTALLED PACKAGE");
609                 ad->item_dev_name = NULL;
610         } else {
611
612                 ad->item_dev_name =
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));
624
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;
630                         }
631                         //ad->item_dev_name->input_type = ELM_INPUT_PANEL_LAYOUT_NUMBER;
632                         ad->item_dev_name->input_panel_disable_flag = EINA_TRUE;
633                 } else {
634                                 SETTING_TRACE_ERROR("ad->item_dev_name is NULL");
635                 }
636                 FREE(pa_sub_desc);
637         }
638
639         // [UI] My number
640         int err;
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);
643
644         if (ad->my_numbers.count == 1) {
645                 item_data =
646                         setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2),
647                                              NULL,
648                                              ad, SWALLOW_Type_INVALID, NULL,
649                                              NULL, 0, SETTING_ABOUT_MY_NUMBER_STR,
650                                              sel_num, NULL);
651                 if (item_data) {
652                         elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
653                 } else {
654                         SETTING_TRACE_ERROR("item_data is NULL");
655                 }
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),
661                                                     NULL, NULL,
662                                                     SWALLOW_Type_INVALID,
663                                                     SETTING_ABOUT_MY_NUMBER_STR,
664                                                     sel_num);
665                 if (item_data) {
666                         item_data->int_slp_setting_binded = STR_SLP_SETTING_SELECT_NUM;
667                 } else {
668                         SETTING_TRACE_ERROR("ad->data_wap is NULL");
669                 }
670
671         } else {
672                 SETTING_TRACE_ERROR("don't have my number");
673         }
674
675         // [UI] Phone model
676         memset(str, 0x00, sizeof(str));
677         setting_about_main_get_phone_model_name(str, sizeof(str));
678         item_data =
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);
682         if (item_data) {
683                 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
684         } else {
685                 SETTING_TRACE_ERROR("item_data is NULL");
686         }
687
688         // [UI] SW version
689         memset(str, 0x00, sizeof(str));
690         setting_about_main_get_sw_version(str, sizeof(str));
691         item_data =
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);
695         if (item_data) {
696                 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
697         } else {
698                 SETTING_TRACE_ERROR("item_data is NULL");
699         }
700
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));
705                 ad->item_data_bt =
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);
711                 } else {
712                                 SETTING_TRACE_ERROR("item_data is NULL");
713                 }
714         }
715
716         // [UI] MAC address
717         memset(str, 0x00, sizeof(str));
718         setting_about_main_get_wifi_mac_address_string(str, sizeof(str));
719
720         SETTING_TRACE_DEBUG("[about main] get_wifi_mac_address : %s", str);
721
722         ad->item_data_wifi =
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);
728         } else {
729                 SETTING_TRACE_ERROR("item_data is NULL");
730         }
731
732         // [UI] Battery
733         memset(str, 0x00, sizeof(str));
734         setting_about_main_get_battery_string(str, sizeof(str));
735         item_data =
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);
739         if (item_data) {
740                 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
741                 ad->item_data_battery = item_data;
742         } else {
743                 SETTING_TRACE_ERROR("item_data is NULL");
744         }
745
746         // [UI] CPU Info
747         memset(str, 0x00, sizeof(str));
748         float usr, sys;
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"));
753         } else {
754                 snprintf(str, sizeof(str), "%.0f%s", usr + sys, "\%");
755         }
756
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);
761         if (item_data) {
762                 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
763         } else {
764                 SETTING_TRACE_ERROR("item_data is NULL");
765         }
766
767         // [UI] separator
768         item =
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);
772
773 #ifdef SUPPORT_DIAG_USAGE
774         // [UI] Diagnostics and Usage
775         if (!is_emul_bin) {
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,
780                                          NULL, NULL);
781         }
782 #endif
783
784         // [UI] Certificates
785         // implementation is in progress.
786         if (is_ug_installed_by_ug_args("setting-manage-applications-efl"))
787         {
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);
792
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);
796         }
797
798
799         ad->update_timer =
800             ecore_timer_add(2, (Ecore_Task_Cb) __timer_update_cb, ad);
801
802         return SETTING_RETURN_SUCCESS;
803 }
804
805 static int setting_about_main_create(void *cb)
806 {
807         SETTING_TRACE_BEGIN;
808         /* error check */
809         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
810
811         SettingAboutUG *ad = (SettingAboutUG *) cb;
812
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 */
818
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;
826
827         ad->ly_main =
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);
834
835         evas_object_event_callback_add(scroller, EVAS_CALLBACK_MOUSE_UP,
836                                        __about_main_gl_mouse_up, ad);
837
838         ad->navi_item = elm_naviframe_top_item_get(ad->navi_bar);
839
840         setting_about_generate_genlist((void *)ad);
841
842         setting_view_about_main.is_create = 1;
843         SETTING_TRACE_END;
844         return SETTING_RETURN_SUCCESS;
845 }
846
847 static int setting_about_main_destroy(void *cb)
848 {
849         SETTING_TRACE_BEGIN;
850         /* error check */
851         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
852
853         SettingAboutUG *ad = (SettingAboutUG *) cb;
854
855         if (ad->update_timer) {
856                 ecore_timer_del(ad->update_timer);
857                 ad->update_timer = NULL;
858         }
859         if (ad->popup) {
860                 evas_object_del(ad->popup);
861                 ad->popup = NULL;
862         }
863
864         if (ad->ly_main != NULL) {
865                 evas_object_del(ad->ly_main);
866                 ad->ly_main = NULL;
867         }
868
869         setting_view_about_main.is_create = 0;
870         return SETTING_RETURN_SUCCESS;
871 }
872
873 static int setting_about_main_update(void *cb)
874 {
875         SETTING_TRACE_BEGIN;
876         /* error check */
877         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
878
879         SettingAboutUG *ad = (SettingAboutUG *) cb;
880
881         if (ad->ly_main != NULL) {
882                 evas_object_show(ad->ly_main);
883         }
884
885         return SETTING_RETURN_SUCCESS;
886 }
887
888 static int setting_about_main_cleanup(void *cb)
889 {
890         SETTING_TRACE_BEGIN;
891         /* error check */
892         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
893
894         SettingAboutUG *ad = (SettingAboutUG *) cb;
895
896         if (ad->ly_main != NULL) {
897                 /*  evas_object_hide(ad->ly_main); */
898         }
899
900         return SETTING_RETURN_SUCCESS;
901 }
902
903 /* ***************************************************
904  *
905  *general func
906  *
907  ***************************************************/
908
909 /* ***************************************************
910  *
911  *call back func
912  *
913  ***************************************************/
914
915 static void
916 setting_about_main_click_softkey_back_cb(void *data, Evas_Object *obj,
917                                          void *event_info)
918 {
919         SETTING_TRACE_BEGIN;
920         /* error check */
921         setting_retm_if(data == NULL, "Data parameter is NULL");
922
923         SettingAboutUG *ad = (SettingAboutUG *) data;
924         if (ad->empty_flag) {
925                 if (ad->popup) {
926                         evas_object_del(ad->popup);
927                         ad->popup = NULL;
928                 }
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);
933                 }
934                 return;
935         }
936
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);
945         }
946
947         SETTING_TRACE_END;
948 }
949
950 /**
951 * @brief
952 *
953 * @param data
954 * @param obj
955 * @param event_info
956 */
957 static void
958 setting_about_main_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj,
959                                             void *event_info)
960 {
961         SETTING_TRACE_BEGIN;
962         /* error check */
963         setting_retm_if(data == NULL, "Data parameter is NULL");
964
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);
969
970         /* SettingAboutUG *ad = (SettingAboutUG *) data; */
971
972         SETTING_TRACE("clicking item[%s]", _(list_item->keyStr));
973         if (!safeStrCmp("IDS_ST_BODY_OPEN_SOURCE_LICENCES", list_item->keyStr)) {
974
975                 //setting_view_change(&setting_view_about_main, &setting_view_about_licences, data);
976
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);
983         }
984 }
985
986 static void __destroy_certificates_ug_cb(ui_gadget_h ug, void *priv)
987 {
988         SETTING_TRACE_BEGIN;
989
990         /* restore the '<-' button on the navigate bar */
991         ret_if(!priv);
992         SettingAboutUG *ad = (SettingAboutUG *) priv;   /* ad is point to priv */
993
994         if (ug) {
995                 ug_destroy(ug);
996                 ad->ug_loading = NULL;
997         }
998
999 }
1000
1001 static void __setting_about_main_certificates_clicked(void *data)
1002 {
1003         SETTING_TRACE_BEGIN;
1004         retm_if(data == NULL, "Data parameter is NULL");
1005         SettingAboutUG *ad = (SettingAboutUG *)data;
1006
1007         struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
1008         if (!cbs) {
1009                 return;
1010         }
1011
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;
1016
1017         ad->ug_loading =
1018             ug_create(ad->ug, "setting-manage-certificates-efl", UG_MODE_FULLVIEW, NULL, cbs);
1019
1020         if (NULL == ad->ug_loading) {   /* error handling */
1021                 SETTING_TRACE_ERROR("NULL == ad->ug_loading");
1022         }
1023         FREE(cbs);
1024 }
1025
1026 static void __top_back_cb(void *data, Evas_Object *obj,
1027                                          void *event_info)
1028 {
1029         SETTING_TRACE_BEGIN;
1030         /* error check */
1031         setting_retm_if(data == NULL, "Data parameter is NULL");
1032
1033         SettingAboutUG *ad = (SettingAboutUG *) data;
1034
1035         if (ad->item_dev_name)
1036                 setting_hide_input_pannel_cb(ad->item_dev_name->eo_check);
1037
1038         SETTING_TRACE_END;
1039 }
1040
1041 static void _input_panel_event_cb(void *data, Ecore_IMF_Context *ctx, int value)
1042 {
1043         SETTING_TRACE_BEGIN;
1044         retm_if(data == NULL, "Data parameter is NULL");
1045         retm_if(ctx == NULL, "obj parameter is NULL");
1046
1047         SettingAboutUG *ad = (SettingAboutUG *)data;
1048
1049         if(value == ECORE_IMF_INPUT_PANEL_STATE_SHOW)
1050         {
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"))
1053                 {
1054                         Evas_Object *r_button = setting_create_button(ad->navi_bar,
1055                                                                         dgettext("sys_string", "IDS_COM_BODY_BACK"),
1056                                                                         NAVI_BACK_BUTTON_STYLE,
1057                                                                         __top_back_cb,
1058                                                                         ad);
1059                         elm_object_item_part_content_set(ad->navi_item, "title_right_btn", r_button);
1060                 }
1061         }
1062         else if(value == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
1063         {
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);
1068                 }
1069
1070                 if (ad->item_dev_name) {
1071                         elm_object_focus_set(ad->item_dev_name->eo_check, EINA_FALSE);
1072                 }
1073         }
1074 }
1075
1076 static void __setting_about_main_device_name_clicked(void *data, Evas_Object *obj)
1077 {
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;
1082
1083         if (!elm_object_focus_get(obj)) {
1084                 elm_object_focus_set(obj, EINA_TRUE);
1085         }
1086
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);
1091 }
1092
1093
1094 static void __destroy_diagnostics_usage_ug_cb(ui_gadget_h ug, void *priv)
1095 {
1096         SETTING_TRACE_BEGIN;
1097
1098         /* restore the '<-' button on the navigate bar */
1099         ret_if(!priv);
1100         SettingAboutUG *ad = (SettingAboutUG *) priv;   /* ad is point to priv */
1101
1102         if (ug) {
1103                 ug_destroy(ug);
1104                 ad->ug_loading = NULL;
1105         }
1106
1107         Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
1108         ret_if(!navi_it);
1109         Evas_Object *back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
1110
1111         if (back_btn != NULL) {
1112                 elm_object_style_set(back_btn, NAVI_BACK_BUTTON_STYLE); /* take into effect */
1113         }
1114 }
1115
1116 static void __setting_about_main_diagnostics_usage_clicked(void *data, Evas_Object *obj)
1117 {
1118         SETTING_TRACE_BEGIN;
1119         retm_if(data == NULL, "Data parameter is NULL");
1120         SettingAboutUG *ad = (SettingAboutUG *)data;
1121
1122         // create UG
1123         if (!ad)
1124                 return;         /*  do nothing if ad is NULL */
1125
1126         struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
1127         if (!cbs) {
1128                 return;
1129         }
1130
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;
1135
1136         ad->ug_loading =
1137             ug_create(ad->ug, "setting-crash-efl", UG_MODE_FULLVIEW, NULL, cbs);
1138
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));
1142         }
1143         FREE(cbs);
1144 }