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.
22 #include <setting-common-general-func.h>
23 #include <setting-common-data-slp-setting.h>
26 #include <iniparser.h>
28 #include <libxml/xmlmemory.h>
29 #include <libxml/parser.h>
31 char *setting_file_basename(char *path)
33 if (NULL == path || '\0' == path[0]) {
34 return NULL; /* invalid arguement */
36 char *p = strrchr(path, '/');
38 return (char *)g_strdup(path); /* cannot find '/' */
41 return NULL; /* end with '/' */
43 return (char *)g_strdup(p + 1);
46 char *get_pa_usb_connect_mode_str()
48 int ret = SETTING_RETURN_FAIL;
51 ret = vconf_get_int(VCONFKEY_SETAPPL_USB_MODE_INT, &value);
52 setting_retvm_if(SETTING_RETURN_FAIL == ret, NULL, "Failed to get vconf value"); /* file system exceptional handle */
56 case SETTING_USB_DEBUG_MODE:
57 return (char*)g_strdup(_("IDS_ST_BODY_USB_DEBUGGING"));
59 return (char*)g_strdup(_("IDS_COM_POP_DISCONNECTED"));
63 char *get_brightness_mode_str()
66 setting_get_int_slp_key(INT_SLP_SETTING_AUTOMATIC_BRIGHTNESS, &value,
68 if (value != SETTING_BRIGHTNESS_AUTOMATIC_OFF) {
69 return setting_gettext("IDS_COM_BODY_AUTOMATIC");
71 return setting_gettext("IDS_COM_BODY_MANUAL");
75 char *get_pa_backlight_time_str()
78 char backlight_time_str[MAX_DISPLAY_NAME_LEN_ON_UI];
80 #if SUPPORT_LCD_TIMEOUT_KEEPING
81 if (0 != vconf_get_int(VCONFKEY_LCD_TIMEOUT_NORMAL_BACKUP, &value)) {
84 value = 0; /* keep agree with postin file */
87 vconf_set_int(VCONFKEY_LCD_TIMEOUT_NORMAL_BACKUP, value);
92 setting_get_int_slp_key(INT_SLP_SETTING_LCD_TIMEOUT_NORMAL, &value,
95 if (SETTING_RETURN_FAIL == ret || value < 0) { /* file system exceptional handle, eg. The vconf file lost due to file system. */
98 value = 0; /* keep agree with postin file */
101 setting_set_int_slp_key(INT_SLP_SETTING_LCD_TIMEOUT_NORMAL,
104 #else // for MDM server
110 // if 120 < < 300, 120
111 // if 300 < < 600, 300
115 if (SETTING_RETURN_FAIL == ret || value < 15)
117 else if(value >= 15 && value < 30)
119 else if(value >= 30 && value < 60)
121 else if(value >= 60 && value < 120)
123 else if(value >= 120 && value < 300)
125 else if(value >= 300 && value < 600)
132 if (SETTING_RETURN_FAIL == ret || value < 30)
134 else if(value >= 30 && value < 60)
136 else if(value >= 60 && value < 120)
138 else if(value >= 120 && value < 300)
140 else if(value >= 300 && value < 600)
146 setting_set_int_slp_key(INT_SLP_SETTING_LCD_TIMEOUT_NORMAL,
152 snprintf(backlight_time_str, sizeof(backlight_time_str), "%s",
153 _("IDS_ST_BODY_ALWAYS_ON"));
154 } else if (value == 60) {
155 snprintf(backlight_time_str, sizeof(backlight_time_str), "%s",
156 _("IDS_COM_BODY_1_MINUTE"));
157 } else if (value > 60) {
158 snprintf(backlight_time_str, sizeof(backlight_time_str),
159 "%d %s", value / 60, (char *)(_("IDS_COM_BODY_MINUTES_LC")));
161 snprintf(backlight_time_str, sizeof(backlight_time_str),
162 "%d %s", value, (char *)(_("IDS_COM_BODY_SECONDS_LC")));
164 return (char *)g_strdup(backlight_time_str);
167 char *get_pa_powersaving_at_str()
170 char powersaving_at_str[MAX_DISPLAY_NAME_LEN_ON_UI + 1];
174 setting_get_int_slp_key(INT_SLP_SETTING_POWERSAVING_AT, &value,
176 if (SETTING_RETURN_FAIL == ret || value < 0) { /* file system exceptional handle, eg. The vconf file lost due to file system. */
177 value = 30; /* keep agree with postin file */
178 setting_set_int_slp_key(INT_SLP_SETTING_POWERSAVING_AT,
182 snprintf(powersaving_at_str, MAX_DISPLAY_NAME_LEN_ON_UI, "At %d%% %s",
183 value, "battery power");
184 return (char *)g_strdup(powersaving_at_str);
187 char *get_pa_screen_timeout_str()
190 char screen_timeout_str[MAX_DISPLAY_NAME_LEN_ON_UI + 1];
194 setting_get_int_slp_key(INT_SLP_SETTING_POWERSAVING_SCREEN_TIMEOUT,
197 if (SETTING_RETURN_FAIL == ret || value < 0) { /* file system exceptional handle, eg. The vconf file lost due to file system. */
198 value = 15; /* keep agree with postin file */
199 setting_set_int_slp_key
200 (INT_SLP_SETTING_POWERSAVING_SCREEN_TIMEOUT, value, &err);
204 snprintf(screen_timeout_str, MAX_DISPLAY_NAME_LEN_ON_UI, "%s",
206 } else if (value >= 60) {
207 snprintf(screen_timeout_str, MAX_DISPLAY_NAME_LEN_ON_UI,
209 (char *)(_("IDS_COM_BODY_MINUTES_LC")));
211 snprintf(screen_timeout_str, MAX_DISPLAY_NAME_LEN_ON_UI,
213 (char *)(_("IDS_COM_BODY_SECONDS_LC")));
215 return (char *)g_strdup(screen_timeout_str);
218 char *get_pa_display_language_str()
220 int ret = SETTING_RETURN_FAIL;
224 Eina_List* list = setting_get_language_list();
225 Eina_List* elist = NULL;
227 ret = setting_get_int_slp_key(INT_SLP_SETTING_LANG, &index, &err);
230 return g_strdup("Automatic");
232 setting_lang_entry* pnode;
235 EINA_LIST_FOREACH( list, elist, pnode)
237 if (pnode->number == index)
238 title = g_strdup(pnode->title);
243 char *get_pa_Wi_Fi_on_off_str()
246 int ret = SETTING_RETURN_FAIL;
248 setting_get_int_slp_key(INT_SLP_SETTING_WIFI_STATUS, &value, &err);
250 if (SETTING_RETURN_FAIL == ret) { /* file system exceptional handle, eg. The vconf file lost due to file system. */
251 value = VCONFKEY_WIFI_OFF;
252 setting_set_int_slp_key(INT_SLP_SETTING_WIFI_STATUS,
253 VCONFKEY_WIFI_OFF, &err);
257 char *pa_wifi_device = vconf_get_str(VCONFKEY_WIFI_CONNECTED_AP_NAME);
258 SETTING_TRACE("pa_wifi_device:%s", pa_wifi_device);
259 if (NULL != pa_wifi_device && '\0' != pa_wifi_device[0]) {
260 return pa_wifi_device;
263 return (char*)g_strdup(setting_gettext("IDS_COM_BODY_ON_M_STATUS"));
265 return (char*)g_strdup(setting_gettext("IDS_COM_BODY_OFF_M_STATUS"));
269 char *get_Mobile_AP_on_off_str()
273 setting_get_int_slp_key(INT_SLP_SETTING_MOBILE_AP_STATUS, &value,
276 /* 7 means bitwise-operation */
283 if (0 != ret || value < 0 || value > 7) {
285 setting_set_int_slp_key(INT_SLP_SETTING_MOBILE_AP_STATUS, value,
290 return setting_gettext("IDS_COM_BODY_ON_M_STATUS");
292 return setting_gettext("IDS_COM_BODY_OFF_M_STATUS");
296 char *get_BT_on_off_str()
298 int ret = SETTING_RETURN_FAIL;
300 ret = setting_get_int_slp_key(INT_SLP_SETTING_BT_STATUS, &value, &err);
302 if (SETTING_RETURN_FAIL == ret) { /* file system exceptional handle, eg. The vconf file lost due to file system. */
303 value = VCONFKEY_BT_STATUS_OFF;
304 setting_set_int_slp_key(INT_SLP_SETTING_BT_STATUS,
305 VCONFKEY_BT_STATUS_OFF, &err);
308 if (VCONFKEY_BT_STATUS_OFF == value) {
309 return setting_gettext("IDS_COM_BODY_OFF_M_STATUS");
311 return setting_gettext("IDS_COM_BODY_ON_M_STATUS");
315 char *get_NFC_on_off_str()
317 int ret = SETTING_RETURN_FAIL;
318 int value = 0, err = 0;
319 ret = setting_get_bool_slp_key(BOOL_SLP_SETTING_NFC_STATUS, &value, &err);
321 if (SETTING_RETURN_FAIL == ret) { /* file system exceptional handle, eg. The vconf file lost due to file system. */
322 SETTING_TRACE_DEBUG("fail to get nfc status from vconf");
323 value = VCONFKEY_NFC_STATE_OFF;
326 if (VCONFKEY_NFC_STATE_OFF == value) {
327 return setting_gettext("IDS_COM_BODY_OFF_M_STATUS");
329 return setting_gettext("IDS_COM_BODY_ON_M_STATUS");
333 char *get_pa_time_format_str()
335 int ret = SETTING_RETURN_FAIL;
337 char *format_str[] = { _("IDS_COM_BODY_12_HOURS"),
338 _("IDS_ST_BODY_24_HOURS") };
340 setting_get_int_slp_key(INT_SLP_SETTING_REGIONFORMAT_TIME1224,
342 setting_retvm_if(SETTING_RETURN_FAIL == ret, NULL, "Failed to get vconf value"); /* file system exceptional handle */
345 /* value 1:12H 2:24H */
346 if (value > 0 && value <= 2) /* 1, 2 */
347 return (char *)g_strdup(format_str[value - 1]);
349 return (char *)g_strdup(format_str[0]); /* set to 12H compelsery */
353 char *get_pa_date_format_str()
355 int ret = SETTING_RETURN_FAIL;
357 char *format_str[] = { _("IDS_ST_BODY_DDMMYYYY_DOT"),
358 _("IDS_ST_BODY_MM_DD_YYYY_DOT"),
359 _("IDS_COM_BODY_YYYYMMDD"), _("IDS_ST_BODY_YYYY_DD_MM_DOT")
362 setting_get_int_slp_key(INT_SLP_SETTING_DATE_FORMAT, &value, &err);
363 setting_retvm_if(SETTING_RETURN_FAIL == ret, NULL, "Failed to get vconf value"); /* file system exceptional handle */
364 return (char *)g_strdup(format_str[value]);
367 char *get_pa_week_format_str()
369 int ret = SETTING_RETURN_FAIL;
371 char *format_str[] = {
372 _("IDS_ST_BODY_SUNDAY"),
373 _("IDS_ST_BODY_MONDAY"),
377 setting_get_int_slp_key(INT_SLP_SETTING_WEEK_FORMAT, &value, &err);
378 setting_retvm_if(SETTING_RETURN_FAIL == ret, NULL, "Failed to get vconf value"); /* file system exceptional handle */
379 return (char *)g_strdup(format_str[value]);
382 char *get_pa_roaming_network_str()
384 int ret = SETTING_RETURN_FAIL;
386 char *roaming_str[] = {
387 _("IDS_ST_BODY_AUTO_DOWNLOAD"), _("IDS_COM_BODY_MANUAL"),
388 _("IDS_ST_BODY_ALWAYS_REJECT")
391 setting_get_int_slp_key(INT_SLP_SETTING_ROAMING_NETWORK, &value,
393 setting_retvm_if(SETTING_RETURN_FAIL == ret, NULL, "Failed to get vconf value"); /* file system exceptional handle */
394 return (char *)g_strdup(roaming_str[value]);
397 double get_widgets_factor()
399 return elm_scale_get();
402 char *setting_gettext(const char *s)
404 /* fisrt find in app pg */
410 char *p = dgettext(SETTING_PACKAGE, s);
412 if (!safeStrCmp(s, p)) { /* not found */
413 /* find in system pkg */
414 p = dgettext(SYSTEM_PACKAGE, s);
419 bool is_digital_str(const char *cstr)
421 if (cstr == NULL || cstr[0] == 0) {
425 int len = (int)(safeStrLen(cstr));
427 if (cstr[0] == '-' || cstr[0] == '+') {
435 if (cstr[pos] < '0' || cstr[pos] > '9') {
444 bool is_substr_ncase(const char *parentstr, const char *substr)
446 if (NULL == parentstr || '\0' == parentstr[0])
449 int word_len = safeStrLen(parentstr);
450 int search_len = safeStrLen(substr);
453 for (i = 0; i < word_len; i++) {
454 if (!strncasecmp(substr, &parentstr[i], search_len)) {
462 bool is_string_belong_to_array(const char *partern, const char **array,
466 for (; idx < array_num; idx++) {
467 if (!safeStrCmp(partern, array[idx])) {
474 bool isEmptyStr(const char *str)
476 if (NULL == str || str[0] == '\0') {
483 int safeStrCmp(const char *s1, const char *s2)
485 /* Check NULL value first */
486 if (isEmptyStr(s1) && isEmptyStr(s2)) {
488 } else if (isEmptyStr(s1)) {
490 } else if (isEmptyStr(s2)) {
491 return SETTING_RETURN_FAIL;
494 return strcmp(s1, s2);
497 int safeStrNCmp(const char *s1, const char *s2, int len)
500 /* Check NULL value first */
501 if (isEmptyStr(s1) && isEmptyStr(s2)) {
503 } else if (isEmptyStr(s1)) {
505 } else if (isEmptyStr(s2)) {
506 return SETTING_RETURN_FAIL;
513 return strncmp(s1, s2, len);
516 char *safeStrNCat(char *dst, const char *src, int maxlen)
518 if (dst && !isEmptyStr(src) && maxlen > 0) {
519 (void) g_strlcat(dst, src, maxlen + 1);
526 char *safeCopyStr(char *dst, const char *src, int maxlen)
536 int temp = (int)safeStrLen(src);
537 len = (temp <= maxlen) ? temp : maxlen;
538 memcpy(dst, src, len);
547 int safeStrLen(const char *str)
549 if (isEmptyStr(str)) {
550 SETTING_TRACE_DEBUG("string is empty");
558 * get the int value of substring before delim
560 bool get_substring_int(const char **ipStr, int *ipValue, char delim)
562 int iValue = *ipValue = 0;
563 const char *str = *ipStr;
565 if (str == NULL || str[0] == 0) { /* empty string */
569 bool bNegative = FALSE;
570 if ('-' == str[0]) { /* allow Negative number.. */
574 if (str[0] < '0' || str[0] > '9') { /* first elementy is not digital */
578 if (str[0] == '0') { /* first elementy is 0 */
579 if (str[1] == delim) {
594 /****first elementy is not 0*/
595 iValue = iValue * 10 + str[0] - '0';
597 if (((unsigned int)iValue & 0x80000000) != 0) { /* think about overloading */
601 if (str[0] == delim) {
618 if (str[0] < '0' || str[0] > '9') {
627 #define MaxIPAddressLength 15
630 * CHeck Whether a special string Is An IP String
632 * @param ipstr string representing IP numbers like "aaa.bbb.ccc.ddd"
634 * @return true if it's IP format string otherwise false
636 bool is_ip_string(const char *ipstr)
638 if (NULL == ipstr || 0 == ipstr[0])
640 int len = (int)safeStrLen(ipstr);
641 if (len > MaxIPAddressLength) {
645 if (ipstr[len - 1] == '.') {
652 if (!get_substring_int(&ipstr, &ip, '.') || ip > 255) {
653 SETTING_TRACE("ipstr:%s", ipstr);
656 SETTING_TRACE("ipstr:%s", ipstr);
665 int setting_invoke_reset_function(char *lib_name, service_h service, void *ext)
667 SETTING_TRACE("Enter %s with lib_name:%s", __FUNCTION__, lib_name);
668 int (*reset) (service_h pair, void *ptr);
669 int ret = OPERATE_LIB_SUCESS;
671 void *handle = dlopen(lib_name, RTLD_LAZY);
673 SETTING_TRACE_ERROR(" >>>>>>>>>>> %s", dlerror());
674 return LOAD_LIB_FAILED;
678 reset = dlsym(handle, "setting_plugin_reset");
679 if ((error = dlerror()) != NULL) {
680 SETTING_TRACE_ERROR(" >>>>>>>>>>> %s", error);
682 return UNDEFINED_LIB_SYMBOL;
686 ret = (*reset) (service, ext); /* CALL */
688 if (ret < 0) ret += UNDEFINED_LIB_SYMBOL;//from -2 on
694 int excuteCmd(char* exec_path, int option_num, ...)
696 char cmd[MAX_COMMON_BUFFER_LEN + 1] = {0, };
697 snprintf(cmd, MAX_COMMON_BUFFER_LEN,
702 va_start(args, option_num);
706 for (; argno < option_num; argno++) {
707 para = va_arg( args, char *);
708 SETTING_TRACE("Parameter #%d is: %s", argno, para);
711 g_strlcat(cmd, " ", MAX_COMMON_BUFFER_LEN + 1);
712 g_strlcat(cmd, para, MAX_COMMON_BUFFER_LEN + 1);
718 SETTING_TRACE("excute:%s", cmd);
723 void create_fontlink(const char *linkpath, const char *linkname,
724 const char *fontfilepath, const char *fontfilename)
726 char newpath[MAX_COMMON_BUFFER_LEN + 1];
727 char lcpath[MAX_COMMON_BUFFER_LEN + 1];
730 snprintf(newpath, MAX_COMMON_BUFFER_LEN, "%s/%s", linkpath, linkname);
732 snprintf(lcpath, MAX_COMMON_BUFFER_LEN, "%s/%s", fontfilepath, fontfilename);
734 SETTING_TRACE("newpath:%s", newpath);
735 SETTING_TRACE("lcpath:%s", lcpath);
738 ret = symlink(lcpath, newpath);
739 setting_retm_if(ret != 0, "fail to call symlink");
742 char* get_icon_path(const char *package)
744 ail_appinfo_h handle;
747 char *icon_path = IMG_DefaultIcon;//The default icon must exist.(it will be installed by Setting App)
752 if (ail_package_get_appinfo(package, &handle) != AIL_ERROR_OK) {
753 SETTING_TRACE_ERROR("Failed to ail_package_get_appinfo.");
758 if (result && ail_appinfo_get_str(handle, AIL_PROP_ICON_STR, &icon_path) != AIL_ERROR_OK) {
759 SETTING_TRACE_ERROR("Failed to ail_appinfo_get_str.");
763 if (result && access(icon_path, R_OK|F_OK ) !=0 ) {//The file cannot be accessed.
764 SETTING_TRACE_ERROR("The file[%s] cannot be accessed. To use defaut icon.", icon_path);
765 icon_path = IMG_DefaultIcon;
768 ret_str = strdup(icon_path);
769 if (destroy && ail_package_destroy_appinfo(handle) != AIL_ERROR_OK) {
770 SETTING_TRACE_ERROR("Failed to ail_package_destroy_appinfo.");
779 dictionary* dic = iniparser_load("/etc/info.ini");
780 char* str = (char *)iniparser_getstr(dic, "Version:Build");
786 if (!strncmp(str, "SLP", 3)) return 1;
791 iniparser_freedict(dic);
799 char szEmul[__LEN_STR_EMUL+1];
800 const char* szBinVer = NULL;
802 dictionary* dic = iniparser_load(BIN_INFO_FILE_PATH);
803 // when failed to get the info, let's regard the binary as an emulator one
807 szBinVer = (const char*)iniparser_getstr(dic, "Version:Build");
809 char* str = g_strdup(szBinVer);
816 sscanf(str, "%*s %4s", szEmul);
822 iniparser_freedict(dic);
826 if (!strncmp(szEmul, __STR_EMUL, __LEN_STR_EMUL)) {
833 int get_popup_btn_response_type(const char *btn_str)
835 SETTING_TRACE("btn_str:%s", btn_str);
836 POPUP_BTN_RESPONSE_TYPE rsp_type = POPUP_RESPONSE_INVALID;
837 retv_if(!btn_str, rsp_type);
838 if (0 == safeStrCmp(btn_str, _("IDS_COM_BODY_CLOSE"))
839 || 0 == safeStrCmp(btn_str, _("IDS_COM_SK_TRY"))//KeyStr_Try
840 || 0 == safeStrCmp(btn_str, _("IDS_COM_SK_OK"))
841 || 0 == safeStrCmp(btn_str, _("IDS_COM_SK_YES"))
842 || 0 == safeStrCmp(btn_str, _("IDS_ST_BODY_USE_MOTION"))
843 || 0 == safeStrCmp(btn_str, _("IDS_COM_POP_TRY_AGAIN"))
844 || 0 == safeStrCmp(btn_str, _("IDS_COM_SK_DELETE"))
845 || 0 == safeStrCmp(btn_str, _(KeyStr_Save)))
847 rsp_type = POPUP_RESPONSE_OK;
851 rsp_type = POPUP_RESPONSE_CANCEL;
856 #define SUPPORT_STATIC_LOAD 1
857 #if SUPPORT_STATIC_LOAD
858 static char *system_service_list[MAX_SYSTEM_SERVICE_NUM] = {NULL, };
860 void clear_system_service_data()
862 #if SUPPORT_STATIC_LOAD
864 for (idx = 0; idx < MAX_SYSTEM_SERVICE_NUM && system_service_list[idx]; idx++)
866 FREE(system_service_list[idx]);
871 bool is_system_service(const char *pkg_name)
873 //SLP native apps list,
874 if (0 == safeStrCmp(pkg_name, "com.samsung.menu-screen")
875 || 0 == safeStrCmp(pkg_name, "com.samsung.live-data-provider")
876 || 0 == safeStrCmp(pkg_name, "com.samsung.live-magazine")
877 || 0 == safeStrCmp(pkg_name, "com.samsung.pwlock")
878 || 0 == safeStrCmp(pkg_name, "com.samsung.quickpanel")
879 || 0 == safeStrCmp(pkg_name, "com.samsung.vtmain")
880 || 0 == safeStrCmp(pkg_name, "com.samsung.call")
881 || 0 == safeStrCmp(pkg_name, "usb_setting")
882 || 0 == safeStrCmp(pkg_name, "com.samsung.indicator")
883 || 0 == safeStrCmp(pkg_name, "com.samsung.cluster-home")
889 //OSP service app list,
891 #if SUPPORT_STATIC_LOAD
893 if (!system_service_list[0]) //just load the file
895 FILE *fp = fopen(SYSTEM_SERVICE_LIST_PATH, "r");
897 char result[MAX_PKG_NAME_LEN+1] = {0, };
898 while (fgets(result, MAX_PKG_NAME_LEN, fp))
900 result[strlen(result) - 1] = '\0';//offset 1
901 system_service_list[idx++] = strdup(result);
908 for (idx = 0; idx < MAX_SYSTEM_SERVICE_NUM && system_service_list[idx]; idx++)
910 if (0 == safeStrCmp(pkg_name, system_service_list[idx])) {
916 FILE *fp = fopen(SYSTEM_SERVICE_LIST_PATH, "r");
918 char result[MAX_PKG_NAME_LEN+1] = {0, };
919 while (fgets(result, MAX_PKG_NAME_LEN, fp))
921 result[strlen(result) - 1] = '\0';//offset 1
922 if (0 == safeStrCmp(pkg_name, result)) {
930 SETTING_TRACE("ret:%d", ret);
935 * should use g_free to free returned string
937 char *get_default_font(int language)
939 char *font_name = NULL;
943 case SETTING_LANG_KOREA:
944 font_name = g_strdup("SLPSansKorean");
946 case SETTING_LANG_CHINA:
947 /* output_font : SLPSansFallback*/
948 case SETTING_LANG_CANTONESE:
949 /* output_font : SLPSansFallback*/
950 case SETTING_LANG_TAIWAN:
951 font_name = g_strdup("SLPSansFallback");
953 case SETTING_LANG_JAPAN:
954 font_name = g_strdup("UDGothic");
956 case SETTING_LANG_AUTOMATIC:
957 /* output_font : HelveticaNeue*/
958 case SETTING_LANG_ENGLISH:
959 /* output_font : HelveticaNeue*/
960 case SETTING_LANG_GERMAN:
961 /* output_font : HelveticaNeue*/
962 case SETTING_LANG_DUTCH:
963 /* output_font : HelveticaNeue*/
964 case SETTING_LANG_SPAINISH:
965 /* output_font : HelveticaNeue*/
966 case SETTING_LANG_PORTUGUESE:
967 /* output_font : HelveticaNeue*/
968 case SETTING_LANG_GREEK:
969 /* output_font : HelveticaNeue*/
970 case SETTING_LANG_ITALIAN:
971 /* output_font : HelveticaNeue*/
972 case SETTING_LANG_FRENCH:
973 /* output_font : HelveticaNeue*/
974 case SETTING_LANG_TURKISH:
975 /* output_font : HelveticaNeue*/
976 case SETTING_LANG_RUSSIAN:
977 font_name = g_strdup("HelveticaNeue");
980 font_name = g_strdup("HelveticaNeue");
986 void *font_conf_doc_parse(char *doc_name, char *font_name)
989 setting_retvm_if(doc_name == NULL, NULL, "Param data is NULL");
990 setting_retvm_if(font_name == NULL, NULL, "Param data is NULL");
991 xmlDocPtr doc = NULL;
992 xmlNodePtr cur = NULL;
993 xmlNodePtr cur2 = NULL;
994 xmlNodePtr cur3 = NULL;
997 doc = xmlParseFile(doc_name);
998 setting_retvm_if(doc == NULL, NULL, "Document not parsed successfully.");
1000 cur = xmlDocGetRootElement(doc);
1003 SETTING_TRACE_DEBUG("empty document");
1009 if(xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1010 SETTING_TRACE_DEBUG("document of the wrong type, root node != fontconfig");
1016 cur = cur->xmlChildrenNode;
1020 if((!xmlStrcmp(cur->name, (const xmlChar *)"match")))
1022 cur2 = cur->xmlChildrenNode;
1025 if((!xmlStrcmp(cur2->name, (const xmlChar *)"edit")))
1027 cur3 = cur2->xmlChildrenNode;
1030 if((!xmlStrcmp(cur3->name, (const xmlChar *)"string")))
1032 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1033 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1034 SETTING_TRACE_DEBUG("after changed, string is: %s\n", key);
1054 * should use g_free to free return string
1056 char *cur_font_get()
1058 SETTING_TRACE_BEGIN;
1059 xmlDocPtr doc = NULL;
1060 xmlNodePtr cur = NULL;
1061 xmlNodePtr cur2 = NULL;
1062 xmlNodePtr cur3 = NULL;
1063 xmlChar *key = NULL;
1065 char *font_name = NULL;
1067 doc = xmlParseFile(SETTING_FONT_CONF_FILE);
1068 setting_retvm_if(doc == NULL, NULL, "Document not parsed successfully.");
1070 cur = xmlDocGetRootElement(doc);
1073 SETTING_TRACE_DEBUG("empty document");
1079 if(xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1080 SETTING_TRACE_DEBUG("document of the wrong type, root node != fontconfig");
1086 cur = cur->xmlChildrenNode;
1090 if((!xmlStrcmp(cur->name, (const xmlChar *)"match")))
1092 cur2 = cur->xmlChildrenNode;
1095 if((!xmlStrcmp(cur2->name, (const xmlChar *)"edit")))
1097 cur3 = cur2->xmlChildrenNode;
1100 if((!xmlStrcmp(cur3->name, (const xmlChar *)"string")))
1102 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1103 SETTING_TRACE_DEBUG("string is: %s", key);
1105 font_name = g_strdup((char *)key);
1126 static int __font_size_get()
1131 int ret = setting_get_int_slp_key(INT_SLP_SETTING_ACCESSIBILITY_FONT_SIZE, &value, &err);
1132 retvm_if(ret != 0, -1, "get vconf failed");
1135 case SYSTEM_SETTINGS_FONT_SIZE_SMALL:
1136 font_size = SMALL_FONT_DPI;
1138 case SYSTEM_SETTINGS_FONT_SIZE_NORMAL:
1139 font_size = MIDDLE_FONT_DPI;
1141 case SYSTEM_SETTINGS_FONT_SIZE_LARGE:
1142 font_size = LARGE_FONT_DPI;
1144 case SYSTEM_SETTINGS_FONT_SIZE_HUGE:
1145 font_size = HUGE_FONT_DPI;
1147 case SYSTEM_SETTINGS_FONT_SIZE_GIANT:
1148 font_size = GIANT_FONT_DPI;
1151 font_size = MIDDLE_FONT_DPI;
1157 void font_config_set(char *font_name)
1159 Eina_List *text_classes = NULL;
1160 Elm_Text_Class *etc = NULL;
1161 const Eina_List *l = NULL;
1162 Eina_List *fo_list = NULL;
1163 Elm_Font_Overlay *efo = NULL;
1164 int font_size = __font_size_get();
1167 text_classes = elm_config_text_classes_list_get();
1169 fo_list = (Eina_List *)elm_config_font_overlay_list_get();
1171 Eina_List *ll = NULL;
1172 Eina_List *l_next = NULL;
1174 Eina_Bool slp_medium_exist = EINA_FALSE;
1175 Eina_Bool slp_roman_exist = EINA_FALSE;
1176 Eina_Bool slp_bold_exist = EINA_FALSE;
1177 Eina_Bool slp_regular_exist = EINA_FALSE;
1179 EINA_LIST_FOREACH_SAFE(fo_list, ll, l_next, efo)
1181 if (!safeStrCmp(efo->text_class, "slp_medium")) {
1182 elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size);
1183 slp_medium_exist = EINA_TRUE;
1184 } else if (!safeStrCmp(efo->text_class, "slp_roman")) {
1185 elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size);
1186 slp_roman_exist = EINA_TRUE;
1187 } else if (!safeStrCmp(efo->text_class, "slp_bold")) {
1188 elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size);
1189 slp_bold_exist = EINA_TRUE;
1190 } else if (!safeStrCmp(efo->text_class, "slp_regular")) {
1191 elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size);
1192 slp_regular_exist = EINA_TRUE;
1196 /* if slp_XX do not exist, need to set them, font size is -100(100%) */
1197 if (slp_medium_exist == EINA_FALSE) {
1198 elm_config_font_overlay_set("slp_medium", (const char*)font_name, MIDDLE_FONT_DPI);
1200 if (slp_roman_exist == EINA_FALSE) {
1201 elm_config_font_overlay_set("slp_roman", (const char*)font_name, MIDDLE_FONT_DPI);
1203 if (slp_bold_exist == EINA_FALSE) {
1204 elm_config_font_overlay_set("slp_bold", (const char*)font_name, MIDDLE_FONT_DPI);
1206 if (slp_regular_exist == EINA_FALSE) {
1207 elm_config_font_overlay_set("slp_regular", (const char*)font_name, MIDDLE_FONT_DPI);
1210 EINA_LIST_FOREACH(text_classes, l, etc)
1215 EINA_LIST_FOREACH(fo_list, ll, efo)
1217 if (!safeStrCmp(etc->name, efo->text_class)) {
1221 elm_config_font_overlay_set(etc->name, (const char*)font_name, size);
1224 elm_config_font_overlay_apply();
1225 elm_config_all_flush();
1226 elm_config_engine_set("software_x11");
1228 elm_config_text_classes_list_free(text_classes);
1229 text_classes = NULL;
1232 vconf_set_str(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, font_name);
1235 void font_size_set()
1237 Eina_List *text_classes = NULL;
1238 Elm_Text_Class *etc = NULL;
1239 const Eina_List *l = NULL;
1240 int font_size = __font_size_get();
1241 char *font_name = cur_font_get();
1243 if (font_size == -1) {
1244 SETTING_TRACE_DEBUG("failed to call font_size_get");
1248 text_classes = elm_config_text_classes_list_get();
1250 EINA_LIST_FOREACH(text_classes, l, etc)
1252 elm_config_font_overlay_set(etc->name, font_name, font_size);
1255 elm_config_all_flush();
1256 elm_config_engine_set("software_x11");
1258 elm_config_text_classes_list_free(text_classes);
1259 text_classes = NULL;