Fix network UI issue and fix P120829-5114,P120829-5115
[apps/core/preloaded/settings.git] / setting-common / src / setting-common-general-func.c
old mode 100644 (file)
new mode 100755 (executable)
index 841c9cc..bae736c
@@ -1,20 +1,23 @@
 /*
-  * Copyright 2012  Samsung Electronics Co., Ltd
-  *
-  * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
-  *
-  * 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.
-  */
-
-
+ * setting
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
+ *
+ * Contact: MyoungJune Park <mj2004.park@samsung.com>
+ *
+ * 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 <ail.h>
 #include <setting-common-general-func.h>
 #include <setting-common-data-slp-setting.h>
 #include <glib.h>
 #include <iniparser.h>
 #include <dlfcn.h>
-#define SETTING_USB_DEFAULT_MODE       0
-#define DEFAULT_USB_BUF_SIZE   64
+#include <libxml/xmlmemory.h>
+#include <libxml/parser.h>
+#include <system_info.h>
+
+#include <system_settings.h>
 
 char *setting_file_basename(char *path)
 {
@@ -43,65 +49,26 @@ char *setting_file_basename(char *path)
 char *get_pa_usb_connect_mode_str()
 {
        int ret = SETTING_RETURN_FAIL;
-       int value, selMode;
-       char title_default_usb_subtitle[DEFAULT_USB_BUF_SIZE];
+       int value;
 
        ret = vconf_get_int(VCONFKEY_SETAPPL_USB_MODE_INT, &value);
        setting_retvm_if(SETTING_RETURN_FAIL == ret, NULL, "Failed to get vconf value");        /* file system exceptional handle */
 
        switch (value)
        {
-       case SETTING_USB_NONE_MODE:
-               ret = vconf_get_int(VCONFKEY_SETAPPL_USB_SEL_MODE_INT, &selMode);
-               setting_retvm_if(SETTING_RETURN_FAIL == ret, NULL, "Failed to get vconf value");
-               if (SETTING_USB_DEBUG_MODE == selMode)
-                       return (char*)g_strdup(_("IDS_ST_BODY_USB_DEBUGGING"));
-       case SETTING_USB_DEFAULT_MODE:
-               snprintf(title_default_usb_subtitle, DEFAULT_USB_BUF_SIZE, "USB %s",  _("IDS_COM_BODY_DEFAULT"));
-               return (char*)g_strdup(title_default_usb_subtitle);
        case SETTING_USB_DEBUG_MODE:
                return (char*)g_strdup(_("IDS_ST_BODY_USB_DEBUGGING"));
        default:
-               return NULL;
-       }
-}
-
-char *get_pa_theme_name_str()
-{
-       int ret = SETTING_RETURN_FAIL;
-       int err;
-       char value[SETTING_STR_SLP_LEN] = { 0, };
-       char *name;
-       char *ext;
-       ret = setting_get_string_slp_key(STR_SLP_SETTING_THEME_NAME, value, &err);
-       setting_retvm_if(SETTING_RETURN_FAIL == ret, NULL, "Failed to get vconf value");        /* file system exceptional handle */
-
-       name = strrchr(value, '/');
-       ext = strstr(value, ".edj");
-
-       if (!name)
-               name = value;
-       else
-               ++name;
-
-       if (!ext)
-               ext = value + safeStrLen(value);
-
-       if (0 == safeStrCmp("tizen-black-hd", name)) {
-               return (char *)g_strdup(_("IDS_ST_BODY_BLACK"));
-       } else if (0 == safeStrCmp("tizen-hd", name)) {
-               return (char *)g_strdup(_("IDS_ST_BODY_WHITE"));
-       } else {
-               return (char *)g_strndup(name, ext - name);
+               return (char*)g_strdup(_("IDS_COM_POP_DISCONNECTED"));
        }
 }
 
 char *get_brightness_mode_str()
 {
        int value, err;
-       setting_get_bool_slp_key(BOOL_SLP_SETTING_AUTOMATIC_BRIGHTNESS, &value,
+       setting_get_int_slp_key(INT_SLP_SETTING_AUTOMATIC_BRIGHTNESS, &value,
                                 &err);
-       if (value) {
+       if (value != SETTING_BRIGHTNESS_AUTOMATIC_OFF) {
                return setting_gettext("IDS_COM_BODY_AUTOMATIC");
        } else {
                return setting_gettext("IDS_COM_BODY_MANUAL");
@@ -110,23 +77,87 @@ char *get_brightness_mode_str()
 
 char *get_pa_backlight_time_str()
 {
-       int value = 30;
+       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; */
+               if(isEmulBin())
+                       value = 0;      /* keep agree with postin file */
+               else
+                       value = 30;
+               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 = 30;     /* keep agree with postin file */
+               /* value = 600; */
+               if(isEmulBin())
+                       value = 0;      /* keep agree with postin file */
+               else
+                       value = 30;
                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(isEmulBin())
+       {
+               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;
+       }
+       else
+       {
+               if (SETTING_RETURN_FAIL == ret || 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;
+       }
 
-       if (value == 60) {
+       setting_set_int_slp_key(INT_SLP_SETTING_LCD_TIMEOUT_NORMAL,
+                                       value, &err);
+       #endif
+#endif
+
+       if (value == 0) {
                snprintf(backlight_time_str, sizeof(backlight_time_str), "%s",
-                        _("1 minute"));
-       } else if (value >= 60) {
+                        _("IDS_ST_BODY_ALWAYS_ON"));
+       } else if (value == 60) {
+               snprintf(backlight_time_str, sizeof(backlight_time_str), "%s",
+                        _("IDS_COM_BODY_1_MINUTE"));
+       } else if (value > 60) {
                snprintf(backlight_time_str, sizeof(backlight_time_str),
                         "%d %s", value / 60, (char *)(_("IDS_COM_BODY_MINUTES_LC")));
        } else {
@@ -151,7 +182,7 @@ char *get_pa_powersaving_at_str()
                                        value, &err);
        }
 
-       snprintf(powersaving_at_str, MAX_DISPLAY_NAME_LEN_ON_UI, "%d%% %s",
+       snprintf(powersaving_at_str, MAX_DISPLAY_NAME_LEN_ON_UI, "At %d%% %s",
                 value, "battery power");
        return (char *)g_strdup(powersaving_at_str);
 }
@@ -192,26 +223,24 @@ char *get_pa_display_language_str()
        int ret = SETTING_RETURN_FAIL;
        int err;
        int index;
-       setting_lang_entry* table = setting_get_language_table();
+
+       Eina_List* list = setting_get_language_list();
+       Eina_List* elist = NULL;
+
        ret = setting_get_int_slp_key(INT_SLP_SETTING_LANG, &index, &err);
-       return (char *)g_strdup(table[index].title); // "auto"
-}
 
-char *setting_pa_main_get_language()
-{
-       setting_lang_entry* table = setting_get_language_table();
-       char* pa_path = vconf_get_str(VCONFKEY_LANGSET);
+       if (0 == index)
+               return g_strdup("Automatic");
 
-       int i;
-       for (i=0; i<SETTING_LANG_MAX; i++) {
-               if ( ! strcmp(table[i].locale, pa_path) )
-               {
-                       FREE(pa_path);
-                       return (char *)g_strdup(table[i].locale);
-               }
-       }
-       FREE(pa_path);
-       return (char *)g_strdup(table[0].locale);       // "auto"
+       setting_lang_entry* pnode;
+
+       char* title = NULL;
+    EINA_LIST_FOREACH( list, elist, pnode)
+    {
+               if (pnode->number == index)
+               title = g_strdup(pnode->title);
+    }
+       return title;
 }
 
 char *get_pa_Wi_Fi_on_off_str()
@@ -286,6 +315,24 @@ char *get_BT_on_off_str()
        }
 }
 
+char *get_NFC_on_off_str()
+{
+       int ret = SETTING_RETURN_FAIL;
+       int value = 0, err = 0;
+       ret = setting_get_bool_slp_key(BOOL_SLP_SETTING_NFC_STATUS, &value, &err);
+
+       if (SETTING_RETURN_FAIL == ret) {       /* file system exceptional handle, eg. The vconf file lost due to file system. */
+               SETTING_TRACE_DEBUG("fail to get nfc status from vconf");
+               value = VCONFKEY_NFC_STATE_OFF;
+       }
+
+       if (VCONFKEY_NFC_STATE_OFF == value) {
+               return setting_gettext("IDS_COM_BODY_OFF_M_STATUS");
+       } else {
+               return setting_gettext("IDS_COM_BODY_ON_M_STATUS");
+       }
+}
+
 char *get_pa_time_format_str()
 {
        int ret = SETTING_RETURN_FAIL;
@@ -327,11 +374,6 @@ char *get_pa_week_format_str()
        char *format_str[] = {
                _("IDS_ST_BODY_SUNDAY"),
                _("IDS_ST_BODY_MONDAY"),
-               _("IDS_ST_BODY_TUESDAY"),
-               _("IDS_ST_BODY_WEDNESDAY"),
-               _("IDS_ST_BODY_THURSDAY"),
-               _("IDS_ST_BODY_FRIDAY"),
-               _("IDS_ST_BODY_SATURDAY"),
        };
 
        ret =
@@ -360,50 +402,6 @@ double get_widgets_factor()
        return elm_scale_get();
 }
 
-static Theme_Type g_theme_type = Theme_Invalid;
-
-
-Theme_Type setting_get_theme()
-{
-       if (Theme_Invalid == g_theme_type) {
-               int ret = SETTING_RETURN_FAIL;
-               int err;
-               char value[SETTING_STR_SLP_LEN] = { 0, };
-               char *name;
-               char *ext;
-               ret =
-                   setting_get_string_slp_key(STR_SLP_SETTING_THEME_NAME,
-                                              value, &err);
-               setting_retvm_if(SETTING_RETURN_FAIL == ret, Theme_ERROR, "Failed to get vconf value"); /* file system exceptional handle */
-
-               name = strrchr(value, '/');
-               ext = strstr(value, ".edj");
-
-               if (!name)
-                       name = value;
-               else
-                       ++name;
-
-               if (!ext)
-                       ext = value + safeStrLen(value);
-
-               /* special theme process.. */
-               if (0 == safeStrCmp("tizen-black", name) || 0 == safeStrCmp("tizen-black-hd", name)) {
-                       g_theme_type = Theme_Tizen_Black;
-               } else if (0 == safeStrCmp("tizen", name) || 0 == safeStrCmp("tizen-hd", name)) {
-                       g_theme_type = Theme_Tizen;
-               } else if (0 == safeStrCmp("tizen-blue", name)) {
-                       g_theme_type = Theme_Tizen_Blue;
-               } else if (0 == safeStrCmp("grey-hd", name)) {
-                       g_theme_type = Theme_Tizen_Grey;
-               } else {
-                       g_theme_type = Theme_ERROR;
-               }
-       }
-
-       return g_theme_type;
-}
-
 char *setting_gettext(const char *s)
 {
        /* fisrt find in app pg */
@@ -476,15 +474,27 @@ bool is_string_belong_to_array(const char *partern, const char **array,
        return FALSE;
 }
 
+//NULL, "", "  ", "     " etc.. are all empty strings
 bool isEmptyStr(const char *str)
 {
-       if (NULL == str || str[0] == '\0') {
-               return TRUE;
-       } else {
-               return FALSE;
+       //if (NULL == str)
+       //      return TRUE;
+       while (str)
+       {
+               if (*str != '\0' && *str != ' ')
+               {
+                       return FALSE;
+               }
+               else if (*str == '\0')
+               {
+                       return TRUE;
+               }
+               str++;
        }
+       return TRUE;
 }
 
+
 int safeStrCmp(const char *s1, const char *s2)
 {
        /*  Check NULL value first */
@@ -667,10 +677,10 @@ bool is_ip_string(const char *ipstr)
        return TRUE;
 }
 
-int setting_invoke_reset_function(char *lib_name, bundle *data, void *ext)
+int setting_invoke_reset_function(char *lib_name, service_h service, void *ext)
 {
        SETTING_TRACE("Enter %s with lib_name:%s", __FUNCTION__, lib_name);
-       int (*reset) (bundle *pair, void *ptr);
+       int (*reset) (service_h pair, void *ptr);
        int ret = OPERATE_LIB_SUCESS;
 
        void *handle = dlopen(lib_name, RTLD_LAZY);
@@ -688,7 +698,7 @@ int setting_invoke_reset_function(char *lib_name, bundle *data, void *ext)
        }
 
        if (reset)
-               ret = (*reset) (data, ext);   /*  CALL */
+               ret = (*reset) (service, ext);   /*  CALL */
 
        if (ret < 0) ret += UNDEFINED_LIB_SYMBOL;//from -2 on
 
@@ -724,30 +734,6 @@ int excuteCmd(char* exec_path, int option_num, ...)
        return system(cmd);
 }
 
-void set_font_dpi(short size)
-{
-       char buf[MAX_COMMON_BUFFER_LEN +1];
-       const char *xrespath = "/opt/etc/X11/Xresources";
-       int ret = snprintf(buf, sizeof(buf), "/bin/echo \"Xft.dpi: %d\" > %s", size,
-                          xrespath);
-       ret_if(ret < 0);
-
-       ret = system(buf);//echo Xft.dpi: 48 > /opt/etc/X11/Xresources
-       if ( ret == -1) {
-               SETTING_TRACE_ERROR("Xft.dpi error \n");
-               abort();
-       }
-
-
-       snprintf(buf, MAX_COMMON_BUFFER_LEN, "/usr/bin/xrdb -nocpp -load %s", xrespath);
-       ret = system(buf);
-       if ( ret == -1) {
-               SETTING_TRACE_ERROR("xrdb -nocpp -load \n");
-               abort();
-       } else {
-               SETTING_TRACE("xrdb -nocpp -load - DONE \n");
-       }
-}
 
 void create_fontlink(const char *linkpath, const char *linkname,
                    const char *fontfilepath, const char *fontfilename)
@@ -764,14 +750,15 @@ void create_fontlink(const char *linkpath, const char *linkname,
        SETTING_TRACE("lcpath:%s", lcpath);
 
        remove(newpath);
-       symlink(lcpath, newpath);
+       ret = symlink(lcpath, newpath);
+       setting_retm_if(ret != 0, "fail to call symlink");
 }
 
 char* get_icon_path(const char *package)
 {
-    ail_appinfo_h handle;
+       ail_appinfo_h handle;
 
-    char* ret_str;
+       char* ret_str;
        char *icon_path = IMG_DefaultIcon;//The default icon must exist.(it will be installed by Setting App)
 
        bool result = TRUE;
@@ -781,32 +768,55 @@ char* get_icon_path(const char *package)
                SETTING_TRACE_ERROR("Failed to ail_package_get_appinfo.");
                result = FALSE;
                destroy = FALSE;
-    }
+       }
 
        if (result && ail_appinfo_get_str(handle, AIL_PROP_ICON_STR, &icon_path) != AIL_ERROR_OK) {
                SETTING_TRACE_ERROR("Failed to ail_appinfo_get_str.");
                result = FALSE;
-    }
+       }
 
        if (result && access(icon_path, R_OK|F_OK ) !=0 ) {//The file cannot be accessed.
                SETTING_TRACE_ERROR("The file[%s] cannot be accessed. To use defaut icon.", icon_path);
                icon_path = IMG_DefaultIcon;
-    }
+       }
 
-       ret_str = strdup(icon_path);
+       ret_str = strdup(icon_path);
        if (destroy && ail_package_destroy_appinfo(handle) != AIL_ERROR_OK) {
                SETTING_TRACE_ERROR("Failed to ail_package_destroy_appinfo.");
        }
        return ret_str;
 }
 
+// SLP : 1
+// not SLP : 0
+int is_slp_binary()
+{
+       dictionary* dic = iniparser_load("/etc/info.ini");
+       char* str = (char *)iniparser_getstr(dic, "Version:Build");
+       char* pos = str;
+       if (str) {
+               while(*pos++){
+                       if('_' == *pos) {
+                               *pos = '\0';
+                               if (!strncmp(str, "SLP", 3)) return 1;
+                       }
+               }
+       }
+       if (dic) {
+               iniparser_freedict(dic);
+               dic = NULL;
+       }
+       return 0;
+}
+
 bool isEmulBin()
 {
+#if DISABLED_CODE
        char szEmul[__LEN_STR_EMUL+1];
        const char* szBinVer = NULL;
 
        dictionary* dic = iniparser_load(BIN_INFO_FILE_PATH);
-// when failed to get the info, let's regard the binary as an emulator one
+       // when failed to get the info, let's regard the binary as an emulator one
        if (!dic)
                return TRUE;
 
@@ -834,6 +844,24 @@ bool isEmulBin()
        } else {
                return FALSE;
        }
+#else
+       char *model_str = NULL;
+       int ret = system_info_get_value_string(SYSTEM_INFO_KEY_MODEL, &model_str);
+       //SETTING_TRACE("model_str : %s", model_str);
+       if (ret != SYSTEM_INFO_ERROR_NONE) {
+               SETTING_TRACE_ERROR("fail to call system_info_get_value_string");
+               FREE(model_str);
+               return FALSE;
+       }
+
+       if (0 == safeStrCmp(KeyStr_Emulator, model_str)) {
+               FREE(model_str);
+               return TRUE;
+       } else {
+               FREE(model_str);
+               return FALSE;
+       }
+#endif
 }
 
 int get_popup_btn_response_type(const char *btn_str)
@@ -842,20 +870,426 @@ int get_popup_btn_response_type(const char *btn_str)
        POPUP_BTN_RESPONSE_TYPE rsp_type = POPUP_RESPONSE_INVALID;
        retv_if(!btn_str, rsp_type);
        if (0 == safeStrCmp(btn_str, _("IDS_COM_BODY_CLOSE"))
-           || 0 == safeStrCmp(btn_str, _("Try"))//KeyStr_Try
+           || 0 == safeStrCmp(btn_str, _("IDS_COM_SK_TRY"))//KeyStr_Try
            || 0 == safeStrCmp(btn_str, _("IDS_COM_SK_OK"))
            || 0 == safeStrCmp(btn_str, _("IDS_COM_SK_YES"))
            || 0 == safeStrCmp(btn_str, _("IDS_ST_BODY_USE_MOTION"))
            || 0 == safeStrCmp(btn_str, _("IDS_COM_POP_TRY_AGAIN"))
-           || 0 == safeStrCmp(btn_str, _("IDS_COM_SK_DELETE")))
+           || 0 == safeStrCmp(btn_str, _("IDS_COM_SK_DELETE"))
+           || 0 == safeStrCmp(btn_str, _(KeyStr_Save)))
        {
                rsp_type = POPUP_RESPONSE_OK;
        }
-       else //for others, 
+       else //for others,
        {
                rsp_type = POPUP_RESPONSE_CANCEL;
        }
        return rsp_type;
 }
 
+#define SUPPORT_STATIC_LOAD 1
+#if SUPPORT_STATIC_LOAD
+static char *system_service_list[MAX_SYSTEM_SERVICE_NUM] = {NULL, };
+#endif
+void clear_system_service_data()
+{
+       #if SUPPORT_STATIC_LOAD
+       int idx;
+       for (idx = 0; idx < MAX_SYSTEM_SERVICE_NUM && system_service_list[idx]; idx++)
+       {
+               FREE(system_service_list[idx]);
+       }
+       #endif
+}
+
+bool is_system_service(const char *pkg_name)
+{
+       //SLP native apps list,
+       if (0 == safeStrCmp(pkg_name, "com.samsung.menu-screen")
+           || 0 == safeStrCmp(pkg_name, "com.samsung.live-data-provider")
+           || 0 == safeStrCmp(pkg_name, "com.samsung.live-magazine")
+           || 0 == safeStrCmp(pkg_name, "com.samsung.pwlock")
+           || 0 == safeStrCmp(pkg_name, "com.samsung.quickpanel")
+           || 0 == safeStrCmp(pkg_name, "com.samsung.vtmain")
+           || 0 == safeStrCmp(pkg_name, "com.samsung.call")
+           || 0 == safeStrCmp(pkg_name, "usb_setting")
+           || 0 == safeStrCmp(pkg_name, "com.samsung.indicator")
+           || 0 == safeStrCmp(pkg_name, "com.samsung.cluster-home")
+          )
+       {
+               return TRUE;
+       }
+
+       //OSP service app list,
+       bool ret = FALSE;
+#if SUPPORT_STATIC_LOAD
+       int idx = 0;
+       if (!system_service_list[0]) //just load the file
+       {
+               FILE *fp = fopen(SYSTEM_SERVICE_LIST_PATH, "r");
+               if (fp) {
+                       char result[MAX_PKG_NAME_LEN+1] = {0, };
+                       while (fgets(result, MAX_PKG_NAME_LEN, fp))
+                       {
+                               result[strlen(result) - 1] = '\0';//offset 1
+                               system_service_list[idx++] = strdup(result);
+                       }
+                       fclose(fp);
+               }
+
+       }
+
+       for (idx = 0; idx < MAX_SYSTEM_SERVICE_NUM && system_service_list[idx]; idx++)
+       {
+               if (0 == safeStrCmp(pkg_name, system_service_list[idx])) {
+                       ret = TRUE;
+                       break;
+               }
+       }
+#else
+       FILE *fp = fopen(SYSTEM_SERVICE_LIST_PATH, "r");
+       if (fp) {
+               char result[MAX_PKG_NAME_LEN+1] = {0, };
+               while (fgets(result, MAX_PKG_NAME_LEN, fp))
+               {
+                       result[strlen(result) - 1] = '\0';//offset 1
+                       if (0 == safeStrCmp(pkg_name, result)) {
+                               ret = TRUE;
+                               break;
+                       }
+               }
+               fclose(fp);
+       }
+#endif
+       SETTING_TRACE("ret:%d", ret);
+       return ret;
+}
+
+/**
+  * should use g_free to free returned string
+  */
+char *get_default_font(int language)
+{
+       char *font_name = NULL;
+
+       switch(language)
+       {
+       case SETTING_LANG_KOREA:
+               font_name = g_strdup("SLPSansKorean");
+               break;
+       case SETTING_LANG_CHINA:
+               /* output_font : SLPSansFallback*/
+       case SETTING_LANG_CANTONESE:
+               /* output_font : SLPSansFallback*/
+       case SETTING_LANG_TAIWAN:
+               font_name = g_strdup("SLPSansFallback");
+               break;
+       case SETTING_LANG_JAPAN:
+               font_name = g_strdup("UDGothic");
+               break;
+       case SETTING_LANG_AUTOMATIC:
+               /* output_font : HelveticaNeue*/
+       case SETTING_LANG_ENGLISH:
+               /* output_font : HelveticaNeue*/
+       case SETTING_LANG_GERMAN:
+               /* output_font : HelveticaNeue*/
+       case SETTING_LANG_DUTCH:
+               /* output_font : HelveticaNeue*/
+       case SETTING_LANG_SPAINISH:
+               /* output_font : HelveticaNeue*/
+       case SETTING_LANG_PORTUGUESE:
+               /* output_font : HelveticaNeue*/
+       case SETTING_LANG_GREEK:
+               /* output_font : HelveticaNeue*/
+       case SETTING_LANG_ITALIAN:
+               /* output_font : HelveticaNeue*/
+       case SETTING_LANG_FRENCH:
+               /* output_font : HelveticaNeue*/
+       case SETTING_LANG_TURKISH:
+               /* output_font : HelveticaNeue*/
+       case SETTING_LANG_RUSSIAN:
+               font_name = g_strdup("HelveticaNeue");
+               break;
+       default:
+               font_name = g_strdup("HelveticaNeue");
+               break;
+       }
+       return font_name;
+}
+
+void *font_conf_doc_parse(char *doc_name, char *font_name)
+{
+       SETTING_TRACE_BEGIN;
+       setting_retvm_if(doc_name == NULL, NULL, "Param data is NULL");
+       setting_retvm_if(font_name == NULL, NULL, "Param data is NULL");
+       xmlDocPtr doc = NULL;
+       xmlNodePtr cur = NULL;
+       xmlNodePtr cur2 = NULL;
+       xmlNodePtr cur3 = NULL;
+       xmlChar *key = NULL;
+
+       doc = xmlParseFile(doc_name);
+       setting_retvm_if(doc == NULL, NULL, "Document not parsed successfully.");
+
+       cur = xmlDocGetRootElement(doc);
+
+       if (cur == NULL) {
+               SETTING_TRACE_DEBUG("empty document");
+               xmlFreeDoc(doc);
+               doc = NULL;
+               return NULL;
+       }
+
+       if(xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
+               SETTING_TRACE_DEBUG("document of the wrong type, root node != fontconfig");
+               xmlFreeDoc(doc);
+               doc = NULL;
+               return NULL;
+       }
+
+       cur = cur->xmlChildrenNode;
+
+       while(cur != NULL)
+       {
+               if((!xmlStrcmp(cur->name, (const xmlChar *)"match")))
+               {
+                       cur2 = cur->xmlChildrenNode;
+                       while(cur2 != NULL)
+                       {
+                               if((!xmlStrcmp(cur2->name, (const xmlChar *)"edit")))
+                               {
+                                       cur3 = cur2->xmlChildrenNode;
+                                       while(cur3 != NULL)
+                                       {
+                                               if((!xmlStrcmp(cur3->name, (const xmlChar *)"string")))
+                                               {
+                                                       xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
+                                                       key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
+                                                       SETTING_TRACE_DEBUG("after changed, string is: %s\n", key);
+                                                       xmlFree(key);
+                                                       key = NULL;
+                                                       return doc;
+                                               }
+                                               cur3 = cur3->next;
+                                       }
+                               }
+                               cur2 = cur2->next;
+                       }
+               }
+               cur = cur->next;
+       }
+
+       xmlFreeDoc(doc);
+       doc = NULL;
+       return NULL;
+}
+
+/**
+ * should use g_free to free return string
+ */
+char *cur_font_get()
+{
+       SETTING_TRACE_BEGIN;
+       xmlDocPtr doc = NULL;
+       xmlNodePtr cur = NULL;
+       xmlNodePtr cur2 = NULL;
+       xmlNodePtr cur3 = NULL;
+       xmlChar *key = NULL;
 
+       char *font_name = NULL;
+
+       doc = xmlParseFile(SETTING_FONT_CONF_FILE);
+       setting_retvm_if(doc == NULL, NULL, "Document not parsed successfully.");
+
+       cur = xmlDocGetRootElement(doc);
+
+       if(cur == NULL) {
+               SETTING_TRACE_DEBUG("empty document");
+               xmlFreeDoc(doc);
+               doc = NULL;
+               return NULL;
+       }
+
+       if(xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
+               SETTING_TRACE_DEBUG("document of the wrong type, root node != fontconfig");
+               xmlFreeDoc(doc);
+               doc = NULL;
+               return NULL;
+       }
+
+       cur = cur->xmlChildrenNode;
+
+       while(cur != NULL)
+       {
+               if((!xmlStrcmp(cur->name, (const xmlChar *)"match")))
+               {
+                       cur2 = cur->xmlChildrenNode;
+                       while(cur2 != NULL)
+                       {
+                               if((!xmlStrcmp(cur2->name, (const xmlChar *)"edit")))
+                               {
+                                       cur3 = cur2->xmlChildrenNode;
+                                       while(cur3 != NULL)
+                                       {
+                                               if((!xmlStrcmp(cur3->name, (const xmlChar *)"string")))
+                                               {
+                                                       key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
+                                                       SETTING_TRACE_DEBUG("string is: %s", key);
+
+                                                       font_name = g_strdup((char *)key);
+                                                       xmlFree(key);
+                                                       key = NULL;
+                                                       xmlFreeDoc(doc);
+                                                       doc = NULL;
+                                                       return font_name;
+                                               }
+                                               cur3 = cur3->next;
+                                       }
+                               }
+                               cur2 = cur2->next;
+                       }
+               }
+               cur = cur->next;
+       }
+
+       xmlFreeDoc(doc);
+       doc = NULL;
+       return NULL;
+}
+
+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;
+}
+
+void font_config_set(char *font_name)
+{
+       Eina_List *text_classes = NULL;
+       Elm_Text_Class *etc = NULL;
+       const Eina_List *l = NULL;
+       Eina_List *fo_list = NULL;
+       Elm_Font_Overlay *efo = NULL;
+       int font_size = __font_size_get();
+       int size = 0;
+
+       text_classes = elm_config_text_classes_list_get();
+
+       fo_list = (Eina_List *)elm_config_font_overlay_list_get();
+
+       Eina_List *ll = NULL;
+       Eina_List *l_next = NULL;
+
+       Eina_Bool slp_medium_exist = EINA_FALSE;
+       Eina_Bool slp_roman_exist = EINA_FALSE;
+       Eina_Bool slp_bold_exist = EINA_FALSE;
+       Eina_Bool slp_regular_exist = EINA_FALSE;
+
+       EINA_LIST_FOREACH_SAFE(fo_list, ll, l_next, efo)
+       {
+               if (!safeStrCmp(efo->text_class, "slp_medium")) {
+                       elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size);
+                       slp_medium_exist = EINA_TRUE;
+               } else if (!safeStrCmp(efo->text_class, "slp_roman")) {
+                       elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size);
+                       slp_roman_exist = EINA_TRUE;
+               } else if (!safeStrCmp(efo->text_class, "slp_bold")) {
+                       elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size);
+                       slp_bold_exist = EINA_TRUE;
+               } else if (!safeStrCmp(efo->text_class, "slp_regular")) {
+                       elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size);
+                       slp_regular_exist = EINA_TRUE;
+               }
+       }
+
+       /* if slp_XX do not exist, need to set them, font size is -100(100%) */
+       if (slp_medium_exist == EINA_FALSE) {
+               elm_config_font_overlay_set("slp_medium", (const char*)font_name,  MIDDLE_FONT_DPI);
+       }
+       if (slp_roman_exist == EINA_FALSE) {
+               elm_config_font_overlay_set("slp_roman", (const char*)font_name,  MIDDLE_FONT_DPI);
+       }
+       if (slp_bold_exist == EINA_FALSE) {
+               elm_config_font_overlay_set("slp_bold", (const char*)font_name,  MIDDLE_FONT_DPI);
+       }
+       if (slp_regular_exist == EINA_FALSE) {
+               elm_config_font_overlay_set("slp_regular", (const char*)font_name,  MIDDLE_FONT_DPI);
+       }
+
+       EINA_LIST_FOREACH(text_classes, l, etc)
+       {
+               ll = NULL;
+
+               size = font_size;
+               EINA_LIST_FOREACH(fo_list, ll, efo)
+               {
+                       if (!safeStrCmp(etc->name, efo->text_class)) {
+                               size = efo->size;
+                       }
+               }
+               elm_config_font_overlay_set(etc->name, (const char*)font_name, size);
+       }
+
+       elm_config_font_overlay_apply();
+       elm_config_all_flush();
+       elm_config_engine_set("software_x11");
+       elm_config_save();
+       elm_config_text_classes_list_free(text_classes);
+       text_classes = NULL;
+
+       // vconf update
+       vconf_set_str(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, font_name);
+}
+
+void font_size_set()
+{
+       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;
+       }
+
+       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_engine_set("software_x11");
+       elm_config_save();
+       elm_config_text_classes_list_free(text_classes);
+       text_classes = NULL;
+       G_FREE(font_name);
+}