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>
30 #include <system_info.h>
32 #include <system_settings.h>
34 char *setting_file_basename(char *path)
36 if (NULL == path || '\0' == path[0]) {
37 return NULL; /* invalid arguement */
39 char *p = strrchr(path, '/');
41 return (char *)g_strdup(path); /* cannot find '/' */
44 return NULL; /* end with '/' */
46 return (char *)g_strdup(p + 1);
49 char *get_pa_usb_connect_mode_str()
51 int ret = SETTING_RETURN_FAIL;
54 ret = vconf_get_int(VCONFKEY_SETAPPL_USB_MODE_INT, &value);
55 setting_retvm_if(SETTING_RETURN_FAIL == ret, NULL, "Failed to get vconf value"); /* file system exceptional handle */
59 case SETTING_USB_DEBUG_MODE:
60 return (char*)g_strdup(_("IDS_ST_BODY_USB_DEBUGGING"));
62 return (char*)g_strdup(_("IDS_COM_POP_DISCONNECTED"));
66 char *get_brightness_mode_str()
69 setting_get_int_slp_key(INT_SLP_SETTING_AUTOMATIC_BRIGHTNESS, &value,
71 if (value != SETTING_BRIGHTNESS_AUTOMATIC_OFF) {
72 return setting_gettext("IDS_COM_BODY_AUTOMATIC");
74 return setting_gettext("IDS_COM_BODY_MANUAL");
78 char *get_pa_backlight_time_str()
81 char backlight_time_str[MAX_DISPLAY_NAME_LEN_ON_UI];
83 #if SUPPORT_LCD_TIMEOUT_KEEPING
84 if (0 != vconf_get_int(VCONFKEY_LCD_TIMEOUT_NORMAL_BACKUP, &value)) {
87 value = 0; /* keep agree with postin file */
90 vconf_set_int(VCONFKEY_LCD_TIMEOUT_NORMAL_BACKUP, value);
95 setting_get_int_slp_key(INT_SLP_SETTING_LCD_TIMEOUT_NORMAL, &value,
98 if (SETTING_RETURN_FAIL == ret || value < 0) { /* file system exceptional handle, eg. The vconf file lost due to file system. */
101 value = 0; /* keep agree with postin file */
104 setting_set_int_slp_key(INT_SLP_SETTING_LCD_TIMEOUT_NORMAL,
107 #else // for MDM server
113 // if 120 < < 300, 120
114 // if 300 < < 600, 300
118 if (SETTING_RETURN_FAIL == ret || value < 15)
120 else if(value >= 15 && value < 30)
122 else if(value >= 30 && value < 60)
124 else if(value >= 60 && value < 120)
126 else if(value >= 120 && value < 300)
128 else if(value >= 300 && value < 600)
135 if (SETTING_RETURN_FAIL == ret || value < 30)
137 else if(value >= 30 && value < 60)
139 else if(value >= 60 && value < 120)
141 else if(value >= 120 && value < 300)
143 else if(value >= 300 && value < 600)
149 setting_set_int_slp_key(INT_SLP_SETTING_LCD_TIMEOUT_NORMAL,
155 snprintf(backlight_time_str, sizeof(backlight_time_str), "%s",
156 _("IDS_ST_BODY_ALWAYS_ON"));
157 } else if (value == 60) {
158 snprintf(backlight_time_str, sizeof(backlight_time_str), "%s",
159 _("IDS_COM_BODY_1_MINUTE"));
160 } else if (value > 60) {
161 snprintf(backlight_time_str, sizeof(backlight_time_str),
162 "%d %s", value / 60, (char *)(_("IDS_COM_BODY_MINUTES_LC")));
164 snprintf(backlight_time_str, sizeof(backlight_time_str),
165 "%d %s", value, (char *)(_("IDS_COM_BODY_SECONDS_LC")));
167 return (char *)g_strdup(backlight_time_str);
170 char *get_pa_powersaving_at_str()
173 char powersaving_at_str[MAX_DISPLAY_NAME_LEN_ON_UI + 1];
177 setting_get_int_slp_key(INT_SLP_SETTING_POWERSAVING_AT, &value,
179 if (SETTING_RETURN_FAIL == ret || value < 0) { /* file system exceptional handle, eg. The vconf file lost due to file system. */
180 value = 30; /* keep agree with postin file */
181 setting_set_int_slp_key(INT_SLP_SETTING_POWERSAVING_AT,
185 snprintf(powersaving_at_str, MAX_DISPLAY_NAME_LEN_ON_UI, "At %d%% %s",
186 value, "battery power");
187 return (char *)g_strdup(powersaving_at_str);
190 char *get_pa_screen_timeout_str()
193 char screen_timeout_str[MAX_DISPLAY_NAME_LEN_ON_UI + 1];
197 setting_get_int_slp_key(INT_SLP_SETTING_POWERSAVING_SCREEN_TIMEOUT,
200 if (SETTING_RETURN_FAIL == ret || value < 0) { /* file system exceptional handle, eg. The vconf file lost due to file system. */
201 value = 15; /* keep agree with postin file */
202 setting_set_int_slp_key
203 (INT_SLP_SETTING_POWERSAVING_SCREEN_TIMEOUT, value, &err);
207 snprintf(screen_timeout_str, MAX_DISPLAY_NAME_LEN_ON_UI, "%s",
209 } else if (value >= 60) {
210 snprintf(screen_timeout_str, MAX_DISPLAY_NAME_LEN_ON_UI,
212 (char *)(_("IDS_COM_BODY_MINUTES_LC")));
214 snprintf(screen_timeout_str, MAX_DISPLAY_NAME_LEN_ON_UI,
216 (char *)(_("IDS_COM_BODY_SECONDS_LC")));
218 return (char *)g_strdup(screen_timeout_str);
221 char *get_pa_display_language_str()
223 int ret = SETTING_RETURN_FAIL;
227 Eina_List* list = setting_get_language_list();
228 Eina_List* elist = NULL;
230 ret = setting_get_int_slp_key(INT_SLP_SETTING_LANG, &index, &err);
233 return g_strdup("Automatic");
235 setting_lang_entry* pnode;
238 EINA_LIST_FOREACH( list, elist, pnode)
240 if (pnode->number == index)
241 title = g_strdup(pnode->title);
246 char *get_pa_Wi_Fi_on_off_str()
249 int ret = SETTING_RETURN_FAIL;
251 setting_get_int_slp_key(INT_SLP_SETTING_WIFI_STATUS, &value, &err);
253 if (SETTING_RETURN_FAIL == ret) { /* file system exceptional handle, eg. The vconf file lost due to file system. */
254 value = VCONFKEY_WIFI_OFF;
255 setting_set_int_slp_key(INT_SLP_SETTING_WIFI_STATUS,
256 VCONFKEY_WIFI_OFF, &err);
260 char *pa_wifi_device = vconf_get_str(VCONFKEY_WIFI_CONNECTED_AP_NAME);
261 SETTING_TRACE("pa_wifi_device:%s", pa_wifi_device);
262 if (NULL != pa_wifi_device && '\0' != pa_wifi_device[0]) {
263 return pa_wifi_device;
266 return (char*)g_strdup(setting_gettext("IDS_COM_BODY_ON_M_STATUS"));
268 return (char*)g_strdup(setting_gettext("IDS_COM_BODY_OFF_M_STATUS"));
272 char *get_Mobile_AP_on_off_str()
276 setting_get_int_slp_key(INT_SLP_SETTING_MOBILE_AP_STATUS, &value,
279 /* 7 means bitwise-operation */
286 if (0 != ret || value < 0 || value > 7) {
288 setting_set_int_slp_key(INT_SLP_SETTING_MOBILE_AP_STATUS, value,
293 return setting_gettext("IDS_COM_BODY_ON_M_STATUS");
295 return setting_gettext("IDS_COM_BODY_OFF_M_STATUS");
299 char *get_BT_on_off_str()
301 int ret = SETTING_RETURN_FAIL;
303 ret = setting_get_int_slp_key(INT_SLP_SETTING_BT_STATUS, &value, &err);
305 if (SETTING_RETURN_FAIL == ret) { /* file system exceptional handle, eg. The vconf file lost due to file system. */
306 value = VCONFKEY_BT_STATUS_OFF;
307 setting_set_int_slp_key(INT_SLP_SETTING_BT_STATUS,
308 VCONFKEY_BT_STATUS_OFF, &err);
311 if (VCONFKEY_BT_STATUS_OFF == value) {
312 return setting_gettext("IDS_COM_BODY_OFF_M_STATUS");
314 return setting_gettext("IDS_COM_BODY_ON_M_STATUS");
318 char *get_NFC_on_off_str()
320 int ret = SETTING_RETURN_FAIL;
321 int value = 0, err = 0;
322 ret = setting_get_bool_slp_key(BOOL_SLP_SETTING_NFC_STATUS, &value, &err);
324 if (SETTING_RETURN_FAIL == ret) { /* file system exceptional handle, eg. The vconf file lost due to file system. */
325 SETTING_TRACE_DEBUG("fail to get nfc status from vconf");
326 value = VCONFKEY_NFC_STATE_OFF;
329 if (VCONFKEY_NFC_STATE_OFF == value) {
330 return setting_gettext("IDS_COM_BODY_OFF_M_STATUS");
332 return setting_gettext("IDS_COM_BODY_ON_M_STATUS");
336 char *get_pa_time_format_str()
338 int ret = SETTING_RETURN_FAIL;
340 char *format_str[] = { _("IDS_COM_BODY_12_HOURS"),
341 _("IDS_ST_BODY_24_HOURS") };
343 setting_get_int_slp_key(INT_SLP_SETTING_REGIONFORMAT_TIME1224,
345 setting_retvm_if(SETTING_RETURN_FAIL == ret, NULL, "Failed to get vconf value"); /* file system exceptional handle */
348 /* value 1:12H 2:24H */
349 if (value > 0 && value <= 2) /* 1, 2 */
350 return (char *)g_strdup(format_str[value - 1]);
352 return (char *)g_strdup(format_str[0]); /* set to 12H compelsery */
356 char *get_pa_date_format_str()
358 int ret = SETTING_RETURN_FAIL;
360 char *format_str[] = { _("IDS_ST_BODY_DDMMYYYY_DOT"),
361 _("IDS_ST_BODY_MM_DD_YYYY_DOT"),
362 _("IDS_COM_BODY_YYYYMMDD"), _("IDS_ST_BODY_YYYY_DD_MM_DOT")
365 setting_get_int_slp_key(INT_SLP_SETTING_DATE_FORMAT, &value, &err);
366 setting_retvm_if(SETTING_RETURN_FAIL == ret, NULL, "Failed to get vconf value"); /* file system exceptional handle */
367 return (char *)g_strdup(format_str[value]);
370 char *get_pa_week_format_str()
372 int ret = SETTING_RETURN_FAIL;
374 char *format_str[] = {
375 _("IDS_ST_BODY_SUNDAY"),
376 _("IDS_ST_BODY_MONDAY"),
380 setting_get_int_slp_key(INT_SLP_SETTING_WEEK_FORMAT, &value, &err);
381 setting_retvm_if(SETTING_RETURN_FAIL == ret, NULL, "Failed to get vconf value"); /* file system exceptional handle */
382 return (char *)g_strdup(format_str[value]);
385 char *get_pa_roaming_network_str()
387 int ret = SETTING_RETURN_FAIL;
389 char *roaming_str[] = {
390 _("IDS_ST_BODY_AUTO_DOWNLOAD"), _("IDS_COM_BODY_MANUAL"),
391 _("IDS_ST_BODY_ALWAYS_REJECT")
394 setting_get_int_slp_key(INT_SLP_SETTING_ROAMING_NETWORK, &value,
396 setting_retvm_if(SETTING_RETURN_FAIL == ret, NULL, "Failed to get vconf value"); /* file system exceptional handle */
397 return (char *)g_strdup(roaming_str[value]);
400 double get_widgets_factor()
402 return elm_scale_get();
405 char *setting_gettext(const char *s)
407 /* fisrt find in app pg */
413 char *p = dgettext(SETTING_PACKAGE, s);
415 if (!safeStrCmp(s, p)) { /* not found */
416 /* find in system pkg */
417 p = dgettext(SYSTEM_PACKAGE, s);
422 bool is_digital_str(const char *cstr)
424 if (cstr == NULL || cstr[0] == 0) {
428 int len = (int)(safeStrLen(cstr));
430 if (cstr[0] == '-' || cstr[0] == '+') {
438 if (cstr[pos] < '0' || cstr[pos] > '9') {
447 bool is_substr_ncase(const char *parentstr, const char *substr)
449 if (NULL == parentstr || '\0' == parentstr[0])
452 int word_len = safeStrLen(parentstr);
453 int search_len = safeStrLen(substr);
456 for (i = 0; i < word_len; i++) {
457 if (!strncasecmp(substr, &parentstr[i], search_len)) {
465 bool is_string_belong_to_array(const char *partern, const char **array,
469 for (; idx < array_num; idx++) {
470 if (!safeStrCmp(partern, array[idx])) {
477 bool isEmptyStr(const char *str)
479 if (NULL == str || str[0] == '\0') {
486 int safeStrCmp(const char *s1, const char *s2)
488 /* Check NULL value first */
489 if (isEmptyStr(s1) && isEmptyStr(s2)) {
491 } else if (isEmptyStr(s1)) {
493 } else if (isEmptyStr(s2)) {
494 return SETTING_RETURN_FAIL;
497 return strcmp(s1, s2);
500 int safeStrNCmp(const char *s1, const char *s2, int len)
503 /* Check NULL value first */
504 if (isEmptyStr(s1) && isEmptyStr(s2)) {
506 } else if (isEmptyStr(s1)) {
508 } else if (isEmptyStr(s2)) {
509 return SETTING_RETURN_FAIL;
516 return strncmp(s1, s2, len);
519 char *safeStrNCat(char *dst, const char *src, int maxlen)
521 if (dst && !isEmptyStr(src) && maxlen > 0) {
522 (void) g_strlcat(dst, src, maxlen + 1);
529 char *safeCopyStr(char *dst, const char *src, int maxlen)
539 int temp = (int)safeStrLen(src);
540 len = (temp <= maxlen) ? temp : maxlen;
541 memcpy(dst, src, len);
550 int safeStrLen(const char *str)
552 if (isEmptyStr(str)) {
553 SETTING_TRACE_DEBUG("string is empty");
561 * get the int value of substring before delim
563 bool get_substring_int(const char **ipStr, int *ipValue, char delim)
565 int iValue = *ipValue = 0;
566 const char *str = *ipStr;
568 if (str == NULL || str[0] == 0) { /* empty string */
572 bool bNegative = FALSE;
573 if ('-' == str[0]) { /* allow Negative number.. */
577 if (str[0] < '0' || str[0] > '9') { /* first elementy is not digital */
581 if (str[0] == '0') { /* first elementy is 0 */
582 if (str[1] == delim) {
597 /****first elementy is not 0*/
598 iValue = iValue * 10 + str[0] - '0';
600 if (((unsigned int)iValue & 0x80000000) != 0) { /* think about overloading */
604 if (str[0] == delim) {
621 if (str[0] < '0' || str[0] > '9') {
630 #define MaxIPAddressLength 15
633 * CHeck Whether a special string Is An IP String
635 * @param ipstr string representing IP numbers like "aaa.bbb.ccc.ddd"
637 * @return true if it's IP format string otherwise false
639 bool is_ip_string(const char *ipstr)
641 if (NULL == ipstr || 0 == ipstr[0])
643 int len = (int)safeStrLen(ipstr);
644 if (len > MaxIPAddressLength) {
648 if (ipstr[len - 1] == '.') {
655 if (!get_substring_int(&ipstr, &ip, '.') || ip > 255) {
656 SETTING_TRACE("ipstr:%s", ipstr);
659 SETTING_TRACE("ipstr:%s", ipstr);
668 int setting_invoke_reset_function(char *lib_name, service_h service, void *ext)
670 SETTING_TRACE("Enter %s with lib_name:%s", __FUNCTION__, lib_name);
671 int (*reset) (service_h pair, void *ptr);
672 int ret = OPERATE_LIB_SUCESS;
674 void *handle = dlopen(lib_name, RTLD_LAZY);
676 SETTING_TRACE_ERROR(" >>>>>>>>>>> %s", dlerror());
677 return LOAD_LIB_FAILED;
681 reset = dlsym(handle, "setting_plugin_reset");
682 if ((error = dlerror()) != NULL) {
683 SETTING_TRACE_ERROR(" >>>>>>>>>>> %s", error);
685 return UNDEFINED_LIB_SYMBOL;
689 ret = (*reset) (service, ext); /* CALL */
691 if (ret < 0) ret += UNDEFINED_LIB_SYMBOL;//from -2 on
697 int excuteCmd(char* exec_path, int option_num, ...)
699 char cmd[MAX_COMMON_BUFFER_LEN + 1] = {0, };
700 snprintf(cmd, MAX_COMMON_BUFFER_LEN,
705 va_start(args, option_num);
709 for (; argno < option_num; argno++) {
710 para = va_arg( args, char *);
711 SETTING_TRACE("Parameter #%d is: %s", argno, para);
714 g_strlcat(cmd, " ", MAX_COMMON_BUFFER_LEN + 1);
715 g_strlcat(cmd, para, MAX_COMMON_BUFFER_LEN + 1);
721 SETTING_TRACE("excute:%s", cmd);
726 void create_fontlink(const char *linkpath, const char *linkname,
727 const char *fontfilepath, const char *fontfilename)
729 char newpath[MAX_COMMON_BUFFER_LEN + 1];
730 char lcpath[MAX_COMMON_BUFFER_LEN + 1];
733 snprintf(newpath, MAX_COMMON_BUFFER_LEN, "%s/%s", linkpath, linkname);
735 snprintf(lcpath, MAX_COMMON_BUFFER_LEN, "%s/%s", fontfilepath, fontfilename);
737 SETTING_TRACE("newpath:%s", newpath);
738 SETTING_TRACE("lcpath:%s", lcpath);
741 ret = symlink(lcpath, newpath);
742 setting_retm_if(ret != 0, "fail to call symlink");
745 char* get_icon_path(const char *package)
747 ail_appinfo_h handle;
750 char *icon_path = IMG_DefaultIcon;//The default icon must exist.(it will be installed by Setting App)
755 if (ail_package_get_appinfo(package, &handle) != AIL_ERROR_OK) {
756 SETTING_TRACE_ERROR("Failed to ail_package_get_appinfo.");
761 if (result && ail_appinfo_get_str(handle, AIL_PROP_ICON_STR, &icon_path) != AIL_ERROR_OK) {
762 SETTING_TRACE_ERROR("Failed to ail_appinfo_get_str.");
766 if (result && access(icon_path, R_OK|F_OK ) !=0 ) {//The file cannot be accessed.
767 SETTING_TRACE_ERROR("The file[%s] cannot be accessed. To use defaut icon.", icon_path);
768 icon_path = IMG_DefaultIcon;
771 ret_str = strdup(icon_path);
772 if (destroy && ail_package_destroy_appinfo(handle) != AIL_ERROR_OK) {
773 SETTING_TRACE_ERROR("Failed to ail_package_destroy_appinfo.");
782 dictionary* dic = iniparser_load("/etc/info.ini");
783 char* str = (char *)iniparser_getstr(dic, "Version:Build");
789 if (!strncmp(str, "SLP", 3)) return 1;
794 iniparser_freedict(dic);
803 char szEmul[__LEN_STR_EMUL+1];
804 const char* szBinVer = NULL;
806 dictionary* dic = iniparser_load(BIN_INFO_FILE_PATH);
807 // when failed to get the info, let's regard the binary as an emulator one
811 szBinVer = (const char*)iniparser_getstr(dic, "Version:Build");
813 char* str = g_strdup(szBinVer);
820 sscanf(str, "%*s %4s", szEmul);
826 iniparser_freedict(dic);
830 if (!strncmp(szEmul, __STR_EMUL, __LEN_STR_EMUL)) {
836 char *model_str = NULL;
837 int ret = system_info_get_value_string(SYSTEM_INFO_KEY_MODEL, &model_str);
838 //SETTING_TRACE("model_str : %s", model_str);
839 if (ret != SYSTEM_INFO_ERROR_NONE) {
840 SETTING_TRACE_ERROR("fail to call system_info_get_value_string");
845 if (0 == safeStrCmp(KeyStr_Emulator, model_str)) {
855 int get_popup_btn_response_type(const char *btn_str)
857 SETTING_TRACE("btn_str:%s", btn_str);
858 POPUP_BTN_RESPONSE_TYPE rsp_type = POPUP_RESPONSE_INVALID;
859 retv_if(!btn_str, rsp_type);
860 if (0 == safeStrCmp(btn_str, _("IDS_COM_BODY_CLOSE"))
861 || 0 == safeStrCmp(btn_str, _("IDS_COM_SK_TRY"))//KeyStr_Try
862 || 0 == safeStrCmp(btn_str, _("IDS_COM_SK_OK"))
863 || 0 == safeStrCmp(btn_str, _("IDS_COM_SK_YES"))
864 || 0 == safeStrCmp(btn_str, _("IDS_ST_BODY_USE_MOTION"))
865 || 0 == safeStrCmp(btn_str, _("IDS_COM_POP_TRY_AGAIN"))
866 || 0 == safeStrCmp(btn_str, _("IDS_COM_SK_DELETE"))
867 || 0 == safeStrCmp(btn_str, _(KeyStr_Save)))
869 rsp_type = POPUP_RESPONSE_OK;
873 rsp_type = POPUP_RESPONSE_CANCEL;
878 #define SUPPORT_STATIC_LOAD 1
879 #if SUPPORT_STATIC_LOAD
880 static char *system_service_list[MAX_SYSTEM_SERVICE_NUM] = {NULL, };
882 void clear_system_service_data()
884 #if SUPPORT_STATIC_LOAD
886 for (idx = 0; idx < MAX_SYSTEM_SERVICE_NUM && system_service_list[idx]; idx++)
888 FREE(system_service_list[idx]);
893 bool is_system_service(const char *pkg_name)
895 //SLP native apps list,
896 if (0 == safeStrCmp(pkg_name, "com.samsung.menu-screen")
897 || 0 == safeStrCmp(pkg_name, "com.samsung.live-data-provider")
898 || 0 == safeStrCmp(pkg_name, "com.samsung.live-magazine")
899 || 0 == safeStrCmp(pkg_name, "com.samsung.pwlock")
900 || 0 == safeStrCmp(pkg_name, "com.samsung.quickpanel")
901 || 0 == safeStrCmp(pkg_name, "com.samsung.vtmain")
902 || 0 == safeStrCmp(pkg_name, "com.samsung.call")
903 || 0 == safeStrCmp(pkg_name, "usb_setting")
904 || 0 == safeStrCmp(pkg_name, "com.samsung.indicator")
905 || 0 == safeStrCmp(pkg_name, "com.samsung.cluster-home")
911 //OSP service app list,
913 #if SUPPORT_STATIC_LOAD
915 if (!system_service_list[0]) //just load the file
917 FILE *fp = fopen(SYSTEM_SERVICE_LIST_PATH, "r");
919 char result[MAX_PKG_NAME_LEN+1] = {0, };
920 while (fgets(result, MAX_PKG_NAME_LEN, fp))
922 result[strlen(result) - 1] = '\0';//offset 1
923 system_service_list[idx++] = strdup(result);
930 for (idx = 0; idx < MAX_SYSTEM_SERVICE_NUM && system_service_list[idx]; idx++)
932 if (0 == safeStrCmp(pkg_name, system_service_list[idx])) {
938 FILE *fp = fopen(SYSTEM_SERVICE_LIST_PATH, "r");
940 char result[MAX_PKG_NAME_LEN+1] = {0, };
941 while (fgets(result, MAX_PKG_NAME_LEN, fp))
943 result[strlen(result) - 1] = '\0';//offset 1
944 if (0 == safeStrCmp(pkg_name, result)) {
952 SETTING_TRACE("ret:%d", ret);
957 * should use g_free to free returned string
959 char *get_default_font(int language)
961 char *font_name = NULL;
965 case SETTING_LANG_KOREA:
966 font_name = g_strdup("SLPSansKorean");
968 case SETTING_LANG_CHINA:
969 /* output_font : SLPSansFallback*/
970 case SETTING_LANG_CANTONESE:
971 /* output_font : SLPSansFallback*/
972 case SETTING_LANG_TAIWAN:
973 font_name = g_strdup("SLPSansFallback");
975 case SETTING_LANG_JAPAN:
976 font_name = g_strdup("UDGothic");
978 case SETTING_LANG_AUTOMATIC:
979 /* output_font : HelveticaNeue*/
980 case SETTING_LANG_ENGLISH:
981 /* output_font : HelveticaNeue*/
982 case SETTING_LANG_GERMAN:
983 /* output_font : HelveticaNeue*/
984 case SETTING_LANG_DUTCH:
985 /* output_font : HelveticaNeue*/
986 case SETTING_LANG_SPAINISH:
987 /* output_font : HelveticaNeue*/
988 case SETTING_LANG_PORTUGUESE:
989 /* output_font : HelveticaNeue*/
990 case SETTING_LANG_GREEK:
991 /* output_font : HelveticaNeue*/
992 case SETTING_LANG_ITALIAN:
993 /* output_font : HelveticaNeue*/
994 case SETTING_LANG_FRENCH:
995 /* output_font : HelveticaNeue*/
996 case SETTING_LANG_TURKISH:
997 /* output_font : HelveticaNeue*/
998 case SETTING_LANG_RUSSIAN:
999 font_name = g_strdup("HelveticaNeue");
1002 font_name = g_strdup("HelveticaNeue");
1008 void *font_conf_doc_parse(char *doc_name, char *font_name)
1010 SETTING_TRACE_BEGIN;
1011 setting_retvm_if(doc_name == NULL, NULL, "Param data is NULL");
1012 setting_retvm_if(font_name == NULL, NULL, "Param data is NULL");
1013 xmlDocPtr doc = NULL;
1014 xmlNodePtr cur = NULL;
1015 xmlNodePtr cur2 = NULL;
1016 xmlNodePtr cur3 = NULL;
1017 xmlChar *key = NULL;
1019 doc = xmlParseFile(doc_name);
1020 setting_retvm_if(doc == NULL, NULL, "Document not parsed successfully.");
1022 cur = xmlDocGetRootElement(doc);
1025 SETTING_TRACE_DEBUG("empty document");
1031 if(xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1032 SETTING_TRACE_DEBUG("document of the wrong type, root node != fontconfig");
1038 cur = cur->xmlChildrenNode;
1042 if((!xmlStrcmp(cur->name, (const xmlChar *)"match")))
1044 cur2 = cur->xmlChildrenNode;
1047 if((!xmlStrcmp(cur2->name, (const xmlChar *)"edit")))
1049 cur3 = cur2->xmlChildrenNode;
1052 if((!xmlStrcmp(cur3->name, (const xmlChar *)"string")))
1054 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1055 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1056 SETTING_TRACE_DEBUG("after changed, string is: %s\n", key);
1076 * should use g_free to free return string
1078 char *cur_font_get()
1080 SETTING_TRACE_BEGIN;
1081 xmlDocPtr doc = NULL;
1082 xmlNodePtr cur = NULL;
1083 xmlNodePtr cur2 = NULL;
1084 xmlNodePtr cur3 = NULL;
1085 xmlChar *key = NULL;
1087 char *font_name = NULL;
1089 doc = xmlParseFile(SETTING_FONT_CONF_FILE);
1090 setting_retvm_if(doc == NULL, NULL, "Document not parsed successfully.");
1092 cur = xmlDocGetRootElement(doc);
1095 SETTING_TRACE_DEBUG("empty document");
1101 if(xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1102 SETTING_TRACE_DEBUG("document of the wrong type, root node != fontconfig");
1108 cur = cur->xmlChildrenNode;
1112 if((!xmlStrcmp(cur->name, (const xmlChar *)"match")))
1114 cur2 = cur->xmlChildrenNode;
1117 if((!xmlStrcmp(cur2->name, (const xmlChar *)"edit")))
1119 cur3 = cur2->xmlChildrenNode;
1122 if((!xmlStrcmp(cur3->name, (const xmlChar *)"string")))
1124 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1125 SETTING_TRACE_DEBUG("string is: %s", key);
1127 font_name = g_strdup((char *)key);
1148 static int __font_size_get()
1153 int ret = setting_get_int_slp_key(INT_SLP_SETTING_ACCESSIBILITY_FONT_SIZE, &value, &err);
1154 retvm_if(ret != 0, -1, "get vconf failed");
1157 case SYSTEM_SETTINGS_FONT_SIZE_SMALL:
1158 font_size = SMALL_FONT_DPI;
1160 case SYSTEM_SETTINGS_FONT_SIZE_NORMAL:
1161 font_size = MIDDLE_FONT_DPI;
1163 case SYSTEM_SETTINGS_FONT_SIZE_LARGE:
1164 font_size = LARGE_FONT_DPI;
1166 case SYSTEM_SETTINGS_FONT_SIZE_HUGE:
1167 font_size = HUGE_FONT_DPI;
1169 case SYSTEM_SETTINGS_FONT_SIZE_GIANT:
1170 font_size = GIANT_FONT_DPI;
1173 font_size = MIDDLE_FONT_DPI;
1179 void font_config_set(char *font_name)
1181 Eina_List *text_classes = NULL;
1182 Elm_Text_Class *etc = NULL;
1183 const Eina_List *l = NULL;
1184 Eina_List *fo_list = NULL;
1185 Elm_Font_Overlay *efo = NULL;
1186 int font_size = __font_size_get();
1189 text_classes = elm_config_text_classes_list_get();
1191 fo_list = (Eina_List *)elm_config_font_overlay_list_get();
1193 Eina_List *ll = NULL;
1194 Eina_List *l_next = NULL;
1196 Eina_Bool slp_medium_exist = EINA_FALSE;
1197 Eina_Bool slp_roman_exist = EINA_FALSE;
1198 Eina_Bool slp_bold_exist = EINA_FALSE;
1199 Eina_Bool slp_regular_exist = EINA_FALSE;
1201 EINA_LIST_FOREACH_SAFE(fo_list, ll, l_next, efo)
1203 if (!safeStrCmp(efo->text_class, "slp_medium")) {
1204 elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size);
1205 slp_medium_exist = EINA_TRUE;
1206 } else if (!safeStrCmp(efo->text_class, "slp_roman")) {
1207 elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size);
1208 slp_roman_exist = EINA_TRUE;
1209 } else if (!safeStrCmp(efo->text_class, "slp_bold")) {
1210 elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size);
1211 slp_bold_exist = EINA_TRUE;
1212 } else if (!safeStrCmp(efo->text_class, "slp_regular")) {
1213 elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size);
1214 slp_regular_exist = EINA_TRUE;
1218 /* if slp_XX do not exist, need to set them, font size is -100(100%) */
1219 if (slp_medium_exist == EINA_FALSE) {
1220 elm_config_font_overlay_set("slp_medium", (const char*)font_name, MIDDLE_FONT_DPI);
1222 if (slp_roman_exist == EINA_FALSE) {
1223 elm_config_font_overlay_set("slp_roman", (const char*)font_name, MIDDLE_FONT_DPI);
1225 if (slp_bold_exist == EINA_FALSE) {
1226 elm_config_font_overlay_set("slp_bold", (const char*)font_name, MIDDLE_FONT_DPI);
1228 if (slp_regular_exist == EINA_FALSE) {
1229 elm_config_font_overlay_set("slp_regular", (const char*)font_name, MIDDLE_FONT_DPI);
1232 EINA_LIST_FOREACH(text_classes, l, etc)
1237 EINA_LIST_FOREACH(fo_list, ll, efo)
1239 if (!safeStrCmp(etc->name, efo->text_class)) {
1243 elm_config_font_overlay_set(etc->name, (const char*)font_name, size);
1246 elm_config_font_overlay_apply();
1247 elm_config_all_flush();
1248 elm_config_engine_set("software_x11");
1250 elm_config_text_classes_list_free(text_classes);
1251 text_classes = NULL;
1254 vconf_set_str(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, font_name);
1257 void font_size_set()
1259 Eina_List *text_classes = NULL;
1260 Elm_Text_Class *etc = NULL;
1261 const Eina_List *l = NULL;
1262 int font_size = __font_size_get();
1263 char *font_name = cur_font_get();
1265 if (font_size == -1) {
1266 SETTING_TRACE_DEBUG("failed to call font_size_get");
1270 text_classes = elm_config_text_classes_list_get();
1272 EINA_LIST_FOREACH(text_classes, l, etc)
1274 elm_config_font_overlay_set(etc->name, font_name, font_size);
1277 elm_config_all_flush();
1278 elm_config_engine_set("software_x11");
1280 elm_config_text_classes_list_free(text_classes);
1281 text_classes = NULL;