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.
23 *@defgroup setting-phone
24 *UG creation code for setting-phone
27 * - event notification
32 #include <setting-phone.h>
33 #include <libxml/xmlmemory.h>
35 #include "unicode/unum.h"
36 #include <iniparser.h>
38 #include <setting-cfg.h>
40 #include <eventsystem.h>
41 #include <system_settings.h>
44 #define UG_MODULE_API __attribute__ ((visibility("default")))
47 #define SETTING_PHONE_EDJ_PATH EDJDIR
48 #define SETTING_PHONE_GENLIST_EDJ_NAME SETTING_PHONE_EDJ_PATH"/setting-genlist.edj"
51 setting_view *__get_phone_view_to_load(app_control_h service)
55 char *viewtype = NULL;
56 app_control_get_extra_data(service, "viewtype", &viewtype);
61 SETTING_TRACE("viewtype:%s", viewtype);
63 if (!safeStrCmp(viewtype, "language")) {
66 app_control_get_extra_data(service, "caller", &caller);
68 setting_view_node_table_register(&setting_view_phone_display_language, NULL);
71 return &setting_view_phone_display_language;
73 setting_view_node_table_register(&setting_view_phone_language_region, NULL);
74 setting_view_node_table_register(&setting_view_phone_display_language,
75 &setting_view_phone_language_region);
76 setting_view_node_table_register(&setting_view_phone_region_format,
77 &setting_view_phone_language_region);
79 return &setting_view_phone_language_region;
81 } else if (!safeStrCmp(viewtype, "license")) {
82 setting_view_node_table_register(&setting_view_phone_license_main, NULL);
84 return &setting_view_phone_license_main;
86 #ifdef ENABLE_TICKER_NOTI
87 else if (!safeStrCmp(viewtype, "notification")) {
88 setting_view_node_table_register(&setting_view_phone_ticker_notification, NULL);
89 setting_view_node_table_register(&setting_view_phone_ticker_notification_details, &setting_view_phone_ticker_notification);
91 return &setting_view_phone_ticker_notification;
94 else if (!safeStrCmp(viewtype, "region")) {
95 setting_view_node_table_register(&setting_view_phone_region_format, NULL);
97 return &setting_view_phone_region_format;
100 return NULL; /* &setting_view_phone_main; */
104 Evas_Object *__get_phone_layout_to_return(app_control_h service, void *priv)
107 SettingPhoneUG *phoneUG = priv;
108 char *viewtype = NULL;
110 app_control_get_extra_data(service, "viewtype", &viewtype);
114 SETTING_TRACE("viewtype:%s", viewtype);
116 if (!safeStrCmp(viewtype, "language")) {
118 return phoneUG->ly_language;
119 } else if (!safeStrCmp(viewtype, "license")) {
121 return phoneUG->ly_license;
122 } else if (!safeStrCmp(viewtype, "notification")) {
124 return phoneUG->ly_ticker;
125 } else if (!safeStrCmp(viewtype, "region")) {
127 return phoneUG->ly_region;
130 return NULL; /* &setting_view_phone_main; */
136 const char *get_language_by_mobile_country_code(char *mcc)
138 const char *simLanguage = NULL;
139 char temp[128] = {0,};
140 Eina_List *elist = NULL;
141 setting_lang_entry *pnode = NULL;
142 Eina_List *langlist = setting_get_language_list();
144 EINA_LIST_FOREACH(langlist, elist, pnode) {
145 if (strstr(pnode->mcc, mcc) != NULL) {
146 snprintf(temp, 127, "%s.UTF-8", pnode->locale);
150 if (safeStrLen(temp) > 0) {
151 simLanguage = (char *)strdup(temp);
152 SETTING_TRACE_DEBUG("simLanguage: %s", simLanguage);
159 static void setting_phone_update_item(void *data)
161 setting_retm_if(data == NULL, "data is NULL");
162 SettingPhoneUG *ad = (SettingPhoneUG *) data;
164 Setting_GenGroupItem_Data *item_to_update = NULL;
166 item_to_update = ad->data_display_language;
167 retm_if(!item_to_update, "ad->data_display_language is NULL");
169 if (item_to_update) {
170 item_to_update->sub_desc = get_pa_display_language_str();
171 elm_object_item_data_set(item_to_update->item, item_to_update);
172 elm_genlist_item_update(item_to_update->item);
175 char *pa_region = vconf_get_str(VCONFKEY_REGIONFORMAT);
176 if (pa_region == NULL) {
178 ("[Error] get value of VCONFKEY_REGIONFORMAT fail.");
182 item_to_update = ad->data_region_fmt;
183 retm_if(!item_to_update, "ad->data_region_fmt is NULL");
185 if (item_to_update) {
186 int region_automatic = 1;
187 int ret = vconf_get_bool(VCONFKEY_SETAPPL_REGION_AUTOMATIC_BOOL, ®ion_automatic);
188 if (ret == VCONF_ERROR) {
189 SETTING_TRACE_ERROR("get vconf region automatic err.");
192 if (region_automatic == 1) {
193 item_to_update->sub_desc = (char *)g_strdup(_("IDS_ST_BODY_ANSWERINGMODE_AUTOMATIC"));
195 item_to_update->sub_desc = setting_phone_lang_get_region_str(pa_region);
197 item_to_update->keyStr = (char *)g_strdup(_(REGION_FORMAT_LOWER));
198 elm_object_item_data_set(item_to_update->item, item_to_update);
199 elm_genlist_item_update(item_to_update->item);
202 if (ad->data_region_fmt_example) {
205 setting_phone_lang_get_example_desc(pa_region, ad);
206 ad->data_region_fmt_example->keyStr =
207 (char *)g_strdup(example_desc);
209 elm_object_item_data_set(ad->data_region_fmt_example->item, ad->data_region_fmt_example);
210 elm_genlist_item_update(ad->data_region_fmt_example->item);
216 char *setting_phone_lang_get_region_str(const char *region)
219 setting_retvm_if(region == NULL, NULL, "region parameter is NULL");
220 const char *localeID = NULL;
221 UChar displayname[SETTING_STR_SLP_LEN] = { 0, };
222 UErrorCode status = U_ZERO_ERROR;
223 char *ret_str = NULL;
225 const char *pa_lang = vconf_get_str(VCONFKEY_LANGSET);
227 char *q = strchr(pa_lang, '.');
231 SETTING_TRACE("pa_lang:%s", pa_lang);
233 uloc_setDefault(pa_lang, &err);
234 free((void *)pa_lang);
237 SETTING_TRACE_ERROR("get vconf failed");
240 localeID = uloc_getDefault();
241 uloc_getDisplayName(region, localeID, displayname, SETTING_STR_SLP_LEN,
244 char *str_displayname = setting_phone_lang_str_to_utf8(displayname);
245 if (str_displayname == NULL) {
246 SETTING_TRACE("Get displayname in utf8 failed");
251 char source[256] = {0,};
252 UChar dest[256] = {0,};
253 if (strlen(str_displayname) < 256) {
254 strcpy(source, str_displayname);
256 FREE(str_displayname);
259 u_strFromUTF8(dest, 256, &len, source, 256, &errcode);
260 u_strToUpper(dest, 1, dest, 1, "", &errcode);
261 u_strToUTF8(source, 256, NULL, dest, 256, &errcode);
262 ret_str = (char *)g_strdup(source);
264 FREE(str_displayname);
269 * Change language string to UTF8 format, the invoker need to free the return string
271 * @param unichars The source string will be translated.
273 * @return UTF8 format string.
275 char *setting_phone_lang_str_to_utf8(const UChar *unichars)
277 retv_if(unichars == NULL, NULL);
282 UErrorCode status = U_ZERO_ERROR;
284 len = u_strlen(unichars);
285 len_str = sizeof(char)*4*(len+1);
286 str = (char *)calloc(1, len_str);
291 u_strToUTF8(str, len_str, &len_utf8, unichars, len, &status);
295 char *setting_phone_lang_get_by_pattern(const char *locale, const char *skeleton, void *data)
297 setting_retvm_if(!locale, NULL, "locale parameter is NULL");
298 setting_retvm_if(data == NULL, NULL, "Data parameter is NULL");
300 SettingPhoneUG *ad = (SettingPhoneUG *) data;
302 /*remove ".UTF-8" in locale */
303 char locale_tmp[32] = {0,};
304 if (strlen(locale) < 32) {
305 strcpy(locale_tmp, locale);
309 char *p = safeStrStr(locale_tmp, ".UTF-8");
314 char *ret_str = NULL;
315 UChar customSkeleton[SETTING_STR_SLP_LEN] = { 0, };
316 UErrorCode status = U_ZERO_ERROR;
317 UDateFormat *formatter = NULL;
319 UChar bestPattern[SETTING_STR_SLP_LEN] = { 0, };
320 UChar formatted[SETTING_STR_SLP_LEN] = { 0, };
322 char bestPatternString[SETTING_STR_SLP_LEN] = { 0, };
323 char formattedString[SETTING_STR_SLP_LEN] = { 0, };
325 u_uastrncpy(customSkeleton, skeleton, safeStrLen(skeleton));
327 if (ad->pattern_generator == NULL
328 || safeStrCmp(locale_tmp, ad->prev_locale) != 0) {
329 if (ad->pattern_generator != NULL) {
330 udatpg_close(ad->pattern_generator);
331 ad->pattern_generator = NULL;
333 ad->pattern_generator = udatpg_open(locale_tmp, &status);
336 int32_t bestPatternCapacity =
337 (int32_t)(sizeof(bestPattern) / sizeof((bestPattern)[0]));
338 (void)udatpg_getBestPattern(ad->pattern_generator, customSkeleton,
339 u_strlen(customSkeleton), bestPattern,
340 bestPatternCapacity, &status);
342 u_austrcpy(bestPatternString, bestPattern);
343 SETTING_TRACE("BestPattern is %s", bestPatternString);
345 UDate date = ucal_getNow();
347 udat_open(UDAT_IGNORE, UDAT_IGNORE, locale_tmp, NULL, -1, bestPattern,
349 int32_t formattedCapacity =
350 (int32_t)(sizeof(formatted) / sizeof((formatted)[0]));
351 (void)udat_format(formatter, date, formatted, formattedCapacity, NULL,
353 u_austrcpy(formattedString, formatted);
354 SETTING_TRACE("DATE & TIME is %s", formattedString);
356 udat_close(formatter);
358 ret_str = g_strdup(formattedString);
363 static char *__setting_phone_number_format_get(const char *region)
366 setting_retvm_if(region == NULL, NULL, "region parameter is NULL");
367 UNumberFormat *fmt = NULL;
368 UErrorCode status = U_ZERO_ERROR;
369 char decimal[MAX_DISPLAY_NAME_LEN_ON_UI] = { 0 };
370 char separator[MAX_DISPLAY_NAME_LEN_ON_UI] = { 0 };
372 char separator_ch = 0;
373 UChar u_decimal[MAX_DISPLAY_NAME_LEN_ON_UI] = { 0 };
374 UChar u_thousand[MAX_DISPLAY_NAME_LEN_ON_UI] = { 0 };
375 fmt = unum_open(UNUM_DEFAULT, NULL, -1, region, NULL, &status);
376 unum_getSymbol(fmt, UNUM_DECIMAL_SEPARATOR_SYMBOL, u_decimal, MAX_DISPLAY_NAME_LEN_ON_UI, &status);
377 u_austrcpy(decimal, u_decimal);
378 unum_getSymbol(fmt, UNUM_GROUPING_SEPARATOR_SYMBOL, u_thousand, MAX_DISPLAY_NAME_LEN_ON_UI, &status);
379 u_austrcpy(separator, u_thousand);
381 int len_seq = safeStrLen(separator);
382 decimal_ch = decimal[0];
383 separator_ch = separator[0];
384 if (len_seq == 2 || len_seq == 0) {
387 if (len_seq == 3 && !safeStrCmp(separator, "\xe2\x80\x99")) {
391 len_seq = safeStrLen(decimal);
392 if (len_seq == 2 || len_seq == 0) {
395 SETTING_TRACE("separator, decimal = %c, %c", separator_ch, decimal_ch);
400 char loc_number[MAX_DISPLAY_NAME_LEN_ON_UI] = {0,};
401 snprintf(loc_number, sizeof(loc_number), "1%c234%c567%c89", separator_ch, separator_ch, decimal_ch);
402 SETTING_TRACE("loc_number = %s", loc_number);
403 return g_strdup(loc_number); /* should be freed by caller */
409 static char *__setting_phone_number_format_get(const char *region)
411 setting_retvm_if(region == NULL, NULL, "region parameter is NULL");
412 UNumberFormat *fmt = NULL;
413 UErrorCode status = U_ZERO_ERROR;
414 UChar number_uchar[MAX_DISPLAY_NAME_LEN_ON_UI] = {0,};
415 char number_char[MAX_DISPLAY_NAME_LEN_ON_UI] = {0,};
416 double example_number = 1234567.89;
418 fmt = unum_open(UNUM_DEFAULT, NULL, -1, region, NULL, &status);
419 unum_formatDouble(fmt, example_number, number_uchar, MAX_DISPLAY_NAME_LEN_ON_UI, NULL, &status);
420 u_austrcpy(number_char, number_uchar);
421 SETTING_TRACE("number_char = %s", number_char);
424 return g_strdup(number_char); /* should be freed by caller */
429 static char *__setting_phone_number_format_get(const char *region)
432 struct lconv *locale = NULL;
433 char *decimal = NULL;
434 char *separator = NULL;
436 char separator_ch = 0;
438 locale = localeconv();
439 SETTING_TRACE("check localeconv");
440 decimal = locale->decimal_point;
441 separator = locale->thousands_sep;
442 int len_seq = safeStrLen(separator);
443 decimal_ch = decimal[0];
444 separator_ch = separator[0];
445 if (len_seq == 2 || len_seq == 0) {
448 SETTING_TRACE("separator, decimal = %c, %c", separator_ch, decimal_ch);
451 char loc_number[MAX_DISPLAY_NAME_LEN_ON_UI] = {0,};
452 snprintf(loc_number, sizeof(loc_number), "1%c234%c567%c89", separator_ch, separator_ch, decimal_ch);
453 SETTING_TRACE("loc_number = %s", loc_number);
454 return g_strdup(loc_number); /* should be freed by caller */
458 char *setting_phone_lang_get_example_desc(const char *region, void *data)
460 setting_retvm_if(region == NULL, NULL, "region parameter is NULL");
461 setting_retvm_if(data == NULL, NULL, "Data parameter is NULL");
462 char *date = setting_phone_lang_get_by_pattern(region,
463 UDAT_YEAR_MONTH_WEEKDAY_DAY,
466 enum appcore_time_format timeformat = APPCORE_TIME_FORMAT_12;
467 int ret = appcore_get_timeformat(&timeformat);
469 SETTING_TRACE_ERROR("call appcore_get_timeformat fail.");
470 timeformat = APPCORE_TIME_FORMAT_12;
473 char *time_skeleton = "hhmm";
474 if (timeformat == APPCORE_TIME_FORMAT_24) {
475 time_skeleton = "HHmm";
478 /*char *region_jp = vconf_get_str(VCONFKEY_REGIONFORMAT); */
481 /*if (safeStrStr(region_jp, "ja_JP") == NULL) { */
482 time = setting_phone_lang_get_by_pattern(region, time_skeleton, data);
484 time = setting_phone_lang_get_by_pattern("en_GB.UTF-8", time_skeleton, data);
487 char *number = __setting_phone_number_format_get(region);
489 Eina_Strbuf *temp_str = eina_strbuf_new();
490 char *r_str_text = NULL;
491 eina_strbuf_append_printf(temp_str,
492 "%s", _("IDS_ST_BODY_REGIONAL_EXAMPLE"));
493 eina_strbuf_append_printf(temp_str, "<br>%s : %s", _("IDS_ST_BODY_DATE"), date);
494 eina_strbuf_append_printf(temp_str, "<br>%s : %s", _("IDS_ST_HEADER_TIME"), time);
495 eina_strbuf_append_printf(temp_str, "<br>%s : %s", _("IDS_ST_BODY_NUMBER"), number);
497 SETTING_TRACE("temp_str: %s", temp_str);
498 r_str_text = eina_strbuf_string_steal(temp_str);
499 /* eina_strbuf_string_free(temp_str); */
500 eina_strbuf_free(temp_str);
501 SETTING_TRACE("r_str_text: %s", r_str_text);
506 return r_str_text; /* will be freed in calling place */
510 static void setting_phone_ug_cb_resize(void *data, Evas *e, Evas_Object *obj,
513 SettingPhoneUG *ad = (SettingPhoneUG *) data;
514 /* setting_view_update(&setting_view_about_main, ad); */
515 setting_view_update(ad->view_to_load, ad);
518 static void *setting_phone_ug_on_create(ui_gadget_h ug, enum ug_mode mode,
519 app_control_h service, void *priv)
521 setting_retvm_if((!priv), NULL, "!priv");
523 SettingPhoneUG *phoneUG = priv;
526 phoneUG->win_main_layout = (Evas_Object *) ug_get_parent_layout(ug);
527 phoneUG->win_get = (Evas_Object *) ug_get_window();
528 evas_object_show(phoneUG->win_main_layout);
529 phoneUG->evas = evas_object_evas_get(phoneUG->win_main_layout);
531 setting_retvm_if(phoneUG->win_main_layout == NULL, NULL,
532 "cannot get main window ");
534 /* --------------------------------------------------------- */
535 char *pa_path = NULL;;
537 /*elm_theme_extension_add(NULL, SETTING_PHONE_GENLIST_EDJ_NAME); */
539 pa_path = vconf_get_str(VCONFKEY_LANGSET);
542 ("%s*** language setting has no proper value (nil) ***%s",
543 SETTING_FONT_BGREEN, SETTING_FONT_BLACK);
547 bindtextdomain(SETTING_PACKAGE, SETTING_LOCALEDIR);
549 /* --------------------------------------------------------- */
552 int ret = setting_get_int_slp_key(INT_SLP_SETTING_SIM_SLOT, &value, &err);
554 SETTING_TRACE("fail to get vconf");
556 if (value == VCONFKEY_TELEPHONY_SIM_INSERTED) {
557 phoneUG->handle = tel_init(NULL);
558 SETTING_TRACE("phoneUG->handle:%d", phoneUG->handle);
559 memset(&(phoneUG->imsi), 0, sizeof(TelSimImsiInfo_t));
561 && TAPI_API_SUCCESS == tel_get_sim_imsi(phoneUG->handle, &(phoneUG->imsi))) {
562 SETTING_TRACE_SECURE_DEBUG("********************************************");
563 SETTING_TRACE_SECURE_DEBUG("imsi.szMcc: [%s]", phoneUG->imsi.szMcc);
564 SETTING_TRACE_SECURE_DEBUG("imsi.szMnc: [%s]", phoneUG->imsi.szMnc);
565 SETTING_TRACE_SECURE_DEBUG("imsi.szMsin: [%s]", phoneUG->imsi.szMsin);
566 SETTING_TRACE_SECURE_DEBUG("********************************************");
568 phoneUG->sim_lang = get_language_by_mobile_country_code(phoneUG->imsi.szMcc);
571 if (!phoneUG->sim_lang) {
572 /* if CSC has updated configuration for setting, initial vconf value changes. */
573 phoneUG->sim_lang = vconf_get_str(VCONFKEY_LANGSET); /* allocated */
575 SETTING_TRACE("sim_lang: [%s]", phoneUG->sim_lang);
577 /* register view node table */
578 setting_view_node_table_intialize();
580 setting_create_Gendial_itc(SETTING_GENLIST_ICON_1LINE_STYLE, &(phoneUG->itc_1text_1icon_2));
581 setting_create_Gendial_itc(SETTING_GENLIST_ICON_1LINE_STYLE, &(phoneUG->itc_1text_1icon));
582 setting_create_Gendial_itc(SETTING_GENLIST_ICON_1LINE_STYLE, &(phoneUG->itc_1text_tb));
583 setting_create_Gendial_itc(SETTING_GENLIST_ICON_1LINE_STYLE, &(phoneUG->itc_1text));
584 setting_create_Gendial_itc(SETTING_GENLIST_ICON_1LINE_STYLE, &(phoneUG->itc_1icon_1text_sub));
586 /* 2 text - genlist > items */
587 setting_create_Gendial_itc("dialogue/2text", &(phoneUG->itc_1icon_2text));
588 setting_create_Gendial_itc(SETTING_GENLIST_2LINE_STYLE, &(phoneUG->itc_2text_3_parent));
589 setting_create_Gendial_itc(SETTING_GENLIST_2LINE_STYLE, &(phoneUG->itc_2text_2));
590 setting_create_Gendial_itc("multiline/1text",
591 &(phoneUG->itc_bg_1icon));
592 phoneUG->pattern_generator = NULL;
593 phoneUG->prev_locale = NULL;
594 /* creating a view. */
595 phoneUG->bundle_data = service;
596 phoneUG->view_to_load = __get_phone_view_to_load(service);
597 setting_retvm_if(NULL == phoneUG->view_to_load, NULL,
598 "NULL == phoneUG->view_to_load");
599 setting_view_node_set_cur_view(phoneUG->view_to_load);
600 setting_view_create(phoneUG->view_to_load, (void *)phoneUG);
601 evas_object_event_callback_add(phoneUG->win_main_layout,
602 EVAS_CALLBACK_RESIZE,
603 setting_phone_ug_cb_resize, phoneUG);
604 return __get_phone_layout_to_return(service, phoneUG);
607 static void setting_phone_ug_on_start(ui_gadget_h ug, app_control_h service,
612 static void setting_phone_ug_on_pause(ui_gadget_h ug, app_control_h service,
617 static void setting_phone_ug_on_resume(ui_gadget_h ug, app_control_h service,
622 SettingPhoneUG *phoneUG = priv;
624 Eina_Bool is_freezed = evas_object_freeze_events_get(phoneUG->navi_bar);
625 SETTING_TRACE_DEBUG("is_freezed : %d", is_freezed);
627 evas_object_freeze_events_set(phoneUG->navi_bar, EINA_FALSE);
630 static void setting_phone_ug_on_destroy(ui_gadget_h ug, app_control_h service,
634 setting_retm_if((!ug || !priv), "!ug || !priv");
635 SettingPhoneUG *phoneUG = priv;
637 evas_object_event_callback_del(phoneUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_phone_ug_cb_resize); /* fix flash issue for gallery */
640 if (phoneUG->handle && tel_deinit(phoneUG->handle) != TAPI_API_SUCCESS) {
641 SETTING_TRACE_ERROR("tel_deinit failed");
643 /* called when this shared gadget is terminated. similar with app_exit */
644 if (&setting_view_phone_language_region == phoneUG->view_to_load) {
645 setting_view_destroy(&setting_view_phone_display_language,
647 setting_view_destroy(&setting_view_phone_region_format,
649 setting_view_destroy(&setting_view_phone_language_region, phoneUG);
651 #ifdef ENABLE_TICKER_NOTI
652 else if (&setting_view_phone_ticker_notification ==
653 phoneUG->view_to_load) {
654 setting_view_destroy(&setting_view_phone_ticker_notification,
656 setting_view_destroy(&setting_view_phone_ticker_notification_details, phoneUG);
660 else if (&setting_view_phone_license_main == phoneUG->view_to_load) {
661 setting_view_destroy(&setting_view_phone_license_main, phoneUG);
664 FREE(phoneUG->sim_lang);
666 if (NULL != ug_get_layout(phoneUG->ug)) {
667 evas_object_hide((Evas_Object *) ug_get_layout(phoneUG->ug));
668 evas_object_del((Evas_Object *) ug_get_layout(phoneUG->ug));
674 static void setting_phone_ug_on_message(ui_gadget_h ug, app_control_h msg,
675 app_control_h service, void *priv)
678 setting_retm_if(NULL == priv, "priv is NULL");
679 char *pid_str = NULL;
681 app_control_get_extra_data(msg, "DEADPID", &pid_str);
684 int pid = (int)g_ascii_strtod(pid_str, NULL);
685 SETTING_TRACE_DEBUG("pid = %d", pid);
686 setting_retm_if(errno == ERANGE, "call g_ascii_strtod fail");
688 int ret = app_terminate_dead_cb(pid, priv);
689 setting_retm_if(ret != 0, "call app_terminate_dead_cb fail");
693 static void setting_phone_ug_on_event(ui_gadget_h ug, enum ug_event event,
694 app_control_h service, void *priv)
698 SettingPhoneUG *ad = (SettingPhoneUG *) priv;
700 case UG_EVENT_LOW_MEMORY:
702 case UG_EVENT_LOW_BATTERY:
704 case UG_EVENT_REGION_CHANGE: {
705 if (ad->gl_lang_region && setting_view_phone_language_region.is_create) {
706 elm_genlist_realized_items_update(ad->gl_lang_region);
707 setting_phone_update_item(ad);
711 case UG_EVENT_LANG_CHANGE: {
712 ad->lang_change = EINA_TRUE;
714 if (ad->gl_lang_region && setting_view_phone_language_region.is_create) {
715 elm_genlist_realized_items_update(ad->gl_lang_region);
716 setting_phone_update_item(ad);
719 setting_navi_items_update(ad->navi_bar);
723 case UG_EVENT_ROTATE_PORTRAIT:
725 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
727 case UG_EVENT_ROTATE_LANDSCAPE:
729 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
736 static void setting_phone_ug_on_key_event(ui_gadget_h ug,
737 enum ug_key_event event,
738 app_control_h service, void *priv)
741 SettingPhoneUG *ad = (SettingPhoneUG *) priv;
743 SETTING_TRACE("event:%d", event);
745 case UG_KEY_EVENT_END: {
746 if (elm_naviframe_top_item_get(ad->navi_bar) ==
747 elm_naviframe_bottom_item_get(ad->navi_bar)) {
750 setting_view_cb_at_endKey(ad);
759 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
762 SettingPhoneUG *phoneUG = calloc(1, sizeof(SettingPhoneUG));
763 setting_retvm_if(!phoneUG, -1, "Create SettingPhoneUG obj failed");
765 ops->create = setting_phone_ug_on_create;
766 ops->start = setting_phone_ug_on_start;
767 ops->pause = setting_phone_ug_on_pause;
768 ops->resume = setting_phone_ug_on_resume;
769 ops->destroy = setting_phone_ug_on_destroy;
770 ops->message = setting_phone_ug_on_message;
771 ops->event = setting_phone_ug_on_event;
772 ops->key_event = setting_phone_ug_on_key_event;
774 ops->opt = UG_OPT_INDICATOR_ENABLE;
779 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
782 struct SettingPhoneUG *phoneUG;
783 setting_retm_if(!ops, "ops == NULL");
791 /************* n-depth search **************/
792 static Setting_Cfg_Node_T s_cfg_node_array[] = {
793 {"IDS_ST_HEADER_DISPLAY_LANGUAGE", NULL, "viewtype:language;caller:setting", Cfg_Item_Pos_Level0, 0, 0, Cfg_Item_View_Node, NULL, NULL, NULL, NULL},
794 {"IDS_ST_BODY_REGION", NULL, "viewtype:region", 0, 0, 0, Cfg_Item_View_Node, NULL, NULL, NULL, NULL},
795 {"IDS_ST_BODY_KEYBOARD", NULL, "viewtype:language", 0, 0, 0, Cfg_Item_View_Node, NULL, NULL, NULL, NULL},
799 UG_MODULE_API int setting_plugin_search_init(app_control_h service, void *priv, char **applocale)
802 SETTING_TRACE(">> setting-phone-efl DB search code");
803 setting_retvm_if(!priv || !applocale, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER, "pplist/applocale is NULL");
805 *applocale = strdup("setting:/usr/apps/org.tizen.setting/res/locale");
807 Eina_List **pplist = (Eina_List **)priv;
809 int size = sizeof(s_cfg_node_array) / sizeof(s_cfg_node_array[0]);
810 for (i = 0; i < size; i++) {
811 Setting_Cfg_Node_T *node = setting_plugin_search_item_subindex_add(s_cfg_node_array[i].key_name, s_cfg_node_array[i].ug_args, IMG_LanguageInput, s_cfg_node_array[i].item_type, s_cfg_node_array[i].data, "Language and Region");
812 *pplist = eina_list_append(*pplist, node);
817 int set_language_helper(char *lang)
820 int ret = vconf_set_str(VCONFKEY_LANGSET, lang);
823 /* set event system */
824 setting_set_event_system(SYS_EVENT_LANGUAGE_SET, EVT_KEY_LANGUAGE_SET, lang);
827 int ret = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, lang);
832 int set_regionformat_helper(char *region)
836 int ret = vconf_set_str(VCONFKEY_REGIONFORMAT, region);
838 /* set event system */
839 setting_set_event_system(SYS_EVENT_REGION_FORMAT, EVT_KEY_REGION_FORMAT, region);
842 int ret = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, region);