/* * setting * * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. * * Contact: MyoungJune Park * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include "setting-common-general-func.h" #include "setting-common-data-slp-setting.h" #include #include #include "setting-cfg.h" #include #define EPISLON 10e-5 EXPORT_PUBLIC char *get_application_default_icon(const char *appid) { int ret = 0; char *type = NULL; const char *icon = NULL; pkgmgrinfo_appinfo_h handle = NULL; icon = SETTING_ICON_PATH"/mainmenu.png"; ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle); if (PMINFO_R_OK != ret) { SETTING_TRACE_ERROR("pkgmgrinfo_appinfo_get_appinfo() Fail(%s)", get_error_message(ret)); return strdup(icon); } ret = pkgmgrinfo_appinfo_get_component_type(handle, &type); if (PMINFO_R_OK == ret) { if (0 == safeStrCmp(type, "svcapp")) icon = SETTING_ICON_PATH"/default_icon_service.png"; } else { SETTING_TRACE_ERROR( "pkgmgrinfo_appinfo_get_component_type() Fail(%s)", get_error_message(ret)); } pkgmgrinfo_appinfo_destroy_appinfo(handle); return strdup(icon); } EXPORT_PUBLIC char *setting_file_basename(const char *path) { retv_if(NULL == path || '\0' == path[0], NULL); /* invalid arguement */ char *p = strrchr(path, '/'); if (!p) return (char *)g_strdup(path); /* cannot find '/' */ if ('\0' == p[1]) /* end with '/' */ return NULL; return (char *)g_strdup(p + 1); } EXPORT_PUBLIC char *get_brightness_mode_str() { int value, err; setting_get_int_slp_key(INT_SLP_SETTING_AUTOMATIC_BRIGHTNESS, &value, &err); if (value != SETTING_BRIGHTNESS_AUTOMATIC_OFF) return "IDS_ST_BODY_ANSWERINGMODE_AUTOMATIC"; else return "IDS_ST_BODY_MANUAL"; } EXPORT_PUBLIC char *get_pa_backlight_time_str() { int value = 0; char backlight_time_str[MAX_DISPLAY_NAME_LEN_ON_UI]; #if SUPPORT_LCD_TIMEOUT_KEEPING if (0 != vconf_get_int(VCONFKEY_LCD_TIMEOUT_NORMAL_BACKUP, &value)) { /* value = 600; */ value = 0; /* keep agree with postin file */ vconf_set_int(VCONFKEY_LCD_TIMEOUT_NORMAL_BACKUP, value); } #else int err; int ret = setting_get_int_slp_key(INT_SLP_SETTING_LCD_TIMEOUT_NORMAL, &value, &err); #if NORMAL if (SETTING_RETURN_FAIL == ret || value < 0) { /* file system exceptional handle, eg. * The vconf file lost due to file system. */ /* value = 600; */ value = 0; /* keep agree with postin file */ setting_set_int_slp_key(INT_SLP_SETTING_LCD_TIMEOUT_NORMAL, value, &err); } #else /* for MDM server */ /* adjust value. */ /* if < 15, 15 */ /* if 15 < < 30, 15 */ /* if 30 < < 60, 30 */ /* if 60 < < 120, 60 */ /* if 120 < < 300, 120 */ /* if 300 < < 600, 300 */ /* if > 600, 600 */ if (SETTING_RETURN_FAIL == ret || value < 15) value = 0; else if (value >= 15 && value < 30) value = 15; else if (value >= 30 && value < 60) value = 30; else if (value >= 60 && value < 120) value = 60; else if (value >= 120 && value < 300) value = 120; else if (value >= 300 && value < 600) value = 300; else value = 600; setting_set_int_slp_key(INT_SLP_SETTING_LCD_TIMEOUT_NORMAL, value, &err); #endif #endif switch (value) { case 0: snprintf(backlight_time_str, sizeof(backlight_time_str), "%s", _(KeyStr_Backlight_Always_On)); break; case 15: snprintf(backlight_time_str, sizeof(backlight_time_str), "%s", _(KeyStr_Backlight_15_SEC_STR)); break; case 30: snprintf(backlight_time_str, sizeof(backlight_time_str), "%s", _(KeyStr_Backlight_30_SEC_STR)); break; case 60: snprintf(backlight_time_str, sizeof(backlight_time_str), "%s", _(KeyStr_Backlight_1_MIN_STR)); break; case 120: snprintf(backlight_time_str, sizeof(backlight_time_str), "%s", _(KeyStr_Backlight_2_MIN_STR)); break; case 300: snprintf(backlight_time_str, sizeof(backlight_time_str), "%s", _(KeyStr_Backlight_5_MIN_STR)); break; case 600: snprintf(backlight_time_str, sizeof(backlight_time_str), "%s", _(KeyStr_Backlight_10_MIN_STR)); break; default: snprintf(backlight_time_str, sizeof(backlight_time_str), "%s", _(KeyStr_Backlight_30_SEC_STR)); break; } return (char *)g_strdup(backlight_time_str); } EXPORT_PUBLIC int adjust_backlight_time_value(int value) { /* adjust value. */ /* if < 15, 15 */ /* if 15 < < 30, 15 */ /* if 30 < < 60, 30 */ /* if 60 < < 120, 60 */ /* if 120 < < 300, 120 */ /* if 300 < < 600, 300 */ /* if > 600, 600 */ if (value < 15) value = 0; else if (value >= 15 && value < 30) value = 15; else if (value >= 30 && value < 60) value = 30; else if (value >= 60 && value < 120) value = 60; else if (value >= 120 && value < 300) value = 120; else if (value >= 300 && value < 600) value = 300; else value = 600; return value; } EXPORT_PUBLIC char *get_pa_backlight_time_value_str() { int ret = 0; int value = 0; char backlight_time_str[MAX_DISPLAY_NAME_LEN_ON_UI]; ret = system_settings_get_value_int(SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME , &value); if (ret) SETTING_TRACE_ERROR("Error getting SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME value: %s", get_error_message(ret)); value = adjust_backlight_time_value(value); switch (value) { case 0: snprintf(backlight_time_str, sizeof(backlight_time_str), "%s", _(KeyStr_Backlight_Always_On)); break; case 15: snprintf(backlight_time_str, sizeof(backlight_time_str), "%s", _(KeyStr_Backlight_15_SEC_STR)); break; case 30: snprintf(backlight_time_str, sizeof(backlight_time_str), "%s", _(KeyStr_Backlight_30_SEC_STR)); break; case 60: snprintf(backlight_time_str, sizeof(backlight_time_str), "%s", _(KeyStr_Backlight_1_MIN_STR)); break; case 120: snprintf(backlight_time_str, sizeof(backlight_time_str), "%s", _(KeyStr_Backlight_2_MIN_STR)); break; case 300: snprintf(backlight_time_str, sizeof(backlight_time_str), "%s", _(KeyStr_Backlight_5_MIN_STR)); break; case 600: snprintf(backlight_time_str, sizeof(backlight_time_str), "%s", _(KeyStr_Backlight_10_MIN_STR)); break; default: snprintf(backlight_time_str, sizeof(backlight_time_str), "%s", _(KeyStr_Backlight_30_SEC_STR)); break; } return (char *)g_strdup(backlight_time_str); } EXPORT_PUBLIC char *get_pa_display_language_str() { int ret = SETTING_RETURN_FAIL; int lang_automatic; ret = vconf_get_bool(VCONFKEY_SETAPPL_LANG_AUTOMATIC_BOOL, &lang_automatic); SETTING_TRACE_DEBUG("vconf_get_bool() returns %d", ret); if (lang_automatic == 1) { return (char *)g_strdup(setting_gettext( "IDS_ST_BODY_ANSWERINGMODE_AUTOMATIC")); } else { Eina_List *list = setting_get_language_list(); Eina_List *elist = NULL; const char *locale = NULL; locale = vconf_get_str(VCONFKEY_LANGSET); if (locale == NULL) return g_strdup("Error"); char *q = strchr(locale, '.'); if (q) *q = '\0'; setting_lang_entry *pnode; char *title = NULL; EINA_LIST_FOREACH(list, elist, pnode) { if (strcmp(pnode->locale, locale) == 0) { title = g_strdup(pnode->title); break; } } FREE(locale); return title; } } EXPORT_PUBLIC char *get_pa_time_format_str() { int ret = SETTING_RETURN_FAIL; int value, err; char *format_str[] = { "IDS_ST_BODY_12_HOURS", "IDS_ST_BODY_24_HOURS" }; ret = setting_get_int_slp_key(INT_SLP_SETTING_REGIONFORMAT_TIME1224, &value, &err); /* file system exceptional handle */ setting_retvm_if(SETTING_RETURN_FAIL == ret, NULL, "Failed to get vconf value"); /* scope */ /* value 1:12H 2:24H */ if (value > 0 && value <= 2) { /* 1, 2 */ return (char *)g_strdup(format_str[value - 1]); } else { /* set to 12H compelsery */ return (char *)g_strdup(format_str[0]); } } /** @deprecated */ EXPORT_PUBLIC char *get_pa_date_format_str() { int ret = SETTING_RETURN_FAIL; int value, err; char *format_str[] = { _("IDS_ST_BODY_DDMMYYYY_DOT"), _("IDS_ST_BODY_MM_DD_YYYY_DOT"), _("IDS_ST_BODY_YYYY_MM_DD_DOT"), _("IDS_ST_BODY_YYYY_DD_MM_DOT") }; ret = setting_get_int_slp_key(INT_SLP_SETTING_DATE_FORMAT, &value, &err); /* file system exceptional handle */ setting_retvm_if(SETTING_RETURN_FAIL == ret, NULL, "Failed to get vconf value"); return (char *)g_strdup(format_str[value]); } EXPORT_PUBLIC char *get_pa_select_network() { int ret = 0; int state = 0; char *net_name = NULL; int service_type = VCONFKEY_TELEPHONY_SVCTYPE_SEARCH; if (vconf_get_int(VCONFKEY_TELEPHONY_SVCTYPE, &service_type) != 0) SETTING_TRACE_ERROR("fail to get VCONFKEY_TELEPHONY_SVCTYPE"); if (service_type == VCONFKEY_TELEPHONY_SVCTYPE_NOSVC) return strdup(_("IDS_ST_BODY_NOSERVICE")); if (service_type == VCONFKEY_TELEPHONY_SVCTYPE_EMERGENCY) return strdup(_("IDS_CALL_POP_CALLING_EMERG_ONLY")); if (service_type == VCONFKEY_TELEPHONY_SVCTYPE_SEARCH || service_type == VCONFKEY_TELEPHONY_SVCTYPE_NONE) return strdup(_("IDS_ST_POP_NETWORKSERVICES_SEARCHING")); ret = vconf_get_int(VCONFKEY_TELEPHONY_SPN_DISP_CONDITION, &state); if (ret == 0) { char name[MAX_COMMON_BUFFER_LEN] = { 0, }; const char *kv = NULL; if (state != VCONFKEY_TELEPHONY_DISP_INVALID) { /*counting. */ int i = 0; if (state & VCONFKEY_TELEPHONY_DISP_SPN) { kv = vconf_get_str(VCONFKEY_TELEPHONY_SPN_NAME); g_strlcat(name, kv, MAX_COMMON_BUFFER_LEN); FREE(kv); i++; } if (state & VCONFKEY_TELEPHONY_DISP_PLMN) { if (i != 0) g_strlcat(name, " - ", MAX_COMMON_BUFFER_LEN); kv = vconf_get_str(VCONFKEY_TELEPHONY_NWNAME); g_strlcat(name, kv, MAX_COMMON_BUFFER_LEN); FREE(kv); i++; } net_name = isEmptyStr(name) ? NULL : strdup(name); } } return net_name; } EXPORT_PUBLIC char *setting_gettext(const char *s) { /* fisrt find in app pg */ retv_if(s == NULL, "NULL"); char *p = dgettext(SETTING_PACKAGE, s); /* if not found, find in system pkg */ if (!safeStrCmp(s, p)) p = dgettext(SYSTEM_PACKAGE, s); return p; } /*remove sub string from a parent string */ EXPORT_PUBLIC char *remove_first_substring(const char *parent, const char *pat) { setting_retvm_if(!parent, NULL, "NULL == parent, Exit %s with return NULL", __FUNCTION__); /*to process the case parent pointing to const string */ char *str = strdup(parent); retv_if(!str, NULL); setting_retvm_if(!pat, str, "NULL == pat, Exit %s with return [%s]", __FUNCTION__, str); int idx = 0; int str_len = safeStrLen(str); int pat_len = safeStrLen(pat); setting_retvm_if(pat_len > str_len, str, "patlen[%d] > strlen[%d], Exit %s with return [%s]", pat_len, str_len, __FUNCTION__, str); char *p = NULL; char *q = NULL; for (; idx < str_len; idx++) { if (0 == safeStrNCmp(pat, str + idx, pat_len)) { p = str + idx; q = str + idx + pat_len; while ('\0' != *q) { *p = *q; p++; q++; } *p = '\0'; break; } } /*now str keeps the result string */ SETTING_TRACE("Exit %s with return str:%s", __FUNCTION__, str); return str; } /*return True just when NULL or '\0' */ EXPORT_PUBLIC bool isEmptyStr(const char *str) { if (NULL == str || '\0' == str[0]) return TRUE; return FALSE; } /*return True just when str is NULL, '\0' or all strings made up of spaces */ EXPORT_PUBLIC bool isSpaceStr(const char *str) { while (str) { if (*str != '\0' && *str != ' ') return FALSE; else if (*str == '\0') return TRUE; str++; } return TRUE; } int EXPORT_PUBLIC safeStrCmp(const char *s1, const char *s2) { /* Check NULL value first */ if (isEmptyStr(s1) && isEmptyStr(s2)) return 0; else if (isEmptyStr(s1)) return 1; else if (isEmptyStr(s2)) return SETTING_RETURN_FAIL; return strcmp(s1, s2); } EXPORT_PUBLIC int safeStrNCmp(const char *s1, const char *s2, int len) { /* Check NULL value first */ if (isEmptyStr(s1) && isEmptyStr(s2)) return 0; else if (isEmptyStr(s1)) return 1; else if (isEmptyStr(s2)) return SETTING_RETURN_FAIL; if (0 == len) return 0; return strncmp(s1, s2, len); } EXPORT_PUBLIC char *safeCopyStr(char *dst, const char *src, int maxlen) { if (maxlen < 0) return NULL; if (dst) { int len = 0; if (src) { int temp = (int)safeStrLen(src); len = (temp <= maxlen) ? temp : maxlen; memcpy(dst, src, len); } dst[len] = '\0'; } return dst; } EXPORT_PUBLIC int safeStrLen(const char *str) { if (isEmptyStr(str)) { SETTING_TRACE_DEBUG("string is empty"); return 0; } else { return strlen(str); } } EXPORT_PUBLIC char *safeStrStr(const char *str, const char *strSearch) { if (isEmptyStr(str)) return NULL; return strstr(str, strSearch); } EXPORT_PUBLIC char *safeStrRStr(const char *str, const char *strSearch) { if (isEmptyStr(str)) return NULL; char *ptr = (char *)str; char *last = NULL; while ((ptr = strstr(ptr, strSearch))) { last = ptr; ptr++; } return last; } /* SLP : 1 */ /* not SLP : 0 */ EXPORT_PUBLIC int is_slp_binary() { char *str = NULL; int ret = system_info_get_platform_string( "http://tizen.org/system/build.string", &str); if (ret != SYSTEM_INFO_ERROR_NONE) { SETTING_TRACE_ERROR( "fail to call system_info_get_platform_string"); FREE(str); return 0; } char *pos = str; if (str) { while (*pos++) { if ('_' == *pos) { *pos = '\0'; if (!strncmp(str, "SLP", 3)) { FREE(str); return 1; } } } } FREE(str); return 0; } EXPORT_PUBLIC bool isEmulBin() { char *model_str = NULL; int ret = system_info_get_platform_string("tizen.org/system/model_name", &model_str); if (ret != SYSTEM_INFO_ERROR_NONE) { SETTING_TRACE_ERROR( "fail to call system_info_get_platform_string"); FREE(model_str); return FALSE; } if (0 == safeStrCmp(KeyStr_Emulator, model_str) || 0 == safeStrCmp("EMULATOR", model_str)) { FREE(model_str); return TRUE; } else { FREE(model_str); return FALSE; } } EXPORT_PUBLIC int get_popup_btn_response_type(Evas_Object *obj) { retv_if(obj == NULL, -1); POPUP_BTN_RESPONSE_TYPE rsp_type = POPUP_RESPONSE_CANCEL; char *btn_str = elm_entry_markup_to_utf8(elm_object_text_get(obj)); if (btn_str) { SETTING_TRACE("btn_str:%s", btn_str); if (0 == safeStrCmp(btn_str, _("IDS_CST_BUTTON_CLOSE")) /*KeyStr_Try */ || 0 == safeStrCmp(btn_str, _("IDS_ST_BUTTON_OK")) || 0 == safeStrCmp(btn_str, _("IDS_ST_SK_YES")) || 0 == safeStrCmp(btn_str, _("IDS_ST_BUTTON_STOP")) || 0 == safeStrCmp(btn_str, _("IDS_ST_BUTTON_DISCONNECT")) || 0 == safeStrCmp(btn_str, _("IDS_ST_BODY_USE_MOTION")) || 0 == safeStrCmp(btn_str, _("IDS_ST_TPOP_TRY_AGAIN")) || 0 == safeStrCmp(btn_str, _("IDS_ST_BODY_DELETE")) || 0 == safeStrCmp(btn_str, _("IDS_ST_HEADER_RESET")) || 0 == safeStrCmp(btn_str, _("IDS_ST_SK_FORMAT_ABB")) || 0 == safeStrCmp(btn_str, _("IDS_ST_HEADER_FORMAT_MVERB_ABB")) || 0 == safeStrCmp(btn_str, _("IDS_ST_BUTTON_CONTINUE")) || 0 == safeStrCmp(btn_str, _(KeyStr_Save)) || 0 == safeStrCmp(btn_str, _("IDS_ST_BUTTON_ENABLE")) || 0 == safeStrCmp(btn_str, _("IDS_ST_BUTTON_DISABLE")) || 0 == safeStrCmp(btn_str, _("IDS_ST_BODY_TURN_OFF")) || 0 == safeStrCmp(btn_str, _("IDS_CLD_BUTTON_EXPORT")) || 0 == safeStrCmp(btn_str, _(IDS_ST_BUTTON_UNINSTALL)) || 0 == safeStrCmp(btn_str, _("IDS_SMEMO_BUTTON_IMPORT")) || 0 == safeStrCmp(btn_str, _("IDS_ST_HEADER_CLEAR_CACHE_ABB")) || 0 == safeStrCmp(btn_str, _("IDS_MTTRL_BUTTON_ENABLE_MOTION")) /* The below 'Add switch' label must be substituted with valid localization tag * once it is defined */ || 0 == safeStrCmp(btn_str, _("Add switch"))) { rsp_type = POPUP_RESPONSE_OK; } else { /*for others, */ rsp_type = POPUP_RESPONSE_CANCEL; } FREE(btn_str); } else { rsp_type = POPUP_RESPONSE_INVALID; } FREE(btn_str); return rsp_type; } /** * [API] internal API (system-settings) * should use g_free to free return string * @see font_size_set() * REFACTORING: */ EXPORT_PUBLIC char *cur_font_get() { /*SETTING_TRACE_BEGIN; */ char *font_name = NULL; int retcode = system_settings_get_value_string( SYSTEM_SETTINGS_KEY_FONT_TYPE, &font_name); if (SYSTEM_SETTINGS_ERROR_NONE != retcode) return NULL; return font_name; } EXPORT_PUBLIC char *cur_font_family_get() { char *ret = cur_font_get(); if (ret && !safeStrCmp(ret, "Default")) { free(ret); return _get_default_font(); } return ret; } /** * [API] system-settings * @see font_size_set() */ static int __font_size_get() { int font_size = -1; int value = -1; int err = -1; int ret = setting_get_int_slp_key( INT_SLP_SETTING_ACCESSIBILITY_FONT_SIZE, &value, &err); retvm_if(ret != 0, -1, "get vconf failed"); switch (value) { case SYSTEM_SETTINGS_FONT_SIZE_SMALL: font_size = SMALL_FONT_DPI; break; case SYSTEM_SETTINGS_FONT_SIZE_NORMAL: font_size = MIDDLE_FONT_DPI; break; case SYSTEM_SETTINGS_FONT_SIZE_LARGE: font_size = LARGE_FONT_DPI; break; case SYSTEM_SETTINGS_FONT_SIZE_HUGE: font_size = HUGE_FONT_DPI; break; case SYSTEM_SETTINGS_FONT_SIZE_GIANT: font_size = GIANT_FONT_DPI; break; default: font_size = MIDDLE_FONT_DPI; break; } return font_size; } EXPORT_PUBLIC char *_get_default_font() { char *ret = NULL; int err = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_DEFAULT_FONT_TYPE, &ret); if (err != TIZEN_ERROR_NONE) { SETTING_TRACE_ERROR("system_settings_get_value_string failed for SYSTEM_SETTINGS_KEY_DEFAULT_FONT_TYPE: %s", get_error_message(err)); return NULL; } return ret; } /** * @see setting_font_font_size_list_mouse_up_cb */ EXPORT_PUBLIC void font_size_set() { SETTING_TRACE_BEGIN; Eina_List *text_classes = NULL; Elm_Text_Class *etc = NULL; const Eina_List *l = NULL; int font_size = __font_size_get(); char *font_name = cur_font_get(); if (font_size == -1) { SETTING_TRACE_DEBUG("failed to call font_size_get"); return; } /* update all screen */ text_classes = elm_config_text_classes_list_get(); EINA_LIST_FOREACH(text_classes, l, etc) { elm_config_font_overlay_set(etc->name, font_name, font_size); } elm_config_all_flush(); elm_config_save(); elm_config_text_classes_list_free(text_classes); text_classes = NULL; G_FREE(font_name); SETTING_TRACE_END; } /*example 1: app_launcher("setting-myaccount-efl|mode:account_list"); */ /*example 2: app_launcher("emergency-msg-setting-efl"); */ /*example 3: app_launcher( * "sevenemail-setting-efl|caller:setting;cmd:main option"); */ EXPORT_PUBLIC int app_launcher(const char *pkg_name, app_control_reply_cb callback, void *user_data) { int ret; app_control_h service = get_svc_from_args((void *)pkg_name); retv_if(!service, -1); ret = app_launcher_svc(pkg_name, service, callback, user_data); app_control_destroy(service); return ret; } EXPORT_PUBLIC int app_launcher_svc(const char *pkg_name, app_control_h service, app_control_reply_cb callback, void *user_data) { int ret = -1; char *path = NULL; path = get_path_from_args((void *)pkg_name); app_control_set_operation(service, APP_CONTROL_OPERATION_PICK); app_control_set_launch_mode(service, APP_CONTROL_LAUNCH_MODE_GROUP); if (path) { app_control_set_app_id(service, path); SETTING_TRACE("app path - %s", path); } SETTING_TRACE("service name - %s", path); int launch_ret = app_control_send_launch_request(service, callback, user_data); SETTING_TRACE("after app_service_create - %s : %s ", pkg_name, get_error_message(launch_ret)); if (launch_ret == APP_CONTROL_ERROR_NONE) { /* on success */ SETTING_TRACE("on success"); ret = 0; } else { /* on error */ SETTING_TRACE("on error"); ret = -1; } FREE(path); return ret; } EXPORT_PUBLIC int app_group_launcher(const char *pkg_name) { int ret = -1; char *path = get_path_from_args((void *)pkg_name); retv_if(!path, -1); app_control_h service = get_svc_from_args((void *)pkg_name); if (!service) { free(path); return -1; } app_control_set_operation(service, APP_CONTROL_OPERATION_PICK); app_control_set_launch_mode(service, APP_CONTROL_LAUNCH_MODE_GROUP); if (path) app_control_set_app_id(service, path); int launch_ret = app_control_send_launch_request(service, NULL, NULL); SETTING_TRACE("after app_service_create - %s : %d ", pkg_name, launch_ret); if (launch_ret == APP_CONTROL_ERROR_NONE) { /* on success */ SETTING_TRACE("on success"); ret = 0; } else { /* on error */ SETTING_TRACE("on error"); ret = -1; } app_control_destroy(service); service = NULL; FREE(path); return ret; } EXPORT_PUBLIC bool get_tethering_status() { /* check status of tethering */ bool therthering_on = false; int mobile_ap_status = VCONFKEY_MOBILE_HOTSPOT_MODE_NONE; int err = -1; int ret = setting_get_int_slp_key(INT_SLP_SETTING_MOBILE_AP_STATUS, &mobile_ap_status, &err); if (ret == SETTING_RETURN_FAIL) SETTING_TRACE_ERROR("fail to get vconf"); /** * - 1 : wi-fi * - 2 : bluetooth * - 4 : USB * - 8 : Wifi AP * 4, 2, 1 = 7 --7 means bitwise-operation */ if (mobile_ap_status & ( VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI | VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI_AP)) { therthering_on = true; } return therthering_on; } static const char *font_size_arr[] = { "IDS_ST_BODY_SMALL_M_TEXTSIZE", /* 0 */ "IDS_ST_BODY_MEDIUM", /* 1 */ "IDS_ST_BODY_TEXTSTYLE_LARGE", /* 2 */ "IDS_EMAIL_OPT_HUGE_M_TEXTSIZE", /* 3 */ "IDS_EMAIL_POP_GIANT_M_TEXTSIZE", /* 4 */ }; /** * [API] font-size */ EXPORT_PUBLIC const char *get_font_size_str(int font_size) { switch (font_size) { case SYSTEM_SETTINGS_FONT_SIZE_SMALL: return (char *)font_size_arr[0]; case SYSTEM_SETTINGS_FONT_SIZE_NORMAL: return (char *)font_size_arr[1]; case SYSTEM_SETTINGS_FONT_SIZE_LARGE: return (char *)font_size_arr[2]; case SYSTEM_SETTINGS_FONT_SIZE_HUGE: return (char *)font_size_arr[3]; case SYSTEM_SETTINGS_FONT_SIZE_GIANT: return (char *)font_size_arr[4]; default: return (char *)font_size_arr[1]; } } /** * Gets full path of filename from res dir * * @return path statically allocated string or null on error. */ EXPORT_PUBLIC const char *setting_get_resource_path(const char *filename) { static char path_str[PATH_MAX] = {'\0',}; char *app_res_path = app_get_resource_path(); snprintf(path_str, sizeof(path_str), "%s/%s", app_res_path, filename); free(app_res_path); return path_str; } EXPORT_PUBLIC extern bool isZero(double val) { if (fabs(val) < EPISLON) { return true; } return false; } EXPORT_PUBLIC extern Eina_Array *eina_array_transform(Eina_Array *array, transform_cb cb, void *user_data) { unsigned int size = eina_array_count_get(array); for (unsigned int idx = 0; idx < size; idx++) { void *data = eina_array_data_get(array, idx); eina_array_data_set(array, idx, cb(data, user_data)); } return array; }